Update exercise code from 1.11.x

pull/3768/head
Julio Montoya 4 years ago
parent 6f257f35fc
commit e0f7b0e979
  1. 3
      public/main/exercise/exercise.class.php
  2. 3
      public/main/inc/lib/exercise.lib.php
  3. 7
      public/main/inc/lib/javascript/record_audio/record_audio.js
  4. 298
      public/main/inc/lib/javascript/rtc/RecordRTC.js
  5. 61
      public/main/template/default/exercise/oral_expression.html.twig

@ -4383,13 +4383,14 @@ class Exercise
$result = Database::query($sql);
$data = Database::fetch_array($result);
$choice = '';
$questionScore = 0;
if ($data) {
$choice = $data['answer'];
$questionScore = $data['marks'];
}
$choice = str_replace('\r\n', '', $choice);
$choice = stripslashes($choice);
$questionScore = $data['marks'];
if (-1 == $questionScore) {
$totalScore += 0;

@ -174,7 +174,7 @@ class ExerciseLib
$select_items[0]['letter'] = '--';
$select_items[0]['answer'] = '';
foreach ($answer_matching as $id => $value) {
$select_items[$i]['id'] = $value['id_auto'];
$select_items[$i]['id'] = $value['iid'];
$select_items[$i]['letter'] = $cpt1[$id];
$select_items[$i]['answer'] = $value['answer'];
$i++;
@ -1116,6 +1116,7 @@ class ExerciseLib
$s .= '<td width="10%" valign="top" align="center">
<div class="select-matching">
<select
class="form-control"
id="choice_id_'.$current_item.'_'.$lines_count.'"
name="choice['.$questionId.']['.$numAnswer.']">';

@ -1,6 +1,5 @@
/* For licensing terms, see /license.txt */
window.RecordAudio = (function () {
var isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
function startTimer() {
$("#timer").show();
@ -124,8 +123,10 @@ window.RecordAudio = (function () {
stopTimer();
startTimer();
recordRTC = RecordRTC(stream, {
recorderType: isSafari ? RecordRTC.StereoAudioRecorder : RecordRTC.MediaStreamRecorder,
type: 'audio'
recorderType: RecordRTC.StereoAudioRecorder,
type: 'audio',
mimeType: 'audio/wav',
numberOfAudioChannels: 2
});
recordRTC.startRecording();

File diff suppressed because one or more lines are too long

@ -7,6 +7,19 @@
</div>
<div class="col-sm-12">
<div class="form-group text-center">
<div id="timer" style="display: none">
<h2>
<div class="label label-danger">
<span id="hour">00</span>
<span class="divider">:</span>
<span id="minute">00</span>
<span class="divider">:</span>
<span id="second">00</span>
</div>
</h2>
<br />
</div>
<button class="btn btn-primary" type="button" id="btn-start-record-{{ question_id }}">
<span class="fa fa-circle fa-fw" aria-hidden="true"></span> {{ 'StartRecordingAudio'|get_lang }}
</button>
@ -20,8 +33,8 @@
<span class="fa fa-square fa-fw" aria-hidden="true"></span> {{ 'StopRecordingAudio'|get_lang }}
</button>
<button class="btn btn-success hidden" type="button" id="btn-save-record-{{ question_id }}"
data-loadingtext="{{ 'Uploading'|get_lang }}"
disabled>
data-loadingtext="{{ 'Uploading'|get_lang }}"
disabled>
<span class="fa fa-send fa-fw" aria-hidden="true"></span> {{ 'SaveRecordedAudio'|get_lang }}
</button>
<button id="hide_description_{{ question_id }}" type="button" class="btn btn-default advanced_options" data-toggle="button" aria-pressed="false" autocomplete="off">
@ -45,26 +58,26 @@
</div>
<script>
$(function () {
RecordAudio.init({
blockId: '#record-audio-recordrtc-{{ question_id }}',
btnStartId: '#btn-start-record-{{ question_id }}',
btnPauseId: '#btn-pause-record-{{ question_id }}',
btnPlayId: '#btn-play-record-{{ question_id }}',
btnStopId: '#btn-stop-record-{{ question_id }}',
plyrPreviewId: '#record-preview-{{ question_id }}',
directory: '{{ directory }}',
type: 'document'
}, {
blockId: '#record-audio-wami-{{ question_id }}',
containerId: 'record-audio-wami-container-{{ question_id }}',
directory: '{{ directory }}',
userId: {{ user_id }},
type: 'document'
}, '{{ file_name }}');
$(function () {
RecordAudio.init({
blockId: '#record-audio-recordrtc-{{ question_id }}',
btnStartId: '#btn-start-record-{{ question_id }}',
btnPauseId: '#btn-pause-record-{{ question_id }}',
btnPlayId: '#btn-play-record-{{ question_id }}',
btnStopId: '#btn-stop-record-{{ question_id }}',
plyrPreviewId: '#record-preview-{{ question_id }}',
directory: '{{ directory }}',
type: 'document'
}, {
blockId: '#record-audio-wami-{{ question_id }}',
containerId: 'record-audio-wami-container-{{ question_id }}',
directory: '{{ directory }}',
userId: {{ user_id }},
type: 'document'
}, '{{ file_name }}');
if (0 === $('#hide_description_{{ question_id }}_options').length) {
$('#hide_description_{{ question_id }}').remove();
}
});
</script>
if (0 === $('#hide_description_{{ question_id }}_options').length) {
$('#hide_description_{{ question_id }}').remove();
}
});
</script>
Loading…
Cancel
Save