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


PHP completion_info::get_criteria方法代码示例

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


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

示例1: array

$group = groups_get_course_group($course, true);
// Supposed to verify group
if ($group === 0 && $course->groupmode == SEPARATEGROUPS) {
    require_capability('moodle/site:accessallgroups', $context);
}
/**
 * Load data
 */
// Get criteria for course
$completion = new completion_info($course);
if (!$completion->has_criteria()) {
    print_error('err_nocriteria', 'completion', $CFG->wwwroot . '/course/report.php?id=' . $course->id);
}
// Get criteria and put in correct order
$criteria = array();
foreach ($completion->get_criteria(COMPLETION_CRITERIA_TYPE_COURSE) as $criterion) {
    $criteria[] = $criterion;
}
foreach ($completion->get_criteria(COMPLETION_CRITERIA_TYPE_ACTIVITY) as $criterion) {
    $criteria[] = $criterion;
}
foreach ($completion->get_criteria() as $criterion) {
    if (!in_array($criterion->criteriatype, array(COMPLETION_CRITERIA_TYPE_COURSE, COMPLETION_CRITERIA_TYPE_ACTIVITY))) {
        $criteria[] = $criterion;
    }
}
// Can logged in user mark users as complete?
// (if the logged in user has a role defined in the role criteria)
$allow_marking = false;
$allow_marking_criteria = null;
if (!$csv) {
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:31,代码来源:index.php

示例2: block_intuitel_get_completion_status_course

/**
 *  Retrieves the completion status of the course for an specific user (100 if this is completed and 0 if not), returns NULL if completion tracking is not enabled for the course and criteria for completing the course has not been set
 * @author elever
 *
 * @param int $lo_id : id of the course
 * @param int $native_user_id : moodle identifier of the user
 * @return int $completion_status| NULL
 */
function block_intuitel_get_completion_status_course($lo_id, $native_user_id)
{
    $course = get_course($lo_id);
    $completion = new \completion_info($course);
    global $DB;
    if ($completion->is_enabled() > 0) {
        $criteria = $completion->get_criteria();
        if (!empty($criteria)) {
            //if criteria has been stablished for completing the course (in another case there is no course completion tracking)
            //when a user completes a course this is registered in table course_completions
            $timecompleted = $DB->get_field('course_completions', 'timecompleted', array('userid' => $native_user_id, 'course' => $lo_id));
            if ($timecompleted == false) {
                $completion_status = 0;
            } else {
                $completion_status = 100;
            }
            // a record exists then the course has been completed
        } else {
            $completion_status = null;
        }
    } else {
        $completion_status = null;
        // completion is not enabled for the course
    }
    return $completion_status;
}
开发者ID:juacas,项目名称:moodle-block_intuitel,代码行数:34,代码来源:locallib.php

示例3: get_completion

 public static function get_completion($userid, $courseid)
 {
     global $DB;
     // Going to build an array for the data.
     $data = array();
     // Count the three statii for the graph.
     $notstarted = 0;
     $inprogress = 0;
     $completed = 0;
     // Get completion data for course.
     // Get course object.
     if (!($course = $DB->get_record('course', array('id' => $courseid)))) {
         error('unable to find course record');
     }
     $datum = new stdclass();
     $datum->coursename = $course->fullname;
     // Instantiate completion info thingy.
     $info = new completion_info($course);
     // Get gradebook details.
     $gbsql = "select gg.finalgrade as result from {grade_grades} gg, {grade_items} gi\n                  WHERE gi.courseid={$courseid} AND gi.itemtype='course' AND gg.userid={$userid}\n                  AND gi.id=gg.itemid";
     if (!($gradeinfo = $DB->get_record_sql($gbsql))) {
         $gradeinfo = new object();
         $gradeinfo->result = null;
     }
     // If completion is not enabled on the course
     // there's no point carrying on.
     if (!$info->is_enabled()) {
         $datum->enabled = false;
         $data[$courseid] = $datum;
         return false;
     } else {
         $datum->enabled = true;
     }
     // Get criteria for coursed.
     // This is an array of tracked activities (only tracked ones).
     $criteria = $info->get_criteria();
     // Number of tracked activities to complete.
     $trackedcount = count($criteria);
     $datum->trackedcount = $trackedcount;
     // Get data for all users in course.
     // This is an array of users in the course. It contains a 'progress'
     // array showing completed *tracked* activities.
     $progress = $info->get_progress_all();
     $u = new stdclass();
     // Iterate over users to get info.
     if (isset($progress[$userid])) {
         $user = $progress[$userid];
         // Find user's completion info for this course.
         if ($completioninfo = $DB->get_record('course_completions', array('userid' => $user->id, 'course' => $courseid))) {
             $u->timeenrolled = $completioninfo->timeenrolled;
             if (!empty($completioninfo->timestarted)) {
                 $u->timestarted = $completioninfo->timestarted;
                 if (!empty($completioninfo->timecompleted)) {
                     $u->timecompleted = $completioninfo->timecompleted;
                     $u->status = 'completed';
                     ++$completed;
                 } else {
                     $u->timecompleted = 0;
                     $u->status = 'inprogress';
                     ++$inprogress;
                 }
             } else {
                 $u->timestarted = 0;
                 $u->status = 'notstarted';
                 ++$notstarted;
             }
         } else {
             $u->timeenrolled = 0;
             $u->timecompleted = 0;
             $u->timestarted = 0;
             $u->status = 'notstarted';
             ++$notstarted;
         }
     } else {
         $u->completed_count = 0;
         $u->completed_percent = '--';
         $u->completed_progress = 'notstarted';
     }
     $u->result = round($gradeinfo->result, 0);
     $datum->completion = $u;
     $data[$courseid] = $datum;
     // Make return object.
     $returnobj = new stdclass();
     $returnobj->data = $data;
     $returnobj->criteria = $criteria;
     return $returnobj;
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:87,代码来源:lib.php

示例4: definition

 /**
  * Defines the form fields.
  */
 public function definition()
 {
     global $USER, $CFG, $DB;
     $courseconfig = get_config('moodlecourse');
     $mform = $this->_form;
     $course = $this->_customdata['course'];
     $completion = new completion_info($course);
     $params = array('course' => $course->id);
     // Check if there are existing criteria completions.
     if ($completion->is_course_locked()) {
         $mform->addElement('header', 'completionsettingslocked', get_string('completionsettingslocked', 'completion'));
         $mform->addElement('static', '', '', get_string('err_settingslocked', 'completion'));
         $mform->addElement('submit', 'settingsunlock', get_string('unlockcompletiondelete', 'completion'));
     }
     // Get array of all available aggregation methods.
     $aggregation_methods = $completion->get_aggregation_methods();
     // Overall criteria aggregation.
     $mform->addElement('header', 'overallcriteria', get_string('general', 'core_form'));
     // Map aggregation methods to context-sensitive human readable dropdown menu.
     $overallaggregationmenu = array();
     foreach ($aggregation_methods as $methodcode => $methodname) {
         if ($methodcode === COMPLETION_AGGREGATION_ALL) {
             $overallaggregationmenu[COMPLETION_AGGREGATION_ALL] = get_string('overallaggregation_all', 'core_completion');
         } else {
             if ($methodcode === COMPLETION_AGGREGATION_ANY) {
                 $overallaggregationmenu[COMPLETION_AGGREGATION_ANY] = get_string('overallaggregation_any', 'core_completion');
             } else {
                 $overallaggregationmenu[$methodcode] = $methodname;
             }
         }
     }
     $mform->addElement('select', 'overall_aggregation', get_string('overallaggregation', 'core_completion'), $overallaggregationmenu);
     $mform->setDefault('overall_aggregation', $completion->get_aggregation_method());
     // Activity completion criteria
     $label = get_string('coursecompletioncondition', 'core_completion', get_string('activitiescompleted', 'core_completion'));
     $mform->addElement('header', 'activitiescompleted', $label);
     // Get the list of currently specified conditions and expand the section if some are found.
     $current = $completion->get_criteria(COMPLETION_CRITERIA_TYPE_ACTIVITY);
     if (!empty($current)) {
         $mform->setExpanded('activitiescompleted');
     }
     $activities = $completion->get_activities();
     if (!empty($activities)) {
         if (!$completion->is_course_locked()) {
             $this->add_checkbox_controller(1, null, null, 0);
         }
         foreach ($activities as $activity) {
             $params_a = array('moduleinstance' => $activity->id);
             $criteria = new completion_criteria_activity(array_merge($params, $params_a));
             $criteria->config_form_display($mform, $activity);
         }
         $mform->addElement('static', 'criteria_role_note', '', get_string('activitiescompletednote', 'core_completion'));
         if (count($activities) > 1) {
             // Map aggregation methods to context-sensitive human readable dropdown menu.
             $activityaggregationmenu = array();
             foreach ($aggregation_methods as $methodcode => $methodname) {
                 if ($methodcode === COMPLETION_AGGREGATION_ALL) {
                     $activityaggregationmenu[COMPLETION_AGGREGATION_ALL] = get_string('activityaggregation_all', 'core_completion');
                 } else {
                     if ($methodcode === COMPLETION_AGGREGATION_ANY) {
                         $activityaggregationmenu[COMPLETION_AGGREGATION_ANY] = get_string('activityaggregation_any', 'core_completion');
                     } else {
                         $activityaggregationmenu[$methodcode] = $methodname;
                     }
                 }
             }
             $mform->addElement('select', 'activity_aggregation', get_string('activityaggregation', 'core_completion'), $activityaggregationmenu);
             $mform->setDefault('activity_aggregation', $completion->get_aggregation_method(COMPLETION_CRITERIA_TYPE_ACTIVITY));
         }
     } else {
         $mform->addElement('static', 'noactivities', '', get_string('err_noactivities', 'completion'));
     }
     // Course prerequisite completion criteria.
     $label = get_string('coursecompletioncondition', 'core_completion', get_string('dependenciescompleted', 'core_completion'));
     $mform->addElement('header', 'courseprerequisites', $label);
     // Get the list of currently specified conditions and expand the section if some are found.
     $current = $completion->get_criteria(COMPLETION_CRITERIA_TYPE_COURSE);
     if (!empty($current)) {
         $mform->setExpanded('courseprerequisites');
     }
     // Get applicable courses (prerequisites).
     $courses = $DB->get_records_sql("\n                SELECT DISTINCT c.id, c.category, c.fullname, cc.id AS selected\n                  FROM {course} c\n             LEFT JOIN {course_completion_criteria} cc ON cc.courseinstance = c.id AND cc.course = {$course->id}\n            INNER JOIN {course_completion_criteria} ccc ON ccc.course = c.id\n                 WHERE c.enablecompletion = " . COMPLETION_ENABLED . "\n                       AND c.id <> {$course->id}");
     if (!empty($courses)) {
         // Get category list.
         require_once $CFG->libdir . '/coursecatlib.php';
         $list = coursecat::make_categories_list();
         // Get course list for select box.
         $selectbox = array();
         $selected = array();
         foreach ($courses as $c) {
             $selectbox[$c->id] = $list[$c->category] . ' / ' . format_string($c->fullname, true, array('context' => context_course::instance($c->id)));
             // If already selected ...
             if ($c->selected) {
                 $selected[] = $c->id;
             }
         }
         // Show multiselect box.
//.........这里部分代码省略.........
开发者ID:evltuma,项目名称:moodle,代码行数:101,代码来源:completion_form.php


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