Skip to content

Commit 98efe2a

Browse files
author
Ivan Zambrano
committed
Question degre de certitude
1 parent 00f3e4a commit 98efe2a

16 files changed

+2375
-526
lines changed

main/exercise/answer.class.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,8 @@ public function duplicate($newQuestion, $course_info = null)
844844
$tableAnswer = Database::get_course_table(TABLE_QUIZ_ANSWER);
845845

846846
if (self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE ||
847-
self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE
847+
self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE ||
848+
self::getQuestionType() == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY
848849
) {
849850
// Selecting origin options
850851
$origin_options = Question::readQuestionOption(
@@ -963,7 +964,8 @@ public function duplicate($newQuestion, $course_info = null)
963964

964965
$correct = $this->correct[$i];
965966
if ($newQuestion->type == MULTIPLE_ANSWER_TRUE_FALSE ||
966-
$newQuestion->type == MULTIPLE_ANSWER_TRUE_FALSE
967+
$newQuestion->type == MULTIPLE_ANSWER_TRUE_FALSE ||
968+
$newQuestion->type == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY
967969
) {
968970
$correct = $fixed_list[intval($correct)];
969971
}

main/exercise/exercise.class.php

Lines changed: 300 additions & 187 deletions
Large diffs are not rendered by default.

main/exercise/exercise_show.php

Lines changed: 105 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@
6464
$exerciseResult = Session::read('exerciseResult');
6565
}
6666

67+
if (empty($choiceDegreeCertainty)) {
68+
$choiceDegreeCertainty = isset($_REQUEST['choiceDegreeCertainty']) ? $_REQUEST['choiceDegreeCertainty'] : null;
69+
}
6770
$questionId = isset($_REQUEST['questionId']) ? $_REQUEST['questionId'] : null;
6871

6972
if (empty($choice)) {
@@ -87,11 +90,8 @@
8790

8891
$courseInfo = api_get_course_info();
8992
$sessionId = api_get_session_id();
90-
$is_allowedToEdit = api_is_allowed_to_edit(null, true) ||
91-
api_is_course_tutor() ||
92-
api_is_session_admin() ||
93-
api_is_drh() ||
94-
api_is_student_boss();
93+
$is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_course_tutor() || api_is_session_admin()
94+
|| api_is_drh() || api_is_student_boss();
9595

9696
if (!empty($sessionId) && !$is_allowedToEdit) {
9797
if (api_is_course_session_coach(
@@ -150,6 +150,7 @@
150150
$interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Result')];
151151

152152
$this_section = SECTION_COURSES;
153+
153154
$htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/css/hotspot.css">';
154155
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js"></script>';
155156
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).'annotation/js/annotation.js"></script>';
@@ -222,7 +223,7 @@ function getFCK(vals, marksid) {
222223
}
223224
}
224225
</script>
225-
<?php
226+
<?php
226227
}
227228

228229
$show_results = true;
@@ -234,41 +235,43 @@ function getFCK(vals, marksid) {
234235
// if the results_disabled of the Quiz is 1 when block the script
235236
$result_disabled = $track_exercise_info['results_disabled'];
236237

237-
if ($result_disabled == RESULT_DISABLE_NO_SCORE_AND_EXPECTED_ANSWERS) {
238-
$show_results = false;
239-
} elseif ($result_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY) {
240-
$show_results = false;
241-
$show_only_total_score = true;
242-
if ($origin != 'learnpath') {
243-
if ($currentUserId == $student_id) {
244-
echo Display::return_message(
245-
get_lang('ThankYouForPassingTheTest'),
246-
'warning',
247-
false
248-
);
249-
}
250-
}
251-
} elseif ($result_disabled == RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT) {
252-
$attempts = Event::getExerciseResultsByUser(
253-
$currentUserId,
254-
$objExercise->id,
255-
api_get_course_int_id(),
256-
api_get_session_id(),
257-
$track_exercise_info['orig_lp_id'],
258-
$track_exercise_info['orig_lp_item_id'],
259-
'desc'
260-
);
261-
$numberAttempts = count($attempts);
262-
if ($numberAttempts >= $track_exercise_info['max_attempt']) {
263-
$show_results = true;
238+
if (true) {
239+
if ($result_disabled == RESULT_DISABLE_NO_SCORE_AND_EXPECTED_ANSWERS) {
240+
$show_results = false;
241+
} elseif ($result_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY) {
242+
$show_results = false;
264243
$show_only_total_score = true;
265-
// Attempt reach max so show score/feedback now
266-
$showTotalScoreAndUserChoicesInLastAttempt = true;
267-
} else {
268-
$show_results = true;
269-
$show_only_total_score = true;
270-
// Last attempt not reach don't show score/feedback
271-
$showTotalScoreAndUserChoicesInLastAttempt = false;
244+
if ($origin != 'learnpath') {
245+
if ($currentUserId == $student_id) {
246+
echo Display::return_message(
247+
get_lang('ThankYouForPassingTheTest'),
248+
'warning',
249+
false
250+
);
251+
}
252+
}
253+
} elseif ($result_disabled == RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT) {
254+
$attempts = Event::getExerciseResultsByUser(
255+
$currentUserId,
256+
$objExercise->id,
257+
api_get_course_int_id(),
258+
api_get_session_id(),
259+
$track_exercise_info['orig_lp_id'],
260+
$track_exercise_info['orig_lp_item_id'],
261+
'desc'
262+
);
263+
$numberAttempts = count($attempts);
264+
if ($numberAttempts >= $track_exercise_info['max_attempt']) {
265+
$show_results = true;
266+
$show_only_total_score = true;
267+
// Attempt reach max so show score/feedback now
268+
$showTotalScoreAndUserChoicesInLastAttempt = true;
269+
} else {
270+
$show_results = true;
271+
$show_only_total_score = true;
272+
// Last attempt not reach don't show score/feedback
273+
$showTotalScoreAndUserChoicesInLastAttempt = false;
274+
}
272275
}
273276
}
274277
} else {
@@ -323,11 +326,11 @@ function getFCK(vals, marksid) {
323326
attempts.exe_id = ".intval($id)." $user_restriction
324327
GROUP BY quizz_rel_questions.question_order, attempts.question_id";
325328
$result = Database::query($sql);
326-
$questionListFromDatabase = [];
329+
$question_list_from_database = [];
327330
$exerciseResult = [];
328331

329332
while ($row = Database::fetch_array($result)) {
330-
$questionListFromDatabase[] = $row['question_id'];
333+
$question_list_from_database[] = $row['question_id'];
331334
$exerciseResult[$row['question_id']] = $row['answer'];
332335
}
333336

@@ -341,16 +344,16 @@ function getFCK(vals, marksid) {
341344
}
342345
// If for some reason data_tracking is empty we select the question list from db
343346
if (empty($questionList)) {
344-
$questionList = $questionListFromDatabase;
347+
$questionList = $question_list_from_database;
345348
}
346349
} else {
347-
$questionList = $questionListFromDatabase;
350+
$questionList = $question_list_from_database;
348351
}
349352

350353
// Display the text when finished message if we are on a LP #4227
351-
$endOfMessage = $objExercise->selectTextWhenFinished();
352-
if (!empty($endOfMessage) && ($origin == 'learnpath')) {
353-
echo Display::return_message($endOfMessage, 'normal', false);
354+
$end_of_message = $objExercise->selectTextWhenFinished();
355+
if (!empty($end_of_message) && ($origin == 'learnpath')) {
356+
echo Display::return_message($end_of_message, 'normal', false);
354357
echo "<div class='clear'>&nbsp;</div>";
355358
}
356359

@@ -367,6 +370,7 @@ function getFCK(vals, marksid) {
367370
$exercise_content = '';
368371
$category_list = [];
369372
$useAdvancedEditor = true;
373+
370374
if (!empty($maxEditors) && count($questionList) > $maxEditors) {
371375
$useAdvancedEditor = false;
372376
}
@@ -430,6 +434,25 @@ function getFCK(vals, marksid) {
430434
$questionScore = $question_result['score'];
431435
$totalScore += $question_result['score'];
432436
break;
437+
case MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY:
438+
$choiceTmp = [];
439+
$choiceTmp["choice"] = $choice;
440+
$choiceTmp["choiceDegreeCertainty"] = $choiceDegreeCertainty;
441+
442+
$questionResult = $objExercise->manage_answer(
443+
$id,
444+
$questionId,
445+
$choiceTmp,
446+
'exercise_show',
447+
[],
448+
false,
449+
true,
450+
$show_results,
451+
$objExercise->selectPropagateNeg()
452+
);
453+
$questionScore = $questionResult['score'];
454+
$totalScore += $questionResult['score'];
455+
break;
433456
case HOT_SPOT:
434457
if ($show_results || $showTotalScoreAndUserChoicesInLastAttempt) {
435458
echo '<table width="500" border="0"><tr>
@@ -757,6 +780,8 @@ function getFCK(vals, marksid) {
757780
}
758781
$feedback_form->setDefaults($default);
759782
$feedback_form->display();
783+
784+
760785
echo '</div>';
761786

762787
if ($allowRecordAudio && $allowTeacherCommentAudio) {
@@ -923,31 +948,46 @@ function getFCK(vals, marksid) {
923948
$exercise_content .= Display::panel($question_content);
924949
} // end of large foreach on questions
925950

926-
$total_score_text = '';
951+
$totalScoreText = '';
927952

928953
//Total score
929954
if ($origin != 'learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) {
930955
if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoicesInLastAttempt) {
931-
$total_score_text .= '<div class="question_row">';
932-
$my_total_score_temp = $totalScore;
933-
if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) {
934-
$my_total_score_temp = 0;
956+
$totalScoreText .= '<div class="question_row">';
957+
$myTotalScoreTemp = $totalScore;
958+
if ($objExercise->selectPropagateNeg() == 0 && $myTotalScoreTemp < 0) {
959+
$myTotalScoreTemp = 0;
935960
}
936-
$total_score_text .= ExerciseLib::getTotalScoreRibbon(
937-
$objExercise,
938-
$my_total_score_temp,
939-
$totalWeighting,
940-
true,
941-
$countPendingQuestions
942-
);
943-
$total_score_text .= '</div>';
961+
962+
if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
963+
$totalScoreText .= ExerciseLib::getQuestionRibbonDiag(
964+
$objExercise,
965+
$myTotalScoreTemp,
966+
$totalWeighting,
967+
true
968+
);
969+
} else{
970+
$totalScoreText .= ExerciseLib::getTotalScoreRibbon(
971+
$objExercise,
972+
$myTotalScoreTemp,
973+
$totalWeighting,
974+
true,
975+
$countPendingQuestions
976+
);
977+
}
978+
979+
$totalScoreText .= '</div>';
944980
}
945981
}
982+
if ( $answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY){
983+
$chartMultiAnswer = MultipleAnswerTrueFalseDegreeCertainty::displayStudentsChartResults($id, $objExercise);
984+
echo $chartMultiAnswer;
985+
}
946986

947987
if (!empty($category_list) && ($show_results || $show_only_total_score || $showTotalScoreAndUserChoicesInLastAttempt)) {
948988
// Adding total
949989
$category_list['total'] = [
950-
'score' => $my_total_score_temp,
990+
'score' => $myTotalScoreTemp,
951991
'total' => $totalWeighting,
952992
];
953993
echo TestCategory::get_stats_table_by_attempt(
@@ -956,12 +996,12 @@ function getFCK(vals, marksid) {
956996
);
957997
}
958998

959-
echo $total_score_text;
999+
echo $totalScoreText;
9601000
echo $exercise_content;
9611001

9621002
// only show "score" in bottom of page if there's exercise content
9631003
if ($show_results) {
964-
echo $total_score_text;
1004+
echo $totalScoreText;
9651005
}
9661006

9671007
if ($action == 'export') {
@@ -1090,14 +1130,14 @@ function getFCK(vals, marksid) {
10901130
</button>
10911131
<?php
10921132
} elseif ($origin == 'myprogress') {
1093-
?>
1133+
?>
10941134
<button type="button" class="save"
10951135
onclick="top.location.href='../auth/my_progress.php?course=<?php echo api_get_course_id(); ?>'"
10961136
value="<?php echo get_lang('Finish'); ?>">
10971137
<?php echo get_lang('Finish'); ?>
10981138
</button>
10991139
<?php
1100-
}
1140+
}
11011141

11021142
if ($origin != 'learnpath') {
11031143
//we are not in learnpath tool
@@ -1135,5 +1175,3 @@ function getFCK(vals, marksid) {
11351175

11361176
Session::erase('exerciseResult');
11371177
unset($exerciseResult);
1138-
1139-
Session::erase('calculatedAnswerId');

0 commit comments

Comments
 (0)