Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is 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  namespace qtype_shortanswer;
  18  
  19  defined('MOODLE_INTERNAL') || die();
  20  
  21  global $CFG;
  22  require_once($CFG->dirroot . '/question/engine/upgrade/tests/helper.php');
  23  
  24  
  25  /**
  26   * Testing the upgrade of shortanswer question attempts.
  27   *
  28   * @package    qtype_shortanswer
  29   * @copyright  2009 The Open University
  30   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  31   */
  32  class upgrade_old_attempt_data_test extends \question_attempt_upgrader_test_base {
  33  
  34      public function test_shortanswer_deferredfeedback_history620() {
  35          $quiz = (object) array(
  36              'id' => '221',
  37              'course' => '187',
  38              'name' => 'Practice CTMA04',
  39              '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. ',
  40              'introformat' => FORMAT_HTML,
  41              'questiondecimalpoints' => '-1',
  42              'showuserpicture' => '1',
  43              'showblocks' => '1',
  44              'timeopen' => '1178492400',
  45              'timeclose' => '1193875200',
  46              'preferredbehaviour' => 'deferredfeedback',
  47              'attempts' => '0',
  48              'attemptonlast' => '0',
  49              'grademethod' => '1',
  50              'decimalpoints' => '2',
  51              'review' => '71727591',
  52              'questionsperpage' => '1',
  53              'shufflequestions' => '0',
  54              'shuffleanswers' => '0',
  55              'sumgrades' => '100',
  56              'grade' => '100',
  57              'timecreated' => '0',
  58              'timemodified' => '1195232889',
  59              'password' => '',
  60              'subnet' => '',
  61              'popup' => '0',
  62              'delay1' => '0',
  63              'delay2' => '0',
  64              'timelimit' => '0',
  65          );
  66          $attempt = (object) array(
  67              'id' => '4025',
  68              'uniqueid' => '4025',
  69              'quiz' => '221',
  70              'userid' => '55568',
  71              'attempt' => '1',
  72              'sumgrades' => '30',
  73              'timestart' => '1178549306',
  74              'timefinish' => '1178641326',
  75              'timemodified' => '1178549306',
  76              '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',
  77              'preview' => '0',
  78          );
  79          $question = (object) array(
  80              'id' => '4239',
  81              'category' => '204',
  82              'parent' => '0',
  83              'name' => '4hdP73 Book 11 Section 2.1 ignore unavoidable costs when analysing data',
  84              'questiontext' => 'Complete the following sentence.
  85   <p>In general, the procedures for analysing cost data for decision making are: </p>
  86   <p>Ignore all sunk costs, ignore all ______ costs, use remaining costs for decision making purposes. </p>',
  87              'questiontextformat' => '1',
  88              'defaultmark' => '1',
  89              'penalty' => '1',
  90              'qtype' => 'shortanswer',
  91              'length' => '1',
  92              'stamp' => 'learn.open.ac.uk+070417143728+6z2qbB',
  93              'version' => 'learn.open.ac.uk+070417143728+BJ8YOd',
  94              'hidden' => '0',
  95              'generalfeedback' => '',
  96              'generalfeedbackformat' => '1',
  97              'timecreated' => '0',
  98              'timemodified' => '0',
  99              'createdby' => null,
 100              'modifiedby' => null,
 101              'unlimited' => null,
 102              'maxmark' => '1',
 103              'options' => (object) array(
 104                  'answers' => array(
 105                      12944 => (object) array(
 106                          'question' => '4239',
 107                          'answer' => 'unavoidable*',
 108                          'fraction' => '1',
 109                          'feedback' => 'Yes, the correct answer is unavoidable costs. Well done! <p> Book 11 Section 2.1',
 110                          'id' => 12944,
 111                      ),
 112                      12945 => (object) array(
 113                          'question' => '4239',
 114                          'answer' => 'irrelevant*',
 115                          'fraction' => '1',
 116                          'feedback' => 'Yes, the correct answer is unavoidable (or \'irrelevant\') costs. Well done! <p> Book 11 Section 2.1',
 117                          'id' => 12945,
 118                      ),
 119                      12946 => (object) array(
 120                          'question' => '4239',
 121                          'answer' => 'comitte*',
 122                          'fraction' => '1',
 123                          'feedback' => 'Yes, the correct answer is unavoidable costs. Well done! <i> <p> Book 11 Section 2.1',
 124                          'id' => 12946,
 125                      ),
 126                      12947 => (object) array(
 127                          'question' => '4239',
 128                          'answer' => 'commite*',
 129                          'fraction' => '1',
 130                          'feedback' => 'Yes, the correct answer is unavoidable costs. Well done! <i> <p> Book 11 Section 2.1',
 131                          'id' => 12947,
 132                      ),
 133                      12948 => (object) array(
 134                          'question' => '4239',
 135                          'answer' => '*',
 136                          'fraction' => '0',
 137                          'feedback' => 'The correct answer is unavoidable costs. <p> Book 11 Section 2.1',
 138                          'id' => 12948,
 139                      ),
 140                  ),
 141                  'usecase' => '0',
 142              ),
 143              'hints' => false,
 144          );
 145          $qsession = (object) array(
 146              'id' => '39422',
 147              'attemptid' => '4025',
 148              'questionid' => '4239',
 149              'newest' => '94517',
 150              'newgraded' => '94517',
 151              'sumpenalty' => '1',
 152              'manualcomment' => '',
 153              'manualcommentformat' => '1',
 154              'flagged' => '1',
 155          );
 156          $qstates = array(
 157              92129 => (object) array(
 158                  'attempt' => '4025',
 159                  'question' => '4239',
 160                  'originalquestion' => '0',
 161                  'seq_number' => '0',
 162                  'answer' => '',
 163                  'timestamp' => '1178549306',
 164                  'event' => '0',
 165                  'grade' => '0',
 166                  'raw_grade' => '0',
 167                  'penalty' => '0',
 168                  'id' => 92129,
 169              ),
 170              94433 => (object) array(
 171                  'attempt' => '4025',
 172                  'question' => '4239',
 173                  'originalquestion' => '0',
 174                  'seq_number' => '1',
 175                  'answer' => 'irrelevant',
 176                  'timestamp' => '1178639607',
 177                  'event' => '2',
 178                  'grade' => '0',
 179                  'raw_grade' => '1',
 180                  'penalty' => '1',
 181                  'id' => 94433,
 182              ),
 183              94517 => (object) array(
 184                  'attempt' => '4025',
 185                  'question' => '4239',
 186                  'originalquestion' => '0',
 187                  'seq_number' => '2',
 188                  'answer' => 'irrelevant',
 189                  'timestamp' => '1178639607',
 190                  'event' => '6',
 191                  'grade' => '1',
 192                  'raw_grade' => '1',
 193                  'penalty' => '1',
 194                  'id' => 94517,
 195              ),
 196          );
 197  
 198          $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
 199  
 200          $expectedqa = (object) array(
 201              'behaviour' => 'deferredfeedback',
 202              'questionid' => 4239,
 203              'variant' => 1,
 204              'maxmark' => 1,
 205              'minfraction' => 0,
 206              'maxfraction' => 1,
 207              'flagged' => 0,
 208              '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.",
 209              'rightanswer' => 'unavoidable*',
 210              'responsesummary' => 'irrelevant',
 211              'timemodified' => 1178639607,
 212              'steps' => array(
 213                  0 => (object) array(
 214                      'sequencenumber' => 0,
 215                      'state' => 'todo',
 216                      'fraction' => null,
 217                      'timecreated' => 1178549306,
 218                      'userid' => 55568,
 219                      'data' => array(),
 220                  ),
 221                  1 => (object) array(
 222                      'sequencenumber' => 1,
 223                      'state' => 'complete',
 224                      'fraction' => null,
 225                      'timecreated' => 1178639607,
 226                      'userid' => 55568,
 227                      'data' => array('answer' => 'irrelevant'),
 228                  ),
 229                  2 => (object) array(
 230                      'sequencenumber' => 2,
 231                      'state' => 'gradedright',
 232                      'fraction' => 1,
 233                      'timecreated' => 1178639607,
 234                      'userid' => 55568,
 235                      'data' => array('answer' => 'irrelevant', '-finish' => 1),
 236                  ),
 237              ),
 238          );
 239  
 240          $this->compare_qas($expectedqa, $qa);
 241      }
 242  
 243      public function test_shortanswer_deferredfeedback_history60() {
 244          $quiz = (object) array(
 245              'id' => '789',
 246              'course' => '3500',
 247              'name' => 'Modes of integration quiz',
 248              '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>
 249          <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>',
 250              'introformat' => FORMAT_HTML,
 251              'questiondecimalpoints' => '-1',
 252              'showuserpicture' => '1',
 253              'showblocks' => '1',
 254              'timeopen' => '1147960800',
 255              'timeclose' => '1233414000',
 256              'preferredbehaviour' => 'deferredfeedback',
 257              'attempts' => '0',
 258              'attemptonlast' => '0',
 259              'grademethod' => '1',
 260              'decimalpoints' => '2',
 261              'review' => '71760879',
 262              'questionsperpage' => '0',
 263              'shufflequestions' => '1',
 264              'shuffleanswers' => '1',
 265              'sumgrades' => '5',
 266              'grade' => '5',
 267              'timecreated' => '0',
 268              'timemodified' => '1191939532',
 269              'password' => '',
 270              'subnet' => '',
 271              'popup' => '0',
 272              'delay1' => '0',
 273              'delay2' => '0',
 274              'timelimit' => '0',
 275          );
 276          $attempt = (object) array(
 277              'id' => '17778',
 278              'uniqueid' => '17778',
 279              'quiz' => '789',
 280              'userid' => '111471',
 281              'attempt' => '1',
 282              'sumgrades' => '4.6',
 283              'timestart' => '1161205933',
 284              'timefinish' => '1161206024',
 285              'timemodified' => '1161206024',
 286              'layout' => '10219,10220,10216,10217,10218,0',
 287              'preview' => '0',
 288          );
 289          $question = (object) array(
 290              'id' => '10216',
 291              'category' => '528',
 292              'parent' => '0',
 293              'name' => 'Q2',
 294              '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>',
 295              'questiontextformat' => '1',
 296              'defaultmark' => '1',
 297              'penalty' => '0.1',
 298              'qtype' => 'shortanswer',
 299              'length' => '1',
 300              'stamp' => 'vledemo.open.ac.uk+060512111049+aApRic',
 301              'version' => 'vledemo.open.ac.uk+060719152101+aydsEU',
 302              'hidden' => '0',
 303              'generalfeedback' => '',
 304              'generalfeedbackformat' => '1',
 305              'timecreated' => '0',
 306              'timemodified' => '0',
 307              'createdby' => null,
 308              'modifiedby' => null,
 309              'unlimited' => null,
 310              'maxmark' => '1',
 311              'options' => (object) array(
 312                  'answers' => array(
 313                      31846 => (object) array(
 314                          'question' => '10216',
 315                          'answer' => '*Enterprise data model*',
 316                          'fraction' => '1',
 317                          'feedback' => 'It is the \'Enterprise data model\'.',
 318                          'id' => 31846,
 319                      ),
 320                      31847 => (object) array(
 321                          'question' => '10216',
 322                          'answer' => '*Enterprise*',
 323                          'fraction' => '0.8',
 324                          'feedback' => 'It is the \'Enterprise data model\'.',
 325                          'id' => 31847,
 326                      ),
 327                      31848 => (object) array(
 328                          'question' => '10216',
 329                          'answer' => '*',
 330                          'fraction' => '0',
 331                          'feedback' => 'It is the \'Enterprise data model\'.',
 332                          'id' => 31848,
 333                      ),
 334                  ),
 335                  'usecase' => '0',
 336              ),
 337              'hints' => false,
 338          );
 339          $qsession = (object) array(
 340              'id' => '283784',
 341              'attemptid' => '17778',
 342              'questionid' => '10216',
 343              'newest' => '677550',
 344              'newgraded' => '677550',
 345              'sumpenalty' => '0',
 346              'manualcomment' => '',
 347              'manualcommentformat' => '1',
 348              'flagged' => '1',
 349          );
 350          $qstates = array(
 351              677543 => (object) array(
 352                  'attempt' => '17778',
 353                  'question' => '10216',
 354                  'originalquestion' => '0',
 355                  'seq_number' => '0',
 356                  'answer' => '',
 357                  'timestamp' => '1161205933',
 358                  'event' => '0',
 359                  'grade' => '0',
 360                  'raw_grade' => '0',
 361                  'penalty' => '0',
 362                  'id' => 677543,
 363              ),
 364              677550 => (object) array(
 365                  'attempt' => '17778',
 366                  'question' => '10216',
 367                  'originalquestion' => '0',
 368                  'seq_number' => '1',
 369                  'answer' => 'enterprise data dictionary',
 370                  'timestamp' => '1161206024',
 371                  'event' => '6',
 372                  'grade' => '0.8',
 373                  'raw_grade' => '0.8',
 374                  'penalty' => '0.1',
 375                  'id' => 677550,
 376              ),
 377          );
 378  
 379          $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
 380  
 381          $expectedqa = (object) array(
 382              'behaviour' => 'deferredfeedback',
 383              'questionid' => 10216,
 384              'variant' => 1,
 385              'maxmark' => 1,
 386              'minfraction' => 0,
 387              'maxfraction' => 1,
 388              'flagged' => 0,
 389              '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?',
 390              'rightanswer' => '*Enterprise data model*',
 391              'responsesummary' => 'enterprise data dictionary',
 392              'timemodified' => 1161206024,
 393              'steps' => array(
 394                  0 => (object) array(
 395                      'sequencenumber' => 0,
 396                      'state' => 'todo',
 397                      'fraction' => null,
 398                      'timecreated' => 1161205933,
 399                      'userid' => 111471,
 400                      'data' => array(),
 401                  ),
 402                  1 => (object) array(
 403                      'sequencenumber' => 1,
 404                      'state' => 'gradedpartial',
 405                      'fraction' => 0.8,
 406                      'timecreated' => 1161206024,
 407                      'userid' => 111471,
 408                      'data' => array('answer' => 'enterprise data dictionary', '-finish' => 1),
 409                  ),
 410              ),
 411          );
 412  
 413          $this->compare_qas($expectedqa, $qa);
 414      }
 415  
 416      public function test_shortanswer_deferredfeedback_history3220() {
 417          $quiz = (object) array(
 418              'id' => '221',
 419              'course' => '187',
 420              'name' => 'Practice CTMA04',
 421              '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. ',
 422              'introformat' => FORMAT_HTML,
 423              'questiondecimalpoints' => '-1',
 424              'showuserpicture' => '1',
 425              'showblocks' => '1',
 426              'timeopen' => '1178492400',
 427              'timeclose' => '1193875200',
 428              'preferredbehaviour' => 'deferredfeedback',
 429              'attempts' => '0',
 430              'attemptonlast' => '0',
 431              'grademethod' => '1',
 432              'decimalpoints' => '2',
 433              'review' => '71727591',
 434              'questionsperpage' => '1',
 435              'shufflequestions' => '0',
 436              'shuffleanswers' => '0',
 437              'sumgrades' => '100',
 438              'grade' => '100',
 439              'timecreated' => '0',
 440              'timemodified' => '1195232889',
 441              'password' => '',
 442              'subnet' => '',
 443              'popup' => '0',
 444              'delay1' => '0',
 445              'delay2' => '0',
 446              'timelimit' => '0',
 447          );
 448          $attempt = (object) array(
 449              'id' => '4058',
 450              'uniqueid' => '4058',
 451              'quiz' => '221',
 452              'userid' => '83485',
 453              'attempt' => '1',
 454              'sumgrades' => '19',
 455              'timestart' => '1178636138',
 456              'timefinish' => '1178874880',
 457              'timemodified' => '1178636138',
 458              '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',
 459              'preview' => '0',
 460          );
 461          $question = (object) array(
 462              'id' => '4184',
 463              'category' => '204',
 464              'parent' => '0',
 465              'name' => '4abP1 Book 11 Section 3.1 capit invest appraisal defn',
 466              'questiontext' => 'Complete the following sentence by providing an appropriate word for the indicated gap.
 467   <p>Capital investment appraisal involves both quantitative and ______ issues. </p>',
 468              'questiontextformat' => '1',
 469              'defaultmark' => '1',
 470              'penalty' => '1',
 471              'qtype' => 'shortanswer',
 472              'length' => '1',
 473              'stamp' => 'learn.open.ac.uk+070417143727+tO4yGs',
 474              'version' => 'learn.open.ac.uk+070417143727+fieanX',
 475              'hidden' => '0',
 476              'generalfeedback' => '',
 477              'generalfeedbackformat' => '1',
 478              'timecreated' => '0',
 479              'timemodified' => '0',
 480              'createdby' => null,
 481              'modifiedby' => null,
 482              'unlimited' => null,
 483              'maxmark' => '1',
 484              'options' => (object) array(
 485                  'answers' => array(
 486                      12768 => (object) array(
 487                          'question' => '4184',
 488                          'answer' => 'qualitative*',
 489                          'fraction' => '1',
 490                          'feedback' => 'Yes, the correct answer is qualitative issues. Well done! <p> Book 11 Section 3.1',
 491                          'id' => 12768,
 492                      ),
 493                      12769 => (object) array(
 494                          'question' => '4184',
 495                          'answer' => 'qual*tat*ve*',
 496                          'fraction' => '1',
 497                          'feedback' => 'Yes, the correct answer is qualitative issues. Well done! <i>(but watch your spelling!)</i> <p> Book 11 Section 3.1',
 498                          'id' => 12769,
 499                      ),
 500                      12770 => (object) array(
 501                          'question' => '4184',
 502                          'answer' => '*',
 503                          'fraction' => '0',
 504                          'feedback' => 'The correct answer is qualitative issues. <p> Book 11 Section 3.1',
 505                          'id' => 12770,
 506                      ),
 507                  ),
 508                  'usecase' => '0',
 509              ),
 510              'hints' => false,
 511          );
 512          $qsession = (object) array(
 513              'id' => '40854',
 514              'attemptid' => '4058',
 515              'questionid' => '4184',
 516              'newest' => '100733',
 517              'newgraded' => '100733',
 518              'sumpenalty' => '1',
 519              'manualcomment' => '',
 520              'manualcommentformat' => '1',
 521              'flagged' => '1',
 522          );
 523          $qstates = array(
 524              94330 => (object) array(
 525                  'attempt' => '4058',
 526                  'question' => '4184',
 527                  'originalquestion' => '0',
 528                  'seq_number' => '0',
 529                  'answer' => '',
 530                  'timestamp' => '1178636138',
 531                  'event' => '0',
 532                  'grade' => '0',
 533                  'raw_grade' => '0',
 534                  'penalty' => '0',
 535                  'id' => 94330,
 536              ),
 537              94415 => (object) array(
 538                  'attempt' => '4058',
 539                  'question' => '4184',
 540                  'originalquestion' => '0',
 541                  'seq_number' => '1',
 542                  'answer' => 'qualitative',
 543                  'timestamp' => '1178636171',
 544                  'event' => '2',
 545                  'grade' => '0',
 546                  'raw_grade' => '1',
 547                  'penalty' => '1',
 548                  'id' => 94415,
 549              ),
 550              100142 => (object) array(
 551                  'attempt' => '4058',
 552                  'question' => '4184',
 553                  'originalquestion' => '0',
 554                  'seq_number' => '2',
 555                  'answer' => 'subjective',
 556                  'timestamp' => '1178825180',
 557                  'event' => '2',
 558                  'grade' => '0',
 559                  'raw_grade' => '0',
 560                  'penalty' => '1',
 561                  'id' => 100142,
 562              ),
 563              100733 => (object) array(
 564                  'attempt' => '4058',
 565                  'question' => '4184',
 566                  'originalquestion' => '0',
 567                  'seq_number' => '3',
 568                  'answer' => 'subjective',
 569                  'timestamp' => '1178825180',
 570                  'event' => '3',
 571                  'grade' => '0',
 572                  'raw_grade' => '0',
 573                  'penalty' => '1',
 574                  'id' => 100733,
 575              ),
 576          );
 577  
 578          $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
 579  
 580          $expectedqa = (object) array(
 581              'behaviour' => 'deferredfeedback',
 582              'questionid' => 4184,
 583              'variant' => 1,
 584              'maxmark' => 1,
 585              'minfraction' => 0,
 586              'maxfraction' => 1,
 587              'flagged' => 0,
 588              'questionsummary' => "Complete the following sentence by providing an appropriate word for the indicated gap. \n\nCapital investment appraisal involves both quantitative and ______ issues.",
 589              'rightanswer' => 'qualitative*',
 590              'responsesummary' => 'subjective',
 591              'timemodified' => 1178825180,
 592              'steps' => array(
 593                  0 => (object) array(
 594                      'sequencenumber' => 0,
 595                      'state' => 'todo',
 596                      'fraction' => null,
 597                      'timecreated' => 1178636138,
 598                      'userid' => 83485,
 599                      'data' => array(),
 600                  ),
 601                  1 => (object) array(
 602                      'sequencenumber' => 1,
 603                      'state' => 'complete',
 604                      'fraction' => null,
 605                      'timecreated' => 1178636171,
 606                      'userid' => 83485,
 607                      'data' => array('answer' => 'qualitative'),
 608                  ),
 609                  2 => (object) array(
 610                      'sequencenumber' => 2,
 611                      'state' => 'complete',
 612                      'fraction' => null,
 613                      'timecreated' => 1178825180,
 614                      'userid' => 83485,
 615                      'data' => array('answer' => 'subjective'),
 616                  ),
 617                  3 => (object) array(
 618                      'sequencenumber' => 3,
 619                      'state' => 'gradedwrong',
 620                      'fraction' => 0,
 621                      'timecreated' => 1178825180,
 622                      'userid' => 83485,
 623                      'data' => array('answer' => 'subjective', '-finish' => 1),
 624                  ),
 625              ),
 626          );
 627  
 628          $this->compare_qas($expectedqa, $qa);
 629      }
 630  }