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


PHP assign_update_grades函数代码示例

本文整理汇总了PHP中assign_update_grades函数的典型用法代码示例。如果您正苦于以下问题:PHP assign_update_grades函数的具体用法?PHP assign_update_grades怎么用?PHP assign_update_grades使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: process_set_batch_marking_workflow_state

 /**
  * Set the workflow state for multiple users
  *
  * @return void
  */
 protected function process_set_batch_marking_workflow_state()
 {
     global $DB;
     require_sesskey();
     $batchusers = required_param('selectedusers', PARAM_TEXT);
     $state = required_param('markingworkflowstate', PARAM_ALPHA);
     $useridlist = explode(',', $batchusers);
     foreach ($useridlist as $userid) {
         $flags = $this->get_user_flags($userid, true);
         $flags->workflowstate = $state;
         $gradingdisabled = $this->grading_disabled($userid);
         // Will not apply update if user does not have permission to assign this workflow state.
         if (!$gradingdisabled && $this->update_user_flags($flags)) {
             if ($state == ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
                 // Update Gradebook.
                 $assign = clone $this->get_instance();
                 $assign->cmidnumber = $this->get_course_module()->idnumber;
                 assign_update_grades($assign, $userid);
             }
             $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
             $params = array('id' => $user->id, 'fullname' => fullname($user), 'state' => $state);
             $message = get_string('setmarkingworkflowstateforlog', 'assign', $params);
             $addtolog = $this->add_to_log('set marking workflow state', $message, '', true);
             $params = array('context' => $this->context, 'objectid' => $this->get_instance()->id, 'relateduserid' => $userid, 'other' => array('newstate' => $state));
             $event = \mod_assign\event\workflow_state_updated::create($params);
             $event->set_legacy_logdata($addtolog);
             $event->trigger();
         }
     }
 }
开发者ID:covex-nn,项目名称:moodle,代码行数:35,代码来源:locallib.php

示例2: process_set_batch_marking_workflow_state

 /**
  * Set the workflow state for multiple users
  *
  * @return void
  */
 protected function process_set_batch_marking_workflow_state()
 {
     global $CFG, $DB;
     // Include batch marking workflow form.
     require_once $CFG->dirroot . '/mod/assign/batchsetmarkingworkflowstateform.php';
     $formparams = array('userscount' => 0, 'usershtml' => '', 'markingworkflowstates' => $this->get_marking_workflow_states_for_current_user());
     $mform = new mod_assign_batch_set_marking_workflow_state_form(null, $formparams);
     if ($mform->is_cancelled()) {
         return true;
     }
     if ($formdata = $mform->get_data()) {
         $useridlist = explode(',', $formdata->selectedusers);
         $state = $formdata->markingworkflowstate;
         foreach ($useridlist as $userid) {
             $flags = $this->get_user_flags($userid, true);
             $flags->workflowstate = $state;
             // Clear the mailed flag if notification is requested, the student hasn't been
             // notified previously, the student can access the assignment, and the state
             // is "Released".
             $modinfo = get_fast_modinfo($this->course, $userid);
             $cm = $modinfo->get_cm($this->get_course_module()->id);
             if ($formdata->sendstudentnotifications && $cm->uservisible && $state == ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
                 $flags->mailed = 0;
             }
             $gradingdisabled = $this->grading_disabled($userid);
             // Will not apply update if user does not have permission to assign this workflow state.
             if (!$gradingdisabled && $this->update_user_flags($flags)) {
                 if ($state == ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
                     // Update Gradebook.
                     $assign = clone $this->get_instance();
                     $assign->cmidnumber = $this->get_course_module()->idnumber;
                     // Set assign gradebook feedback plugin status.
                     $assign->gradefeedbackenabled = $this->is_gradebook_feedback_enabled();
                     assign_update_grades($assign, $userid);
                 }
                 $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
                 \mod_assign\event\workflow_state_updated::create_from_user($this, $user, $state)->trigger();
             }
         }
     }
 }
开发者ID:mercysmart,项目名称:naikelas,代码行数:46,代码来源:locallib.php

示例3: process_set_batch_marking_workflow_state

 /**
  * Set the workflow state for multiple users
  *
  * @return void
  */
 protected function process_set_batch_marking_workflow_state()
 {
     global $CFG, $DB;
     // Include batch marking workflow form.
     require_once $CFG->dirroot . '/mod/assign/batchsetmarkingworkflowstateform.php';
     $formparams = array('userscount' => 0, 'usershtml' => '', 'markingworkflowstates' => $this->get_marking_workflow_states_for_current_user());
     $mform = new mod_assign_batch_set_marking_workflow_state_form(null, $formparams);
     if ($mform->is_cancelled()) {
         return true;
     }
     if ($formdata = $mform->get_data()) {
         $useridlist = explode(',', $formdata->selectedusers);
         $state = $formdata->markingworkflowstate;
         foreach ($useridlist as $userid) {
             $flags = $this->get_user_flags($userid, true);
             $flags->workflowstate = $state;
             $gradingdisabled = $this->grading_disabled($userid);
             // Will not apply update if user does not have permission to assign this workflow state.
             if (!$gradingdisabled && $this->update_user_flags($flags)) {
                 if ($state == ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
                     // Update Gradebook.
                     $assign = clone $this->get_instance();
                     $assign->cmidnumber = $this->get_course_module()->idnumber;
                     // Set assign gradebook feedback plugin status.
                     $assign->gradefeedbackenabled = $this->is_gradebook_feedback_enabled();
                     assign_update_grades($assign, $userid);
                 }
                 $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
                 $params = array('id' => $user->id, 'fullname' => fullname($user), 'state' => $state);
                 $message = get_string('setmarkingworkflowstateforlog', 'assign', $params);
                 $addtolog = $this->add_to_log('set marking workflow state', $message, '', true);
                 $params = array('context' => $this->context, 'objectid' => $this->get_instance()->id, 'relateduserid' => $userid, 'other' => array('newstate' => $state));
                 $event = \mod_assign\event\workflow_state_updated::create($params);
                 $event->set_legacy_logdata($addtolog);
                 $event->trigger();
             }
         }
     }
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:44,代码来源:locallib.php

示例4: assign_rescale_activity_grades

/**
 * Rescale all grades for this activity and push the new grades to the gradebook.
 *
 * @param stdClass $course Course db record
 * @param stdClass $cm Course module db record
 * @param float $oldmin
 * @param float $oldmax
 * @param float $newmin
 * @param float $newmax
 */
function assign_rescale_activity_grades($course, $cm, $oldmin, $oldmax, $newmin, $newmax)
{
    global $DB;
    if ($oldmax <= $oldmin) {
        // Grades cannot be scaled.
        return false;
    }
    $scale = ($newmax - $newmin) / ($oldmax - $oldmin);
    if ($newmax - $newmin <= 1) {
        // We would lose too much precision, lets bail.
        return false;
    }
    $params = array('p1' => $oldmin, 'p2' => $scale, 'p3' => $newmin, 'a' => $cm->instance);
    $sql = 'UPDATE {assign_grades} set grade = (((grade - :p1) * :p2) + :p3) where assignment = :a';
    $dbupdate = $DB->execute($sql, $params);
    if (!$dbupdate) {
        return false;
    }
    // Now re-push all grades to the gradebook.
    $dbparams = array('id' => $cm->instance);
    $assign = $DB->get_record('assign', $dbparams);
    $assign->cmidnumber = $cm->idnumber;
    assign_update_grades($assign);
    return true;
}
开发者ID:dg711,项目名称:moodle,代码行数:35,代码来源:lib.php

示例5: process_set_batch_marking_workflow_state

    /**
     * Set the workflow state for multiple users
     *
     * @return void
     */
    protected function process_set_batch_marking_workflow_state() {
        global $CFG, $DB;

        // Include batch marking workflow form.
        require_once($CFG->dirroot . '/mod/assign/batchsetmarkingworkflowstateform.php');

        $formparams = array(
            'userscount' => 0,  // This form is never re-displayed, so we don't need to
            'usershtml' => '',  // initialise these parameters with real information.
            'markingworkflowstates' => $this->get_marking_workflow_states_for_current_user()
        );

        $mform = new mod_assign_batch_set_marking_workflow_state_form(null, $formparams);

        if ($mform->is_cancelled()) {
            return true;
        }

        if ($formdata = $mform->get_data()) {
            $useridlist = explode(',', $formdata->selectedusers);
            $state = $formdata->markingworkflowstate;

            foreach ($useridlist as $userid) {
                $flags = $this->get_user_flags($userid, true);

                $flags->workflowstate = $state;

                $gradingdisabled = $this->grading_disabled($userid);

                // Will not apply update if user does not have permission to assign this workflow state.
                if (!$gradingdisabled && $this->update_user_flags($flags)) {
                    if ($state == ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
                        // Update Gradebook.
                        $assign = clone $this->get_instance();
                        $assign->cmidnumber = $this->get_course_module()->idnumber;
                        // Set assign gradebook feedback plugin status.
                        $assign->gradefeedbackenabled = $this->is_gradebook_feedback_enabled();
                        assign_update_grades($assign, $userid);
                    }

                    $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
                    \mod_assign\event\workflow_state_updated::create_from_user($this, $user, $state)->trigger();
                }
            }
        }
    }
开发者ID:jtibbetts,项目名称:moodle,代码行数:51,代码来源:locallib.php


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