[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/mod/feedback/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  /**
  18   * mod_feedback data generator.
  19   *
  20   * @package    mod_feedback
  21   * @category   test
  22   * @copyright  2013 Ankit Agarwal
  23   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  24   */
  25  
  26  defined('MOODLE_INTERNAL') || die();
  27  
  28  /**
  29   * mod_feedback data generator class.
  30   *
  31   * @package    mod_feedback
  32   * @category   test
  33   * @copyright  2013 Ankit Agarwal
  34   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  35   */
  36  class mod_feedback_generator extends testing_module_generator {
  37  
  38      public function create_instance($record = null, array $options = null) {
  39          global $CFG;
  40          require_once($CFG->dirroot.'/mod/feedback/lib.php');
  41          $record = (object)(array)$record;
  42  
  43          if (!isset($record->anonymous)) {
  44              $record->anonymous = FEEDBACK_ANONYMOUS_YES;
  45          }
  46          if (!isset($record->email_notification)) {
  47              $record->email_notification = 0;
  48          }
  49          if (!isset($record->multiple_submit)) {
  50              $record->multiple_submit = 0;
  51          }
  52          if (!isset($record->autonumbering)) {
  53              $record->autonumbering = 0;
  54          }
  55          if (!isset($record->site_after_submit)) {
  56              $record->site_after_submit = '';
  57          }
  58          if (!isset($record->page_after_submit)) {
  59              $record->page_after_submit = 'This is page after submit';
  60          }
  61          if (!isset($record->page_after_submitformat)) {
  62              $record->page_after_submitformat = FORMAT_MOODLE;
  63          }
  64          if (!isset($record->publish_stats)) {
  65              $record->publish_stats = 0;
  66          }
  67          if (!isset($record->timeopen)) {
  68              $record->timeopen = 0;
  69          }
  70          if (!isset($record->timeclose)) {
  71              $record->timeclose = 0;
  72          }
  73          if (!isset($record->timemodified)) {
  74              $record->timemodified = time();
  75          }
  76          if (!isset($record->completionsubmit)) {
  77              $record->completionsubmit = 0;
  78          }
  79  
  80          // Hack to bypass draft processing of feedback_add_instance.
  81          $record->page_after_submit_editor['itemid'] = false;
  82  
  83          return parent::create_instance($record, (array)$options);
  84      }
  85  
  86  }
  87  


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