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


PHP workshop::allocator_instance方法代码示例

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


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

示例1: workshop_viewed

 /**
  * Triggered when the '\mod_workshop\event\course_module_viewed' event is triggered.
  *
  * This does the same job as {@link workshopallocation_scheduled_cron()} but for the
  * single workshop. The idea is that we do not need to wait for cron to execute.
  * Displaying the workshop main view.php can trigger the scheduled allocation, too.
  *
  * @param \mod_workshop\event\course_module_viewed $event
  * @return bool
  */
 public static function workshop_viewed($event)
 {
     global $DB, $CFG;
     require_once $CFG->dirroot . '/mod/workshop/locallib.php';
     $workshop = $event->get_record_snapshot('workshop', $event->objectid);
     $course = $event->get_record_snapshot('course', $event->courseid);
     $cm = $event->get_record_snapshot('course_modules', $event->contextinstanceid);
     $workshop = new \workshop($workshop, $cm, $course);
     $now = time();
     // Non-expensive check to see if the scheduled allocation can even happen.
     if ($workshop->phase == \workshop::PHASE_SUBMISSION and $workshop->submissionend > 0 and $workshop->submissionend < $now) {
         // Make sure the scheduled allocation has been configured for this workshop, that it has not
         // been executed yet and that the passed workshop record is still valid.
         $sql = "SELECT a.id\n                      FROM {workshopallocation_scheduled} a\n                      JOIN {workshop} w ON a.workshopid = w.id\n                     WHERE w.id = :workshopid\n                           AND a.enabled = 1\n                           AND w.phase = :phase\n                           AND w.submissionend > 0\n                           AND w.submissionend < :now\n                           AND (a.timeallocated IS NULL OR a.timeallocated < w.submissionend)";
         $params = array('workshopid' => $workshop->id, 'phase' => \workshop::PHASE_SUBMISSION, 'now' => $now);
         if ($DB->record_exists_sql($sql, $params)) {
             // Allocate submissions for assessments.
             $allocator = $workshop->allocator_instance('scheduled');
             $result = $allocator->execute();
             // Todo inform the teachers about the results.
         }
     }
     return true;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:34,代码来源:observer.php

示例2: array

$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->allocation_url($method));

require_login($course, false, $cm);
$context = $PAGE->context;
require_capability('mod/workshop:allocate', $context);

$PAGE->set_title($workshop->name);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add(get_string('allocation', 'workshop'));

$allocator  = $workshop->allocator_instance($method);
$initresult = $allocator->init();

//
// Output starts here
//
$output = $PAGE->get_renderer('mod_workshop');
echo $output->header();

$allocators = workshop::installed_allocators();
if (!empty($allocators)) {
    $tabs       = array();
    $row        = array();
    $inactive   = array();
    $activated  = array();
    foreach ($allocators as $methodid => $methodname) {
开发者ID:JP-Git,项目名称:moodle,代码行数:31,代码来源:allocation.php

示例3: workshopallocation_live_assessable_uploaded

function workshopallocation_live_assessable_uploaded($event)
{
    global $DB;
    $cm = get_coursemodule_from_id('workshop', $event->contextinstanceid, 0, false, MUST_EXIST);
    $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
    $instance = $DB->get_record('workshop', array('id' => $cm->instance), '*', MUST_EXIST);
    $workshop = new workshop($instance, $cm, $course);
    $record = $DB->get_record('workshopallocation_live', array('workshopid' => $workshop->id));
    if ($workshop->phase == workshop::PHASE_ASSESSMENT and $record and $record->enabled) {
        $randomallocator = $workshop->allocator_instance('random');
        $settings = workshop_random_allocator_setting::instance_from_text($record->settings);
        $result = new workshop_allocation_result($randomallocator);
        $randomallocator->execute($settings, $result);
    }
    return true;
}
开发者ID:albertgasset,项目名称:moodle-workshopallocation_live,代码行数:16,代码来源:lib.php

示例4: workshopallocation_scheduled_cron

/**
 * Regular jobs to execute via cron
 */
function workshopallocation_scheduled_cron() {
    global $CFG, $DB;

    $sql = "SELECT w.*
              FROM {workshopallocation_scheduled} a
              JOIN {workshop} w ON a.workshopid = w.id
             WHERE a.enabled = 1
                   AND w.phase = 20
                   AND w.submissionend > 0
                   AND w.submissionend < ?
                   AND (a.timeallocated IS NULL OR a.timeallocated < w.submissionend)";

    $workshops = $DB->get_records_sql($sql, array(time()));

    if (empty($workshops)) {
        mtrace('... no workshops awaiting scheduled allocation. ', '');
        return;
    }

    mtrace('... executing scheduled allocation in '.count($workshops).' workshop(s) ... ', '');

    // let's have some fun!
    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);
        $allocator = $workshop->allocator_instance('scheduled');
        $result = $allocator->execute();

        // todo inform the teachers about the results
    }
}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:37,代码来源:lib.php


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