diff --git a/mod/quiz/config.html b/mod/quiz/config.html index dcc772e9f95..0adde501176 100644 --- a/mod/quiz/config.html +++ b/mod/quiz/config.html @@ -145,10 +145,6 @@ $attemptoptions[$i] = "$i ".strtolower(get_string("attempts", "quiz")); } - $penaltyoptions = array(); - $penaltyoptions[QUIZ_PENALTYNONE] = get_string('penaltynone', 'quiz'); - $penaltyoptions[QUIZ_PENALTYMULTIPLY] = get_string('penaltymultiply', 'quiz'); - $penaltyoptions[QUIZ_PENALTYSUBTRACT] = get_string('penaltysubtract', 'quiz'); ?>
| : | penaltyscheme", ""); + choose_from_menu($yesnooptions, "penaltyscheme", "$form->penaltyscheme", ""); helpbutton("penaltyscheme", get_string("penaltyscheme","quiz"), "quiz"); ?> | diff --git a/mod/quiz/edit.php b/mod/quiz/edit.php index 0d3c5835e04..5fa9bb5344d 100644 --- a/mod/quiz/edit.php +++ b/mod/quiz/edit.php @@ -335,7 +335,7 @@ } /// Delete any teacher preview attempts if the quiz has been modified - if (isset($_REQUEST['delete']) or isset($_REQUEST['repaginate']) or isset($_REQUEST['addrandom']) or isset($_REQUEST['addquestion']) or isset($_REQUEST['up']) or isset($_REQUEST['down']) or isset($_REQUEST['add'])) { + if (isset($_REQUEST['setgrades']) or isset($_REQUEST['delete']) or isset($_REQUEST['repaginate']) or isset($_REQUEST['addrandom']) or isset($_REQUEST['addquestion']) or isset($_REQUEST['up']) or isset($_REQUEST['down']) or isset($_REQUEST['add'])) { delete_records('quiz_attempts', 'preview', '1', 'quiz', $modform->id); } diff --git a/mod/quiz/lang/en/quiz.php b/mod/quiz/lang/en/quiz.php index 56c927e51cc..de3a13ad3c6 100644 --- a/mod/quiz/lang/en/quiz.php +++ b/mod/quiz/lang/en/quiz.php @@ -24,6 +24,7 @@ $string['confirmattemptclose'] = 'You still have an unfinished attempt. Do you w $string['confirmclose'] = 'You are about to close this attempt. Once you close the attempt you will no longer be able to change your answers.'; $string['continueattemptfail'] = 'Error: Could not load the last attempt'; $string['continueattemptquiz'] = 'Continue the last attempt'; +$string['correct'] = 'Correct'; $string['deleteitemtypecheck'] = 'Are you absolutely sure you want to delete \'$a\'?'; $string['duplicateresponse'] = 'This submission has been ignored because you gave an equivalent answer earlier.'; $string['editingitemtype'] = 'Editing an Item Type'; @@ -35,11 +36,12 @@ $string['event3'] = 'Grade'; $string['event5'] = 'Validate'; $string['event6'] = 'Close'; $string['fillcorrect'] = 'Fill with correct'; -$string['gradeavailable'] = 'Maximum possible marks: $a'; -$string['gradingdetails'] = 'Marks for this submission: $a->raw/$a->max.'; -$string['gradingdetailsnopenalty'] = 'Marks for this submission: $a->raw/$a->max. Counting all previous submissions this gives $a->cur/$a->max.'; -$string['gradingdetailszeropenalty'] = 'Marks for this submission: $a->raw/$a->max. You were not penalized for this submission. Counting all previous submissions this gives $a->cur/$a->max.'; -$string['gradingdetailspenalty'] = 'Marks for this submission: $a->raw/$a->max with a penalty of $a->penalty. Counting all previous submissions this gives $a->cur/$a->max.'; +$string['gradeavailable'] = 'Maximum possible marks: $a '; +$string['gradingdetails'] = 'Marks for this submission: $a->raw/$a->max. '; +$string['gradingdetailsadjustment'] = 'With previous penalties this gives $a->cur/$a->max. '; +$string['gradingdetailszeropenalty'] = 'You were not penalized for this submission. '; +$string['gradingdetailspenalty'] = 'This submission attracted a penalty of $a. '; +$string['incorrect'] = 'Incorrect'; $string['info'] = 'Info'; $string['invalidsource'] = 'The source is not accepted as valid by the server $a->rendering_server.'; $string['invalidsourcetype'] = 'Invalid source type.'; @@ -67,6 +69,7 @@ $string['notypes'] = 'No item types have been defined! The administrator must ad $string['notypeselected'] = 'No type selected'; $string['numberabbr'] = '#'; $string['outof'] = ' out of a maximum of '; +$string['partiallycorrect'] = 'Partially correct'; $string['penalty'] = 'Penalty'; $string['penaltynone'] = 'None'; $string['penaltymultiply'] = 'Multiplicative'; diff --git a/mod/quiz/locallib.php b/mod/quiz/locallib.php index 8dcbe3bd558..c96d8a233a1 100644 --- a/mod/quiz/locallib.php +++ b/mod/quiz/locallib.php @@ -46,14 +46,6 @@ define('QUIZ_EVENTVALIDATE', '5'); define('QUIZ_EVENTCLOSE', '6'); /**#@-*/ -/**#@+ -* The different penalty schemes -*/ -define('QUIZ_PENALTYNONE', '0'); -define('QUIZ_PENALTYMULTIPLY', '1'); -define('QUIZ_PENALTYSUBTRACT', '2'); -/**#@-*/ - /**#@+ * The defined question types * @@ -595,7 +587,7 @@ class quiz_default_questiontype { echo '||||
| ';
- if ($options->scores) {
+ if ($question->maxgrade and $options->scores and ($quiz->optionflags & QUIZ_ADAPTIVE)) {
$this->print_question_grading_details($question, $state, $quiz, $options);
}
@@ -699,14 +691,7 @@ class quiz_default_questiontype {
* @param object $quiz The quiz to which the question belongs. The
* grading details may be rendered differently
* depending on the quiz settings.
- * @param object $options An object describing the rendering options. The
- * fields are:
- * ->readonly Review / interactive mode
- * ->feedback Show feedback
- * ->validation Show how the response was
- * interpreted
- * ->correct_responses Show solutions
- * These are all boolean values.
+ * @param object $options An object describing the rendering options.
*/
function print_question_grading_details(&$question, &$state, $quiz, $options) {
/* The default implementation prints the number of marks if no attempt
@@ -716,35 +701,46 @@ class quiz_default_questiontype {
responses (and penalties) */
if (!empty($question->maxgrade)) {
- echo ' ';
if (!('' === $state->last_graded->grade)) {
// Display the grading details from the last graded state
$grade->cur = format_float($state->last_graded->grade, $quiz->decimalpoints);
$grade->max = $question->maxgrade;
$grade->raw = format_float($state->last_graded->raw_grade, $quiz->decimalpoints);
- if (QUIZ_EVENTCLOSE == $state->event) {
- /* No further attempts are possible so don't bother
- displaying the penalty */
- print_string('gradingdetailsnopenalty', 'quiz', $grade);
- } else if ('' !== $state->last_graded->penalty && ((float)
- $state->last_graded->penalty) > 0.0) {
- // A penalty was applied so display it
- $grade->penalty = $state->last_graded->penalty;
- print_string('gradingdetailspenalty', 'quiz', $grade);
- } else if ($state->last_graded->raw_grade >=
- $question->maxgrade) {
- /* No penalty was applied because the response was
- correct so don't bother noting that no penalty was
- applied for the attempt */
- print_string('gradingdetailsnopenalty', 'quiz', $grade);
+
+ // let student know wether the answer was correct
+ echo ' ';
}
}
@@ -779,14 +775,6 @@ class quiz_default_questiontype {
* question will likely be rendered differently
* depending on the quiz settings.
* @param object $options An object describing the rendering options.
- * The fields are:
- * ->readonly Review / interactive mode
- * ->feedback Show feedback for the graded
- * responses
- * ->validation Show how the current responses
- * responses were interpreted
- * ->correct_responses Show solutions
- * These are all boolean values.
*/
function print_question_formulation_and_controls(&$question, &$state, $quiz, $options) {
/* This default implementation prints an error and must be overridden
@@ -818,14 +806,7 @@ class quiz_default_questiontype {
* @param object $quiz The quiz to which the question belongs. The
* choice of buttons will likely depend on the quiz
* settings.
- * @param object $options An object describing the rendering options. The
- * fields are:
- * ->readonly Review / interactive mode
- * ->feedback Show feedback
- * ->validation Show how the response was
- * interpreted
- * ->correct_responses Show solutions
- * These are all boolean values.
+ * @param object $options An object describing the rendering options.
*/
function print_question_submit_buttons(&$question, &$state, $quiz, $options) {
/* The default implementation should be suitable for most question
@@ -959,7 +940,7 @@ class quiz_default_questiontype {
if (empty($state->raw_grade)) {
$state->raw_grade = 0.0;
}
- $state->penalty = 0;
+ $state->penalty = $question->penalty * $question->maxgrade;
// Only allow one attempt at the question
$state->event = QUIZ_EVENTCLOSE;
return true;
@@ -1378,7 +1359,8 @@ function quiz_restore_state(&$question, &$state) {
*
* The state object representing the current state of the session for the
* question is saved to the quiz_states table with ->responses[''] saved
-* to the answer field of the database table.
+* to the answer field of the database table. The information in the
+* quiz_newest_states table is updated.
* The question type specific data is then saved.
* @return boolean Indicates success or failure.
* @param object $question The question for which session is to be saved.
@@ -1411,7 +1393,7 @@ function quiz_save_question_session(&$question, &$state) {
$new->questionid = $question->id;
$new->new = $state->id;
$new->newgraded = $state->id;
- $new->sumpenalty = '0.0';
+ $new->sumpenalty = $state->sumpenalty;
if (!insert_record('quiz_newest_states', $new)) {
error('Could not insert entry in quiz_newest_states');
}
@@ -1785,19 +1767,11 @@ function quiz_search_for_duplicate_responses(&$question, &$state) {
* scheme to apply is given by the ->penaltyscheme field.
*/
function quiz_apply_penalty(&$question, &$state, $quiz) {
- switch ($quiz->penaltyscheme) {
- case QUIZ_PENALTYMULTIPLY:
- $state->grade = (1 - $state->sumpenalty) * $state->raw_grade;
- $state->sumpenalty += $state->penalty * (1-$state->sumpenalty);
- break;
- case QUIZ_PENALTYSUBTRACT:
- $state->grade = $state->raw_grade - ($question->maxgrade * $state->sumpenalty);
+ if ($quiz->penaltyscheme) {
+ $state->grade = $state->raw_grade - $state->sumpenalty;
$state->sumpenalty += (float) $state->penalty;
- break;
- case QUIZ_PENALTYNONE:
- default:
- $state->grade = $state->raw_grade;
- break;
+ } else {
+ $state->grade = $state->raw_grade;
}
// Ensure that the grade does not go down
$state->grade = max($state->grade, $state->last_graded->grade);
diff --git a/mod/quiz/mod.html b/mod/quiz/mod.html
index 79eaff979ba..32bf44010b3 100644
--- a/mod/quiz/mod.html
+++ b/mod/quiz/mod.html
@@ -109,11 +109,6 @@
$attemptoptions[$i] = "$i ".strtolower(get_string("attempts", "quiz"));
}
- $penaltyoptions = array();
- $penaltyoptions[QUIZ_PENALTYNONE] = get_string('penaltynone', 'quiz');
- $penaltyoptions[QUIZ_PENALTYMULTIPLY] = get_string('penaltymultiply', 'quiz');
- $penaltyoptions[QUIZ_PENALTYSUBTRACT] = get_string('penaltysubtract', 'quiz');
-
?>
@@ -289,7 +284,7 @@
';
+ if ($state->last_graded->raw_grade >= $question->maxgrade) {
+ print_string('correct', 'quiz');
+ } else if ($state->last_graded->raw_grade > 0) {
+ print_string('partiallycorrect', 'quiz');
} else {
- /* No penalty was applied even though the answer was
- not correct (eg. a syntax error) so tell the student
- that they were not penalised for the attempt */
- print_string('gradingdetailszeropenalty', 'quiz', $grade);
+ print_string('incorrect', 'quiz');
}
+ echo ' ';
+
+
+ echo '';
+ // print grade for this submission
+ print_string('gradingdetails', 'quiz', $grade);
+ // print details of grade adjustment due to penalties
+ if ($state->last_graded->raw_grade > $state->last_graded->grade){
+ print_string('gradingdetailsadjustment', 'quiz', $grade);
+ }
+ // print info about new penalty
+ // penalty is relevant only if the answer is not correct and further attempts are possible
+ if (($state->last_graded->raw_grade < $question->maxgrade) and (QUIZ_EVENTCLOSE !== $state->event)) {
+ if ('' !== $state->last_graded->penalty && ((float)$state->last_graded->penalty) > 0.0) {
+ // A penalty was applied so display it
+ print_string('gradingdetailspenalty', 'quiz', $state->last_graded->penalty);
+ } else {
+ /* No penalty was applied even though the answer was
+ not correct (eg. a syntax error) so tell the student
+ that they were not penalised for the attempt */
+ print_string('gradingdetailszeropenalty', 'quiz');
+ }
+ }
+ echo ' ';
}
- echo ' | : | penaltyscheme", ""); + choose_from_menu($yesnooptions, "penaltyscheme", "$form->penaltyscheme", ""); helpbutton("penaltyscheme", get_string("penaltyscheme","quiz"), "quiz"); ?> | @@ -488,7 +483,7 @@: | penaltyscheme", ""); + choose_from_menu($yesnooptions, "penaltyscheme", "$form->penaltyscheme", ""); helpbutton("penaltyscheme", get_string("penaltyscheme","quiz"), "quiz"); ?> | diff --git a/mod/quiz/questiontypes/calculated/calculated.html b/mod/quiz/questiontypes/calculated/calculated.html index 01b22ef894d..04f71fb16f9 100644 --- a/mod/quiz/questiontypes/calculated/calculated.html +++ b/mod/quiz/questiontypes/calculated/calculated.html @@ -33,7 +33,7 @@"; } @@ -66,7 +66,14 @@ ?> |
| : | ++ " /> + + + | +||||
| : | @@ -113,7 +120,7 @@ | " /> () | @@ -133,12 +140,12 @@ for ($i=1; $i|||
| : | @@ -21,7 +21,7 @@ | ||||
| :
@@ -35,7 +35,7 @@ |
- "; @@ -57,7 +57,7 @@ ?> | ||||
| : | @@ -70,7 +70,14 @@ ?> | ||||
| : | ++ " /> + + + | +||||
| : | @@ -82,7 +89,7 @@ ?> | ||||
| : | @@ -101,7 +108,7 @@ | : |
"/>
- fraction, "");
@@ -109,14 +116,14 @@
|
||
| : | |||||
| : | ++ " /> + + + | +||||
| : | diff --git a/mod/quiz/questiontypes/rqp/questiontype.php b/mod/quiz/questiontypes/rqp/questiontype.php index 52ad1751da0..64605bb5aba 100644 --- a/mod/quiz/questiontypes/rqp/questiontype.php +++ b/mod/quiz/questiontypes/rqp/questiontype.php @@ -232,14 +232,6 @@ class quiz_rqp_qtype extends quiz_default_questiontype { * responses are in ->last_graded->responses). * @param object $quiz The quiz to which the question belongs. * @param object $options An object describing the rendering options. - * The fields are: - * ->readonly Review / interactive mode - * ->feedback Show feedback for the graded - * responses - * ->validation Show how the current responses - * responses were interpreted - * ->correct_responses Show solutions - * These are all boolean values. */ function print_question_formulation_and_controls(&$question, &$state, $quiz, $options) { @@ -414,7 +406,7 @@ class quiz_rqp_qtype extends quiz_default_questiontype { 'rawScore'][0]; if (isset($output->outcomeVars[RQP_URI_OUTCOME . 'penalty'])) { $state->penalty = (float) $output->outcomeVars[RQP_URI_OUTCOME . - 'penalty'][0]; + 'penalty'][0] * $question->maxgrade; } else { $state->penalty = 0; } diff --git a/mod/quiz/questiontypes/shortanswer/questiontype.php b/mod/quiz/questiontypes/shortanswer/questiontype.php index fd40b7ff01b..a47bbca986b 100644 --- a/mod/quiz/questiontypes/shortanswer/questiontype.php +++ b/mod/quiz/questiontypes/shortanswer/questiontype.php @@ -170,7 +170,7 @@ class quiz_shortanswer_qtype extends quiz_default_questiontype { // Make sure we don't assign negative or too high marks $state->raw_grade = min(max((float) $state->raw_grade, 0.0), 1.0) * $question->maxgrade; - $state->penalty = $question->penalty; + $state->penalty = $question->penalty * $question->maxgrade; // Only allow one attempt at the question // $state->event = QUIZ_EVENTCLOSE; return true; @@ -215,9 +215,6 @@ class quiz_shortanswer_qtype extends quiz_default_questiontype { return false; } - function print_question_grading_details(&$question, &$state, $quiz, $options) { - // do nothing - } } //// END OF CLASS //// diff --git a/mod/quiz/questiontypes/truefalse/questiontype.php b/mod/quiz/questiontypes/truefalse/questiontype.php index ec648f32cc0..759cb0336c7 100644 --- a/mod/quiz/questiontypes/truefalse/questiontype.php +++ b/mod/quiz/questiontypes/truefalse/questiontype.php @@ -218,17 +218,6 @@ class quiz_truefalse_qtype extends quiz_default_questiontype { } } - /** - * This questiontype does not have to print any additional grading details - * - * @param object $question - * @param object $state - * @param object $quiz - * @param object $options - */ - function print_question_grading_details(&$question, &$state, $quiz, $options) { - // do nothing - } } //// END OF CLASS //// diff --git a/mod/quiz/styles.php b/mod/quiz/styles.php index 7bcb92256eb..8d1279c80c3 100644 --- a/mod/quiz/styles.php +++ b/mod/quiz/styles.php @@ -30,6 +30,14 @@ body#mod-quiz-attempts table#attempts td { border-right-style: solid; vertical-align: bottom; } + +.grade { + font-size: small; + margin-top: 10pt +} +.gradingdetails { + font-size: small; +} .feedbacktext { text-align:right; } | ||||