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


PHP completion_completion::mark_complete方法代码示例

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


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

示例1: review

 /**
  * Review this criteria and decide if the user has completed
  *
  * @param completion_completion $completion     The user's completion record
  * @param bool $mark Optionally set false to not save changes to database
  * @return bool
  */
 public function review($completion, $mark = true)
 {
     global $DB;
     $course = $DB->get_record('course', array('id' => $completion->course));
     $cm = $DB->get_record('course_modules', array('id' => $this->moduleinstance));
     $info = new completion_info($course);
     $data = $info->get_data($cm, false, $completion->userid);
     // If the activity is complete
     if (in_array($data->completionstate, array(COMPLETION_COMPLETE, COMPLETION_COMPLETE_PASS))) {
         if ($mark) {
             $completion->mark_complete();
         }
         return true;
     }
     return false;
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:23,代码来源:completion_criteria_activity.php

示例2: test_course_completed_event

 /**
  * Test course completed event.
  */
 public function test_course_completed_event()
 {
     global $USER;
     $this->setup_data();
     $this->setAdminUser();
     $completionauto = array('completion' => COMPLETION_TRACKING_AUTOMATIC);
     $ccompletion = new completion_completion(array('course' => $this->course->id, 'userid' => $this->user->id));
     // Mark course as complete and get triggered event.
     $sink = $this->redirectEvents();
     $ccompletion->mark_complete();
     $events = $sink->get_events();
     $event = reset($events);
     $this->assertInstanceOf('\\core\\event\\course_completed', $event);
     $this->assertEquals($this->course->id, $event->get_record_snapshot('course_completions', $event->objectid)->course);
     $this->assertEquals($this->course->id, $event->courseid);
     $this->assertEquals($USER->id, $event->userid);
     $this->assertEquals($this->user->id, $event->relateduserid);
     $this->assertEquals(context_course::instance($this->course->id), $event->get_context());
     $this->assertInstanceOf('moodle_url', $event->get_url());
     $data = $ccompletion->get_record_data();
     $this->assertEventLegacyData($data, $event);
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:25,代码来源:completionlib_test.php

示例3: review

 /**
  * Review this criteria and decide if the user has completed
  *
  * @param completion_completion $completion The user's completion record
  * @param bool $mark Optionally set false to not save changes to database
  * @param bool $is_complete Set to false if the criteria has been completed just now.
  * @return bool
  */
 public function review($completion, $mark = true, $is_complete = false)
 {
     // If we are marking this as complete
     if ($is_complete && $mark) {
         $completion->completedself = 1;
         $completion->mark_complete();
         return true;
     }
     return $completion->is_complete();
 }
开发者ID:evltuma,项目名称:moodle,代码行数:18,代码来源:completion_criteria_role.php

示例4: completion_cron_completions


//.........这里部分代码省略.........
        AND crc.userid = cc.userid
        WHERE
            c.enablecompletion = 1
        AND crc.timecompleted IS NULL
        AND crc.reaggregate > 0
        AND crc.reaggregate < :timestarted
        ORDER BY
            course,
            userid
    ';
    // Check if result is empty
    if (!($rs = $DB->get_recordset_sql($sql, array('timestarted' => $timestarted)))) {
        return;
    }
    $current_user = null;
    $current_course = null;
    $completions = array();
    while (1) {
        // Grab records for current user/course
        foreach ($rs as $record) {
            // If we are still grabbing the same users completions
            if ($record->userid === $current_user && $record->course === $current_course) {
                $completions[$record->criteriaid] = $record;
            } else {
                break;
            }
        }
        // Aggregate
        if (!empty($completions)) {
            if (debugging()) {
                mtrace('Aggregating completions for user ' . $current_user . ' in course ' . $current_course);
            }
            // Get course info object
            $info = new completion_info((object) array('id' => $current_course));
            // Setup aggregation
            $overall = $info->get_aggregation_method();
            $activity = $info->get_aggregation_method(COMPLETION_CRITERIA_TYPE_ACTIVITY);
            $prerequisite = $info->get_aggregation_method(COMPLETION_CRITERIA_TYPE_COURSE);
            $role = $info->get_aggregation_method(COMPLETION_CRITERIA_TYPE_ROLE);
            $overall_status = null;
            $activity_status = null;
            $prerequisite_status = null;
            $role_status = null;
            // Get latest timecompleted
            $timecompleted = null;
            // Check each of the criteria
            foreach ($completions as $params) {
                $timecompleted = max($timecompleted, $params->timecompleted);
                $completion = new completion_criteria_completion($params, false);
                // Handle aggregation special cases
                if ($params->criteriatype == COMPLETION_CRITERIA_TYPE_ACTIVITY) {
                    completion_cron_aggregate($activity, $completion->is_complete(), $activity_status);
                } else {
                    if ($params->criteriatype == COMPLETION_CRITERIA_TYPE_COURSE) {
                        completion_cron_aggregate($prerequisite, $completion->is_complete(), $prerequisite_status);
                    } else {
                        if ($params->criteriatype == COMPLETION_CRITERIA_TYPE_ROLE) {
                            completion_cron_aggregate($role, $completion->is_complete(), $role_status);
                        } else {
                            completion_cron_aggregate($overall, $completion->is_complete(), $overall_status);
                        }
                    }
                }
            }
            // Include role criteria aggregation in overall aggregation
            if ($role_status !== null) {
                completion_cron_aggregate($overall, $role_status, $overall_status);
            }
            // Include activity criteria aggregation in overall aggregation
            if ($activity_status !== null) {
                completion_cron_aggregate($overall, $activity_status, $overall_status);
            }
            // Include prerequisite criteria aggregation in overall aggregation
            if ($prerequisite_status !== null) {
                completion_cron_aggregate($overall, $prerequisite_status, $overall_status);
            }
            // If aggregation status is true, mark course complete for user
            if ($overall_status) {
                if (debugging()) {
                    mtrace('Marking complete');
                }
                $ccompletion = new completion_completion(array('course' => $params->course, 'userid' => $params->userid));
                $ccompletion->mark_complete($timecompleted);
            }
        }
        // If this is the end of the recordset, break the loop
        if (!$rs->valid()) {
            $rs->close();
            break;
        }
        // New/next user, update user details, reset completions
        $current_user = $record->userid;
        $current_course = $record->course;
        $completions = array();
        $completions[$record->criteriaid] = $record;
    }
    // Mark all users as aggregated
    $sql = "\n        UPDATE\n            {course_completions}\n        SET\n            reaggregate = 0\n        WHERE\n            reaggregate < {$timestarted}\n    ";
    $DB->execute($sql);
}
开发者ID:vuchannguyen,项目名称:web,代码行数:101,代码来源:cron.php

示例5: test_badges_observer_course_criteria_review

 /**
  * Test badges observer when course_completed event is fired.
  */
 public function test_badges_observer_course_criteria_review()
 {
     $this->preventResetByRollback();
     // Messaging is not compatible with transactions.
     $badge = new badge($this->coursebadge);
     $this->assertFalse($badge->is_issued($this->user->id));
     $criteria_overall = award_criteria::build(array('criteriatype' => BADGE_CRITERIA_TYPE_OVERALL, 'badgeid' => $badge->id));
     $criteria_overall->save(array('agg' => BADGE_CRITERIA_AGGREGATION_ANY));
     $criteria_overall1 = award_criteria::build(array('criteriatype' => BADGE_CRITERIA_TYPE_COURSE, 'badgeid' => $badge->id));
     $criteria_overall1->save(array('agg' => BADGE_CRITERIA_AGGREGATION_ANY, 'course_' . $this->course->id => $this->course->id));
     $ccompletion = new completion_completion(array('course' => $this->course->id, 'userid' => $this->user->id));
     // Mark course as complete.
     $sink = $this->redirectEmails();
     $ccompletion->mark_complete();
     $this->assertCount(1, $sink->get_messages());
     $sink->close();
     // Check if badge is awarded.
     $this->assertDebuggingCalled('Error baking badge image!');
     $this->assertTrue($badge->is_issued($this->user->id));
 }
开发者ID:nikitskynikita,项目名称:moodle,代码行数:23,代码来源:badgeslib_test.php

示例6: review

 /**
  * Review this criteria and decide if the user has completed
  *
  * @param completion_completion $completion The user's completion record
  * @param bool $mark Optionally set false to not save changes to database
  * @return bool
  */
 public function review($completion, $mark = true)
 {
     // If current time is past timeend
     if ($this->timeend && $this->timeend < time()) {
         if ($mark) {
             $completion->mark_complete();
         }
         return true;
     }
     return false;
 }
开发者ID:nmicha,项目名称:moodle,代码行数:18,代码来源:completion_criteria_date.php

示例7: review

 /**
  * Review this criteria and decide if the user has completed
  *
  * @param completion_completion $completion The user's completion record
  * @param bool $mark Optionally set false to not save changes to database
  * @return bool
  */
 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:evltuma,项目名称:moodle,代码行数:21,代码来源:completion_criteria_course.php

示例8: sync_enrolments


//.........这里部分代码省略.........
                     }
                     $trace->output('Old grade for courseid ' . $cinfo['courseid'] . " and userid " . $userid . " is " . $currentgrade . ".");
                 } else {
                     $trace->output('Error: Unable to get final exam record for courseid ' . $cinfo['courseid'] . " and userid " . $userid . ". Course completion will be ignored.");
                     continue;
                 }
                 if (isset($cinfo['grade'])) {
                     if ($cinfo['grade'] > $currentgrade || empty($currentgrade)) {
                         // If imported grade is larger update the final exam grade
                         $grade = array();
                         $grade['userid'] = $userid;
                         $grade['rawgrade'] = $cinfo['grade'] / 10;
                         //learn.saylor.org is currently using rawmaxgrade of 10.0000
                         grade_update('mod/quiz', $cinfo['courseid'], $gi->itemtype, $gi->itemmodule, $gi->iteminstance, $gi->itemnumber, $grade);
                         $trace->output('Updating grade for courseid ' . $cinfo['courseid'] . " and userid " . $userid . " to " . $grade['rawgrade'] . ".");
                     } else {
                         if (!empty($currentgrade) && $currentgrade >= $cinfo['grade']) {
                             $trace->output("Current grade for final exam for courseid " . $cinfo['courseid'] . " and userid " . $userid . " is larger or equal to the imported grade. Not updating grade.");
                             continue;
                         } else {
                             debugging("Unable to determine if there is a current final exam grade for courseid " . $cinfo['courseid'] . " and userid " . $userid . " or whether it is less than the imported grade.");
                             continue;
                         }
                     }
                     //Mark course as complete. Create completion_completion object to handle completion info for that user and course.
                     $cparams = array('userid' => $userid, 'course' => $cinfo['courseid']);
                     $cc = new completion_completion($cparams);
                     if ($cc->is_complete()) {
                         continue;
                         //Skip adding completion info for this course if the user has already completed this course. Possibility that his grade gets bumped up.
                     }
                     if (isset($cinfo['completiondate'])) {
                         $completeddatestamp = strtotime($cinfo['completiondate']);
                         //Convert the date string to a unix time stamp.
                     } else {
                         $completeddatestamp = time();
                         //If not set, just use the current date.
                     }
                     if (isset($cinfo['enroldate'])) {
                         $enroldatestamp = strtotime($cinfo['enroldate']);
                         //Convert the date string to a unix time stamp.
                     } else {
                         $enroldatestamp = $completeddatestamp;
                     }
                     $cc->mark_enrolled($enroldatestamp);
                     $cc->mark_inprogress($enroldatestamp);
                     $cc->mark_complete($completeddatestamp);
                     $trace->output('Setting completion data for userid ' . $userid . ' and courseid ' . $cinfo['courseid'] . ".");
                 } else {
                     if (!isset($cinfo['grade'])) {
                         $trace->output("Error: No grade info in external db for completed course " . $cinfo['courseid'] . " for user " . $userid . ".");
                     }
                 }
             }
         }
         // Deal with enrolments removed from external table.
         if ($unenrolaction == ENROL_EXT_REMOVED_UNENROL) {
             if (!$preventfullunenrol) {
                 // Unenrol.
                 foreach ($currentstatus as $userid => $status) {
                     if (isset($requestedenrols[$userid])) {
                         continue;
                     }
                     $this->unenrol_user($instance, $userid);
                     $trace->output("unenrolling: {$userid} ==> {$course->shortname}", 1);
                 }
             }
         } else {
             if ($unenrolaction == ENROL_EXT_REMOVED_KEEP) {
                 // Keep - only adding enrolments.
             } else {
                 if ($unenrolaction == ENROL_EXT_REMOVED_SUSPEND or $unenrolaction == ENROL_EXT_REMOVED_SUSPENDNOROLES) {
                     // Suspend enrolments.
                     foreach ($currentstatus as $userid => $status) {
                         if (isset($requestedenrols[$userid])) {
                             continue;
                         }
                         if ($status != ENROL_USER_SUSPENDED) {
                             $this->update_user_enrol($instance, $userid, ENROL_USER_SUSPENDED);
                             $trace->output("suspending: {$userid} ==> {$course->shortname}", 1);
                         }
                         if ($unenrolaction == ENROL_EXT_REMOVED_SUSPENDNOROLES) {
                             if (isset($requestedroles[$userid])) {
                                 // We want this "other user" to keep their roles.
                                 continue;
                             }
                             role_unassign_all(array('contextid' => $context->id, 'userid' => $userid, 'component' => '', 'itemid' => $instance->id));
                             $trace->output("unsassigning all roles: {$userid} ==> {$course->shortname}", 1);
                         }
                     }
                 }
             }
         }
     }
     // Close db connection.
     $extdb->Close();
     $trace->output('...user enrolment synchronisation finished.');
     $trace->finished();
     return 0;
 }
开发者ID:saylordotorg,项目名称:moodle-enrol_dbself,代码行数:101,代码来源:lib.php


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