Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question degre de certitude #2485

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
98efe2a
Question degre de certitude
Apr 9, 2018
34ed68e
Update multiple_answer_true_false_degree_certainty.class.php
pielRouge Jul 11, 2018
5907ef4
Update exercise.lib.php
pielRouge Jul 11, 2018
e7e2072
Rename multiple_answer_true_false_degree_certainty.class.php to multi…
pielRouge Jul 11, 2018
3d663b2
Update question.class.php
pielRouge Jul 11, 2018
8feed6a
Update exercise_submit.php
pielRouge Jul 11, 2018
8bdd8fa
Update api.lib.php
pielRouge Jul 11, 2018
53d13e2
Update exercise_show_functions.lib.php
pielRouge Jul 11, 2018
b730333
Update exercise.class.php
pielRouge Jul 11, 2018
2e30bfd
Update exercise.class.php
pielRouge Jul 11, 2018
bc1499f
Update exercise.lib.php
pielRouge Jul 11, 2018
822753f
Update exercise_show_functions.lib.php
pielRouge Jul 11, 2018
cb887d3
Update exercise.lib.php
pielRouge Jul 11, 2018
18e09f7
Update exercise_show_functions.lib.php
pielRouge Jul 11, 2018
4bd3ff6
Update exercise.lib.php
pielRouge Jul 11, 2018
7176820
Patch https://flintci.io/repositories/1013/analyses/8726
baelmyhu Jul 11, 2018
bb07e5b
Update exercise_show_functions.lib.php
pielRouge Jul 12, 2018
4bd1afc
Update multipleAnswerTrueFalseDegreeCertainty.php
pielRouge Jul 12, 2018
c7cd686
Update exercise.lib.php
pielRouge Jul 12, 2018
dbd1d88
Update exercise_show_functions.lib.php
pielRouge Jul 12, 2018
d929709
Update exercise_show.php
pielRouge Jul 16, 2018
e56d374
Update exercise_submit.php
pielRouge Jul 16, 2018
19b85a5
Update exercise_submit.php
pielRouge Jul 16, 2018
dfc9f56
Update api.lib.php
pielRouge Jul 16, 2018
0336826
Update api.lib.php
pielRouge Jul 16, 2018
49fa4b7
Update api.lib.php
pielRouge Jul 16, 2018
c239a31
Update api.lib.php
pielRouge Jul 16, 2018
a34cb58
Update api.lib.php
pielRouge Jul 16, 2018
849e6f6
Update api.lib.php
pielRouge Jul 16, 2018
d6dcd17
Update api.lib.php
pielRouge Jul 16, 2018
9e89ca4
Merge branch '1.11.x' into question_degre_certitude_remote
jmontoyaa Jul 16, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions main/exercise/answer.class.php
Expand Up @@ -845,7 +845,8 @@ public function duplicate($newQuestion, $course_info = null)
$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(
Expand Down Expand Up @@ -964,7 +965,8 @@ public function duplicate($newQuestion, $course_info = null)

$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)];
}
Expand Down
212 changes: 166 additions & 46 deletions main/exercise/exercise.class.php

Large diffs are not rendered by default.

158 changes: 99 additions & 59 deletions main/exercise/exercise_show.php
Expand Up @@ -64,6 +64,9 @@
$exerciseResult = Session::read('exerciseResult');
}

if (empty($choiceDegreeCertainty)) {
$choiceDegreeCertainty = isset($_REQUEST['choiceDegreeCertainty']) ? $_REQUEST['choiceDegreeCertainty'] : null;
}
$questionId = isset($_REQUEST['questionId']) ? $_REQUEST['questionId'] : null;

if (empty($choice)) {
Expand Down Expand Up @@ -148,6 +151,7 @@
$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>';
Expand Down Expand Up @@ -232,41 +236,43 @@ function getFCK(vals, marksid) {
// if the results_disabled of the Quiz is 1 when block the script
$result_disabled = $track_exercise_info['results_disabled'];

if ($result_disabled == RESULT_DISABLE_NO_SCORE_AND_EXPECTED_ANSWERS) {
$show_results = false;
} elseif ($result_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY) {
$show_results = false;
$show_only_total_score = true;
if ($origin != 'learnpath') {
if ($currentUserId == $student_id) {
echo Display::return_message(
get_lang('ThankYouForPassingTheTest'),
'warning',
false
);
}
}
} elseif ($result_disabled == RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT) {
$attempts = Event::getExerciseResultsByUser(
$currentUserId,
$objExercise->id,
api_get_course_int_id(),
api_get_session_id(),
$track_exercise_info['orig_lp_id'],
$track_exercise_info['orig_lp_item_id'],
'desc'
);
$numberAttempts = count($attempts);
if ($numberAttempts >= $track_exercise_info['max_attempt']) {
$show_results = true;
$show_only_total_score = true;
// Attempt reach max so show score/feedback now
$showTotalScoreAndUserChoicesInLastAttempt = true;
} else {
$show_results = true;
if (true) {
if ($result_disabled == RESULT_DISABLE_NO_SCORE_AND_EXPECTED_ANSWERS) {
$show_results = false;
} elseif ($result_disabled == RESULT_DISABLE_SHOW_SCORE_ONLY) {
$show_results = false;
$show_only_total_score = true;
// Last attempt not reach don't show score/feedback
$showTotalScoreAndUserChoicesInLastAttempt = false;
if ($origin != 'learnpath') {
if ($currentUserId == $student_id) {
echo Display::return_message(
get_lang('ThankYouForPassingTheTest'),
'warning',
false
);
}
}
} elseif ($result_disabled == RESULT_DISABLE_SHOW_SCORE_ATTEMPT_SHOW_ANSWERS_LAST_ATTEMPT) {
$attempts = Event::getExerciseResultsByUser(
$currentUserId,
$objExercise->id,
api_get_course_int_id(),
api_get_session_id(),
$track_exercise_info['orig_lp_id'],
$track_exercise_info['orig_lp_item_id'],
'desc'
);
$numberAttempts = count($attempts);
if ($numberAttempts >= $track_exercise_info['max_attempt']) {
$show_results = true;
$show_only_total_score = true;
// Attempt reach max so show score/feedback now
$showTotalScoreAndUserChoicesInLastAttempt = true;
} else {
$show_results = true;
$show_only_total_score = true;
// Last attempt not reach don't show score/feedback
$showTotalScoreAndUserChoicesInLastAttempt = false;
}
}
}
} else {
Expand Down Expand Up @@ -321,11 +327,11 @@ function getFCK(vals, marksid) {
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'];
}

Expand All @@ -339,16 +345,16 @@ function getFCK(vals, marksid) {
}
// 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>";
}

Expand All @@ -365,6 +371,7 @@ function getFCK(vals, marksid) {
$exercise_content = '';
$category_list = [];
$useAdvancedEditor = true;

if (!empty($maxEditors) && count($questionList) > $maxEditors) {
$useAdvancedEditor = false;
}
Expand Down Expand Up @@ -428,6 +435,25 @@ function getFCK(vals, marksid) {
$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>
Expand Down Expand Up @@ -757,6 +783,7 @@ function getFCK(vals, marksid) {
}
$feedback_form->setDefaults($default);
$feedback_form->display();

echo '</div>';

if ($allowRecordAudio && $allowTeacherCommentAudio) {
Expand Down Expand Up @@ -923,31 +950,46 @@ function getFCK(vals, marksid) {
$exercise_content .= Display::panel($question_content);
} // end of large foreach on questions

$total_score_text = '';
$totalScoreText = '';

// Total score
$my_total_score_temp = $totalScore;
if ($origin != 'learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) {
if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoicesInLastAttempt) {
$total_score_text .= '<div class="question_row">';
if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) {
$my_total_score_temp = 0;
if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoicesInLastAttempt) {
$totalScoreText .= '<div class="question_row">';
if ($objExercise->selectPropagateNeg() == 0 && $myTotalScoreTemp < 0) {
$myTotalScoreTemp = 0;
}
$total_score_text .= ExerciseLib::getTotalScoreRibbon(
$objExercise,
$my_total_score_temp,
$totalWeighting,
true,
$countPendingQuestions
);
$total_score_text .= '</div>';

if ($answerType == MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
$totalScoreText .= ExerciseLib::getQuestionRibbonDiag(
$objExercise,
$myTotalScoreTemp,
$totalWeighting,
true
);
} else {
$totalScoreText .= ExerciseLib::getTotalScoreRibbon(
$objExercise,
$myTotalScoreTemp,
$totalWeighting,
true,
$countPendingQuestions
);
}

$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(
Expand All @@ -956,12 +998,12 @@ function getFCK(vals, marksid) {
);
}

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') {
Expand Down Expand Up @@ -1135,5 +1177,3 @@ function getFCK(vals, marksid) {

Session::erase('exerciseResult');
unset($exerciseResult);

Session::erase('calculatedAnswerId');