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


PHP completion_info::count_course_user_data方法代码示例

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


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

示例1: execute

    function execute($data, $row, $user, $courseid, $starttime = 0, $endtime = 0) {
        global $DB, $CFG;

        require_once("{$CFG->libdir}/completionlib.php");

        $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);

        $info = new completion_info($course);

        // Is course complete?
        $coursecomplete = $info->is_course_complete($row->id);

        // Load course completion.
        $params = array(
            'userid' => $row->id,
            'course' => $course->id
        );
        $ccompletion = new completion_completion($params);

        // Has this user completed any criteria?
        $criteriacomplete = $info->count_course_user_data($row->id);

        $content = "";
        if ($coursecomplete) {
            $content .= get_string('complete');
        } else if (!$criteriacomplete && !$ccompletion->timestarted) {
            $content .= html_writer::tag('i', get_string('notyetstarted', 'completion'));
        } else {
            $content .= html_writer::tag('i', get_string('inprogress', 'completion'));
        }
        return $content;
    }
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:32,代码来源:plugin.class.php

示例2: array

if ($USER->id != $user->id) {
    echo html_writer::start_tag('tr');
    echo html_writer::start_tag('td', array('colspan' => '2'));
    echo html_writer::tag('b', get_string('showinguser', 'completion'));
    $url = new moodle_url('/user/view.php', array('id' => $user->id, 'course' => $course->id));
    echo html_writer::link($url, fullname($user));
    echo html_writer::end_tag('td');
    echo html_writer::end_tag('tr');
}
echo html_writer::start_tag('tr');
echo html_writer::start_tag('td', array('colspan' => '2'));
echo html_writer::tag('b', get_string('status'));
// Is course complete?
$coursecomplete = $info->is_course_complete($user->id);
// Has this user completed any criteria?
$criteriacomplete = $info->count_course_user_data($user->id);
// Load course completion.
$params = array('userid' => $user->id, 'course' => $course->id);
$ccompletion = new completion_completion($params);
if ($coursecomplete) {
    echo get_string('complete');
} else {
    if (!$criteriacomplete && !$ccompletion->timestarted) {
        echo html_writer::tag('i', get_string('notyetstarted', 'completion'));
    } else {
        echo html_writer::tag('i', get_string('inprogress', 'completion'));
    }
}
echo html_writer::end_tag('td');
echo html_writer::end_tag('tr');
// Load criteria to display.
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:31,代码来源:details.php

示例3: get_content


//.........这里部分代码省略.........
     // For aggregating activity completion
     $activities = array();
     $activities_complete = 0;
     // For aggregating course prerequisites
     $prerequisites = array();
     $prerequisites_complete = 0;
     // Flag to set if current completion data is inconsistent with
     // what is stored in the database
     $pending_update = false;
     // Loop through course criteria
     foreach ($completions as $completion) {
         $criteria = $completion->get_criteria();
         $complete = $completion->is_complete();
         if (!$pending_update && $criteria->is_pending($completion)) {
             $pending_update = true;
         }
         // Activities are a special case, so cache them and leave them till last
         if ($criteria->criteriatype == COMPLETION_CRITERIA_TYPE_ACTIVITY) {
             $activities[$criteria->moduleinstance] = $complete;
             if ($complete) {
                 $activities_complete++;
             }
             continue;
         }
         // Prerequisites are also a special case, so cache them and leave them till last
         if ($criteria->criteriatype == COMPLETION_CRITERIA_TYPE_COURSE) {
             $prerequisites[$criteria->courseinstance] = $complete;
             if ($complete) {
                 $prerequisites_complete++;
             }
             continue;
         }
         $shtml .= '<tr><td>';
         $shtml .= $criteria->get_title();
         $shtml .= '</td><td style="text-align: right">';
         $shtml .= $completion->get_status();
         $shtml .= '</td></tr>';
     }
     // Aggregate activities
     if (!empty($activities)) {
         $shtml .= '<tr><td>';
         $shtml .= get_string('activitiescompleted', 'completion');
         $shtml .= '</td><td style="text-align: right">';
         $a = new stdClass();
         $a->first = $activities_complete;
         $a->second = count($activities);
         $shtml .= get_string('firstofsecond', 'block_completionstatus', $a);
         $shtml .= '</td></tr>';
     }
     // Aggregate prerequisites
     if (!empty($prerequisites)) {
         $phtml = '<tr><td>';
         $phtml .= get_string('prerequisitescompleted', 'completion');
         $phtml .= '</td><td style="text-align: right">';
         $a = new stdClass();
         $a->first = $prerequisites_complete;
         $a->second = count($prerequisites);
         $shtml .= get_string('firstofsecond', 'block_completionstatus', $a);
         $phtml .= '</td></tr>';
         $shtml = $phtml . $shtml;
     }
     // Display completion status
     $this->content->text = '<table width="100%" style="font-size: 90%;"><tbody>';
     $this->content->text .= '<tr><td colspan="2"><b>' . get_string('status') . ':</b> ';
     // Is course complete?
     $coursecomplete = $info->is_course_complete($USER->id);
     // Load course completion
     $params = array('userid' => $USER->id, 'course' => $COURSE->id);
     $ccompletion = new completion_completion($params);
     // Has this user completed any criteria?
     $criteriacomplete = $info->count_course_user_data($USER->id);
     if ($pending_update) {
         $this->content->text .= '<i>' . get_string('pending', 'completion') . '</i>';
     } else {
         if ($coursecomplete) {
             $this->content->text .= get_string('complete');
         } else {
             if (!$criteriacomplete && !$ccompletion->timestarted) {
                 $this->content->text .= '<i>' . get_string('notyetstarted', 'completion') . '</i>';
             } else {
                 $this->content->text .= '<i>' . get_string('inprogress', 'completion') . '</i>';
             }
         }
     }
     $this->content->text .= '</td></tr>';
     $this->content->text .= '<tr><td colspan="2">';
     // Get overall aggregation method
     $overall = $info->get_aggregation_method();
     if ($overall == COMPLETION_AGGREGATION_ALL) {
         $this->content->text .= get_string('criteriarequiredall', 'completion');
     } else {
         $this->content->text .= get_string('criteriarequiredany', 'completion');
     }
     $this->content->text .= ':</td></tr>';
     $this->content->text .= '<tr><td><b>' . get_string('requiredcriteria', 'completion') . '</b></td><td style="text-align: right"><b>' . get_string('status') . '</b></td></tr>';
     $this->content->text .= $shtml . '</tbody></table>';
     // Display link to detailed view
     $this->content->footer = '<br><a href="' . $CFG->wwwroot . '/blocks/completionstatus/details.php?course=' . $COURSE->id . '">' . get_string('moredetails', 'completion') . '</a>';
     return $this->content;
 }
开发者ID:nutanrajmalanai,项目名称:moodle,代码行数:101,代码来源:block_completionstatus.php

示例4: get_content


//.........这里部分代码省略.........
                 }
                 continue;
             }
             $row = new html_table_row();
             $row->cells[0] = new html_table_cell($criteria->get_title());
             $row->cells[1] = new html_table_cell($completion->get_status());
             $row->cells[1]->style = 'text-align: right;';
             $srows[] = $row;
         }
         // Aggregate activities.
         if (!empty($activities)) {
             $a = new stdClass();
             $a->first = $activities_complete;
             $a->second = count($activities);
             $row = new html_table_row();
             $row->cells[0] = new html_table_cell(get_string('activitiescompleted', 'completion'));
             $row->cells[1] = new html_table_cell(get_string('firstofsecond', 'block_completionstatus', $a));
             $row->cells[1]->style = 'text-align: right;';
             $srows[] = $row;
         }
         // Aggregate prerequisites.
         if (!empty($prerequisites)) {
             $a = new stdClass();
             $a->first = $prerequisites_complete;
             $a->second = count($prerequisites);
             $row = new html_table_row();
             $row->cells[0] = new html_table_cell(get_string('dependenciescompleted', 'completion'));
             $row->cells[1] = new html_table_cell(get_string('firstofsecond', 'block_completionstatus', $a));
             $row->cells[1]->style = 'text-align: right;';
             $prows[] = $row;
             $srows = array_merge($prows, $srows);
         }
         // Display completion status.
         $table = new html_table();
         $table->width = '100%';
         $table->attributes = array('style' => 'font-size: 90%;', 'class' => '');
         $row = new html_table_row();
         $content = html_writer::tag('b', get_string('status') . ': ');
         // Is course complete?
         $coursecomplete = $info->is_course_complete($USER->id);
         // Load course completion.
         $params = array('userid' => $USER->id, 'course' => $course->id);
         $ccompletion = new completion_completion($params);
         // Has this user completed any criteria?
         $criteriacomplete = $info->count_course_user_data($USER->id);
         if ($pending_update) {
             $content .= html_writer::tag('i', get_string('pending', 'completion'));
         } else {
             if ($coursecomplete) {
                 $content .= get_string('complete');
             } else {
                 if (!$criteriacomplete && !$ccompletion->timestarted) {
                     $content .= html_writer::tag('i', get_string('notyetstarted', 'completion'));
                 } else {
                     $content .= html_writer::tag('i', get_string('inprogress', 'completion'));
                 }
             }
         }
         $row->cells[0] = new html_table_cell($content);
         $row->cells[0]->colspan = '2';
         $rows[] = $row;
         $row = new html_table_row();
         $content = "";
         // Get overall aggregation method.
         $overall = $info->get_aggregation_method();
         if ($overall == COMPLETION_AGGREGATION_ALL) {
             $content .= get_string('criteriarequiredall', 'completion');
         } else {
             $content .= get_string('criteriarequiredany', 'completion');
         }
         $content .= ':';
         $row->cells[0] = new html_table_cell($content);
         $row->cells[0]->colspan = '2';
         $rows[] = $row;
         $row = new html_table_row();
         $row->cells[0] = new html_table_cell(html_writer::tag('b', get_string('requiredcriteria', 'completion')));
         $row->cells[1] = new html_table_cell(html_writer::tag('b', get_string('status')));
         $row->cells[1]->style = 'text-align: right;';
         $rows[] = $row;
         // Array merge $rows and $data here.
         $rows = array_merge($rows, $srows);
         $table->data = $rows;
         $this->content->text .= html_writer::table($table);
         // Display link to detailed view.
         $details = new moodle_url('/blocks/completionstatus/details.php', array('course' => $course->id));
         $this->content->footer .= html_writer::link($details, get_string('moredetails', 'completion'));
     } else {
         // If user is not enrolled, show error.
         $this->content->text = get_string('nottracked', 'completion');
     }
     if (has_capability('report/completion:view', $context)) {
         $report = new moodle_url('/report/completion/index.php', array('course' => $course->id));
         if (empty($this->content->footer)) {
             $this->content->footer = '';
         }
         $this->content->footer .= html_writer::empty_tag('br');
         $this->content->footer .= html_writer::link($report, get_string('viewcoursereport', 'completion'));
     }
     return $this->content;
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:101,代码来源:block_completionstatus.php

示例5: get_content

    public function get_content()
    {
        global $USER, $CFG, $DB, $COURSE;
        if ($this->content !== null) {
            return $this->content;
        }
        $this->content = new stdClass();
        $courses1 = enrol_get_my_courses('', 'visible DESC,sortorder ASC');
        //defined in lib/enrollib.php file
        // Display completion status
        $this->content->text .= '<table cellpadding="0" cellspacing="0" width="178" border="0">';
        $this->content->text .= '<tr>';
        $this->content->text .= '<td width="85" align="right"><b>Total</b>';
        $this->content->text .= '</td><td align="left"><b>Over</b>';
        $this->content->text .= '</td><td align="left"><b>%</b>';
        $this->content->text .= '</td></tr></table>';
        $this->content->text .= '<table cellpadding="0" cellspacing="0" width="178" border="0">';
        foreach ($courses1 as $course1) {
            if ($course1->id == SITEID) {
                continue;
            }
            $userid = optional_param('user', 0, PARAM_INT);
            // Load course
            $course = $DB->get_record('course', array('id' => $course1->id));
            // Load user
            if ($userid) {
                $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
            } else {
                $user = $USER;
            }
            $coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
            $personalcontext = get_context_instance(CONTEXT_USER, $user->id);
            $can_view = false;
            // Can view own report
            if ($USER->id == $user->id) {
                $can_view = true;
            } else {
                if (has_capability('moodle/user:viewuseractivitiesreport', $personalcontext)) {
                    $can_view = true;
                } else {
                    if (has_capability('coursereport/completion:view', $coursecontext)) {
                        $can_view = true;
                    } else {
                        if (has_capability('coursereport/completion:view', $personalcontext)) {
                            $can_view = true;
                        }
                    }
                }
            }
            if (!$can_view) {
                $this->content->text .= print_error('cannotviewreport');
            }
            // Load completion data
            $info = new completion_info($course);
            // Load criteria to display
            $completions = $info->get_completions($user->id);
            // Check this user is enroled
            if (!$info->is_tracked_user($user->id)) {
                if ($USER->id == $user->id) {
                    $this->content->text .= print_error('notenroled', 'completion', $returnurl);
                } else {
                    $this->content->text .= print_error('usernotenroled', 'completion', $returnurl);
                }
            }
            // Is course complete?
            $coursecomplete = $info->is_course_complete($user->id);
            // Has this user completed any criteria?
            $criteriacomplete = $info->count_course_user_data($user->id);
            if ($coursecomplete) {
                $status = get_string('complete');
            } else {
                if (!$criteriacomplete) {
                    $status = '<i>' . get_string('notyetstarted', 'completion') . '</i>';
                } else {
                    $status = '<i>' . get_string('inprogress', 'completion') . '</i>';
                }
            }
            //GET TOTAL NUMBER OF TASKS ASSIGNED TO CURRENT USER
            $conditions = array("course" => $course->id);
            $tot_rec = $DB->count_records('course_completion_criteria', $conditions);
            //GET TOTAL NUMBER OF TASKS ASSIGNED TO CURRENT USER
            $result = $DB->get_records_sql('SELECT mc.coursemoduleid,mc.userid,mc.completionstate,
				m.id,m.course FROM `mdl_course_modules_completion` mc 
				LEFT JOIN 
				mdl_course_modules m
				ON
				mc.coursemoduleid=m.id WHERE mc.userid = ? AND m.course = ?', array($user->id, $course->id));
            $tot_comp = count($result);
            $count1 = $tot_comp / $tot_rec;
            $count2 = $count1 * 100;
            $count = number_format($count2, 0);
            $linkhref = new moodle_url('/course/view.php', array('id' => $course->id));
            $this->content->text .= '<tr><td colspan="4"><b title="Course" style="color:#000066;">';
            $this->content->text .= '<a href="' . $linkhref . '">' . $course1->fullname . '</a>';
            $this->content->text .= '</b></td></tr>';
            $this->content->text .= '<tr><td align="left" width="70" title="Activity completion status">';
            //$this->content->text .=$course1->fullname;
            $this->content->text .= $status;
            $this->content->text .= '</td><td align="left" width="27" title="Total activities">' . $tot_rec;
            $this->content->text .= '</td><td width="27" align="left" title="Total Activities completed">' . $tot_comp;
//.........这里部分代码省略.........
开发者ID:nadavkav,项目名称:Moodle2-Hebrew-plugins,代码行数:101,代码来源:block_activity_track.php

示例6: get_targets_by_username


//.........这里部分代码省略.........
         $courses[$core]['course_total_modified'] = $gi_item->timemodified;
         $gg = new grade_grade();
         $gg_grade = $gg::fetch(array('itemid' => $gi_item->id, 'userid' => $user->id));
         // If the scale is going to be a U (or Refer, or Fail etc) as the L3VA is 0, pass null.
         if ($gg_grade && $gg_grade->finalgrade > 0) {
             $courses[$core]['course_total'] = $gg_grade->finalgrade;
             $gs = new grade_scale();
             $gs_scale = $gs::fetch(array('id' => $gi_item->scaleid));
             if ($gi_item->display != 0) {
                 // Check first for a non-zero 'display' variable, and run with that if found.
                 $courses[$core]['course_total_display'] = grade_format_gradevalue($gg_grade->finalgrade, $gi_item, true, $gi_item->display);
             } else {
                 if ($gs_scale) {
                     // See if we have a scale and use that if found.
                     $courses[$core]['course_total_display'] = $gs_scale->get_nearest_item($gg_grade->finalgrade);
                 } else {
                     if (is_numeric($gg_grade->finalgrade)) {
                         $courses[$core]['course_total_display'] = round($courses[$core]['course_total'], 0, PHP_ROUND_HALF_UP);
                     } else {
                         $courses[$core]['course_total_display'] = $courses[$core]['course_total'];
                     }
                 }
             }
         } else {
             $courses[$core]['course_total'] = 0;
             $courses[$core]['course_total_display'] = null;
         }
         // For each target, same as above.
         foreach ($targets as $target) {
             $gi = new grade_item();
             $gi_item = $gi::fetch(array('courseid' => $courses[$core]['course_id'], 'itemtype' => 'manual', 'itemname' => $target));
             $gg = new grade_grade();
             $gg_grade = $gg::fetch(array('itemid' => $gi_item->id, 'userid' => $user->id));
             $courses[$core][strtolower($target)] = $gg_grade->finalgrade;
             // Get the named result (e.g. 'merit') only for targets which are not L3VA.
             if ($target != 'L3VA') {
                 $gs = new grade_scale();
                 $gs_scale = $gs::fetch(array('id' => $gi_item->scaleid));
                 // Updating the most recently modified date if it's newer.
                 if ($gi_item->timemodified > $courses[$core]['course_total_modified']) {
                     $courses[$core]['course_total_modified'] = $gi_item->timemodified;
                 }
                 // If the scale is going to be a U (or Refer, or Fail etc) as the L3VA is 0, pass null.
                 if ($gg_grade->finalgrade > 0) {
                     // If there's no scale, just pass the data across.
                     if ($gs_scale) {
                         $courses[$core][strtolower($target) . '_display'] = $gs_scale->get_nearest_item($gg_grade->finalgrade);
                     } else {
                         $courses[$core][strtolower($target) . '_display'] = $gg_grade->finalgrade;
                     }
                 } else {
                     $courses[$core][strtolower($target) . '_display'] = null;
                 }
             } else {
                 $courses[$core][strtolower($target) . '_display'] = $courses[$core][strtolower($target)];
             }
             // Rounding.
             if (is_numeric($courses[$core][strtolower($target) . '_display'])) {
                 $courses[$core][strtolower($target) . '_display'] = round($courses[$core][strtolower($target) . '_display'], 2, PHP_ROUND_HALF_UP);
             }
         }
         // Default both of these to null.
         $courses[$core]['course_completion_total'] = null;
         $courses[$core]['course_completion_completed'] = null;
         // We could do with a course object to use.
         $sql = "SELECT id from {course} WHERE id LIKE ?;";
         if (!($thiscourse = $DB->get_record_sql($sql, array($courses[$core]['course_id'])))) {
             exit(1);
         }
         if (completion_info::is_enabled_for_site()) {
             $info = new completion_info($thiscourse);
             $completions = $info->get_completions($user->id);
             // If there's no completions, none have been configured so do nothing.
             if (!empty($completions)) {
                 $courses[$core]['course_completion_total'] = count($completions);
                 $courses[$core]['course_completion_completed'] = $info->count_course_user_data($user->id);
                 // Loop through each timecompleted value, ignore if null, update if more recent.
                 foreach ($completions as $completion) {
                     if (!is_null($completion->timecompleted) && $completion->timecompleted > $courses[$core]['course_total_modified']) {
                         $courses[$core]['course_total_modified'] = $completion->timecompleted;
                     }
                 }
             }
         }
         // END completion info enabled for site check.
         // Stress reduction code.
         $courses[$core]['meaning_of_life'] = '42';
         $courses[$core]['smiley_face'] = ':)';
         // Incomplete course check.
         // TODO: make this better. We scan through all four 'leapcore_' tags (and all the new A2 ones) and get the results,
         // but sometimes there aren't any.  So for the tags with no associated courses, we remove them.
         if (!isset($courses[$core]['course_shortname'])) {
             unset($courses[$core]);
         }
     }
     // END foreach $courses.
     if (!empty($courses)) {
         return $courses;
     }
 }
开发者ID:briancrocker81,项目名称:moodle-local_leapwebservices,代码行数:101,代码来源:externallib.php


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