[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/question/type/multichoice/tests/ -> upgradelibnewqe_test.php (source)

   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   * multichoice questions.
  20   *
  21   * @package    qtype
  22   * @subpackage multichoice
  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 multichoice 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_multichoice_attempt_upgrader_test extends question_attempt_upgrader_test_base {
  41  
  42      public function test_multichoice_deferredfeedback_history960() {
  43          $quiz = (object) array(
  44              'id' => '1',
  45              'course' => '3',
  46              'name' => 'Test quiz 1',
  47              'intro' => '',
  48              'introformat' => FORMAT_HTML,
  49              'questiondecimalpoints' => '-1',
  50              'showuserpicture' => '1',
  51              'showblocks' => '1',
  52              'timeopen' => '0',
  53              'timeclose' => '0',
  54              'preferredbehaviour' => 'deferredfeedback',
  55              'attempts' => '0',
  56              'attemptonlast' => '0',
  57              'grademethod' => '1',
  58              'decimalpoints' => '2',
  59              'questionsperpage' => '0',
  60              'shufflequestions' => '0',
  61              'shuffleanswers' => '1',
  62              'timecreated' => '0',
  63              'timemodified' => '1278603396',
  64              'timelimit' => '0',
  65              'password' => '',
  66              'subnet' => '',
  67              'popup' => '0',
  68              'delay1' => '0',
  69              'delay2' => '0',
  70              'sumgrades' => '1.00000',
  71              'grade' => '10.00000',
  72              'questiondecimalpoints' => '-1',
  73              'showuserpicture' => '0',
  74              'introformat' => '0',
  75              'preferredbehaviour' => 'deferredfeedback',
  76              'reviewattempt' => '69904',
  77              'reviewcorrectness' => '69904',
  78              'reviewmarks' => '69904',
  79              'reviewspecificfeedback' => '69904',
  80              'reviewgeneralfeedback' => '69904',
  81              'reviewrightanswer' => '69904',
  82              'reviewoverallfeedback' => '4368',
  83          );
  84          $attempt = (object) array(
  85              'id' => '2',
  86              'uniqueid' => '2',
  87              'quiz' => '2',
  88              'userid' => '4',
  89              'attempt' => '1',
  90              'timestart' => '1278604557',
  91              'timefinish' => '1278604570',
  92              'timemodified' => '1278604597',
  93              'layout' => '2,0',
  94              'preview' => '0',
  95              'sumgrades' => '0.90000',
  96          );
  97          $question = (object) array(
  98              'id' => '2',
  99              'category' => '2',
 100              'parent' => '0',
 101              'name' => 'Which is the amphibian',
 102              'questiontext' => 'Which is the amphibian?',
 103              'questiontextformat' => '1',
 104              'generalfeedback' => '',
 105              'generalfeedbackformat' => '1',
 106              'qtype' => 'multichoice',
 107              'length' => '1',
 108              'stamp' => 'tjh238.vledev.open.ac.uk+100708154547+JrHygi',
 109              'version' => 'tjh238.vledev.open.ac.uk+100708154548+a3zh8v',
 110              'hidden' => '0',
 111              'timecreated' => '1278603947',
 112              'timemodified' => '1278603947',
 113              'createdby' => '3',
 114              'modifiedby' => '3',
 115              'defaultmark' => '1.0000000',
 116              'penalty' => '0.3333333',
 117              'maxmark' => '1.00000',
 118              'options' => (object) array(
 119                  'id' => '1',
 120                  'question' => '2',
 121                  'layout' => '0',
 122                  'answers' => array(
 123                      3 => (object) array(
 124                          'question' => '2',
 125                          'answer' => 'Cat',
 126                          'feedback' => '',
 127                          'fraction' => '0.0000000',
 128                          'id' => 3,
 129                      ),
 130                      4 => (object) array(
 131                          'question' => '2',
 132                          'answer' => 'Frog',
 133                          'feedback' => '',
 134                          'fraction' => '1.0000000',
 135                          'id' => 4,
 136                      ),
 137                      5 => (object) array(
 138                          'question' => '2',
 139                          'answer' => 'Ant',
 140                          'feedback' => '',
 141                          'fraction' => '0.0000000',
 142                          'id' => 5,
 143                      ),
 144                      6 => (object) array(
 145                          'question' => '2',
 146                          'answer' => 'Dog',
 147                          'feedback' => '',
 148                          'fraction' => '0.0000000',
 149                          'id' => 6,
 150                      ),
 151                  ),
 152                  'single' => '1',
 153                  'shuffleanswers' => '1',
 154                  'correctfeedback' => '',
 155                  'partiallycorrectfeedback' => '',
 156                  'incorrectfeedback' => '',
 157                  'answernumbering' => 'none',
 158                  'shownumcorrect' => '0',
 159              ),
 160              'hints' => array (
 161                  1 => (object) array(
 162                      'hint' => 'First hint',
 163                      'questionid' => '2',
 164                      'shownumcorrect' => null,
 165                      'clearwrong' => null,
 166                      'options' => null,
 167                      'id' => 1,
 168                  ),
 169                  2 => (object) array(
 170                      'hint' => 'Second hint',
 171                      'questionid' => '2',
 172                      'shownumcorrect' => null,
 173                      'clearwrong' => null,
 174                      'options' => null,
 175                      'id' => 2,
 176                  ),
 177              ),
 178          );
 179          $qsession = (object) array(
 180              'id' => '2',
 181              'attemptid' => '2',
 182              'questionid' => '2',
 183              'newest' => '6',
 184              'newgraded' => '6',
 185              'sumpenalty' => '0.3333333',
 186              'manualcomment' => 'Well done!',
 187              'manualcommentformat' => '1',
 188              'flagged' => '1',
 189          );
 190          $qstates = array(
 191              0 => (object) array(
 192                  'id' => '4',
 193                  'attempt' => '2',
 194                  'question' => '2',
 195                  'originalquestion' => '0',
 196                  'seq_number' => '0',
 197                  'answer' => '5,4,6,3:',
 198                  'timestamp' => '1278604557',
 199                  'event' => '0',
 200                  'grade' => '0',
 201                  'raw_grade' => '0',
 202                  'penalty' => '0',
 203              ),
 204              1 => (object) array(
 205                  'id' => '5',
 206                  'attempt' => '2',
 207                  'question' => '2',
 208                  'originalquestion' => '0',
 209                  'seq_number' => '1',
 210                  'answer' => '5,4,6,3:4',
 211                  'timestamp' => '1278604562',
 212                  'event' => '6',
 213                  'grade' => '1',
 214                  'raw_grade' => '1',
 215                  'penalty' => '0.3333333',
 216              ),
 217              2 => (object) array(
 218                  'id' => '6',
 219                  'attempt' => '2',
 220                  'question' => '2',
 221                  'originalquestion' => '0',
 222                  'seq_number' => '2',
 223                  'answer' => '5,4,6,3:4',
 224                  'timestamp' => '1278604597',
 225                  'event' => '9',
 226                  'grade' => '0.9',
 227                  'raw_grade' => '0.9',
 228                  'penalty' => '0',
 229              ),
 230          );
 231  
 232          $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
 233  
 234          $expectedqa = (object) array(
 235              'behaviour' => 'deferredfeedback',
 236              'questionid' => 2,
 237              'variant' => 1,
 238              'maxmark' => 1,
 239              'minfraction' => 0,
 240              'maxfraction' => 1,
 241              'flagged' => 0,
 242              'questionsummary' => 'Which is the amphibian?',
 243              'rightanswer' => 'Frog',
 244              'responsesummary' => 'Frog',
 245              'timemodified' => 1278604597,
 246              'steps' => array(
 247                  0 => (object) array(
 248                      'sequencenumber' => 0,
 249                      'state' => 'todo',
 250                      'fraction' => null,
 251                      'timecreated' => 1278604557,
 252                      'userid' => 4,
 253                      'data' => array('_order' => '5,4,6,3'),
 254                  ),
 255                  1 => (object) array(
 256                      'sequencenumber' => 1,
 257                      'state' => 'gradedright',
 258                      'fraction' => 1,
 259                      'timecreated' => 1278604562,
 260                      'userid' => 4,
 261                      'data' => array('-finish' => '1', 'answer' => '1'),
 262                  ),
 263                  2 => (object) array(
 264                      'sequencenumber' => 2,
 265                      'state' => 'mangrpartial',
 266                      'fraction' => 0.9,
 267                      'timecreated' => 1278604597,
 268                      'userid' => null,
 269                      'data' => array('-comment' => 'Well done!', '-mark' => '0.9', '-maxmark' => '1'),
 270                  ),
 271              ),
 272          );
 273  
 274          $this->compare_qas($expectedqa, $qa);
 275      }
 276  
 277      public function test_multichoice_deferredfeedback_history0() {
 278          $quiz = (object) array(
 279              'id' => '8',
 280              'course' => '1095',
 281              'name' => 'End of course quiz',
 282              'intro' => 'Use this self-assessment quiz to judge your overall understanding. ',
 283              'introformat' => FORMAT_HTML,
 284              'questiondecimalpoints' => '-1',
 285              'showuserpicture' => '1',
 286              'showblocks' => '1',
 287              'timeopen' => '1150107600',
 288              'timeclose' => '0',
 289              'preferredbehaviour' => 'deferredfeedback',
 290              'attempts' => '0',
 291              'attemptonlast' => '0',
 292              'grademethod' => '1',
 293              'decimalpoints' => '2',
 294              'review' => '71760879',
 295              'questionsperpage' => '0',
 296              'shufflequestions' => '1',
 297              'shuffleanswers' => '1',
 298              'sumgrades' => '25',
 299              'grade' => '25',
 300              'timecreated' => '0',
 301              'timemodified' => '1150107596',
 302              'password' => '',
 303              'subnet' => '',
 304              'popup' => '0',
 305              'delay1' => '0',
 306              'delay2' => '0',
 307              'timelimit' => '0',
 308          );
 309          $attempt = (object) array(
 310              'id' => '17',
 311              'uniqueid' => '17',
 312              'quiz' => '8',
 313              'userid' => '26290',
 314              'attempt' => '1',
 315              'sumgrades' => '0',
 316              'timestart' => '1150203042',
 317              'timefinish' => '0',
 318              'timemodified' => '1150203042',
 319              'layout' => '93,76,82,75,87,74,90,94,73,77,81,95,79,92,88,80,91,86,72,83,84,89,85,78,71,0',
 320              'preview' => '1',
 321          );
 322          $question = (object) array(
 323              'id' => '72',
 324              'category' => '10',
 325              'parent' => '0',
 326              'name' => 'Q02',
 327              'questiontext' => 'Why were standards such an important driver in the growth of systems integration?',
 328              'questiontextformat' => '1',
 329              'defaultmark' => '1',
 330              'penalty' => '0.1',
 331              'qtype' => 'multichoice',
 332              'length' => '1',
 333              'stamp' => 'learn.open.ac.uk+060612113403+Fz0GGO',
 334              'version' => 'learn.open.ac.uk+060612160802+I6ctMQ',
 335              'hidden' => '0',
 336              'generalfeedback' => '',
 337              'generalfeedbackformat' => '1',
 338              'timecreated' => '0',
 339              'timemodified' => '0',
 340              'createdby' => null,
 341              'modifiedby' => null,
 342              'unlimited' => null,
 343              'maxmark' => '1',
 344              'options' => (object) array(
 345                  'id' => '44',
 346                  'question' => '72',
 347                  'layout' => '0',
 348                  'answers' => array(
 349                      200 => (object) array(
 350                          'question' => '72',
 351                          'answer' => 'Because they enable stored data and interfaces to be standardised.',
 352                          'fraction' => '1',
 353                          'feedback' => 'Standards enable the various components of an integrated system to communicate using well defined mechanisms and enable the components to have a standard view of stored data.',
 354                          'id' => 200,
 355                      ),
 356                      201 => (object) array(
 357                          'question' => '72',
 358                          'answer' => 'Because they enable the members of an integration team to communicate together.',
 359                          'fraction' => '0',
 360                          'feedback' => 'Standards enable the various components of an integrated system to communicate using well defined mechanisms and enable the components to have a standard view of stored data.',
 361                          'id' => 201,
 362                      ),
 363                      202 => (object) array(
 364                          'question' => '72',
 365                          'answer' => 'Because they produce good quality documentation.',
 366                          'fraction' => '0',
 367                          'feedback' => 'Standards enable the various components of an integrated system to communicate using well defined mechanisms and enable the components to have a standard view of stored data.',
 368                          'id' => 202,
 369                      ),
 370                  ),
 371                  'single' => '1',
 372                  'shuffleanswers' => '1',
 373                  'correctfeedback' => '',
 374                  'partiallycorrectfeedback' => '',
 375                  'incorrectfeedback' => '',
 376                  'answernumbering' => 'abc',
 377              ),
 378              'hints' => false,
 379          );
 380          $qsession = (object) array(
 381              'id' => '132',
 382              'attemptid' => '17',
 383              'questionid' => '72',
 384              'newest' => '196',
 385              'newgraded' => '196',
 386              'sumpenalty' => '0',
 387              'manualcomment' => '',
 388              'manualcommentformat' => '1',
 389              'flagged' => '1',
 390          );
 391          $qstates = array(
 392              196 => (object) array(
 393                  'attempt' => '17',
 394                  'question' => '72',
 395                  'originalquestion' => '0',
 396                  'seq_number' => '0',
 397                  'answer' => '200,202,201:',
 398                  'timestamp' => '1150203042',
 399                  'event' => '0',
 400                  'grade' => '0',
 401                  'raw_grade' => '0',
 402                  'penalty' => '0',
 403                  'id' => 196,
 404              ),
 405          );
 406  
 407          $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
 408  
 409          $expectedqa = (object) array(
 410              'behaviour' => 'deferredfeedback',
 411              'questionid' => 72,
 412              'variant' => 1,
 413              'maxmark' => 1,
 414              'minfraction' => 0,
 415              'maxfraction' => 1,
 416              'flagged' => 0,
 417              'questionsummary' => 'Why were standards such an important driver in the growth of systems integration?',
 418              'rightanswer' => 'Because they enable stored data and interfaces to be standardised.',
 419              'responsesummary' => '',
 420              'timemodified' => 1150203042,
 421              'steps' => array(
 422                  0 => (object) array(
 423                      'sequencenumber' => 0,
 424                      'state' => 'todo',
 425                      'fraction' => null,
 426                      'timecreated' => 1150203042,
 427                      'userid' => 26290,
 428                      'data' => array('_order' => '200,202,201'),
 429                  ),
 430              ),
 431          );
 432  
 433          $this->compare_qas($expectedqa, $qa);
 434      }
 435  
 436      public function test_multichoice_deferredfeedback_history60() {
 437          $quiz = (object) array(
 438              'id' => '13',
 439              'course' => '1416',
 440              'name' => 'Self assessment',
 441              'intro' => '<p>This quiz enables you to rate how much you have demonstrated certain skills in assignments.
 442          </p>
 443          <p>Each question is phrased so that you agree or disagree with a statement that describes your level of attainment, and is accompanied by a link to advice on recognising and practising the skill.
 444          </p>
 445          <p>The quiz is intended to form part of a dialogue on skills improvement between you and your tutor. Hence there is no "right" answer to it, and it is awarded no marks towards the course result.
 446          </p>
 447          <p>Any benefits to you depend on your being realistic about what you have demonstrated. Reserve the extreme ratings for when you think you have demonstrated mastery or complete incompetence!
 448              <br />
 449          </p>',
 450              'introformat' => FORMAT_HTML,
 451              'questiondecimalpoints' => '-1',
 452              'showuserpicture' => '1',
 453              'showblocks' => '1',
 454              'timeopen' => '0',
 455              'timeclose' => '0',
 456              'preferredbehaviour' => 'deferredfeedback',
 457              'attempts' => '0',
 458              'attemptonlast' => '1',
 459              'grademethod' => '4',
 460              'decimalpoints' => '0',
 461              'review' => '71760879',
 462              'questionsperpage' => '0',
 463              'shufflequestions' => '0',
 464              'shuffleanswers' => '0',
 465              'sumgrades' => '7',
 466              'grade' => '0',
 467              'timecreated' => '0',
 468              'timemodified' => '1160991947',
 469              'password' => '',
 470              'subnet' => '',
 471              'popup' => '0',
 472              'delay1' => '0',
 473              'delay2' => '0',
 474              'timelimit' => '0',
 475          );
 476          $attempt = (object) array(
 477              'id' => '181',
 478              'uniqueid' => '181',
 479              'quiz' => '13',
 480              'userid' => '9932',
 481              'attempt' => '1',
 482              'sumgrades' => '0',
 483              'timestart' => '1161946984',
 484              'timefinish' => '1161947130',
 485              'timemodified' => '1161947130',
 486              'layout' => '218,221,219,220,223,224,222,0',
 487              'preview' => '0',
 488          );
 489          $question = (object) array(
 490              'id' => '218',
 491              'category' => '21',
 492              'parent' => '0',
 493              'name' => 'Answering the question that is asked',
 494              'questiontext' => '<p>I have demonstrated the ability to analyse and <strong>answer the question</strong> that is asked. (<a title="Advice" href="http://learnacct.open.ac.uk/mod/resourcepage/view.php?id=5989">Click for advice on this skill</a>)',
 495              'questiontextformat' => '1',
 496              'defaultmark' => '1',
 497              'penalty' => '0',
 498              'qtype' => 'multichoice',
 499              'length' => '1',
 500              'stamp' => 'learn.open.ac.uk+060822084343+5JvlNr',
 501              'version' => 'learn.open.ac.uk+060822084343+CQPfhb',
 502              'hidden' => '0',
 503              'generalfeedback' => '',
 504              'generalfeedbackformat' => '1',
 505              'timecreated' => '0',
 506              'timemodified' => '0',
 507              'createdby' => null,
 508              'modifiedby' => null,
 509              'unlimited' => null,
 510              'maxmark' => '1',
 511              'options' => (object) array(
 512                  'id' => '152',
 513                  'question' => '218',
 514                  'layout' => '0',
 515                  'answers' => array(
 516                      664 => (object) array(
 517                          'question' => '218',
 518                          'answer' => 'Agree',
 519                          'fraction' => '0',
 520                          'feedback' => ' ',
 521                          'id' => 664,
 522                      ),
 523                      665 => (object) array(
 524                          'question' => '218',
 525                          'answer' => 'Uncertain',
 526                          'fraction' => '0',
 527                          'feedback' => ' ',
 528                          'id' => 665,
 529                      ),
 530                      666 => (object) array(
 531                          'question' => '218',
 532                          'answer' => 'Disagree',
 533                          'fraction' => '0',
 534                          'feedback' => ' ',
 535                          'id' => 666,
 536                      ),
 537                      667 => (object) array(
 538                          'question' => '218',
 539                          'answer' => 'Strongly disagree',
 540                          'fraction' => '0',
 541                          'feedback' => ' ',
 542                          'id' => 667,
 543                      ),
 544                      668 => (object) array(
 545                          'question' => '218',
 546                          'answer' => 'Strongly agree',
 547                          'fraction' => '0',
 548                          'feedback' => ' ',
 549                          'id' => 668,
 550                      ),
 551                  ),
 552                  'single' => '0',
 553                  'shuffleanswers' => '0',
 554                  'correctfeedback' => '',
 555                  'partiallycorrectfeedback' => '',
 556                  'incorrectfeedback' => '',
 557                  'answernumbering' => 'abc',
 558              ),
 559              'hints' => false,
 560          );
 561          $qsession = (object) array(
 562              'id' => '2412',
 563              'attemptid' => '181',
 564              'questionid' => '218',
 565              'newest' => '3891',
 566              'newgraded' => '3891',
 567              'sumpenalty' => '0',
 568              'manualcomment' => '',
 569              'manualcommentformat' => '1',
 570              'flagged' => '1',
 571          );
 572          $qstates = array(
 573              3888 => (object) array(
 574                  'attempt' => '181',
 575                  'question' => '218',
 576                  'originalquestion' => '0',
 577                  'seq_number' => '0',
 578                  'answer' => '664,665,666,667,668:',
 579                  'timestamp' => '1161946984',
 580                  'event' => '0',
 581                  'grade' => '0',
 582                  'raw_grade' => '0',
 583                  'penalty' => '0',
 584                  'id' => 3888,
 585              ),
 586              3891 => (object) array(
 587                  'attempt' => '181',
 588                  'question' => '218',
 589                  'originalquestion' => '0',
 590                  'seq_number' => '1',
 591                  'answer' => '664,665,666,667,668:664',
 592                  'timestamp' => '1161947130',
 593                  'event' => '6',
 594                  'grade' => '0',
 595                  'raw_grade' => '0',
 596                  'penalty' => '0',
 597                  'id' => 3891,
 598              ),
 599          );
 600  
 601          $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
 602  
 603          $expectedqa = (object) array(
 604              'behaviour' => 'deferredfeedback',
 605              'questionid' => 218,
 606              'variant' => 1,
 607              'maxmark' => 1,
 608              'minfraction' => 0,
 609              'maxfraction' => 1,
 610              'flagged' => 0,
 611              'questionsummary' => 'I have demonstrated the ability to analyse and ANSWER THE QUESTION that is asked. (Click for advice on this skill)',
 612              'rightanswer' => '',
 613              'responsesummary' => 'Agree',
 614              'timemodified' => 1161947130,
 615              'steps' => array(
 616                  0 => (object) array(
 617                      'sequencenumber' => 0,
 618                      'state' => 'todo',
 619                      'fraction' => null,
 620                      'timecreated' => 1161946984,
 621                      'userid' => 9932,
 622                      'data' => array('_order' => '664,665,666,667,668'),
 623                  ),
 624                  1 => (object) array(
 625                      'sequencenumber' => 1,
 626                      'state' => 'gradedwrong',
 627                      'fraction' => 0,
 628                      'timecreated' => 1161947130,
 629                      'userid' => 9932,
 630                      'data' => array('choice0' => 1, 'choice1' => 0, 'choice2' => 0, 'choice3' => 0, 'choice4' => 0, '-finish' => 1),
 631                  ),
 632              ),
 633          );
 634  
 635          $this->compare_qas($expectedqa, $qa);
 636      }
 637  
 638      public function test_multichoice_deferredfeedback_history6220() {
 639          $quiz = (object) array(
 640              'id' => '95',
 641              'course' => '1181',
 642              'name' => 'Study Guide 7 Quiz',
 643              'intro' => '',
 644              'introformat' => FORMAT_HTML,
 645              'questiondecimalpoints' => '-1',
 646              'showuserpicture' => '1',
 647              'showblocks' => '1',
 648              'timeopen' => '0',
 649              'timeclose' => '0',
 650              'preferredbehaviour' => 'deferredfeedback',
 651              'attempts' => '0',
 652              'attemptonlast' => '1',
 653              'grademethod' => '1',
 654              'decimalpoints' => '2',
 655              'review' => '71760879',
 656              'questionsperpage' => '2',
 657              'shufflequestions' => '0',
 658              'shuffleanswers' => '0',
 659              'sumgrades' => '59',
 660              'grade' => '59',
 661              'timecreated' => '0',
 662              'timemodified' => '1170427431',
 663              'password' => '',
 664              'subnet' => '',
 665              'popup' => '0',
 666              'delay1' => '0',
 667              'delay2' => '0',
 668              'timelimit' => '0',
 669          );
 670          $attempt = (object) array(
 671              'id' => '3237',
 672              'uniqueid' => '3237',
 673              'quiz' => '95',
 674              'userid' => '120555',
 675              'attempt' => '1',
 676              'sumgrades' => '35.4166',
 677              'timestart' => '1177006492',
 678              'timefinish' => '1177008802',
 679              'timemodified' => '1177008794',
 680              'layout' => '2855,2856,0,2857,2858,0,2859,2860,0,2861,2862,0,2863,2864,0,2865,0',
 681              'preview' => '0',
 682          );
 683          $question = (object) array(
 684              'id' => '2855',
 685              'category' => '114',
 686              'parent' => '0',
 687              'name' => 'Question 1',
 688              'questiontext' => '<p>Which of the following techniques can identify non-functional requirements?</p>',
 689              'questiontextformat' => '1',
 690              'defaultmark' => '1',
 691              'penalty' => '0',
 692              'qtype' => 'multichoice',
 693              'length' => '1',
 694              'stamp' => 'learn.open.ac.uk+061221143845+nohATp',
 695              'version' => 'learn.open.ac.uk+070131102906+bviJOZ',
 696              'hidden' => '0',
 697              'generalfeedback' => 'The correct answers are b and c.
 698          For further information about this question see Study Guide 7 SAQ 2.1(b and c)
 699          Misuse cases were discussed in SG4',
 700              'generalfeedbackformat' => '1',
 701              'timecreated' => '0',
 702              'timemodified' => '0',
 703              'createdby' => null,
 704              'modifiedby' => null,
 705              'unlimited' => null,
 706              'maxmark' => '5',
 707              'options' => (object) array(
 708                  'id' => '943',
 709                  'question' => '2855',
 710                  'layout' => '0',
 711                  'answers' => array(
 712                      8356 => (object) array(
 713                          'question' => '2855',
 714                          'answer' => 'Use cases.',
 715                          'fraction' => '-0.33333',
 716                          'feedback' => '',
 717                          'id' => 8356,
 718                      ),
 719                      8357 => (object) array(
 720                          'question' => '2855',
 721                          'answer' => 'Verb identification.',
 722                          'fraction' => '0.5',
 723                          'feedback' => '',
 724                          'id' => 8357,
 725                      ),
 726                      8358 => (object) array(
 727                          'question' => '2855',
 728                          'answer' => 'Misuse cases.',
 729                          'fraction' => '0.5',
 730                          'feedback' => '',
 731                          'id' => 8358,
 732                      ),
 733                      8359 => (object) array(
 734                          'question' => '2855',
 735                          'answer' => 'Adjective identification.',
 736                          'fraction' => '-0.33333',
 737                          'feedback' => '',
 738                          'id' => 8359,
 739                      ),
 740                      8360 => (object) array(
 741                          'question' => '2855',
 742                          'answer' => 'Noun identification.',
 743                          'fraction' => '-0.33333',
 744                          'feedback' => '',
 745                          'id' => 8360,
 746                      ),
 747                  ),
 748                  'single' => '0',
 749                  'shuffleanswers' => '0',
 750                  'correctfeedback' => 'Your answer is correct.',
 751                  'partiallycorrectfeedback' => 'Your answer is partially correct.',
 752                  'incorrectfeedback' => 'Your answer is incorrect.',
 753                  'answernumbering' => 'abc',
 754              ),
 755              'hints' => false,
 756          );
 757          $qsession = (object) array(
 758              'id' => '30584',
 759              'attemptid' => '3237',
 760              'questionid' => '2855',
 761              'newest' => '72341',
 762              'newgraded' => '72341',
 763              'sumpenalty' => '0',
 764              'manualcomment' => '',
 765              'manualcommentformat' => '1',
 766              'flagged' => '1',
 767          );
 768          $qstates = array(
 769              72307 => (object) array(
 770                  'attempt' => '3237',
 771                  'question' => '2855',
 772                  'originalquestion' => '0',
 773                  'seq_number' => '0',
 774                  'answer' => '8356,8357,8358,8359,8360:',
 775                  'timestamp' => '1177006492',
 776                  'event' => '0',
 777                  'grade' => '0',
 778                  'raw_grade' => '0',
 779                  'penalty' => '0',
 780                  'id' => 72307,
 781              ),
 782              72318 => (object) array(
 783                  'attempt' => '3237',
 784                  'question' => '2855',
 785                  'originalquestion' => '0',
 786                  'seq_number' => '1',
 787                  'answer' => '8356,8357,8358,8359,8360:8357,8359',
 788                  'timestamp' => '1177007066',
 789                  'event' => '2',
 790                  'grade' => '0',
 791                  'raw_grade' => '0.83335',
 792                  'penalty' => '0',
 793                  'id' => 72318,
 794              ),
 795              72328 => (object) array(
 796                  'attempt' => '3237',
 797                  'question' => '2855',
 798                  'originalquestion' => '0',
 799                  'seq_number' => '2',
 800                  'answer' => '8356,8357,8358,8359,8360:8357,8359',
 801                  'timestamp' => '1177008016',
 802                  'event' => '2',
 803                  'grade' => '0',
 804                  'raw_grade' => '0.83335',
 805                  'penalty' => '0',
 806                  'id' => 72328,
 807              ),
 808              72341 => (object) array(
 809                  'attempt' => '3237',
 810                  'question' => '2855',
 811                  'originalquestion' => '0',
 812                  'seq_number' => '3',
 813                  'answer' => '8356,8357,8358,8359,8360:8357,8359',
 814                  'timestamp' => '1177008016',
 815                  'event' => '6',
 816                  'grade' => '0.83335',
 817                  'raw_grade' => '0.83335',
 818                  'penalty' => '0',
 819                  'id' => 72341,
 820              ),
 821          );
 822  
 823          $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
 824  
 825          $expectedqa = (object) array(
 826              'behaviour' => 'deferredfeedback',
 827              'questionid' => 2855,
 828              'variant' => 1,
 829              'maxmark' => 5,
 830              'minfraction' => 0,
 831              'maxfraction' => 1,
 832              'flagged' => 0,
 833              'questionsummary' => 'Which of the following techniques can identify non-functional requirements?',
 834              'rightanswer' => 'Verb identification.; Misuse cases.',
 835              'responsesummary' => 'Verb identification.; Adjective identification.',
 836              'timemodified' => 1177008016,
 837              'steps' => array(
 838                  0 => (object) array(
 839                      'sequencenumber' => 0,
 840                      'state' => 'todo',
 841                      'fraction' => null,
 842                      'timecreated' => 1177006492,
 843                      'userid' => 120555,
 844                      'data' => array('_order' => '8356,8357,8358,8359,8360'),
 845                  ),
 846                  1 => (object) array(
 847                      'sequencenumber' => 1,
 848                      'state' => 'complete',
 849                      'fraction' => null,
 850                      'timecreated' => 1177007066,
 851                      'userid' => 120555,
 852                      'data' => array('choice0' => 0, 'choice1' => 1, 'choice2' => 0, 'choice3' => 1, 'choice4' => 0),
 853                  ),
 854                  2 => (object) array(
 855                      'sequencenumber' => 2,
 856                      'state' => 'complete',
 857                      'fraction' => null,
 858                      'timecreated' => 1177008016,
 859                      'userid' => 120555,
 860                      'data' => array('choice0' => 0, 'choice1' => 1, 'choice2' => 0, 'choice3' => 1, 'choice4' => 0),
 861                  ),
 862                  3 => (object) array(
 863                      'sequencenumber' => 3,
 864                      'state' => 'gradedpartial',
 865                      'fraction' => 0.16667,
 866                      'timecreated' => 1177008016,
 867                      'userid' => 120555,
 868                      'data' => array('choice0' => 0, 'choice1' => 1, 'choice2' => 0, 'choice3' => 1, 'choice4' => 0, '-finish' => 1),
 869                  ),
 870              ),
 871          );
 872  
 873          $this->compare_qas($expectedqa, $qa);
 874      }
 875  
 876      public function test_multichoice_deferredfeedback_missing() {
 877          $quiz = (object) array(
 878              'id' => '8',
 879              'course' => '1095',
 880              'name' => 'End of course quiz',
 881              'intro' => 'Use this self-assessment quiz to judge your overall understanding. ',
 882              'introformat' => FORMAT_HTML,
 883              'questiondecimalpoints' => '-1',
 884              'showuserpicture' => '1',
 885              'showblocks' => '1',
 886              'timeopen' => '1150107600',
 887              'timeclose' => '0',
 888              'preferredbehaviour' => 'deferredfeedback',
 889              'attempts' => '0',
 890              'attemptonlast' => '0',
 891              'grademethod' => '1',
 892              'decimalpoints' => '2',
 893              'review' => '71760879',
 894              'questionsperpage' => '0',
 895              'shufflequestions' => '1',
 896              'shuffleanswers' => '1',
 897              'sumgrades' => '25',
 898              'grade' => '25',
 899              'timecreated' => '0',
 900              'timemodified' => '1150107596',
 901              'password' => '',
 902              'subnet' => '',
 903              'popup' => '0',
 904              'delay1' => '0',
 905              'delay2' => '0',
 906              'timelimit' => '0',
 907          );
 908          $attempt = (object) array(
 909              'id' => '17',
 910              'uniqueid' => '17',
 911              'quiz' => '8',
 912              'userid' => '26290',
 913              'attempt' => '1',
 914              'sumgrades' => '0',
 915              'timestart' => '1150203042',
 916              'timefinish' => '0',
 917              'timemodified' => '1150203042',
 918              'layout' => '93,76,82,75,87,74,90,94,73,77,81,95,79,92,88,80,91,86,72,83,84,89,85,78,71,0',
 919              'preview' => '1',
 920          );
 921          $question = (object) array(
 922              'id' => '72',
 923              'category' => '10',
 924              'parent' => '0',
 925              'name' => 'Q02',
 926              'questiontext' => 'Why were standards such an important driver in the growth of systems integration?',
 927              'questiontextformat' => '1',
 928              'defaultmark' => '1',
 929              'penalty' => '0.1',
 930              'qtype' => 'multichoice',
 931              'length' => '1',
 932              'stamp' => 'learn.open.ac.uk+060612113403+Fz0GGO',
 933              'version' => 'learn.open.ac.uk+060612160802+I6ctMQ',
 934              'hidden' => '0',
 935              'generalfeedback' => '',
 936              'generalfeedbackformat' => '1',
 937              'timecreated' => '0',
 938              'timemodified' => '0',
 939              'createdby' => null,
 940              'modifiedby' => null,
 941              'unlimited' => null,
 942              'maxmark' => '1',
 943              'options' => (object) array(
 944                  'id' => '44',
 945                  'question' => '72',
 946                  'layout' => '0',
 947                  'answers' => array(
 948                      200 => (object) array(
 949                          'question' => '72',
 950                          'answer' => 'Because they enable stored data and interfaces to be standardised.',
 951                          'fraction' => '1',
 952                          'feedback' => 'Standards enable the various components of an integrated system to communicate using well defined mechanisms and enable the components to have a standard view of stored data.',
 953                          'id' => 200,
 954                      ),
 955                      201 => (object) array(
 956                          'question' => '72',
 957                          'answer' => 'Because they enable the members of an integration team to communicate together.',
 958                          'fraction' => '0',
 959                          'feedback' => 'Standards enable the various components of an integrated system to communicate using well defined mechanisms and enable the components to have a standard view of stored data.',
 960                          'id' => 201,
 961                      ),
 962                      202 => (object) array(
 963                          'question' => '72',
 964                          'answer' => 'Because they produce good quality documentation.',
 965                          'fraction' => '0',
 966                          'feedback' => 'Standards enable the various components of an integrated system to communicate using well defined mechanisms and enable the components to have a standard view of stored data.',
 967                          'id' => 202,
 968                      ),
 969                  ),
 970                  'single' => '1',
 971                  'shuffleanswers' => '1',
 972                  'correctfeedback' => '',
 973                  'partiallycorrectfeedback' => '',
 974                  'incorrectfeedback' => '',
 975                  'answernumbering' => 'abc',
 976              ),
 977              'hints' => false,
 978          );
 979  
 980          $qa = $this->updater->supply_missing_question_attempt($quiz, $attempt, $question);
 981  
 982          $expectedqa = (object) array(
 983              'behaviour' => 'deferredfeedback',
 984              'questionid' => 72,
 985              'variant' => 1,
 986              'maxmark' => 1,
 987              'minfraction' => 0,
 988              'maxfraction' => 1,
 989              'flagged' => 0,
 990              'questionsummary' => 'Why were standards such an important driver in the growth of systems integration?',
 991              'rightanswer' => 'Because they enable stored data and interfaces to be standardised.',
 992              'responsesummary' => '',
 993              'timemodified' => 1150203042,
 994              'steps' => array(
 995                  0 => (object) array(
 996                      'sequencenumber' => 0,
 997                      'state' => 'todo',
 998                      'fraction' => null,
 999                      'timecreated' => 1150203042,
1000                      'userid' => 26290,
1001                      'data' => array('_order' => '200,201,202'),
1002                  ),
1003              ),
1004          );
1005  
1006          $this->compare_qas($expectedqa, $qa);
1007      }
1008  
1009  public function test_multichoice_deferredfeedback_qsession140() {
1010          $quiz = (object) array(
1011              'id' => '58',
1012              'course' => '3420',
1013              'name' => 'Practice Quiz',
1014              'intro' => '',
1015              'introformat' => FORMAT_HTML,
1016              'questiondecimalpoints' => '-1',
1017              'showuserpicture' => '1',
1018              'showblocks' => '1',
1019              'timeopen' => '0',
1020              'timeclose' => '0',
1021              'optionflags' => '0',
1022              'attempts' => '0',
1023              'attemptonlast' => '0',
1024              'grademethod' => '3',
1025              'decimalpoints' => '2',
1026              'review' => '71760879',
1027              'questionsperpage' => '2',
1028              'shufflequestions' => '0',
1029              'shuffleanswers' => '1',
1030              'sumgrades' => '10',
1031              'grade' => '10',
1032              'timecreated' => '0',
1033              'timemodified' => '1200043605',
1034              'password' => '',
1035              'subnet' => '',
1036              'popup' => '0',
1037              'delay1' => '0',
1038              'delay2' => '0',
1039              'timelimit' => '0',
1040              'preferredbehaviour' => 'deferredfeedback',
1041          );
1042          $attempt = (object) array(
1043              'id' => '38',
1044              'uniqueid' => '38',
1045              'quiz' => '58',
1046              'userid' => '51335',
1047              'attempt' => '1',
1048              'sumgrades' => '5',
1049              'timestart' => '1198254245',
1050              'timefinish' => '1198254438',
1051              'timemodified' => '1198254352',
1052              'layout' => '178,179,180,181,182,183,184,185,189,187,0',
1053              'preview' => '0',
1054          );
1055          $question = (object) array(
1056              'id' => '179',
1057              'category' => '51',
1058              'parent' => '0',
1059              'name' => 'Question 2',
1060              'questiontext' => '<p>Where will the 19th International Biology Olympiad be held?</p>',
1061              'questiontextformat' => '1',
1062              'defaultmark' => '1',
1063              'penalty' => '0.1',
1064              'qtype' => 'multichoice',
1065              'length' => '1',
1066              'stamp' => 'openlearn.open.ac.uk+071210172238+HpCRWO',
1067              'version' => 'openlearn.open.ac.uk+071211115640+SZulvf',
1068              'hidden' => '0',
1069              'generalfeedback' => '<p></p>',
1070              'generalfeedbackformat' => '1',
1071              'timecreated' => '0',
1072              'timemodified' => '0',
1073              'createdby' => null,
1074              'modifiedby' => null,
1075              'unlimited' => null,
1076              'maxmark' => '1',
1077              'options' => (object) array(
1078                  'id' => '71',
1079                  'question' => '179',
1080                  'layout' => '0',
1081                  'answers' => array(
1082                      372 => (object) array(
1083                          'question' => '179',
1084                          'answer' => 'Mumbai, India',
1085                          'fraction' => '1',
1086                          'feedback' => '',
1087                          'id' => 372,
1088                      ),
1089                      373 => (object) array(
1090                          'question' => '179',
1091                          'answer' => 'Rome, Italy',
1092                          'fraction' => '-1',
1093                          'feedback' => '',
1094                          'id' => 373,
1095                      ),
1096                      374 => (object) array(
1097                          'question' => '179',
1098                          'answer' => 'Oslo, Norway',
1099                          'fraction' => '-1',
1100                          'feedback' => '',
1101                          'id' => 374,
1102                      ),
1103                      375 => (object) array(
1104                          'question' => '179',
1105                          'answer' => 'Tokyo, Japan',
1106                          'fraction' => '-1',
1107                          'feedback' => '',
1108                          'id' => 375,
1109                      ),
1110                  ),
1111                  'single' => '1',
1112                  'shuffleanswers' => '1',
1113                  'correctfeedback' => '',
1114                  'partiallycorrectfeedback' => '',
1115                  'incorrectfeedback' => '',
1116                  'answernumbering' => 'abc',
1117              ),
1118              'hints' => false,
1119          );
1120          $qsession = (object) array(
1121              'id' => '140',
1122              'attemptid' => '38',
1123              'questionid' => '179',
1124              'newest' => '273',
1125              'newgraded' => '273',
1126              'sumpenalty' => '0.2',
1127              'manualcomment' => '',
1128              'manualcommentformat' => '1',
1129              'flagged' => '1',
1130          );
1131          $qstates = array(
1132              243 => (object) array(
1133                  'attempt' => '38',
1134                  'question' => '179',
1135                  'originalquestion' => '0',
1136                  'seq_number' => '0',
1137                  'answer' => '375,372,374,373:',
1138                  'timestamp' => '1198254245',
1139                  'event' => '0',
1140                  'grade' => '0',
1141                  'raw_grade' => '0',
1142                  'penalty' => '0',
1143                  'id' => 243,
1144              ),
1145              254 => (object) array(
1146                  'attempt' => '38',
1147                  'question' => '179',
1148                  'originalquestion' => '0',
1149                  'seq_number' => '1',
1150                  'answer' => '375,372,374,373:375',
1151                  'timestamp' => '1198254261',
1152                  'event' => '3',
1153                  'grade' => '0',
1154                  'raw_grade' => '0',
1155                  'penalty' => '0.1',
1156                  'id' => 254,
1157              ),
1158              273 => (object) array(
1159                  'attempt' => '38',
1160                  'question' => '179',
1161                  'originalquestion' => '0',
1162                  'seq_number' => '2',
1163                  'answer' => '375,372,374,373:375',
1164                  'timestamp' => '1198254261',
1165                  'event' => '6',
1166                  'grade' => '0',
1167                  'raw_grade' => '0',
1168                  'penalty' => '0.1',
1169                  'id' => 273,
1170              ),
1171          );
1172  
1173          $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
1174  
1175          $expectedqa = (object) array(
1176              'behaviour' => 'deferredfeedback',
1177              'questionid' => 179,
1178              'variant' => 1,
1179              'maxmark' => 1,
1180              'minfraction' => 0,
1181              'maxfraction' => 1,
1182              'flagged' => 0,
1183              'questionsummary' => 'Where will the 19th International Biology Olympiad be held?',
1184              'rightanswer' => 'Mumbai, India',
1185              'responsesummary' => 'Tokyo, Japan',
1186              'timemodified' => 1198254261,
1187              'steps' => array(
1188                  0 => (object) array(
1189                      'sequencenumber' => 0,
1190                      'state' => 'todo',
1191                      'fraction' => null,
1192                      'timecreated' => 1198254245,
1193                      'userid' => 51335,
1194                      'data' => array('_order' => '375,372,374,373'),
1195                  ),
1196                  1 => (object) array(
1197                      'sequencenumber' => 1,
1198                      'state' => 'gradedwrong',
1199                      'fraction' => 0,
1200                      'timecreated' => 1198254261,
1201                      'userid' => 51335,
1202                      'data' => array('answer' => '0', '-finish' => '1'),
1203                  ),
1204              ),
1205          );
1206  
1207          $this->compare_qas($expectedqa, $qa);
1208      }
1209  
1210      public function test_multichoice_deferredfeedback_qsession2018195() {
1211          $quiz = (object) array(
1212              'id' => '1832',
1213              'course' => '4912',
1214              'name' => 'Unit 12 IL & ICT review quiz',
1215              'intro' => '<p>This quiz has been developed to help you review your skills development in information literacy and ICT and to gather feedback on the use of the skills activities within K315 and within the Social Work degree Practice Learning courses.</p>
1216          <p>We would welcome your input (allow 10-15 minutes). The data you provide will be anonymised and used for research purposes only. This project is administered under the OU’s general data protection policy guidelines, which can be seen here: <a href="http://www3.open.ac.uk/our-student-policies/pdf/dataprotection.pdf">http://www3.open.ac.uk/our-student-policies/pdf/dataprotection.pdf</a></p>',
1217              'introformat' => FORMAT_HTML,
1218              'questiondecimalpoints' => '-1',
1219              'showuserpicture' => '1',
1220              'showblocks' => '1',
1221              'timeopen' => '0',
1222              'timeclose' => '0',
1223              'optionflags' => '0',
1224              'penaltyscheme' => '1',
1225              'attempts' => '0',
1226              'attemptonlast' => '0',
1227              'grademethod' => '1',
1228              'decimalpoints' => '2',
1229              'review' => '71565312',
1230              'questionsperpage' => '2',
1231              'shufflequestions' => '0',
1232              'shuffleanswers' => '0',
1233              'sumgrades' => '0',
1234              'grade' => '0',
1235              'timecreated' => '0',
1236              'timemodified' => '1232636874',
1237              'password' => '',
1238              'subnet' => '',
1239              'popup' => '0',
1240              'delay1' => '0',
1241              'delay2' => '0',
1242              'timelimit' => '0',
1243              'preferredbehaviour' => 'deferredfeedback',
1244          );
1245          $attempt = (object) array(
1246              'id' => '174744',
1247              'uniqueid' => '174745',
1248              'quiz' => '1832',
1249              'userid' => '181806',
1250              'attempt' => '1',
1251              'sumgrades' => '0',
1252              'timestart' => '1249488674',
1253              'timefinish' => '1250702880',
1254              'timemodified' => '1249488674',
1255              'layout' => '26132,26128,0,26143,26140,0,26144,26141,0,26145,26142,0,26126,26127,0,26134,26135,0,26131,26133,0,26130,26129,0,26136,26137,0,26139,26138,0',
1256              'preview' => '0',
1257          );
1258          $question = (object) array(
1259              'id' => '26132',
1260              'category' => '2506',
1261              'parent' => '0',
1262              'name' => '01 most useful',
1263              'questiontext' => 'Which was the most useful K315 information literacy or ICT activity?',
1264              'questiontextformat' => '1',
1265              'defaultmark' => '1',
1266              'penalty' => '0.1',
1267              'qtype' => 'multichoice',
1268              'length' => '1',
1269              'stamp' => 'learn.open.ac.uk+080529101041+d4XuNI',
1270              'version' => 'learn.open.ac.uk+100725192556+KIetVC',
1271              'hidden' => '0',
1272              'generalfeedback' => '',
1273              'generalfeedbackformat' => '1',
1274              'timecreated' => '1212055841',
1275              'timemodified' => '1280085956',
1276              'createdby' => '28856',
1277              'modifiedby' => '25299',
1278              'unlimited' => '0',
1279              'maxmark' => '0',
1280              'options' => (object) array(
1281                  'id' => '11628',
1282                  'question' => '26132',
1283                  'layout' => '0',
1284                  'answers' => array(
1285                      77406 => (object) array(
1286                          'question' => '26132',
1287                          'answer' => 'Introduction to & evaluation of MyStuff (Course Introduction)',
1288                          'fraction' => '0',
1289                          'feedback' => '',
1290                          'id' => 77406,
1291                      ),
1292                      77407 => (object) array(
1293                          'question' => '26132',
1294                          'answer' => 'Values Exchange case studies',
1295                          'fraction' => '1',
1296                          'feedback' => '',
1297                          'id' => 77407,
1298                      ),
1299                      77408 => (object) array(
1300                          'question' => '26132',
1301                          'answer' => 'Secure accommodation orders (Unit 2, Activity 3.3)',
1302                          'fraction' => '0',
1303                          'feedback' => '',
1304                          'id' => 77408,
1305                      ),
1306                      77409 => (object) array(
1307                          'question' => '26132',
1308                          'answer' => 'Advanced search tools (Unit 3, Activity 1.3)',
1309                          'fraction' => '0',
1310                          'feedback' => '',
1311                          'id' => 77409,
1312                      ),
1313                      77410 => (object) array(
1314                          'question' => '26132',
1315                          'answer' => 'Different types of information (Unit 7, Activity 1.2)',
1316                          'fraction' => '0',
1317                          'feedback' => '',
1318                          'id' => 77410,
1319                      ),
1320                      77411 => (object) array(
1321                          'question' => '26132',
1322                          'answer' => 'Informing your practice with empirical evidence (Unit 8, Activity 3.1)',
1323                          'fraction' => '0',
1324                          'feedback' => '',
1325                          'id' => 77411,
1326                      ),
1327                      77412 => (object) array(
1328                          'question' => '26132',
1329                          'answer' => 'Reviewing and saving your work (Unit 12, Activity 2.2)',
1330                          'fraction' => '0',
1331                          'feedback' => '',
1332                          'id' => 77412,
1333                      ),
1334                  ),
1335                  'single' => '1',
1336                  'shuffleanswers' => '0',
1337                  'correctfeedback' => '',
1338                  'partiallycorrectfeedback' => '',
1339                  'incorrectfeedback' => '',
1340                  'answernumbering' => 'abc',
1341              ),
1342              'hints' => false,
1343          );
1344          $qsession = (object) array(
1345              'id' => '2018195',
1346              'attemptid' => '174745',
1347              'questionid' => '26132',
1348              'newest' => '5162301',
1349              'newgraded' => '5162301',
1350              'sumpenalty' => '0',
1351              'manualcomment' => '',
1352              'manualcommentformat' => '1',
1353              'flagged' => '1',
1354          );
1355          $qstates = array(
1356              5107187 => (object) array(
1357                  'attempt' => '174745',
1358                  'question' => '26132',
1359                  'originalquestion' => '0',
1360                  'seq_number' => '0',
1361                  'answer' => '77406,77407,77408,77409,77410,77411,77412:',
1362                  'timestamp' => '1249488674',
1363                  'event' => '0',
1364                  'grade' => '0',
1365                  'raw_grade' => '0',
1366                  'penalty' => '0',
1367                  'id' => 5107187,
1368              ),
1369              5107188 => (object) array(
1370                  'attempt' => '174745',
1371                  'question' => '26132',
1372                  'originalquestion' => '0',
1373                  'seq_number' => '0',
1374                  'answer' => '',
1375                  'timestamp' => '1249488674',
1376                  'event' => '0',
1377                  'grade' => '0',
1378                  'raw_grade' => '0',
1379                  'penalty' => '0',
1380                  'id' => 5107188,
1381              ),
1382              5107190 => (object) array(
1383                  'attempt' => '174745',
1384                  'question' => '26132',
1385                  'originalquestion' => '0',
1386                  'seq_number' => '1',
1387                  'answer' => '77406,77407,77408,77409,77410,77411,77412:77407',
1388                  'timestamp' => '1249488763',
1389                  'event' => '2',
1390                  'grade' => '0',
1391                  'raw_grade' => '0',
1392                  'penalty' => '0',
1393                  'id' => 5107190,
1394              ),
1395              5162301 => (object) array(
1396                  'attempt' => '174745',
1397                  'question' => '26132',
1398                  'originalquestion' => '0',
1399                  'seq_number' => '2',
1400                  'answer' => '77406,77407,77408,77409,77410,77411,77412:77407',
1401                  'timestamp' => '1249488763',
1402                  'event' => '6',
1403                  'grade' => '0',
1404                  'raw_grade' => '0',
1405                  'penalty' => '0',
1406                  'id' => 5162301,
1407              ),
1408          );
1409  
1410          $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
1411  
1412          $expectedqa = (object) array(
1413              'behaviour' => 'deferredfeedback',
1414              'questionid' => 26132,
1415              'variant' => 1,
1416              'maxmark' => 0,
1417              'minfraction' => 0,
1418              'maxfraction' => 1,
1419              'flagged' => 0,
1420              'questionsummary' => 'Which was the most useful K315 information literacy or ICT activity?',
1421              'rightanswer' => 'Values Exchange case studies',
1422              'responsesummary' => 'Values Exchange case studies',
1423              'timemodified' => 1249488763,
1424              'steps' => array(
1425                  0 => (object) array(
1426                      'sequencenumber' => 0,
1427                      'state' => 'todo',
1428                      'fraction' => null,
1429                      'timecreated' => 1249488674,
1430                      'userid' => 181806,
1431                      'data' => array('_order' => '77406,77407,77408,77409,77410,77411,77412'),
1432                  ),
1433                  1 => (object) array(
1434                      'sequencenumber' => 1,
1435                      'state' => 'complete',
1436                      'fraction' => null,
1437                      'timecreated' => 1249488763,
1438                      'userid' => 181806,
1439                      'data' => array('answer' => '1'),
1440                  ),
1441                  2 => (object) array(
1442                      'sequencenumber' => 2,
1443                      'state' => 'finished',
1444                      'fraction' => null,
1445                      'timecreated' => 1249488763,
1446                      'userid' => 181806,
1447                      'data' => array('answer' => '1', '-finish' => '1'),
1448                  ),
1449              ),
1450          );
1451  
1452          $this->compare_qas($expectedqa, $qa);
1453      }
1454  
1455      public function test_multichoice_deferredfeedback_qsession2653368() {
1456          $quiz = (object) array(
1457              'id' => '3273',
1458              'course' => '5862',
1459              'name' => 'Assessing information sources',
1460              'intro' => 'Assessing information sources - literature review table',
1461              'introformat' => FORMAT_HTML,
1462              'questiondecimalpoints' => '-1',
1463              'showuserpicture' => '1',
1464              'showblocks' => '1',
1465              'timeopen' => '0',
1466              'timeclose' => '0',
1467              'optionflags' => '0',
1468              'penaltyscheme' => '1',
1469              'attempts' => '0',
1470              'attemptonlast' => '1',
1471              'grademethod' => '4',
1472              'decimalpoints' => '2',
1473              'review' => '71727591',
1474              'questionsperpage' => '0',
1475              'shufflequestions' => '0',
1476              'shuffleanswers' => '0',
1477              'questions' => '60135,60136,60137,0',
1478              'sumgrades' => '3',
1479              'grade' => '10',
1480              'timecreated' => '0',
1481              'timemodified' => '1223992271',
1482              'password' => '',
1483              'subnet' => '',
1484              'popup' => '0',
1485              'delay1' => '0',
1486              'delay2' => '0',
1487              'timelimit' => '0',
1488              'preferredbehaviour' => 'deferredfeedback',
1489          );
1490          $attempt = (object) array(
1491              'id' => '229025',
1492              'uniqueid' => '229026',
1493              'quiz' => '3273',
1494              'userid' => '597153',
1495              'attempt' => '4',
1496              'sumgrades' => '0.999999',
1497              'timestart' => '1258492857',
1498              'timefinish' => '1258492862',
1499              'timemodified' => '1258492857',
1500              'layout' => '60135,60136,60137,0',
1501              'preview' => '0',
1502          );
1503          $question = (object) array(
1504              'id' => '60137',
1505              'category' => '6026',
1506              'parent' => '0',
1507              'name' => 'Assessing information sources - No. 3',
1508              'questiontext' => 'For source 3, the \'Loose Change\' video, select the statements to indicate \'yes\':',
1509              'questiontextformat' => '1',
1510              'defaultmark' => '1',
1511              'penalty' => '0.1',
1512              'qtype' => 'multichoice',
1513              'length' => '1',
1514              'stamp' => 'learn.open.ac.uk+080811153454+BMEq1t',
1515              'version' => 'learn.open.ac.uk+081010072800+oSu1g3',
1516              'hidden' => '0',
1517              'generalfeedback' => '',
1518              'generalfeedbackformat' => '1',
1519              'timecreated' => '1218468894',
1520              'timemodified' => '1223623680',
1521              'createdby' => '26409',
1522              'modifiedby' => '351133',
1523              'unlimited' => null,
1524              'maxmark' => '1',
1525              'options' => (object) array(
1526                  'id' => '23896',
1527                  'question' => '60137',
1528                  'layout' => '0',
1529                  'answers' => array(
1530                      181821 => (object) array(
1531                          'question' => '60137',
1532                          'answer' => 'Would you regard this source as objective?',
1533                          'fraction' => '0.142857',
1534                          'feedback' => '',
1535                          'id' => 181821,
1536                      ),
1537                      181822 => (object) array(
1538                          'question' => '60137',
1539                          'answer' => 'Does the source provide references?',
1540                          'fraction' => '0.142857',
1541                          'feedback' => '',
1542                          'id' => 181822,
1543                      ),
1544                      181823 => (object) array(
1545                          'question' => '60137',
1546                          'answer' => 'Are all viewpoints considered?',
1547                          'fraction' => '0.142857',
1548                          'feedback' => '',
1549                          'id' => 181823,
1550                      ),
1551                      181824 => (object) array(
1552                          'question' => '60137',
1553                          'answer' => 'Are quotations placed in their full context?',
1554                          'fraction' => '0.142857',
1555                          'feedback' => '',
1556                          'id' => 181824,
1557                      ),
1558                      181825 => (object) array(
1559                          'question' => '60137',
1560                          'answer' => 'Does the source include conclusions based on evidence?',
1561                          'fraction' => '0.142857',
1562                          'feedback' => '',
1563                          'id' => 181825,
1564                      ),
1565                      181826 => (object) array(
1566                          'question' => '60137',
1567                          'answer' => 'Would you trust this source?',
1568                          'fraction' => '0.142857',
1569                          'feedback' => '',
1570                          'id' => 181826,
1571                      ),
1572                      181827 => (object) array(
1573                          'question' => '60137',
1574                          'answer' => 'Has it been peer-reviewed?',
1575                          'fraction' => '0.142857',
1576                          'feedback' => '',
1577                          'id' => 181827,
1578                      ),
1579                  ),
1580                  'single' => '0',
1581                  'shuffleanswers' => '0',
1582                  'correctfeedback' => 'This is a very polemical source which clearly has a standpoint. Whether or not you would use this material would be largely dependent on your reseach question. If you did use it, you would need to be clear that you would require academic sources that would support the claims being made.<br />',
1583                  'partiallycorrectfeedback' => 'This is a very polemical source which clearly has a standpoint. Whether or not you would use this material would be largely dependent on your reseach question. If you did use it, you would need to be clear that you would require academic sources that would support the claims being made.<br /><br />',
1584                  'incorrectfeedback' => 'This is a very polemical source which clearly has a standpoint. Whether or not you would use this material would be largely dependent on your reseach question. If you did use it, you would need to be clear that you would require academic sources that would support the claims being made.<br /><br />',
1585                  'answernumbering' => 'abc',
1586              ),
1587              'hints' => false,
1588          );
1589          $qsession = (object) array(
1590              'id' => '2653368',
1591              'attemptid' => '229026',
1592              'questionid' => '60137',
1593              'newest' => '6676055',
1594              'newgraded' => '6676055',
1595              'sumpenalty' => '0.1',
1596              'manualcomment' => '',
1597              'manualcommentformat' => '1',
1598              'flagged' => '1',
1599          );
1600          $qstates = array(
1601              6676031 => (object) array(
1602                  'attempt' => '229026',
1603                  'question' => '60137',
1604                  'originalquestion' => '0',
1605                  'seq_number' => '0',
1606                  'answer' => '181821,181822,181823,181824,181825,181826,181827:181821,181822,181823,181824,181825,181826',
1607                  'timestamp' => '1258492857',
1608                  'event' => '0',
1609                  'grade' => '0',
1610                  'raw_grade' => '0.857142',
1611                  'penalty' => '0',
1612                  'id' => 6676031,
1613              ),
1614              6676034 => (object) array(
1615                  'attempt' => '229026',
1616                  'question' => '60137',
1617                  'originalquestion' => '0',
1618                  'seq_number' => '1',
1619                  'answer' => '181821,181822,181823,181824,181825,181826,181827:',
1620                  'timestamp' => '1258492857',
1621                  'event' => '0',
1622                  'grade' => '0',
1623                  'raw_grade' => '0',
1624                  'penalty' => '0.1',
1625                  'id' => 6676034,
1626              ),
1627              6676055 => (object) array(
1628                  'attempt' => '229026',
1629                  'question' => '60137',
1630                  'originalquestion' => '0',
1631                  'seq_number' => '2',
1632                  'answer' => '181821,181822,181823,181824,181825,181826,181827:',
1633                  'timestamp' => '1258492857',
1634                  'event' => '6',
1635                  'grade' => '0',
1636                  'raw_grade' => '0',
1637                  'penalty' => '0.1',
1638                  'id' => 6676055,
1639              ),
1640          );
1641  
1642          $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
1643  
1644          $expectedqa = (object) array(
1645              'behaviour' => 'deferredfeedback',
1646              'questionid' => 60137,
1647              'variant' => 1,
1648              'maxmark' => 1,
1649              'minfraction' => 0,
1650              'maxfraction' => 1,
1651              'flagged' => 0,
1652              'questionsummary' => "For source 3, the 'Loose Change' video, select the statements to indicate 'yes':",
1653              'rightanswer' => 'Would you regard this source as objective?; Does the source provide references?; Are all viewpoints considered?; Are quotations placed in their full context?; Does the source include conclusions based on evidence?; Would you trust this source?; Has it been peer-reviewed?',
1654              'responsesummary' => 'Would you regard this source as objective?; Does the source provide references?; Are all viewpoints considered?; Are quotations placed in their full context?; Does the source include conclusions based on evidence?; Would you trust this source?',
1655              'timemodified' => 1258492857,
1656              'steps' => array(
1657                  0 => (object) array(
1658                      'sequencenumber' => 0,
1659                      'state' => 'todo',
1660                      'fraction' => null,
1661                      'timecreated' => 1258492857,
1662                      'userid' => 597153,
1663                      'data' => array('_order' => '181821,181822,181823,181824,181825,181826,181827'),
1664                  ),
1665                  1 => (object) array(
1666                      'sequencenumber' => 1,
1667                      'state' => 'gradedwrong',
1668                      'fraction' => 0,
1669                      'timecreated' => 1258492857,
1670                      'userid' => 597153,
1671                      'data' => array('choice0' => 0, 'choice1' => 0, 'choice2' => 0, 'choice3' => 0, 'choice4' => 0, 'choice5' => 0, 'choice6' => 0, '-finish' => '1'),
1672                  ),
1673              ),
1674          );
1675  
1676          $this->compare_qas($expectedqa, $qa);
1677      }
1678  
1679      public function test_multichoice_deferredfeedback_qsession3131() {
1680          $quiz = (object) array(
1681              'id' => '10',
1682              'course' => '608',
1683              'name' => 'TMA 01, Part 1 (Activity 12)',
1684              'intro' => '<p>Activity 12 is a multiple-choice assessment quiz. It is Part 1 of TMA 01 and contributes 20 per cent of the marks for the TMA. It invites you to check your understandings of the topics with which you engaged in Activities 6–11.</p>
1685  
1686          <p>Activity 12 is distinctive in that you are welcome to try as much as you want at any one time and to try as often as you wish. However, you have to get <strong>full marks</strong> on it in order to proceed to the second part of TMA 01, Activity 15.</p>
1687  
1688          <p>There are 30 questions, which can be attempted in any order. When you are ready to attempt a question, choose your answer and then \'Submit\'. You will get feedback. If you need to try again, follow the same process. When you are satisfied with your answer to one question, go on to another. Remember to choose \'Submit\' for each answer that you want to be saved.</p>
1689  
1690          <p>You do not have to do the questions all at one sitting: at any time you can choose \'Save without submitting\'. This saves the current state of all questions so you can come back later to do some more.</p>
1691  
1692          <p>When you are satisfied with your answers to all 30 questions, choose \'Submit all and finish\'. This marks all questions, closes the current quiz attempt and gives the PCAP team formal notification that you have successfully completed this part of the TMA. <strong>Should you inadvertently choose this option you will need to start from scratch when you next attempt the task.</strong></p>',
1693              'introformat' => FORMAT_HTML,
1694              'questiondecimalpoints' => '-1',
1695              'showuserpicture' => '1',
1696              'showblocks' => '1',
1697              'timeopen' => '0',
1698              'timeclose' => '0',
1699              'optionflags' => '0',
1700              'attempts' => '0',
1701              'attemptonlast' => '0',
1702              'grademethod' => '2',
1703              'decimalpoints' => '2',
1704              'review' => '71760879',
1705              'questionsperpage' => '1',
1706              'shufflequestions' => '0',
1707              'shuffleanswers' => '1',
1708              'sumgrades' => '30',
1709              'grade' => '10',
1710              'timecreated' => '0',
1711              'timemodified' => '1266247621',
1712              'password' => '',
1713              'subnet' => '',
1714              'popup' => '0',
1715              'delay1' => '0',
1716              'delay2' => '0',
1717              'timelimit' => '0',
1718              'preferredbehaviour' => 'deferredfeedback',
1719          );
1720          $attempt = (object) array(
1721              'id' => '302',
1722              'uniqueid' => '302',
1723              'quiz' => '10',
1724              'userid' => '63173',
1725              'attempt' => '1',
1726              'sumgrades' => '30',
1727              'timestart' => '1163428543',
1728              'timefinish' => '1166546613',
1729              'timemodified' => '1166546472',
1730              'layout' => '161,0,160,0,162,0,163,0,164,0,165,0,166,0,190,0,191,0,192,0,193,0,194,0,195,0,196,0,197,0,198,0,168,0,169,0,170,0,171,0,172,0,173,0,174,0,175,0,176,0,177,0,178,0,179,0,180,0,181,0',
1731              'preview' => '0',
1732          );
1733          $question = (object) array(
1734              'id' => '163',
1735              'category' => '15',
1736              'parent' => '0',
1737              'name' => 'Question 04',
1738              'questiontext' => 'Can we have a \'realist\' or objective social science?',
1739              'questiontextformat' => '1',
1740              'defaultmark' => '1',
1741              'penalty' => '1',
1742              'qtype' => 'multichoice',
1743              'length' => '1',
1744              'stamp' => 'learn.open.ac.uk+060614160624+gkAYii',
1745              'version' => 'learn.open.ac.uk+060614160624+LYm8Rl',
1746              'hidden' => '0',
1747              'generalfeedback' => '',
1748              'generalfeedbackformat' => '1',
1749              'timecreated' => '0',
1750              'timemodified' => '0',
1751              'createdby' => null,
1752              'modifiedby' => null,
1753              'unlimited' => null,
1754              'maxmark' => '1',
1755              'options' => (object) array(
1756                  'id' => '117',
1757                  'question' => '163',
1758                  'layout' => '0',
1759                  'answers' => array(
1760                      456 => (object) array(
1761                          'question' => '163',
1762                          'answer' => 'No',
1763                          'fraction' => '0',
1764                          'feedback' => 'This is a common position but it does overlook areas in which it is possible to observe, tally and describe in pretty objective (low-inference) ways. Much social geography is of this sort.',
1765                          'id' => 456,
1766                      ),
1767                      457 => (object) array(
1768                          'question' => '163',
1769                          'answer' => 'Yes',
1770                          'fraction' => '0',
1771                          'feedback' => 'A great deal of social science is to do with making sense of subjective phenomena. We might expect social scientists to be honest and careful but, where subjective phenomena are concerned there can be no objective truth. However, there are areas in which it is possible to observe, tally and describe in pretty objective (low-inference) ways. Much social geography is of this sort.',
1772                          'id' => 457,
1773                      ),
1774                      458 => (object) array(
1775                          'question' => '163',
1776                          'answer' => 'Sometimes',
1777                          'fraction' => '1',
1778                          'feedback' => 'This is a judicious response to two positions, each of which has strengths but neither of which covers the range of social science practices.',
1779                          'id' => 458,
1780                      ),
1781                  ),
1782                  'single' => '1',
1783                  'shuffleanswers' => '0',
1784                  'correctfeedback' => '',
1785                  'partiallycorrectfeedback' => '',
1786                  'incorrectfeedback' => '',
1787                  'answernumbering' => 'abc',
1788              ),
1789              'hints' => false,
1790          );
1791          $qsession = (object) array(
1792              'id' => '3131',
1793              'attemptid' => '302',
1794              'questionid' => '163',
1795              'newest' => '14715',
1796              'newgraded' => '14715',
1797              'sumpenalty' => '0',
1798              'manualcomment' => '',
1799              'manualcommentformat' => '1',
1800              'flagged' => '1',
1801          );
1802          $qstates = array(
1803              5922 => (object) array(
1804                  'attempt' => '302',
1805                  'question' => '163',
1806                  'originalquestion' => '0',
1807                  'seq_number' => '0',
1808                  'answer' => '456,457,458:',
1809                  'timestamp' => '1163428543',
1810                  'event' => '0',
1811                  'grade' => '0',
1812                  'raw_grade' => '0',
1813                  'penalty' => '0',
1814                  'id' => 5922,
1815              ),
1816              5941 => (object) array(
1817                  'attempt' => '302',
1818                  'question' => '163',
1819                  'originalquestion' => '0',
1820                  'seq_number' => '1',
1821                  'answer' => '456,457,458:',
1822                  'timestamp' => '1163428576',
1823                  'event' => '2',
1824                  'grade' => '0',
1825                  'raw_grade' => '0',
1826                  'penalty' => '1',
1827                  'id' => 5941,
1828              ),
1829              5942 => (object) array(
1830                  'attempt' => '302',
1831                  'question' => '163',
1832                  'originalquestion' => '0',
1833                  'seq_number' => '2',
1834                  'answer' => '456,457,458:',
1835                  'timestamp' => '1163428577',
1836                  'event' => '2',
1837                  'grade' => '0',
1838                  'raw_grade' => '0',
1839                  'penalty' => '1',
1840                  'id' => 5942,
1841              ),
1842              14713 => (object) array(
1843                  'attempt' => '302',
1844                  'question' => '163',
1845                  'originalquestion' => '0',
1846                  'seq_number' => '3',
1847                  'answer' => '456,457,458:456',
1848                  'timestamp' => '1165355190',
1849                  'event' => '3',
1850                  'grade' => '0',
1851                  'raw_grade' => '0',
1852                  'penalty' => '1',
1853                  'id' => 14713,
1854              ),
1855              14715 => (object) array(
1856                  'attempt' => '302',
1857                  'question' => '163',
1858                  'originalquestion' => '0',
1859                  'seq_number' => '4',
1860                  'answer' => '456,457,458:458',
1861                  'timestamp' => '1165355352',
1862                  'event' => '3',
1863                  'grade' => '1',
1864                  'raw_grade' => '1',
1865                  'penalty' => '1',
1866                  'id' => 14715,
1867              ),
1868          );
1869  
1870          $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
1871  
1872          $expectedqa = (object) array(
1873              'behaviour' => 'deferredfeedback',
1874              'questionid' => 163,
1875              'variant' => 1,
1876              'maxmark' => 1,
1877              'minfraction' => 0,
1878              'maxfraction' => 1,
1879              'flagged' => 0,
1880              'questionsummary' => 'Can we have a \'realist\' or objective social science?',
1881              'rightanswer' => 'Sometimes',
1882              'responsesummary' => 'Sometimes',
1883              'timemodified' => 1165355352,
1884              'steps' => array(
1885                  0 => (object) array(
1886                      'sequencenumber' => 0,
1887                      'state' => 'todo',
1888                      'fraction' => null,
1889                      'timecreated' => 1163428543,
1890                      'userid' => 63173,
1891                      'data' => array('_order' => '456,457,458'),
1892                  ),
1893                  1 => (object) array(
1894                      'sequencenumber' => 1,
1895                      'state' => 'todo',
1896                      'fraction' => null,
1897                      'timecreated' => 1163428576,
1898                      'userid' => 63173,
1899                      'data' => array(),
1900                  ),
1901                  2 => (object) array(
1902                      'sequencenumber' => 2,
1903                      'state' => 'todo',
1904                      'fraction' => null,
1905                      'timecreated' => 1163428577,
1906                      'userid' => 63173,
1907                      'data' => array(),
1908                  ),
1909                  3 => (object) array(
1910                      'sequencenumber' => 3,
1911                      'state' => 'gradedright',
1912                      'fraction' => 1,
1913                      'timecreated' => 1165355352,
1914                      'userid' => 63173,
1915                      'data' => array('answer' => '2', '-finish' => '1'),
1916                  ),
1917              ),
1918          );
1919  
1920          $this->compare_qas($expectedqa, $qa);
1921      }
1922  
1923      public function test_multichoice_deferredfeedback_qsession4307870 () {
1924          $quiz = (object) array(
1925              'id' => '4070',
1926              'course' => '5139',
1927              'name' => 'Reading practice: Session 16',
1928              'intro' => '',
1929              'introformat' => FORMAT_HTML,
1930              'questiondecimalpoints' => '-1',
1931              'showuserpicture' => '1',
1932              'showblocks' => '1',
1933              'timeopen' => '0',
1934              'timeclose' => '0',
1935              'optionflags' => '0',
1936              'penaltyscheme' => '1',
1937              'attempts' => '0',
1938              'attemptonlast' => '0',
1939              'grademethod' => '1',
1940              'decimalpoints' => '0',
1941              'review' => '71727591',
1942              'questionsperpage' => '1',
1943              'shufflequestions' => '0',
1944              'shuffleanswers' => '1',
1945              'sumgrades' => '8',
1946              'grade' => '8',
1947              'timecreated' => '0',
1948              'timemodified' => '1265136533',
1949              'password' => '',
1950              'subnet' => '',
1951              'popup' => '0',
1952              'delay1' => '0',
1953              'delay2' => '0',
1954              'timelimit' => '0',
1955              'showscores' => '1',
1956              'preferredbehaviour' => 'deferredfeedback',
1957          );
1958          $attempt = (object) array(
1959              'id' => '428769',
1960              'uniqueid' => '428770',
1961              'quiz' => '4070',
1962              'userid' => '605575',
1963              'attempt' => '3',
1964              'sumgrades' => '7',
1965              'timestart' => '1275088684',
1966              'timefinish' => '1275089588',
1967              'timemodified' => '1275089451',
1968              'layout' => '89002,0,89040,0,89042,0,89043,0,89044,0,89045,0,89046,0,89047,0',
1969              'preview' => '0',
1970          );
1971          $question = (object) array(
1972              'id' => '89040',
1973              'category' => '6016',
1974              'parent' => '0',
1975              'name' => 'R2S16',
1976              'questiontext' => '<p>Read the text below and then answer the question based on the information given.</p><p><span lang="ZH-CN">我大哥没有我二哥高,我比我二哥高。</span></p><p>Who is the tallest?</p>',
1977              'questiontextformat' => '1',
1978              'defaultmark' => '1',
1979              'penalty' => '0.33',
1980              'qtype' => 'multichoice',
1981              'length' => '1',
1982              'stamp' => 'learn.open.ac.uk+100204101142+Bygd63',
1983              'version' => 'learn.open.ac.uk+100204101142+exBG6F',
1984              'hidden' => '0',
1985              'generalfeedback' => '',
1986              'generalfeedbackformat' => '1',
1987              'timecreated' => '1265278302',
1988              'timemodified' => '1265278302',
1989              'createdby' => '532546',
1990              'modifiedby' => '532546',
1991              'unlimited' => '0',
1992              'maxmark' => '1',
1993              'options' => (object) array(
1994                  'id' => '33730',
1995                  'question' => '89040',
1996                  'layout' => '0',
1997                  'answers' => array(
1998                      300601 => (object) array(
1999                          'question' => '89040',
2000                          'answer' => '我。',
2001                          'fraction' => '1',
2002                          'feedback' => '',
2003                          'id' => 300601,
2004                      ),
2005                      300602 => (object) array(
2006                          'question' => '89040',
2007                          'answer' => '我大哥。',
2008                          'fraction' => '0',
2009                          'feedback' => '',
2010                          'id' => 300602,
2011                      ),
2012                      300603 => (object) array(
2013                          'question' => '89040',
2014                          'answer' => '我二哥。',
2015                          'fraction' => '0',
2016                          'feedback' => '',
2017                          'id' => 300603,
2018                      ),
2019                  ),
2020                  'single' => '1',
2021                  'shuffleanswers' => '1',
2022                  'correctfeedback' => '',
2023                  'partiallycorrectfeedback' => '',
2024                  'incorrectfeedback' => '',
2025                  'answernumbering' => 'none',
2026              ),
2027              'hints' => false,
2028          );
2029          $qsession = (object) array(
2030              'id' => '4307870',
2031              'attemptid' => '428770',
2032              'questionid' => '89040',
2033              'newest' => '11002905',
2034              'newgraded' => '11002905',
2035              'sumpenalty' => '0.33',
2036              'manualcomment' => '',
2037              'manualcommentformat' => '1',
2038              'flagged' => '1',
2039          );
2040          $qstates = array(
2041              11002780 => (object) array(
2042                  'attempt' => '428770',
2043                  'question' => '89040',
2044                  'originalquestion' => '0',
2045                  'seq_number' => '0',
2046                  'answer' => '300603,300602,300601:',
2047                  'timestamp' => '1275088684',
2048                  'event' => '0',
2049                  'grade' => '0',
2050                  'raw_grade' => '0',
2051                  'penalty' => '0',
2052                  'id' => 11002780,
2053              ),
2054              11002813 => (object) array(
2055                  'attempt' => '428770',
2056                  'question' => '89040',
2057                  'originalquestion' => '0',
2058                  'seq_number' => '1',
2059                  'answer' => '300601',
2060                  'timestamp' => '1275089101',
2061                  'event' => '2',
2062                  'grade' => '0',
2063                  'raw_grade' => '1',
2064                  'penalty' => '0.33',
2065                  'id' => 11002813,
2066              ),
2067              11002905 => (object) array(
2068                  'attempt' => '428770',
2069                  'question' => '89040',
2070                  'originalquestion' => '0',
2071                  'seq_number' => '2',
2072                  'answer' => '300603,300602,300601:300601',
2073                  'timestamp' => '1275089101',
2074                  'event' => '6',
2075                  'grade' => '1',
2076                  'raw_grade' => '1',
2077                  'penalty' => '0.33',
2078                  'id' => 11002905,
2079              ),
2080          );
2081  
2082          $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
2083  
2084          $expectedqa = (object) array(
2085              'behaviour' => 'deferredfeedback',
2086              'questionid' => 89040,
2087              'variant' => 1,
2088              'maxmark' => 1,
2089              'minfraction' => 0,
2090              'maxfraction' => 1,
2091              'flagged' => 0,
2092              'questionsummary' => "Read the text below and then answer the question based on the information given.\n\n我大哥没有我二哥高,我比我二哥高。\n\nWho is the tallest?",
2093              'rightanswer' => '我。',
2094              'responsesummary' => '我。',
2095              'timemodified' => 1275089101,
2096              'steps' => array(
2097                  0 => (object) array(
2098                      'sequencenumber' => 0,
2099                      'state' => 'todo',
2100                      'fraction' => null,
2101                      'timecreated' => 1275088684,
2102                      'userid' => 605575,
2103                      'data' => array('_order' => '300603,300602,300601'),
2104                  ),
2105                  1 => (object) array(
2106                      'sequencenumber' => 1,
2107                      'state' => 'complete',
2108                      'fraction' => null,
2109                      'timecreated' => 1275089101,
2110                      'userid' => 605575,
2111                      'data' => array('answer' => '2'),
2112                  ),
2113                  2 => (object) array(
2114                      'sequencenumber' => 2,
2115                      'state' => 'gradedright',
2116                      'fraction' => 1,
2117                      'timecreated' => 1275089101,
2118                      'userid' => 605575,
2119                      'data' => array('answer' => '2', '-finish' => '1'),
2120                  ),
2121              ),
2122          );
2123  
2124          $this->compare_qas($expectedqa, $qa);
2125      }
2126  
2127      public function test_multichoice_deferredfeedback_qsession49446() {
2128          $quiz = (object) array(
2129              'id' => '203',
2130              'course' => '2359',
2131              'name' => 'Quiz 1',
2132              'intro' => '',
2133              'introformat' => FORMAT_HTML,
2134              'questiondecimalpoints' => '-1',
2135              'showuserpicture' => '1',
2136              'showblocks' => '1',
2137              'timeopen' => '0',
2138              'timeclose' => '0',
2139              'preferredbehaviour' => 'deferredfeedback',
2140              'attempts' => '0',
2141              'attemptonlast' => '1',
2142              'grademethod' => '1',
2143              'decimalpoints' => '2',
2144              'review' => '71760879',
2145              'questionsperpage' => '2',
2146              'shufflequestions' => '0',
2147              'shuffleanswers' => '0',
2148              'sumgrades' => '50',
2149              'grade' => '50',
2150              'timecreated' => '0',
2151              'timemodified' => '1176461532',
2152              'password' => '',
2153              'subnet' => '',
2154              'popup' => '0',
2155              'delay1' => '0',
2156              'delay2' => '0',
2157              'timelimit' => '0',
2158          );
2159          $attempt = (object) array(
2160              'id' => '4338',
2161              'uniqueid' => '4338',
2162              'quiz' => '203',
2163              'userid' => '30631',
2164              'attempt' => '2',
2165              'sumgrades' => '30',
2166              'timestart' => '1179303963',
2167              'timefinish' => '1179303960',
2168              'timemodified' => '1179303420',
2169              'layout' => '3859,3860,0,3861,3862,0,3863,3864,0,3865,3866,0,3867,3868,0',
2170              'preview' => '0',
2171          );
2172          $question = (object) array(
2173              'id' => '3863',
2174              'category' => '187',
2175              'parent' => '0',
2176              'name' => 'Question 5',
2177              'questiontext' => 'What is SOAP?',
2178              'questiontextformat' => '1',
2179              'defaultmark' => '1',
2180              'penalty' => '0',
2181              'qtype' => 'multichoice',
2182              'length' => '1',
2183              'stamp' => 'learn.open.ac.uk+070404142540+CpseAv',
2184              'version' => 'learn.open.ac.uk+070405112519+qNb2kt',
2185              'hidden' => '0',
2186              'generalfeedback' => '<p></p>',
2187              'generalfeedbackformat' => '1',
2188              'timecreated' => '0',
2189              'timemodified' => '0',
2190              'createdby' => null,
2191              'modifiedby' => null,
2192              'unlimited' => null,
2193              'maxmark' => '5',
2194              'options' => (object) array(
2195                  'id' => '1439',
2196                  'question' => '3863',
2197                  'layout' => '0',
2198                  'answers' => array(
2199                      11686 => (object) array(
2200                          'question' => '3863',
2201                          'answer' => 'It is a technology used for sending bulk data through the internet.',
2202                          'fraction' => '0',
2203                          'feedback' => 'Your answer is incorrect. <br />The correct answer is b. ',
2204                          'id' => 11686,
2205                      ),
2206                      11687 => (object) array(
2207                          'question' => '3863',
2208                          'answer' => 'It is the transport mechanism used with web services.',
2209                          'fraction' => '1',
2210                          'feedback' => 'Your answer is correct ',
2211                          'id' => 11687,
2212                      ),
2213                      11688 => (object) array(
2214                          'question' => '3863',
2215                          'answer' => 'It is a distributed object technology',
2216                          'fraction' => '0',
2217                          'feedback' => 'Your answer is incorrect. <br />The correct answer is b. ',
2218                          'id' => 11688,
2219                      ),
2220                  ),
2221                  'single' => '1',
2222                  'shuffleanswers' => '0',
2223                  'correctfeedback' => '',
2224                  'partiallycorrectfeedback' => '',
2225                  'incorrectfeedback' => '',
2226                  'answernumbering' => 'abc',
2227              ),
2228              'hints' => false,
2229          );
2230          $qsession = (object) array(
2231              'id' => '49446',
2232              'attemptid' => '4338',
2233              'questionid' => '3863',
2234              'newest' => '112195',
2235              'newgraded' => '112195',
2236              'sumpenalty' => '0',
2237              'manualcomment' => '',
2238              'manualcommentformat' => '1',
2239              'flagged' => '1',
2240          );
2241          $qstates = array(
2242              112159 => (object) array(
2243                  'attempt' => '4338',
2244                  'question' => '3863',
2245                  'originalquestion' => '0',
2246                  'seq_number' => '0',
2247                  'answer' => '11686,11687,11688:',
2248                  'timestamp' => '1179303963',
2249                  'event' => '8',
2250                  'grade' => '0',
2251                  'raw_grade' => '0',
2252                  'penalty' => '0',
2253                  'id' => 112159,
2254              ),
2255              112164 => (object) array(
2256                  'attempt' => '4338',
2257                  'question' => '3863',
2258                  'originalquestion' => '0',
2259                  'seq_number' => '0',
2260                  'answer' => '11686,11687,11688:',
2261                  'timestamp' => '1179303963',
2262                  'event' => '0',
2263                  'grade' => '0',
2264                  'raw_grade' => '0',
2265                  'penalty' => '0',
2266                  'id' => 112164,
2267              ),
2268              112176 => (object) array(
2269                  'attempt' => '4338',
2270                  'question' => '3863',
2271                  'originalquestion' => '0',
2272                  'seq_number' => '1',
2273                  'answer' => '11686,11687,11688:11687',
2274                  'timestamp' => '1179303218',
2275                  'event' => '2',
2276                  'grade' => '0',
2277                  'raw_grade' => '5',
2278                  'penalty' => '0',
2279                  'id' => 112176,
2280              ),
2281              112195 => (object) array(
2282                  'attempt' => '4338',
2283                  'question' => '3863',
2284                  'originalquestion' => '0',
2285                  'seq_number' => '2',
2286                  'answer' => '11686,11687,11688:11687',
2287                  'timestamp' => '1179303218',
2288                  'event' => '6',
2289                  'grade' => '5',
2290                  'raw_grade' => '5',
2291                  'penalty' => '0',
2292                  'id' => 112195,
2293              ),
2294          );
2295  
2296          $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
2297  
2298          $expectedqa = (object) array(
2299              'behaviour' => 'deferredfeedback',
2300              'questionid' => 3863,
2301              'variant' => 1,
2302              'maxmark' => 5,
2303              'minfraction' => 0,
2304              'maxfraction' => 1,
2305              'flagged' => 0,
2306              'questionsummary' => 'What is SOAP?',
2307              'rightanswer' => 'It is the transport mechanism used with web services.',
2308              'responsesummary' => 'It is the transport mechanism used with web services.',
2309              'timemodified' => 1179303963,
2310              'steps' => array(
2311                  0 => (object) array(
2312                      'sequencenumber' => 0,
2313                      'state' => 'todo',
2314                      'fraction' => null,
2315                      'timecreated' => 1179303963,
2316                      'userid' => 30631,
2317                      'data' => array('_order' => '11686,11687,11688'),
2318                  ),
2319                  1 => (object) array(
2320                      'sequencenumber' => 1,
2321                      'state' => 'complete',
2322                      'fraction' => null,
2323                      'timecreated' => 1179303218,
2324                      'userid' => 30631,
2325                      'data' => array('answer' => 1),
2326                  ),
2327                  2 => (object) array(
2328                      'sequencenumber' => 2,
2329                      'state' => 'gradedright',
2330                      'fraction' => 1,
2331                      'timecreated' => 1179303218,
2332                      'userid' => 30631,
2333                      'data' => array('answer' => 1, '-finish' => 1),
2334                  ),
2335              ),
2336          );
2337  
2338          $this->compare_qas($expectedqa, $qa);
2339      }
2340  
2341      public function test_multichoice_deferredfeedback_qsession591() {
2342          $quiz = (object) array(
2343              'id' => '22',
2344              'course' => '272',
2345              'name' => 'ICT self-assessment quiz',
2346              'intro' => '<p>Work through the ICT skills self-assessment quiz in order to assess your ability to use ICT for study on the Youth Justice Programme. Doing this will also help you to plan a short programme of learning.</p>
2347          <p>Use the questions to rate your ability in each area as either:</p>
2348          <ul>
2349              <li>\'Well developed\'</li>
2350              <li>\'Not sure\', or</li>
2351              <li>\'Needs development\'.</li>
2352          </ul>
2353          <p>Once you have done that, and seen the feedback associated with your answers, you will need to think about prioritising the skills that need development. You will also need to allocate some time in order to develop the skills you need to concentrate on. Within the feedback for each question are some subject-related links which you may find useful.</p>',
2354              'introformat' => FORMAT_HTML,
2355              'questiondecimalpoints' => '-1',
2356              'showuserpicture' => '1',
2357              'showblocks' => '1',
2358              'timeopen' => '0',
2359              'timeclose' => '0',
2360              'preferredbehaviour' => 'deferredfeedback',
2361              'attempts' => '0',
2362              'attemptonlast' => '0',
2363              'grademethod' => '4',
2364              'decimalpoints' => '0',
2365              'review' => '71760879',
2366              'questionsperpage' => '1',
2367              'shufflequestions' => '0',
2368              'shuffleanswers' => '0',
2369              'sumgrades' => '0',
2370              'grade' => '0',
2371              'timecreated' => '0',
2372              'timemodified' => '1174581121',
2373              'password' => '',
2374              'subnet' => '',
2375              'popup' => '0',
2376              'delay1' => '0',
2377              'delay2' => '0',
2378              'timelimit' => '0',
2379          );
2380          $attempt = (object) array(
2381              'id' => '95',
2382              'uniqueid' => '94',
2383              'quiz' => '22',
2384              'userid' => '9721',
2385              'attempt' => '1',
2386              'timestart' => '1177777016',
2387              'timefinish' => '1177777128',
2388              'timemodified' => '1177777101',
2389              'layout' => '242,0,243,0,244,0,245,0,246,0,247,0',
2390              'preview' => '0',
2391              'sumgrades' => '0',
2392          );
2393          $question = (object) array(
2394              'id' => '247',
2395              'category' => '12',
2396              'parent' => '0',
2397              'name' => 'Regular access to a computer',
2398              'questiontext' => '[CUT]',
2399              'questiontextformat' => '1',
2400              'defaultmark' => '0',
2401              'penalty' => '0',
2402              'qtype' => 'multichoice',
2403              'length' => '1',
2404              'stamp' => 'learn.open.ac.uk+070321164105+qIeJ9g',
2405              'hidden' => '0',
2406              'version' => 'learn.open.ac.uk+070427170153+plBFqV',
2407              'generalfeedback' => '',
2408              'generalfeedbackformat' => '1',
2409              'timecreated' => '0',
2410              'timemodified' => '0',
2411              'createdby' => null,
2412              'modifiedby' => null,
2413              'unlimited' => null,
2414              'maxmark' => '0',
2415              'options' => (object) array(
2416                  'id' => '180',
2417                  'question' => '247',
2418                  'layout' => '0',
2419                  'answers' => array(
2420                      666 => (object) array(
2421                          'question' => '247',
2422                          'answer' => 'Well developed',
2423                          'feedback' => 'It\'s good that you don\'t feel as though you will have problems accessing a computer in order to study within the Youth Justice Programme. However, you may find the OU Library\'s information page on <a href="http://library.open.ac.uk/libraries/update/access_computers.html" target="blank"><b>Using public access computers in libraries and other venues</b></a> of interest.',
2424                          'fraction' => '1',
2425                          'id' => 666,
2426                      ),
2427                      667 => (object) array(
2428                          'question' => '247',
2429                          'answer' => 'Not sure',
2430                          'feedback' => 'We recommend that you visit the OU Library\'s information page on <a href="http://library.open.ac.uk/libraries/update/access_computers.html" target="blank"><b>Using public access computers in libraries and other venues</b></a>.',
2431                          'fraction' => '1',
2432                          'id' => 667,
2433                      ),
2434                      668 => (object) array(
2435                          'question' => '247',
2436                          'answer' => 'Needs development',
2437                          'feedback' => 'We recommend that you visit the OU Library\'s information page on <a href="http://library.open.ac.uk/libraries/update/access_computers.html" target="blank"><b>Using public access computers in libraries and other venues</b></a>.',
2438                          'fraction' => '1',
2439                          'id' => 668,
2440                      ),
2441                  ),
2442                  'single' => '1',
2443                  'shuffleanswers' => '0',
2444                  'answernumbering' => 'abc',
2445                  'correctfeedback' => '',
2446                  'partiallycorrectfeedback' => '',
2447                  'incorrectfeedback' => '',
2448              ),
2449              'hints' => false,
2450          );
2451          $qsession = (object) array(
2452              'id' => '591',
2453              'attemptid' => '94',
2454              'questionid' => '247',
2455              'newest' => '1220',
2456              'newgraded' => '1220',
2457              'sumpenalty' => '0',
2458              'manualcomment' => '',
2459              'manualcommentformat' => '1',
2460              'flagged' => '1',
2461          );
2462          $qstates = array(
2463              1208 => (object) array(
2464                  'attempt' => '94',
2465                  'question' => '247',
2466                  'originalquestion' => '0',
2467                  'seq_number' => '0',
2468                  'answer' => '666,667,668:',
2469                  'timestamp' => '1177777016',
2470                  'event' => '0',
2471                  'grade' => '0',
2472                  'raw_grade' => '0',
2473                  'penalty' => '0',
2474                  'id' => 1208,
2475              ),
2476              1219 => (object) array(
2477                  'attempt' => '94',
2478                  'question' => '247',
2479                  'originalquestion' => '0',
2480                  'seq_number' => '1',
2481                  'answer' => '666,667,668:666',
2482                  'timestamp' => '1177777116',
2483                  'event' => '2',
2484                  'grade' => '0',
2485                  'raw_grade' => '0',
2486                  'penalty' => '0',
2487                  'id' => 1219,
2488              ),
2489              1220 => (object) array(
2490                  'attempt' => '94',
2491                  'question' => '247',
2492                  'originalquestion' => '0',
2493                  'seq_number' => '2',
2494                  'answer' => '666,667,668:666',
2495                  'timestamp' => '1177777116',
2496                  'event' => '6',
2497                  'grade' => '0',
2498                  'raw_grade' => '0',
2499                  'penalty' => '0',
2500                  'id' => 1220,
2501              ),
2502          );
2503  
2504          $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
2505  
2506          $expectedqa = (object) array(
2507              'behaviour' => 'deferredfeedback',
2508              'questionid' => 247,
2509              'variant' => 1,
2510              'maxmark' => 0,
2511              'minfraction' => 0,
2512              'maxfraction' => 1,
2513              'flagged' => 0,
2514              'questionsummary' => '[CUT]',
2515              'rightanswer' => 'Well developed',
2516              'responsesummary' => 'Well developed',
2517              'timemodified' => 1177777116,
2518              'steps' => array(
2519                  0 => (object) array(
2520                      'sequencenumber' => 0,
2521                      'state' => 'todo',
2522                      'fraction' => null,
2523                      'timecreated' => 1177777016,
2524                      'userid' => 9721,
2525                      'data' => array('_order' => '666,667,668'),
2526                  ),
2527                  1 => (object) array(
2528                      'sequencenumber' => 1,
2529                      'state' => 'complete',
2530                      'fraction' => null,
2531                      'timecreated' => 1177777116,
2532                      'userid' => 9721,
2533                      'data' => array('answer' => 0),
2534                  ),
2535                  2 => (object) array(
2536                      'sequencenumber' => 2,
2537                      'state' => 'finished',
2538                      'fraction' => null,
2539                      'timecreated' => 1177777116,
2540                      'userid' => 9721,
2541                      'data' => array('answer' => 0, '-finish' => 1),
2542                  ),
2543              ),
2544          );
2545  
2546          $this->compare_qas($expectedqa, $qa);
2547      }
2548  
2549      public function test_multichoice_deferredfeedback_qsession594() {
2550          $quiz = (object) array(
2551              'id' => '22',
2552              'course' => '272',
2553              'name' => 'ICT self-assessment quiz',
2554              'intro' => '<p>Work through the ICT skills self-assessment quiz in order to assess your ability to use ICT for study on the Youth Justice Programme. Doing this will also help you to plan a short programme of learning.</p>
2555          <p>Use the questions to rate your ability in each area as either:</p>
2556          <ul>
2557              <li>\'Well developed\'</li>
2558              <li>\'Not sure\', or</li>
2559              <li>\'Needs development\'.</li>
2560          </ul>
2561          <p>Once you have done that, and seen the feedback associated with your answers, you will need to think about prioritising the skills that need development. You will also need to allocate some time in order to develop the skills you need to concentrate on. Within the feedback for each question are some subject-related links which you may find useful.</p>',
2562              'introformat' => FORMAT_HTML,
2563              'questiondecimalpoints' => '-1',
2564              'showuserpicture' => '1',
2565              'showblocks' => '1',
2566              'timeopen' => '0',
2567              'timeclose' => '0',
2568              'preferredbehaviour' => 'deferredfeedback',
2569              'attempts' => '0',
2570              'attemptonlast' => '0',
2571              'grademethod' => '4',
2572              'decimalpoints' => '0',
2573              'review' => '71760879',
2574              'questionsperpage' => '1',
2575              'shufflequestions' => '0',
2576              'shuffleanswers' => '0',
2577              'sumgrades' => '0',
2578              'grade' => '0',
2579              'timecreated' => '0',
2580              'timemodified' => '1174581121',
2581              'password' => '',
2582              'subnet' => '',
2583              'popup' => '0',
2584              'delay1' => '0',
2585              'delay2' => '0',
2586              'timelimit' => '0',
2587          );
2588          $attempt = (object) array(
2589              'id' => '95',
2590              'uniqueid' => '94',
2591              'quiz' => '22',
2592              'userid' => '9721',
2593              'attempt' => '1',
2594              'timestart' => '1177777016',
2595              'timefinish' => '1177777128',
2596              'timemodified' => '1177777101',
2597              'layout' => '242,0,243,0,244,0,245,0,246,0,247,0',
2598              'preview' => '0',
2599              'sumgrades' => '0',
2600          );
2601          $question = (object) array(
2602              'id' => '242',
2603              'category' => '12',
2604              'parent' => '0',
2605              'name' => 'Using the internet',
2606              'questiontext' => '<p><strong>Using the internet</strong></p>
2607          <p><font face="Verdana,Verdana" size="2">Many study resources are available online, and you will also be expected to find things out yourself using the web.</font></p>
2608          <p><i><font face="Verdana,Verdana" size="2">How would you rate your skills in using browsers and managing documents you find on the internet? </font></i></p>',
2609              'questiontextformat' => '1',
2610              'defaultmark' => '0',
2611              'penalty' => '0',
2612              'qtype' => 'multichoice',
2613              'length' => '1',
2614              'stamp' => 'learn.open.ac.uk+070321161800+WlAJ5D',
2615              'hidden' => '0',
2616              'version' => 'learn.open.ac.uk+070329133200+dO4WQO',
2617              'generalfeedback' => '',
2618              'generalfeedbackformat' => '1',
2619              'timecreated' => '0',
2620              'timemodified' => '0',
2621              'createdby' => null,
2622              'modifiedby' => null,
2623              'unlimited' => null,
2624              'maxmark' => '0',
2625              'options' => (object) array(
2626                  'id' => '175',
2627                  'question' => '242',
2628                  'layout' => '0',
2629                  'answers' => array(
2630                      651 => (object) array(
2631                          'question' => '242',
2632                          'answer' => 'Well developed',
2633                          'feedback' => 'You obviously feel confident about using the internet in order to manage your documentation and find information on the World Wide Web. However, you may still find the OU\'s <a href="http://www.open.ac.uk/webguide/" target="blank"><b>Web Guide</b></a> site of interest.',
2634                          'fraction' => '1',
2635                          'id' => 651,
2636                      ),
2637                      652 => (object) array(
2638                          'question' => '242',
2639                          'answer' => 'Not sure',
2640                          'feedback' => 'We recommend that you visit the OU\'s <a href="http://www.open.ac.uk/webguide/" target="blank"><b>Web Guide</b></a> site and work through some of the tips and advice about using the web effectively.',
2641                          'fraction' => '1',
2642                          'id' => 652,
2643                      ),
2644                      653 => (object) array(
2645                          'question' => '242',
2646                          'answer' => 'Needs development',
2647                          'feedback' => 'We recommend that you visit the OU\'s <a href="http://www.open.ac.uk/webguide/" target="blank"><b>Web Guide</b></a> site and work through some of the tips and advice about using the web effectively.',
2648                          'fraction' => '1',
2649                          'id' => 653,
2650                      ),
2651                  ),
2652                  'single' => '1',
2653                  'shuffleanswers' => '0',
2654                  'answernumbering' => 'abc',
2655                  'correctfeedback' => '',
2656                  'partiallycorrectfeedback' => '',
2657                  'incorrectfeedback' => '',
2658              ),
2659              'hints' => false,
2660          );
2661          $qsession = (object) array(
2662              'id' => '594',
2663              'attemptid' => '94',
2664              'questionid' => '242',
2665              'newest' => '1223',
2666              'newgraded' => '1223',
2667              'sumpenalty' => '0',
2668              'manualcomment' => '',
2669              'manualcommentformat' => '1',
2670              'flagged' => '1',
2671          );
2672          $qstates = array(
2673              1211 => (object) array(
2674                  'attempt' => '94',
2675                  'question' => '242',
2676                  'originalquestion' => '0',
2677                  'seq_number' => '0',
2678                  'answer' => '651,652,653:',
2679                  'timestamp' => '1177777016',
2680                  'event' => '0',
2681                  'grade' => '0',
2682                  'raw_grade' => '0',
2683                  'penalty' => '0',
2684                  'id' => 1211,
2685              ),
2686              1214 => (object) array(
2687                  'attempt' => '94',
2688                  'question' => '242',
2689                  'originalquestion' => '0',
2690                  'seq_number' => '1',
2691                  'answer' => '651,652,653:651',
2692                  'timestamp' => '1177777040',
2693                  'event' => '2',
2694                  'grade' => '0',
2695                  'raw_grade' => '0',
2696                  'penalty' => '0',
2697                  'id' => 1214,
2698              ),
2699              1223 => (object) array(
2700                  'attempt' => '94',
2701                  'question' => '242',
2702                  'originalquestion' => '0',
2703                  'seq_number' => '2',
2704                  'answer' => '651,652,653:651',
2705                  'timestamp' => '1177777040',
2706                  'event' => '6',
2707                  'grade' => '0',
2708                  'raw_grade' => '0',
2709                  'penalty' => '0',
2710                  'id' => 1223,
2711              ),
2712          );
2713  
2714          $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
2715  
2716          $expectedqa = (object) array(
2717              'behaviour' => 'deferredfeedback',
2718              'questionid' => 242,
2719              'variant' => 1,
2720              'maxmark' => 0,
2721              'minfraction' => 0,
2722              'maxfraction' => 1,
2723              'flagged' => 0,
2724              'questionsummary' => "USING THE INTERNET \n\nMany study resources are available online, and you will also be expected to find things out yourself using the web. \n\n_How would you rate your skills in using browsers and managing documents you find on the internet? _",
2725              'rightanswer' => 'Well developed',
2726              'responsesummary' => 'Well developed',
2727              'timemodified' => 1177777040,
2728              'steps' => array(
2729                  0 => (object) array(
2730                      'sequencenumber' => 0,
2731                      'state' => 'todo',
2732                      'fraction' => null,
2733                      'timecreated' => 1177777016,
2734                      'userid' => 9721,
2735                      'data' => array('_order' => '651,652,653'),
2736                  ),
2737                  1 => (object) array(
2738                      'sequencenumber' => 1,
2739                      'state' => 'complete',
2740                      'fraction' => null,
2741                      'timecreated' => 1177777040,
2742                      'userid' => 9721,
2743                      'data' => array('answer' => '0'),
2744                  ),
2745                  2 => (object) array(
2746                      'sequencenumber' => 2,
2747                      'state' => 'finished',
2748                      'fraction' => null,
2749                      'timecreated' => 1177777040,
2750                      'userid' => 9721,
2751                      'data' => array('answer' => '0', '-finish' => 1),
2752                  ),
2753              ),
2754          );
2755  
2756          $this->compare_qas($expectedqa, $qa);
2757      }
2758  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1