id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
215,000 | moodle/moodle | mod/assign/locallib.php | assign.get_all_submissions | public function get_all_submissions($userid) {
global $DB, $USER;
// If the userid is not null then use userid.
if (!$userid) {
$userid = $USER->id;
}
$params = array();
if ($this->get_instance()->teamsubmission) {
$groupid = 0;
$group = $this->get_submission_group($userid);
if ($group) {
$groupid = $group->id;
}
// Params to get the group submissions.
$params = array('assignment'=>$this->get_instance()->id, 'groupid'=>$groupid, 'userid'=>0);
} else {
// Params to get the user submissions.
$params = array('assignment'=>$this->get_instance()->id, 'userid'=>$userid);
}
// Return the submissions ordered by attempt.
$submissions = $DB->get_records('assign_submission', $params, 'attemptnumber ASC');
return $submissions;
} | php | public function get_all_submissions($userid) {
global $DB, $USER;
// If the userid is not null then use userid.
if (!$userid) {
$userid = $USER->id;
}
$params = array();
if ($this->get_instance()->teamsubmission) {
$groupid = 0;
$group = $this->get_submission_group($userid);
if ($group) {
$groupid = $group->id;
}
// Params to get the group submissions.
$params = array('assignment'=>$this->get_instance()->id, 'groupid'=>$groupid, 'userid'=>0);
} else {
// Params to get the user submissions.
$params = array('assignment'=>$this->get_instance()->id, 'userid'=>$userid);
}
// Return the submissions ordered by attempt.
$submissions = $DB->get_records('assign_submission', $params, 'attemptnumber ASC');
return $submissions;
} | [
"public",
"function",
"get_all_submissions",
"(",
"$",
"userid",
")",
"{",
"global",
"$",
"DB",
",",
"$",
"USER",
";",
"// If the userid is not null then use userid.",
"if",
"(",
"!",
"$",
"userid",
")",
"{",
"$",
"userid",
"=",
"$",
"USER",
"->",
"id",
";",
"}",
"$",
"params",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"teamsubmission",
")",
"{",
"$",
"groupid",
"=",
"0",
";",
"$",
"group",
"=",
"$",
"this",
"->",
"get_submission_group",
"(",
"$",
"userid",
")",
";",
"if",
"(",
"$",
"group",
")",
"{",
"$",
"groupid",
"=",
"$",
"group",
"->",
"id",
";",
"}",
"// Params to get the group submissions.",
"$",
"params",
"=",
"array",
"(",
"'assignment'",
"=>",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"id",
",",
"'groupid'",
"=>",
"$",
"groupid",
",",
"'userid'",
"=>",
"0",
")",
";",
"}",
"else",
"{",
"// Params to get the user submissions.",
"$",
"params",
"=",
"array",
"(",
"'assignment'",
"=>",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"id",
",",
"'userid'",
"=>",
"$",
"userid",
")",
";",
"}",
"// Return the submissions ordered by attempt.",
"$",
"submissions",
"=",
"$",
"DB",
"->",
"get_records",
"(",
"'assign_submission'",
",",
"$",
"params",
",",
"'attemptnumber ASC'",
")",
";",
"return",
"$",
"submissions",
";",
"}"
] | Get the submissions for all previous attempts.
@param int $userid If not set, $USER->id will be used.
@return array $submissions All submission records for this user (or group). | [
"Get",
"the",
"submissions",
"for",
"all",
"previous",
"attempts",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L5484-L5512 |
215,001 | moodle/moodle | mod/assign/locallib.php | assign.get_assign_grading_summary_renderable | public function get_assign_grading_summary_renderable($activitygroup = null) {
$instance = $this->get_instance();
$cm = $this->get_course_module();
$draft = ASSIGN_SUBMISSION_STATUS_DRAFT;
$submitted = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
$isvisible = $cm->visible;
if ($activitygroup === null) {
$activitygroup = groups_get_activity_group($cm);
}
if ($instance->teamsubmission) {
$defaultteammembers = $this->get_submission_group_members(0, true);
$warnofungroupedusers = (count($defaultteammembers) > 0 && $instance->preventsubmissionnotingroup);
$summary = new assign_grading_summary($this->count_teams($activitygroup),
$instance->submissiondrafts,
$this->count_submissions_with_status($draft, $activitygroup),
$this->is_any_submission_plugin_enabled(),
$this->count_submissions_with_status($submitted, $activitygroup),
$instance->cutoffdate,
$instance->duedate,
$this->get_course_module()->id,
$this->count_submissions_need_grading($activitygroup),
$instance->teamsubmission,
$warnofungroupedusers,
$this->can_grade(),
$isvisible);
} else {
// The active group has already been updated in groups_print_activity_menu().
$countparticipants = $this->count_participants($activitygroup);
$summary = new assign_grading_summary($countparticipants,
$instance->submissiondrafts,
$this->count_submissions_with_status($draft, $activitygroup),
$this->is_any_submission_plugin_enabled(),
$this->count_submissions_with_status($submitted, $activitygroup),
$instance->cutoffdate,
$instance->duedate,
$this->get_course_module()->id,
$this->count_submissions_need_grading($activitygroup),
$instance->teamsubmission,
false,
$this->can_grade(),
$isvisible);
}
return $summary;
} | php | public function get_assign_grading_summary_renderable($activitygroup = null) {
$instance = $this->get_instance();
$cm = $this->get_course_module();
$draft = ASSIGN_SUBMISSION_STATUS_DRAFT;
$submitted = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
$isvisible = $cm->visible;
if ($activitygroup === null) {
$activitygroup = groups_get_activity_group($cm);
}
if ($instance->teamsubmission) {
$defaultteammembers = $this->get_submission_group_members(0, true);
$warnofungroupedusers = (count($defaultteammembers) > 0 && $instance->preventsubmissionnotingroup);
$summary = new assign_grading_summary($this->count_teams($activitygroup),
$instance->submissiondrafts,
$this->count_submissions_with_status($draft, $activitygroup),
$this->is_any_submission_plugin_enabled(),
$this->count_submissions_with_status($submitted, $activitygroup),
$instance->cutoffdate,
$instance->duedate,
$this->get_course_module()->id,
$this->count_submissions_need_grading($activitygroup),
$instance->teamsubmission,
$warnofungroupedusers,
$this->can_grade(),
$isvisible);
} else {
// The active group has already been updated in groups_print_activity_menu().
$countparticipants = $this->count_participants($activitygroup);
$summary = new assign_grading_summary($countparticipants,
$instance->submissiondrafts,
$this->count_submissions_with_status($draft, $activitygroup),
$this->is_any_submission_plugin_enabled(),
$this->count_submissions_with_status($submitted, $activitygroup),
$instance->cutoffdate,
$instance->duedate,
$this->get_course_module()->id,
$this->count_submissions_need_grading($activitygroup),
$instance->teamsubmission,
false,
$this->can_grade(),
$isvisible);
}
return $summary;
} | [
"public",
"function",
"get_assign_grading_summary_renderable",
"(",
"$",
"activitygroup",
"=",
"null",
")",
"{",
"$",
"instance",
"=",
"$",
"this",
"->",
"get_instance",
"(",
")",
";",
"$",
"cm",
"=",
"$",
"this",
"->",
"get_course_module",
"(",
")",
";",
"$",
"draft",
"=",
"ASSIGN_SUBMISSION_STATUS_DRAFT",
";",
"$",
"submitted",
"=",
"ASSIGN_SUBMISSION_STATUS_SUBMITTED",
";",
"$",
"isvisible",
"=",
"$",
"cm",
"->",
"visible",
";",
"if",
"(",
"$",
"activitygroup",
"===",
"null",
")",
"{",
"$",
"activitygroup",
"=",
"groups_get_activity_group",
"(",
"$",
"cm",
")",
";",
"}",
"if",
"(",
"$",
"instance",
"->",
"teamsubmission",
")",
"{",
"$",
"defaultteammembers",
"=",
"$",
"this",
"->",
"get_submission_group_members",
"(",
"0",
",",
"true",
")",
";",
"$",
"warnofungroupedusers",
"=",
"(",
"count",
"(",
"$",
"defaultteammembers",
")",
">",
"0",
"&&",
"$",
"instance",
"->",
"preventsubmissionnotingroup",
")",
";",
"$",
"summary",
"=",
"new",
"assign_grading_summary",
"(",
"$",
"this",
"->",
"count_teams",
"(",
"$",
"activitygroup",
")",
",",
"$",
"instance",
"->",
"submissiondrafts",
",",
"$",
"this",
"->",
"count_submissions_with_status",
"(",
"$",
"draft",
",",
"$",
"activitygroup",
")",
",",
"$",
"this",
"->",
"is_any_submission_plugin_enabled",
"(",
")",
",",
"$",
"this",
"->",
"count_submissions_with_status",
"(",
"$",
"submitted",
",",
"$",
"activitygroup",
")",
",",
"$",
"instance",
"->",
"cutoffdate",
",",
"$",
"instance",
"->",
"duedate",
",",
"$",
"this",
"->",
"get_course_module",
"(",
")",
"->",
"id",
",",
"$",
"this",
"->",
"count_submissions_need_grading",
"(",
"$",
"activitygroup",
")",
",",
"$",
"instance",
"->",
"teamsubmission",
",",
"$",
"warnofungroupedusers",
",",
"$",
"this",
"->",
"can_grade",
"(",
")",
",",
"$",
"isvisible",
")",
";",
"}",
"else",
"{",
"// The active group has already been updated in groups_print_activity_menu().",
"$",
"countparticipants",
"=",
"$",
"this",
"->",
"count_participants",
"(",
"$",
"activitygroup",
")",
";",
"$",
"summary",
"=",
"new",
"assign_grading_summary",
"(",
"$",
"countparticipants",
",",
"$",
"instance",
"->",
"submissiondrafts",
",",
"$",
"this",
"->",
"count_submissions_with_status",
"(",
"$",
"draft",
",",
"$",
"activitygroup",
")",
",",
"$",
"this",
"->",
"is_any_submission_plugin_enabled",
"(",
")",
",",
"$",
"this",
"->",
"count_submissions_with_status",
"(",
"$",
"submitted",
",",
"$",
"activitygroup",
")",
",",
"$",
"instance",
"->",
"cutoffdate",
",",
"$",
"instance",
"->",
"duedate",
",",
"$",
"this",
"->",
"get_course_module",
"(",
")",
"->",
"id",
",",
"$",
"this",
"->",
"count_submissions_need_grading",
"(",
"$",
"activitygroup",
")",
",",
"$",
"instance",
"->",
"teamsubmission",
",",
"false",
",",
"$",
"this",
"->",
"can_grade",
"(",
")",
",",
"$",
"isvisible",
")",
";",
"}",
"return",
"$",
"summary",
";",
"}"
] | Creates an assign_grading_summary renderable.
@param mixed $activitygroup int|null the group for calculating the grading summary (if null the function will determine it)
@return assign_grading_summary renderable object | [
"Creates",
"an",
"assign_grading_summary",
"renderable",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L5520-L5569 |
215,002 | moodle/moodle | mod/assign/locallib.php | assign.convert_submission_for_gradebook | protected function convert_submission_for_gradebook(stdClass $submission) {
$gradebookgrade = array();
$gradebookgrade['userid'] = $submission->userid;
$gradebookgrade['usermodified'] = $submission->userid;
$gradebookgrade['datesubmitted'] = $submission->timemodified;
return $gradebookgrade;
} | php | protected function convert_submission_for_gradebook(stdClass $submission) {
$gradebookgrade = array();
$gradebookgrade['userid'] = $submission->userid;
$gradebookgrade['usermodified'] = $submission->userid;
$gradebookgrade['datesubmitted'] = $submission->timemodified;
return $gradebookgrade;
} | [
"protected",
"function",
"convert_submission_for_gradebook",
"(",
"stdClass",
"$",
"submission",
")",
"{",
"$",
"gradebookgrade",
"=",
"array",
"(",
")",
";",
"$",
"gradebookgrade",
"[",
"'userid'",
"]",
"=",
"$",
"submission",
"->",
"userid",
";",
"$",
"gradebookgrade",
"[",
"'usermodified'",
"]",
"=",
"$",
"submission",
"->",
"userid",
";",
"$",
"gradebookgrade",
"[",
"'datesubmitted'",
"]",
"=",
"$",
"submission",
"->",
"timemodified",
";",
"return",
"$",
"gradebookgrade",
";",
"}"
] | Convert submission details for the gradebook.
@param stdClass $submission
@return array | [
"Convert",
"submission",
"details",
"for",
"the",
"gradebook",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L5663-L5671 |
215,003 | moodle/moodle | mod/assign/locallib.php | assign.gradebook_item_update | protected function gradebook_item_update($submission=null, $grade=null) {
global $CFG;
require_once($CFG->dirroot.'/mod/assign/lib.php');
// Do not push grade to gradebook if blind marking is active as
// the gradebook would reveal the students.
if ($this->is_blind_marking()) {
return false;
}
// If marking workflow is enabled and grade is not released then remove any grade that may exist in the gradebook.
if ($this->get_instance()->markingworkflow && !empty($grade) &&
$this->get_grading_status($grade->userid) != ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
// Remove the grade (if it exists) from the gradebook as it is not 'final'.
$grade->grade = -1;
$grade->feedbacktext = '';
$grade->feebackfiles = [];
}
if ($submission != null) {
if ($submission->userid == 0) {
// This is a group submission update.
$team = groups_get_members($submission->groupid, 'u.id');
foreach ($team as $member) {
$membersubmission = clone $submission;
$membersubmission->groupid = 0;
$membersubmission->userid = $member->id;
$this->gradebook_item_update($membersubmission, null);
}
return;
}
$gradebookgrade = $this->convert_submission_for_gradebook($submission);
} else {
$gradebookgrade = $this->convert_grade_for_gradebook($grade);
}
// Grading is disabled, return.
if ($this->grading_disabled($gradebookgrade['userid'])) {
return false;
}
$assign = clone $this->get_instance();
$assign->cmidnumber = $this->get_course_module()->idnumber;
// Set assign gradebook feedback plugin status (enabled and visible).
$assign->gradefeedbackenabled = $this->is_gradebook_feedback_enabled();
return assign_grade_item_update($assign, $gradebookgrade) == GRADE_UPDATE_OK;
} | php | protected function gradebook_item_update($submission=null, $grade=null) {
global $CFG;
require_once($CFG->dirroot.'/mod/assign/lib.php');
// Do not push grade to gradebook if blind marking is active as
// the gradebook would reveal the students.
if ($this->is_blind_marking()) {
return false;
}
// If marking workflow is enabled and grade is not released then remove any grade that may exist in the gradebook.
if ($this->get_instance()->markingworkflow && !empty($grade) &&
$this->get_grading_status($grade->userid) != ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
// Remove the grade (if it exists) from the gradebook as it is not 'final'.
$grade->grade = -1;
$grade->feedbacktext = '';
$grade->feebackfiles = [];
}
if ($submission != null) {
if ($submission->userid == 0) {
// This is a group submission update.
$team = groups_get_members($submission->groupid, 'u.id');
foreach ($team as $member) {
$membersubmission = clone $submission;
$membersubmission->groupid = 0;
$membersubmission->userid = $member->id;
$this->gradebook_item_update($membersubmission, null);
}
return;
}
$gradebookgrade = $this->convert_submission_for_gradebook($submission);
} else {
$gradebookgrade = $this->convert_grade_for_gradebook($grade);
}
// Grading is disabled, return.
if ($this->grading_disabled($gradebookgrade['userid'])) {
return false;
}
$assign = clone $this->get_instance();
$assign->cmidnumber = $this->get_course_module()->idnumber;
// Set assign gradebook feedback plugin status (enabled and visible).
$assign->gradefeedbackenabled = $this->is_gradebook_feedback_enabled();
return assign_grade_item_update($assign, $gradebookgrade) == GRADE_UPDATE_OK;
} | [
"protected",
"function",
"gradebook_item_update",
"(",
"$",
"submission",
"=",
"null",
",",
"$",
"grade",
"=",
"null",
")",
"{",
"global",
"$",
"CFG",
";",
"require_once",
"(",
"$",
"CFG",
"->",
"dirroot",
".",
"'/mod/assign/lib.php'",
")",
";",
"// Do not push grade to gradebook if blind marking is active as",
"// the gradebook would reveal the students.",
"if",
"(",
"$",
"this",
"->",
"is_blind_marking",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"// If marking workflow is enabled and grade is not released then remove any grade that may exist in the gradebook.",
"if",
"(",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"markingworkflow",
"&&",
"!",
"empty",
"(",
"$",
"grade",
")",
"&&",
"$",
"this",
"->",
"get_grading_status",
"(",
"$",
"grade",
"->",
"userid",
")",
"!=",
"ASSIGN_MARKING_WORKFLOW_STATE_RELEASED",
")",
"{",
"// Remove the grade (if it exists) from the gradebook as it is not 'final'.",
"$",
"grade",
"->",
"grade",
"=",
"-",
"1",
";",
"$",
"grade",
"->",
"feedbacktext",
"=",
"''",
";",
"$",
"grade",
"->",
"feebackfiles",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"$",
"submission",
"!=",
"null",
")",
"{",
"if",
"(",
"$",
"submission",
"->",
"userid",
"==",
"0",
")",
"{",
"// This is a group submission update.",
"$",
"team",
"=",
"groups_get_members",
"(",
"$",
"submission",
"->",
"groupid",
",",
"'u.id'",
")",
";",
"foreach",
"(",
"$",
"team",
"as",
"$",
"member",
")",
"{",
"$",
"membersubmission",
"=",
"clone",
"$",
"submission",
";",
"$",
"membersubmission",
"->",
"groupid",
"=",
"0",
";",
"$",
"membersubmission",
"->",
"userid",
"=",
"$",
"member",
"->",
"id",
";",
"$",
"this",
"->",
"gradebook_item_update",
"(",
"$",
"membersubmission",
",",
"null",
")",
";",
"}",
"return",
";",
"}",
"$",
"gradebookgrade",
"=",
"$",
"this",
"->",
"convert_submission_for_gradebook",
"(",
"$",
"submission",
")",
";",
"}",
"else",
"{",
"$",
"gradebookgrade",
"=",
"$",
"this",
"->",
"convert_grade_for_gradebook",
"(",
"$",
"grade",
")",
";",
"}",
"// Grading is disabled, return.",
"if",
"(",
"$",
"this",
"->",
"grading_disabled",
"(",
"$",
"gradebookgrade",
"[",
"'userid'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"assign",
"=",
"clone",
"$",
"this",
"->",
"get_instance",
"(",
")",
";",
"$",
"assign",
"->",
"cmidnumber",
"=",
"$",
"this",
"->",
"get_course_module",
"(",
")",
"->",
"idnumber",
";",
"// Set assign gradebook feedback plugin status (enabled and visible).",
"$",
"assign",
"->",
"gradefeedbackenabled",
"=",
"$",
"this",
"->",
"is_gradebook_feedback_enabled",
"(",
")",
";",
"return",
"assign_grade_item_update",
"(",
"$",
"assign",
",",
"$",
"gradebookgrade",
")",
"==",
"GRADE_UPDATE_OK",
";",
"}"
] | Update grades in the gradebook.
@param mixed $submission stdClass|null
@param mixed $grade stdClass|null
@return bool | [
"Update",
"grades",
"in",
"the",
"gradebook",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L5680-L5727 |
215,004 | moodle/moodle | mod/assign/locallib.php | assign.update_team_submission | protected function update_team_submission(stdClass $submission, $userid, $updatetime) {
global $DB;
if ($updatetime) {
$submission->timemodified = time();
}
// First update the submission for the current user.
$mysubmission = $this->get_user_submission($userid, true, $submission->attemptnumber);
$mysubmission->status = $submission->status;
$this->update_submission($mysubmission, 0, $updatetime, false);
// Now check the team settings to see if this assignment qualifies as submitted or draft.
$team = $this->get_submission_group_members($submission->groupid, true);
$allsubmitted = true;
$anysubmitted = false;
$result = true;
if ($submission->status != ASSIGN_SUBMISSION_STATUS_REOPENED) {
foreach ($team as $member) {
$membersubmission = $this->get_user_submission($member->id, false, $submission->attemptnumber);
// If no submission found for team member and member is active then everyone has not submitted.
if (!$membersubmission || $membersubmission->status != ASSIGN_SUBMISSION_STATUS_SUBMITTED
&& ($this->is_active_user($member->id))) {
$allsubmitted = false;
if ($anysubmitted) {
break;
}
} else {
$anysubmitted = true;
}
}
if ($this->get_instance()->requireallteammemberssubmit) {
if ($allsubmitted) {
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
} else {
$submission->status = ASSIGN_SUBMISSION_STATUS_DRAFT;
}
$result = $DB->update_record('assign_submission', $submission);
} else {
if ($anysubmitted) {
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
} else {
$submission->status = ASSIGN_SUBMISSION_STATUS_DRAFT;
}
$result = $DB->update_record('assign_submission', $submission);
}
} else {
// Set the group submission to reopened.
foreach ($team as $member) {
$membersubmission = $this->get_user_submission($member->id, true, $submission->attemptnumber);
$membersubmission->status = ASSIGN_SUBMISSION_STATUS_REOPENED;
$result = $DB->update_record('assign_submission', $membersubmission) && $result;
}
$result = $DB->update_record('assign_submission', $submission) && $result;
}
$this->gradebook_item_update($submission);
return $result;
} | php | protected function update_team_submission(stdClass $submission, $userid, $updatetime) {
global $DB;
if ($updatetime) {
$submission->timemodified = time();
}
// First update the submission for the current user.
$mysubmission = $this->get_user_submission($userid, true, $submission->attemptnumber);
$mysubmission->status = $submission->status;
$this->update_submission($mysubmission, 0, $updatetime, false);
// Now check the team settings to see if this assignment qualifies as submitted or draft.
$team = $this->get_submission_group_members($submission->groupid, true);
$allsubmitted = true;
$anysubmitted = false;
$result = true;
if ($submission->status != ASSIGN_SUBMISSION_STATUS_REOPENED) {
foreach ($team as $member) {
$membersubmission = $this->get_user_submission($member->id, false, $submission->attemptnumber);
// If no submission found for team member and member is active then everyone has not submitted.
if (!$membersubmission || $membersubmission->status != ASSIGN_SUBMISSION_STATUS_SUBMITTED
&& ($this->is_active_user($member->id))) {
$allsubmitted = false;
if ($anysubmitted) {
break;
}
} else {
$anysubmitted = true;
}
}
if ($this->get_instance()->requireallteammemberssubmit) {
if ($allsubmitted) {
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
} else {
$submission->status = ASSIGN_SUBMISSION_STATUS_DRAFT;
}
$result = $DB->update_record('assign_submission', $submission);
} else {
if ($anysubmitted) {
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
} else {
$submission->status = ASSIGN_SUBMISSION_STATUS_DRAFT;
}
$result = $DB->update_record('assign_submission', $submission);
}
} else {
// Set the group submission to reopened.
foreach ($team as $member) {
$membersubmission = $this->get_user_submission($member->id, true, $submission->attemptnumber);
$membersubmission->status = ASSIGN_SUBMISSION_STATUS_REOPENED;
$result = $DB->update_record('assign_submission', $membersubmission) && $result;
}
$result = $DB->update_record('assign_submission', $submission) && $result;
}
$this->gradebook_item_update($submission);
return $result;
} | [
"protected",
"function",
"update_team_submission",
"(",
"stdClass",
"$",
"submission",
",",
"$",
"userid",
",",
"$",
"updatetime",
")",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"$",
"updatetime",
")",
"{",
"$",
"submission",
"->",
"timemodified",
"=",
"time",
"(",
")",
";",
"}",
"// First update the submission for the current user.",
"$",
"mysubmission",
"=",
"$",
"this",
"->",
"get_user_submission",
"(",
"$",
"userid",
",",
"true",
",",
"$",
"submission",
"->",
"attemptnumber",
")",
";",
"$",
"mysubmission",
"->",
"status",
"=",
"$",
"submission",
"->",
"status",
";",
"$",
"this",
"->",
"update_submission",
"(",
"$",
"mysubmission",
",",
"0",
",",
"$",
"updatetime",
",",
"false",
")",
";",
"// Now check the team settings to see if this assignment qualifies as submitted or draft.",
"$",
"team",
"=",
"$",
"this",
"->",
"get_submission_group_members",
"(",
"$",
"submission",
"->",
"groupid",
",",
"true",
")",
";",
"$",
"allsubmitted",
"=",
"true",
";",
"$",
"anysubmitted",
"=",
"false",
";",
"$",
"result",
"=",
"true",
";",
"if",
"(",
"$",
"submission",
"->",
"status",
"!=",
"ASSIGN_SUBMISSION_STATUS_REOPENED",
")",
"{",
"foreach",
"(",
"$",
"team",
"as",
"$",
"member",
")",
"{",
"$",
"membersubmission",
"=",
"$",
"this",
"->",
"get_user_submission",
"(",
"$",
"member",
"->",
"id",
",",
"false",
",",
"$",
"submission",
"->",
"attemptnumber",
")",
";",
"// If no submission found for team member and member is active then everyone has not submitted.",
"if",
"(",
"!",
"$",
"membersubmission",
"||",
"$",
"membersubmission",
"->",
"status",
"!=",
"ASSIGN_SUBMISSION_STATUS_SUBMITTED",
"&&",
"(",
"$",
"this",
"->",
"is_active_user",
"(",
"$",
"member",
"->",
"id",
")",
")",
")",
"{",
"$",
"allsubmitted",
"=",
"false",
";",
"if",
"(",
"$",
"anysubmitted",
")",
"{",
"break",
";",
"}",
"}",
"else",
"{",
"$",
"anysubmitted",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"requireallteammemberssubmit",
")",
"{",
"if",
"(",
"$",
"allsubmitted",
")",
"{",
"$",
"submission",
"->",
"status",
"=",
"ASSIGN_SUBMISSION_STATUS_SUBMITTED",
";",
"}",
"else",
"{",
"$",
"submission",
"->",
"status",
"=",
"ASSIGN_SUBMISSION_STATUS_DRAFT",
";",
"}",
"$",
"result",
"=",
"$",
"DB",
"->",
"update_record",
"(",
"'assign_submission'",
",",
"$",
"submission",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"anysubmitted",
")",
"{",
"$",
"submission",
"->",
"status",
"=",
"ASSIGN_SUBMISSION_STATUS_SUBMITTED",
";",
"}",
"else",
"{",
"$",
"submission",
"->",
"status",
"=",
"ASSIGN_SUBMISSION_STATUS_DRAFT",
";",
"}",
"$",
"result",
"=",
"$",
"DB",
"->",
"update_record",
"(",
"'assign_submission'",
",",
"$",
"submission",
")",
";",
"}",
"}",
"else",
"{",
"// Set the group submission to reopened.",
"foreach",
"(",
"$",
"team",
"as",
"$",
"member",
")",
"{",
"$",
"membersubmission",
"=",
"$",
"this",
"->",
"get_user_submission",
"(",
"$",
"member",
"->",
"id",
",",
"true",
",",
"$",
"submission",
"->",
"attemptnumber",
")",
";",
"$",
"membersubmission",
"->",
"status",
"=",
"ASSIGN_SUBMISSION_STATUS_REOPENED",
";",
"$",
"result",
"=",
"$",
"DB",
"->",
"update_record",
"(",
"'assign_submission'",
",",
"$",
"membersubmission",
")",
"&&",
"$",
"result",
";",
"}",
"$",
"result",
"=",
"$",
"DB",
"->",
"update_record",
"(",
"'assign_submission'",
",",
"$",
"submission",
")",
"&&",
"$",
"result",
";",
"}",
"$",
"this",
"->",
"gradebook_item_update",
"(",
"$",
"submission",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Update team submission.
@param stdClass $submission
@param int $userid
@param bool $updatetime
@return bool | [
"Update",
"team",
"submission",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L5737-L5798 |
215,005 | moodle/moodle | mod/assign/locallib.php | assign.update_submission | protected function update_submission(stdClass $submission, $userid, $updatetime, $teamsubmission) {
global $DB;
if ($teamsubmission) {
return $this->update_team_submission($submission, $userid, $updatetime);
}
if ($updatetime) {
$submission->timemodified = time();
}
$result= $DB->update_record('assign_submission', $submission);
if ($result) {
$this->gradebook_item_update($submission);
}
return $result;
} | php | protected function update_submission(stdClass $submission, $userid, $updatetime, $teamsubmission) {
global $DB;
if ($teamsubmission) {
return $this->update_team_submission($submission, $userid, $updatetime);
}
if ($updatetime) {
$submission->timemodified = time();
}
$result= $DB->update_record('assign_submission', $submission);
if ($result) {
$this->gradebook_item_update($submission);
}
return $result;
} | [
"protected",
"function",
"update_submission",
"(",
"stdClass",
"$",
"submission",
",",
"$",
"userid",
",",
"$",
"updatetime",
",",
"$",
"teamsubmission",
")",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"$",
"teamsubmission",
")",
"{",
"return",
"$",
"this",
"->",
"update_team_submission",
"(",
"$",
"submission",
",",
"$",
"userid",
",",
"$",
"updatetime",
")",
";",
"}",
"if",
"(",
"$",
"updatetime",
")",
"{",
"$",
"submission",
"->",
"timemodified",
"=",
"time",
"(",
")",
";",
"}",
"$",
"result",
"=",
"$",
"DB",
"->",
"update_record",
"(",
"'assign_submission'",
",",
"$",
"submission",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"gradebook_item_update",
"(",
"$",
"submission",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Update grades in the gradebook based on submission time.
@param stdClass $submission
@param int $userid
@param bool $updatetime
@param bool $teamsubmission
@return bool | [
"Update",
"grades",
"in",
"the",
"gradebook",
"based",
"on",
"submission",
"time",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L5809-L5824 |
215,006 | moodle/moodle | mod/assign/locallib.php | assign.submissions_open | public function submissions_open($userid = 0,
$skipenrolled = false,
$submission = false,
$flags = false,
$gradinginfo = false) {
global $USER;
if (!$userid) {
$userid = $USER->id;
}
$time = time();
$dateopen = true;
$finaldate = false;
if ($this->get_instance()->cutoffdate) {
$finaldate = $this->get_instance()->cutoffdate;
}
if ($flags === false) {
$flags = $this->get_user_flags($userid, false);
}
if ($flags && $flags->locked) {
return false;
}
// User extensions.
if ($finaldate) {
if ($flags && $flags->extensionduedate) {
// Extension can be before cut off date.
if ($flags->extensionduedate > $finaldate) {
$finaldate = $flags->extensionduedate;
}
}
}
if ($finaldate) {
$dateopen = ($this->get_instance()->allowsubmissionsfromdate <= $time && $time <= $finaldate);
} else {
$dateopen = ($this->get_instance()->allowsubmissionsfromdate <= $time);
}
if (!$dateopen) {
return false;
}
// Now check if this user has already submitted etc.
if (!$skipenrolled && !is_enrolled($this->get_course_context(), $userid)) {
return false;
}
// Note you can pass null for submission and it will not be fetched.
if ($submission === false) {
if ($this->get_instance()->teamsubmission) {
$submission = $this->get_group_submission($userid, 0, false);
} else {
$submission = $this->get_user_submission($userid, false);
}
}
if ($submission) {
if ($this->get_instance()->submissiondrafts && $submission->status == ASSIGN_SUBMISSION_STATUS_SUBMITTED) {
// Drafts are tracked and the student has submitted the assignment.
return false;
}
}
// See if this user grade is locked in the gradebook.
if ($gradinginfo === false) {
$gradinginfo = grade_get_grades($this->get_course()->id,
'mod',
'assign',
$this->get_instance()->id,
array($userid));
}
if ($gradinginfo &&
isset($gradinginfo->items[0]->grades[$userid]) &&
$gradinginfo->items[0]->grades[$userid]->locked) {
return false;
}
return true;
} | php | public function submissions_open($userid = 0,
$skipenrolled = false,
$submission = false,
$flags = false,
$gradinginfo = false) {
global $USER;
if (!$userid) {
$userid = $USER->id;
}
$time = time();
$dateopen = true;
$finaldate = false;
if ($this->get_instance()->cutoffdate) {
$finaldate = $this->get_instance()->cutoffdate;
}
if ($flags === false) {
$flags = $this->get_user_flags($userid, false);
}
if ($flags && $flags->locked) {
return false;
}
// User extensions.
if ($finaldate) {
if ($flags && $flags->extensionduedate) {
// Extension can be before cut off date.
if ($flags->extensionduedate > $finaldate) {
$finaldate = $flags->extensionduedate;
}
}
}
if ($finaldate) {
$dateopen = ($this->get_instance()->allowsubmissionsfromdate <= $time && $time <= $finaldate);
} else {
$dateopen = ($this->get_instance()->allowsubmissionsfromdate <= $time);
}
if (!$dateopen) {
return false;
}
// Now check if this user has already submitted etc.
if (!$skipenrolled && !is_enrolled($this->get_course_context(), $userid)) {
return false;
}
// Note you can pass null for submission and it will not be fetched.
if ($submission === false) {
if ($this->get_instance()->teamsubmission) {
$submission = $this->get_group_submission($userid, 0, false);
} else {
$submission = $this->get_user_submission($userid, false);
}
}
if ($submission) {
if ($this->get_instance()->submissiondrafts && $submission->status == ASSIGN_SUBMISSION_STATUS_SUBMITTED) {
// Drafts are tracked and the student has submitted the assignment.
return false;
}
}
// See if this user grade is locked in the gradebook.
if ($gradinginfo === false) {
$gradinginfo = grade_get_grades($this->get_course()->id,
'mod',
'assign',
$this->get_instance()->id,
array($userid));
}
if ($gradinginfo &&
isset($gradinginfo->items[0]->grades[$userid]) &&
$gradinginfo->items[0]->grades[$userid]->locked) {
return false;
}
return true;
} | [
"public",
"function",
"submissions_open",
"(",
"$",
"userid",
"=",
"0",
",",
"$",
"skipenrolled",
"=",
"false",
",",
"$",
"submission",
"=",
"false",
",",
"$",
"flags",
"=",
"false",
",",
"$",
"gradinginfo",
"=",
"false",
")",
"{",
"global",
"$",
"USER",
";",
"if",
"(",
"!",
"$",
"userid",
")",
"{",
"$",
"userid",
"=",
"$",
"USER",
"->",
"id",
";",
"}",
"$",
"time",
"=",
"time",
"(",
")",
";",
"$",
"dateopen",
"=",
"true",
";",
"$",
"finaldate",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"cutoffdate",
")",
"{",
"$",
"finaldate",
"=",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"cutoffdate",
";",
"}",
"if",
"(",
"$",
"flags",
"===",
"false",
")",
"{",
"$",
"flags",
"=",
"$",
"this",
"->",
"get_user_flags",
"(",
"$",
"userid",
",",
"false",
")",
";",
"}",
"if",
"(",
"$",
"flags",
"&&",
"$",
"flags",
"->",
"locked",
")",
"{",
"return",
"false",
";",
"}",
"// User extensions.",
"if",
"(",
"$",
"finaldate",
")",
"{",
"if",
"(",
"$",
"flags",
"&&",
"$",
"flags",
"->",
"extensionduedate",
")",
"{",
"// Extension can be before cut off date.",
"if",
"(",
"$",
"flags",
"->",
"extensionduedate",
">",
"$",
"finaldate",
")",
"{",
"$",
"finaldate",
"=",
"$",
"flags",
"->",
"extensionduedate",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"finaldate",
")",
"{",
"$",
"dateopen",
"=",
"(",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"allowsubmissionsfromdate",
"<=",
"$",
"time",
"&&",
"$",
"time",
"<=",
"$",
"finaldate",
")",
";",
"}",
"else",
"{",
"$",
"dateopen",
"=",
"(",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"allowsubmissionsfromdate",
"<=",
"$",
"time",
")",
";",
"}",
"if",
"(",
"!",
"$",
"dateopen",
")",
"{",
"return",
"false",
";",
"}",
"// Now check if this user has already submitted etc.",
"if",
"(",
"!",
"$",
"skipenrolled",
"&&",
"!",
"is_enrolled",
"(",
"$",
"this",
"->",
"get_course_context",
"(",
")",
",",
"$",
"userid",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Note you can pass null for submission and it will not be fetched.",
"if",
"(",
"$",
"submission",
"===",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"teamsubmission",
")",
"{",
"$",
"submission",
"=",
"$",
"this",
"->",
"get_group_submission",
"(",
"$",
"userid",
",",
"0",
",",
"false",
")",
";",
"}",
"else",
"{",
"$",
"submission",
"=",
"$",
"this",
"->",
"get_user_submission",
"(",
"$",
"userid",
",",
"false",
")",
";",
"}",
"}",
"if",
"(",
"$",
"submission",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"submissiondrafts",
"&&",
"$",
"submission",
"->",
"status",
"==",
"ASSIGN_SUBMISSION_STATUS_SUBMITTED",
")",
"{",
"// Drafts are tracked and the student has submitted the assignment.",
"return",
"false",
";",
"}",
"}",
"// See if this user grade is locked in the gradebook.",
"if",
"(",
"$",
"gradinginfo",
"===",
"false",
")",
"{",
"$",
"gradinginfo",
"=",
"grade_get_grades",
"(",
"$",
"this",
"->",
"get_course",
"(",
")",
"->",
"id",
",",
"'mod'",
",",
"'assign'",
",",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"id",
",",
"array",
"(",
"$",
"userid",
")",
")",
";",
"}",
"if",
"(",
"$",
"gradinginfo",
"&&",
"isset",
"(",
"$",
"gradinginfo",
"->",
"items",
"[",
"0",
"]",
"->",
"grades",
"[",
"$",
"userid",
"]",
")",
"&&",
"$",
"gradinginfo",
"->",
"items",
"[",
"0",
"]",
"->",
"grades",
"[",
"$",
"userid",
"]",
"->",
"locked",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Is this assignment open for submissions?
Check the due date,
prevent late submissions,
has this person already submitted,
is the assignment locked?
@param int $userid - Optional userid so we can see if a different user can submit
@param bool $skipenrolled - Skip enrollment checks (because they have been done already)
@param stdClass $submission - Pre-fetched submission record (or false to fetch it)
@param stdClass $flags - Pre-fetched user flags record (or false to fetch it)
@param stdClass $gradinginfo - Pre-fetched user gradinginfo record (or false to fetch it)
@return bool | [
"Is",
"this",
"assignment",
"open",
"for",
"submissions?"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L5841-L5921 |
215,007 | moodle/moodle | mod/assign/locallib.php | assign.render_area_files | public function render_area_files($component, $area, $submissionid) {
global $USER;
return $this->get_renderer()->assign_files($this->context, $submissionid, $area, $component);
} | php | public function render_area_files($component, $area, $submissionid) {
global $USER;
return $this->get_renderer()->assign_files($this->context, $submissionid, $area, $component);
} | [
"public",
"function",
"render_area_files",
"(",
"$",
"component",
",",
"$",
"area",
",",
"$",
"submissionid",
")",
"{",
"global",
"$",
"USER",
";",
"return",
"$",
"this",
"->",
"get_renderer",
"(",
")",
"->",
"assign_files",
"(",
"$",
"this",
"->",
"context",
",",
"$",
"submissionid",
",",
"$",
"area",
",",
"$",
"component",
")",
";",
"}"
] | Render the files in file area.
@param string $component
@param string $area
@param int $submissionid
@return string | [
"Render",
"the",
"files",
"in",
"file",
"area",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L5931-L5936 |
215,008 | moodle/moodle | mod/assign/locallib.php | assign.can_edit_submission | public function can_edit_submission($userid, $graderid = 0) {
global $USER;
if (empty($graderid)) {
$graderid = $USER->id;
}
$instance = $this->get_instance();
if ($userid == $graderid &&
$instance->teamsubmission &&
$instance->preventsubmissionnotingroup &&
$this->get_submission_group($userid) == false) {
return false;
}
if ($userid == $graderid) {
if ($this->submissions_open($userid) &&
has_capability('mod/assign:submit', $this->context, $graderid)) {
// User can edit their own submission.
return true;
} else {
// We need to return here because editothersubmission should never apply to a users own submission.
return false;
}
}
if (!has_capability('mod/assign:editothersubmission', $this->context, $graderid)) {
return false;
}
$cm = $this->get_course_module();
if (groups_get_activity_groupmode($cm) == SEPARATEGROUPS) {
$sharedgroupmembers = $this->get_shared_group_members($cm, $graderid);
return in_array($userid, $sharedgroupmembers);
}
return true;
} | php | public function can_edit_submission($userid, $graderid = 0) {
global $USER;
if (empty($graderid)) {
$graderid = $USER->id;
}
$instance = $this->get_instance();
if ($userid == $graderid &&
$instance->teamsubmission &&
$instance->preventsubmissionnotingroup &&
$this->get_submission_group($userid) == false) {
return false;
}
if ($userid == $graderid) {
if ($this->submissions_open($userid) &&
has_capability('mod/assign:submit', $this->context, $graderid)) {
// User can edit their own submission.
return true;
} else {
// We need to return here because editothersubmission should never apply to a users own submission.
return false;
}
}
if (!has_capability('mod/assign:editothersubmission', $this->context, $graderid)) {
return false;
}
$cm = $this->get_course_module();
if (groups_get_activity_groupmode($cm) == SEPARATEGROUPS) {
$sharedgroupmembers = $this->get_shared_group_members($cm, $graderid);
return in_array($userid, $sharedgroupmembers);
}
return true;
} | [
"public",
"function",
"can_edit_submission",
"(",
"$",
"userid",
",",
"$",
"graderid",
"=",
"0",
")",
"{",
"global",
"$",
"USER",
";",
"if",
"(",
"empty",
"(",
"$",
"graderid",
")",
")",
"{",
"$",
"graderid",
"=",
"$",
"USER",
"->",
"id",
";",
"}",
"$",
"instance",
"=",
"$",
"this",
"->",
"get_instance",
"(",
")",
";",
"if",
"(",
"$",
"userid",
"==",
"$",
"graderid",
"&&",
"$",
"instance",
"->",
"teamsubmission",
"&&",
"$",
"instance",
"->",
"preventsubmissionnotingroup",
"&&",
"$",
"this",
"->",
"get_submission_group",
"(",
"$",
"userid",
")",
"==",
"false",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"userid",
"==",
"$",
"graderid",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"submissions_open",
"(",
"$",
"userid",
")",
"&&",
"has_capability",
"(",
"'mod/assign:submit'",
",",
"$",
"this",
"->",
"context",
",",
"$",
"graderid",
")",
")",
"{",
"// User can edit their own submission.",
"return",
"true",
";",
"}",
"else",
"{",
"// We need to return here because editothersubmission should never apply to a users own submission.",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"!",
"has_capability",
"(",
"'mod/assign:editothersubmission'",
",",
"$",
"this",
"->",
"context",
",",
"$",
"graderid",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"cm",
"=",
"$",
"this",
"->",
"get_course_module",
"(",
")",
";",
"if",
"(",
"groups_get_activity_groupmode",
"(",
"$",
"cm",
")",
"==",
"SEPARATEGROUPS",
")",
"{",
"$",
"sharedgroupmembers",
"=",
"$",
"this",
"->",
"get_shared_group_members",
"(",
"$",
"cm",
",",
"$",
"graderid",
")",
";",
"return",
"in_array",
"(",
"$",
"userid",
",",
"$",
"sharedgroupmembers",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Capability check to make sure this grader can edit this submission.
@param int $userid - The user whose submission is to be edited
@param int $graderid (optional) - The user who will do the editing (default to $USER->id).
@return bool | [
"Capability",
"check",
"to",
"make",
"sure",
"this",
"grader",
"can",
"edit",
"this",
"submission",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L5945-L5981 |
215,009 | moodle/moodle | mod/assign/locallib.php | assign.get_shared_group_members | public function get_shared_group_members($cm, $userid) {
if (!isset($this->sharedgroupmembers[$userid])) {
$this->sharedgroupmembers[$userid] = array();
if ($members = groups_get_activity_shared_group_members($cm, $userid)) {
$this->sharedgroupmembers[$userid] = array_keys($members);
}
}
return $this->sharedgroupmembers[$userid];
} | php | public function get_shared_group_members($cm, $userid) {
if (!isset($this->sharedgroupmembers[$userid])) {
$this->sharedgroupmembers[$userid] = array();
if ($members = groups_get_activity_shared_group_members($cm, $userid)) {
$this->sharedgroupmembers[$userid] = array_keys($members);
}
}
return $this->sharedgroupmembers[$userid];
} | [
"public",
"function",
"get_shared_group_members",
"(",
"$",
"cm",
",",
"$",
"userid",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"sharedgroupmembers",
"[",
"$",
"userid",
"]",
")",
")",
"{",
"$",
"this",
"->",
"sharedgroupmembers",
"[",
"$",
"userid",
"]",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"members",
"=",
"groups_get_activity_shared_group_members",
"(",
"$",
"cm",
",",
"$",
"userid",
")",
")",
"{",
"$",
"this",
"->",
"sharedgroupmembers",
"[",
"$",
"userid",
"]",
"=",
"array_keys",
"(",
"$",
"members",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"sharedgroupmembers",
"[",
"$",
"userid",
"]",
";",
"}"
] | Returns IDs of the users who share group membership with the specified user.
@param stdClass|cm_info $cm Course-module
@param int $userid User ID
@return array An array of ID of users. | [
"Returns",
"IDs",
"of",
"the",
"users",
"who",
"share",
"group",
"membership",
"with",
"the",
"specified",
"user",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L5990-L5999 |
215,010 | moodle/moodle | mod/assign/locallib.php | assign.get_graders | protected function get_graders($userid) {
// Potential graders should be active users only.
$potentialgraders = get_enrolled_users($this->context, "mod/assign:grade", null, 'u.*', null, null, null, true);
$graders = array();
if (groups_get_activity_groupmode($this->get_course_module()) == SEPARATEGROUPS) {
if ($groups = groups_get_all_groups($this->get_course()->id, $userid, $this->get_course_module()->groupingid)) {
foreach ($groups as $group) {
foreach ($potentialgraders as $grader) {
if ($grader->id == $userid) {
// Do not send self.
continue;
}
if (groups_is_member($group->id, $grader->id)) {
$graders[$grader->id] = $grader;
}
}
}
} else {
// User not in group, try to find graders without group.
foreach ($potentialgraders as $grader) {
if ($grader->id == $userid) {
// Do not send self.
continue;
}
if (!groups_has_membership($this->get_course_module(), $grader->id)) {
$graders[$grader->id] = $grader;
}
}
}
} else {
foreach ($potentialgraders as $grader) {
if ($grader->id == $userid) {
// Do not send self.
continue;
}
// Must be enrolled.
if (is_enrolled($this->get_course_context(), $grader->id)) {
$graders[$grader->id] = $grader;
}
}
}
return $graders;
} | php | protected function get_graders($userid) {
// Potential graders should be active users only.
$potentialgraders = get_enrolled_users($this->context, "mod/assign:grade", null, 'u.*', null, null, null, true);
$graders = array();
if (groups_get_activity_groupmode($this->get_course_module()) == SEPARATEGROUPS) {
if ($groups = groups_get_all_groups($this->get_course()->id, $userid, $this->get_course_module()->groupingid)) {
foreach ($groups as $group) {
foreach ($potentialgraders as $grader) {
if ($grader->id == $userid) {
// Do not send self.
continue;
}
if (groups_is_member($group->id, $grader->id)) {
$graders[$grader->id] = $grader;
}
}
}
} else {
// User not in group, try to find graders without group.
foreach ($potentialgraders as $grader) {
if ($grader->id == $userid) {
// Do not send self.
continue;
}
if (!groups_has_membership($this->get_course_module(), $grader->id)) {
$graders[$grader->id] = $grader;
}
}
}
} else {
foreach ($potentialgraders as $grader) {
if ($grader->id == $userid) {
// Do not send self.
continue;
}
// Must be enrolled.
if (is_enrolled($this->get_course_context(), $grader->id)) {
$graders[$grader->id] = $grader;
}
}
}
return $graders;
} | [
"protected",
"function",
"get_graders",
"(",
"$",
"userid",
")",
"{",
"// Potential graders should be active users only.",
"$",
"potentialgraders",
"=",
"get_enrolled_users",
"(",
"$",
"this",
"->",
"context",
",",
"\"mod/assign:grade\"",
",",
"null",
",",
"'u.*'",
",",
"null",
",",
"null",
",",
"null",
",",
"true",
")",
";",
"$",
"graders",
"=",
"array",
"(",
")",
";",
"if",
"(",
"groups_get_activity_groupmode",
"(",
"$",
"this",
"->",
"get_course_module",
"(",
")",
")",
"==",
"SEPARATEGROUPS",
")",
"{",
"if",
"(",
"$",
"groups",
"=",
"groups_get_all_groups",
"(",
"$",
"this",
"->",
"get_course",
"(",
")",
"->",
"id",
",",
"$",
"userid",
",",
"$",
"this",
"->",
"get_course_module",
"(",
")",
"->",
"groupingid",
")",
")",
"{",
"foreach",
"(",
"$",
"groups",
"as",
"$",
"group",
")",
"{",
"foreach",
"(",
"$",
"potentialgraders",
"as",
"$",
"grader",
")",
"{",
"if",
"(",
"$",
"grader",
"->",
"id",
"==",
"$",
"userid",
")",
"{",
"// Do not send self.",
"continue",
";",
"}",
"if",
"(",
"groups_is_member",
"(",
"$",
"group",
"->",
"id",
",",
"$",
"grader",
"->",
"id",
")",
")",
"{",
"$",
"graders",
"[",
"$",
"grader",
"->",
"id",
"]",
"=",
"$",
"grader",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"// User not in group, try to find graders without group.",
"foreach",
"(",
"$",
"potentialgraders",
"as",
"$",
"grader",
")",
"{",
"if",
"(",
"$",
"grader",
"->",
"id",
"==",
"$",
"userid",
")",
"{",
"// Do not send self.",
"continue",
";",
"}",
"if",
"(",
"!",
"groups_has_membership",
"(",
"$",
"this",
"->",
"get_course_module",
"(",
")",
",",
"$",
"grader",
"->",
"id",
")",
")",
"{",
"$",
"graders",
"[",
"$",
"grader",
"->",
"id",
"]",
"=",
"$",
"grader",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"potentialgraders",
"as",
"$",
"grader",
")",
"{",
"if",
"(",
"$",
"grader",
"->",
"id",
"==",
"$",
"userid",
")",
"{",
"// Do not send self.",
"continue",
";",
"}",
"// Must be enrolled.",
"if",
"(",
"is_enrolled",
"(",
"$",
"this",
"->",
"get_course_context",
"(",
")",
",",
"$",
"grader",
"->",
"id",
")",
")",
"{",
"$",
"graders",
"[",
"$",
"grader",
"->",
"id",
"]",
"=",
"$",
"grader",
";",
"}",
"}",
"}",
"return",
"$",
"graders",
";",
"}"
] | Returns a list of teachers that should be grading given submission.
@param int $userid The submission to grade
@return array | [
"Returns",
"a",
"list",
"of",
"teachers",
"that",
"should",
"be",
"grading",
"given",
"submission",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L6007-L6050 |
215,011 | moodle/moodle | mod/assign/locallib.php | assign.get_notifiable_users | protected function get_notifiable_users($userid) {
// Potential users should be active users only.
$potentialusers = get_enrolled_users($this->context, "mod/assign:receivegradernotifications",
null, 'u.*', null, null, null, true);
$notifiableusers = array();
if (groups_get_activity_groupmode($this->get_course_module()) == SEPARATEGROUPS) {
if ($groups = groups_get_all_groups($this->get_course()->id, $userid, $this->get_course_module()->groupingid)) {
foreach ($groups as $group) {
foreach ($potentialusers as $potentialuser) {
if ($potentialuser->id == $userid) {
// Do not send self.
continue;
}
if (groups_is_member($group->id, $potentialuser->id)) {
$notifiableusers[$potentialuser->id] = $potentialuser;
}
}
}
} else {
// User not in group, try to find graders without group.
foreach ($potentialusers as $potentialuser) {
if ($potentialuser->id == $userid) {
// Do not send self.
continue;
}
if (!groups_has_membership($this->get_course_module(), $potentialuser->id)) {
$notifiableusers[$potentialuser->id] = $potentialuser;
}
}
}
} else {
foreach ($potentialusers as $potentialuser) {
if ($potentialuser->id == $userid) {
// Do not send self.
continue;
}
// Must be enrolled.
if (is_enrolled($this->get_course_context(), $potentialuser->id)) {
$notifiableusers[$potentialuser->id] = $potentialuser;
}
}
}
return $notifiableusers;
} | php | protected function get_notifiable_users($userid) {
// Potential users should be active users only.
$potentialusers = get_enrolled_users($this->context, "mod/assign:receivegradernotifications",
null, 'u.*', null, null, null, true);
$notifiableusers = array();
if (groups_get_activity_groupmode($this->get_course_module()) == SEPARATEGROUPS) {
if ($groups = groups_get_all_groups($this->get_course()->id, $userid, $this->get_course_module()->groupingid)) {
foreach ($groups as $group) {
foreach ($potentialusers as $potentialuser) {
if ($potentialuser->id == $userid) {
// Do not send self.
continue;
}
if (groups_is_member($group->id, $potentialuser->id)) {
$notifiableusers[$potentialuser->id] = $potentialuser;
}
}
}
} else {
// User not in group, try to find graders without group.
foreach ($potentialusers as $potentialuser) {
if ($potentialuser->id == $userid) {
// Do not send self.
continue;
}
if (!groups_has_membership($this->get_course_module(), $potentialuser->id)) {
$notifiableusers[$potentialuser->id] = $potentialuser;
}
}
}
} else {
foreach ($potentialusers as $potentialuser) {
if ($potentialuser->id == $userid) {
// Do not send self.
continue;
}
// Must be enrolled.
if (is_enrolled($this->get_course_context(), $potentialuser->id)) {
$notifiableusers[$potentialuser->id] = $potentialuser;
}
}
}
return $notifiableusers;
} | [
"protected",
"function",
"get_notifiable_users",
"(",
"$",
"userid",
")",
"{",
"// Potential users should be active users only.",
"$",
"potentialusers",
"=",
"get_enrolled_users",
"(",
"$",
"this",
"->",
"context",
",",
"\"mod/assign:receivegradernotifications\"",
",",
"null",
",",
"'u.*'",
",",
"null",
",",
"null",
",",
"null",
",",
"true",
")",
";",
"$",
"notifiableusers",
"=",
"array",
"(",
")",
";",
"if",
"(",
"groups_get_activity_groupmode",
"(",
"$",
"this",
"->",
"get_course_module",
"(",
")",
")",
"==",
"SEPARATEGROUPS",
")",
"{",
"if",
"(",
"$",
"groups",
"=",
"groups_get_all_groups",
"(",
"$",
"this",
"->",
"get_course",
"(",
")",
"->",
"id",
",",
"$",
"userid",
",",
"$",
"this",
"->",
"get_course_module",
"(",
")",
"->",
"groupingid",
")",
")",
"{",
"foreach",
"(",
"$",
"groups",
"as",
"$",
"group",
")",
"{",
"foreach",
"(",
"$",
"potentialusers",
"as",
"$",
"potentialuser",
")",
"{",
"if",
"(",
"$",
"potentialuser",
"->",
"id",
"==",
"$",
"userid",
")",
"{",
"// Do not send self.",
"continue",
";",
"}",
"if",
"(",
"groups_is_member",
"(",
"$",
"group",
"->",
"id",
",",
"$",
"potentialuser",
"->",
"id",
")",
")",
"{",
"$",
"notifiableusers",
"[",
"$",
"potentialuser",
"->",
"id",
"]",
"=",
"$",
"potentialuser",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"// User not in group, try to find graders without group.",
"foreach",
"(",
"$",
"potentialusers",
"as",
"$",
"potentialuser",
")",
"{",
"if",
"(",
"$",
"potentialuser",
"->",
"id",
"==",
"$",
"userid",
")",
"{",
"// Do not send self.",
"continue",
";",
"}",
"if",
"(",
"!",
"groups_has_membership",
"(",
"$",
"this",
"->",
"get_course_module",
"(",
")",
",",
"$",
"potentialuser",
"->",
"id",
")",
")",
"{",
"$",
"notifiableusers",
"[",
"$",
"potentialuser",
"->",
"id",
"]",
"=",
"$",
"potentialuser",
";",
"}",
"}",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"potentialusers",
"as",
"$",
"potentialuser",
")",
"{",
"if",
"(",
"$",
"potentialuser",
"->",
"id",
"==",
"$",
"userid",
")",
"{",
"// Do not send self.",
"continue",
";",
"}",
"// Must be enrolled.",
"if",
"(",
"is_enrolled",
"(",
"$",
"this",
"->",
"get_course_context",
"(",
")",
",",
"$",
"potentialuser",
"->",
"id",
")",
")",
"{",
"$",
"notifiableusers",
"[",
"$",
"potentialuser",
"->",
"id",
"]",
"=",
"$",
"potentialuser",
";",
"}",
"}",
"}",
"return",
"$",
"notifiableusers",
";",
"}"
] | Returns a list of users that should receive notification about given submission.
@param int $userid The submission to grade
@return array | [
"Returns",
"a",
"list",
"of",
"users",
"that",
"should",
"receive",
"notification",
"about",
"given",
"submission",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L6058-L6102 |
215,012 | moodle/moodle | mod/assign/locallib.php | assign.format_notification_message_text | protected static function format_notification_message_text($messagetype,
$info,
$course,
$context,
$modulename,
$assignmentname) {
$formatparams = array('context' => $context->get_course_context());
$posttext = format_string($course->shortname, true, $formatparams) .
' -> ' .
$modulename .
' -> ' .
format_string($assignmentname, true, $formatparams) . "\n";
$posttext .= '---------------------------------------------------------------------' . "\n";
$posttext .= get_string($messagetype . 'text', 'assign', $info)."\n";
$posttext .= "\n---------------------------------------------------------------------\n";
return $posttext;
} | php | protected static function format_notification_message_text($messagetype,
$info,
$course,
$context,
$modulename,
$assignmentname) {
$formatparams = array('context' => $context->get_course_context());
$posttext = format_string($course->shortname, true, $formatparams) .
' -> ' .
$modulename .
' -> ' .
format_string($assignmentname, true, $formatparams) . "\n";
$posttext .= '---------------------------------------------------------------------' . "\n";
$posttext .= get_string($messagetype . 'text', 'assign', $info)."\n";
$posttext .= "\n---------------------------------------------------------------------\n";
return $posttext;
} | [
"protected",
"static",
"function",
"format_notification_message_text",
"(",
"$",
"messagetype",
",",
"$",
"info",
",",
"$",
"course",
",",
"$",
"context",
",",
"$",
"modulename",
",",
"$",
"assignmentname",
")",
"{",
"$",
"formatparams",
"=",
"array",
"(",
"'context'",
"=>",
"$",
"context",
"->",
"get_course_context",
"(",
")",
")",
";",
"$",
"posttext",
"=",
"format_string",
"(",
"$",
"course",
"->",
"shortname",
",",
"true",
",",
"$",
"formatparams",
")",
".",
"' -> '",
".",
"$",
"modulename",
".",
"' -> '",
".",
"format_string",
"(",
"$",
"assignmentname",
",",
"true",
",",
"$",
"formatparams",
")",
".",
"\"\\n\"",
";",
"$",
"posttext",
".=",
"'---------------------------------------------------------------------'",
".",
"\"\\n\"",
";",
"$",
"posttext",
".=",
"get_string",
"(",
"$",
"messagetype",
".",
"'text'",
",",
"'assign'",
",",
"$",
"info",
")",
".",
"\"\\n\"",
";",
"$",
"posttext",
".=",
"\"\\n---------------------------------------------------------------------\\n\"",
";",
"return",
"$",
"posttext",
";",
"}"
] | Format a notification for plain text.
@param string $messagetype
@param stdClass $info
@param stdClass $course
@param stdClass $context
@param string $modulename
@param string $assignmentname | [
"Format",
"a",
"notification",
"for",
"plain",
"text",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L6114-L6130 |
215,013 | moodle/moodle | mod/assign/locallib.php | assign.format_notification_message_html | protected static function format_notification_message_html($messagetype,
$info,
$course,
$context,
$modulename,
$coursemodule,
$assignmentname) {
global $CFG;
$formatparams = array('context' => $context->get_course_context());
$posthtml = '<p><font face="sans-serif">' .
'<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $course->id . '">' .
format_string($course->shortname, true, $formatparams) .
'</a> ->' .
'<a href="' . $CFG->wwwroot . '/mod/assign/index.php?id=' . $course->id . '">' .
$modulename .
'</a> ->' .
'<a href="' . $CFG->wwwroot . '/mod/assign/view.php?id=' . $coursemodule->id . '">' .
format_string($assignmentname, true, $formatparams) .
'</a></font></p>';
$posthtml .= '<hr /><font face="sans-serif">';
$posthtml .= '<p>' . get_string($messagetype . 'html', 'assign', $info) . '</p>';
$posthtml .= '</font><hr />';
return $posthtml;
} | php | protected static function format_notification_message_html($messagetype,
$info,
$course,
$context,
$modulename,
$coursemodule,
$assignmentname) {
global $CFG;
$formatparams = array('context' => $context->get_course_context());
$posthtml = '<p><font face="sans-serif">' .
'<a href="' . $CFG->wwwroot . '/course/view.php?id=' . $course->id . '">' .
format_string($course->shortname, true, $formatparams) .
'</a> ->' .
'<a href="' . $CFG->wwwroot . '/mod/assign/index.php?id=' . $course->id . '">' .
$modulename .
'</a> ->' .
'<a href="' . $CFG->wwwroot . '/mod/assign/view.php?id=' . $coursemodule->id . '">' .
format_string($assignmentname, true, $formatparams) .
'</a></font></p>';
$posthtml .= '<hr /><font face="sans-serif">';
$posthtml .= '<p>' . get_string($messagetype . 'html', 'assign', $info) . '</p>';
$posthtml .= '</font><hr />';
return $posthtml;
} | [
"protected",
"static",
"function",
"format_notification_message_html",
"(",
"$",
"messagetype",
",",
"$",
"info",
",",
"$",
"course",
",",
"$",
"context",
",",
"$",
"modulename",
",",
"$",
"coursemodule",
",",
"$",
"assignmentname",
")",
"{",
"global",
"$",
"CFG",
";",
"$",
"formatparams",
"=",
"array",
"(",
"'context'",
"=>",
"$",
"context",
"->",
"get_course_context",
"(",
")",
")",
";",
"$",
"posthtml",
"=",
"'<p><font face=\"sans-serif\">'",
".",
"'<a href=\"'",
".",
"$",
"CFG",
"->",
"wwwroot",
".",
"'/course/view.php?id='",
".",
"$",
"course",
"->",
"id",
".",
"'\">'",
".",
"format_string",
"(",
"$",
"course",
"->",
"shortname",
",",
"true",
",",
"$",
"formatparams",
")",
".",
"'</a> ->'",
".",
"'<a href=\"'",
".",
"$",
"CFG",
"->",
"wwwroot",
".",
"'/mod/assign/index.php?id='",
".",
"$",
"course",
"->",
"id",
".",
"'\">'",
".",
"$",
"modulename",
".",
"'</a> ->'",
".",
"'<a href=\"'",
".",
"$",
"CFG",
"->",
"wwwroot",
".",
"'/mod/assign/view.php?id='",
".",
"$",
"coursemodule",
"->",
"id",
".",
"'\">'",
".",
"format_string",
"(",
"$",
"assignmentname",
",",
"true",
",",
"$",
"formatparams",
")",
".",
"'</a></font></p>'",
";",
"$",
"posthtml",
".=",
"'<hr /><font face=\"sans-serif\">'",
";",
"$",
"posthtml",
".=",
"'<p>'",
".",
"get_string",
"(",
"$",
"messagetype",
".",
"'html'",
",",
"'assign'",
",",
"$",
"info",
")",
".",
"'</p>'",
";",
"$",
"posthtml",
".=",
"'</font><hr />'",
";",
"return",
"$",
"posthtml",
";",
"}"
] | Format a notification for HTML.
@param string $messagetype
@param stdClass $info
@param stdClass $course
@param stdClass $context
@param string $modulename
@param stdClass $coursemodule
@param string $assignmentname | [
"Format",
"a",
"notification",
"for",
"HTML",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L6143-L6166 |
215,014 | moodle/moodle | mod/assign/locallib.php | assign.send_notification | public function send_notification($userfrom, $userto, $messagetype, $eventtype, $updatetime) {
global $USER;
$userid = core_user::is_real_user($userfrom->id) ? $userfrom->id : $USER->id;
$uniqueid = $this->get_uniqueid_for_user($userid);
self::send_assignment_notification($userfrom,
$userto,
$messagetype,
$eventtype,
$updatetime,
$this->get_course_module(),
$this->get_context(),
$this->get_course(),
$this->get_module_name(),
$this->get_instance()->name,
$this->is_blind_marking(),
$uniqueid);
} | php | public function send_notification($userfrom, $userto, $messagetype, $eventtype, $updatetime) {
global $USER;
$userid = core_user::is_real_user($userfrom->id) ? $userfrom->id : $USER->id;
$uniqueid = $this->get_uniqueid_for_user($userid);
self::send_assignment_notification($userfrom,
$userto,
$messagetype,
$eventtype,
$updatetime,
$this->get_course_module(),
$this->get_context(),
$this->get_course(),
$this->get_module_name(),
$this->get_instance()->name,
$this->is_blind_marking(),
$uniqueid);
} | [
"public",
"function",
"send_notification",
"(",
"$",
"userfrom",
",",
"$",
"userto",
",",
"$",
"messagetype",
",",
"$",
"eventtype",
",",
"$",
"updatetime",
")",
"{",
"global",
"$",
"USER",
";",
"$",
"userid",
"=",
"core_user",
"::",
"is_real_user",
"(",
"$",
"userfrom",
"->",
"id",
")",
"?",
"$",
"userfrom",
"->",
"id",
":",
"$",
"USER",
"->",
"id",
";",
"$",
"uniqueid",
"=",
"$",
"this",
"->",
"get_uniqueid_for_user",
"(",
"$",
"userid",
")",
";",
"self",
"::",
"send_assignment_notification",
"(",
"$",
"userfrom",
",",
"$",
"userto",
",",
"$",
"messagetype",
",",
"$",
"eventtype",
",",
"$",
"updatetime",
",",
"$",
"this",
"->",
"get_course_module",
"(",
")",
",",
"$",
"this",
"->",
"get_context",
"(",
")",
",",
"$",
"this",
"->",
"get_course",
"(",
")",
",",
"$",
"this",
"->",
"get_module_name",
"(",
")",
",",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"name",
",",
"$",
"this",
"->",
"is_blind_marking",
"(",
")",
",",
"$",
"uniqueid",
")",
";",
"}"
] | Message someone about something.
@param stdClass $userfrom
@param stdClass $userto
@param string $messagetype
@param string $eventtype
@param int $updatetime
@return void | [
"Message",
"someone",
"about",
"something",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L6275-L6291 |
215,015 | moodle/moodle | mod/assign/locallib.php | assign.notify_student_submission_copied | protected function notify_student_submission_copied(stdClass $submission) {
global $DB, $USER;
$adminconfig = $this->get_admin_config();
// Use the same setting for this - no need for another one.
if (empty($adminconfig->submissionreceipts)) {
// No need to do anything.
return;
}
if ($submission->userid) {
$user = $DB->get_record('user', array('id'=>$submission->userid), '*', MUST_EXIST);
} else {
$user = $USER;
}
$this->send_notification($user,
$user,
'submissioncopied',
'assign_notification',
$submission->timemodified);
} | php | protected function notify_student_submission_copied(stdClass $submission) {
global $DB, $USER;
$adminconfig = $this->get_admin_config();
// Use the same setting for this - no need for another one.
if (empty($adminconfig->submissionreceipts)) {
// No need to do anything.
return;
}
if ($submission->userid) {
$user = $DB->get_record('user', array('id'=>$submission->userid), '*', MUST_EXIST);
} else {
$user = $USER;
}
$this->send_notification($user,
$user,
'submissioncopied',
'assign_notification',
$submission->timemodified);
} | [
"protected",
"function",
"notify_student_submission_copied",
"(",
"stdClass",
"$",
"submission",
")",
"{",
"global",
"$",
"DB",
",",
"$",
"USER",
";",
"$",
"adminconfig",
"=",
"$",
"this",
"->",
"get_admin_config",
"(",
")",
";",
"// Use the same setting for this - no need for another one.",
"if",
"(",
"empty",
"(",
"$",
"adminconfig",
"->",
"submissionreceipts",
")",
")",
"{",
"// No need to do anything.",
"return",
";",
"}",
"if",
"(",
"$",
"submission",
"->",
"userid",
")",
"{",
"$",
"user",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'user'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"submission",
"->",
"userid",
")",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"}",
"else",
"{",
"$",
"user",
"=",
"$",
"USER",
";",
"}",
"$",
"this",
"->",
"send_notification",
"(",
"$",
"user",
",",
"$",
"user",
",",
"'submissioncopied'",
",",
"'assign_notification'",
",",
"$",
"submission",
"->",
"timemodified",
")",
";",
"}"
] | Notify student upon successful submission copy.
@param stdClass $submission
@return void | [
"Notify",
"student",
"upon",
"successful",
"submission",
"copy",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L6299-L6318 |
215,016 | moodle/moodle | mod/assign/locallib.php | assign.notify_student_submission_receipt | protected function notify_student_submission_receipt(stdClass $submission) {
global $DB, $USER;
$adminconfig = $this->get_admin_config();
if (empty($adminconfig->submissionreceipts)) {
// No need to do anything.
return;
}
if ($submission->userid) {
$user = $DB->get_record('user', array('id'=>$submission->userid), '*', MUST_EXIST);
} else {
$user = $USER;
}
if ($submission->userid == $USER->id) {
$this->send_notification(core_user::get_noreply_user(),
$user,
'submissionreceipt',
'assign_notification',
$submission->timemodified);
} else {
$this->send_notification($USER,
$user,
'submissionreceiptother',
'assign_notification',
$submission->timemodified);
}
} | php | protected function notify_student_submission_receipt(stdClass $submission) {
global $DB, $USER;
$adminconfig = $this->get_admin_config();
if (empty($adminconfig->submissionreceipts)) {
// No need to do anything.
return;
}
if ($submission->userid) {
$user = $DB->get_record('user', array('id'=>$submission->userid), '*', MUST_EXIST);
} else {
$user = $USER;
}
if ($submission->userid == $USER->id) {
$this->send_notification(core_user::get_noreply_user(),
$user,
'submissionreceipt',
'assign_notification',
$submission->timemodified);
} else {
$this->send_notification($USER,
$user,
'submissionreceiptother',
'assign_notification',
$submission->timemodified);
}
} | [
"protected",
"function",
"notify_student_submission_receipt",
"(",
"stdClass",
"$",
"submission",
")",
"{",
"global",
"$",
"DB",
",",
"$",
"USER",
";",
"$",
"adminconfig",
"=",
"$",
"this",
"->",
"get_admin_config",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"adminconfig",
"->",
"submissionreceipts",
")",
")",
"{",
"// No need to do anything.",
"return",
";",
"}",
"if",
"(",
"$",
"submission",
"->",
"userid",
")",
"{",
"$",
"user",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'user'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"submission",
"->",
"userid",
")",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"}",
"else",
"{",
"$",
"user",
"=",
"$",
"USER",
";",
"}",
"if",
"(",
"$",
"submission",
"->",
"userid",
"==",
"$",
"USER",
"->",
"id",
")",
"{",
"$",
"this",
"->",
"send_notification",
"(",
"core_user",
"::",
"get_noreply_user",
"(",
")",
",",
"$",
"user",
",",
"'submissionreceipt'",
",",
"'assign_notification'",
",",
"$",
"submission",
"->",
"timemodified",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"send_notification",
"(",
"$",
"USER",
",",
"$",
"user",
",",
"'submissionreceiptother'",
",",
"'assign_notification'",
",",
"$",
"submission",
"->",
"timemodified",
")",
";",
"}",
"}"
] | Notify student upon successful submission.
@param stdClass $submission
@return void | [
"Notify",
"student",
"upon",
"successful",
"submission",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L6325-L6351 |
215,017 | moodle/moodle | mod/assign/locallib.php | assign.notify_graders | protected function notify_graders(stdClass $submission) {
global $DB, $USER;
$instance = $this->get_instance();
$late = $instance->duedate && ($instance->duedate < time());
if (!$instance->sendnotifications && !($late && $instance->sendlatenotifications)) {
// No need to do anything.
return;
}
if ($submission->userid) {
$user = $DB->get_record('user', array('id'=>$submission->userid), '*', MUST_EXIST);
} else {
$user = $USER;
}
if ($notifyusers = $this->get_notifiable_users($user->id)) {
foreach ($notifyusers as $notifyuser) {
$this->send_notification($user,
$notifyuser,
'gradersubmissionupdated',
'assign_notification',
$submission->timemodified);
}
}
} | php | protected function notify_graders(stdClass $submission) {
global $DB, $USER;
$instance = $this->get_instance();
$late = $instance->duedate && ($instance->duedate < time());
if (!$instance->sendnotifications && !($late && $instance->sendlatenotifications)) {
// No need to do anything.
return;
}
if ($submission->userid) {
$user = $DB->get_record('user', array('id'=>$submission->userid), '*', MUST_EXIST);
} else {
$user = $USER;
}
if ($notifyusers = $this->get_notifiable_users($user->id)) {
foreach ($notifyusers as $notifyuser) {
$this->send_notification($user,
$notifyuser,
'gradersubmissionupdated',
'assign_notification',
$submission->timemodified);
}
}
} | [
"protected",
"function",
"notify_graders",
"(",
"stdClass",
"$",
"submission",
")",
"{",
"global",
"$",
"DB",
",",
"$",
"USER",
";",
"$",
"instance",
"=",
"$",
"this",
"->",
"get_instance",
"(",
")",
";",
"$",
"late",
"=",
"$",
"instance",
"->",
"duedate",
"&&",
"(",
"$",
"instance",
"->",
"duedate",
"<",
"time",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"instance",
"->",
"sendnotifications",
"&&",
"!",
"(",
"$",
"late",
"&&",
"$",
"instance",
"->",
"sendlatenotifications",
")",
")",
"{",
"// No need to do anything.",
"return",
";",
"}",
"if",
"(",
"$",
"submission",
"->",
"userid",
")",
"{",
"$",
"user",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'user'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"submission",
"->",
"userid",
")",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"}",
"else",
"{",
"$",
"user",
"=",
"$",
"USER",
";",
"}",
"if",
"(",
"$",
"notifyusers",
"=",
"$",
"this",
"->",
"get_notifiable_users",
"(",
"$",
"user",
"->",
"id",
")",
")",
"{",
"foreach",
"(",
"$",
"notifyusers",
"as",
"$",
"notifyuser",
")",
"{",
"$",
"this",
"->",
"send_notification",
"(",
"$",
"user",
",",
"$",
"notifyuser",
",",
"'gradersubmissionupdated'",
",",
"'assign_notification'",
",",
"$",
"submission",
"->",
"timemodified",
")",
";",
"}",
"}",
"}"
] | Send notifications to graders upon student submissions.
@param stdClass $submission
@return void | [
"Send",
"notifications",
"to",
"graders",
"upon",
"student",
"submissions",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L6359-L6386 |
215,018 | moodle/moodle | mod/assign/locallib.php | assign.submit_for_grading | public function submit_for_grading($data, $notices) {
global $USER;
$userid = $USER->id;
if (!empty($data->userid)) {
$userid = $data->userid;
}
// Need submit permission to submit an assignment.
if ($userid == $USER->id) {
require_capability('mod/assign:submit', $this->context);
} else {
if (!$this->can_edit_submission($userid, $USER->id)) {
print_error('nopermission');
}
}
$instance = $this->get_instance();
if ($instance->teamsubmission) {
$submission = $this->get_group_submission($userid, 0, true);
} else {
$submission = $this->get_user_submission($userid, true);
}
if (!$this->submissions_open($userid)) {
$notices[] = get_string('submissionsclosed', 'assign');
return false;
}
if ($instance->requiresubmissionstatement && empty($data->submissionstatement) && $USER->id == $userid) {
return false;
}
if ($submission->status != ASSIGN_SUBMISSION_STATUS_SUBMITTED) {
// Give each submission plugin a chance to process the submission.
$plugins = $this->get_submission_plugins();
foreach ($plugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
$plugin->submit_for_grading($submission);
}
}
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
$this->update_submission($submission, $userid, true, $instance->teamsubmission);
$completion = new completion_info($this->get_course());
if ($completion->is_enabled($this->get_course_module()) && $instance->completionsubmit) {
$this->update_activity_completion_records($instance->teamsubmission,
$instance->requireallteammemberssubmit,
$submission,
$userid,
COMPLETION_COMPLETE,
$completion);
}
if (!empty($data->submissionstatement) && $USER->id == $userid) {
\mod_assign\event\statement_accepted::create_from_submission($this, $submission)->trigger();
}
$this->notify_graders($submission);
$this->notify_student_submission_receipt($submission);
\mod_assign\event\assessable_submitted::create_from_submission($this, $submission, false)->trigger();
return true;
}
$notices[] = get_string('submissionsclosed', 'assign');
return false;
} | php | public function submit_for_grading($data, $notices) {
global $USER;
$userid = $USER->id;
if (!empty($data->userid)) {
$userid = $data->userid;
}
// Need submit permission to submit an assignment.
if ($userid == $USER->id) {
require_capability('mod/assign:submit', $this->context);
} else {
if (!$this->can_edit_submission($userid, $USER->id)) {
print_error('nopermission');
}
}
$instance = $this->get_instance();
if ($instance->teamsubmission) {
$submission = $this->get_group_submission($userid, 0, true);
} else {
$submission = $this->get_user_submission($userid, true);
}
if (!$this->submissions_open($userid)) {
$notices[] = get_string('submissionsclosed', 'assign');
return false;
}
if ($instance->requiresubmissionstatement && empty($data->submissionstatement) && $USER->id == $userid) {
return false;
}
if ($submission->status != ASSIGN_SUBMISSION_STATUS_SUBMITTED) {
// Give each submission plugin a chance to process the submission.
$plugins = $this->get_submission_plugins();
foreach ($plugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
$plugin->submit_for_grading($submission);
}
}
$submission->status = ASSIGN_SUBMISSION_STATUS_SUBMITTED;
$this->update_submission($submission, $userid, true, $instance->teamsubmission);
$completion = new completion_info($this->get_course());
if ($completion->is_enabled($this->get_course_module()) && $instance->completionsubmit) {
$this->update_activity_completion_records($instance->teamsubmission,
$instance->requireallteammemberssubmit,
$submission,
$userid,
COMPLETION_COMPLETE,
$completion);
}
if (!empty($data->submissionstatement) && $USER->id == $userid) {
\mod_assign\event\statement_accepted::create_from_submission($this, $submission)->trigger();
}
$this->notify_graders($submission);
$this->notify_student_submission_receipt($submission);
\mod_assign\event\assessable_submitted::create_from_submission($this, $submission, false)->trigger();
return true;
}
$notices[] = get_string('submissionsclosed', 'assign');
return false;
} | [
"public",
"function",
"submit_for_grading",
"(",
"$",
"data",
",",
"$",
"notices",
")",
"{",
"global",
"$",
"USER",
";",
"$",
"userid",
"=",
"$",
"USER",
"->",
"id",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
"->",
"userid",
")",
")",
"{",
"$",
"userid",
"=",
"$",
"data",
"->",
"userid",
";",
"}",
"// Need submit permission to submit an assignment.",
"if",
"(",
"$",
"userid",
"==",
"$",
"USER",
"->",
"id",
")",
"{",
"require_capability",
"(",
"'mod/assign:submit'",
",",
"$",
"this",
"->",
"context",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"can_edit_submission",
"(",
"$",
"userid",
",",
"$",
"USER",
"->",
"id",
")",
")",
"{",
"print_error",
"(",
"'nopermission'",
")",
";",
"}",
"}",
"$",
"instance",
"=",
"$",
"this",
"->",
"get_instance",
"(",
")",
";",
"if",
"(",
"$",
"instance",
"->",
"teamsubmission",
")",
"{",
"$",
"submission",
"=",
"$",
"this",
"->",
"get_group_submission",
"(",
"$",
"userid",
",",
"0",
",",
"true",
")",
";",
"}",
"else",
"{",
"$",
"submission",
"=",
"$",
"this",
"->",
"get_user_submission",
"(",
"$",
"userid",
",",
"true",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"submissions_open",
"(",
"$",
"userid",
")",
")",
"{",
"$",
"notices",
"[",
"]",
"=",
"get_string",
"(",
"'submissionsclosed'",
",",
"'assign'",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"instance",
"->",
"requiresubmissionstatement",
"&&",
"empty",
"(",
"$",
"data",
"->",
"submissionstatement",
")",
"&&",
"$",
"USER",
"->",
"id",
"==",
"$",
"userid",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"submission",
"->",
"status",
"!=",
"ASSIGN_SUBMISSION_STATUS_SUBMITTED",
")",
"{",
"// Give each submission plugin a chance to process the submission.",
"$",
"plugins",
"=",
"$",
"this",
"->",
"get_submission_plugins",
"(",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
"$",
"plugin",
"->",
"is_enabled",
"(",
")",
"&&",
"$",
"plugin",
"->",
"is_visible",
"(",
")",
")",
"{",
"$",
"plugin",
"->",
"submit_for_grading",
"(",
"$",
"submission",
")",
";",
"}",
"}",
"$",
"submission",
"->",
"status",
"=",
"ASSIGN_SUBMISSION_STATUS_SUBMITTED",
";",
"$",
"this",
"->",
"update_submission",
"(",
"$",
"submission",
",",
"$",
"userid",
",",
"true",
",",
"$",
"instance",
"->",
"teamsubmission",
")",
";",
"$",
"completion",
"=",
"new",
"completion_info",
"(",
"$",
"this",
"->",
"get_course",
"(",
")",
")",
";",
"if",
"(",
"$",
"completion",
"->",
"is_enabled",
"(",
"$",
"this",
"->",
"get_course_module",
"(",
")",
")",
"&&",
"$",
"instance",
"->",
"completionsubmit",
")",
"{",
"$",
"this",
"->",
"update_activity_completion_records",
"(",
"$",
"instance",
"->",
"teamsubmission",
",",
"$",
"instance",
"->",
"requireallteammemberssubmit",
",",
"$",
"submission",
",",
"$",
"userid",
",",
"COMPLETION_COMPLETE",
",",
"$",
"completion",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
"->",
"submissionstatement",
")",
"&&",
"$",
"USER",
"->",
"id",
"==",
"$",
"userid",
")",
"{",
"\\",
"mod_assign",
"\\",
"event",
"\\",
"statement_accepted",
"::",
"create_from_submission",
"(",
"$",
"this",
",",
"$",
"submission",
")",
"->",
"trigger",
"(",
")",
";",
"}",
"$",
"this",
"->",
"notify_graders",
"(",
"$",
"submission",
")",
";",
"$",
"this",
"->",
"notify_student_submission_receipt",
"(",
"$",
"submission",
")",
";",
"\\",
"mod_assign",
"\\",
"event",
"\\",
"assessable_submitted",
"::",
"create_from_submission",
"(",
"$",
"this",
",",
"$",
"submission",
",",
"false",
")",
"->",
"trigger",
"(",
")",
";",
"return",
"true",
";",
"}",
"$",
"notices",
"[",
"]",
"=",
"get_string",
"(",
"'submissionsclosed'",
",",
"'assign'",
")",
";",
"return",
"false",
";",
"}"
] | Submit a submission for grading.
@param stdClass $data - The form data
@param array $notices - List of error messages to display on an error condition.
@return bool Return false if the submission was not submitted. | [
"Submit",
"a",
"submission",
"for",
"grading",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L6395-L6461 |
215,019 | moodle/moodle | mod/assign/locallib.php | assign.process_submit_other_for_grading | protected function process_submit_other_for_grading($mform, $notices) {
global $USER, $CFG;
require_sesskey();
$userid = optional_param('userid', $USER->id, PARAM_INT);
if (!$this->submissions_open($userid)) {
$notices[] = get_string('submissionsclosed', 'assign');
return false;
}
$data = new stdClass();
$data->userid = $userid;
return $this->submit_for_grading($data, $notices);
} | php | protected function process_submit_other_for_grading($mform, $notices) {
global $USER, $CFG;
require_sesskey();
$userid = optional_param('userid', $USER->id, PARAM_INT);
if (!$this->submissions_open($userid)) {
$notices[] = get_string('submissionsclosed', 'assign');
return false;
}
$data = new stdClass();
$data->userid = $userid;
return $this->submit_for_grading($data, $notices);
} | [
"protected",
"function",
"process_submit_other_for_grading",
"(",
"$",
"mform",
",",
"$",
"notices",
")",
"{",
"global",
"$",
"USER",
",",
"$",
"CFG",
";",
"require_sesskey",
"(",
")",
";",
"$",
"userid",
"=",
"optional_param",
"(",
"'userid'",
",",
"$",
"USER",
"->",
"id",
",",
"PARAM_INT",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"submissions_open",
"(",
"$",
"userid",
")",
")",
"{",
"$",
"notices",
"[",
"]",
"=",
"get_string",
"(",
"'submissionsclosed'",
",",
"'assign'",
")",
";",
"return",
"false",
";",
"}",
"$",
"data",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"data",
"->",
"userid",
"=",
"$",
"userid",
";",
"return",
"$",
"this",
"->",
"submit_for_grading",
"(",
"$",
"data",
",",
"$",
"notices",
")",
";",
"}"
] | A students submission is submitted for grading by a teacher.
@return bool | [
"A",
"students",
"submission",
"is",
"submitted",
"for",
"grading",
"by",
"a",
"teacher",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L6468-L6482 |
215,020 | moodle/moodle | mod/assign/locallib.php | assign.process_submit_for_grading | protected function process_submit_for_grading($mform, $notices) {
global $CFG;
require_once($CFG->dirroot . '/mod/assign/submissionconfirmform.php');
require_sesskey();
if (!$this->submissions_open()) {
$notices[] = get_string('submissionsclosed', 'assign');
return false;
}
$data = new stdClass();
$adminconfig = $this->get_admin_config();
$requiresubmissionstatement = $this->get_instance()->requiresubmissionstatement;
$submissionstatement = '';
if ($requiresubmissionstatement) {
$submissionstatement = $this->get_submissionstatement($adminconfig, $this->get_instance(), $this->get_context());
}
// If we get back an empty submission statement, we have to set $requiredsubmisisonstatement to false to prevent
// that the submission statement checkbox will be displayed.
if (empty($submissionstatement)) {
$requiresubmissionstatement = false;
}
if ($mform == null) {
$mform = new mod_assign_confirm_submission_form(null, array($requiresubmissionstatement,
$submissionstatement,
$this->get_course_module()->id,
$data));
}
$data = $mform->get_data();
if (!$mform->is_cancelled()) {
if ($mform->get_data() == false) {
return false;
}
return $this->submit_for_grading($data, $notices);
}
return true;
} | php | protected function process_submit_for_grading($mform, $notices) {
global $CFG;
require_once($CFG->dirroot . '/mod/assign/submissionconfirmform.php');
require_sesskey();
if (!$this->submissions_open()) {
$notices[] = get_string('submissionsclosed', 'assign');
return false;
}
$data = new stdClass();
$adminconfig = $this->get_admin_config();
$requiresubmissionstatement = $this->get_instance()->requiresubmissionstatement;
$submissionstatement = '';
if ($requiresubmissionstatement) {
$submissionstatement = $this->get_submissionstatement($adminconfig, $this->get_instance(), $this->get_context());
}
// If we get back an empty submission statement, we have to set $requiredsubmisisonstatement to false to prevent
// that the submission statement checkbox will be displayed.
if (empty($submissionstatement)) {
$requiresubmissionstatement = false;
}
if ($mform == null) {
$mform = new mod_assign_confirm_submission_form(null, array($requiresubmissionstatement,
$submissionstatement,
$this->get_course_module()->id,
$data));
}
$data = $mform->get_data();
if (!$mform->is_cancelled()) {
if ($mform->get_data() == false) {
return false;
}
return $this->submit_for_grading($data, $notices);
}
return true;
} | [
"protected",
"function",
"process_submit_for_grading",
"(",
"$",
"mform",
",",
"$",
"notices",
")",
"{",
"global",
"$",
"CFG",
";",
"require_once",
"(",
"$",
"CFG",
"->",
"dirroot",
".",
"'/mod/assign/submissionconfirmform.php'",
")",
";",
"require_sesskey",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"submissions_open",
"(",
")",
")",
"{",
"$",
"notices",
"[",
"]",
"=",
"get_string",
"(",
"'submissionsclosed'",
",",
"'assign'",
")",
";",
"return",
"false",
";",
"}",
"$",
"data",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"adminconfig",
"=",
"$",
"this",
"->",
"get_admin_config",
"(",
")",
";",
"$",
"requiresubmissionstatement",
"=",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"requiresubmissionstatement",
";",
"$",
"submissionstatement",
"=",
"''",
";",
"if",
"(",
"$",
"requiresubmissionstatement",
")",
"{",
"$",
"submissionstatement",
"=",
"$",
"this",
"->",
"get_submissionstatement",
"(",
"$",
"adminconfig",
",",
"$",
"this",
"->",
"get_instance",
"(",
")",
",",
"$",
"this",
"->",
"get_context",
"(",
")",
")",
";",
"}",
"// If we get back an empty submission statement, we have to set $requiredsubmisisonstatement to false to prevent",
"// that the submission statement checkbox will be displayed.",
"if",
"(",
"empty",
"(",
"$",
"submissionstatement",
")",
")",
"{",
"$",
"requiresubmissionstatement",
"=",
"false",
";",
"}",
"if",
"(",
"$",
"mform",
"==",
"null",
")",
"{",
"$",
"mform",
"=",
"new",
"mod_assign_confirm_submission_form",
"(",
"null",
",",
"array",
"(",
"$",
"requiresubmissionstatement",
",",
"$",
"submissionstatement",
",",
"$",
"this",
"->",
"get_course_module",
"(",
")",
"->",
"id",
",",
"$",
"data",
")",
")",
";",
"}",
"$",
"data",
"=",
"$",
"mform",
"->",
"get_data",
"(",
")",
";",
"if",
"(",
"!",
"$",
"mform",
"->",
"is_cancelled",
"(",
")",
")",
"{",
"if",
"(",
"$",
"mform",
"->",
"get_data",
"(",
")",
"==",
"false",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"submit_for_grading",
"(",
"$",
"data",
",",
"$",
"notices",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Assignment submission is processed before grading.
@param moodleform|null $mform If validation failed when submitting this form - this is the moodleform.
It can be null.
@return bool Return false if the validation fails. This affects which page is displayed next. | [
"Assignment",
"submission",
"is",
"processed",
"before",
"grading",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L6491-L6532 |
215,021 | moodle/moodle | mod/assign/locallib.php | assign.save_user_extension | public function save_user_extension($userid, $extensionduedate) {
global $DB;
// Need submit permission to submit an assignment.
require_capability('mod/assign:grantextension', $this->context);
if (!is_enrolled($this->get_course_context(), $userid)) {
return false;
}
if (!has_capability('mod/assign:submit', $this->context, $userid)) {
return false;
}
if ($this->get_instance()->duedate && $extensionduedate) {
if ($this->get_instance()->duedate > $extensionduedate) {
return false;
}
}
if ($this->get_instance()->allowsubmissionsfromdate && $extensionduedate) {
if ($this->get_instance()->allowsubmissionsfromdate > $extensionduedate) {
return false;
}
}
$flags = $this->get_user_flags($userid, true);
$flags->extensionduedate = $extensionduedate;
$result = $this->update_user_flags($flags);
if ($result) {
\mod_assign\event\extension_granted::create_from_assign($this, $userid)->trigger();
}
return $result;
} | php | public function save_user_extension($userid, $extensionduedate) {
global $DB;
// Need submit permission to submit an assignment.
require_capability('mod/assign:grantextension', $this->context);
if (!is_enrolled($this->get_course_context(), $userid)) {
return false;
}
if (!has_capability('mod/assign:submit', $this->context, $userid)) {
return false;
}
if ($this->get_instance()->duedate && $extensionduedate) {
if ($this->get_instance()->duedate > $extensionduedate) {
return false;
}
}
if ($this->get_instance()->allowsubmissionsfromdate && $extensionduedate) {
if ($this->get_instance()->allowsubmissionsfromdate > $extensionduedate) {
return false;
}
}
$flags = $this->get_user_flags($userid, true);
$flags->extensionduedate = $extensionduedate;
$result = $this->update_user_flags($flags);
if ($result) {
\mod_assign\event\extension_granted::create_from_assign($this, $userid)->trigger();
}
return $result;
} | [
"public",
"function",
"save_user_extension",
"(",
"$",
"userid",
",",
"$",
"extensionduedate",
")",
"{",
"global",
"$",
"DB",
";",
"// Need submit permission to submit an assignment.",
"require_capability",
"(",
"'mod/assign:grantextension'",
",",
"$",
"this",
"->",
"context",
")",
";",
"if",
"(",
"!",
"is_enrolled",
"(",
"$",
"this",
"->",
"get_course_context",
"(",
")",
",",
"$",
"userid",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"has_capability",
"(",
"'mod/assign:submit'",
",",
"$",
"this",
"->",
"context",
",",
"$",
"userid",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"duedate",
"&&",
"$",
"extensionduedate",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"duedate",
">",
"$",
"extensionduedate",
")",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"allowsubmissionsfromdate",
"&&",
"$",
"extensionduedate",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"allowsubmissionsfromdate",
">",
"$",
"extensionduedate",
")",
"{",
"return",
"false",
";",
"}",
"}",
"$",
"flags",
"=",
"$",
"this",
"->",
"get_user_flags",
"(",
"$",
"userid",
",",
"true",
")",
";",
"$",
"flags",
"->",
"extensionduedate",
"=",
"$",
"extensionduedate",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"update_user_flags",
"(",
"$",
"flags",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"\\",
"mod_assign",
"\\",
"event",
"\\",
"extension_granted",
"::",
"create_from_assign",
"(",
"$",
"this",
",",
"$",
"userid",
")",
"->",
"trigger",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Save the extension date for a single user.
@param int $userid The user id
@param mixed $extensionduedate Either an integer date or null
@return boolean | [
"Save",
"the",
"extension",
"date",
"for",
"a",
"single",
"user",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L6541-L6574 |
215,022 | moodle/moodle | mod/assign/locallib.php | assign.process_save_extension | protected function process_save_extension(& $mform) {
global $DB, $CFG;
// Include extension form.
require_once($CFG->dirroot . '/mod/assign/extensionform.php');
require_sesskey();
$users = optional_param('userid', 0, PARAM_INT);
if (!$users) {
$users = required_param('selectedusers', PARAM_SEQUENCE);
}
$userlist = explode(',', $users);
$keys = array('duedate', 'cutoffdate', 'allowsubmissionsfromdate');
$maxoverride = array('allowsubmissionsfromdate' => 0, 'duedate' => 0, 'cutoffdate' => 0);
foreach ($userlist as $userid) {
// To validate extension date with users overrides.
$override = $this->override_exists($userid);
foreach ($keys as $key) {
if ($override->{$key}) {
if ($maxoverride[$key] < $override->{$key}) {
$maxoverride[$key] = $override->{$key};
}
} else if ($maxoverride[$key] < $this->get_instance()->{$key}) {
$maxoverride[$key] = $this->get_instance()->{$key};
}
}
}
foreach ($keys as $key) {
if ($maxoverride[$key]) {
$this->get_instance()->{$key} = $maxoverride[$key];
}
}
$formparams = array(
'instance' => $this->get_instance(),
'assign' => $this,
'userlist' => $userlist
);
$mform = new mod_assign_extension_form(null, $formparams);
if ($mform->is_cancelled()) {
return true;
}
if ($formdata = $mform->get_data()) {
if (!empty($formdata->selectedusers)) {
$users = explode(',', $formdata->selectedusers);
$result = true;
foreach ($users as $userid) {
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
$result = $this->save_user_extension($user->id, $formdata->extensionduedate) && $result;
}
return $result;
}
if (!empty($formdata->userid)) {
$user = $DB->get_record('user', array('id' => $formdata->userid), '*', MUST_EXIST);
return $this->save_user_extension($user->id, $formdata->extensionduedate);
}
}
return false;
} | php | protected function process_save_extension(& $mform) {
global $DB, $CFG;
// Include extension form.
require_once($CFG->dirroot . '/mod/assign/extensionform.php');
require_sesskey();
$users = optional_param('userid', 0, PARAM_INT);
if (!$users) {
$users = required_param('selectedusers', PARAM_SEQUENCE);
}
$userlist = explode(',', $users);
$keys = array('duedate', 'cutoffdate', 'allowsubmissionsfromdate');
$maxoverride = array('allowsubmissionsfromdate' => 0, 'duedate' => 0, 'cutoffdate' => 0);
foreach ($userlist as $userid) {
// To validate extension date with users overrides.
$override = $this->override_exists($userid);
foreach ($keys as $key) {
if ($override->{$key}) {
if ($maxoverride[$key] < $override->{$key}) {
$maxoverride[$key] = $override->{$key};
}
} else if ($maxoverride[$key] < $this->get_instance()->{$key}) {
$maxoverride[$key] = $this->get_instance()->{$key};
}
}
}
foreach ($keys as $key) {
if ($maxoverride[$key]) {
$this->get_instance()->{$key} = $maxoverride[$key];
}
}
$formparams = array(
'instance' => $this->get_instance(),
'assign' => $this,
'userlist' => $userlist
);
$mform = new mod_assign_extension_form(null, $formparams);
if ($mform->is_cancelled()) {
return true;
}
if ($formdata = $mform->get_data()) {
if (!empty($formdata->selectedusers)) {
$users = explode(',', $formdata->selectedusers);
$result = true;
foreach ($users as $userid) {
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
$result = $this->save_user_extension($user->id, $formdata->extensionduedate) && $result;
}
return $result;
}
if (!empty($formdata->userid)) {
$user = $DB->get_record('user', array('id' => $formdata->userid), '*', MUST_EXIST);
return $this->save_user_extension($user->id, $formdata->extensionduedate);
}
}
return false;
} | [
"protected",
"function",
"process_save_extension",
"(",
"&",
"$",
"mform",
")",
"{",
"global",
"$",
"DB",
",",
"$",
"CFG",
";",
"// Include extension form.",
"require_once",
"(",
"$",
"CFG",
"->",
"dirroot",
".",
"'/mod/assign/extensionform.php'",
")",
";",
"require_sesskey",
"(",
")",
";",
"$",
"users",
"=",
"optional_param",
"(",
"'userid'",
",",
"0",
",",
"PARAM_INT",
")",
";",
"if",
"(",
"!",
"$",
"users",
")",
"{",
"$",
"users",
"=",
"required_param",
"(",
"'selectedusers'",
",",
"PARAM_SEQUENCE",
")",
";",
"}",
"$",
"userlist",
"=",
"explode",
"(",
"','",
",",
"$",
"users",
")",
";",
"$",
"keys",
"=",
"array",
"(",
"'duedate'",
",",
"'cutoffdate'",
",",
"'allowsubmissionsfromdate'",
")",
";",
"$",
"maxoverride",
"=",
"array",
"(",
"'allowsubmissionsfromdate'",
"=>",
"0",
",",
"'duedate'",
"=>",
"0",
",",
"'cutoffdate'",
"=>",
"0",
")",
";",
"foreach",
"(",
"$",
"userlist",
"as",
"$",
"userid",
")",
"{",
"// To validate extension date with users overrides.",
"$",
"override",
"=",
"$",
"this",
"->",
"override_exists",
"(",
"$",
"userid",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"override",
"->",
"{",
"$",
"key",
"}",
")",
"{",
"if",
"(",
"$",
"maxoverride",
"[",
"$",
"key",
"]",
"<",
"$",
"override",
"->",
"{",
"$",
"key",
"}",
")",
"{",
"$",
"maxoverride",
"[",
"$",
"key",
"]",
"=",
"$",
"override",
"->",
"{",
"$",
"key",
"}",
";",
"}",
"}",
"else",
"if",
"(",
"$",
"maxoverride",
"[",
"$",
"key",
"]",
"<",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"{",
"$",
"key",
"}",
")",
"{",
"$",
"maxoverride",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"{",
"$",
"key",
"}",
";",
"}",
"}",
"}",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"maxoverride",
"[",
"$",
"key",
"]",
")",
"{",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"{",
"$",
"key",
"}",
"=",
"$",
"maxoverride",
"[",
"$",
"key",
"]",
";",
"}",
"}",
"$",
"formparams",
"=",
"array",
"(",
"'instance'",
"=>",
"$",
"this",
"->",
"get_instance",
"(",
")",
",",
"'assign'",
"=>",
"$",
"this",
",",
"'userlist'",
"=>",
"$",
"userlist",
")",
";",
"$",
"mform",
"=",
"new",
"mod_assign_extension_form",
"(",
"null",
",",
"$",
"formparams",
")",
";",
"if",
"(",
"$",
"mform",
"->",
"is_cancelled",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"formdata",
"=",
"$",
"mform",
"->",
"get_data",
"(",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"formdata",
"->",
"selectedusers",
")",
")",
"{",
"$",
"users",
"=",
"explode",
"(",
"','",
",",
"$",
"formdata",
"->",
"selectedusers",
")",
";",
"$",
"result",
"=",
"true",
";",
"foreach",
"(",
"$",
"users",
"as",
"$",
"userid",
")",
"{",
"$",
"user",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'user'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"userid",
")",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"save_user_extension",
"(",
"$",
"user",
"->",
"id",
",",
"$",
"formdata",
"->",
"extensionduedate",
")",
"&&",
"$",
"result",
";",
"}",
"return",
"$",
"result",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"formdata",
"->",
"userid",
")",
")",
"{",
"$",
"user",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'user'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"formdata",
"->",
"userid",
")",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"return",
"$",
"this",
"->",
"save_user_extension",
"(",
"$",
"user",
"->",
"id",
",",
"$",
"formdata",
"->",
"extensionduedate",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Save extension date.
@param moodleform $mform The submitted form
@return boolean | [
"Save",
"extension",
"date",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L6582-L6645 |
215,023 | moodle/moodle | mod/assign/locallib.php | assign.format_grade_for_log | public function format_grade_for_log(stdClass $grade) {
global $DB;
$user = $DB->get_record('user', array('id' => $grade->userid), '*', MUST_EXIST);
$info = get_string('gradestudent', 'assign', array('id'=>$user->id, 'fullname'=>fullname($user)));
if ($grade->grade != '') {
$info .= get_string('grade') . ': ' . $this->display_grade($grade->grade, false) . '. ';
} else {
$info .= get_string('nograde', 'assign');
}
return $info;
} | php | public function format_grade_for_log(stdClass $grade) {
global $DB;
$user = $DB->get_record('user', array('id' => $grade->userid), '*', MUST_EXIST);
$info = get_string('gradestudent', 'assign', array('id'=>$user->id, 'fullname'=>fullname($user)));
if ($grade->grade != '') {
$info .= get_string('grade') . ': ' . $this->display_grade($grade->grade, false) . '. ';
} else {
$info .= get_string('nograde', 'assign');
}
return $info;
} | [
"public",
"function",
"format_grade_for_log",
"(",
"stdClass",
"$",
"grade",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"user",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'user'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"grade",
"->",
"userid",
")",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"$",
"info",
"=",
"get_string",
"(",
"'gradestudent'",
",",
"'assign'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"user",
"->",
"id",
",",
"'fullname'",
"=>",
"fullname",
"(",
"$",
"user",
")",
")",
")",
";",
"if",
"(",
"$",
"grade",
"->",
"grade",
"!=",
"''",
")",
"{",
"$",
"info",
".=",
"get_string",
"(",
"'grade'",
")",
".",
"': '",
".",
"$",
"this",
"->",
"display_grade",
"(",
"$",
"grade",
"->",
"grade",
",",
"false",
")",
".",
"'. '",
";",
"}",
"else",
"{",
"$",
"info",
".=",
"get_string",
"(",
"'nograde'",
",",
"'assign'",
")",
";",
"}",
"return",
"$",
"info",
";",
"}"
] | Take a grade object and print a short summary for the log file.
The size limit for the log file is 255 characters, so be careful not
to include too much information.
@deprecated since 2.7
@param stdClass $grade
@return string | [
"Take",
"a",
"grade",
"object",
"and",
"print",
"a",
"short",
"summary",
"for",
"the",
"log",
"file",
".",
"The",
"size",
"limit",
"for",
"the",
"log",
"file",
"is",
"255",
"characters",
"so",
"be",
"careful",
"not",
"to",
"include",
"too",
"much",
"information",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L7031-L7043 |
215,024 | moodle/moodle | mod/assign/locallib.php | assign.format_submission_for_log | public function format_submission_for_log(stdClass $submission) {
global $DB;
$info = '';
if ($submission->userid) {
$user = $DB->get_record('user', array('id' => $submission->userid), '*', MUST_EXIST);
$name = fullname($user);
} else {
$group = $this->get_submission_group($submission->userid);
if ($group) {
$name = $group->name;
} else {
$name = get_string('defaultteam', 'assign');
}
}
$status = get_string('submissionstatus_' . $submission->status, 'assign');
$params = array('id'=>$submission->userid, 'fullname'=>$name, 'status'=>$status);
$info .= get_string('submissionlog', 'assign', $params) . ' <br>';
foreach ($this->submissionplugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
$info .= '<br>' . $plugin->format_for_log($submission);
}
}
return $info;
} | php | public function format_submission_for_log(stdClass $submission) {
global $DB;
$info = '';
if ($submission->userid) {
$user = $DB->get_record('user', array('id' => $submission->userid), '*', MUST_EXIST);
$name = fullname($user);
} else {
$group = $this->get_submission_group($submission->userid);
if ($group) {
$name = $group->name;
} else {
$name = get_string('defaultteam', 'assign');
}
}
$status = get_string('submissionstatus_' . $submission->status, 'assign');
$params = array('id'=>$submission->userid, 'fullname'=>$name, 'status'=>$status);
$info .= get_string('submissionlog', 'assign', $params) . ' <br>';
foreach ($this->submissionplugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
$info .= '<br>' . $plugin->format_for_log($submission);
}
}
return $info;
} | [
"public",
"function",
"format_submission_for_log",
"(",
"stdClass",
"$",
"submission",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"info",
"=",
"''",
";",
"if",
"(",
"$",
"submission",
"->",
"userid",
")",
"{",
"$",
"user",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'user'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"submission",
"->",
"userid",
")",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"$",
"name",
"=",
"fullname",
"(",
"$",
"user",
")",
";",
"}",
"else",
"{",
"$",
"group",
"=",
"$",
"this",
"->",
"get_submission_group",
"(",
"$",
"submission",
"->",
"userid",
")",
";",
"if",
"(",
"$",
"group",
")",
"{",
"$",
"name",
"=",
"$",
"group",
"->",
"name",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"get_string",
"(",
"'defaultteam'",
",",
"'assign'",
")",
";",
"}",
"}",
"$",
"status",
"=",
"get_string",
"(",
"'submissionstatus_'",
".",
"$",
"submission",
"->",
"status",
",",
"'assign'",
")",
";",
"$",
"params",
"=",
"array",
"(",
"'id'",
"=>",
"$",
"submission",
"->",
"userid",
",",
"'fullname'",
"=>",
"$",
"name",
",",
"'status'",
"=>",
"$",
"status",
")",
";",
"$",
"info",
".=",
"get_string",
"(",
"'submissionlog'",
",",
"'assign'",
",",
"$",
"params",
")",
".",
"' <br>'",
";",
"foreach",
"(",
"$",
"this",
"->",
"submissionplugins",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
"$",
"plugin",
"->",
"is_enabled",
"(",
")",
"&&",
"$",
"plugin",
"->",
"is_visible",
"(",
")",
")",
"{",
"$",
"info",
".=",
"'<br>'",
".",
"$",
"plugin",
"->",
"format_for_log",
"(",
"$",
"submission",
")",
";",
"}",
"}",
"return",
"$",
"info",
";",
"}"
] | Take a submission object and print a short summary for the log file.
The size limit for the log file is 255 characters, so be careful not
to include too much information.
@deprecated since 2.7
@param stdClass $submission
@return string | [
"Take",
"a",
"submission",
"object",
"and",
"print",
"a",
"short",
"summary",
"for",
"the",
"log",
"file",
".",
"The",
"size",
"limit",
"for",
"the",
"log",
"file",
"is",
"255",
"characters",
"so",
"be",
"careful",
"not",
"to",
"include",
"too",
"much",
"information",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L7055-L7081 |
215,025 | moodle/moodle | mod/assign/locallib.php | assign.submission_empty | public function submission_empty($submission) {
$allempty = true;
foreach ($this->submissionplugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
if (!$allempty || !$plugin->is_empty($submission)) {
$allempty = false;
}
}
}
return $allempty;
} | php | public function submission_empty($submission) {
$allempty = true;
foreach ($this->submissionplugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
if (!$allempty || !$plugin->is_empty($submission)) {
$allempty = false;
}
}
}
return $allempty;
} | [
"public",
"function",
"submission_empty",
"(",
"$",
"submission",
")",
"{",
"$",
"allempty",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"submissionplugins",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
"$",
"plugin",
"->",
"is_enabled",
"(",
")",
"&&",
"$",
"plugin",
"->",
"is_visible",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"allempty",
"||",
"!",
"$",
"plugin",
"->",
"is_empty",
"(",
"$",
"submission",
")",
")",
"{",
"$",
"allempty",
"=",
"false",
";",
"}",
"}",
"}",
"return",
"$",
"allempty",
";",
"}"
] | Determine if the current submission is empty or not.
@param submission $submission the students submission record to check.
@return bool | [
"Determine",
"if",
"the",
"current",
"submission",
"is",
"empty",
"or",
"not",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L7194-L7205 |
215,026 | moodle/moodle | mod/assign/locallib.php | assign.new_submission_empty | public function new_submission_empty($data) {
foreach ($this->submissionplugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible() && $plugin->allow_submissions() &&
!$plugin->submission_is_empty($data)) {
return false;
}
}
return true;
} | php | public function new_submission_empty($data) {
foreach ($this->submissionplugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible() && $plugin->allow_submissions() &&
!$plugin->submission_is_empty($data)) {
return false;
}
}
return true;
} | [
"public",
"function",
"new_submission_empty",
"(",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"submissionplugins",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
"$",
"plugin",
"->",
"is_enabled",
"(",
")",
"&&",
"$",
"plugin",
"->",
"is_visible",
"(",
")",
"&&",
"$",
"plugin",
"->",
"allow_submissions",
"(",
")",
"&&",
"!",
"$",
"plugin",
"->",
"submission_is_empty",
"(",
"$",
"data",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Determine if a new submission is empty or not
@param stdClass $data Submission data
@return bool | [
"Determine",
"if",
"a",
"new",
"submission",
"is",
"empty",
"or",
"not"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L7213-L7221 |
215,027 | moodle/moodle | mod/assign/locallib.php | assign.process_save_submission | protected function process_save_submission(&$mform, &$notices) {
global $CFG, $USER;
// Include submission form.
require_once($CFG->dirroot . '/mod/assign/submission_form.php');
$userid = optional_param('userid', $USER->id, PARAM_INT);
// Need submit permission to submit an assignment.
require_sesskey();
if (!$this->submissions_open($userid)) {
$notices[] = get_string('duedatereached', 'assign');
return false;
}
$instance = $this->get_instance();
$data = new stdClass();
$data->userid = $userid;
$mform = new mod_assign_submission_form(null, array($this, $data));
if ($mform->is_cancelled()) {
return true;
}
if ($data = $mform->get_data()) {
return $this->save_submission($data, $notices);
}
return false;
} | php | protected function process_save_submission(&$mform, &$notices) {
global $CFG, $USER;
// Include submission form.
require_once($CFG->dirroot . '/mod/assign/submission_form.php');
$userid = optional_param('userid', $USER->id, PARAM_INT);
// Need submit permission to submit an assignment.
require_sesskey();
if (!$this->submissions_open($userid)) {
$notices[] = get_string('duedatereached', 'assign');
return false;
}
$instance = $this->get_instance();
$data = new stdClass();
$data->userid = $userid;
$mform = new mod_assign_submission_form(null, array($this, $data));
if ($mform->is_cancelled()) {
return true;
}
if ($data = $mform->get_data()) {
return $this->save_submission($data, $notices);
}
return false;
} | [
"protected",
"function",
"process_save_submission",
"(",
"&",
"$",
"mform",
",",
"&",
"$",
"notices",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"USER",
";",
"// Include submission form.",
"require_once",
"(",
"$",
"CFG",
"->",
"dirroot",
".",
"'/mod/assign/submission_form.php'",
")",
";",
"$",
"userid",
"=",
"optional_param",
"(",
"'userid'",
",",
"$",
"USER",
"->",
"id",
",",
"PARAM_INT",
")",
";",
"// Need submit permission to submit an assignment.",
"require_sesskey",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"submissions_open",
"(",
"$",
"userid",
")",
")",
"{",
"$",
"notices",
"[",
"]",
"=",
"get_string",
"(",
"'duedatereached'",
",",
"'assign'",
")",
";",
"return",
"false",
";",
"}",
"$",
"instance",
"=",
"$",
"this",
"->",
"get_instance",
"(",
")",
";",
"$",
"data",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"data",
"->",
"userid",
"=",
"$",
"userid",
";",
"$",
"mform",
"=",
"new",
"mod_assign_submission_form",
"(",
"null",
",",
"array",
"(",
"$",
"this",
",",
"$",
"data",
")",
")",
";",
"if",
"(",
"$",
"mform",
"->",
"is_cancelled",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"data",
"=",
"$",
"mform",
"->",
"get_data",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"save_submission",
"(",
"$",
"data",
",",
"$",
"notices",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Save assignment submission.
@param moodleform $mform
@param array $notices Any error messages that should be shown
to the user at the top of the edit submission form.
@return bool | [
"Save",
"assignment",
"submission",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L7346-L7371 |
215,028 | moodle/moodle | mod/assign/locallib.php | assign.grading_disabled | public function grading_disabled($userid, $checkworkflow=true) {
global $CFG;
if ($checkworkflow && $this->get_instance()->markingworkflow) {
$grade = $this->get_user_grade($userid, false);
$validstates = $this->get_marking_workflow_states_for_current_user();
if (!empty($grade) && !empty($grade->workflowstate) && !array_key_exists($grade->workflowstate, $validstates)) {
return true;
}
}
$gradinginfo = grade_get_grades($this->get_course()->id,
'mod',
'assign',
$this->get_instance()->id,
array($userid));
if (!$gradinginfo) {
return false;
}
if (!isset($gradinginfo->items[0]->grades[$userid])) {
return false;
}
$gradingdisabled = $gradinginfo->items[0]->grades[$userid]->locked ||
$gradinginfo->items[0]->grades[$userid]->overridden;
return $gradingdisabled;
} | php | public function grading_disabled($userid, $checkworkflow=true) {
global $CFG;
if ($checkworkflow && $this->get_instance()->markingworkflow) {
$grade = $this->get_user_grade($userid, false);
$validstates = $this->get_marking_workflow_states_for_current_user();
if (!empty($grade) && !empty($grade->workflowstate) && !array_key_exists($grade->workflowstate, $validstates)) {
return true;
}
}
$gradinginfo = grade_get_grades($this->get_course()->id,
'mod',
'assign',
$this->get_instance()->id,
array($userid));
if (!$gradinginfo) {
return false;
}
if (!isset($gradinginfo->items[0]->grades[$userid])) {
return false;
}
$gradingdisabled = $gradinginfo->items[0]->grades[$userid]->locked ||
$gradinginfo->items[0]->grades[$userid]->overridden;
return $gradingdisabled;
} | [
"public",
"function",
"grading_disabled",
"(",
"$",
"userid",
",",
"$",
"checkworkflow",
"=",
"true",
")",
"{",
"global",
"$",
"CFG",
";",
"if",
"(",
"$",
"checkworkflow",
"&&",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"markingworkflow",
")",
"{",
"$",
"grade",
"=",
"$",
"this",
"->",
"get_user_grade",
"(",
"$",
"userid",
",",
"false",
")",
";",
"$",
"validstates",
"=",
"$",
"this",
"->",
"get_marking_workflow_states_for_current_user",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"grade",
")",
"&&",
"!",
"empty",
"(",
"$",
"grade",
"->",
"workflowstate",
")",
"&&",
"!",
"array_key_exists",
"(",
"$",
"grade",
"->",
"workflowstate",
",",
"$",
"validstates",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"$",
"gradinginfo",
"=",
"grade_get_grades",
"(",
"$",
"this",
"->",
"get_course",
"(",
")",
"->",
"id",
",",
"'mod'",
",",
"'assign'",
",",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"id",
",",
"array",
"(",
"$",
"userid",
")",
")",
";",
"if",
"(",
"!",
"$",
"gradinginfo",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"gradinginfo",
"->",
"items",
"[",
"0",
"]",
"->",
"grades",
"[",
"$",
"userid",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"gradingdisabled",
"=",
"$",
"gradinginfo",
"->",
"items",
"[",
"0",
"]",
"->",
"grades",
"[",
"$",
"userid",
"]",
"->",
"locked",
"||",
"$",
"gradinginfo",
"->",
"items",
"[",
"0",
"]",
"->",
"grades",
"[",
"$",
"userid",
"]",
"->",
"overridden",
";",
"return",
"$",
"gradingdisabled",
";",
"}"
] | Determine if this users grade can be edited.
@param int $userid - The student userid
@param bool $checkworkflow - whether to include a check for the workflow state.
@return bool $gradingdisabled | [
"Determine",
"if",
"this",
"users",
"grade",
"can",
"be",
"edited",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L7381-L7405 |
215,029 | moodle/moodle | mod/assign/locallib.php | assign.get_grading_instance | protected function get_grading_instance($userid, $grade, $gradingdisabled) {
global $CFG, $USER;
$grademenu = make_grades_menu($this->get_instance()->grade);
$allowgradedecimals = $this->get_instance()->grade > 0;
$advancedgradingwarning = false;
$gradingmanager = get_grading_manager($this->context, 'mod_assign', 'submissions');
$gradinginstance = null;
if ($gradingmethod = $gradingmanager->get_active_method()) {
$controller = $gradingmanager->get_controller($gradingmethod);
if ($controller->is_form_available()) {
$itemid = null;
if ($grade) {
$itemid = $grade->id;
}
if ($gradingdisabled && $itemid) {
$gradinginstance = $controller->get_current_instance($USER->id, $itemid);
} else if (!$gradingdisabled) {
$instanceid = optional_param('advancedgradinginstanceid', 0, PARAM_INT);
$gradinginstance = $controller->get_or_create_instance($instanceid,
$USER->id,
$itemid);
}
} else {
$advancedgradingwarning = $controller->form_unavailable_notification();
}
}
if ($gradinginstance) {
$gradinginstance->get_controller()->set_grade_range($grademenu, $allowgradedecimals);
}
return $gradinginstance;
} | php | protected function get_grading_instance($userid, $grade, $gradingdisabled) {
global $CFG, $USER;
$grademenu = make_grades_menu($this->get_instance()->grade);
$allowgradedecimals = $this->get_instance()->grade > 0;
$advancedgradingwarning = false;
$gradingmanager = get_grading_manager($this->context, 'mod_assign', 'submissions');
$gradinginstance = null;
if ($gradingmethod = $gradingmanager->get_active_method()) {
$controller = $gradingmanager->get_controller($gradingmethod);
if ($controller->is_form_available()) {
$itemid = null;
if ($grade) {
$itemid = $grade->id;
}
if ($gradingdisabled && $itemid) {
$gradinginstance = $controller->get_current_instance($USER->id, $itemid);
} else if (!$gradingdisabled) {
$instanceid = optional_param('advancedgradinginstanceid', 0, PARAM_INT);
$gradinginstance = $controller->get_or_create_instance($instanceid,
$USER->id,
$itemid);
}
} else {
$advancedgradingwarning = $controller->form_unavailable_notification();
}
}
if ($gradinginstance) {
$gradinginstance->get_controller()->set_grade_range($grademenu, $allowgradedecimals);
}
return $gradinginstance;
} | [
"protected",
"function",
"get_grading_instance",
"(",
"$",
"userid",
",",
"$",
"grade",
",",
"$",
"gradingdisabled",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"USER",
";",
"$",
"grademenu",
"=",
"make_grades_menu",
"(",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"grade",
")",
";",
"$",
"allowgradedecimals",
"=",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"grade",
">",
"0",
";",
"$",
"advancedgradingwarning",
"=",
"false",
";",
"$",
"gradingmanager",
"=",
"get_grading_manager",
"(",
"$",
"this",
"->",
"context",
",",
"'mod_assign'",
",",
"'submissions'",
")",
";",
"$",
"gradinginstance",
"=",
"null",
";",
"if",
"(",
"$",
"gradingmethod",
"=",
"$",
"gradingmanager",
"->",
"get_active_method",
"(",
")",
")",
"{",
"$",
"controller",
"=",
"$",
"gradingmanager",
"->",
"get_controller",
"(",
"$",
"gradingmethod",
")",
";",
"if",
"(",
"$",
"controller",
"->",
"is_form_available",
"(",
")",
")",
"{",
"$",
"itemid",
"=",
"null",
";",
"if",
"(",
"$",
"grade",
")",
"{",
"$",
"itemid",
"=",
"$",
"grade",
"->",
"id",
";",
"}",
"if",
"(",
"$",
"gradingdisabled",
"&&",
"$",
"itemid",
")",
"{",
"$",
"gradinginstance",
"=",
"$",
"controller",
"->",
"get_current_instance",
"(",
"$",
"USER",
"->",
"id",
",",
"$",
"itemid",
")",
";",
"}",
"else",
"if",
"(",
"!",
"$",
"gradingdisabled",
")",
"{",
"$",
"instanceid",
"=",
"optional_param",
"(",
"'advancedgradinginstanceid'",
",",
"0",
",",
"PARAM_INT",
")",
";",
"$",
"gradinginstance",
"=",
"$",
"controller",
"->",
"get_or_create_instance",
"(",
"$",
"instanceid",
",",
"$",
"USER",
"->",
"id",
",",
"$",
"itemid",
")",
";",
"}",
"}",
"else",
"{",
"$",
"advancedgradingwarning",
"=",
"$",
"controller",
"->",
"form_unavailable_notification",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"gradinginstance",
")",
"{",
"$",
"gradinginstance",
"->",
"get_controller",
"(",
")",
"->",
"set_grade_range",
"(",
"$",
"grademenu",
",",
"$",
"allowgradedecimals",
")",
";",
"}",
"return",
"$",
"gradinginstance",
";",
"}"
] | Get an instance of a grading form if advanced grading is enabled.
This is specific to the assignment, marker and student.
@param int $userid - The student userid
@param stdClass|false $grade - The grade record
@param bool $gradingdisabled
@return mixed gradingform_instance|null $gradinginstance | [
"Get",
"an",
"instance",
"of",
"a",
"grading",
"form",
"if",
"advanced",
"grading",
"is",
"enabled",
".",
"This",
"is",
"specific",
"to",
"the",
"assignment",
"marker",
"and",
"student",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L7417-L7449 |
215,030 | moodle/moodle | mod/assign/locallib.php | assign.add_plugin_submission_elements | protected function add_plugin_submission_elements($submission,
MoodleQuickForm $mform,
stdClass $data,
$userid) {
foreach ($this->submissionplugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible() && $plugin->allow_submissions()) {
$plugin->get_form_elements_for_user($submission, $mform, $data, $userid);
}
}
} | php | protected function add_plugin_submission_elements($submission,
MoodleQuickForm $mform,
stdClass $data,
$userid) {
foreach ($this->submissionplugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible() && $plugin->allow_submissions()) {
$plugin->get_form_elements_for_user($submission, $mform, $data, $userid);
}
}
} | [
"protected",
"function",
"add_plugin_submission_elements",
"(",
"$",
"submission",
",",
"MoodleQuickForm",
"$",
"mform",
",",
"stdClass",
"$",
"data",
",",
"$",
"userid",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"submissionplugins",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
"$",
"plugin",
"->",
"is_enabled",
"(",
")",
"&&",
"$",
"plugin",
"->",
"is_visible",
"(",
")",
"&&",
"$",
"plugin",
"->",
"allow_submissions",
"(",
")",
")",
"{",
"$",
"plugin",
"->",
"get_form_elements_for_user",
"(",
"$",
"submission",
",",
"$",
"mform",
",",
"$",
"data",
",",
"$",
"userid",
")",
";",
"}",
"}",
"}"
] | Add elements in submission plugin form.
@param mixed $submission stdClass|null
@param MoodleQuickForm $mform
@param stdClass $data
@param int $userid The current userid (same as $USER->id)
@return void | [
"Add",
"elements",
"in",
"submission",
"plugin",
"form",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L7738-L7747 |
215,031 | moodle/moodle | mod/assign/locallib.php | assign.is_any_feedback_plugin_enabled | public function is_any_feedback_plugin_enabled() {
if (!isset($this->cache['any_feedback_plugin_enabled'])) {
$this->cache['any_feedback_plugin_enabled'] = false;
foreach ($this->feedbackplugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
$this->cache['any_feedback_plugin_enabled'] = true;
break;
}
}
}
return $this->cache['any_feedback_plugin_enabled'];
} | php | public function is_any_feedback_plugin_enabled() {
if (!isset($this->cache['any_feedback_plugin_enabled'])) {
$this->cache['any_feedback_plugin_enabled'] = false;
foreach ($this->feedbackplugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
$this->cache['any_feedback_plugin_enabled'] = true;
break;
}
}
}
return $this->cache['any_feedback_plugin_enabled'];
} | [
"public",
"function",
"is_any_feedback_plugin_enabled",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"'any_feedback_plugin_enabled'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"cache",
"[",
"'any_feedback_plugin_enabled'",
"]",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"feedbackplugins",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
"$",
"plugin",
"->",
"is_enabled",
"(",
")",
"&&",
"$",
"plugin",
"->",
"is_visible",
"(",
")",
")",
"{",
"$",
"this",
"->",
"cache",
"[",
"'any_feedback_plugin_enabled'",
"]",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"cache",
"[",
"'any_feedback_plugin_enabled'",
"]",
";",
"}"
] | Check if feedback plugins installed are enabled.
@return bool | [
"Check",
"if",
"feedback",
"plugins",
"installed",
"are",
"enabled",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L7754-L7767 |
215,032 | moodle/moodle | mod/assign/locallib.php | assign.is_any_submission_plugin_enabled | public function is_any_submission_plugin_enabled() {
if (!isset($this->cache['any_submission_plugin_enabled'])) {
$this->cache['any_submission_plugin_enabled'] = false;
foreach ($this->submissionplugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible() && $plugin->allow_submissions()) {
$this->cache['any_submission_plugin_enabled'] = true;
break;
}
}
}
return $this->cache['any_submission_plugin_enabled'];
} | php | public function is_any_submission_plugin_enabled() {
if (!isset($this->cache['any_submission_plugin_enabled'])) {
$this->cache['any_submission_plugin_enabled'] = false;
foreach ($this->submissionplugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible() && $plugin->allow_submissions()) {
$this->cache['any_submission_plugin_enabled'] = true;
break;
}
}
}
return $this->cache['any_submission_plugin_enabled'];
} | [
"public",
"function",
"is_any_submission_plugin_enabled",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"'any_submission_plugin_enabled'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"cache",
"[",
"'any_submission_plugin_enabled'",
"]",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"submissionplugins",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
"$",
"plugin",
"->",
"is_enabled",
"(",
")",
"&&",
"$",
"plugin",
"->",
"is_visible",
"(",
")",
"&&",
"$",
"plugin",
"->",
"allow_submissions",
"(",
")",
")",
"{",
"$",
"this",
"->",
"cache",
"[",
"'any_submission_plugin_enabled'",
"]",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"cache",
"[",
"'any_submission_plugin_enabled'",
"]",
";",
"}"
] | Check if submission plugins installed are enabled.
@return bool | [
"Check",
"if",
"submission",
"plugins",
"installed",
"are",
"enabled",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L7774-L7787 |
215,033 | moodle/moodle | mod/assign/locallib.php | assign.add_submission_form_elements | public function add_submission_form_elements(MoodleQuickForm $mform, stdClass $data) {
global $USER;
$userid = $data->userid;
// Team submissions.
if ($this->get_instance()->teamsubmission) {
$submission = $this->get_group_submission($userid, 0, false);
} else {
$submission = $this->get_user_submission($userid, false);
}
// Submission statement.
$adminconfig = $this->get_admin_config();
$requiresubmissionstatement = $this->get_instance()->requiresubmissionstatement;
$draftsenabled = $this->get_instance()->submissiondrafts;
$submissionstatement = '';
if ($requiresubmissionstatement) {
$submissionstatement = $this->get_submissionstatement($adminconfig, $this->get_instance(), $this->get_context());
}
// If we get back an empty submission statement, we have to set $requiredsubmisisonstatement to false to prevent
// that the submission statement checkbox will be displayed.
if (empty($submissionstatement)) {
$requiresubmissionstatement = false;
}
// Only show submission statement if we are editing our own submission.
if ($requiresubmissionstatement && !$draftsenabled && $userid == $USER->id) {
$mform->addElement('checkbox', 'submissionstatement', '', $submissionstatement);
$mform->addRule('submissionstatement', get_string('required'), 'required', null, 'client');
}
$this->add_plugin_submission_elements($submission, $mform, $data, $userid);
// Hidden params.
$mform->addElement('hidden', 'id', $this->get_course_module()->id);
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'userid', $userid);
$mform->setType('userid', PARAM_INT);
$mform->addElement('hidden', 'action', 'savesubmission');
$mform->setType('action', PARAM_ALPHA);
} | php | public function add_submission_form_elements(MoodleQuickForm $mform, stdClass $data) {
global $USER;
$userid = $data->userid;
// Team submissions.
if ($this->get_instance()->teamsubmission) {
$submission = $this->get_group_submission($userid, 0, false);
} else {
$submission = $this->get_user_submission($userid, false);
}
// Submission statement.
$adminconfig = $this->get_admin_config();
$requiresubmissionstatement = $this->get_instance()->requiresubmissionstatement;
$draftsenabled = $this->get_instance()->submissiondrafts;
$submissionstatement = '';
if ($requiresubmissionstatement) {
$submissionstatement = $this->get_submissionstatement($adminconfig, $this->get_instance(), $this->get_context());
}
// If we get back an empty submission statement, we have to set $requiredsubmisisonstatement to false to prevent
// that the submission statement checkbox will be displayed.
if (empty($submissionstatement)) {
$requiresubmissionstatement = false;
}
// Only show submission statement if we are editing our own submission.
if ($requiresubmissionstatement && !$draftsenabled && $userid == $USER->id) {
$mform->addElement('checkbox', 'submissionstatement', '', $submissionstatement);
$mform->addRule('submissionstatement', get_string('required'), 'required', null, 'client');
}
$this->add_plugin_submission_elements($submission, $mform, $data, $userid);
// Hidden params.
$mform->addElement('hidden', 'id', $this->get_course_module()->id);
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'userid', $userid);
$mform->setType('userid', PARAM_INT);
$mform->addElement('hidden', 'action', 'savesubmission');
$mform->setType('action', PARAM_ALPHA);
} | [
"public",
"function",
"add_submission_form_elements",
"(",
"MoodleQuickForm",
"$",
"mform",
",",
"stdClass",
"$",
"data",
")",
"{",
"global",
"$",
"USER",
";",
"$",
"userid",
"=",
"$",
"data",
"->",
"userid",
";",
"// Team submissions.",
"if",
"(",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"teamsubmission",
")",
"{",
"$",
"submission",
"=",
"$",
"this",
"->",
"get_group_submission",
"(",
"$",
"userid",
",",
"0",
",",
"false",
")",
";",
"}",
"else",
"{",
"$",
"submission",
"=",
"$",
"this",
"->",
"get_user_submission",
"(",
"$",
"userid",
",",
"false",
")",
";",
"}",
"// Submission statement.",
"$",
"adminconfig",
"=",
"$",
"this",
"->",
"get_admin_config",
"(",
")",
";",
"$",
"requiresubmissionstatement",
"=",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"requiresubmissionstatement",
";",
"$",
"draftsenabled",
"=",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"submissiondrafts",
";",
"$",
"submissionstatement",
"=",
"''",
";",
"if",
"(",
"$",
"requiresubmissionstatement",
")",
"{",
"$",
"submissionstatement",
"=",
"$",
"this",
"->",
"get_submissionstatement",
"(",
"$",
"adminconfig",
",",
"$",
"this",
"->",
"get_instance",
"(",
")",
",",
"$",
"this",
"->",
"get_context",
"(",
")",
")",
";",
"}",
"// If we get back an empty submission statement, we have to set $requiredsubmisisonstatement to false to prevent",
"// that the submission statement checkbox will be displayed.",
"if",
"(",
"empty",
"(",
"$",
"submissionstatement",
")",
")",
"{",
"$",
"requiresubmissionstatement",
"=",
"false",
";",
"}",
"// Only show submission statement if we are editing our own submission.",
"if",
"(",
"$",
"requiresubmissionstatement",
"&&",
"!",
"$",
"draftsenabled",
"&&",
"$",
"userid",
"==",
"$",
"USER",
"->",
"id",
")",
"{",
"$",
"mform",
"->",
"addElement",
"(",
"'checkbox'",
",",
"'submissionstatement'",
",",
"''",
",",
"$",
"submissionstatement",
")",
";",
"$",
"mform",
"->",
"addRule",
"(",
"'submissionstatement'",
",",
"get_string",
"(",
"'required'",
")",
",",
"'required'",
",",
"null",
",",
"'client'",
")",
";",
"}",
"$",
"this",
"->",
"add_plugin_submission_elements",
"(",
"$",
"submission",
",",
"$",
"mform",
",",
"$",
"data",
",",
"$",
"userid",
")",
";",
"// Hidden params.",
"$",
"mform",
"->",
"addElement",
"(",
"'hidden'",
",",
"'id'",
",",
"$",
"this",
"->",
"get_course_module",
"(",
")",
"->",
"id",
")",
";",
"$",
"mform",
"->",
"setType",
"(",
"'id'",
",",
"PARAM_INT",
")",
";",
"$",
"mform",
"->",
"addElement",
"(",
"'hidden'",
",",
"'userid'",
",",
"$",
"userid",
")",
";",
"$",
"mform",
"->",
"setType",
"(",
"'userid'",
",",
"PARAM_INT",
")",
";",
"$",
"mform",
"->",
"addElement",
"(",
"'hidden'",
",",
"'action'",
",",
"'savesubmission'",
")",
";",
"$",
"mform",
"->",
"setType",
"(",
"'action'",
",",
"PARAM_ALPHA",
")",
";",
"}"
] | Add elements to submission form.
@param MoodleQuickForm $mform
@param stdClass $data
@return void | [
"Add",
"elements",
"to",
"submission",
"form",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L7795-L7840 |
215,034 | moodle/moodle | mod/assign/locallib.php | assign.remove_submission | public function remove_submission($userid) {
global $USER;
if (!$this->can_edit_submission($userid, $USER->id)) {
print_error('nopermission');
}
if ($this->get_instance()->teamsubmission) {
$submission = $this->get_group_submission($userid, 0, false);
} else {
$submission = $this->get_user_submission($userid, false);
}
if (!$submission) {
return false;
}
// Tell each submission plugin we were saved with no data.
$plugins = $this->get_submission_plugins();
foreach ($plugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
$plugin->remove($submission);
}
}
if ($submission->userid != 0) {
\mod_assign\event\submission_status_updated::create_from_submission($this, $submission)->trigger();
}
return true;
} | php | public function remove_submission($userid) {
global $USER;
if (!$this->can_edit_submission($userid, $USER->id)) {
print_error('nopermission');
}
if ($this->get_instance()->teamsubmission) {
$submission = $this->get_group_submission($userid, 0, false);
} else {
$submission = $this->get_user_submission($userid, false);
}
if (!$submission) {
return false;
}
// Tell each submission plugin we were saved with no data.
$plugins = $this->get_submission_plugins();
foreach ($plugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
$plugin->remove($submission);
}
}
if ($submission->userid != 0) {
\mod_assign\event\submission_status_updated::create_from_submission($this, $submission)->trigger();
}
return true;
} | [
"public",
"function",
"remove_submission",
"(",
"$",
"userid",
")",
"{",
"global",
"$",
"USER",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"can_edit_submission",
"(",
"$",
"userid",
",",
"$",
"USER",
"->",
"id",
")",
")",
"{",
"print_error",
"(",
"'nopermission'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"teamsubmission",
")",
"{",
"$",
"submission",
"=",
"$",
"this",
"->",
"get_group_submission",
"(",
"$",
"userid",
",",
"0",
",",
"false",
")",
";",
"}",
"else",
"{",
"$",
"submission",
"=",
"$",
"this",
"->",
"get_user_submission",
"(",
"$",
"userid",
",",
"false",
")",
";",
"}",
"if",
"(",
"!",
"$",
"submission",
")",
"{",
"return",
"false",
";",
"}",
"// Tell each submission plugin we were saved with no data.",
"$",
"plugins",
"=",
"$",
"this",
"->",
"get_submission_plugins",
"(",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
"$",
"plugin",
"->",
"is_enabled",
"(",
")",
"&&",
"$",
"plugin",
"->",
"is_visible",
"(",
")",
")",
"{",
"$",
"plugin",
"->",
"remove",
"(",
"$",
"submission",
")",
";",
"}",
"}",
"if",
"(",
"$",
"submission",
"->",
"userid",
"!=",
"0",
")",
"{",
"\\",
"mod_assign",
"\\",
"event",
"\\",
"submission_status_updated",
"::",
"create_from_submission",
"(",
"$",
"this",
",",
"$",
"submission",
")",
"->",
"trigger",
"(",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Remove any data from the current submission.
@param int $userid
@return boolean | [
"Remove",
"any",
"data",
"from",
"the",
"current",
"submission",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L7848-L7877 |
215,035 | moodle/moodle | mod/assign/locallib.php | assign.revert_to_draft | public function revert_to_draft($userid) {
global $DB, $USER;
// Need grade permission.
require_capability('mod/assign:grade', $this->context);
if ($this->get_instance()->teamsubmission) {
$submission = $this->get_group_submission($userid, 0, false);
} else {
$submission = $this->get_user_submission($userid, false);
}
if (!$submission) {
return false;
}
$submission->status = ASSIGN_SUBMISSION_STATUS_DRAFT;
$this->update_submission($submission, $userid, false, $this->get_instance()->teamsubmission);
// Give each submission plugin a chance to process the reverting to draft.
$plugins = $this->get_submission_plugins();
foreach ($plugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
$plugin->revert_to_draft($submission);
}
}
// Update the modified time on the grade (grader modified).
$grade = $this->get_user_grade($userid, true);
$grade->grader = $USER->id;
$this->update_grade($grade);
$completion = new completion_info($this->get_course());
if ($completion->is_enabled($this->get_course_module()) &&
$this->get_instance()->completionsubmit) {
$completion->update_state($this->get_course_module(), COMPLETION_INCOMPLETE, $userid);
}
\mod_assign\event\submission_status_updated::create_from_submission($this, $submission)->trigger();
return true;
} | php | public function revert_to_draft($userid) {
global $DB, $USER;
// Need grade permission.
require_capability('mod/assign:grade', $this->context);
if ($this->get_instance()->teamsubmission) {
$submission = $this->get_group_submission($userid, 0, false);
} else {
$submission = $this->get_user_submission($userid, false);
}
if (!$submission) {
return false;
}
$submission->status = ASSIGN_SUBMISSION_STATUS_DRAFT;
$this->update_submission($submission, $userid, false, $this->get_instance()->teamsubmission);
// Give each submission plugin a chance to process the reverting to draft.
$plugins = $this->get_submission_plugins();
foreach ($plugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
$plugin->revert_to_draft($submission);
}
}
// Update the modified time on the grade (grader modified).
$grade = $this->get_user_grade($userid, true);
$grade->grader = $USER->id;
$this->update_grade($grade);
$completion = new completion_info($this->get_course());
if ($completion->is_enabled($this->get_course_module()) &&
$this->get_instance()->completionsubmit) {
$completion->update_state($this->get_course_module(), COMPLETION_INCOMPLETE, $userid);
}
\mod_assign\event\submission_status_updated::create_from_submission($this, $submission)->trigger();
return true;
} | [
"public",
"function",
"revert_to_draft",
"(",
"$",
"userid",
")",
"{",
"global",
"$",
"DB",
",",
"$",
"USER",
";",
"// Need grade permission.",
"require_capability",
"(",
"'mod/assign:grade'",
",",
"$",
"this",
"->",
"context",
")",
";",
"if",
"(",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"teamsubmission",
")",
"{",
"$",
"submission",
"=",
"$",
"this",
"->",
"get_group_submission",
"(",
"$",
"userid",
",",
"0",
",",
"false",
")",
";",
"}",
"else",
"{",
"$",
"submission",
"=",
"$",
"this",
"->",
"get_user_submission",
"(",
"$",
"userid",
",",
"false",
")",
";",
"}",
"if",
"(",
"!",
"$",
"submission",
")",
"{",
"return",
"false",
";",
"}",
"$",
"submission",
"->",
"status",
"=",
"ASSIGN_SUBMISSION_STATUS_DRAFT",
";",
"$",
"this",
"->",
"update_submission",
"(",
"$",
"submission",
",",
"$",
"userid",
",",
"false",
",",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"teamsubmission",
")",
";",
"// Give each submission plugin a chance to process the reverting to draft.",
"$",
"plugins",
"=",
"$",
"this",
"->",
"get_submission_plugins",
"(",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
"$",
"plugin",
"->",
"is_enabled",
"(",
")",
"&&",
"$",
"plugin",
"->",
"is_visible",
"(",
")",
")",
"{",
"$",
"plugin",
"->",
"revert_to_draft",
"(",
"$",
"submission",
")",
";",
"}",
"}",
"// Update the modified time on the grade (grader modified).",
"$",
"grade",
"=",
"$",
"this",
"->",
"get_user_grade",
"(",
"$",
"userid",
",",
"true",
")",
";",
"$",
"grade",
"->",
"grader",
"=",
"$",
"USER",
"->",
"id",
";",
"$",
"this",
"->",
"update_grade",
"(",
"$",
"grade",
")",
";",
"$",
"completion",
"=",
"new",
"completion_info",
"(",
"$",
"this",
"->",
"get_course",
"(",
")",
")",
";",
"if",
"(",
"$",
"completion",
"->",
"is_enabled",
"(",
"$",
"this",
"->",
"get_course_module",
"(",
")",
")",
"&&",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"completionsubmit",
")",
"{",
"$",
"completion",
"->",
"update_state",
"(",
"$",
"this",
"->",
"get_course_module",
"(",
")",
",",
"COMPLETION_INCOMPLETE",
",",
"$",
"userid",
")",
";",
"}",
"\\",
"mod_assign",
"\\",
"event",
"\\",
"submission_status_updated",
"::",
"create_from_submission",
"(",
"$",
"this",
",",
"$",
"submission",
")",
"->",
"trigger",
"(",
")",
";",
"return",
"true",
";",
"}"
] | Revert to draft.
@param int $userid
@return boolean | [
"Revert",
"to",
"draft",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L7885-L7922 |
215,036 | moodle/moodle | mod/assign/locallib.php | assign.process_remove_submission | protected function process_remove_submission($userid = 0) {
require_sesskey();
if (!$userid) {
$userid = required_param('userid', PARAM_INT);
}
return $this->remove_submission($userid);
} | php | protected function process_remove_submission($userid = 0) {
require_sesskey();
if (!$userid) {
$userid = required_param('userid', PARAM_INT);
}
return $this->remove_submission($userid);
} | [
"protected",
"function",
"process_remove_submission",
"(",
"$",
"userid",
"=",
"0",
")",
"{",
"require_sesskey",
"(",
")",
";",
"if",
"(",
"!",
"$",
"userid",
")",
"{",
"$",
"userid",
"=",
"required_param",
"(",
"'userid'",
",",
"PARAM_INT",
")",
";",
"}",
"return",
"$",
"this",
"->",
"remove_submission",
"(",
"$",
"userid",
")",
";",
"}"
] | Remove the current submission.
@param int $userid
@return boolean | [
"Remove",
"the",
"current",
"submission",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L7930-L7938 |
215,037 | moodle/moodle | mod/assign/locallib.php | assign.process_revert_to_draft | protected function process_revert_to_draft($userid = 0) {
require_sesskey();
if (!$userid) {
$userid = required_param('userid', PARAM_INT);
}
return $this->revert_to_draft($userid);
} | php | protected function process_revert_to_draft($userid = 0) {
require_sesskey();
if (!$userid) {
$userid = required_param('userid', PARAM_INT);
}
return $this->revert_to_draft($userid);
} | [
"protected",
"function",
"process_revert_to_draft",
"(",
"$",
"userid",
"=",
"0",
")",
"{",
"require_sesskey",
"(",
")",
";",
"if",
"(",
"!",
"$",
"userid",
")",
"{",
"$",
"userid",
"=",
"required_param",
"(",
"'userid'",
",",
"PARAM_INT",
")",
";",
"}",
"return",
"$",
"this",
"->",
"revert_to_draft",
"(",
"$",
"userid",
")",
";",
"}"
] | Revert to draft.
Uses url parameter userid if userid not supplied as a parameter.
@param int $userid
@return boolean | [
"Revert",
"to",
"draft",
".",
"Uses",
"url",
"parameter",
"userid",
"if",
"userid",
"not",
"supplied",
"as",
"a",
"parameter",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L7947-L7955 |
215,038 | moodle/moodle | mod/assign/locallib.php | assign.lock_submission | public function lock_submission($userid) {
global $USER, $DB;
// Need grade permission.
require_capability('mod/assign:grade', $this->context);
// Give each submission plugin a chance to process the locking.
$plugins = $this->get_submission_plugins();
$submission = $this->get_user_submission($userid, false);
$flags = $this->get_user_flags($userid, true);
$flags->locked = 1;
$this->update_user_flags($flags);
foreach ($plugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
$plugin->lock($submission, $flags);
}
}
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
\mod_assign\event\submission_locked::create_from_user($this, $user)->trigger();
return true;
} | php | public function lock_submission($userid) {
global $USER, $DB;
// Need grade permission.
require_capability('mod/assign:grade', $this->context);
// Give each submission plugin a chance to process the locking.
$plugins = $this->get_submission_plugins();
$submission = $this->get_user_submission($userid, false);
$flags = $this->get_user_flags($userid, true);
$flags->locked = 1;
$this->update_user_flags($flags);
foreach ($plugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
$plugin->lock($submission, $flags);
}
}
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
\mod_assign\event\submission_locked::create_from_user($this, $user)->trigger();
return true;
} | [
"public",
"function",
"lock_submission",
"(",
"$",
"userid",
")",
"{",
"global",
"$",
"USER",
",",
"$",
"DB",
";",
"// Need grade permission.",
"require_capability",
"(",
"'mod/assign:grade'",
",",
"$",
"this",
"->",
"context",
")",
";",
"// Give each submission plugin a chance to process the locking.",
"$",
"plugins",
"=",
"$",
"this",
"->",
"get_submission_plugins",
"(",
")",
";",
"$",
"submission",
"=",
"$",
"this",
"->",
"get_user_submission",
"(",
"$",
"userid",
",",
"false",
")",
";",
"$",
"flags",
"=",
"$",
"this",
"->",
"get_user_flags",
"(",
"$",
"userid",
",",
"true",
")",
";",
"$",
"flags",
"->",
"locked",
"=",
"1",
";",
"$",
"this",
"->",
"update_user_flags",
"(",
"$",
"flags",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
"$",
"plugin",
"->",
"is_enabled",
"(",
")",
"&&",
"$",
"plugin",
"->",
"is_visible",
"(",
")",
")",
"{",
"$",
"plugin",
"->",
"lock",
"(",
"$",
"submission",
",",
"$",
"flags",
")",
";",
"}",
"}",
"$",
"user",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'user'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"userid",
")",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"\\",
"mod_assign",
"\\",
"event",
"\\",
"submission_locked",
"::",
"create_from_user",
"(",
"$",
"this",
",",
"$",
"user",
")",
"->",
"trigger",
"(",
")",
";",
"return",
"true",
";",
"}"
] | Prevent student updates to this submission
@param int $userid
@return bool | [
"Prevent",
"student",
"updates",
"to",
"this",
"submission"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L7963-L7985 |
215,039 | moodle/moodle | mod/assign/locallib.php | assign.process_set_batch_marking_workflow_state | 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;
// 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();
}
}
}
} | php | 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;
// 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();
}
}
}
} | [
"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",
";",
"// 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",
"(",
")",
";",
"}",
"}",
"}",
"}"
] | Set the workflow state for multiple users
@return void | [
"Set",
"the",
"workflow",
"state",
"for",
"multiple",
"users"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L7993-L8048 |
215,040 | moodle/moodle | mod/assign/locallib.php | assign.process_set_batch_marking_allocation | protected function process_set_batch_marking_allocation() {
global $CFG, $DB;
// Include batch marking allocation form.
require_once($CFG->dirroot . '/mod/assign/batchsetallocatedmarkerform.php');
$formparams = array(
'userscount' => 0, // This form is never re-displayed, so we don't need to
'usershtml' => '' // initialise these parameters with real information.
);
list($sort, $params) = users_order_by_sql('u');
// Only enrolled users could be assigned as potential markers.
$markers = get_enrolled_users($this->get_context(), 'mod/assign:grade', 0, 'u.*', $sort);
$markerlist = array();
foreach ($markers as $marker) {
$markerlist[$marker->id] = fullname($marker);
}
$formparams['markers'] = $markerlist;
$mform = new mod_assign_batch_set_allocatedmarker_form(null, $formparams);
if ($mform->is_cancelled()) {
return true;
}
if ($formdata = $mform->get_data()) {
$useridlist = explode(',', $formdata->selectedusers);
$marker = $DB->get_record('user', array('id' => $formdata->allocatedmarker), '*', MUST_EXIST);
foreach ($useridlist as $userid) {
$flags = $this->get_user_flags($userid, true);
if ($flags->workflowstate == ASSIGN_MARKING_WORKFLOW_STATE_READYFORREVIEW ||
$flags->workflowstate == ASSIGN_MARKING_WORKFLOW_STATE_INREVIEW ||
$flags->workflowstate == ASSIGN_MARKING_WORKFLOW_STATE_READYFORRELEASE ||
$flags->workflowstate == ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
continue; // Allocated marker can only be changed in certain workflow states.
}
$flags->allocatedmarker = $marker->id;
if ($this->update_user_flags($flags)) {
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
\mod_assign\event\marker_updated::create_from_marker($this, $user, $marker)->trigger();
}
}
}
} | php | protected function process_set_batch_marking_allocation() {
global $CFG, $DB;
// Include batch marking allocation form.
require_once($CFG->dirroot . '/mod/assign/batchsetallocatedmarkerform.php');
$formparams = array(
'userscount' => 0, // This form is never re-displayed, so we don't need to
'usershtml' => '' // initialise these parameters with real information.
);
list($sort, $params) = users_order_by_sql('u');
// Only enrolled users could be assigned as potential markers.
$markers = get_enrolled_users($this->get_context(), 'mod/assign:grade', 0, 'u.*', $sort);
$markerlist = array();
foreach ($markers as $marker) {
$markerlist[$marker->id] = fullname($marker);
}
$formparams['markers'] = $markerlist;
$mform = new mod_assign_batch_set_allocatedmarker_form(null, $formparams);
if ($mform->is_cancelled()) {
return true;
}
if ($formdata = $mform->get_data()) {
$useridlist = explode(',', $formdata->selectedusers);
$marker = $DB->get_record('user', array('id' => $formdata->allocatedmarker), '*', MUST_EXIST);
foreach ($useridlist as $userid) {
$flags = $this->get_user_flags($userid, true);
if ($flags->workflowstate == ASSIGN_MARKING_WORKFLOW_STATE_READYFORREVIEW ||
$flags->workflowstate == ASSIGN_MARKING_WORKFLOW_STATE_INREVIEW ||
$flags->workflowstate == ASSIGN_MARKING_WORKFLOW_STATE_READYFORRELEASE ||
$flags->workflowstate == ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
continue; // Allocated marker can only be changed in certain workflow states.
}
$flags->allocatedmarker = $marker->id;
if ($this->update_user_flags($flags)) {
$user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
\mod_assign\event\marker_updated::create_from_marker($this, $user, $marker)->trigger();
}
}
}
} | [
"protected",
"function",
"process_set_batch_marking_allocation",
"(",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"DB",
";",
"// Include batch marking allocation form.",
"require_once",
"(",
"$",
"CFG",
"->",
"dirroot",
".",
"'/mod/assign/batchsetallocatedmarkerform.php'",
")",
";",
"$",
"formparams",
"=",
"array",
"(",
"'userscount'",
"=>",
"0",
",",
"// This form is never re-displayed, so we don't need to",
"'usershtml'",
"=>",
"''",
"// initialise these parameters with real information.",
")",
";",
"list",
"(",
"$",
"sort",
",",
"$",
"params",
")",
"=",
"users_order_by_sql",
"(",
"'u'",
")",
";",
"// Only enrolled users could be assigned as potential markers.",
"$",
"markers",
"=",
"get_enrolled_users",
"(",
"$",
"this",
"->",
"get_context",
"(",
")",
",",
"'mod/assign:grade'",
",",
"0",
",",
"'u.*'",
",",
"$",
"sort",
")",
";",
"$",
"markerlist",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"markers",
"as",
"$",
"marker",
")",
"{",
"$",
"markerlist",
"[",
"$",
"marker",
"->",
"id",
"]",
"=",
"fullname",
"(",
"$",
"marker",
")",
";",
"}",
"$",
"formparams",
"[",
"'markers'",
"]",
"=",
"$",
"markerlist",
";",
"$",
"mform",
"=",
"new",
"mod_assign_batch_set_allocatedmarker_form",
"(",
"null",
",",
"$",
"formparams",
")",
";",
"if",
"(",
"$",
"mform",
"->",
"is_cancelled",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"formdata",
"=",
"$",
"mform",
"->",
"get_data",
"(",
")",
")",
"{",
"$",
"useridlist",
"=",
"explode",
"(",
"','",
",",
"$",
"formdata",
"->",
"selectedusers",
")",
";",
"$",
"marker",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'user'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"formdata",
"->",
"allocatedmarker",
")",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"foreach",
"(",
"$",
"useridlist",
"as",
"$",
"userid",
")",
"{",
"$",
"flags",
"=",
"$",
"this",
"->",
"get_user_flags",
"(",
"$",
"userid",
",",
"true",
")",
";",
"if",
"(",
"$",
"flags",
"->",
"workflowstate",
"==",
"ASSIGN_MARKING_WORKFLOW_STATE_READYFORREVIEW",
"||",
"$",
"flags",
"->",
"workflowstate",
"==",
"ASSIGN_MARKING_WORKFLOW_STATE_INREVIEW",
"||",
"$",
"flags",
"->",
"workflowstate",
"==",
"ASSIGN_MARKING_WORKFLOW_STATE_READYFORRELEASE",
"||",
"$",
"flags",
"->",
"workflowstate",
"==",
"ASSIGN_MARKING_WORKFLOW_STATE_RELEASED",
")",
"{",
"continue",
";",
"// Allocated marker can only be changed in certain workflow states.",
"}",
"$",
"flags",
"->",
"allocatedmarker",
"=",
"$",
"marker",
"->",
"id",
";",
"if",
"(",
"$",
"this",
"->",
"update_user_flags",
"(",
"$",
"flags",
")",
")",
"{",
"$",
"user",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'user'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"userid",
")",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"\\",
"mod_assign",
"\\",
"event",
"\\",
"marker_updated",
"::",
"create_from_marker",
"(",
"$",
"this",
",",
"$",
"user",
",",
"$",
"marker",
")",
"->",
"trigger",
"(",
")",
";",
"}",
"}",
"}",
"}"
] | Set the marking allocation for multiple users
@return void | [
"Set",
"the",
"marking",
"allocation",
"for",
"multiple",
"users"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L8055-L8104 |
215,041 | moodle/moodle | mod/assign/locallib.php | assign.process_lock_submission | protected function process_lock_submission($userid = 0) {
require_sesskey();
if (!$userid) {
$userid = required_param('userid', PARAM_INT);
}
return $this->lock_submission($userid);
} | php | protected function process_lock_submission($userid = 0) {
require_sesskey();
if (!$userid) {
$userid = required_param('userid', PARAM_INT);
}
return $this->lock_submission($userid);
} | [
"protected",
"function",
"process_lock_submission",
"(",
"$",
"userid",
"=",
"0",
")",
"{",
"require_sesskey",
"(",
")",
";",
"if",
"(",
"!",
"$",
"userid",
")",
"{",
"$",
"userid",
"=",
"required_param",
"(",
"'userid'",
",",
"PARAM_INT",
")",
";",
"}",
"return",
"$",
"this",
"->",
"lock_submission",
"(",
"$",
"userid",
")",
";",
"}"
] | Prevent student updates to this submission.
Uses url parameter userid.
@param int $userid
@return void | [
"Prevent",
"student",
"updates",
"to",
"this",
"submission",
".",
"Uses",
"url",
"parameter",
"userid",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L8114-L8123 |
215,042 | moodle/moodle | mod/assign/locallib.php | assign.process_unlock_submission | protected function process_unlock_submission($userid = 0) {
require_sesskey();
if (!$userid) {
$userid = required_param('userid', PARAM_INT);
}
return $this->unlock_submission($userid);
} | php | protected function process_unlock_submission($userid = 0) {
require_sesskey();
if (!$userid) {
$userid = required_param('userid', PARAM_INT);
}
return $this->unlock_submission($userid);
} | [
"protected",
"function",
"process_unlock_submission",
"(",
"$",
"userid",
"=",
"0",
")",
"{",
"require_sesskey",
"(",
")",
";",
"if",
"(",
"!",
"$",
"userid",
")",
"{",
"$",
"userid",
"=",
"required_param",
"(",
"'userid'",
",",
"PARAM_INT",
")",
";",
"}",
"return",
"$",
"this",
"->",
"unlock_submission",
"(",
"$",
"userid",
")",
";",
"}"
] | Unlock the student submission.
Uses url parameter userid.
@param int $userid
@return bool | [
"Unlock",
"the",
"student",
"submission",
".",
"Uses",
"url",
"parameter",
"userid",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L8163-L8172 |
215,043 | moodle/moodle | mod/assign/locallib.php | assign.process_outcomes | protected function process_outcomes($userid, $formdata, $sourceuserid = null) {
global $CFG, $USER;
if (empty($CFG->enableoutcomes)) {
return;
}
if ($this->grading_disabled($userid)) {
return;
}
require_once($CFG->libdir.'/gradelib.php');
$data = array();
$gradinginfo = grade_get_grades($this->get_course()->id,
'mod',
'assign',
$this->get_instance()->id,
$userid);
if (!empty($gradinginfo->outcomes)) {
foreach ($gradinginfo->outcomes as $index => $oldoutcome) {
$name = 'outcome_'.$index;
$sourceuserid = $sourceuserid !== null ? $sourceuserid : $userid;
if (isset($formdata->{$name}[$sourceuserid]) &&
$oldoutcome->grades[$userid]->grade != $formdata->{$name}[$sourceuserid]) {
$data[$index] = $formdata->{$name}[$sourceuserid];
}
}
}
if (count($data) > 0) {
grade_update_outcomes('mod/assign',
$this->course->id,
'mod',
'assign',
$this->get_instance()->id,
$userid,
$data);
}
} | php | protected function process_outcomes($userid, $formdata, $sourceuserid = null) {
global $CFG, $USER;
if (empty($CFG->enableoutcomes)) {
return;
}
if ($this->grading_disabled($userid)) {
return;
}
require_once($CFG->libdir.'/gradelib.php');
$data = array();
$gradinginfo = grade_get_grades($this->get_course()->id,
'mod',
'assign',
$this->get_instance()->id,
$userid);
if (!empty($gradinginfo->outcomes)) {
foreach ($gradinginfo->outcomes as $index => $oldoutcome) {
$name = 'outcome_'.$index;
$sourceuserid = $sourceuserid !== null ? $sourceuserid : $userid;
if (isset($formdata->{$name}[$sourceuserid]) &&
$oldoutcome->grades[$userid]->grade != $formdata->{$name}[$sourceuserid]) {
$data[$index] = $formdata->{$name}[$sourceuserid];
}
}
}
if (count($data) > 0) {
grade_update_outcomes('mod/assign',
$this->course->id,
'mod',
'assign',
$this->get_instance()->id,
$userid,
$data);
}
} | [
"protected",
"function",
"process_outcomes",
"(",
"$",
"userid",
",",
"$",
"formdata",
",",
"$",
"sourceuserid",
"=",
"null",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"USER",
";",
"if",
"(",
"empty",
"(",
"$",
"CFG",
"->",
"enableoutcomes",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"grading_disabled",
"(",
"$",
"userid",
")",
")",
"{",
"return",
";",
"}",
"require_once",
"(",
"$",
"CFG",
"->",
"libdir",
".",
"'/gradelib.php'",
")",
";",
"$",
"data",
"=",
"array",
"(",
")",
";",
"$",
"gradinginfo",
"=",
"grade_get_grades",
"(",
"$",
"this",
"->",
"get_course",
"(",
")",
"->",
"id",
",",
"'mod'",
",",
"'assign'",
",",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"id",
",",
"$",
"userid",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"gradinginfo",
"->",
"outcomes",
")",
")",
"{",
"foreach",
"(",
"$",
"gradinginfo",
"->",
"outcomes",
"as",
"$",
"index",
"=>",
"$",
"oldoutcome",
")",
"{",
"$",
"name",
"=",
"'outcome_'",
".",
"$",
"index",
";",
"$",
"sourceuserid",
"=",
"$",
"sourceuserid",
"!==",
"null",
"?",
"$",
"sourceuserid",
":",
"$",
"userid",
";",
"if",
"(",
"isset",
"(",
"$",
"formdata",
"->",
"{",
"$",
"name",
"}",
"[",
"$",
"sourceuserid",
"]",
")",
"&&",
"$",
"oldoutcome",
"->",
"grades",
"[",
"$",
"userid",
"]",
"->",
"grade",
"!=",
"$",
"formdata",
"->",
"{",
"$",
"name",
"}",
"[",
"$",
"sourceuserid",
"]",
")",
"{",
"$",
"data",
"[",
"$",
"index",
"]",
"=",
"$",
"formdata",
"->",
"{",
"$",
"name",
"}",
"[",
"$",
"sourceuserid",
"]",
";",
"}",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"data",
")",
">",
"0",
")",
"{",
"grade_update_outcomes",
"(",
"'mod/assign'",
",",
"$",
"this",
"->",
"course",
"->",
"id",
",",
"'mod'",
",",
"'assign'",
",",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"id",
",",
"$",
"userid",
",",
"$",
"data",
")",
";",
"}",
"}"
] | Save outcomes submitted from grading form.
@param int $userid
@param stdClass $formdata
@param int $sourceuserid The user ID under which the outcome data is accessible. This is relevant
for an outcome set to a user but applied to an entire group. | [
"Save",
"outcomes",
"submitted",
"from",
"grading",
"form",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L8271-L8309 |
215,044 | moodle/moodle | mod/assign/locallib.php | assign.reopen_submission_if_required | protected function reopen_submission_if_required($userid, $submission, $addattempt) {
$instance = $this->get_instance();
$maxattemptsreached = !empty($submission) &&
$submission->attemptnumber >= ($instance->maxattempts - 1) &&
$instance->maxattempts != ASSIGN_UNLIMITED_ATTEMPTS;
$shouldreopen = false;
if ($instance->attemptreopenmethod == ASSIGN_ATTEMPT_REOPEN_METHOD_UNTILPASS) {
// Check the gradetopass from the gradebook.
$gradeitem = $this->get_grade_item();
if ($gradeitem) {
$gradegrade = grade_grade::fetch(array('userid' => $userid, 'itemid' => $gradeitem->id));
// Do not reopen if is_passed returns null, e.g. if there is no pass criterion set.
if ($gradegrade && ($gradegrade->is_passed() === false)) {
$shouldreopen = true;
}
}
}
if ($instance->attemptreopenmethod == ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL &&
!empty($addattempt)) {
$shouldreopen = true;
}
if ($shouldreopen && !$maxattemptsreached) {
$this->add_attempt($userid);
return true;
}
return false;
} | php | protected function reopen_submission_if_required($userid, $submission, $addattempt) {
$instance = $this->get_instance();
$maxattemptsreached = !empty($submission) &&
$submission->attemptnumber >= ($instance->maxattempts - 1) &&
$instance->maxattempts != ASSIGN_UNLIMITED_ATTEMPTS;
$shouldreopen = false;
if ($instance->attemptreopenmethod == ASSIGN_ATTEMPT_REOPEN_METHOD_UNTILPASS) {
// Check the gradetopass from the gradebook.
$gradeitem = $this->get_grade_item();
if ($gradeitem) {
$gradegrade = grade_grade::fetch(array('userid' => $userid, 'itemid' => $gradeitem->id));
// Do not reopen if is_passed returns null, e.g. if there is no pass criterion set.
if ($gradegrade && ($gradegrade->is_passed() === false)) {
$shouldreopen = true;
}
}
}
if ($instance->attemptreopenmethod == ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL &&
!empty($addattempt)) {
$shouldreopen = true;
}
if ($shouldreopen && !$maxattemptsreached) {
$this->add_attempt($userid);
return true;
}
return false;
} | [
"protected",
"function",
"reopen_submission_if_required",
"(",
"$",
"userid",
",",
"$",
"submission",
",",
"$",
"addattempt",
")",
"{",
"$",
"instance",
"=",
"$",
"this",
"->",
"get_instance",
"(",
")",
";",
"$",
"maxattemptsreached",
"=",
"!",
"empty",
"(",
"$",
"submission",
")",
"&&",
"$",
"submission",
"->",
"attemptnumber",
">=",
"(",
"$",
"instance",
"->",
"maxattempts",
"-",
"1",
")",
"&&",
"$",
"instance",
"->",
"maxattempts",
"!=",
"ASSIGN_UNLIMITED_ATTEMPTS",
";",
"$",
"shouldreopen",
"=",
"false",
";",
"if",
"(",
"$",
"instance",
"->",
"attemptreopenmethod",
"==",
"ASSIGN_ATTEMPT_REOPEN_METHOD_UNTILPASS",
")",
"{",
"// Check the gradetopass from the gradebook.",
"$",
"gradeitem",
"=",
"$",
"this",
"->",
"get_grade_item",
"(",
")",
";",
"if",
"(",
"$",
"gradeitem",
")",
"{",
"$",
"gradegrade",
"=",
"grade_grade",
"::",
"fetch",
"(",
"array",
"(",
"'userid'",
"=>",
"$",
"userid",
",",
"'itemid'",
"=>",
"$",
"gradeitem",
"->",
"id",
")",
")",
";",
"// Do not reopen if is_passed returns null, e.g. if there is no pass criterion set.",
"if",
"(",
"$",
"gradegrade",
"&&",
"(",
"$",
"gradegrade",
"->",
"is_passed",
"(",
")",
"===",
"false",
")",
")",
"{",
"$",
"shouldreopen",
"=",
"true",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"instance",
"->",
"attemptreopenmethod",
"==",
"ASSIGN_ATTEMPT_REOPEN_METHOD_MANUAL",
"&&",
"!",
"empty",
"(",
"$",
"addattempt",
")",
")",
"{",
"$",
"shouldreopen",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"shouldreopen",
"&&",
"!",
"$",
"maxattemptsreached",
")",
"{",
"$",
"this",
"->",
"add_attempt",
"(",
"$",
"userid",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | If the requirements are met - reopen the submission for another attempt.
Only call this function when grading the latest attempt.
@param int $userid The userid.
@param stdClass $submission The submission (may be a group submission).
@param bool $addattempt - True if the "allow another attempt" checkbox was checked.
@return bool - true if another attempt was added. | [
"If",
"the",
"requirements",
"are",
"met",
"-",
"reopen",
"the",
"submission",
"for",
"another",
"attempt",
".",
"Only",
"call",
"this",
"function",
"when",
"grading",
"the",
"latest",
"attempt",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L8320-L8347 |
215,045 | moodle/moodle | mod/assign/locallib.php | assign.save_grade | public function save_grade($userid, $data) {
// Need grade permission.
require_capability('mod/assign:grade', $this->context);
$instance = $this->get_instance();
$submission = null;
if ($instance->teamsubmission) {
// We need to know what the most recent group submission is.
// Specifically when determining if we are adding another attempt (we only want to add one attempt per team),
// and when deciding if we need to update the gradebook with an edited grade.
$mostrecentsubmission = $this->get_group_submission($userid, 0, false, -1);
$this->set_most_recent_team_submission($mostrecentsubmission);
// Get the submission that we are saving grades for. The data attempt number determines which submission attempt.
$submission = $this->get_group_submission($userid, 0, false, $data->attemptnumber);
} else {
$submission = $this->get_user_submission($userid, false, $data->attemptnumber);
}
if ($instance->teamsubmission && !empty($data->applytoall)) {
$groupid = 0;
if ($this->get_submission_group($userid)) {
$group = $this->get_submission_group($userid);
if ($group) {
$groupid = $group->id;
}
}
$members = $this->get_submission_group_members($groupid, true, $this->show_only_active_users());
foreach ($members as $member) {
// We only want to update the grade for this group submission attempt. The data attempt number could be
// -1 which may end up in additional attempts being created for each group member instead of just one
// additional attempt for the group.
$this->apply_grade_to_user($data, $member->id, $submission->attemptnumber);
$this->process_outcomes($member->id, $data, $userid);
}
} else {
$this->apply_grade_to_user($data, $userid, $data->attemptnumber);
$this->process_outcomes($userid, $data);
}
return true;
} | php | public function save_grade($userid, $data) {
// Need grade permission.
require_capability('mod/assign:grade', $this->context);
$instance = $this->get_instance();
$submission = null;
if ($instance->teamsubmission) {
// We need to know what the most recent group submission is.
// Specifically when determining if we are adding another attempt (we only want to add one attempt per team),
// and when deciding if we need to update the gradebook with an edited grade.
$mostrecentsubmission = $this->get_group_submission($userid, 0, false, -1);
$this->set_most_recent_team_submission($mostrecentsubmission);
// Get the submission that we are saving grades for. The data attempt number determines which submission attempt.
$submission = $this->get_group_submission($userid, 0, false, $data->attemptnumber);
} else {
$submission = $this->get_user_submission($userid, false, $data->attemptnumber);
}
if ($instance->teamsubmission && !empty($data->applytoall)) {
$groupid = 0;
if ($this->get_submission_group($userid)) {
$group = $this->get_submission_group($userid);
if ($group) {
$groupid = $group->id;
}
}
$members = $this->get_submission_group_members($groupid, true, $this->show_only_active_users());
foreach ($members as $member) {
// We only want to update the grade for this group submission attempt. The data attempt number could be
// -1 which may end up in additional attempts being created for each group member instead of just one
// additional attempt for the group.
$this->apply_grade_to_user($data, $member->id, $submission->attemptnumber);
$this->process_outcomes($member->id, $data, $userid);
}
} else {
$this->apply_grade_to_user($data, $userid, $data->attemptnumber);
$this->process_outcomes($userid, $data);
}
return true;
} | [
"public",
"function",
"save_grade",
"(",
"$",
"userid",
",",
"$",
"data",
")",
"{",
"// Need grade permission.",
"require_capability",
"(",
"'mod/assign:grade'",
",",
"$",
"this",
"->",
"context",
")",
";",
"$",
"instance",
"=",
"$",
"this",
"->",
"get_instance",
"(",
")",
";",
"$",
"submission",
"=",
"null",
";",
"if",
"(",
"$",
"instance",
"->",
"teamsubmission",
")",
"{",
"// We need to know what the most recent group submission is.",
"// Specifically when determining if we are adding another attempt (we only want to add one attempt per team),",
"// and when deciding if we need to update the gradebook with an edited grade.",
"$",
"mostrecentsubmission",
"=",
"$",
"this",
"->",
"get_group_submission",
"(",
"$",
"userid",
",",
"0",
",",
"false",
",",
"-",
"1",
")",
";",
"$",
"this",
"->",
"set_most_recent_team_submission",
"(",
"$",
"mostrecentsubmission",
")",
";",
"// Get the submission that we are saving grades for. The data attempt number determines which submission attempt.",
"$",
"submission",
"=",
"$",
"this",
"->",
"get_group_submission",
"(",
"$",
"userid",
",",
"0",
",",
"false",
",",
"$",
"data",
"->",
"attemptnumber",
")",
";",
"}",
"else",
"{",
"$",
"submission",
"=",
"$",
"this",
"->",
"get_user_submission",
"(",
"$",
"userid",
",",
"false",
",",
"$",
"data",
"->",
"attemptnumber",
")",
";",
"}",
"if",
"(",
"$",
"instance",
"->",
"teamsubmission",
"&&",
"!",
"empty",
"(",
"$",
"data",
"->",
"applytoall",
")",
")",
"{",
"$",
"groupid",
"=",
"0",
";",
"if",
"(",
"$",
"this",
"->",
"get_submission_group",
"(",
"$",
"userid",
")",
")",
"{",
"$",
"group",
"=",
"$",
"this",
"->",
"get_submission_group",
"(",
"$",
"userid",
")",
";",
"if",
"(",
"$",
"group",
")",
"{",
"$",
"groupid",
"=",
"$",
"group",
"->",
"id",
";",
"}",
"}",
"$",
"members",
"=",
"$",
"this",
"->",
"get_submission_group_members",
"(",
"$",
"groupid",
",",
"true",
",",
"$",
"this",
"->",
"show_only_active_users",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"members",
"as",
"$",
"member",
")",
"{",
"// We only want to update the grade for this group submission attempt. The data attempt number could be",
"// -1 which may end up in additional attempts being created for each group member instead of just one",
"// additional attempt for the group.",
"$",
"this",
"->",
"apply_grade_to_user",
"(",
"$",
"data",
",",
"$",
"member",
"->",
"id",
",",
"$",
"submission",
"->",
"attemptnumber",
")",
";",
"$",
"this",
"->",
"process_outcomes",
"(",
"$",
"member",
"->",
"id",
",",
"$",
"data",
",",
"$",
"userid",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"apply_grade_to_user",
"(",
"$",
"data",
",",
"$",
"userid",
",",
"$",
"data",
"->",
"attemptnumber",
")",
";",
"$",
"this",
"->",
"process_outcomes",
"(",
"$",
"userid",
",",
"$",
"data",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Save grade update.
@param int $userid
@param stdClass $data
@return bool - was the grade saved | [
"Save",
"grade",
"update",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L8356-L8397 |
215,046 | moodle/moodle | mod/assign/locallib.php | assign.process_save_grade | protected function process_save_grade(&$mform) {
global $CFG, $SESSION;
// Include grade form.
require_once($CFG->dirroot . '/mod/assign/gradeform.php');
require_sesskey();
$instance = $this->get_instance();
$rownum = required_param('rownum', PARAM_INT);
$attemptnumber = optional_param('attemptnumber', -1, PARAM_INT);
$useridlistid = optional_param('useridlistid', $this->get_useridlist_key_id(), PARAM_ALPHANUM);
$userid = optional_param('userid', 0, PARAM_INT);
if (!$userid) {
if (empty($SESSION->mod_assign_useridlist[$this->get_useridlist_key($useridlistid)])) {
// If the userid list is not stored we must not save, as it is possible that the user in a
// given row position may not be the same now as when the grading page was generated.
$url = new moodle_url('/mod/assign/view.php', array('id' => $this->get_course_module()->id));
throw new moodle_exception('useridlistnotcached', 'mod_assign', $url);
}
$useridlist = $SESSION->mod_assign_useridlist[$this->get_useridlist_key($useridlistid)];
} else {
$useridlist = array($userid);
$rownum = 0;
}
$last = false;
$userid = $useridlist[$rownum];
if ($rownum == count($useridlist) - 1) {
$last = true;
}
$data = new stdClass();
$gradeformparams = array('rownum' => $rownum,
'useridlistid' => $useridlistid,
'last' => $last,
'attemptnumber' => $attemptnumber,
'userid' => $userid);
$mform = new mod_assign_grade_form(null,
array($this, $data, $gradeformparams),
'post',
'',
array('class'=>'gradeform'));
if ($formdata = $mform->get_data()) {
return $this->save_grade($userid, $formdata);
} else {
return false;
}
} | php | protected function process_save_grade(&$mform) {
global $CFG, $SESSION;
// Include grade form.
require_once($CFG->dirroot . '/mod/assign/gradeform.php');
require_sesskey();
$instance = $this->get_instance();
$rownum = required_param('rownum', PARAM_INT);
$attemptnumber = optional_param('attemptnumber', -1, PARAM_INT);
$useridlistid = optional_param('useridlistid', $this->get_useridlist_key_id(), PARAM_ALPHANUM);
$userid = optional_param('userid', 0, PARAM_INT);
if (!$userid) {
if (empty($SESSION->mod_assign_useridlist[$this->get_useridlist_key($useridlistid)])) {
// If the userid list is not stored we must not save, as it is possible that the user in a
// given row position may not be the same now as when the grading page was generated.
$url = new moodle_url('/mod/assign/view.php', array('id' => $this->get_course_module()->id));
throw new moodle_exception('useridlistnotcached', 'mod_assign', $url);
}
$useridlist = $SESSION->mod_assign_useridlist[$this->get_useridlist_key($useridlistid)];
} else {
$useridlist = array($userid);
$rownum = 0;
}
$last = false;
$userid = $useridlist[$rownum];
if ($rownum == count($useridlist) - 1) {
$last = true;
}
$data = new stdClass();
$gradeformparams = array('rownum' => $rownum,
'useridlistid' => $useridlistid,
'last' => $last,
'attemptnumber' => $attemptnumber,
'userid' => $userid);
$mform = new mod_assign_grade_form(null,
array($this, $data, $gradeformparams),
'post',
'',
array('class'=>'gradeform'));
if ($formdata = $mform->get_data()) {
return $this->save_grade($userid, $formdata);
} else {
return false;
}
} | [
"protected",
"function",
"process_save_grade",
"(",
"&",
"$",
"mform",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"SESSION",
";",
"// Include grade form.",
"require_once",
"(",
"$",
"CFG",
"->",
"dirroot",
".",
"'/mod/assign/gradeform.php'",
")",
";",
"require_sesskey",
"(",
")",
";",
"$",
"instance",
"=",
"$",
"this",
"->",
"get_instance",
"(",
")",
";",
"$",
"rownum",
"=",
"required_param",
"(",
"'rownum'",
",",
"PARAM_INT",
")",
";",
"$",
"attemptnumber",
"=",
"optional_param",
"(",
"'attemptnumber'",
",",
"-",
"1",
",",
"PARAM_INT",
")",
";",
"$",
"useridlistid",
"=",
"optional_param",
"(",
"'useridlistid'",
",",
"$",
"this",
"->",
"get_useridlist_key_id",
"(",
")",
",",
"PARAM_ALPHANUM",
")",
";",
"$",
"userid",
"=",
"optional_param",
"(",
"'userid'",
",",
"0",
",",
"PARAM_INT",
")",
";",
"if",
"(",
"!",
"$",
"userid",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"SESSION",
"->",
"mod_assign_useridlist",
"[",
"$",
"this",
"->",
"get_useridlist_key",
"(",
"$",
"useridlistid",
")",
"]",
")",
")",
"{",
"// If the userid list is not stored we must not save, as it is possible that the user in a",
"// given row position may not be the same now as when the grading page was generated.",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"'/mod/assign/view.php'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"this",
"->",
"get_course_module",
"(",
")",
"->",
"id",
")",
")",
";",
"throw",
"new",
"moodle_exception",
"(",
"'useridlistnotcached'",
",",
"'mod_assign'",
",",
"$",
"url",
")",
";",
"}",
"$",
"useridlist",
"=",
"$",
"SESSION",
"->",
"mod_assign_useridlist",
"[",
"$",
"this",
"->",
"get_useridlist_key",
"(",
"$",
"useridlistid",
")",
"]",
";",
"}",
"else",
"{",
"$",
"useridlist",
"=",
"array",
"(",
"$",
"userid",
")",
";",
"$",
"rownum",
"=",
"0",
";",
"}",
"$",
"last",
"=",
"false",
";",
"$",
"userid",
"=",
"$",
"useridlist",
"[",
"$",
"rownum",
"]",
";",
"if",
"(",
"$",
"rownum",
"==",
"count",
"(",
"$",
"useridlist",
")",
"-",
"1",
")",
"{",
"$",
"last",
"=",
"true",
";",
"}",
"$",
"data",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"gradeformparams",
"=",
"array",
"(",
"'rownum'",
"=>",
"$",
"rownum",
",",
"'useridlistid'",
"=>",
"$",
"useridlistid",
",",
"'last'",
"=>",
"$",
"last",
",",
"'attemptnumber'",
"=>",
"$",
"attemptnumber",
",",
"'userid'",
"=>",
"$",
"userid",
")",
";",
"$",
"mform",
"=",
"new",
"mod_assign_grade_form",
"(",
"null",
",",
"array",
"(",
"$",
"this",
",",
"$",
"data",
",",
"$",
"gradeformparams",
")",
",",
"'post'",
",",
"''",
",",
"array",
"(",
"'class'",
"=>",
"'gradeform'",
")",
")",
";",
"if",
"(",
"$",
"formdata",
"=",
"$",
"mform",
"->",
"get_data",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"save_grade",
"(",
"$",
"userid",
",",
"$",
"formdata",
")",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Save grade.
@param moodleform $mform
@return bool - was the grade saved | [
"Save",
"grade",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L8405-L8454 |
215,047 | moodle/moodle | mod/assign/locallib.php | assign.can_upgrade_assignment | public static function can_upgrade_assignment($type, $version) {
$assignment = new assign(null, null, null);
return $assignment->can_upgrade($type, $version);
} | php | public static function can_upgrade_assignment($type, $version) {
$assignment = new assign(null, null, null);
return $assignment->can_upgrade($type, $version);
} | [
"public",
"static",
"function",
"can_upgrade_assignment",
"(",
"$",
"type",
",",
"$",
"version",
")",
"{",
"$",
"assignment",
"=",
"new",
"assign",
"(",
"null",
",",
"null",
",",
"null",
")",
";",
"return",
"$",
"assignment",
"->",
"can_upgrade",
"(",
"$",
"type",
",",
"$",
"version",
")",
";",
"}"
] | This function is a static wrapper around can_upgrade.
@param string $type The plugin type
@param int $version The plugin version
@return bool | [
"This",
"function",
"is",
"a",
"static",
"wrapper",
"around",
"can_upgrade",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L8463-L8466 |
215,048 | moodle/moodle | mod/assign/locallib.php | assign.can_upgrade | public function can_upgrade($type, $version) {
if ($type == 'offline' && $version >= 2011112900) {
return true;
}
foreach ($this->submissionplugins as $plugin) {
if ($plugin->can_upgrade($type, $version)) {
return true;
}
}
foreach ($this->feedbackplugins as $plugin) {
if ($plugin->can_upgrade($type, $version)) {
return true;
}
}
return false;
} | php | public function can_upgrade($type, $version) {
if ($type == 'offline' && $version >= 2011112900) {
return true;
}
foreach ($this->submissionplugins as $plugin) {
if ($plugin->can_upgrade($type, $version)) {
return true;
}
}
foreach ($this->feedbackplugins as $plugin) {
if ($plugin->can_upgrade($type, $version)) {
return true;
}
}
return false;
} | [
"public",
"function",
"can_upgrade",
"(",
"$",
"type",
",",
"$",
"version",
")",
"{",
"if",
"(",
"$",
"type",
"==",
"'offline'",
"&&",
"$",
"version",
">=",
"2011112900",
")",
"{",
"return",
"true",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"submissionplugins",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
"$",
"plugin",
"->",
"can_upgrade",
"(",
"$",
"type",
",",
"$",
"version",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"feedbackplugins",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
"$",
"plugin",
"->",
"can_upgrade",
"(",
"$",
"type",
",",
"$",
"version",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | This function returns true if it can upgrade an assignment from the 2.2 module.
@param string $type The plugin type
@param int $version The plugin version
@return bool | [
"This",
"function",
"returns",
"true",
"if",
"it",
"can",
"upgrade",
"an",
"assignment",
"from",
"the",
"2",
".",
"2",
"module",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L8475-L8490 |
215,049 | moodle/moodle | mod/assign/locallib.php | assign.copy_area_files_for_upgrade | public function copy_area_files_for_upgrade($oldcontextid,
$oldcomponent,
$oldfilearea,
$olditemid,
$newcontextid,
$newcomponent,
$newfilearea,
$newitemid) {
// Note, this code is based on some code in filestorage - but that code
// deleted the old files (which we don't want).
$count = 0;
$fs = get_file_storage();
$oldfiles = $fs->get_area_files($oldcontextid,
$oldcomponent,
$oldfilearea,
$olditemid,
'id',
false);
foreach ($oldfiles as $oldfile) {
$filerecord = new stdClass();
$filerecord->contextid = $newcontextid;
$filerecord->component = $newcomponent;
$filerecord->filearea = $newfilearea;
$filerecord->itemid = $newitemid;
$fs->create_file_from_storedfile($filerecord, $oldfile);
$count += 1;
}
return $count;
} | php | public function copy_area_files_for_upgrade($oldcontextid,
$oldcomponent,
$oldfilearea,
$olditemid,
$newcontextid,
$newcomponent,
$newfilearea,
$newitemid) {
// Note, this code is based on some code in filestorage - but that code
// deleted the old files (which we don't want).
$count = 0;
$fs = get_file_storage();
$oldfiles = $fs->get_area_files($oldcontextid,
$oldcomponent,
$oldfilearea,
$olditemid,
'id',
false);
foreach ($oldfiles as $oldfile) {
$filerecord = new stdClass();
$filerecord->contextid = $newcontextid;
$filerecord->component = $newcomponent;
$filerecord->filearea = $newfilearea;
$filerecord->itemid = $newitemid;
$fs->create_file_from_storedfile($filerecord, $oldfile);
$count += 1;
}
return $count;
} | [
"public",
"function",
"copy_area_files_for_upgrade",
"(",
"$",
"oldcontextid",
",",
"$",
"oldcomponent",
",",
"$",
"oldfilearea",
",",
"$",
"olditemid",
",",
"$",
"newcontextid",
",",
"$",
"newcomponent",
",",
"$",
"newfilearea",
",",
"$",
"newitemid",
")",
"{",
"// Note, this code is based on some code in filestorage - but that code",
"// deleted the old files (which we don't want).",
"$",
"count",
"=",
"0",
";",
"$",
"fs",
"=",
"get_file_storage",
"(",
")",
";",
"$",
"oldfiles",
"=",
"$",
"fs",
"->",
"get_area_files",
"(",
"$",
"oldcontextid",
",",
"$",
"oldcomponent",
",",
"$",
"oldfilearea",
",",
"$",
"olditemid",
",",
"'id'",
",",
"false",
")",
";",
"foreach",
"(",
"$",
"oldfiles",
"as",
"$",
"oldfile",
")",
"{",
"$",
"filerecord",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"filerecord",
"->",
"contextid",
"=",
"$",
"newcontextid",
";",
"$",
"filerecord",
"->",
"component",
"=",
"$",
"newcomponent",
";",
"$",
"filerecord",
"->",
"filearea",
"=",
"$",
"newfilearea",
";",
"$",
"filerecord",
"->",
"itemid",
"=",
"$",
"newitemid",
";",
"$",
"fs",
"->",
"create_file_from_storedfile",
"(",
"$",
"filerecord",
",",
"$",
"oldfile",
")",
";",
"$",
"count",
"+=",
"1",
";",
"}",
"return",
"$",
"count",
";",
"}"
] | Copy all the files from the old assignment files area to the new one.
This is used by the plugin upgrade code.
@param int $oldcontextid The old assignment context id
@param int $oldcomponent The old assignment component ('assignment')
@param int $oldfilearea The old assignment filearea ('submissions')
@param int $olditemid The old submissionid (can be null e.g. intro)
@param int $newcontextid The new assignment context id
@param int $newcomponent The new assignment component ('assignment')
@param int $newfilearea The new assignment filearea ('submissions')
@param int $newitemid The new submissionid (can be null e.g. intro)
@return int The number of files copied | [
"Copy",
"all",
"the",
"files",
"from",
"the",
"old",
"assignment",
"files",
"area",
"to",
"the",
"new",
"one",
".",
"This",
"is",
"used",
"by",
"the",
"plugin",
"upgrade",
"code",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L8506-L8537 |
215,050 | moodle/moodle | mod/assign/locallib.php | assign.process_add_attempt_group | protected function process_add_attempt_group($useridlist) {
$groupsprocessed = array();
$result = true;
foreach ($useridlist as $userid) {
$groupid = 0;
$group = $this->get_submission_group($userid);
if ($group) {
$groupid = $group->id;
}
if (empty($groupsprocessed[$groupid])) {
// We need to know what the most recent group submission is.
// Specifically when determining if we are adding another attempt (we only want to add one attempt per team),
// and when deciding if we need to update the gradebook with an edited grade.
$currentsubmission = $this->get_group_submission($userid, 0, false, -1);
$this->set_most_recent_team_submission($currentsubmission);
$result = $this->process_add_attempt($userid) && $result;
$groupsprocessed[$groupid] = true;
}
}
return $result;
} | php | protected function process_add_attempt_group($useridlist) {
$groupsprocessed = array();
$result = true;
foreach ($useridlist as $userid) {
$groupid = 0;
$group = $this->get_submission_group($userid);
if ($group) {
$groupid = $group->id;
}
if (empty($groupsprocessed[$groupid])) {
// We need to know what the most recent group submission is.
// Specifically when determining if we are adding another attempt (we only want to add one attempt per team),
// and when deciding if we need to update the gradebook with an edited grade.
$currentsubmission = $this->get_group_submission($userid, 0, false, -1);
$this->set_most_recent_team_submission($currentsubmission);
$result = $this->process_add_attempt($userid) && $result;
$groupsprocessed[$groupid] = true;
}
}
return $result;
} | [
"protected",
"function",
"process_add_attempt_group",
"(",
"$",
"useridlist",
")",
"{",
"$",
"groupsprocessed",
"=",
"array",
"(",
")",
";",
"$",
"result",
"=",
"true",
";",
"foreach",
"(",
"$",
"useridlist",
"as",
"$",
"userid",
")",
"{",
"$",
"groupid",
"=",
"0",
";",
"$",
"group",
"=",
"$",
"this",
"->",
"get_submission_group",
"(",
"$",
"userid",
")",
";",
"if",
"(",
"$",
"group",
")",
"{",
"$",
"groupid",
"=",
"$",
"group",
"->",
"id",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"groupsprocessed",
"[",
"$",
"groupid",
"]",
")",
")",
"{",
"// We need to know what the most recent group submission is.",
"// Specifically when determining if we are adding another attempt (we only want to add one attempt per team),",
"// and when deciding if we need to update the gradebook with an edited grade.",
"$",
"currentsubmission",
"=",
"$",
"this",
"->",
"get_group_submission",
"(",
"$",
"userid",
",",
"0",
",",
"false",
",",
"-",
"1",
")",
";",
"$",
"this",
"->",
"set_most_recent_team_submission",
"(",
"$",
"currentsubmission",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"process_add_attempt",
"(",
"$",
"userid",
")",
"&&",
"$",
"result",
";",
"$",
"groupsprocessed",
"[",
"$",
"groupid",
"]",
"=",
"true",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Add a new attempt for each user in the list - but reopen each group assignment
at most 1 time.
@param array $useridlist Array of userids to reopen.
@return bool | [
"Add",
"a",
"new",
"attempt",
"for",
"each",
"user",
"in",
"the",
"list",
"-",
"but",
"reopen",
"each",
"group",
"assignment",
"at",
"most",
"1",
"time",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L8546-L8568 |
215,051 | moodle/moodle | mod/assign/locallib.php | assign.add_attempt | protected function add_attempt($userid) {
require_capability('mod/assign:grade', $this->context);
if ($this->get_instance()->attemptreopenmethod == ASSIGN_ATTEMPT_REOPEN_METHOD_NONE) {
return false;
}
if ($this->get_instance()->teamsubmission) {
$oldsubmission = $this->get_group_submission($userid, 0, false);
} else {
$oldsubmission = $this->get_user_submission($userid, false);
}
if (!$oldsubmission) {
return false;
}
// No more than max attempts allowed.
if ($this->get_instance()->maxattempts != ASSIGN_UNLIMITED_ATTEMPTS &&
$oldsubmission->attemptnumber >= ($this->get_instance()->maxattempts - 1)) {
return false;
}
// Create the new submission record for the group/user.
if ($this->get_instance()->teamsubmission) {
if (isset($this->mostrecentteamsubmission)) {
// Team submissions can end up in this function for each user (via save_grade). We don't want to create
// more than one attempt for the whole team.
if ($this->mostrecentteamsubmission->attemptnumber == $oldsubmission->attemptnumber) {
$newsubmission = $this->get_group_submission($userid, 0, true, $oldsubmission->attemptnumber + 1);
} else {
$newsubmission = $this->get_group_submission($userid, 0, false, $oldsubmission->attemptnumber);
}
} else {
debugging('Please use set_most_recent_team_submission() before calling add_attempt', DEBUG_DEVELOPER);
$newsubmission = $this->get_group_submission($userid, 0, true, $oldsubmission->attemptnumber + 1);
}
} else {
$newsubmission = $this->get_user_submission($userid, true, $oldsubmission->attemptnumber + 1);
}
// Set the status of the new attempt to reopened.
$newsubmission->status = ASSIGN_SUBMISSION_STATUS_REOPENED;
// Give each submission plugin a chance to process the add_attempt.
$plugins = $this->get_submission_plugins();
foreach ($plugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
$plugin->add_attempt($oldsubmission, $newsubmission);
}
}
$this->update_submission($newsubmission, $userid, false, $this->get_instance()->teamsubmission);
$flags = $this->get_user_flags($userid, false);
if (isset($flags->locked) && $flags->locked) { // May not exist.
$this->process_unlock_submission($userid);
}
return true;
} | php | protected function add_attempt($userid) {
require_capability('mod/assign:grade', $this->context);
if ($this->get_instance()->attemptreopenmethod == ASSIGN_ATTEMPT_REOPEN_METHOD_NONE) {
return false;
}
if ($this->get_instance()->teamsubmission) {
$oldsubmission = $this->get_group_submission($userid, 0, false);
} else {
$oldsubmission = $this->get_user_submission($userid, false);
}
if (!$oldsubmission) {
return false;
}
// No more than max attempts allowed.
if ($this->get_instance()->maxattempts != ASSIGN_UNLIMITED_ATTEMPTS &&
$oldsubmission->attemptnumber >= ($this->get_instance()->maxattempts - 1)) {
return false;
}
// Create the new submission record for the group/user.
if ($this->get_instance()->teamsubmission) {
if (isset($this->mostrecentteamsubmission)) {
// Team submissions can end up in this function for each user (via save_grade). We don't want to create
// more than one attempt for the whole team.
if ($this->mostrecentteamsubmission->attemptnumber == $oldsubmission->attemptnumber) {
$newsubmission = $this->get_group_submission($userid, 0, true, $oldsubmission->attemptnumber + 1);
} else {
$newsubmission = $this->get_group_submission($userid, 0, false, $oldsubmission->attemptnumber);
}
} else {
debugging('Please use set_most_recent_team_submission() before calling add_attempt', DEBUG_DEVELOPER);
$newsubmission = $this->get_group_submission($userid, 0, true, $oldsubmission->attemptnumber + 1);
}
} else {
$newsubmission = $this->get_user_submission($userid, true, $oldsubmission->attemptnumber + 1);
}
// Set the status of the new attempt to reopened.
$newsubmission->status = ASSIGN_SUBMISSION_STATUS_REOPENED;
// Give each submission plugin a chance to process the add_attempt.
$plugins = $this->get_submission_plugins();
foreach ($plugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
$plugin->add_attempt($oldsubmission, $newsubmission);
}
}
$this->update_submission($newsubmission, $userid, false, $this->get_instance()->teamsubmission);
$flags = $this->get_user_flags($userid, false);
if (isset($flags->locked) && $flags->locked) { // May not exist.
$this->process_unlock_submission($userid);
}
return true;
} | [
"protected",
"function",
"add_attempt",
"(",
"$",
"userid",
")",
"{",
"require_capability",
"(",
"'mod/assign:grade'",
",",
"$",
"this",
"->",
"context",
")",
";",
"if",
"(",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"attemptreopenmethod",
"==",
"ASSIGN_ATTEMPT_REOPEN_METHOD_NONE",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"teamsubmission",
")",
"{",
"$",
"oldsubmission",
"=",
"$",
"this",
"->",
"get_group_submission",
"(",
"$",
"userid",
",",
"0",
",",
"false",
")",
";",
"}",
"else",
"{",
"$",
"oldsubmission",
"=",
"$",
"this",
"->",
"get_user_submission",
"(",
"$",
"userid",
",",
"false",
")",
";",
"}",
"if",
"(",
"!",
"$",
"oldsubmission",
")",
"{",
"return",
"false",
";",
"}",
"// No more than max attempts allowed.",
"if",
"(",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"maxattempts",
"!=",
"ASSIGN_UNLIMITED_ATTEMPTS",
"&&",
"$",
"oldsubmission",
"->",
"attemptnumber",
">=",
"(",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"maxattempts",
"-",
"1",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Create the new submission record for the group/user.",
"if",
"(",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"teamsubmission",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"mostrecentteamsubmission",
")",
")",
"{",
"// Team submissions can end up in this function for each user (via save_grade). We don't want to create",
"// more than one attempt for the whole team.",
"if",
"(",
"$",
"this",
"->",
"mostrecentteamsubmission",
"->",
"attemptnumber",
"==",
"$",
"oldsubmission",
"->",
"attemptnumber",
")",
"{",
"$",
"newsubmission",
"=",
"$",
"this",
"->",
"get_group_submission",
"(",
"$",
"userid",
",",
"0",
",",
"true",
",",
"$",
"oldsubmission",
"->",
"attemptnumber",
"+",
"1",
")",
";",
"}",
"else",
"{",
"$",
"newsubmission",
"=",
"$",
"this",
"->",
"get_group_submission",
"(",
"$",
"userid",
",",
"0",
",",
"false",
",",
"$",
"oldsubmission",
"->",
"attemptnumber",
")",
";",
"}",
"}",
"else",
"{",
"debugging",
"(",
"'Please use set_most_recent_team_submission() before calling add_attempt'",
",",
"DEBUG_DEVELOPER",
")",
";",
"$",
"newsubmission",
"=",
"$",
"this",
"->",
"get_group_submission",
"(",
"$",
"userid",
",",
"0",
",",
"true",
",",
"$",
"oldsubmission",
"->",
"attemptnumber",
"+",
"1",
")",
";",
"}",
"}",
"else",
"{",
"$",
"newsubmission",
"=",
"$",
"this",
"->",
"get_user_submission",
"(",
"$",
"userid",
",",
"true",
",",
"$",
"oldsubmission",
"->",
"attemptnumber",
"+",
"1",
")",
";",
"}",
"// Set the status of the new attempt to reopened.",
"$",
"newsubmission",
"->",
"status",
"=",
"ASSIGN_SUBMISSION_STATUS_REOPENED",
";",
"// Give each submission plugin a chance to process the add_attempt.",
"$",
"plugins",
"=",
"$",
"this",
"->",
"get_submission_plugins",
"(",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
"$",
"plugin",
"->",
"is_enabled",
"(",
")",
"&&",
"$",
"plugin",
"->",
"is_visible",
"(",
")",
")",
"{",
"$",
"plugin",
"->",
"add_attempt",
"(",
"$",
"oldsubmission",
",",
"$",
"newsubmission",
")",
";",
"}",
"}",
"$",
"this",
"->",
"update_submission",
"(",
"$",
"newsubmission",
",",
"$",
"userid",
",",
"false",
",",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"teamsubmission",
")",
";",
"$",
"flags",
"=",
"$",
"this",
"->",
"get_user_flags",
"(",
"$",
"userid",
",",
"false",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"flags",
"->",
"locked",
")",
"&&",
"$",
"flags",
"->",
"locked",
")",
"{",
"// May not exist.",
"$",
"this",
"->",
"process_unlock_submission",
"(",
"$",
"userid",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Add a new attempt for a user.
@param int $userid int The user to add the attempt for
@return bool - true if successful. | [
"Add",
"a",
"new",
"attempt",
"for",
"a",
"user",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L8588-L8646 |
215,052 | moodle/moodle | mod/assign/locallib.php | assign.get_user_grades_for_gradebook | public function get_user_grades_for_gradebook($userid) {
global $DB, $CFG;
$grades = array();
$assignmentid = $this->get_instance()->id;
$adminconfig = $this->get_admin_config();
$gradebookpluginname = $adminconfig->feedback_plugin_for_gradebook;
$gradebookplugin = null;
// Find the gradebook plugin.
foreach ($this->feedbackplugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
if (('assignfeedback_' . $plugin->get_type()) == $gradebookpluginname) {
$gradebookplugin = $plugin;
}
}
}
if ($userid) {
$where = ' WHERE u.id = :userid ';
} else {
$where = ' WHERE u.id != :userid ';
}
// When the gradebook asks us for grades - only return the last attempt for each user.
$params = array('assignid1'=>$assignmentid,
'assignid2'=>$assignmentid,
'userid'=>$userid);
$graderesults = $DB->get_recordset_sql('SELECT
u.id as userid,
s.timemodified as datesubmitted,
g.grade as rawgrade,
g.timemodified as dategraded,
g.grader as usermodified
FROM {user} u
LEFT JOIN {assign_submission} s
ON u.id = s.userid and s.assignment = :assignid1 AND
s.latest = 1
JOIN {assign_grades} g
ON u.id = g.userid and g.assignment = :assignid2 AND
g.attemptnumber = s.attemptnumber' .
$where, $params);
foreach ($graderesults as $result) {
$gradingstatus = $this->get_grading_status($result->userid);
if (!$this->get_instance()->markingworkflow || $gradingstatus == ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
$gradebookgrade = clone $result;
// Now get the feedback.
if ($gradebookplugin) {
$grade = $this->get_user_grade($result->userid, false);
if ($grade) {
$gradebookgrade->feedback = $gradebookplugin->text_for_gradebook($grade);
$gradebookgrade->feedbackformat = $gradebookplugin->format_for_gradebook($grade);
$gradebookgrade->feedbackfiles = $gradebookplugin->files_for_gradebook($grade);
}
}
$grades[$gradebookgrade->userid] = $gradebookgrade;
}
}
$graderesults->close();
return $grades;
} | php | public function get_user_grades_for_gradebook($userid) {
global $DB, $CFG;
$grades = array();
$assignmentid = $this->get_instance()->id;
$adminconfig = $this->get_admin_config();
$gradebookpluginname = $adminconfig->feedback_plugin_for_gradebook;
$gradebookplugin = null;
// Find the gradebook plugin.
foreach ($this->feedbackplugins as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
if (('assignfeedback_' . $plugin->get_type()) == $gradebookpluginname) {
$gradebookplugin = $plugin;
}
}
}
if ($userid) {
$where = ' WHERE u.id = :userid ';
} else {
$where = ' WHERE u.id != :userid ';
}
// When the gradebook asks us for grades - only return the last attempt for each user.
$params = array('assignid1'=>$assignmentid,
'assignid2'=>$assignmentid,
'userid'=>$userid);
$graderesults = $DB->get_recordset_sql('SELECT
u.id as userid,
s.timemodified as datesubmitted,
g.grade as rawgrade,
g.timemodified as dategraded,
g.grader as usermodified
FROM {user} u
LEFT JOIN {assign_submission} s
ON u.id = s.userid and s.assignment = :assignid1 AND
s.latest = 1
JOIN {assign_grades} g
ON u.id = g.userid and g.assignment = :assignid2 AND
g.attemptnumber = s.attemptnumber' .
$where, $params);
foreach ($graderesults as $result) {
$gradingstatus = $this->get_grading_status($result->userid);
if (!$this->get_instance()->markingworkflow || $gradingstatus == ASSIGN_MARKING_WORKFLOW_STATE_RELEASED) {
$gradebookgrade = clone $result;
// Now get the feedback.
if ($gradebookplugin) {
$grade = $this->get_user_grade($result->userid, false);
if ($grade) {
$gradebookgrade->feedback = $gradebookplugin->text_for_gradebook($grade);
$gradebookgrade->feedbackformat = $gradebookplugin->format_for_gradebook($grade);
$gradebookgrade->feedbackfiles = $gradebookplugin->files_for_gradebook($grade);
}
}
$grades[$gradebookgrade->userid] = $gradebookgrade;
}
}
$graderesults->close();
return $grades;
} | [
"public",
"function",
"get_user_grades_for_gradebook",
"(",
"$",
"userid",
")",
"{",
"global",
"$",
"DB",
",",
"$",
"CFG",
";",
"$",
"grades",
"=",
"array",
"(",
")",
";",
"$",
"assignmentid",
"=",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"id",
";",
"$",
"adminconfig",
"=",
"$",
"this",
"->",
"get_admin_config",
"(",
")",
";",
"$",
"gradebookpluginname",
"=",
"$",
"adminconfig",
"->",
"feedback_plugin_for_gradebook",
";",
"$",
"gradebookplugin",
"=",
"null",
";",
"// Find the gradebook plugin.",
"foreach",
"(",
"$",
"this",
"->",
"feedbackplugins",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
"$",
"plugin",
"->",
"is_enabled",
"(",
")",
"&&",
"$",
"plugin",
"->",
"is_visible",
"(",
")",
")",
"{",
"if",
"(",
"(",
"'assignfeedback_'",
".",
"$",
"plugin",
"->",
"get_type",
"(",
")",
")",
"==",
"$",
"gradebookpluginname",
")",
"{",
"$",
"gradebookplugin",
"=",
"$",
"plugin",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"userid",
")",
"{",
"$",
"where",
"=",
"' WHERE u.id = :userid '",
";",
"}",
"else",
"{",
"$",
"where",
"=",
"' WHERE u.id != :userid '",
";",
"}",
"// When the gradebook asks us for grades - only return the last attempt for each user.",
"$",
"params",
"=",
"array",
"(",
"'assignid1'",
"=>",
"$",
"assignmentid",
",",
"'assignid2'",
"=>",
"$",
"assignmentid",
",",
"'userid'",
"=>",
"$",
"userid",
")",
";",
"$",
"graderesults",
"=",
"$",
"DB",
"->",
"get_recordset_sql",
"(",
"'SELECT\n u.id as userid,\n s.timemodified as datesubmitted,\n g.grade as rawgrade,\n g.timemodified as dategraded,\n g.grader as usermodified\n FROM {user} u\n LEFT JOIN {assign_submission} s\n ON u.id = s.userid and s.assignment = :assignid1 AND\n s.latest = 1\n JOIN {assign_grades} g\n ON u.id = g.userid and g.assignment = :assignid2 AND\n g.attemptnumber = s.attemptnumber'",
".",
"$",
"where",
",",
"$",
"params",
")",
";",
"foreach",
"(",
"$",
"graderesults",
"as",
"$",
"result",
")",
"{",
"$",
"gradingstatus",
"=",
"$",
"this",
"->",
"get_grading_status",
"(",
"$",
"result",
"->",
"userid",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"markingworkflow",
"||",
"$",
"gradingstatus",
"==",
"ASSIGN_MARKING_WORKFLOW_STATE_RELEASED",
")",
"{",
"$",
"gradebookgrade",
"=",
"clone",
"$",
"result",
";",
"// Now get the feedback.",
"if",
"(",
"$",
"gradebookplugin",
")",
"{",
"$",
"grade",
"=",
"$",
"this",
"->",
"get_user_grade",
"(",
"$",
"result",
"->",
"userid",
",",
"false",
")",
";",
"if",
"(",
"$",
"grade",
")",
"{",
"$",
"gradebookgrade",
"->",
"feedback",
"=",
"$",
"gradebookplugin",
"->",
"text_for_gradebook",
"(",
"$",
"grade",
")",
";",
"$",
"gradebookgrade",
"->",
"feedbackformat",
"=",
"$",
"gradebookplugin",
"->",
"format_for_gradebook",
"(",
"$",
"grade",
")",
";",
"$",
"gradebookgrade",
"->",
"feedbackfiles",
"=",
"$",
"gradebookplugin",
"->",
"files_for_gradebook",
"(",
"$",
"grade",
")",
";",
"}",
"}",
"$",
"grades",
"[",
"$",
"gradebookgrade",
"->",
"userid",
"]",
"=",
"$",
"gradebookgrade",
";",
"}",
"}",
"$",
"graderesults",
"->",
"close",
"(",
")",
";",
"return",
"$",
"grades",
";",
"}"
] | Get an upto date list of user grades and feedback for the gradebook.
@param int $userid int or 0 for all users
@return array of grade data formated for the gradebook api
The data required by the gradebook api is userid,
rawgrade,
feedback,
feedbackformat,
usermodified,
dategraded,
datesubmitted | [
"Get",
"an",
"upto",
"date",
"list",
"of",
"user",
"grades",
"and",
"feedback",
"for",
"the",
"gradebook",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L8661-L8722 |
215,053 | moodle/moodle | mod/assign/locallib.php | assign.allocate_unique_ids | public static function allocate_unique_ids($assignid) {
global $DB;
$cm = get_coursemodule_from_instance('assign', $assignid, 0, false, MUST_EXIST);
$context = context_module::instance($cm->id);
$currentgroup = groups_get_activity_group($cm, true);
$users = get_enrolled_users($context, "mod/assign:submit", $currentgroup, 'u.id');
// Shuffle the users.
shuffle($users);
foreach ($users as $user) {
$record = $DB->get_record('assign_user_mapping',
array('assignment'=>$assignid, 'userid'=>$user->id),
'id');
if (!$record) {
$record = new stdClass();
$record->assignment = $assignid;
$record->userid = $user->id;
$DB->insert_record('assign_user_mapping', $record);
}
}
} | php | public static function allocate_unique_ids($assignid) {
global $DB;
$cm = get_coursemodule_from_instance('assign', $assignid, 0, false, MUST_EXIST);
$context = context_module::instance($cm->id);
$currentgroup = groups_get_activity_group($cm, true);
$users = get_enrolled_users($context, "mod/assign:submit", $currentgroup, 'u.id');
// Shuffle the users.
shuffle($users);
foreach ($users as $user) {
$record = $DB->get_record('assign_user_mapping',
array('assignment'=>$assignid, 'userid'=>$user->id),
'id');
if (!$record) {
$record = new stdClass();
$record->assignment = $assignid;
$record->userid = $user->id;
$DB->insert_record('assign_user_mapping', $record);
}
}
} | [
"public",
"static",
"function",
"allocate_unique_ids",
"(",
"$",
"assignid",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"cm",
"=",
"get_coursemodule_from_instance",
"(",
"'assign'",
",",
"$",
"assignid",
",",
"0",
",",
"false",
",",
"MUST_EXIST",
")",
";",
"$",
"context",
"=",
"context_module",
"::",
"instance",
"(",
"$",
"cm",
"->",
"id",
")",
";",
"$",
"currentgroup",
"=",
"groups_get_activity_group",
"(",
"$",
"cm",
",",
"true",
")",
";",
"$",
"users",
"=",
"get_enrolled_users",
"(",
"$",
"context",
",",
"\"mod/assign:submit\"",
",",
"$",
"currentgroup",
",",
"'u.id'",
")",
";",
"// Shuffle the users.",
"shuffle",
"(",
"$",
"users",
")",
";",
"foreach",
"(",
"$",
"users",
"as",
"$",
"user",
")",
"{",
"$",
"record",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'assign_user_mapping'",
",",
"array",
"(",
"'assignment'",
"=>",
"$",
"assignid",
",",
"'userid'",
"=>",
"$",
"user",
"->",
"id",
")",
",",
"'id'",
")",
";",
"if",
"(",
"!",
"$",
"record",
")",
"{",
"$",
"record",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"record",
"->",
"assignment",
"=",
"$",
"assignid",
";",
"$",
"record",
"->",
"userid",
"=",
"$",
"user",
"->",
"id",
";",
"$",
"DB",
"->",
"insert_record",
"(",
"'assign_user_mapping'",
",",
"$",
"record",
")",
";",
"}",
"}",
"}"
] | Foreach participant in the course - assign them a random id.
@param int $assignid The assignid to lookup | [
"Foreach",
"participant",
"in",
"the",
"course",
"-",
"assign",
"them",
"a",
"random",
"id",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L8739-L8762 |
215,054 | moodle/moodle | mod/assign/locallib.php | assign.get_uniqueid_for_user_static | public static function get_uniqueid_for_user_static($assignid, $userid) {
global $DB;
// Search for a record.
$params = array('assignment'=>$assignid, 'userid'=>$userid);
if ($record = $DB->get_record('assign_user_mapping', $params, 'id')) {
return $record->id;
}
// Be a little smart about this - there is no record for the current user.
// We should ensure any unallocated ids for the current participant
// list are distrubited randomly.
self::allocate_unique_ids($assignid);
// Retry the search for a record.
if ($record = $DB->get_record('assign_user_mapping', $params, 'id')) {
return $record->id;
}
// The requested user must not be a participant. Add a record anyway.
$record = new stdClass();
$record->assignment = $assignid;
$record->userid = $userid;
return $DB->insert_record('assign_user_mapping', $record);
} | php | public static function get_uniqueid_for_user_static($assignid, $userid) {
global $DB;
// Search for a record.
$params = array('assignment'=>$assignid, 'userid'=>$userid);
if ($record = $DB->get_record('assign_user_mapping', $params, 'id')) {
return $record->id;
}
// Be a little smart about this - there is no record for the current user.
// We should ensure any unallocated ids for the current participant
// list are distrubited randomly.
self::allocate_unique_ids($assignid);
// Retry the search for a record.
if ($record = $DB->get_record('assign_user_mapping', $params, 'id')) {
return $record->id;
}
// The requested user must not be a participant. Add a record anyway.
$record = new stdClass();
$record->assignment = $assignid;
$record->userid = $userid;
return $DB->insert_record('assign_user_mapping', $record);
} | [
"public",
"static",
"function",
"get_uniqueid_for_user_static",
"(",
"$",
"assignid",
",",
"$",
"userid",
")",
"{",
"global",
"$",
"DB",
";",
"// Search for a record.",
"$",
"params",
"=",
"array",
"(",
"'assignment'",
"=>",
"$",
"assignid",
",",
"'userid'",
"=>",
"$",
"userid",
")",
";",
"if",
"(",
"$",
"record",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'assign_user_mapping'",
",",
"$",
"params",
",",
"'id'",
")",
")",
"{",
"return",
"$",
"record",
"->",
"id",
";",
"}",
"// Be a little smart about this - there is no record for the current user.",
"// We should ensure any unallocated ids for the current participant",
"// list are distrubited randomly.",
"self",
"::",
"allocate_unique_ids",
"(",
"$",
"assignid",
")",
";",
"// Retry the search for a record.",
"if",
"(",
"$",
"record",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'assign_user_mapping'",
",",
"$",
"params",
",",
"'id'",
")",
")",
"{",
"return",
"$",
"record",
"->",
"id",
";",
"}",
"// The requested user must not be a participant. Add a record anyway.",
"$",
"record",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"record",
"->",
"assignment",
"=",
"$",
"assignid",
";",
"$",
"record",
"->",
"userid",
"=",
"$",
"userid",
";",
"return",
"$",
"DB",
"->",
"insert_record",
"(",
"'assign_user_mapping'",
",",
"$",
"record",
")",
";",
"}"
] | Lookup this user id and return the unique id for this assignment.
@param int $assignid The assignment id
@param int $userid The userid to lookup
@return int The unique id | [
"Lookup",
"this",
"user",
"id",
"and",
"return",
"the",
"unique",
"id",
"for",
"this",
"assignment",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L8771-L8796 |
215,055 | moodle/moodle | mod/assign/locallib.php | assign.get_user_id_for_uniqueid_static | public static function get_user_id_for_uniqueid_static($assignid, $uniqueid) {
global $DB;
// Search for a record.
if ($record = $DB->get_record('assign_user_mapping',
array('assignment'=>$assignid, 'id'=>$uniqueid),
'userid',
IGNORE_MISSING)) {
return $record->userid;
}
return false;
} | php | public static function get_user_id_for_uniqueid_static($assignid, $uniqueid) {
global $DB;
// Search for a record.
if ($record = $DB->get_record('assign_user_mapping',
array('assignment'=>$assignid, 'id'=>$uniqueid),
'userid',
IGNORE_MISSING)) {
return $record->userid;
}
return false;
} | [
"public",
"static",
"function",
"get_user_id_for_uniqueid_static",
"(",
"$",
"assignid",
",",
"$",
"uniqueid",
")",
"{",
"global",
"$",
"DB",
";",
"// Search for a record.",
"if",
"(",
"$",
"record",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'assign_user_mapping'",
",",
"array",
"(",
"'assignment'",
"=>",
"$",
"assignid",
",",
"'id'",
"=>",
"$",
"uniqueid",
")",
",",
"'userid'",
",",
"IGNORE_MISSING",
")",
")",
"{",
"return",
"$",
"record",
"->",
"userid",
";",
"}",
"return",
"false",
";",
"}"
] | Lookup this unique id and return the user id for this assignment.
@param int $assignid The id of the assignment this user mapping is in
@param int $uniqueid The uniqueid to lookup
@return int The user id or false if they don't exist | [
"Lookup",
"this",
"unique",
"id",
"and",
"return",
"the",
"user",
"id",
"for",
"this",
"assignment",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L8815-L8827 |
215,056 | moodle/moodle | mod/assign/locallib.php | assign.get_marking_workflow_states_for_current_user | public function get_marking_workflow_states_for_current_user() {
if (!empty($this->markingworkflowstates)) {
return $this->markingworkflowstates;
}
$states = array();
if (has_capability('mod/assign:grade', $this->context)) {
$states[ASSIGN_MARKING_WORKFLOW_STATE_INMARKING] = get_string('markingworkflowstateinmarking', 'assign');
$states[ASSIGN_MARKING_WORKFLOW_STATE_READYFORREVIEW] = get_string('markingworkflowstatereadyforreview', 'assign');
}
if (has_any_capability(array('mod/assign:reviewgrades',
'mod/assign:managegrades'), $this->context)) {
$states[ASSIGN_MARKING_WORKFLOW_STATE_INREVIEW] = get_string('markingworkflowstateinreview', 'assign');
$states[ASSIGN_MARKING_WORKFLOW_STATE_READYFORRELEASE] = get_string('markingworkflowstatereadyforrelease', 'assign');
}
if (has_any_capability(array('mod/assign:releasegrades',
'mod/assign:managegrades'), $this->context)) {
$states[ASSIGN_MARKING_WORKFLOW_STATE_RELEASED] = get_string('markingworkflowstatereleased', 'assign');
}
$this->markingworkflowstates = $states;
return $this->markingworkflowstates;
} | php | public function get_marking_workflow_states_for_current_user() {
if (!empty($this->markingworkflowstates)) {
return $this->markingworkflowstates;
}
$states = array();
if (has_capability('mod/assign:grade', $this->context)) {
$states[ASSIGN_MARKING_WORKFLOW_STATE_INMARKING] = get_string('markingworkflowstateinmarking', 'assign');
$states[ASSIGN_MARKING_WORKFLOW_STATE_READYFORREVIEW] = get_string('markingworkflowstatereadyforreview', 'assign');
}
if (has_any_capability(array('mod/assign:reviewgrades',
'mod/assign:managegrades'), $this->context)) {
$states[ASSIGN_MARKING_WORKFLOW_STATE_INREVIEW] = get_string('markingworkflowstateinreview', 'assign');
$states[ASSIGN_MARKING_WORKFLOW_STATE_READYFORRELEASE] = get_string('markingworkflowstatereadyforrelease', 'assign');
}
if (has_any_capability(array('mod/assign:releasegrades',
'mod/assign:managegrades'), $this->context)) {
$states[ASSIGN_MARKING_WORKFLOW_STATE_RELEASED] = get_string('markingworkflowstatereleased', 'assign');
}
$this->markingworkflowstates = $states;
return $this->markingworkflowstates;
} | [
"public",
"function",
"get_marking_workflow_states_for_current_user",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"markingworkflowstates",
")",
")",
"{",
"return",
"$",
"this",
"->",
"markingworkflowstates",
";",
"}",
"$",
"states",
"=",
"array",
"(",
")",
";",
"if",
"(",
"has_capability",
"(",
"'mod/assign:grade'",
",",
"$",
"this",
"->",
"context",
")",
")",
"{",
"$",
"states",
"[",
"ASSIGN_MARKING_WORKFLOW_STATE_INMARKING",
"]",
"=",
"get_string",
"(",
"'markingworkflowstateinmarking'",
",",
"'assign'",
")",
";",
"$",
"states",
"[",
"ASSIGN_MARKING_WORKFLOW_STATE_READYFORREVIEW",
"]",
"=",
"get_string",
"(",
"'markingworkflowstatereadyforreview'",
",",
"'assign'",
")",
";",
"}",
"if",
"(",
"has_any_capability",
"(",
"array",
"(",
"'mod/assign:reviewgrades'",
",",
"'mod/assign:managegrades'",
")",
",",
"$",
"this",
"->",
"context",
")",
")",
"{",
"$",
"states",
"[",
"ASSIGN_MARKING_WORKFLOW_STATE_INREVIEW",
"]",
"=",
"get_string",
"(",
"'markingworkflowstateinreview'",
",",
"'assign'",
")",
";",
"$",
"states",
"[",
"ASSIGN_MARKING_WORKFLOW_STATE_READYFORRELEASE",
"]",
"=",
"get_string",
"(",
"'markingworkflowstatereadyforrelease'",
",",
"'assign'",
")",
";",
"}",
"if",
"(",
"has_any_capability",
"(",
"array",
"(",
"'mod/assign:releasegrades'",
",",
"'mod/assign:managegrades'",
")",
",",
"$",
"this",
"->",
"context",
")",
")",
"{",
"$",
"states",
"[",
"ASSIGN_MARKING_WORKFLOW_STATE_RELEASED",
"]",
"=",
"get_string",
"(",
"'markingworkflowstatereleased'",
",",
"'assign'",
")",
";",
"}",
"$",
"this",
"->",
"markingworkflowstates",
"=",
"$",
"states",
";",
"return",
"$",
"this",
"->",
"markingworkflowstates",
";",
"}"
] | Get the list of marking_workflow states the current user has permission to transition a grade to.
@return array of state => description | [
"Get",
"the",
"list",
"of",
"marking_workflow",
"states",
"the",
"current",
"user",
"has",
"permission",
"to",
"transition",
"a",
"grade",
"to",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L8834-L8854 |
215,057 | moodle/moodle | mod/assign/locallib.php | assign.show_only_active_users | public function show_only_active_users() {
global $CFG;
if (is_null($this->showonlyactiveenrol)) {
$defaultgradeshowactiveenrol = !empty($CFG->grade_report_showonlyactiveenrol);
$this->showonlyactiveenrol = get_user_preferences('grade_report_showonlyactiveenrol', $defaultgradeshowactiveenrol);
if (!is_null($this->context)) {
$this->showonlyactiveenrol = $this->showonlyactiveenrol ||
!has_capability('moodle/course:viewsuspendedusers', $this->context);
}
}
return $this->showonlyactiveenrol;
} | php | public function show_only_active_users() {
global $CFG;
if (is_null($this->showonlyactiveenrol)) {
$defaultgradeshowactiveenrol = !empty($CFG->grade_report_showonlyactiveenrol);
$this->showonlyactiveenrol = get_user_preferences('grade_report_showonlyactiveenrol', $defaultgradeshowactiveenrol);
if (!is_null($this->context)) {
$this->showonlyactiveenrol = $this->showonlyactiveenrol ||
!has_capability('moodle/course:viewsuspendedusers', $this->context);
}
}
return $this->showonlyactiveenrol;
} | [
"public",
"function",
"show_only_active_users",
"(",
")",
"{",
"global",
"$",
"CFG",
";",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"showonlyactiveenrol",
")",
")",
"{",
"$",
"defaultgradeshowactiveenrol",
"=",
"!",
"empty",
"(",
"$",
"CFG",
"->",
"grade_report_showonlyactiveenrol",
")",
";",
"$",
"this",
"->",
"showonlyactiveenrol",
"=",
"get_user_preferences",
"(",
"'grade_report_showonlyactiveenrol'",
",",
"$",
"defaultgradeshowactiveenrol",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"context",
")",
")",
"{",
"$",
"this",
"->",
"showonlyactiveenrol",
"=",
"$",
"this",
"->",
"showonlyactiveenrol",
"||",
"!",
"has_capability",
"(",
"'moodle/course:viewsuspendedusers'",
",",
"$",
"this",
"->",
"context",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"showonlyactiveenrol",
";",
"}"
] | Check is only active users in course should be shown.
@return bool true if only active users should be shown. | [
"Check",
"is",
"only",
"active",
"users",
"in",
"course",
"should",
"be",
"shown",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L8861-L8874 |
215,058 | moodle/moodle | mod/assign/locallib.php | assign.is_gradebook_feedback_enabled | public function is_gradebook_feedback_enabled() {
// Get default grade book feedback plugin.
$adminconfig = $this->get_admin_config();
$gradebookplugin = $adminconfig->feedback_plugin_for_gradebook;
$gradebookplugin = str_replace('assignfeedback_', '', $gradebookplugin);
// Check if default gradebook feedback is visible and enabled.
$gradebookfeedbackplugin = $this->get_feedback_plugin_by_type($gradebookplugin);
if (empty($gradebookfeedbackplugin)) {
return false;
}
if ($gradebookfeedbackplugin->is_visible() && $gradebookfeedbackplugin->is_enabled()) {
return true;
}
// Gradebook feedback plugin is either not visible/enabled.
return false;
} | php | public function is_gradebook_feedback_enabled() {
// Get default grade book feedback plugin.
$adminconfig = $this->get_admin_config();
$gradebookplugin = $adminconfig->feedback_plugin_for_gradebook;
$gradebookplugin = str_replace('assignfeedback_', '', $gradebookplugin);
// Check if default gradebook feedback is visible and enabled.
$gradebookfeedbackplugin = $this->get_feedback_plugin_by_type($gradebookplugin);
if (empty($gradebookfeedbackplugin)) {
return false;
}
if ($gradebookfeedbackplugin->is_visible() && $gradebookfeedbackplugin->is_enabled()) {
return true;
}
// Gradebook feedback plugin is either not visible/enabled.
return false;
} | [
"public",
"function",
"is_gradebook_feedback_enabled",
"(",
")",
"{",
"// Get default grade book feedback plugin.",
"$",
"adminconfig",
"=",
"$",
"this",
"->",
"get_admin_config",
"(",
")",
";",
"$",
"gradebookplugin",
"=",
"$",
"adminconfig",
"->",
"feedback_plugin_for_gradebook",
";",
"$",
"gradebookplugin",
"=",
"str_replace",
"(",
"'assignfeedback_'",
",",
"''",
",",
"$",
"gradebookplugin",
")",
";",
"// Check if default gradebook feedback is visible and enabled.",
"$",
"gradebookfeedbackplugin",
"=",
"$",
"this",
"->",
"get_feedback_plugin_by_type",
"(",
"$",
"gradebookplugin",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"gradebookfeedbackplugin",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"gradebookfeedbackplugin",
"->",
"is_visible",
"(",
")",
"&&",
"$",
"gradebookfeedbackplugin",
"->",
"is_enabled",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"// Gradebook feedback plugin is either not visible/enabled.",
"return",
"false",
";",
"}"
] | Returns true if gradebook feedback plugin is enabled
@return bool true if gradebook feedback plugin is enabled and visible else false. | [
"Returns",
"true",
"if",
"gradebook",
"feedback",
"plugin",
"is",
"enabled"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L8891-L8910 |
215,059 | moodle/moodle | mod/assign/locallib.php | assign.get_grading_status | public function get_grading_status($userid) {
if ($this->get_instance()->markingworkflow) {
$flags = $this->get_user_flags($userid, false);
if (!empty($flags->workflowstate)) {
return $flags->workflowstate;
}
return ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED;
} else {
$attemptnumber = optional_param('attemptnumber', -1, PARAM_INT);
$grade = $this->get_user_grade($userid, false, $attemptnumber);
if (!empty($grade) && $grade->grade !== null && $grade->grade >= 0) {
return ASSIGN_GRADING_STATUS_GRADED;
} else {
return ASSIGN_GRADING_STATUS_NOT_GRADED;
}
}
} | php | public function get_grading_status($userid) {
if ($this->get_instance()->markingworkflow) {
$flags = $this->get_user_flags($userid, false);
if (!empty($flags->workflowstate)) {
return $flags->workflowstate;
}
return ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED;
} else {
$attemptnumber = optional_param('attemptnumber', -1, PARAM_INT);
$grade = $this->get_user_grade($userid, false, $attemptnumber);
if (!empty($grade) && $grade->grade !== null && $grade->grade >= 0) {
return ASSIGN_GRADING_STATUS_GRADED;
} else {
return ASSIGN_GRADING_STATUS_NOT_GRADED;
}
}
} | [
"public",
"function",
"get_grading_status",
"(",
"$",
"userid",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"markingworkflow",
")",
"{",
"$",
"flags",
"=",
"$",
"this",
"->",
"get_user_flags",
"(",
"$",
"userid",
",",
"false",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"flags",
"->",
"workflowstate",
")",
")",
"{",
"return",
"$",
"flags",
"->",
"workflowstate",
";",
"}",
"return",
"ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED",
";",
"}",
"else",
"{",
"$",
"attemptnumber",
"=",
"optional_param",
"(",
"'attemptnumber'",
",",
"-",
"1",
",",
"PARAM_INT",
")",
";",
"$",
"grade",
"=",
"$",
"this",
"->",
"get_user_grade",
"(",
"$",
"userid",
",",
"false",
",",
"$",
"attemptnumber",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"grade",
")",
"&&",
"$",
"grade",
"->",
"grade",
"!==",
"null",
"&&",
"$",
"grade",
"->",
"grade",
">=",
"0",
")",
"{",
"return",
"ASSIGN_GRADING_STATUS_GRADED",
";",
"}",
"else",
"{",
"return",
"ASSIGN_GRADING_STATUS_NOT_GRADED",
";",
"}",
"}",
"}"
] | Returns the grading status.
@param int $userid the user id
@return string returns the grading status | [
"Returns",
"the",
"grading",
"status",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L8918-L8935 |
215,060 | moodle/moodle | mod/assign/locallib.php | assign.get_useridlist_key | public function get_useridlist_key($id = null) {
if ($id === null) {
$id = $this->get_useridlist_key_id();
}
return $this->get_course_module()->id . '_' . $id;
} | php | public function get_useridlist_key($id = null) {
if ($id === null) {
$id = $this->get_useridlist_key_id();
}
return $this->get_course_module()->id . '_' . $id;
} | [
"public",
"function",
"get_useridlist_key",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"id",
"===",
"null",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"get_useridlist_key_id",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"get_course_module",
"(",
")",
"->",
"id",
".",
"'_'",
".",
"$",
"id",
";",
"}"
] | Generates the key that should be used for an entry in the useridlist cache.
@param string $id Generate a key for this instance (optional)
@return string The key for the id, or new entry if no $id is passed. | [
"Generates",
"the",
"key",
"that",
"should",
"be",
"used",
"for",
"an",
"entry",
"in",
"the",
"useridlist",
"cache",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L8952-L8957 |
215,061 | moodle/moodle | mod/assign/locallib.php | assign.update_activity_completion_records | protected function update_activity_completion_records($teamsubmission,
$requireallteammemberssubmit,
$submission,
$userid,
$complete,
$completion) {
if (($teamsubmission && $submission->groupid > 0 && !$requireallteammemberssubmit) ||
($teamsubmission && $submission->groupid > 0 && $requireallteammemberssubmit &&
$submission->status == ASSIGN_SUBMISSION_STATUS_SUBMITTED)) {
$members = groups_get_members($submission->groupid);
foreach ($members as $member) {
$completion->update_state($this->get_course_module(), $complete, $member->id);
}
} else {
$completion->update_state($this->get_course_module(), $complete, $userid);
}
return;
} | php | protected function update_activity_completion_records($teamsubmission,
$requireallteammemberssubmit,
$submission,
$userid,
$complete,
$completion) {
if (($teamsubmission && $submission->groupid > 0 && !$requireallteammemberssubmit) ||
($teamsubmission && $submission->groupid > 0 && $requireallteammemberssubmit &&
$submission->status == ASSIGN_SUBMISSION_STATUS_SUBMITTED)) {
$members = groups_get_members($submission->groupid);
foreach ($members as $member) {
$completion->update_state($this->get_course_module(), $complete, $member->id);
}
} else {
$completion->update_state($this->get_course_module(), $complete, $userid);
}
return;
} | [
"protected",
"function",
"update_activity_completion_records",
"(",
"$",
"teamsubmission",
",",
"$",
"requireallteammemberssubmit",
",",
"$",
"submission",
",",
"$",
"userid",
",",
"$",
"complete",
",",
"$",
"completion",
")",
"{",
"if",
"(",
"(",
"$",
"teamsubmission",
"&&",
"$",
"submission",
"->",
"groupid",
">",
"0",
"&&",
"!",
"$",
"requireallteammemberssubmit",
")",
"||",
"(",
"$",
"teamsubmission",
"&&",
"$",
"submission",
"->",
"groupid",
">",
"0",
"&&",
"$",
"requireallteammemberssubmit",
"&&",
"$",
"submission",
"->",
"status",
"==",
"ASSIGN_SUBMISSION_STATUS_SUBMITTED",
")",
")",
"{",
"$",
"members",
"=",
"groups_get_members",
"(",
"$",
"submission",
"->",
"groupid",
")",
";",
"foreach",
"(",
"$",
"members",
"as",
"$",
"member",
")",
"{",
"$",
"completion",
"->",
"update_state",
"(",
"$",
"this",
"->",
"get_course_module",
"(",
")",
",",
"$",
"complete",
",",
"$",
"member",
"->",
"id",
")",
";",
"}",
"}",
"else",
"{",
"$",
"completion",
"->",
"update_state",
"(",
"$",
"this",
"->",
"get_course_module",
"(",
")",
",",
"$",
"complete",
",",
"$",
"userid",
")",
";",
"}",
"return",
";",
"}"
] | Updates and creates the completion records in mdl_course_modules_completion.
@param int $teamsubmission value of 0 or 1 to indicate whether this is a group activity
@param int $requireallteammemberssubmit value of 0 or 1 to indicate whether all group members must click Submit
@param obj $submission the submission
@param int $userid the user id
@param int $complete
@param obj $completion
@return null | [
"Updates",
"and",
"creates",
"the",
"completion",
"records",
"in",
"mdl_course_modules_completion",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L8971-L8992 |
215,062 | moodle/moodle | mod/assign/locallib.php | assign.add_grade_notices | protected function add_grade_notices() {
if (has_capability('mod/assign:grade', $this->get_context()) && get_config('assign', 'has_rescaled_null_grades_' . $this->get_instance()->id)) {
$link = new \moodle_url('/mod/assign/view.php', array('id' => $this->get_course_module()->id, 'action' => 'fixrescalednullgrades'));
\core\notification::warning(get_string('fixrescalednullgrades', 'mod_assign', ['link' => $link->out()]));
}
} | php | protected function add_grade_notices() {
if (has_capability('mod/assign:grade', $this->get_context()) && get_config('assign', 'has_rescaled_null_grades_' . $this->get_instance()->id)) {
$link = new \moodle_url('/mod/assign/view.php', array('id' => $this->get_course_module()->id, 'action' => 'fixrescalednullgrades'));
\core\notification::warning(get_string('fixrescalednullgrades', 'mod_assign', ['link' => $link->out()]));
}
} | [
"protected",
"function",
"add_grade_notices",
"(",
")",
"{",
"if",
"(",
"has_capability",
"(",
"'mod/assign:grade'",
",",
"$",
"this",
"->",
"get_context",
"(",
")",
")",
"&&",
"get_config",
"(",
"'assign'",
",",
"'has_rescaled_null_grades_'",
".",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"id",
")",
")",
"{",
"$",
"link",
"=",
"new",
"\\",
"moodle_url",
"(",
"'/mod/assign/view.php'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"this",
"->",
"get_course_module",
"(",
")",
"->",
"id",
",",
"'action'",
"=>",
"'fixrescalednullgrades'",
")",
")",
";",
"\\",
"core",
"\\",
"notification",
"::",
"warning",
"(",
"get_string",
"(",
"'fixrescalednullgrades'",
",",
"'mod_assign'",
",",
"[",
"'link'",
"=>",
"$",
"link",
"->",
"out",
"(",
")",
"]",
")",
")",
";",
"}",
"}"
] | Checks for any grade notices, and adds notifications. Will display on assignment main page and grading table.
@return void The notifications API will render the notifications at the appropriate part of the page. | [
"Checks",
"for",
"any",
"grade",
"notices",
"and",
"adds",
"notifications",
".",
"Will",
"display",
"on",
"assignment",
"main",
"page",
"and",
"grading",
"table",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L9024-L9029 |
215,063 | moodle/moodle | mod/assign/locallib.php | assign.get_marking_allocation_filters | public function get_marking_allocation_filters($export = false) {
$markingallocation = $this->get_instance()->markingworkflow &&
$this->get_instance()->markingallocation &&
has_capability('mod/assign:manageallocations', $this->context);
// Get markers to use in drop lists.
$markingallocationoptions = array();
if ($markingallocation) {
list($sort, $params) = users_order_by_sql('u');
// Only enrolled users could be assigned as potential markers.
$markers = get_enrolled_users($this->context, 'mod/assign:grade', 0, 'u.*', $sort);
$markingallocationoptions[''] = get_string('filternone', 'assign');
$markingallocationoptions[ASSIGN_MARKER_FILTER_NO_MARKER] = get_string('markerfilternomarker', 'assign');
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->context);
foreach ($markers as $marker) {
$markingallocationoptions[$marker->id] = fullname($marker, $viewfullnames);
}
}
if ($export) {
$allocationfilter = get_user_preferences('assign_markerfilter', '');
$result = [];
foreach ($markingallocationoptions as $option => $label) {
array_push($result, [
'key' => $option,
'name' => $label,
'active' => ($allocationfilter == $option),
]);
}
return $result;
}
return $markingworkflowoptions;
} | php | public function get_marking_allocation_filters($export = false) {
$markingallocation = $this->get_instance()->markingworkflow &&
$this->get_instance()->markingallocation &&
has_capability('mod/assign:manageallocations', $this->context);
// Get markers to use in drop lists.
$markingallocationoptions = array();
if ($markingallocation) {
list($sort, $params) = users_order_by_sql('u');
// Only enrolled users could be assigned as potential markers.
$markers = get_enrolled_users($this->context, 'mod/assign:grade', 0, 'u.*', $sort);
$markingallocationoptions[''] = get_string('filternone', 'assign');
$markingallocationoptions[ASSIGN_MARKER_FILTER_NO_MARKER] = get_string('markerfilternomarker', 'assign');
$viewfullnames = has_capability('moodle/site:viewfullnames', $this->context);
foreach ($markers as $marker) {
$markingallocationoptions[$marker->id] = fullname($marker, $viewfullnames);
}
}
if ($export) {
$allocationfilter = get_user_preferences('assign_markerfilter', '');
$result = [];
foreach ($markingallocationoptions as $option => $label) {
array_push($result, [
'key' => $option,
'name' => $label,
'active' => ($allocationfilter == $option),
]);
}
return $result;
}
return $markingworkflowoptions;
} | [
"public",
"function",
"get_marking_allocation_filters",
"(",
"$",
"export",
"=",
"false",
")",
"{",
"$",
"markingallocation",
"=",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"markingworkflow",
"&&",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"markingallocation",
"&&",
"has_capability",
"(",
"'mod/assign:manageallocations'",
",",
"$",
"this",
"->",
"context",
")",
";",
"// Get markers to use in drop lists.",
"$",
"markingallocationoptions",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"markingallocation",
")",
"{",
"list",
"(",
"$",
"sort",
",",
"$",
"params",
")",
"=",
"users_order_by_sql",
"(",
"'u'",
")",
";",
"// Only enrolled users could be assigned as potential markers.",
"$",
"markers",
"=",
"get_enrolled_users",
"(",
"$",
"this",
"->",
"context",
",",
"'mod/assign:grade'",
",",
"0",
",",
"'u.*'",
",",
"$",
"sort",
")",
";",
"$",
"markingallocationoptions",
"[",
"''",
"]",
"=",
"get_string",
"(",
"'filternone'",
",",
"'assign'",
")",
";",
"$",
"markingallocationoptions",
"[",
"ASSIGN_MARKER_FILTER_NO_MARKER",
"]",
"=",
"get_string",
"(",
"'markerfilternomarker'",
",",
"'assign'",
")",
";",
"$",
"viewfullnames",
"=",
"has_capability",
"(",
"'moodle/site:viewfullnames'",
",",
"$",
"this",
"->",
"context",
")",
";",
"foreach",
"(",
"$",
"markers",
"as",
"$",
"marker",
")",
"{",
"$",
"markingallocationoptions",
"[",
"$",
"marker",
"->",
"id",
"]",
"=",
"fullname",
"(",
"$",
"marker",
",",
"$",
"viewfullnames",
")",
";",
"}",
"}",
"if",
"(",
"$",
"export",
")",
"{",
"$",
"allocationfilter",
"=",
"get_user_preferences",
"(",
"'assign_markerfilter'",
",",
"''",
")",
";",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"markingallocationoptions",
"as",
"$",
"option",
"=>",
"$",
"label",
")",
"{",
"array_push",
"(",
"$",
"result",
",",
"[",
"'key'",
"=>",
"$",
"option",
",",
"'name'",
"=>",
"$",
"label",
",",
"'active'",
"=>",
"(",
"$",
"allocationfilter",
"==",
"$",
"option",
")",
",",
"]",
")",
";",
"}",
"return",
"$",
"result",
";",
"}",
"return",
"$",
"markingworkflowoptions",
";",
"}"
] | Return array of valid grading allocation filters for the grading interface.
@param boolean $export Export the list of filters for a template.
@return array | [
"Return",
"array",
"of",
"valid",
"grading",
"allocation",
"filters",
"for",
"the",
"grading",
"interface",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L9123-L9153 |
215,064 | moodle/moodle | mod/assign/locallib.php | assign.get_marking_workflow_filters | public function get_marking_workflow_filters($export = false) {
$markingworkflow = $this->get_instance()->markingworkflow;
// Get marking states to show in form.
$markingworkflowoptions = array();
if ($markingworkflow) {
$notmarked = get_string('markingworkflowstatenotmarked', 'assign');
$markingworkflowoptions[''] = get_string('filternone', 'assign');
$markingworkflowoptions[ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED] = $notmarked;
$markingworkflowoptions = array_merge($markingworkflowoptions, $this->get_marking_workflow_states_for_current_user());
}
if ($export) {
$workflowfilter = get_user_preferences('assign_workflowfilter', '');
$result = [];
foreach ($markingworkflowoptions as $option => $label) {
array_push($result, [
'key' => $option,
'name' => $label,
'active' => ($workflowfilter == $option),
]);
}
return $result;
}
return $markingworkflowoptions;
} | php | public function get_marking_workflow_filters($export = false) {
$markingworkflow = $this->get_instance()->markingworkflow;
// Get marking states to show in form.
$markingworkflowoptions = array();
if ($markingworkflow) {
$notmarked = get_string('markingworkflowstatenotmarked', 'assign');
$markingworkflowoptions[''] = get_string('filternone', 'assign');
$markingworkflowoptions[ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED] = $notmarked;
$markingworkflowoptions = array_merge($markingworkflowoptions, $this->get_marking_workflow_states_for_current_user());
}
if ($export) {
$workflowfilter = get_user_preferences('assign_workflowfilter', '');
$result = [];
foreach ($markingworkflowoptions as $option => $label) {
array_push($result, [
'key' => $option,
'name' => $label,
'active' => ($workflowfilter == $option),
]);
}
return $result;
}
return $markingworkflowoptions;
} | [
"public",
"function",
"get_marking_workflow_filters",
"(",
"$",
"export",
"=",
"false",
")",
"{",
"$",
"markingworkflow",
"=",
"$",
"this",
"->",
"get_instance",
"(",
")",
"->",
"markingworkflow",
";",
"// Get marking states to show in form.",
"$",
"markingworkflowoptions",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"markingworkflow",
")",
"{",
"$",
"notmarked",
"=",
"get_string",
"(",
"'markingworkflowstatenotmarked'",
",",
"'assign'",
")",
";",
"$",
"markingworkflowoptions",
"[",
"''",
"]",
"=",
"get_string",
"(",
"'filternone'",
",",
"'assign'",
")",
";",
"$",
"markingworkflowoptions",
"[",
"ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED",
"]",
"=",
"$",
"notmarked",
";",
"$",
"markingworkflowoptions",
"=",
"array_merge",
"(",
"$",
"markingworkflowoptions",
",",
"$",
"this",
"->",
"get_marking_workflow_states_for_current_user",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"export",
")",
"{",
"$",
"workflowfilter",
"=",
"get_user_preferences",
"(",
"'assign_workflowfilter'",
",",
"''",
")",
";",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"markingworkflowoptions",
"as",
"$",
"option",
"=>",
"$",
"label",
")",
"{",
"array_push",
"(",
"$",
"result",
",",
"[",
"'key'",
"=>",
"$",
"option",
",",
"'name'",
"=>",
"$",
"label",
",",
"'active'",
"=>",
"(",
"$",
"workflowfilter",
"==",
"$",
"option",
")",
",",
"]",
")",
";",
"}",
"return",
"$",
"result",
";",
"}",
"return",
"$",
"markingworkflowoptions",
";",
"}"
] | Return array of valid grading workflow filters for the grading interface.
@param boolean $export Export the list of filters for a template.
@return array | [
"Return",
"array",
"of",
"valid",
"grading",
"workflow",
"filters",
"for",
"the",
"grading",
"interface",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L9161-L9184 |
215,065 | moodle/moodle | mod/assign/locallib.php | assign.get_filters | public function get_filters() {
$filterkeys = [
ASSIGN_FILTER_SUBMITTED,
ASSIGN_FILTER_NOT_SUBMITTED,
ASSIGN_FILTER_REQUIRE_GRADING,
ASSIGN_FILTER_GRANTED_EXTENSION
];
$current = get_user_preferences('assign_filter', '');
$filters = [];
// First is always "no filter" option.
array_push($filters, [
'key' => 'none',
'name' => get_string('filternone', 'assign'),
'active' => ($current == '')
]);
foreach ($filterkeys as $key) {
array_push($filters, [
'key' => $key,
'name' => get_string('filter' . $key, 'assign'),
'active' => ($current == $key)
]);
}
return $filters;
} | php | public function get_filters() {
$filterkeys = [
ASSIGN_FILTER_SUBMITTED,
ASSIGN_FILTER_NOT_SUBMITTED,
ASSIGN_FILTER_REQUIRE_GRADING,
ASSIGN_FILTER_GRANTED_EXTENSION
];
$current = get_user_preferences('assign_filter', '');
$filters = [];
// First is always "no filter" option.
array_push($filters, [
'key' => 'none',
'name' => get_string('filternone', 'assign'),
'active' => ($current == '')
]);
foreach ($filterkeys as $key) {
array_push($filters, [
'key' => $key,
'name' => get_string('filter' . $key, 'assign'),
'active' => ($current == $key)
]);
}
return $filters;
} | [
"public",
"function",
"get_filters",
"(",
")",
"{",
"$",
"filterkeys",
"=",
"[",
"ASSIGN_FILTER_SUBMITTED",
",",
"ASSIGN_FILTER_NOT_SUBMITTED",
",",
"ASSIGN_FILTER_REQUIRE_GRADING",
",",
"ASSIGN_FILTER_GRANTED_EXTENSION",
"]",
";",
"$",
"current",
"=",
"get_user_preferences",
"(",
"'assign_filter'",
",",
"''",
")",
";",
"$",
"filters",
"=",
"[",
"]",
";",
"// First is always \"no filter\" option.",
"array_push",
"(",
"$",
"filters",
",",
"[",
"'key'",
"=>",
"'none'",
",",
"'name'",
"=>",
"get_string",
"(",
"'filternone'",
",",
"'assign'",
")",
",",
"'active'",
"=>",
"(",
"$",
"current",
"==",
"''",
")",
"]",
")",
";",
"foreach",
"(",
"$",
"filterkeys",
"as",
"$",
"key",
")",
"{",
"array_push",
"(",
"$",
"filters",
",",
"[",
"'key'",
"=>",
"$",
"key",
",",
"'name'",
"=>",
"get_string",
"(",
"'filter'",
".",
"$",
"key",
",",
"'assign'",
")",
",",
"'active'",
"=>",
"(",
"$",
"current",
"==",
"$",
"key",
")",
"]",
")",
";",
"}",
"return",
"$",
"filters",
";",
"}"
] | Return array of valid search filters for the grading interface.
@return array | [
"Return",
"array",
"of",
"valid",
"search",
"filters",
"for",
"the",
"grading",
"interface",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L9191-L9217 |
215,066 | moodle/moodle | mod/assign/locallib.php | assign.get_submissionstatement | protected function get_submissionstatement($adminconfig, $instance, $context) {
$submissionstatement = '';
if (!($context instanceof context)) {
return $submissionstatement;
}
// Single submission.
if (!$instance->teamsubmission) {
// Single submission statement is not empty.
if (!empty($adminconfig->submissionstatement)) {
// Format the submission statement before its sent. We turn off para because this is going within
// a form element.
$options = array(
'context' => $context,
'para' => false
);
$submissionstatement = format_text($adminconfig->submissionstatement, FORMAT_MOODLE, $options);
}
} else { // Team submission.
// One user can submit for the whole team.
if (!empty($adminconfig->submissionstatementteamsubmission) && !$instance->requireallteammemberssubmit) {
// Format the submission statement before its sent. We turn off para because this is going within
// a form element.
$options = array(
'context' => $context,
'para' => false
);
$submissionstatement = format_text($adminconfig->submissionstatementteamsubmission,
FORMAT_MOODLE, $options);
} else if (!empty($adminconfig->submissionstatementteamsubmissionallsubmit) &&
$instance->requireallteammemberssubmit) {
// All team members must submit.
// Format the submission statement before its sent. We turn off para because this is going within
// a form element.
$options = array(
'context' => $context,
'para' => false
);
$submissionstatement = format_text($adminconfig->submissionstatementteamsubmissionallsubmit,
FORMAT_MOODLE, $options);
}
}
return $submissionstatement;
} | php | protected function get_submissionstatement($adminconfig, $instance, $context) {
$submissionstatement = '';
if (!($context instanceof context)) {
return $submissionstatement;
}
// Single submission.
if (!$instance->teamsubmission) {
// Single submission statement is not empty.
if (!empty($adminconfig->submissionstatement)) {
// Format the submission statement before its sent. We turn off para because this is going within
// a form element.
$options = array(
'context' => $context,
'para' => false
);
$submissionstatement = format_text($adminconfig->submissionstatement, FORMAT_MOODLE, $options);
}
} else { // Team submission.
// One user can submit for the whole team.
if (!empty($adminconfig->submissionstatementteamsubmission) && !$instance->requireallteammemberssubmit) {
// Format the submission statement before its sent. We turn off para because this is going within
// a form element.
$options = array(
'context' => $context,
'para' => false
);
$submissionstatement = format_text($adminconfig->submissionstatementteamsubmission,
FORMAT_MOODLE, $options);
} else if (!empty($adminconfig->submissionstatementteamsubmissionallsubmit) &&
$instance->requireallteammemberssubmit) {
// All team members must submit.
// Format the submission statement before its sent. We turn off para because this is going within
// a form element.
$options = array(
'context' => $context,
'para' => false
);
$submissionstatement = format_text($adminconfig->submissionstatementteamsubmissionallsubmit,
FORMAT_MOODLE, $options);
}
}
return $submissionstatement;
} | [
"protected",
"function",
"get_submissionstatement",
"(",
"$",
"adminconfig",
",",
"$",
"instance",
",",
"$",
"context",
")",
"{",
"$",
"submissionstatement",
"=",
"''",
";",
"if",
"(",
"!",
"(",
"$",
"context",
"instanceof",
"context",
")",
")",
"{",
"return",
"$",
"submissionstatement",
";",
"}",
"// Single submission.",
"if",
"(",
"!",
"$",
"instance",
"->",
"teamsubmission",
")",
"{",
"// Single submission statement is not empty.",
"if",
"(",
"!",
"empty",
"(",
"$",
"adminconfig",
"->",
"submissionstatement",
")",
")",
"{",
"// Format the submission statement before its sent. We turn off para because this is going within",
"// a form element.",
"$",
"options",
"=",
"array",
"(",
"'context'",
"=>",
"$",
"context",
",",
"'para'",
"=>",
"false",
")",
";",
"$",
"submissionstatement",
"=",
"format_text",
"(",
"$",
"adminconfig",
"->",
"submissionstatement",
",",
"FORMAT_MOODLE",
",",
"$",
"options",
")",
";",
"}",
"}",
"else",
"{",
"// Team submission.",
"// One user can submit for the whole team.",
"if",
"(",
"!",
"empty",
"(",
"$",
"adminconfig",
"->",
"submissionstatementteamsubmission",
")",
"&&",
"!",
"$",
"instance",
"->",
"requireallteammemberssubmit",
")",
"{",
"// Format the submission statement before its sent. We turn off para because this is going within",
"// a form element.",
"$",
"options",
"=",
"array",
"(",
"'context'",
"=>",
"$",
"context",
",",
"'para'",
"=>",
"false",
")",
";",
"$",
"submissionstatement",
"=",
"format_text",
"(",
"$",
"adminconfig",
"->",
"submissionstatementteamsubmission",
",",
"FORMAT_MOODLE",
",",
"$",
"options",
")",
";",
"}",
"else",
"if",
"(",
"!",
"empty",
"(",
"$",
"adminconfig",
"->",
"submissionstatementteamsubmissionallsubmit",
")",
"&&",
"$",
"instance",
"->",
"requireallteammemberssubmit",
")",
"{",
"// All team members must submit.",
"// Format the submission statement before its sent. We turn off para because this is going within",
"// a form element.",
"$",
"options",
"=",
"array",
"(",
"'context'",
"=>",
"$",
"context",
",",
"'para'",
"=>",
"false",
")",
";",
"$",
"submissionstatement",
"=",
"format_text",
"(",
"$",
"adminconfig",
"->",
"submissionstatementteamsubmissionallsubmit",
",",
"FORMAT_MOODLE",
",",
"$",
"options",
")",
";",
"}",
"}",
"return",
"$",
"submissionstatement",
";",
"}"
] | Get the correct submission statement depending on single submisison, team submission or team submission
where all team memebers must submit.
@param array $adminconfig
@param assign $instance
@param context $context
@return string | [
"Get",
"the",
"correct",
"submission",
"statement",
"depending",
"on",
"single",
"submisison",
"team",
"submission",
"or",
"team",
"submission",
"where",
"all",
"team",
"memebers",
"must",
"submit",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L9229-L9274 |
215,067 | moodle/moodle | mod/assign/locallib.php | assign_portfolio_caller.load_data | public function load_data() {
global $DB;
$context = context_module::instance($this->cmid);
if (empty($this->fileid)) {
if (empty($this->sid) || empty($this->area)) {
throw new portfolio_caller_exception('invalidfileandsubmissionid', 'mod_assign');
}
$submission = $DB->get_record('assign_submission', array('id' => $this->sid));
} else {
$submissionid = $DB->get_field('files', 'itemid', array('id' => $this->fileid, 'contextid' => $context->id));
if ($submissionid) {
$submission = $DB->get_record('assign_submission', array('id' => $submissionid));
}
}
if (empty($submission)) {
throw new portfolio_caller_exception('filenotfound');
} else if ($submission->userid == 0) {
// This must be a group submission.
if (!groups_is_member($submission->groupid, $this->user->id)) {
throw new portfolio_caller_exception('filenotfound');
}
} else if ($this->user->id != $submission->userid) {
throw new portfolio_caller_exception('filenotfound');
}
// Export either an area of files or a single file (see function for more detail).
// The first arg is an id or null. If it is an id, the rest of the args are ignored.
// If it is null, the rest of the args are used to load a list of files from get_areafiles.
$this->set_file_and_format_data($this->fileid,
$context->id,
$this->component,
$this->area,
$this->sid,
'timemodified',
false);
} | php | public function load_data() {
global $DB;
$context = context_module::instance($this->cmid);
if (empty($this->fileid)) {
if (empty($this->sid) || empty($this->area)) {
throw new portfolio_caller_exception('invalidfileandsubmissionid', 'mod_assign');
}
$submission = $DB->get_record('assign_submission', array('id' => $this->sid));
} else {
$submissionid = $DB->get_field('files', 'itemid', array('id' => $this->fileid, 'contextid' => $context->id));
if ($submissionid) {
$submission = $DB->get_record('assign_submission', array('id' => $submissionid));
}
}
if (empty($submission)) {
throw new portfolio_caller_exception('filenotfound');
} else if ($submission->userid == 0) {
// This must be a group submission.
if (!groups_is_member($submission->groupid, $this->user->id)) {
throw new portfolio_caller_exception('filenotfound');
}
} else if ($this->user->id != $submission->userid) {
throw new portfolio_caller_exception('filenotfound');
}
// Export either an area of files or a single file (see function for more detail).
// The first arg is an id or null. If it is an id, the rest of the args are ignored.
// If it is null, the rest of the args are used to load a list of files from get_areafiles.
$this->set_file_and_format_data($this->fileid,
$context->id,
$this->component,
$this->area,
$this->sid,
'timemodified',
false);
} | [
"public",
"function",
"load_data",
"(",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"context",
"=",
"context_module",
"::",
"instance",
"(",
"$",
"this",
"->",
"cmid",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"fileid",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"sid",
")",
"||",
"empty",
"(",
"$",
"this",
"->",
"area",
")",
")",
"{",
"throw",
"new",
"portfolio_caller_exception",
"(",
"'invalidfileandsubmissionid'",
",",
"'mod_assign'",
")",
";",
"}",
"$",
"submission",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'assign_submission'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"this",
"->",
"sid",
")",
")",
";",
"}",
"else",
"{",
"$",
"submissionid",
"=",
"$",
"DB",
"->",
"get_field",
"(",
"'files'",
",",
"'itemid'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"this",
"->",
"fileid",
",",
"'contextid'",
"=>",
"$",
"context",
"->",
"id",
")",
")",
";",
"if",
"(",
"$",
"submissionid",
")",
"{",
"$",
"submission",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'assign_submission'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"submissionid",
")",
")",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"submission",
")",
")",
"{",
"throw",
"new",
"portfolio_caller_exception",
"(",
"'filenotfound'",
")",
";",
"}",
"else",
"if",
"(",
"$",
"submission",
"->",
"userid",
"==",
"0",
")",
"{",
"// This must be a group submission.",
"if",
"(",
"!",
"groups_is_member",
"(",
"$",
"submission",
"->",
"groupid",
",",
"$",
"this",
"->",
"user",
"->",
"id",
")",
")",
"{",
"throw",
"new",
"portfolio_caller_exception",
"(",
"'filenotfound'",
")",
";",
"}",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"user",
"->",
"id",
"!=",
"$",
"submission",
"->",
"userid",
")",
"{",
"throw",
"new",
"portfolio_caller_exception",
"(",
"'filenotfound'",
")",
";",
"}",
"// Export either an area of files or a single file (see function for more detail).",
"// The first arg is an id or null. If it is an id, the rest of the args are ignored.",
"// If it is null, the rest of the args are used to load a list of files from get_areafiles.",
"$",
"this",
"->",
"set_file_and_format_data",
"(",
"$",
"this",
"->",
"fileid",
",",
"$",
"context",
"->",
"id",
",",
"$",
"this",
"->",
"component",
",",
"$",
"this",
"->",
"area",
",",
"$",
"this",
"->",
"sid",
",",
"'timemodified'",
",",
"false",
")",
";",
"}"
] | Load data needed for the portfolio export.
If the assignment type implements portfolio_load_data(), the processing is delegated
to it. Otherwise, the caller must provide either fileid (to export single file) or
submissionid and filearea (to export all data attached to the given submission file area)
via callback arguments.
@throws portfolio_caller_exception | [
"Load",
"data",
"needed",
"for",
"the",
"portfolio",
"export",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L9342-L9382 |
215,068 | moodle/moodle | mod/assign/locallib.php | assign_portfolio_caller.get_submission_plugin | protected function get_submission_plugin() {
global $CFG;
if (!$this->plugin || !$this->cmid) {
return null;
}
require_once($CFG->dirroot . '/mod/assign/locallib.php');
$context = context_module::instance($this->cmid);
$assignment = new assign($context, null, null);
return $assignment->get_submission_plugin_by_type($this->plugin);
} | php | protected function get_submission_plugin() {
global $CFG;
if (!$this->plugin || !$this->cmid) {
return null;
}
require_once($CFG->dirroot . '/mod/assign/locallib.php');
$context = context_module::instance($this->cmid);
$assignment = new assign($context, null, null);
return $assignment->get_submission_plugin_by_type($this->plugin);
} | [
"protected",
"function",
"get_submission_plugin",
"(",
")",
"{",
"global",
"$",
"CFG",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"plugin",
"||",
"!",
"$",
"this",
"->",
"cmid",
")",
"{",
"return",
"null",
";",
"}",
"require_once",
"(",
"$",
"CFG",
"->",
"dirroot",
".",
"'/mod/assign/locallib.php'",
")",
";",
"$",
"context",
"=",
"context_module",
"::",
"instance",
"(",
"$",
"this",
"->",
"cmid",
")",
";",
"$",
"assignment",
"=",
"new",
"assign",
"(",
"$",
"context",
",",
"null",
",",
"null",
")",
";",
"return",
"$",
"assignment",
"->",
"get_submission_plugin_by_type",
"(",
"$",
"this",
"->",
"plugin",
")",
";",
"}"
] | Fetch the plugin by its type.
@return assign_submission_plugin | [
"Fetch",
"the",
"plugin",
"by",
"its",
"type",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L9487-L9499 |
215,069 | moodle/moodle | mod/assign/locallib.php | assign_portfolio_caller.get_sha1 | public function get_sha1() {
if ($this->plugin && $this->editor) {
$plugin = $this->get_submission_plugin();
$options = portfolio_format_text_options();
$options->context = context_module::instance($this->cmid);
$text = format_text($plugin->get_editor_text($this->editor, $this->sid),
$plugin->get_editor_format($this->editor, $this->sid),
$options);
$textsha1 = sha1($text);
$filesha1 = '';
try {
$filesha1 = $this->get_sha1_file();
} catch (portfolio_caller_exception $e) {
// No files.
}
return sha1($textsha1 . $filesha1);
}
return $this->get_sha1_file();
} | php | public function get_sha1() {
if ($this->plugin && $this->editor) {
$plugin = $this->get_submission_plugin();
$options = portfolio_format_text_options();
$options->context = context_module::instance($this->cmid);
$text = format_text($plugin->get_editor_text($this->editor, $this->sid),
$plugin->get_editor_format($this->editor, $this->sid),
$options);
$textsha1 = sha1($text);
$filesha1 = '';
try {
$filesha1 = $this->get_sha1_file();
} catch (portfolio_caller_exception $e) {
// No files.
}
return sha1($textsha1 . $filesha1);
}
return $this->get_sha1_file();
} | [
"public",
"function",
"get_sha1",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"plugin",
"&&",
"$",
"this",
"->",
"editor",
")",
"{",
"$",
"plugin",
"=",
"$",
"this",
"->",
"get_submission_plugin",
"(",
")",
";",
"$",
"options",
"=",
"portfolio_format_text_options",
"(",
")",
";",
"$",
"options",
"->",
"context",
"=",
"context_module",
"::",
"instance",
"(",
"$",
"this",
"->",
"cmid",
")",
";",
"$",
"text",
"=",
"format_text",
"(",
"$",
"plugin",
"->",
"get_editor_text",
"(",
"$",
"this",
"->",
"editor",
",",
"$",
"this",
"->",
"sid",
")",
",",
"$",
"plugin",
"->",
"get_editor_format",
"(",
"$",
"this",
"->",
"editor",
",",
"$",
"this",
"->",
"sid",
")",
",",
"$",
"options",
")",
";",
"$",
"textsha1",
"=",
"sha1",
"(",
"$",
"text",
")",
";",
"$",
"filesha1",
"=",
"''",
";",
"try",
"{",
"$",
"filesha1",
"=",
"$",
"this",
"->",
"get_sha1_file",
"(",
")",
";",
"}",
"catch",
"(",
"portfolio_caller_exception",
"$",
"e",
")",
"{",
"// No files.",
"}",
"return",
"sha1",
"(",
"$",
"textsha1",
".",
"$",
"filesha1",
")",
";",
"}",
"return",
"$",
"this",
"->",
"get_sha1_file",
"(",
")",
";",
"}"
] | Calculate a sha1 has of either a single file or a list
of files based on the data set by load_data.
@return string | [
"Calculate",
"a",
"sha1",
"has",
"of",
"either",
"a",
"single",
"file",
"or",
"a",
"list",
"of",
"files",
"based",
"on",
"the",
"data",
"set",
"by",
"load_data",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L9507-L9527 |
215,070 | moodle/moodle | lib/mustache/src/Mustache/Logger/StreamLogger.php | Mustache_Logger_StreamLogger.setLevel | public function setLevel($level)
{
if (!array_key_exists($level, self::$levels)) {
throw new Mustache_Exception_InvalidArgumentException(sprintf('Unexpected logging level: %s', $level));
}
$this->level = $level;
} | php | public function setLevel($level)
{
if (!array_key_exists($level, self::$levels)) {
throw new Mustache_Exception_InvalidArgumentException(sprintf('Unexpected logging level: %s', $level));
}
$this->level = $level;
} | [
"public",
"function",
"setLevel",
"(",
"$",
"level",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"level",
",",
"self",
"::",
"$",
"levels",
")",
")",
"{",
"throw",
"new",
"Mustache_Exception_InvalidArgumentException",
"(",
"sprintf",
"(",
"'Unexpected logging level: %s'",
",",
"$",
"level",
")",
")",
";",
"}",
"$",
"this",
"->",
"level",
"=",
"$",
"level",
";",
"}"
] | Set the minimum logging level.
@throws Mustache_Exception_InvalidArgumentException if the logging level is unknown
@param int $level The minimum logging level which will be written | [
"Set",
"the",
"minimum",
"logging",
"level",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/mustache/src/Mustache/Logger/StreamLogger.php#L72-L79 |
215,071 | moodle/moodle | lib/mustache/src/Mustache/Logger/StreamLogger.php | Mustache_Logger_StreamLogger.writeLog | protected function writeLog($level, $message, array $context = array())
{
if (!is_resource($this->stream)) {
if (!isset($this->url)) {
throw new Mustache_Exception_LogicException('Missing stream url, the stream can not be opened. This may be caused by a premature call to close().');
}
$this->stream = fopen($this->url, 'a');
if (!is_resource($this->stream)) {
// @codeCoverageIgnoreStart
throw new Mustache_Exception_RuntimeException(sprintf('The stream or file "%s" could not be opened.', $this->url));
// @codeCoverageIgnoreEnd
}
}
fwrite($this->stream, self::formatLine($level, $message, $context));
} | php | protected function writeLog($level, $message, array $context = array())
{
if (!is_resource($this->stream)) {
if (!isset($this->url)) {
throw new Mustache_Exception_LogicException('Missing stream url, the stream can not be opened. This may be caused by a premature call to close().');
}
$this->stream = fopen($this->url, 'a');
if (!is_resource($this->stream)) {
// @codeCoverageIgnoreStart
throw new Mustache_Exception_RuntimeException(sprintf('The stream or file "%s" could not be opened.', $this->url));
// @codeCoverageIgnoreEnd
}
}
fwrite($this->stream, self::formatLine($level, $message, $context));
} | [
"protected",
"function",
"writeLog",
"(",
"$",
"level",
",",
"$",
"message",
",",
"array",
"$",
"context",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"this",
"->",
"stream",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"url",
")",
")",
"{",
"throw",
"new",
"Mustache_Exception_LogicException",
"(",
"'Missing stream url, the stream can not be opened. This may be caused by a premature call to close().'",
")",
";",
"}",
"$",
"this",
"->",
"stream",
"=",
"fopen",
"(",
"$",
"this",
"->",
"url",
",",
"'a'",
")",
";",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"this",
"->",
"stream",
")",
")",
"{",
"// @codeCoverageIgnoreStart",
"throw",
"new",
"Mustache_Exception_RuntimeException",
"(",
"sprintf",
"(",
"'The stream or file \"%s\" could not be opened.'",
",",
"$",
"this",
"->",
"url",
")",
")",
";",
"// @codeCoverageIgnoreEnd",
"}",
"}",
"fwrite",
"(",
"$",
"this",
"->",
"stream",
",",
"self",
"::",
"formatLine",
"(",
"$",
"level",
",",
"$",
"message",
",",
"$",
"context",
")",
")",
";",
"}"
] | Write a record to the log.
@throws Mustache_Exception_LogicException If neither a stream resource nor url is present
@throws Mustache_Exception_RuntimeException If the stream url cannot be opened
@param int $level The logging level
@param string $message The log message
@param array $context The log context | [
"Write",
"a",
"record",
"to",
"the",
"log",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/mustache/src/Mustache/Logger/StreamLogger.php#L121-L137 |
215,072 | moodle/moodle | lib/mustache/src/Mustache/Logger/StreamLogger.php | Mustache_Logger_StreamLogger.formatLine | protected static function formatLine($level, $message, array $context = array())
{
return sprintf(
"%s: %s\n",
self::getLevelName($level),
self::interpolateMessage($message, $context)
);
} | php | protected static function formatLine($level, $message, array $context = array())
{
return sprintf(
"%s: %s\n",
self::getLevelName($level),
self::interpolateMessage($message, $context)
);
} | [
"protected",
"static",
"function",
"formatLine",
"(",
"$",
"level",
",",
"$",
"message",
",",
"array",
"$",
"context",
"=",
"array",
"(",
")",
")",
"{",
"return",
"sprintf",
"(",
"\"%s: %s\\n\"",
",",
"self",
"::",
"getLevelName",
"(",
"$",
"level",
")",
",",
"self",
"::",
"interpolateMessage",
"(",
"$",
"message",
",",
"$",
"context",
")",
")",
";",
"}"
] | Format a log line for output.
@param int $level The logging level
@param string $message The log message
@param array $context The log context
@return string | [
"Format",
"a",
"log",
"line",
"for",
"output",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/mustache/src/Mustache/Logger/StreamLogger.php#L162-L169 |
215,073 | moodle/moodle | lib/mustache/src/Mustache/LambdaHelper.php | Mustache_LambdaHelper.render | public function render($string)
{
return $this->mustache
->loadLambda((string) $string, $this->delims)
->renderInternal($this->context);
} | php | public function render($string)
{
return $this->mustache
->loadLambda((string) $string, $this->delims)
->renderInternal($this->context);
} | [
"public",
"function",
"render",
"(",
"$",
"string",
")",
"{",
"return",
"$",
"this",
"->",
"mustache",
"->",
"loadLambda",
"(",
"(",
"string",
")",
"$",
"string",
",",
"$",
"this",
"->",
"delims",
")",
"->",
"renderInternal",
"(",
"$",
"this",
"->",
"context",
")",
";",
"}"
] | Render a string as a Mustache template with the current rendering context.
@param string $string
@return string Rendered template | [
"Render",
"a",
"string",
"as",
"a",
"Mustache",
"template",
"with",
"the",
"current",
"rendering",
"context",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/mustache/src/Mustache/LambdaHelper.php#L46-L51 |
215,074 | moodle/moodle | mod/assign/feedback/offline/importgradeslib.php | assignfeedback_offline_grade_importer.init | public function init() {
if ($this->csvreader == null) {
$this->csvreader = new csv_import_reader($this->importid, 'assignfeedback_offline');
}
$this->csvreader->init();
$columns = $this->csvreader->get_columns();
$strgrade = get_string('grade');
$strid = get_string('recordid', 'assign');
$strmodified = get_string('lastmodifiedgrade', 'assign');
foreach ($this->assignment->get_feedback_plugins() as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
foreach ($plugin->get_editor_fields() as $field => $description) {
$this->feedbackcolumnindexes[$description] = array('plugin'=>$plugin,
'field'=>$field,
'description'=>$description);
}
}
}
if ($columns) {
foreach ($columns as $index => $column) {
if (isset($this->feedbackcolumnindexes[$column])) {
$this->feedbackcolumnindexes[$column]['index'] = $index;
}
if ($column == $strgrade) {
$this->gradeindex = $index;
}
if ($column == $strid) {
$this->idindex = $index;
}
if ($column == $strmodified) {
$this->modifiedindex = $index;
}
}
}
if ($this->idindex < 0 || $this->gradeindex < 0 || $this->modifiedindex < 0) {
return false;
}
$groupmode = groups_get_activity_groupmode($this->assignment->get_course_module());
// All users.
$groupid = 0;
$groupname = '';
if ($groupmode) {
$groupid = groups_get_activity_group($this->assignment->get_course_module(), true);
$groupname = groups_get_group_name($groupid).'-';
}
$this->validusers = $this->assignment->list_participants($groupid, false);
return true;
} | php | public function init() {
if ($this->csvreader == null) {
$this->csvreader = new csv_import_reader($this->importid, 'assignfeedback_offline');
}
$this->csvreader->init();
$columns = $this->csvreader->get_columns();
$strgrade = get_string('grade');
$strid = get_string('recordid', 'assign');
$strmodified = get_string('lastmodifiedgrade', 'assign');
foreach ($this->assignment->get_feedback_plugins() as $plugin) {
if ($plugin->is_enabled() && $plugin->is_visible()) {
foreach ($plugin->get_editor_fields() as $field => $description) {
$this->feedbackcolumnindexes[$description] = array('plugin'=>$plugin,
'field'=>$field,
'description'=>$description);
}
}
}
if ($columns) {
foreach ($columns as $index => $column) {
if (isset($this->feedbackcolumnindexes[$column])) {
$this->feedbackcolumnindexes[$column]['index'] = $index;
}
if ($column == $strgrade) {
$this->gradeindex = $index;
}
if ($column == $strid) {
$this->idindex = $index;
}
if ($column == $strmodified) {
$this->modifiedindex = $index;
}
}
}
if ($this->idindex < 0 || $this->gradeindex < 0 || $this->modifiedindex < 0) {
return false;
}
$groupmode = groups_get_activity_groupmode($this->assignment->get_course_module());
// All users.
$groupid = 0;
$groupname = '';
if ($groupmode) {
$groupid = groups_get_activity_group($this->assignment->get_course_module(), true);
$groupname = groups_get_group_name($groupid).'-';
}
$this->validusers = $this->assignment->list_participants($groupid, false);
return true;
} | [
"public",
"function",
"init",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"csvreader",
"==",
"null",
")",
"{",
"$",
"this",
"->",
"csvreader",
"=",
"new",
"csv_import_reader",
"(",
"$",
"this",
"->",
"importid",
",",
"'assignfeedback_offline'",
")",
";",
"}",
"$",
"this",
"->",
"csvreader",
"->",
"init",
"(",
")",
";",
"$",
"columns",
"=",
"$",
"this",
"->",
"csvreader",
"->",
"get_columns",
"(",
")",
";",
"$",
"strgrade",
"=",
"get_string",
"(",
"'grade'",
")",
";",
"$",
"strid",
"=",
"get_string",
"(",
"'recordid'",
",",
"'assign'",
")",
";",
"$",
"strmodified",
"=",
"get_string",
"(",
"'lastmodifiedgrade'",
",",
"'assign'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"assignment",
"->",
"get_feedback_plugins",
"(",
")",
"as",
"$",
"plugin",
")",
"{",
"if",
"(",
"$",
"plugin",
"->",
"is_enabled",
"(",
")",
"&&",
"$",
"plugin",
"->",
"is_visible",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"plugin",
"->",
"get_editor_fields",
"(",
")",
"as",
"$",
"field",
"=>",
"$",
"description",
")",
"{",
"$",
"this",
"->",
"feedbackcolumnindexes",
"[",
"$",
"description",
"]",
"=",
"array",
"(",
"'plugin'",
"=>",
"$",
"plugin",
",",
"'field'",
"=>",
"$",
"field",
",",
"'description'",
"=>",
"$",
"description",
")",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"columns",
")",
"{",
"foreach",
"(",
"$",
"columns",
"as",
"$",
"index",
"=>",
"$",
"column",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"feedbackcolumnindexes",
"[",
"$",
"column",
"]",
")",
")",
"{",
"$",
"this",
"->",
"feedbackcolumnindexes",
"[",
"$",
"column",
"]",
"[",
"'index'",
"]",
"=",
"$",
"index",
";",
"}",
"if",
"(",
"$",
"column",
"==",
"$",
"strgrade",
")",
"{",
"$",
"this",
"->",
"gradeindex",
"=",
"$",
"index",
";",
"}",
"if",
"(",
"$",
"column",
"==",
"$",
"strid",
")",
"{",
"$",
"this",
"->",
"idindex",
"=",
"$",
"index",
";",
"}",
"if",
"(",
"$",
"column",
"==",
"$",
"strmodified",
")",
"{",
"$",
"this",
"->",
"modifiedindex",
"=",
"$",
"index",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"idindex",
"<",
"0",
"||",
"$",
"this",
"->",
"gradeindex",
"<",
"0",
"||",
"$",
"this",
"->",
"modifiedindex",
"<",
"0",
")",
"{",
"return",
"false",
";",
"}",
"$",
"groupmode",
"=",
"groups_get_activity_groupmode",
"(",
"$",
"this",
"->",
"assignment",
"->",
"get_course_module",
"(",
")",
")",
";",
"// All users.",
"$",
"groupid",
"=",
"0",
";",
"$",
"groupname",
"=",
"''",
";",
"if",
"(",
"$",
"groupmode",
")",
"{",
"$",
"groupid",
"=",
"groups_get_activity_group",
"(",
"$",
"this",
"->",
"assignment",
"->",
"get_course_module",
"(",
")",
",",
"true",
")",
";",
"$",
"groupname",
"=",
"groups_get_group_name",
"(",
"$",
"groupid",
")",
".",
"'-'",
";",
"}",
"$",
"this",
"->",
"validusers",
"=",
"$",
"this",
"->",
"assignment",
"->",
"list_participants",
"(",
"$",
"groupid",
",",
"false",
")",
";",
"return",
"true",
";",
"}"
] | Initialise the import reader and locate the column indexes.
@return bool false is a failed import | [
"Initialise",
"the",
"import",
"reader",
"and",
"locate",
"the",
"column",
"indexes",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/feedback/offline/importgradeslib.php#L96-L149 |
215,075 | moodle/moodle | question/classes/statistics/responses/analysis_for_subpart.php | analysis_for_subpart.count_response | public function count_response($subpart, $try = 0) {
$responseanalysisforclass = $this->get_response_class($subpart->responseclassid);
$responseanalysisforclass->count_response($subpart->response, $subpart->fraction, $try);
} | php | public function count_response($subpart, $try = 0) {
$responseanalysisforclass = $this->get_response_class($subpart->responseclassid);
$responseanalysisforclass->count_response($subpart->response, $subpart->fraction, $try);
} | [
"public",
"function",
"count_response",
"(",
"$",
"subpart",
",",
"$",
"try",
"=",
"0",
")",
"{",
"$",
"responseanalysisforclass",
"=",
"$",
"this",
"->",
"get_response_class",
"(",
"$",
"subpart",
"->",
"responseclassid",
")",
";",
"$",
"responseanalysisforclass",
"->",
"count_response",
"(",
"$",
"subpart",
"->",
"response",
",",
"$",
"subpart",
"->",
"fraction",
",",
"$",
"try",
")",
";",
"}"
] | Count a part of a response.
@param \question_classified_response $subpart
@param int $try the try number or zero if not keeping track of try number | [
"Count",
"a",
"part",
"of",
"a",
"response",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/statistics/responses/analysis_for_subpart.php#L109-L112 |
215,076 | moodle/moodle | question/classes/statistics/responses/analysis_for_subpart.php | analysis_for_subpart.cache | public function cache($qubaids, $whichtries, $questionid, $variantno, $subpartid) {
foreach ($this->get_response_class_ids() as $responseclassid) {
$analysisforclass = $this->get_response_class($responseclassid);
$analysisforclass->cache($qubaids, $whichtries, $questionid, $variantno, $subpartid, $responseclassid);
}
} | php | public function cache($qubaids, $whichtries, $questionid, $variantno, $subpartid) {
foreach ($this->get_response_class_ids() as $responseclassid) {
$analysisforclass = $this->get_response_class($responseclassid);
$analysisforclass->cache($qubaids, $whichtries, $questionid, $variantno, $subpartid, $responseclassid);
}
} | [
"public",
"function",
"cache",
"(",
"$",
"qubaids",
",",
"$",
"whichtries",
",",
"$",
"questionid",
",",
"$",
"variantno",
",",
"$",
"subpartid",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"get_response_class_ids",
"(",
")",
"as",
"$",
"responseclassid",
")",
"{",
"$",
"analysisforclass",
"=",
"$",
"this",
"->",
"get_response_class",
"(",
"$",
"responseclassid",
")",
";",
"$",
"analysisforclass",
"->",
"cache",
"(",
"$",
"qubaids",
",",
"$",
"whichtries",
",",
"$",
"questionid",
",",
"$",
"variantno",
",",
"$",
"subpartid",
",",
"$",
"responseclassid",
")",
";",
"}",
"}"
] | Cache analysis for sub part.
@param \qubaid_condition $qubaids which question usages have been analysed.
@param string $whichtries which tries have been analysed?
@param int $questionid which question.
@param int $variantno which variant.
@param string $subpartid which sub part. | [
"Cache",
"analysis",
"for",
"sub",
"part",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/statistics/responses/analysis_for_subpart.php#L123-L128 |
215,077 | moodle/moodle | question/classes/statistics/responses/analysis_for_subpart.php | analysis_for_subpart.has_actual_responses | public function has_actual_responses() {
foreach ($this->get_response_class_ids() as $responseclassid) {
if ($this->get_response_class($responseclassid)->has_actual_responses()) {
return true;
}
}
return false;
} | php | public function has_actual_responses() {
foreach ($this->get_response_class_ids() as $responseclassid) {
if ($this->get_response_class($responseclassid)->has_actual_responses()) {
return true;
}
}
return false;
} | [
"public",
"function",
"has_actual_responses",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"get_response_class_ids",
"(",
")",
"as",
"$",
"responseclassid",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"get_response_class",
"(",
"$",
"responseclassid",
")",
"->",
"has_actual_responses",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Has actual responses different to the model response for this class?
@return bool whether this analysis has a response class with more than one
different actual response, or if the actual response is different from
the model response. | [
"Has",
"actual",
"responses",
"different",
"to",
"the",
"model",
"response",
"for",
"this",
"class?"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/statistics/responses/analysis_for_subpart.php#L137-L144 |
215,078 | moodle/moodle | question/classes/statistics/responses/analysis_for_subpart.php | analysis_for_subpart.get_maximum_tries | public function get_maximum_tries() {
$max = 1;
foreach ($this->get_response_class_ids() as $responseclassid) {
$max = max($max, $this->get_response_class($responseclassid)->get_maximum_tries());
}
return $max;
} | php | public function get_maximum_tries() {
$max = 1;
foreach ($this->get_response_class_ids() as $responseclassid) {
$max = max($max, $this->get_response_class($responseclassid)->get_maximum_tries());
}
return $max;
} | [
"public",
"function",
"get_maximum_tries",
"(",
")",
"{",
"$",
"max",
"=",
"1",
";",
"foreach",
"(",
"$",
"this",
"->",
"get_response_class_ids",
"(",
")",
"as",
"$",
"responseclassid",
")",
"{",
"$",
"max",
"=",
"max",
"(",
"$",
"max",
",",
"$",
"this",
"->",
"get_response_class",
"(",
"$",
"responseclassid",
")",
"->",
"get_maximum_tries",
"(",
")",
")",
";",
"}",
"return",
"$",
"max",
";",
"}"
] | What is the highest try number for this sub part?
@return int max tries | [
"What",
"is",
"the",
"highest",
"try",
"number",
"for",
"this",
"sub",
"part?"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/statistics/responses/analysis_for_subpart.php#L151-L157 |
215,079 | moodle/moodle | mod/quiz/report/overview/report.php | quiz_overview_report.process_actions | protected function process_actions($quiz, $cm, $currentgroup, \core\dml\sql_join $groupstudentsjoins,
\core\dml\sql_join $allowedjoins, $redirecturl) {
parent::process_actions($quiz, $cm, $currentgroup, $groupstudentsjoins, $allowedjoins, $redirecturl);
if (empty($currentgroup) || $this->hasgroupstudents) {
if (optional_param('regrade', 0, PARAM_BOOL) && confirm_sesskey()) {
if ($attemptids = optional_param_array('attemptid', array(), PARAM_INT)) {
$this->start_regrade($quiz, $cm);
$this->regrade_attempts($quiz, false, $groupstudentsjoins, $attemptids);
$this->finish_regrade($redirecturl);
}
}
}
if (optional_param('regradeall', 0, PARAM_BOOL) && confirm_sesskey()) {
$this->start_regrade($quiz, $cm);
$this->regrade_attempts($quiz, false, $groupstudentsjoins);
$this->finish_regrade($redirecturl);
} else if (optional_param('regradealldry', 0, PARAM_BOOL) && confirm_sesskey()) {
$this->start_regrade($quiz, $cm);
$this->regrade_attempts($quiz, true, $groupstudentsjoins);
$this->finish_regrade($redirecturl);
} else if (optional_param('regradealldrydo', 0, PARAM_BOOL) && confirm_sesskey()) {
$this->start_regrade($quiz, $cm);
$this->regrade_attempts_needing_it($quiz, $groupstudentsjoins);
$this->finish_regrade($redirecturl);
}
} | php | protected function process_actions($quiz, $cm, $currentgroup, \core\dml\sql_join $groupstudentsjoins,
\core\dml\sql_join $allowedjoins, $redirecturl) {
parent::process_actions($quiz, $cm, $currentgroup, $groupstudentsjoins, $allowedjoins, $redirecturl);
if (empty($currentgroup) || $this->hasgroupstudents) {
if (optional_param('regrade', 0, PARAM_BOOL) && confirm_sesskey()) {
if ($attemptids = optional_param_array('attemptid', array(), PARAM_INT)) {
$this->start_regrade($quiz, $cm);
$this->regrade_attempts($quiz, false, $groupstudentsjoins, $attemptids);
$this->finish_regrade($redirecturl);
}
}
}
if (optional_param('regradeall', 0, PARAM_BOOL) && confirm_sesskey()) {
$this->start_regrade($quiz, $cm);
$this->regrade_attempts($quiz, false, $groupstudentsjoins);
$this->finish_regrade($redirecturl);
} else if (optional_param('regradealldry', 0, PARAM_BOOL) && confirm_sesskey()) {
$this->start_regrade($quiz, $cm);
$this->regrade_attempts($quiz, true, $groupstudentsjoins);
$this->finish_regrade($redirecturl);
} else if (optional_param('regradealldrydo', 0, PARAM_BOOL) && confirm_sesskey()) {
$this->start_regrade($quiz, $cm);
$this->regrade_attempts_needing_it($quiz, $groupstudentsjoins);
$this->finish_regrade($redirecturl);
}
} | [
"protected",
"function",
"process_actions",
"(",
"$",
"quiz",
",",
"$",
"cm",
",",
"$",
"currentgroup",
",",
"\\",
"core",
"\\",
"dml",
"\\",
"sql_join",
"$",
"groupstudentsjoins",
",",
"\\",
"core",
"\\",
"dml",
"\\",
"sql_join",
"$",
"allowedjoins",
",",
"$",
"redirecturl",
")",
"{",
"parent",
"::",
"process_actions",
"(",
"$",
"quiz",
",",
"$",
"cm",
",",
"$",
"currentgroup",
",",
"$",
"groupstudentsjoins",
",",
"$",
"allowedjoins",
",",
"$",
"redirecturl",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"currentgroup",
")",
"||",
"$",
"this",
"->",
"hasgroupstudents",
")",
"{",
"if",
"(",
"optional_param",
"(",
"'regrade'",
",",
"0",
",",
"PARAM_BOOL",
")",
"&&",
"confirm_sesskey",
"(",
")",
")",
"{",
"if",
"(",
"$",
"attemptids",
"=",
"optional_param_array",
"(",
"'attemptid'",
",",
"array",
"(",
")",
",",
"PARAM_INT",
")",
")",
"{",
"$",
"this",
"->",
"start_regrade",
"(",
"$",
"quiz",
",",
"$",
"cm",
")",
";",
"$",
"this",
"->",
"regrade_attempts",
"(",
"$",
"quiz",
",",
"false",
",",
"$",
"groupstudentsjoins",
",",
"$",
"attemptids",
")",
";",
"$",
"this",
"->",
"finish_regrade",
"(",
"$",
"redirecturl",
")",
";",
"}",
"}",
"}",
"if",
"(",
"optional_param",
"(",
"'regradeall'",
",",
"0",
",",
"PARAM_BOOL",
")",
"&&",
"confirm_sesskey",
"(",
")",
")",
"{",
"$",
"this",
"->",
"start_regrade",
"(",
"$",
"quiz",
",",
"$",
"cm",
")",
";",
"$",
"this",
"->",
"regrade_attempts",
"(",
"$",
"quiz",
",",
"false",
",",
"$",
"groupstudentsjoins",
")",
";",
"$",
"this",
"->",
"finish_regrade",
"(",
"$",
"redirecturl",
")",
";",
"}",
"else",
"if",
"(",
"optional_param",
"(",
"'regradealldry'",
",",
"0",
",",
"PARAM_BOOL",
")",
"&&",
"confirm_sesskey",
"(",
")",
")",
"{",
"$",
"this",
"->",
"start_regrade",
"(",
"$",
"quiz",
",",
"$",
"cm",
")",
";",
"$",
"this",
"->",
"regrade_attempts",
"(",
"$",
"quiz",
",",
"true",
",",
"$",
"groupstudentsjoins",
")",
";",
"$",
"this",
"->",
"finish_regrade",
"(",
"$",
"redirecturl",
")",
";",
"}",
"else",
"if",
"(",
"optional_param",
"(",
"'regradealldrydo'",
",",
"0",
",",
"PARAM_BOOL",
")",
"&&",
"confirm_sesskey",
"(",
")",
")",
"{",
"$",
"this",
"->",
"start_regrade",
"(",
"$",
"quiz",
",",
"$",
"cm",
")",
";",
"$",
"this",
"->",
"regrade_attempts_needing_it",
"(",
"$",
"quiz",
",",
"$",
"groupstudentsjoins",
")",
";",
"$",
"this",
"->",
"finish_regrade",
"(",
"$",
"redirecturl",
")",
";",
"}",
"}"
] | Extends parent function processing any submitted actions.
@param object $quiz
@param object $cm
@param int $currentgroup
@param \core\dml\sql_join $groupstudentsjoins (joins, wheres, params)
@param \core\dml\sql_join $allowedjoins (joins, wheres, params)
@param moodle_url $redirecturl | [
"Extends",
"parent",
"function",
"processing",
"any",
"submitted",
"actions",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/overview/report.php#L246-L275 |
215,080 | moodle/moodle | mod/quiz/report/overview/report.php | quiz_overview_report.start_regrade | protected function start_regrade($quiz, $cm) {
require_capability('mod/quiz:regrade', $this->context);
$this->print_header_and_tabs($cm, $this->course, $quiz, $this->mode);
} | php | protected function start_regrade($quiz, $cm) {
require_capability('mod/quiz:regrade', $this->context);
$this->print_header_and_tabs($cm, $this->course, $quiz, $this->mode);
} | [
"protected",
"function",
"start_regrade",
"(",
"$",
"quiz",
",",
"$",
"cm",
")",
"{",
"require_capability",
"(",
"'mod/quiz:regrade'",
",",
"$",
"this",
"->",
"context",
")",
";",
"$",
"this",
"->",
"print_header_and_tabs",
"(",
"$",
"cm",
",",
"$",
"this",
"->",
"course",
",",
"$",
"quiz",
",",
"$",
"this",
"->",
"mode",
")",
";",
"}"
] | Check necessary capabilities, and start the display of the regrade progress page.
@param object $quiz the quiz settings.
@param object $cm the cm object for the quiz. | [
"Check",
"necessary",
"capabilities",
"and",
"start",
"the",
"display",
"of",
"the",
"regrade",
"progress",
"page",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/overview/report.php#L282-L285 |
215,081 | moodle/moodle | mod/quiz/report/overview/report.php | quiz_overview_report.finish_regrade | protected function finish_regrade($nexturl) {
global $OUTPUT;
\core\notification::success(get_string('regradecomplete', 'quiz_overview'));
echo $OUTPUT->continue_button($nexturl);
echo $OUTPUT->footer();
die();
} | php | protected function finish_regrade($nexturl) {
global $OUTPUT;
\core\notification::success(get_string('regradecomplete', 'quiz_overview'));
echo $OUTPUT->continue_button($nexturl);
echo $OUTPUT->footer();
die();
} | [
"protected",
"function",
"finish_regrade",
"(",
"$",
"nexturl",
")",
"{",
"global",
"$",
"OUTPUT",
";",
"\\",
"core",
"\\",
"notification",
"::",
"success",
"(",
"get_string",
"(",
"'regradecomplete'",
",",
"'quiz_overview'",
")",
")",
";",
"echo",
"$",
"OUTPUT",
"->",
"continue_button",
"(",
"$",
"nexturl",
")",
";",
"echo",
"$",
"OUTPUT",
"->",
"footer",
"(",
")",
";",
"die",
"(",
")",
";",
"}"
] | Finish displaying the regrade progress page.
@param moodle_url $nexturl where to send the user after the regrade.
@uses exit. This method never returns. | [
"Finish",
"displaying",
"the",
"regrade",
"progress",
"page",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/overview/report.php#L292-L298 |
215,082 | moodle/moodle | mod/quiz/report/overview/report.php | quiz_overview_report.regrade_attempts | protected function regrade_attempts($quiz, $dryrun = false,
\core\dml\sql_join$groupstudentsjoins = null, $attemptids = array()) {
global $DB;
$this->unlock_session();
$sql = "SELECT quiza.*
FROM {quiz_attempts} quiza";
$where = "quiz = :qid AND preview = 0";
$params = array('qid' => $quiz->id);
if ($this->hasgroupstudents && !empty($groupstudentsjoins->joins)) {
$sql .= "\nJOIN {user} u ON u.id = quiza.userid
{$groupstudentsjoins->joins}";
$where .= " AND {$groupstudentsjoins->wheres}";
$params += $groupstudentsjoins->params;
}
if ($attemptids) {
$aids = join(',', $attemptids);
$where .= " AND quiza.id IN ({$aids})";
}
$sql .= "\nWHERE {$where}";
$attempts = $DB->get_records_sql($sql, $params);
if (!$attempts) {
return;
}
$this->clear_regrade_table($quiz, $groupstudentsjoins);
$progressbar = new progress_bar('quiz_overview_regrade', 500, true);
$a = array(
'count' => count($attempts),
'done' => 0,
);
foreach ($attempts as $attempt) {
$this->regrade_attempt($attempt, $dryrun);
$a['done']++;
$progressbar->update($a['done'], $a['count'],
get_string('regradingattemptxofy', 'quiz_overview', $a));
}
if (!$dryrun) {
$this->update_overall_grades($quiz);
}
} | php | protected function regrade_attempts($quiz, $dryrun = false,
\core\dml\sql_join$groupstudentsjoins = null, $attemptids = array()) {
global $DB;
$this->unlock_session();
$sql = "SELECT quiza.*
FROM {quiz_attempts} quiza";
$where = "quiz = :qid AND preview = 0";
$params = array('qid' => $quiz->id);
if ($this->hasgroupstudents && !empty($groupstudentsjoins->joins)) {
$sql .= "\nJOIN {user} u ON u.id = quiza.userid
{$groupstudentsjoins->joins}";
$where .= " AND {$groupstudentsjoins->wheres}";
$params += $groupstudentsjoins->params;
}
if ($attemptids) {
$aids = join(',', $attemptids);
$where .= " AND quiza.id IN ({$aids})";
}
$sql .= "\nWHERE {$where}";
$attempts = $DB->get_records_sql($sql, $params);
if (!$attempts) {
return;
}
$this->clear_regrade_table($quiz, $groupstudentsjoins);
$progressbar = new progress_bar('quiz_overview_regrade', 500, true);
$a = array(
'count' => count($attempts),
'done' => 0,
);
foreach ($attempts as $attempt) {
$this->regrade_attempt($attempt, $dryrun);
$a['done']++;
$progressbar->update($a['done'], $a['count'],
get_string('regradingattemptxofy', 'quiz_overview', $a));
}
if (!$dryrun) {
$this->update_overall_grades($quiz);
}
} | [
"protected",
"function",
"regrade_attempts",
"(",
"$",
"quiz",
",",
"$",
"dryrun",
"=",
"false",
",",
"\\",
"core",
"\\",
"dml",
"\\",
"sql_join",
"$",
"groupstudentsjoins",
"=",
"null",
",",
"$",
"attemptids",
"=",
"array",
"(",
")",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"this",
"->",
"unlock_session",
"(",
")",
";",
"$",
"sql",
"=",
"\"SELECT quiza.*\n FROM {quiz_attempts} quiza\"",
";",
"$",
"where",
"=",
"\"quiz = :qid AND preview = 0\"",
";",
"$",
"params",
"=",
"array",
"(",
"'qid'",
"=>",
"$",
"quiz",
"->",
"id",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasgroupstudents",
"&&",
"!",
"empty",
"(",
"$",
"groupstudentsjoins",
"->",
"joins",
")",
")",
"{",
"$",
"sql",
".=",
"\"\\nJOIN {user} u ON u.id = quiza.userid\n {$groupstudentsjoins->joins}\"",
";",
"$",
"where",
".=",
"\" AND {$groupstudentsjoins->wheres}\"",
";",
"$",
"params",
"+=",
"$",
"groupstudentsjoins",
"->",
"params",
";",
"}",
"if",
"(",
"$",
"attemptids",
")",
"{",
"$",
"aids",
"=",
"join",
"(",
"','",
",",
"$",
"attemptids",
")",
";",
"$",
"where",
".=",
"\" AND quiza.id IN ({$aids})\"",
";",
"}",
"$",
"sql",
".=",
"\"\\nWHERE {$where}\"",
";",
"$",
"attempts",
"=",
"$",
"DB",
"->",
"get_records_sql",
"(",
"$",
"sql",
",",
"$",
"params",
")",
";",
"if",
"(",
"!",
"$",
"attempts",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"clear_regrade_table",
"(",
"$",
"quiz",
",",
"$",
"groupstudentsjoins",
")",
";",
"$",
"progressbar",
"=",
"new",
"progress_bar",
"(",
"'quiz_overview_regrade'",
",",
"500",
",",
"true",
")",
";",
"$",
"a",
"=",
"array",
"(",
"'count'",
"=>",
"count",
"(",
"$",
"attempts",
")",
",",
"'done'",
"=>",
"0",
",",
")",
";",
"foreach",
"(",
"$",
"attempts",
"as",
"$",
"attempt",
")",
"{",
"$",
"this",
"->",
"regrade_attempt",
"(",
"$",
"attempt",
",",
"$",
"dryrun",
")",
";",
"$",
"a",
"[",
"'done'",
"]",
"++",
";",
"$",
"progressbar",
"->",
"update",
"(",
"$",
"a",
"[",
"'done'",
"]",
",",
"$",
"a",
"[",
"'count'",
"]",
",",
"get_string",
"(",
"'regradingattemptxofy'",
",",
"'quiz_overview'",
",",
"$",
"a",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"dryrun",
")",
"{",
"$",
"this",
"->",
"update_overall_grades",
"(",
"$",
"quiz",
")",
";",
"}",
"}"
] | Regrade attempts for this quiz, exactly which attempts are regraded is
controlled by the parameters.
@param object $quiz the quiz settings.
@param bool $dryrun if true, do a pretend regrade, otherwise do it for real.
@param \core\dml\sql_join|array $groupstudentsjoins empty for all attempts, otherwise regrade attempts
for these users.
@param array $attemptids blank for all attempts, otherwise only regrade
attempts whose id is in this list. | [
"Regrade",
"attempts",
"for",
"this",
"quiz",
"exactly",
"which",
"attempts",
"are",
"regraded",
"is",
"controlled",
"by",
"the",
"parameters",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/overview/report.php#L374-L419 |
215,083 | moodle/moodle | mod/quiz/report/overview/report.php | quiz_overview_report.regrade_attempts_needing_it | protected function regrade_attempts_needing_it($quiz, \core\dml\sql_join $groupstudentsjoins) {
global $DB;
$this->unlock_session();
$join = '{quiz_overview_regrades} qqr ON qqr.questionusageid = quiza.uniqueid';
$where = "quiza.quiz = :qid AND quiza.preview = 0 AND qqr.regraded = 0";
$params = array('qid' => $quiz->id);
// Fetch all attempts that need regrading.
if ($this->hasgroupstudents && !empty($groupstudentsjoins->joins)) {
$join .= "\nJOIN {user} u ON u.id = quiza.userid
{$groupstudentsjoins->joins}";
$where .= " AND {$groupstudentsjoins->wheres}";
$params += $groupstudentsjoins->params;
}
$toregrade = $DB->get_recordset_sql("
SELECT quiza.uniqueid, qqr.slot
FROM {quiz_attempts} quiza
JOIN $join
WHERE $where", $params);
$attemptquestions = array();
foreach ($toregrade as $row) {
$attemptquestions[$row->uniqueid][] = $row->slot;
}
$toregrade->close();
if (!$attemptquestions) {
return;
}
$attempts = $DB->get_records_list('quiz_attempts', 'uniqueid',
array_keys($attemptquestions));
$this->clear_regrade_table($quiz, $groupstudentsjoins);
$progressbar = new progress_bar('quiz_overview_regrade', 500, true);
$a = array(
'count' => count($attempts),
'done' => 0,
);
foreach ($attempts as $attempt) {
$this->regrade_attempt($attempt, false, $attemptquestions[$attempt->uniqueid]);
$a['done']++;
$progressbar->update($a['done'], $a['count'],
get_string('regradingattemptxofy', 'quiz_overview', $a));
}
$this->update_overall_grades($quiz);
} | php | protected function regrade_attempts_needing_it($quiz, \core\dml\sql_join $groupstudentsjoins) {
global $DB;
$this->unlock_session();
$join = '{quiz_overview_regrades} qqr ON qqr.questionusageid = quiza.uniqueid';
$where = "quiza.quiz = :qid AND quiza.preview = 0 AND qqr.regraded = 0";
$params = array('qid' => $quiz->id);
// Fetch all attempts that need regrading.
if ($this->hasgroupstudents && !empty($groupstudentsjoins->joins)) {
$join .= "\nJOIN {user} u ON u.id = quiza.userid
{$groupstudentsjoins->joins}";
$where .= " AND {$groupstudentsjoins->wheres}";
$params += $groupstudentsjoins->params;
}
$toregrade = $DB->get_recordset_sql("
SELECT quiza.uniqueid, qqr.slot
FROM {quiz_attempts} quiza
JOIN $join
WHERE $where", $params);
$attemptquestions = array();
foreach ($toregrade as $row) {
$attemptquestions[$row->uniqueid][] = $row->slot;
}
$toregrade->close();
if (!$attemptquestions) {
return;
}
$attempts = $DB->get_records_list('quiz_attempts', 'uniqueid',
array_keys($attemptquestions));
$this->clear_regrade_table($quiz, $groupstudentsjoins);
$progressbar = new progress_bar('quiz_overview_regrade', 500, true);
$a = array(
'count' => count($attempts),
'done' => 0,
);
foreach ($attempts as $attempt) {
$this->regrade_attempt($attempt, false, $attemptquestions[$attempt->uniqueid]);
$a['done']++;
$progressbar->update($a['done'], $a['count'],
get_string('regradingattemptxofy', 'quiz_overview', $a));
}
$this->update_overall_grades($quiz);
} | [
"protected",
"function",
"regrade_attempts_needing_it",
"(",
"$",
"quiz",
",",
"\\",
"core",
"\\",
"dml",
"\\",
"sql_join",
"$",
"groupstudentsjoins",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"this",
"->",
"unlock_session",
"(",
")",
";",
"$",
"join",
"=",
"'{quiz_overview_regrades} qqr ON qqr.questionusageid = quiza.uniqueid'",
";",
"$",
"where",
"=",
"\"quiza.quiz = :qid AND quiza.preview = 0 AND qqr.regraded = 0\"",
";",
"$",
"params",
"=",
"array",
"(",
"'qid'",
"=>",
"$",
"quiz",
"->",
"id",
")",
";",
"// Fetch all attempts that need regrading.",
"if",
"(",
"$",
"this",
"->",
"hasgroupstudents",
"&&",
"!",
"empty",
"(",
"$",
"groupstudentsjoins",
"->",
"joins",
")",
")",
"{",
"$",
"join",
".=",
"\"\\nJOIN {user} u ON u.id = quiza.userid\n {$groupstudentsjoins->joins}\"",
";",
"$",
"where",
".=",
"\" AND {$groupstudentsjoins->wheres}\"",
";",
"$",
"params",
"+=",
"$",
"groupstudentsjoins",
"->",
"params",
";",
"}",
"$",
"toregrade",
"=",
"$",
"DB",
"->",
"get_recordset_sql",
"(",
"\"\n SELECT quiza.uniqueid, qqr.slot\n FROM {quiz_attempts} quiza\n JOIN $join\n WHERE $where\"",
",",
"$",
"params",
")",
";",
"$",
"attemptquestions",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"toregrade",
"as",
"$",
"row",
")",
"{",
"$",
"attemptquestions",
"[",
"$",
"row",
"->",
"uniqueid",
"]",
"[",
"]",
"=",
"$",
"row",
"->",
"slot",
";",
"}",
"$",
"toregrade",
"->",
"close",
"(",
")",
";",
"if",
"(",
"!",
"$",
"attemptquestions",
")",
"{",
"return",
";",
"}",
"$",
"attempts",
"=",
"$",
"DB",
"->",
"get_records_list",
"(",
"'quiz_attempts'",
",",
"'uniqueid'",
",",
"array_keys",
"(",
"$",
"attemptquestions",
")",
")",
";",
"$",
"this",
"->",
"clear_regrade_table",
"(",
"$",
"quiz",
",",
"$",
"groupstudentsjoins",
")",
";",
"$",
"progressbar",
"=",
"new",
"progress_bar",
"(",
"'quiz_overview_regrade'",
",",
"500",
",",
"true",
")",
";",
"$",
"a",
"=",
"array",
"(",
"'count'",
"=>",
"count",
"(",
"$",
"attempts",
")",
",",
"'done'",
"=>",
"0",
",",
")",
";",
"foreach",
"(",
"$",
"attempts",
"as",
"$",
"attempt",
")",
"{",
"$",
"this",
"->",
"regrade_attempt",
"(",
"$",
"attempt",
",",
"false",
",",
"$",
"attemptquestions",
"[",
"$",
"attempt",
"->",
"uniqueid",
"]",
")",
";",
"$",
"a",
"[",
"'done'",
"]",
"++",
";",
"$",
"progressbar",
"->",
"update",
"(",
"$",
"a",
"[",
"'done'",
"]",
",",
"$",
"a",
"[",
"'count'",
"]",
",",
"get_string",
"(",
"'regradingattemptxofy'",
",",
"'quiz_overview'",
",",
"$",
"a",
")",
")",
";",
"}",
"$",
"this",
"->",
"update_overall_grades",
"(",
"$",
"quiz",
")",
";",
"}"
] | Regrade those questions in those attempts that are marked as needing regrading
in the quiz_overview_regrades table.
@param object $quiz the quiz settings.
@param \core\dml\sql_join $groupstudentsjoins empty for all attempts, otherwise regrade attempts
for these users. | [
"Regrade",
"those",
"questions",
"in",
"those",
"attempts",
"that",
"are",
"marked",
"as",
"needing",
"regrading",
"in",
"the",
"quiz_overview_regrades",
"table",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/overview/report.php#L428-L478 |
215,084 | moodle/moodle | mod/quiz/report/overview/report.php | quiz_overview_report.count_question_attempts_needing_regrade | protected function count_question_attempts_needing_regrade($quiz, \core\dml\sql_join $groupstudentsjoins) {
global $DB;
$userjoin = '';
$usertest = '';
$params = array();
if ($this->hasgroupstudents) {
$userjoin = "JOIN {user} u ON u.id = quiza.userid
{$groupstudentsjoins->joins}";
$usertest = "{$groupstudentsjoins->wheres} AND u.id = quiza.userid AND ";
$params = $groupstudentsjoins->params;
}
$params['cquiz'] = $quiz->id;
$sql = "SELECT COUNT(DISTINCT quiza.id)
FROM {quiz_attempts} quiza
JOIN {quiz_overview_regrades} qqr ON quiza.uniqueid = qqr.questionusageid
$userjoin
WHERE
$usertest
quiza.quiz = :cquiz AND
quiza.preview = 0 AND
qqr.regraded = 0";
return $DB->count_records_sql($sql, $params);
} | php | protected function count_question_attempts_needing_regrade($quiz, \core\dml\sql_join $groupstudentsjoins) {
global $DB;
$userjoin = '';
$usertest = '';
$params = array();
if ($this->hasgroupstudents) {
$userjoin = "JOIN {user} u ON u.id = quiza.userid
{$groupstudentsjoins->joins}";
$usertest = "{$groupstudentsjoins->wheres} AND u.id = quiza.userid AND ";
$params = $groupstudentsjoins->params;
}
$params['cquiz'] = $quiz->id;
$sql = "SELECT COUNT(DISTINCT quiza.id)
FROM {quiz_attempts} quiza
JOIN {quiz_overview_regrades} qqr ON quiza.uniqueid = qqr.questionusageid
$userjoin
WHERE
$usertest
quiza.quiz = :cquiz AND
quiza.preview = 0 AND
qqr.regraded = 0";
return $DB->count_records_sql($sql, $params);
} | [
"protected",
"function",
"count_question_attempts_needing_regrade",
"(",
"$",
"quiz",
",",
"\\",
"core",
"\\",
"dml",
"\\",
"sql_join",
"$",
"groupstudentsjoins",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"userjoin",
"=",
"''",
";",
"$",
"usertest",
"=",
"''",
";",
"$",
"params",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasgroupstudents",
")",
"{",
"$",
"userjoin",
"=",
"\"JOIN {user} u ON u.id = quiza.userid\n {$groupstudentsjoins->joins}\"",
";",
"$",
"usertest",
"=",
"\"{$groupstudentsjoins->wheres} AND u.id = quiza.userid AND \"",
";",
"$",
"params",
"=",
"$",
"groupstudentsjoins",
"->",
"params",
";",
"}",
"$",
"params",
"[",
"'cquiz'",
"]",
"=",
"$",
"quiz",
"->",
"id",
";",
"$",
"sql",
"=",
"\"SELECT COUNT(DISTINCT quiza.id)\n FROM {quiz_attempts} quiza\n JOIN {quiz_overview_regrades} qqr ON quiza.uniqueid = qqr.questionusageid\n $userjoin\n WHERE\n $usertest\n quiza.quiz = :cquiz AND\n quiza.preview = 0 AND\n qqr.regraded = 0\"",
";",
"return",
"$",
"DB",
"->",
"count_records_sql",
"(",
"$",
"sql",
",",
"$",
"params",
")",
";",
"}"
] | Count the number of attempts in need of a regrade.
@param object $quiz the quiz settings.
@param \core\dml\sql_join $groupstudentsjoins (joins, wheres, params) If this is given, only data relating
to these users is cleared. | [
"Count",
"the",
"number",
"of",
"attempts",
"in",
"need",
"of",
"a",
"regrade",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/overview/report.php#L486-L510 |
215,085 | moodle/moodle | mod/quiz/report/overview/report.php | quiz_overview_report.get_bands_count_and_width | public static function get_bands_count_and_width($quiz) {
$bands = $quiz->grade;
while ($bands > 20 || $bands <= 10) {
if ($bands > 50) {
$bands /= 5;
} else if ($bands > 20) {
$bands /= 2;
}
if ($bands < 4) {
$bands *= 5;
} else if ($bands <= 10) {
$bands *= 2;
}
}
// See MDL-34589. Using doubles as array keys causes problems in PHP 5.4, hence the explicit cast to int.
$bands = (int) ceil($bands);
return [$bands, $quiz->grade / $bands];
} | php | public static function get_bands_count_and_width($quiz) {
$bands = $quiz->grade;
while ($bands > 20 || $bands <= 10) {
if ($bands > 50) {
$bands /= 5;
} else if ($bands > 20) {
$bands /= 2;
}
if ($bands < 4) {
$bands *= 5;
} else if ($bands <= 10) {
$bands *= 2;
}
}
// See MDL-34589. Using doubles as array keys causes problems in PHP 5.4, hence the explicit cast to int.
$bands = (int) ceil($bands);
return [$bands, $quiz->grade / $bands];
} | [
"public",
"static",
"function",
"get_bands_count_and_width",
"(",
"$",
"quiz",
")",
"{",
"$",
"bands",
"=",
"$",
"quiz",
"->",
"grade",
";",
"while",
"(",
"$",
"bands",
">",
"20",
"||",
"$",
"bands",
"<=",
"10",
")",
"{",
"if",
"(",
"$",
"bands",
">",
"50",
")",
"{",
"$",
"bands",
"/=",
"5",
";",
"}",
"else",
"if",
"(",
"$",
"bands",
">",
"20",
")",
"{",
"$",
"bands",
"/=",
"2",
";",
"}",
"if",
"(",
"$",
"bands",
"<",
"4",
")",
"{",
"$",
"bands",
"*=",
"5",
";",
"}",
"else",
"if",
"(",
"$",
"bands",
"<=",
"10",
")",
"{",
"$",
"bands",
"*=",
"2",
";",
"}",
"}",
"// See MDL-34589. Using doubles as array keys causes problems in PHP 5.4, hence the explicit cast to int.",
"$",
"bands",
"=",
"(",
"int",
")",
"ceil",
"(",
"$",
"bands",
")",
";",
"return",
"[",
"$",
"bands",
",",
"$",
"quiz",
"->",
"grade",
"/",
"$",
"bands",
"]",
";",
"}"
] | Get the bands configuration for the quiz.
This returns the configuration for having between 11 and 20 bars in
a chart based on the maximum grade to be given on a quiz. The width of
a band is the number of grade points it encapsulates.
@param object $quiz The quiz object.
@return array Contains the number of bands, and their width. | [
"Get",
"the",
"bands",
"configuration",
"for",
"the",
"quiz",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/overview/report.php#L577-L594 |
215,086 | moodle/moodle | mod/quiz/report/overview/report.php | quiz_overview_report.get_bands_labels | public static function get_bands_labels($bands, $bandwidth, $quiz) {
$bandlabels = [];
for ($i = 1; $i <= $bands; $i++) {
$bandlabels[] = quiz_format_grade($quiz, ($i - 1) * $bandwidth) . ' - ' . quiz_format_grade($quiz, $i * $bandwidth);
}
return $bandlabels;
} | php | public static function get_bands_labels($bands, $bandwidth, $quiz) {
$bandlabels = [];
for ($i = 1; $i <= $bands; $i++) {
$bandlabels[] = quiz_format_grade($quiz, ($i - 1) * $bandwidth) . ' - ' . quiz_format_grade($quiz, $i * $bandwidth);
}
return $bandlabels;
} | [
"public",
"static",
"function",
"get_bands_labels",
"(",
"$",
"bands",
",",
"$",
"bandwidth",
",",
"$",
"quiz",
")",
"{",
"$",
"bandlabels",
"=",
"[",
"]",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"bands",
";",
"$",
"i",
"++",
")",
"{",
"$",
"bandlabels",
"[",
"]",
"=",
"quiz_format_grade",
"(",
"$",
"quiz",
",",
"(",
"$",
"i",
"-",
"1",
")",
"*",
"$",
"bandwidth",
")",
".",
"' - '",
".",
"quiz_format_grade",
"(",
"$",
"quiz",
",",
"$",
"i",
"*",
"$",
"bandwidth",
")",
";",
"}",
"return",
"$",
"bandlabels",
";",
"}"
] | Get the bands labels.
@param int $bands The number of bands.
@param int $bandwidth The band width.
@param object $quiz The quiz object.
@return string[] The labels. | [
"Get",
"the",
"bands",
"labels",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/overview/report.php#L604-L610 |
215,087 | moodle/moodle | mod/quiz/report/overview/report.php | quiz_overview_report.get_chart | protected static function get_chart($labels, $data) {
$chart = new \core\chart_bar();
$chart->set_labels($labels);
$chart->get_xaxis(0, true)->set_label(get_string('grade'));
$yaxis = $chart->get_yaxis(0, true);
$yaxis->set_label(get_string('participants'));
$yaxis->set_stepsize(max(1, round(max($data) / 10)));
$series = new \core\chart_series(get_string('participants'), $data);
$chart->add_series($series);
return $chart;
} | php | protected static function get_chart($labels, $data) {
$chart = new \core\chart_bar();
$chart->set_labels($labels);
$chart->get_xaxis(0, true)->set_label(get_string('grade'));
$yaxis = $chart->get_yaxis(0, true);
$yaxis->set_label(get_string('participants'));
$yaxis->set_stepsize(max(1, round(max($data) / 10)));
$series = new \core\chart_series(get_string('participants'), $data);
$chart->add_series($series);
return $chart;
} | [
"protected",
"static",
"function",
"get_chart",
"(",
"$",
"labels",
",",
"$",
"data",
")",
"{",
"$",
"chart",
"=",
"new",
"\\",
"core",
"\\",
"chart_bar",
"(",
")",
";",
"$",
"chart",
"->",
"set_labels",
"(",
"$",
"labels",
")",
";",
"$",
"chart",
"->",
"get_xaxis",
"(",
"0",
",",
"true",
")",
"->",
"set_label",
"(",
"get_string",
"(",
"'grade'",
")",
")",
";",
"$",
"yaxis",
"=",
"$",
"chart",
"->",
"get_yaxis",
"(",
"0",
",",
"true",
")",
";",
"$",
"yaxis",
"->",
"set_label",
"(",
"get_string",
"(",
"'participants'",
")",
")",
";",
"$",
"yaxis",
"->",
"set_stepsize",
"(",
"max",
"(",
"1",
",",
"round",
"(",
"max",
"(",
"$",
"data",
")",
"/",
"10",
")",
")",
")",
";",
"$",
"series",
"=",
"new",
"\\",
"core",
"\\",
"chart_series",
"(",
"get_string",
"(",
"'participants'",
")",
",",
"$",
"data",
")",
";",
"$",
"chart",
"->",
"add_series",
"(",
"$",
"series",
")",
";",
"return",
"$",
"chart",
";",
"}"
] | Get a chart.
@param string[] $labels Chart labels.
@param int[] $data The data.
@return \core\chart_base | [
"Get",
"a",
"chart",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/overview/report.php#L619-L631 |
215,088 | moodle/moodle | lib/phpexcel/PHPExcel/Shared/File.php | PHPExcel_Shared_File.file_exists | public static function file_exists($pFilename)
{
// Sick construction, but it seems that
// file_exists returns strange values when
// doing the original file_exists on ZIP archives...
if (strtolower(substr($pFilename, 0, 3)) == 'zip') {
// Open ZIP file and verify if the file exists
$zipFile = substr($pFilename, 6, strpos($pFilename, '#') - 6);
$archiveFile = substr($pFilename, strpos($pFilename, '#') + 1);
$zip = new ZipArchive();
if ($zip->open($zipFile) === true) {
$returnValue = ($zip->getFromName($archiveFile) !== false);
$zip->close();
return $returnValue;
} else {
return false;
}
} else {
// Regular file_exists
return file_exists($pFilename);
}
} | php | public static function file_exists($pFilename)
{
// Sick construction, but it seems that
// file_exists returns strange values when
// doing the original file_exists on ZIP archives...
if (strtolower(substr($pFilename, 0, 3)) == 'zip') {
// Open ZIP file and verify if the file exists
$zipFile = substr($pFilename, 6, strpos($pFilename, '#') - 6);
$archiveFile = substr($pFilename, strpos($pFilename, '#') + 1);
$zip = new ZipArchive();
if ($zip->open($zipFile) === true) {
$returnValue = ($zip->getFromName($archiveFile) !== false);
$zip->close();
return $returnValue;
} else {
return false;
}
} else {
// Regular file_exists
return file_exists($pFilename);
}
} | [
"public",
"static",
"function",
"file_exists",
"(",
"$",
"pFilename",
")",
"{",
"// Sick construction, but it seems that",
"// file_exists returns strange values when",
"// doing the original file_exists on ZIP archives...",
"if",
"(",
"strtolower",
"(",
"substr",
"(",
"$",
"pFilename",
",",
"0",
",",
"3",
")",
")",
"==",
"'zip'",
")",
"{",
"// Open ZIP file and verify if the file exists",
"$",
"zipFile",
"=",
"substr",
"(",
"$",
"pFilename",
",",
"6",
",",
"strpos",
"(",
"$",
"pFilename",
",",
"'#'",
")",
"-",
"6",
")",
";",
"$",
"archiveFile",
"=",
"substr",
"(",
"$",
"pFilename",
",",
"strpos",
"(",
"$",
"pFilename",
",",
"'#'",
")",
"+",
"1",
")",
";",
"$",
"zip",
"=",
"new",
"ZipArchive",
"(",
")",
";",
"if",
"(",
"$",
"zip",
"->",
"open",
"(",
"$",
"zipFile",
")",
"===",
"true",
")",
"{",
"$",
"returnValue",
"=",
"(",
"$",
"zip",
"->",
"getFromName",
"(",
"$",
"archiveFile",
")",
"!==",
"false",
")",
";",
"$",
"zip",
"->",
"close",
"(",
")",
";",
"return",
"$",
"returnValue",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"else",
"{",
"// Regular file_exists",
"return",
"file_exists",
"(",
"$",
"pFilename",
")",
";",
"}",
"}"
] | Verify if a file exists
@param string $pFilename Filename
@return bool | [
"Verify",
"if",
"a",
"file",
"exists"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpexcel/PHPExcel/Shared/File.php#L67-L89 |
215,089 | moodle/moodle | admin/tool/log/classes/local/privacy/moodle_database_export_and_delete.php | moodle_database_export_and_delete.delete_data_for_userlist | public static function delete_data_for_userlist(\core_privacy\local\request\approved_userlist $userlist) {
list($db, $table) = static::get_database_and_table();
if (!$db || !$table) {
return;
}
list($insql, $inparams) = $db->get_in_or_equal($userlist->get_userids(), SQL_PARAMS_NAMED);
$params = array_merge($inparams, ['contextid' => $userlist->get_context()->id]);
$db->delete_records_select($table, "contextid = :contextid AND userid $insql", $params);
} | php | public static function delete_data_for_userlist(\core_privacy\local\request\approved_userlist $userlist) {
list($db, $table) = static::get_database_and_table();
if (!$db || !$table) {
return;
}
list($insql, $inparams) = $db->get_in_or_equal($userlist->get_userids(), SQL_PARAMS_NAMED);
$params = array_merge($inparams, ['contextid' => $userlist->get_context()->id]);
$db->delete_records_select($table, "contextid = :contextid AND userid $insql", $params);
} | [
"public",
"static",
"function",
"delete_data_for_userlist",
"(",
"\\",
"core_privacy",
"\\",
"local",
"\\",
"request",
"\\",
"approved_userlist",
"$",
"userlist",
")",
"{",
"list",
"(",
"$",
"db",
",",
"$",
"table",
")",
"=",
"static",
"::",
"get_database_and_table",
"(",
")",
";",
"if",
"(",
"!",
"$",
"db",
"||",
"!",
"$",
"table",
")",
"{",
"return",
";",
"}",
"list",
"(",
"$",
"insql",
",",
"$",
"inparams",
")",
"=",
"$",
"db",
"->",
"get_in_or_equal",
"(",
"$",
"userlist",
"->",
"get_userids",
"(",
")",
",",
"SQL_PARAMS_NAMED",
")",
";",
"$",
"params",
"=",
"array_merge",
"(",
"$",
"inparams",
",",
"[",
"'contextid'",
"=>",
"$",
"userlist",
"->",
"get_context",
"(",
")",
"->",
"id",
"]",
")",
";",
"$",
"db",
"->",
"delete_records_select",
"(",
"$",
"table",
",",
"\"contextid = :contextid AND userid $insql\"",
",",
"$",
"params",
")",
";",
"}"
] | Delete all user data for the specified users, in the specified context.
@param \core_privacy\local\request\approved_userlist $contextlist The approved contexts and user information to delete information for. | [
"Delete",
"all",
"user",
"data",
"for",
"the",
"specified",
"users",
"in",
"the",
"specified",
"context",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/log/classes/local/privacy/moodle_database_export_and_delete.php#L128-L136 |
215,090 | moodle/moodle | admin/tool/xmldb/actions/create_xml_file/create_xml_file.class.php | create_xml_file.get_plugin_type | function get_plugin_type($dirpath) {
global $CFG;
$dirpath = $CFG->dirroot.$dirpath;
// Reverse order so that we get subplugin matches.
$plugintypes = array_reverse(core_component::get_plugin_types());
foreach ($plugintypes as $plugintype => $pluginbasedir) {
if (substr($dirpath, 0, strlen($pluginbasedir)) == $pluginbasedir) {
return $plugintype;
}
}
return null;
} | php | function get_plugin_type($dirpath) {
global $CFG;
$dirpath = $CFG->dirroot.$dirpath;
// Reverse order so that we get subplugin matches.
$plugintypes = array_reverse(core_component::get_plugin_types());
foreach ($plugintypes as $plugintype => $pluginbasedir) {
if (substr($dirpath, 0, strlen($pluginbasedir)) == $pluginbasedir) {
return $plugintype;
}
}
return null;
} | [
"function",
"get_plugin_type",
"(",
"$",
"dirpath",
")",
"{",
"global",
"$",
"CFG",
";",
"$",
"dirpath",
"=",
"$",
"CFG",
"->",
"dirroot",
".",
"$",
"dirpath",
";",
"// Reverse order so that we get subplugin matches.",
"$",
"plugintypes",
"=",
"array_reverse",
"(",
"core_component",
"::",
"get_plugin_types",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"plugintypes",
"as",
"$",
"plugintype",
"=>",
"$",
"pluginbasedir",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"dirpath",
",",
"0",
",",
"strlen",
"(",
"$",
"pluginbasedir",
")",
")",
"==",
"$",
"pluginbasedir",
")",
"{",
"return",
"$",
"plugintype",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | From a given path, work out what type of plugin
this belongs to
@param string $dirpath Path to the db file for this plugin
@return string the type of the plugin or null if not found | [
"From",
"a",
"given",
"path",
"work",
"out",
"what",
"type",
"of",
"plugin",
"this",
"belongs",
"to"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/xmldb/actions/create_xml_file/create_xml_file.class.php#L118-L129 |
215,091 | moodle/moodle | lib/ddl/database_manager.php | database_manager.dispose | public function dispose() {
if ($this->generator) {
$this->generator->dispose();
$this->generator = null;
}
$this->mdb = null;
} | php | public function dispose() {
if ($this->generator) {
$this->generator->dispose();
$this->generator = null;
}
$this->mdb = null;
} | [
"public",
"function",
"dispose",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"generator",
")",
"{",
"$",
"this",
"->",
"generator",
"->",
"dispose",
"(",
")",
";",
"$",
"this",
"->",
"generator",
"=",
"null",
";",
"}",
"$",
"this",
"->",
"mdb",
"=",
"null",
";",
"}"
] | Releases all resources | [
"Releases",
"all",
"resources"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ddl/database_manager.php#L61-L67 |
215,092 | moodle/moodle | lib/ddl/database_manager.php | database_manager.find_index_name | public function find_index_name(xmldb_table $xmldb_table, xmldb_index $xmldb_index, $returnall = false) {
// Calculate the name of the table
$tablename = $xmldb_table->getName();
// Check the table exists
if (!$this->table_exists($xmldb_table)) {
throw new ddl_table_missing_exception($tablename);
}
// Extract index columns
$indcolumns = $xmldb_index->getFields();
// Get list of indexes in table
$indexes = $this->mdb->get_indexes($tablename);
$return = array();
// Iterate over them looking for columns coincidence
foreach ($indexes as $indexname => $index) {
$columns = $index['columns'];
// Check if index matches queried index
$diferences = array_merge(array_diff($columns, $indcolumns), array_diff($indcolumns, $columns));
// If no differences, we have find the index
if (empty($diferences)) {
if ($returnall) {
$return[] = $indexname;
} else {
return $indexname;
}
}
}
if ($return and $returnall) {
return $return;
}
// Arriving here, index not found
return false;
} | php | public function find_index_name(xmldb_table $xmldb_table, xmldb_index $xmldb_index, $returnall = false) {
// Calculate the name of the table
$tablename = $xmldb_table->getName();
// Check the table exists
if (!$this->table_exists($xmldb_table)) {
throw new ddl_table_missing_exception($tablename);
}
// Extract index columns
$indcolumns = $xmldb_index->getFields();
// Get list of indexes in table
$indexes = $this->mdb->get_indexes($tablename);
$return = array();
// Iterate over them looking for columns coincidence
foreach ($indexes as $indexname => $index) {
$columns = $index['columns'];
// Check if index matches queried index
$diferences = array_merge(array_diff($columns, $indcolumns), array_diff($indcolumns, $columns));
// If no differences, we have find the index
if (empty($diferences)) {
if ($returnall) {
$return[] = $indexname;
} else {
return $indexname;
}
}
}
if ($return and $returnall) {
return $return;
}
// Arriving here, index not found
return false;
} | [
"public",
"function",
"find_index_name",
"(",
"xmldb_table",
"$",
"xmldb_table",
",",
"xmldb_index",
"$",
"xmldb_index",
",",
"$",
"returnall",
"=",
"false",
")",
"{",
"// Calculate the name of the table",
"$",
"tablename",
"=",
"$",
"xmldb_table",
"->",
"getName",
"(",
")",
";",
"// Check the table exists",
"if",
"(",
"!",
"$",
"this",
"->",
"table_exists",
"(",
"$",
"xmldb_table",
")",
")",
"{",
"throw",
"new",
"ddl_table_missing_exception",
"(",
"$",
"tablename",
")",
";",
"}",
"// Extract index columns",
"$",
"indcolumns",
"=",
"$",
"xmldb_index",
"->",
"getFields",
"(",
")",
";",
"// Get list of indexes in table",
"$",
"indexes",
"=",
"$",
"this",
"->",
"mdb",
"->",
"get_indexes",
"(",
"$",
"tablename",
")",
";",
"$",
"return",
"=",
"array",
"(",
")",
";",
"// Iterate over them looking for columns coincidence",
"foreach",
"(",
"$",
"indexes",
"as",
"$",
"indexname",
"=>",
"$",
"index",
")",
"{",
"$",
"columns",
"=",
"$",
"index",
"[",
"'columns'",
"]",
";",
"// Check if index matches queried index",
"$",
"diferences",
"=",
"array_merge",
"(",
"array_diff",
"(",
"$",
"columns",
",",
"$",
"indcolumns",
")",
",",
"array_diff",
"(",
"$",
"indcolumns",
",",
"$",
"columns",
")",
")",
";",
"// If no differences, we have find the index",
"if",
"(",
"empty",
"(",
"$",
"diferences",
")",
")",
"{",
"if",
"(",
"$",
"returnall",
")",
"{",
"$",
"return",
"[",
"]",
"=",
"$",
"indexname",
";",
"}",
"else",
"{",
"return",
"$",
"indexname",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"return",
"and",
"$",
"returnall",
")",
"{",
"return",
"$",
"return",
";",
"}",
"// Arriving here, index not found",
"return",
"false",
";",
"}"
] | Given one xmldb_index, the function returns the name of the index in DB
of false if it doesn't exist
@param xmldb_table $xmldb_table table to be searched
@param xmldb_index $xmldb_index the index to be searched
@param bool $returnall true means return array of all indexes, false means first index only as string
@return array|string|bool Index name, array of index names or false if no indexes are found.
@throws ddl_table_missing_exception Thrown when table is not found. | [
"Given",
"one",
"xmldb_index",
"the",
"function",
"returns",
"the",
"name",
"of",
"the",
"index",
"in",
"DB",
"of",
"false",
"if",
"it",
"doesn",
"t",
"exist"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ddl/database_manager.php#L174-L212 |
215,093 | moodle/moodle | lib/ddl/database_manager.php | database_manager.delete_tables_from_xmldb_file | public function delete_tables_from_xmldb_file($file) {
$xmldb_file = new xmldb_file($file);
if (!$xmldb_file->fileExists()) {
throw new ddl_exception('ddlxmlfileerror', null, 'File does not exist');
}
$loaded = $xmldb_file->loadXMLStructure();
$structure = $xmldb_file->getStructure();
if (!$loaded || !$xmldb_file->isLoaded()) {
// Show info about the error if we can find it
if ($structure) {
if ($errors = $structure->getAllErrors()) {
throw new ddl_exception('ddlxmlfileerror', null, 'Errors found in XMLDB file: '. implode (', ', $errors));
}
}
throw new ddl_exception('ddlxmlfileerror', null, 'not loaded??');
}
if ($xmldb_tables = $structure->getTables()) {
// Delete in opposite order, this should help with foreign keys in the future.
$xmldb_tables = array_reverse($xmldb_tables);
foreach($xmldb_tables as $table) {
if ($this->table_exists($table)) {
$this->drop_table($table);
}
}
}
} | php | public function delete_tables_from_xmldb_file($file) {
$xmldb_file = new xmldb_file($file);
if (!$xmldb_file->fileExists()) {
throw new ddl_exception('ddlxmlfileerror', null, 'File does not exist');
}
$loaded = $xmldb_file->loadXMLStructure();
$structure = $xmldb_file->getStructure();
if (!$loaded || !$xmldb_file->isLoaded()) {
// Show info about the error if we can find it
if ($structure) {
if ($errors = $structure->getAllErrors()) {
throw new ddl_exception('ddlxmlfileerror', null, 'Errors found in XMLDB file: '. implode (', ', $errors));
}
}
throw new ddl_exception('ddlxmlfileerror', null, 'not loaded??');
}
if ($xmldb_tables = $structure->getTables()) {
// Delete in opposite order, this should help with foreign keys in the future.
$xmldb_tables = array_reverse($xmldb_tables);
foreach($xmldb_tables as $table) {
if ($this->table_exists($table)) {
$this->drop_table($table);
}
}
}
} | [
"public",
"function",
"delete_tables_from_xmldb_file",
"(",
"$",
"file",
")",
"{",
"$",
"xmldb_file",
"=",
"new",
"xmldb_file",
"(",
"$",
"file",
")",
";",
"if",
"(",
"!",
"$",
"xmldb_file",
"->",
"fileExists",
"(",
")",
")",
"{",
"throw",
"new",
"ddl_exception",
"(",
"'ddlxmlfileerror'",
",",
"null",
",",
"'File does not exist'",
")",
";",
"}",
"$",
"loaded",
"=",
"$",
"xmldb_file",
"->",
"loadXMLStructure",
"(",
")",
";",
"$",
"structure",
"=",
"$",
"xmldb_file",
"->",
"getStructure",
"(",
")",
";",
"if",
"(",
"!",
"$",
"loaded",
"||",
"!",
"$",
"xmldb_file",
"->",
"isLoaded",
"(",
")",
")",
"{",
"// Show info about the error if we can find it",
"if",
"(",
"$",
"structure",
")",
"{",
"if",
"(",
"$",
"errors",
"=",
"$",
"structure",
"->",
"getAllErrors",
"(",
")",
")",
"{",
"throw",
"new",
"ddl_exception",
"(",
"'ddlxmlfileerror'",
",",
"null",
",",
"'Errors found in XMLDB file: '",
".",
"implode",
"(",
"', '",
",",
"$",
"errors",
")",
")",
";",
"}",
"}",
"throw",
"new",
"ddl_exception",
"(",
"'ddlxmlfileerror'",
",",
"null",
",",
"'not loaded??'",
")",
";",
"}",
"if",
"(",
"$",
"xmldb_tables",
"=",
"$",
"structure",
"->",
"getTables",
"(",
")",
")",
"{",
"// Delete in opposite order, this should help with foreign keys in the future.",
"$",
"xmldb_tables",
"=",
"array_reverse",
"(",
"$",
"xmldb_tables",
")",
";",
"foreach",
"(",
"$",
"xmldb_tables",
"as",
"$",
"table",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"table_exists",
"(",
"$",
"table",
")",
")",
"{",
"$",
"this",
"->",
"drop_table",
"(",
"$",
"table",
")",
";",
"}",
"}",
"}",
"}"
] | This function will delete all tables found in XMLDB file from db
@param string $file Full path to the XML file to be used.
@return void | [
"This",
"function",
"will",
"delete",
"all",
"tables",
"found",
"in",
"XMLDB",
"file",
"from",
"db"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ddl/database_manager.php#L283-L313 |
215,094 | moodle/moodle | lib/ddl/database_manager.php | database_manager.load_xmldb_file | private function load_xmldb_file($file) {
$xmldb_file = new xmldb_file($file);
if (!$xmldb_file->fileExists()) {
throw new ddl_exception('ddlxmlfileerror', null, 'File does not exist');
}
$loaded = $xmldb_file->loadXMLStructure();
if (!$loaded || !$xmldb_file->isLoaded()) {
// Show info about the error if we can find it
if ($structure = $xmldb_file->getStructure()) {
if ($errors = $structure->getAllErrors()) {
throw new ddl_exception('ddlxmlfileerror', null, 'Errors found in XMLDB file: '. implode (', ', $errors));
}
}
throw new ddl_exception('ddlxmlfileerror', null, 'not loaded??');
}
return $xmldb_file;
} | php | private function load_xmldb_file($file) {
$xmldb_file = new xmldb_file($file);
if (!$xmldb_file->fileExists()) {
throw new ddl_exception('ddlxmlfileerror', null, 'File does not exist');
}
$loaded = $xmldb_file->loadXMLStructure();
if (!$loaded || !$xmldb_file->isLoaded()) {
// Show info about the error if we can find it
if ($structure = $xmldb_file->getStructure()) {
if ($errors = $structure->getAllErrors()) {
throw new ddl_exception('ddlxmlfileerror', null, 'Errors found in XMLDB file: '. implode (', ', $errors));
}
}
throw new ddl_exception('ddlxmlfileerror', null, 'not loaded??');
}
return $xmldb_file;
} | [
"private",
"function",
"load_xmldb_file",
"(",
"$",
"file",
")",
"{",
"$",
"xmldb_file",
"=",
"new",
"xmldb_file",
"(",
"$",
"file",
")",
";",
"if",
"(",
"!",
"$",
"xmldb_file",
"->",
"fileExists",
"(",
")",
")",
"{",
"throw",
"new",
"ddl_exception",
"(",
"'ddlxmlfileerror'",
",",
"null",
",",
"'File does not exist'",
")",
";",
"}",
"$",
"loaded",
"=",
"$",
"xmldb_file",
"->",
"loadXMLStructure",
"(",
")",
";",
"if",
"(",
"!",
"$",
"loaded",
"||",
"!",
"$",
"xmldb_file",
"->",
"isLoaded",
"(",
")",
")",
"{",
"// Show info about the error if we can find it",
"if",
"(",
"$",
"structure",
"=",
"$",
"xmldb_file",
"->",
"getStructure",
"(",
")",
")",
"{",
"if",
"(",
"$",
"errors",
"=",
"$",
"structure",
"->",
"getAllErrors",
"(",
")",
")",
"{",
"throw",
"new",
"ddl_exception",
"(",
"'ddlxmlfileerror'",
",",
"null",
",",
"'Errors found in XMLDB file: '",
".",
"implode",
"(",
"', '",
",",
"$",
"errors",
")",
")",
";",
"}",
"}",
"throw",
"new",
"ddl_exception",
"(",
"'ddlxmlfileerror'",
",",
"null",
",",
"'not loaded??'",
")",
";",
"}",
"return",
"$",
"xmldb_file",
";",
"}"
] | Load an install.xml file, checking that it exists, and that the structure is OK.
@param string $file the full path to the XMLDB file.
@return xmldb_file the loaded file. | [
"Load",
"an",
"install",
".",
"xml",
"file",
"checking",
"that",
"it",
"exists",
"and",
"that",
"the",
"structure",
"is",
"OK",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ddl/database_manager.php#L340-L359 |
215,095 | moodle/moodle | lib/ddl/database_manager.php | database_manager.install_from_xmldb_structure | public function install_from_xmldb_structure($xmldb_structure) {
if (!$sqlarr = $this->generator->getCreateStructureSQL($xmldb_structure)) {
return; // nothing to do
}
$tablenames = array();
foreach ($xmldb_structure as $xmldb_table) {
if ($xmldb_table instanceof xmldb_table) {
$tablenames[] = $xmldb_table->getName();
}
}
$this->execute_sql_arr($sqlarr, $tablenames);
} | php | public function install_from_xmldb_structure($xmldb_structure) {
if (!$sqlarr = $this->generator->getCreateStructureSQL($xmldb_structure)) {
return; // nothing to do
}
$tablenames = array();
foreach ($xmldb_structure as $xmldb_table) {
if ($xmldb_table instanceof xmldb_table) {
$tablenames[] = $xmldb_table->getName();
}
}
$this->execute_sql_arr($sqlarr, $tablenames);
} | [
"public",
"function",
"install_from_xmldb_structure",
"(",
"$",
"xmldb_structure",
")",
"{",
"if",
"(",
"!",
"$",
"sqlarr",
"=",
"$",
"this",
"->",
"generator",
"->",
"getCreateStructureSQL",
"(",
"$",
"xmldb_structure",
")",
")",
"{",
"return",
";",
"// nothing to do",
"}",
"$",
"tablenames",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"xmldb_structure",
"as",
"$",
"xmldb_table",
")",
"{",
"if",
"(",
"$",
"xmldb_table",
"instanceof",
"xmldb_table",
")",
"{",
"$",
"tablenames",
"[",
"]",
"=",
"$",
"xmldb_table",
"->",
"getName",
"(",
")",
";",
"}",
"}",
"$",
"this",
"->",
"execute_sql_arr",
"(",
"$",
"sqlarr",
",",
"$",
"tablenames",
")",
";",
"}"
] | This function will generate all the needed SQL statements, specific for each
RDBMS type and, finally, it will execute all those statements against the DB.
@param stdClass $xmldb_structure xmldb_structure object.
@return void | [
"This",
"function",
"will",
"generate",
"all",
"the",
"needed",
"SQL",
"statements",
"specific",
"for",
"each",
"RDBMS",
"type",
"and",
"finally",
"it",
"will",
"execute",
"all",
"those",
"statements",
"against",
"the",
"DB",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ddl/database_manager.php#L413-L426 |
215,096 | moodle/moodle | lib/ddl/database_manager.php | database_manager.rename_table | public function rename_table(xmldb_table $xmldb_table, $newname) {
// Check newname isn't empty
if (!$newname) {
throw new ddl_exception('ddlunknownerror', null, 'newname can not be empty');
}
$check = new xmldb_table($newname);
// Check table already renamed
if (!$this->table_exists($xmldb_table)) {
if ($this->table_exists($check)) {
throw new ddl_exception('ddlunknownerror', null, 'table probably already renamed');
} else {
throw new ddl_table_missing_exception($xmldb_table->getName());
}
}
// Check new table doesn't exist
if ($this->table_exists($check)) {
throw new ddl_exception('ddltablealreadyexists', $check->getName(), 'can not rename table');
}
if (!$sqlarr = $this->generator->getRenameTableSQL($xmldb_table, $newname)) {
throw new ddl_exception('ddlunknownerror', null, 'table rename sql not generated');
}
$this->execute_sql_arr($sqlarr);
} | php | public function rename_table(xmldb_table $xmldb_table, $newname) {
// Check newname isn't empty
if (!$newname) {
throw new ddl_exception('ddlunknownerror', null, 'newname can not be empty');
}
$check = new xmldb_table($newname);
// Check table already renamed
if (!$this->table_exists($xmldb_table)) {
if ($this->table_exists($check)) {
throw new ddl_exception('ddlunknownerror', null, 'table probably already renamed');
} else {
throw new ddl_table_missing_exception($xmldb_table->getName());
}
}
// Check new table doesn't exist
if ($this->table_exists($check)) {
throw new ddl_exception('ddltablealreadyexists', $check->getName(), 'can not rename table');
}
if (!$sqlarr = $this->generator->getRenameTableSQL($xmldb_table, $newname)) {
throw new ddl_exception('ddlunknownerror', null, 'table rename sql not generated');
}
$this->execute_sql_arr($sqlarr);
} | [
"public",
"function",
"rename_table",
"(",
"xmldb_table",
"$",
"xmldb_table",
",",
"$",
"newname",
")",
"{",
"// Check newname isn't empty",
"if",
"(",
"!",
"$",
"newname",
")",
"{",
"throw",
"new",
"ddl_exception",
"(",
"'ddlunknownerror'",
",",
"null",
",",
"'newname can not be empty'",
")",
";",
"}",
"$",
"check",
"=",
"new",
"xmldb_table",
"(",
"$",
"newname",
")",
";",
"// Check table already renamed",
"if",
"(",
"!",
"$",
"this",
"->",
"table_exists",
"(",
"$",
"xmldb_table",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"table_exists",
"(",
"$",
"check",
")",
")",
"{",
"throw",
"new",
"ddl_exception",
"(",
"'ddlunknownerror'",
",",
"null",
",",
"'table probably already renamed'",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"ddl_table_missing_exception",
"(",
"$",
"xmldb_table",
"->",
"getName",
"(",
")",
")",
";",
"}",
"}",
"// Check new table doesn't exist",
"if",
"(",
"$",
"this",
"->",
"table_exists",
"(",
"$",
"check",
")",
")",
"{",
"throw",
"new",
"ddl_exception",
"(",
"'ddltablealreadyexists'",
",",
"$",
"check",
"->",
"getName",
"(",
")",
",",
"'can not rename table'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"sqlarr",
"=",
"$",
"this",
"->",
"generator",
"->",
"getRenameTableSQL",
"(",
"$",
"xmldb_table",
",",
"$",
"newname",
")",
")",
"{",
"throw",
"new",
"ddl_exception",
"(",
"'ddlunknownerror'",
",",
"null",
",",
"'table rename sql not generated'",
")",
";",
"}",
"$",
"this",
"->",
"execute_sql_arr",
"(",
"$",
"sqlarr",
")",
";",
"}"
] | This function will rename the table passed as argument
Before renaming the index, the function will check it exists
@param xmldb_table $xmldb_table Table object (just the name is mandatory).
@param string $newname New name of the index.
@return void | [
"This",
"function",
"will",
"rename",
"the",
"table",
"passed",
"as",
"argument",
"Before",
"renaming",
"the",
"index",
"the",
"function",
"will",
"check",
"it",
"exists"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ddl/database_manager.php#L493-L520 |
215,097 | moodle/moodle | lib/ddl/database_manager.php | database_manager.add_field | public function add_field(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
// Check the field doesn't exist
if ($this->field_exists($xmldb_table, $xmldb_field)) {
throw new ddl_exception('ddlfieldalreadyexists', $xmldb_field->getName());
}
// If NOT NULL and no default given (we ask the generator about the
// *real* default that will be used) check the table is empty
if ($xmldb_field->getNotNull() && $this->generator->getDefaultValue($xmldb_field) === NULL && $this->mdb->count_records($xmldb_table->getName())) {
throw new ddl_exception('ddlunknownerror', null, 'Field ' . $xmldb_table->getName() . '->' . $xmldb_field->getName() .
' cannot be added. Not null fields added to non empty tables require default value. Create skipped');
}
if (!$sqlarr = $this->generator->getAddFieldSQL($xmldb_table, $xmldb_field)) {
throw new ddl_exception('ddlunknownerror', null, 'addfield sql not generated');
}
$this->execute_sql_arr($sqlarr, array($xmldb_table->getName()));
} | php | public function add_field(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
// Check the field doesn't exist
if ($this->field_exists($xmldb_table, $xmldb_field)) {
throw new ddl_exception('ddlfieldalreadyexists', $xmldb_field->getName());
}
// If NOT NULL and no default given (we ask the generator about the
// *real* default that will be used) check the table is empty
if ($xmldb_field->getNotNull() && $this->generator->getDefaultValue($xmldb_field) === NULL && $this->mdb->count_records($xmldb_table->getName())) {
throw new ddl_exception('ddlunknownerror', null, 'Field ' . $xmldb_table->getName() . '->' . $xmldb_field->getName() .
' cannot be added. Not null fields added to non empty tables require default value. Create skipped');
}
if (!$sqlarr = $this->generator->getAddFieldSQL($xmldb_table, $xmldb_field)) {
throw new ddl_exception('ddlunknownerror', null, 'addfield sql not generated');
}
$this->execute_sql_arr($sqlarr, array($xmldb_table->getName()));
} | [
"public",
"function",
"add_field",
"(",
"xmldb_table",
"$",
"xmldb_table",
",",
"xmldb_field",
"$",
"xmldb_field",
")",
"{",
"// Check the field doesn't exist",
"if",
"(",
"$",
"this",
"->",
"field_exists",
"(",
"$",
"xmldb_table",
",",
"$",
"xmldb_field",
")",
")",
"{",
"throw",
"new",
"ddl_exception",
"(",
"'ddlfieldalreadyexists'",
",",
"$",
"xmldb_field",
"->",
"getName",
"(",
")",
")",
";",
"}",
"// If NOT NULL and no default given (we ask the generator about the",
"// *real* default that will be used) check the table is empty",
"if",
"(",
"$",
"xmldb_field",
"->",
"getNotNull",
"(",
")",
"&&",
"$",
"this",
"->",
"generator",
"->",
"getDefaultValue",
"(",
"$",
"xmldb_field",
")",
"===",
"NULL",
"&&",
"$",
"this",
"->",
"mdb",
"->",
"count_records",
"(",
"$",
"xmldb_table",
"->",
"getName",
"(",
")",
")",
")",
"{",
"throw",
"new",
"ddl_exception",
"(",
"'ddlunknownerror'",
",",
"null",
",",
"'Field '",
".",
"$",
"xmldb_table",
"->",
"getName",
"(",
")",
".",
"'->'",
".",
"$",
"xmldb_field",
"->",
"getName",
"(",
")",
".",
"' cannot be added. Not null fields added to non empty tables require default value. Create skipped'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"sqlarr",
"=",
"$",
"this",
"->",
"generator",
"->",
"getAddFieldSQL",
"(",
"$",
"xmldb_table",
",",
"$",
"xmldb_field",
")",
")",
"{",
"throw",
"new",
"ddl_exception",
"(",
"'ddlunknownerror'",
",",
"null",
",",
"'addfield sql not generated'",
")",
";",
"}",
"$",
"this",
"->",
"execute_sql_arr",
"(",
"$",
"sqlarr",
",",
"array",
"(",
"$",
"xmldb_table",
"->",
"getName",
"(",
")",
")",
")",
";",
"}"
] | This function will add the field to the table passed as arguments
@param xmldb_table $xmldb_table Table object (just the name is mandatory).
@param xmldb_field $xmldb_field Index object (full specs are required).
@return void | [
"This",
"function",
"will",
"add",
"the",
"field",
"to",
"the",
"table",
"passed",
"as",
"arguments"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ddl/database_manager.php#L529-L546 |
215,098 | moodle/moodle | lib/ddl/database_manager.php | database_manager.drop_field | public function drop_field(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
if (!$this->table_exists($xmldb_table)) {
throw new ddl_table_missing_exception($xmldb_table->getName());
}
// Check the field exists
if (!$this->field_exists($xmldb_table, $xmldb_field)) {
throw new ddl_field_missing_exception($xmldb_field->getName(), $xmldb_table->getName());
}
// Check for dependencies in the DB before performing any action
$this->check_field_dependencies($xmldb_table, $xmldb_field);
if (!$sqlarr = $this->generator->getDropFieldSQL($xmldb_table, $xmldb_field)) {
throw new ddl_exception('ddlunknownerror', null, 'drop_field sql not generated');
}
$this->execute_sql_arr($sqlarr, array($xmldb_table->getName()));
} | php | public function drop_field(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
if (!$this->table_exists($xmldb_table)) {
throw new ddl_table_missing_exception($xmldb_table->getName());
}
// Check the field exists
if (!$this->field_exists($xmldb_table, $xmldb_field)) {
throw new ddl_field_missing_exception($xmldb_field->getName(), $xmldb_table->getName());
}
// Check for dependencies in the DB before performing any action
$this->check_field_dependencies($xmldb_table, $xmldb_field);
if (!$sqlarr = $this->generator->getDropFieldSQL($xmldb_table, $xmldb_field)) {
throw new ddl_exception('ddlunknownerror', null, 'drop_field sql not generated');
}
$this->execute_sql_arr($sqlarr, array($xmldb_table->getName()));
} | [
"public",
"function",
"drop_field",
"(",
"xmldb_table",
"$",
"xmldb_table",
",",
"xmldb_field",
"$",
"xmldb_field",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"table_exists",
"(",
"$",
"xmldb_table",
")",
")",
"{",
"throw",
"new",
"ddl_table_missing_exception",
"(",
"$",
"xmldb_table",
"->",
"getName",
"(",
")",
")",
";",
"}",
"// Check the field exists",
"if",
"(",
"!",
"$",
"this",
"->",
"field_exists",
"(",
"$",
"xmldb_table",
",",
"$",
"xmldb_field",
")",
")",
"{",
"throw",
"new",
"ddl_field_missing_exception",
"(",
"$",
"xmldb_field",
"->",
"getName",
"(",
")",
",",
"$",
"xmldb_table",
"->",
"getName",
"(",
")",
")",
";",
"}",
"// Check for dependencies in the DB before performing any action",
"$",
"this",
"->",
"check_field_dependencies",
"(",
"$",
"xmldb_table",
",",
"$",
"xmldb_field",
")",
";",
"if",
"(",
"!",
"$",
"sqlarr",
"=",
"$",
"this",
"->",
"generator",
"->",
"getDropFieldSQL",
"(",
"$",
"xmldb_table",
",",
"$",
"xmldb_field",
")",
")",
"{",
"throw",
"new",
"ddl_exception",
"(",
"'ddlunknownerror'",
",",
"null",
",",
"'drop_field sql not generated'",
")",
";",
"}",
"$",
"this",
"->",
"execute_sql_arr",
"(",
"$",
"sqlarr",
",",
"array",
"(",
"$",
"xmldb_table",
"->",
"getName",
"(",
")",
")",
")",
";",
"}"
] | This function will drop the field from the table passed as arguments
@param xmldb_table $xmldb_table Table object (just the name is mandatory).
@param xmldb_field $xmldb_field Index object (full specs are required).
@return void | [
"This",
"function",
"will",
"drop",
"the",
"field",
"from",
"the",
"table",
"passed",
"as",
"arguments"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ddl/database_manager.php#L555-L571 |
215,099 | moodle/moodle | lib/ddl/database_manager.php | database_manager.change_field_type | public function change_field_type(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
if (!$this->table_exists($xmldb_table)) {
throw new ddl_table_missing_exception($xmldb_table->getName());
}
// Check the field exists
if (!$this->field_exists($xmldb_table, $xmldb_field)) {
throw new ddl_field_missing_exception($xmldb_field->getName(), $xmldb_table->getName());
}
// Check for dependencies in the DB before performing any action
$this->check_field_dependencies($xmldb_table, $xmldb_field);
if (!$sqlarr = $this->generator->getAlterFieldSQL($xmldb_table, $xmldb_field)) {
return; // probably nothing to do
}
$this->execute_sql_arr($sqlarr, array($xmldb_table->getName()));
} | php | public function change_field_type(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
if (!$this->table_exists($xmldb_table)) {
throw new ddl_table_missing_exception($xmldb_table->getName());
}
// Check the field exists
if (!$this->field_exists($xmldb_table, $xmldb_field)) {
throw new ddl_field_missing_exception($xmldb_field->getName(), $xmldb_table->getName());
}
// Check for dependencies in the DB before performing any action
$this->check_field_dependencies($xmldb_table, $xmldb_field);
if (!$sqlarr = $this->generator->getAlterFieldSQL($xmldb_table, $xmldb_field)) {
return; // probably nothing to do
}
$this->execute_sql_arr($sqlarr, array($xmldb_table->getName()));
} | [
"public",
"function",
"change_field_type",
"(",
"xmldb_table",
"$",
"xmldb_table",
",",
"xmldb_field",
"$",
"xmldb_field",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"table_exists",
"(",
"$",
"xmldb_table",
")",
")",
"{",
"throw",
"new",
"ddl_table_missing_exception",
"(",
"$",
"xmldb_table",
"->",
"getName",
"(",
")",
")",
";",
"}",
"// Check the field exists",
"if",
"(",
"!",
"$",
"this",
"->",
"field_exists",
"(",
"$",
"xmldb_table",
",",
"$",
"xmldb_field",
")",
")",
"{",
"throw",
"new",
"ddl_field_missing_exception",
"(",
"$",
"xmldb_field",
"->",
"getName",
"(",
")",
",",
"$",
"xmldb_table",
"->",
"getName",
"(",
")",
")",
";",
"}",
"// Check for dependencies in the DB before performing any action",
"$",
"this",
"->",
"check_field_dependencies",
"(",
"$",
"xmldb_table",
",",
"$",
"xmldb_field",
")",
";",
"if",
"(",
"!",
"$",
"sqlarr",
"=",
"$",
"this",
"->",
"generator",
"->",
"getAlterFieldSQL",
"(",
"$",
"xmldb_table",
",",
"$",
"xmldb_field",
")",
")",
"{",
"return",
";",
"// probably nothing to do",
"}",
"$",
"this",
"->",
"execute_sql_arr",
"(",
"$",
"sqlarr",
",",
"array",
"(",
"$",
"xmldb_table",
"->",
"getName",
"(",
")",
")",
")",
";",
"}"
] | This function will change the type of the field in the table passed as arguments
@param xmldb_table $xmldb_table Table object (just the name is mandatory).
@param xmldb_field $xmldb_field Index object (full specs are required).
@return void | [
"This",
"function",
"will",
"change",
"the",
"type",
"of",
"the",
"field",
"in",
"the",
"table",
"passed",
"as",
"arguments"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ddl/database_manager.php#L580-L596 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.