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


PHP assign::get_submission_group方法代码示例

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


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

示例1:

 /**
  * Use a static cache to try and reduce DB calls.
  *
  * @param int $userid The user id for this submission
  * @param int $groupid The groupid (returned)
  * @param mixed $submission The stdClass submission or false (returned)
  */
 function get_group_and_submission($userid, &$group, &$submission)
 {
     $group = false;
     if (isset($this->submissiongroups[$userid])) {
         $group = $this->submissiongroups[$userid];
     } else {
         $group = $this->assignment->get_submission_group($userid, false);
         $this->submissiongroups[$userid] = $group;
     }
     $groupid = 0;
     if ($group) {
         $groupid = $group->id;
     }
     if (isset($this->groupsubmissions[$groupid])) {
         $submission = $this->groupsubmissions[$groupid];
     } else {
         $submission = $this->assignment->get_group_submission($userid, $groupid, false);
         $this->groupsubmissions[$groupid] = $submission;
     }
 }
开发者ID:vinoth4891,项目名称:clinique,代码行数:27,代码来源:gradingtable.php

示例2: get_group_and_submission

 /**
  * Use a static cache to try and reduce DB calls.
  *
  * @param int $userid The user id for this submission
  * @param int $group The groupid (returned)
  * @param stdClass|false $submission The stdClass submission or false (returned)
  * @param int $attemptnumber Return a specific attempt number (-1 for latest)
  */
 protected function get_group_and_submission($userid, &$group, &$submission, $attemptnumber)
 {
     $group = false;
     if (isset($this->submissiongroups[$userid])) {
         $group = $this->submissiongroups[$userid];
     } else {
         $group = $this->assignment->get_submission_group($userid, false);
         $this->submissiongroups[$userid] = $group;
     }
     $groupid = 0;
     if ($group) {
         $groupid = $group->id;
     }
     // Static cache is keyed by groupid and attemptnumber.
     // We may need both the latest and previous attempt in the same page.
     if (isset($this->groupsubmissions[$groupid . ':' . $attemptnumber])) {
         $submission = $this->groupsubmissions[$groupid . ':' . $attemptnumber];
     } else {
         $submission = $this->assignment->get_group_submission($userid, $groupid, false, $attemptnumber);
         $this->groupsubmissions[$groupid . ':' . $attemptnumber] = $submission;
     }
 }
开发者ID:antoniorodrigues,项目名称:redes-digitais,代码行数:30,代码来源:gradingtable.php

示例3: assignsubmission_comments_comment_validate

/**
 *
 * Callback method for data validation---- required method for AJAXmoodle based comment API
 *
 * @param stdClass $options
 * @return bool
 */
function assignsubmission_comments_comment_validate(stdClass $options)
{
    global $USER, $CFG, $DB;
    if ($options->commentarea != 'submission_comments' && $options->commentarea != 'submission_comments_upgrade') {
        throw new comment_exception('invalidcommentarea');
    }
    if (!($submission = $DB->get_record('assign_submission', array('id' => $options->itemid)))) {
        throw new comment_exception('invalidcommentitemid');
    }
    $context = $options->context;
    require_once $CFG->dirroot . '/mod/assign/locallib.php';
    $assignment = new assign($context, null, null);
    if ($assignment->get_instance()->id != $submission->assignment) {
        throw new comment_exception('invalidcontext');
    }
    if (!has_capability('mod/assign:grade', $context)) {
        if (!has_capability('mod/assign:submit', $context)) {
            throw new comment_exception('nopermissiontocomment');
        } else {
            if ($assignment->get_instance()->teamsubmission) {
                $group = $assignment->get_submission_group($USER->id);
                $groupid = 0;
                if ($group) {
                    $groupid = $group->id;
                }
                if ($groupid != $submission->groupid) {
                    throw new comment_exception('nopermissiontocomment');
                }
            } else {
                if ($submission->userid != $USER->id) {
                    throw new comment_exception('nopermissiontocomment');
                }
            }
        }
    }
    return true;
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:44,代码来源:lib.php

示例4: update_grade

 /**
  * Update module grade and gradebook.
  */
 private function update_grade($cm, $submission, $userid, $type = 'submission')
 {
     global $DB, $USER, $CFG;
     $return = true;
     $grade = $submission->getGrade();
     if (!is_null($grade) && $cm->modname != 'forum') {
         // Module grade object.
         $grade = new stdClass();
         // If submission has multiple content/files in it then get average grade.
         // Ignore NULL grades and files no longer part of submission.
         // Create module object.
         $moduleclass = "turnitin_" . $cm->modname;
         $moduleobject = new $moduleclass();
         // Get file from pathname hash
         $submissiondata = $DB->get_record('plagiarism_turnitin_files', array('externalid' => $submission->getSubmissionId()), 'identifier');
         // Get file as we need item id for discounting files that are no longer in submission.
         $fs = get_file_storage();
         if ($file = $fs->get_file_by_hash($submissiondata->identifier)) {
             $moodlefiles = $DB->get_records_select('files', " component = ? AND itemid = ? AND source IS NOT null ", array($moduleobject->filecomponent, $file->get_itemid()), 'id DESC', 'pathnamehash');
             list($insql, $inparams) = $DB->get_in_or_equal(array_keys($moodlefiles), SQL_PARAMS_QM, 'param', true);
             $tiisubmissions = $DB->get_records_select('plagiarism_turnitin_files', " userid = ? AND cm = ? AND identifier " . $insql, array_merge(array($userid, $cm->id), $inparams));
         } else {
             $tiisubmissions = $DB->get_records('plagiarism_turnitin_files', array('userid' => $userid, 'cm' => $cm->id));
             $tiisubmissions = current($tiisubmissions);
         }
         if (count($tiisubmissions) > 1) {
             $averagegrade = null;
             $gradescounted = 0;
             foreach ($tiisubmissions as $tiisubmission) {
                 if (!is_null($tiisubmission->grade)) {
                     $averagegrade = $averagegrade + $tiisubmission->grade;
                     $gradescounted += 1;
                 }
             }
             $grade->grade = !is_null($averagegrade) && $gradescounted > 0 ? (int) ($averagegrade / $gradescounted) : null;
         } else {
             $grade->grade = $submission->getGrade();
         }
         // Check whether submission is a group submission - only applicable to assignment module.
         // If it's a group submission we will update the grade for everyone in the group.
         // Note: This will not work if the submitting user is in multiple groups.
         $userids = array($userid);
         $moduledata = $DB->get_record($cm->modname, array('id' => $cm->instance));
         if ($cm->modname == "assign" && !empty($moduledata->teamsubmission)) {
             require_once $CFG->dirroot . '/mod/assign/locallib.php';
             $context = context_course::instance($cm->course);
             $assignment = new assign($context, $cm, null);
             if ($group = $assignment->get_submission_group($userid)) {
                 $users = groups_get_members($group->id);
                 $userids = array_keys($users);
             }
         }
         // Loop through all users and update grade
         foreach ($userids as $userid) {
             // Get gradebook data.
             switch ($cm->modname) {
                 case 'assign':
                     // Query grades based on attempt number.
                     $gradesquery = array('userid' => $userid, 'assignment' => $cm->instance);
                     $attemptnumber = 0;
                     $usersubmissions = $DB->get_records('assign_submission', $gradesquery, 'attemptnumber DESC', 'attemptnumber', 0, 1);
                     $usersubmission = current($usersubmissions);
                     $attemptnumber = $usersubmission->attemptnumber;
                     $gradesquery['attemptnumber'] = $attemptnumber;
                     $currentgrades = $DB->get_records('assign_grades', $gradesquery, 'id DESC');
                     $currentgrade = current($currentgrades);
                     break;
                 case 'workshop':
                     if ($gradeitem = $DB->get_record('grade_items', array('iteminstance' => $cm->instance, 'itemmodule' => $cm->modname, 'itemnumber' => 0))) {
                         $currentgrade = $DB->get_record('grade_grades', array('userid' => $userid, 'itemid' => $gradeitem->id));
                     }
                     break;
             }
             // Create module object.
             $moduleclass = "turnitin_" . $cm->modname;
             $moduleobject = new $moduleclass();
             // Configure grade object and save to db.
             $table = $moduleobject->grades_table;
             $grade->timemodified = time();
             if ($currentgrade) {
                 $grade->id = $currentgrade->id;
                 $return = $DB->update_record($table, $grade);
             } else {
                 $grade->userid = $userid;
                 $grade->timecreated = time();
                 switch ($cm->modname) {
                     case 'workshop':
                         $grade->itemid = $gradeitem->id;
                         $grade->usermodified = $USER->id;
                         break;
                     case 'assign':
                         $grade->assignment = $cm->instance;
                         $grade->grader = $USER->id;
                         $grade->attemptnumber = $attemptnumber;
                         break;
                 }
                 $return = $DB->insert_record($table, $grade);
//.........这里部分代码省略.........
开发者ID:jmcgettrick,项目名称:moodle-plagiarism_turnitin,代码行数:101,代码来源:lib.php

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

示例6: tii_submission

 /**
  * If there is no submission record then we are creating one. Text content should be submitted.
  * If a file has already been submitted then check whether the identifier is the same, if it is do nothing.
  * If it's not then either edit submission or create new one depending on module settings.
  */
 public function tii_submission($cm, $tiiassignmentid, $user, $identifier, $submissiontype, $itemid = 0, $title = '', $textcontent = '', $context = 'instant')
 {
     global $CFG, $DB, $USER;
     $settings = $this->get_settings($cm->id);
     // Update user's details on Turnitin.
     $user->edit_tii_user();
     // Clean up old Turnitin submission files.
     if ($itemid != 0 && $submissiontype == 'file' && $cm->modname != 'forum') {
         $this->clean_old_turnitin_submissions($cm, $user->id, $itemid, $submissiontype, $identifier);
     }
     // Work out submission method.
     // If this file has successfully submitted in the past then break, text content is to be submitted.
     switch ($submissiontype) {
         case 'file':
         case 'text_content':
             // Get file data or prepare text submission.
             if ($submissiontype == 'file') {
                 $fs = get_file_storage();
                 $file = $fs->get_file_by_hash($identifier);
                 $title = $file->get_filename();
                 $timemodified = $file->get_timemodified();
                 $filename = $file->get_filename();
                 $textcontent = $file->get_content();
             } else {
                 // If we are submitting text_content via AJAX there will be no actual content passed in so we need to grab it.
                 if ($textcontent == '') {
                     switch ($cm->modname) {
                         case 'assign':
                             // Check whether submission is a group submission so we can get the correct content.
                             // Note: This will not work if the submitting user is in multiple groups.
                             $submissionsquery = array('assignment' => $cm->instance);
                             $submissionsquery['userid'] = $user->id;
                             if ($CFG->branch > 23) {
                                 $moduledata = $DB->get_record($cm->modname, array('id' => $cm->instance));
                                 if ($moduledata->teamsubmission) {
                                     require_once $CFG->dirroot . '/mod/assign/locallib.php';
                                     $context = context_course::instance($cm->course);
                                     $assignment = new assign($context, $cm, null);
                                     $submissionsquery['userid'] = 0;
                                     $submissionsquery['groupid'] = 0;
                                     if ($group = $assignment->get_submission_group($user->id)) {
                                         $submissionsquery['groupid'] = $group->id;
                                     }
                                 }
                             }
                             // This will need to be reworked when linkarray in get_links() contains submission id.
                             $moodlesubmissions = $DB->get_records('assign_submission', $submissionsquery, 'id, timemodified');
                             $moodlesubmission = end($moodlesubmissions);
                             $moodletextsubmission = $DB->get_record('assignsubmission_onlinetext', array('submission' => $moodlesubmission->id), 'onlinetext');
                             $timemodified = $moodlesubmission->timemodified;
                             $textcontent = strip_tags($moodletextsubmission->onlinetext);
                             break;
                         case 'workshop':
                             $moodlesubmission = $DB->get_record('workshop_submissions', array('workshopid' => $cm->instance, 'authorid' => $user->id), 'title, content, timemodified');
                             $timemodified = $moodlesubmission->timemodified;
                             $textcontent = strip_tags($moodlesubmission->content);
                             $title = $moodlesubmission->title;
                             break;
                     }
                 } else {
                     switch ($cm->modname) {
                         case 'assign':
                             $moodlesubmission = $DB->get_record('assign_submission', array('assignment' => $cm->instance, 'userid' => $user->id, 'id' => $itemid), 'id, timemodified');
                             $timemodified = $moodlesubmission->timemodified;
                             $textcontent = strip_tags($textcontent);
                             break;
                         case 'workshop':
                             $moodlesubmission = $DB->get_record('workshop_submissions', array('workshopid' => $cm->instance, 'authorid' => $user->id), 'title, content, timemodified');
                             $timemodified = $moodlesubmission->timemodified;
                             $textcontent = strip_tags($textcontent);
                             break;
                     }
                 }
                 $title = !empty($title) ? $title : 'onlinetext_' . $user->id . "_" . $cm->id . "_" . $cm->instance . '.txt';
                 $filename = substr($title, -4) == '.txt' ? $title : $title . '.txt';
             }
             // Get submission method depending on whether there has been a previous submission.
             $submissionfields = 'id, cm, externalid, identifier, statuscode, lastmodified, attempt, errorcode';
             $typefield = $CFG->dbtype == "oci" ? " to_char(submissiontype) " : " submissiontype ";
             // Double check there is only one submission.
             $previoussubmissions = $DB->get_records_select('plagiarism_turnitin_files', " cm = ? AND userid = ? AND " . $typefield . " = ? AND identifier = ? ", array($cm->id, $user->id, $submissiontype, $identifier), 'id', $submissionfields);
             $previoussubmission = end($previoussubmissions);
             if ($previoussubmission) {
                 $errorcode = (int) $previoussubmission->errorcode;
                 // Don't submit if submission hasn't changed.
                 if ($previoussubmission->statuscode == "success" && ($submissiontype == 'file' && $timemodified <= $previoussubmission->lastmodified || $submissiontype != 'file')) {
                     return true;
                 } else {
                     if ($previoussubmission->statuscode == "error" && $timemodified <= $previoussubmission->lastmodified) {
                         $return["success"] = false;
                         $return["message"] = get_string('errorcode' . $errorcode, 'turnitintooltwo');
                         return $return;
                     } else {
                         if ($previoussubmission->attempt >= 5) {
                             // Do not submit if 5 attempts have been made previously.
//.........这里部分代码省略.........
开发者ID:aolley,项目名称:MoodleDirectV2,代码行数:101,代码来源:lib.php


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