Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/question/type/essay/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_essay_attempt_upgrader_test extends question_attempt_upgrader_test_base {
00040 
00041     public function test_essay_deferredfeedback_history98220() {
00042         $quiz = (object) array(
00043             'id' => '4140',
00044             'course' => '5012',
00045             'name' => 'M887 Online Examination: 19th April 2010, 10am - 1pm',
00046             'intro' => '<h2>M887 Examination Paper 19th April 2010</h2>
00047 
00048         <h2>Postgraduate Computing<br />Web Systems Integration<br /></h2>
00049 
00050         <h2>Begin by pressing Start Attempt (below)</h2>',
00051             'introformat' => FORMAT_HTML,
00052             'questiondecimalpoints' => '-1',
00053             'showuserpicture' => '1',
00054             'showblocks' => '1',
00055             'timeopen' => '1271665800',
00056             'timeclose' => '1271682000',
00057             'preferredbehaviour' => 'deferredfeedback',
00058             'attempts' => '1',
00059             'attemptonlast' => '0',
00060             'grademethod' => '1',
00061             'decimalpoints' => '2',
00062             'review' => '71727591',
00063             'questionsperpage' => '1',
00064             'shufflequestions' => '0',
00065             'shuffleanswers' => '1',
00066             'questions' => '90042,0,90043,0,90045,0,90052,0,90053,0,90054,0,90055,0,90056,0,90057,0,90058,0,90059,0,90046,0,90044,0,90047,0,90048,0,90049,0',
00067             'sumgrades' => '100',
00068             'grade' => '100',
00069             'timecreated' => '0',
00070             'timemodified' => '1272274569',
00071             'password' => '',
00072             'subnet' => '',
00073             'popup' => '0',
00074             'delay1' => '0',
00075             'delay2' => '0',
00076             'timelimit' => '0',
00077         );
00078         $attempt = (object) array(
00079             'id' => '388325',
00080             'uniqueid' => '388326',
00081             'quiz' => '4140',
00082             'userid' => '118065',
00083             'attempt' => '1',
00084             'sumgrades' => '51',
00085             'timestart' => '1271667586',
00086             'timefinish' => '1271678351',
00087             'timemodified' => '1273069013',
00088             'layout' => '90042,0,90043,0,90045,0,90052,0,90053,0,90054,0,90055,0,90056,0,90057,0,90058,0,90059,0,90046,0,90044,0,90047,0,90048,0,90049,0',
00089             'preview' => '0',
00090             'needsupgradetonewqe' => '1',
00091         );
00092         $question = (object) array(
00093             'id' => '90056',
00094             'category' => '8619',
00095             'parent' => '0',
00096             'name' => 'Question 6',
00097             'questiontext' => '<p>
00098 
00099         <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta><meta name="ProgId" content="Word.Document"></meta><meta name="Generator" content="Microsoft Word 11"></meta><meta name="Originator" content="Microsoft Word 11"></meta><link rel="File-List" href="file:///C:\\DOCUME~1\\pgt2\\LOCALS~1\\Temp\\msohtml1\\01\\clip_filelist.xml"></link><style></style>Give two examples of facilities within XML schemas that cannot be found in Document Type Definitions (DTDs).<br /><i>(2 marks)</i></p>',
00100             'questiontextformat' => '1',
00101             'defaultmark' => '2',
00102             'penalty' => '0',
00103             'qtype' => 'essay',
00104             'length' => '1',
00105             'stamp' => 'learn.open.ac.uk+100205101651+5eB30s',
00106             'version' => 'learn.open.ac.uk+100209161823+oZCX9n',
00107             'hidden' => '0',
00108             'generalfeedback' => '',
00109             'generalfeedbackformat' => '1',
00110             'timecreated' => '1265365011',
00111             'timemodified' => '1265732303',
00112             'createdby' => '219095',
00113             'modifiedby' => '25483',
00114             'unlimited' => '0',
00115             'maxmark' => '2',
00116             'options' => (object) array(
00117                 'answers' => array(
00118                     303772 => (object) array(
00119                         'question' => '90056',
00120                         'answer' => '',
00121                         'fraction' => '0',
00122                         'feedback' => '',
00123                         'id' => 303772,
00124                     ),
00125                 ),
00126             ),
00127             'hints' => false,
00128         );
00129         $qsession = (object) array(
00130             'id' => '3962570',
00131             'attemptid' => '388326',
00132             'questionid' => '90056',
00133             'newest' => '10517712',
00134             'newgraded' => '10517712',
00135             'sumpenalty' => '0',
00136             'manualcomment' => '',
00137             'manualcommentformat' => '1',
00138             'flagged' => '1',
00139         );
00140         $qstates = array(
00141             10094242 => (object) array(
00142                 'attempt' => '388326',
00143                 'question' => '90056',
00144                 'originalquestion' => '0',
00145                 'seq_number' => '0',
00146                 'answer' => '',
00147                 'timestamp' => '1271667586',
00148                 'event' => '0',
00149                 'grade' => '0',
00150                 'raw_grade' => '0',
00151                 'penalty' => '0',
00152                 'id' => 10094242,
00153             ),
00154             10096161 => (object) array(
00155                 'attempt' => '388326',
00156                 'question' => '90056',
00157                 'originalquestion' => '0',
00158                 'seq_number' => '1',
00159                 'answer' => '<p>Variable typeing</p>
00160         <p>Namespaces</p>',
00161                 'timestamp' => '1271670445',
00162                 'event' => '2',
00163                 'grade' => '0',
00164                 'raw_grade' => '0',
00165                 'penalty' => '0',
00166                 'id' => 10096161,
00167             ),
00168             10097144 => (object) array(
00169                 'attempt' => '388326',
00170                 'question' => '90056',
00171                 'originalquestion' => '0',
00172                 'seq_number' => '2',
00173                 'answer' => '<p>Variable can be typed</p>
00174         <p>xml Schemas fully support Namespaces</p>',
00175                 'timestamp' => '1271671440',
00176                 'event' => '2',
00177                 'grade' => '0',
00178                 'raw_grade' => '0',
00179                 'penalty' => '0',
00180                 'id' => 10097144,
00181             ),
00182             10103710 => (object) array(
00183                 'attempt' => '388326',
00184                 'question' => '90056',
00185                 'originalquestion' => '0',
00186                 'seq_number' => '3',
00187                 'answer' => '<p>Variable can be typed</p>
00188         <p>xml Schemas fully support Namespaces</p>',
00189                 'timestamp' => '1271671440',
00190                 'event' => '8',
00191                 'grade' => '0',
00192                 'raw_grade' => '0',
00193                 'penalty' => '0',
00194                 'id' => 10103710,
00195             ),
00196             10517712 => (object) array(
00197                 'attempt' => '388326',
00198                 'question' => '90056',
00199                 'originalquestion' => '0',
00200                 'seq_number' => '4',
00201                 'answer' => '<p>Variable can be typed</p>
00202         <p>xml Schemas fully support Namespaces</p>',
00203                 'timestamp' => '1273068477',
00204                 'event' => '9',
00205                 'grade' => '2',
00206                 'raw_grade' => '2',
00207                 'penalty' => '0',
00208                 'id' => 10517712,
00209             ),
00210         );
00211 
00212         $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
00213 
00214         $expectedqa = (object) array(
00215             'behaviour' => 'manualgraded',
00216             'questionid' => 90056,
00217             'variant' => 1,
00218             'maxmark' => 2,
00219             'minfraction' => 0,
00220             'flagged' => 0,
00221             'questionsummary' => "* Give two examples of facilities within XML schemas that cannot be found in Document Type Definitions (DTDs).\n_(2 marks)_",
00222             'rightanswer' => '',
00223             'responsesummary' => "Variable can be typed \n\nxml Schemas fully support Namespaces",
00224             'timemodified' => 1273068477,
00225             'steps' => array(
00226                 0 => (object) array(
00227                     'sequencenumber' => 0,
00228                     'state' => 'todo',
00229                     'fraction' => null,
00230                     'timecreated' => 1271667586,
00231                     'userid' => 118065,
00232                     'data' => array(),
00233                 ),
00234                 1 => (object) array(
00235                     'sequencenumber' => 1,
00236                     'state' => 'complete',
00237                     'fraction' => null,
00238                     'timecreated' => 1271670445,
00239                     'userid' => 118065,
00240                     'data' => array('answer' => '<p>Variable typeing</p>
00241         <p>Namespaces</p>'),
00242                 ),
00243                 2 => (object) array(
00244                     'sequencenumber' => 2,
00245                     'state' => 'complete',
00246                     'fraction' => null,
00247                     'timecreated' => 1271671440,
00248                     'userid' => 118065,
00249                     'data' => array('answer' => '<p>Variable can be typed</p>
00250         <p>xml Schemas fully support Namespaces</p>'),
00251                 ),
00252                 3 => (object) array(
00253                     'sequencenumber' => 3,
00254                     'state' => 'needsgrading',
00255                     'fraction' => null,
00256                     'timecreated' => 1271671440,
00257                     'userid' => 118065,
00258                     'data' => array('answer' => '<p>Variable can be typed</p>
00259         <p>xml Schemas fully support Namespaces</p>', '-finish' => 1),
00260                 ),
00261                 4 => (object) array(
00262                     'sequencenumber' => 4,
00263                     'state' => 'mangrright',
00264                     'fraction' => 1,
00265                     'timecreated' => 1273068477,
00266                     'userid' => null,
00267                     'data' => array('-comment' => '', '-mark' => 2, '-maxmark' => 2),
00268                 ),
00269             ),
00270         );
00271 
00272         $this->compare_qas($expectedqa, $qa);
00273     }
00274 
00275     public function test_essay_deferredfeedback_history820() {
00276         $quiz = (object) array(
00277             'id' => '142',
00278             'course' => '187',
00279             'name' => 'Questionnaire',
00280             'intro' => '<p>B680 is pioneering the use of the eAssessment module in the OU VLE (Virtual Learning Environment). We believe that the module is fit for purpose but we need users\' (students and ALs) experience to confirm this. Your answers to this short questionnaire therefore are of wide importance to the OU VLE Development Programme.  If you could complete this short questionnaire after attempting Practice CTMA04 <b></b>it would be greatly appreciated.</p>
00281         <p>The questionnaire has 15 questions and we would like you to answer as many of these as possible.  When you have completed your answers you will see a End test button, similar to the one in Practice CTMA 04, which you will need to click.  This will move you to a Summary page.  Please click the \'Submit all and finish\' button when you are happy to submit your final answers.  <strong>Please complete the questionnaire only once.</strong>  At a later stage the B680 Course Team will analyse the students\' answers to the questions. <br /></p>',
00282             'introformat' => FORMAT_HTML,
00283             'questiondecimalpoints' => '-1',
00284             'showuserpicture' => '1',
00285             'showblocks' => '1',
00286             'timeopen' => '0',
00287             'timeclose' => '0',
00288             'preferredbehaviour' => 'deferredfeedback',
00289             'attempts' => '0',
00290             'attemptonlast' => '0',
00291             'grademethod' => '1',
00292             'decimalpoints' => '2',
00293             'review' => '71727591',
00294             'questionsperpage' => '1',
00295             'shufflequestions' => '0',
00296             'shuffleanswers' => '0',
00297             'questions' => '3664,3716,0,3663,3717,0,3718,3719,0,3720,0,3733,3727,0,3728,3730,0,3731,3732,0,3726,3729,0',
00298             'sumgrades' => '0',
00299             'grade' => '0',
00300             'timecreated' => '0',
00301             'timemodified' => '1178202609',
00302             'password' => '',
00303             'subnet' => '',
00304             'popup' => '0',
00305             'delay1' => '0',
00306             'delay2' => '0',
00307             'timelimit' => '0',
00308         );
00309         $attempt = (object) array(
00310             'id' => '4246',
00311             'uniqueid' => '4246',
00312             'quiz' => '142',
00313             'userid' => '96864',
00314             'attempt' => '1',
00315             'sumgrades' => '0',
00316             'timestart' => '1179134211',
00317             'timefinish' => '1179134998',
00318             'timemodified' => '1179134869',
00319             'layout' => '3664,3716,0,3663,3717,0,3718,3719,0,3720,0,3733,3727,0,3728,3730,0,3731,3732,0,3726,3729,0',
00320             'preview' => '0',
00321             'needsupgradetonewqe' => '1',
00322         );
00323         $question = (object) array(
00324             'id' => '3729',
00325             'category' => '163',
00326             'parent' => '0',
00327             'name' => 'Question 98',
00328             'questiontext' => 'If you answered ‘No’ to the previous question please expand on your problem here.<br /><b></b><br />',
00329             'questiontextformat' => '1',
00330             'defaultmark' => '0',
00331             'penalty' => '0',
00332             'qtype' => 'essay',
00333             'length' => '1',
00334             'stamp' => 'learn.open.ac.uk+070312094434+k2HaUF',
00335             'version' => 'learn.open.ac.uk+070501173219+spx2IM',
00336             'hidden' => '0',
00337             'generalfeedback' => '',
00338             'generalfeedbackformat' => '1',
00339             'timecreated' => '0',
00340             'timemodified' => '0',
00341             'createdby' => null,
00342             'modifiedby' => null,
00343             'unlimited' => null,
00344             'maxmark' => '0',
00345             'options' => (object) array(
00346                 'answers' => array(
00347                     11264 => (object) array(
00348                         'question' => '3729',
00349                         'answer' => '',
00350                         'fraction' => '0',
00351                         'feedback' => '',
00352                         'id' => 11264,
00353                     ),
00354                 ),
00355             ),
00356             'hints' => false,
00357         );
00358         $qsession = (object) array(
00359             'id' => '47133',
00360             'attemptid' => '4246',
00361             'questionid' => '3729',
00362             'newest' => '107502',
00363             'newgraded' => '107407',
00364             'sumpenalty' => '0',
00365             'manualcomment' => '',
00366             'manualcommentformat' => '1',
00367             'flagged' => '1',
00368         );
00369         $qstates = array(
00370             107407 => (object) array(
00371                 'attempt' => '4246',
00372                 'question' => '3729',
00373                 'originalquestion' => '0',
00374                 'seq_number' => '0',
00375                 'answer' => '',
00376                 'timestamp' => '1179134211',
00377                 'event' => '0',
00378                 'grade' => '0',
00379                 'raw_grade' => '0',
00380                 'penalty' => '0',
00381                 'id' => 107407,
00382             ),
00383             107484 => (object) array(
00384                 'attempt' => '4246',
00385                 'question' => '3729',
00386                 'originalquestion' => '0',
00387                 'seq_number' => '1',
00388                 'answer' => 'it would be better to point our a \'red colour\' on the number which indicates the questions that we have done wrong. similar to previously, from question 1 to 10, green colour shows the right answer and red colour shows the wrong answer, so that we do not need to click on each answer to find out if it is right or wrong.',
00389                 'timestamp' => '1179134869',
00390                 'event' => '2',
00391                 'grade' => '0',
00392                 'raw_grade' => '0',
00393                 'penalty' => '0',
00394                 'id' => 107484,
00395             ),
00396             107502 => (object) array(
00397                 'attempt' => '4246',
00398                 'question' => '3729',
00399                 'originalquestion' => '0',
00400                 'seq_number' => '2',
00401                 'answer' => 'it would be better to point our a \'red colour\' on the number which indicates the questions that we have done wrong. similar to previously, from question 1 to 10, green colour shows the right answer and red colour shows the wrong answer, so that we do not need to click on each answer to find out if it is right or wrong.',
00402                 'timestamp' => '1179134869',
00403                 'event' => '8',
00404                 'grade' => '0',
00405                 'raw_grade' => '0',
00406                 'penalty' => '0',
00407                 'id' => 107502,
00408             ),
00409         );
00410 
00411         $qa = $this->updater->convert_question_attempt($quiz, $attempt, $question, $qsession, $qstates);
00412 
00413         $expectedqa = (object) array(
00414             'behaviour' => 'manualgraded',
00415             'questionid' => 3729,
00416             'variant' => 1,
00417             'maxmark' => 0,
00418             'minfraction' => 0,
00419             'flagged' => 0,
00420             'questionsummary' => "If you answered ‘No’ to the previous question please expand on your problem here.",
00421             'rightanswer' => '',
00422             'responsesummary' => 'it would be better to point our a \'red colour\' on the number which indicates the questions that we have done wrong. similar to previously, from question 1 to 10, green colour shows the right answer and red colour shows the wrong answer, so that we do not need to click on each answer to find out if it is right or wrong.',
00423             'timemodified' => 1179134869,
00424             'steps' => array(
00425                 0 => (object) array(
00426                     'sequencenumber' => 0,
00427                     'state' => 'todo',
00428                     'fraction' => null,
00429                     'timecreated' => 1179134211,
00430                     'userid' => 96864,
00431                     'data' => array(),
00432                 ),
00433                 1 => (object) array(
00434                     'sequencenumber' => 1,
00435                     'state' => 'complete',
00436                     'fraction' => null,
00437                     'timecreated' => 1179134869,
00438                     'userid' => 96864,
00439                     'data' => array('answer' => 'it would be better to point our a \'red colour\' on the number which indicates the questions that we have done wrong. similar to previously, from question 1 to 10, green colour shows the right answer and red colour shows the wrong answer, so that we do not need to click on each answer to find out if it is right or wrong.'),
00440                 ),
00441                 2 => (object) array(
00442                     'sequencenumber' => 2,
00443                     'state' => 'needsgrading',
00444                     'fraction' => null,
00445                     'timecreated' => 1179134869,
00446                     'userid' => 96864,
00447                     'data' => array('-finish' => 1, 'answer' => 'it would be better to point our a \'red colour\' on the number which indicates the questions that we have done wrong. similar to previously, from question 1 to 10, green colour shows the right answer and red colour shows the wrong answer, so that we do not need to click on each answer to find out if it is right or wrong.'),
00448                 ),
00449             ),
00450         );
00451 
00452         $this->compare_qas($expectedqa, $qa);
00453     }
00454 
00455     public function test_essay_deferredfeedback_missing() {
00456         $quiz = (object) array(
00457             'id' => '142',
00458             'course' => '187',
00459             'name' => 'Questionnaire',
00460             'intro' => '<p>B680 is pioneering the use of the eAssessment module in the OU VLE (Virtual Learning Environment). We believe that the module is fit for purpose but we need users\' (students and ALs) experience to confirm this. Your answers to this short questionnaire therefore are of wide importance to the OU VLE Development Programme.  If you could complete this short questionnaire after attempting Practice CTMA04 <b></b>it would be greatly appreciated.</p>
00461         <p>The questionnaire has 15 questions and we would like you to answer as many of these as possible.  When you have completed your answers you will see a End test button, similar to the one in Practice CTMA 04, which you will need to click.  This will move you to a Summary page.  Please click the \'Submit all and finish\' button when you are happy to submit your final answers.  <strong>Please complete the questionnaire only once.</strong>  At a later stage the B680 Course Team will analyse the students\' answers to the questions. <br /></p>',
00462             'introformat' => FORMAT_HTML,
00463             'questiondecimalpoints' => '-1',
00464             'showuserpicture' => '1',
00465             'showblocks' => '1',
00466             'timeopen' => '0',
00467             'timeclose' => '0',
00468             'preferredbehaviour' => 'deferredfeedback',
00469             'attempts' => '0',
00470             'attemptonlast' => '0',
00471             'grademethod' => '1',
00472             'decimalpoints' => '2',
00473             'review' => '71727591',
00474             'questionsperpage' => '1',
00475             'shufflequestions' => '0',
00476             'shuffleanswers' => '0',
00477             'questions' => '3664,3716,0,3663,3717,0,3718,3719,0,3720,0,3733,3727,0,3728,3730,0,3731,3732,0,3726,3729,0',
00478             'sumgrades' => '0',
00479             'grade' => '0',
00480             'timecreated' => '0',
00481             'timemodified' => '1178202609',
00482             'password' => '',
00483             'subnet' => '',
00484             'popup' => '0',
00485             'delay1' => '0',
00486             'delay2' => '0',
00487             'timelimit' => '0',
00488         );
00489         $attempt = (object) array(
00490             'id' => '4246',
00491             'uniqueid' => '4246',
00492             'quiz' => '142',
00493             'userid' => '96864',
00494             'attempt' => '1',
00495             'sumgrades' => '0',
00496             'timestart' => '1179134211',
00497             'timefinish' => '1179134998',
00498             'timemodified' => '1179134869',
00499             'layout' => '3664,3716,0,3663,3717,0,3718,3719,0,3720,0,3733,3727,0,3728,3730,0,3731,3732,0,3726,3729,0',
00500             'preview' => '0',
00501             'needsupgradetonewqe' => '1',
00502         );
00503         $question = (object) array(
00504             'id' => '3729',
00505             'category' => '163',
00506             'parent' => '0',
00507             'name' => 'Question 98',
00508             'questiontext' => 'If you answered ‘No’ to the previous question please expand on your problem here.<br /><b></b><br />',
00509             'questiontextformat' => '1',
00510             'defaultmark' => '0',
00511             'penalty' => '0',
00512             'qtype' => 'essay',
00513             'length' => '1',
00514             'stamp' => 'learn.open.ac.uk+070312094434+k2HaUF',
00515             'version' => 'learn.open.ac.uk+070501173219+spx2IM',
00516             'hidden' => '0',
00517             'generalfeedback' => '',
00518             'generalfeedbackformat' => '1',
00519             'timecreated' => '0',
00520             'timemodified' => '0',
00521             'createdby' => null,
00522             'modifiedby' => null,
00523             'unlimited' => null,
00524             'maxmark' => '0',
00525             'options' => (object) array(
00526                 'answers' => array(
00527                     11264 => (object) array(
00528                         'question' => '3729',
00529                         'answer' => '',
00530                         'fraction' => '0',
00531                         'feedback' => '',
00532                         'id' => 11264,
00533                     ),
00534                 ),
00535             ),
00536             'hints' => false,
00537         );
00538 
00539         $qa = $this->updater->supply_missing_question_attempt( $quiz, $attempt, $question);
00540 
00541         $expectedqa = (object) array(
00542             'behaviour' => 'manualgraded',
00543             'questionid' => 3729,
00544             'variant' => 1,
00545             'maxmark' => 0,
00546             'minfraction' => 0,
00547             'flagged' => 0,
00548             'questionsummary' => "If you answered ‘No’ to the previous question please expand on your problem here.",
00549             'rightanswer' => '',
00550             'responsesummary' => '',
00551             'timemodified' => 1179134211,
00552             'steps' => array(
00553                 0 => (object) array(
00554                     'sequencenumber' => 0,
00555                     'state' => 'todo',
00556                     'fraction' => null,
00557                     'timecreated' => 1179134211,
00558                     'userid' => 96864,
00559                     'data' => array(),
00560                 ),
00561             ),
00562         );
00563 
00564         $this->compare_qas($expectedqa, $qa);
00565     }
00566 }
 All Data Structures Namespaces Files Functions Variables Enumerations