function print_question_formulation_and_controls(&$question, &$state, $cmoptions, $options) {
global $CFG;
/// This implementation is also used by question type 'numerical'
- $correctanswers = $this->get_correct_responses($question, $state);
$readonly = empty($options->readonly) ? '' : 'readonly="readonly"';
$formatoptions = new stdClass;
$formatoptions->noclean = true;
}
}
}
-
- $correctanswer = '';
- if ($options->readonly && $options->correct_responses) {
- $delimiter = '';
- if ($correctanswers) {
- foreach ($correctanswers as $ca) {
- $correctanswer .= $delimiter.$ca;
- $delimiter = ', ';
- }
- }
- }
+
+ /// Removed correct answer, to be displayed later MDL-7496
include("$CFG->dirroot/question/type/shortanswer/display.html");
}
return $status;
}
+
+
+ /**
+ * Prints the score obtained and maximum score available plus any penalty
+ * information
+ *
+ * This function prints a summary of the scoring in the most recently
+ * graded state (the question may not have been submitted for marking at
+ * the current state). The default implementation should be suitable for most
+ * question types.
+ * @param object $question The question for which the grading details are
+ * to be rendered. Question type specific information
+ * is included. The maximum possible grade is in
+ * ->maxgrade.
+ * @param object $state The state. In particular the grading information
+ * is in ->grade, ->raw_grade and ->penalty.
+ * @param object $cmoptions
+ * @param object $options An object describing the rendering options.
+ */
+ function print_question_grading_details(&$question, &$state, $cmoptions, $options) {
+ /* The default implementation prints the number of marks if no attempt
+ has been made. Otherwise it displays the grade obtained out of the
+ maximum grade available and a warning if a penalty was applied for the
+ attempt and displays the overall grade obtained counting all previous
+ responses (and penalties) */
+
+ // MDL-7496 show correct answer after "Incorrect"
+ $correctanswer = '';
+ if ($correctanswers = $this->get_correct_responses($question, $state)) {
+ if ($options->readonly && $options->correct_responses) {
+ $delimiter = '';
+ if ($correctanswers) {
+ foreach ($correctanswers as $ca) {
+ $correctanswer .= $delimiter.$ca;
+ $delimiter = ', ';
+ }
+ }
+ }
+ }
+
+ if (QUESTION_EVENTDUPLICATE == $state->event) {
+ echo ' ';
+ print_string('duplicateresponse', 'quiz');
+ }
+ if (!empty($question->maxgrade) && $options->scores) {
+ if (question_state_is_graded($state->last_graded)) {
+ // Display the grading details from the last graded state
+ $grade = new stdClass;
+ $grade->cur = round($state->last_graded->grade, $cmoptions->decimalpoints);
+ $grade->max = $question->maxgrade;
+ $grade->raw = round($state->last_graded->raw_grade, $cmoptions->decimalpoints);
+
+ // let student know wether the answer was correct
+ echo '<div class="correctness ';
+ if ($state->last_graded->raw_grade >= $question->maxgrade/1.01) { // We divide by 1.01 so that rounding errors dont matter.
+ echo ' correct">';
+ print_string('correct', 'quiz');
+ } else if ($state->last_graded->raw_grade > 0) {
+ echo ' partiallycorrect">';
+ print_string('partiallycorrect', 'quiz');
+ // MDL-7496
+ if ($correctanswer) {
+ echo ('<div class="correctness correct">');
+ print_string('correctansweris', 'quiz', s($correctanswer));
+ echo ('</div>');
+ }
+ } else {
+ echo ' incorrect">';
+ // MDL-7496
+ print_string('incorrect', 'quiz');
+ if ($correctanswer) {
+ echo ('<div class="correctness correct">');
+ print_string('correctansweris', 'quiz', s($correctanswer));
+ echo ('</div>');
+ }
+ }
+ echo '</div>';
+
+ echo '<div class="gradingdetails">';
+ // print grade for this submission
+ print_string('gradingdetails', 'quiz', $grade);
+ if ($cmoptions->penaltyscheme) {
+ // print details of grade adjustment due to penalties
+ if ($state->last_graded->raw_grade > $state->last_graded->grade){
+ echo ' ';
+ 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 (QUESTION_EVENTCLOSEANDGRADE !== $state->event)) {
+ if ('' !== $state->last_graded->penalty && ((float)$state->last_graded->penalty) > 0.0) {
+ // A penalty was applied so display it
+ echo ' ';
+ 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 */
+ echo ' ';
+ print_string('gradingdetailszeropenalty', 'quiz');
+ }
+ }
+ }
+ echo '</div>';
+ }
+ }
+ }
+
+
+
+
+
}
//// END OF CLASS ////