Fix PHP warning, update from 1.11.x

pull/3768/head
Julio Montoya 5 years ago
parent 5e8c5a689d
commit c2d2043613
  1. 2
      public/main/calendar/agenda.php
  2. 3
      public/main/calendar/agenda_list.php
  3. 70
      public/main/exercise/exercise_question_reminder.php
  4. 3
      public/main/exercise/exercise_reminder.php
  5. 23
      public/main/exercise/exercise_report.php
  6. 28
      public/main/exercise/exercise_result.php
  7. 2
      public/main/exercise/exercise_show.php
  8. 146
      public/main/exercise/exercise_submit.php
  9. 12
      public/main/forum/viewthread.php
  10. 56
      public/main/inc/lib/exercise.lib.php
  11. 9
      public/main/inc/lib/extra_field.lib.php
  12. 2
      public/main/tracking/courseLog.php
  13. 2
      src/CourseBundle/Entity/CForumPost.php

@ -20,7 +20,7 @@ $this_section = SECTION_COURSES;
$url = null;
if (empty($action)) {
if (!empty($course_info)) {
$url = api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=course'.'&'.api_get_cidreq();
$url = api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=course&'.api_get_cidreq();
} else {
$url = api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?';
}

@ -12,7 +12,8 @@ $logInfo = [
];
Event::registerLog($logInfo);
$type = $_REQUEST['type'] ?? null;
$typeList = ['personal', 'course', 'admin', 'platform'];
$type = isset($_REQUEST['type']) && in_array($_REQUEST['type'], $typeList, true) ? $_REQUEST['type'] : null;
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type='.Security::remove_XSS($type),

@ -38,10 +38,11 @@ if (empty($objExercise) || empty($questionCategoryId) || empty($exeId) || empty(
api_not_allowed(true);
}
$categoryId = $categoryObj->id;
$categoryId = (int) $categoryObj->id;
$params = "exe_id=$exeId&exerciseId=$exerciseId&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id&".api_get_cidreq();
$url = api_get_path(WEB_CODE_PATH).'exercise/exercise_submit.php?'.$params;
$validateUrl = api_get_self().'?'.$params.'&category_id='.$categoryId.'&validate=1';
$validateUrl = api_get_path(WEB_CODE_PATH).'exercise/exercise_question_reminder.php?'.
$params.'&category_id='.$categoryId.'&validate=1';
$time_control = false;
$clock_expired_time = ExerciseLib::get_session_time_control_key(
@ -103,11 +104,11 @@ if (!$hideHeaderAndFooter) {
}
// I'm in a preview mode as course admin. Display the action menu.
if (api_is_course_admin() && !$hideHeaderAndFooter) {
if (!$hideHeaderAndFooter && api_is_course_admin()) {
echo '<div class="actions">';
echo '<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->id.'">'.
echo '<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->iId.'">'.
Display::return_icon('back.png', get_lang('GoBackToQuestionList'), [], 32).'</a>';
echo '<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->id.'">'.
echo '<a href="exercise_admin.php?'.api_get_cidreq().'&modifyExercise=yes&exerciseId='.$objExercise->iId.'">'.
Display::return_icon('edit.png', get_lang('ModifyExercise'), [], 32).'</a>';
echo '</div>';
}
@ -115,12 +116,14 @@ echo Display::page_header($categoryObj->name);
echo '<p>'.Security::remove_XSS($categoryObj->description).'</p>';
echo '<p>'.get_lang('BlockCategoryExplanation').'</p>';
if ($objExercise->review_answers) {
$categoryList = Session::read('categoryList');
$disableAllQuestions = '';
$questionList = [];
$categoryList = Session::read('categoryList');
if (isset($categoryList[$categoryId])) {
$questionList = $categoryList[$categoryId];
}
if ($objExercise->review_answers) {
$disableAllQuestions = 'changeOptionStatus(0);';
echo $objExercise->getReminderTable($questionList, $trackInfo);
}
@ -130,19 +133,27 @@ if ($time_control) {
echo Display::div('', ['id' => 'message']);
$previousQuestion = $currentQuestion - 1;
$nextQuestion = $currentQuestion + 1;
if (!empty($questionList)) {
$firstQuestionOfCategory = end($questionList);
$dataTracking = explode(',', $trackInfo['data_tracking']);
$index = 0;
foreach ($dataTracking as $index => $question) {
if ($firstQuestionOfCategory == $question) {
break;
}
}
$nextQuestion = $index + 1;
}
echo '<script>
var lp_data = $.param({
"learnpath_id": '.$learnpath_id.',
"learnpath_item_id" : '.$learnpath_item_id.',
"learnpath_item_view_id": '.$learnpath_item_view_id.'
});
function goBack() {
window.location = "'.$url.'&num='.$previousQuestion.'&" + lp_data;
window.location = "'.$url.'&num='.$previousQuestion.'";
}
function continueExercise() {
window.location = "'.$validateUrl.'&num='.$currentQuestion.'&" + lp_data;
'.$disableAllQuestions.'
window.location = "'.$validateUrl.'&num='.$nextQuestion.'";
}
function final_submit() {
@ -164,17 +175,40 @@ if (!in_array($categoryId, $blockedCategories)) {
['onclick' => 'goBack();', 'class' => 'btn btn-default']
);
}
if ($objExercise->review_answers) {
$exerciseActions .= Display::url(
get_lang('ReviewQuestions'),
'javascript://',
['onclick' => 'reviewQuestions();', 'class' => 'btn btn-primary']
);
$exerciseActions .= '&nbsp;'.Display::url(
get_lang('ContinueTest'),
get_lang('SelectAll'),
'javascript://',
['onclick' => 'continueExercise();', 'class' => 'btn btn-primary']
['onclick' => 'selectAll();', 'class' => 'btn btn-default']
);
/*
$exerciseActions .= '&nbsp;'.Display::url(
get_lang('UnSelectAll'),
'javascript://',
['onclick' => 'changeOptionStatus(0);', 'class' => 'btn btn-default']
);
}
end($categoryList);
// This is the last category
if (key($categoryList) === $categoryId) {
$exerciseActions .= '&nbsp;'.Display::url(
get_lang('EndTest'),
'javascript://',
['onclick' => 'final_submit();', 'class' => 'btn btn-warning']
);*/
);
} else {
$exerciseActions .= '&nbsp;'.Display::url(
get_lang('ContinueTest'),
'javascript://',
['onclick' => 'continueExercise();', 'class' => 'btn btn-primary']
);
}
echo Display::div('', ['class' => 'clear']);
echo Display::div($exerciseActions, ['class' => 'form-actions']);

@ -85,7 +85,6 @@ $interbreadcrumb[] = ['url' => 'exercise.php?'.api_get_cidreq(), 'name' => get_l
$hideHeaderAndFooter = in_array($origin, ['learnpath', 'embeddable']);
if (!$hideHeaderAndFooter) {
//so we are not in learnpath tool
Display::display_header($nameTools, get_lang('Test'));
} else {
Display::display_reduced_header();
@ -94,7 +93,7 @@ if (!$hideHeaderAndFooter) {
/* DISPLAY AND MAIN PROCESS */
// I'm in a preview mode as course admin. Display the action menu.
if (api_is_course_admin() && !$hideHeaderAndFooter) {
if (!$hideHeaderAndFooter && api_is_course_admin()) {
echo '<div class="actions">';
echo '<a href="admin.php?'.api_get_cidreq().'&exerciseId='.$objExercise->getId().'">'.
Display::return_icon('back.png', get_lang('Go back to the questions list'), [], 32).'</a>';

@ -287,6 +287,8 @@ if (isset($_REQUEST['comments']) &&
$notifications = api_get_configuration_value('exercise_finished_notification_settings');
if ($notifications) {
$oldResultDisabled = $objExerciseTmp->results_disabled;
$objExerciseTmp->results_disabled = RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS;
ob_start();
$stats = ExerciseLib::displayQuestionListByAttempt(
$objExerciseTmp,
@ -297,7 +299,25 @@ if (isset($_REQUEST['comments']) &&
api_get_configuration_value('quiz_results_answers_report'),
false
);
$objExerciseTmp->results_disabled = $oldResultDisabled;
ob_end_clean();
// Show all for teachers.
$oldResultDisabled = $objExerciseTmp->results_disabled;
$objExerciseTmp->results_disabled = RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS;
$objExerciseTmp->forceShowExpectedChoiceColumn = true;
ob_start();
$statsTeacher = ExerciseLib::displayQuestionListByAttempt(
$objExerciseTmp,
$track_exercise_info['exe_id'],
false,
false,
false,
api_get_configuration_value('quiz_results_answers_report'),
false
);
ob_end_clean();
$objExerciseTmp->forceShowExpectedChoiceColumn = false;
$objExerciseTmp->results_disabled = $oldResultDisabled;
$attemptCount = Event::getAttemptPosition(
$track_exercise_info['exe_id'],
@ -314,7 +334,8 @@ if (isset($_REQUEST['comments']) &&
$track_exercise_info,
api_get_course_info(),
$attemptCount,
$stats
$stats,
$statsTeacher
);
}
// Updating LP score here

@ -83,6 +83,7 @@ if (!empty($objExercise->getResultAccess())) {
$showHeader = false;
$showFooter = false;
$showLearnPath = true;
$pageActions = '';
$pageTop = '';
$pageBottom = '';
@ -92,6 +93,7 @@ $courseInfo = api_get_course_info();
if (!in_array($origin, ['learnpath', 'embeddable', 'mobileapp'])) {
// So we are not in learnpath tool
$showHeader = true;
$showLearnPath = false;
}
// I'm in a preview mode as course admin. Display the action menu.
@ -215,7 +217,6 @@ $saveResults = true;
$feedbackType = $objExercise->getFeedbackType();
ob_start();
// Display and save questions
$stats = ExerciseLib::displayQuestionListByAttempt(
$objExercise,
$exeId,
@ -228,7 +229,25 @@ $stats = ExerciseLib::displayQuestionListByAttempt(
$pageContent .= ob_get_contents();
ob_end_clean();
//Unset session for clock time
$oldResultDisabled = $objExercise->results_disabled;
$objExercise->results_disabled = RESULT_DISABLE_SHOW_SCORE_AND_EXPECTED_ANSWERS;
$objExercise->forceShowExpectedChoiceColumn = true;
ob_start();
$statsTeacher = ExerciseLib::displayQuestionListByAttempt(
$objExercise,
$exeId,
$saveResults,
$remainingMessage,
$allowSignature,
api_get_configuration_value('quiz_results_answers_report'),
false
);
ob_end_clean();
$objExercise->results_disabled = $oldResultDisabled;
$objExercise->forceShowExpectedChoiceColumn = false;
// Save here LP status
if (!empty($learnpath_id) && $saveResults) {
// Save attempt in lp
Exercise::saveExerciseInLp($learnpath_item_id, $exeId);
@ -240,7 +259,8 @@ ExerciseLib::sendNotification(
$exercise_stat_info,
$courseInfo,
$attempt_count++,
$stats
$stats,
$statsTeacher
);
/*$hookQuizEnd = HookQuizEnd::create();
@ -295,7 +315,7 @@ if (!in_array($origin, ['learnpath', 'embeddable', 'mobileapp'])) {
$showFooter = false;
}
$template = new Template($nameTools, $showHeader, $showFooter);
$template = new Template($nameTools, $showHeader, $showFooter, $showLearnPath);
$template->assign('page_top', $pageTop);
$template->assign('page_content', $pageContent);
$template->assign('page_bottom', $pageBottom);

@ -28,7 +28,6 @@ if (empty($id)) {
// Getting results from the exe_id. This variable also contain all the information about the exercise
$track_exercise_info = ExerciseLib::get_exercise_track_exercise_info($id);
//No track info
if (empty($track_exercise_info)) {
api_not_allowed($printHeaders);
}
@ -1124,7 +1123,6 @@ if ('learnpath' != $origin) {
}
}
// Destroying the session
Session::erase('questionList');
unset($questionList);

@ -110,7 +110,7 @@ if (isset($zoomOptions['options']) && !in_array($origin, ['embeddable', 'mobilea
$(document).contextmenu(function() {
return false;
})
});
});
</script>';
@ -180,7 +180,7 @@ if (empty($exerciseInSession) || (!empty($exerciseInSession) && ($exerciseInSess
} else {
Session::write('firstTime', false);
}
//2. Checking if $objExercise is set
// 2. Checking if $objExercise is set.
/** @var |Exercise $objExercise */
if (!isset($objExercise) && isset($exerciseInSession)) {
if ($debug) {
@ -191,7 +191,7 @@ if (!isset($objExercise) && isset($exerciseInSession)) {
$exerciseInSession = Session::read('objExercise');
//3. $objExercise is not set, then return to the exercise list
// 3. $objExercise is not set, then return to the exercise list.
if (!is_object($objExercise)) {
header('Location: exercise.php?'.api_get_cidreq());
exit;
@ -204,7 +204,7 @@ if ('true' === api_get_plugin_setting('positioning', 'tool_enable')) {
}
}
// if the user has submitted the form
// if the user has submitted the form.
$exercise_title = $objExercise->selectTitle();
$exercise_sound = $objExercise->selectSound();
@ -450,7 +450,7 @@ if (empty($exercise_stat_info)) {
if (!empty($resolvedQuestions) &&
!empty($exercise_stat_info['data_tracking'])
) {
$last = current(end($resolvedQuestions));
/*$last = current(end($resolvedQuestions));
$attemptQuestionList = explode(',', $exercise_stat_info['data_tracking']);
$count = 1;
foreach ($attemptQuestionList as $question) {
@ -460,10 +460,25 @@ if (empty($exercise_stat_info)) {
$count++;
}
$current_question = $count;
*/
// Get current question based in data_tracking question list, instead of track_e_attempt order BT#17789.
$resolvedQuestionsQuestionIds = array_keys($resolvedQuestions);
$count = 0;
$attemptQuestionList = explode(',', $exercise_stat_info['data_tracking']);
//var_dump($attemptQuestionList, $resolvedQuestionsQuestionIds);
foreach ($attemptQuestionList as $index => $question) {
if (in_array($question, $resolvedQuestionsQuestionIds)) {
$count = $index;
continue;
}
}
$current_question = $count;
//var_dump($current_question, $index);exit;
}
}
}
Session::write('exe_id', $exe_id);
$checkAnswersUrl = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?a=check_answers&exe_id='.$exe_id.'&'.api_get_cidreq();
$saveDurationUrl = api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?a=update_duration&exe_id='.$exe_id.'&'.api_get_cidreq();
$questionListInSession = Session::read('questionList');
$selectionType = $objExercise->getQuestionSelectionType();
@ -523,7 +538,7 @@ if (!empty($exercise_stat_info['questions_to_check'])) {
$params = "exe_id=$exe_id&exerciseId=$exerciseId&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id&".api_get_cidreq().'&reminder='.$reminder;
if (2 == $reminder && empty($myRemindList)) {
if (2 === $reminder && empty($myRemindList)) {
if ($debug) {
error_log('6.2 calling the exercise_reminder.php ');
}
@ -546,7 +561,7 @@ if ($time_control) {
}
if (!isset($_SESSION['expired_time'][$current_expired_time_key])) {
//Timer - Get expired_time for a student
// Timer - Get expired_time for a student.
if (!empty($exercise_stat_info)) {
$expired_time_of_this_attempt = $exercise_stat_info['expired_time_control'];
if ($debug) {
@ -570,7 +585,7 @@ if ($time_control) {
$last_attempt_date = api_get_utc_datetime(api_strtotime($last_attempt_date, 'UTC') + $diff);
}
//New expired time - it is due to the possible closure of session
// New expired time - it is due to the possible closure of session.
$new_expired_time_in_seconds = api_strtotime($expired_time_of_this_attempt, 'UTC') - api_strtotime($last_attempt_date, 'UTC');
$expected_time = $current_timestamp + $new_expired_time_in_seconds;
$clock_expired_time = api_get_utc_datetime($expected_time);
@ -609,7 +624,8 @@ $time_left = api_strtotime($clock_expired_time, 'UTC') - time();
* The time control feature is enable here - this feature is enable for a jquery plugin called epiclock
* for more details of how it works see this link : http://eric.garside.name/docs.html?p=epiclock
*/
if ($time_control) { //Sends the exercise form when the expired time is finished
if ($time_control) {
//Sends the exercise form when the expired time is finished.
$htmlHeadXtra[] = $objExercise->showTimeControlJS($time_left);
}
@ -672,42 +688,55 @@ if ($allowBlockCategory &&
$count++;
}
//var_dump($questionCheck);exit;
// Use reminder list to get the current question.
if (2 === $reminder && !empty($myRemindList)) {
/*if (2 === $reminder && !empty($myRemindList)) {
$remindQuestionId = current($myRemindList);
$questionCheck = Question::read($remindQuestionId);
}
}*/
$categoryId = 0;
if (null !== $questionCheck) {
$categoryId = $questionCheck->category;
}
if ($objExercise->review_answers && isset($_GET['category_id'])) {
$categoryId = $_GET['category_id'] ?? 0;
}
//var_dump($categoryId, $categoryList);
if (!empty($categoryId)) {
$categoryInfo = $categoryList[$categoryId];
$count = 1;
$total = count($categoryList[$categoryId]);
//var_dump($questionCheck);
foreach ($categoryList[$categoryId] as $checkQuestionId) {
if ((int) $checkQuestionId === $questionCheck->iid) {
if ((int) $checkQuestionId === (int) $questionCheck->iid) {
break;
}
$count++;
}
//var_dump($count , $total);
if ($count === $total) {
$isLastQuestionInCategory = $categoryId;
if ($isLastQuestionInCategory) {
// This is the last question
if ((int) $current_question + 1 === count($questionList)) {
if (false === $objExercise->review_answers) {
$isLastQuestionInCategory = 0;
}
}
}
}
if (0 === $isLastQuestionInCategory) {
$showPreviousButton = false;
}
if (0 === $isLastQuestionInCategory && 2 === $reminder) {
// $isLastQuestionInCategory = $categoryId;
}
}
//var_dump($categoryId, $blockedCategories, $isLastQuestionInCategory);
// Blocked if category was already answered.
if ($categoryId && in_array($categoryId, $blockedCategories)) {
@ -721,7 +750,7 @@ if ($debug) {
error_log('8. Question list loaded '.print_r($questionList, 1));
}
//Real question count
// Real question count.
$question_count = 0;
if (!empty($questionList)) {
$question_count = count($questionList);
@ -770,12 +799,12 @@ if ($formSent && isset($_POST)) {
$exerciseResult = $choice;
} else {
// gets the question ID from $choice. It is the key of the array
list($key) = array_keys($choice);
[$key] = array_keys($choice);
// if the user didn't already answer this question
if (!isset($exerciseResult[$key])) {
// stores the user answer into the array
$exerciseResult[$key] = $choice[$key];
//saving each question
// Saving each question.
if (!in_array($objExercise->getFeedbackType(), [EXERCISE_FEEDBACK_TYPE_DIRECT])) {
$nro_question = $current_question; // - 1;
$questionId = $key;
@ -965,6 +994,7 @@ $interbreadcrumb[] = [
];
$interbreadcrumb[] = ['url' => '#', 'name' => $objExercise->selectTitle(true)];
// Time per question.
$questionTimeCondition = '';
$showQuestionClock = false;
if ($allowTimePerQuestion && $objExercise->type == ONE_PER_PAGE) {
@ -1011,7 +1041,8 @@ if ($allowTimePerQuestion && $objExercise->type == ONE_PER_PAGE) {
";
}
}
if (!in_array($origin, ['learnpath', 'embeddable', 'mobileapp'])) { //so we are not in learnpath tool
if (!in_array($origin, ['learnpath', 'embeddable', 'mobileapp'])) {
//so we are not in learnpath tool
SessionManager::addFlashSessionReadOnly();
Display::display_header(null, 'Exercises');
@ -1131,7 +1162,6 @@ if (isset($_custom['exercises_hidden_when_no_start_date']) &&
}
}
// Timer control
if ($time_control) {
echo $objExercise->returnTimeLeftDiv();
echo '<div style="display:none" class="warning-message" id="expired-message-id">'.
@ -1251,6 +1281,23 @@ if ($objExercise->review_answers) {
}
}
if ($allowBlockCategory &&
ONE_PER_PAGE == $objExercise->type &&
EX_Q_SELECTION_CATEGORIES_ORDERED_QUESTIONS_RANDOM == $selectionType
) {
if (0 === $isLastQuestionInCategory && 2 === $reminder) {
$endReminderValue = false;
if (!empty($myRemindList)) {
$endValue = end($myRemindList);
if ($endValue == $questionId) {
$endReminderValue = true;
}
}
if ($endReminderValue) {
$isLastQuestionInCategory = $categoryId;
}
}
}
$saveIcon = Display::return_icon(
'save.png',
get_lang('Saved...'),
@ -1259,6 +1306,7 @@ if ($objExercise->review_answers) {
false,
true
);
$loading = Display::returnFontAwesomeIcon('spinner', null, true, 'fa-spin');
echo '<script>
function addExerciseEvent(elm, evType, fn, useCapture) {
@ -1310,24 +1358,13 @@ if ($objExercise->review_answers) {
}
});
$(".main_question").mouseover(function() {
//$(this).find(".exercise_save_now_button").show();
//$(this).addClass("question_highlight");
});
$(".main_question").mouseout(function() {
//$(this).find(".exercise_save_now_button").hide();
$(this).removeClass("question_highlight");
});
$(".no_remind_highlight").hide();
// if the users validates the form using return key,
// prevent form action and simulates click on validation button
/*$("#exercise_form").submit(function(){
$(".question-validate-btn").first().trigger("click");
return false;
});*/
$("form#exercise_form").prepend($("#exercise-description"));
@ -1351,6 +1388,48 @@ if ($objExercise->review_answers) {
save_question_list(questionList);
});
$(\'button[name="check_answers"]\').on(\'touchstart click\', function (e) {
e.preventDefault();
e.stopPropagation();
var $this = $(this);
var urlExtra = $this.data(\'url\') || null;
var questionId = parseInt($this.data(\'question\')) || 0;
save_now(questionId, "check_answers");
var checkUrl = "'.$checkAnswersUrl.'";
$("#global-modal").attr("data-keyboard", "false");
$("#global-modal").attr("data-backdrop", "static");
$("#global-modal").find(".close").hide();
$("#global-modal .modal-body").load(checkUrl, function() {
$("#global-modal .modal-body").append("<div class=\"btn-group\"></div>");
var continueTest = $("<a>",{
text: "'.addslashes(get_lang('ContinueTest')).'",
title: "'.addslashes(get_lang('ContinueTest')).'",
href: "javascript:void(0);",
click: function(){
$(this).attr("disabled", "disabled");
$("#global-modal").modal("hide");
$("#global-modal .modal-body").html("");
}
}).addClass("btn btn-default").appendTo("#global-modal .modal-body .btn-group");
$("<a>",{
text: "'.addslashes(get_lang('EndTest')).'",
title: "'.addslashes(get_lang('EndTest')).'",
href: "javascript:void(0);",
click: function() {
$(this).attr("disabled", "disabled");
continueTest.attr("disabled", "disabled");
save_now(questionId, urlExtra);
$("#global-modal .modal-body").html("<span style=\"text-align:center\">'.addslashes($loading).addslashes(get_lang('Loading')).'</span>");
}
}).addClass("btn btn-primary").appendTo("#global-modal .modal-body .btn-group");
});
$("#global-modal").modal("show");
});
$(\'button[name="save_now"]\').on(\'touchstart click\', function (e) {
e.preventDefault();
e.stopPropagation();
@ -1443,8 +1522,7 @@ if ($objExercise->review_answers) {
dataparam += remind_list ? ("&" + remind_list) : "";
dataparam += my_choiceDc ? ("&" + my_choiceDc) : "";
$("#save_for_now_"+question_id).html(\''.
Display::returnFontAwesomeIcon('spinner', null, true, 'fa-spin').'\');
$("#save_for_now_"+question_id).html(\''.$loading.'\');
$.ajax({
type:"post",
url: "'.api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?'.api_get_cidreq().'&a=save_exercise_by_now",
@ -1470,8 +1548,7 @@ if ($objExercise->review_answers) {
// If last question in category send to exercise_question_reminder.php
if ('.$isLastQuestionInCategory.' > 0 ) {
url = "exercise_question_reminder.php?'.$params.'&num='.$current_question.
'&category_id='.$isLastQuestionInCategory.'";
url = "exercise_question_reminder.php?'.$params.'&num='.($current_question - 1).'&category_id='.$isLastQuestionInCategory.'";
}
if (url_extra) {
@ -1481,6 +1558,9 @@ if ($objExercise->review_answers) {
$("#save_for_now_"+question_id).html(\''.
Display::return_icon('save.png', get_lang('Saved'), [], ICON_SIZE_SMALL).'\');
if ("check_answers" === url_extra) {
return true;
}
// window.quizTimeEnding will be reset in exercise.class.php
if (window.quizTimeEnding) {
redirectExerciseToResult();
@ -1520,7 +1600,7 @@ if ($objExercise->review_answers) {
});
free_answers = $.param(free_answers);
$("#save_all_response").html(\''.Display::returnFontAwesomeIcon('spinner', null, true, 'fa-spin').'\');
$("#save_all_response").html(\''.$loading.'\');
var requestData = "'.$params.'&type=all";
requestData += "&" + my_choice;

@ -441,7 +441,14 @@ foreach ($posts as $post) {
$deleteUrl,
[
'onclick' => "javascript:if(!confirm('"
.addslashes(api_htmlentities(get_lang('Are you sure you want to delete this post? Deleting this post will also delete the replies on this post. Please check the threaded view to see which posts will also be deleted'), ENT_QUOTES))
.addslashes(
api_htmlentities(
get_lang(
'Are you sure you want to delete this post? Deleting this post will also delete the replies on this post. Please check the threaded view to see which posts will also be deleted'
),
ENT_QUOTES
)
)
."')) return false;",
'id' => "delete-post-{$post['post_id']}",
]
@ -524,10 +531,11 @@ foreach ($posts as $post) {
$posterId,
$threadId
);
$userId = $postEntity->getUser()->getId();
if (false == $locked) {
$iconEdit .= '<a href="forumqualify.php?'.api_get_cidreq()
."&forum=$forumId&thread=$threadId&action=list&post={$post['post_id']}"
."&user={$post['user_id']}&user_id={$post['user_id']}"
."&user={$userId}&user_id={$userId}"
."&idtextqualify=$current_qualify_thread"
.'" >'.Display::return_icon('quiz.png', get_lang('Grade activity')).'</a>';
}

@ -533,8 +533,14 @@ class ExerciseLib
}
}
if (UNIQUE_ANSWER_IMAGE != $answerType) {
$answer = Security::remove_XSS($answer, STUDENT);
if ($answerType != UNIQUE_ANSWER_IMAGE) {
$userStatus = STUDENT;
// Allows to do a remove_XSS in question of exersice with user status COURSEMANAGER
// see BT#18242
if (api_get_configuration_value('question_exercise_html_strict_filtering')) {
$userStatus = COURSEMANAGERLOWSECURITY;
}
$answer = Security::remove_XSS($answer, $userStatus);
}
$s .= Display::input(
'hidden',
@ -580,7 +586,13 @@ class ExerciseLib
case GLOBAL_MULTIPLE_ANSWER:
case MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY:
$input_id = 'choice-'.$questionId.'-'.$answerId;
$answer = Security::remove_XSS($answer, STUDENT);
$userStatus = STUDENT;
// Allows to do a remove_XSS in question of exersice with user status COURSEMANAGER
// see BT#18242
if (api_get_configuration_value('question_exercise_html_strict_filtering')) {
$userStatus = COURSEMANAGERLOWSECURITY;
}
$answer = Security::remove_XSS($answer, $userStatus);
if (in_array($numAnswer, $userChoiceList)) {
$attributes = [
@ -777,7 +789,13 @@ class ExerciseLib
}
}
$answer = Security::remove_XSS($answer, STUDENT);
$userStatus = STUDENT;
// Allows to do a remove_XSS in question of exersice with user status COURSEMANAGER
// see BT#18242
if (api_get_configuration_value('question_exercise_html_strict_filtering')) {
$userStatus = COURSEMANAGERLOWSECURITY;
}
$answer = Security::remove_XSS($answer, $userStatus);
$answer_input = '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
$answer_input .= '<label class="checkbox">';
$answer_input .= Display::input(
@ -813,7 +831,13 @@ class ExerciseLib
}
}
}
$answer = Security::remove_XSS($answer, STUDENT);
$userStatus = STUDENT;
// Allows to do a remove_XSS in question of exersice with user status COURSEMANAGER
// see BT#18242
if (api_get_configuration_value('question_exercise_html_strict_filtering')) {
$userStatus = COURSEMANAGERLOWSECURITY;
}
$answer = Security::remove_XSS($answer, $userStatus);
$s .= '<tr>';
$s .= Display::tag('td', $answer);
foreach ($objQuestionTmp->options as $key => $item) {
@ -1490,7 +1514,6 @@ HTML;
}
echo $objQuestionTmp->getTitleToDisplay($current_item);
}
//@todo I need to the get the feedback type
if ($questionRequireAuth) {
WhispeakAuthPlugin::quizQuestionAuthentify($questionId, $exercise);
@ -4295,6 +4318,7 @@ EOT;
$total_score = $total_weight = 0;
$exercise_content = null;
// Hide results
$show_results = false;
$show_only_score = false;
if (in_array($objExercise->results_disabled,
@ -5685,23 +5709,34 @@ EOT;
return $total;
}
public static function parseContent($content, $stats, $exercise, $trackInfo, $currentUserId = 0)
public static function parseContent($content, $stats, Exercise $exercise, $trackInfo, $currentUserId = 0)
{
$wrongAnswersCount = $stats['failed_answers_count'];
$attemptDate = substr($trackInfo['exe_date'], 0, 10);
$exerciseId = $exercise->iId;
$resultsStudentUrl = api_get_path(WEB_CODE_PATH).
'exercise/result.php?id='.$exerciseId.'&'.api_get_cidreq();
$resultsTeacherUrl = api_get_path(WEB_CODE_PATH).
'exercise/exercise_show.php?action=edit&id='.$exerciseId.'&'.api_get_cidreq();
$content = str_replace(
[
'((exercise_error_count))',
'((all_answers_html))',
'((all_answers_teacher_html))',
'((exercise_title))',
'((exercise_attempt_date))',
'((link_to_test_result_page_student))',
'((link_to_test_result_page_teacher))',
],
[
$wrongAnswersCount,
$stats['all_answers_html'],
$stats['all_answers_teacher_html'],
$exercise->get_formated_title(),
$attemptDate,
$resultsStudentUrl,
$resultsTeacherUrl,
],
$content
);
@ -5724,7 +5759,8 @@ EOT;
$exercise_stat_info,
$courseInfo,
$attemptCountToSend,
$stats
$stats,
$statsTeacher
) {
$notifications = api_get_configuration_value('exercise_finished_notification_settings');
if (empty($notifications)) {
@ -5736,6 +5772,7 @@ EOT;
$wrongAnswersCount = $stats['failed_answers_count'];
$exercisePassed = $stats['exercise_passed'];
$countPendingQuestions = $stats['count_pending_questions'];
$stats['all_answers_teacher_html'] = $statsTeacher['all_answers_html'];
// If there are no pending questions (Open questions).
if (0 === $countPendingQuestions) {
@ -5804,11 +5841,10 @@ EOT;
if ($extraFieldData && isset($extraFieldData['value'])) {
$content = $extraFieldData['value'];
$content = self::parseContent($content, $stats, $objExercise, $exercise_stat_info, $studentId);
if (false === $exercisePassed) {
//if (false === $exercisePassed) {
if (0 !== $wrongAnswersCount) {
$content .= $stats['failed_answers_html'];
}
}
$sendMessage = true;
if (!empty($exerciseNotification)) {

@ -161,6 +161,9 @@ class ExtraField extends Model
case 'track_exercise':
$this->extraFieldType = EntityExtraField::TRACK_EXERCISE_FIELD_TYPE;
break;
case 'portfolio':
$this->extraFieldType = EntityExtraField::PORTFOLIO_TYPE;
break;
}
$this->pageUrl = 'extra_fields.php?type='.$this->type;
@ -196,6 +199,9 @@ class ExtraField extends Model
if (api_get_configuration_value('allow_scheduled_announcements')) {
$result[] = 'scheduled_announcement';
}
if (api_get_configuration_value('allow_portfolio_tool')) {
$result[] = 'portfolio';
}
sort($result);
return $result;
@ -1158,7 +1164,6 @@ class ExtraField extends Model
'checkbox',
'extra_'.$field_details['variable'],
null,
//$field_details['display_text'].'<br />',
get_lang('Yes'),
$checkboxAttributes
);
@ -1181,9 +1186,11 @@ class ExtraField extends Model
if (empty($defaultValueId)) {
$options[''] = get_lang('Please select an option');
}
if (isset($field_details['options']) && !empty($field_details['options'])) {
foreach ($field_details['options'] as $optionDetails) {
$options[$optionDetails['option_value']] = $optionDetails['display_text'];
}
}
$form->addElement(
'select',
'extra_'.$field_details['variable'],

@ -854,7 +854,7 @@ if (!empty($groupList)) {
foreach ($exerciseList as $exerciseData) {
foreach ($usersInGroup as $userId) {
$results = Event::get_best_exercise_results_by_user(
$exerciseData['id'],
$exerciseData['iid'],
$courseInfo['real_id'],
0,
$userId

@ -382,7 +382,7 @@ class CForumPost extends AbstractResource implements ResourceInterface
}
/**
* @return mixed
* @return User
*/
public function getUser()
{

Loading…
Cancel
Save