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


PHP workshop::switch_phase方法代码示例

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


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

示例1: test_reset_phase

 /**
  * Test the workshop reset feature.
  */
 public function test_reset_phase()
 {
     $this->resetAfterTest(true);
     $this->workshop->switch_phase(workshop::PHASE_CLOSED);
     $this->assertEquals(workshop::PHASE_CLOSED, $this->workshop->phase);
     $settings = (object) array('reset_workshop_phase' => 0);
     $status = $this->workshop->reset_userdata($settings);
     $this->assertEquals(workshop::PHASE_CLOSED, $this->workshop->phase);
     $settings = (object) array('reset_workshop_phase' => 1);
     $status = $this->workshop->reset_userdata($settings);
     $this->assertEquals(workshop::PHASE_SETUP, $this->workshop->phase);
     foreach ($status as $result) {
         $this->assertFalse($result['error']);
     }
 }
开发者ID:dg711,项目名称:moodle,代码行数:18,代码来源:locallib_test.php

示例2: array

// Mark viewed
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
$eventdata = array();
$eventdata['objectid'] = $workshop->id;
$eventdata['context'] = $workshop->context;
$PAGE->set_url($workshop->view_url());
$event = \mod_workshop\event\course_module_viewed::create($eventdata);
$event->add_record_snapshot('course', $course);
$event->add_record_snapshot('workshop', $workshoprecord);
$event->add_record_snapshot('course_modules', $cm);
$event->trigger();
// If the phase is to be switched, do it asap. This just has to happen after triggering
// the event so that the scheduled allocator had a chance to allocate submissions.
if ($workshop->phase == workshop::PHASE_SUBMISSION and $workshop->phaseswitchassessment and $workshop->submissionend > 0 and $workshop->submissionend < time()) {
    $workshop->switch_phase(workshop::PHASE_ASSESSMENT);
    // Disable the automatic switching now so that it is not executed again by accident
    // if the teacher changes the phase back to the submission one.
    $DB->set_field('workshop', 'phaseswitchassessment', 0, array('id' => $workshop->id));
    $workshop->phaseswitchassessment = 0;
}
if (!is_null($editmode) && $PAGE->user_allowed_editing()) {
    $USER->editing = $editmode;
}
$PAGE->set_title($workshop->name);
$PAGE->set_heading($course->fullname);
if ($perpage and $perpage > 0 and $perpage <= 1000) {
    require_sesskey();
    set_user_preference('workshop_perpage', $perpage);
    redirect($PAGE->url);
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:31,代码来源:view.php

示例3: workshop_cron

/**
 * Regular jobs to execute via cron
 *
 * @return boolean true on success, false otherwise
 */
function workshop_cron() {
    global $CFG, $DB;

    $now = time();

    mtrace(' processing workshop subplugins ...');
    cron_execute_plugin_type('workshopallocation', 'workshop allocation methods');

    // now when the scheduled allocator had a chance to do its job, check if there
    // are some workshops to switch into the assessment phase
    $workshops = $DB->get_records_select("workshop",
        "phase = 20 AND phaseswitchassessment = 1 AND submissionend > 0 AND submissionend < ?", array($now));

    if (!empty($workshops)) {
        mtrace('Processing automatic assessment phase switch in '.count($workshops).' workshop(s) ... ', '');
        require_once($CFG->dirroot.'/mod/workshop/locallib.php');
        foreach ($workshops as $workshop) {
            $cm = get_coursemodule_from_instance('workshop', $workshop->id, $workshop->course, false, MUST_EXIST);
            $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
            $workshop = new workshop($workshop, $cm, $course);
            $workshop->switch_phase(workshop::PHASE_ASSESSMENT);
            $workshop->log('update switch phase', $workshop->view_url(), $workshop->phase);
            // disable the automatic switching now so that it is not executed again by accident
            // if the teacher changes the phase back to the submission one
            $DB->set_field('workshop', 'phaseswitchassessment', 0, array('id' => $workshop->id));

            // todo inform the teachers
        }
        mtrace('done');
    }

    return true;
}
开发者ID:ncsu-delta,项目名称:moodle,代码行数:38,代码来源:lib.php

示例4: array

// course module
$phase = required_param('phase', PARAM_INT);
// the code of the new phase
$confirm = optional_param('confirm', false, PARAM_BOOL);
// confirmation
$cm = get_coursemodule_from_id('workshop', $cmid, 0, false, MUST_EXIST);
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
$workshop = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST);
$workshop = new workshop($workshop, $cm, $course);
$PAGE->set_url($workshop->switchphase_url($phase), array('cmid' => $cmid, 'phase' => $phase));
require_login($course, false, $cm);
require_capability('mod/workshop:switchphase', $PAGE->context);
if ($confirm) {
    if (!confirm_sesskey()) {
        throw new moodle_exception('confirmsesskeybad');
    }
    if (!$workshop->switch_phase($phase)) {
        print_error('errorswitchingphase', 'workshop', $workshop->view_url());
    }
    redirect($workshop->view_url());
}
$PAGE->set_title($workshop->name);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add(get_string('switchingphase', 'workshop'));
//
// Output starts here
//
echo $OUTPUT->header();
echo $OUTPUT->heading(format_string($workshop->name));
echo $OUTPUT->confirm(get_string('switchphase' . $phase . 'info', 'workshop'), new moodle_url($PAGE->url, array('confirm' => 1)), $workshop->view_url());
echo $OUTPUT->footer();
开发者ID:alanaipe2015,项目名称:moodle,代码行数:31,代码来源:switchphase.php


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