当前位置: 首页>>代码示例>>PHP>>正文


PHP phpunit_util::get_data_generator方法代码示例

本文整理汇总了PHP中phpunit_util::get_data_generator方法的典型用法代码示例。如果您正苦于以下问题:PHP phpunit_util::get_data_generator方法的具体用法?PHP phpunit_util::get_data_generator怎么用?PHP phpunit_util::get_data_generator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在phpunit_util的用法示例。


在下文中一共展示了phpunit_util::get_data_generator方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getDataGenerator

 /**
  * Get data generator
  * @static
  * @return testing_data_generator
  */
 public static function getDataGenerator() {
     return phpunit_util::get_data_generator();
 }
开发者ID:rwijaya,项目名称:moodle,代码行数:8,代码来源:advanced_testcase.php

示例2: make

 /**
  * Runs the entire 'make' process.
  *
  * @return int Course id
  */
 public function make()
 {
     global $DB, $CFG;
     require_once $CFG->dirroot . '/lib/phpunit/classes/util.php';
     raise_memory_limit(MEMORY_EXTRA);
     if ($this->progress && !CLI_SCRIPT) {
         echo html_writer::start_tag('ul');
     }
     $entirestart = microtime(true);
     // Start transaction.
     $transaction = $DB->start_delegated_transaction();
     // Get generator.
     $this->generator = phpunit_util::get_data_generator();
     // Make course.
     $this->course = $this->create_course();
     $this->create_users();
     $this->create_pages();
     $this->create_small_files();
     $this->create_big_files();
     $this->create_forum();
     // Log total time.
     $this->log('coursecompleted', round(microtime(true) - $entirestart, 1));
     if ($this->progress && !CLI_SCRIPT) {
         echo html_writer::end_tag('ul');
     }
     // Commit transaction and finish.
     $transaction->allow_commit();
     return $this->course->id;
 }
开发者ID:verbazend,项目名称:AWFA,代码行数:34,代码来源:course_backend.php

示例3: create_marker_module

 private function create_marker_module($markerid)
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/lib/phpunit/classes/util.php';
     // Start transaction.
     $transaction = $DB->start_delegated_transaction();
     try {
         // Get generator.
         $generator = phpunit_util::get_data_generator();
         /**@var mod_emarking_generator $emarking_generator*/
         $emarking_generator = $generator->get_plugin_generator('mod_emarking');
         $blueprint = $DB->get_record('emarking', array("id" => $this->cm->instance));
         $blueprint->timecreated = time();
         $originalname = $blueprint->name;
         $markers = get_users_by_capability($this->context, 'mod/emarking:grade', 'u.id,u.username');
         $marker = $markers[$markerid];
         if (!$marker) {
             throw new Exception("Marker not found");
         }
         $previous = $DB->get_record('emarking_markers', array('masteractivity' => $this->parentcm->instance, 'markerid' => $markerid));
         if ($previous) {
             throw new Exception("Delete previous marker record before assigning a new one");
         }
         $submissions = $DB->get_records('emarking_submission', array("emarking" => $this->cm->instance));
         $pages = array();
         foreach ($submissions as $sub) {
             $pages[$sub->id] = $DB->get_records('emarking_page', array("submission" => $sub->id));
         }
         unset($blueprint->id);
         $blueprint->name = $originalname . " -- " . $marker->username;
         $inserted = $emarking_generator->create_instance($blueprint, array("visible" => 0));
         $markermap = new stdClass();
         $markermap->masteractivity = $this->parentcm->instance;
         $markermap->markerid = $marker->id;
         $markermap->activityid = $inserted->id;
         $DB->insert_record('emarking_markers', $markermap);
         // se agrega el grading method correcto.
         require_once $CFG->dirroot . '/grade/grading/lib.php';
         $gradingman = get_grading_manager(context_module::instance($inserted->cmid), 'mod_emarking');
         $gradingman->set_area("attempt");
         $gradingman->set_active_method("rubric");
         emarking_grade_item_update($inserted);
         //Now replicate submissions
         foreach ($submissions as $sub) {
             $insertable = clone $sub;
             unset($insertable->id);
             $insertable->emarking = $inserted->id;
             $id = $DB->insert_record('emarking_submission', $insertable);
             foreach ($pages[$sub->id] as $subpage) {
                 $insertablepage = clone $subpage;
                 unset($insertablepage->id);
                 $insertablepage->submission = $id;
                 $DB->insert_record('emarking_page', $insertablepage);
             }
             // Update the raw grade of the user
             $grade_item = grade_item::fetch(array('itemtype' => 'mod', 'itemmodule' => 'emarking', 'iteminstance' => $inserted->id));
             $grade = $grade_item->get_grade($insertable->student, true);
             $grade_item->update_final_grade($insertable->student, null, 'upload', '', FORMAT_HTML, $marker->id);
             // grade
         }
         $transaction->allow_commit();
     } catch (Exception $e) {
         $transaction->rollback($e);
     }
 }
开发者ID:jorgecabane93,项目名称:eMarkingWeb,代码行数:65,代码来源:crowdlib.php

示例4: define

 * @copyright  2015 Skylar Kelty <S.Kelty@kent.ac.uk>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
define('CLI_SCRIPT', true);
require __DIR__ . '/../../../../config.php';
require_once $CFG->libdir . '/clilib.php';
require_once $CFG->libdir . '/coursecatlib.php';
require_once $CFG->dirroot . '/lib/phpunit/classes/util.php';
cli_writeln('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
cli_writeln('Welcome to the school generator!');
cli_writeln('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
cli_writeln('');
$category = $DB->get_record('course_categories', array('name' => 'School of Witchcraft and Wizardry'));
if (!$category) {
    cli_writeln('Creating category...');
    $category = \coursecat::create(array('name' => 'School of Witchcraft and Wizardry', 'description' => 'A school like no other!', 'descriptionformat' => 1, 'parent' => 0, 'sortorder' => 520000, 'coursecount' => 0, 'visible' => 1, 'visibleold' => 1, 'timemodified' => 0, 'depth' => 1, 'path' => '/2', 'theme' => ''));
} else {
    cli_writeln('Using existing category.');
}
$courses = array('Astronomy', 'Charms', 'Dark Arts', 'Defence Against the Dark Arts', 'Flying', 'Herbology', 'History of Magic', 'Muggle Studies', 'Potions', 'Transfiguration', 'Alchemy', 'Apparition', 'Arithmancy', 'Care of Magical Creatures', 'Divination', 'Study of Ancient Runes', 'Extra-curricular subjects', 'Ancient Studies', 'Art', 'Frog Choir', 'Ghoul Studies', 'Magical Theory', 'Muggle Art', 'Music', 'Muggle Music', 'Orchestra', 'Xylomancy');
cli_writeln('Creating courses...');
$generator = \phpunit_util::get_data_generator();
$id = 1000;
foreach ($courses as $course) {
    if ($DB->record_exists('course', array('fullname' => $course))) {
        continue;
    }
    $courserecord = array('shortname' => "WZ{$id}", 'fullname' => $course, 'numsections' => 10, 'startdate' => usergetmidnight(time()), 'category' => $category->id);
    $generator->create_course($courserecord, array('createsections' => true));
    $id += 100;
}
开发者ID:unikent,项目名称:moodle-tool_kent,代码行数:31,代码来源:testgen.php

示例5: create_framework

 /**
  * Create a new framework.
  *
  * @param array|stdClass $record
  * @return competency_framework
  */
 public function create_framework($record = null)
 {
     $generator = phpunit_util::get_data_generator();
     $this->frameworkcount++;
     $i = $this->frameworkcount;
     $record = (object) $record;
     if (!isset($record->shortname)) {
         $record->shortname = "Framework shortname {$i}";
     }
     if (!isset($record->idnumber)) {
         $record->idnumber = "frm{$i}";
     }
     if (!isset($record->description)) {
         $record->description = "Framework {$i} description ";
     }
     if (!isset($record->descriptionformat)) {
         $record->descriptionformat = FORMAT_HTML;
     }
     if (!isset($record->visible)) {
         $record->visible = 1;
     }
     if (!isset($record->scaleid)) {
         if (isset($record->scaleconfiguration)) {
             throw new coding_exception('Scale configuration must be provided with a scale.');
         }
         if (!$this->scale) {
             $this->scale = $generator->create_scale(array('scale' => 'A,B,C,D'));
         }
         $record->scaleid = $this->scale->id;
     }
     if (!isset($record->scaleconfiguration)) {
         $scale = grade_scale::fetch(array('id' => $record->scaleid));
         $values = $scale->load_items();
         foreach ($values as $key => $value) {
             // Add a key (make the first value 1).
             $values[$key] = array('id' => $key + 1, 'name' => $value);
         }
         if (count($values) < 2) {
             throw new coding_exception('Please provide the scale configuration for one-item scales.');
         }
         $scaleconfig = array();
         // Last item is proficient.
         $item = array_pop($values);
         array_unshift($scaleconfig, array('id' => $item['id'], 'proficient' => 1));
         // Second-last item is default and proficient.
         $item = array_pop($values);
         array_unshift($scaleconfig, array('id' => $item['id'], 'scaledefault' => 1, 'proficient' => 1));
         array_unshift($scaleconfig, array('scaleid' => $record->scaleid));
         $record->scaleconfiguration = json_encode($scaleconfig);
     }
     if (is_array($record->scaleconfiguration) || is_object($record->scaleconfiguration)) {
         // Conveniently encode the config.
         $record->scaleconfiguration = json_encode($record->scaleconfiguration);
     }
     if (!isset($record->contextid)) {
         $record->contextid = context_system::instance()->id;
     }
     $framework = new competency_framework(0, $record);
     $framework->create();
     return $framework;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:67,代码来源:lib.php

示例6: make

 /**
  * Runs the entire 'make' process.
  *
  * @return int Course id
  */
 public function make()
 {
     global $DB, $CFG;
     require_once $CFG->dirroot . '/lib/phpunit/classes/util.php';
     raise_memory_limit(MEMORY_EXTRA);
     if ($this->progress && !CLI_SCRIPT) {
         echo html_writer::start_tag('ul');
     }
     $entirestart = microtime(true);
     // Get generator.
     $this->generator = phpunit_util::get_data_generator();
     // Make course.
     $this->course = $this->create_course();
     $this->create_assignments();
     $this->create_pages();
     $this->create_small_files();
     $this->create_big_files();
     // Create users as late as possible to reduce regarding in the gradebook.
     $this->create_users();
     $this->create_forum();
     // Log total time.
     $this->log('coursecompleted', round(microtime(true) - $entirestart, 1));
     if ($this->progress && !CLI_SCRIPT) {
         echo html_writer::end_tag('ul');
     }
     return $this->course->id;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:32,代码来源:course_backend.php


注:本文中的phpunit_util::get_data_generator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。