[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/mod/quiz/tests/generator/ -> lib.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  defined('MOODLE_INTERNAL') || die();
  18  
  19  /**
  20   * Quiz module test data generator class
  21   *
  22   * @package mod_quiz
  23   * @copyright 2012 The Open University
  24   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  25   */
  26  class mod_quiz_generator extends testing_module_generator {
  27  
  28      public function create_instance($record = null, array $options = null) {
  29          global $CFG;
  30  
  31          require_once($CFG->dirroot.'/mod/quiz/locallib.php');
  32          $record = (object)(array)$record;
  33  
  34          $defaultquizsettings = array(
  35              'timeopen'               => 0,
  36              'timeclose'              => 0,
  37              'preferredbehaviour'     => 'deferredfeedback',
  38              'attempts'               => 0,
  39              'attemptonlast'          => 0,
  40              'grademethod'            => QUIZ_GRADEHIGHEST,
  41              'decimalpoints'          => 2,
  42              'questiondecimalpoints'  => -1,
  43              'attemptduring'          => 1,
  44              'correctnessduring'      => 1,
  45              'marksduring'            => 1,
  46              'specificfeedbackduring' => 1,
  47              'generalfeedbackduring'  => 1,
  48              'rightanswerduring'      => 1,
  49              'overallfeedbackduring'  => 0,
  50              'attemptimmediately'          => 1,
  51              'correctnessimmediately'      => 1,
  52              'marksimmediately'            => 1,
  53              'specificfeedbackimmediately' => 1,
  54              'generalfeedbackimmediately'  => 1,
  55              'rightanswerimmediately'      => 1,
  56              'overallfeedbackimmediately'  => 1,
  57              'attemptopen'            => 1,
  58              'correctnessopen'        => 1,
  59              'marksopen'              => 1,
  60              'specificfeedbackopen'   => 1,
  61              'generalfeedbackopen'    => 1,
  62              'rightansweropen'        => 1,
  63              'overallfeedbackopen'    => 1,
  64              'attemptclosed'          => 1,
  65              'correctnessclosed'      => 1,
  66              'marksclosed'            => 1,
  67              'specificfeedbackclosed' => 1,
  68              'generalfeedbackclosed'  => 1,
  69              'rightanswerclosed'      => 1,
  70              'overallfeedbackclosed'  => 1,
  71              'questionsperpage'       => 1,
  72              'shuffleanswers'         => 1,
  73              'sumgrades'              => 0,
  74              'grade'                  => 100,
  75              'timecreated'            => time(),
  76              'timemodified'           => time(),
  77              'timelimit'              => 0,
  78              'overduehandling'        => 'autoabandon',
  79              'graceperiod'            => 86400,
  80              'quizpassword'           => '',
  81              'subnet'                 => '',
  82              'browsersecurity'        => '',
  83              'delay1'                 => 0,
  84              'delay2'                 => 0,
  85              'showuserpicture'        => 0,
  86              'showblocks'             => 0,
  87              'navmethod'              => QUIZ_NAVMETHOD_FREE,
  88          );
  89  
  90          foreach ($defaultquizsettings as $name => $value) {
  91              if (!isset($record->{$name})) {
  92                  $record->{$name} = $value;
  93              }
  94          }
  95  
  96          return parent::create_instance($record, (array)$options);
  97      }
  98  }


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