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


PHP assign::save_grade方法代码示例

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


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

示例1: save_grades

 /**
  * Save multiple student grades for a single assignment.
  *
  * @param int $assignmentid The id of the assignment
  * @param boolean $applytoall If set to true and this is a team assignment,
  * apply the grade to all members of the group
  * @param array $grades grade data for one or more students that includes
  *                  userid - The id of the student being graded
  *                  grade - The grade (ignored if the assignment uses advanced grading)
  *                  attemptnumber - The attempt number
  *                  addattempt - Allow another attempt
  *                  workflowstate - New workflow state
  *                  plugindata - Custom data used by plugins
  *                  advancedgradingdata - Optional Advanced grading data
  * @throws invalid_parameter_exception if multiple grades are supplied for
  * a team assignment that has $applytoall set to true
  * @return null
  * @since Moodle 2.7
  */
 public static function save_grades($assignmentid, $applytoall = false, $grades)
 {
     global $CFG, $USER;
     require_once "{$CFG->dirroot}/mod/assign/locallib.php";
     $params = self::validate_parameters(self::save_grades_parameters(), array('assignmentid' => $assignmentid, 'applytoall' => $applytoall, 'grades' => $grades));
     $cm = get_coursemodule_from_instance('assign', $params['assignmentid'], 0, false, MUST_EXIST);
     $context = context_module::instance($cm->id);
     self::validate_context($context);
     $assignment = new assign($context, $cm, null);
     if ($assignment->get_instance()->teamsubmission && $params['applytoall']) {
         // Check that only 1 user per submission group is provided.
         $groupids = array();
         foreach ($params['grades'] as $gradeinfo) {
             $group = $assignment->get_submission_group($gradeinfo['userid']);
             if (in_array($group->id, $groupids)) {
                 throw new invalid_parameter_exception('Multiple grades for the same team have been supplied ' . ' this is not permitted when the applytoall flag is set');
             } else {
                 $groupids[] = $group->id;
             }
         }
     }
     foreach ($params['grades'] as $gradeinfo) {
         $gradedata = (object) $gradeinfo['plugindata'];
         $gradedata->addattempt = $gradeinfo['addattempt'];
         $gradedata->attemptnumber = $gradeinfo['attemptnumber'];
         $gradedata->workflowstate = $gradeinfo['workflowstate'];
         $gradedata->applytoall = $params['applytoall'];
         $gradedata->grade = $gradeinfo['grade'];
         if (!empty($gradeinfo['advancedgradingdata'])) {
             $advancedgrading = array();
             $criteria = reset($gradeinfo['advancedgradingdata']);
             foreach ($criteria as $key => $criterion) {
                 $details = array();
                 foreach ($criterion as $value) {
                     foreach ($value['fillings'] as $filling) {
                         $details[$value['criterionid']] = $filling;
                     }
                 }
                 $advancedgrading[$key] = $details;
             }
             $gradedata->advancedgrading = $advancedgrading;
         }
         $assignment->save_grade($gradeinfo['userid'], $gradedata);
     }
     return null;
 }
开发者ID:rushi963,项目名称:moodle,代码行数:65,代码来源:externallib.php

示例2: save_grade

    /**
     * Save a student grade for a single assignment.
     *
     * @param int $assignmentid The id of the assignment
     * @param int $userid The id of the user
     * @param float $grade The grade
     * @param int $attemptnumber The attempt number
     * @param bool $addattempt Allow another attempt
     * @param string $workflowstate New workflow state
     * @param bool $applytoall Apply the grade to all members of the group
     * @param array $plugindata Custom data used by plugins
     * @return null
     * @since Moodle 2.6
     */
    public static function save_grade($assignmentid,
                                      $userid,
                                      $grade,
                                      $attemptnumber,
                                      $addattempt,
                                      $workflowstate,
                                      $applytoall,
                                      $plugindata) {
        global $CFG, $USER;
        require_once("$CFG->dirroot/mod/assign/locallib.php");

        $params = self::validate_parameters(self::save_grade_parameters(),
                                            array('assignmentid' => $assignmentid,
                                                  'userid' => $userid,
                                                  'grade' => $grade,
                                                  'attemptnumber' => $attemptnumber,
                                                  'workflowstate' => $workflowstate,
                                                  'addattempt' => $addattempt,
                                                  'applytoall' => $applytoall,
                                                  'plugindata' => $plugindata));

        $cm = get_coursemodule_from_instance('assign', $assignmentid, 0, false, MUST_EXIST);
        $context = context_module::instance($cm->id);

        $assignment = new assign($context, $cm, null);

        $gradedata = (object)$plugindata;

        $gradedata->addattempt = $addattempt;
        $gradedata->attemptnumber = $attemptnumber;
        $gradedata->workflowstate = $workflowstate;
        $gradedata->applytoall = $applytoall;
        $gradedata->grade = $grade;

        $assignment->save_grade($userid, $gradedata);

        return null;
    }
开发者ID:rwijaya,项目名称:moodle,代码行数:52,代码来源:externallib.php


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