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


PHP completion_info::is_course_complete方法代码示例

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


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

 public function get_content()
 {
     global $CFG, $USER;
     // If content is cached
     if ($this->content !== NULL) {
         return $this->content;
     }
     // Create empty content
     $this->content = new stdClass();
     // Can edit settings?
     $can_edit = has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $this->page->course->id));
     // Get course completion data
     $info = new completion_info($this->page->course);
     // Don't display if completion isn't enabled!
     if (!completion_info::is_enabled_for_site()) {
         if ($can_edit) {
             $this->content->text = get_string('completionnotenabledforsite', 'completion');
         }
         return $this->content;
     } else {
         if (!$info->is_enabled()) {
             if ($can_edit) {
                 $this->content->text = get_string('completionnotenabledforcourse', 'completion');
             }
             return $this->content;
         }
     }
     // Get this user's data
     $completion = $info->get_completion($USER->id, COMPLETION_CRITERIA_TYPE_SELF);
     // Check if self completion is one of this course's criteria
     if (empty($completion)) {
         if ($can_edit) {
             $this->content->text = get_string('selfcompletionnotenabled', 'block_selfcompletion');
         }
         return $this->content;
     }
     // Check this user is enroled
     if (!$info->is_tracked_user($USER->id)) {
         $this->content->text = get_string('notenroled', 'completion');
         return $this->content;
     }
     // Is course complete?
     if ($info->is_course_complete($USER->id)) {
         $this->content->text = get_string('coursealreadycompleted', 'completion');
         return $this->content;
         // Check if the user has already marked themselves as complete
     } else {
         if ($completion->is_complete()) {
             $this->content->text = get_string('alreadyselfcompleted', 'block_selfcompletion');
             return $this->content;
             // If user is not complete, or has not yet self completed
         } else {
             $this->content->text = '';
             $this->content->footer = '<br /><a href="' . $CFG->wwwroot . '/course/togglecompletion.php?course=' . $this->page->course->id . '">';
             $this->content->footer .= get_string('completecourse', 'block_selfcompletion') . '</a>...';
         }
     }
     return $this->content;
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:59,代码来源:block_selfcompletion.php

示例3: get_content

 public function get_content()
 {
     global $USER;
     // If content is cached
     if ($this->content !== NULL) {
         return $this->content;
     }
     global $CFG;
     // Create empty content
     $this->content = new stdClass();
     // Don't display if completion isn't enabled!
     if (!$this->page->course->enablecompletion) {
         $this->content->text = get_string('completionnotenabled', 'block_selfcompletion');
         return $this->content;
     }
     // Get course completion data
     $info = new completion_info($this->page->course);
     $completion = $info->get_completion($USER->id, COMPLETION_CRITERIA_TYPE_SELF);
     // Is course complete?
     if ($info->is_course_complete($USER->id)) {
         return $this->content;
     }
     // Check if self completion is one of this course's criteria
     if (empty($completion)) {
         $this->content->text = get_string('selfcompletionnotenabled', 'block_selfcompletion');
         return $this->content;
     }
     // Check this user is enroled
     if (!$info->is_tracked_user($USER->id)) {
         $this->content->text = get_string('notenroled', 'completion');
         return $this->content;
     }
     // Check if the user has already marked themselves as complete
     if ($completion->is_complete()) {
         return $this->content;
     } else {
         $this->content->text = '';
         $this->content->footer = '<br /><a href="' . $CFG->wwwroot . '/course/togglecompletion.php?course=' . $this->page->course->id . '">' . get_string('completecourse', 'block_selfcompletion') . '</a>...';
     }
     return $this->content;
 }
开发者ID:nfreear,项目名称:moodle,代码行数:41,代码来源:block_selfcompletion.php

示例4: array

echo html_writer::start_tag('tbody');
// If not display logged in user, show user name.
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');
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:31,代码来源:details.php

示例5: execute

 /**
  * Performs the synchronisation of grades.
  *
  * @return bool|void
  */
 public function execute()
 {
     global $DB, $CFG;
     require_once $CFG->dirroot . '/enrol/lti/ims-blti/OAuth.php';
     require_once $CFG->dirroot . '/enrol/lti/ims-blti/OAuthBody.php';
     require_once $CFG->dirroot . '/lib/completionlib.php';
     require_once $CFG->libdir . '/gradelib.php';
     require_once $CFG->dirroot . '/grade/querylib.php';
     // Check if the authentication plugin is disabled.
     if (!is_enabled_auth('lti')) {
         mtrace('Skipping task - ' . get_string('pluginnotenabled', 'auth', get_string('pluginname', 'auth_lti')));
         return true;
     }
     // Check if the enrolment plugin is disabled - isn't really necessary as the task should not run if
     // the plugin is disabled, but there is no harm in making sure core hasn't done something wrong.
     if (!enrol_is_enabled('lti')) {
         mtrace('Skipping task - ' . get_string('enrolisdisabled', 'enrol_lti'));
         return true;
     }
     // Get all the enabled tools.
     if ($tools = \enrol_lti\helper::get_lti_tools(array('status' => ENROL_INSTANCE_ENABLED, 'gradesync' => 1))) {
         foreach ($tools as $tool) {
             mtrace("Starting - Grade sync for shared tool '{$tool->id}' for the course '{$tool->courseid}'.");
             // Variables to keep track of information to display later.
             $usercount = 0;
             $sendcount = 0;
             // We check for all the users - users can access the same tool from different consumers.
             if ($ltiusers = $DB->get_records('enrol_lti_users', array('toolid' => $tool->id), 'lastaccess DESC')) {
                 $completion = new \completion_info(get_course($tool->courseid));
                 foreach ($ltiusers as $ltiuser) {
                     $mtracecontent = "for the user '{$ltiuser->userid}' in the tool '{$tool->id}' for the course " . "'{$tool->courseid}'";
                     $usercount = $usercount + 1;
                     // Check if we do not have a serviceurl - this can happen if the sync process has an unexpected error.
                     if (empty($ltiuser->serviceurl)) {
                         mtrace("Skipping - Empty serviceurl {$mtracecontent}.");
                         continue;
                     }
                     // Check if we do not have a sourceid - this can happen if the sync process has an unexpected error.
                     if (empty($ltiuser->sourceid)) {
                         mtrace("Skipping - Empty sourceid {$mtracecontent}.");
                         continue;
                     }
                     // Need a valid context to continue.
                     if (!($context = \context::instance_by_id($tool->contextid))) {
                         mtrace("Failed - Invalid contextid '{$tool->contextid}' for the tool '{$tool->id}'.");
                         continue;
                     }
                     // Ok, let's get the grade.
                     $grade = false;
                     if ($context->contextlevel == CONTEXT_COURSE) {
                         // Check if the user did not completed the course when it was required.
                         if ($tool->gradesynccompletion && !$completion->is_course_complete($ltiuser->userid)) {
                             mtrace("Skipping - Course not completed {$mtracecontent}.");
                             continue;
                         }
                         // Get the grade.
                         if ($grade = grade_get_course_grade($ltiuser->userid, $tool->courseid)) {
                             $grademax = floatval($grade->item->grademax);
                             $grade = $grade->grade;
                         }
                     } else {
                         if ($context->contextlevel == CONTEXT_MODULE) {
                             $cm = get_coursemodule_from_id(false, $context->instanceid, 0, false, MUST_EXIST);
                             if ($tool->gradesynccompletion) {
                                 $data = $completion->get_data($cm, false, $ltiuser->userid);
                                 if ($data->completionstate != COMPLETION_COMPLETE_PASS && $data->completionstate != COMPLETION_COMPLETE) {
                                     mtrace("Skipping - Activity not completed {$mtracecontent}.");
                                     continue;
                                 }
                             }
                             $grades = grade_get_grades($cm->course, 'mod', $cm->modname, $cm->instance, $ltiuser->userid);
                             if (!empty($grades->items[0]->grades)) {
                                 $grade = reset($grades->items[0]->grades);
                                 if (!empty($grade->item)) {
                                     $grademax = floatval($grade->item->grademax);
                                 } else {
                                     $grademax = floatval($grades->items[0]->grademax);
                                 }
                                 $grade = $grade->grade;
                             }
                         }
                     }
                     if ($grade === false || $grade === null || strlen($grade) < 1) {
                         mtrace("Skipping - Invalid grade {$mtracecontent}.");
                         continue;
                     }
                     // No need to be dividing by zero.
                     if (empty($grademax)) {
                         mtrace("Skipping - Invalid grade {$mtracecontent}.");
                         continue;
                     }
                     // This can happen if the sync process has an unexpected error.
                     if ($grade == $ltiuser->lastgrade) {
                         mtrace("Not sent - The grade {$mtracecontent} was not sent as the grades are the same.");
                         continue;
//.........这里部分代码省略.........
开发者ID:evltuma,项目名称:moodle,代码行数:101,代码来源:sync_grades.php

示例6: 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

示例7: get_course_completion_status

 /**
  * Get Course completion status
  *
  * @param int $courseid ID of the Course
  * @param int $userid ID of the User
  * @return array of course completion status and warnings
  * @since Moodle 2.9
  * @throws moodle_exception
  */
 public static function get_course_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_course_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);
     // Can current user see user's course completion status?
     // This check verifies if completion is enabled because $course is mandatory.
     if (!completion_can_view_data($user->id, $course)) {
         throw new moodle_exception('cannotviewreport');
     }
     // The previous function doesn't check groups.
     if ($user->id != $USER->id) {
         if (!groups_user_groups_visible($course, $user->id)) {
             // We are not in the same group!
             throw new moodle_exception('accessdenied', 'admin');
         }
     }
     $info = new completion_info($course);
     // Check this user is enroled.
     if (!$info->is_tracked_user($user->id)) {
         if ($USER->id == $user->id) {
             throw new moodle_exception('notenroled', 'completion');
         } else {
             throw new moodle_exception('usernotenroled', 'completion');
         }
     }
     $completions = $info->get_completions($user->id);
     if (empty($completions)) {
         throw new moodle_exception('nocriteriaset', 'completion');
     }
     // Load course completion.
     $completionparams = array('userid' => $user->id, 'course' => $course->id);
     $ccompletion = new completion_completion($completionparams);
     $completionrows = array();
     // Loop through course criteria.
     foreach ($completions as $completion) {
         $criteria = $completion->get_criteria();
         $completionrow = array();
         $completionrow['type'] = $criteria->criteriatype;
         $completionrow['title'] = $criteria->get_title();
         $completionrow['status'] = $completion->get_status();
         $completionrow['complete'] = $completion->is_complete();
         $completionrow['timecompleted'] = $completion->timecompleted;
         $completionrow['details'] = $criteria->get_details($completion);
         $completionrows[] = $completionrow;
     }
     $result = array('completed' => $info->is_course_complete($user->id), 'aggregation' => $info->get_aggregation_method(), 'completions' => $completionrows);
     $results = array('completionstatus' => $result, 'warnings' => $warnings);
     return $results;
 }
开发者ID:educakanchay,项目名称:campus,代码行数:65,代码来源:external.php

示例8: review

 /**
  * Review this criteria and decide if it has been completed
  *
  * @return bool Whether criteria is complete
  */
 public function review($userid)
 {
     global $DB;
     foreach ($this->params as $param) {
         $course = $DB->get_record('course', array('id' => $param['course']));
         $info = new completion_info($course);
         $check_grade = true;
         $check_date = true;
         if (isset($param['grade'])) {
             $grade = grade_get_course_grade($userid, $course->id);
             $check_grade = $grade->grade >= $param['grade'];
         }
         if (isset($param['bydate'])) {
             $cparams = array('userid' => $userid, 'course' => $course->id);
             $completion = new completion_completion($cparams);
             $date = $completion->timecompleted;
             $check_date = $date <= $param['bydate'];
         }
         $overall = false;
         if ($this->method == BADGE_CRITERIA_AGGREGATION_ALL) {
             if ($info->is_course_complete($userid) && $check_grade && $check_date) {
                 $overall = true;
                 continue;
             } else {
                 return false;
             }
         } else {
             if ($this->method == BADGE_CRITERIA_AGGREGATION_ANY) {
                 if ($info->is_course_complete($userid) && $check_grade && $check_date) {
                     return true;
                 } else {
                     $overall = false;
                     continue;
                 }
             }
         }
     }
     return $overall;
 }
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:44,代码来源:award_criteria_courseset.php

示例9: review

 /**
  * Review this criteria and decide if the user has completed
  * @access  public
  * @param   object  $completion     The user's completion record
  * @param   boolean $mark           Optionally set false to not save changes to database
  * @return  boolean
  */
 public function review($completion, $mark = true)
 {
     global $DB;
     $course = $DB->get_record('course', array('id' => $this->courseinstance));
     $info = new completion_info($course);
     // If the course is complete
     if ($info->is_course_complete($completion->userid)) {
         if ($mark) {
             $completion->mark_complete();
         }
         return true;
     }
     return false;
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:21,代码来源:completion_criteria_course.php

示例10: 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

示例11: mtrace

 }
 mtrace("   Sending grades for user {$user->userid}");
 $user_count = $user_count + 1;
 // This can happen is the sync process has an unexpected error
 if (strlen($user->serviceurl) < 1) {
     mtrace("   Empty serviceurl");
     continue;
 }
 if (strlen($user->sourceid) < 1) {
     mtrace("   Empty sourceid");
     continue;
 }
 $grade = false;
 if ($context = $DB->get_record('context', array('id' => $tool->contextid))) {
     if ($context->contextlevel == CONTEXT_COURSE) {
         if ($tool->requirecompletion and !$completion->is_course_complete($user->userid)) {
             mtrace("   Skipping user {$user->userid} since he didn't complete the course");
             continue;
         }
         if ($grade = grade_get_course_grade($user->userid, $tool->courseid)) {
             $grademax = floatval($grade->item->grademax);
             $grade = $grade->grade;
         }
     } else {
         if ($context->contextlevel == CONTEXT_MODULE) {
             $cm = get_coursemodule_from_id(false, $context->instanceid, 0, false, MUST_EXIST);
             if ($tool->requirecompletion) {
                 $data = $completion->get_data($cm, false, $user->userid);
                 if ($data->completionstate != COMPLETION_COMPLETE_PASS and $data->completionstate != COMPLETION_COMPLETE) {
                     mtrace("   Skipping user {$user->userid} since he didn't complete the activity");
                     continue;
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:31,代码来源:forcesendgrades.php

示例12: review

 /**
  * Review this criteria and decide if it has been completed
  *
  * @param int $userid User whose criteria completion needs to be reviewed.
  * @param bool $filtered An additional parameter indicating that user list
  *        has been reduced and some expensive checks can be skipped.
  *
  * @return bool Whether criteria is complete
  */
 public function review($userid, $filtered = false)
 {
     $course = new stdClass();
     $course->id = $this->courseid;
     if ($this->coursestartdate > time()) {
         return false;
     }
     $info = new completion_info($course);
     foreach ($this->params as $param) {
         $check_grade = true;
         $check_date = true;
         if (isset($param['grade'])) {
             $grade = grade_get_course_grade($userid, $course->id);
             $check_grade = $grade->grade >= $param['grade'];
         }
         if (!$filtered && isset($param['bydate'])) {
             $cparams = array('userid' => $userid, 'course' => $course->id);
             $completion = new completion_completion($cparams);
             $date = $completion->timecompleted;
             $check_date = $date <= $param['bydate'];
         }
         if ($info->is_course_complete($userid) && $check_grade && $check_date) {
             return true;
         }
     }
     return false;
 }
开发者ID:Hirenvaghasiya,项目名称:moodle,代码行数:36,代码来源:award_criteria_course.php

示例13: review

 /**
  * Review this criteria and decide if it has been completed
  *
  * @param int $userid User whose criteria completion needs to be reviewed.
  * @return bool Whether criteria is complete
  */
 public function review($userid)
 {
     global $DB;
     foreach ($this->params as $param) {
         $course = $DB->get_record('course', array('id' => $param['course']));
         if ($course->startdate > time()) {
             return false;
         }
         $info = new completion_info($course);
         $check_grade = true;
         $check_date = true;
         if (isset($param['grade'])) {
             $grade = grade_get_course_grade($userid, $course->id);
             $check_grade = $grade->grade >= $param['grade'];
         }
         if (isset($param['bydate'])) {
             $cparams = array('userid' => $userid, 'course' => $course->id);
             $completion = new completion_completion($cparams);
             $date = $completion->timecompleted;
             $check_date = $date <= $param['bydate'];
         }
         if ($info->is_course_complete($userid) && $check_grade && $check_date) {
             return true;
         }
     }
     return false;
 }
开发者ID:bobpuffer,项目名称:moodleUCLA-LUTH,代码行数:33,代码来源:award_criteria_course.php

示例14: local_ltiprovider_cron

/**
 * Cron function for sync grades
 * @return void
 */
function local_ltiprovider_cron()
{
    global $DB, $CFG;
    require_once $CFG->dirroot . "/local/ltiprovider/locallib.php";
    require_once $CFG->dirroot . "/local/ltiprovider/ims-blti/OAuth.php";
    require_once $CFG->dirroot . "/local/ltiprovider/ims-blti/OAuthBody.php";
    require_once $CFG->libdir . '/gradelib.php';
    require_once $CFG->dirroot . '/grade/querylib.php';
    // TODO - Add a global setting for this
    $synctime = 60 * 60;
    // Every 1 hour grades are sync
    $timenow = time();
    mtrace('Running cron for ltiprovider');
    mtrace('Deleting LTI tools assigned to deleted courses');
    if ($tools = $DB->get_records('local_ltiprovider')) {
        foreach ($tools as $tool) {
            local_ltiprovider_check_missing_course($tool);
        }
    }
    // Grades service.
    if ($tools = $DB->get_records_select('local_ltiprovider', 'disabled = ? AND sendgrades = ?', array(0, 1))) {
        foreach ($tools as $tool) {
            if ($tool->lastsync + $synctime < $timenow) {
                mtrace(" Starting sync tool for grades id {$tool->id} course id {$tool->courseid}");
                if ($tool->requirecompletion) {
                    mtrace("  Grades require activity or course completion");
                }
                $user_count = 0;
                $send_count = 0;
                $error_count = 0;
                $completion = new completion_info(get_course($tool->courseid));
                if ($users = $DB->get_records('local_ltiprovider_user', array('toolid' => $tool->id))) {
                    foreach ($users as $user) {
                        $user_count = $user_count + 1;
                        // This can happen is the sync process has an unexpected error
                        if (strlen($user->serviceurl) < 1) {
                            mtrace("   Empty serviceurl");
                            continue;
                        }
                        if (strlen($user->sourceid) < 1) {
                            mtrace("   Empty sourceid");
                            continue;
                        }
                        if ($user->lastsync > $tool->lastsync) {
                            mtrace("   Skipping user {$user->id} due to recent sync");
                            continue;
                        }
                        $grade = false;
                        if ($context = $DB->get_record('context', array('id' => $tool->contextid))) {
                            if ($context->contextlevel == CONTEXT_COURSE) {
                                if ($tool->requirecompletion and !$completion->is_course_complete($user->userid)) {
                                    mtrace("   Skipping user {$user->userid} since he didn't complete the course");
                                    continue;
                                }
                                if ($grade = grade_get_course_grade($user->userid, $tool->courseid)) {
                                    $grademax = floatval($grade->item->grademax);
                                    $grade = $grade->grade;
                                }
                            } else {
                                if ($context->contextlevel == CONTEXT_MODULE) {
                                    $cm = get_coursemodule_from_id(false, $context->instanceid, 0, false, MUST_EXIST);
                                    if ($tool->requirecompletion) {
                                        $data = $completion->get_data($cm, false, $user->userid);
                                        if ($data->completionstate != COMPLETION_COMPLETE_PASS and $data->completionstate != COMPLETION_COMPLETE) {
                                            mtrace("   Skipping user {$user->userid} since he didn't complete the activity");
                                            continue;
                                        }
                                    }
                                    $grades = grade_get_grades($cm->course, 'mod', $cm->modname, $cm->instance, $user->userid);
                                    if (empty($grades->items[0]->grades)) {
                                        $grade = false;
                                    } else {
                                        $grade = reset($grades->items[0]->grades);
                                        if (!empty($grade->item)) {
                                            $grademax = floatval($grade->item->grademax);
                                        } else {
                                            $grademax = floatval($grades->items[0]->grademax);
                                        }
                                        $grade = $grade->grade;
                                    }
                                }
                            }
                            if ($grade === false || $grade === NULL || strlen($grade) < 1) {
                                mtrace("   Invalid grade {$grade}");
                                continue;
                            }
                            // No need to be dividing by zero
                            if ($grademax == 0.0) {
                                $grademax = 100.0;
                            }
                            // TODO: Make lastgrade should be float or string - but it is integer so we truncate
                            // TODO: Then remove those intval() calls
                            // Don't double send
                            if (intval($grade) == $user->lastgrade) {
                                mtrace("   Skipping, last grade send is equal to current grade");
                                continue;
//.........这里部分代码省略.........
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:101,代码来源:lib.php

示例15: 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


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