Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.
   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Tests of the upgrade to the new Moodle question engine for attempts at
  19   * truefalse questions.
  20   *
  21   * @package    qtype
  22   * @subpackage shortanswer
  23   * @copyright  2009 The Open University
  24   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  25   */
  26  
  27  
  28  defined('MOODLE_INTERNAL') || die();
  29  
  30  global $CFG;
  31  require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php');
  32  
  33  
  34  /**
  35   * Testing the upgrade of shortanswer question attempts.
  36   *
  37   * @copyright  2009 The Open University
  38   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  39   */
  40  class qtype_shortanswer_attempt_upgrader_test extends question_attempt_upgrader_test_base {
  41  
  42      public function test_shortanswer_deferredfeedback_history620() {
  43          $quiz = (object) array(
  44              'id' => '221',
  45              'course' => '187',
  46              'name' => 'Practice CTMA04',
  47              'intro' => 'This is the Practice CTMA04. Your mark for this CTMA <span style="font-style: italic">does not </span>contribute to your continuous assessment mark for B680.<br /><br />This CTMA covers material primarily in Books 10 and 11, however some of the questions may return to material you covered in Books 0 to 9. There are 100 questions in total.<br /><br />It is a function of this testing software that it cannot provide for every possible spelling error that you make. The onus is therefore on you, the student, to ensure that your spelling is correct. ',
  48              'introformat' => FORMAT_HTML,
  49              'questiondecimalpoints' => '-1',
  50              'showuserpicture' => '1',
  51              'showblocks' => '1',
  52              'timeopen' => '1178492400',
  53              'timeclose' => '1193875200',
  54              'preferredbehaviour' => 'deferredfeedback',
  55              'attempts' => '0',
  56              'attemptonlast' => '0',
  57              'grademethod' => '1',
  58              'decimalpoints' => '2',
  59              'review' => '71727591',
  60              'questionsperpage' => '1',
  61              'shufflequestions' => '0',
  62              'shuffleanswers' => '0',
  63              'sumgrades' => '100',
  64              'grade' => '100',
  65              'timecreated' => '0',
  66              'timemodified' => '1195232889',
  67              'password' => '',
  68              'subnet' => '',
  69              'popup' => '0',
  70              'delay1' => '0',
  71              'delay2' => '0',
  72              'timelimit' => '0',
  73          );
  74          $attempt = (object) array(
  75              'id' => '4025',
  76              'uniqueid' => '4025',
  77              'quiz' => '221',
  78              'userid' => '55568',
  79              'attempt' => '1',
  80              'sumgrades' => '30',
  81              'timestart' => '1178549306',
  82              'timefinish' => '1178641326',
  83              'timemodified' => '1178549306',
  84              'layout' => '4184,0,4185,0,4154,0,4186,0,4187,0,4188,0,4189,0,4190,0,4162,0,4191,0,4192,0,4193,0,4254,0,4195,0,4196,0,4163,0,4197,0,4198,0,4199,0,4164,0,4200,0,4165,0,4201,0,4202,0,4166,0,4203,0,4204,0,4205,0,4167,0,4155,0,4168,0,4206,0,4207,0,4208,0,4209,0,4210,0,4211,0,4212,0,4213,0,4214,0,4156,0,4215,0,4216,0,4217,0,4169,0,4170,0,4157,0,4218,0,4219,0,4220,0,4171,0,4221,0,4172,0,4222,0,4223,0,4224,0,4225,0,4226,0,4227,0,4228,0,4173,0,4229,0,4230,0,4231,0,4232,0,4174,0,4233,0,4234,0,4235,0,4236,0,4237,0,4238,0,4239,0,4240,0,4241,0,4242,0,4158,0,4243,0,4244,0,4245,0,4246,0,4159,0,4175,0,4247,0,4176,0,4248,0,4177,0,4160,0,4249,0,4178,0,4250,0,4161,0,4251,0,4179,0,4252,0,4180,0,4181,0,4182,0,4253,0,4183,0',
  85              'preview' => '0',
  86          );
  87          $question = (object) array(
  88              'id' => '4239',
  89              'category' => '204',
  90              'parent' => '0',
  91              'name' => '4hdP73 Book 11 Section 2.1 ignore unavoidable costs when analysing data',
  92              'questiontext' => 'Complete the following sentence.
  93   <p>In general, the procedures for analysing cost data for decision making are: </p>
  94   <p>Ignore all sunk costs, ignore all ______ costs, use remaining costs for decision making purposes. </p>',
  95              'questiontextformat' => '1',
  96              'defaultmark' => '1',
  97              'penalty' => '1',
  98              'qtype' => 'shortanswer',
  99              'length' => '1',
 100              'stamp' => 'learn.open.ac.uk+070417143728+6z2qbB',
 101              'version' => 'learn.open.ac.uk+070417143728+BJ8YOd',
 102              'hidden' => '0',
 103              'generalfeedback' => '',
 104              'generalfeedbackformat' => '1',
 105              'timecreated' => '0',
 106              'timemodified' => '0',
 107              'createdby' => null,
 108              'modifiedby' => null,
 109              'unlimited' => null,
 110              'maxmark' => '1',
 111              'options' => (object) array(
 112                  'answers' => array(
 113                      12944 => (object) array(
 114                          'question' => '4239',
 115                          'answer' => 'unavoidable*',
 116                          'fraction' => '1',
 117                          'feedback' => 'Yes, the correct answer is unavoidable costs. Well done! <p> Book 11 Section 2.1',
 118                          'id' => 12944,
 119                      ),
 120                      12945 => (object) array(
 121                          'question' => '4239',
 122                          'answer' => 'irrelevant*',
 123                          'fraction' => '1',
 124                          'feedback' => 'Yes, the correct answer is unavoidable (or \'irrelevant\') costs. Well done! <p> Book 11 Section 2.1',
 125                          'id' => 12945,
 126                      ),
 127                      12946 => (object) array(
 128                          'question' => '4239',
 129                          'answer' => 'comitte*',
 130                          'fraction' => '1',
 131                          'feedback' => 'Yes, the correct answer is unavoidable costs. Well done! <i> <p> Book 11 Section 2.1',
 132                          'id' => 12946,
 133                      ),
 134                      12947 => (object) array(
 135                          'question' => '4239',
 136                          'answer' => 'commite*',
 137                          'fraction' => '1',
 138                          'feedback' => 'Yes, the correct answer is unavoidable costs. Well done! <i> <p> Book 11 Section 2.1',
 139                          'id' => 12947,
 140                      ),
 141                      12948 => (object) array(
 142                          'question' => '4239',
 143                          'answer' => '*',
 144                          'fraction' => '0',
 145                          'feedback' => 'The correct answer is unavoidable costs. <p> Book 11 Section 2.1',
 146                          'id' => 12948,
 147                      ),
 148                  ),
 149                  'usecase' => '0',
 150              ),
 151              'hints' => false,
 152          );
 153          $qsession = (object) array(
 154              'id' => '39422',
 155              'attemptid' => '4025',
 156              'questionid' => '4239',
 157              'newest' => '94517',
 158              'newgraded' => '94517',
 159              'sumpenalty' => '1',
 160              'manualcomment' => '',
 161              'manualcommentformat' => '1',
 162              'flagged' => '1',
 163          );
 164          $qstates = array(
 165              92129 => (object) array(
 166                  'attempt' => '4025',
 167                  'question' => '4239',
 168                  'originalquestion' => '0',
 169                  'seq_number' => '0',
 170                  'answer' => '',
 171                  'timestamp' => '1178549306',
 172                  'event' => '0',
 173                  'grade' => '0',
 174                  'raw_grade' => '0',
 175                  'penalty' => '0',
 176                  'id' => 92129,
 177              ),
 178              94433 => (object) array(
 179                  'attempt' => '4025',
 180                  'question' => '4239',
 181                  'originalquestion' => '0',
 182                  'seq_number' => '1',
 183                  'answer' => 'irrelevant',
 184                  'timestamp' => '1178639607',
 185                  'event' => '2',
 186                  'grade' => '0',
 187                  'raw_grade' => '1',
 188                  'penalty' => '1',
 189                  'id' => 94433,
 190              ),
 191              94517 => (object) array(
 192                  'attempt' => '4025',
 193                  'question' => '4239',
 194                  'originalquestion' => '0',
 195                  'seq_number' => '2',
 196                  'answer' => 'irrelevant',
 197                  'timestamp' => '1178639607',
 198                  'event' => '6',
 199                  'grade' => '1',
 200                  'raw_grade' => '1',
 201                  'penalty' => '1',
 202                  'id' => 94517,
 203              ),
 204          );
 205  
 206          $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
 207  
 208          $expectedqa = (object) array(
 209              'behaviour' => 'deferredfeedback',
 210              'questionid' => 4239,
 211              'variant' => 1,
 212              'maxmark' => 1,
 213              'minfraction' => 0,
 214              'maxfraction' => 1,
 215              'flagged' => 0,
 216              'questionsummary' => "Complete the following sentence. \n\nIn general, the procedures for analysing cost data for decision making are:  \n\nIgnore all sunk costs, ignore all ______ costs, use remaining costs for decision making purposes.",
 217              'rightanswer' => 'unavoidable*',
 218              'responsesummary' => 'irrelevant',
 219              'timemodified' => 1178639607,
 220              'steps' => array(
 221                  0 => (object) array(
 222                      'sequencenumber' => 0,
 223                      'state' => 'todo',
 224                      'fraction' => null,
 225                      'timecreated' => 1178549306,
 226                      'userid' => 55568,
 227                      'data' => array(),
 228                  ),
 229                  1 => (object) array(
 230                      'sequencenumber' => 1,
 231                      'state' => 'complete',
 232                      'fraction' => null,
 233                      'timecreated' => 1178639607,
 234                      'userid' => 55568,
 235                      'data' => array('answer' => 'irrelevant'),
 236                  ),
 237                  2 => (object) array(
 238                      'sequencenumber' => 2,
 239                      'state' => 'gradedright',
 240                      'fraction' => 1,
 241                      'timecreated' => 1178639607,
 242                      'userid' => 55568,
 243                      'data' => array('answer' => 'irrelevant', '-finish' => 1),
 244                  ),
 245              ),
 246          );
 247  
 248          $this->compare_qas($expectedqa, $qa);
 249      }
 250  
 251      public function test_shortanswer_deferredfeedback_history60() {
 252          $quiz = (object) array(
 253              'id' => '789',
 254              'course' => '3500',
 255              'name' => 'Modes of integration quiz',
 256              'intro' => '<p><font size="2">Use this quiz to test your knowledge of when you have completed <span style="font-style: italic">Modes of Integration</span>.</font> </p>
 257          <p><font size="2">This quiz is for your information only, the results will not be used as part of the work based activity. </font></p>',
 258              'introformat' => FORMAT_HTML,
 259              'questiondecimalpoints' => '-1',
 260              'showuserpicture' => '1',
 261              'showblocks' => '1',
 262              'timeopen' => '1147960800',
 263              'timeclose' => '1233414000',
 264              'preferredbehaviour' => 'deferredfeedback',
 265              'attempts' => '0',
 266              'attemptonlast' => '0',
 267              'grademethod' => '1',
 268              'decimalpoints' => '2',
 269              'review' => '71760879',
 270              'questionsperpage' => '0',
 271              'shufflequestions' => '1',
 272              'shuffleanswers' => '1',
 273              'sumgrades' => '5',
 274              'grade' => '5',
 275              'timecreated' => '0',
 276              'timemodified' => '1191939532',
 277              'password' => '',
 278              'subnet' => '',
 279              'popup' => '0',
 280              'delay1' => '0',
 281              'delay2' => '0',
 282              'timelimit' => '0',
 283          );
 284          $attempt = (object) array(
 285              'id' => '17778',
 286              'uniqueid' => '17778',
 287              'quiz' => '789',
 288              'userid' => '111471',
 289              'attempt' => '1',
 290              'sumgrades' => '4.6',
 291              'timestart' => '1161205933',
 292              'timefinish' => '1161206024',
 293              'timemodified' => '1161206024',
 294              'layout' => '10219,10220,10216,10217,10218,0',
 295              'preview' => '0',
 296          );
 297          $question = (object) array(
 298              'id' => '10216',
 299              'category' => '528',
 300              'parent' => '0',
 301              'name' => 'Q2',
 302              'questiontext' => '<font size="2">In information-oriented integration what is the document which describes all the data structures in a potential integrated system and their relationships, for example, the fact that one database contained on a server will consist of a subset of another database contained in another server?</font>',
 303              'questiontextformat' => '1',
 304              'defaultmark' => '1',
 305              'penalty' => '0.1',
 306              'qtype' => 'shortanswer',
 307              'length' => '1',
 308              'stamp' => 'vledemo.open.ac.uk+060512111049+aApRic',
 309              'version' => 'vledemo.open.ac.uk+060719152101+aydsEU',
 310              'hidden' => '0',
 311              'generalfeedback' => '',
 312              'generalfeedbackformat' => '1',
 313              'timecreated' => '0',
 314              'timemodified' => '0',
 315              'createdby' => null,
 316              'modifiedby' => null,
 317              'unlimited' => null,
 318              'maxmark' => '1',
 319              'options' => (object) array(
 320                  'answers' => array(
 321                      31846 => (object) array(
 322                          'question' => '10216',
 323                          'answer' => '*Enterprise data model*',
 324                          'fraction' => '1',
 325                          'feedback' => 'It is the \'Enterprise data model\'.',
 326                          'id' => 31846,
 327                      ),
 328                      31847 => (object) array(
 329                          'question' => '10216',
 330                          'answer' => '*Enterprise*',
 331                          'fraction' => '0.8',
 332                          'feedback' => 'It is the \'Enterprise data model\'.',
 333                          'id' => 31847,
 334                      ),
 335                      31848 => (object) array(
 336                          'question' => '10216',
 337                          'answer' => '*',
 338                          'fraction' => '0',
 339                          'feedback' => 'It is the \'Enterprise data model\'.',
 340                          'id' => 31848,
 341                      ),
 342                  ),
 343                  'usecase' => '0',
 344              ),
 345              'hints' => false,
 346          );
 347          $qsession = (object) array(
 348              'id' => '283784',
 349              'attemptid' => '17778',
 350              'questionid' => '10216',
 351              'newest' => '677550',
 352              'newgraded' => '677550',
 353              'sumpenalty' => '0',
 354              'manualcomment' => '',
 355              'manualcommentformat' => '1',
 356              'flagged' => '1',
 357          );
 358          $qstates = array(
 359              677543 => (object) array(
 360                  'attempt' => '17778',
 361                  'question' => '10216',
 362                  'originalquestion' => '0',
 363                  'seq_number' => '0',
 364                  'answer' => '',
 365                  'timestamp' => '1161205933',
 366                  'event' => '0',
 367                  'grade' => '0',
 368                  'raw_grade' => '0',
 369                  'penalty' => '0',
 370                  'id' => 677543,
 371              ),
 372              677550 => (object) array(
 373                  'attempt' => '17778',
 374                  'question' => '10216',
 375                  'originalquestion' => '0',
 376                  'seq_number' => '1',
 377                  'answer' => 'enterprise data dictionary',
 378                  'timestamp' => '1161206024',
 379                  'event' => '6',
 380                  'grade' => '0.8',
 381                  'raw_grade' => '0.8',
 382                  'penalty' => '0.1',
 383                  'id' => 677550,
 384              ),
 385          );
 386  
 387          $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
 388  
 389          $expectedqa = (object) array(
 390              'behaviour' => 'deferredfeedback',
 391              'questionid' => 10216,
 392              'variant' => 1,
 393              'maxmark' => 1,
 394              'minfraction' => 0,
 395              'maxfraction' => 1,
 396              'flagged' => 0,
 397              'questionsummary' => 'In information-oriented integration what is the document which describes all the data structures in a potential integrated system and their relationships, for example, the fact that one database contained on a server will consist of a subset of another database contained in another server?',
 398              'rightanswer' => '*Enterprise data model*',
 399              'responsesummary' => 'enterprise data dictionary',
 400              'timemodified' => 1161206024,
 401              'steps' => array(
 402                  0 => (object) array(
 403                      'sequencenumber' => 0,
 404                      'state' => 'todo',
 405                      'fraction' => null,
 406                      'timecreated' => 1161205933,
 407                      'userid' => 111471,
 408                      'data' => array(),
 409                  ),
 410                  1 => (object) array(
 411                      'sequencenumber' => 1,
 412                      'state' => 'gradedpartial',
 413                      'fraction' => 0.8,
 414                      'timecreated' => 1161206024,
 415                      'userid' => 111471,
 416                      'data' => array('answer' => 'enterprise data dictionary', '-finish' => 1),
 417                  ),
 418              ),
 419          );
 420  
 421          $this->compare_qas($expectedqa, $qa);
 422      }
 423  
 424      public function test_shortanswer_deferredfeedback_history3220() {
 425          $quiz = (object) array(
 426              'id' => '221',
 427              'course' => '187',
 428              'name' => 'Practice CTMA04',
 429              'intro' => 'This is the Practice CTMA04. Your mark for this CTMA <span style="font-style: italic">does not </span>contribute to your continuous assessment mark for B680.<br /><br />This CTMA covers material primarily in Books 10 and 11, however some of the questions may return to material you covered in Books 0 to 9. There are 100 questions in total.<br /><br />It is a function of this testing software that it cannot provide for every possible spelling error that you make. The onus is therefore on you, the student, to ensure that your spelling is correct. ',
 430              'introformat' => FORMAT_HTML,
 431              'questiondecimalpoints' => '-1',
 432              'showuserpicture' => '1',
 433              'showblocks' => '1',
 434              'timeopen' => '1178492400',
 435              'timeclose' => '1193875200',
 436              'preferredbehaviour' => 'deferredfeedback',
 437              'attempts' => '0',
 438              'attemptonlast' => '0',
 439              'grademethod' => '1',
 440              'decimalpoints' => '2',
 441              'review' => '71727591',
 442              'questionsperpage' => '1',
 443              'shufflequestions' => '0',
 444              'shuffleanswers' => '0',
 445              'sumgrades' => '100',
 446              'grade' => '100',
 447              'timecreated' => '0',
 448              'timemodified' => '1195232889',
 449              'password' => '',
 450              'subnet' => '',
 451              'popup' => '0',
 452              'delay1' => '0',
 453              'delay2' => '0',
 454              'timelimit' => '0',
 455          );
 456          $attempt = (object) array(
 457              'id' => '4058',
 458              'uniqueid' => '4058',
 459              'quiz' => '221',
 460              'userid' => '83485',
 461              'attempt' => '1',
 462              'sumgrades' => '19',
 463              'timestart' => '1178636138',
 464              'timefinish' => '1178874880',
 465              'timemodified' => '1178636138',
 466              'layout' => '4184,0,4185,0,4154,0,4186,0,4187,0,4188,0,4189,0,4190,0,4162,0,4191,0,4192,0,4193,0,4254,0,4195,0,4196,0,4163,0,4197,0,4198,0,4199,0,4164,0,4200,0,4165,0,4201,0,4202,0,4166,0,4203,0,4204,0,4205,0,4167,0,4155,0,4168,0,4206,0,4207,0,4208,0,4209,0,4210,0,4211,0,4212,0,4213,0,4214,0,4156,0,4215,0,4216,0,4217,0,4169,0,4170,0,4157,0,4218,0,4219,0,4220,0,4171,0,4221,0,4172,0,4222,0,4223,0,4224,0,4225,0,4226,0,4227,0,4228,0,4173,0,4229,0,4230,0,4231,0,4232,0,4174,0,4233,0,4234,0,4235,0,4236,0,4237,0,4238,0,4239,0,4240,0,4241,0,4242,0,4158,0,4243,0,4244,0,4245,0,4246,0,4159,0,4175,0,4247,0,4176,0,4248,0,4177,0,4160,0,4249,0,4178,0,4250,0,4161,0,4251,0,4179,0,4252,0,4180,0,4181,0,4182,0,4253,0,4183,0',
 467              'preview' => '0',
 468          );
 469          $question = (object) array(
 470              'id' => '4184',
 471              'category' => '204',
 472              'parent' => '0',
 473              'name' => '4abP1 Book 11 Section 3.1 capit invest appraisal defn',
 474              'questiontext' => 'Complete the following sentence by providing an appropriate word for the indicated gap.
 475   <p>Capital investment appraisal involves both quantitative and ______ issues. </p>',
 476              'questiontextformat' => '1',
 477              'defaultmark' => '1',
 478              'penalty' => '1',
 479              'qtype' => 'shortanswer',
 480              'length' => '1',
 481              'stamp' => 'learn.open.ac.uk+070417143727+tO4yGs',
 482              'version' => 'learn.open.ac.uk+070417143727+fieanX',
 483              'hidden' => '0',
 484              'generalfeedback' => '',
 485              'generalfeedbackformat' => '1',
 486              'timecreated' => '0',
 487              'timemodified' => '0',
 488              'createdby' => null,
 489              'modifiedby' => null,
 490              'unlimited' => null,
 491              'maxmark' => '1',
 492              'options' => (object) array(
 493                  'answers' => array(
 494                      12768 => (object) array(
 495                          'question' => '4184',
 496                          'answer' => 'qualitative*',
 497                          'fraction' => '1',
 498                          'feedback' => 'Yes, the correct answer is qualitative issues. Well done! <p> Book 11 Section 3.1',
 499                          'id' => 12768,
 500                      ),
 501                      12769 => (object) array(
 502                          'question' => '4184',
 503                          'answer' => 'qual*tat*ve*',
 504                          'fraction' => '1',
 505                          'feedback' => 'Yes, the correct answer is qualitative issues. Well done! <i>(but watch your spelling!)</i> <p> Book 11 Section 3.1',
 506                          'id' => 12769,
 507                      ),
 508                      12770 => (object) array(
 509                          'question' => '4184',
 510                          'answer' => '*',
 511                          'fraction' => '0',
 512                          'feedback' => 'The correct answer is qualitative issues. <p> Book 11 Section 3.1',
 513                          'id' => 12770,
 514                      ),
 515                  ),
 516                  'usecase' => '0',
 517              ),
 518              'hints' => false,
 519          );
 520          $qsession = (object) array(
 521              'id' => '40854',
 522              'attemptid' => '4058',
 523              'questionid' => '4184',
 524              'newest' => '100733',
 525              'newgraded' => '100733',
 526              'sumpenalty' => '1',
 527              'manualcomment' => '',
 528              'manualcommentformat' => '1',
 529              'flagged' => '1',
 530          );
 531          $qstates = array(
 532              94330 => (object) array(
 533                  'attempt' => '4058',
 534                  'question' => '4184',
 535                  'originalquestion' => '0',
 536                  'seq_number' => '0',
 537                  'answer' => '',
 538                  'timestamp' => '1178636138',
 539                  'event' => '0',
 540                  'grade' => '0',
 541                  'raw_grade' => '0',
 542                  'penalty' => '0',
 543                  'id' => 94330,
 544              ),
 545              94415 => (object) array(
 546                  'attempt' => '4058',
 547                  'question' => '4184',
 548                  'originalquestion' => '0',
 549                  'seq_number' => '1',
 550                  'answer' => 'qualitative',
 551                  'timestamp' => '1178636171',
 552                  'event' => '2',
 553                  'grade' => '0',
 554                  'raw_grade' => '1',
 555                  'penalty' => '1',
 556                  'id' => 94415,
 557              ),
 558              100142 => (object) array(
 559                  'attempt' => '4058',
 560                  'question' => '4184',
 561                  'originalquestion' => '0',
 562                  'seq_number' => '2',
 563                  'answer' => 'subjective',
 564                  'timestamp' => '1178825180',
 565                  'event' => '2',
 566                  'grade' => '0',
 567                  'raw_grade' => '0',
 568                  'penalty' => '1',
 569                  'id' => 100142,
 570              ),
 571              100733 => (object) array(
 572                  'attempt' => '4058',
 573                  'question' => '4184',
 574                  'originalquestion' => '0',
 575                  'seq_number' => '3',
 576                  'answer' => 'subjective',
 577                  'timestamp' => '1178825180',
 578                  'event' => '3',
 579                  'grade' => '0',
 580                  'raw_grade' => '0',
 581                  'penalty' => '1',
 582                  'id' => 100733,
 583              ),
 584          );
 585  
 586          $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
 587  
 588          $expectedqa = (object) array(
 589              'behaviour' => 'deferredfeedback',
 590              'questionid' => 4184,
 591              'variant' => 1,
 592              'maxmark' => 1,
 593              'minfraction' => 0,
 594              'maxfraction' => 1,
 595              'flagged' => 0,
 596              'questionsummary' => "Complete the following sentence by providing an appropriate word for the indicated gap. \n\nCapital investment appraisal involves both quantitative and ______ issues.",
 597              'rightanswer' => 'qualitative*',
 598              'responsesummary' => 'subjective',
 599              'timemodified' => 1178825180,
 600              'steps' => array(
 601                  0 => (object) array(
 602                      'sequencenumber' => 0,
 603                      'state' => 'todo',
 604                      'fraction' => null,
 605                      'timecreated' => 1178636138,
 606                      'userid' => 83485,
 607                      'data' => array(),
 608                  ),
 609                  1 => (object) array(
 610                      'sequencenumber' => 1,
 611                      'state' => 'complete',
 612                      'fraction' => null,
 613                      'timecreated' => 1178636171,
 614                      'userid' => 83485,
 615                      'data' => array('answer' => 'qualitative'),
 616                  ),
 617                  2 => (object) array(
 618                      'sequencenumber' => 2,
 619                      'state' => 'complete',
 620                      'fraction' => null,
 621                      'timecreated' => 1178825180,
 622                      'userid' => 83485,
 623                      'data' => array('answer' => 'subjective'),
 624                  ),
 625                  3 => (object) array(
 626                      'sequencenumber' => 3,
 627                      'state' => 'gradedwrong',
 628                      'fraction' => 0,
 629                      'timecreated' => 1178825180,
 630                      'userid' => 83485,
 631                      'data' => array('answer' => 'subjective', '-finish' => 1),
 632                  ),
 633              ),
 634          );
 635  
 636          $this->compare_qas($expectedqa, $qa);
 637      }
 638  }