當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。