Exercise: Fix partial quizzes and questions types - refs BT#21266

pull/5024/head
christian 2 years ago
parent 21f5ea1e0e
commit 938b0f7f15
  1. 29
      assets/css/app.scss
  2. 8
      public/main/exercise/MultipleAnswerTrueFalseDegreeCertainty.php
  3. 2
      public/main/exercise/exercise.class.php
  4. 8
      public/main/exercise/multiple_answer_true_false.class.php
  5. 8
      public/main/inc/lib/exercise.lib.php

@ -466,6 +466,35 @@ table#skill_holder {
color: rgb(46 117 163 / var(--tw-text-opacity));
}
.question_description img, .question_options img {
display: inherit !important;
}
.question_options .droppable {
padding: 5px;
text-align: center;
background-color: #ECF0F1;
border: dotted #dddddd 2px;
border-radius: 4px;
color: #666666;
display: inline-block;
width: 85%;
margin-bottom: 0;
}
.question_options .droppable-item {
background-color: #84bd00;
color: #FFF;
padding: 3px 0 3px 5px;
width: 20%;
}
.question_options .droppable-item .number {
font-size: 16px;
font-weight: bold;
display: inline-block;
}
/* ****************************************************
END SKILL
**************************************************** */

@ -141,8 +141,10 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question
foreach ($optionData as $id => $data) {
$rdoCorrect = $form->addElement('radio', 'correct['.$i.']', null, null, $id);
if (isset($_POST['correct']) && isset($_POST['correct'][$i]) && $id == $_POST['correct'][$i]) {
if (isset($_POST['correct']) && isset($_POST['correct'][$i]) && $j == $_POST['correct'][$i]) {
$rdoCorrect->setValue(Security::remove_XSS($_POST['correct'][$i]));
} else {
$rdoCorrect->setValue($j);
}
$j++;
if (3 == $j) {
@ -246,9 +248,9 @@ class MultipleAnswerTrueFalseDegreeCertainty extends Question
$question = $repo->find($this->id);
$options = $question->getOptions();
if (!empty($options)) {
if (!$options->isEmpty()) {
foreach ($options as $optionData) {
$optionData->setName($optionData);
$optionData->setName($optionData->getName());
}
} else {
for ($i = 1; $i <= 8; $i++) {

@ -3763,7 +3763,7 @@ class Exercise
}
} else {
// false answer and student is Unsure or PrettySur
if ($quiz_question_options[$studentChoiceDegree]['position'] >= 3
if (isset($quiz_question_options[$studentChoiceDegree]) && $quiz_question_options[$studentChoiceDegree]['position'] >= 3
&& $quiz_question_options[$studentChoiceDegree]['position'] < 9) {
$questionScore += $false_score;
} else {

@ -118,8 +118,10 @@ class MultipleAnswerTrueFalse extends Question
foreach ($optionData as $id => $data) {
$rdoCorrect = $form->addElement('radio', 'correct['.$i.']', null, null, $id);
if (isset($_POST['correct']) && isset($_POST['correct'][$i]) && $id == $_POST['correct'][$i]) {
if (isset($_POST['correct']) && isset($_POST['correct'][$i]) && $j == $_POST['correct'][$i]) {
$rdoCorrect->setValue(Security::remove_XSS($_POST['correct'][$i]));
} else {
$rdoCorrect->setValue($j);
}
$j++;
if (3 == $j) {
@ -251,9 +253,9 @@ class MultipleAnswerTrueFalse extends Question
$options = $question->getOptions();
$em = Database::getManager();
if (!empty($options)) {
if (!$options->isEmpty()) {
foreach ($options as $optionData) {
$optionData->setName($optionData);
$optionData->setName($optionData->getName());
}
} else {
for ($i = 1; $i <= 3; $i++) {

@ -632,6 +632,7 @@ class ExerciseLib
$s .= Display::tag('td', $answer);
if (!empty($quizQuestionOptions)) {
$j = 1;
foreach ($quizQuestionOptions as $id => $item) {
if (isset($myChoice[$numAnswer]) && $id == $myChoice[$numAnswer]) {
$attributes = [
@ -643,7 +644,7 @@ class ExerciseLib
}
if ($debug_mark_answer) {
if ($id == $answerCorrect) {
if ($j == $answerCorrect) {
$attributes['checked'] = 1;
$attributes['selected'] = 1;
}
@ -658,6 +659,7 @@ class ExerciseLib
),
['style' => '']
);
$j++;
}
}
@ -686,6 +688,7 @@ class ExerciseLib
$s .= Display::tag('td', $answer);
if (!empty($quizQuestionOptions)) {
$j = 1;
foreach ($quizQuestionOptions as $id => $item) {
if (isset($myChoice[$numAnswer]) && $id == $myChoice[$numAnswer]) {
$attributes = ['checked' => 1, 'selected' => 1];
@ -706,7 +709,7 @@ class ExerciseLib
$attributes1['onChange'] = 'RadioValidator('.$questionId.', '.$numAnswer.')';
if ($debug_mark_answer) {
if ($id == $answerCorrect) {
if ($j == $answerCorrect) {
$attributes['checked'] = 1;
$attributes['selected'] = 1;
}
@ -739,6 +742,7 @@ class ExerciseLib
]
);
}
$j++;
}
}

Loading…
Cancel
Save