| 1 | 
           efrain | 
           1 | 
           <?php
  | 
        
        
            | 
            | 
           2 | 
           // This file is part of Moodle - http://moodle.org/
  | 
        
        
            | 
            | 
           3 | 
           //
  | 
        
        
            | 
            | 
           4 | 
           // Moodle is free software: you can redistribute it and/or modify
  | 
        
        
            | 
            | 
           5 | 
           // it under the terms of the GNU General Public License as published by
  | 
        
        
            | 
            | 
           6 | 
           // the Free Software Foundation, either version 3 of the License, or
  | 
        
        
            | 
            | 
           7 | 
           // (at your option) any later version.
  | 
        
        
            | 
            | 
           8 | 
           //
  | 
        
        
            | 
            | 
           9 | 
           // Moodle is distributed in the hope that it will be useful,
  | 
        
        
            | 
            | 
           10 | 
           // but WITHOUT ANY WARRANTY; without even the implied warranty of
  | 
        
        
            | 
            | 
           11 | 
           // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  | 
        
        
            | 
            | 
           12 | 
           // GNU General Public License for more details.
  | 
        
        
            | 
            | 
           13 | 
           //
  | 
        
        
            | 
            | 
           14 | 
           // You should have received a copy of the GNU General Public License
  | 
        
        
            | 
            | 
           15 | 
           // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  | 
        
        
            | 
            | 
           16 | 
              | 
        
        
            | 
            | 
           17 | 
           namespace qformat_blackboard_six;
  | 
        
        
            | 
            | 
           18 | 
              | 
        
        
            | 
            | 
           19 | 
           use qformat_blackboard_six;
  | 
        
        
            | 
            | 
           20 | 
           use qformat_blackboard_six_file;
  | 
        
        
            | 
            | 
           21 | 
           use question_bank;
  | 
        
        
            | 
            | 
           22 | 
           use question_check_specified_fields_expectation;
  | 
        
        
            | 
            | 
           23 | 
              | 
        
        
            | 
            | 
           24 | 
           defined('MOODLE_INTERNAL') || die();
  | 
        
        
            | 
            | 
           25 | 
              | 
        
        
            | 
            | 
           26 | 
           global $CFG;
  | 
        
        
            | 
            | 
           27 | 
           require_once($CFG->libdir . '/questionlib.php');
  | 
        
        
            | 
            | 
           28 | 
           require_once($CFG->dirroot . '/question/format.php');
  | 
        
        
            | 
            | 
           29 | 
           require_once($CFG->dirroot . '/question/format/blackboard_six/format.php');
  | 
        
        
            | 
            | 
           30 | 
           require_once($CFG->dirroot . '/question/engine/tests/helpers.php');
  | 
        
        
            | 
            | 
           31 | 
              | 
        
        
            | 
            | 
           32 | 
           /**
  | 
        
        
            | 
            | 
           33 | 
            * Unit tests for the blackboard v6+ question import format.
  | 
        
        
            | 
            | 
           34 | 
            *
  | 
        
        
            | 
            | 
           35 | 
            * @package    qformat_blackboard_six
  | 
        
        
            | 
            | 
           36 | 
            * @copyright  2012 Jean-Michel Vedrine
  | 
        
        
            | 
            | 
           37 | 
            * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  | 
        
        
            | 
            | 
           38 | 
            */
  | 
        
        
            | 
            | 
           39 | 
           class blackboardformatpool_test extends \question_testcase {
  | 
        
        
            | 
            | 
           40 | 
              | 
        
        
            | 
            | 
           41 | 
               public function make_test_xml() {
  | 
        
        
            | 
            | 
           42 | 
                   $xmlfile = new qformat_blackboard_six_file();
  | 
        
        
            | 
            | 
           43 | 
                   $xmlfile->filetype = 2;
  | 
        
        
            | 
            | 
           44 | 
                   $xmlfile->text = file_get_contents(__DIR__ . '/fixtures/sample_blackboard_pool.dat');
  | 
        
        
            | 
            | 
           45 | 
                   return array(0 => $xmlfile);
  | 
        
        
            | 
            | 
           46 | 
               }
  | 
        
        
            | 
            | 
           47 | 
              | 
        
        
           | 11 | 
           efrain | 
           48 | 
               public function test_import_match(): void {
  | 
        
        
           | 1 | 
           efrain | 
           49 | 
              | 
        
        
            | 
            | 
           50 | 
                   $xml = $this->make_test_xml();
  | 
        
        
            | 
            | 
           51 | 
              | 
        
        
            | 
            | 
           52 | 
                   $importer = new qformat_blackboard_six();
  | 
        
        
            | 
            | 
           53 | 
                   $questions = $importer->readquestions($xml);
  | 
        
        
            | 
            | 
           54 | 
              | 
        
        
            | 
            | 
           55 | 
                   $q = $questions[5];
  | 
        
        
            | 
            | 
           56 | 
              | 
        
        
            | 
            | 
           57 | 
                   // If qtype_ddmatch is installed, the formatter produces ddmatch
  | 
        
        
            | 
            | 
           58 | 
                   // qtypes, not match ones.
  | 
        
        
            | 
            | 
           59 | 
                   $ddmatchisinstalled = question_bank::is_qtype_installed('ddmatch');
  | 
        
        
            | 
            | 
           60 | 
              | 
        
        
            | 
            | 
           61 | 
                   $expectedq = new \stdClass();
  | 
        
        
            | 
            | 
           62 | 
                   $expectedq->qtype = $ddmatchisinstalled ? 'ddmatch' : 'match';
  | 
        
        
            | 
            | 
           63 | 
                   $expectedq->name = 'Classify the animals.';
  | 
        
        
            | 
            | 
           64 | 
                   $expectedq->questiontext = '<i>Classify the animals.</i>';
  | 
        
        
            | 
            | 
           65 | 
                   $expectedq->questiontextformat = FORMAT_HTML;
  | 
        
        
            | 
            | 
           66 | 
                   $expectedq->correctfeedback = array('text' => '',
  | 
        
        
            | 
            | 
           67 | 
                           'format' => FORMAT_HTML);
  | 
        
        
            | 
            | 
           68 | 
                   $expectedq->partiallycorrectfeedback = array('text' => '',
  | 
        
        
            | 
            | 
           69 | 
                           'format' => FORMAT_HTML);
  | 
        
        
            | 
            | 
           70 | 
                   $expectedq->incorrectfeedback = array('text' => '',
  | 
        
        
            | 
            | 
           71 | 
                           'format' => FORMAT_HTML);
  | 
        
        
            | 
            | 
           72 | 
                   $expectedq->generalfeedback = '';
  | 
        
        
            | 
            | 
           73 | 
                   $expectedq->generalfeedbackformat = FORMAT_HTML;
  | 
        
        
            | 
            | 
           74 | 
                   $expectedq->defaultmark = 1;
  | 
        
        
            | 
            | 
           75 | 
                   $expectedq->length = 1;
  | 
        
        
            | 
            | 
           76 | 
                   $expectedq->penalty = 0.3333333;
  | 
        
        
            | 
            | 
           77 | 
                   $expectedq->shuffleanswers = get_config('quiz', 'shuffleanswers');
  | 
        
        
            | 
            | 
           78 | 
                   $expectedq->subquestions = array(
  | 
        
        
            | 
            | 
           79 | 
                       array('text' => 'cat', 'format' => FORMAT_HTML),
  | 
        
        
            | 
            | 
           80 | 
                       array('text' => '', 'format' => FORMAT_HTML),
  | 
        
        
            | 
            | 
           81 | 
                       array('text' => 'frog', 'format' => FORMAT_HTML),
  | 
        
        
            | 
            | 
           82 | 
                       array('text' => 'newt', 'format' => FORMAT_HTML));
  | 
        
        
            | 
            | 
           83 | 
              | 
        
        
            | 
            | 
           84 | 
                   if ($ddmatchisinstalled) {
  | 
        
        
            | 
            | 
           85 | 
                       $expectedq->subanswers = array(
  | 
        
        
            | 
            | 
           86 | 
                           array('text' => 'mammal', 'format' => FORMAT_HTML),
  | 
        
        
            | 
            | 
           87 | 
                           array('text' => 'insect', 'format' => FORMAT_HTML),
  | 
        
        
            | 
            | 
           88 | 
                           array('text' => 'amphibian', 'format' => FORMAT_HTML),
  | 
        
        
            | 
            | 
           89 | 
                           array('text' => 'amphibian', 'format' => FORMAT_HTML),
  | 
        
        
            | 
            | 
           90 | 
                       );
  | 
        
        
            | 
            | 
           91 | 
                   } else {
  | 
        
        
            | 
            | 
           92 | 
                       $expectedq->subanswers = array('mammal', 'insect', 'amphibian', 'amphibian');
  | 
        
        
            | 
            | 
           93 | 
                   }
  | 
        
        
            | 
            | 
           94 | 
                   $this->assert(new question_check_specified_fields_expectation($expectedq), $q);
  | 
        
        
            | 
            | 
           95 | 
               }
  | 
        
        
            | 
            | 
           96 | 
              | 
        
        
           | 11 | 
           efrain | 
           97 | 
               public function test_import_multichoice_single(): void {
  | 
        
        
           | 1 | 
           efrain | 
           98 | 
              | 
        
        
            | 
            | 
           99 | 
                   $xml = $this->make_test_xml();
  | 
        
        
            | 
            | 
           100 | 
              | 
        
        
            | 
            | 
           101 | 
                   $importer = new qformat_blackboard_six();
  | 
        
        
            | 
            | 
           102 | 
                   $questions = $importer->readquestions($xml);
  | 
        
        
            | 
            | 
           103 | 
                   $q = $questions[2];
  | 
        
        
            | 
            | 
           104 | 
              | 
        
        
            | 
            | 
           105 | 
                   $expectedq = new \stdClass();
  | 
        
        
            | 
            | 
           106 | 
                   $expectedq->qtype = 'multichoice';
  | 
        
        
            | 
            | 
           107 | 
                   $expectedq->single = 1;
  | 
        
        
            | 
            | 
           108 | 
                   $expectedq->name = 'What\'s between orange and green in the spectrum?';
  | 
        
        
            | 
            | 
           109 | 
                   $expectedq->questiontext = '<span style="font-size:12pt">What\'s between orange and green in the spectrum?</span>';
  | 
        
        
            | 
            | 
           110 | 
                   $expectedq->questiontextformat = FORMAT_HTML;
  | 
        
        
            | 
            | 
           111 | 
                   $expectedq->correctfeedback = array('text' => 'You gave the right answer.',
  | 
        
        
            | 
            | 
           112 | 
                           'format' => FORMAT_HTML);
  | 
        
        
            | 
            | 
           113 | 
                   $expectedq->partiallycorrectfeedback = array('text' => '',
  | 
        
        
            | 
            | 
           114 | 
                           'format' => FORMAT_HTML);
  | 
        
        
            | 
            | 
           115 | 
                   $expectedq->incorrectfeedback = array('text' => 'Only yellow is between orange and green in the spectrum.',
  | 
        
        
            | 
            | 
           116 | 
                           'format' => FORMAT_HTML);
  | 
        
        
            | 
            | 
           117 | 
                   $expectedq->generalfeedback = '';
  | 
        
        
            | 
            | 
           118 | 
                   $expectedq->generalfeedbackformat = FORMAT_HTML;
  | 
        
        
            | 
            | 
           119 | 
                   $expectedq->defaultmark = 1;
  | 
        
        
            | 
            | 
           120 | 
                   $expectedq->length = 1;
  | 
        
        
            | 
            | 
           121 | 
                   $expectedq->penalty = 0.3333333;
  | 
        
        
            | 
            | 
           122 | 
                   $expectedq->shuffleanswers = get_config('quiz', 'shuffleanswers');
  | 
        
        
            | 
            | 
           123 | 
                   $expectedq->answer = array(
  | 
        
        
            | 
            | 
           124 | 
              | 
        
        
            | 
            | 
           125 | 
                               'text' => '<span style="font-size:12pt">red</span>',
  | 
        
        
            | 
            | 
           126 | 
                               'format' => FORMAT_HTML,
  | 
        
        
            | 
            | 
           127 | 
                           ),
  | 
        
        
            | 
            | 
           128 | 
                           1 => array(
  | 
        
        
            | 
            | 
           129 | 
                               'text' => '<span style="font-size:12pt">yellow</span>',
  | 
        
        
            | 
            | 
           130 | 
                               'format' => FORMAT_HTML,
  | 
        
        
            | 
            | 
           131 | 
                           ),
  | 
        
        
            | 
            | 
           132 | 
                           2 => array(
  | 
        
        
            | 
            | 
           133 | 
                               'text' => '<span style="font-size:12pt">blue</span>',
  | 
        
        
            | 
            | 
           134 | 
                               'format' => FORMAT_HTML,
  | 
        
        
            | 
            | 
           135 | 
                           )
  | 
        
        
            | 
            | 
           136 | 
                       );
  | 
        
        
            | 
            | 
           137 | 
                   $expectedq->fraction = array(0, 1, 0);
  | 
        
        
            | 
            | 
           138 | 
                   $expectedq->feedback = array(
  | 
        
        
            | 
            | 
           139 | 
              | 
        
        
            | 
            | 
           140 | 
                               'text' => '',
  | 
        
        
            | 
            | 
           141 | 
                               'format' => FORMAT_HTML,
  | 
        
        
            | 
            | 
           142 | 
                           ),
  | 
        
        
            | 
            | 
           143 | 
                           1 => array(
  | 
        
        
            | 
            | 
           144 | 
                               'text' => '',
  | 
        
        
            | 
            | 
           145 | 
                               'format' => FORMAT_HTML,
  | 
        
        
            | 
            | 
           146 | 
                           ),
  | 
        
        
            | 
            | 
           147 | 
                           2 => array(
  | 
        
        
            | 
            | 
           148 | 
                               'text' => '',
  | 
        
        
            | 
            | 
           149 | 
                               'format' => FORMAT_HTML,
  | 
        
        
            | 
            | 
           150 | 
                           )
  | 
        
        
            | 
            | 
           151 | 
                       );
  | 
        
        
            | 
            | 
           152 | 
              | 
        
        
            | 
            | 
           153 | 
                   $this->assert(new question_check_specified_fields_expectation($expectedq), $q);
  | 
        
        
            | 
            | 
           154 | 
               }
  | 
        
        
            | 
            | 
           155 | 
              | 
        
        
           | 11 | 
           efrain | 
           156 | 
               public function test_import_multichoice_multi(): void {
  | 
        
        
           | 1 | 
           efrain | 
           157 | 
              | 
        
        
            | 
            | 
           158 | 
                   $xml = $this->make_test_xml();
  | 
        
        
            | 
            | 
           159 | 
              | 
        
        
            | 
            | 
           160 | 
                   $importer = new qformat_blackboard_six();
  | 
        
        
            | 
            | 
           161 | 
                   $questions = $importer->readquestions($xml);
  | 
        
        
            | 
            | 
           162 | 
                   $q = $questions[3];
  | 
        
        
            | 
            | 
           163 | 
              | 
        
        
            | 
            | 
           164 | 
                   $expectedq = new \stdClass();
  | 
        
        
            | 
            | 
           165 | 
                   $expectedq->qtype = 'multichoice';
  | 
        
        
            | 
            | 
           166 | 
                   $expectedq->single = 0;
  | 
        
        
            | 
            | 
           167 | 
                   $expectedq->name = 'What\'s between orange and green in the spectrum?';
  | 
        
        
            | 
            | 
           168 | 
                   $expectedq->questiontext = '<span style="font-size:12pt">What\'s between orange and green in the spectrum?</span>';
  | 
        
        
            | 
            | 
           169 | 
                   $expectedq->questiontextformat = FORMAT_HTML;
  | 
        
        
            | 
            | 
           170 | 
                   $expectedq->correctfeedback = array(
  | 
        
        
            | 
            | 
           171 | 
                           'text' => 'You gave the right answer.',
  | 
        
        
            | 
            | 
           172 | 
                           'format' => FORMAT_HTML,
  | 
        
        
            | 
            | 
           173 | 
                       );
  | 
        
        
            | 
            | 
           174 | 
                   $expectedq->partiallycorrectfeedback = array(
  | 
        
        
            | 
            | 
           175 | 
                           'text' => 'Only yellow and off-beige are between orange and green in the spectrum.',
  | 
        
        
            | 
            | 
           176 | 
                           'format' => FORMAT_HTML,
  | 
        
        
            | 
            | 
           177 | 
                       );
  | 
        
        
            | 
            | 
           178 | 
                   $expectedq->incorrectfeedback = array(
  | 
        
        
            | 
            | 
           179 | 
                           'text' => 'Only yellow and off-beige are between orange and green in the spectrum.',
  | 
        
        
            | 
            | 
           180 | 
                           'format' => FORMAT_HTML,
  | 
        
        
            | 
            | 
           181 | 
                           );
  | 
        
        
            | 
            | 
           182 | 
                   $expectedq->generalfeedback = '';
  | 
        
        
            | 
            | 
           183 | 
                   $expectedq->generalfeedbackformat = FORMAT_HTML;
  | 
        
        
            | 
            | 
           184 | 
                   $expectedq->defaultmark = 1;
  | 
        
        
            | 
            | 
           185 | 
                   $expectedq->length = 1;
  | 
        
        
            | 
            | 
           186 | 
                   $expectedq->penalty = 0.3333333;
  | 
        
        
            | 
            | 
           187 | 
                   $expectedq->shuffleanswers = get_config('quiz', 'shuffleanswers');
  | 
        
        
            | 
            | 
           188 | 
                   $expectedq->answer = array(
  | 
        
        
            | 
            | 
           189 | 
              | 
        
        
            | 
            | 
           190 | 
                               'text' => '<span style="font-size:12pt">yellow</span>',
  | 
        
        
            | 
            | 
           191 | 
                               'format' => FORMAT_HTML,
  | 
        
        
            | 
            | 
           192 | 
                           ),
  | 
        
        
            | 
            | 
           193 | 
                           1 => array(
  | 
        
        
            | 
            | 
           194 | 
                               'text' => '<span style="font-size:12pt">red</span>',
  | 
        
        
            | 
            | 
           195 | 
                               'format' => FORMAT_HTML,
  | 
        
        
            | 
            | 
           196 | 
                           ),
  | 
        
        
            | 
            | 
           197 | 
                           2 => array(
  | 
        
        
            | 
            | 
           198 | 
                               'text' => '<span style="font-size:12pt">off-beige</span>',
  | 
        
        
            | 
            | 
           199 | 
                               'format' => FORMAT_HTML,
  | 
        
        
            | 
            | 
           200 | 
                           ),
  | 
        
        
            | 
            | 
           201 | 
                           3 => array(
  | 
        
        
            | 
            | 
           202 | 
                               'text' => '<span style="font-size:12pt">blue</span>',
  | 
        
        
            | 
            | 
           203 | 
                               'format' => FORMAT_HTML,
  | 
        
        
            | 
            | 
           204 | 
                           )
  | 
        
        
            | 
            | 
           205 | 
                       );
  | 
        
        
            | 
            | 
           206 | 
                   $expectedq->fraction = array(0.5, 0, 0.5, 0);
  | 
        
        
            | 
            | 
           207 | 
                   $expectedq->feedback = array(
  | 
        
        
            | 
            | 
           208 | 
              | 
        
        
            | 
            | 
           209 | 
                               'text' => '',
  | 
        
        
            | 
            | 
           210 | 
                               'format' => FORMAT_HTML,
  | 
        
        
            | 
            | 
           211 | 
                           ),
  | 
        
        
            | 
            | 
           212 | 
                           1 => array(
  | 
        
        
            | 
            | 
           213 | 
                               'text' => '',
  | 
        
        
            | 
            | 
           214 | 
                               'format' => FORMAT_HTML,
  | 
        
        
            | 
            | 
           215 | 
                           ),
  | 
        
        
            | 
            | 
           216 | 
                           2 => array(
  | 
        
        
            | 
            | 
           217 | 
                               'text' => '',
  | 
        
        
            | 
            | 
           218 | 
                               'format' => FORMAT_HTML,
  | 
        
        
            | 
            | 
           219 | 
                           ),
  | 
        
        
            | 
            | 
           220 | 
                           3 => array(
  | 
        
        
            | 
            | 
           221 | 
                               'text' => '',
  | 
        
        
            | 
            | 
           222 | 
                               'format' => FORMAT_HTML,
  | 
        
        
            | 
            | 
           223 | 
                           )
  | 
        
        
            | 
            | 
           224 | 
                       );
  | 
        
        
            | 
            | 
           225 | 
              | 
        
        
            | 
            | 
           226 | 
                   $this->assert(new question_check_specified_fields_expectation($expectedq), $q);
  | 
        
        
            | 
            | 
           227 | 
               }
  | 
        
        
            | 
            | 
           228 | 
              | 
        
        
           | 11 | 
           efrain | 
           229 | 
               public function test_import_truefalse(): void {
  | 
        
        
           | 1 | 
           efrain | 
           230 | 
              | 
        
        
            | 
            | 
           231 | 
                   $xml = $this->make_test_xml();
  | 
        
        
            | 
            | 
           232 | 
              | 
        
        
            | 
            | 
           233 | 
                   $importer = new qformat_blackboard_six();
  | 
        
        
            | 
            | 
           234 | 
                   $questions = $importer->readquestions($xml);
  | 
        
        
            | 
            | 
           235 | 
                   $q = $questions[1];
  | 
        
        
            | 
            | 
           236 | 
              | 
        
        
            | 
            | 
           237 | 
                   $expectedq = new \stdClass();
  | 
        
        
            | 
            | 
           238 | 
                   $expectedq->qtype = 'truefalse';
  | 
        
        
            | 
            | 
           239 | 
                   $expectedq->name = '42 is the Absolute Answer to everything.';
  | 
        
        
            | 
            | 
           240 | 
                   $expectedq->questiontext = '<span style="font-size:12pt">42 is the Absolute Answer to everything.</span>';
  | 
        
        
            | 
            | 
           241 | 
                   $expectedq->questiontextformat = FORMAT_HTML;
  | 
        
        
            | 
            | 
           242 | 
                   $expectedq->generalfeedback = '';
  | 
        
        
            | 
            | 
           243 | 
                   $expectedq->generalfeedbackformat = FORMAT_HTML;
  | 
        
        
            | 
            | 
           244 | 
                   $expectedq->defaultmark = 1;
  | 
        
        
            | 
            | 
           245 | 
                   $expectedq->length = 1;
  | 
        
        
            | 
            | 
           246 | 
                   $expectedq->correctanswer = 0;
  | 
        
        
            | 
            | 
           247 | 
                   $expectedq->feedbacktrue = array(
  | 
        
        
            | 
            | 
           248 | 
                           'text' => '42 is the Ultimate Answer.',
  | 
        
        
            | 
            | 
           249 | 
                           'format' => FORMAT_HTML,
  | 
        
        
            | 
            | 
           250 | 
                       );
  | 
        
        
            | 
            | 
           251 | 
                   $expectedq->feedbackfalse = array(
  | 
        
        
            | 
            | 
           252 | 
                           'text' => 'You gave the right answer.',
  | 
        
        
            | 
            | 
           253 | 
                           'format' => FORMAT_HTML,
  | 
        
        
            | 
            | 
           254 | 
                       );
  | 
        
        
            | 
            | 
           255 | 
                   $this->assert(new question_check_specified_fields_expectation($expectedq), $q);
  | 
        
        
            | 
            | 
           256 | 
               }
  | 
        
        
            | 
            | 
           257 | 
              | 
        
        
           | 11 | 
           efrain | 
           258 | 
               public function test_import_fill_in_the_blank(): void {
  | 
        
        
           | 1 | 
           efrain | 
           259 | 
              | 
        
        
            | 
            | 
           260 | 
                   $xml = $this->make_test_xml();
  | 
        
        
            | 
            | 
           261 | 
              | 
        
        
            | 
            | 
           262 | 
                   $importer = new qformat_blackboard_six();
  | 
        
        
            | 
            | 
           263 | 
                   $questions = $importer->readquestions($xml);
  | 
        
        
            | 
            | 
           264 | 
                   $q = $questions[4];
  | 
        
        
            | 
            | 
           265 | 
              | 
        
        
            | 
            | 
           266 | 
                   $expectedq = new \stdClass();
  | 
        
        
            | 
            | 
           267 | 
                   $expectedq->qtype = 'shortanswer';
  | 
        
        
            | 
            | 
           268 | 
                   $expectedq->name = 'Name an amphibian: __________.';
  | 
        
        
            | 
            | 
           269 | 
                   $expectedq->questiontext = '<span style="font-size:12pt">Name an amphibian: __________.</span>';
  | 
        
        
            | 
            | 
           270 | 
                   $expectedq->questiontextformat = FORMAT_HTML;
  | 
        
        
            | 
            | 
           271 | 
                   $expectedq->generalfeedback = '';
  | 
        
        
            | 
            | 
           272 | 
                   $expectedq->generalfeedbackformat = FORMAT_HTML;
  | 
        
        
            | 
            | 
           273 | 
                   $expectedq->defaultmark = 1;
  | 
        
        
            | 
            | 
           274 | 
                   $expectedq->length = 1;
  | 
        
        
            | 
            | 
           275 | 
                   $expectedq->usecase = 0;
  | 
        
        
            | 
            | 
           276 | 
                   $expectedq->answer = array('frog', '*');
  | 
        
        
            | 
            | 
           277 | 
                   $expectedq->fraction = array(1, 0);
  | 
        
        
            | 
            | 
           278 | 
                   $expectedq->feedback = array(
  | 
        
        
            | 
            | 
           279 | 
              | 
        
        
            | 
            | 
           280 | 
                               'text' => '',
  | 
        
        
            | 
            | 
           281 | 
                               'format' => FORMAT_HTML,
  | 
        
        
            | 
            | 
           282 | 
                           ),
  | 
        
        
            | 
            | 
           283 | 
                           1 => array(
  | 
        
        
            | 
            | 
           284 | 
                               'text' => '',
  | 
        
        
            | 
            | 
           285 | 
                               'format' => FORMAT_HTML,
  | 
        
        
            | 
            | 
           286 | 
                           )
  | 
        
        
            | 
            | 
           287 | 
                       );
  | 
        
        
            | 
            | 
           288 | 
              | 
        
        
            | 
            | 
           289 | 
                   $this->assert(new question_check_specified_fields_expectation($expectedq), $q);
  | 
        
        
            | 
            | 
           290 | 
               }
  | 
        
        
            | 
            | 
           291 | 
              | 
        
        
           | 11 | 
           efrain | 
           292 | 
               public function test_import_essay(): void {
  | 
        
        
           | 1 | 
           efrain | 
           293 | 
              | 
        
        
            | 
            | 
           294 | 
                   $xml = $this->make_test_xml();
  | 
        
        
            | 
            | 
           295 | 
              | 
        
        
            | 
            | 
           296 | 
                   $importer = new qformat_blackboard_six();
  | 
        
        
            | 
            | 
           297 | 
                   $questions = $importer->readquestions($xml);
  | 
        
        
            | 
            | 
           298 | 
                   $q = $questions[6];
  | 
        
        
            | 
            | 
           299 | 
              | 
        
        
            | 
            | 
           300 | 
                   $expectedq = new \stdClass();
  | 
        
        
            | 
            | 
           301 | 
                   $expectedq->qtype = 'essay';
  | 
        
        
            | 
            | 
           302 | 
                   $expectedq->name = 'How are you?';
  | 
        
        
            | 
            | 
           303 | 
                   $expectedq->questiontext = 'How are you?';
  | 
        
        
            | 
            | 
           304 | 
                   $expectedq->questiontextformat = FORMAT_HTML;
  | 
        
        
            | 
            | 
           305 | 
                   $expectedq->generalfeedback = '';
  | 
        
        
            | 
            | 
           306 | 
                   $expectedq->generalfeedbackformat = FORMAT_HTML;
  | 
        
        
            | 
            | 
           307 | 
                   $expectedq->defaultmark = 1;
  | 
        
        
            | 
            | 
           308 | 
                   $expectedq->length = 1;
  | 
        
        
            | 
            | 
           309 | 
                   $expectedq->responseformat = 'editor';
  | 
        
        
            | 
            | 
           310 | 
                   $expectedq->responsefieldlines = 15;
  | 
        
        
            | 
            | 
           311 | 
                   $expectedq->attachments = 0;
  | 
        
        
            | 
            | 
           312 | 
                   $expectedq->graderinfo = array(
  | 
        
        
            | 
            | 
           313 | 
                           'text' => 'Blackboard answer for essay questions will be imported as informations for graders.',
  | 
        
        
            | 
            | 
           314 | 
                           'format' => FORMAT_HTML,
  | 
        
        
            | 
            | 
           315 | 
                       );
  | 
        
        
            | 
            | 
           316 | 
              | 
        
        
            | 
            | 
           317 | 
                   $this->assert(new question_check_specified_fields_expectation($expectedq), $q);
  | 
        
        
            | 
            | 
           318 | 
               }
  | 
        
        
            | 
            | 
           319 | 
              | 
        
        
           | 11 | 
           efrain | 
           320 | 
               public function test_import_category(): void {
  | 
        
        
           | 1 | 
           efrain | 
           321 | 
              | 
        
        
            | 
            | 
           322 | 
                   $xml = $this->make_test_xml();
  | 
        
        
            | 
            | 
           323 | 
              | 
        
        
            | 
            | 
           324 | 
                   $importer = new qformat_blackboard_six();
  | 
        
        
            | 
            | 
           325 | 
                   $questions = $importer->readquestions($xml);
  | 
        
        
            | 
            | 
           326 | 
                   $q = $questions[0];
  | 
        
        
            | 
            | 
           327 | 
              | 
        
        
            | 
            | 
           328 | 
                   $expectedq = new \stdClass();
  | 
        
        
            | 
            | 
           329 | 
                   $expectedq->qtype = 'category';
  | 
        
        
            | 
            | 
           330 | 
                   $expectedq->category = 'exam 3 2008-9';
  | 
        
        
            | 
            | 
           331 | 
              | 
        
        
            | 
            | 
           332 | 
                   $this->assert(new question_check_specified_fields_expectation($expectedq), $q);
  | 
        
        
            | 
            | 
           333 | 
               }
  | 
        
        
            | 
            | 
           334 | 
           }
  |