Files
moodle/mod/feedback/tests/generator/lib.php
T

88 lines
2.8 KiB
PHP

<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* mod_feedback data generator.
*
* @package mod_feedback
* @category test
* @copyright 2013 Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
/**
* mod_feedback data generator class.
*
* @package mod_feedback
* @category test
* @copyright 2013 Ankit Agarwal
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_feedback_generator extends testing_module_generator {
public function create_instance($record = null, array $options = null) {
global $CFG;
require_once($CFG->dirroot.'/mod/feedback/lib.php');
$record = (object)(array)$record;
if (!isset($record->anonymous)) {
$record->anonymous = FEEDBACK_ANONYMOUS_YES;
}
if (!isset($record->email_notification)) {
$record->email_notification = 0;
}
if (!isset($record->multiple_submit)) {
$record->multiple_submit = 0;
}
if (!isset($record->autonumbering)) {
$record->autonumbering = 0;
}
if (!isset($record->site_after_submit)) {
$record->site_after_submit = '';
}
if (!isset($record->page_after_submit)) {
$record->page_after_submit = 'This is page after submit';
}
if (!isset($record->page_after_submitformat)) {
$record->page_after_submitformat = FORMAT_MOODLE;
}
if (!isset($record->publish_stats)) {
$record->publish_stats = 0;
}
if (!isset($record->timeopen)) {
$record->timeopen = 0;
}
if (!isset($record->timeclose)) {
$record->timeclose = 0;
}
if (!isset($record->timemodified)) {
$record->timemodified = time();
}
if (!isset($record->completionsubmit)) {
$record->completionsubmit = 0;
}
// Hack to bypass draft processing of feedback_add_instance.
$record->page_after_submit_editor['itemid'] = false;
return parent::create_instance($record, (array)$options);
}
}