Skip to content

Commit

Permalink
MDL-34483 qformat_examview: handle more questions.
Browse files Browse the repository at this point in the history
These fixes come from testing with the example file supplied by Rick
Jerz.
  • Loading branch information
Jean-Michel Vedrine authored and timhunt committed Jul 27, 2012
1 parent 0940ba1 commit e3f79e9
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions question/format/examview/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ class qformat_examview extends qformat_default {
'mtf' => 99,
'nr' => NUMERICAL,
'pr' => 99,
'es' => 99,
'es' => ESSAY,
'ca' => 99,
'ot' => 99,
'sa' => ESSAY
'sa' => SHORTANSWER
);

public $matching_questions = array();
Expand Down Expand Up @@ -113,7 +113,7 @@ protected function parse_matching_groups($matching_groups) {
return;
}
foreach ($matching_groups as $match_group) {
$newgroup = null;
$newgroup = new stdClass();
$groupname = trim($match_group['@']['name']);
$questiontext = $this->unxmlise($match_group['#']['text'][0]['#']);
$newgroup->questiontext = trim($questiontext);
Expand All @@ -136,7 +136,7 @@ protected function parse_ma($qrec, $groupname) {
$phrase = trim($this->unxmlise($qrec['text']['0']['#']));
$answer = trim($this->unxmlise($qrec['answer']['0']['#']));
$answer = strip_tags( $answer );
$match_group->subquestions[] = $this->text_field($phrase);
$match_group->subquestions[] = $phrase;
$match_group->subanswers[] = $match_group->subchoices[$answer];
$this->matching_questions[$groupname] = $match_group;
return null;
Expand All @@ -159,7 +159,7 @@ protected function process_matches(&$questions) {
$question->subanswers = array();
foreach ($match_group->subquestions as $key => $value) {
$htmltext = s($value);
$question->subquestions[] = $htmltext;
$question->subquestions[] = $this->text_field($htmltext);

$htmltext = s($match_group->subanswers[$key]);
$question->subanswers[] = $htmltext;
Expand Down Expand Up @@ -231,7 +231,7 @@ public function readquestion($qrec) {
$question = $this->parse_co($qrec['#'], $question);
break;
case ESSAY:
$question = $this->parse_sa($qrec['#'], $question);
$question = $this->parse_es($qrec['#'], $question);
break;
case NUMERICAL:
$question = $this->parse_nr($qrec['#'], $question);
Expand Down Expand Up @@ -298,9 +298,13 @@ protected function parse_co($qrec, $question) {
return $question;
}

protected function parse_sa($qrec, $question) {
protected function parse_es($qrec, $question) {
$feedback = trim($this->unxmlise($qrec['answer'][0]['#']));
$question->graderinfo = $this->text_field($feedback);
$question->feedback = $feedback;
$question->responseformat = 'editor';
$question->responsefieldlines = 15;
$question->attachments = 0;
$question->fraction = 0;
return $question;
}
Expand All @@ -317,8 +321,7 @@ protected function parse_nr($qrec, $question) {
$question->answer[$key] = $value;
$question->fraction[$key] = 1;
$question->feedback[$key] = $this->text_field("Correct");
$question->min[$key] = $question->answer[$key] - $errormargin;
$question->max[$key] = $question->answer[$key] + $errormargin;
$question->tolerance[$key] = $errormargin;
}
}
return $question;
Expand Down

0 comments on commit e3f79e9

Please sign in to comment.