reading_comprehension.html.twig 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <div id="question-{{ id }}" class="question-reading-comprehension-container">
  2. <div class="question-reading-comprehension-overlay"></div>
  3. {% if exercise_type == 1 %} {# all in one page #}
  4. <button type="button" class="btn btn-default btn-lg" id="question-{{ id }}-start">
  5. {{ 'StartTimeWindow'|get_lang }}
  6. <span class="fa fa-play" aria-hidden="true"></span>
  7. </button>
  8. {% endif %}
  9. <div id="question-{{ id }}-text" class="center-block question-reading-comprehension-text" onselectstart="return false">
  10. {{ text }}
  11. </div>
  12. </div>
  13. <style>
  14. .question-reading-comprehension-container {
  15. position: relative;
  16. }
  17. .question-reading-comprehension-container button {
  18. left: 50%;
  19. margin-left: -60px;
  20. margin-top: -23px;
  21. position: absolute;
  22. top: 50%;
  23. width: 120px;
  24. }
  25. .question-reading-comprehension-container .question-reading-comprehension-overlay {
  26. bottom: 0;
  27. left: 0;
  28. position: absolute;
  29. right: 0;
  30. top: 0;
  31. }
  32. .question-reading-comprehension-text {
  33. text-align: justify;
  34. -webkit-touch-callout: none;
  35. -webkit-user-select: none;
  36. -khtml-user-select: none;
  37. -moz-user-select: none;
  38. -ms-user-select: none;
  39. user-select: none;
  40. }
  41. .question-reading-comprehension-text .text-highlight {
  42. color: transparent;
  43. -webkit-text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
  44. -khtml-text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
  45. -moz-text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
  46. -ms-text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
  47. text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
  48. -webkit-transition: color .5s linear, text-shadow .5s linear;
  49. -khtml-transition: color .5s linear, text-shadow .5s linear;
  50. -moz-transition: color .5s linear, text-shadow .5s linear;
  51. -ms-transition: color .5s linear, text-shadow .5s linear;
  52. transition: color .5s linear, text-shadow .5s linear;
  53. }
  54. .question-reading-comprehension-text .text-highlight.active {
  55. color: #000;
  56. -webkit-text-shadow: none;
  57. -khtml-text-shadow: none;
  58. -moz-text-shadow: none;
  59. -ms-text-shadow: none;
  60. text-shadow: none;
  61. -webkit-transition: color .5s linear, text-shadow .5s linear;
  62. -khtml-transition: color .5s linear, text-shadow .5s linear;
  63. -moz-transition: color .5s linear, text-shadow .5s linear;
  64. -ms-transition: color .5s linear, text-shadow .5s linear;
  65. transition: color .5s linear, text-shadow .5s linear;
  66. }
  67. .question-reading-comprehension-text .text-highlight.border {
  68. color: #bbb;
  69. -webkit-text-shadow: none;
  70. -khtml-text-shadow: none;
  71. -moz-text-shadow: none;
  72. -ms-text-shadow: none;
  73. text-shadow: none;
  74. -webkit-transition: color .5s linear, text-shadow .5s linear;
  75. -khtml-transition: color .5s linear, text-shadow .5s linear;
  76. -moz-transition: color .5s linear, text-shadow .5s linear;
  77. -ms-transition: color .5s linear, text-shadow .5s linear;
  78. transition: color .5s linear, text-shadow .5s linear;
  79. }
  80. .question-reading-comprehension-text br {
  81. margin-bottom: 1em;
  82. }
  83. .radio.hide-reading-answers, .question_title.hide-reading-answers {
  84. display: none;
  85. }
  86. </style>
  87. <script>
  88. $(function () {
  89. var index = 0,
  90. $questionTexts = $('#question-{{ id }}-text .text-highlight'),
  91. $btnFinish = $('#question_div_{{ id }} .form-actions button.question-validate-btn'),
  92. total = $questionTexts.length,
  93. timeOuId = null;
  94. function updateView()
  95. {
  96. $questionTexts.removeClass('active border');
  97. if (index == total - 1) {
  98. $('#question_div_{{ id }} .radio, #question_div_{{ id }} .question_title').removeClass('hide-reading-answers');
  99. $btnFinish.show();
  100. }
  101. if (index >= total) {
  102. window.clearInterval(timeOuId);
  103. return;
  104. }
  105. var prev = index > 0 ? $('#question-{{ id }}-text .text-highlight').get(index - 1) : null,
  106. current = $questionTexts.get(index),
  107. next = index < total ? $('#question-{{ id }}-text .text-highlight').get(index + 1) : null;
  108. $(current).addClass('active');
  109. if (prev) {
  110. $(prev).addClass('border');
  111. }
  112. if (next) {
  113. $(next).addClass('border');
  114. }
  115. index++;
  116. }
  117. function startQuestion() {
  118. updateView();
  119. timeOuId = window.setInterval(updateView, {{ refresh_time }} * 1000);
  120. }
  121. $btnFinish.hide();
  122. {% if exercise_type == 1 %}
  123. $('#question-{{ id }}-start').on('click', function (e) {
  124. e.preventDefault();
  125. startQuestion();
  126. $(this).remove();
  127. });
  128. {% else %}
  129. startQuestion();
  130. {% endif %}
  131. });
  132. </script>