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


PHP completion_completion::mark_inprogress方法代码示例

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


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

示例1: facetoface_user_signup


//.........这里部分代码省略.........
        $success = (bool)$usersignup->id;
    }

    if (!$success) {
        print_error('error:couldnotupdatef2frecord', 'facetoface');
    }

    // Work out which status to use

    // If approval not required
    if (!$facetoface->approvalreqd) {
        $new_status = $statuscode;
    } else {
        // If approval required

        // Get current status (if any)
        $current_status =  $DB->get_field('facetoface_signups_status', 'statuscode', array('signupid' => $usersignup->id, 'superceded' => 0));

        // If approved, then no problem
        if ($current_status == MDL_F2F_STATUS_APPROVED) {
            $new_status = $statuscode;
        } else if ($session->datetimeknown) {
            // If currently on the waitlist they have already been approved, no need to approve them again.
            if ($current_status == MDL_F2F_STATUS_WAITLISTED) {
                $new_status = $statuscode;
            } else {
                // Otherwise, send manager request.
                $new_status = MDL_F2F_STATUS_REQUESTED;
            }
        } else {
            $new_status = MDL_F2F_STATUS_WAITLISTED;
        }
    }

    // Update status.
    if (!facetoface_update_signup_status($usersignup->id, $new_status, $USER->id)) {
        print_error('error:f2ffailedupdatestatus', 'facetoface');
    }

    // Add to user calendar -- if facetoface usercalentry is set to true
    if ($facetoface->usercalentry && in_array($new_status, array(MDL_F2F_STATUS_BOOKED, MDL_F2F_STATUS_WAITLISTED))) {
        facetoface_add_session_to_calendar($session, $facetoface, 'user', $userid, 'booking');
    }

    // If session has already started, do not send a notification
    if (facetoface_has_session_started($session, $timenow)) {
        $notifyuser = false;
    }

    // Send notification.
    $notifytype = ((int)$notificationtype == MDL_F2F_NONE ? false : true);
    $session->notifyuser = $notifyuser && $notifytype;

    switch ($new_status) {
        case MDL_F2F_STATUS_BOOKED:
            $error = facetoface_send_confirmation_notice($facetoface, $session, $userid, $notificationtype, false);
            break;

        case MDL_F2F_STATUS_WAITLISTED:
            $error = facetoface_send_confirmation_notice($facetoface, $session, $userid, $notificationtype, true);
            break;

        case MDL_F2F_STATUS_REQUESTED:
            $error = facetoface_send_request_notice($facetoface, $session, $userid);
            break;
    }

    if (!empty($error)) {
        if ($error == 'userdoesnotexist') {
            print_error($error, 'facetoface');
        } else {
            // Don't fail if email isn't sent, just display a warning
            echo $OUTPUT->notification(get_string($error, 'facetoface'), 'notifyproblem');
        }
    }

    if ($session->notifyuser) {
        if (!$DB->update_record('facetoface_signups', $usersignup)) {
            print_error('error:couldnotupdatef2frecord', 'facetoface');
        }
    }

    // Update course completion.
    if (in_array($new_status, array(MDL_F2F_STATUS_BOOKED, MDL_F2F_STATUS_WAITLISTED))) {

        $completion = new completion_info($course);
        if ($completion->is_enabled()) {

            $ccdetails = array(
                'course' => $course->id,
                'userid' => $userid,
            );

            $cc = new completion_completion($ccdetails);
            $cc->mark_inprogress($timenow);
        }
    }

    return true;
}
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:101,代码来源:lib.php

示例2: mark_complete

 /**
  * Mark this criteria complete for the associated user
  *
  * This method creates a course_completion_crit_compl record
  */
 public function mark_complete()
 {
     // Create record
     $this->timecompleted = time();
     // Save record
     if ($this->id) {
         $this->update();
     } else {
         $this->insert();
     }
     // Mark course completion record as started (if not already)
     $cc = array('course' => $this->course, 'userid' => $this->userid);
     $ccompletion = new completion_completion($cc);
     $ccompletion->mark_inprogress($this->timecompleted);
 }
开发者ID:nicusX,项目名称:moodle,代码行数:20,代码来源:completion_criteria_completion.php

示例3: facetoface_user_signup

/**
 * Add a record to the facetoface submissions table and sends out an
 * email confirmation
 *
 * @param class $session record from the facetoface_sessions table
 * @param class $facetoface record from the facetoface table
 * @param class $course record from the course table
 * @param string $discountcode code entered by the user
 * @param integer $notificationtype type of notifications to send to user
 * @see {{MDL_F2F_INVITE}}
 * @param integer $statuscode Status code to set
 * @param integer $userid user to signup
 * @param bool $notifyuser whether or not to send an email confirmation
 * @param bool $displayerrors whether or not to return an error page on errors
 */
function facetoface_user_signup($session, $facetoface, $course, $discountcode, $notificationtype, $statuscode, $userid = false, $notifyuser = true)
{
    global $CFG, $DB;
    // Get user ID.
    if (!$userid) {
        global $USER;
        $userid = $USER->id;
    }
    $return = false;
    $timenow = time();
    // Check to see if a signup already exists.
    if ($existingsignup = $DB->get_record('facetoface_signups', array('sessionid' => $session->id, 'userid' => $userid))) {
        $usersignup = $existingsignup;
    } else {
        // Otherwise, prepare a signup object.
        $usersignup = new stdclass();
        $usersignup->sessionid = $session->id;
        $usersignup->userid = $userid;
    }
    $usersignup->mailedreminder = 0;
    $usersignup->notificationtype = $notificationtype;
    $usersignup->discountcode = trim(strtoupper($discountcode));
    if (empty($usersignup->discountcode)) {
        $usersignup->discountcode = null;
    }
    // Update/insert the signup record.
    if (!empty($usersignup->id)) {
        $success = $DB->update_record('facetoface_signups', $usersignup);
    } else {
        $usersignup->id = $DB->insert_record('facetoface_signups', $usersignup);
        $success = (bool) $usersignup->id;
    }
    if (!$success) {
        print_error('error:couldnotupdatef2frecord', 'facetoface');
        return false;
    }
    // Work out which status to use.
    // If approval not required.
    if (!$facetoface->approvalreqd) {
        $newstatus = $statuscode;
    } else {
        // If approval required.
        // Get current status (if any).
        $currentstatus = $DB->get_field('facetoface_signups_status', 'statuscode', array('signupid' => $usersignup->id, 'superceded' => 0));
        // If approved, then no problem.
        if ($currentstatus == MDL_F2F_STATUS_APPROVED) {
            $newstatus = $statuscode;
        } else {
            if ($session->datetimeknown) {
                // Otherwise, send manager request.
                $newstatus = MDL_F2F_STATUS_REQUESTED;
            } else {
                $newstatus = MDL_F2F_STATUS_WAITLISTED;
            }
        }
    }
    // Update status.
    if (!facetoface_update_signup_status($usersignup->id, $newstatus, $userid)) {
        print_error('error:f2ffailedupdatestatus', 'facetoface');
        return false;
    }
    // Add to user calendar -- if facetoface usercalentry is set to true.
    if ($facetoface->usercalentry) {
        if (in_array($newstatus, array(MDL_F2F_STATUS_BOOKED, MDL_F2F_STATUS_WAITLISTED))) {
            facetoface_add_session_to_calendar($session, $facetoface, 'user', $userid, 'booking');
        }
    }
    // Course completion.
    if (in_array($newstatus, array(MDL_F2F_STATUS_BOOKED, MDL_F2F_STATUS_WAITLISTED))) {
        $completion = new completion_info($course);
        if ($completion->is_enabled()) {
            $ccdetails = array('course' => $course->id, 'userid' => $userid);
            $cc = new completion_completion($ccdetails);
            $cc->mark_inprogress($timenow);
        }
    }
    // If session has already started, do not send a notification.
    if (facetoface_has_session_started($session, $timenow)) {
        $notifyuser = false;
    }
    // Send notification.
    if ($notifyuser) {
        // If booked/waitlisted.
        switch ($newstatus) {
            case MDL_F2F_STATUS_BOOKED:
//.........这里部分代码省略.........
开发者ID:CWRTP,项目名称:facetoface-2.0,代码行数:101,代码来源:lib.php

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