Add allow_teacher_comment_audio configuration setting - refs BT#12615

pull/2487/head
Angel Fernando Quiroz Campos 8 years ago
parent 80151243e0
commit 3327cd4912
  1. 26
      main/exercise/exercise_show.php
  2. 18
      main/inc/ajax/record_audio_wami.ajax.php
  3. 62
      main/inc/lib/exercise.lib.php
  4. 2
      main/install/configuration.dist.php

@ -139,6 +139,9 @@ if (isset($_SESSION['gradebook'])) {
$gradebook = Security::remove_XSS($_SESSION['gradebook']);
}
$allowRecordAudio = api_get_setting('enable_record_audio') === 'true';
$allowTeacherComentAudio = api_get_configuration_value('allow_teacher_comment_audio') === true;
if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[] = array(
'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
@ -159,6 +162,14 @@ $htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PA
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>';
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'annotation/js/annotation.js"></script>';
if ($allowRecordAudio && $allowTeacherComentAudio) {
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'rtc/RecordRTC.js"></script>';
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'wami-recorder/recorder.js"></script>';
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'wami-recorder/gui.js"></script>';
$htmlHeadXtra[] = '<script type="text/javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'swfobject/swfobject.js"></script>';
$htmlHeadXtra[] = api_get_js('record_audio/record_audio.js');
}
if ($origin != 'learnpath') {
Display::display_header('');
} else {
@ -713,10 +724,13 @@ foreach ($questionList as $questionId) {
$comnt = trim(Event::get_comments($id, $questionId));
if (!empty($comnt)) {
echo ExerciseLib::getFeedbackText($comnt);
echo ExerciseLib::getOralFeedbackAudio($id, $questionId, $student_id);
}
echo '</div>';
echo '<div id="'.$name.'" class="hidden">';
echo '<div id="'.$name.'" class="row hidden">';
echo '<div class="col-sm-'.($allowTeacherComentAudio ? 7 : 12).'">';
$arrid[] = $questionId;
$feedback_form = new FormValidator('frmcomments'.$questionId);
$renderer = &$feedback_form->defaultRenderer();
@ -742,6 +756,15 @@ foreach ($questionList as $questionId) {
}
$feedback_form->setDefaults($default);
$feedback_form->display();
echo '</div>';
if ($allowRecordAudio && $allowTeacherComentAudio) {
echo '<div class="col-sm-5">';
echo ExerciseLib::getOralFeedbackForm($id, $questionId, $student_id);
echo '</div>';
}
echo '</div>';
} else {
@ -750,6 +773,7 @@ foreach ($questionList as $questionId) {
if (!empty($comnt)) {
echo '<b>'.get_lang('Feedback').'</b>';
echo ExerciseLib::getFeedbackText($comnt);
echo ExerciseLib::getOralFeedbackAudio($id, $questionId, $student_id);
}
}

@ -23,7 +23,7 @@ if (isset($params['waminame']) && isset($params['wamidir']) && isset($params['wa
die();
}
if ($wamiuserid != api_get_user_id() || api_get_user_id() == 0 || $wamiuserid == 0) {
if (empty($wamiuserid)) {
api_not_allowed();
die();
}
@ -58,14 +58,14 @@ if (!is_dir($saveDir)) {
//avoid duplicates
$waminame_to_save = $waminame;
$waminame_noex = basename($waminame, ".wav");
if (file_exists($saveDir.'/'.$waminame_noex.'.'.$ext)) {
$i = 1;
while (file_exists($saveDir.'/'.$waminame_noex.'_'.$i.'.'.$ext)) {
$i++;
}
$waminame_to_save = $waminame_noex.'_'.$i.'.'.$ext;
}
//$waminame_noex = basename($waminame, ".wav");
//if (file_exists($saveDir.'/'.$waminame_noex.'.'.$ext)) {
// $i = 1;
// while (file_exists($saveDir.'/'.$waminame_noex.'_'.$i.'.'.$ext)) {
// $i++;
// }
// $waminame_to_save = $waminame_noex.'_'.$i.'.'.$ext;
//}
$documentPath = $saveDir.'/'.$waminame_to_save;

@ -3859,10 +3859,19 @@ HOTSPOT;
$comnt = null;
if ($show_results) {
$comnt = Event::get_comments($exe_id, $questionId);
if (!empty($comnt)) {
$teacherAudio = ExerciseLib::getOralFeedbackAudio($exe_id, $questionId, api_get_user_id());;
if (!empty($comnt) || $teacherAudio) {
echo '<b>'.get_lang('Feedback').'</b>';
}
if (!empty($comnt)) {
echo ExerciseLib::getFeedbackText($comnt);
}
if ($teacherAudio) {
echo $teacherAudio;
}
}
if ($show_results) {
@ -4154,4 +4163,55 @@ HOTSPOT;
//return '<div id="question_feedback">'.$message.'</div>';
return Display::return_message($message, 'warning', false);
}
/**
* Get the recorder audio component for save a teacher audio feedback
* @param int $attemptId
* @param int $questionId
* @param int $userId
* @return string
*/
public static function getOralFeedbackForm($attemptId, $questionId, $userId)
{
$view = new Template('', false, false, false, false, false, false);
$view->assign('user_id', $userId);
$view->assign('question_id', $questionId);
$view->assign('directory', "/../exercises/teacher_audio/$attemptId/");
$view->assign('file_name', "{$questionId}_{$userId}");
$template = $view->get_template('exercise/oral_expression.tpl');
return $view->fetch($template);
}
/**
* Get the audio componen for a teacher audio feedback
* @param int $attemptId
* @param int $questionId
* @param int $userId
* @return string
*/
public static function getOralFeedbackAudio($attemptId, $questionId, $userId)
{
$courseInfo = api_get_course_info();
$sysCourseDir = api_get_path(SYS_COURSE_PATH).$courseInfo['path'];
$webCourseDir = api_get_path(WEB_COURSE_PATH).$courseInfo['path'];
$fileName = "{$questionId}_{$userId}";
$filePath = null;
if (file_exists("$sysCourseDir/exercises/teacher_audio/$attemptId/$fileName.ogg")) {
$filePath = "$webCourseDir/exercises/teacher_audio/$attemptId/$fileName.ogg";
} elseif (file_exists("$sysCourseDir/exercises/teacher_audio/$attemptId/$fileName.wav.wav")) {
$filePath = "$webCourseDir/exercises/teacher_audio/$attemptId/$fileName.wav.wav";
}
if (!$filePath) {
return '';
}
return Display::tag(
'audio',
null,
['src' => $filePath]
);
}
}

@ -508,6 +508,8 @@ $_configuration['send_all_emails_to'] = [
// Add option in exercise to show or hide the "previous" button.
//ALTER TABLE c_quiz ADD show_previous_button TINYINT(1) DEFAULT 1;
//$_configuration['allow_quiz_show_previous_button_setting'] = false;
// Allow to teachers review exercises question with audio notes
//$_configuration["allow_teacher_comment_audio"] = false;
// ------
// Hide search form in session list
//$_configuration['hide_search_form_in_session_list'] = false;

Loading…
Cancel
Save