Minor - format code

pull/2487/head
jmontoyaa 9 years ago
parent 24d31284f9
commit f8a668d41b
  1. 4
      main/exercise/exercise_submit.php
  2. 19
      main/exercise/oral_expression.class.php
  3. 4
      main/inc/ajax/exercise.ajax.php
  4. 2
      main/inc/ajax/record_audio_rtc.ajax.php
  5. 1
      main/inc/lib/events.lib.php
  6. 224
      main/template/default/exercise/oral_expression.tpl

@ -532,7 +532,9 @@ if ($formSent && isset($_POST)) {
$choice = $exerciseResult[$questionId];
if (isset($exe_id)) {
// Manage the question and answer attempts
if ($debug) { error_log('8.3. manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice,1)); }
if ($debug) {
error_log('8.3. manage_answer exe_id: '.$exe_id.' - $questionId: '.$questionId.' Choice'.print_r($choice,1));
}
$objExercise->manage_answer(
$exe_id,
$questionId,

@ -138,7 +138,7 @@ class OralExpression extends Question
mkdir($this->storePath . $this->sessionId . '/' . $this->exerciseId . '/' . $this->id . '/' . $this->userId);
}
return $this->storePath .= implode(
$this->storePath .= implode(
'/',
array(
$this->sessionId,
@ -147,6 +147,7 @@ class OralExpression extends Question
$this->userId
)
) . '/';
return $this->storePath;
}
/**
@ -222,7 +223,13 @@ class OralExpression extends Question
]);
if (!$result) {
return null;
return '';
}
$fileName = $result->getFilename();
if (empty($fileName)) {
return '';
}
return $this->storePath . $result->getFilename();
@ -237,16 +244,18 @@ class OralExpression extends Question
return "{$this->storePath}$fileName.$extension.$extension";
}
return null;
return '';
}
/**
* Get the URL for the audio file. Return null if the file doesn't exists
* @param bool $loadFromDatabase
*
* @return string
*/
public function getFileUrl()
public function getFileUrl($loadFromDatabase = false)
{
$filePath = $this->getAbsoluteFilePath();
$filePath = $this->getAbsoluteFilePath($loadFromDatabase);
if (empty($filePath)) {
return null;

@ -1,7 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
use \ChamiloSession as Session;
use ChamiloSession as Session;
/**
* Responses to AJAX calls
@ -326,7 +326,7 @@ switch ($action) {
exit;
}
$_SESSION['exe_id'] = $exe_id;
Session::write('exe_id', $exe_id);
// Getting the total weight if the request is simple
$total_weight = 0;

@ -15,7 +15,7 @@ if (!isset($_FILES['audio_blob'], $_REQUEST['audio_dir'])) {
api_not_allowed();
}
$file = $_FILES["audio_blob"];
$file = $_FILES['audio_blob'];
$audioDir = Security::remove_XSS($_REQUEST['audio_dir']);
$userId = api_get_user_id();

@ -498,7 +498,6 @@ class Event
);
// Check if attempt exists.
$sql = "SELECT exe_id FROM $TBL_TRACK_ATTEMPT
WHERE
c_id = $course_id AND

@ -30,133 +30,133 @@
</div>
<script>
$(document).on('ready', function () {
function useRecordRTC() {
$('#record-audio-recordrtc').show();
var mediaConstraints = {audio: true},
recordRTC = null,
btnStart = $('#btn-start-record'),
btnStop = $('#btn-stop-record'),
btnSave = $('#btn-save-record'),
tagAudio = $('#record-preview');
btnStart.on('click', function () {
navigator.getUserMedia = navigator.getUserMedia ||
navigator.mozGetUserMedia ||
navigator.webkitGetUserMedia;
if (navigator.getUserMedia) {
navigator.getUserMedia(mediaConstraints, successCallback, errorCallback);
} else if (navigator.mediaDevices.getUserMedia) {
navigator.mediaDevices.getUserMedia(mediaConstraints)
.then(successCallback).error(errorCallback);
}
function successCallback(stream) {
recordRTC = RecordRTC(stream, {
numberOfAudioChannels: 1,
type: 'audio'
});
recordRTC.startRecording();
btnSave.prop('disabled', true);
btnStop.prop('disabled', false);
btnStart.prop('disabled', true);
tagAudio.removeClass('show').addClass('hidden');
}
function errorCallback(error) {
alert(error.message);
}
});
btnStop.on('click', function () {
if (!recordRTC) {
return;
}
recordRTC.stopRecording(function (audioURL) {
btnStart.prop('disabled', false);
btnStop.prop('disabled', true);
btnSave.prop('disabled', false);
$(document).on('ready', function () {
function useRecordRTC() {
$('#record-audio-recordrtc').show();
var mediaConstraints = {audio: true},
recordRTC = null,
btnStart = $('#btn-start-record'),
btnStop = $('#btn-stop-record'),
btnSave = $('#btn-save-record'),
tagAudio = $('#record-preview');
btnStart.on('click', function () {
navigator.getUserMedia = navigator.getUserMedia ||
navigator.mozGetUserMedia ||
navigator.webkitGetUserMedia;
if (navigator.getUserMedia) {
navigator.getUserMedia(mediaConstraints, successCallback, errorCallback);
} else if (navigator.mediaDevices.getUserMedia) {
navigator.mediaDevices.getUserMedia(mediaConstraints)
.then(successCallback).error(errorCallback);
}
tagAudio
.removeClass('hidden')
.addClass('show')
.prop('src', audioURL);
function successCallback(stream) {
recordRTC = RecordRTC(stream, {
numberOfAudioChannels: 1,
type: 'audio'
});
});
recordRTC.startRecording();
btnSave.on('click', function () {
if (!recordRTC) {
return;
}
btnSave.prop('disabled', true);
btnStop.prop('disabled', false);
btnStart.prop('disabled', true);
tagAudio.removeClass('show').addClass('hidden');
}
var recordedBlob = recordRTC.getBlob();
function errorCallback(error) {
alert(error.message);
}
});
if (!recordedBlob) {
return;
}
btnStop.on('click', function () {
if (!recordRTC) {
return;
}
var fileName = '{{ file_name }}',
fileExtension = '.' + recordedBlob.type.split('/')[1];
var formData = new FormData();
formData.append('audio_blob', recordedBlob, fileName + fileExtension);
formData.append('audio_dir', '{{ directory }}');
$.ajax({
url: '{{ _p.web_ajax }}record_audio_rtc.ajax.php',
data: formData,
processData: false,
contentType: false,
type: 'POST'
}).then(function () {
btnSave.prop('disabled', true);
btnStop.prop('disabled', true);
btnStart.prop('disabled', false);
});
recordRTC.stopRecording(function (audioURL) {
btnStart.prop('disabled', false);
btnStop.prop('disabled', true);
btnSave.prop('disabled', false);
tagAudio
.removeClass('hidden')
.addClass('show')
.prop('src', audioURL);
});
}
});
function useWami() {
$('#record-audio-wami').show();
// Download button
btnSave.on('click', function () {
if (!recordRTC) {
return;
}
var recordedBlob = recordRTC.getBlob();
if (!recordedBlob) {
return;
}
Wami.setup({
id: "record-audio-wami-container",
onReady: setupGUI,
swfUrl: '{{ _p.web_lib }}wami-recorder/Wami.swf'
var fileName = '{{ file_name }}',
fileExtension = '.' + recordedBlob.type.split('/')[1];
var formData = new FormData();
formData.append('audio_blob', recordedBlob, fileName + fileExtension);
formData.append('audio_dir', '{{ directory }}');
$.ajax({
url: '{{ _p.web_ajax }}record_audio_rtc.ajax.php',
data: formData,
processData: false,
contentType: false,
type: 'POST'
}).then(function () {
btnSave.prop('disabled', true);
btnStop.prop('disabled', true);
btnStart.prop('disabled', false);
});
});
}
function useWami() {
$('#record-audio-wami').show();
Wami.setup({
id: "record-audio-wami-container",
onReady: setupGUI,
swfUrl: '{{ _p.web_lib }}wami-recorder/Wami.swf'
});
function setupGUI() {
var gui = new Wami.GUI({
id: 'record-audio-wami-container',
singleButton: true,
recordUrl: '{{ _p.web_ajax }}record_audio_wami.ajax.php?' + $.param({
waminame: '{{ file_name }}.wav',
wamidir: '{{ directory }}',
wamiuserid: {{ user_id }}
}),
buttonUrl: '{{ _p.web_lib }}wami-recorder/buttons.png',
buttonNoUrl: '{{ _p.web_img }}blank.gif'
}
);
function setupGUI() {
var gui = new Wami.GUI({
id: 'record-audio-wami-container',
singleButton: true,
recordUrl: '{{ _p.web_ajax }}record_audio_wami.ajax.php?' + $.param({
waminame: '{{ file_name }}.wav',
wamidir: '{{ directory }}',
wamiuserid: {{ user_id }}
}),
buttonUrl: '{{ _p.web_lib }}wami-recorder/buttons.png',
buttonNoUrl: '{{ _p.web_img }}blank.gif'
}
);
gui.setPlayEnabled(false);
}
gui.setPlayEnabled(false);
}
}
$('#record-audio-recordrtc, #record-audio-wami').hide();
$('#record-audio-recordrtc, #record-audio-wami').hide();
var webRTCIsEnabled = navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.getUserMedia ||
navigator.mediaDevices.getUserMedia;
var webRTCIsEnabled = navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.getUserMedia ||
navigator.mediaDevices.getUserMedia;
if (webRTCIsEnabled) {
useRecordRTC();
if (webRTCIsEnabled) {
useRecordRTC();
return;
}
return;
}
useWami();
});
useWami();
});
</script>

Loading…
Cancel
Save