Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-34483 qformat_examview: handle more questions.

These fixes come from testing with the example file supplied by Rick
Jerz.
  • Loading branch information...
commit e3f79e93474bfbb98b51e2b8933ed3632e905f67 1 parent 0940ba1
Jean-Michel Vedrine authored timhunt committed
Showing with 12 additions and 9 deletions.
  1. +12 −9 question/format/examview/format.php
View
21 question/format/examview/format.php
@@ -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();
@@ -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);
@@ -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;
@@ -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;
@@ -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);
@@ -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;
}
@@ -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;
Please sign in to comment.
Something went wrong with that request. Please try again.