Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

correcting display of datasetitems_form for multiple answers

  • Loading branch information...
commit ff04b09e916025dc15003947fd6454e9a2856e67 1 parent d10e19d
pichetp authored
Showing with 18 additions and 12 deletions.
  1. +18 −12 question/type/calculated/questiontype.php
View
30 question/type/calculated/questiontype.php
@@ -354,8 +354,11 @@ function print_question_formulation_and_controls(&$question, &$state, $cmoptions
// Substitute variables in questiontext before giving the data to the
// virtual type for printing
$virtualqtype = $this->get_virtual_qtype();
- $unit = $virtualqtype->get_default_numerical_unit($question);
-
+ if($unit = $virtualqtype->get_default_numerical_unit($question)){
+ $unit = $unit->unit;
+ } else {
+ $unit = '';
+ }
// We modify the question to look like a numerical question
$numericalquestion = fullclone($question);
foreach ($numericalquestion->options->answers as $key => $answer) {
@@ -363,7 +366,7 @@ function print_question_formulation_and_controls(&$question, &$state, $cmoptions
$correctanswer = qtype_calculated_calculate_answer(
$answer->answer, $state->options->dataset, $answer->tolerance,
$answer->tolerancetype, $answer->correctanswerlength,
- $answer->correctanswerformat, $unit->unit);
+ $answer->correctanswerformat, $unit);
$numericalquestion->options->answers[$key]->answer = $correctanswer->answer;
}
$numericalquestion->questiontext = parent::substitute_variables(
@@ -700,7 +703,6 @@ function generate_dataset_item($options) {
function comment_header($question) {
//$this->get_question_options($question);
- global $SESSION;
$strheader = '';
$delimiter = '';
@@ -712,7 +714,7 @@ function comment_header($question) {
} else {
$strheader .= $delimiter.$answer->answer;
}
- $delimiter = ',';
+ $delimiter = '<br/><br/>';
}
return $strheader;
}
@@ -749,15 +751,15 @@ function comment_on_datasetitems($question, $data, $number) {
$virtualqtype->get_tolerance_interval($calculated);
if ($calculated->min === '') {
// This should mean that something is wrong
- $errors .= " -$calculated->answer";
- $stranswers .= $delimiter;
+ $stranswers .= " -$calculated->answer".'<br/><br/>';
} else {
$stranswers .= $formula.' = '.$calculated->answer. '<br/>';
- $strmin .= $delimiter.$calculated->min;
- $strmax .= $delimiter.$calculated->max;
+ $stranswers .= $strmin. $delimiter.$calculated->min.'---';
+ $stranswers .= $strmax.$delimiter.$calculated->max;
+ $stranswers .='<br/>';
}
}
- return "$stranswers$strmin<br/>$strmax<br/>$errors";
+ return "$stranswers";
}
function tolerance_types() {
@@ -814,13 +816,17 @@ function construct_dataset_menus($form, $mandatorydatasets,
function get_correct_responses(&$question, &$state) {
$virtualqtype = $this->get_virtual_qtype();
- $unit = $virtualqtype->get_default_numerical_unit($question);
+ if($unit = $virtualqtype->get_default_numerical_unit($question)){
+ $unit = $unit->unit;
+ } else {
+ $unit = '';
+ }
foreach ($question->options->answers as $answer) {
if (((int) $answer->fraction) === 1) {
$answernumerical = qtype_calculated_calculate_answer(
$answer->answer, $state->options->dataset, $answer->tolerance,
$answer->tolerancetype, $answer->correctanswerlength,
- $answer->correctanswerformat, $unit->unit);
+ $answer->correctanswerformat, $unit);
return array('' => $answernumerical->answer);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.