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


PHP workshop::reset_userdata方法代码示例

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


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

示例1: test_reset_userdata_submissions

 /**
  * Test deleting submissions related data on workshop reset.
  */
 public function test_reset_userdata_submissions()
 {
     global $DB;
     $this->resetAfterTest(true);
     $student1 = $this->getDataGenerator()->create_user();
     $student2 = $this->getDataGenerator()->create_user();
     $this->getDataGenerator()->enrol_user($student1->id, $this->workshop->course->id);
     $this->getDataGenerator()->enrol_user($student2->id, $this->workshop->course->id);
     $workshopgenerator = $this->getDataGenerator()->get_plugin_generator('mod_workshop');
     $subid1 = $workshopgenerator->create_submission($this->workshop->id, $student1->id);
     $subid2 = $workshopgenerator->create_submission($this->workshop->id, $student2->id);
     $asid1 = $workshopgenerator->create_assessment($subid1, $student2->id);
     $asid2 = $workshopgenerator->create_assessment($subid2, $student1->id);
     $settings = (object) array('reset_workshop_submissions' => 1);
     $status = $this->workshop->reset_userdata($settings);
     foreach ($status as $result) {
         $this->assertFalse($result['error']);
     }
     $this->assertEquals(0, $DB->count_records('workshop_submissions', array('workshopid' => $this->workshop->id)));
     $this->assertEquals(0, $DB->count_records('workshop_assessments'));
 }
开发者ID:dg711,项目名称:moodle,代码行数:24,代码来源:locallib_test.php

示例2: workshop_reset_userdata

/**
 * Performs the reset of all workshop instances in the course.
 *
 * @param stdClass $data The actual course reset settings.
 * @return array List of results, each being array[(string)component, (string)item, (string)error]
 */
function workshop_reset_userdata(stdClass $data) {
    global $CFG, $DB;

    if (empty($data->reset_workshop_submissions)
            and empty($data->reset_workshop_assessments)
            and empty($data->reset_workshop_phase) ) {
        // Nothing to do here.
        return array();
    }

    $workshoprecords = $DB->get_records('workshop', array('course' => $data->courseid));

    if (empty($workshoprecords)) {
        // What a boring course - no workshops here!
        return array();
    }

    require_once($CFG->dirroot . '/mod/workshop/locallib.php');

    $course = $DB->get_record('course', array('id' => $data->courseid), '*', MUST_EXIST);
    $status = array();

    foreach ($workshoprecords as $workshoprecord) {
        $cm = get_coursemodule_from_instance('workshop', $workshoprecord->id, $course->id, false, MUST_EXIST);
        $workshop = new workshop($workshoprecord, $cm, $course);
        $status = array_merge($status, $workshop->reset_userdata($data));
    }

    return $status;
}
开发者ID:rohitshriwas,项目名称:moodle,代码行数:36,代码来源:lib.php


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