Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/question/type/truefalse/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_truefalse_attempt_upgrader_test extends question_attempt_upgrader_test_base {
00040 
00041     public function test_truefalse_deferredfeedback_history620() {
00042         $quiz = (object) array(
00043             'id' => '203',
00044             'course' => '2359',
00045             'name' => 'Quiz 1',
00046             'intro' => '',
00047             'introformat' => FORMAT_HTML,
00048             'timeopen' => '0',
00049             'timeclose' => '0',
00050             'preferredbehaviour' => 'deferredfeedback',
00051             'attempts' => '0',
00052             'attemptonlast' => '1',
00053             'grademethod' => '1',
00054             'decimalpoints' => '2',
00055             'review' => '71760879',
00056             'questionsperpage' => '2',
00057             'questiondecimalpoints' => '-1',
00058             'showuserpicture' => '1',
00059             'showblocks' => '1',
00060             'shufflequestions' => '0',
00061             'shuffleanswers' => '0',
00062             'questions' => '3859,3860,0,3861,3862,0,3863,3864,0,3865,3866,0,3867,3868,0',
00063             'sumgrades' => '50',
00064             'grade' => '50',
00065             'timecreated' => '0',
00066             'timemodified' => '1176461532',
00067             'password' => '',
00068             'subnet' => '',
00069             'popup' => '0',
00070             'delay1' => '0',
00071             'delay2' => '0',
00072             'timelimit' => '0',
00073         );
00074         $attempt = (object) array(
00075             'id' => '3795',
00076             'uniqueid' => '3795',
00077             'quiz' => '203',
00078             'userid' => '1888',
00079             'attempt' => '1',
00080             'sumgrades' => '40',
00081             'timestart' => '1177841172',
00082             'timefinish' => '1177841409',
00083             'timemodified' => '1177841394',
00084             'layout' => '3859,3860,0,3861,3862,0,3863,3864,0,3865,3866,0,3867,3868,0',
00085             'preview' => '0',
00086             'needsupgradetonewqe' => '1',
00087         );
00088         $question = (object) array(
00089             'id' => '3865',
00090             'category' => '187',
00091             'parent' => '0',
00092             'name' => 'Question 7',
00093             'questiontext' => '<p>The term ‘integration server’ is another name for an application server, true or false?</p>',
00094             'questiontextformat' => '1',
00095             'defaultmark' => '1',
00096             'penalty' => '0',
00097             'qtype' => 'truefalse',
00098             'length' => '1',
00099             'stamp' => 'learn.open.ac.uk+070404143040+oLimmG',
00100             'version' => 'learn.open.ac.uk+070405112705+DLhORU',
00101             'hidden' => '0',
00102             'generalfeedback' => '<p></p>',
00103             'generalfeedbackformat' => '1',
00104             'timecreated' => '0',
00105             'timemodified' => '0',
00106             'createdby' => null,
00107             'modifiedby' => null,
00108             'unlimited' => null,
00109             'maxmark' => '5',
00110             'options' => (object) array(
00111                 'id' => '98',
00112                 'question' => '3865',
00113                 'trueanswer' => '11693',
00114                 'falseanswer' => '11694',
00115                 'answers' => array(
00116                     11693 => (object) array(
00117                         'question' => '3865',
00118                         'answer' => 'True',
00119                         'fraction' => '0',
00120                         'feedback' => '',
00121                         'id' => 11693,
00122                     ),
00123                     11694 => (object) array(
00124                         'question' => '3865',
00125                         'answer' => 'False',
00126                         'fraction' => '1',
00127                         'feedback' => '',
00128                         'id' => 11694,
00129                     ),
00130                 ),
00131             ),
00132             'hints' => false,
00133         );
00134         $qsession = (object) array(
00135             'id' => '35137',
00136             'attemptid' => '3795',
00137             'questionid' => '3865',
00138             'newest' => '84791',
00139             'newgraded' => '84791',
00140             'sumpenalty' => '0',
00141             'manualcomment' => '',
00142             'manualcommentformat' => '1',
00143             'flagged' => '1',
00144         );
00145         $qstates = array(
00146             84771 => (object) array(
00147                 'attempt' => '3795',
00148                 'question' => '3865',
00149                 'originalquestion' => '0',
00150                 'seq_number' => '0',
00151                 'answer' => '',
00152                 'timestamp' => '1177841172',
00153                 'event' => '0',
00154                 'grade' => '0',
00155                 'raw_grade' => '0',
00156                 'penalty' => '0',
00157                 'id' => 84771,
00158             ),
00159             84785 => (object) array(
00160                 'attempt' => '3795',
00161                 'question' => '3865',
00162                 'originalquestion' => '0',
00163                 'seq_number' => '1',
00164                 'answer' => '11694',
00165                 'timestamp' => '1177841361',
00166                 'event' => '2',
00167                 'grade' => '0',
00168                 'raw_grade' => '5',
00169                 'penalty' => '5',
00170                 'id' => 84785,
00171             ),
00172             84791 => (object) array(
00173                 'attempt' => '3795',
00174                 'question' => '3865',
00175                 'originalquestion' => '0',
00176                 'seq_number' => '2',
00177                 'answer' => '11694',
00178                 'timestamp' => '1177841361',
00179                 'event' => '6',
00180                 'grade' => '5',
00181                 'raw_grade' => '5',
00182                 'penalty' => '5',
00183                 'id' => 84791,
00184             ),
00185         );
00186 
00187         $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
00188 
00189         $expectedqa = (object) array(
00190             'behaviour' => 'deferredfeedback',
00191             'questionid' => 3865,
00192             'variant' => 1,
00193             'maxmark' => 5,
00194             'minfraction' => 0,
00195             'flagged' => 0,
00196             'questionsummary' => 'The term ‘integration server’ is another name for an application server, true or false?',
00197             'rightanswer' => 'False',
00198             'responsesummary' => 'False',
00199             'timemodified' => 1177841361,
00200             'steps' => array(
00201                 0 => (object) array(
00202                     'sequencenumber' => 0,
00203                     'state' => 'todo',
00204                     'fraction' => null,
00205                     'timecreated' => 1177841172,
00206                     'userid' => 1888,
00207                     'data' => array(),
00208                 ),
00209                 1 => (object) array(
00210                     'sequencenumber' => 1,
00211                     'state' => 'complete',
00212                     'fraction' => null,
00213                     'timecreated' => 1177841361,
00214                     'userid' => 1888,
00215                     'data' => array('answer' => 0),
00216                 ),
00217                 2 => (object) array(
00218                     'sequencenumber' => 2,
00219                     'state' => 'gradedright',
00220                     'fraction' => 1,
00221                     'timecreated' => 1177841361,
00222                     'userid' => 1888,
00223                     'data' => array('answer' => 0, '-finish' => 1),
00224                 ),
00225             ),
00226         );
00227 
00228         $this->compare_qas($expectedqa, $qa);
00229     }
00230 
00231     public function test_truefalse_deferredfeedback_history20() {
00232         $quiz = (object) array(
00233             'id' => '551',
00234             'course' => '2828',
00235             'name' => 'Unit 4 Quiz',
00236             'intro' => '',
00237             'introformat' => FORMAT_HTML,
00238             'questiondecimalpoints' => '-1',
00239             'showuserpicture' => '1',
00240             'showblocks' => '1',
00241             'timeopen' => '0',
00242             'timeclose' => '0',
00243             'preferredbehaviour' => 'deferredfeedback',
00244             'attempts' => '0',
00245             'attemptonlast' => '0',
00246             'grademethod' => '1',
00247             'decimalpoints' => '2',
00248             'review' => '71760879',
00249             'questionsperpage' => '1',
00250             'shufflequestions' => '0',
00251             'shuffleanswers' => '1',
00252             'questions' => '9043,0,9057,0,9062,0,9241,0',
00253             'sumgrades' => '4',
00254             'grade' => '4',
00255             'timecreated' => '0',
00256             'timemodified' => '1190277883',
00257             'password' => '',
00258             'subnet' => '',
00259             'popup' => '0',
00260             'delay1' => '0',
00261             'delay2' => '0',
00262             'timelimit' => '0',
00263         );
00264         $attempt = (object) array(
00265             'id' => '23226',
00266             'uniqueid' => '23226',
00267             'quiz' => '551',
00268             'userid' => '80300',
00269             'attempt' => '2',
00270             'sumgrades' => '0',
00271             'timestart' => '1200326384',
00272             'timefinish' => '0',
00273             'timemodified' => '1200326384',
00274             'layout' => '9043,0,9057,0,9062,0,9241,0',
00275             'preview' => '0',
00276             'needsupgradetonewqe' => '1',
00277         );
00278         $question = (object) array(
00279             'id' => '9062',
00280             'category' => '481',
00281             'parent' => '0',
00282             'name' => 'U04_NA_In viaggio_Q3',
00283             'questiontext' => '<p><img title="my market" height="336" alt="my market" hspace="0" src="http://learnacct.open.ac.uk/file.php/2828/Naples_My_market.jpg" /></p>
00284         <p>What can you buy in this shop? Is this list accurate?</p>
00285         <p><br />Mark true or false (for the list as a whole).</p>
00286 
00287 
00288         <p><i>single tickets</i></p>
00289         <p><i>weekly season tickets</i></p>
00290         <p><i>monthly season tickets</i></p>
00291         <p><i>wine and grappa</i></p>
00292         <p><i>fruit and vegetables</i></p>
00293         <p><i>tobacco </i></p>',
00294             'questiontextformat' => '1',
00295             'defaultmark' => '1',
00296             'penalty' => '0',
00297             'qtype' => 'truefalse',
00298             'length' => '1',
00299             'stamp' => 'learn.open.ac.uk+070820163735+PqUlDM',
00300             'version' => 'learn.open.ac.uk+080304160318+owhQUb',
00301             'hidden' => '0',
00302             'generalfeedback' => '',
00303             'generalfeedbackformat' => '1',
00304             'timecreated' => '0',
00305             'timemodified' => '1204646598',
00306             'createdby' => null,
00307             'modifiedby' => '97230',
00308             'unlimited' => '0',
00309             'maxmark' => '1',
00310             'options' => (object) array(
00311                 'id' => '199',
00312                 'question' => '9062',
00313                 'trueanswer' => '28221',
00314                 'falseanswer' => '28222',
00315                 'answers' => array(
00316                     28221 => (object) array(
00317                         'question' => '9062',
00318                         'answer' => 'True',
00319                         'fraction' => '0',
00320                         'feedback' => '<p>The correct answer is \'false\'.  The only items on the list not sold at My Market are tobacco and weekly season tickets. It sells everything else! <br /><em>Biglietto unico</em> is a single ticket for bus, funicular railway or metro (underground) while <em>abbonamento mensile</em> is a monthly season ticket.<br />The shop also sells wine and grappa, as you can see them in the window, and fruit and vegetables as it says in the sign. Small shops in Naples often sell a variety of things, not always connected! </p>',
00321                         'id' => 28221,
00322                     ),
00323                     28222 => (object) array(
00324                         'question' => '9062',
00325                         'answer' => 'False',
00326                         'fraction' => '1',
00327                         'feedback' => 'The correct anstwer is \'false\'. The only items on the list not sold at My Market are tobacco and weekly season tickets. It sells everything else! <em>Biglietto</em> <em>unico</em> is a single ticket for bus, funicular railway or metro (underground) while \'abbonamento mensile\' is a monthly season ticket. It also sells wine and grappa, as you can see them in the window, and fruit and vegetables as it says in the sign! Small shops in Naples often sell a variety of things, not always connected! ',
00328                         'id' => 28222,
00329                     ),
00330                 ),
00331             ),
00332             'hints' => false,
00333         );
00334         $qsession = (object) array(
00335             'id' => '351032',
00336             'attemptid' => '23226',
00337             'questionid' => '9062',
00338             'newest' => '848428',
00339             'newgraded' => '848426',
00340             'sumpenalty' => '0',
00341             'manualcomment' => '',
00342             'manualcommentformat' => '1',
00343             'flagged' => '1',
00344         );
00345         $qstates = array(
00346             848426 => (object) array(
00347                 'attempt' => '23226',
00348                 'question' => '9062',
00349                 'originalquestion' => '0',
00350                 'seq_number' => '0',
00351                 'answer' => '',
00352                 'timestamp' => '1200326384',
00353                 'event' => '0',
00354                 'grade' => '0',
00355                 'raw_grade' => '0',
00356                 'penalty' => '0',
00357                 'id' => 848426,
00358             ),
00359             848428 => (object) array(
00360                 'attempt' => '23226',
00361                 'question' => '9062',
00362                 'originalquestion' => '0',
00363                 'seq_number' => '1',
00364                 'answer' => '28221',
00365                 'timestamp' => '1200326384',
00366                 'event' => '2',
00367                 'grade' => '0',
00368                 'raw_grade' => '0',
00369                 'penalty' => '1',
00370                 'id' => 848428,
00371             ),
00372         );
00373 
00374         $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
00375 
00376         $expectedqa = (object) array(
00377             'behaviour' => 'deferredfeedback',
00378             'questionid' => 9062,
00379             'variant' => 1,
00380             'maxmark' => 1,
00381             'minfraction' => 0,
00382             'flagged' => 0,
00383             'questionsummary' => "[my market] \n\nWhat can you buy in this shop? Is this list accurate? \n\nMark true or false (for the list as a whole). \n\n_single tickets_ \n\n_weekly season tickets_ \n\n_monthly season tickets_ \n\n_wine and grappa_ \n\n_fruit and vegetables_ \n\n_tobacco _",
00384             'rightanswer' => 'False',
00385             'responsesummary' => 'True',
00386             'timemodified' => 1200326384,
00387             'steps' => array(
00388                 0 => (object) array(
00389                     'sequencenumber' => 0,
00390                     'state' => 'todo',
00391                     'fraction' => null,
00392                     'timecreated' => 1200326384,
00393                     'userid' => 80300,
00394                     'data' => array(),
00395                 ),
00396                 1 => (object) array(
00397                     'sequencenumber' => 1,
00398                     'state' => 'complete',
00399                     'fraction' => null,
00400                     'timecreated' => 1200326384,
00401                     'userid' => 80300,
00402                     'data' => array('answer' => 1),
00403                 ),
00404             ),
00405         );
00406 
00407         $this->compare_qas($expectedqa, $qa);
00408     }
00409 
00410     public function test_truefalse_deferredfeedback_history90() {
00411         $quiz = (object) array(
00412             'id' => '3',
00413             'course' => '1095',
00414             'name' => 'Introduction quiz',
00415             'intro' => 'Use this self-assessment quiz after you have read the course introduction. ',
00416             'introformat' => FORMAT_HTML,
00417             'questiondecimalpoints' => '-1',
00418             'showuserpicture' => '1',
00419             'showblocks' => '1',
00420             'timeopen' => '1150107000',
00421             'timeclose' => '0',
00422             'preferredbehaviour' => 'deferredfeedback',
00423             'attempts' => '0',
00424             'attemptonlast' => '0',
00425             'grademethod' => '1',
00426             'decimalpoints' => '2',
00427             'review' => '71760879',
00428             'questionsperpage' => '0',
00429             'shufflequestions' => '1',
00430             'shuffleanswers' => '1',
00431             'questions' => '96,98,104,106,101,108,111,102,113,0',
00432             'sumgrades' => '9',
00433             'grade' => '9',
00434             'timecreated' => '0',
00435             'timemodified' => '1150127779',
00436             'password' => '',
00437             'subnet' => '',
00438             'popup' => '0',
00439             'delay1' => '0',
00440             'delay2' => '0',
00441             'timelimit' => '0',
00442         );
00443         $attempt = (object) array(
00444             'id' => '19',
00445             'uniqueid' => '19',
00446             'quiz' => '3',
00447             'userid' => '49542',
00448             'attempt' => '1',
00449             'sumgrades' => '9',
00450             'timestart' => '1150301292',
00451             'timefinish' => '1150301347',
00452             'timemodified' => '1150454872',
00453             'layout' => '96,108,102,101,106,113,104,98,111,0',
00454             'preview' => '0',
00455             'needsupgradetonewqe' => '1',
00456         );
00457         $question = (object) array(
00458             'id' => '111',
00459             'category' => '5',
00460             'parent' => '0',
00461             'name' => 'Q7',
00462             'questiontext' => 'Web services, integration servers, XML, application servers, message-oriented middleware and remote procedure call can be used to enable integrated systems?',
00463             'questiontextformat' => '1',
00464             'defaultgrade' => '1',
00465             'penalty' => '0',
00466             'qtype' => 'truefalse',
00467             'length' => '1',
00468             'stamp' => 'learn.open.ac.uk+060612113518+uuFWow',
00469             'version' => 'learn.open.ac.uk+060612154736+HeFOV0',
00470             'hidden' => '0',
00471             'generalfeedback' => '',
00472             'generalfeedbackformat' => '1',
00473             'timecreated' => '0',
00474             'timemodified' => '0',
00475             'createdby' => null,
00476             'modifiedby' => null,
00477             'unlimited' => null,
00478             'maxmark' => '1',
00479             'options' => (object) array(
00480                 'id' => '24',
00481                 'question' => '111',
00482                 'trueanswer' => '312',
00483                 'falseanswer' => '313',
00484                 'answers' => array(
00485                     312 => (object) array(
00486                         'question' => '111',
00487                         'answer' => 'True',
00488                         'fraction' => '1',
00489                         'feedback' => 'They are all used in storing data or connecting together components of an integrated system.',
00490                         'id' => 312,
00491                     ),
00492                     313 => (object) array(
00493                         'question' => '111',
00494                         'answer' => 'False',
00495                         'fraction' => '0',
00496                         'feedback' => 'They are all used in storing data or connecting together components of an integrated system.',
00497                         'id' => 313,
00498                     ),
00499                 ),
00500             ),
00501             'hints' => false,
00502         );
00503         $qsession = (object) array(
00504             'id' => '169',
00505             'attemptid' => '19',
00506             'questionid' => '111',
00507             'newest' => '252',
00508             'newgraded' => '252',
00509             'sumpenalty' => '0',
00510             'manualcomment' => '',
00511             'manualcommentformat' => '1',
00512             'flagged' => '1',
00513         );
00514         $qstates = array(
00515             242 => (object) array(
00516                 'attempt' => '19',
00517                 'question' => '111',
00518                 'originalquestion' => '0',
00519                 'seq_number' => '0',
00520                 'answer' => '',
00521                 'timestamp' => '1150301292',
00522                 'event' => '0',
00523                 'grade' => '0',
00524                 'raw_grade' => '0',
00525                 'penalty' => '0',
00526                 'id' => 242,
00527             ),
00528             252 => (object) array(
00529                 'attempt' => '19',
00530                 'question' => '111',
00531                 'originalquestion' => '0',
00532                 'seq_number' => '1',
00533                 'answer' => '',
00534                 'timestamp' => '1150454872',
00535                 'event' => '9',
00536                 'grade' => '1',
00537                 'raw_grade' => '1',
00538                 'penalty' => '0',
00539                 'id' => 252,
00540             ),
00541         );
00542 
00543         $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
00544 
00545         $expectedqa = (object) array(
00546             'behaviour' => 'deferredfeedback',
00547             'questionid' => 111,
00548             'variant' => 1,
00549             'maxmark' => 1,
00550             'minfraction' => 0,
00551             'flagged' => 0,
00552             'questionsummary' => 'Web services, integration servers, XML, application servers, message-oriented middleware and remote procedure call can be used to enable integrated systems?',
00553             'rightanswer' => 'True',
00554             'responsesummary' => '',
00555             'timemodified' => 1150454872,
00556             'steps' => array(
00557                 0 => (object) array(
00558                     'sequencenumber' => 0,
00559                     'state' => 'todo',
00560                     'fraction' => null,
00561                     'timecreated' => 1150301292,
00562                     'userid' => 49542,
00563                     'data' => array(),
00564                 ),
00565                 1 => (object) array(
00566                     'sequencenumber' => 1,
00567                     'state' => 'gradedwrong',
00568                     'fraction' => null,
00569                     'timecreated' => 1150454872,
00570                     'userid' => 49542,
00571                     'data' => array('-finish' => 1),
00572                 ),
00573                 2 => (object) array(
00574                     'sequencenumber' => 2,
00575                     'state' => 'mangrright',
00576                     'fraction' => 1,
00577                     'timecreated' => 1150454872,
00578                     'userid' => null,
00579                     'data' => array('-comment' => '', '-maxmark' => 1, '-mark' => 1),
00580                 ),
00581             ),
00582         );
00583 
00584         $this->compare_qas($expectedqa, $qa);
00585     }
00586 
00587     public function test_truefalse_adaptive_qsession119() {
00588         $quiz = (object) array(
00589             'id' => '6',
00590             'course' => '3',
00591             'name' => 'Simply quiz',
00592             'intro' => '<p>One quiz with 1 true/false Q</p>',
00593             'introformat' => '1',
00594             'timeopen' => '0',
00595             'timeclose' => '0',
00596             'attempts' => '0',
00597             'attemptonlast' => '0',
00598             'grademethod' => '1',
00599             'decimalpoints' => '2',
00600             'questiondecimalpoints' => '-1',
00601             'review' => '4459503',
00602             'questionsperpage' => '1',
00603             'shufflequestions' => '0',
00604             'shuffleanswers' => '1',
00605             'questions' => '30,0',
00606             'sumgrades' => '10.00000',
00607             'grade' => '10.00000',
00608             'timecreated' => '0',
00609             'timemodified' => '1309103209',
00610             'timelimit' => '0',
00611             'password' => '',
00612             'subnet' => '',
00613             'popup' => '0',
00614             'delay1' => '0',
00615             'delay2' => '0',
00616             'showuserpicture' => '0',
00617             'showblocks' => '0',
00618             'preferredbehaviour' => 'adaptive',
00619         );
00620         $attempt = (object) array(
00621             'id' => '20',
00622             'uniqueid' => '20',
00623             'quiz' => '6',
00624             'userid' => '7',
00625             'attempt' => '1',
00626             'sumgrades' => '10.00000',
00627             'timestart' => '1309103112',
00628             'timefinish' => '1309103120',
00629             'timemodified' => '1309103120',
00630             'layout' => '30,0',
00631             'preview' => '0',
00632             'needsupgradetonewqe' => 1,
00633         );
00634         $question = (object) array(
00635             'id' => '30',
00636             'category' => '10',
00637             'parent' => '0',
00638             'name' => '1 + 1 = 2 ?',
00639             'questiontext' => '<p>1 +1 = 2 ?</p>',
00640             'questiontextformat' => '1',
00641             'generalfeedback' => '<p>this is general feedback</p>',
00642             'generalfeedbackformat' => '1',
00643             'penalty' => '1.0000000',
00644             'qtype' => 'truefalse',
00645             'length' => '1',
00646             'stamp' => '127.0.0.1+110626154410+wFrWwP',
00647             'version' => '127.0.0.1+110626154410+u7CoaA',
00648             'hidden' => '0',
00649             'timecreated' => '1309103050',
00650             'timemodified' => '1309103050',
00651             'createdby' => '6',
00652             'modifiedby' => '6',
00653             'maxmark' => '10.0000000',
00654             'options' => (object) array(
00655                 'id' => '4',
00656                 'question' => '30',
00657                 'trueanswer' => '53',
00658                 'falseanswer' => '54',
00659                 'answers' => array(
00660                     53 => (object) array(
00661                         'id' => '53',
00662                         'question' => '30',
00663                         'answer' => 'True',
00664                         'answerformat' => '0',
00665                         'fraction' => '1.0000000',
00666                         'feedback' => '<p>this is correct (for true) feedback</p>',
00667                         'feedbackformat' => '1',
00668                     ),
00669                     54 => (object) array(
00670                         'id' => '54',
00671                         'question' => '30',
00672                         'answer' => 'False',
00673                         'answerformat' => '0',
00674                         'fraction' => '0.0000000',
00675                         'feedback' => '<p>this is incorrect (for false) feedback</p>',
00676                         'feedbackformat' => '1',
00677                     ),
00678                 ),
00679             ),
00680             'defaultmark' => '1.0000000',
00681         );
00682         $qsession = (object) array(
00683             'id' => '119',
00684             'attemptid' => '20',
00685             'questionid' => '30',
00686             'newest' => '312',
00687             'newgraded' => '312',
00688             'sumpenalty' => '10.0000000',
00689             'manualcomment' => '',
00690             'manualcommentformat' => '1',
00691             'flagged' => '0',
00692         );
00693         $qstates = array(
00694             310 => (object) array(
00695                 'id' => '310',
00696                 'attempt' => '20',
00697                 'question' => '30',
00698                 'seq_number' => '0',
00699                 'answer' => '',
00700                 'timestamp' => '1309103112',
00701                 'event' => '0',
00702                 'grade' => '0.0000000',
00703                 'raw_grade' => '0.0000000',
00704                 'penalty' => '0.0000000',
00705             ),
00706             311 => (object) array(
00707                 'id' => '311',
00708                 'attempt' => '20',
00709                 'question' => '30',
00710                 'seq_number' => '1',
00711                 'answer' => '53',
00712                 'timestamp' => '1309103115',
00713                 'event' => '3',
00714                 'grade' => '10.0000000',
00715                 'raw_grade' => '10.0000000',
00716                 'penalty' => '10.0000000',
00717             ),
00718             312 => (object) array(
00719                 'id' => '312',
00720                 'attempt' => '20',
00721                 'question' => '30',
00722                 'seq_number' => '1',
00723                 'answer' => '53',
00724                 'timestamp' => '1309103115',
00725                 'event' => '6',
00726                 'grade' => '10.0000000',
00727                 'raw_grade' => '10.0000000',
00728                 'penalty' => '10.0000000',
00729             ),
00730         );
00731 
00732         $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
00733 
00734         $expectedqa = (object) array(
00735             'behaviour' => 'adaptive',
00736             'questionid' => 30,
00737             'variant' => 1,
00738             'maxmark' => 10.0000000,
00739             'minfraction' => 0,
00740             'flagged' => 0,
00741             'questionsummary' => '1 +1 = 2 ?',
00742             'rightanswer' => 'True',
00743             'responsesummary' => 'True',
00744             'timemodified' => 1309103115,
00745             'steps' => array(
00746                 0 => (object) array(
00747                     'sequencenumber' => 0,
00748                     'state' => 'todo',
00749                     'fraction' => null,
00750                     'timecreated' => 1309103112,
00751                     'userid' => 7,
00752                     'data' => array(),
00753                 ),
00754                 1 => (object) array(
00755                     'sequencenumber' => 1,
00756                     'state' => 'complete',
00757                     'fraction' => 1.0,
00758                     'timecreated' => 1309103115,
00759                     'userid' => 7,
00760                     'data' => array('answer' => '1', '-_try' => '1',
00761                             '-_rawfraction' => '1', '-submit' => '1'),
00762                 ),
00763                 2 => (object) array(
00764                     'sequencenumber' => 2,
00765                     'state' => 'gradedright',
00766                     'fraction' => 1.0,
00767                     'timecreated' => 1309103115,
00768                     'userid' => 7,
00769                     'data' => array('answer' => '1', '-_try' => '1',
00770                             '-_rawfraction' => '1', '-finish' => '1'),
00771                 ),
00772             ),
00773         );
00774 
00775         $this->compare_qas($expectedqa, $qa);
00776     }
00777 
00778     public function test_truefalse_adaptive_qsession120() {
00779         $quiz = (object) array(
00780             'id' => '6',
00781             'course' => '3',
00782             'name' => 'Simply quiz',
00783             'intro' => '<p>One quiz with 1 true/false Q</p>',
00784             'introformat' => '1',
00785             'timeopen' => '0',
00786             'timeclose' => '0',
00787             'attempts' => '0',
00788             'attemptonlast' => '0',
00789             'grademethod' => '1',
00790             'decimalpoints' => '2',
00791             'questiondecimalpoints' => '-1',
00792             'review' => '4459503',
00793             'questionsperpage' => '1',
00794             'shufflequestions' => '0',
00795             'shuffleanswers' => '1',
00796             'questions' => '30,0',
00797             'sumgrades' => '10.00000',
00798             'grade' => '10.00000',
00799             'timecreated' => '0',
00800             'timemodified' => '1309103209',
00801             'timelimit' => '0',
00802             'password' => '',
00803             'subnet' => '',
00804             'popup' => '0',
00805             'delay1' => '0',
00806             'delay2' => '0',
00807             'showuserpicture' => '0',
00808             'showblocks' => '0',
00809             'preferredbehaviour' => 'adaptive',
00810         );
00811         $attempt = (object) array(
00812             'id' => '21',
00813             'uniqueid' => '21',
00814             'quiz' => '6',
00815             'userid' => '7',
00816             'attempt' => '2',
00817             'sumgrades' => '0.00000',
00818             'timestart' => '1309103130',
00819             'timefinish' => '1309103136',
00820             'timemodified' => '1309103136',
00821             'layout' => '30,0',
00822             'preview' => '0',
00823             'needsupgradetonewqe' => 1,
00824         );
00825         $question = (object) array(
00826             'id' => '30',
00827             'category' => '10',
00828             'parent' => '0',
00829             'name' => '1 + 1 = 2 ?',
00830             'questiontext' => '<p>1 +1 = 2 ?</p>',
00831             'questiontextformat' => '1',
00832             'generalfeedback' => '<p>this is general feedback</p>',
00833             'generalfeedbackformat' => '1',
00834             'penalty' => '1.0000000',
00835             'qtype' => 'truefalse',
00836             'length' => '1',
00837             'stamp' => '127.0.0.1+110626154410+wFrWwP',
00838             'version' => '127.0.0.1+110626154410+u7CoaA',
00839             'hidden' => '0',
00840             'timecreated' => '1309103050',
00841             'timemodified' => '1309103050',
00842             'createdby' => '6',
00843             'modifiedby' => '6',
00844             'maxmark' => '10.0000000',
00845             'options' => (object) array(
00846                 'id' => '4',
00847                 'question' => '30',
00848                 'trueanswer' => '53',
00849                 'falseanswer' => '54',
00850                 'answers' => array(
00851                     53 => (object) array(
00852                         'id' => '53',
00853                         'question' => '30',
00854                         'answer' => 'True',
00855                         'answerformat' => '0',
00856                         'fraction' => '1.0000000',
00857                         'feedback' => '<p>this is correct (for true) feedback</p>',
00858                         'feedbackformat' => '1',
00859                     ),
00860                     54 => (object) array(
00861                         'id' => '54',
00862                         'question' => '30',
00863                         'answer' => 'False',
00864                         'answerformat' => '0',
00865                         'fraction' => '0.0000000',
00866                         'feedback' => '<p>this is incorrect (for false) feedback</p>',
00867                         'feedbackformat' => '1',
00868                     ),
00869                 ),
00870             ),
00871             'defaultmark' => '1.0000000',
00872         );
00873         $qsession = (object) array(
00874             'id' => '120',
00875             'attemptid' => '21',
00876             'questionid' => '30',
00877             'newest' => '315',
00878             'newgraded' => '315',
00879             'sumpenalty' => '10.0000000',
00880             'manualcomment' => '',
00881             'manualcommentformat' => '1',
00882             'flagged' => '0',
00883         );
00884         $qstates = array(
00885             313 => (object) array(
00886                 'id' => '313',
00887                 'attempt' => '21',
00888                 'question' => '30',
00889                 'seq_number' => '0',
00890                 'answer' => '',
00891                 'timestamp' => '1309103130',
00892                 'event' => '0',
00893                 'grade' => '0.0000000',
00894                 'raw_grade' => '0.0000000',
00895                 'penalty' => '0.0000000',
00896             ),
00897             314 => (object) array(
00898                 'id' => '314',
00899                 'attempt' => '21',
00900                 'question' => '30',
00901                 'seq_number' => '1',
00902                 'answer' => '54',
00903                 'timestamp' => '1309103132',
00904                 'event' => '2',
00905                 'grade' => '0.0000000',
00906                 'raw_grade' => '0.0000000',
00907                 'penalty' => '10.0000000',
00908             ),
00909             315 => (object) array(
00910                 'id' => '315',
00911                 'attempt' => '21',
00912                 'question' => '30',
00913                 'seq_number' => '2',
00914                 'answer' => '54',
00915                 'timestamp' => '1309103132',
00916                 'event' => '6',
00917                 'grade' => '0.0000000',
00918                 'raw_grade' => '0.0000000',
00919                 'penalty' => '10.0000000',
00920             ),
00921         );
00922 
00923         $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
00924 
00925         $expectedqa = (object) array(
00926             'behaviour' => 'adaptive',
00927             'questionid' => 30,
00928             'variant' => 1,
00929             'maxmark' => 10.0000000,
00930             'minfraction' => 0,
00931             'flagged' => 0,
00932             'questionsummary' => '1 +1 = 2 ?',
00933             'rightanswer' => 'True',
00934             'responsesummary' => 'False',
00935             'timemodified' => 1309103132,
00936             'steps' => array(
00937                 0 => (object) array(
00938                     'sequencenumber' => 0,
00939                     'state' => 'todo',
00940                     'fraction' => null,
00941                     'timecreated' => 1309103130,
00942                     'userid' => 7,
00943                     'data' => array(),
00944                 ),
00945                 1 => (object) array(
00946                     'sequencenumber' => 1,
00947                     'state' => 'complete',
00948                     'fraction' => null,
00949                     'timecreated' => 1309103132,
00950                     'userid' => 7,
00951                     'data' => array('answer' => '0'),
00952                 ),
00953                 2 => (object) array(
00954                     'sequencenumber' => 2,
00955                     'state' => 'gradedwrong',
00956                     'fraction' => 0.0,
00957                     'timecreated' => 1309103132,
00958                     'userid' => 7,
00959                     'data' => array('answer' => 0, '-finish' => 1,
00960                             '-_try' => 1, '-_rawfraction' => 0),
00961                 ),
00962             ),
00963         );
00964 
00965         $this->compare_qas($expectedqa, $qa);
00966     }
00967 
00968  public function test_truefalse_adaptive_qsession3() {
00969         $quiz = (object) array(
00970             'id' => '1',
00971             'course' => '2',
00972             'name' => 'Test Quiz',
00973             'intro' => '',
00974             'introformat' => '1',
00975             'timeopen' => '0',
00976             'timeclose' => '0',
00977             'preferredbehaviour' => 'adaptive',
00978             'attempts' => '0',
00979             'attemptonlast' => '0',
00980             'grademethod' => '1',
00981             'decimalpoints' => '2',
00982             'questiondecimalpoints' => '-1',
00983             'reviewattempt' => '69888',
00984             'reviewcorrectness' => '69888',
00985             'reviewmarks' => '69888',
00986             'reviewspecificfeedback' => '69888',
00987             'reviewgeneralfeedback' => '69888',
00988             'reviewrightanswer' => '69888',
00989             'reviewoverallfeedback' => '4352',
00990             'questionsperpage' => '1',
00991             'shufflequestions' => '0',
00992             'shuffleanswers' => '1',
00993             'questions' => '1,0',
00994             'sumgrades' => '1.00000',
00995             'grade' => '10.00000',
00996             'timecreated' => '0',
00997             'timemodified' => '1309441728',
00998             'timelimit' => '0',
00999             'password' => '',
01000             'subnet' => '',
01001             'popup' => '0',
01002             'delay1' => '0',
01003             'delay2' => '0',
01004             'showuserpicture' => '0',
01005             'showblocks' => '0',
01006         );
01007         $attempt = (object) array(
01008             'id' => '3',
01009             'uniqueid' => '3',
01010             'quiz' => '1',
01011             'userid' => '4',
01012             'attempt' => '2',
01013             'sumgrades' => null,
01014             'timestart' => '1309441460',
01015             'timefinish' => '1309441471',
01016             'timemodified' => '1309441969',
01017             'layout' => '1,0',
01018             'preview' => '0',
01019             'needsupgradetonewqe' => 1,
01020         );
01021         $question = (object) array(
01022             'id' => '1',
01023             'category' => '2',
01024             'parent' => '0',
01025             'name' => 'Does 1 + 1 = 2?',
01026             'questiontext' => '',
01027             'questiontextformat' => '1',
01028             'generalfeedback' => '',
01029             'generalfeedbackformat' => '1',
01030             'defaultmark' => '1.0000000',
01031             'penalty' => '1.0000000',
01032             'qtype' => 'truefalse',
01033             'length' => '1',
01034             'stamp' => 'localhost:8888+110630134237+QzfsHZ',
01035             'version' => 'localhost:8888+110630134237+IaYGE6',
01036             'hidden' => '0',
01037             'timecreated' => '1309441357',
01038             'timemodified' => '1309441357',
01039             'createdby' => '3',
01040             'modifiedby' => '3',
01041             'maxmark' => '1.0000000',
01042             'options' => (object) array(
01043                 'id' => '1',
01044                 'question' => '1',
01045                 'trueanswer' => '1',
01046                 'falseanswer' => '2',
01047                 'answers' => array(
01048                     1 => (object) array(
01049                         'id' => '1',
01050                         'question' => '1',
01051                         'answer' => 'True',
01052                         'answerformat' => '0',
01053                         'fraction' => '1.0000000',
01054                         'feedback' => '',
01055                         'feedbackformat' => '1',
01056                     ),
01057                     2 => (object) array(
01058                         'id' => '2',
01059                         'question' => '1',
01060                         'answer' => 'False',
01061                         'answerformat' => '0',
01062                         'fraction' => '0.0000000',
01063                         'feedback' => '',
01064                         'feedbackformat' => '1',
01065                     ),
01066                 ),
01067             ),
01068         );
01069         $qsession = (object) array(
01070             'id' => '3',
01071             'attemptid' => '3',
01072             'questionid' => '1',
01073             'newest' => '7',
01074             'newgraded' => '7',
01075             'sumpenalty' => '1.0000000',
01076             'manualcomment' => '',
01077             'manualcommentformat' => '1',
01078             'flagged' => '0',
01079         );
01080         $qstates = array(
01081             5 => (object) array(
01082                 'id' => '5',
01083                 'attempt' => '3',
01084                 'question' => '1',
01085                 'seq_number' => '0',
01086                 'answer' => '',
01087                 'timestamp' => '1309441460',
01088                 'event' => '0',
01089                 'grade' => '0.0000000',
01090                 'raw_grade' => '0.0000000',
01091                 'penalty' => '0.0000000',
01092             ),
01093             6 => (object) array(
01094                 'id' => '6',
01095                 'attempt' => '3',
01096                 'question' => '1',
01097                 'seq_number' => '1',
01098                 'answer' => '1',
01099                 'timestamp' => '1309441463',
01100                 'event' => '3',
01101                 'grade' => '1.0000000',
01102                 'raw_grade' => '1.0000000',
01103                 'penalty' => '1.0000000',
01104             ),
01105             7 => (object) array(
01106                 'id' => '7',
01107                 'attempt' => '3',
01108                 'question' => '1',
01109                 'seq_number' => '1',
01110                 'answer' => '1',
01111                 'timestamp' => '1309441463',
01112                 'event' => '6',
01113                 'grade' => '1.0000000',
01114                 'raw_grade' => '1.0000000',
01115                 'penalty' => '1.0000000',
01116             ),
01117         );
01118 
01119         $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
01120 
01121         $expectedqa = (object) array(
01122             'behaviour' => 'adaptive',
01123             'questionid' => 1,
01124             'variant' => 1,
01125             'maxmark' => 1.0000000,
01126             'minfraction' => 0,
01127             'flagged' => 0,
01128             'questionsummary' => '',
01129             'rightanswer' => 'True',
01130             'responsesummary' => 'True',
01131             'timemodified' => 1309441463,
01132             'steps' => array(
01133                 0 => (object) array(
01134                     'sequencenumber' => 0,
01135                     'state' => 'todo',
01136                     'fraction' => null,
01137                     'timecreated' => 1309441460,
01138                     'userid' => 4,
01139                     'data' => array(),
01140                 ),
01141                 1 => (object) array(
01142                     'sequencenumber' => 1,
01143                     'state' => 'complete',
01144                     'fraction' => 1,
01145                     'timecreated' => 1309441463,
01146                     'userid' => 4,
01147                     'data' => array('answer' => 1, '-submit' => 1,
01148                             '-_try' => 1, '-_rawfraction' => 1),
01149                 ),
01150                 2 => (object) array(
01151                     'sequencenumber' => 2,
01152                     'state' => 'gradedright',
01153                     'fraction' => 1,
01154                     'timecreated' => 1309441463,
01155                     'userid' => 4,
01156                     'data' => array('answer' => 1, '-finish' => 1,
01157                             '-_try' => 1, '-_rawfraction' => 1),
01158                 ),
01159             ),
01160         );
01161 
01162         $this->compare_qas($expectedqa, $qa);
01163     }
01164 }
 All Data Structures Namespaces Files Functions Variables Enumerations