|
|
|
@ -160,7 +160,6 @@ switch ($action) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 1. Setting variables needed by jqgrid |
|
|
|
|
$action = $_GET['a']; |
|
|
|
|
$exercise_id = (int) $_GET['exercise_id']; |
|
|
|
|
$page = (int) $_REQUEST['page']; //page |
|
|
|
|
$limit = (int) $_REQUEST['rows']; //quantity of rows |
|
|
|
@ -391,12 +390,44 @@ switch ($action) { |
|
|
|
|
echo 1; |
|
|
|
|
exit; |
|
|
|
|
break; |
|
|
|
|
case 'check_answers': |
|
|
|
|
if (false === api_is_allowed_to_session_edit()) { |
|
|
|
|
echo 'error'; |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** @var Exercise $objExercise */ |
|
|
|
|
$objExercise = Session::read('objExercise'); |
|
|
|
|
$questionList = Session::read('questionList'); |
|
|
|
|
$exeId = Session::read('exe_id'); |
|
|
|
|
|
|
|
|
|
// If exercise or question is not set then exit. |
|
|
|
|
if (empty($questionList) || empty($objExercise)) { |
|
|
|
|
echo 'error'; |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$statInfo = $objExercise->get_stat_track_exercise_info_by_exe_id($exeId); |
|
|
|
|
|
|
|
|
|
echo Display::page_subheader(get_lang('QuestionsToReview')); |
|
|
|
|
echo $objExercise->getReminderTable($questionList, $statInfo, true); |
|
|
|
|
break; |
|
|
|
|
case 'save_exercise_by_now': |
|
|
|
|
$course_info = api_get_course_info_by_id($course_id); |
|
|
|
|
$course_id = $course_info['real_id']; |
|
|
|
|
|
|
|
|
|
// Use have permissions? |
|
|
|
|
if (api_is_allowed_to_session_edit()) { |
|
|
|
|
// Use have permissions to edit exercises results now? |
|
|
|
|
if (false === api_is_allowed_to_session_edit()) { |
|
|
|
|
echo 'error'; |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log( |
|
|
|
|
'Exercises attempt '.$exeId.': Failed saving question(s) in course/session '. |
|
|
|
|
$course_id.'/'.$session_id. |
|
|
|
|
': The user ('.api_get_user_id().') does not have the permission to access this session now' |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
// "all" or "simple" strings means that there's one or all questions exercise type |
|
|
|
|
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : null; |
|
|
|
|
|
|
|
|
@ -476,7 +507,7 @@ switch ($action) { |
|
|
|
|
$attemptList = Event::getAllExerciseEventByExeId($exeId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Updating Reminder algorithm. |
|
|
|
|
// No exe id? Can't save answer. |
|
|
|
|
if (empty($exeId)) { |
|
|
|
|
// Fires an error. |
|
|
|
|
echo 'error'; |
|
|
|
@ -510,7 +541,7 @@ switch ($action) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// No exe id? Can't save answer. |
|
|
|
|
// Getting the total weight if the request is simple. |
|
|
|
|
$total_weight = 0; |
|
|
|
|
if ('simple' === $type) { |
|
|
|
|
foreach ($question_list as $my_question_id) { |
|
|
|
@ -519,12 +550,12 @@ switch ($action) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
unset($objQuestionTmp); |
|
|
|
|
// Fires an error. |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log('Starting questions loop in save_exercise_by_now'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Getting the total weight if the request is simple |
|
|
|
|
// Check we have at least one non-empty answer in the array |
|
|
|
|
// provided by the user's click on the "Finish test" button. |
|
|
|
|
if ('all' === $type) { |
|
|
|
|
$atLeastOneAnswer = false; |
|
|
|
|
foreach ($question_list as $my_question_id) { |
|
|
|
@ -545,7 +576,7 @@ switch ($action) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Looping the question list |
|
|
|
|
// Looping the question list from database (not from the user answer) |
|
|
|
|
foreach ($question_list as $my_question_id) { |
|
|
|
|
if ('simple' === $type && $question_id != $my_question_id) { |
|
|
|
|
if ($debug) { |
|
|
|
@ -556,7 +587,6 @@ switch ($action) { |
|
|
|
|
|
|
|
|
|
$my_choice = isset($choice[$my_question_id]) ? $choice[$my_question_id] : null; |
|
|
|
|
|
|
|
|
|
// Creates a temporary Question object |
|
|
|
|
$objQuestionTmp = Question::read($my_question_id, $objExercise->course); |
|
|
|
|
|
|
|
|
|
$myChoiceDegreeCertainty = null; |
|
|
|
@ -589,7 +619,7 @@ switch ($action) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ('simple' === $type) { |
|
|
|
|
// Getting old attempt in order to decrees the total score. |
|
|
|
|
// Getting old attempt in order to decrease the total score. |
|
|
|
|
$old_result = $objExercise->manage_answer( |
|
|
|
|
$exeId, |
|
|
|
|
$my_question_id, |
|
|
|
@ -620,7 +650,7 @@ switch ($action) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// Deleting old attempt |
|
|
|
|
// Deleting old attempt. |
|
|
|
|
if (isset($attemptList) && !empty($attemptList[$my_question_id])) { |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log("delete_attempt exe_id : $exeId, my_question_id: $my_question_id"); |
|
|
|
@ -780,20 +810,11 @@ switch ($action) { |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log('Finished questions loop in save_exercise_by_now'); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if ($type === 'all') { |
|
|
|
|
if ($debug) { |
|
|
|
|
error_log( |
|
|
|
|
'Exercises attempt '.$exeId.': Failed saving question(s) in course/session '. |
|
|
|
|
$course_id.'/'.$session_id. |
|
|
|
|
': The user ('. |
|
|
|
|
api_get_user_id(). |
|
|
|
|
') does not have the permission to access this session now'); |
|
|
|
|
error_log("result: ok - all"); |
|
|
|
|
error_log(" ------ end ajax call ------- "); |
|
|
|
|
} |
|
|
|
|
echo 'error'; |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ('all' == $type) { |
|
|
|
|
echo 'ok'; |
|
|
|
|
exit; |
|
|
|
|
} |
|
|
|
|