Skip to content

Commit 6536618

Browse files
committed
Import an exercise via Excel: error calculating the maximum score #3145
Fixed problem in javascript to show custom scores. Only the items marked as correct in the unique response are added to the total.
1 parent 47fc147 commit 6536618

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

main/exercise/upload_exercise.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@
2323

2424
$this_section = SECTION_COURSES;
2525
$htmlHeadXtra[] = "<script>
26-
$(function(){
27-
$('#user_custom_score').click(function() {
28-
$('#options').toggle();
26+
$(function () {
27+
$('#user_custom_score').on('change', function () {
28+
if ($('#user_custom_score[type=\"checkbox\"]').prop('checked')) {
29+
$('#options').removeClass('hidden')
30+
} else {
31+
$('#options').addClass('hidden')
32+
}
2933
});
3034
});
3135
</script>";
@@ -110,7 +114,7 @@ function lp_upload_quiz_main()
110114
get_lang('UseCustomScoreForAllQuestions'),
111115
['id' => 'user_custom_score']
112116
);
113-
$form->addElement('html', '<div id="options" style="display:none">');
117+
$form->addElement('html', '<div id="options" class="hidden">');
114118
$form->addElement('text', 'correct_score', get_lang('CorrectScore'));
115119
$form->addElement('text', 'incorrect_score', get_lang('IncorrectScore'));
116120
$form->addElement('html', '</div>');
@@ -427,8 +431,10 @@ function lp_upload_quiz_action_handling()
427431
$score,
428432
$id
429433
);
430-
431-
$total += (float) $score;
434+
if ($correct) {
435+
//only add the item marked as correct ( x )
436+
$total += (float)$score;
437+
}
432438
$id++;
433439
}
434440

0 commit comments

Comments
 (0)