From 7897d6fcad1e02e15e25818224c602fef1b8fb91 Mon Sep 17 00:00:00 2001
From: Pierre Pichet
Date: Tue, 25 May 2010 17:12:17 +0000
Subject: [PATCH] MDL-20296 using $state->options->raw_unitpenalty to dispaly
the unit penalty
---
question/type/shortanswer/questiontype.php | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/question/type/shortanswer/questiontype.php b/question/type/shortanswer/questiontype.php
index 77f9fc8173c..a86c6a145be 100644
--- a/question/type/shortanswer/questiontype.php
+++ b/question/type/shortanswer/questiontype.php
@@ -98,11 +98,6 @@ class question_shortanswer_qtype extends default_questiontype {
function print_question_formulation_and_controls(&$question, &$state, $cmoptions, $options) {
global $CFG;
- // $state->raw_unitgrade = 2 ;
- // echo "state
";print_r($state);echo "
";
- // echo "cmoptions
";print_r($cmoptions);echo "
";
- // echo "options
";print_r($options);echo "
";
- // echo " questionoptions
";print_r($question);echo "
";
/// This implementation is also used by question type 'numerical'
$readonly = empty($options->readonly) ? '' : 'readonly="readonly"';
$formatoptions = new stdClass;
@@ -266,7 +261,7 @@ class question_shortanswer_qtype extends default_questiontype {
return $status;
}
- /**
+ /**
* Prints the score obtained and maximum score available plus any penalty
* information
*
@@ -330,6 +325,13 @@ class question_shortanswer_qtype extends default_questiontype {
echo '';
// print grade for this submission
print_string('gradingdetails', 'quiz', $grade) ;
+ // A unit penalty for numerical was applied so display it
+ // a temporary solution for unit rendering in numerical
+ // waiting for the new question engine code for a permanent one
+ if(isset($state->options->raw_unitpenalty) && $state->options->raw_unitpenalty > 0.0 ){
+ echo ' ';
+ print_string('unitappliedpenalty','qtype_numerical',question_format_grade($cmoptions, $state->options->raw_unitpenalty ));
+ }
if ($cmoptions->penaltyscheme) {
// print details of grade adjustment due to penalties
if ($state->last_graded->raw_grade > $state->last_graded->grade){
@@ -340,11 +342,6 @@ class question_shortanswer_qtype extends default_questiontype {
// 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 unit penalty for numerical was applied so display it
- if(isset($this->raw_unitpenalty) && $this->raw_unitpenalty > 0.0 ){
- echo ' ';
- print_string('unitappliedpenalty','qtype_numerical',question_format_grade($cmoptions, $this->raw_unitpenalty));
- }
echo ' ' ;
print_string('gradingdetailspenalty', 'quiz', question_format_grade($cmoptions, $state->last_graded->penalty));
} else {