Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/question/type/match/db/simpletest/testupgradelibnewqe.php
Go to the documentation of this file.
00001 <?php
00002 // This file is part of Moodle - http://moodle.org/
00003 //
00004 // Moodle is free software: you can redistribute it and/or modify
00005 // it under the terms of the GNU General Public License as published by
00006 // the Free Software Foundation, either version 3 of the License, or
00007 // (at your option) any later version.
00008 //
00009 // Moodle is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00016 
00028 defined('MOODLE_INTERNAL') || die();
00029 
00030 require_once($CFG->dirroot . '/question/engine/upgrade/simpletest/helper.php');
00031 
00032 
00039 class qtype_match_attempt_upgrader_test extends question_attempt_upgrader_test_base {
00040 
00041     public function test_match_deferredfeedback_history6220() {
00042         $quiz = (object) array(
00043             'id' => '72',
00044             'course' => '1181',
00045             'name' => 'Study Guide 4 Quiz',
00046             'intro' => '',
00047             'introformat' => FORMAT_HTML,
00048             'questiondecimalpoints' => '-1',
00049             'showuserpicture' => '1',
00050             'showblocks' => '1',
00051             'timeopen' => '0',
00052             'timeclose' => '0',
00053             'preferredbehaviour' => 'deferredfeedback',
00054             'attempts' => '0',
00055             'attemptonlast' => '1',
00056             'grademethod' => '1',
00057             'decimalpoints' => '2',
00058             'review' => '71760879',
00059             'questionsperpage' => '2',
00060             'shufflequestions' => '0',
00061             'shuffleanswers' => '0',
00062             'questions' => '689,690,0,691,692,0,693,694,0,695,696,0,697,698,0',
00063             'sumgrades' => '48',
00064             'grade' => '48',
00065             'timecreated' => '0',
00066             'timemodified' => '1170427370',
00067             'password' => '',
00068             'subnet' => '',
00069             'popup' => '0',
00070             'delay1' => '0',
00071             'delay2' => '0',
00072             'timelimit' => '0',
00073         );
00074         $attempt = (object) array(
00075             'id' => '3562',
00076             'uniqueid' => '3562',
00077             'quiz' => '72',
00078             'userid' => '91483',
00079             'attempt' => '6',
00080             'sumgrades' => '43',
00081             'timestart' => '1177419915',
00082             'timefinish' => '1177419962',
00083             'timemodified' => '1168015476',
00084             'layout' => '689,690,0,691,692,0,693,694,0,695,696,0,697,698,0',
00085             'preview' => '0',
00086             'needsupgradetonewqe' => '1',
00087         );
00088         $question = (object) array(
00089             'id' => '695',
00090             'category' => '65',
00091             'parent' => '0',
00092             'name' => 'Question 7',
00093             'questiontext' => '<p>Associate the appropriate definition with each term.</p>',
00094             'questiontextformat' => '1',
00095             'defaultmark' => '1',
00096             'penalty' => '0',
00097             'qtype' => 'match',
00098             'length' => '1',
00099             'stamp' => 'learn.open.ac.uk+061123110024+a0RsuG',
00100             'version' => 'learn.open.ac.uk+061123163015+Oe63zC',
00101             'hidden' => '0',
00102             'generalfeedback' => 'For further information about this question see Study Guide 4 SAQ 3.1',
00103             'generalfeedbackformat' => '1',
00104             'timecreated' => '0',
00105             'timemodified' => '0',
00106             'createdby' => null,
00107             'modifiedby' => null,
00108             'unlimited' => null,
00109             'maxmark' => '3',
00110             'options' => (object) array(
00111                 'id' => '27',
00112                 'question' => '695',
00113                 'subquestions' => array(
00114                     148 => (object) array(
00115                         'code' => '511093512',
00116                         'question' => '695',
00117                         'questiontext' => 'Active adjacent system',
00118                         'answertext' => 'A system that interacts with or participates in the work.',
00119                         'id' => 148,
00120                     ),
00121                     149 => (object) array(
00122                         'code' => '10881658',
00123                         'question' => '695',
00124                         'questiontext' => 'Autonomous adjacent system',
00125                         'answertext' => 'An external entity that acts independently of the work under study.',
00126                         'id' => 149,
00127                     ),
00128                     150 => (object) array(
00129                         'code' => '661953276',
00130                         'question' => '695',
00131                         'questiontext' => 'Cooperative adjacent system',
00132                         'answertext' => 'A system that is involved in the response to a business event.',
00133                         'id' => 150,
00134                     ),
00135                     151 => (object) array(
00136                         'code' => '786218388',
00137                         'question' => '695',
00138                         'questiontext' => '',
00139                         'answertext' => 'A system which does not supply or receive data from the work.',
00140                         'id' => 151,
00141                     ),
00142                     152 => (object) array(
00143                         'code' => '166673328',
00144                         'question' => '695',
00145                         'questiontext' => '',
00146                         'answertext' => 'An external entity that performs part of the work under study.',
00147                         'id' => 152,
00148                     ),
00149                 ),
00150                 'shuffleanswers' => '1',
00151                 'correctfeedback' => '',
00152                 'partiallycorrectfeedback' => '',
00153                 'incorrectfeedback' => '',
00154                 'correctresponsesfeedback' => '0',
00155             ),
00156             'hints' => false,
00157         );
00158         $qsession = (object) array(
00159             'id' => '33092',
00160             'attemptid' => '3562',
00161             'questionid' => '695',
00162             'newest' => '79626',
00163             'newgraded' => '79626',
00164             'sumpenalty' => '0',
00165             'manualcomment' => '',
00166             'manualcommentformat' => '1',
00167             'flagged' => '1',
00168         );
00169         $qstates = array(
00170             79604 => (object) array(
00171                 'attempt' => '3562',
00172                 'question' => '695',
00173                 'originalquestion' => '0',
00174                 'seq_number' => '0',
00175                 'answer' => '148-0,149-0,150-0,151-0,152-0',
00176                 'timestamp' => '1177419915',
00177                 'event' => '0',
00178                 'grade' => '0',
00179                 'raw_grade' => '0',
00180                 'penalty' => '0',
00181                 'id' => 79604,
00182             ),
00183             79614 => (object) array(
00184                 'attempt' => '3562',
00185                 'question' => '695',
00186                 'originalquestion' => '0',
00187                 'seq_number' => '1',
00188                 'answer' => '148-511093512,149-786218388,150-166673328,151-0,152-0',
00189                 'timestamp' => '1177419855',
00190                 'event' => '2',
00191                 'grade' => '0',
00192                 'raw_grade' => '1',
00193                 'penalty' => '0',
00194                 'id' => 79614,
00195             ),
00196             79619 => (object) array(
00197                 'attempt' => '3562',
00198                 'question' => '695',
00199                 'originalquestion' => '0',
00200                 'seq_number' => '2',
00201                 'answer' => '148-511093512,149-10881658,150-661953276,151-0,152-0',
00202                 'timestamp' => '1177419956',
00203                 'event' => '2',
00204                 'grade' => '0',
00205                 'raw_grade' => '3',
00206                 'penalty' => '0',
00207                 'id' => 79619,
00208             ),
00209             79626 => (object) array(
00210                 'attempt' => '3562',
00211                 'question' => '695',
00212                 'originalquestion' => '0',
00213                 'seq_number' => '3',
00214                 'answer' => '148-511093512,149-10881658,150-661953276,151-0,152-0',
00215                 'timestamp' => '1177419956',
00216                 'event' => '6',
00217                 'grade' => '3',
00218                 'raw_grade' => '3',
00219                 'penalty' => '0',
00220                 'id' => 79626,
00221             ),
00222         );
00223 
00224         $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
00225 
00226         $expectedqa = (object) array(
00227             'behaviour' => 'deferredfeedback',
00228             'questionid' => 695,
00229             'variant' => 1,
00230             'maxmark' => 3,
00231             'minfraction' => 0,
00232             'flagged' => 0,
00233             'questionsummary' => 'Associate the appropriate definition with each term. {Active adjacent system; Autonomous adjacent system; Cooperative adjacent system} -> {A system that interacts with or participates in the work.; An external entity that acts independently of the work under study.; A system that is involved in the response to a business event.; A system which does not supply or receive data from the work.; An external entity that performs part of the work under study.}',
00234             'rightanswer' => 'Active adjacent system -> A system that interacts with or participates in the work.; Autonomous adjacent system -> An external entity that acts independently of the work under study.; Cooperative adjacent system -> A system that is involved in the response to a business event.',
00235             'responsesummary' => 'Active adjacent system -> A system that interacts with or participates in the work.; Autonomous adjacent system -> An external entity that acts independently of the work under study.; Cooperative adjacent system -> A system that is involved in the response to a business event.',
00236             'timemodified' => 1177419956,
00237             'steps' => array(
00238                 0 => (object) array(
00239                     'sequencenumber' => 0,
00240                     'state' => 'todo',
00241                     'fraction' => null,
00242                     'timecreated' => 1177419915,
00243                     'userid' => 91483,
00244                     'data' => array('_stemorder' => '148,149,150', '_choiceorder' => 'todo - see below'),
00245                 ),
00246                 1 => (object) array(
00247                     'sequencenumber' => 1,
00248                     'state' => 'complete',
00249                     'fraction' => null,
00250                     'timecreated' => 1177419855,
00251                     'userid' => 91483,
00252                     'data' => array('sub0' => 148, 'sub1' => 151, 'sub2' => 152),
00253                 ),
00254                 2 => (object) array(
00255                     'sequencenumber' => 2,
00256                     'state' => 'complete',
00257                     'fraction' => null,
00258                     'timecreated' => 1177419956,
00259                     'userid' => 91483,
00260                     'data' => array('sub0' => 148, 'sub1' => 149, 'sub2' => 150),
00261                 ),
00262                 3 => (object) array(
00263                     'sequencenumber' => 3,
00264                     'state' => 'gradedright',
00265                     'fraction' => 1,
00266                     'timecreated' => 1177419956,
00267                     'userid' => 91483,
00268                     'data' => array('sub0' => 148, 'sub1' => 149, 'sub2' => 150, '-finish' => 1),
00269                 ),
00270             ),
00271         );
00272 
00273         // This is a random thing, so just set expected to actual:
00274         $expectedqa->steps[0]->data['_choiceorder'] = $qa->steps[0]->data['_choiceorder'];
00275         $order = explode(',', $qa->steps[0]->data['_choiceorder']);
00276         $order = array_combine(array_values($order), array_keys($order));
00277         for ($i = 1; $i <= 3; $i++) {
00278             for ($sub = 0; $sub < 3; $sub++) {
00279                 $expectedqa->steps[$i]->data['sub' . $sub] =
00280                         $order[$expectedqa->steps[$i]->data['sub' . $sub]] + 1;
00281             }
00282         }
00283 
00284         $this->compare_qas($expectedqa, $qa);
00285     }
00286 
00287     public function test_match_deferredfeedback_history60() {
00288         $quiz = (object) array(
00289             'id' => '60',
00290             'course' => '2304',
00291             'name' => 'Types of resources available quiz',
00292             'intro' => 'This quiz covers the different types of information resources available and how to select which is most appropriate. ',
00293             'introformat' => FORMAT_HTML,
00294             'questiondecimalpoints' => '-1',
00295             'showuserpicture' => '1',
00296             'showblocks' => '1',
00297             'timeopen' => '1164153600',
00298             'timeclose' => '1606003200',
00299             'preferredbehaviour' => 'deferredfeedback',
00300             'attempts' => '0',
00301             'attemptonlast' => '0',
00302             'grademethod' => '1',
00303             'decimalpoints' => '3',
00304             'review' => '71752557',
00305             'questionsperpage' => '1',
00306             'shufflequestions' => '0',
00307             'shuffleanswers' => '0',
00308             'questions' => '509,0,510,0,511,0,738,0,514,0',
00309             'sumgrades' => '5',
00310             'grade' => '10',
00311             'timecreated' => '0',
00312             'timemodified' => '1170245956',
00313             'password' => '',
00314             'subnet' => '',
00315             'popup' => '0',
00316             'delay1' => '0',
00317             'delay2' => '0',
00318             'timelimit' => '0',
00319         );
00320         $attempt = (object) array(
00321             'id' => '1065',
00322             'uniqueid' => '1065',
00323             'quiz' => '60',
00324             'userid' => '182682',
00325             'attempt' => '1',
00326             'sumgrades' => '3.99998',
00327             'timestart' => '1168267317',
00328             'timefinish' => '1168267508',
00329             'timemodified' => '1168267508',
00330             'layout' => '509,510,511,738,514,0',
00331             'preview' => '0',
00332             'needsupgradetonewqe' => '1',
00333         );
00334         $question = (object) array(
00335             'id' => '738',
00336             'category' => '60',
00337             'parent' => '0',
00338             'name' => 'TR004',
00339             'questiontext' => '<p>Which of the following statements about subject gateways are true, and which are false? </p>',
00340             'questiontextformat' => '1',
00341             'defaultmark' => '1',
00342             'penalty' => '0.1',
00343             'qtype' => 'match',
00344             'length' => '1',
00345             'stamp' => 'learn.open.ac.uk+061128151507+CLevuJ',
00346             'version' => 'learn.open.ac.uk+070108115531+VvJurj',
00347             'hidden' => '0',
00348             'generalfeedback' => '<UL><LI>Subject gateways provide links to sites that have been quality checked = True</LI>
00349         <LI>Subject gateways offer more variety than search engines = False</LI>
00350         <LI>Subject gateways index websites automatically = False</LI>
00351         <LI>Subject gateways can provide a more direct route to websites containing academic content = True</LI>
00352         </UL>',
00353             'generalfeedbackformat' => '1',
00354             'timecreated' => '0',
00355             'timemodified' => '0',
00356             'createdby' => null,
00357             'modifiedby' => null,
00358             'unlimited' => null,
00359             'maxmark' => '1',
00360             'options' => (object) array(
00361                 'id' => '35',
00362                 'question' => '738',
00363                 'subquestions' => array(
00364                     213 => (object) array(
00365                         'code' => '860968335',
00366                         'question' => '738',
00367                         'questiontext' => 'Subject gateways provide links to sites that have been quality checked ',
00368                         'answertext' => 'True',
00369                         'id' => 213,
00370                     ),
00371                     214 => (object) array(
00372                         'code' => '253006016',
00373                         'question' => '738',
00374                         'questiontext' => 'Subject gateways offer more variety than search engines ',
00375                         'answertext' => 'False',
00376                         'id' => 214,
00377                     ),
00378                     215 => (object) array(
00379                         'code' => '964910717',
00380                         'question' => '738',
00381                         'questiontext' => 'Subject gateways index websites automatically',
00382                         'answertext' => 'False',
00383                         'id' => 215,
00384                     ),
00385                     216 => (object) array(
00386                         'code' => '3109713',
00387                         'question' => '738',
00388                         'questiontext' => 'Subject gateways can provide a more direct route to websites containing academic content ',
00389                         'answertext' => 'True',
00390                         'id' => 216,
00391                     ),
00392                 ),
00393                 'shuffleanswers' => '1',
00394                 'correctfeedback' => '',
00395                 'partiallycorrectfeedback' => '',
00396                 'incorrectfeedback' => '',
00397                 'correctresponsesfeedback' => '0',
00398             ),
00399             'hints' => false,
00400         );
00401         $qsession = (object) array(
00402             'id' => '9258',
00403             'attemptid' => '1065',
00404             'questionid' => '738',
00405             'newest' => '24966',
00406             'newgraded' => '24966',
00407             'sumpenalty' => '0',
00408             'manualcomment' => '',
00409             'manualcommentformat' => '1',
00410             'flagged' => '1',
00411         );
00412         $qstates = array(
00413             24961 => (object) array(
00414                 'attempt' => '1065',
00415                 'question' => '738',
00416                 'originalquestion' => '0',
00417                 'seq_number' => '0',
00418                 'answer' => '213-0,214-0,215-0,216-0',
00419                 'timestamp' => '1168267317',
00420                 'event' => '0',
00421                 'grade' => '0',
00422                 'raw_grade' => '0',
00423                 'penalty' => '0',
00424                 'id' => 24961,
00425             ),
00426             24966 => (object) array(
00427                 'attempt' => '1065',
00428                 'question' => '738',
00429                 'originalquestion' => '0',
00430                 'seq_number' => '1',
00431                 'answer' => '213-860968335,214-253006016,215-964910717,216-3109713',
00432                 'timestamp' => '1168267508',
00433                 'event' => '6',
00434                 'grade' => '1',
00435                 'raw_grade' => '1',
00436                 'penalty' => '0.1',
00437                 'id' => 24966,
00438             ),
00439         );
00440 
00441         $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
00442 
00443         $expectedqa = (object) array(
00444             'behaviour' => 'deferredfeedback',
00445             'questionid' => 738,
00446             'variant' => 1,
00447             'maxmark' => 1,
00448             'minfraction' => 0,
00449             'flagged' => 0,
00450             'questionsummary' => 'Which of the following statements about subject gateways are true, and which are false? {Subject gateways provide links to sites that have been quality checked; Subject gateways offer more variety than search engines; Subject gateways index websites automatically; Subject gateways can provide a more direct route to websites containing academic content} -> {True; False}',
00451             'rightanswer' => 'Subject gateways provide links to sites that have been quality checked -> True; Subject gateways offer more variety than search engines -> False; Subject gateways index websites automatically -> False; Subject gateways can provide a more direct route to websites containing academic content -> True',
00452             'responsesummary' => 'Subject gateways provide links to sites that have been quality checked -> True; Subject gateways offer more variety than search engines -> False; Subject gateways index websites automatically -> False; Subject gateways can provide a more direct route to websites containing academic content -> True',
00453             'timemodified' => 1168267508,
00454             'steps' => array(
00455                 0 => (object) array(
00456                     'sequencenumber' => 0,
00457                     'state' => 'todo',
00458                     'fraction' => null,
00459                     'timecreated' => 1168267317,
00460                     'userid' => 182682,
00461                     'data' => array('_stemorder' => '213,214,215,216', '_choiceorder' => 'todo - see below'),
00462                 ),
00463                 1 => (object) array(
00464                     'sequencenumber' => 1,
00465                     'state' => 'gradedright',
00466                     'fraction' => 1,
00467                     'timecreated' => 1168267508,
00468                     'userid' => 182682,
00469                     'data' => array('sub0' => 213, 'sub1' => 214,'sub2' => 214,'sub3' => 213, '-finish' => 1),
00470                 ),
00471             ),
00472         );
00473 
00474         // This is a random thing, so just set expected to actual:
00475         $expectedqa->steps[0]->data['_choiceorder'] = $qa->steps[0]->data['_choiceorder'];
00476         $order = explode(',', $qa->steps[0]->data['_choiceorder']);
00477         $order = array_combine(array_values($order), array_keys($order));
00478         for ($i = 1; $i <= 1; $i++) {
00479             for ($sub = 0; $sub < 4; $sub++) {
00480                 $expectedqa->steps[$i]->data['sub' . $sub] =
00481                         $order[$expectedqa->steps[$i]->data['sub' . $sub]] + 1;
00482             }
00483         }
00484 
00485         $this->compare_qas($expectedqa, $qa);
00486     }
00487 
00488     public function test_match_deferredfeedback_history622220() {
00489         $quiz = (object) array(
00490             'id' => '719',
00491             'course' => '3541',
00492             'name' => 'Types of resources quiz',
00493             'intro' => '',
00494             'introformat' => FORMAT_HTML,
00495             'questiondecimalpoints' => '-1',
00496             'showuserpicture' => '1',
00497             'showblocks' => '1',
00498             'timeopen' => '0',
00499             'timeclose' => '0',
00500             'preferredbehaviour' => 'deferredfeedback',
00501             'attempts' => '0',
00502             'attemptonlast' => '0',
00503             'grademethod' => '1',
00504             'decimalpoints' => '2',
00505             'review' => '71760879',
00506             'questionsperpage' => '1',
00507             'shufflequestions' => '0',
00508             'shuffleanswers' => '1',
00509             'questions' => '11163,0,11164,0,11165,0,11135,0,11166,0',
00510             'sumgrades' => '5',
00511             'grade' => '10',
00512             'timecreated' => '0',
00513             'timemodified' => '1193678199',
00514             'password' => '',
00515             'subnet' => '',
00516             'popup' => '0',
00517             'delay1' => '0',
00518             'delay2' => '0',
00519             'timelimit' => '0',
00520         );
00521         $attempt = (object) array(
00522             'id' => '23777',
00523             'uniqueid' => '23777',
00524             'quiz' => '719',
00525             'userid' => '6584',
00526             'attempt' => '1',
00527             'sumgrades' => '3.91664',
00528             'timestart' => '1200506648',
00529             'timefinish' => '1200507571',
00530             'timemodified' => '1200506959',
00531             'layout' => '11163,0,11164,0,11165,0,11135,0,11166,0',
00532             'preview' => '0',
00533             'needsupgradetonewqe' => '1',
00534         );
00535         $question = (object) array(
00536             'id' => '11135',
00537             'category' => '675',
00538             'parent' => '0',
00539             'name' => 'TR004',
00540             'questiontext' => '<p>Which of the following statements about subject gateways are true, and which are false? </p>',
00541             'questiontextformat' => '0',
00542             'defaultmark' => '1',
00543             'penalty' => '0.1',
00544             'qtype' => 'match',
00545             'length' => '1',
00546             'stamp' => 'learn.open.ac.uk+071023110917+tqaM6z',
00547             'version' => 'learn.open.ac.uk+071023110917+Ia7Hpz',
00548             'hidden' => '0',
00549             'generalfeedback' => '<ul>
00550             <li>Subject gateways provide links to sites that have been quality checked = True </li>
00551  </ul>
00552  <p>All links in a subject gateway have been added by a knowledgeable subject specialist and so have to be of a certain quality to be added to the collection.</p>
00553  <ul>
00554             <li>Subject gateways offer more variety than search engines = False </li>
00555  </ul>
00556  <p>Subject gateways will most likely provide fewer links than a search engine, but this is because they are selected with a particular subject area in mind </p>
00557  <ul>
00558             <li>Subject gateways index websites automatically = False </li>
00559  </ul>
00560  <p>Subject gateways links are indexed by knowledgeable subject specialists rather than a machine. </p>
00561  <ul>
00562             <li>Subject gateways can provide a more direct route to websites containing academic content = True </li>
00563  </ul>
00564  <p>All links in a subject gateway have been added by a knowledgeable subject specialist and so you can find academic content easier than using a web search engine.</p>',
00565             'generalfeedbackformat' => '1',
00566             'timecreated' => '0',
00567             'timemodified' => '0',
00568             'createdby' => null,
00569             'modifiedby' => null,
00570             'unlimited' => null,
00571             'maxmark' => '1',
00572             'options' => (object) array(
00573                 'id' => '279',
00574                 'question' => '11135',
00575                 'subquestions' => array(
00576                     1632 => (object) array(
00577                         'code' => '315604704',
00578                         'question' => '11135',
00579                         'questiontext' => 'Subject gateways provide links to sites that have been quality checked',
00580                         'answertext' => 'True',
00581                         'id' => 1632,
00582                     ),
00583                     1633 => (object) array(
00584                         'code' => '750106618',
00585                         'question' => '11135',
00586                         'questiontext' => 'Subject gateways offer more variety than search engines',
00587                         'answertext' => 'False',
00588                         'id' => 1633,
00589                     ),
00590                     1634 => (object) array(
00591                         'code' => '446418834',
00592                         'question' => '11135',
00593                         'questiontext' => 'Subject gateways index websites automatically',
00594                         'answertext' => 'False',
00595                         'id' => 1634,
00596                     ),
00597                     1635 => (object) array(
00598                         'code' => '3262827',
00599                         'question' => '11135',
00600                         'questiontext' => 'Subject gateways can provide a more direct route to websites containing academic content',
00601                         'answertext' => 'True',
00602                         'id' => 1635,
00603                     ),
00604                 ),
00605                 'shuffleanswers' => '1',
00606                 'correctfeedback' => '',
00607                 'partiallycorrectfeedback' => '',
00608                 'incorrectfeedback' => '',
00609                 'correctresponsesfeedback' => '0',
00610             ),
00611             'hints' => false,
00612         );
00613         $qsession = (object) array(
00614             'id' => '356418',
00615             'attemptid' => '23777',
00616             'questionid' => '11135',
00617             'newest' => '862740',
00618             'newgraded' => '862740',
00619             'sumpenalty' => '0.1',
00620             'manualcomment' => '',
00621             'manualcommentformat' => '1',
00622             'flagged' => '1',
00623         );
00624         $qstates = array(
00625             862587 => (object) array(
00626                 'attempt' => '23777',
00627                 'question' => '11135',
00628                 'originalquestion' => '0',
00629                 'seq_number' => '0',
00630                 'answer' => '1633-0,1635-0,1634-0,1632-0',
00631                 'timestamp' => '1200506648',
00632                 'event' => '0',
00633                 'grade' => '0',
00634                 'raw_grade' => '0',
00635                 'penalty' => '0',
00636                 'id' => 862587,
00637             ),
00638             862638 => (object) array(
00639                 'attempt' => '23777',
00640                 'question' => '11135',
00641                 'originalquestion' => '0',
00642                 'seq_number' => '1',
00643                 'answer' => '1633-750106618,1635-3262827,1634-0,1632-315604704',
00644                 'timestamp' => '1200507025',
00645                 'event' => '2',
00646                 'grade' => '0',
00647                 'raw_grade' => '0.75',
00648                 'penalty' => '0.1',
00649                 'id' => 862638,
00650             ),
00651             862668 => (object) array(
00652                 'attempt' => '23777',
00653                 'question' => '11135',
00654                 'originalquestion' => '0',
00655                 'seq_number' => '2',
00656                 'answer' => '1633-750106618,1635-3262827,1634-0,1632-315604704',
00657                 'timestamp' => '1200507125',
00658                 'event' => '2',
00659                 'grade' => '0',
00660                 'raw_grade' => '0.75',
00661                 'penalty' => '0.1',
00662                 'id' => 862668,
00663             ),
00664             862673 => (object) array(
00665                 'attempt' => '23777',
00666                 'question' => '11135',
00667                 'originalquestion' => '0',
00668                 'seq_number' => '3',
00669                 'answer' => '1633-750106618,1635-3262827,1634-0,1632-315604704',
00670                 'timestamp' => '1200507172',
00671                 'event' => '2',
00672                 'grade' => '0',
00673                 'raw_grade' => '0.75',
00674                 'penalty' => '0.1',
00675                 'id' => 862673,
00676             ),
00677             862716 => (object) array(
00678                 'attempt' => '23777',
00679                 'question' => '11135',
00680                 'originalquestion' => '0',
00681                 'seq_number' => '4',
00682                 'answer' => '1633-750106618,1635-3262827,1634-3262827,1632-315604704',
00683                 'timestamp' => '1200507467',
00684                 'event' => '2',
00685                 'grade' => '0',
00686                 'raw_grade' => '0.75',
00687                 'penalty' => '0.1',
00688                 'id' => 862716,
00689             ),
00690             862740 => (object) array(
00691                 'attempt' => '23777',
00692                 'question' => '11135',
00693                 'originalquestion' => '0',
00694                 'seq_number' => '5',
00695                 'answer' => '1633-750106618,1635-3262827,1634-3262827,1632-315604704',
00696                 'timestamp' => '1200507467',
00697                 'event' => '6',
00698                 'grade' => '0.75',
00699                 'raw_grade' => '0.75',
00700                 'penalty' => '0.1',
00701                 'id' => 862740,
00702             ),
00703         );
00704 
00705         $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
00706 
00707         $expectedqa = (object) array(
00708             'behaviour' => 'deferredfeedback',
00709             'questionid' => 11135,
00710             'variant' => 1,
00711             'maxmark' => 1,
00712             'minfraction' => 0,
00713             'flagged' => 0,
00714             'questionsummary' => 'Which of the following statements about subject gateways are true, and which are false? {Subject gateways provide links to sites that have been quality checked; Subject gateways offer more variety than search engines; Subject gateways index websites automatically; Subject gateways can provide a more direct route to websites containing academic content} -> {True; False}',
00715             'rightanswer' => 'Subject gateways provide links to sites that have been quality checked -> True; Subject gateways offer more variety than search engines -> False; Subject gateways index websites automatically -> False; Subject gateways can provide a more direct route to websites containing academic content -> True',
00716             'responsesummary' => 'Subject gateways offer more variety than search engines -> False; Subject gateways can provide a more direct route to websites containing academic content -> True; Subject gateways index websites automatically -> True; Subject gateways provide links to sites that have been quality checked -> True',
00717             'timemodified' => 1200507467,
00718             'steps' => array(
00719                 0 => (object) array(
00720                     'sequencenumber' => 0,
00721                     'state' => 'todo',
00722                     'fraction' => null,
00723                     'timecreated' => 1200506648,
00724                     'userid' => 6584,
00725                     'data' => array('_stemorder' => '1633,1635,1634,1632', '_choiceorder' => 'todo - see below'),
00726                 ),
00727                 1 => (object) array(
00728                     'sequencenumber' => 1,
00729                     'state' => 'complete',
00730                     'fraction' => null,
00731                     'timecreated' => 1200507025,
00732                     'userid' => 6584,
00733                     'data' => array('sub0' => 1633, 'sub1' => 1632, 'sub2' => 0, 'sub3' => 1632),
00734                 ),
00735                 2 => (object) array(
00736                     'sequencenumber' => 2,
00737                     'state' => 'complete',
00738                     'fraction' => null,
00739                     'timecreated' => 1200507125,
00740                     'userid' => 6584,
00741                     'data' => array('sub0' => 1633, 'sub1' => 1632, 'sub2' => 0, 'sub3' => 1632),
00742                 ),
00743                 3 => (object) array(
00744                     'sequencenumber' => 3,
00745                     'state' => 'complete',
00746                     'fraction' => null,
00747                     'timecreated' => 1200507172,
00748                     'userid' => 6584,
00749                     'data' => array('sub0' => 1633, 'sub1' => 1632, 'sub2' => 0, 'sub3' => 1632),
00750                 ),
00751                 4 => (object) array(
00752                     'sequencenumber' => 4,
00753                     'state' => 'complete',
00754                     'fraction' => null,
00755                     'timecreated' => 1200507467,
00756                     'userid' => 6584,
00757                     'data' => array('sub0' => 1633, 'sub1' => 1632, 'sub2' => 1632, 'sub3' => 1632),
00758                 ),
00759                 5 => (object) array(
00760                     'sequencenumber' => 5,
00761                     'state' => 'gradedpartial',
00762                     'fraction' => 0.75,
00763                     'timecreated' => 1200507467,
00764                     'userid' => 6584,
00765                     'data' => array('sub0' => 1633, 'sub1' => 1632, 'sub2' => 1632, 'sub3' => 1632, '-finish' => 1),
00766                 ),
00767             ),
00768         );
00769 
00770         // This is a random thing, so just set expected to actual:
00771         $expectedqa->steps[0]->data['_choiceorder'] = $qa->steps[0]->data['_choiceorder'];
00772         $order = explode(',', $qa->steps[0]->data['_choiceorder']);
00773         $order = array_combine(array_values($order), array_keys($order));
00774         for ($i = 1; $i <= 5; $i++) {
00775             for ($sub = 0; $sub < 5; $sub++) {
00776                 if (!array_key_exists('sub' . $sub, $expectedqa->steps[$i]->data) ||
00777                         $expectedqa->steps[$i]->data['sub' . $sub] == 0) {
00778                     continue;
00779                 }
00780                 $expectedqa->steps[$i]->data['sub' . $sub] =
00781                         $order[$expectedqa->steps[$i]->data['sub' . $sub]] + 1;
00782             }
00783         }
00784 
00785         $this->compare_qas($expectedqa, $qa);
00786     }
00787 }
 All Data Structures Namespaces Files Functions Variables Enumerations