Question degre de certitude

pull/2485/head
Ivan Zambrano 8 years ago
parent 00f3e4a650
commit 98efe2a62d
  1. 6
      main/exercise/answer.class.php
  2. 167
      main/exercise/exercise.class.php
  3. 88
      main/exercise/exercise_show.php
  4. 69
      main/exercise/exercise_submit.php
  5. 1151
      main/exercise/multiple_answer_true_false_degree_certainty.class.php
  6. 19
      main/exercise/question.class.php
  7. BIN
      main/img/icons/22/mccert.png
  8. BIN
      main/img/icons/22/mccert_na.png
  9. BIN
      main/img/icons/32/mccert.png
  10. BIN
      main/img/icons/64/mccert.png
  11. BIN
      main/img/icons/64/mccert_na.png
  12. 28
      main/inc/ajax/exercise.ajax.php
  13. 51
      main/inc/lib/api.lib.php
  14. 549
      main/inc/lib/exercise.lib.php
  15. 99
      main/inc/lib/exercise_show_functions.lib.php
  16. 48
      main/lang/french/trad4all.inc.php

@ -844,7 +844,8 @@ class Answer
$tableAnswer = Database::get_course_table(TABLE_QUIZ_ANSWER);
if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE ||
self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE
self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE ||
self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY
) {
// Selecting origin options
$origin_options = Question::readQuestionOption(
@ -963,7 +964,8 @@ class Answer
$correct = $this->correct[$i];
if ($newQuestion->type == MULTIPLE_ANSWER_TRUE_FALSE ||
$newQuestion->type == MULTIPLE_ANSWER_TRUE_FALSE
$newQuestion->type == MULTIPLE_ANSWER_TRUE_FALSE ||
$newQuestion->type == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY
) {
$correct = $fixed_list[intval($correct)];
}

@ -3397,12 +3397,16 @@ class Exercise
$totalScore = 0;
// Extra information of the question
if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE && !empty($extra)) {
if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE ||
$answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY &&
!empty($extra)
) {
$extra = explode(':', $extra);
if ($debug) {
error_log(print_r($extra, 1));
}
// Fixes problems with negatives values using intval
$true_score = floatval(trim($extra[0]));
$false_score = floatval(trim($extra[1]));
$doubt_score = floatval(trim($extra[2]));
@ -3417,6 +3421,12 @@ class Exercise
error_log('$answerType: '.$answerType);
}
if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
$choiceTmp = $choice;
$choice = $choiceTmp["choice"];
$choiceDegreeCertainty = $choiceTmp["choiceDegreeCertainty"];
}
if ($answerType == FREE_ANSWER ||
$answerType == ORAL_EXPRESSION ||
$answerType == CALCULATED_ANSWER ||
@ -3565,6 +3575,55 @@ class Exercise
}
$totalScore = $questionScore;
break;
case MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY:
if ($from_database) {
$choice = [];
$choiceDegreeCertainty = [];
$sql = "SELECT answer
FROM $TBL_TRACK_ATTEMPT
WHERE
exe_id = $exeId AND question_id = " . $questionId;
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
$ind = $row['answer'];
$values = explode(':', $ind);
$myAnswerId = $values[0];
$option = $values[1];
$percent = $values[2];
$choice[$myAnswerId] = $option;
$choiceDegreeCertainty[$myAnswerId] = $percent;
}
}
$studentChoice = isset($choice[$answerAutoId]) ? $choice[$answerAutoId] : null;
$studentChoiceDegree = isset($choiceDegreeCertainty[$answerAutoId]) ? $choiceDegreeCertainty[$answerAutoId] : null;
// student score update
if (!empty($studentChoice)){
if ($studentChoice == $answerCorrect) {
// correct answer and student is Unsure or PrettySur
if ($quiz_question_options[$studentChoiceDegree]['position'] >= 3
&& $quiz_question_options[$studentChoiceDegree]['position'] < 9) {
$questionScore += $true_score;
} else {
// student ignore correct answer
$questionScore += $doubt_score;
}
} else {
// false answer and student is Unsure or PrettySur
if ($quiz_question_options[$studentChoiceDegree]['position'] >= 3
&& $quiz_question_options[$studentChoiceDegree]['position'] < 9) {
$questionScore += $false_score;
} else {
// student ignore correct answer
$questionScore += $doubt_score;
}
}
}
$totalScore = $questionScore;
break;
case MULTIPLE_ANSWER: //2
if ($from_database) {
$choice = [];
@ -3777,12 +3836,12 @@ class Exercise
$choice[$j] = null;
}
} else {
// This value is the user input, not escaped while correct answer is escaped by ckeditor
// This value is the user input, not escaped while correct answer is escaped by fckeditor
$choice[$j] = api_htmlentities(trim($choice[$j]));
}
$user_tags[] = $choice[$j];
// Put the contents of the [] answer tag into correct_tags[]
//put the contents of the [] answer tag into correct_tags[]
$correct_tags[] = api_substr($temp, 0, $pos);
$j++;
$temp = api_substr($temp, $pos + 1);
@ -3790,6 +3849,7 @@ class Exercise
$answer = '';
$real_correct_tags = $correct_tags;
$chosen_list = [];
for ($i = 0; $i < count($real_correct_tags); $i++) {
if ($i == 0) {
$answer .= $real_text[0];
@ -3975,9 +4035,7 @@ class Exercise
}
break;
case CALCULATED_ANSWER:
$calculatedAnswerList = Session::read('calculatedAnswerId');
if (!empty($calculatedAnswerList)) {
$answer = $objAnswerTmp->selectAnswer($calculatedAnswerList[$questionId]);
$answer = $objAnswerTmp->selectAnswer($_SESSION['calculatedAnswerId'][$questionId]);
$preArray = explode('@@', $answer);
$last = count($preArray) - 1;
$answer = '';
@ -4093,19 +4151,6 @@ class Exercise
$answer .= $realText[$i + 1];
}
}
} else {
if ($from_database) {
$sql = "SELECT *
FROM $TBL_TRACK_ATTEMPT
WHERE
exe_id = $exeId AND
question_id= ".intval($questionId);
$result = Database::query($sql);
$resultData = Database::fetch_array($result, 'ASSOC');
$answer = $resultData['answer'];
$questionScore = $resultData['marks'];
}
}
break;
case FREE_ANSWER:
if ($from_database) {
@ -4624,6 +4669,21 @@ class Exercise
$results_disabled,
$showTotalScoreAndUserChoicesInLastAttempt
);
} elseif ($answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY){
ExerciseShowFunctions::displayMultipleAnswerTrueFalseDegreeCertainty(
$feedback_type,
$studentChoice,
$studentChoiceDegree,
$answer,
$answerComment,
$answerCorrect,
0,
$questionId,
0,
$results_disabled
);
} elseif ($answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
ExerciseShowFunctions::display_multiple_answer_combination_true_false(
$this,
@ -5005,6 +5065,35 @@ class Exercise
);
}
break;
case MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY :
if ($answerId == 1) {
ExerciseShowFunctions::displayMultipleAnswerTrueFalseDegreeCertainty(
$feedback_type,
$studentChoice,
$studentChoiceDegree,
$answer,
$answerComment,
$answerCorrect,
$exeId,
$questionId,
$answerId,
$results_disabled
);
} else {
ExerciseShowFunctions::displayMultipleAnswerTrueFalseDegreeCertainty(
$feedback_type,
$studentChoice,
$studentChoiceDegree,
$answer,
$answerComment,
$answerCorrect,
$exeId,
$questionId,
"",
$results_disabled
);
}
break;
case FILL_IN_BLANKS:
ExerciseShowFunctions::display_fill_in_blanks_answer(
$feedback_type,
@ -5523,9 +5612,11 @@ class Exercise
}
}
//if ($origin != 'learnpath') {
if ($show_result && $answerType != ANNOTATION) {
echo '</table>';
}
// }
}
unset($objAnswerTmp);
@ -5544,21 +5635,43 @@ class Exercise
if (empty($choice)) {
$choice = 0;
}
if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) {
// with certainty degree
if (empty($choiceDegreeCertainty)) {
$choiceDegreeCertainty = 0;
}
if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE ||
$answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE ||
$answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY
) {
if ($choice != 0) {
$reply = array_keys($choice);
for ($i = 0; $i < sizeof($reply); $i++) {
$ans = $reply[$i];
$answerChoosen = $reply[$i];
if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
if ($choiceDegreeCertainty != 0) {
$replyDegreeCertainty = array_keys($choiceDegreeCertainty);
$answerDegreeCertainty = $replyDegreeCertainty[$i];
Event::saveQuestionAttempt(
$questionScore,
$answerChoosen . ':' . $choice[$answerChoosen] . ':' . $choiceDegreeCertainty[$answerDegreeCertainty],
$quesId,
$exeId,
$i,
$this->id
);
}
} else {
Event::saveQuestionAttempt(
$questionScore,
$ans.':'.$choice[$ans],
$answerChoosen.':'.$choice[$answerChoosen],
$quesId,
$exeId,
$i,
$this->id
);
}
if ($debug) {
error_log('result =>'.$questionScore.' '.$ans.':'.$choice[$ans]);
error_log('result =>'.$questionScore.' '.$answerChoosen.':'.$choice[$answerChoosen]);
}
}
} else {
@ -5685,14 +5798,14 @@ class Exercise
}
if ($saved_results) {
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$sql = 'UPDATE '.$table.' SET
$stat_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
$sql = 'UPDATE '.$stat_table.' SET
exe_result = exe_result + ' . floatval($questionScore).'
WHERE exe_id = ' . $exeId;
Database::query($sql);
}
$return = [
$return_array = [
'score' => $questionScore,
'weight' => $questionWeighting,
'extra' => $extra_data,
@ -5702,7 +5815,7 @@ class Exercise
'generated_oral_file' => $generatedFile,
];
return $return;
return $return_array;
}
/**

@ -64,6 +64,9 @@ if (empty($exerciseResult)) {
$exerciseResult = Session::read('exerciseResult');
}
if (empty($choiceDegreeCertainty)) {
$choiceDegreeCertainty = isset($_REQUEST['choiceDegreeCertainty']) ? $_REQUEST['choiceDegreeCertainty'] : null;
}
$questionId = isset($_REQUEST['questionId']) ? $_REQUEST['questionId'] : null;
if (empty($choice)) {
@ -87,11 +90,8 @@ $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
$courseInfo = api_get_course_info();
$sessionId = api_get_session_id();
$is_allowedToEdit = api_is_allowed_to_edit(null, true) ||
api_is_course_tutor() ||
api_is_session_admin() ||
api_is_drh() ||
api_is_student_boss();
$is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_course_tutor() || api_is_session_admin()
|| api_is_drh() || api_is_student_boss();
if (!empty($sessionId) && !$is_allowedToEdit) {
if (api_is_course_session_coach(
@ -150,6 +150,7 @@ $interbreadcrumb[] = [
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Result')];
$this_section = SECTION_COURSES;
$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">';
$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>';
@ -234,6 +235,7 @@ if (!empty($track_exercise_info)) {
// if the results_disabled of the Quiz is 1 when block the script
$result_disabled = $track_exercise_info['results_disabled'];
if (true) {
if ($result_disabled == RESULT_DISABLE_NO_SCORE_AND_EXPECTED_ANSWERS) {
$show_results = false;
} elseif ($result_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY) {
@ -271,6 +273,7 @@ if (!empty($track_exercise_info)) {
$showTotalScoreAndUserChoicesInLastAttempt = false;
}
}
}
} else {
echo Display::return_message(get_lang('CantViewResults'), 'warning');
$show_results = false;
@ -323,11 +326,11 @@ $sql = "SELECT attempts.question_id, answer
attempts.exe_id = ".intval($id)." $user_restriction
GROUP BY quizz_rel_questions.question_order, attempts.question_id";
$result = Database::query($sql);
$questionListFromDatabase = [];
$question_list_from_database = [];
$exerciseResult = [];
while ($row = Database::fetch_array($result)) {
$questionListFromDatabase[] = $row['question_id'];
$question_list_from_database[] = $row['question_id'];
$exerciseResult[$row['question_id']] = $row['answer'];
}
@ -341,16 +344,16 @@ if (!empty($track_exercise_info['data_tracking'])) {
}
// If for some reason data_tracking is empty we select the question list from db
if (empty($questionList)) {
$questionList = $questionListFromDatabase;
$questionList = $question_list_from_database;
}
} else {
$questionList = $questionListFromDatabase;
$questionList = $question_list_from_database;
}
// Display the text when finished message if we are on a LP #4227
$endOfMessage = $objExercise->selectTextWhenFinished();
if (!empty($endOfMessage) && ($origin == 'learnpath')) {
echo Display::return_message($endOfMessage, 'normal', false);
$end_of_message = $objExercise->selectTextWhenFinished();
if (!empty($end_of_message) && ($origin == 'learnpath')) {
echo Display::return_message($end_of_message, 'normal', false);
echo "<div class='clear'>&nbsp;</div>";
}
@ -367,6 +370,7 @@ $counter = 1;
$exercise_content = '';
$category_list = [];
$useAdvancedEditor = true;
if (!empty($maxEditors) && count($questionList) > $maxEditors) {
$useAdvancedEditor = false;
}
@ -430,6 +434,25 @@ foreach ($questionList as $questionId) {
$questionScore = $question_result['score'];
$totalScore += $question_result['score'];
break;
case MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY:
$choiceTmp = [];
$choiceTmp["choice"] = $choice;
$choiceTmp["choiceDegreeCertainty"] = $choiceDegreeCertainty;
$questionResult = $objExercise->manage_answer(
$id,
$questionId,
$choiceTmp,
'exercise_show',
[],
false,
true,
$show_results,
$objExercise->selectPropagateNeg()
);
$questionScore = $questionResult['score'];
$totalScore += $questionResult['score'];
break;
case HOT_SPOT:
if ($show_results || $showTotalScoreAndUserChoicesInLastAttempt) {
echo '<table width="500" border="0"><tr>
@ -757,6 +780,8 @@ foreach ($questionList as $questionId) {
}
$feedback_form->setDefaults($default);
$feedback_form->display();
echo '</div>';
if ($allowRecordAudio && $allowTeacherCommentAudio) {
@ -923,31 +948,46 @@ foreach ($questionList as $questionId) {
$exercise_content .= Display::panel($question_content);
} // end of large foreach on questions
$total_score_text = '';
$totalScoreText = '';
//Total score
if ($origin != 'learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) {
if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoicesInLastAttempt) {
$total_score_text .= '<div class="question_row">';
$my_total_score_temp = $totalScore;
if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) {
$my_total_score_temp = 0;
$totalScoreText .= '<div class="question_row">';
$myTotalScoreTemp = $totalScore;
if ($objExercise->selectPropagateNeg() == 0 && $myTotalScoreTemp < 0) {
$myTotalScoreTemp = 0;
}
$total_score_text .= ExerciseLib::getTotalScoreRibbon(
if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
$totalScoreText .= ExerciseLib::getQuestionRibbonDiag(
$objExercise,
$my_total_score_temp,
$myTotalScoreTemp,
$totalWeighting,
true
);
} else{
$totalScoreText .= ExerciseLib::getTotalScoreRibbon(
$objExercise,
$myTotalScoreTemp,
$totalWeighting,
true,
$countPendingQuestions
);
$total_score_text .= '</div>';
}
$totalScoreText .= '</div>';
}
}
if ( $answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY){
$chartMultiAnswer = MultipleAnswerTrueFalseDegreeCertainty::displayStudentsChartResults($id, $objExercise);
echo $chartMultiAnswer;
}
if (!empty($category_list) && ($show_results || $show_only_total_score || $showTotalScoreAndUserChoicesInLastAttempt)) {
// Adding total
$category_list['total'] = [
'score' => $my_total_score_temp,
'score' => $myTotalScoreTemp,
'total' => $totalWeighting,
];
echo TestCategory::get_stats_table_by_attempt(
@ -956,12 +996,12 @@ if (!empty($category_list) && ($show_results || $show_only_total_score || $showT
);
}
echo $total_score_text;
echo $totalScoreText;
echo $exercise_content;
// only show "score" in bottom of page if there's exercise content
if ($show_results) {
echo $total_score_text;
echo $totalScoreText;
}
if ($action == 'export') {
@ -1135,5 +1175,3 @@ unset($questionList);
Session::erase('exerciseResult');
unset($exerciseResult);
Session::erase('calculatedAnswerId');

@ -786,7 +786,64 @@ if ($question_count != 0) {
header('Location: exercise_reminder.php?'.$params);
exit;
} else {
header("Location: exercise_result.php?".api_get_cidreq()."&exe_id=$exe_id&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&learnpath_item_view_id=$learnpath_item_view_id");
// Question degree certainty
// We send un email to the student before redirection to the result page
$userInfo = api_get_user_info($user_id);
$recipient_name = api_get_person_name($userInfo['firstname'],
$userInfo['lastname'],
null,
PERSON_NAME_EMAIL_ADDRESS
);
$emailTo = $userInfo['email'];
$senderName = api_get_person_name(api_get_setting('administratorName'),
api_get_setting('administratorSurname'),
null,
PERSON_NAME_EMAIL_ADDRESS
);
$emailGenerique = api_get_setting('emailAdministrator');
$subject = "[" . get_lang('DoNotReply') . "] "
. html_entity_decode(get_lang('ResultAccomplishedTest')." \"" . $objExercise->title . "\"");
// message sended to the student
$message = get_lang('Dear') . ' ' . $recipient_name . ",<br><br>";
//calcul du chemmin sans les script php
$url = $_SERVER['SCRIPT_NAME'];
$pos = strripos($url, "/");
$path = substr($url, 0, $pos);
$message .= get_lang('MessageQuestionCertainty');
$exerciseLink = "<a href='" . api_get_path(WEB_CODE_PATH) . "/exercise/result.php?show_headers=1&"
. api_get_cidreq()
. "&id=$exe_id'>";
$titleExercice = $objExercise->title;
$message = str_replace('%exerTitle', $titleExercice, $message);
$message = str_replace('%webPath', api_get_path(WEB_PATH), $message);
$message = str_replace('%s', $exerciseLink, $message);
// show histogram
require_once api_get_path(SYS_CODE_PATH)
. "exercise/multiple_answer_true_false_degree_certainty.class.php";
$message .= MultipleAnswerTrueFalseDegreeCertainty::displayStudentsChartResults($exe_id, $objExercise);
$message .= get_lang('KindRegards');
$message = api_preg_replace("/\\\n/", "", $message);
api_mail_html($recipient_name,
$emailTo,
$subject,
$message,
$senderName,
$emailGenerique,
['content-type' => 'html']
);
header("Location: exercise_result.php?"
. api_get_cidreq()
. "&exe_id=$exe_id&learnpath_id=$learnpath_id&learnpath_item_id="
. $learnpath_item_id
. "&learnpath_item_view_id=$learnpath_item_view_id"
);
exit;
}
}
@ -1041,6 +1098,8 @@ if (!empty($error)) {
$onsubmit = "onsubmit=\"return validateFlashVar('".$number_of_hotspot_questions."', '".get_lang('HotspotValidateError1')."', '".get_lang('HotspotValidateError2')."');\"";
}
$saveIcon = Display::return_icon(
'save.png',
get_lang('Saved'),
@ -1113,6 +1172,7 @@ if (!empty($error)) {
$(\'button[name="previous_question_and_save"]\').on("click", function (e) {
e.preventDefault();
e.stopPropagation();
var
$this = $(this),
previousId = parseInt($this.data(\'prev\')) || 0,
@ -1133,6 +1193,7 @@ if (!empty($error)) {
$(\'button[name="save_now"]\').on(\'click\', function (e) {
e.preventDefault();
e.stopPropagation();
var
$this = $(this),
questionId = parseInt($this.data(\'question\')) || 0,
@ -1144,6 +1205,7 @@ if (!empty($error)) {
$(\'button[name="validate_all"]\').on(\'click\', function (e) {
e.preventDefault();
e.stopPropagation();
validate_all();
});
@ -1190,6 +1252,9 @@ if (!empty($error)) {
//3. Hotspots
var hotspot = $(\'*[name*="hotspot[\'+question_id+\']"]\').serialize();
//4. choice for degree of certainty
var myChoiceDegreeCertainty = $(\'*[name*="choiceDegreeCertainty[\'+question_id+\']"]\').serialize();
// Checking FCK
if (question_id) {
if (CKEDITOR.instances["choice["+question_id+"]"]) {
@ -1213,7 +1278,7 @@ if (!empty($error)) {
type:"post",
async: false,
url: "'.api_get_path(WEB_AJAX_PATH).'exercise.ajax.php?'.api_get_cidreq().'&a=save_exercise_by_now",
data: "'.$params.'&type=simple&question_id="+question_id+"&"+my_choice+"&"+hotspot+"&"+remind_list,
data: "'.$params.'&type=simple&question_id="+question_id+"&"+my_choice+"&"+hotspot+"&"+remind_list+"&"+myChoiceDegreeCertainty,
success: function(return_value) {
if (return_value == "ok") {
$("#save_for_now_"+question_id).html(\''.Display::return_icon('save.png', get_lang('Saved'), [], ICON_SIZE_SMALL).'\');

@ -50,6 +50,10 @@ abstract class Question
MULTIPLE_ANSWER_COMBINATION => ['multiple_answer_combination.class.php', 'MultipleAnswerCombination'],
UNIQUE_ANSWER_NO_OPTION => ['unique_answer_no_option.class.php', 'UniqueAnswerNoOption'],
MULTIPLE_ANSWER_TRUE_FALSE => ['multiple_answer_true_false.class.php', 'MultipleAnswerTrueFalse'],
MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY => [
'multiple_answer_true_false_degree_certainty.class.php',
'MultipleAnswerTrueFalseDegreeCertainty'
],
MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE => [
'multiple_answer_combination_true_false.class.php',
'MultipleAnswerCombinationTrueFalse',
@ -1519,12 +1523,13 @@ abstract class Question
public static function getInstance($type)
{
if (!is_null($type)) {
list($file_name, $class_name) = self::get_question_type($type);
if (!empty($file_name)) {
if (class_exists($class_name)) {
return new $class_name();
list($fileName, $className) = self::get_question_type($type);
if (!empty($fileName)) {
include_once $fileName;
if (class_exists($className)) {
return new $className();
} else {
echo 'Can\'t instanciate class '.$class_name.' of type '.$type;
echo 'Can\'t instanciate class '.$className.' of type '.$type;
}
}
}
@ -1980,7 +1985,11 @@ abstract class Question
'missing' => $score['weight'],
];
$header .= Display::page_subheader2($counterLabel.'. '.$this->question);
// dont display score for certainty degree questions
if($this->type != MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
$header .= $exercise->getQuestionRibbon($class, $score_label, $score['result'], $scoreCurrent);
}
if ($this->type != READING_COMPREHENSION) {
// Do not show the description (the text to read) if the question is of type READING_COMPREHENSION
$header .= Display::div(

Binary file not shown.

After

Width:  |  Height:  |  Size: 1000 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

@ -12,6 +12,7 @@ api_protect_course_script(true);
$action = $_REQUEST['a'];
$course_id = api_get_course_int_id();
if ($debug) {
error_log("-----------------");
error_log("$action ajax call");
@ -380,6 +381,9 @@ switch ($action) {
// Questions choices.
$choice = isset($_REQUEST['choice']) ? $_REQUEST['choice'] : null;
// cretainty degree choice
$choiceDegreeCertainty = isset($_REQUEST['choiceDegreeCertainty']) ? $_REQUEST['choiceDegreeCertainty'] : null;
// Hot spot coordinates from all questions.
$hot_spot_coordinates = isset($_REQUEST['hotspot']) ? $_REQUEST['hotspot'] : null;
@ -503,6 +507,11 @@ switch ($action) {
// Creates a temporary Question object
$objQuestionTmp = Question::read($my_question_id, $course_id);
if ($objQuestionTmp->type == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
// LQ debug
$myChoiceDegreeCertainty = isset($choiceDegreeCertainty[$my_question_id]) ? $choiceDegreeCertainty[$my_question_id] : null;
}
// Getting free choice data.
if (in_array($objQuestionTmp->type, [FREE_ANSWER, ORAL_EXPRESSION]) && $type == 'all') {
$my_choice = isset($_REQUEST['free_choice'][$my_question_id]) && !empty($_REQUEST['free_choice'][$my_question_id])
@ -570,6 +579,24 @@ switch ($action) {
}
// We're inside *one* question. Go through each possible answer for this question
if ($objQuestionTmp->type == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
$myChoiceTmp = [];
$myChoiceTmp["choice"] = $my_choice;
$myChoiceTmp["choiceDegreeCertainty"] = $myChoiceDegreeCertainty;
$result = $objExercise->manage_answer(
$exeId,
$my_question_id,
$myChoiceTmp,
'exercise_result',
$hot_spot_coordinates,
true,
false,
false,
$objExercise->selectPropagateNeg(),
$hotspot_delineation_result
);
} else {
$result = $objExercise->manage_answer(
$exeId,
$my_question_id,
@ -582,6 +609,7 @@ switch ($action) {
$objExercise->selectPropagateNeg(),
$hotspot_delineation_result
);
}
// Adding the new score.
$total_score += $result['score'];

@ -485,6 +485,7 @@ define('DRAGGABLE', 18);
define('MATCHING_DRAGGABLE', 19);
define('ANNOTATION', 20);
define('READING_COMPREHENSION', 21);
define('MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY', 22);
define('EXERCISE_CATEGORY_RANDOM_SHUFFLED', 1);
define('EXERCISE_CATEGORY_RANDOM_ORDERED', 2);
@ -536,6 +537,7 @@ define(
UNIQUE_ANSWER_IMAGE.':'.
DRAGGABLE.':'.
MATCHING_DRAGGABLE.':'.
MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY.':'.
ANNOTATION
);
@ -747,7 +749,7 @@ function api_get_path($path = '', $configuration = [])
$server_name .= ":".$_SERVER['SERVER_PORT'];
}
$root_web = $server_protocol.'://'.$server_name.$root_rel;
$root_sys = str_replace('\\', '/', realpath(__DIR__.'/../../../')).'/';
$root_sys = str_replace('\\', '/', realpath(__DIR__ . '/../../ficher test degre certitudes/')).'/';
}
// Here we give up, so we don't touch anything.
}
@ -2024,7 +2026,7 @@ function api_get_course_info($course_code = null, $strict = false)
*
* @return \Chamilo\CoreBundle\Entity\Course
*/
function api_get_course_entity($courseId = 0)
function api_get_course_entity($courseId)
{
if (empty($courseId)) {
$courseId = api_get_course_int_id();
@ -2033,20 +2035,6 @@ function api_get_course_entity($courseId = 0)
return Database::getManager()->getRepository('ChamiloCoreBundle:Course')->find($courseId);
}
/**
* @param int $id
*
* @return \Chamilo\CoreBundle\Entity\Session
*/
function api_get_session_entity($id = 0)
{
if (empty($id)) {
$id = api_get_session_id();
}
return Database::getManager()->getRepository('ChamiloCoreBundle:Session')->find($id);
}
/**
* Returns the current course info array.
@ -2180,8 +2168,7 @@ function api_format_course_array($course_data)
null,
null,
null,
true,
false
true
);
}
$_course['course_image_large'] = $url_image;
@ -2732,11 +2719,6 @@ function api_get_settings_params($params)
return $result;
}
/**
* @param array $params example: [id = ? => '1']
*
* @return array
*/
function api_get_settings_params_simple($params)
{
$table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
@ -2974,7 +2956,7 @@ function api_is_coach($session_id = 0, $courseId = null, $check_student_view = t
$session_table = Database::get_main_table(TABLE_MAIN_SESSION);
$session_rel_course_rel_user_table = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$sessionIsCoach = [];
$sessionIsCoach = null;
if (!empty($courseId)) {
$sql = "SELECT DISTINCT s.id, name, access_start_date, access_end_date
@ -3257,6 +3239,10 @@ function api_is_allowed_to_edit(
$session_coach = false,
$check_student_view = true
) {
$sessionId = api_get_session_id();
$is_allowed_coach_to_edit = api_is_coach(null, null, $check_student_view);
$session_visibility = api_get_session_visibility($sessionId);
// Admins can edit anything.
if (api_is_platform_admin(false)) {
//The student preview was on
@ -3267,9 +3253,6 @@ function api_is_allowed_to_edit(
}
}
$sessionId = api_get_session_id();
$is_allowed_coach_to_edit = api_is_coach(null, null, $check_student_view);
$session_visibility = api_get_session_visibility($sessionId);
$is_courseAdmin = api_is_course_admin();
if (!$is_courseAdmin && $tutor) {
@ -4895,9 +4878,9 @@ function api_get_visual_theme()
}
$course_id = api_get_course_id();
if (!empty($course_id)) {
if (!empty($course_id) && $course_id != -1) {
if (api_get_setting('allow_course_theme') == 'true') {
$course_theme = api_get_course_setting('course_theme', $course_id);
$course_theme = api_get_course_setting('course_theme');
if (!empty($course_theme) && $course_theme != -1) {
if (!empty($course_theme)) {
@ -6177,7 +6160,6 @@ function api_is_element_in_the_session($tool, $element_id, $session_id = null)
return true;
}
}
return false;
}
@ -9038,18 +9020,17 @@ function api_float_val($number)
* 3.141516 => 3.14
* 3,141516 => 3,14
*
* @todo WIP
*
* @param string $number number in iso code
* @param int $decimals
* @param string $decimalSeparator
* @param string $thousandSeparator
*
* @return bool|string
*/
function api_number_format($number, $decimals = 0, $decimalSeparator = '.', $thousandSeparator = ',')
function api_number_format($number, $decimals = 0)
{
$number = api_float_val($number);
return number_format($number, $decimals, $decimalSeparator, $thousandSeparator);
return number_format($number, $decimals);
}
/**

@ -98,7 +98,7 @@ class ExerciseLib
// construction of the Answer object (also gets all answers details)
$objAnswerTmp = new Answer($questionId, api_get_course_int_id(), $exercise);
$nbrAnswers = $objAnswerTmp->selectNbrAnswers();
$quiz_question_options = Question::readQuestionOption(
$quizQuestionOptions = Question::readQuestionOption(
$questionId,
$course_id
);
@ -248,6 +248,182 @@ class ExerciseLib
$header,
['style' => 'text-align:left;']
);
} else if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY){
echo "<script>
function RadioValidator(question_id, answer_id)
{
var ShowAlert = \"\";
var typeRadioB = \"\";
var AllFormElements = window.document.getElementById(\"exercise_form\").elements;
for (i = 0; i < AllFormElements.length; i++) {
if (AllFormElements[i].type == \"radio\") {
var ThisRadio = AllFormElements[i].name;
var ThisChecked = \"No\";
var AllRadioOptions = document.getElementsByName(ThisRadio);
for (x = 0; x < AllRadioOptions.length; x++) {
if (AllRadioOptions[x].checked && ThisChecked == \"No\") {
ThisChecked = \"Yes\";
break;
}
}
var AlreadySearched = ShowAlert.indexOf(ThisRadio);
if (ThisChecked == \"No\" && AlreadySearched == -1) {
ShowAlert = ShowAlert + ThisRadio;
}
}
}
if (ShowAlert != \"\") {
} else {
$(\".question-validate-btn\").attr(\"onclick\", \"save_now (\" + question_id +\", '', \" + answer_id+\")\");
$(\".question-validate-btn\").removeAttr('disabled');
}
}
function handleRadioRow(event, question_id, answer_id) {
var t = event.target;
if (t && t.tagName == \"INPUT\")
return;
while (t && t.tagName != \"TD\") {
t = t.parentElement;
}
var r = t.getElementsByTagName(\"INPUT\")[0];
r.click();
RadioValidator(question_id, answer_id);
}
$( document ).ready(function() {
var ShowAlert = \"\";
var typeRadioB = \"\";
var question_id = $('input[name=question_id]').val()
var AllFormElements = window.document.getElementById(\"exercise_form\").elements;
for (i = 0; i < AllFormElements.length; i++) {
if (AllFormElements[i].type == \"radio\") {
var ThisRadio = AllFormElements[i].name;
var ThisChecked = \"No\";
var AllRadioOptions = document.getElementsByName(ThisRadio);
for (x = 0; x < AllRadioOptions.length; x++) {
if (AllRadioOptions[x].checked && ThisChecked == \"No\") {
ThisChecked = \"Yes\";
break;
}
}
var AlreadySearched = ShowAlert.indexOf(ThisRadio);
if (ThisChecked == \"No\" && AlreadySearched == -1) {
ShowAlert = ShowAlert + ThisRadio;
}
}
}
if (ShowAlert != \"\") {
$(\".question-validate-btn\").attr(\"onclick\", \"\");
$(\".question-validate-btn\").attr(\"disabled\", \"disabled\");
} else {
$(\".question-validate-btn\").attr(\"onclick\", \"save_now(\" + question_id +\", '', '')\");
$(\".question-validate-btn\").removeAttr('disabled');
}
});
</script>";
$header = Display::tag('th', get_lang('Options'), array('width' => '50%'));
foreach ($objQuestionTmp->optionsTitle as $item) {
if (in_array($item, $objQuestionTmp->optionsTitle)) {
$properties = array();
if ($item == "langAnswers") {
$properties["colspan"] = 2;
$properties["style"] = "background-color: #F56B2A; color: #ffffff;";
} else if ($item == "DegreeOfCertainty") {
$properties["colspan"] = 6;
$properties["style"] = "background-color: #330066; color: #ffffff;";
}
$header .= Display::tag('th', get_lang($item), $properties);
} else {
$header .= Display::tag('th', $item);
}
}
if ($show_comment) {
$header .= Display::tag('th', get_lang('Feedback'));
}
$s .= '<table class="data_table">';
$s .= Display::tag('tr', $header, ['style' => 'text-align:left;']);
// ajout de la 2eme ligne d'entête pour true/falss et les pourcentages de certitude
$header1 = Display::tag('th', '&nbsp;');
$cpt1 = 0;
foreach ($objQuestionTmp->options as $item) {
$colorBorder1 =($cpt1 == (count($objQuestionTmp->options)-1))?'':'border-right: solid #FFFFFF 1px;' ;
if ($item == "True" || $item == "False") {
$header1 .= Display::tag('th',
get_lang($item),
['style' => 'background-color: #F7C9B4; color: black;'. $colorBorder1]
);
} else {
$header1 .= Display::tag('th',
$item,
['style' => 'background-color: #e6e6ff; color: black;padding:5px; '.$colorBorder1]);
}
$cpt1++;
}
if ($show_comment) {
$header1 .= Display::tag('th', '&nbsp;');
}
$s .= Display::tag('tr', $header1);
// add explanation
$header2 = Display::tag('th', '&nbsp;');
$descriptionList = [
get_lang('Ignorance'),
get_lang('VeryUnsure'),
get_lang('Unsure'),
get_lang('PrettySur'),
get_lang('Sur'),
get_lang('VerySur')
];
$counter2 = 0;
foreach ($objQuestionTmp->options as $item) {
if ($item == "True" || $item == "False") {
$header2 .= Display::tag('td',
'&nbsp;',
['style' => 'background-color: #F7E1D7; color: black;border-right: solid #FFFFFF 1px;']);
} else {
$color_border2 =($counter2 == (count($objQuestionTmp->options)-1)) ? '' : 'border-right: solid #FFFFFF 1px;font-size:11px;' ;
$header2 .= Display::tag(
'td',
nl2br($descriptionList[$counter2]),
array('style' => 'background-color: #EFEFFC; color: black; width: 110px; text-align:center; vertical-align: top; padding:5px; '.$color_border2));
$counter2++;
}
}
if ($show_comment) {
$header2 .= Display::tag('th', '&nbsp;');
}
$s .= Display::tag('tr', $header2);
}
if ($show_comment) {
@ -276,10 +452,10 @@ class ExerciseLib
}
$matching_correct_answer = 0;
$user_choice_array = [];
$userChoiceList = [];
if (!empty($user_choice)) {
foreach ($user_choice as $item) {
$user_choice_array[] = $item['answer'];
$userChoiceList[] = $item['answer'];
}
}
@ -384,13 +560,14 @@ class ExerciseLib
$s .= $answer_input;
}
break;
case MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY:
case MULTIPLE_ANSWER:
case MULTIPLE_ANSWER_TRUE_FALSE:
case GLOBAL_MULTIPLE_ANSWER:
$input_id = 'choice-'.$questionId.'-'.$answerId;
$answer = Security::remove_XSS($answer, STUDENT);
if (in_array($numAnswer, $user_choice_array)) {
if (in_array($numAnswer, $userChoiceList)) {
$attributes = [
'id' => $input_id,
'checked' => 1,
@ -432,20 +609,20 @@ class ExerciseLib
$s .= $answer_input;
}
} elseif ($answerType == MULTIPLE_ANSWER_TRUE_FALSE) {
$my_choice = [];
if (!empty($user_choice_array)) {
foreach ($user_choice_array as $item) {
$myChoice = [];
if (!empty($userChoiceList)) {
foreach ($userChoiceList as $item) {
$item = explode(':', $item);
$my_choice[$item[0]] = $item[1];
$myChoice[$item[0]] = $item[1];
}
}
$s .= '<tr>';
$s .= Display::tag('td', $answer);
if (!empty($quiz_question_options)) {
foreach ($quiz_question_options as $id => $item) {
if (isset($my_choice[$numAnswer]) && $id == $my_choice[$numAnswer]) {
if (!empty($quizQuestionOptions)) {
foreach ($quizQuestionOptions as $id => $item) {
if (isset($myChoice[$numAnswer]) && $id == $myChoice[$numAnswer]) {
$attributes = [
'checked' => 1,
'selected' => 1,
@ -473,6 +650,82 @@ class ExerciseLib
}
}
if ($show_comment) {
$s .= '<td>';
$s .= $comment;
$s .= '</td>';
}
$s .= '</tr>';
} elseif ($answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY){
$myChoice = [];
if (!empty($userChoiceList)) {
foreach ($userChoiceList as $item) {
$item = explode(':', $item);
$myChoice[$item[0]] = $item[1];
}
}
$myChoiceDegreeCertainty = [];
if (!empty($userChoiceList)) {
foreach ($userChoiceList as $item) {
$item = explode(':', $item);
$myChoiceDegreeCertainty[$item[0]] = $item[2];
}
}
$s .= '<tr>';
$s .= Display::tag('td', $answer);
if (!empty($quizQuestionOptions)) {
foreach ($quizQuestionOptions as $id => $item) {
if (isset($myChoice[$numAnswer]) && $id == $myChoice[$numAnswer]) {
$attributes = ['checked' => 1, 'selected' => 1];
} else {
$attributes = [];
}
$attributes['onChange'] = 'RadioValidator(' . $questionId . ', ' . $numAnswer . ')';
// gère la séletion des radio button du degré de certitude
if (isset($myChoiceDegreeCertainty[$numAnswer]) && $id == $myChoiceDegreeCertainty[$numAnswer]) {
$attributes1 = ['checked' => 1, 'selected' => 1];
} else {
$attributes1 = [];
}
$attributes1['onChange'] = 'RadioValidator(' . $questionId . ', ' . $numAnswer . ')';
if ($debug_mark_answer) {
if ($id == $answerCorrect) {
$attributes['checked'] = 1;
$attributes['selected'] = 1;
}
}
if ($item["name"] == "True" || $item["name"] == "False") {
$s .= Display::tag('td',
Display::input('radio',
'choice[' . $questionId . '][' . $numAnswer . ']',
$id,
$attributes
),
['style' => 'text-align:center; background-color:#F7E1D7;',
'onclick' => 'handleRadioRow(event, ' . $questionId . ', ' . $numAnswer . ')'
]
);
} else {
$s .= Display::tag('td',
Display::input('radio',
'choiceDegreeCertainty[' . $questionId . '][' . $numAnswer . ']',
$id,
$attributes1
),
['style' => 'text-align:center; background-color:#EFEFFC;',
'onclick' => 'handleRadioRow(event, ' . $questionId . ', ' . $numAnswer . ')'
]
);
}
}
}
if ($show_comment) {
$s .= '<td>';
$s .= $comment;
@ -485,7 +738,7 @@ class ExerciseLib
// multiple answers
$input_id = 'choice-'.$questionId.'-'.$answerId;
if (in_array($numAnswer, $user_choice_array)) {
if (in_array($numAnswer, $userChoiceList)) {
$attributes = [
'id' => $input_id,
'checked' => 1,
@ -529,12 +782,12 @@ class ExerciseLib
break;
case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE:
$s .= '<input type="hidden" name="choice2['.$questionId.']" value="0" />';
$my_choice = [];
if (!empty($user_choice_array)) {
foreach ($user_choice_array as $item) {
$myChoice = [];
if (!empty($userChoiceList)) {
foreach ($userChoiceList as $item) {
$item = explode(':', $item);
if (isset($item[1]) && isset($item[0])) {
$my_choice[$item[0]] = $item[1];
$myChoice[$item[0]] = $item[1];
}
}
}
@ -542,7 +795,7 @@ class ExerciseLib
$s .= '<tr>';
$s .= Display::tag('td', $answer);
foreach ($objQuestionTmp->options as $key => $item) {
if (isset($my_choice[$numAnswer]) && $key == $my_choice[$numAnswer]) {
if (isset($myChoice[$numAnswer]) && $key == $myChoice[$numAnswer]) {
$attributes = [
'checked' => 1,
'selected' => 1,
@ -668,11 +921,13 @@ class ExerciseLib
$rowLastAttempt = Database::fetch_array($rsLastAttempt);
$answer = $rowLastAttempt['answer'];
if (empty($answer)) {
$randomValue = mt_rand(1, $nbrAnswers);
$answer = $objAnswerTmp->selectAnswer($randomValue);
$calculatedAnswer = Session::read('calculatedAnswerId');
$calculatedAnswer[$questionId] = $randomValue;
Session::write('calculatedAnswerId', $calculatedAnswer);
$_SESSION['calculatedAnswerId'][$questionId] = mt_rand(
1,
$nbrAnswers
);
$answer = $objAnswerTmp->selectAnswer(
$_SESSION['calculatedAnswerId'][$questionId]
);
}
}
@ -684,8 +939,7 @@ class ExerciseLib
$correctAnswerList
);
// get student answer to display it if student go back to
// previous calculated answer question in a test
// get student answer to display it if student go back to previous calculated answer question in a test
if (isset($user_choice[0]['answer'])) {
api_preg_match_all(
'/\[[^]]+\]/',
@ -695,7 +949,9 @@ class ExerciseLib
$studentAnswerListTobecleaned = $studentAnswerList[0];
$studentAnswerList = [];
for ($i = 0; $i < count($studentAnswerListTobecleaned); $i++) {
for ($i = 0; $i < count(
$studentAnswerListTobecleaned
); $i++) {
$answerCorrected = $studentAnswerListTobecleaned[$i];
$answerCorrected = api_preg_replace(
'| / <font color="green"><b>.*$|',
@ -722,8 +978,7 @@ class ExerciseLib
}
}
// If display preview of answer in test view for exaemple,
// set the student answer to the correct answers
// If display preview of answer in test view for exemple, set the student answer to the correct answers
if ($debug_mark_answer) {
// contain the rights answers surronded with brackets
$studentAnswerList = $correctAnswerList[0];
@ -742,7 +997,7 @@ class ExerciseLib
' '.$answer.' '
);
if (!empty($correctAnswerList) && !empty($studentAnswerList)) {
$answer = '';
$answer = "";
$i = 0;
foreach ($studentAnswerList as $studentItem) {
// remove surronding brackets
@ -1074,6 +1329,7 @@ HTML;
UNIQUE_ANSWER_NO_OPTION,
MULTIPLE_ANSWER_TRUE_FALSE,
MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE,
MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY
]
)) {
$s .= '</table>';
@ -1682,7 +1938,6 @@ HOTSPOT;
* @param bool $showSessionField
* @param bool $showExerciseCategories
* @param array $userExtraFieldsToAdd
* @param bool $useCommaAsDecimalPoint
*
* @return array
*/
@ -1697,8 +1952,7 @@ HOTSPOT;
$courseCode = null,
$showSessionField = false,
$showExerciseCategories = false,
$userExtraFieldsToAdd = [],
$useCommaAsDecimalPoint = false
$userExtraFieldsToAdd = []
) {
//@todo replace all this globals
global $documentPath, $filter;
@ -1711,12 +1965,7 @@ HOTSPOT;
}
$course_id = $courseInfo['real_id'];
$is_allowedToEdit =
api_is_allowed_to_edit(null, true) ||
api_is_allowed_to_edit(true) ||
api_is_drh() ||
api_is_student_boss() ||
api_is_session_admin();
$is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_allowed_to_edit(true) || api_is_drh() || api_is_student_boss();
$TBL_USER = Database::get_main_table(TABLE_MAIN_USER);
$TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
$TBL_GROUP_REL_USER = Database::get_course_table(TABLE_GROUP_USER);
@ -1943,7 +2192,9 @@ HOTSPOT;
return $rowx[0];
}
$teacher_list = CourseManager::get_teacher_list_from_course_code($courseCode);
$teacher_list = CourseManager::get_teacher_list_from_course_code(
$courseCode
);
$teacher_id_list = [];
if (!empty($teacher_list)) {
foreach ($teacher_list as $teacher) {
@ -1951,15 +2202,6 @@ HOTSPOT;
}
}
$scoreDisplay = new ScoreDisplay();
$decimalSeparator = '.';
$thousandSeparator = ',';
if ($useCommaAsDecimalPoint) {
$decimalSeparator = ',';
$thousandSeparator = '';
}
$listInfo = [];
// Simple exercises
if (empty($hotpotatoe_where)) {
@ -1977,6 +2219,7 @@ HOTSPOT;
while ($rowx = Database::fetch_array($resx, 'ASSOC')) {
$results[] = $rowx;
}
$group_list = GroupManager::get_group_list(null, $courseInfo);
$clean_group_list = [];
if (!empty($group_list)) {
@ -1989,7 +2232,7 @@ HOTSPOT;
$lp_list = $lp_list_obj->get_flat_list();
$oldIds = array_column($lp_list, 'lp_old_id', 'iid');
if (!empty($results)) {
if (is_array($results)) {
$users_array_id = [];
$from_gradebook = false;
if (isset($_GET['gradebook']) && $_GET['gradebook'] == 'view') {
@ -1997,7 +2240,11 @@ HOTSPOT;
}
$sizeof = count($results);
$user_list_id = [];
$locked = api_resource_is_locked_by_gradebook($exercise_id, LINK_EXERCISE);
$locked = api_resource_is_locked_by_gradebook(
$exercise_id,
LINK_EXERCISE
);
$timeNow = strtotime(api_get_utc_datetime());
// Looping results
for ($i = 0; $i < $sizeof; $i++) {
@ -2079,9 +2326,10 @@ HOTSPOT;
// we filter the results if we have the permission to
$result_disabled = 0;
if (isset($results[$i]['results_disabled'])) {
$result_disabled = (int) $results[$i]['results_disabled'];
$result_disabled = intval(
$results[$i]['results_disabled']
);
}
if ($result_disabled == 0) {
$my_res = $results[$i]['exe_result'];
$my_total = $results[$i]['exe_weighting'];
@ -2093,19 +2341,9 @@ HOTSPOT;
$my_res = 0;
}
$score = self::show_score(
$my_res,
$my_total,
true,
true,
false,
false,
$decimalSeparator,
$thousandSeparator
);
$score = self::show_score($my_res, $my_total);
$actions = '<div class="pull-right">';
if ($is_allowedToEdit) {
if (isset($teacher_id_list)) {
if (in_array(
@ -2190,7 +2428,7 @@ HOTSPOT;
}
// Admin can always delete the attempt
if (($locked == false || (api_is_platform_admin()) && !api_is_student_boss())) {
if (($locked == false || api_is_platform_admin()) && !api_is_student_boss()) {
$ip = Tracking::get_ip_from_user_event(
$results[$i]['exe_user_id'],
api_get_utc_datetime(),
@ -2235,9 +2473,6 @@ HOTSPOT;
if (api_is_drh() && !api_is_platform_admin()) {
$delete_link = null;
}
if (api_is_session_admin()) {
$delete_link = '';
}
if ($revised == 3) {
$delete_link = null;
}
@ -2353,17 +2588,7 @@ HOTSPOT;
}
foreach ($category_list as $categoryId => $result) {
$scoreToDisplay = self::show_score(
$result['score'],
$result['total'],
true,
true,
false,
false,
$decimalSeparator,
$thousandSeparator
);
$scoreToDisplay = self::show_score($result['score'], $result['total']);
$results[$i]['category_'.$categoryId] = $scoreToDisplay;
$results[$i]['category_'.$categoryId.'_score_percentage'] = self::show_score(
$result['score'],
@ -2371,9 +2596,7 @@ HOTSPOT;
true,
true,
true, // $show_only_percentage = false
true, // hide % sign
$decimalSeparator,
$thousandSeparator
true // hide % sign
);
$results[$i]['category_'.$categoryId.'_only_score'] = $result['score'];
$results[$i]['category_'.$categoryId.'_total'] = $result['total'];
@ -2388,23 +2611,10 @@ HOTSPOT;
true,
true,
true,
true,
$decimalSeparator,
$thousandSeparator
);
$results[$i]['only_score'] = $scoreDisplay->format_score(
$my_res,
false,
$decimalSeparator,
$thousandSeparator
);
$results[$i]['total'] = $scoreDisplay->format_score(
$my_total,
false,
$decimalSeparator,
$thousandSeparator
true
);
$results[$i]['only_score'] = $my_res;
$results[$i]['total'] = $my_total;
$results[$i]['lp'] = $lp_name;
$results[$i]['actions'] = $actions;
$listInfo[] = $results[$i];
@ -2483,9 +2693,7 @@ HOTSPOT;
* @param bool $show_percentage show percentage or not
* @param bool $use_platform_settings use or not the platform settings
* @param bool $show_only_percentage
* @param bool $hidePercentageSign hide "%" sign
* @param string $decimalSeparator
* @param string $thousandSeparator
* @param bool $hidePercetangeSign hide "%" sign
*
* @return string an html with the score modified
*/
@ -2495,9 +2703,7 @@ HOTSPOT;
$show_percentage = true,
$use_platform_settings = true,
$show_only_percentage = false,
$hidePercentageSign = false,
$decimalSeparator = '.',
$thousandSeparator = ','
$hidePercetangeSign = false
) {
if (is_null($score) && is_null($weight)) {
return '-';
@ -2519,13 +2725,14 @@ HOTSPOT;
$percentage = (100 * $score) / ($weight != 0 ? $weight : 1);
// Formats values
$percentage = float_format($percentage, 1, $decimalSeparator, $thousandSeparator);
$score = float_format($score, 1, $decimalSeparator, $thousandSeparator);
$weight = float_format($weight, 1, $decimalSeparator, $thousandSeparator);
$percentage = float_format($percentage, 1);
$score = float_format($score, 1);
$weight = float_format($weight, 1);
$html = '';
if ($show_percentage) {
$percentageSign = '%';
if ($hidePercentageSign) {
if ($hidePercetangeSign) {
$percentageSign = '';
}
$html = $percentage."$percentageSign ($score / $weight)";
@ -2555,7 +2762,9 @@ HOTSPOT;
*/
public static function getModelStyle($model, $percentage)
{
//$modelWithStyle = get_lang($model['name']);
$modelWithStyle = '<span class="'.$model['css_class'].'"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>';
//$modelWithStyle .= $percentage;
return $modelWithStyle;
}
@ -3315,7 +3524,10 @@ EOT;
$avg_score = 0;
if (!empty($user_results)) {
foreach ($user_results as $result) {
if (!empty($result['exe_weighting']) && intval($result['exe_weighting']) != 0) {
if (!empty($result['exe_weighting']) && intval(
$result['exe_weighting']
) != 0
) {
$score = $result['exe_result'] / $result['exe_weighting'];
$avg_score += $score;
}
@ -3510,8 +3722,7 @@ EOT;
*
* @param int $question_id
* @param int $exercise_id
*
* @return array
* @return int
*/
public static function getNumberStudentsFillBlanksAnswerCount(
$question_id,
@ -3535,6 +3746,7 @@ EOT;
);
$arrayCount = [];
foreach ($listFillTheBlankResult as $resultCount) {
foreach ($resultCount as $index => $count) {
//this is only for declare the array index per answer
@ -3997,6 +4209,41 @@ EOT;
return $return;
}
/**
* @param string $in_name is the name and the id of the <select>
* @param string $in_default default value for option
* @param string $in_onchange
* @return string the html code of the <select>
*/
public static function displayGroupMenu($in_name, $in_default, $in_onchange = "")
{
// check the default value of option
$tabSelected = [$in_default => " selected='selected' "];
$res = "";
$res .= "<select name='$in_name' id='$in_name' onchange='".$in_onchange."' >";
$res .= "<option value='-1'".$tabSelected["-1"].">-- ".get_lang(
'AllGroups'
)." --</option>";
$res .= "<option value='0'".$tabSelected["0"].">- ".get_lang(
'NotInAGroup'
)." -</option>";
$tabGroups = GroupManager::get_group_list();
$currentCatId = 0;
for ($i = 0; $i < count($tabGroups); $i++) {
$tabCategory = GroupManager::get_category_from_group(
$tabGroups[$i]['iid']
);
if ($tabCategory["id"] != $currentCatId) {
$res .= "<option value='-1' disabled='disabled'>".$tabCategory["title"]."</option>";
$currentCatId = $tabCategory["id"];
}
$res .= "<option ".$tabSelected[$tabGroups[$i]["id"]]."style='margin-left:40px' value='".$tabGroups[$i]["id"]."'>".
$tabGroups[$i]["name"]."</option>";
}
$res .= "</select>";
return $res;
}
/**
* @param int $exe_id
*/
@ -4323,17 +4570,35 @@ EOT;
} // end foreach() block that loops over all questions
}
$total_score_text = null;
$totalScoreText = null;
if ($show_results || $show_only_score) {
$total_score_text .= '<div class="question_row_score">';
$total_score_text .= self::getTotalScoreRibbon(
if ($result['answer_type'] == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
echo "<h1 style='text-align : center; margin : 20px 0;'>Vos Résultats</h1><br>";
}
$totalScoreText .= '<div class="question_row_score">';
if ($result['answer_type'] == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY){
$totalScoreText .= self::getQuestionRibbonDiag($objExercise,
$total_score,
$total_weight,
true
);
} else {
$totalScoreText .= self::getTotalScoreRibbon(
$objExercise,
$total_score,
$total_weight,
true,
$countPendingQuestions
);
$total_score_text .= '</div>';
}
$totalScoreText .= '</div>';
}
if($result['answer_type'] == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY){
$chartMultiAnswer = MultipleAnswerTrueFalseDegreeCertainty::displayStudentsChartResults(
$exeId,
$objExercise);
echo $chartMultiAnswer;
}
if (!empty($category_list) && ($show_results || $show_only_score)) {
@ -4349,8 +4614,7 @@ EOT;
}
if ($show_all_but_expected_answer) {
$exercise_content .= "<div class='normal-message'>".
get_lang('ExerciseWithFeedbackWithoutCorrectionComment')."</div>";
$exercise_content .= "<div class='normal-message'>".get_lang('ExerciseWithFeedbackWithoutCorrectionComment')."</div>";
}
// Remove audio auto play from questions on results page - refs BT#7939
@ -4360,7 +4624,7 @@ EOT;
$exercise_content
);
echo $total_score_text;
echo $totalScoreText;
// Ofaj change BT#11784
if (!empty($objExercise->description)) {
@ -4370,7 +4634,7 @@ EOT;
echo $exercise_content;
if (!$show_only_score) {
echo $total_score_text;
echo $totalScoreText;
}
if (!empty($remainingMessage)) {
@ -4418,6 +4682,57 @@ EOT;
}
}
/**
* @param Exercise $objExercise
* @param float $score
* @param float $weight
* @param bool $checkPassPercentage
* @return string
*/
public static function getQuestionRibbonDiag($objExercise, $score, $weight, $checkPassPercentage = false) {
$displayChartDegree = true;
$ribbon = $displayChartDegree? '<div class="ribbon">' : '';
if ($checkPassPercentage) {
$isSuccess = self::isSuccessExerciseResult(
$score, $weight, $objExercise->selectPassPercentage()
);
// Color the final test score if pass_percentage activated
$ribbonTotalSuccessOrError = "";
if (self::isPassPercentageEnabled($objExercise->selectPassPercentage())) {
if ($isSuccess) {
$ribbonTotalSuccessOrError = ' ribbon-total-success';
} else {
$ribbonTotalSuccessOrError = ' ribbon-total-error';
}
}
$ribbon .= $displayChartDegree? '<div class="rib rib-total ' . $ribbonTotalSuccessOrError . '">' : '';
} else {
$ribbon .= $displayChartDegree? '<div class="rib rib-total">' : '';
}
if ($displayChartDegree){
$ribbon .= '<h3>' . get_lang('YourTotalScore') . ":&nbsp;";
$ribbon .= self::show_score($score, $weight, false, true);
$ribbon .= '</h3>';
$ribbon .= '</div>';
}
if ($checkPassPercentage) {
$ribbon .= self::showSuccessMessage(
$score, $weight, $objExercise->selectPassPercentage()
);
}
$ribbon .= $displayChartDegree? '</div>' : '';
return $ribbon;
}
/**
* @param Exercise $objExercise
* @param float $score

@ -496,6 +496,105 @@ class ExerciseShowFunctions
echo '</tr>';
}
/**
* Display the answers to a multiple choice question
*
* @param int $feedbackType
* @param int $studentChoice
* @param int $studentChoiceDegree
* @param string $answer
* @param string $answerComment
* @param int $answerCorrect
* @param int $id
* @param int $questionId
* @param int $answerNumber
* @param boolean $inResultsDisabled
* @return void
*/
static function displayMultipleAnswerTrueFalseDegreeCertainty(
$feedbackType, $studentChoice, $studentChoiceDegree, $answer, $answerComment, $answerCorrect, $id, $questionId, $answerNumber, $inResultsDisabled
) {
$hideExpectedAnswer = false;
if ($feedbackType == 0 && $inResultsDisabled == 2) {
$hideExpectedAnswer = true;
}
?>
<tr>
<td width="5%">
<?php
$question = new MultipleAnswerTrueFalseDegreeCertainty();
$courseId = api_get_course_int_id();
$newOptions = Question::readQuestionOption($questionId, $courseId);
//Your choice
if (isset($newOptions[$studentChoice])) {
echo get_lang($newOptions[$studentChoice]['name']);
} else {
echo '-';
}
?>
</td>
<td width="5%">
<?php
//Expected choice
if (!$hideExpectedAnswer) {
if (isset($newOptions[$answerCorrect])) {
echo get_lang($newOptions[$answerCorrect]['name']);
} else {
echo '-';
}
} else {
echo '-';
}
?>
</td>
<td width="25%">
<?php echo $answer; ?>
</td>
<td width="5%" style="text-align:center;">
<?php
echo $newOptions[$studentChoiceDegree]['name'];
?>
</td>
<!-- color by certainty -->
<?php
$degreCertitudeColor = $question->getColorResponse($studentChoice,
$answerCorrect,
$newOptions[$studentChoiceDegree]['position']
);
if($degreCertitudeColor == "#088A08" || $degreCertitudeColor == "#FE2E2E"){
$color = "#FFFFFF";
} else {
$color = "#000000";
}
$codeResponse = $question->getCodeResponse($studentChoice,
$answerCorrect,
$newOptions[$studentChoiceDegree]['position']
);
?>
<td width="10%">
<div style="text-align:center;color: <?php echo $color; ?>; border:1px #D6D4D4 solid;background-color: <?php echo $degreCertitudeColor; ?>; line-height:30px;height:30px;width: 100%;margin:auto;"><?php echo nl2br($codeResponse); ?></div>
</td>
<?php if ($feedbackType != EXERCISE_FEEDBACK_TYPE_EXAM) { ?>
<td width="20%">
<?php
$color = "black";
if (isset($newOptions[$studentChoice])) {
echo '<span style="font-weight: bold; color: ' . $color . ';">' . nl2br($answerComment) . '</span>';
}
?>
</td>
<?php } else { ?>
<td>&nbsp;</td>
<?php } ?>
</tr>
<?php
}
/**
* Display the answers to a multiple choice question.
*

@ -6233,6 +6233,7 @@ $DisableLPAutoLaunch = "Désactiver lancement automatique du parcours";
$TheLPAutoLaunchSettingIsONStudentsWillBeRedirectToAnSpecificLP = "Le paramètre d'auto-démarrage des parcours d'apprentissage est activé. Lorsque les apprenants entreront dans cet espace de cours, ils seront automatiquement redirigés vers le parcours d'apprentissage sélectionné pour l'auto-démarrage.";
$UniqueAnswerNoOption = "Rép. unique avec ne-sais-pas";
$MultipleAnswerTrueFalse = "Rép. multiples vrai/faux/ne-sais-pas";
$MultipleAnswerTrueFalseDegreeCertainty = "Rép. multiples vrai/faux/degré de certitude";
$MultipleAnswerCombinationTrueFalse = "C. exacte vrai/faux/ne-sais-pas";
$DontKnow = "Ne sais pas";
$ExamNotAvailableAtThisTime = "Examen non disponible pour l'instant";
@ -6294,6 +6295,32 @@ $LatestAttempt = "Dernière tentative";
$PDFWaterMarkHeader = "En-tête en filigrane (exports PDF)";
$False = "Faux";
$DoubtScore = "Ne sais pas";
// remplacer texte "Ne sais pas" par "Degré de certitude" pour MultipleAnswerTrueFalse
$YourDegreeOfCertainty = "Votre degré de certitude";
$DegreeOfCertainty = "Degré de certitude que la réponse soit jugée correcte";
// explication des degré de certitude du tableau d'exercice
$Ignorance = "J’ignore la bonne réponse et j’ai choisi au hasard";
$VeryUnsure = "Je suis très peu sûr";
$Unsure = "Je suis peu sûr";
$PrettySur = "Je suis assez sûr";
$Sur = "Je suis quasiment sûr";
$VerySur = "Je suis tout à fait sûr";
// description des codes couleur
$langVeryUnsure = "Erreur dangereuse";
$langExplainVeryUnsure = " votre réponse a été incorrecte et vous étiez pourtant sûr à 80% ou plus";
$langUnsure = "Erreur présumée";
$langExplainUnsure = "votre réponse a été incorrecte, mais vous en doutiez (certitude 60% ou 70 %)";
$langIgnorance = "Ignorance déclarée";
$langExplainIgnorance = " vous ne connnaissiez pas la réponse - dégré de certitude 50%";
$langPrettySur = "Savoir fragile";
$langExplainPrettySur = "votre réponse a été correcte mais vous etiez peu sûr (certitude 60% ou 70%)";
$langVerySure = "Savoir certain";
$langExplainVerySure = "votre réponse a été correcte et vous etiez sûr à 80% ou plus - <b>félicitation</b>";
$langAnswers = "Réponses";
// description réponse sur les histogrammes
$langCorrectsAnswers = "Réponses correctes";
$langWrongsAnswers = "Réponses incorrectes";
$langIgnoranceAnswers = "Ignorance";
$RegistrationByUsersGroups = "Inscription par groupes d'utilisateurs";
$ContactInformationHasNotBeenSent = "Vos détails de contact n'ont pas pu être envoyés. C'est probablement dû à un problème de réseau. Veuillez essayer à nouveau dans quelques secondes. Si le problème persiste, ignorez simplement ce processus d'inscription et cliquez sur l'autre bouton pour passer à l'étape suivante.";
$FillCourses = "Générer des cours";
@ -8046,6 +8073,27 @@ $YouWillReceivedASecondEmail = "Vous allez recevoir un autre mail avec votre mot
$YouReceivedAnEmailWithTheUsername = "Vous avez du recevoir un autre mail avec votre identifiant.";
$TheScormPackageWillBeUpdatedYouMustUploadTheFileWithTheSameName = "Vous devez envoyer un fichier zip du même nom que le fichier SCORM original.";
$YourChoice = "Votre choix";
$MessageQuestionCertainty = "Voici ci dessous vos résultats du test \"<span style=\"font-family: Arial; font-size: 18px; color: green;\">"
. "%exerTitle" //$objExercise->title
. "\"</span>."
. "<br/>Pour consulter le détail des résultats "
. "<br/><br/>1. Connectez vous sur la plate forme Chamilo (identifiant/mot de passe universitaire) : "
. "<a href='"
. " %webPath " // api_get_path(WEB_PATH)
. "'>se connecter à Chamilo : </a>"
. "<br/><br/>2. Puis cliquez sur ce lien %s "
. "voir mes résultats détaillés </a>.<br/><br/>";
$KindRegards = "Cordialement, <br>";
$DoNotReply = "Ne pas répondre";
$ResultAccomplishedTest = "Résultats du test réalisé";
$NonCategory = "Sans catégorie";
$ResultTest = "Votre résultat sur l'ensemble du test";
$CompareLastResult = "Pour comparaison, votre dernier résultat à ce test";
$ResultsbyDiscipline = "Vos résultats discipline par discipline";
$YouNeedToCreateASkillProfile = "Vous devez créer un profil de compétences";
$SkillLevel = "Niveau de compétence";
$Portfolio = "Portfolio";

Loading…
Cancel
Save