本文整理汇总了PHP中completion_info::get_progress_all方法的典型用法代码示例。如果您正苦于以下问题:PHP completion_info::get_progress_all方法的具体用法?PHP completion_info::get_progress_all怎么用?PHP completion_info::get_progress_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类completion_info
的用法示例。
在下文中一共展示了completion_info::get_progress_all方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: course_completion_gauge
public function course_completion_gauge(&$course, $div, $width = 160, $height = 160, $type = 'progressbar')
{
global $USER, $PAGE;
$str = '';
$completion = new completion_info($course);
if ($completion->is_enabled(null)) {
$alltracked = count($completion->get_activities());
$progressinfo = $completion->get_progress_all('u.id = :userid', array('userid' => $USER->id));
$completed = 0;
if (!empty($progressinfo)) {
if (!empty($progressinfo[$USER->id]->progress)) {
foreach ($progressinfo[$USER->id]->progress as $progressrecord) {
if ($progressrecord->completionstate) {
$completed++;
}
}
}
}
$ratio = $alltracked == 0 ? 0 : round($completed / $alltracked * 100);
$jqwrenderer = $PAGE->get_renderer('local_vflibs');
if ($div == 'div') {
$str .= '<div class="course-completion" title="' . get_string('completion', 'local_my', 0 + $ratio) . '">';
} else {
$str .= '<td class="course-completion" title="' . get_string('completion', 'local_my', 0 + $ratio) . '">';
}
if ($type == 'gauge') {
$properties = array('width' => $width, 'height' => $height, 'max' => 100, 'crop' => 120);
$str .= $jqwrenderer->jqw_bargauge_simple('completion-jqw-' . $course->id, array($ratio), $properties);
} else {
$properties = array('width' => $width, 'height' => $height, 'animation' => 300, 'template' => 'success');
$str .= $jqwrenderer->jqw_progress_bar('completion-jqw-' . $course->id, $ratio, $properties);
}
if ($div == 'div') {
$str .= '</div>';
} else {
$str .= '</td>';
}
} else {
if ($div == 'div') {
$str .= '<div class="course-completion">';
} else {
$str .= '<td class="course-completion">';
}
if ($div == 'div') {
$str .= '</div>';
} else {
$str .= '</td>';
}
}
return $str;
}
示例2: array
$where_params['silast'] = $silast . '%';
}
// Get user match count
$total = $completion->get_num_tracked_users(implode(' AND ', $where), $where_params, $group);
// Total user count
$grandtotal = $completion->get_num_tracked_users('', array(), $group);
// If no users in this course what-so-ever
if (!$grandtotal) {
echo $OUTPUT->container(get_string('err_nousers', 'completion'), 'errorbox errorboxcontent');
echo $OUTPUT->footer();
exit;
}
// Get user data
$progress = array();
if ($total) {
$progress = $completion->get_progress_all(implode(' AND ', $where), $where_params, $group, $firstnamesort ? 'u.firstname ASC' : 'u.lastname ASC', $csv ? 0 : COMPLETION_REPORT_PAGE, $csv ? 0 : $start);
}
// Build link for paging
$link = $CFG->wwwroot . '/course/report/completion/?course=' . $course->id;
if (strlen($sort)) {
$link .= '&sort=' . $sort;
}
$link .= '&start=';
// Build the the page by Initial bar
$initials = array('first', 'last');
$alphabet = explode(',', get_string('alphabet', 'langconfig'));
$pagingbar = '';
foreach ($initials as $initial) {
$var = 'si' . $initial;
$pagingbar .= ' <div class="initialbar ' . $initial . 'initial">';
$pagingbar .= get_string($initial . 'name') . ': ';
示例3: get_activities_completion_status
/**
* Get Activities completion status
*
* @param int $courseid ID of the Course
* @param int $userid ID of the User
* @return array of activities progress and warnings
* @throws moodle_exception
* @since Moodle 2.9
* @throws moodle_exception
*/
public static function get_activities_completion_status($courseid, $userid)
{
global $CFG, $USER;
require_once $CFG->libdir . '/grouplib.php';
$warnings = array();
$arrayparams = array('courseid' => $courseid, 'userid' => $userid);
$params = self::validate_parameters(self::get_activities_completion_status_parameters(), $arrayparams);
$course = get_course($params['courseid']);
$user = core_user::get_user($params['userid'], 'id', MUST_EXIST);
$context = context_course::instance($course->id);
self::validate_context($context);
// Check that current user have permissions to see this user's activities.
if ($user->id != $USER->id) {
require_capability('report/progress:view', $context);
if (!groups_user_groups_visible($course, $user->id)) {
// We are not in the same group!
throw new moodle_exception('accessdenied', 'admin');
}
}
$completion = new completion_info($course);
$activities = $completion->get_activities();
$progresses = $completion->get_progress_all();
$userprogress = $progresses[$user->id];
$results = array();
foreach ($activities as $activity) {
// Check if current user has visibility on this activity.
if (!$activity->uservisible) {
continue;
}
// Get progress information and state.
if (array_key_exists($activity->id, $userprogress->progress)) {
$thisprogress = $userprogress->progress[$activity->id];
$state = $thisprogress->completionstate;
$timecompleted = $thisprogress->timemodified;
} else {
$state = COMPLETION_INCOMPLETE;
$timecompleted = 0;
}
$results[] = array('cmid' => $activity->id, 'modname' => $activity->modname, 'instance' => $activity->instance, 'state' => $state, 'timecompleted' => $timecompleted, 'tracking' => $activity->completion);
}
$results = array('statuses' => $results, 'warnings' => $warnings);
return $results;
}
示例4: header
require_capability('coursereport/progress:view', $context);
// Get group mode
$group = groups_get_course_group($course, true);
// Supposed to verify group
if ($group === 0 && $course->groupmode == SEPARATEGROUPS) {
require_capability('moodle/site:accessallgroups', $context);
}
// Get data on activities and progress of all users, and give error if we've
// nothing to display (no users or no activities)
$reportsurl = $CFG->wwwroot . '/course/report.php?id=' . $course->id;
$completion = new completion_info($course);
$activities = $completion->get_activities();
if (count($activities) == 0) {
print_error('err_noactivities', 'completion', $reportsurl);
}
$progress = $completion->get_progress_all($firstnamesort, $group, $csv ? 0 : COMPLETION_REPORT_PAGE, $csv ? 0 : $start);
if ($csv) {
header('Content-Disposition: attachment; filename=progress.' . preg_replace('/[^a-z0-9-]/', '_', strtolower($course->shortname)) . '.csv');
// Unicode byte-order mark for Excel
if ($excel) {
header('Content-Type: text/csv; charset=UTF-16LE');
print chr(0xff) . chr(0xfe);
$sep = "\t" . chr(0);
$line = "\n" . chr(0);
} else {
header('Content-Type: text/csv; charset=UTF-8');
$sep = ",";
$line = "\n";
}
} else {
// Use SVG to draw sideways text if supported
示例5: 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;
}