[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/question/type/ddwtos/tests/ -> helper.php (source)

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Test helpers for the drag-and-drop words into sentences question type.
  19   *
  20   * @package   qtype_ddwtos
  21   * @copyright 2010 The Open University
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  
  26  defined('MOODLE_INTERNAL') || die();
  27  
  28  
  29  /**
  30   * Test helper class for the drag-and-drop words into sentences question type.
  31   *
  32   * @copyright  2010 The Open University
  33   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  34   */
  35  class qtype_ddwtos_test_helper extends question_test_helper {
  36      public function get_test_questions() {
  37          return array('fox', 'maths');
  38      }
  39  
  40      /**
  41       * @return qtype_ddwtos_question
  42       */
  43      public function make_ddwtos_question_fox() {
  44          question_bank::load_question_definition_classes('ddwtos');
  45          $dd = new qtype_ddwtos_question();
  46  
  47          test_question_maker::initialise_a_question($dd);
  48  
  49          $dd->name = 'Drag-and-drop words into sentences question';
  50          $dd->questiontext = 'The [[1]] brown [[2]] jumped over the [[3]] dog.';
  51          $dd->generalfeedback = 'This sentence uses each letter of the alphabet.';
  52          $dd->qtype = question_bank::get_qtype('ddwtos');
  53  
  54          $dd->shufflechoices = true;
  55  
  56          test_question_maker::set_standard_combined_feedback_fields($dd);
  57  
  58          $dd->choices = array(
  59              1 => array(
  60                  1 => new qtype_ddwtos_choice('quick', 1),
  61                  2 => new qtype_ddwtos_choice('slow', 1)),
  62              2 => array(
  63                  1 => new qtype_ddwtos_choice('fox', 2),
  64                  2 => new qtype_ddwtos_choice('dog', 2)),
  65              3 => array(
  66                  1 => new qtype_ddwtos_choice('lazy', 3),
  67                  2 => new qtype_ddwtos_choice('assiduous', 3)),
  68          );
  69  
  70          $dd->places = array(1 => 1, 2 => 2, 3 => 3);
  71          $dd->rightchoices = array(1 => 1, 2 => 1, 3 => 1);
  72          $dd->textfragments = array('The ', ' brown ', ' jumped over the ', ' dog.');
  73  
  74          return $dd;
  75      }
  76  
  77      /**
  78       * @return stdClass date to create a ddwtos question.
  79       */
  80      public function get_ddwtos_question_form_data_fox() {
  81          $fromform = new stdClass();
  82  
  83          $fromform->name = 'Drag-and-drop words into sentences question';
  84          $fromform->questiontext = array('text' => 'The [[1]] brown [[2]] jumped over the [[3]] dog.', 'format' => FORMAT_HTML);
  85          $fromform->defaultmark = 1.0;
  86          $fromform->generalfeedback = array('text' => 'This sentence uses each letter of the alphabet.', 'format' => FORMAT_HTML);
  87          $fromform->choices = array(
  88              array('answer' => 'quick',     'choicegroup' => '1'),
  89              array('answer' => 'fox',       'choicegroup' => '2'),
  90              array('answer' => 'lazy',      'choicegroup' => '3'),
  91              array('answer' => 'slow',      'choicegroup' => '1'),
  92              array('answer' => 'dog',       'choicegroup' => '2'),
  93              array('answer' => 'assiduous', 'choicegroup' => '3'),
  94          );
  95          test_question_maker::set_standard_combined_feedback_form_data($fromform);
  96          $fromform->shownumcorrect = 0;
  97          $fromform->penalty = 0.3333333;
  98  
  99          return $fromform;
 100      }
 101  
 102      /**
 103       * @return qtype_ddwtos_question
 104       */
 105      public function make_ddwtos_question_maths() {
 106          question_bank::load_question_definition_classes('ddwtos');
 107          $dd = new qtype_ddwtos_question();
 108  
 109          test_question_maker::initialise_a_question($dd);
 110  
 111          $dd->name = 'Drag-and-drop words into sentences question';
 112          $dd->questiontext = 'Fill in the operators to make this equation work: ' .
 113                  '7 [[1]] 11 [[2]] 13 [[1]] 17 [[2]] 19 = 3';
 114          $dd->generalfeedback = 'This sentence uses each letter of the alphabet.';
 115          $dd->qtype = question_bank::get_qtype('ddwtos');
 116  
 117          $dd->shufflechoices = true;
 118  
 119          test_question_maker::set_standard_combined_feedback_fields($dd);
 120  
 121          $dd->choices = array(
 122              1 => array(
 123                  1 => new qtype_ddwtos_choice('+', 1, true),
 124                  2 => new qtype_ddwtos_choice('-', 1, true),
 125                  3 => new qtype_ddwtos_choice('*', 1, true),
 126                  4 => new qtype_ddwtos_choice('/', 1, true),
 127              ));
 128  
 129          $dd->places = array(1 => 1, 2 => 1, 3 => 1, 4 => 1);
 130          $dd->rightchoices = array(1 => 1, 2 => 2, 3 => 1, 4 => 2);
 131          $dd->textfragments = array('7 ', ' 11 ', ' 13 ', ' 17 ', ' 19 = 3');
 132  
 133          return $dd;
 134      }
 135  }


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