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
214,900
moodle/moodle
lib/horde/framework/Horde/Secret.php
Horde_Secret.clearKey
public function clearKey($keyname = self::DEFAULT_KEY) { if (isset($_COOKIE[$this->_params['session_name']]) && isset($_COOKIE[$keyname . '_key'])) { $this->_setCookie($keyname, false); return true; } return false; }
php
public function clearKey($keyname = self::DEFAULT_KEY) { if (isset($_COOKIE[$this->_params['session_name']]) && isset($_COOKIE[$keyname . '_key'])) { $this->_setCookie($keyname, false); return true; } return false; }
[ "public", "function", "clearKey", "(", "$", "keyname", "=", "self", "::", "DEFAULT_KEY", ")", "{", "if", "(", "isset", "(", "$", "_COOKIE", "[", "$", "this", "->", "_params", "[", "'session_name'", "]", "]", ")", "&&", "isset", "(", "$", "_COOKIE", "[", "$", "keyname", ".", "'_key'", "]", ")", ")", "{", "$", "this", "->", "_setCookie", "(", "$", "keyname", ",", "false", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Clears a secret key entry from the current cookie. @param string $keyname The name of the key to clear. @return boolean True if key existed, false if not.
[ "Clears", "a", "secret", "key", "entry", "from", "the", "current", "cookie", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Secret.php#L188-L197
214,901
moodle/moodle
comment/classes/privacy/provider.php
provider.delete_comments_for_users
public static function delete_comments_for_users(\core_privacy\local\request\approved_userlist $userlist, string $component, string $commentarea = null, int $itemid = null) { global $DB; $context = $userlist->get_context(); $params = [ 'contextid' => $context->id, 'component' => $component, ]; $areasql = ''; if (isset($commentarea)) { $params['commentarea'] = $commentarea; $areasql = 'AND commentarea = :commentarea'; } $itemsql = ''; if (isset($itemid)) { $params['itemid'] = $itemid; $itemsql = 'AND itemid = :itemid'; } list($insql, $inparams) = $DB->get_in_or_equal($userlist->get_userids(), SQL_PARAMS_NAMED); $params += $inparams; $select = "contextid = :contextid AND component = :component {$areasql} {$itemsql} AND userid {$insql}"; $DB->delete_records_select('comments', $select, $params); }
php
public static function delete_comments_for_users(\core_privacy\local\request\approved_userlist $userlist, string $component, string $commentarea = null, int $itemid = null) { global $DB; $context = $userlist->get_context(); $params = [ 'contextid' => $context->id, 'component' => $component, ]; $areasql = ''; if (isset($commentarea)) { $params['commentarea'] = $commentarea; $areasql = 'AND commentarea = :commentarea'; } $itemsql = ''; if (isset($itemid)) { $params['itemid'] = $itemid; $itemsql = 'AND itemid = :itemid'; } list($insql, $inparams) = $DB->get_in_or_equal($userlist->get_userids(), SQL_PARAMS_NAMED); $params += $inparams; $select = "contextid = :contextid AND component = :component {$areasql} {$itemsql} AND userid {$insql}"; $DB->delete_records_select('comments', $select, $params); }
[ "public", "static", "function", "delete_comments_for_users", "(", "\\", "core_privacy", "\\", "local", "\\", "request", "\\", "approved_userlist", "$", "userlist", ",", "string", "$", "component", ",", "string", "$", "commentarea", "=", "null", ",", "int", "$", "itemid", "=", "null", ")", "{", "global", "$", "DB", ";", "$", "context", "=", "$", "userlist", "->", "get_context", "(", ")", ";", "$", "params", "=", "[", "'contextid'", "=>", "$", "context", "->", "id", ",", "'component'", "=>", "$", "component", ",", "]", ";", "$", "areasql", "=", "''", ";", "if", "(", "isset", "(", "$", "commentarea", ")", ")", "{", "$", "params", "[", "'commentarea'", "]", "=", "$", "commentarea", ";", "$", "areasql", "=", "'AND commentarea = :commentarea'", ";", "}", "$", "itemsql", "=", "''", ";", "if", "(", "isset", "(", "$", "itemid", ")", ")", "{", "$", "params", "[", "'itemid'", "]", "=", "$", "itemid", ";", "$", "itemsql", "=", "'AND itemid = :itemid'", ";", "}", "list", "(", "$", "insql", ",", "$", "inparams", ")", "=", "$", "DB", "->", "get_in_or_equal", "(", "$", "userlist", "->", "get_userids", "(", ")", ",", "SQL_PARAMS_NAMED", ")", ";", "$", "params", "+=", "$", "inparams", ";", "$", "select", "=", "\"contextid = :contextid AND component = :component {$areasql} {$itemsql} AND userid {$insql}\"", ";", "$", "DB", "->", "delete_records_select", "(", "'comments'", ",", "$", "select", ",", "$", "params", ")", ";", "}" ]
Deletes all records for a context from a list of approved users. @param \core_privacy\local\request\approved_userlist $userlist Contains the list of users and a context to be deleted from. @param string $component Component to delete from. @param string $commentarea Area to delete from. @param int $itemid The item id to delete from.
[ "Deletes", "all", "records", "for", "a", "context", "from", "a", "list", "of", "approved", "users", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/comment/classes/privacy/provider.php#L209-L233
214,902
moodle/moodle
comment/classes/privacy/provider.php
provider.get_users_in_context_from_sql
public static function get_users_in_context_from_sql( userlist $userlist, string $alias, string $component, string $area, int $contextid = null, string $insql = '', array $params = []) { if ($insql != '') { $insql = "AND {$alias}.itemid {$insql}"; } $contextsql = ''; if (isset($contextid)) { $contextsql = "AND {$alias}.contextid = :{$alias}contextid"; $params["{$alias}contextid"] = $contextid; } // Comment authors. $sql = "SELECT {$alias}.userid FROM {comments} {$alias} WHERE {$alias}.component = :{$alias}component AND {$alias}.commentarea = :{$alias}commentarea $contextsql $insql"; $params["{$alias}component"] = $component; $params["{$alias}commentarea"] = $area; $userlist->add_from_sql('userid', $sql, $params); }
php
public static function get_users_in_context_from_sql( userlist $userlist, string $alias, string $component, string $area, int $contextid = null, string $insql = '', array $params = []) { if ($insql != '') { $insql = "AND {$alias}.itemid {$insql}"; } $contextsql = ''; if (isset($contextid)) { $contextsql = "AND {$alias}.contextid = :{$alias}contextid"; $params["{$alias}contextid"] = $contextid; } // Comment authors. $sql = "SELECT {$alias}.userid FROM {comments} {$alias} WHERE {$alias}.component = :{$alias}component AND {$alias}.commentarea = :{$alias}commentarea $contextsql $insql"; $params["{$alias}component"] = $component; $params["{$alias}commentarea"] = $area; $userlist->add_from_sql('userid', $sql, $params); }
[ "public", "static", "function", "get_users_in_context_from_sql", "(", "userlist", "$", "userlist", ",", "string", "$", "alias", ",", "string", "$", "component", ",", "string", "$", "area", ",", "int", "$", "contextid", "=", "null", ",", "string", "$", "insql", "=", "''", ",", "array", "$", "params", "=", "[", "]", ")", "{", "if", "(", "$", "insql", "!=", "''", ")", "{", "$", "insql", "=", "\"AND {$alias}.itemid {$insql}\"", ";", "}", "$", "contextsql", "=", "''", ";", "if", "(", "isset", "(", "$", "contextid", ")", ")", "{", "$", "contextsql", "=", "\"AND {$alias}.contextid = :{$alias}contextid\"", ";", "$", "params", "[", "\"{$alias}contextid\"", "]", "=", "$", "contextid", ";", "}", "// Comment authors.", "$", "sql", "=", "\"SELECT {$alias}.userid\n FROM {comments} {$alias}\n WHERE {$alias}.component = :{$alias}component\n AND {$alias}.commentarea = :{$alias}commentarea\n $contextsql $insql\"", ";", "$", "params", "[", "\"{$alias}component\"", "]", "=", "$", "component", ";", "$", "params", "[", "\"{$alias}commentarea\"", "]", "=", "$", "area", ";", "$", "userlist", "->", "add_from_sql", "(", "'userid'", ",", "$", "sql", ",", "$", "params", ")", ";", "}" ]
Add the list of users who have commented in the specified constraints. @param userlist $userlist The userlist to add the users to. @param string $alias An alias prefix to use for comment selects to avoid interference with your own sql. @param string $component The component to check. @param string $area The comment area to check. @param int $contextid The context id. @param string $insql The SQL to use in a sub-select for the itemid query. @param array $params The params required for the insql.
[ "Add", "the", "list", "of", "users", "who", "have", "commented", "in", "the", "specified", "constraints", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/comment/classes/privacy/provider.php#L246-L270
214,903
moodle/moodle
report/insights/classes/output/insight.php
insight.get_calculation_display
public static function get_calculation_display(\core_analytics\calculable $calculable, $value, $output, $subtype = false) { $outcome = $calculable->get_calculation_outcome($value, $subtype); switch ($outcome) { case \core_analytics\calculable::OUTCOME_NEUTRAL: $style = ''; $text = get_string('outcomeneutral', 'report_insights'); $icon = 't/check'; break; case \core_analytics\calculable::OUTCOME_VERY_POSITIVE: $style = 'success'; $text = get_string('outcomeverypositive', 'report_insights'); $icon = 't/approve'; break; case \core_analytics\calculable::OUTCOME_OK: $style = 'info'; $text = get_string('outcomeok', 'report_insights'); $icon = 't/check'; break; case \core_analytics\calculable::OUTCOME_NEGATIVE: $style = 'warning'; $text = get_string('outcomenegative', 'report_insights'); $icon = 'i/warning'; break; case \core_analytics\calculable::OUTCOME_VERY_NEGATIVE: $style = 'danger'; $text = get_string('outcomeverynegative', 'report_insights'); $icon = 'i/warning'; break; default: throw new \coding_exception('The outcome returned by ' . get_class($calculable) . '::get_calculation_outcome is ' . 'not one of the accepted values. Please use \core_analytics\calculable::OUTCOME_VERY_POSITIVE, ' . '\core_analytics\calculable::OUTCOME_OK, \core_analytics\calculable::OUTCOME_NEGATIVE, ' . '\core_analytics\calculable::OUTCOME_VERY_NEGATIVE or \core_analytics\calculable::OUTCOME_NEUTRAL'); } $icon = new \pix_icon($icon, $text); return array($style, $icon->export_for_template($output)); }
php
public static function get_calculation_display(\core_analytics\calculable $calculable, $value, $output, $subtype = false) { $outcome = $calculable->get_calculation_outcome($value, $subtype); switch ($outcome) { case \core_analytics\calculable::OUTCOME_NEUTRAL: $style = ''; $text = get_string('outcomeneutral', 'report_insights'); $icon = 't/check'; break; case \core_analytics\calculable::OUTCOME_VERY_POSITIVE: $style = 'success'; $text = get_string('outcomeverypositive', 'report_insights'); $icon = 't/approve'; break; case \core_analytics\calculable::OUTCOME_OK: $style = 'info'; $text = get_string('outcomeok', 'report_insights'); $icon = 't/check'; break; case \core_analytics\calculable::OUTCOME_NEGATIVE: $style = 'warning'; $text = get_string('outcomenegative', 'report_insights'); $icon = 'i/warning'; break; case \core_analytics\calculable::OUTCOME_VERY_NEGATIVE: $style = 'danger'; $text = get_string('outcomeverynegative', 'report_insights'); $icon = 'i/warning'; break; default: throw new \coding_exception('The outcome returned by ' . get_class($calculable) . '::get_calculation_outcome is ' . 'not one of the accepted values. Please use \core_analytics\calculable::OUTCOME_VERY_POSITIVE, ' . '\core_analytics\calculable::OUTCOME_OK, \core_analytics\calculable::OUTCOME_NEGATIVE, ' . '\core_analytics\calculable::OUTCOME_VERY_NEGATIVE or \core_analytics\calculable::OUTCOME_NEUTRAL'); } $icon = new \pix_icon($icon, $text); return array($style, $icon->export_for_template($output)); }
[ "public", "static", "function", "get_calculation_display", "(", "\\", "core_analytics", "\\", "calculable", "$", "calculable", ",", "$", "value", ",", "$", "output", ",", "$", "subtype", "=", "false", ")", "{", "$", "outcome", "=", "$", "calculable", "->", "get_calculation_outcome", "(", "$", "value", ",", "$", "subtype", ")", ";", "switch", "(", "$", "outcome", ")", "{", "case", "\\", "core_analytics", "\\", "calculable", "::", "OUTCOME_NEUTRAL", ":", "$", "style", "=", "''", ";", "$", "text", "=", "get_string", "(", "'outcomeneutral'", ",", "'report_insights'", ")", ";", "$", "icon", "=", "'t/check'", ";", "break", ";", "case", "\\", "core_analytics", "\\", "calculable", "::", "OUTCOME_VERY_POSITIVE", ":", "$", "style", "=", "'success'", ";", "$", "text", "=", "get_string", "(", "'outcomeverypositive'", ",", "'report_insights'", ")", ";", "$", "icon", "=", "'t/approve'", ";", "break", ";", "case", "\\", "core_analytics", "\\", "calculable", "::", "OUTCOME_OK", ":", "$", "style", "=", "'info'", ";", "$", "text", "=", "get_string", "(", "'outcomeok'", ",", "'report_insights'", ")", ";", "$", "icon", "=", "'t/check'", ";", "break", ";", "case", "\\", "core_analytics", "\\", "calculable", "::", "OUTCOME_NEGATIVE", ":", "$", "style", "=", "'warning'", ";", "$", "text", "=", "get_string", "(", "'outcomenegative'", ",", "'report_insights'", ")", ";", "$", "icon", "=", "'i/warning'", ";", "break", ";", "case", "\\", "core_analytics", "\\", "calculable", "::", "OUTCOME_VERY_NEGATIVE", ":", "$", "style", "=", "'danger'", ";", "$", "text", "=", "get_string", "(", "'outcomeverynegative'", ",", "'report_insights'", ")", ";", "$", "icon", "=", "'i/warning'", ";", "break", ";", "default", ":", "throw", "new", "\\", "coding_exception", "(", "'The outcome returned by '", ".", "get_class", "(", "$", "calculable", ")", ".", "'::get_calculation_outcome is '", ".", "'not one of the accepted values. Please use \\core_analytics\\calculable::OUTCOME_VERY_POSITIVE, '", ".", "'\\core_analytics\\calculable::OUTCOME_OK, \\core_analytics\\calculable::OUTCOME_NEGATIVE, '", ".", "'\\core_analytics\\calculable::OUTCOME_VERY_NEGATIVE or \\core_analytics\\calculable::OUTCOME_NEUTRAL'", ")", ";", "}", "$", "icon", "=", "new", "\\", "pix_icon", "(", "$", "icon", ",", "$", "text", ")", ";", "return", "array", "(", "$", "style", ",", "$", "icon", "->", "export_for_template", "(", "$", "output", ")", ")", ";", "}" ]
Returns display info for the calculated value outcome. @param \core_analytics\calculable $calculable @param float $value @param \renderer_base $output @param string|false $subtype @return array The style as 'success', 'info', 'warning' or 'danger' and pix_icon
[ "Returns", "display", "info", "for", "the", "calculated", "value", "outcome", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/report/insights/classes/output/insight.php#L177-L213
214,904
moodle/moodle
blog/edit_form.php
blog_edit_form.validation
public function validation($data, $files) { global $CFG, $DB, $USER; $errors = parent::validation($data, $files); // Validate course association. if (!empty($data['courseassoc'])) { $coursecontext = context::instance_by_id($data['courseassoc']); if ($coursecontext->contextlevel != CONTEXT_COURSE) { $errors['courseassoc'] = get_string('error'); } } // Validate mod association. if (!empty($data['modassoc'])) { $modcontextid = $data['modassoc']; $modcontext = context::instance_by_id($modcontextid); if ($modcontext->contextlevel == CONTEXT_MODULE) { // Get context of the mod's course. $coursecontext = $modcontext->get_course_context(true); // Ensure only one course is associated. if (!empty($data['courseassoc'])) { if ($data['courseassoc'] != $coursecontext->id) { $errors['modassoc'] = get_string('onlyassociateonecourse', 'blog'); } } else { $data['courseassoc'] = $coursecontext->id; } } else { $errors['modassoc'] = get_string('error'); } } if ($errors) { return $errors; } return true; }
php
public function validation($data, $files) { global $CFG, $DB, $USER; $errors = parent::validation($data, $files); // Validate course association. if (!empty($data['courseassoc'])) { $coursecontext = context::instance_by_id($data['courseassoc']); if ($coursecontext->contextlevel != CONTEXT_COURSE) { $errors['courseassoc'] = get_string('error'); } } // Validate mod association. if (!empty($data['modassoc'])) { $modcontextid = $data['modassoc']; $modcontext = context::instance_by_id($modcontextid); if ($modcontext->contextlevel == CONTEXT_MODULE) { // Get context of the mod's course. $coursecontext = $modcontext->get_course_context(true); // Ensure only one course is associated. if (!empty($data['courseassoc'])) { if ($data['courseassoc'] != $coursecontext->id) { $errors['modassoc'] = get_string('onlyassociateonecourse', 'blog'); } } else { $data['courseassoc'] = $coursecontext->id; } } else { $errors['modassoc'] = get_string('error'); } } if ($errors) { return $errors; } return true; }
[ "public", "function", "validation", "(", "$", "data", ",", "$", "files", ")", "{", "global", "$", "CFG", ",", "$", "DB", ",", "$", "USER", ";", "$", "errors", "=", "parent", "::", "validation", "(", "$", "data", ",", "$", "files", ")", ";", "// Validate course association.", "if", "(", "!", "empty", "(", "$", "data", "[", "'courseassoc'", "]", ")", ")", "{", "$", "coursecontext", "=", "context", "::", "instance_by_id", "(", "$", "data", "[", "'courseassoc'", "]", ")", ";", "if", "(", "$", "coursecontext", "->", "contextlevel", "!=", "CONTEXT_COURSE", ")", "{", "$", "errors", "[", "'courseassoc'", "]", "=", "get_string", "(", "'error'", ")", ";", "}", "}", "// Validate mod association.", "if", "(", "!", "empty", "(", "$", "data", "[", "'modassoc'", "]", ")", ")", "{", "$", "modcontextid", "=", "$", "data", "[", "'modassoc'", "]", ";", "$", "modcontext", "=", "context", "::", "instance_by_id", "(", "$", "modcontextid", ")", ";", "if", "(", "$", "modcontext", "->", "contextlevel", "==", "CONTEXT_MODULE", ")", "{", "// Get context of the mod's course.", "$", "coursecontext", "=", "$", "modcontext", "->", "get_course_context", "(", "true", ")", ";", "// Ensure only one course is associated.", "if", "(", "!", "empty", "(", "$", "data", "[", "'courseassoc'", "]", ")", ")", "{", "if", "(", "$", "data", "[", "'courseassoc'", "]", "!=", "$", "coursecontext", "->", "id", ")", "{", "$", "errors", "[", "'modassoc'", "]", "=", "get_string", "(", "'onlyassociateonecourse'", ",", "'blog'", ")", ";", "}", "}", "else", "{", "$", "data", "[", "'courseassoc'", "]", "=", "$", "coursecontext", "->", "id", ";", "}", "}", "else", "{", "$", "errors", "[", "'modassoc'", "]", "=", "get_string", "(", "'error'", ")", ";", "}", "}", "if", "(", "$", "errors", ")", "{", "return", "$", "errors", ";", "}", "return", "true", ";", "}" ]
Validate the blog form data. @param array $data Data to be validated @param array $files unused @return array|bool
[ "Validate", "the", "blog", "form", "data", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/blog/edit_form.php#L152-L192
214,905
moodle/moodle
lib/dml/moodle_transaction.php
moodle_transaction.rollback
public function rollback($e) { if ($this->is_disposed()) { throw new dml_transaction_exception('Transactions already disposed', $this); } $this->database->rollback_delegated_transaction($this, $e); }
php
public function rollback($e) { if ($this->is_disposed()) { throw new dml_transaction_exception('Transactions already disposed', $this); } $this->database->rollback_delegated_transaction($this, $e); }
[ "public", "function", "rollback", "(", "$", "e", ")", "{", "if", "(", "$", "this", "->", "is_disposed", "(", ")", ")", "{", "throw", "new", "dml_transaction_exception", "(", "'Transactions already disposed'", ",", "$", "this", ")", ";", "}", "$", "this", "->", "database", "->", "rollback_delegated_transaction", "(", "$", "this", ",", "$", "e", ")", ";", "}" ]
Rollback all current delegated transactions. @param Exception|Throwable $e mandatory exception/throwable @return void
[ "Rollback", "all", "current", "delegated", "transactions", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/dml/moodle_transaction.php#L101-L106
214,906
moodle/moodle
lib/classes/event/course_restored.php
course_restored.get_description
public function get_description() { $retstring = "The user with id '$this->userid' restored the course with id '$this->courseid'."; if (isset($this->other['originalcourseid'])) { $originalcourseid = $this->other['originalcourseid']; $retstring = "The user with id '$this->userid' restored old course with id " . "'$originalcourseid' to a new course with id '$this->courseid'."; } return $retstring; }
php
public function get_description() { $retstring = "The user with id '$this->userid' restored the course with id '$this->courseid'."; if (isset($this->other['originalcourseid'])) { $originalcourseid = $this->other['originalcourseid']; $retstring = "The user with id '$this->userid' restored old course with id " . "'$originalcourseid' to a new course with id '$this->courseid'."; } return $retstring; }
[ "public", "function", "get_description", "(", ")", "{", "$", "retstring", "=", "\"The user with id '$this->userid' restored the course with id '$this->courseid'.\"", ";", "if", "(", "isset", "(", "$", "this", "->", "other", "[", "'originalcourseid'", "]", ")", ")", "{", "$", "originalcourseid", "=", "$", "this", "->", "other", "[", "'originalcourseid'", "]", ";", "$", "retstring", "=", "\"The user with id '$this->userid' restored old course with id \"", ".", "\"'$originalcourseid' to a new course with id '$this->courseid'.\"", ";", "}", "return", "$", "retstring", ";", "}" ]
Returns non-localised description of what happened. @return string
[ "Returns", "non", "-", "localised", "description", "of", "what", "happened", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/event/course_restored.php#L73-L83
214,907
moodle/moodle
lib/adodb/perf/perf-oci8.inc.php
perf_oci8.SuspiciousSQL
function SuspiciousSQL($numsql=10) { $sql = " select substr(to_char(s.pct, '99.00'), 2) || '%' load, s.executions executes, p.sql_text from ( select address, buffer_gets, executions, pct, rank() over (order by buffer_gets desc) ranking from ( select address, buffer_gets, executions, 100 * ratio_to_report(buffer_gets) over () pct from sys.v_\$sql where command_type != 47 and module != 'T.O.A.D.' ) where buffer_gets > 50 * executions ) s, sys.v_\$sqltext p where s.ranking <= $numsql and p.address = s.address order by 1 desc, s.address, p.piece"; global $ADODB_CACHE_MODE; if (isset($_GET['expsixora']) && isset($_GET['sql'])) { $partial = empty($_GET['part']); echo "<a name=explain></a>".$this->Explain($_GET['sql'],$partial)."\n"; } if (isset($_GET['sql'])) return $this->_SuspiciousSQL($numsql); $s = ''; $timer = time(); $s .= $this->_SuspiciousSQL($numsql); $timer = time() - $timer; if ($timer > $this->noShowIxora) return $s; $s .= '<p>'; $save = $ADODB_CACHE_MODE; $ADODB_CACHE_MODE = ADODB_FETCH_NUM; if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false); $savelog = $this->conn->LogSQL(false); $rs = $this->conn->SelectLimit($sql); $this->conn->LogSQL($savelog); if (isset($savem)) $this->conn->SetFetchMode($savem); $ADODB_CACHE_MODE = $save; if ($rs) { $s .= "\n<h3>Ixora Suspicious SQL</h3>"; $s .= $this->tohtml($rs,'expsixora'); } return $s; }
php
function SuspiciousSQL($numsql=10) { $sql = " select substr(to_char(s.pct, '99.00'), 2) || '%' load, s.executions executes, p.sql_text from ( select address, buffer_gets, executions, pct, rank() over (order by buffer_gets desc) ranking from ( select address, buffer_gets, executions, 100 * ratio_to_report(buffer_gets) over () pct from sys.v_\$sql where command_type != 47 and module != 'T.O.A.D.' ) where buffer_gets > 50 * executions ) s, sys.v_\$sqltext p where s.ranking <= $numsql and p.address = s.address order by 1 desc, s.address, p.piece"; global $ADODB_CACHE_MODE; if (isset($_GET['expsixora']) && isset($_GET['sql'])) { $partial = empty($_GET['part']); echo "<a name=explain></a>".$this->Explain($_GET['sql'],$partial)."\n"; } if (isset($_GET['sql'])) return $this->_SuspiciousSQL($numsql); $s = ''; $timer = time(); $s .= $this->_SuspiciousSQL($numsql); $timer = time() - $timer; if ($timer > $this->noShowIxora) return $s; $s .= '<p>'; $save = $ADODB_CACHE_MODE; $ADODB_CACHE_MODE = ADODB_FETCH_NUM; if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false); $savelog = $this->conn->LogSQL(false); $rs = $this->conn->SelectLimit($sql); $this->conn->LogSQL($savelog); if (isset($savem)) $this->conn->SetFetchMode($savem); $ADODB_CACHE_MODE = $save; if ($rs) { $s .= "\n<h3>Ixora Suspicious SQL</h3>"; $s .= $this->tohtml($rs,'expsixora'); } return $s; }
[ "function", "SuspiciousSQL", "(", "$", "numsql", "=", "10", ")", "{", "$", "sql", "=", "\"\nselect\n substr(to_char(s.pct, '99.00'), 2) || '%' load,\n s.executions executes,\n p.sql_text\nfrom\n (\n select\n address,\n buffer_gets,\n executions,\n pct,\n rank() over (order by buffer_gets desc) ranking\n from\n (\n\tselect\n\t address,\n\t buffer_gets,\n\t executions,\n\t 100 * ratio_to_report(buffer_gets) over () pct\n\tfrom\n\t sys.v_\\$sql\n\twhere\n\t command_type != 47 and module != 'T.O.A.D.'\n )\n where\n buffer_gets > 50 * executions\n ) s,\n sys.v_\\$sqltext p\nwhere\n s.ranking <= $numsql and\n p.address = s.address\norder by\n 1 desc, s.address, p.piece\"", ";", "global", "$", "ADODB_CACHE_MODE", ";", "if", "(", "isset", "(", "$", "_GET", "[", "'expsixora'", "]", ")", "&&", "isset", "(", "$", "_GET", "[", "'sql'", "]", ")", ")", "{", "$", "partial", "=", "empty", "(", "$", "_GET", "[", "'part'", "]", ")", ";", "echo", "\"<a name=explain></a>\"", ".", "$", "this", "->", "Explain", "(", "$", "_GET", "[", "'sql'", "]", ",", "$", "partial", ")", ".", "\"\\n\"", ";", "}", "if", "(", "isset", "(", "$", "_GET", "[", "'sql'", "]", ")", ")", "return", "$", "this", "->", "_SuspiciousSQL", "(", "$", "numsql", ")", ";", "$", "s", "=", "''", ";", "$", "timer", "=", "time", "(", ")", ";", "$", "s", ".=", "$", "this", "->", "_SuspiciousSQL", "(", "$", "numsql", ")", ";", "$", "timer", "=", "time", "(", ")", "-", "$", "timer", ";", "if", "(", "$", "timer", ">", "$", "this", "->", "noShowIxora", ")", "return", "$", "s", ";", "$", "s", ".=", "'<p>'", ";", "$", "save", "=", "$", "ADODB_CACHE_MODE", ";", "$", "ADODB_CACHE_MODE", "=", "ADODB_FETCH_NUM", ";", "if", "(", "$", "this", "->", "conn", "->", "fetchMode", "!==", "false", ")", "$", "savem", "=", "$", "this", "->", "conn", "->", "SetFetchMode", "(", "false", ")", ";", "$", "savelog", "=", "$", "this", "->", "conn", "->", "LogSQL", "(", "false", ")", ";", "$", "rs", "=", "$", "this", "->", "conn", "->", "SelectLimit", "(", "$", "sql", ")", ";", "$", "this", "->", "conn", "->", "LogSQL", "(", "$", "savelog", ")", ";", "if", "(", "isset", "(", "$", "savem", ")", ")", "$", "this", "->", "conn", "->", "SetFetchMode", "(", "$", "savem", ")", ";", "$", "ADODB_CACHE_MODE", "=", "$", "save", ";", "if", "(", "$", "rs", ")", "{", "$", "s", ".=", "\"\\n<h3>Ixora Suspicious SQL</h3>\"", ";", "$", "s", ".=", "$", "this", "->", "tohtml", "(", "$", "rs", ",", "'expsixora'", ")", ";", "}", "return", "$", "s", ";", "}" ]
requires oracle 8.1.7 or later
[ "requires", "oracle", "8", ".", "1", ".", "7", "or", "later" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adodb/perf/perf-oci8.inc.php#L532-L601
214,908
moodle/moodle
blocks/moodleblock.class.php
block_base.name
function name() { // Returns the block name, as present in the class name, // the database, the block directory, etc etc. static $myname; if ($myname === NULL) { $myname = strtolower(get_class($this)); $myname = substr($myname, strpos($myname, '_') + 1); } return $myname; }
php
function name() { // Returns the block name, as present in the class name, // the database, the block directory, etc etc. static $myname; if ($myname === NULL) { $myname = strtolower(get_class($this)); $myname = substr($myname, strpos($myname, '_') + 1); } return $myname; }
[ "function", "name", "(", ")", "{", "// Returns the block name, as present in the class name,", "// the database, the block directory, etc etc.", "static", "$", "myname", ";", "if", "(", "$", "myname", "===", "NULL", ")", "{", "$", "myname", "=", "strtolower", "(", "get_class", "(", "$", "this", ")", ")", ";", "$", "myname", "=", "substr", "(", "$", "myname", ",", "strpos", "(", "$", "myname", ",", "'_'", ")", "+", "1", ")", ";", "}", "return", "$", "myname", ";", "}" ]
Returns the block name, as present in the class name, the database, the block directory, etc etc. @return string
[ "Returns", "the", "block", "name", "as", "present", "in", "the", "class", "name", "the", "database", "the", "block", "directory", "etc", "etc", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/blocks/moodleblock.class.php#L132-L141
214,909
moodle/moodle
blocks/moodleblock.class.php
block_base.is_empty
function is_empty() { if ( !has_capability('moodle/block:view', $this->context) ) { return true; } $this->get_content(); return(empty($this->content->text) && empty($this->content->footer)); }
php
function is_empty() { if ( !has_capability('moodle/block:view', $this->context) ) { return true; } $this->get_content(); return(empty($this->content->text) && empty($this->content->footer)); }
[ "function", "is_empty", "(", ")", "{", "if", "(", "!", "has_capability", "(", "'moodle/block:view'", ",", "$", "this", "->", "context", ")", ")", "{", "return", "true", ";", "}", "$", "this", "->", "get_content", "(", ")", ";", "return", "(", "empty", "(", "$", "this", "->", "content", "->", "text", ")", "&&", "empty", "(", "$", "this", "->", "content", "->", "footer", ")", ")", ";", "}" ]
Returns true or false, depending on whether this block has any content to display and whether the user has permission to view the block @return boolean
[ "Returns", "true", "or", "false", "depending", "on", "whether", "this", "block", "has", "any", "content", "to", "display", "and", "whether", "the", "user", "has", "permission", "to", "view", "the", "block" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/blocks/moodleblock.class.php#L187-L194
214,910
moodle/moodle
blocks/moodleblock.class.php
block_base.get_content_for_output
public function get_content_for_output($output) { global $CFG; $bc = new block_contents($this->html_attributes()); $bc->attributes['data-block'] = $this->name(); $bc->blockinstanceid = $this->instance->id; $bc->blockpositionid = $this->instance->blockpositionid; if ($this->instance->visible) { $bc->content = $this->formatted_contents($output); if (!empty($this->content->footer)) { $bc->footer = $this->content->footer; } } else { $bc->add_class('invisible'); } if (!$this->hide_header()) { $bc->title = $this->title; } if (empty($bc->title)) { $bc->arialabel = new lang_string('pluginname', get_class($this)); $this->arialabel = $bc->arialabel; } if ($this->page->user_is_editing()) { $bc->controls = $this->page->blocks->edit_controls($this); } else { // we must not use is_empty on hidden blocks if ($this->is_empty() && !$bc->controls) { return null; } } if (empty($CFG->allowuserblockhiding) || (empty($bc->content) && empty($bc->footer)) || !$this->instance_can_be_collapsed()) { $bc->collapsible = block_contents::NOT_HIDEABLE; } else if (get_user_preferences('block' . $bc->blockinstanceid . 'hidden', false)) { $bc->collapsible = block_contents::HIDDEN; } else { $bc->collapsible = block_contents::VISIBLE; } if ($this->instance_can_be_docked() && !$this->hide_header()) { $bc->dockable = true; } $bc->annotation = ''; // TODO MDL-19398 need to work out what to say here. return $bc; }
php
public function get_content_for_output($output) { global $CFG; $bc = new block_contents($this->html_attributes()); $bc->attributes['data-block'] = $this->name(); $bc->blockinstanceid = $this->instance->id; $bc->blockpositionid = $this->instance->blockpositionid; if ($this->instance->visible) { $bc->content = $this->formatted_contents($output); if (!empty($this->content->footer)) { $bc->footer = $this->content->footer; } } else { $bc->add_class('invisible'); } if (!$this->hide_header()) { $bc->title = $this->title; } if (empty($bc->title)) { $bc->arialabel = new lang_string('pluginname', get_class($this)); $this->arialabel = $bc->arialabel; } if ($this->page->user_is_editing()) { $bc->controls = $this->page->blocks->edit_controls($this); } else { // we must not use is_empty on hidden blocks if ($this->is_empty() && !$bc->controls) { return null; } } if (empty($CFG->allowuserblockhiding) || (empty($bc->content) && empty($bc->footer)) || !$this->instance_can_be_collapsed()) { $bc->collapsible = block_contents::NOT_HIDEABLE; } else if (get_user_preferences('block' . $bc->blockinstanceid . 'hidden', false)) { $bc->collapsible = block_contents::HIDDEN; } else { $bc->collapsible = block_contents::VISIBLE; } if ($this->instance_can_be_docked() && !$this->hide_header()) { $bc->dockable = true; } $bc->annotation = ''; // TODO MDL-19398 need to work out what to say here. return $bc; }
[ "public", "function", "get_content_for_output", "(", "$", "output", ")", "{", "global", "$", "CFG", ";", "$", "bc", "=", "new", "block_contents", "(", "$", "this", "->", "html_attributes", "(", ")", ")", ";", "$", "bc", "->", "attributes", "[", "'data-block'", "]", "=", "$", "this", "->", "name", "(", ")", ";", "$", "bc", "->", "blockinstanceid", "=", "$", "this", "->", "instance", "->", "id", ";", "$", "bc", "->", "blockpositionid", "=", "$", "this", "->", "instance", "->", "blockpositionid", ";", "if", "(", "$", "this", "->", "instance", "->", "visible", ")", "{", "$", "bc", "->", "content", "=", "$", "this", "->", "formatted_contents", "(", "$", "output", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "content", "->", "footer", ")", ")", "{", "$", "bc", "->", "footer", "=", "$", "this", "->", "content", "->", "footer", ";", "}", "}", "else", "{", "$", "bc", "->", "add_class", "(", "'invisible'", ")", ";", "}", "if", "(", "!", "$", "this", "->", "hide_header", "(", ")", ")", "{", "$", "bc", "->", "title", "=", "$", "this", "->", "title", ";", "}", "if", "(", "empty", "(", "$", "bc", "->", "title", ")", ")", "{", "$", "bc", "->", "arialabel", "=", "new", "lang_string", "(", "'pluginname'", ",", "get_class", "(", "$", "this", ")", ")", ";", "$", "this", "->", "arialabel", "=", "$", "bc", "->", "arialabel", ";", "}", "if", "(", "$", "this", "->", "page", "->", "user_is_editing", "(", ")", ")", "{", "$", "bc", "->", "controls", "=", "$", "this", "->", "page", "->", "blocks", "->", "edit_controls", "(", "$", "this", ")", ";", "}", "else", "{", "// we must not use is_empty on hidden blocks", "if", "(", "$", "this", "->", "is_empty", "(", ")", "&&", "!", "$", "bc", "->", "controls", ")", "{", "return", "null", ";", "}", "}", "if", "(", "empty", "(", "$", "CFG", "->", "allowuserblockhiding", ")", "||", "(", "empty", "(", "$", "bc", "->", "content", ")", "&&", "empty", "(", "$", "bc", "->", "footer", ")", ")", "||", "!", "$", "this", "->", "instance_can_be_collapsed", "(", ")", ")", "{", "$", "bc", "->", "collapsible", "=", "block_contents", "::", "NOT_HIDEABLE", ";", "}", "else", "if", "(", "get_user_preferences", "(", "'block'", ".", "$", "bc", "->", "blockinstanceid", ".", "'hidden'", ",", "false", ")", ")", "{", "$", "bc", "->", "collapsible", "=", "block_contents", "::", "HIDDEN", ";", "}", "else", "{", "$", "bc", "->", "collapsible", "=", "block_contents", "::", "VISIBLE", ";", "}", "if", "(", "$", "this", "->", "instance_can_be_docked", "(", ")", "&&", "!", "$", "this", "->", "hide_header", "(", ")", ")", "{", "$", "bc", "->", "dockable", "=", "true", ";", "}", "$", "bc", "->", "annotation", "=", "''", ";", "// TODO MDL-19398 need to work out what to say here.", "return", "$", "bc", ";", "}" ]
Return a block_contents object representing the full contents of this block. This internally calls ->get_content(), and then adds the editing controls etc. You probably should not override this method, but instead override {@link html_attributes()}, {@link formatted_contents()} or {@link get_content()}, {@link hide_header()}, {@link (get_edit_controls)}, etc. @return block_contents a representation of the block, for rendering. @since Moodle 2.0.
[ "Return", "a", "block_contents", "object", "representing", "the", "full", "contents", "of", "this", "block", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/blocks/moodleblock.class.php#L221-L273
214,911
moodle/moodle
blocks/moodleblock.class.php
block_base.get_content_for_external
public function get_content_for_external($output) { $bc = new stdClass; $bc->title = null; $bc->content = null; $bc->contentformat = FORMAT_HTML; $bc->footer = null; $bc->files = []; if ($this->instance->visible) { $bc->content = $this->formatted_contents($output); if (!empty($this->content->footer)) { $bc->footer = $this->content->footer; } } if (!$this->hide_header()) { $bc->title = $this->title; } return $bc; }
php
public function get_content_for_external($output) { $bc = new stdClass; $bc->title = null; $bc->content = null; $bc->contentformat = FORMAT_HTML; $bc->footer = null; $bc->files = []; if ($this->instance->visible) { $bc->content = $this->formatted_contents($output); if (!empty($this->content->footer)) { $bc->footer = $this->content->footer; } } if (!$this->hide_header()) { $bc->title = $this->title; } return $bc; }
[ "public", "function", "get_content_for_external", "(", "$", "output", ")", "{", "$", "bc", "=", "new", "stdClass", ";", "$", "bc", "->", "title", "=", "null", ";", "$", "bc", "->", "content", "=", "null", ";", "$", "bc", "->", "contentformat", "=", "FORMAT_HTML", ";", "$", "bc", "->", "footer", "=", "null", ";", "$", "bc", "->", "files", "=", "[", "]", ";", "if", "(", "$", "this", "->", "instance", "->", "visible", ")", "{", "$", "bc", "->", "content", "=", "$", "this", "->", "formatted_contents", "(", "$", "output", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "content", "->", "footer", ")", ")", "{", "$", "bc", "->", "footer", "=", "$", "this", "->", "content", "->", "footer", ";", "}", "}", "if", "(", "!", "$", "this", "->", "hide_header", "(", ")", ")", "{", "$", "bc", "->", "title", "=", "$", "this", "->", "title", ";", "}", "return", "$", "bc", ";", "}" ]
Return an object containing all the block content to be returned by external functions. If your block is returning formatted content or provide files for download, you should override this method to use the external_format_text, external_format_string functions for formatting or external_util::get_area_files for files. @param core_renderer $output the rendered used for output @return stdClass object containing the block title, central content, footer and linked files (if any). @since Moodle 3.6
[ "Return", "an", "object", "containing", "all", "the", "block", "content", "to", "be", "returned", "by", "external", "functions", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/blocks/moodleblock.class.php#L286-L306
214,912
moodle/moodle
blocks/moodleblock.class.php
block_base.formatted_contents
protected function formatted_contents($output) { $this->get_content(); $this->get_required_javascript(); if (!empty($this->content->text)) { return $this->content->text; } else { return ''; } }
php
protected function formatted_contents($output) { $this->get_content(); $this->get_required_javascript(); if (!empty($this->content->text)) { return $this->content->text; } else { return ''; } }
[ "protected", "function", "formatted_contents", "(", "$", "output", ")", "{", "$", "this", "->", "get_content", "(", ")", ";", "$", "this", "->", "get_required_javascript", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "content", "->", "text", ")", ")", "{", "return", "$", "this", "->", "content", "->", "text", ";", "}", "else", "{", "return", "''", ";", "}", "}" ]
Convert the contents of the block to HTML. This is used by block base classes like block_list to convert the structured $this->content->list and $this->content->icons arrays to HTML. So, in most blocks, you probaby want to override the {@link get_contents()} method, which generates that structured representation of the contents. @param $output The core_renderer to use when generating the output. @return string the HTML that should appearn in the body of the block. @since Moodle 2.0.
[ "Convert", "the", "contents", "of", "the", "block", "to", "HTML", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/blocks/moodleblock.class.php#L320-L328
214,913
moodle/moodle
blocks/moodleblock.class.php
block_base.has_add_block_capability
private function has_add_block_capability($page, $capability) { // Check if the capability exists. if (!get_capability_info($capability)) { // Debug warning that the capability does not exist, but no more than once per page. static $warned = array(); if (!isset($warned[$this->name()])) { debugging('The block ' .$this->name() . ' does not define the standard capability ' . $capability , DEBUG_DEVELOPER); $warned[$this->name()] = 1; } // If the capability does not exist, the block can always be added. return true; } else { return has_capability($capability, $page->context); } }
php
private function has_add_block_capability($page, $capability) { // Check if the capability exists. if (!get_capability_info($capability)) { // Debug warning that the capability does not exist, but no more than once per page. static $warned = array(); if (!isset($warned[$this->name()])) { debugging('The block ' .$this->name() . ' does not define the standard capability ' . $capability , DEBUG_DEVELOPER); $warned[$this->name()] = 1; } // If the capability does not exist, the block can always be added. return true; } else { return has_capability($capability, $page->context); } }
[ "private", "function", "has_add_block_capability", "(", "$", "page", ",", "$", "capability", ")", "{", "// Check if the capability exists.", "if", "(", "!", "get_capability_info", "(", "$", "capability", ")", ")", "{", "// Debug warning that the capability does not exist, but no more than once per page.", "static", "$", "warned", "=", "array", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "warned", "[", "$", "this", "->", "name", "(", ")", "]", ")", ")", "{", "debugging", "(", "'The block '", ".", "$", "this", "->", "name", "(", ")", ".", "' does not define the standard capability '", ".", "$", "capability", ",", "DEBUG_DEVELOPER", ")", ";", "$", "warned", "[", "$", "this", "->", "name", "(", ")", "]", "=", "1", ";", "}", "// If the capability does not exist, the block can always be added.", "return", "true", ";", "}", "else", "{", "return", "has_capability", "(", "$", "capability", ",", "$", "page", "->", "context", ")", ";", "}", "}" ]
Returns true if the user can add a block to a page. @param moodle_page $page @param string $capability the capability to check @return boolean true if user can add a block, false otherwise.
[ "Returns", "true", "if", "the", "user", "can", "add", "a", "block", "to", "a", "page", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/blocks/moodleblock.class.php#L628-L643
214,914
moodle/moodle
blocks/moodleblock.class.php
block_tree.formatted_contents
protected function formatted_contents($output) { // based of code in admin_tree global $PAGE; // TODO change this when there is a proper way for blocks to get stuff into head. static $eventattached; if ($eventattached===null) { $eventattached = true; } if (!$this->content) { $this->content = new stdClass; $this->content->items = array(); } $this->get_required_javascript(); $this->get_content(); $content = $output->tree_block_contents($this->content->items,array('class'=>'block_tree list')); if (isset($this->id) && !is_numeric($this->id)) { $content = $output->box($content, 'block_tree_box', $this->id); } return $content; }
php
protected function formatted_contents($output) { // based of code in admin_tree global $PAGE; // TODO change this when there is a proper way for blocks to get stuff into head. static $eventattached; if ($eventattached===null) { $eventattached = true; } if (!$this->content) { $this->content = new stdClass; $this->content->items = array(); } $this->get_required_javascript(); $this->get_content(); $content = $output->tree_block_contents($this->content->items,array('class'=>'block_tree list')); if (isset($this->id) && !is_numeric($this->id)) { $content = $output->box($content, 'block_tree_box', $this->id); } return $content; }
[ "protected", "function", "formatted_contents", "(", "$", "output", ")", "{", "// based of code in admin_tree", "global", "$", "PAGE", ";", "// TODO change this when there is a proper way for blocks to get stuff into head.", "static", "$", "eventattached", ";", "if", "(", "$", "eventattached", "===", "null", ")", "{", "$", "eventattached", "=", "true", ";", "}", "if", "(", "!", "$", "this", "->", "content", ")", "{", "$", "this", "->", "content", "=", "new", "stdClass", ";", "$", "this", "->", "content", "->", "items", "=", "array", "(", ")", ";", "}", "$", "this", "->", "get_required_javascript", "(", ")", ";", "$", "this", "->", "get_content", "(", ")", ";", "$", "content", "=", "$", "output", "->", "tree_block_contents", "(", "$", "this", "->", "content", "->", "items", ",", "array", "(", "'class'", "=>", "'block_tree list'", ")", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "id", ")", "&&", "!", "is_numeric", "(", "$", "this", "->", "id", ")", ")", "{", "$", "content", "=", "$", "output", "->", "box", "(", "$", "content", ",", "'block_tree_box'", ",", "$", "this", "->", "id", ")", ";", "}", "return", "$", "content", ";", "}" ]
Make the formatted HTML ouput. Also adds the required javascript call to the page output. @param core_renderer $output @return string HTML
[ "Make", "the", "formatted", "HTML", "ouput", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/blocks/moodleblock.class.php#L800-L818
214,915
moodle/moodle
report/insights/classes/external.php
external.validate_prediction
protected static function validate_prediction($predictionid) { list($model, $prediction, $context) = \core_analytics\manager::get_prediction($predictionid); self::validate_context($context); return array($model, $prediction, $context); }
php
protected static function validate_prediction($predictionid) { list($model, $prediction, $context) = \core_analytics\manager::get_prediction($predictionid); self::validate_context($context); return array($model, $prediction, $context); }
[ "protected", "static", "function", "validate_prediction", "(", "$", "predictionid", ")", "{", "list", "(", "$", "model", ",", "$", "prediction", ",", "$", "context", ")", "=", "\\", "core_analytics", "\\", "manager", "::", "get_prediction", "(", "$", "predictionid", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "return", "array", "(", "$", "model", ",", "$", "prediction", ",", "$", "context", ")", ";", "}" ]
Validates access to the prediction and returns it. @param int $predictionid @return array array($model, $prediction, $context)
[ "Validates", "access", "to", "the", "prediction", "and", "returns", "it", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/report/insights/classes/external.php#L147-L154
214,916
moodle/moodle
availability/classes/info.php
info.get_availability_tree
public function get_availability_tree() { if (is_null($this->availabilitytree)) { if (is_null($this->availability)) { throw new \coding_exception( 'Cannot call get_availability_tree with null availability'); } $this->availabilitytree = $this->decode_availability($this->availability, true); } return $this->availabilitytree; }
php
public function get_availability_tree() { if (is_null($this->availabilitytree)) { if (is_null($this->availability)) { throw new \coding_exception( 'Cannot call get_availability_tree with null availability'); } $this->availabilitytree = $this->decode_availability($this->availability, true); } return $this->availabilitytree; }
[ "public", "function", "get_availability_tree", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "availabilitytree", ")", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "availability", ")", ")", "{", "throw", "new", "\\", "coding_exception", "(", "'Cannot call get_availability_tree with null availability'", ")", ";", "}", "$", "this", "->", "availabilitytree", "=", "$", "this", "->", "decode_availability", "(", "$", "this", "->", "availability", ",", "true", ")", ";", "}", "return", "$", "this", "->", "availabilitytree", ";", "}" ]
Gets the availability tree, decoding it if not already done. @return tree Availability tree
[ "Gets", "the", "availability", "tree", "decoding", "it", "if", "not", "already", "done", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/availability/classes/info.php#L108-L117
214,917
moodle/moodle
availability/classes/info.php
info.decode_availability
protected function decode_availability($availability, $lax) { // Decode JSON data. $structure = json_decode($availability); if (is_null($structure)) { throw new \coding_exception('Invalid availability text', $availability); } // Recursively decode tree. return new tree($structure, $lax); }
php
protected function decode_availability($availability, $lax) { // Decode JSON data. $structure = json_decode($availability); if (is_null($structure)) { throw new \coding_exception('Invalid availability text', $availability); } // Recursively decode tree. return new tree($structure, $lax); }
[ "protected", "function", "decode_availability", "(", "$", "availability", ",", "$", "lax", ")", "{", "// Decode JSON data.", "$", "structure", "=", "json_decode", "(", "$", "availability", ")", ";", "if", "(", "is_null", "(", "$", "structure", ")", ")", "{", "throw", "new", "\\", "coding_exception", "(", "'Invalid availability text'", ",", "$", "availability", ")", ";", "}", "// Recursively decode tree.", "return", "new", "tree", "(", "$", "structure", ",", "$", "lax", ")", ";", "}" ]
Decodes availability data from JSON format. This function also validates the retrieved data as follows: 1. Data that does not meet the API-defined structure causes a coding_exception (this should be impossible unless there is a system bug or somebody manually hacks the database). 2. Data that meets the structure but cannot be implemented (e.g. reference to missing plugin or to module that doesn't exist) is either silently discarded (if $lax is true) or causes a coding_exception (if $lax is false). @param string $availability Availability string in JSON format @param boolean $lax If true, throw exceptions only for invalid structure @return tree Availability tree @throws \coding_exception If data is not valid JSON format
[ "Decodes", "availability", "data", "from", "JSON", "format", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/availability/classes/info.php#L136-L145
214,918
moodle/moodle
availability/classes/info.php
info.is_available
public function is_available(&$information, $grabthelot = false, $userid = 0, \course_modinfo $modinfo = null) { global $USER; // Default to no information. $information = ''; // Do nothing if there are no availability restrictions. if (is_null($this->availability)) { return true; } // Resolve optional parameters. if (!$userid) { $userid = $USER->id; } if (!$modinfo) { $modinfo = get_fast_modinfo($this->course, $userid); } $this->modinfo = $modinfo; // Get availability from tree. try { $tree = $this->get_availability_tree(); $result = $tree->check_available(false, $this, $grabthelot, $userid); } catch (\coding_exception $e) { $this->warn_about_invalid_availability($e); $this->modinfo = null; return false; } // See if there are any messages. if ($result->is_available()) { $this->modinfo = null; return true; } else { // If the item is marked as 'not visible' then we don't change the available // flag (visible/available are treated distinctly), but we remove any // availability info. If the item is hidden with the eye icon, it doesn't // make sense to show 'Available from <date>' or similar, because even // when that date arrives it will still not be available unless somebody // toggles the eye icon. if ($this->visible) { $information = $tree->get_result_information($this, $result); } $this->modinfo = null; return false; } }
php
public function is_available(&$information, $grabthelot = false, $userid = 0, \course_modinfo $modinfo = null) { global $USER; // Default to no information. $information = ''; // Do nothing if there are no availability restrictions. if (is_null($this->availability)) { return true; } // Resolve optional parameters. if (!$userid) { $userid = $USER->id; } if (!$modinfo) { $modinfo = get_fast_modinfo($this->course, $userid); } $this->modinfo = $modinfo; // Get availability from tree. try { $tree = $this->get_availability_tree(); $result = $tree->check_available(false, $this, $grabthelot, $userid); } catch (\coding_exception $e) { $this->warn_about_invalid_availability($e); $this->modinfo = null; return false; } // See if there are any messages. if ($result->is_available()) { $this->modinfo = null; return true; } else { // If the item is marked as 'not visible' then we don't change the available // flag (visible/available are treated distinctly), but we remove any // availability info. If the item is hidden with the eye icon, it doesn't // make sense to show 'Available from <date>' or similar, because even // when that date arrives it will still not be available unless somebody // toggles the eye icon. if ($this->visible) { $information = $tree->get_result_information($this, $result); } $this->modinfo = null; return false; } }
[ "public", "function", "is_available", "(", "&", "$", "information", ",", "$", "grabthelot", "=", "false", ",", "$", "userid", "=", "0", ",", "\\", "course_modinfo", "$", "modinfo", "=", "null", ")", "{", "global", "$", "USER", ";", "// Default to no information.", "$", "information", "=", "''", ";", "// Do nothing if there are no availability restrictions.", "if", "(", "is_null", "(", "$", "this", "->", "availability", ")", ")", "{", "return", "true", ";", "}", "// Resolve optional parameters.", "if", "(", "!", "$", "userid", ")", "{", "$", "userid", "=", "$", "USER", "->", "id", ";", "}", "if", "(", "!", "$", "modinfo", ")", "{", "$", "modinfo", "=", "get_fast_modinfo", "(", "$", "this", "->", "course", ",", "$", "userid", ")", ";", "}", "$", "this", "->", "modinfo", "=", "$", "modinfo", ";", "// Get availability from tree.", "try", "{", "$", "tree", "=", "$", "this", "->", "get_availability_tree", "(", ")", ";", "$", "result", "=", "$", "tree", "->", "check_available", "(", "false", ",", "$", "this", ",", "$", "grabthelot", ",", "$", "userid", ")", ";", "}", "catch", "(", "\\", "coding_exception", "$", "e", ")", "{", "$", "this", "->", "warn_about_invalid_availability", "(", "$", "e", ")", ";", "$", "this", "->", "modinfo", "=", "null", ";", "return", "false", ";", "}", "// See if there are any messages.", "if", "(", "$", "result", "->", "is_available", "(", ")", ")", "{", "$", "this", "->", "modinfo", "=", "null", ";", "return", "true", ";", "}", "else", "{", "// If the item is marked as 'not visible' then we don't change the available", "// flag (visible/available are treated distinctly), but we remove any", "// availability info. If the item is hidden with the eye icon, it doesn't", "// make sense to show 'Available from <date>' or similar, because even", "// when that date arrives it will still not be available unless somebody", "// toggles the eye icon.", "if", "(", "$", "this", "->", "visible", ")", "{", "$", "information", "=", "$", "tree", "->", "get_result_information", "(", "$", "this", ",", "$", "result", ")", ";", "}", "$", "this", "->", "modinfo", "=", "null", ";", "return", "false", ";", "}", "}" ]
Determines whether this particular item is currently available according to the availability criteria. - This does not include the 'visible' setting (i.e. this might return true even if visible is false); visible is handled independently. - This does not take account of the viewhiddenactivities capability. That should apply later. Depending on options selected, a description of the restrictions which mean the student can't view it (in HTML format) may be stored in $information. If there is nothing in $information and this function returns false, then the activity should not be displayed at all. This function displays debugging() messages if the availability information is invalid. @param string $information String describing restrictions in HTML format @param bool $grabthelot Performance hint: if true, caches information required for all course-modules, to make the front page and similar pages work more quickly (works only for current user) @param int $userid If set, specifies a different user ID to check availability for @param \course_modinfo $modinfo Usually leave as null for default. Specify when calling recursively from inside get_fast_modinfo() @return bool True if this item is available to the user, false otherwise
[ "Determines", "whether", "this", "particular", "item", "is", "currently", "available", "according", "to", "the", "availability", "criteria", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/availability/classes/info.php#L173-L222
214,919
moodle/moodle
availability/classes/info.php
info.is_available_for_all
public function is_available_for_all() { if (is_null($this->availability)) { return true; } else { try { return $this->get_availability_tree()->is_available_for_all(); } catch (\coding_exception $e) { $this->warn_about_invalid_availability($e); return false; } } }
php
public function is_available_for_all() { if (is_null($this->availability)) { return true; } else { try { return $this->get_availability_tree()->is_available_for_all(); } catch (\coding_exception $e) { $this->warn_about_invalid_availability($e); return false; } } }
[ "public", "function", "is_available_for_all", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "availability", ")", ")", "{", "return", "true", ";", "}", "else", "{", "try", "{", "return", "$", "this", "->", "get_availability_tree", "(", ")", "->", "is_available_for_all", "(", ")", ";", "}", "catch", "(", "\\", "coding_exception", "$", "e", ")", "{", "$", "this", "->", "warn_about_invalid_availability", "(", "$", "e", ")", ";", "return", "false", ";", "}", "}", "}" ]
Checks whether this activity is going to be available for all users. Normally, if there are any conditions, then it may be hidden depending on the user. However in the case of date conditions there are some conditions which will definitely not result in it being hidden for anyone. @return bool True if activity is available for all
[ "Checks", "whether", "this", "activity", "is", "going", "to", "be", "available", "for", "all", "users", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/availability/classes/info.php#L234-L245
214,920
moodle/moodle
availability/classes/info.php
info.warn_about_invalid_availability
protected function warn_about_invalid_availability(\coding_exception $e) { $name = $this->get_thing_name(); // If it occurs while building modinfo based on somebody calling $cm->name, // we can't get $cm->name, and this line will cause a warning. $htmlname = @$this->format_info($name, $this->course); if ($htmlname === '') { // So instead use the numbers (cmid) from the tag. $htmlname = preg_replace('~[^0-9]~', '', $name); } $info = 'Error processing availability data for &lsquo;' . $htmlname . '&rsquo;: ' . s($e->a); debugging($info, DEBUG_DEVELOPER); }
php
protected function warn_about_invalid_availability(\coding_exception $e) { $name = $this->get_thing_name(); // If it occurs while building modinfo based on somebody calling $cm->name, // we can't get $cm->name, and this line will cause a warning. $htmlname = @$this->format_info($name, $this->course); if ($htmlname === '') { // So instead use the numbers (cmid) from the tag. $htmlname = preg_replace('~[^0-9]~', '', $name); } $info = 'Error processing availability data for &lsquo;' . $htmlname . '&rsquo;: ' . s($e->a); debugging($info, DEBUG_DEVELOPER); }
[ "protected", "function", "warn_about_invalid_availability", "(", "\\", "coding_exception", "$", "e", ")", "{", "$", "name", "=", "$", "this", "->", "get_thing_name", "(", ")", ";", "// If it occurs while building modinfo based on somebody calling $cm->name,", "// we can't get $cm->name, and this line will cause a warning.", "$", "htmlname", "=", "@", "$", "this", "->", "format_info", "(", "$", "name", ",", "$", "this", "->", "course", ")", ";", "if", "(", "$", "htmlname", "===", "''", ")", "{", "// So instead use the numbers (cmid) from the tag.", "$", "htmlname", "=", "preg_replace", "(", "'~[^0-9]~'", ",", "''", ",", "$", "name", ")", ";", "}", "$", "info", "=", "'Error processing availability data for &lsquo;'", ".", "$", "htmlname", ".", "'&rsquo;: '", ".", "s", "(", "$", "e", "->", "a", ")", ";", "debugging", "(", "$", "info", ",", "DEBUG_DEVELOPER", ")", ";", "}" ]
In some places we catch coding_exception because if a bug happens, it would be fatal for the course page GUI; instead we just show a developer debug message. @param \coding_exception $e Exception that occurred
[ "In", "some", "places", "we", "catch", "coding_exception", "because", "if", "a", "bug", "happens", "it", "would", "be", "fatal", "for", "the", "course", "page", "GUI", ";", "instead", "we", "just", "show", "a", "developer", "debug", "message", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/availability/classes/info.php#L291-L303
214,921
moodle/moodle
availability/classes/info.php
info.update_dependency_id
protected function update_dependency_id($table, $oldid, $newid) { // Do nothing if there are no availability restrictions. if (is_null($this->availability)) { return false; } // Pass requirement on to tree object. $tree = $this->get_availability_tree(); $changed = $tree->update_dependency_id($table, $oldid, $newid); if ($changed) { // Save modified data. $structure = $tree->save(); $this->set_in_database(json_encode($structure)); } return $changed; }
php
protected function update_dependency_id($table, $oldid, $newid) { // Do nothing if there are no availability restrictions. if (is_null($this->availability)) { return false; } // Pass requirement on to tree object. $tree = $this->get_availability_tree(); $changed = $tree->update_dependency_id($table, $oldid, $newid); if ($changed) { // Save modified data. $structure = $tree->save(); $this->set_in_database(json_encode($structure)); } return $changed; }
[ "protected", "function", "update_dependency_id", "(", "$", "table", ",", "$", "oldid", ",", "$", "newid", ")", "{", "// Do nothing if there are no availability restrictions.", "if", "(", "is_null", "(", "$", "this", "->", "availability", ")", ")", "{", "return", "false", ";", "}", "// Pass requirement on to tree object.", "$", "tree", "=", "$", "this", "->", "get_availability_tree", "(", ")", ";", "$", "changed", "=", "$", "tree", "->", "update_dependency_id", "(", "$", "table", ",", "$", "oldid", ",", "$", "newid", ")", ";", "if", "(", "$", "changed", ")", "{", "// Save modified data.", "$", "structure", "=", "$", "tree", "->", "save", "(", ")", ";", "$", "this", "->", "set_in_database", "(", "json_encode", "(", "$", "structure", ")", ")", ";", "}", "return", "$", "changed", ";", "}" ]
Called on a single item. If necessary, updates availability data where it has a dependency on an item with a particular id. @param string $table Table name e.g. 'course_modules' @param int $oldid Previous ID @param int $newid New ID @return bool True if it changed, otherwise false
[ "Called", "on", "a", "single", "item", ".", "If", "necessary", "updates", "availability", "data", "where", "it", "has", "a", "dependency", "on", "an", "item", "with", "a", "particular", "id", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/availability/classes/info.php#L433-L447
214,922
moodle/moodle
availability/classes/info.php
info.add_legacy_availability_condition
public static function add_legacy_availability_condition($availability, $rec, $show) { if (!empty($rec->sourcecmid)) { // Completion condition. $condition = '{"type":"completion","cm":' . $rec->sourcecmid . ',"e":' . $rec->requiredcompletion . '}'; } else { // Grade condition. $minmax = ''; if (!empty($rec->grademin)) { $minmax .= ',"min":' . sprintf('%.5f', $rec->grademin); } if (!empty($rec->grademax)) { $minmax .= ',"max":' . sprintf('%.5f', $rec->grademax); } $condition = '{"type":"grade","id":' . $rec->gradeitemid . $minmax . '}'; } return self::add_legacy_condition($availability, $condition, $show); }
php
public static function add_legacy_availability_condition($availability, $rec, $show) { if (!empty($rec->sourcecmid)) { // Completion condition. $condition = '{"type":"completion","cm":' . $rec->sourcecmid . ',"e":' . $rec->requiredcompletion . '}'; } else { // Grade condition. $minmax = ''; if (!empty($rec->grademin)) { $minmax .= ',"min":' . sprintf('%.5f', $rec->grademin); } if (!empty($rec->grademax)) { $minmax .= ',"max":' . sprintf('%.5f', $rec->grademax); } $condition = '{"type":"grade","id":' . $rec->gradeitemid . $minmax . '}'; } return self::add_legacy_condition($availability, $condition, $show); }
[ "public", "static", "function", "add_legacy_availability_condition", "(", "$", "availability", ",", "$", "rec", ",", "$", "show", ")", "{", "if", "(", "!", "empty", "(", "$", "rec", "->", "sourcecmid", ")", ")", "{", "// Completion condition.", "$", "condition", "=", "'{\"type\":\"completion\",\"cm\":'", ".", "$", "rec", "->", "sourcecmid", ".", "',\"e\":'", ".", "$", "rec", "->", "requiredcompletion", ".", "'}'", ";", "}", "else", "{", "// Grade condition.", "$", "minmax", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "rec", "->", "grademin", ")", ")", "{", "$", "minmax", ".=", "',\"min\":'", ".", "sprintf", "(", "'%.5f'", ",", "$", "rec", "->", "grademin", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "rec", "->", "grademax", ")", ")", "{", "$", "minmax", ".=", "',\"max\":'", ".", "sprintf", "(", "'%.5f'", ",", "$", "rec", "->", "grademax", ")", ";", "}", "$", "condition", "=", "'{\"type\":\"grade\",\"id\":'", ".", "$", "rec", "->", "gradeitemid", ".", "$", "minmax", ".", "'}'", ";", "}", "return", "self", "::", "add_legacy_condition", "(", "$", "availability", ",", "$", "condition", ",", "$", "show", ")", ";", "}" ]
Adds a condition from the legacy availability condition. (For use during restore only.) This function assumes that the activity either has no conditions, or that it has an AND tree with one or more conditions. @param string|null $availability Current availability conditions @param \stdClass $rec Object containing information from old table @param bool $show True if 'show' option should be enabled @return string New availability conditions
[ "Adds", "a", "condition", "from", "the", "legacy", "availability", "condition", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/availability/classes/info.php#L525-L543
214,923
moodle/moodle
availability/classes/info.php
info.add_legacy_availability_field_condition
public static function add_legacy_availability_field_condition($availability, $rec, $show) { if (isset($rec->userfield)) { // Standard field. $fieldbit = ',"sf":' . json_encode($rec->userfield); } else { // Custom field. $fieldbit = ',"cf":' . json_encode($rec->shortname); } // Value is not included for certain operators. switch($rec->operator) { case 'isempty': case 'isnotempty': $valuebit = ''; break; default: $valuebit = ',"v":' . json_encode($rec->value); break; } $condition = '{"type":"profile","op":"' . $rec->operator . '"' . $fieldbit . $valuebit . '}'; return self::add_legacy_condition($availability, $condition, $show); }
php
public static function add_legacy_availability_field_condition($availability, $rec, $show) { if (isset($rec->userfield)) { // Standard field. $fieldbit = ',"sf":' . json_encode($rec->userfield); } else { // Custom field. $fieldbit = ',"cf":' . json_encode($rec->shortname); } // Value is not included for certain operators. switch($rec->operator) { case 'isempty': case 'isnotempty': $valuebit = ''; break; default: $valuebit = ',"v":' . json_encode($rec->value); break; } $condition = '{"type":"profile","op":"' . $rec->operator . '"' . $fieldbit . $valuebit . '}'; return self::add_legacy_condition($availability, $condition, $show); }
[ "public", "static", "function", "add_legacy_availability_field_condition", "(", "$", "availability", ",", "$", "rec", ",", "$", "show", ")", "{", "if", "(", "isset", "(", "$", "rec", "->", "userfield", ")", ")", "{", "// Standard field.", "$", "fieldbit", "=", "',\"sf\":'", ".", "json_encode", "(", "$", "rec", "->", "userfield", ")", ";", "}", "else", "{", "// Custom field.", "$", "fieldbit", "=", "',\"cf\":'", ".", "json_encode", "(", "$", "rec", "->", "shortname", ")", ";", "}", "// Value is not included for certain operators.", "switch", "(", "$", "rec", "->", "operator", ")", "{", "case", "'isempty'", ":", "case", "'isnotempty'", ":", "$", "valuebit", "=", "''", ";", "break", ";", "default", ":", "$", "valuebit", "=", "',\"v\":'", ".", "json_encode", "(", "$", "rec", "->", "value", ")", ";", "break", ";", "}", "$", "condition", "=", "'{\"type\":\"profile\",\"op\":\"'", ".", "$", "rec", "->", "operator", ".", "'\"'", ".", "$", "fieldbit", ".", "$", "valuebit", ".", "'}'", ";", "return", "self", "::", "add_legacy_condition", "(", "$", "availability", ",", "$", "condition", ",", "$", "show", ")", ";", "}" ]
Adds a condition from the legacy availability field condition. (For use during restore only.) This function assumes that the activity either has no conditions, or that it has an AND tree with one or more conditions. @param string|null $availability Current availability conditions @param \stdClass $rec Object containing information from old table @param bool $show True if 'show' option should be enabled @return string New availability conditions
[ "Adds", "a", "condition", "from", "the", "legacy", "availability", "field", "condition", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/availability/classes/info.php#L558-L581
214,924
moodle/moodle
availability/classes/info.php
info.add_legacy_condition
protected static function add_legacy_condition($availability, $condition, $show) { $showtext = ($show ? 'true' : 'false'); if (is_null($availability)) { $availability = '{"op":"&","showc":[' . $showtext . '],"c":[' . $condition . ']}'; } else { $matches = array(); if (!preg_match('~^({"op":"&","showc":\[(?:true|false)(?:,(?:true|false))*)' . '(\],"c":\[.*)(\]})$~', $availability, $matches)) { throw new \coding_exception('Unexpected availability value'); } $availability = $matches[1] . ',' . $showtext . $matches[2] . ',' . $condition . $matches[3]; } return $availability; }
php
protected static function add_legacy_condition($availability, $condition, $show) { $showtext = ($show ? 'true' : 'false'); if (is_null($availability)) { $availability = '{"op":"&","showc":[' . $showtext . '],"c":[' . $condition . ']}'; } else { $matches = array(); if (!preg_match('~^({"op":"&","showc":\[(?:true|false)(?:,(?:true|false))*)' . '(\],"c":\[.*)(\]})$~', $availability, $matches)) { throw new \coding_exception('Unexpected availability value'); } $availability = $matches[1] . ',' . $showtext . $matches[2] . ',' . $condition . $matches[3]; } return $availability; }
[ "protected", "static", "function", "add_legacy_condition", "(", "$", "availability", ",", "$", "condition", ",", "$", "show", ")", "{", "$", "showtext", "=", "(", "$", "show", "?", "'true'", ":", "'false'", ")", ";", "if", "(", "is_null", "(", "$", "availability", ")", ")", "{", "$", "availability", "=", "'{\"op\":\"&\",\"showc\":['", ".", "$", "showtext", ".", "'],\"c\":['", ".", "$", "condition", ".", "']}'", ";", "}", "else", "{", "$", "matches", "=", "array", "(", ")", ";", "if", "(", "!", "preg_match", "(", "'~^({\"op\":\"&\",\"showc\":\\[(?:true|false)(?:,(?:true|false))*)'", ".", "'(\\],\"c\":\\[.*)(\\]})$~'", ",", "$", "availability", ",", "$", "matches", ")", ")", "{", "throw", "new", "\\", "coding_exception", "(", "'Unexpected availability value'", ")", ";", "}", "$", "availability", "=", "$", "matches", "[", "1", "]", ".", "','", ".", "$", "showtext", ".", "$", "matches", "[", "2", "]", ".", "','", ".", "$", "condition", ".", "$", "matches", "[", "3", "]", ";", "}", "return", "$", "availability", ";", "}" ]
Adds a condition to an AND group. (For use during restore only.) This function assumes that the activity either has no conditions, or that it has only conditions added by this function. @param string|null $availability Current availability conditions @param string $condition Condition text '{...}' @param bool $show True if 'show' option should be enabled @return string New availability conditions
[ "Adds", "a", "condition", "to", "an", "AND", "group", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/availability/classes/info.php#L596-L611
214,925
moodle/moodle
mod/assign/locallib.php
assign.register_return_link
public function register_return_link($action, $params) { global $PAGE; $params['action'] = $action; $cm = $this->get_course_module(); if ($cm) { $currenturl = new moodle_url('/mod/assign/view.php', array('id' => $cm->id)); } else { $currenturl = new moodle_url('/mod/assign/index.php', array('id' => $this->get_course()->id)); } $currenturl->params($params); $PAGE->set_url($currenturl); }
php
public function register_return_link($action, $params) { global $PAGE; $params['action'] = $action; $cm = $this->get_course_module(); if ($cm) { $currenturl = new moodle_url('/mod/assign/view.php', array('id' => $cm->id)); } else { $currenturl = new moodle_url('/mod/assign/index.php', array('id' => $this->get_course()->id)); } $currenturl->params($params); $PAGE->set_url($currenturl); }
[ "public", "function", "register_return_link", "(", "$", "action", ",", "$", "params", ")", "{", "global", "$", "PAGE", ";", "$", "params", "[", "'action'", "]", "=", "$", "action", ";", "$", "cm", "=", "$", "this", "->", "get_course_module", "(", ")", ";", "if", "(", "$", "cm", ")", "{", "$", "currenturl", "=", "new", "moodle_url", "(", "'/mod/assign/view.php'", ",", "array", "(", "'id'", "=>", "$", "cm", "->", "id", ")", ")", ";", "}", "else", "{", "$", "currenturl", "=", "new", "moodle_url", "(", "'/mod/assign/index.php'", ",", "array", "(", "'id'", "=>", "$", "this", "->", "get_course", "(", ")", "->", "id", ")", ")", ";", "}", "$", "currenturl", "->", "params", "(", "$", "params", ")", ";", "$", "PAGE", "->", "set_url", "(", "$", "currenturl", ")", ";", "}" ]
Set the action and parameters that can be used to return to the current page. @param string $action The action for the current page @param array $params An array of name value pairs which form the parameters to return to the current page. @return void
[ "Set", "the", "action", "and", "parameters", "that", "can", "be", "used", "to", "return", "to", "the", "current", "page", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L224-L236
214,926
moodle/moodle
mod/assign/locallib.php
assign.get_return_action
public function get_return_action() { global $PAGE; // Web services don't set a URL, we should avoid debugging when ussing the url object. if (!WS_SERVER) { $params = $PAGE->url->params(); } if (!empty($params['action'])) { return $params['action']; } return ''; }
php
public function get_return_action() { global $PAGE; // Web services don't set a URL, we should avoid debugging when ussing the url object. if (!WS_SERVER) { $params = $PAGE->url->params(); } if (!empty($params['action'])) { return $params['action']; } return ''; }
[ "public", "function", "get_return_action", "(", ")", "{", "global", "$", "PAGE", ";", "// Web services don't set a URL, we should avoid debugging when ussing the url object.", "if", "(", "!", "WS_SERVER", ")", "{", "$", "params", "=", "$", "PAGE", "->", "url", "->", "params", "(", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "params", "[", "'action'", "]", ")", ")", "{", "return", "$", "params", "[", "'action'", "]", ";", "}", "return", "''", ";", "}" ]
Return an action that can be used to get back to the current page. @return string action
[ "Return", "an", "action", "that", "can", "be", "used", "to", "get", "back", "to", "the", "current", "page", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L243-L255
214,927
moodle/moodle
mod/assign/locallib.php
assign.show_intro
public function show_intro() { if ($this->get_instance()->alwaysshowdescription || time() > $this->get_instance()->allowsubmissionsfromdate) { return true; } return false; }
php
public function show_intro() { if ($this->get_instance()->alwaysshowdescription || time() > $this->get_instance()->allowsubmissionsfromdate) { return true; } return false; }
[ "public", "function", "show_intro", "(", ")", "{", "if", "(", "$", "this", "->", "get_instance", "(", ")", "->", "alwaysshowdescription", "||", "time", "(", ")", ">", "$", "this", "->", "get_instance", "(", ")", "->", "allowsubmissionsfromdate", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Based on the current assignment settings should we display the intro. @return bool showintro
[ "Based", "on", "the", "current", "assignment", "settings", "should", "we", "display", "the", "intro", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L262-L268
214,928
moodle/moodle
mod/assign/locallib.php
assign.get_return_params
public function get_return_params() { global $PAGE; $params = array(); if (!WS_SERVER) { $params = $PAGE->url->params(); } unset($params['id']); unset($params['action']); return $params; }
php
public function get_return_params() { global $PAGE; $params = array(); if (!WS_SERVER) { $params = $PAGE->url->params(); } unset($params['id']); unset($params['action']); return $params; }
[ "public", "function", "get_return_params", "(", ")", "{", "global", "$", "PAGE", ";", "$", "params", "=", "array", "(", ")", ";", "if", "(", "!", "WS_SERVER", ")", "{", "$", "params", "=", "$", "PAGE", "->", "url", "->", "params", "(", ")", ";", "}", "unset", "(", "$", "params", "[", "'id'", "]", ")", ";", "unset", "(", "$", "params", "[", "'action'", "]", ")", ";", "return", "$", "params", ";", "}" ]
Return a list of parameters that can be used to get back to the current page. @return array params
[ "Return", "a", "list", "of", "parameters", "that", "can", "be", "used", "to", "get", "back", "to", "the", "current", "page", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L275-L285
214,929
moodle/moodle
mod/assign/locallib.php
assign.get_plugin_by_type
public function get_plugin_by_type($subtype, $type) { $shortsubtype = substr($subtype, strlen('assign')); $name = $shortsubtype . 'plugins'; if ($name != 'feedbackplugins' && $name != 'submissionplugins') { return null; } $pluginlist = $this->$name; foreach ($pluginlist as $plugin) { if ($plugin->get_type() == $type) { return $plugin; } } return null; }
php
public function get_plugin_by_type($subtype, $type) { $shortsubtype = substr($subtype, strlen('assign')); $name = $shortsubtype . 'plugins'; if ($name != 'feedbackplugins' && $name != 'submissionplugins') { return null; } $pluginlist = $this->$name; foreach ($pluginlist as $plugin) { if ($plugin->get_type() == $type) { return $plugin; } } return null; }
[ "public", "function", "get_plugin_by_type", "(", "$", "subtype", ",", "$", "type", ")", "{", "$", "shortsubtype", "=", "substr", "(", "$", "subtype", ",", "strlen", "(", "'assign'", ")", ")", ";", "$", "name", "=", "$", "shortsubtype", ".", "'plugins'", ";", "if", "(", "$", "name", "!=", "'feedbackplugins'", "&&", "$", "name", "!=", "'submissionplugins'", ")", "{", "return", "null", ";", "}", "$", "pluginlist", "=", "$", "this", "->", "$", "name", ";", "foreach", "(", "$", "pluginlist", "as", "$", "plugin", ")", "{", "if", "(", "$", "plugin", "->", "get_type", "(", ")", "==", "$", "type", ")", "{", "return", "$", "plugin", ";", "}", "}", "return", "null", ";", "}" ]
Get a specific submission plugin by its type. @param string $subtype assignsubmission | assignfeedback @param string $type @return mixed assign_plugin|null
[ "Get", "a", "specific", "submission", "plugin", "by", "its", "type", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L374-L387
214,930
moodle/moodle
mod/assign/locallib.php
assign.load_plugins
public function load_plugins($subtype) { global $CFG; $result = array(); $names = core_component::get_plugin_list($subtype); foreach ($names as $name => $path) { if (file_exists($path . '/locallib.php')) { require_once($path . '/locallib.php'); $shortsubtype = substr($subtype, strlen('assign')); $pluginclass = 'assign_' . $shortsubtype . '_' . $name; $plugin = new $pluginclass($this, $name); if ($plugin instanceof assign_plugin) { $idx = $plugin->get_sort_order(); while (array_key_exists($idx, $result)) { $idx +=1; } $result[$idx] = $plugin; } } } ksort($result); return $result; }
php
public function load_plugins($subtype) { global $CFG; $result = array(); $names = core_component::get_plugin_list($subtype); foreach ($names as $name => $path) { if (file_exists($path . '/locallib.php')) { require_once($path . '/locallib.php'); $shortsubtype = substr($subtype, strlen('assign')); $pluginclass = 'assign_' . $shortsubtype . '_' . $name; $plugin = new $pluginclass($this, $name); if ($plugin instanceof assign_plugin) { $idx = $plugin->get_sort_order(); while (array_key_exists($idx, $result)) { $idx +=1; } $result[$idx] = $plugin; } } } ksort($result); return $result; }
[ "public", "function", "load_plugins", "(", "$", "subtype", ")", "{", "global", "$", "CFG", ";", "$", "result", "=", "array", "(", ")", ";", "$", "names", "=", "core_component", "::", "get_plugin_list", "(", "$", "subtype", ")", ";", "foreach", "(", "$", "names", "as", "$", "name", "=>", "$", "path", ")", "{", "if", "(", "file_exists", "(", "$", "path", ".", "'/locallib.php'", ")", ")", "{", "require_once", "(", "$", "path", ".", "'/locallib.php'", ")", ";", "$", "shortsubtype", "=", "substr", "(", "$", "subtype", ",", "strlen", "(", "'assign'", ")", ")", ";", "$", "pluginclass", "=", "'assign_'", ".", "$", "shortsubtype", ".", "'_'", ".", "$", "name", ";", "$", "plugin", "=", "new", "$", "pluginclass", "(", "$", "this", ",", "$", "name", ")", ";", "if", "(", "$", "plugin", "instanceof", "assign_plugin", ")", "{", "$", "idx", "=", "$", "plugin", "->", "get_sort_order", "(", ")", ";", "while", "(", "array_key_exists", "(", "$", "idx", ",", "$", "result", ")", ")", "{", "$", "idx", "+=", "1", ";", "}", "$", "result", "[", "$", "idx", "]", "=", "$", "plugin", ";", "}", "}", "}", "ksort", "(", "$", "result", ")", ";", "return", "$", "result", ";", "}" ]
Load the plugins from the sub folders under subtype. @param string $subtype - either submission or feedback @return array - The sorted list of plugins
[ "Load", "the", "plugins", "from", "the", "sub", "folders", "under", "subtype", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L415-L441
214,931
moodle/moodle
mod/assign/locallib.php
assign.delete_grades
protected function delete_grades() { global $CFG; $result = grade_update('mod/assign', $this->get_course()->id, 'mod', 'assign', $this->get_instance()->id, 0, null, array('deleted'=>1)); return $result == GRADE_UPDATE_OK; }
php
protected function delete_grades() { global $CFG; $result = grade_update('mod/assign', $this->get_course()->id, 'mod', 'assign', $this->get_instance()->id, 0, null, array('deleted'=>1)); return $result == GRADE_UPDATE_OK; }
[ "protected", "function", "delete_grades", "(", ")", "{", "global", "$", "CFG", ";", "$", "result", "=", "grade_update", "(", "'mod/assign'", ",", "$", "this", "->", "get_course", "(", ")", "->", "id", ",", "'mod'", ",", "'assign'", ",", "$", "this", "->", "get_instance", "(", ")", "->", "id", ",", "0", ",", "null", ",", "array", "(", "'deleted'", "=>", "1", ")", ")", ";", "return", "$", "result", "==", "GRADE_UPDATE_OK", ";", "}" ]
Delete all grades from the gradebook for this assignment. @return bool
[ "Delete", "all", "grades", "from", "the", "gradebook", "for", "this", "assignment", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L759-L771
214,932
moodle/moodle
mod/assign/locallib.php
assign.update_effective_access
public function update_effective_access($userid) { $override = $this->override_exists($userid); // Merge with assign defaults. $keys = array('duedate', 'cutoffdate', 'allowsubmissionsfromdate'); foreach ($keys as $key) { if (isset($override->{$key})) { $this->get_instance()->{$key} = $override->{$key}; } } }
php
public function update_effective_access($userid) { $override = $this->override_exists($userid); // Merge with assign defaults. $keys = array('duedate', 'cutoffdate', 'allowsubmissionsfromdate'); foreach ($keys as $key) { if (isset($override->{$key})) { $this->get_instance()->{$key} = $override->{$key}; } } }
[ "public", "function", "update_effective_access", "(", "$", "userid", ")", "{", "$", "override", "=", "$", "this", "->", "override_exists", "(", "$", "userid", ")", ";", "// Merge with assign defaults.", "$", "keys", "=", "array", "(", "'duedate'", ",", "'cutoffdate'", ",", "'allowsubmissionsfromdate'", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "isset", "(", "$", "override", "->", "{", "$", "key", "}", ")", ")", "{", "$", "this", "->", "get_instance", "(", ")", "->", "{", "$", "key", "}", "=", "$", "override", "->", "{", "$", "key", "}", ";", "}", "}", "}" ]
Updates the assign properties with override information for a user. Algorithm: For each assign setting, if there is a matching user-specific override, then use that otherwise, if there are group-specific overrides, return the most lenient combination of them. If neither applies, leave the assign setting unchanged. @param int $userid The userid.
[ "Updates", "the", "assign", "properties", "with", "override", "information", "for", "a", "user", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L901-L913
214,933
moodle/moodle
mod/assign/locallib.php
assign.has_overrides
public function has_overrides() { global $DB; $override = $DB->record_exists('assign_overrides', array('assignid' => $this->get_instance()->id)); if ($override) { return true; } return false; }
php
public function has_overrides() { global $DB; $override = $DB->record_exists('assign_overrides', array('assignid' => $this->get_instance()->id)); if ($override) { return true; } return false; }
[ "public", "function", "has_overrides", "(", ")", "{", "global", "$", "DB", ";", "$", "override", "=", "$", "DB", "->", "record_exists", "(", "'assign_overrides'", ",", "array", "(", "'assignid'", "=>", "$", "this", "->", "get_instance", "(", ")", "->", "id", ")", ")", ";", "if", "(", "$", "override", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Returns whether an assign has any overrides. @return true if any, false if not
[ "Returns", "whether", "an", "assign", "has", "any", "overrides", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L920-L930
214,934
moodle/moodle
mod/assign/locallib.php
assign.override_exists
public function override_exists($userid) { global $DB; // Gets an assoc array containing the keys for defined user overrides only. $getuseroverride = function($userid) use ($DB) { $useroverride = $DB->get_record('assign_overrides', ['assignid' => $this->get_instance()->id, 'userid' => $userid]); return $useroverride ? get_object_vars($useroverride) : []; }; // Gets an assoc array containing the keys for defined group overrides only. $getgroupoverride = function($userid) use ($DB) { $groupings = groups_get_user_groups($this->get_instance()->course, $userid); if (empty($groupings[0])) { return []; } // Select all overrides that apply to the User's groups. list($extra, $params) = $DB->get_in_or_equal(array_values($groupings[0])); $sql = "SELECT * FROM {assign_overrides} WHERE groupid $extra AND assignid = ? ORDER BY sortorder ASC"; $params[] = $this->get_instance()->id; $groupoverride = $DB->get_record_sql($sql, $params, IGNORE_MULTIPLE); return $groupoverride ? get_object_vars($groupoverride) : []; }; // Later arguments clobber earlier ones with array_merge. The two helper functions // return arrays containing keys for only the defined overrides. So we get the // desired behaviour as per the algorithm. return (object)array_merge( ['duedate' => null, 'cutoffdate' => null, 'allowsubmissionsfromdate' => null], $getgroupoverride($userid), $getuseroverride($userid) ); }
php
public function override_exists($userid) { global $DB; // Gets an assoc array containing the keys for defined user overrides only. $getuseroverride = function($userid) use ($DB) { $useroverride = $DB->get_record('assign_overrides', ['assignid' => $this->get_instance()->id, 'userid' => $userid]); return $useroverride ? get_object_vars($useroverride) : []; }; // Gets an assoc array containing the keys for defined group overrides only. $getgroupoverride = function($userid) use ($DB) { $groupings = groups_get_user_groups($this->get_instance()->course, $userid); if (empty($groupings[0])) { return []; } // Select all overrides that apply to the User's groups. list($extra, $params) = $DB->get_in_or_equal(array_values($groupings[0])); $sql = "SELECT * FROM {assign_overrides} WHERE groupid $extra AND assignid = ? ORDER BY sortorder ASC"; $params[] = $this->get_instance()->id; $groupoverride = $DB->get_record_sql($sql, $params, IGNORE_MULTIPLE); return $groupoverride ? get_object_vars($groupoverride) : []; }; // Later arguments clobber earlier ones with array_merge. The two helper functions // return arrays containing keys for only the defined overrides. So we get the // desired behaviour as per the algorithm. return (object)array_merge( ['duedate' => null, 'cutoffdate' => null, 'allowsubmissionsfromdate' => null], $getgroupoverride($userid), $getuseroverride($userid) ); }
[ "public", "function", "override_exists", "(", "$", "userid", ")", "{", "global", "$", "DB", ";", "// Gets an assoc array containing the keys for defined user overrides only.", "$", "getuseroverride", "=", "function", "(", "$", "userid", ")", "use", "(", "$", "DB", ")", "{", "$", "useroverride", "=", "$", "DB", "->", "get_record", "(", "'assign_overrides'", ",", "[", "'assignid'", "=>", "$", "this", "->", "get_instance", "(", ")", "->", "id", ",", "'userid'", "=>", "$", "userid", "]", ")", ";", "return", "$", "useroverride", "?", "get_object_vars", "(", "$", "useroverride", ")", ":", "[", "]", ";", "}", ";", "// Gets an assoc array containing the keys for defined group overrides only.", "$", "getgroupoverride", "=", "function", "(", "$", "userid", ")", "use", "(", "$", "DB", ")", "{", "$", "groupings", "=", "groups_get_user_groups", "(", "$", "this", "->", "get_instance", "(", ")", "->", "course", ",", "$", "userid", ")", ";", "if", "(", "empty", "(", "$", "groupings", "[", "0", "]", ")", ")", "{", "return", "[", "]", ";", "}", "// Select all overrides that apply to the User's groups.", "list", "(", "$", "extra", ",", "$", "params", ")", "=", "$", "DB", "->", "get_in_or_equal", "(", "array_values", "(", "$", "groupings", "[", "0", "]", ")", ")", ";", "$", "sql", "=", "\"SELECT * FROM {assign_overrides}\n WHERE groupid $extra AND assignid = ? ORDER BY sortorder ASC\"", ";", "$", "params", "[", "]", "=", "$", "this", "->", "get_instance", "(", ")", "->", "id", ";", "$", "groupoverride", "=", "$", "DB", "->", "get_record_sql", "(", "$", "sql", ",", "$", "params", ",", "IGNORE_MULTIPLE", ")", ";", "return", "$", "groupoverride", "?", "get_object_vars", "(", "$", "groupoverride", ")", ":", "[", "]", ";", "}", ";", "// Later arguments clobber earlier ones with array_merge. The two helper functions", "// return arrays containing keys for only the defined overrides. So we get the", "// desired behaviour as per the algorithm.", "return", "(", "object", ")", "array_merge", "(", "[", "'duedate'", "=>", "null", ",", "'cutoffdate'", "=>", "null", ",", "'allowsubmissionsfromdate'", "=>", "null", "]", ",", "$", "getgroupoverride", "(", "$", "userid", ")", ",", "$", "getuseroverride", "(", "$", "userid", ")", ")", ";", "}" ]
Returns user override Algorithm: For each assign setting, if there is a matching user-specific override, then use that otherwise, if there are group-specific overrides, use the one with the lowest sort order. If neither applies, leave the assign setting unchanged. @param int $userid The userid. @return stdClass The override
[ "Returns", "user", "override" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L942-L977
214,935
moodle/moodle
mod/assign/locallib.php
assign.is_override_calendar_event
public function is_override_calendar_event(\calendar_event $event) { global $DB; if (!isset($event->modulename)) { return false; } if ($event->modulename != 'assign') { return false; } if (!isset($event->instance)) { return false; } if (!isset($event->userid) && !isset($event->groupid)) { return false; } $overrideparams = [ 'assignid' => $event->instance ]; if (isset($event->groupid)) { $overrideparams['groupid'] = $event->groupid; } else if (isset($event->userid)) { $overrideparams['userid'] = $event->userid; } if ($DB->get_record('assign_overrides', $overrideparams)) { return true; } else { return false; } }
php
public function is_override_calendar_event(\calendar_event $event) { global $DB; if (!isset($event->modulename)) { return false; } if ($event->modulename != 'assign') { return false; } if (!isset($event->instance)) { return false; } if (!isset($event->userid) && !isset($event->groupid)) { return false; } $overrideparams = [ 'assignid' => $event->instance ]; if (isset($event->groupid)) { $overrideparams['groupid'] = $event->groupid; } else if (isset($event->userid)) { $overrideparams['userid'] = $event->userid; } if ($DB->get_record('assign_overrides', $overrideparams)) { return true; } else { return false; } }
[ "public", "function", "is_override_calendar_event", "(", "\\", "calendar_event", "$", "event", ")", "{", "global", "$", "DB", ";", "if", "(", "!", "isset", "(", "$", "event", "->", "modulename", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "event", "->", "modulename", "!=", "'assign'", ")", "{", "return", "false", ";", "}", "if", "(", "!", "isset", "(", "$", "event", "->", "instance", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "isset", "(", "$", "event", "->", "userid", ")", "&&", "!", "isset", "(", "$", "event", "->", "groupid", ")", ")", "{", "return", "false", ";", "}", "$", "overrideparams", "=", "[", "'assignid'", "=>", "$", "event", "->", "instance", "]", ";", "if", "(", "isset", "(", "$", "event", "->", "groupid", ")", ")", "{", "$", "overrideparams", "[", "'groupid'", "]", "=", "$", "event", "->", "groupid", ";", "}", "else", "if", "(", "isset", "(", "$", "event", "->", "userid", ")", ")", "{", "$", "overrideparams", "[", "'userid'", "]", "=", "$", "event", "->", "userid", ";", "}", "if", "(", "$", "DB", "->", "get_record", "(", "'assign_overrides'", ",", "$", "overrideparams", ")", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Check if the given calendar_event is either a user or group override event. @return bool
[ "Check", "if", "the", "given", "calendar_event", "is", "either", "a", "user", "or", "group", "override", "event", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L985-L1019
214,936
moodle/moodle
mod/assign/locallib.php
assign.get_valid_calendar_event_timestart_range
function get_valid_calendar_event_timestart_range(\calendar_event $event) { $instance = $this->get_instance(); $submissionsfromdate = $instance->allowsubmissionsfromdate; $cutoffdate = $instance->cutoffdate; $duedate = $instance->duedate; $gradingduedate = $instance->gradingduedate; $mindate = null; $maxdate = null; if ($event->eventtype == ASSIGN_EVENT_TYPE_DUE) { // This check is in here because due date events are currently // the only events that can be overridden, so we can save a DB // query if we don't bother checking other events. if ($this->is_override_calendar_event($event)) { // This is an override event so there is no valid timestart // range to set it to. return [false, false]; } if ($submissionsfromdate) { $mindate = [ $submissionsfromdate, get_string('duedatevalidation', 'assign'), ]; } if ($cutoffdate) { $maxdate = [ $cutoffdate, get_string('cutoffdatevalidation', 'assign'), ]; } if ($gradingduedate) { // If we don't have a cutoff date or we've got a grading due date // that is earlier than the cutoff then we should use that as the // upper limit for the due date. if (!$cutoffdate || $gradingduedate < $cutoffdate) { $maxdate = [ $gradingduedate, get_string('gradingdueduedatevalidation', 'assign'), ]; } } } else if ($event->eventtype == ASSIGN_EVENT_TYPE_GRADINGDUE) { if ($duedate) { $mindate = [ $duedate, get_string('gradingdueduedatevalidation', 'assign'), ]; } else if ($submissionsfromdate) { $mindate = [ $submissionsfromdate, get_string('gradingduefromdatevalidation', 'assign'), ]; } } return [$mindate, $maxdate]; }
php
function get_valid_calendar_event_timestart_range(\calendar_event $event) { $instance = $this->get_instance(); $submissionsfromdate = $instance->allowsubmissionsfromdate; $cutoffdate = $instance->cutoffdate; $duedate = $instance->duedate; $gradingduedate = $instance->gradingduedate; $mindate = null; $maxdate = null; if ($event->eventtype == ASSIGN_EVENT_TYPE_DUE) { // This check is in here because due date events are currently // the only events that can be overridden, so we can save a DB // query if we don't bother checking other events. if ($this->is_override_calendar_event($event)) { // This is an override event so there is no valid timestart // range to set it to. return [false, false]; } if ($submissionsfromdate) { $mindate = [ $submissionsfromdate, get_string('duedatevalidation', 'assign'), ]; } if ($cutoffdate) { $maxdate = [ $cutoffdate, get_string('cutoffdatevalidation', 'assign'), ]; } if ($gradingduedate) { // If we don't have a cutoff date or we've got a grading due date // that is earlier than the cutoff then we should use that as the // upper limit for the due date. if (!$cutoffdate || $gradingduedate < $cutoffdate) { $maxdate = [ $gradingduedate, get_string('gradingdueduedatevalidation', 'assign'), ]; } } } else if ($event->eventtype == ASSIGN_EVENT_TYPE_GRADINGDUE) { if ($duedate) { $mindate = [ $duedate, get_string('gradingdueduedatevalidation', 'assign'), ]; } else if ($submissionsfromdate) { $mindate = [ $submissionsfromdate, get_string('gradingduefromdatevalidation', 'assign'), ]; } } return [$mindate, $maxdate]; }
[ "function", "get_valid_calendar_event_timestart_range", "(", "\\", "calendar_event", "$", "event", ")", "{", "$", "instance", "=", "$", "this", "->", "get_instance", "(", ")", ";", "$", "submissionsfromdate", "=", "$", "instance", "->", "allowsubmissionsfromdate", ";", "$", "cutoffdate", "=", "$", "instance", "->", "cutoffdate", ";", "$", "duedate", "=", "$", "instance", "->", "duedate", ";", "$", "gradingduedate", "=", "$", "instance", "->", "gradingduedate", ";", "$", "mindate", "=", "null", ";", "$", "maxdate", "=", "null", ";", "if", "(", "$", "event", "->", "eventtype", "==", "ASSIGN_EVENT_TYPE_DUE", ")", "{", "// This check is in here because due date events are currently", "// the only events that can be overridden, so we can save a DB", "// query if we don't bother checking other events.", "if", "(", "$", "this", "->", "is_override_calendar_event", "(", "$", "event", ")", ")", "{", "// This is an override event so there is no valid timestart", "// range to set it to.", "return", "[", "false", ",", "false", "]", ";", "}", "if", "(", "$", "submissionsfromdate", ")", "{", "$", "mindate", "=", "[", "$", "submissionsfromdate", ",", "get_string", "(", "'duedatevalidation'", ",", "'assign'", ")", ",", "]", ";", "}", "if", "(", "$", "cutoffdate", ")", "{", "$", "maxdate", "=", "[", "$", "cutoffdate", ",", "get_string", "(", "'cutoffdatevalidation'", ",", "'assign'", ")", ",", "]", ";", "}", "if", "(", "$", "gradingduedate", ")", "{", "// If we don't have a cutoff date or we've got a grading due date", "// that is earlier than the cutoff then we should use that as the", "// upper limit for the due date.", "if", "(", "!", "$", "cutoffdate", "||", "$", "gradingduedate", "<", "$", "cutoffdate", ")", "{", "$", "maxdate", "=", "[", "$", "gradingduedate", ",", "get_string", "(", "'gradingdueduedatevalidation'", ",", "'assign'", ")", ",", "]", ";", "}", "}", "}", "else", "if", "(", "$", "event", "->", "eventtype", "==", "ASSIGN_EVENT_TYPE_GRADINGDUE", ")", "{", "if", "(", "$", "duedate", ")", "{", "$", "mindate", "=", "[", "$", "duedate", ",", "get_string", "(", "'gradingdueduedatevalidation'", ",", "'assign'", ")", ",", "]", ";", "}", "else", "if", "(", "$", "submissionsfromdate", ")", "{", "$", "mindate", "=", "[", "$", "submissionsfromdate", ",", "get_string", "(", "'gradingduefromdatevalidation'", ",", "'assign'", ")", ",", "]", ";", "}", "}", "return", "[", "$", "mindate", ",", "$", "maxdate", "]", ";", "}" ]
This function calculates the minimum and maximum cutoff values for the timestart of the given event. It will return an array with two values, the first being the minimum cutoff value and the second being the maximum cutoff value. Either or both values can be null, which indicates there is no minimum or maximum, respectively. If a cutoff is required then the function must return an array containing the cutoff timestamp and error string to display to the user if the cutoff value is violated. A minimum and maximum cutoff return value will look like: [ [1505704373, 'The due date must be after the sbumission start date'], [1506741172, 'The due date must be before the cutoff date'] ] If the event does not have a valid timestart range then [false, false] will be returned. @param calendar_event $event The calendar event to get the time range for @return array
[ "This", "function", "calculates", "the", "minimum", "and", "maximum", "cutoff", "values", "for", "the", "timestart", "of", "the", "given", "event", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L1044-L1103
214,937
moodle/moodle
mod/assign/locallib.php
assign.update_plugin_instance
protected function update_plugin_instance(assign_plugin $plugin, stdClass $formdata) { if ($plugin->is_visible()) { $enabledname = $plugin->get_subtype() . '_' . $plugin->get_type() . '_enabled'; if (!empty($formdata->$enabledname)) { $plugin->enable(); if (!$plugin->save_settings($formdata)) { print_error($plugin->get_error()); return false; } } else { $plugin->disable(); } } return true; }
php
protected function update_plugin_instance(assign_plugin $plugin, stdClass $formdata) { if ($plugin->is_visible()) { $enabledname = $plugin->get_subtype() . '_' . $plugin->get_type() . '_enabled'; if (!empty($formdata->$enabledname)) { $plugin->enable(); if (!$plugin->save_settings($formdata)) { print_error($plugin->get_error()); return false; } } else { $plugin->disable(); } } return true; }
[ "protected", "function", "update_plugin_instance", "(", "assign_plugin", "$", "plugin", ",", "stdClass", "$", "formdata", ")", "{", "if", "(", "$", "plugin", "->", "is_visible", "(", ")", ")", "{", "$", "enabledname", "=", "$", "plugin", "->", "get_subtype", "(", ")", ".", "'_'", ".", "$", "plugin", "->", "get_type", "(", ")", ".", "'_enabled'", ";", "if", "(", "!", "empty", "(", "$", "formdata", "->", "$", "enabledname", ")", ")", "{", "$", "plugin", "->", "enable", "(", ")", ";", "if", "(", "!", "$", "plugin", "->", "save_settings", "(", "$", "formdata", ")", ")", "{", "print_error", "(", "$", "plugin", "->", "get_error", "(", ")", ")", ";", "return", "false", ";", "}", "}", "else", "{", "$", "plugin", "->", "disable", "(", ")", ";", "}", "}", "return", "true", ";", "}" ]
Update the settings for a single plugin. @param assign_plugin $plugin The plugin to update @param stdClass $formdata The form data @return bool false if an error occurs
[ "Update", "the", "settings", "for", "a", "single", "plugin", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L1229-L1243
214,938
moodle/moodle
mod/assign/locallib.php
assign.update_gradebook
public function update_gradebook($reset, $coursemoduleid) { global $CFG; require_once($CFG->dirroot.'/mod/assign/lib.php'); $assign = clone $this->get_instance(); $assign->cmidnumber = $coursemoduleid; // Set assign gradebook feedback plugin status (enabled and visible). $assign->gradefeedbackenabled = $this->is_gradebook_feedback_enabled(); $param = null; if ($reset) { $param = 'reset'; } return assign_grade_item_update($assign, $param); }
php
public function update_gradebook($reset, $coursemoduleid) { global $CFG; require_once($CFG->dirroot.'/mod/assign/lib.php'); $assign = clone $this->get_instance(); $assign->cmidnumber = $coursemoduleid; // Set assign gradebook feedback plugin status (enabled and visible). $assign->gradefeedbackenabled = $this->is_gradebook_feedback_enabled(); $param = null; if ($reset) { $param = 'reset'; } return assign_grade_item_update($assign, $param); }
[ "public", "function", "update_gradebook", "(", "$", "reset", ",", "$", "coursemoduleid", ")", "{", "global", "$", "CFG", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/mod/assign/lib.php'", ")", ";", "$", "assign", "=", "clone", "$", "this", "->", "get_instance", "(", ")", ";", "$", "assign", "->", "cmidnumber", "=", "$", "coursemoduleid", ";", "// Set assign gradebook feedback plugin status (enabled and visible).", "$", "assign", "->", "gradefeedbackenabled", "=", "$", "this", "->", "is_gradebook_feedback_enabled", "(", ")", ";", "$", "param", "=", "null", ";", "if", "(", "$", "reset", ")", "{", "$", "param", "=", "'reset'", ";", "}", "return", "assign_grade_item_update", "(", "$", "assign", ",", "$", "param", ")", ";", "}" ]
Update the gradebook information for this assignment. @param bool $reset If true, will reset all grades in the gradbook for this assignment @param int $coursemoduleid This is required because it might not exist in the database yet @return bool
[ "Update", "the", "gradebook", "information", "for", "this", "assignment", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L1252-L1268
214,939
moodle/moodle
mod/assign/locallib.php
assign.get_assign_perpage
public function get_assign_perpage() { $perpage = (int) get_user_preferences('assign_perpage', 10); $adminconfig = $this->get_admin_config(); $maxperpage = -1; if (isset($adminconfig->maxperpage)) { $maxperpage = $adminconfig->maxperpage; } if (isset($maxperpage) && $maxperpage != -1 && ($perpage == -1 || $perpage > $maxperpage)) { $perpage = $maxperpage; } return $perpage; }
php
public function get_assign_perpage() { $perpage = (int) get_user_preferences('assign_perpage', 10); $adminconfig = $this->get_admin_config(); $maxperpage = -1; if (isset($adminconfig->maxperpage)) { $maxperpage = $adminconfig->maxperpage; } if (isset($maxperpage) && $maxperpage != -1 && ($perpage == -1 || $perpage > $maxperpage)) { $perpage = $maxperpage; } return $perpage; }
[ "public", "function", "get_assign_perpage", "(", ")", "{", "$", "perpage", "=", "(", "int", ")", "get_user_preferences", "(", "'assign_perpage'", ",", "10", ")", ";", "$", "adminconfig", "=", "$", "this", "->", "get_admin_config", "(", ")", ";", "$", "maxperpage", "=", "-", "1", ";", "if", "(", "isset", "(", "$", "adminconfig", "->", "maxperpage", ")", ")", "{", "$", "maxperpage", "=", "$", "adminconfig", "->", "maxperpage", ";", "}", "if", "(", "isset", "(", "$", "maxperpage", ")", "&&", "$", "maxperpage", "!=", "-", "1", "&&", "(", "$", "perpage", "==", "-", "1", "||", "$", "perpage", ">", "$", "maxperpage", ")", ")", "{", "$", "perpage", "=", "$", "maxperpage", ";", "}", "return", "$", "perpage", ";", "}" ]
Get the marking table page size @return integer
[ "Get", "the", "marking", "table", "page", "size" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L1275-L1288
214,940
moodle/moodle
mod/assign/locallib.php
assign.get_admin_config
public function get_admin_config() { if ($this->adminconfig) { return $this->adminconfig; } $this->adminconfig = get_config('assign'); return $this->adminconfig; }
php
public function get_admin_config() { if ($this->adminconfig) { return $this->adminconfig; } $this->adminconfig = get_config('assign'); return $this->adminconfig; }
[ "public", "function", "get_admin_config", "(", ")", "{", "if", "(", "$", "this", "->", "adminconfig", ")", "{", "return", "$", "this", "->", "adminconfig", ";", "}", "$", "this", "->", "adminconfig", "=", "get_config", "(", "'assign'", ")", ";", "return", "$", "this", "->", "adminconfig", ";", "}" ]
Load and cache the admin config for this module. @return stdClass the plugin config
[ "Load", "and", "cache", "the", "admin", "config", "for", "this", "module", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L1295-L1301
214,941
moodle/moodle
mod/assign/locallib.php
assign.save_intro_draft_files
protected function save_intro_draft_files($formdata) { if (isset($formdata->introattachments)) { file_save_draft_area_files($formdata->introattachments, $this->get_context()->id, 'mod_assign', ASSIGN_INTROATTACHMENT_FILEAREA, 0); } }
php
protected function save_intro_draft_files($formdata) { if (isset($formdata->introattachments)) { file_save_draft_area_files($formdata->introattachments, $this->get_context()->id, 'mod_assign', ASSIGN_INTROATTACHMENT_FILEAREA, 0); } }
[ "protected", "function", "save_intro_draft_files", "(", "$", "formdata", ")", "{", "if", "(", "isset", "(", "$", "formdata", "->", "introattachments", ")", ")", "{", "file_save_draft_area_files", "(", "$", "formdata", "->", "introattachments", ",", "$", "this", "->", "get_context", "(", ")", "->", "id", ",", "'mod_assign'", ",", "ASSIGN_INTROATTACHMENT_FILEAREA", ",", "0", ")", ";", "}", "}" ]
Save the attachments in the draft areas. @param stdClass $formdata
[ "Save", "the", "attachments", "in", "the", "draft", "areas", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L1497-L1502
214,942
moodle/moodle
mod/assign/locallib.php
assign.add_plugin_grade_elements
protected function add_plugin_grade_elements($grade, MoodleQuickForm $mform, stdClass $data, $userid) { foreach ($this->feedbackplugins as $plugin) { if ($plugin->is_enabled() && $plugin->is_visible()) { $plugin->get_form_elements_for_user($grade, $mform, $data, $userid); } } }
php
protected function add_plugin_grade_elements($grade, MoodleQuickForm $mform, stdClass $data, $userid) { foreach ($this->feedbackplugins as $plugin) { if ($plugin->is_enabled() && $plugin->is_visible()) { $plugin->get_form_elements_for_user($grade, $mform, $data, $userid); } } }
[ "protected", "function", "add_plugin_grade_elements", "(", "$", "grade", ",", "MoodleQuickForm", "$", "mform", ",", "stdClass", "$", "data", ",", "$", "userid", ")", "{", "foreach", "(", "$", "this", "->", "feedbackplugins", "as", "$", "plugin", ")", "{", "if", "(", "$", "plugin", "->", "is_enabled", "(", ")", "&&", "$", "plugin", "->", "is_visible", "(", ")", ")", "{", "$", "plugin", "->", "get_form_elements_for_user", "(", "$", "grade", ",", "$", "mform", ",", "$", "data", ",", "$", "userid", ")", ";", "}", "}", "}" ]
Add elements in grading plugin form. @param mixed $grade stdClass|null @param MoodleQuickForm $mform @param stdClass $data @param int $userid - The userid we are grading @return void
[ "Add", "elements", "in", "grading", "plugin", "form", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L1513-L1519
214,943
moodle/moodle
mod/assign/locallib.php
assign.add_plugin_settings
protected function add_plugin_settings(assign_plugin $plugin, MoodleQuickForm $mform, & $pluginsenabled) { global $CFG; if ($plugin->is_visible() && !$plugin->is_configurable() && $plugin->is_enabled()) { $name = $plugin->get_subtype() . '_' . $plugin->get_type() . '_enabled'; $pluginsenabled[] = $mform->createElement('hidden', $name, 1); $mform->setType($name, PARAM_BOOL); $plugin->get_settings($mform); } else if ($plugin->is_visible() && $plugin->is_configurable()) { $name = $plugin->get_subtype() . '_' . $plugin->get_type() . '_enabled'; $label = $plugin->get_name(); $pluginsenabled[] = $mform->createElement('checkbox', $name, '', $label); $helpicon = $this->get_renderer()->help_icon('enabled', $plugin->get_subtype() . '_' . $plugin->get_type()); $pluginsenabled[] = $mform->createElement('static', '', '', $helpicon); $default = get_config($plugin->get_subtype() . '_' . $plugin->get_type(), 'default'); if ($plugin->get_config('enabled') !== false) { $default = $plugin->is_enabled(); } $mform->setDefault($plugin->get_subtype() . '_' . $plugin->get_type() . '_enabled', $default); $plugin->get_settings($mform); } }
php
protected function add_plugin_settings(assign_plugin $plugin, MoodleQuickForm $mform, & $pluginsenabled) { global $CFG; if ($plugin->is_visible() && !$plugin->is_configurable() && $plugin->is_enabled()) { $name = $plugin->get_subtype() . '_' . $plugin->get_type() . '_enabled'; $pluginsenabled[] = $mform->createElement('hidden', $name, 1); $mform->setType($name, PARAM_BOOL); $plugin->get_settings($mform); } else if ($plugin->is_visible() && $plugin->is_configurable()) { $name = $plugin->get_subtype() . '_' . $plugin->get_type() . '_enabled'; $label = $plugin->get_name(); $pluginsenabled[] = $mform->createElement('checkbox', $name, '', $label); $helpicon = $this->get_renderer()->help_icon('enabled', $plugin->get_subtype() . '_' . $plugin->get_type()); $pluginsenabled[] = $mform->createElement('static', '', '', $helpicon); $default = get_config($plugin->get_subtype() . '_' . $plugin->get_type(), 'default'); if ($plugin->get_config('enabled') !== false) { $default = $plugin->is_enabled(); } $mform->setDefault($plugin->get_subtype() . '_' . $plugin->get_type() . '_enabled', $default); $plugin->get_settings($mform); } }
[ "protected", "function", "add_plugin_settings", "(", "assign_plugin", "$", "plugin", ",", "MoodleQuickForm", "$", "mform", ",", "&", "$", "pluginsenabled", ")", "{", "global", "$", "CFG", ";", "if", "(", "$", "plugin", "->", "is_visible", "(", ")", "&&", "!", "$", "plugin", "->", "is_configurable", "(", ")", "&&", "$", "plugin", "->", "is_enabled", "(", ")", ")", "{", "$", "name", "=", "$", "plugin", "->", "get_subtype", "(", ")", ".", "'_'", ".", "$", "plugin", "->", "get_type", "(", ")", ".", "'_enabled'", ";", "$", "pluginsenabled", "[", "]", "=", "$", "mform", "->", "createElement", "(", "'hidden'", ",", "$", "name", ",", "1", ")", ";", "$", "mform", "->", "setType", "(", "$", "name", ",", "PARAM_BOOL", ")", ";", "$", "plugin", "->", "get_settings", "(", "$", "mform", ")", ";", "}", "else", "if", "(", "$", "plugin", "->", "is_visible", "(", ")", "&&", "$", "plugin", "->", "is_configurable", "(", ")", ")", "{", "$", "name", "=", "$", "plugin", "->", "get_subtype", "(", ")", ".", "'_'", ".", "$", "plugin", "->", "get_type", "(", ")", ".", "'_enabled'", ";", "$", "label", "=", "$", "plugin", "->", "get_name", "(", ")", ";", "$", "pluginsenabled", "[", "]", "=", "$", "mform", "->", "createElement", "(", "'checkbox'", ",", "$", "name", ",", "''", ",", "$", "label", ")", ";", "$", "helpicon", "=", "$", "this", "->", "get_renderer", "(", ")", "->", "help_icon", "(", "'enabled'", ",", "$", "plugin", "->", "get_subtype", "(", ")", ".", "'_'", ".", "$", "plugin", "->", "get_type", "(", ")", ")", ";", "$", "pluginsenabled", "[", "]", "=", "$", "mform", "->", "createElement", "(", "'static'", ",", "''", ",", "''", ",", "$", "helpicon", ")", ";", "$", "default", "=", "get_config", "(", "$", "plugin", "->", "get_subtype", "(", ")", ".", "'_'", ".", "$", "plugin", "->", "get_type", "(", ")", ",", "'default'", ")", ";", "if", "(", "$", "plugin", "->", "get_config", "(", "'enabled'", ")", "!==", "false", ")", "{", "$", "default", "=", "$", "plugin", "->", "is_enabled", "(", ")", ";", "}", "$", "mform", "->", "setDefault", "(", "$", "plugin", "->", "get_subtype", "(", ")", ".", "'_'", ".", "$", "plugin", "->", "get_type", "(", ")", ".", "'_enabled'", ",", "$", "default", ")", ";", "$", "plugin", "->", "get_settings", "(", "$", "mform", ")", ";", "}", "}" ]
Add one plugins settings to edit plugin form. @param assign_plugin $plugin The plugin to add the settings from @param MoodleQuickForm $mform The form to add the configuration settings to. This form is modified directly (not returned). @param array $pluginsenabled A list of form elements to be added to a group. The new element is added to this array by this function. @return void
[ "Add", "one", "plugins", "settings", "to", "edit", "plugin", "form", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L1533-L1556
214,944
moodle/moodle
mod/assign/locallib.php
assign.add_all_plugin_settings
public function add_all_plugin_settings(MoodleQuickForm $mform) { $mform->addElement('header', 'submissiontypes', get_string('submissiontypes', 'assign')); $submissionpluginsenabled = array(); $group = $mform->addGroup(array(), 'submissionplugins', get_string('submissiontypes', 'assign'), array(' '), false); foreach ($this->submissionplugins as $plugin) { $this->add_plugin_settings($plugin, $mform, $submissionpluginsenabled); } $group->setElements($submissionpluginsenabled); $mform->addElement('header', 'feedbacktypes', get_string('feedbacktypes', 'assign')); $feedbackpluginsenabled = array(); $group = $mform->addGroup(array(), 'feedbackplugins', get_string('feedbacktypes', 'assign'), array(' '), false); foreach ($this->feedbackplugins as $plugin) { $this->add_plugin_settings($plugin, $mform, $feedbackpluginsenabled); } $group->setElements($feedbackpluginsenabled); $mform->setExpanded('submissiontypes'); }
php
public function add_all_plugin_settings(MoodleQuickForm $mform) { $mform->addElement('header', 'submissiontypes', get_string('submissiontypes', 'assign')); $submissionpluginsenabled = array(); $group = $mform->addGroup(array(), 'submissionplugins', get_string('submissiontypes', 'assign'), array(' '), false); foreach ($this->submissionplugins as $plugin) { $this->add_plugin_settings($plugin, $mform, $submissionpluginsenabled); } $group->setElements($submissionpluginsenabled); $mform->addElement('header', 'feedbacktypes', get_string('feedbacktypes', 'assign')); $feedbackpluginsenabled = array(); $group = $mform->addGroup(array(), 'feedbackplugins', get_string('feedbacktypes', 'assign'), array(' '), false); foreach ($this->feedbackplugins as $plugin) { $this->add_plugin_settings($plugin, $mform, $feedbackpluginsenabled); } $group->setElements($feedbackpluginsenabled); $mform->setExpanded('submissiontypes'); }
[ "public", "function", "add_all_plugin_settings", "(", "MoodleQuickForm", "$", "mform", ")", "{", "$", "mform", "->", "addElement", "(", "'header'", ",", "'submissiontypes'", ",", "get_string", "(", "'submissiontypes'", ",", "'assign'", ")", ")", ";", "$", "submissionpluginsenabled", "=", "array", "(", ")", ";", "$", "group", "=", "$", "mform", "->", "addGroup", "(", "array", "(", ")", ",", "'submissionplugins'", ",", "get_string", "(", "'submissiontypes'", ",", "'assign'", ")", ",", "array", "(", "' '", ")", ",", "false", ")", ";", "foreach", "(", "$", "this", "->", "submissionplugins", "as", "$", "plugin", ")", "{", "$", "this", "->", "add_plugin_settings", "(", "$", "plugin", ",", "$", "mform", ",", "$", "submissionpluginsenabled", ")", ";", "}", "$", "group", "->", "setElements", "(", "$", "submissionpluginsenabled", ")", ";", "$", "mform", "->", "addElement", "(", "'header'", ",", "'feedbacktypes'", ",", "get_string", "(", "'feedbacktypes'", ",", "'assign'", ")", ")", ";", "$", "feedbackpluginsenabled", "=", "array", "(", ")", ";", "$", "group", "=", "$", "mform", "->", "addGroup", "(", "array", "(", ")", ",", "'feedbackplugins'", ",", "get_string", "(", "'feedbacktypes'", ",", "'assign'", ")", ",", "array", "(", "' '", ")", ",", "false", ")", ";", "foreach", "(", "$", "this", "->", "feedbackplugins", "as", "$", "plugin", ")", "{", "$", "this", "->", "add_plugin_settings", "(", "$", "plugin", ",", "$", "mform", ",", "$", "feedbackpluginsenabled", ")", ";", "}", "$", "group", "->", "setElements", "(", "$", "feedbackpluginsenabled", ")", ";", "$", "mform", "->", "setExpanded", "(", "'submissiontypes'", ")", ";", "}" ]
Add settings to edit plugin form. @param MoodleQuickForm $mform The form to add the configuration settings to. This form is modified directly (not returned). @return void
[ "Add", "settings", "to", "edit", "plugin", "form", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L1565-L1583
214,945
moodle/moodle
mod/assign/locallib.php
assign.get_module_name
protected function get_module_name() { if (isset(self::$modulename)) { return self::$modulename; } self::$modulename = get_string('modulename', 'assign'); return self::$modulename; }
php
protected function get_module_name() { if (isset(self::$modulename)) { return self::$modulename; } self::$modulename = get_string('modulename', 'assign'); return self::$modulename; }
[ "protected", "function", "get_module_name", "(", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "modulename", ")", ")", "{", "return", "self", "::", "$", "modulename", ";", "}", "self", "::", "$", "modulename", "=", "get_string", "(", "'modulename'", ",", "'assign'", ")", ";", "return", "self", "::", "$", "modulename", ";", "}" ]
Get the name of the current module. @return string the module name (Assignment)
[ "Get", "the", "name", "of", "the", "current", "module", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L1610-L1616
214,946
moodle/moodle
mod/assign/locallib.php
assign.get_module_name_plural
protected function get_module_name_plural() { if (isset(self::$modulenameplural)) { return self::$modulenameplural; } self::$modulenameplural = get_string('modulenameplural', 'assign'); return self::$modulenameplural; }
php
protected function get_module_name_plural() { if (isset(self::$modulenameplural)) { return self::$modulenameplural; } self::$modulenameplural = get_string('modulenameplural', 'assign'); return self::$modulenameplural; }
[ "protected", "function", "get_module_name_plural", "(", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "modulenameplural", ")", ")", "{", "return", "self", "::", "$", "modulenameplural", ";", "}", "self", "::", "$", "modulenameplural", "=", "get_string", "(", "'modulenameplural'", ",", "'assign'", ")", ";", "return", "self", "::", "$", "modulenameplural", ";", "}" ]
Get the plural name of the current module. @return string the module name plural (Assignments)
[ "Get", "the", "plural", "name", "of", "the", "current", "module", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L1623-L1629
214,947
moodle/moodle
mod/assign/locallib.php
assign.get_instance
public function get_instance() { global $DB; if ($this->instance) { return $this->instance; } if ($this->get_course_module()) { $params = array('id' => $this->get_course_module()->instance); $this->instance = $DB->get_record('assign', $params, '*', MUST_EXIST); } if (!$this->instance) { throw new coding_exception('Improper use of the assignment class. ' . 'Cannot load the assignment record.'); } return $this->instance; }
php
public function get_instance() { global $DB; if ($this->instance) { return $this->instance; } if ($this->get_course_module()) { $params = array('id' => $this->get_course_module()->instance); $this->instance = $DB->get_record('assign', $params, '*', MUST_EXIST); } if (!$this->instance) { throw new coding_exception('Improper use of the assignment class. ' . 'Cannot load the assignment record.'); } return $this->instance; }
[ "public", "function", "get_instance", "(", ")", "{", "global", "$", "DB", ";", "if", "(", "$", "this", "->", "instance", ")", "{", "return", "$", "this", "->", "instance", ";", "}", "if", "(", "$", "this", "->", "get_course_module", "(", ")", ")", "{", "$", "params", "=", "array", "(", "'id'", "=>", "$", "this", "->", "get_course_module", "(", ")", "->", "instance", ")", ";", "$", "this", "->", "instance", "=", "$", "DB", "->", "get_record", "(", "'assign'", ",", "$", "params", ",", "'*'", ",", "MUST_EXIST", ")", ";", "}", "if", "(", "!", "$", "this", "->", "instance", ")", "{", "throw", "new", "coding_exception", "(", "'Improper use of the assignment class. '", ".", "'Cannot load the assignment record.'", ")", ";", "}", "return", "$", "this", "->", "instance", ";", "}" ]
Get the settings for the current instance of this assignment @return stdClass The settings
[ "Get", "the", "settings", "for", "the", "current", "instance", "of", "this", "assignment" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L1645-L1659
214,948
moodle/moodle
mod/assign/locallib.php
assign.get_grade_item
public function get_grade_item() { if ($this->gradeitem) { return $this->gradeitem; } $instance = $this->get_instance(); $params = array('itemtype' => 'mod', 'itemmodule' => 'assign', 'iteminstance' => $instance->id, 'courseid' => $instance->course, 'itemnumber' => 0); $this->gradeitem = grade_item::fetch($params); if (!$this->gradeitem) { throw new coding_exception('Improper use of the assignment class. ' . 'Cannot load the grade item.'); } return $this->gradeitem; }
php
public function get_grade_item() { if ($this->gradeitem) { return $this->gradeitem; } $instance = $this->get_instance(); $params = array('itemtype' => 'mod', 'itemmodule' => 'assign', 'iteminstance' => $instance->id, 'courseid' => $instance->course, 'itemnumber' => 0); $this->gradeitem = grade_item::fetch($params); if (!$this->gradeitem) { throw new coding_exception('Improper use of the assignment class. ' . 'Cannot load the grade item.'); } return $this->gradeitem; }
[ "public", "function", "get_grade_item", "(", ")", "{", "if", "(", "$", "this", "->", "gradeitem", ")", "{", "return", "$", "this", "->", "gradeitem", ";", "}", "$", "instance", "=", "$", "this", "->", "get_instance", "(", ")", ";", "$", "params", "=", "array", "(", "'itemtype'", "=>", "'mod'", ",", "'itemmodule'", "=>", "'assign'", ",", "'iteminstance'", "=>", "$", "instance", "->", "id", ",", "'courseid'", "=>", "$", "instance", "->", "course", ",", "'itemnumber'", "=>", "0", ")", ";", "$", "this", "->", "gradeitem", "=", "grade_item", "::", "fetch", "(", "$", "params", ")", ";", "if", "(", "!", "$", "this", "->", "gradeitem", ")", "{", "throw", "new", "coding_exception", "(", "'Improper use of the assignment class. '", ".", "'Cannot load the grade item.'", ")", ";", "}", "return", "$", "this", "->", "gradeitem", ";", "}" ]
Get the primary grade item for this assign instance. @return grade_item The grade_item record
[ "Get", "the", "primary", "grade", "item", "for", "this", "assign", "instance", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L1666-L1682
214,949
moodle/moodle
mod/assign/locallib.php
assign.get_course_context
public function get_course_context() { if (!$this->context && !$this->course) { throw new coding_exception('Improper use of the assignment class. ' . 'Cannot load the course context.'); } if ($this->context) { return $this->context->get_course_context(); } else { return context_course::instance($this->course->id); } }
php
public function get_course_context() { if (!$this->context && !$this->course) { throw new coding_exception('Improper use of the assignment class. ' . 'Cannot load the course context.'); } if ($this->context) { return $this->context->get_course_context(); } else { return context_course::instance($this->course->id); } }
[ "public", "function", "get_course_context", "(", ")", "{", "if", "(", "!", "$", "this", "->", "context", "&&", "!", "$", "this", "->", "course", ")", "{", "throw", "new", "coding_exception", "(", "'Improper use of the assignment class. '", ".", "'Cannot load the course context.'", ")", ";", "}", "if", "(", "$", "this", "->", "context", ")", "{", "return", "$", "this", "->", "context", "->", "get_course_context", "(", ")", ";", "}", "else", "{", "return", "context_course", "::", "instance", "(", "$", "this", "->", "course", "->", "id", ")", ";", "}", "}" ]
Get the context of the current course. @return mixed context|null The course context
[ "Get", "the", "context", "of", "the", "current", "course", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L1689-L1699
214,950
moodle/moodle
mod/assign/locallib.php
assign.get_course_module
public function get_course_module() { if ($this->coursemodule) { return $this->coursemodule; } if (!$this->context) { return null; } if ($this->context->contextlevel == CONTEXT_MODULE) { $modinfo = get_fast_modinfo($this->get_course()); $this->coursemodule = $modinfo->get_cm($this->context->instanceid); return $this->coursemodule; } return null; }
php
public function get_course_module() { if ($this->coursemodule) { return $this->coursemodule; } if (!$this->context) { return null; } if ($this->context->contextlevel == CONTEXT_MODULE) { $modinfo = get_fast_modinfo($this->get_course()); $this->coursemodule = $modinfo->get_cm($this->context->instanceid); return $this->coursemodule; } return null; }
[ "public", "function", "get_course_module", "(", ")", "{", "if", "(", "$", "this", "->", "coursemodule", ")", "{", "return", "$", "this", "->", "coursemodule", ";", "}", "if", "(", "!", "$", "this", "->", "context", ")", "{", "return", "null", ";", "}", "if", "(", "$", "this", "->", "context", "->", "contextlevel", "==", "CONTEXT_MODULE", ")", "{", "$", "modinfo", "=", "get_fast_modinfo", "(", "$", "this", "->", "get_course", "(", ")", ")", ";", "$", "this", "->", "coursemodule", "=", "$", "modinfo", "->", "get_cm", "(", "$", "this", "->", "context", "->", "instanceid", ")", ";", "return", "$", "this", "->", "coursemodule", ";", "}", "return", "null", ";", "}" ]
Get the current course module. @return cm_info|null The course module or null if not known
[ "Get", "the", "current", "course", "module", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L1707-L1721
214,951
moodle/moodle
mod/assign/locallib.php
assign.get_course
public function get_course() { global $DB; if ($this->course) { return $this->course; } if (!$this->context) { return null; } $params = array('id' => $this->get_course_context()->instanceid); $this->course = $DB->get_record('course', $params, '*', MUST_EXIST); return $this->course; }
php
public function get_course() { global $DB; if ($this->course) { return $this->course; } if (!$this->context) { return null; } $params = array('id' => $this->get_course_context()->instanceid); $this->course = $DB->get_record('course', $params, '*', MUST_EXIST); return $this->course; }
[ "public", "function", "get_course", "(", ")", "{", "global", "$", "DB", ";", "if", "(", "$", "this", "->", "course", ")", "{", "return", "$", "this", "->", "course", ";", "}", "if", "(", "!", "$", "this", "->", "context", ")", "{", "return", "null", ";", "}", "$", "params", "=", "array", "(", "'id'", "=>", "$", "this", "->", "get_course_context", "(", ")", "->", "instanceid", ")", ";", "$", "this", "->", "course", "=", "$", "DB", "->", "get_record", "(", "'course'", ",", "$", "params", ",", "'*'", ",", "MUST_EXIST", ")", ";", "return", "$", "this", "->", "course", ";", "}" ]
Get the current course. @return mixed stdClass|null The course
[ "Get", "the", "current", "course", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L1737-L1751
214,952
moodle/moodle
mod/assign/locallib.php
assign.count_attachments
protected function count_attachments() { $fs = get_file_storage(); $files = $fs->get_area_files($this->get_context()->id, 'mod_assign', ASSIGN_INTROATTACHMENT_FILEAREA, 0, 'id', false); return count($files); }
php
protected function count_attachments() { $fs = get_file_storage(); $files = $fs->get_area_files($this->get_context()->id, 'mod_assign', ASSIGN_INTROATTACHMENT_FILEAREA, 0, 'id', false); return count($files); }
[ "protected", "function", "count_attachments", "(", ")", "{", "$", "fs", "=", "get_file_storage", "(", ")", ";", "$", "files", "=", "$", "fs", "->", "get_area_files", "(", "$", "this", "->", "get_context", "(", ")", "->", "id", ",", "'mod_assign'", ",", "ASSIGN_INTROATTACHMENT_FILEAREA", ",", "0", ",", "'id'", ",", "false", ")", ";", "return", "count", "(", "$", "files", ")", ";", "}" ]
Count the number of intro attachments. @return int
[ "Count", "the", "number", "of", "intro", "attachments", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L1758-L1765
214,953
moodle/moodle
mod/assign/locallib.php
assign.get_participant
public function get_participant($userid) { global $DB, $USER; if ($userid == $USER->id) { $participant = clone ($USER); } else { $participant = $DB->get_record('user', array('id' => $userid)); } if (!$participant) { return null; } if (!is_enrolled($this->context, $participant, 'mod/assign:submit', $this->show_only_active_users())) { return null; } $result = $this->get_submission_info_for_participants(array($participant->id => $participant)); return $result[$participant->id]; }
php
public function get_participant($userid) { global $DB, $USER; if ($userid == $USER->id) { $participant = clone ($USER); } else { $participant = $DB->get_record('user', array('id' => $userid)); } if (!$participant) { return null; } if (!is_enrolled($this->context, $participant, 'mod/assign:submit', $this->show_only_active_users())) { return null; } $result = $this->get_submission_info_for_participants(array($participant->id => $participant)); return $result[$participant->id]; }
[ "public", "function", "get_participant", "(", "$", "userid", ")", "{", "global", "$", "DB", ",", "$", "USER", ";", "if", "(", "$", "userid", "==", "$", "USER", "->", "id", ")", "{", "$", "participant", "=", "clone", "(", "$", "USER", ")", ";", "}", "else", "{", "$", "participant", "=", "$", "DB", "->", "get_record", "(", "'user'", ",", "array", "(", "'id'", "=>", "$", "userid", ")", ")", ";", "}", "if", "(", "!", "$", "participant", ")", "{", "return", "null", ";", "}", "if", "(", "!", "is_enrolled", "(", "$", "this", "->", "context", ",", "$", "participant", ",", "'mod/assign:submit'", ",", "$", "this", "->", "show_only_active_users", "(", ")", ")", ")", "{", "return", "null", ";", "}", "$", "result", "=", "$", "this", "->", "get_submission_info_for_participants", "(", "array", "(", "$", "participant", "->", "id", "=>", "$", "participant", ")", ")", ";", "return", "$", "result", "[", "$", "participant", "->", "id", "]", ";", "}" ]
Load a user if they are enrolled in the current course. Populated with submission status for this assignment. @param int $userid @return null|stdClass user record
[ "Load", "a", "user", "if", "they", "are", "enrolled", "in", "the", "current", "course", ".", "Populated", "with", "submission", "status", "for", "this", "assignment", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L2137-L2155
214,954
moodle/moodle
mod/assign/locallib.php
assign.count_teams
public function count_teams($activitygroup = 0) { $count = 0; $participants = $this->list_participants($activitygroup, true); // If a team submission grouping id is provided all good as all returned groups // are the submission teams, but if no team submission grouping was specified // $groups will contain all participants groups. if ($this->get_instance()->teamsubmissiongroupingid) { // We restrict the users to the selected group ones. $groups = groups_get_all_groups($this->get_course()->id, array_keys($participants), $this->get_instance()->teamsubmissiongroupingid, 'DISTINCT g.id, g.name'); $count = count($groups); // When a specific group is selected we don't count the default group users. if ($activitygroup == 0) { if (empty($this->get_instance()->preventsubmissionnotingroup)) { // See if there are any users in the default group. $defaultusers = $this->get_submission_group_members(0, true); if (count($defaultusers) > 0) { $count += 1; } } } else if ($activitygroup != 0 && empty($groups)) { // Set count to 1 if $groups returns empty. // It means the group is not part of $this->get_instance()->teamsubmissiongroupingid. $count = 1; } } else { // It is faster to loop around participants if no grouping was specified. $groups = array(); foreach ($participants as $participant) { if ($group = $this->get_submission_group($participant->id)) { $groups[$group->id] = true; } else if (empty($this->get_instance()->preventsubmissionnotingroup)) { $groups[0] = true; } } $count = count($groups); } return $count; }
php
public function count_teams($activitygroup = 0) { $count = 0; $participants = $this->list_participants($activitygroup, true); // If a team submission grouping id is provided all good as all returned groups // are the submission teams, but if no team submission grouping was specified // $groups will contain all participants groups. if ($this->get_instance()->teamsubmissiongroupingid) { // We restrict the users to the selected group ones. $groups = groups_get_all_groups($this->get_course()->id, array_keys($participants), $this->get_instance()->teamsubmissiongroupingid, 'DISTINCT g.id, g.name'); $count = count($groups); // When a specific group is selected we don't count the default group users. if ($activitygroup == 0) { if (empty($this->get_instance()->preventsubmissionnotingroup)) { // See if there are any users in the default group. $defaultusers = $this->get_submission_group_members(0, true); if (count($defaultusers) > 0) { $count += 1; } } } else if ($activitygroup != 0 && empty($groups)) { // Set count to 1 if $groups returns empty. // It means the group is not part of $this->get_instance()->teamsubmissiongroupingid. $count = 1; } } else { // It is faster to loop around participants if no grouping was specified. $groups = array(); foreach ($participants as $participant) { if ($group = $this->get_submission_group($participant->id)) { $groups[$group->id] = true; } else if (empty($this->get_instance()->preventsubmissionnotingroup)) { $groups[0] = true; } } $count = count($groups); } return $count; }
[ "public", "function", "count_teams", "(", "$", "activitygroup", "=", "0", ")", "{", "$", "count", "=", "0", ";", "$", "participants", "=", "$", "this", "->", "list_participants", "(", "$", "activitygroup", ",", "true", ")", ";", "// If a team submission grouping id is provided all good as all returned groups", "// are the submission teams, but if no team submission grouping was specified", "// $groups will contain all participants groups.", "if", "(", "$", "this", "->", "get_instance", "(", ")", "->", "teamsubmissiongroupingid", ")", "{", "// We restrict the users to the selected group ones.", "$", "groups", "=", "groups_get_all_groups", "(", "$", "this", "->", "get_course", "(", ")", "->", "id", ",", "array_keys", "(", "$", "participants", ")", ",", "$", "this", "->", "get_instance", "(", ")", "->", "teamsubmissiongroupingid", ",", "'DISTINCT g.id, g.name'", ")", ";", "$", "count", "=", "count", "(", "$", "groups", ")", ";", "// When a specific group is selected we don't count the default group users.", "if", "(", "$", "activitygroup", "==", "0", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "get_instance", "(", ")", "->", "preventsubmissionnotingroup", ")", ")", "{", "// See if there are any users in the default group.", "$", "defaultusers", "=", "$", "this", "->", "get_submission_group_members", "(", "0", ",", "true", ")", ";", "if", "(", "count", "(", "$", "defaultusers", ")", ">", "0", ")", "{", "$", "count", "+=", "1", ";", "}", "}", "}", "else", "if", "(", "$", "activitygroup", "!=", "0", "&&", "empty", "(", "$", "groups", ")", ")", "{", "// Set count to 1 if $groups returns empty.", "// It means the group is not part of $this->get_instance()->teamsubmissiongroupingid.", "$", "count", "=", "1", ";", "}", "}", "else", "{", "// It is faster to loop around participants if no grouping was specified.", "$", "groups", "=", "array", "(", ")", ";", "foreach", "(", "$", "participants", "as", "$", "participant", ")", "{", "if", "(", "$", "group", "=", "$", "this", "->", "get_submission_group", "(", "$", "participant", "->", "id", ")", ")", "{", "$", "groups", "[", "$", "group", "->", "id", "]", "=", "true", ";", "}", "else", "if", "(", "empty", "(", "$", "this", "->", "get_instance", "(", ")", "->", "preventsubmissionnotingroup", ")", ")", "{", "$", "groups", "[", "0", "]", "=", "true", ";", "}", "}", "$", "count", "=", "count", "(", "$", "groups", ")", ";", "}", "return", "$", "count", ";", "}" ]
Load a count of valid teams for this assignment. @param int $activitygroup Activity active group @return int number of valid teams
[ "Load", "a", "count", "of", "valid", "teams", "for", "this", "assignment", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L2163-L2211
214,955
moodle/moodle
mod/assign/locallib.php
assign.count_submissions_need_grading
public function count_submissions_need_grading($currentgroup = null) { global $DB; if ($this->get_instance()->teamsubmission) { // This does not make sense for group assignment because the submission is shared. return 0; } if ($currentgroup === null) { $currentgroup = groups_get_activity_group($this->get_course_module(), true); } list($esql, $params) = get_enrolled_sql($this->get_context(), 'mod/assign:submit', $currentgroup, true); $params['assignid'] = $this->get_instance()->id; $params['submitted'] = ASSIGN_SUBMISSION_STATUS_SUBMITTED; $sqlscalegrade = $this->get_instance()->grade < 0 ? ' OR g.grade = -1' : ''; $sql = 'SELECT COUNT(s.userid) FROM {assign_submission} s LEFT JOIN {assign_grades} g ON s.assignment = g.assignment AND s.userid = g.userid AND g.attemptnumber = s.attemptnumber JOIN(' . $esql . ') e ON e.id = s.userid WHERE s.latest = 1 AND s.assignment = :assignid AND s.timemodified IS NOT NULL AND s.status = :submitted AND (s.timemodified >= g.timemodified OR g.timemodified IS NULL OR g.grade IS NULL ' . $sqlscalegrade . ')'; return $DB->count_records_sql($sql, $params); }
php
public function count_submissions_need_grading($currentgroup = null) { global $DB; if ($this->get_instance()->teamsubmission) { // This does not make sense for group assignment because the submission is shared. return 0; } if ($currentgroup === null) { $currentgroup = groups_get_activity_group($this->get_course_module(), true); } list($esql, $params) = get_enrolled_sql($this->get_context(), 'mod/assign:submit', $currentgroup, true); $params['assignid'] = $this->get_instance()->id; $params['submitted'] = ASSIGN_SUBMISSION_STATUS_SUBMITTED; $sqlscalegrade = $this->get_instance()->grade < 0 ? ' OR g.grade = -1' : ''; $sql = 'SELECT COUNT(s.userid) FROM {assign_submission} s LEFT JOIN {assign_grades} g ON s.assignment = g.assignment AND s.userid = g.userid AND g.attemptnumber = s.attemptnumber JOIN(' . $esql . ') e ON e.id = s.userid WHERE s.latest = 1 AND s.assignment = :assignid AND s.timemodified IS NOT NULL AND s.status = :submitted AND (s.timemodified >= g.timemodified OR g.timemodified IS NULL OR g.grade IS NULL ' . $sqlscalegrade . ')'; return $DB->count_records_sql($sql, $params); }
[ "public", "function", "count_submissions_need_grading", "(", "$", "currentgroup", "=", "null", ")", "{", "global", "$", "DB", ";", "if", "(", "$", "this", "->", "get_instance", "(", ")", "->", "teamsubmission", ")", "{", "// This does not make sense for group assignment because the submission is shared.", "return", "0", ";", "}", "if", "(", "$", "currentgroup", "===", "null", ")", "{", "$", "currentgroup", "=", "groups_get_activity_group", "(", "$", "this", "->", "get_course_module", "(", ")", ",", "true", ")", ";", "}", "list", "(", "$", "esql", ",", "$", "params", ")", "=", "get_enrolled_sql", "(", "$", "this", "->", "get_context", "(", ")", ",", "'mod/assign:submit'", ",", "$", "currentgroup", ",", "true", ")", ";", "$", "params", "[", "'assignid'", "]", "=", "$", "this", "->", "get_instance", "(", ")", "->", "id", ";", "$", "params", "[", "'submitted'", "]", "=", "ASSIGN_SUBMISSION_STATUS_SUBMITTED", ";", "$", "sqlscalegrade", "=", "$", "this", "->", "get_instance", "(", ")", "->", "grade", "<", "0", "?", "' OR g.grade = -1'", ":", "''", ";", "$", "sql", "=", "'SELECT COUNT(s.userid)\n FROM {assign_submission} s\n LEFT JOIN {assign_grades} g ON\n s.assignment = g.assignment AND\n s.userid = g.userid AND\n g.attemptnumber = s.attemptnumber\n JOIN('", ".", "$", "esql", ".", "') e ON e.id = s.userid\n WHERE\n s.latest = 1 AND\n s.assignment = :assignid AND\n s.timemodified IS NOT NULL AND\n s.status = :submitted AND\n (s.timemodified >= g.timemodified OR g.timemodified IS NULL OR g.grade IS NULL '", ".", "$", "sqlscalegrade", ".", "')'", ";", "return", "$", "DB", "->", "count_records_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "}" ]
Load a count of active users submissions in the current module that require grading This means the submission modification time is more recent than the grading modification time and the status is SUBMITTED. @param mixed $currentgroup int|null the group for counting (if null the function will determine it) @return int number of matching submissions
[ "Load", "a", "count", "of", "active", "users", "submissions", "in", "the", "current", "module", "that", "require", "grading", "This", "means", "the", "submission", "modification", "time", "is", "more", "recent", "than", "the", "grading", "modification", "time", "and", "the", "status", "is", "SUBMITTED", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L2232-L2265
214,956
moodle/moodle
mod/assign/locallib.php
assign.count_grades
public function count_grades() { global $DB; if (!$this->has_instance()) { return 0; } $currentgroup = groups_get_activity_group($this->get_course_module(), true); list($esql, $params) = get_enrolled_sql($this->get_context(), 'mod/assign:submit', $currentgroup, true); $params['assignid'] = $this->get_instance()->id; $sql = 'SELECT COUNT(g.userid) FROM {assign_grades} g JOIN(' . $esql . ') e ON e.id = g.userid WHERE g.assignment = :assignid'; return $DB->count_records_sql($sql, $params); }
php
public function count_grades() { global $DB; if (!$this->has_instance()) { return 0; } $currentgroup = groups_get_activity_group($this->get_course_module(), true); list($esql, $params) = get_enrolled_sql($this->get_context(), 'mod/assign:submit', $currentgroup, true); $params['assignid'] = $this->get_instance()->id; $sql = 'SELECT COUNT(g.userid) FROM {assign_grades} g JOIN(' . $esql . ') e ON e.id = g.userid WHERE g.assignment = :assignid'; return $DB->count_records_sql($sql, $params); }
[ "public", "function", "count_grades", "(", ")", "{", "global", "$", "DB", ";", "if", "(", "!", "$", "this", "->", "has_instance", "(", ")", ")", "{", "return", "0", ";", "}", "$", "currentgroup", "=", "groups_get_activity_group", "(", "$", "this", "->", "get_course_module", "(", ")", ",", "true", ")", ";", "list", "(", "$", "esql", ",", "$", "params", ")", "=", "get_enrolled_sql", "(", "$", "this", "->", "get_context", "(", ")", ",", "'mod/assign:submit'", ",", "$", "currentgroup", ",", "true", ")", ";", "$", "params", "[", "'assignid'", "]", "=", "$", "this", "->", "get_instance", "(", ")", "->", "id", ";", "$", "sql", "=", "'SELECT COUNT(g.userid)\n FROM {assign_grades} g\n JOIN('", ".", "$", "esql", ".", "') e ON e.id = g.userid\n WHERE g.assignment = :assignid'", ";", "return", "$", "DB", "->", "count_records_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "}" ]
Load a count of grades. @return int number of grades
[ "Load", "a", "count", "of", "grades", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L2272-L2290
214,957
moodle/moodle
mod/assign/locallib.php
assign.count_submissions
public function count_submissions($includenew = false) { global $DB; if (!$this->has_instance()) { return 0; } $params = array(); $sqlnew = ''; if (!$includenew) { $sqlnew = ' AND s.status <> :status '; $params['status'] = ASSIGN_SUBMISSION_STATUS_NEW; } if ($this->get_instance()->teamsubmission) { // We cannot join on the enrolment tables for group submissions (no userid). $sql = 'SELECT COUNT(DISTINCT s.groupid) FROM {assign_submission} s WHERE s.assignment = :assignid AND s.timemodified IS NOT NULL AND s.userid = :groupuserid' . $sqlnew; $params['assignid'] = $this->get_instance()->id; $params['groupuserid'] = 0; } else { $currentgroup = groups_get_activity_group($this->get_course_module(), true); list($esql, $enrolparams) = get_enrolled_sql($this->get_context(), 'mod/assign:submit', $currentgroup, true); $params = array_merge($params, $enrolparams); $params['assignid'] = $this->get_instance()->id; $sql = 'SELECT COUNT(DISTINCT s.userid) FROM {assign_submission} s JOIN(' . $esql . ') e ON e.id = s.userid WHERE s.assignment = :assignid AND s.timemodified IS NOT NULL ' . $sqlnew; } return $DB->count_records_sql($sql, $params); }
php
public function count_submissions($includenew = false) { global $DB; if (!$this->has_instance()) { return 0; } $params = array(); $sqlnew = ''; if (!$includenew) { $sqlnew = ' AND s.status <> :status '; $params['status'] = ASSIGN_SUBMISSION_STATUS_NEW; } if ($this->get_instance()->teamsubmission) { // We cannot join on the enrolment tables for group submissions (no userid). $sql = 'SELECT COUNT(DISTINCT s.groupid) FROM {assign_submission} s WHERE s.assignment = :assignid AND s.timemodified IS NOT NULL AND s.userid = :groupuserid' . $sqlnew; $params['assignid'] = $this->get_instance()->id; $params['groupuserid'] = 0; } else { $currentgroup = groups_get_activity_group($this->get_course_module(), true); list($esql, $enrolparams) = get_enrolled_sql($this->get_context(), 'mod/assign:submit', $currentgroup, true); $params = array_merge($params, $enrolparams); $params['assignid'] = $this->get_instance()->id; $sql = 'SELECT COUNT(DISTINCT s.userid) FROM {assign_submission} s JOIN(' . $esql . ') e ON e.id = s.userid WHERE s.assignment = :assignid AND s.timemodified IS NOT NULL ' . $sqlnew; } return $DB->count_records_sql($sql, $params); }
[ "public", "function", "count_submissions", "(", "$", "includenew", "=", "false", ")", "{", "global", "$", "DB", ";", "if", "(", "!", "$", "this", "->", "has_instance", "(", ")", ")", "{", "return", "0", ";", "}", "$", "params", "=", "array", "(", ")", ";", "$", "sqlnew", "=", "''", ";", "if", "(", "!", "$", "includenew", ")", "{", "$", "sqlnew", "=", "' AND s.status <> :status '", ";", "$", "params", "[", "'status'", "]", "=", "ASSIGN_SUBMISSION_STATUS_NEW", ";", "}", "if", "(", "$", "this", "->", "get_instance", "(", ")", "->", "teamsubmission", ")", "{", "// We cannot join on the enrolment tables for group submissions (no userid).", "$", "sql", "=", "'SELECT COUNT(DISTINCT s.groupid)\n FROM {assign_submission} s\n WHERE\n s.assignment = :assignid AND\n s.timemodified IS NOT NULL AND\n s.userid = :groupuserid'", ".", "$", "sqlnew", ";", "$", "params", "[", "'assignid'", "]", "=", "$", "this", "->", "get_instance", "(", ")", "->", "id", ";", "$", "params", "[", "'groupuserid'", "]", "=", "0", ";", "}", "else", "{", "$", "currentgroup", "=", "groups_get_activity_group", "(", "$", "this", "->", "get_course_module", "(", ")", ",", "true", ")", ";", "list", "(", "$", "esql", ",", "$", "enrolparams", ")", "=", "get_enrolled_sql", "(", "$", "this", "->", "get_context", "(", ")", ",", "'mod/assign:submit'", ",", "$", "currentgroup", ",", "true", ")", ";", "$", "params", "=", "array_merge", "(", "$", "params", ",", "$", "enrolparams", ")", ";", "$", "params", "[", "'assignid'", "]", "=", "$", "this", "->", "get_instance", "(", ")", "->", "id", ";", "$", "sql", "=", "'SELECT COUNT(DISTINCT s.userid)\n FROM {assign_submission} s\n JOIN('", ".", "$", "esql", ".", "') e ON e.id = s.userid\n WHERE\n s.assignment = :assignid AND\n s.timemodified IS NOT NULL '", ".", "$", "sqlnew", ";", "}", "return", "$", "DB", "->", "count_records_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "}" ]
Load a count of submissions. @param bool $includenew When true, also counts the submissions with status 'new'. @return int number of submissions
[ "Load", "a", "count", "of", "submissions", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L2298-L2343
214,958
moodle/moodle
mod/assign/locallib.php
assign.count_submissions_with_status
public function count_submissions_with_status($status, $currentgroup = null) { global $DB; if ($currentgroup === null) { $currentgroup = groups_get_activity_group($this->get_course_module(), true); } list($esql, $params) = get_enrolled_sql($this->get_context(), 'mod/assign:submit', $currentgroup, true); $params['assignid'] = $this->get_instance()->id; $params['assignid2'] = $this->get_instance()->id; $params['submissionstatus'] = $status; if ($this->get_instance()->teamsubmission) { $groupsstr = ''; if ($currentgroup != 0) { // If there is an active group we should only display the current group users groups. $participants = $this->list_participants($currentgroup, true); $groups = groups_get_all_groups($this->get_course()->id, array_keys($participants), $this->get_instance()->teamsubmissiongroupingid, 'DISTINCT g.id, g.name'); if (empty($groups)) { // If $groups is empty it means it is not part of $this->get_instance()->teamsubmissiongroupingid. // All submissions from students that do not belong to any of teamsubmissiongroupingid groups // count towards groupid = 0. Setting to true as only '0' key matters. $groups = [true]; } list($groupssql, $groupsparams) = $DB->get_in_or_equal(array_keys($groups), SQL_PARAMS_NAMED); $groupsstr = 's.groupid ' . $groupssql . ' AND'; $params = $params + $groupsparams; } $sql = 'SELECT COUNT(s.groupid) FROM {assign_submission} s WHERE s.latest = 1 AND s.assignment = :assignid AND s.timemodified IS NOT NULL AND s.userid = :groupuserid AND ' . $groupsstr . ' s.status = :submissionstatus'; $params['groupuserid'] = 0; } else { $sql = 'SELECT COUNT(s.userid) FROM {assign_submission} s JOIN(' . $esql . ') e ON e.id = s.userid WHERE s.latest = 1 AND s.assignment = :assignid AND s.timemodified IS NOT NULL AND s.status = :submissionstatus'; } return $DB->count_records_sql($sql, $params); }
php
public function count_submissions_with_status($status, $currentgroup = null) { global $DB; if ($currentgroup === null) { $currentgroup = groups_get_activity_group($this->get_course_module(), true); } list($esql, $params) = get_enrolled_sql($this->get_context(), 'mod/assign:submit', $currentgroup, true); $params['assignid'] = $this->get_instance()->id; $params['assignid2'] = $this->get_instance()->id; $params['submissionstatus'] = $status; if ($this->get_instance()->teamsubmission) { $groupsstr = ''; if ($currentgroup != 0) { // If there is an active group we should only display the current group users groups. $participants = $this->list_participants($currentgroup, true); $groups = groups_get_all_groups($this->get_course()->id, array_keys($participants), $this->get_instance()->teamsubmissiongroupingid, 'DISTINCT g.id, g.name'); if (empty($groups)) { // If $groups is empty it means it is not part of $this->get_instance()->teamsubmissiongroupingid. // All submissions from students that do not belong to any of teamsubmissiongroupingid groups // count towards groupid = 0. Setting to true as only '0' key matters. $groups = [true]; } list($groupssql, $groupsparams) = $DB->get_in_or_equal(array_keys($groups), SQL_PARAMS_NAMED); $groupsstr = 's.groupid ' . $groupssql . ' AND'; $params = $params + $groupsparams; } $sql = 'SELECT COUNT(s.groupid) FROM {assign_submission} s WHERE s.latest = 1 AND s.assignment = :assignid AND s.timemodified IS NOT NULL AND s.userid = :groupuserid AND ' . $groupsstr . ' s.status = :submissionstatus'; $params['groupuserid'] = 0; } else { $sql = 'SELECT COUNT(s.userid) FROM {assign_submission} s JOIN(' . $esql . ') e ON e.id = s.userid WHERE s.latest = 1 AND s.assignment = :assignid AND s.timemodified IS NOT NULL AND s.status = :submissionstatus'; } return $DB->count_records_sql($sql, $params); }
[ "public", "function", "count_submissions_with_status", "(", "$", "status", ",", "$", "currentgroup", "=", "null", ")", "{", "global", "$", "DB", ";", "if", "(", "$", "currentgroup", "===", "null", ")", "{", "$", "currentgroup", "=", "groups_get_activity_group", "(", "$", "this", "->", "get_course_module", "(", ")", ",", "true", ")", ";", "}", "list", "(", "$", "esql", ",", "$", "params", ")", "=", "get_enrolled_sql", "(", "$", "this", "->", "get_context", "(", ")", ",", "'mod/assign:submit'", ",", "$", "currentgroup", ",", "true", ")", ";", "$", "params", "[", "'assignid'", "]", "=", "$", "this", "->", "get_instance", "(", ")", "->", "id", ";", "$", "params", "[", "'assignid2'", "]", "=", "$", "this", "->", "get_instance", "(", ")", "->", "id", ";", "$", "params", "[", "'submissionstatus'", "]", "=", "$", "status", ";", "if", "(", "$", "this", "->", "get_instance", "(", ")", "->", "teamsubmission", ")", "{", "$", "groupsstr", "=", "''", ";", "if", "(", "$", "currentgroup", "!=", "0", ")", "{", "// If there is an active group we should only display the current group users groups.", "$", "participants", "=", "$", "this", "->", "list_participants", "(", "$", "currentgroup", ",", "true", ")", ";", "$", "groups", "=", "groups_get_all_groups", "(", "$", "this", "->", "get_course", "(", ")", "->", "id", ",", "array_keys", "(", "$", "participants", ")", ",", "$", "this", "->", "get_instance", "(", ")", "->", "teamsubmissiongroupingid", ",", "'DISTINCT g.id, g.name'", ")", ";", "if", "(", "empty", "(", "$", "groups", ")", ")", "{", "// If $groups is empty it means it is not part of $this->get_instance()->teamsubmissiongroupingid.", "// All submissions from students that do not belong to any of teamsubmissiongroupingid groups", "// count towards groupid = 0. Setting to true as only '0' key matters.", "$", "groups", "=", "[", "true", "]", ";", "}", "list", "(", "$", "groupssql", ",", "$", "groupsparams", ")", "=", "$", "DB", "->", "get_in_or_equal", "(", "array_keys", "(", "$", "groups", ")", ",", "SQL_PARAMS_NAMED", ")", ";", "$", "groupsstr", "=", "'s.groupid '", ".", "$", "groupssql", ".", "' AND'", ";", "$", "params", "=", "$", "params", "+", "$", "groupsparams", ";", "}", "$", "sql", "=", "'SELECT COUNT(s.groupid)\n FROM {assign_submission} s\n WHERE\n s.latest = 1 AND\n s.assignment = :assignid AND\n s.timemodified IS NOT NULL AND\n s.userid = :groupuserid AND '", ".", "$", "groupsstr", ".", "'\n s.status = :submissionstatus'", ";", "$", "params", "[", "'groupuserid'", "]", "=", "0", ";", "}", "else", "{", "$", "sql", "=", "'SELECT COUNT(s.userid)\n FROM {assign_submission} s\n JOIN('", ".", "$", "esql", ".", "') e ON e.id = s.userid\n WHERE\n s.latest = 1 AND\n s.assignment = :assignid AND\n s.timemodified IS NOT NULL AND\n s.status = :submissionstatus'", ";", "}", "return", "$", "DB", "->", "count_records_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "}" ]
Load a count of submissions with a specified status. @param string $status The submission status - should match one of the constants @param mixed $currentgroup int|null the group for counting (if null the function will determine it) @return int number of matching submissions
[ "Load", "a", "count", "of", "submissions", "with", "a", "specified", "status", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L2352-L2407
214,959
moodle/moodle
mod/assign/locallib.php
assign.get_grading_userid_list
protected function get_grading_userid_list($cached = false, $useridlistid = '') { if ($cached) { if (empty($useridlistid)) { $useridlistid = $this->get_useridlist_key_id(); } $useridlistkey = $this->get_useridlist_key($useridlistid); if (empty($SESSION->mod_assign_useridlist[$useridlistkey])) { $SESSION->mod_assign_useridlist[$useridlistkey] = $this->get_grading_userid_list(false, ''); } return $SESSION->mod_assign_useridlist[$useridlistkey]; } $filter = get_user_preferences('assign_filter', ''); $table = new assign_grading_table($this, 0, $filter, 0, false); $useridlist = $table->get_column_data('userid'); return $useridlist; }
php
protected function get_grading_userid_list($cached = false, $useridlistid = '') { if ($cached) { if (empty($useridlistid)) { $useridlistid = $this->get_useridlist_key_id(); } $useridlistkey = $this->get_useridlist_key($useridlistid); if (empty($SESSION->mod_assign_useridlist[$useridlistkey])) { $SESSION->mod_assign_useridlist[$useridlistkey] = $this->get_grading_userid_list(false, ''); } return $SESSION->mod_assign_useridlist[$useridlistkey]; } $filter = get_user_preferences('assign_filter', ''); $table = new assign_grading_table($this, 0, $filter, 0, false); $useridlist = $table->get_column_data('userid'); return $useridlist; }
[ "protected", "function", "get_grading_userid_list", "(", "$", "cached", "=", "false", ",", "$", "useridlistid", "=", "''", ")", "{", "if", "(", "$", "cached", ")", "{", "if", "(", "empty", "(", "$", "useridlistid", ")", ")", "{", "$", "useridlistid", "=", "$", "this", "->", "get_useridlist_key_id", "(", ")", ";", "}", "$", "useridlistkey", "=", "$", "this", "->", "get_useridlist_key", "(", "$", "useridlistid", ")", ";", "if", "(", "empty", "(", "$", "SESSION", "->", "mod_assign_useridlist", "[", "$", "useridlistkey", "]", ")", ")", "{", "$", "SESSION", "->", "mod_assign_useridlist", "[", "$", "useridlistkey", "]", "=", "$", "this", "->", "get_grading_userid_list", "(", "false", ",", "''", ")", ";", "}", "return", "$", "SESSION", "->", "mod_assign_useridlist", "[", "$", "useridlistkey", "]", ";", "}", "$", "filter", "=", "get_user_preferences", "(", "'assign_filter'", ",", "''", ")", ";", "$", "table", "=", "new", "assign_grading_table", "(", "$", "this", ",", "0", ",", "$", "filter", ",", "0", ",", "false", ")", ";", "$", "useridlist", "=", "$", "table", "->", "get_column_data", "(", "'userid'", ")", ";", "return", "$", "useridlist", ";", "}" ]
Utility function to get the userid for every row in the grading table so the order can be frozen while we iterate it. @param boolean $cached If true, the cached list from the session could be returned. @param string $useridlistid String value used for caching the participant list. @return array An array of userids
[ "Utility", "function", "to", "get", "the", "userid", "for", "every", "row", "in", "the", "grading", "table", "so", "the", "order", "can", "be", "frozen", "while", "we", "iterate", "it", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L2417-L2434
214,960
moodle/moodle
mod/assign/locallib.php
assign.pack_files
protected function pack_files($filesforzipping) { global $CFG; // Create path for new zip file. $tempzip = tempnam($CFG->tempdir . '/', 'assignment_'); // Zip files. $zipper = new zip_packer(); if ($zipper->archive_to_pathname($filesforzipping, $tempzip)) { return $tempzip; } return false; }
php
protected function pack_files($filesforzipping) { global $CFG; // Create path for new zip file. $tempzip = tempnam($CFG->tempdir . '/', 'assignment_'); // Zip files. $zipper = new zip_packer(); if ($zipper->archive_to_pathname($filesforzipping, $tempzip)) { return $tempzip; } return false; }
[ "protected", "function", "pack_files", "(", "$", "filesforzipping", ")", "{", "global", "$", "CFG", ";", "// Create path for new zip file.", "$", "tempzip", "=", "tempnam", "(", "$", "CFG", "->", "tempdir", ".", "'/'", ",", "'assignment_'", ")", ";", "// Zip files.", "$", "zipper", "=", "new", "zip_packer", "(", ")", ";", "if", "(", "$", "zipper", "->", "archive_to_pathname", "(", "$", "filesforzipping", ",", "$", "tempzip", ")", ")", "{", "return", "$", "tempzip", ";", "}", "return", "false", ";", "}" ]
Generate zip file from array of given files. @param array $filesforzipping - array of files to pass into archive_to_pathname. This array is indexed by the final file name and each element in the array is an instance of a stored_file object. @return path of temp file - note this returned file does not have a .zip extension - it is a temp file.
[ "Generate", "zip", "file", "from", "array", "of", "given", "files", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L2445-L2455
214,961
moodle/moodle
mod/assign/locallib.php
assign.notify_grade_modified
public function notify_grade_modified($grade, $mailedoverride = false) { global $DB; $flags = $this->get_user_flags($grade->userid, true); if ($flags->mailed != 1 || $mailedoverride) { $flags->mailed = 0; } return $this->update_user_flags($flags); }
php
public function notify_grade_modified($grade, $mailedoverride = false) { global $DB; $flags = $this->get_user_flags($grade->userid, true); if ($flags->mailed != 1 || $mailedoverride) { $flags->mailed = 0; } return $this->update_user_flags($flags); }
[ "public", "function", "notify_grade_modified", "(", "$", "grade", ",", "$", "mailedoverride", "=", "false", ")", "{", "global", "$", "DB", ";", "$", "flags", "=", "$", "this", "->", "get_user_flags", "(", "$", "grade", "->", "userid", ",", "true", ")", ";", "if", "(", "$", "flags", "->", "mailed", "!=", "1", "||", "$", "mailedoverride", ")", "{", "$", "flags", "->", "mailed", "=", "0", ";", "}", "return", "$", "this", "->", "update_user_flags", "(", "$", "flags", ")", ";", "}" ]
Mark in the database that this grade record should have an update notification sent by cron. @param stdClass $grade a grade record keyed on id @param bool $mailedoverride when true, flag notification to be sent again. @return bool true for success
[ "Mark", "in", "the", "database", "that", "this", "grade", "record", "should", "have", "an", "update", "notification", "sent", "by", "cron", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L2665-L2674
214,962
moodle/moodle
mod/assign/locallib.php
assign.update_user_flags
public function update_user_flags($flags) { global $DB; if ($flags->userid <= 0 || $flags->assignment <= 0 || $flags->id <= 0) { return false; } $result = $DB->update_record('assign_user_flags', $flags); return $result; }
php
public function update_user_flags($flags) { global $DB; if ($flags->userid <= 0 || $flags->assignment <= 0 || $flags->id <= 0) { return false; } $result = $DB->update_record('assign_user_flags', $flags); return $result; }
[ "public", "function", "update_user_flags", "(", "$", "flags", ")", "{", "global", "$", "DB", ";", "if", "(", "$", "flags", "->", "userid", "<=", "0", "||", "$", "flags", "->", "assignment", "<=", "0", "||", "$", "flags", "->", "id", "<=", "0", ")", "{", "return", "false", ";", "}", "$", "result", "=", "$", "DB", "->", "update_record", "(", "'assign_user_flags'", ",", "$", "flags", ")", ";", "return", "$", "result", ";", "}" ]
Update user flags for this user in this assignment. @param stdClass $flags a flags record keyed on id @return bool true for success
[ "Update", "user", "flags", "for", "this", "user", "in", "this", "assignment", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L2682-L2690
214,963
moodle/moodle
mod/assign/locallib.php
assign.update_grade
public function update_grade($grade, $reopenattempt = false) { global $DB; $grade->timemodified = time(); if (!empty($grade->workflowstate)) { $validstates = $this->get_marking_workflow_states_for_current_user(); if (!array_key_exists($grade->workflowstate, $validstates)) { return false; } } if ($grade->grade && $grade->grade != -1) { if ($this->get_instance()->grade > 0) { if (!is_numeric($grade->grade)) { return false; } else if ($grade->grade > $this->get_instance()->grade) { return false; } else if ($grade->grade < 0) { return false; } } else { // This is a scale. if ($scale = $DB->get_record('scale', array('id' => -($this->get_instance()->grade)))) { $scaleoptions = make_menu_from_list($scale->scale); if (!array_key_exists((int) $grade->grade, $scaleoptions)) { return false; } } } } if (empty($grade->attemptnumber)) { // Set it to the default. $grade->attemptnumber = 0; } $DB->update_record('assign_grades', $grade); $submission = null; if ($this->get_instance()->teamsubmission) { if (isset($this->mostrecentteamsubmission)) { $submission = $this->mostrecentteamsubmission; } else { $submission = $this->get_group_submission($grade->userid, 0, false); } } else { $submission = $this->get_user_submission($grade->userid, false); } // Only push to gradebook if the update is for the most recent attempt. if ($submission && $submission->attemptnumber != $grade->attemptnumber) { return true; } if ($this->gradebook_item_update(null, $grade)) { \mod_assign\event\submission_graded::create_from_grade($this, $grade)->trigger(); } // If the conditions are met, allow another attempt. if ($submission) { $this->reopen_submission_if_required($grade->userid, $submission, $reopenattempt); } return true; }
php
public function update_grade($grade, $reopenattempt = false) { global $DB; $grade->timemodified = time(); if (!empty($grade->workflowstate)) { $validstates = $this->get_marking_workflow_states_for_current_user(); if (!array_key_exists($grade->workflowstate, $validstates)) { return false; } } if ($grade->grade && $grade->grade != -1) { if ($this->get_instance()->grade > 0) { if (!is_numeric($grade->grade)) { return false; } else if ($grade->grade > $this->get_instance()->grade) { return false; } else if ($grade->grade < 0) { return false; } } else { // This is a scale. if ($scale = $DB->get_record('scale', array('id' => -($this->get_instance()->grade)))) { $scaleoptions = make_menu_from_list($scale->scale); if (!array_key_exists((int) $grade->grade, $scaleoptions)) { return false; } } } } if (empty($grade->attemptnumber)) { // Set it to the default. $grade->attemptnumber = 0; } $DB->update_record('assign_grades', $grade); $submission = null; if ($this->get_instance()->teamsubmission) { if (isset($this->mostrecentteamsubmission)) { $submission = $this->mostrecentteamsubmission; } else { $submission = $this->get_group_submission($grade->userid, 0, false); } } else { $submission = $this->get_user_submission($grade->userid, false); } // Only push to gradebook if the update is for the most recent attempt. if ($submission && $submission->attemptnumber != $grade->attemptnumber) { return true; } if ($this->gradebook_item_update(null, $grade)) { \mod_assign\event\submission_graded::create_from_grade($this, $grade)->trigger(); } // If the conditions are met, allow another attempt. if ($submission) { $this->reopen_submission_if_required($grade->userid, $submission, $reopenattempt); } return true; }
[ "public", "function", "update_grade", "(", "$", "grade", ",", "$", "reopenattempt", "=", "false", ")", "{", "global", "$", "DB", ";", "$", "grade", "->", "timemodified", "=", "time", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "grade", "->", "workflowstate", ")", ")", "{", "$", "validstates", "=", "$", "this", "->", "get_marking_workflow_states_for_current_user", "(", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "grade", "->", "workflowstate", ",", "$", "validstates", ")", ")", "{", "return", "false", ";", "}", "}", "if", "(", "$", "grade", "->", "grade", "&&", "$", "grade", "->", "grade", "!=", "-", "1", ")", "{", "if", "(", "$", "this", "->", "get_instance", "(", ")", "->", "grade", ">", "0", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "grade", "->", "grade", ")", ")", "{", "return", "false", ";", "}", "else", "if", "(", "$", "grade", "->", "grade", ">", "$", "this", "->", "get_instance", "(", ")", "->", "grade", ")", "{", "return", "false", ";", "}", "else", "if", "(", "$", "grade", "->", "grade", "<", "0", ")", "{", "return", "false", ";", "}", "}", "else", "{", "// This is a scale.", "if", "(", "$", "scale", "=", "$", "DB", "->", "get_record", "(", "'scale'", ",", "array", "(", "'id'", "=>", "-", "(", "$", "this", "->", "get_instance", "(", ")", "->", "grade", ")", ")", ")", ")", "{", "$", "scaleoptions", "=", "make_menu_from_list", "(", "$", "scale", "->", "scale", ")", ";", "if", "(", "!", "array_key_exists", "(", "(", "int", ")", "$", "grade", "->", "grade", ",", "$", "scaleoptions", ")", ")", "{", "return", "false", ";", "}", "}", "}", "}", "if", "(", "empty", "(", "$", "grade", "->", "attemptnumber", ")", ")", "{", "// Set it to the default.", "$", "grade", "->", "attemptnumber", "=", "0", ";", "}", "$", "DB", "->", "update_record", "(", "'assign_grades'", ",", "$", "grade", ")", ";", "$", "submission", "=", "null", ";", "if", "(", "$", "this", "->", "get_instance", "(", ")", "->", "teamsubmission", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "mostrecentteamsubmission", ")", ")", "{", "$", "submission", "=", "$", "this", "->", "mostrecentteamsubmission", ";", "}", "else", "{", "$", "submission", "=", "$", "this", "->", "get_group_submission", "(", "$", "grade", "->", "userid", ",", "0", ",", "false", ")", ";", "}", "}", "else", "{", "$", "submission", "=", "$", "this", "->", "get_user_submission", "(", "$", "grade", "->", "userid", ",", "false", ")", ";", "}", "// Only push to gradebook if the update is for the most recent attempt.", "if", "(", "$", "submission", "&&", "$", "submission", "->", "attemptnumber", "!=", "$", "grade", "->", "attemptnumber", ")", "{", "return", "true", ";", "}", "if", "(", "$", "this", "->", "gradebook_item_update", "(", "null", ",", "$", "grade", ")", ")", "{", "\\", "mod_assign", "\\", "event", "\\", "submission_graded", "::", "create_from_grade", "(", "$", "this", ",", "$", "grade", ")", "->", "trigger", "(", ")", ";", "}", "// If the conditions are met, allow another attempt.", "if", "(", "$", "submission", ")", "{", "$", "this", "->", "reopen_submission_if_required", "(", "$", "grade", "->", "userid", ",", "$", "submission", ",", "$", "reopenattempt", ")", ";", "}", "return", "true", ";", "}" ]
Update a grade in the grade table for the assignment and in the gradebook. @param stdClass $grade a grade record keyed on id @param bool $reopenattempt If the attempt reopen method is manual, allow another attempt at this assignment. @return bool true for success
[ "Update", "a", "grade", "in", "the", "grade", "table", "for", "the", "assignment", "and", "in", "the", "gradebook", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L2699-L2765
214,964
moodle/moodle
mod/assign/locallib.php
assign.view_grant_extension
protected function view_grant_extension($mform) { global $CFG; require_once($CFG->dirroot . '/mod/assign/extensionform.php'); $o = ''; $data = new stdClass(); $data->id = $this->get_course_module()->id; $formparams = array( 'instance' => $this->get_instance(), 'assign' => $this ); $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['userlist'] = $userlist; $data->selectedusers = $users; $data->userid = 0; if (empty($mform)) { $mform = new mod_assign_extension_form(null, $formparams); } $mform->set_data($data); $header = new assign_header($this->get_instance(), $this->get_context(), $this->show_intro(), $this->get_course_module()->id, get_string('grantextension', 'assign')); $o .= $this->get_renderer()->render($header); $o .= $this->get_renderer()->render(new assign_form('extensionform', $mform)); $o .= $this->view_footer(); return $o; }
php
protected function view_grant_extension($mform) { global $CFG; require_once($CFG->dirroot . '/mod/assign/extensionform.php'); $o = ''; $data = new stdClass(); $data->id = $this->get_course_module()->id; $formparams = array( 'instance' => $this->get_instance(), 'assign' => $this ); $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['userlist'] = $userlist; $data->selectedusers = $users; $data->userid = 0; if (empty($mform)) { $mform = new mod_assign_extension_form(null, $formparams); } $mform->set_data($data); $header = new assign_header($this->get_instance(), $this->get_context(), $this->show_intro(), $this->get_course_module()->id, get_string('grantextension', 'assign')); $o .= $this->get_renderer()->render($header); $o .= $this->get_renderer()->render(new assign_form('extensionform', $mform)); $o .= $this->view_footer(); return $o; }
[ "protected", "function", "view_grant_extension", "(", "$", "mform", ")", "{", "global", "$", "CFG", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/mod/assign/extensionform.php'", ")", ";", "$", "o", "=", "''", ";", "$", "data", "=", "new", "stdClass", "(", ")", ";", "$", "data", "->", "id", "=", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ";", "$", "formparams", "=", "array", "(", "'instance'", "=>", "$", "this", "->", "get_instance", "(", ")", ",", "'assign'", "=>", "$", "this", ")", ";", "$", "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", "[", "'userlist'", "]", "=", "$", "userlist", ";", "$", "data", "->", "selectedusers", "=", "$", "users", ";", "$", "data", "->", "userid", "=", "0", ";", "if", "(", "empty", "(", "$", "mform", ")", ")", "{", "$", "mform", "=", "new", "mod_assign_extension_form", "(", "null", ",", "$", "formparams", ")", ";", "}", "$", "mform", "->", "set_data", "(", "$", "data", ")", ";", "$", "header", "=", "new", "assign_header", "(", "$", "this", "->", "get_instance", "(", ")", ",", "$", "this", "->", "get_context", "(", ")", ",", "$", "this", "->", "show_intro", "(", ")", ",", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "get_string", "(", "'grantextension'", ",", "'assign'", ")", ")", ";", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "$", "header", ")", ";", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "new", "assign_form", "(", "'extensionform'", ",", "$", "mform", ")", ")", ";", "$", "o", ".=", "$", "this", "->", "view_footer", "(", ")", ";", "return", "$", "o", ";", "}" ]
View the grant extension date page. Uses url parameters 'userid' or from parameter 'selectedusers' @param moodleform $mform - Used for validation of the submitted data @return string
[ "View", "the", "grant", "extension", "date", "page", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L2776-L2835
214,965
moodle/moodle
mod/assign/locallib.php
assign.get_submission_group_members
public function get_submission_group_members($groupid, $onlyids, $excludesuspended = false) { $members = array(); if ($groupid != 0) { $allusers = $this->list_participants($groupid, $onlyids); foreach ($allusers as $user) { if ($this->get_submission_group($user->id)) { $members[] = $user; } } } else { $allusers = $this->list_participants(null, $onlyids); foreach ($allusers as $user) { if ($this->get_submission_group($user->id) == null) { $members[] = $user; } } } // Exclude suspended users, if user can't see them. if ($excludesuspended || !has_capability('moodle/course:viewsuspendedusers', $this->context)) { foreach ($members as $key => $member) { if (!$this->is_active_user($member->id)) { unset($members[$key]); } } } return $members; }
php
public function get_submission_group_members($groupid, $onlyids, $excludesuspended = false) { $members = array(); if ($groupid != 0) { $allusers = $this->list_participants($groupid, $onlyids); foreach ($allusers as $user) { if ($this->get_submission_group($user->id)) { $members[] = $user; } } } else { $allusers = $this->list_participants(null, $onlyids); foreach ($allusers as $user) { if ($this->get_submission_group($user->id) == null) { $members[] = $user; } } } // Exclude suspended users, if user can't see them. if ($excludesuspended || !has_capability('moodle/course:viewsuspendedusers', $this->context)) { foreach ($members as $key => $member) { if (!$this->is_active_user($member->id)) { unset($members[$key]); } } } return $members; }
[ "public", "function", "get_submission_group_members", "(", "$", "groupid", ",", "$", "onlyids", ",", "$", "excludesuspended", "=", "false", ")", "{", "$", "members", "=", "array", "(", ")", ";", "if", "(", "$", "groupid", "!=", "0", ")", "{", "$", "allusers", "=", "$", "this", "->", "list_participants", "(", "$", "groupid", ",", "$", "onlyids", ")", ";", "foreach", "(", "$", "allusers", "as", "$", "user", ")", "{", "if", "(", "$", "this", "->", "get_submission_group", "(", "$", "user", "->", "id", ")", ")", "{", "$", "members", "[", "]", "=", "$", "user", ";", "}", "}", "}", "else", "{", "$", "allusers", "=", "$", "this", "->", "list_participants", "(", "null", ",", "$", "onlyids", ")", ";", "foreach", "(", "$", "allusers", "as", "$", "user", ")", "{", "if", "(", "$", "this", "->", "get_submission_group", "(", "$", "user", "->", "id", ")", "==", "null", ")", "{", "$", "members", "[", "]", "=", "$", "user", ";", "}", "}", "}", "// Exclude suspended users, if user can't see them.", "if", "(", "$", "excludesuspended", "||", "!", "has_capability", "(", "'moodle/course:viewsuspendedusers'", ",", "$", "this", "->", "context", ")", ")", "{", "foreach", "(", "$", "members", "as", "$", "key", "=>", "$", "member", ")", "{", "if", "(", "!", "$", "this", "->", "is_active_user", "(", "$", "member", "->", "id", ")", ")", "{", "unset", "(", "$", "members", "[", "$", "key", "]", ")", ";", "}", "}", "}", "return", "$", "members", ";", "}" ]
Get a list of the users in the same group as this user. @param int $groupid The id of the group whose members we want or 0 for the default group @param bool $onlyids Whether to retrieve only the user id's @param bool $excludesuspended Whether to exclude suspended users @return array The users (possibly id's only)
[ "Get", "a", "list", "of", "the", "users", "in", "the", "same", "group", "as", "this", "user", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L2845-L2872
214,966
moodle/moodle
mod/assign/locallib.php
assign.get_submission_group_members_who_have_not_submitted
public function get_submission_group_members_who_have_not_submitted($groupid, $onlyids) { $instance = $this->get_instance(); if (!$instance->teamsubmission || !$instance->requireallteammemberssubmit) { return array(); } $members = $this->get_submission_group_members($groupid, $onlyids); foreach ($members as $id => $member) { $submission = $this->get_user_submission($member->id, false); if ($submission && $submission->status == ASSIGN_SUBMISSION_STATUS_SUBMITTED) { unset($members[$id]); } else { if ($this->is_blind_marking()) { $members[$id]->alias = get_string('hiddenuser', 'assign') . $this->get_uniqueid_for_user($id); } } } return $members; }
php
public function get_submission_group_members_who_have_not_submitted($groupid, $onlyids) { $instance = $this->get_instance(); if (!$instance->teamsubmission || !$instance->requireallteammemberssubmit) { return array(); } $members = $this->get_submission_group_members($groupid, $onlyids); foreach ($members as $id => $member) { $submission = $this->get_user_submission($member->id, false); if ($submission && $submission->status == ASSIGN_SUBMISSION_STATUS_SUBMITTED) { unset($members[$id]); } else { if ($this->is_blind_marking()) { $members[$id]->alias = get_string('hiddenuser', 'assign') . $this->get_uniqueid_for_user($id); } } } return $members; }
[ "public", "function", "get_submission_group_members_who_have_not_submitted", "(", "$", "groupid", ",", "$", "onlyids", ")", "{", "$", "instance", "=", "$", "this", "->", "get_instance", "(", ")", ";", "if", "(", "!", "$", "instance", "->", "teamsubmission", "||", "!", "$", "instance", "->", "requireallteammemberssubmit", ")", "{", "return", "array", "(", ")", ";", "}", "$", "members", "=", "$", "this", "->", "get_submission_group_members", "(", "$", "groupid", ",", "$", "onlyids", ")", ";", "foreach", "(", "$", "members", "as", "$", "id", "=>", "$", "member", ")", "{", "$", "submission", "=", "$", "this", "->", "get_user_submission", "(", "$", "member", "->", "id", ",", "false", ")", ";", "if", "(", "$", "submission", "&&", "$", "submission", "->", "status", "==", "ASSIGN_SUBMISSION_STATUS_SUBMITTED", ")", "{", "unset", "(", "$", "members", "[", "$", "id", "]", ")", ";", "}", "else", "{", "if", "(", "$", "this", "->", "is_blind_marking", "(", ")", ")", "{", "$", "members", "[", "$", "id", "]", "->", "alias", "=", "get_string", "(", "'hiddenuser'", ",", "'assign'", ")", ".", "$", "this", "->", "get_uniqueid_for_user", "(", "$", "id", ")", ";", "}", "}", "}", "return", "$", "members", ";", "}" ]
Get a list of the users in the same group as this user that have not submitted the assignment. @param int $groupid The id of the group whose members we want or 0 for the default group @param bool $onlyids Whether to retrieve only the user id's @return array The users (possibly id's only)
[ "Get", "a", "list", "of", "the", "users", "in", "the", "same", "group", "as", "this", "user", "that", "have", "not", "submitted", "the", "assignment", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L2881-L2900
214,967
moodle/moodle
mod/assign/locallib.php
assign.view_plugin_page
protected function view_plugin_page() { global $USER; $o = ''; $pluginsubtype = required_param('pluginsubtype', PARAM_ALPHA); $plugintype = required_param('plugin', PARAM_PLUGIN); $pluginaction = required_param('pluginaction', PARAM_ALPHA); $plugin = $this->get_plugin_by_type($pluginsubtype, $plugintype); if (!$plugin) { print_error('invalidformdata', ''); return; } $o .= $plugin->view_page($pluginaction); return $o; }
php
protected function view_plugin_page() { global $USER; $o = ''; $pluginsubtype = required_param('pluginsubtype', PARAM_ALPHA); $plugintype = required_param('plugin', PARAM_PLUGIN); $pluginaction = required_param('pluginaction', PARAM_ALPHA); $plugin = $this->get_plugin_by_type($pluginsubtype, $plugintype); if (!$plugin) { print_error('invalidformdata', ''); return; } $o .= $plugin->view_page($pluginaction); return $o; }
[ "protected", "function", "view_plugin_page", "(", ")", "{", "global", "$", "USER", ";", "$", "o", "=", "''", ";", "$", "pluginsubtype", "=", "required_param", "(", "'pluginsubtype'", ",", "PARAM_ALPHA", ")", ";", "$", "plugintype", "=", "required_param", "(", "'plugin'", ",", "PARAM_PLUGIN", ")", ";", "$", "pluginaction", "=", "required_param", "(", "'pluginaction'", ",", "PARAM_ALPHA", ")", ";", "$", "plugin", "=", "$", "this", "->", "get_plugin_by_type", "(", "$", "pluginsubtype", ",", "$", "plugintype", ")", ";", "if", "(", "!", "$", "plugin", ")", "{", "print_error", "(", "'invalidformdata'", ",", "''", ")", ";", "return", ";", "}", "$", "o", ".=", "$", "plugin", "->", "view_page", "(", "$", "pluginaction", ")", ";", "return", "$", "o", ";", "}" ]
View a page rendered by a plugin. Uses url parameters 'pluginaction', 'pluginsubtype', 'plugin', and 'id'. @return string
[ "View", "a", "page", "rendered", "by", "a", "plugin", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L3072-L3090
214,968
moodle/moodle
mod/assign/locallib.php
assign.get_submission_group
public function get_submission_group($userid) { if (isset($this->usersubmissiongroups[$userid])) { return $this->usersubmissiongroups[$userid]; } $groups = $this->get_all_groups($userid); if (count($groups) != 1) { $return = false; } else { $return = array_pop($groups); } // Cache the user submission group. $this->usersubmissiongroups[$userid] = $return; return $return; }
php
public function get_submission_group($userid) { if (isset($this->usersubmissiongroups[$userid])) { return $this->usersubmissiongroups[$userid]; } $groups = $this->get_all_groups($userid); if (count($groups) != 1) { $return = false; } else { $return = array_pop($groups); } // Cache the user submission group. $this->usersubmissiongroups[$userid] = $return; return $return; }
[ "public", "function", "get_submission_group", "(", "$", "userid", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "usersubmissiongroups", "[", "$", "userid", "]", ")", ")", "{", "return", "$", "this", "->", "usersubmissiongroups", "[", "$", "userid", "]", ";", "}", "$", "groups", "=", "$", "this", "->", "get_all_groups", "(", "$", "userid", ")", ";", "if", "(", "count", "(", "$", "groups", ")", "!=", "1", ")", "{", "$", "return", "=", "false", ";", "}", "else", "{", "$", "return", "=", "array_pop", "(", "$", "groups", ")", ";", "}", "// Cache the user submission group.", "$", "this", "->", "usersubmissiongroups", "[", "$", "userid", "]", "=", "$", "return", ";", "return", "$", "return", ";", "}" ]
This is used for team assignments to get the group for the specified user. If the user is a member of multiple or no groups this will return false @param int $userid The id of the user whose submission we want @return mixed The group or false
[ "This", "is", "used", "for", "team", "assignments", "to", "get", "the", "group", "for", "the", "specified", "user", ".", "If", "the", "user", "is", "a", "member", "of", "multiple", "or", "no", "groups", "this", "will", "return", "false" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L3100-L3117
214,969
moodle/moodle
mod/assign/locallib.php
assign.get_all_groups
public function get_all_groups($userid) { if (isset($this->usergroups[$userid])) { return $this->usergroups[$userid]; } $grouping = $this->get_instance()->teamsubmissiongroupingid; $return = groups_get_all_groups($this->get_course()->id, $userid, $grouping); $this->usergroups[$userid] = $return; return $return; }
php
public function get_all_groups($userid) { if (isset($this->usergroups[$userid])) { return $this->usergroups[$userid]; } $grouping = $this->get_instance()->teamsubmissiongroupingid; $return = groups_get_all_groups($this->get_course()->id, $userid, $grouping); $this->usergroups[$userid] = $return; return $return; }
[ "public", "function", "get_all_groups", "(", "$", "userid", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "usergroups", "[", "$", "userid", "]", ")", ")", "{", "return", "$", "this", "->", "usergroups", "[", "$", "userid", "]", ";", "}", "$", "grouping", "=", "$", "this", "->", "get_instance", "(", ")", "->", "teamsubmissiongroupingid", ";", "$", "return", "=", "groups_get_all_groups", "(", "$", "this", "->", "get_course", "(", ")", "->", "id", ",", "$", "userid", ",", "$", "grouping", ")", ";", "$", "this", "->", "usergroups", "[", "$", "userid", "]", "=", "$", "return", ";", "return", "$", "return", ";", "}" ]
Gets all groups the user is a member of. @param int $userid Teh id of the user who's groups we are checking @return array The group objects
[ "Gets", "all", "groups", "the", "user", "is", "a", "member", "of", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L3125-L3136
214,970
moodle/moodle
mod/assign/locallib.php
assign.view_plugin_content
protected function view_plugin_content($pluginsubtype) { $o = ''; $submissionid = optional_param('sid', 0, PARAM_INT); $gradeid = optional_param('gid', 0, PARAM_INT); $plugintype = required_param('plugin', PARAM_PLUGIN); $item = null; if ($pluginsubtype == 'assignsubmission') { $plugin = $this->get_submission_plugin_by_type($plugintype); if ($submissionid <= 0) { throw new coding_exception('Submission id should not be 0'); } $item = $this->get_submission($submissionid); // Check permissions. if (empty($item->userid)) { // Group submission. $this->require_view_group_submission($item->groupid); } else { $this->require_view_submission($item->userid); } $o .= $this->get_renderer()->render(new assign_header($this->get_instance(), $this->get_context(), $this->show_intro(), $this->get_course_module()->id, $plugin->get_name())); $o .= $this->get_renderer()->render(new assign_submission_plugin_submission($plugin, $item, assign_submission_plugin_submission::FULL, $this->get_course_module()->id, $this->get_return_action(), $this->get_return_params())); // Trigger event for viewing a submission. \mod_assign\event\submission_viewed::create_from_submission($this, $item)->trigger(); } else { $plugin = $this->get_feedback_plugin_by_type($plugintype); if ($gradeid <= 0) { throw new coding_exception('Grade id should not be 0'); } $item = $this->get_grade($gradeid); // Check permissions. $this->require_view_submission($item->userid); $o .= $this->get_renderer()->render(new assign_header($this->get_instance(), $this->get_context(), $this->show_intro(), $this->get_course_module()->id, $plugin->get_name())); $o .= $this->get_renderer()->render(new assign_feedback_plugin_feedback($plugin, $item, assign_feedback_plugin_feedback::FULL, $this->get_course_module()->id, $this->get_return_action(), $this->get_return_params())); // Trigger event for viewing feedback. \mod_assign\event\feedback_viewed::create_from_grade($this, $item)->trigger(); } $o .= $this->view_return_links(); $o .= $this->view_footer(); return $o; }
php
protected function view_plugin_content($pluginsubtype) { $o = ''; $submissionid = optional_param('sid', 0, PARAM_INT); $gradeid = optional_param('gid', 0, PARAM_INT); $plugintype = required_param('plugin', PARAM_PLUGIN); $item = null; if ($pluginsubtype == 'assignsubmission') { $plugin = $this->get_submission_plugin_by_type($plugintype); if ($submissionid <= 0) { throw new coding_exception('Submission id should not be 0'); } $item = $this->get_submission($submissionid); // Check permissions. if (empty($item->userid)) { // Group submission. $this->require_view_group_submission($item->groupid); } else { $this->require_view_submission($item->userid); } $o .= $this->get_renderer()->render(new assign_header($this->get_instance(), $this->get_context(), $this->show_intro(), $this->get_course_module()->id, $plugin->get_name())); $o .= $this->get_renderer()->render(new assign_submission_plugin_submission($plugin, $item, assign_submission_plugin_submission::FULL, $this->get_course_module()->id, $this->get_return_action(), $this->get_return_params())); // Trigger event for viewing a submission. \mod_assign\event\submission_viewed::create_from_submission($this, $item)->trigger(); } else { $plugin = $this->get_feedback_plugin_by_type($plugintype); if ($gradeid <= 0) { throw new coding_exception('Grade id should not be 0'); } $item = $this->get_grade($gradeid); // Check permissions. $this->require_view_submission($item->userid); $o .= $this->get_renderer()->render(new assign_header($this->get_instance(), $this->get_context(), $this->show_intro(), $this->get_course_module()->id, $plugin->get_name())); $o .= $this->get_renderer()->render(new assign_feedback_plugin_feedback($plugin, $item, assign_feedback_plugin_feedback::FULL, $this->get_course_module()->id, $this->get_return_action(), $this->get_return_params())); // Trigger event for viewing feedback. \mod_assign\event\feedback_viewed::create_from_grade($this, $item)->trigger(); } $o .= $this->view_return_links(); $o .= $this->view_footer(); return $o; }
[ "protected", "function", "view_plugin_content", "(", "$", "pluginsubtype", ")", "{", "$", "o", "=", "''", ";", "$", "submissionid", "=", "optional_param", "(", "'sid'", ",", "0", ",", "PARAM_INT", ")", ";", "$", "gradeid", "=", "optional_param", "(", "'gid'", ",", "0", ",", "PARAM_INT", ")", ";", "$", "plugintype", "=", "required_param", "(", "'plugin'", ",", "PARAM_PLUGIN", ")", ";", "$", "item", "=", "null", ";", "if", "(", "$", "pluginsubtype", "==", "'assignsubmission'", ")", "{", "$", "plugin", "=", "$", "this", "->", "get_submission_plugin_by_type", "(", "$", "plugintype", ")", ";", "if", "(", "$", "submissionid", "<=", "0", ")", "{", "throw", "new", "coding_exception", "(", "'Submission id should not be 0'", ")", ";", "}", "$", "item", "=", "$", "this", "->", "get_submission", "(", "$", "submissionid", ")", ";", "// Check permissions.", "if", "(", "empty", "(", "$", "item", "->", "userid", ")", ")", "{", "// Group submission.", "$", "this", "->", "require_view_group_submission", "(", "$", "item", "->", "groupid", ")", ";", "}", "else", "{", "$", "this", "->", "require_view_submission", "(", "$", "item", "->", "userid", ")", ";", "}", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "new", "assign_header", "(", "$", "this", "->", "get_instance", "(", ")", ",", "$", "this", "->", "get_context", "(", ")", ",", "$", "this", "->", "show_intro", "(", ")", ",", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "$", "plugin", "->", "get_name", "(", ")", ")", ")", ";", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "new", "assign_submission_plugin_submission", "(", "$", "plugin", ",", "$", "item", ",", "assign_submission_plugin_submission", "::", "FULL", ",", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "$", "this", "->", "get_return_action", "(", ")", ",", "$", "this", "->", "get_return_params", "(", ")", ")", ")", ";", "// Trigger event for viewing a submission.", "\\", "mod_assign", "\\", "event", "\\", "submission_viewed", "::", "create_from_submission", "(", "$", "this", ",", "$", "item", ")", "->", "trigger", "(", ")", ";", "}", "else", "{", "$", "plugin", "=", "$", "this", "->", "get_feedback_plugin_by_type", "(", "$", "plugintype", ")", ";", "if", "(", "$", "gradeid", "<=", "0", ")", "{", "throw", "new", "coding_exception", "(", "'Grade id should not be 0'", ")", ";", "}", "$", "item", "=", "$", "this", "->", "get_grade", "(", "$", "gradeid", ")", ";", "// Check permissions.", "$", "this", "->", "require_view_submission", "(", "$", "item", "->", "userid", ")", ";", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "new", "assign_header", "(", "$", "this", "->", "get_instance", "(", ")", ",", "$", "this", "->", "get_context", "(", ")", ",", "$", "this", "->", "show_intro", "(", ")", ",", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "$", "plugin", "->", "get_name", "(", ")", ")", ")", ";", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "new", "assign_feedback_plugin_feedback", "(", "$", "plugin", ",", "$", "item", ",", "assign_feedback_plugin_feedback", "::", "FULL", ",", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "$", "this", "->", "get_return_action", "(", ")", ",", "$", "this", "->", "get_return_params", "(", ")", ")", ")", ";", "// Trigger event for viewing feedback.", "\\", "mod_assign", "\\", "event", "\\", "feedback_viewed", "::", "create_from_grade", "(", "$", "this", ",", "$", "item", ")", "->", "trigger", "(", ")", ";", "}", "$", "o", ".=", "$", "this", "->", "view_return_links", "(", ")", ";", "$", "o", ".=", "$", "this", "->", "view_footer", "(", ")", ";", "return", "$", "o", ";", "}" ]
Display the submission that is used by a plugin. Uses url parameters 'sid', 'gid' and 'plugin'. @param string $pluginsubtype @return string
[ "Display", "the", "submission", "that", "is", "used", "by", "a", "plugin", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L3147-L3212
214,971
moodle/moodle
mod/assign/locallib.php
assign.download_rewrite_pluginfile_urls
public function download_rewrite_pluginfile_urls($text, $user, $plugin) { // The groupname prefix for the urls doesn't depend on the group mode of the assignment instance. // Rather, it should be determined by checking the group submission settings of the instance, // which is what download_submission() does when generating the file name prefixes. $groupname = ''; if ($this->get_instance()->teamsubmission) { $submissiongroup = $this->get_submission_group($user->id); if ($submissiongroup) { $groupname = $submissiongroup->name . '-'; } else { $groupname = get_string('defaultteam', 'assign') . '-'; } } if ($this->is_blind_marking()) { $prefix = $groupname . get_string('participant', 'assign'); $prefix = str_replace('_', ' ', $prefix); $prefix = clean_filename($prefix . '_' . $this->get_uniqueid_for_user($user->id) . '_'); } else { $prefix = $groupname . fullname($user); $prefix = str_replace('_', ' ', $prefix); $prefix = clean_filename($prefix . '_' . $this->get_uniqueid_for_user($user->id) . '_'); } // Only prefix files if downloadasfolders user preference is NOT set. if (!get_user_preferences('assign_downloadasfolders', 1)) { $subtype = $plugin->get_subtype(); $type = $plugin->get_type(); $prefix = $prefix . $subtype . '_' . $type . '_'; } else { $prefix = ""; } $result = str_replace('@@PLUGINFILE@@/', $prefix, $text); return $result; }
php
public function download_rewrite_pluginfile_urls($text, $user, $plugin) { // The groupname prefix for the urls doesn't depend on the group mode of the assignment instance. // Rather, it should be determined by checking the group submission settings of the instance, // which is what download_submission() does when generating the file name prefixes. $groupname = ''; if ($this->get_instance()->teamsubmission) { $submissiongroup = $this->get_submission_group($user->id); if ($submissiongroup) { $groupname = $submissiongroup->name . '-'; } else { $groupname = get_string('defaultteam', 'assign') . '-'; } } if ($this->is_blind_marking()) { $prefix = $groupname . get_string('participant', 'assign'); $prefix = str_replace('_', ' ', $prefix); $prefix = clean_filename($prefix . '_' . $this->get_uniqueid_for_user($user->id) . '_'); } else { $prefix = $groupname . fullname($user); $prefix = str_replace('_', ' ', $prefix); $prefix = clean_filename($prefix . '_' . $this->get_uniqueid_for_user($user->id) . '_'); } // Only prefix files if downloadasfolders user preference is NOT set. if (!get_user_preferences('assign_downloadasfolders', 1)) { $subtype = $plugin->get_subtype(); $type = $plugin->get_type(); $prefix = $prefix . $subtype . '_' . $type . '_'; } else { $prefix = ""; } $result = str_replace('@@PLUGINFILE@@/', $prefix, $text); return $result; }
[ "public", "function", "download_rewrite_pluginfile_urls", "(", "$", "text", ",", "$", "user", ",", "$", "plugin", ")", "{", "// The groupname prefix for the urls doesn't depend on the group mode of the assignment instance.", "// Rather, it should be determined by checking the group submission settings of the instance,", "// which is what download_submission() does when generating the file name prefixes.", "$", "groupname", "=", "''", ";", "if", "(", "$", "this", "->", "get_instance", "(", ")", "->", "teamsubmission", ")", "{", "$", "submissiongroup", "=", "$", "this", "->", "get_submission_group", "(", "$", "user", "->", "id", ")", ";", "if", "(", "$", "submissiongroup", ")", "{", "$", "groupname", "=", "$", "submissiongroup", "->", "name", ".", "'-'", ";", "}", "else", "{", "$", "groupname", "=", "get_string", "(", "'defaultteam'", ",", "'assign'", ")", ".", "'-'", ";", "}", "}", "if", "(", "$", "this", "->", "is_blind_marking", "(", ")", ")", "{", "$", "prefix", "=", "$", "groupname", ".", "get_string", "(", "'participant'", ",", "'assign'", ")", ";", "$", "prefix", "=", "str_replace", "(", "'_'", ",", "' '", ",", "$", "prefix", ")", ";", "$", "prefix", "=", "clean_filename", "(", "$", "prefix", ".", "'_'", ".", "$", "this", "->", "get_uniqueid_for_user", "(", "$", "user", "->", "id", ")", ".", "'_'", ")", ";", "}", "else", "{", "$", "prefix", "=", "$", "groupname", ".", "fullname", "(", "$", "user", ")", ";", "$", "prefix", "=", "str_replace", "(", "'_'", ",", "' '", ",", "$", "prefix", ")", ";", "$", "prefix", "=", "clean_filename", "(", "$", "prefix", ".", "'_'", ".", "$", "this", "->", "get_uniqueid_for_user", "(", "$", "user", "->", "id", ")", ".", "'_'", ")", ";", "}", "// Only prefix files if downloadasfolders user preference is NOT set.", "if", "(", "!", "get_user_preferences", "(", "'assign_downloadasfolders'", ",", "1", ")", ")", "{", "$", "subtype", "=", "$", "plugin", "->", "get_subtype", "(", ")", ";", "$", "type", "=", "$", "plugin", "->", "get_type", "(", ")", ";", "$", "prefix", "=", "$", "prefix", ".", "$", "subtype", ".", "'_'", ".", "$", "type", ".", "'_'", ";", "}", "else", "{", "$", "prefix", "=", "\"\"", ";", "}", "$", "result", "=", "str_replace", "(", "'@@PLUGINFILE@@/'", ",", "$", "prefix", ",", "$", "text", ")", ";", "return", "$", "result", ";", "}" ]
Rewrite plugin file urls so they resolve correctly in an exported zip. @param string $text - The replacement text @param stdClass $user - The user record @param assign_plugin $plugin - The assignment plugin
[ "Rewrite", "plugin", "file", "urls", "so", "they", "resolve", "correctly", "in", "an", "exported", "zip", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L3221-L3256
214,972
moodle/moodle
mod/assign/locallib.php
assign.render_editor_content
public function render_editor_content($filearea, $submissionid, $plugintype, $editor, $component, $shortentext = false) { global $CFG; $result = ''; $plugin = $this->get_submission_plugin_by_type($plugintype); $text = $plugin->get_editor_text($editor, $submissionid); if ($shortentext) { $text = shorten_text($text, 140); } $format = $plugin->get_editor_format($editor, $submissionid); $finaltext = file_rewrite_pluginfile_urls($text, 'pluginfile.php', $this->get_context()->id, $component, $filearea, $submissionid); $params = array('overflowdiv' => true, 'context' => $this->get_context()); $result .= format_text($finaltext, $format, $params); if ($CFG->enableportfolios && has_capability('mod/assign:exportownsubmission', $this->context)) { require_once($CFG->libdir . '/portfoliolib.php'); $button = new portfolio_add_button(); $portfolioparams = array('cmid' => $this->get_course_module()->id, 'sid' => $submissionid, 'plugin' => $plugintype, 'editor' => $editor, 'area'=>$filearea); $button->set_callback_options('assign_portfolio_caller', $portfolioparams, 'mod_assign'); $fs = get_file_storage(); if ($files = $fs->get_area_files($this->context->id, $component, $filearea, $submissionid, 'timemodified', false)) { $button->set_formats(PORTFOLIO_FORMAT_RICHHTML); } else { $button->set_formats(PORTFOLIO_FORMAT_PLAINHTML); } $result .= $button->to_html(PORTFOLIO_ADD_TEXT_LINK); } return $result; }
php
public function render_editor_content($filearea, $submissionid, $plugintype, $editor, $component, $shortentext = false) { global $CFG; $result = ''; $plugin = $this->get_submission_plugin_by_type($plugintype); $text = $plugin->get_editor_text($editor, $submissionid); if ($shortentext) { $text = shorten_text($text, 140); } $format = $plugin->get_editor_format($editor, $submissionid); $finaltext = file_rewrite_pluginfile_urls($text, 'pluginfile.php', $this->get_context()->id, $component, $filearea, $submissionid); $params = array('overflowdiv' => true, 'context' => $this->get_context()); $result .= format_text($finaltext, $format, $params); if ($CFG->enableportfolios && has_capability('mod/assign:exportownsubmission', $this->context)) { require_once($CFG->libdir . '/portfoliolib.php'); $button = new portfolio_add_button(); $portfolioparams = array('cmid' => $this->get_course_module()->id, 'sid' => $submissionid, 'plugin' => $plugintype, 'editor' => $editor, 'area'=>$filearea); $button->set_callback_options('assign_portfolio_caller', $portfolioparams, 'mod_assign'); $fs = get_file_storage(); if ($files = $fs->get_area_files($this->context->id, $component, $filearea, $submissionid, 'timemodified', false)) { $button->set_formats(PORTFOLIO_FORMAT_RICHHTML); } else { $button->set_formats(PORTFOLIO_FORMAT_PLAINHTML); } $result .= $button->to_html(PORTFOLIO_ADD_TEXT_LINK); } return $result; }
[ "public", "function", "render_editor_content", "(", "$", "filearea", ",", "$", "submissionid", ",", "$", "plugintype", ",", "$", "editor", ",", "$", "component", ",", "$", "shortentext", "=", "false", ")", "{", "global", "$", "CFG", ";", "$", "result", "=", "''", ";", "$", "plugin", "=", "$", "this", "->", "get_submission_plugin_by_type", "(", "$", "plugintype", ")", ";", "$", "text", "=", "$", "plugin", "->", "get_editor_text", "(", "$", "editor", ",", "$", "submissionid", ")", ";", "if", "(", "$", "shortentext", ")", "{", "$", "text", "=", "shorten_text", "(", "$", "text", ",", "140", ")", ";", "}", "$", "format", "=", "$", "plugin", "->", "get_editor_format", "(", "$", "editor", ",", "$", "submissionid", ")", ";", "$", "finaltext", "=", "file_rewrite_pluginfile_urls", "(", "$", "text", ",", "'pluginfile.php'", ",", "$", "this", "->", "get_context", "(", ")", "->", "id", ",", "$", "component", ",", "$", "filearea", ",", "$", "submissionid", ")", ";", "$", "params", "=", "array", "(", "'overflowdiv'", "=>", "true", ",", "'context'", "=>", "$", "this", "->", "get_context", "(", ")", ")", ";", "$", "result", ".=", "format_text", "(", "$", "finaltext", ",", "$", "format", ",", "$", "params", ")", ";", "if", "(", "$", "CFG", "->", "enableportfolios", "&&", "has_capability", "(", "'mod/assign:exportownsubmission'", ",", "$", "this", "->", "context", ")", ")", "{", "require_once", "(", "$", "CFG", "->", "libdir", ".", "'/portfoliolib.php'", ")", ";", "$", "button", "=", "new", "portfolio_add_button", "(", ")", ";", "$", "portfolioparams", "=", "array", "(", "'cmid'", "=>", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "'sid'", "=>", "$", "submissionid", ",", "'plugin'", "=>", "$", "plugintype", ",", "'editor'", "=>", "$", "editor", ",", "'area'", "=>", "$", "filearea", ")", ";", "$", "button", "->", "set_callback_options", "(", "'assign_portfolio_caller'", ",", "$", "portfolioparams", ",", "'mod_assign'", ")", ";", "$", "fs", "=", "get_file_storage", "(", ")", ";", "if", "(", "$", "files", "=", "$", "fs", "->", "get_area_files", "(", "$", "this", "->", "context", "->", "id", ",", "$", "component", ",", "$", "filearea", ",", "$", "submissionid", ",", "'timemodified'", ",", "false", ")", ")", "{", "$", "button", "->", "set_formats", "(", "PORTFOLIO_FORMAT_RICHHTML", ")", ";", "}", "else", "{", "$", "button", "->", "set_formats", "(", "PORTFOLIO_FORMAT_PLAINHTML", ")", ";", "}", "$", "result", ".=", "$", "button", "->", "to_html", "(", "PORTFOLIO_ADD_TEXT_LINK", ")", ";", "}", "return", "$", "result", ";", "}" ]
Render the content in editor that is often used by plugin. @param string $filearea @param int $submissionid @param string $plugintype @param string $editor @param string $component @param bool $shortentext Whether to shorten the text content. @return string
[ "Render", "the", "content", "in", "editor", "that", "is", "often", "used", "by", "plugin", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L3269-L3316
214,973
moodle/moodle
mod/assign/locallib.php
assign.view_savegrading_result
protected function view_savegrading_result($message) { $o = ''; $o .= $this->get_renderer()->render(new assign_header($this->get_instance(), $this->get_context(), $this->show_intro(), $this->get_course_module()->id, get_string('savegradingresult', 'assign'))); $gradingresult = new assign_gradingmessage(get_string('savegradingresult', 'assign'), $message, $this->get_course_module()->id); $o .= $this->get_renderer()->render($gradingresult); $o .= $this->view_footer(); return $o; }
php
protected function view_savegrading_result($message) { $o = ''; $o .= $this->get_renderer()->render(new assign_header($this->get_instance(), $this->get_context(), $this->show_intro(), $this->get_course_module()->id, get_string('savegradingresult', 'assign'))); $gradingresult = new assign_gradingmessage(get_string('savegradingresult', 'assign'), $message, $this->get_course_module()->id); $o .= $this->get_renderer()->render($gradingresult); $o .= $this->view_footer(); return $o; }
[ "protected", "function", "view_savegrading_result", "(", "$", "message", ")", "{", "$", "o", "=", "''", ";", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "new", "assign_header", "(", "$", "this", "->", "get_instance", "(", ")", ",", "$", "this", "->", "get_context", "(", ")", ",", "$", "this", "->", "show_intro", "(", ")", ",", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "get_string", "(", "'savegradingresult'", ",", "'assign'", ")", ")", ")", ";", "$", "gradingresult", "=", "new", "assign_gradingmessage", "(", "get_string", "(", "'savegradingresult'", ",", "'assign'", ")", ",", "$", "message", ",", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ")", ";", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "$", "gradingresult", ")", ";", "$", "o", ".=", "$", "this", "->", "view_footer", "(", ")", ";", "return", "$", "o", ";", "}" ]
Display a continue page after grading. @param string $message - The message to display. @return string
[ "Display", "a", "continue", "page", "after", "grading", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L3324-L3337
214,974
moodle/moodle
mod/assign/locallib.php
assign.view_quickgrading_result
protected function view_quickgrading_result($message) { $o = ''; $o .= $this->get_renderer()->render(new assign_header($this->get_instance(), $this->get_context(), $this->show_intro(), $this->get_course_module()->id, get_string('quickgradingresult', 'assign'))); $lastpage = optional_param('lastpage', null, PARAM_INT); $gradingresult = new assign_gradingmessage(get_string('quickgradingresult', 'assign'), $message, $this->get_course_module()->id, false, $lastpage); $o .= $this->get_renderer()->render($gradingresult); $o .= $this->view_footer(); return $o; }
php
protected function view_quickgrading_result($message) { $o = ''; $o .= $this->get_renderer()->render(new assign_header($this->get_instance(), $this->get_context(), $this->show_intro(), $this->get_course_module()->id, get_string('quickgradingresult', 'assign'))); $lastpage = optional_param('lastpage', null, PARAM_INT); $gradingresult = new assign_gradingmessage(get_string('quickgradingresult', 'assign'), $message, $this->get_course_module()->id, false, $lastpage); $o .= $this->get_renderer()->render($gradingresult); $o .= $this->view_footer(); return $o; }
[ "protected", "function", "view_quickgrading_result", "(", "$", "message", ")", "{", "$", "o", "=", "''", ";", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "new", "assign_header", "(", "$", "this", "->", "get_instance", "(", ")", ",", "$", "this", "->", "get_context", "(", ")", ",", "$", "this", "->", "show_intro", "(", ")", ",", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "get_string", "(", "'quickgradingresult'", ",", "'assign'", ")", ")", ")", ";", "$", "lastpage", "=", "optional_param", "(", "'lastpage'", ",", "null", ",", "PARAM_INT", ")", ";", "$", "gradingresult", "=", "new", "assign_gradingmessage", "(", "get_string", "(", "'quickgradingresult'", ",", "'assign'", ")", ",", "$", "message", ",", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "false", ",", "$", "lastpage", ")", ";", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "$", "gradingresult", ")", ";", "$", "o", ".=", "$", "this", "->", "view_footer", "(", ")", ";", "return", "$", "o", ";", "}" ]
Display a continue page after quickgrading. @param string $message - The message to display. @return string
[ "Display", "a", "continue", "page", "after", "quickgrading", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L3344-L3360
214,975
moodle/moodle
mod/assign/locallib.php
assign.can_view_grades
public function can_view_grades($groupid = null) { // Permissions check. if (!has_any_capability(array('mod/assign:viewgrades', 'mod/assign:grade'), $this->context)) { return false; } // Checks for the edge case when user belongs to no groups and groupmode is sep. if ($this->get_course_module()->effectivegroupmode == SEPARATEGROUPS) { if ($groupid === null) { $groupid = groups_get_activity_allowed_groups($this->get_course_module()); } $groupflag = has_capability('moodle/site:accessallgroups', $this->get_context()); $groupflag = $groupflag || !empty($groupid); return (bool)$groupflag; } return true; }
php
public function can_view_grades($groupid = null) { // Permissions check. if (!has_any_capability(array('mod/assign:viewgrades', 'mod/assign:grade'), $this->context)) { return false; } // Checks for the edge case when user belongs to no groups and groupmode is sep. if ($this->get_course_module()->effectivegroupmode == SEPARATEGROUPS) { if ($groupid === null) { $groupid = groups_get_activity_allowed_groups($this->get_course_module()); } $groupflag = has_capability('moodle/site:accessallgroups', $this->get_context()); $groupflag = $groupflag || !empty($groupid); return (bool)$groupflag; } return true; }
[ "public", "function", "can_view_grades", "(", "$", "groupid", "=", "null", ")", "{", "// Permissions check.", "if", "(", "!", "has_any_capability", "(", "array", "(", "'mod/assign:viewgrades'", ",", "'mod/assign:grade'", ")", ",", "$", "this", "->", "context", ")", ")", "{", "return", "false", ";", "}", "// Checks for the edge case when user belongs to no groups and groupmode is sep.", "if", "(", "$", "this", "->", "get_course_module", "(", ")", "->", "effectivegroupmode", "==", "SEPARATEGROUPS", ")", "{", "if", "(", "$", "groupid", "===", "null", ")", "{", "$", "groupid", "=", "groups_get_activity_allowed_groups", "(", "$", "this", "->", "get_course_module", "(", ")", ")", ";", "}", "$", "groupflag", "=", "has_capability", "(", "'moodle/site:accessallgroups'", ",", "$", "this", "->", "get_context", "(", ")", ")", ";", "$", "groupflag", "=", "$", "groupflag", "||", "!", "empty", "(", "$", "groupid", ")", ";", "return", "(", "bool", ")", "$", "groupflag", ";", "}", "return", "true", ";", "}" ]
Does this user have view grade or grade permission for this assignment? @param mixed $groupid int|null when is set to a value, use this group instead calculating it @return bool
[ "Does", "this", "user", "have", "view", "grade", "or", "grade", "permission", "for", "this", "assignment?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L3418-L3433
214,976
moodle/moodle
mod/assign/locallib.php
assign.add_to_log
public function add_to_log($action = '', $info = '', $url='', $return = false) { global $USER; $fullurl = 'view.php?id=' . $this->get_course_module()->id; if ($url != '') { $fullurl .= '&' . $url; } $args = array( $this->get_course()->id, 'assign', $action, $fullurl, $info, $this->get_course_module()->id ); if ($return) { // We only need to call debugging when returning a value. This is because the call to // call_user_func_array('add_to_log', $args) will trigger a debugging message of it's own. debugging('The mod_assign add_to_log() function is now deprecated.', DEBUG_DEVELOPER); return $args; } call_user_func_array('add_to_log', $args); }
php
public function add_to_log($action = '', $info = '', $url='', $return = false) { global $USER; $fullurl = 'view.php?id=' . $this->get_course_module()->id; if ($url != '') { $fullurl .= '&' . $url; } $args = array( $this->get_course()->id, 'assign', $action, $fullurl, $info, $this->get_course_module()->id ); if ($return) { // We only need to call debugging when returning a value. This is because the call to // call_user_func_array('add_to_log', $args) will trigger a debugging message of it's own. debugging('The mod_assign add_to_log() function is now deprecated.', DEBUG_DEVELOPER); return $args; } call_user_func_array('add_to_log', $args); }
[ "public", "function", "add_to_log", "(", "$", "action", "=", "''", ",", "$", "info", "=", "''", ",", "$", "url", "=", "''", ",", "$", "return", "=", "false", ")", "{", "global", "$", "USER", ";", "$", "fullurl", "=", "'view.php?id='", ".", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ";", "if", "(", "$", "url", "!=", "''", ")", "{", "$", "fullurl", ".=", "'&'", ".", "$", "url", ";", "}", "$", "args", "=", "array", "(", "$", "this", "->", "get_course", "(", ")", "->", "id", ",", "'assign'", ",", "$", "action", ",", "$", "fullurl", ",", "$", "info", ",", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ")", ";", "if", "(", "$", "return", ")", "{", "// We only need to call debugging when returning a value. This is because the call to", "// call_user_func_array('add_to_log', $args) will trigger a debugging message of it's own.", "debugging", "(", "'The mod_assign add_to_log() function is now deprecated.'", ",", "DEBUG_DEVELOPER", ")", ";", "return", "$", "args", ";", "}", "call_user_func_array", "(", "'add_to_log'", ",", "$", "args", ")", ";", "}" ]
Util function to add a message to the log. @deprecated since 2.7 - Use new events system instead. (see http://docs.moodle.org/dev/Migrating_logging_calls_in_plugins). @param string $action The current action @param string $info A detailed description of the change. But no more than 255 characters. @param string $url The url to the assign module instance. @param bool $return If true, returns the arguments, else adds to log. The purpose of this is to retrieve the arguments to use them with the new event system (Event 2). @return void|array
[ "Util", "function", "to", "add", "a", "message", "to", "the", "log", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L3611-L3635
214,977
moodle/moodle
mod/assign/locallib.php
assign.get_renderer
public function get_renderer() { global $PAGE; if ($this->output) { return $this->output; } $this->output = $PAGE->get_renderer('mod_assign', null, RENDERER_TARGET_GENERAL); return $this->output; }
php
public function get_renderer() { global $PAGE; if ($this->output) { return $this->output; } $this->output = $PAGE->get_renderer('mod_assign', null, RENDERER_TARGET_GENERAL); return $this->output; }
[ "public", "function", "get_renderer", "(", ")", "{", "global", "$", "PAGE", ";", "if", "(", "$", "this", "->", "output", ")", "{", "return", "$", "this", "->", "output", ";", "}", "$", "this", "->", "output", "=", "$", "PAGE", "->", "get_renderer", "(", "'mod_assign'", ",", "null", ",", "RENDERER_TARGET_GENERAL", ")", ";", "return", "$", "this", "->", "output", ";", "}" ]
Lazy load the page renderer and expose the renderer to plugins. @return assign_renderer
[ "Lazy", "load", "the", "page", "renderer", "and", "expose", "the", "renderer", "to", "plugins", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L3642-L3649
214,978
moodle/moodle
mod/assign/locallib.php
assign.get_user_submission
public function get_user_submission($userid, $create, $attemptnumber=-1) { global $DB, $USER; if (!$userid) { $userid = $USER->id; } // If the userid is not null then use userid. $params = array('assignment'=>$this->get_instance()->id, 'userid'=>$userid, 'groupid'=>0); if ($attemptnumber >= 0) { $params['attemptnumber'] = $attemptnumber; } // Only return the row with the highest attemptnumber. $submission = null; $submissions = $DB->get_records('assign_submission', $params, 'attemptnumber DESC', '*', 0, 1); if ($submissions) { $submission = reset($submissions); } if ($submission) { return $submission; } if ($create) { $submission = new stdClass(); $submission->assignment = $this->get_instance()->id; $submission->userid = $userid; $submission->timecreated = time(); $submission->timemodified = $submission->timecreated; $submission->status = ASSIGN_SUBMISSION_STATUS_NEW; if ($attemptnumber >= 0) { $submission->attemptnumber = $attemptnumber; } else { $submission->attemptnumber = 0; } // Work out if this is the latest submission. $submission->latest = 0; $params = array('assignment'=>$this->get_instance()->id, 'userid'=>$userid, 'groupid'=>0); if ($attemptnumber == -1) { // This is a new submission so it must be the latest. $submission->latest = 1; } else { // We need to work this out. $result = $DB->get_records('assign_submission', $params, 'attemptnumber DESC', 'attemptnumber', 0, 1); $latestsubmission = null; if ($result) { $latestsubmission = reset($result); } if (empty($latestsubmission) || ($attemptnumber > $latestsubmission->attemptnumber)) { $submission->latest = 1; } } if ($submission->latest) { // This is the case when we need to set latest to 0 for all the other attempts. $DB->set_field('assign_submission', 'latest', 0, $params); } $sid = $DB->insert_record('assign_submission', $submission); return $DB->get_record('assign_submission', array('id' => $sid)); } return false; }
php
public function get_user_submission($userid, $create, $attemptnumber=-1) { global $DB, $USER; if (!$userid) { $userid = $USER->id; } // If the userid is not null then use userid. $params = array('assignment'=>$this->get_instance()->id, 'userid'=>$userid, 'groupid'=>0); if ($attemptnumber >= 0) { $params['attemptnumber'] = $attemptnumber; } // Only return the row with the highest attemptnumber. $submission = null; $submissions = $DB->get_records('assign_submission', $params, 'attemptnumber DESC', '*', 0, 1); if ($submissions) { $submission = reset($submissions); } if ($submission) { return $submission; } if ($create) { $submission = new stdClass(); $submission->assignment = $this->get_instance()->id; $submission->userid = $userid; $submission->timecreated = time(); $submission->timemodified = $submission->timecreated; $submission->status = ASSIGN_SUBMISSION_STATUS_NEW; if ($attemptnumber >= 0) { $submission->attemptnumber = $attemptnumber; } else { $submission->attemptnumber = 0; } // Work out if this is the latest submission. $submission->latest = 0; $params = array('assignment'=>$this->get_instance()->id, 'userid'=>$userid, 'groupid'=>0); if ($attemptnumber == -1) { // This is a new submission so it must be the latest. $submission->latest = 1; } else { // We need to work this out. $result = $DB->get_records('assign_submission', $params, 'attemptnumber DESC', 'attemptnumber', 0, 1); $latestsubmission = null; if ($result) { $latestsubmission = reset($result); } if (empty($latestsubmission) || ($attemptnumber > $latestsubmission->attemptnumber)) { $submission->latest = 1; } } if ($submission->latest) { // This is the case when we need to set latest to 0 for all the other attempts. $DB->set_field('assign_submission', 'latest', 0, $params); } $sid = $DB->insert_record('assign_submission', $submission); return $DB->get_record('assign_submission', array('id' => $sid)); } return false; }
[ "public", "function", "get_user_submission", "(", "$", "userid", ",", "$", "create", ",", "$", "attemptnumber", "=", "-", "1", ")", "{", "global", "$", "DB", ",", "$", "USER", ";", "if", "(", "!", "$", "userid", ")", "{", "$", "userid", "=", "$", "USER", "->", "id", ";", "}", "// If the userid is not null then use userid.", "$", "params", "=", "array", "(", "'assignment'", "=>", "$", "this", "->", "get_instance", "(", ")", "->", "id", ",", "'userid'", "=>", "$", "userid", ",", "'groupid'", "=>", "0", ")", ";", "if", "(", "$", "attemptnumber", ">=", "0", ")", "{", "$", "params", "[", "'attemptnumber'", "]", "=", "$", "attemptnumber", ";", "}", "// Only return the row with the highest attemptnumber.", "$", "submission", "=", "null", ";", "$", "submissions", "=", "$", "DB", "->", "get_records", "(", "'assign_submission'", ",", "$", "params", ",", "'attemptnumber DESC'", ",", "'*'", ",", "0", ",", "1", ")", ";", "if", "(", "$", "submissions", ")", "{", "$", "submission", "=", "reset", "(", "$", "submissions", ")", ";", "}", "if", "(", "$", "submission", ")", "{", "return", "$", "submission", ";", "}", "if", "(", "$", "create", ")", "{", "$", "submission", "=", "new", "stdClass", "(", ")", ";", "$", "submission", "->", "assignment", "=", "$", "this", "->", "get_instance", "(", ")", "->", "id", ";", "$", "submission", "->", "userid", "=", "$", "userid", ";", "$", "submission", "->", "timecreated", "=", "time", "(", ")", ";", "$", "submission", "->", "timemodified", "=", "$", "submission", "->", "timecreated", ";", "$", "submission", "->", "status", "=", "ASSIGN_SUBMISSION_STATUS_NEW", ";", "if", "(", "$", "attemptnumber", ">=", "0", ")", "{", "$", "submission", "->", "attemptnumber", "=", "$", "attemptnumber", ";", "}", "else", "{", "$", "submission", "->", "attemptnumber", "=", "0", ";", "}", "// Work out if this is the latest submission.", "$", "submission", "->", "latest", "=", "0", ";", "$", "params", "=", "array", "(", "'assignment'", "=>", "$", "this", "->", "get_instance", "(", ")", "->", "id", ",", "'userid'", "=>", "$", "userid", ",", "'groupid'", "=>", "0", ")", ";", "if", "(", "$", "attemptnumber", "==", "-", "1", ")", "{", "// This is a new submission so it must be the latest.", "$", "submission", "->", "latest", "=", "1", ";", "}", "else", "{", "// We need to work this out.", "$", "result", "=", "$", "DB", "->", "get_records", "(", "'assign_submission'", ",", "$", "params", ",", "'attemptnumber DESC'", ",", "'attemptnumber'", ",", "0", ",", "1", ")", ";", "$", "latestsubmission", "=", "null", ";", "if", "(", "$", "result", ")", "{", "$", "latestsubmission", "=", "reset", "(", "$", "result", ")", ";", "}", "if", "(", "empty", "(", "$", "latestsubmission", ")", "||", "(", "$", "attemptnumber", ">", "$", "latestsubmission", "->", "attemptnumber", ")", ")", "{", "$", "submission", "->", "latest", "=", "1", ";", "}", "}", "if", "(", "$", "submission", "->", "latest", ")", "{", "// This is the case when we need to set latest to 0 for all the other attempts.", "$", "DB", "->", "set_field", "(", "'assign_submission'", ",", "'latest'", ",", "0", ",", "$", "params", ")", ";", "}", "$", "sid", "=", "$", "DB", "->", "insert_record", "(", "'assign_submission'", ",", "$", "submission", ")", ";", "return", "$", "DB", "->", "get_record", "(", "'assign_submission'", ",", "array", "(", "'id'", "=>", "$", "sid", ")", ")", ";", "}", "return", "false", ";", "}" ]
Load the submission object for a particular user, optionally creating it if required. For team assignments there are 2 submissions - the student submission and the team submission All files are associated with the team submission but the status of the students contribution is recorded separately. @param int $userid The id of the user whose submission we want or 0 in which case USER->id is used @param bool $create If set to true a new submission object will be created in the database with the status set to "new". @param int $attemptnumber - -1 means the latest attempt @return stdClass The submission
[ "Load", "the", "submission", "object", "for", "a", "particular", "user", "optionally", "creating", "it", "if", "required", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L3663-L3722
214,979
moodle/moodle
mod/assign/locallib.php
assign.get_submission
protected function get_submission($submissionid) { global $DB; $params = array('assignment'=>$this->get_instance()->id, 'id'=>$submissionid); return $DB->get_record('assign_submission', $params, '*', MUST_EXIST); }
php
protected function get_submission($submissionid) { global $DB; $params = array('assignment'=>$this->get_instance()->id, 'id'=>$submissionid); return $DB->get_record('assign_submission', $params, '*', MUST_EXIST); }
[ "protected", "function", "get_submission", "(", "$", "submissionid", ")", "{", "global", "$", "DB", ";", "$", "params", "=", "array", "(", "'assignment'", "=>", "$", "this", "->", "get_instance", "(", ")", "->", "id", ",", "'id'", "=>", "$", "submissionid", ")", ";", "return", "$", "DB", "->", "get_record", "(", "'assign_submission'", ",", "$", "params", ",", "'*'", ",", "MUST_EXIST", ")", ";", "}" ]
Load the submission object from it's id. @param int $submissionid The id of the submission we want @return stdClass The submission
[ "Load", "the", "submission", "object", "from", "it", "s", "id", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L3730-L3735
214,980
moodle/moodle
mod/assign/locallib.php
assign.get_user_flags
public function get_user_flags($userid, $create) { global $DB, $USER; // If the userid is not null then use userid. if (!$userid) { $userid = $USER->id; } $params = array('assignment'=>$this->get_instance()->id, 'userid'=>$userid); $flags = $DB->get_record('assign_user_flags', $params); if ($flags) { return $flags; } if ($create) { $flags = new stdClass(); $flags->assignment = $this->get_instance()->id; $flags->userid = $userid; $flags->locked = 0; $flags->extensionduedate = 0; $flags->workflowstate = ''; $flags->allocatedmarker = 0; // The mailed flag can be one of 3 values: 0 is unsent, 1 is sent and 2 is do not send yet. // This is because students only want to be notified about certain types of update (grades and feedback). $flags->mailed = 2; $fid = $DB->insert_record('assign_user_flags', $flags); $flags->id = $fid; return $flags; } return false; }
php
public function get_user_flags($userid, $create) { global $DB, $USER; // If the userid is not null then use userid. if (!$userid) { $userid = $USER->id; } $params = array('assignment'=>$this->get_instance()->id, 'userid'=>$userid); $flags = $DB->get_record('assign_user_flags', $params); if ($flags) { return $flags; } if ($create) { $flags = new stdClass(); $flags->assignment = $this->get_instance()->id; $flags->userid = $userid; $flags->locked = 0; $flags->extensionduedate = 0; $flags->workflowstate = ''; $flags->allocatedmarker = 0; // The mailed flag can be one of 3 values: 0 is unsent, 1 is sent and 2 is do not send yet. // This is because students only want to be notified about certain types of update (grades and feedback). $flags->mailed = 2; $fid = $DB->insert_record('assign_user_flags', $flags); $flags->id = $fid; return $flags; } return false; }
[ "public", "function", "get_user_flags", "(", "$", "userid", ",", "$", "create", ")", "{", "global", "$", "DB", ",", "$", "USER", ";", "// If the userid is not null then use userid.", "if", "(", "!", "$", "userid", ")", "{", "$", "userid", "=", "$", "USER", "->", "id", ";", "}", "$", "params", "=", "array", "(", "'assignment'", "=>", "$", "this", "->", "get_instance", "(", ")", "->", "id", ",", "'userid'", "=>", "$", "userid", ")", ";", "$", "flags", "=", "$", "DB", "->", "get_record", "(", "'assign_user_flags'", ",", "$", "params", ")", ";", "if", "(", "$", "flags", ")", "{", "return", "$", "flags", ";", "}", "if", "(", "$", "create", ")", "{", "$", "flags", "=", "new", "stdClass", "(", ")", ";", "$", "flags", "->", "assignment", "=", "$", "this", "->", "get_instance", "(", ")", "->", "id", ";", "$", "flags", "->", "userid", "=", "$", "userid", ";", "$", "flags", "->", "locked", "=", "0", ";", "$", "flags", "->", "extensionduedate", "=", "0", ";", "$", "flags", "->", "workflowstate", "=", "''", ";", "$", "flags", "->", "allocatedmarker", "=", "0", ";", "// The mailed flag can be one of 3 values: 0 is unsent, 1 is sent and 2 is do not send yet.", "// This is because students only want to be notified about certain types of update (grades and feedback).", "$", "flags", "->", "mailed", "=", "2", ";", "$", "fid", "=", "$", "DB", "->", "insert_record", "(", "'assign_user_flags'", ",", "$", "flags", ")", ";", "$", "flags", "->", "id", "=", "$", "fid", ";", "return", "$", "flags", ";", "}", "return", "false", ";", "}" ]
This will retrieve a user flags object from the db optionally creating it if required. The user flags was split from the user_grades table in 2.5. @param int $userid The user we are getting the flags for. @param bool $create If true the flags record will be created if it does not exist @return stdClass The flags record
[ "This", "will", "retrieve", "a", "user", "flags", "object", "from", "the", "db", "optionally", "creating", "it", "if", "required", ".", "The", "user", "flags", "was", "split", "from", "the", "user_grades", "table", "in", "2", ".", "5", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L3745-L3778
214,981
moodle/moodle
mod/assign/locallib.php
assign.get_user_grade
public function get_user_grade($userid, $create, $attemptnumber=-1) { global $DB, $USER; // If the userid is not null then use userid. if (!$userid) { $userid = $USER->id; } $submission = null; $params = array('assignment'=>$this->get_instance()->id, 'userid'=>$userid); if ($attemptnumber < 0 || $create) { // Make sure this grade matches the latest submission attempt. if ($this->get_instance()->teamsubmission) { $submission = $this->get_group_submission($userid, 0, true, $attemptnumber); } else { $submission = $this->get_user_submission($userid, true, $attemptnumber); } if ($submission) { $attemptnumber = $submission->attemptnumber; } } if ($attemptnumber >= 0) { $params['attemptnumber'] = $attemptnumber; } $grades = $DB->get_records('assign_grades', $params, 'attemptnumber DESC', '*', 0, 1); if ($grades) { return reset($grades); } if ($create) { $grade = new stdClass(); $grade->assignment = $this->get_instance()->id; $grade->userid = $userid; $grade->timecreated = time(); // If we are "auto-creating" a grade - and there is a submission // the new grade should not have a more recent timemodified value // than the submission. if ($submission) { $grade->timemodified = $submission->timemodified; } else { $grade->timemodified = $grade->timecreated; } $grade->grade = -1; // Do not set the grader id here as it would be the admin users which is incorrect. $grade->grader = -1; if ($attemptnumber >= 0) { $grade->attemptnumber = $attemptnumber; } $gid = $DB->insert_record('assign_grades', $grade); $grade->id = $gid; return $grade; } return false; }
php
public function get_user_grade($userid, $create, $attemptnumber=-1) { global $DB, $USER; // If the userid is not null then use userid. if (!$userid) { $userid = $USER->id; } $submission = null; $params = array('assignment'=>$this->get_instance()->id, 'userid'=>$userid); if ($attemptnumber < 0 || $create) { // Make sure this grade matches the latest submission attempt. if ($this->get_instance()->teamsubmission) { $submission = $this->get_group_submission($userid, 0, true, $attemptnumber); } else { $submission = $this->get_user_submission($userid, true, $attemptnumber); } if ($submission) { $attemptnumber = $submission->attemptnumber; } } if ($attemptnumber >= 0) { $params['attemptnumber'] = $attemptnumber; } $grades = $DB->get_records('assign_grades', $params, 'attemptnumber DESC', '*', 0, 1); if ($grades) { return reset($grades); } if ($create) { $grade = new stdClass(); $grade->assignment = $this->get_instance()->id; $grade->userid = $userid; $grade->timecreated = time(); // If we are "auto-creating" a grade - and there is a submission // the new grade should not have a more recent timemodified value // than the submission. if ($submission) { $grade->timemodified = $submission->timemodified; } else { $grade->timemodified = $grade->timecreated; } $grade->grade = -1; // Do not set the grader id here as it would be the admin users which is incorrect. $grade->grader = -1; if ($attemptnumber >= 0) { $grade->attemptnumber = $attemptnumber; } $gid = $DB->insert_record('assign_grades', $grade); $grade->id = $gid; return $grade; } return false; }
[ "public", "function", "get_user_grade", "(", "$", "userid", ",", "$", "create", ",", "$", "attemptnumber", "=", "-", "1", ")", "{", "global", "$", "DB", ",", "$", "USER", ";", "// If the userid is not null then use userid.", "if", "(", "!", "$", "userid", ")", "{", "$", "userid", "=", "$", "USER", "->", "id", ";", "}", "$", "submission", "=", "null", ";", "$", "params", "=", "array", "(", "'assignment'", "=>", "$", "this", "->", "get_instance", "(", ")", "->", "id", ",", "'userid'", "=>", "$", "userid", ")", ";", "if", "(", "$", "attemptnumber", "<", "0", "||", "$", "create", ")", "{", "// Make sure this grade matches the latest submission attempt.", "if", "(", "$", "this", "->", "get_instance", "(", ")", "->", "teamsubmission", ")", "{", "$", "submission", "=", "$", "this", "->", "get_group_submission", "(", "$", "userid", ",", "0", ",", "true", ",", "$", "attemptnumber", ")", ";", "}", "else", "{", "$", "submission", "=", "$", "this", "->", "get_user_submission", "(", "$", "userid", ",", "true", ",", "$", "attemptnumber", ")", ";", "}", "if", "(", "$", "submission", ")", "{", "$", "attemptnumber", "=", "$", "submission", "->", "attemptnumber", ";", "}", "}", "if", "(", "$", "attemptnumber", ">=", "0", ")", "{", "$", "params", "[", "'attemptnumber'", "]", "=", "$", "attemptnumber", ";", "}", "$", "grades", "=", "$", "DB", "->", "get_records", "(", "'assign_grades'", ",", "$", "params", ",", "'attemptnumber DESC'", ",", "'*'", ",", "0", ",", "1", ")", ";", "if", "(", "$", "grades", ")", "{", "return", "reset", "(", "$", "grades", ")", ";", "}", "if", "(", "$", "create", ")", "{", "$", "grade", "=", "new", "stdClass", "(", ")", ";", "$", "grade", "->", "assignment", "=", "$", "this", "->", "get_instance", "(", ")", "->", "id", ";", "$", "grade", "->", "userid", "=", "$", "userid", ";", "$", "grade", "->", "timecreated", "=", "time", "(", ")", ";", "// If we are \"auto-creating\" a grade - and there is a submission", "// the new grade should not have a more recent timemodified value", "// than the submission.", "if", "(", "$", "submission", ")", "{", "$", "grade", "->", "timemodified", "=", "$", "submission", "->", "timemodified", ";", "}", "else", "{", "$", "grade", "->", "timemodified", "=", "$", "grade", "->", "timecreated", ";", "}", "$", "grade", "->", "grade", "=", "-", "1", ";", "// Do not set the grader id here as it would be the admin users which is incorrect.", "$", "grade", "->", "grader", "=", "-", "1", ";", "if", "(", "$", "attemptnumber", ">=", "0", ")", "{", "$", "grade", "->", "attemptnumber", "=", "$", "attemptnumber", ";", "}", "$", "gid", "=", "$", "DB", "->", "insert_record", "(", "'assign_grades'", ",", "$", "grade", ")", ";", "$", "grade", "->", "id", "=", "$", "gid", ";", "return", "$", "grade", ";", "}", "return", "false", ";", "}" ]
This will retrieve a grade object from the db, optionally creating it if required. @param int $userid The user we are grading @param bool $create If true the grade will be created if it does not exist @param int $attemptnumber The attempt number to retrieve the grade for. -1 means the latest submission. @return stdClass The grade record
[ "This", "will", "retrieve", "a", "grade", "object", "from", "the", "db", "optionally", "creating", "it", "if", "required", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L3788-L3844
214,982
moodle/moodle
mod/assign/locallib.php
assign.get_grade
protected function get_grade($gradeid) { global $DB; $params = array('assignment'=>$this->get_instance()->id, 'id'=>$gradeid); return $DB->get_record('assign_grades', $params, '*', MUST_EXIST); }
php
protected function get_grade($gradeid) { global $DB; $params = array('assignment'=>$this->get_instance()->id, 'id'=>$gradeid); return $DB->get_record('assign_grades', $params, '*', MUST_EXIST); }
[ "protected", "function", "get_grade", "(", "$", "gradeid", ")", "{", "global", "$", "DB", ";", "$", "params", "=", "array", "(", "'assignment'", "=>", "$", "this", "->", "get_instance", "(", ")", "->", "id", ",", "'id'", "=>", "$", "gradeid", ")", ";", "return", "$", "DB", "->", "get_record", "(", "'assign_grades'", ",", "$", "params", ",", "'*'", ",", "MUST_EXIST", ")", ";", "}" ]
This will retrieve a grade object from the db. @param int $gradeid The id of the grade @return stdClass The grade record
[ "This", "will", "retrieve", "a", "grade", "object", "from", "the", "db", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L3852-L3857
214,983
moodle/moodle
mod/assign/locallib.php
assign.view_remove_submission_confirm
protected function view_remove_submission_confirm() { global $USER, $DB; $userid = optional_param('userid', $USER->id, PARAM_INT); if (!$this->can_edit_submission($userid, $USER->id)) { print_error('nopermission'); } $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST); $o = ''; $header = new assign_header($this->get_instance(), $this->get_context(), false, $this->get_course_module()->id); $o .= $this->get_renderer()->render($header); $urlparams = array('id' => $this->get_course_module()->id, 'action' => 'removesubmission', 'userid' => $userid, 'sesskey' => sesskey()); $confirmurl = new moodle_url('/mod/assign/view.php', $urlparams); $urlparams = array('id' => $this->get_course_module()->id, 'action' => 'view'); $cancelurl = new moodle_url('/mod/assign/view.php', $urlparams); if ($userid == $USER->id) { $confirmstr = get_string('removesubmissionconfirm', 'assign'); } else { $name = $this->fullname($user); $confirmstr = get_string('removesubmissionconfirmforstudent', 'assign', $name); } $o .= $this->get_renderer()->confirm($confirmstr, $confirmurl, $cancelurl); $o .= $this->view_footer(); \mod_assign\event\remove_submission_form_viewed::create_from_user($this, $user)->trigger(); return $o; }
php
protected function view_remove_submission_confirm() { global $USER, $DB; $userid = optional_param('userid', $USER->id, PARAM_INT); if (!$this->can_edit_submission($userid, $USER->id)) { print_error('nopermission'); } $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST); $o = ''; $header = new assign_header($this->get_instance(), $this->get_context(), false, $this->get_course_module()->id); $o .= $this->get_renderer()->render($header); $urlparams = array('id' => $this->get_course_module()->id, 'action' => 'removesubmission', 'userid' => $userid, 'sesskey' => sesskey()); $confirmurl = new moodle_url('/mod/assign/view.php', $urlparams); $urlparams = array('id' => $this->get_course_module()->id, 'action' => 'view'); $cancelurl = new moodle_url('/mod/assign/view.php', $urlparams); if ($userid == $USER->id) { $confirmstr = get_string('removesubmissionconfirm', 'assign'); } else { $name = $this->fullname($user); $confirmstr = get_string('removesubmissionconfirmforstudent', 'assign', $name); } $o .= $this->get_renderer()->confirm($confirmstr, $confirmurl, $cancelurl); $o .= $this->view_footer(); \mod_assign\event\remove_submission_form_viewed::create_from_user($this, $user)->trigger(); return $o; }
[ "protected", "function", "view_remove_submission_confirm", "(", ")", "{", "global", "$", "USER", ",", "$", "DB", ";", "$", "userid", "=", "optional_param", "(", "'userid'", ",", "$", "USER", "->", "id", ",", "PARAM_INT", ")", ";", "if", "(", "!", "$", "this", "->", "can_edit_submission", "(", "$", "userid", ",", "$", "USER", "->", "id", ")", ")", "{", "print_error", "(", "'nopermission'", ")", ";", "}", "$", "user", "=", "$", "DB", "->", "get_record", "(", "'user'", ",", "array", "(", "'id'", "=>", "$", "userid", ")", ",", "'*'", ",", "MUST_EXIST", ")", ";", "$", "o", "=", "''", ";", "$", "header", "=", "new", "assign_header", "(", "$", "this", "->", "get_instance", "(", ")", ",", "$", "this", "->", "get_context", "(", ")", ",", "false", ",", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ")", ";", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "$", "header", ")", ";", "$", "urlparams", "=", "array", "(", "'id'", "=>", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "'action'", "=>", "'removesubmission'", ",", "'userid'", "=>", "$", "userid", ",", "'sesskey'", "=>", "sesskey", "(", ")", ")", ";", "$", "confirmurl", "=", "new", "moodle_url", "(", "'/mod/assign/view.php'", ",", "$", "urlparams", ")", ";", "$", "urlparams", "=", "array", "(", "'id'", "=>", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "'action'", "=>", "'view'", ")", ";", "$", "cancelurl", "=", "new", "moodle_url", "(", "'/mod/assign/view.php'", ",", "$", "urlparams", ")", ";", "if", "(", "$", "userid", "==", "$", "USER", "->", "id", ")", "{", "$", "confirmstr", "=", "get_string", "(", "'removesubmissionconfirm'", ",", "'assign'", ")", ";", "}", "else", "{", "$", "name", "=", "$", "this", "->", "fullname", "(", "$", "user", ")", ";", "$", "confirmstr", "=", "get_string", "(", "'removesubmissionconfirmforstudent'", ",", "'assign'", ",", "$", "name", ")", ";", "}", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "confirm", "(", "$", "confirmstr", ",", "$", "confirmurl", ",", "$", "cancelurl", ")", ";", "$", "o", ".=", "$", "this", "->", "view_footer", "(", ")", ";", "\\", "mod_assign", "\\", "event", "\\", "remove_submission_form_viewed", "::", "create_from_user", "(", "$", "this", ",", "$", "user", ")", "->", "trigger", "(", ")", ";", "return", "$", "o", ";", "}" ]
Show a confirmation page to make sure they want to remove submission data. @return string
[ "Show", "a", "confirmation", "page", "to", "make", "sure", "they", "want", "to", "remove", "submission", "data", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L4219-L4260
214,984
moodle/moodle
mod/assign/locallib.php
assign.view_reveal_identities_confirm
protected function view_reveal_identities_confirm() { require_capability('mod/assign:revealidentities', $this->get_context()); $o = ''; $header = new assign_header($this->get_instance(), $this->get_context(), false, $this->get_course_module()->id); $o .= $this->get_renderer()->render($header); $urlparams = array('id'=>$this->get_course_module()->id, 'action'=>'revealidentitiesconfirm', 'sesskey'=>sesskey()); $confirmurl = new moodle_url('/mod/assign/view.php', $urlparams); $urlparams = array('id'=>$this->get_course_module()->id, 'action'=>'grading'); $cancelurl = new moodle_url('/mod/assign/view.php', $urlparams); $o .= $this->get_renderer()->confirm(get_string('revealidentitiesconfirm', 'assign'), $confirmurl, $cancelurl); $o .= $this->view_footer(); \mod_assign\event\reveal_identities_confirmation_page_viewed::create_from_assign($this)->trigger(); return $o; }
php
protected function view_reveal_identities_confirm() { require_capability('mod/assign:revealidentities', $this->get_context()); $o = ''; $header = new assign_header($this->get_instance(), $this->get_context(), false, $this->get_course_module()->id); $o .= $this->get_renderer()->render($header); $urlparams = array('id'=>$this->get_course_module()->id, 'action'=>'revealidentitiesconfirm', 'sesskey'=>sesskey()); $confirmurl = new moodle_url('/mod/assign/view.php', $urlparams); $urlparams = array('id'=>$this->get_course_module()->id, 'action'=>'grading'); $cancelurl = new moodle_url('/mod/assign/view.php', $urlparams); $o .= $this->get_renderer()->confirm(get_string('revealidentitiesconfirm', 'assign'), $confirmurl, $cancelurl); $o .= $this->view_footer(); \mod_assign\event\reveal_identities_confirmation_page_viewed::create_from_assign($this)->trigger(); return $o; }
[ "protected", "function", "view_reveal_identities_confirm", "(", ")", "{", "require_capability", "(", "'mod/assign:revealidentities'", ",", "$", "this", "->", "get_context", "(", ")", ")", ";", "$", "o", "=", "''", ";", "$", "header", "=", "new", "assign_header", "(", "$", "this", "->", "get_instance", "(", ")", ",", "$", "this", "->", "get_context", "(", ")", ",", "false", ",", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ")", ";", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "$", "header", ")", ";", "$", "urlparams", "=", "array", "(", "'id'", "=>", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "'action'", "=>", "'revealidentitiesconfirm'", ",", "'sesskey'", "=>", "sesskey", "(", ")", ")", ";", "$", "confirmurl", "=", "new", "moodle_url", "(", "'/mod/assign/view.php'", ",", "$", "urlparams", ")", ";", "$", "urlparams", "=", "array", "(", "'id'", "=>", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "'action'", "=>", "'grading'", ")", ";", "$", "cancelurl", "=", "new", "moodle_url", "(", "'/mod/assign/view.php'", ",", "$", "urlparams", ")", ";", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "confirm", "(", "get_string", "(", "'revealidentitiesconfirm'", ",", "'assign'", ")", ",", "$", "confirmurl", ",", "$", "cancelurl", ")", ";", "$", "o", ".=", "$", "this", "->", "view_footer", "(", ")", ";", "\\", "mod_assign", "\\", "event", "\\", "reveal_identities_confirmation_page_viewed", "::", "create_from_assign", "(", "$", "this", ")", "->", "trigger", "(", ")", ";", "return", "$", "o", ";", "}" ]
Show a confirmation page to make sure they want to release student identities. @return string
[ "Show", "a", "confirmation", "page", "to", "make", "sure", "they", "want", "to", "release", "student", "identities", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L4268-L4295
214,985
moodle/moodle
mod/assign/locallib.php
assign.view_return_links
protected function view_return_links() { $returnaction = optional_param('returnaction', '', PARAM_ALPHA); $returnparams = optional_param('returnparams', '', PARAM_TEXT); $params = array(); $returnparams = str_replace('&amp;', '&', $returnparams); parse_str($returnparams, $params); $newparams = array('id' => $this->get_course_module()->id, 'action' => $returnaction); $params = array_merge($newparams, $params); $url = new moodle_url('/mod/assign/view.php', $params); return $this->get_renderer()->single_button($url, get_string('back'), 'get'); }
php
protected function view_return_links() { $returnaction = optional_param('returnaction', '', PARAM_ALPHA); $returnparams = optional_param('returnparams', '', PARAM_TEXT); $params = array(); $returnparams = str_replace('&amp;', '&', $returnparams); parse_str($returnparams, $params); $newparams = array('id' => $this->get_course_module()->id, 'action' => $returnaction); $params = array_merge($newparams, $params); $url = new moodle_url('/mod/assign/view.php', $params); return $this->get_renderer()->single_button($url, get_string('back'), 'get'); }
[ "protected", "function", "view_return_links", "(", ")", "{", "$", "returnaction", "=", "optional_param", "(", "'returnaction'", ",", "''", ",", "PARAM_ALPHA", ")", ";", "$", "returnparams", "=", "optional_param", "(", "'returnparams'", ",", "''", ",", "PARAM_TEXT", ")", ";", "$", "params", "=", "array", "(", ")", ";", "$", "returnparams", "=", "str_replace", "(", "'&amp;'", ",", "'&'", ",", "$", "returnparams", ")", ";", "parse_str", "(", "$", "returnparams", ",", "$", "params", ")", ";", "$", "newparams", "=", "array", "(", "'id'", "=>", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "'action'", "=>", "$", "returnaction", ")", ";", "$", "params", "=", "array_merge", "(", "$", "newparams", ",", "$", "params", ")", ";", "$", "url", "=", "new", "moodle_url", "(", "'/mod/assign/view.php'", ",", "$", "params", ")", ";", "return", "$", "this", "->", "get_renderer", "(", ")", "->", "single_button", "(", "$", "url", ",", "get_string", "(", "'back'", ")", ",", "'get'", ")", ";", "}" ]
View a link to go back to the previous page. Uses url parameters returnaction and returnparams. @return string
[ "View", "a", "link", "to", "go", "back", "to", "the", "previous", "page", ".", "Uses", "url", "parameters", "returnaction", "and", "returnparams", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L4302-L4314
214,986
moodle/moodle
mod/assign/locallib.php
assign.view_grader
protected function view_grader() { global $USER, $PAGE; $o = ''; // Need submit permission to submit an assignment. $this->require_view_grades(); $PAGE->set_pagelayout('embedded'); $courseshortname = $this->get_context()->get_course_context()->get_context_name(false, true); $args = [ 'contextname' => $this->get_context()->get_context_name(false, true), 'subpage' => get_string('grading', 'assign') ]; $title = get_string('subpagetitle', 'assign', $args); $title = $courseshortname . ': ' . $title; $PAGE->set_title($title); $o .= $this->get_renderer()->header(); $userid = optional_param('userid', 0, PARAM_INT); $blindid = optional_param('blindid', 0, PARAM_INT); if (!$userid && $blindid) { $userid = $this->get_user_id_for_uniqueid($blindid); } $currentgroup = groups_get_activity_group($this->get_course_module(), true); $framegrader = new grading_app($userid, $currentgroup, $this); $this->update_effective_access($userid); $o .= $this->get_renderer()->render($framegrader); $o .= $this->view_footer(); \mod_assign\event\grading_table_viewed::create_from_assign($this)->trigger(); return $o; }
php
protected function view_grader() { global $USER, $PAGE; $o = ''; // Need submit permission to submit an assignment. $this->require_view_grades(); $PAGE->set_pagelayout('embedded'); $courseshortname = $this->get_context()->get_course_context()->get_context_name(false, true); $args = [ 'contextname' => $this->get_context()->get_context_name(false, true), 'subpage' => get_string('grading', 'assign') ]; $title = get_string('subpagetitle', 'assign', $args); $title = $courseshortname . ': ' . $title; $PAGE->set_title($title); $o .= $this->get_renderer()->header(); $userid = optional_param('userid', 0, PARAM_INT); $blindid = optional_param('blindid', 0, PARAM_INT); if (!$userid && $blindid) { $userid = $this->get_user_id_for_uniqueid($blindid); } $currentgroup = groups_get_activity_group($this->get_course_module(), true); $framegrader = new grading_app($userid, $currentgroup, $this); $this->update_effective_access($userid); $o .= $this->get_renderer()->render($framegrader); $o .= $this->view_footer(); \mod_assign\event\grading_table_viewed::create_from_assign($this)->trigger(); return $o; }
[ "protected", "function", "view_grader", "(", ")", "{", "global", "$", "USER", ",", "$", "PAGE", ";", "$", "o", "=", "''", ";", "// Need submit permission to submit an assignment.", "$", "this", "->", "require_view_grades", "(", ")", ";", "$", "PAGE", "->", "set_pagelayout", "(", "'embedded'", ")", ";", "$", "courseshortname", "=", "$", "this", "->", "get_context", "(", ")", "->", "get_course_context", "(", ")", "->", "get_context_name", "(", "false", ",", "true", ")", ";", "$", "args", "=", "[", "'contextname'", "=>", "$", "this", "->", "get_context", "(", ")", "->", "get_context_name", "(", "false", ",", "true", ")", ",", "'subpage'", "=>", "get_string", "(", "'grading'", ",", "'assign'", ")", "]", ";", "$", "title", "=", "get_string", "(", "'subpagetitle'", ",", "'assign'", ",", "$", "args", ")", ";", "$", "title", "=", "$", "courseshortname", ".", "': '", ".", "$", "title", ";", "$", "PAGE", "->", "set_title", "(", "$", "title", ")", ";", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "header", "(", ")", ";", "$", "userid", "=", "optional_param", "(", "'userid'", ",", "0", ",", "PARAM_INT", ")", ";", "$", "blindid", "=", "optional_param", "(", "'blindid'", ",", "0", ",", "PARAM_INT", ")", ";", "if", "(", "!", "$", "userid", "&&", "$", "blindid", ")", "{", "$", "userid", "=", "$", "this", "->", "get_user_id_for_uniqueid", "(", "$", "blindid", ")", ";", "}", "$", "currentgroup", "=", "groups_get_activity_group", "(", "$", "this", "->", "get_course_module", "(", ")", ",", "true", ")", ";", "$", "framegrader", "=", "new", "grading_app", "(", "$", "userid", ",", "$", "currentgroup", ",", "$", "this", ")", ";", "$", "this", "->", "update_effective_access", "(", "$", "userid", ")", ";", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "$", "framegrader", ")", ";", "$", "o", ".=", "$", "this", "->", "view_footer", "(", ")", ";", "\\", "mod_assign", "\\", "event", "\\", "grading_table_viewed", "::", "create_from_assign", "(", "$", "this", ")", "->", "trigger", "(", ")", ";", "return", "$", "o", ";", "}" ]
View entire grader app. @return string
[ "View", "entire", "grader", "app", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L4510-L4549
214,987
moodle/moodle
mod/assign/locallib.php
assign.view_grading_page
protected function view_grading_page() { global $CFG; $o = ''; // Need submit permission to submit an assignment. $this->require_view_grades(); require_once($CFG->dirroot . '/mod/assign/gradeform.php'); $this->add_grade_notices(); // Only load this if it is. $o .= $this->view_grading_table(); $o .= $this->view_footer(); \mod_assign\event\grading_table_viewed::create_from_assign($this)->trigger(); return $o; }
php
protected function view_grading_page() { global $CFG; $o = ''; // Need submit permission to submit an assignment. $this->require_view_grades(); require_once($CFG->dirroot . '/mod/assign/gradeform.php'); $this->add_grade_notices(); // Only load this if it is. $o .= $this->view_grading_table(); $o .= $this->view_footer(); \mod_assign\event\grading_table_viewed::create_from_assign($this)->trigger(); return $o; }
[ "protected", "function", "view_grading_page", "(", ")", "{", "global", "$", "CFG", ";", "$", "o", "=", "''", ";", "// Need submit permission to submit an assignment.", "$", "this", "->", "require_view_grades", "(", ")", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/mod/assign/gradeform.php'", ")", ";", "$", "this", "->", "add_grade_notices", "(", ")", ";", "// Only load this if it is.", "$", "o", ".=", "$", "this", "->", "view_grading_table", "(", ")", ";", "$", "o", ".=", "$", "this", "->", "view_footer", "(", ")", ";", "\\", "mod_assign", "\\", "event", "\\", "grading_table_viewed", "::", "create_from_assign", "(", "$", "this", ")", "->", "trigger", "(", ")", ";", "return", "$", "o", ";", "}" ]
View entire grading page. @return string
[ "View", "entire", "grading", "page", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L4555-L4573
214,988
moodle/moodle
mod/assign/locallib.php
assign.plagiarism_print_disclosure
protected function plagiarism_print_disclosure() { global $CFG; $o = ''; if (!empty($CFG->enableplagiarism)) { require_once($CFG->libdir . '/plagiarismlib.php'); $o .= plagiarism_print_disclosure($this->get_course_module()->id); } return $o; }
php
protected function plagiarism_print_disclosure() { global $CFG; $o = ''; if (!empty($CFG->enableplagiarism)) { require_once($CFG->libdir . '/plagiarismlib.php'); $o .= plagiarism_print_disclosure($this->get_course_module()->id); } return $o; }
[ "protected", "function", "plagiarism_print_disclosure", "(", ")", "{", "global", "$", "CFG", ";", "$", "o", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "CFG", "->", "enableplagiarism", ")", ")", "{", "require_once", "(", "$", "CFG", "->", "libdir", ".", "'/plagiarismlib.php'", ")", ";", "$", "o", ".=", "plagiarism_print_disclosure", "(", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ")", ";", "}", "return", "$", "o", ";", "}" ]
Capture the output of the plagiarism plugins disclosures and return it as a string. @return string
[ "Capture", "the", "output", "of", "the", "plagiarism", "plugins", "disclosures", "and", "return", "it", "as", "a", "string", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L4580-L4591
214,989
moodle/moodle
mod/assign/locallib.php
assign.view_notices
protected function view_notices($title, $notices) { global $CFG; $o = ''; $header = new assign_header($this->get_instance(), $this->get_context(), $this->show_intro(), $this->get_course_module()->id, $title); $o .= $this->get_renderer()->render($header); foreach ($notices as $notice) { $o .= $this->get_renderer()->notification($notice); } $url = new moodle_url('/mod/assign/view.php', array('id'=>$this->get_course_module()->id, 'action'=>'view')); $o .= $this->get_renderer()->continue_button($url); $o .= $this->view_footer(); return $o; }
php
protected function view_notices($title, $notices) { global $CFG; $o = ''; $header = new assign_header($this->get_instance(), $this->get_context(), $this->show_intro(), $this->get_course_module()->id, $title); $o .= $this->get_renderer()->render($header); foreach ($notices as $notice) { $o .= $this->get_renderer()->notification($notice); } $url = new moodle_url('/mod/assign/view.php', array('id'=>$this->get_course_module()->id, 'action'=>'view')); $o .= $this->get_renderer()->continue_button($url); $o .= $this->view_footer(); return $o; }
[ "protected", "function", "view_notices", "(", "$", "title", ",", "$", "notices", ")", "{", "global", "$", "CFG", ";", "$", "o", "=", "''", ";", "$", "header", "=", "new", "assign_header", "(", "$", "this", "->", "get_instance", "(", ")", ",", "$", "this", "->", "get_context", "(", ")", ",", "$", "this", "->", "show_intro", "(", ")", ",", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "$", "title", ")", ";", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "$", "header", ")", ";", "foreach", "(", "$", "notices", "as", "$", "notice", ")", "{", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "notification", "(", "$", "notice", ")", ";", "}", "$", "url", "=", "new", "moodle_url", "(", "'/mod/assign/view.php'", ",", "array", "(", "'id'", "=>", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "'action'", "=>", "'view'", ")", ")", ";", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "continue_button", "(", "$", "url", ")", ";", "$", "o", ".=", "$", "this", "->", "view_footer", "(", ")", ";", "return", "$", "o", ";", "}" ]
Message for students when assignment submissions have been closed. @param string $title The page title @param array $notices The array of notices to show. @return string
[ "Message", "for", "students", "when", "assignment", "submissions", "have", "been", "closed", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L4600-L4622
214,990
moodle/moodle
mod/assign/locallib.php
assign.fullname
public function fullname($user) { if ($this->is_blind_marking()) { $hasviewblind = has_capability('mod/assign:viewblinddetails', $this->get_context()); if (empty($user->recordid)) { $uniqueid = $this->get_uniqueid_for_user($user->id); } else { $uniqueid = $user->recordid; } if ($hasviewblind) { return get_string('participant', 'assign') . ' ' . $uniqueid . ' (' . fullname($user, has_capability('moodle/site:viewfullnames', $this->get_context())) . ')'; } else { return get_string('participant', 'assign') . ' ' . $uniqueid; } } else { return fullname($user, has_capability('moodle/site:viewfullnames', $this->get_context())); } }
php
public function fullname($user) { if ($this->is_blind_marking()) { $hasviewblind = has_capability('mod/assign:viewblinddetails', $this->get_context()); if (empty($user->recordid)) { $uniqueid = $this->get_uniqueid_for_user($user->id); } else { $uniqueid = $user->recordid; } if ($hasviewblind) { return get_string('participant', 'assign') . ' ' . $uniqueid . ' (' . fullname($user, has_capability('moodle/site:viewfullnames', $this->get_context())) . ')'; } else { return get_string('participant', 'assign') . ' ' . $uniqueid; } } else { return fullname($user, has_capability('moodle/site:viewfullnames', $this->get_context())); } }
[ "public", "function", "fullname", "(", "$", "user", ")", "{", "if", "(", "$", "this", "->", "is_blind_marking", "(", ")", ")", "{", "$", "hasviewblind", "=", "has_capability", "(", "'mod/assign:viewblinddetails'", ",", "$", "this", "->", "get_context", "(", ")", ")", ";", "if", "(", "empty", "(", "$", "user", "->", "recordid", ")", ")", "{", "$", "uniqueid", "=", "$", "this", "->", "get_uniqueid_for_user", "(", "$", "user", "->", "id", ")", ";", "}", "else", "{", "$", "uniqueid", "=", "$", "user", "->", "recordid", ";", "}", "if", "(", "$", "hasviewblind", ")", "{", "return", "get_string", "(", "'participant'", ",", "'assign'", ")", ".", "' '", ".", "$", "uniqueid", ".", "' ('", ".", "fullname", "(", "$", "user", ",", "has_capability", "(", "'moodle/site:viewfullnames'", ",", "$", "this", "->", "get_context", "(", ")", ")", ")", ".", "')'", ";", "}", "else", "{", "return", "get_string", "(", "'participant'", ",", "'assign'", ")", ".", "' '", ".", "$", "uniqueid", ";", "}", "}", "else", "{", "return", "fullname", "(", "$", "user", ",", "has_capability", "(", "'moodle/site:viewfullnames'", ",", "$", "this", "->", "get_context", "(", ")", ")", ")", ";", "}", "}" ]
Get the name for a user - hiding their real name if blind marking is on. @param stdClass $user The user record as required by fullname() @return string The name.
[ "Get", "the", "name", "for", "a", "user", "-", "hiding", "their", "real", "name", "if", "blind", "marking", "is", "on", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L4630-L4647
214,991
moodle/moodle
mod/assign/locallib.php
assign.view_edit_submission_page
protected function view_edit_submission_page($mform, $notices) { global $CFG, $USER, $DB; $o = ''; require_once($CFG->dirroot . '/mod/assign/submission_form.php'); // Need submit permission to submit an assignment. $userid = optional_param('userid', $USER->id, PARAM_INT); $user = $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST); // This variation on the url will link direct to this student. // The benefit is the url will be the same every time for this student, so Atto autosave drafts can match up. $returnparams = array('userid' => $userid, 'rownum' => 0, 'useridlistid' => 0); $this->register_return_link('editsubmission', $returnparams); if ($userid == $USER->id) { if (!$this->can_edit_submission($userid, $USER->id)) { print_error('nopermission'); } // User is editing their own submission. require_capability('mod/assign:submit', $this->context); $title = get_string('editsubmission', 'assign'); } else { // User is editing another user's submission. if (!$this->can_edit_submission($userid, $USER->id)) { print_error('nopermission'); } $name = $this->fullname($user); $title = get_string('editsubmissionother', 'assign', $name); } if (!$this->submissions_open($userid)) { $message = array(get_string('submissionsclosed', 'assign')); return $this->view_notices($title, $message); } $postfix = ''; if ($this->has_visible_attachments()) { $postfix = $this->render_area_files('mod_assign', ASSIGN_INTROATTACHMENT_FILEAREA, 0); } $o .= $this->get_renderer()->render(new assign_header($this->get_instance(), $this->get_context(), $this->show_intro(), $this->get_course_module()->id, $title, '', $postfix)); // Show plagiarism disclosure for any user submitter. $o .= $this->plagiarism_print_disclosure(); $data = new stdClass(); $data->userid = $userid; if (!$mform) { $mform = new mod_assign_submission_form(null, array($this, $data)); } foreach ($notices as $notice) { $o .= $this->get_renderer()->notification($notice); } $o .= $this->get_renderer()->render(new assign_form('editsubmissionform', $mform)); $o .= $this->view_footer(); \mod_assign\event\submission_form_viewed::create_from_user($this, $user)->trigger(); return $o; }
php
protected function view_edit_submission_page($mform, $notices) { global $CFG, $USER, $DB; $o = ''; require_once($CFG->dirroot . '/mod/assign/submission_form.php'); // Need submit permission to submit an assignment. $userid = optional_param('userid', $USER->id, PARAM_INT); $user = $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST); // This variation on the url will link direct to this student. // The benefit is the url will be the same every time for this student, so Atto autosave drafts can match up. $returnparams = array('userid' => $userid, 'rownum' => 0, 'useridlistid' => 0); $this->register_return_link('editsubmission', $returnparams); if ($userid == $USER->id) { if (!$this->can_edit_submission($userid, $USER->id)) { print_error('nopermission'); } // User is editing their own submission. require_capability('mod/assign:submit', $this->context); $title = get_string('editsubmission', 'assign'); } else { // User is editing another user's submission. if (!$this->can_edit_submission($userid, $USER->id)) { print_error('nopermission'); } $name = $this->fullname($user); $title = get_string('editsubmissionother', 'assign', $name); } if (!$this->submissions_open($userid)) { $message = array(get_string('submissionsclosed', 'assign')); return $this->view_notices($title, $message); } $postfix = ''; if ($this->has_visible_attachments()) { $postfix = $this->render_area_files('mod_assign', ASSIGN_INTROATTACHMENT_FILEAREA, 0); } $o .= $this->get_renderer()->render(new assign_header($this->get_instance(), $this->get_context(), $this->show_intro(), $this->get_course_module()->id, $title, '', $postfix)); // Show plagiarism disclosure for any user submitter. $o .= $this->plagiarism_print_disclosure(); $data = new stdClass(); $data->userid = $userid; if (!$mform) { $mform = new mod_assign_submission_form(null, array($this, $data)); } foreach ($notices as $notice) { $o .= $this->get_renderer()->notification($notice); } $o .= $this->get_renderer()->render(new assign_form('editsubmissionform', $mform)); $o .= $this->view_footer(); \mod_assign\event\submission_form_viewed::create_from_user($this, $user)->trigger(); return $o; }
[ "protected", "function", "view_edit_submission_page", "(", "$", "mform", ",", "$", "notices", ")", "{", "global", "$", "CFG", ",", "$", "USER", ",", "$", "DB", ";", "$", "o", "=", "''", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/mod/assign/submission_form.php'", ")", ";", "// Need submit permission to submit an assignment.", "$", "userid", "=", "optional_param", "(", "'userid'", ",", "$", "USER", "->", "id", ",", "PARAM_INT", ")", ";", "$", "user", "=", "$", "DB", "->", "get_record", "(", "'user'", ",", "array", "(", "'id'", "=>", "$", "userid", ")", ",", "'*'", ",", "MUST_EXIST", ")", ";", "// This variation on the url will link direct to this student.", "// The benefit is the url will be the same every time for this student, so Atto autosave drafts can match up.", "$", "returnparams", "=", "array", "(", "'userid'", "=>", "$", "userid", ",", "'rownum'", "=>", "0", ",", "'useridlistid'", "=>", "0", ")", ";", "$", "this", "->", "register_return_link", "(", "'editsubmission'", ",", "$", "returnparams", ")", ";", "if", "(", "$", "userid", "==", "$", "USER", "->", "id", ")", "{", "if", "(", "!", "$", "this", "->", "can_edit_submission", "(", "$", "userid", ",", "$", "USER", "->", "id", ")", ")", "{", "print_error", "(", "'nopermission'", ")", ";", "}", "// User is editing their own submission.", "require_capability", "(", "'mod/assign:submit'", ",", "$", "this", "->", "context", ")", ";", "$", "title", "=", "get_string", "(", "'editsubmission'", ",", "'assign'", ")", ";", "}", "else", "{", "// User is editing another user's submission.", "if", "(", "!", "$", "this", "->", "can_edit_submission", "(", "$", "userid", ",", "$", "USER", "->", "id", ")", ")", "{", "print_error", "(", "'nopermission'", ")", ";", "}", "$", "name", "=", "$", "this", "->", "fullname", "(", "$", "user", ")", ";", "$", "title", "=", "get_string", "(", "'editsubmissionother'", ",", "'assign'", ",", "$", "name", ")", ";", "}", "if", "(", "!", "$", "this", "->", "submissions_open", "(", "$", "userid", ")", ")", "{", "$", "message", "=", "array", "(", "get_string", "(", "'submissionsclosed'", ",", "'assign'", ")", ")", ";", "return", "$", "this", "->", "view_notices", "(", "$", "title", ",", "$", "message", ")", ";", "}", "$", "postfix", "=", "''", ";", "if", "(", "$", "this", "->", "has_visible_attachments", "(", ")", ")", "{", "$", "postfix", "=", "$", "this", "->", "render_area_files", "(", "'mod_assign'", ",", "ASSIGN_INTROATTACHMENT_FILEAREA", ",", "0", ")", ";", "}", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "new", "assign_header", "(", "$", "this", "->", "get_instance", "(", ")", ",", "$", "this", "->", "get_context", "(", ")", ",", "$", "this", "->", "show_intro", "(", ")", ",", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "$", "title", ",", "''", ",", "$", "postfix", ")", ")", ";", "// Show plagiarism disclosure for any user submitter.", "$", "o", ".=", "$", "this", "->", "plagiarism_print_disclosure", "(", ")", ";", "$", "data", "=", "new", "stdClass", "(", ")", ";", "$", "data", "->", "userid", "=", "$", "userid", ";", "if", "(", "!", "$", "mform", ")", "{", "$", "mform", "=", "new", "mod_assign_submission_form", "(", "null", ",", "array", "(", "$", "this", ",", "$", "data", ")", ")", ";", "}", "foreach", "(", "$", "notices", "as", "$", "notice", ")", "{", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "notification", "(", "$", "notice", ")", ";", "}", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "new", "assign_form", "(", "'editsubmissionform'", ",", "$", "mform", ")", ")", ";", "$", "o", ".=", "$", "this", "->", "view_footer", "(", ")", ";", "\\", "mod_assign", "\\", "event", "\\", "submission_form_viewed", "::", "create_from_user", "(", "$", "this", ",", "$", "user", ")", "->", "trigger", "(", ")", ";", "return", "$", "o", ";", "}" ]
View edit submissions page. @param moodleform $mform @param array $notices A list of notices to display at the top of the edit submission form (e.g. from plugins). @return string The page output.
[ "View", "edit", "submissions", "page", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L4657-L4723
214,992
moodle/moodle
mod/assign/locallib.php
assign.is_graded
protected function is_graded($userid) { $grade = $this->get_user_grade($userid, false); if ($grade) { return ($grade->grade !== null && $grade->grade >= 0); } return false; }
php
protected function is_graded($userid) { $grade = $this->get_user_grade($userid, false); if ($grade) { return ($grade->grade !== null && $grade->grade >= 0); } return false; }
[ "protected", "function", "is_graded", "(", "$", "userid", ")", "{", "$", "grade", "=", "$", "this", "->", "get_user_grade", "(", "$", "userid", ",", "false", ")", ";", "if", "(", "$", "grade", ")", "{", "return", "(", "$", "grade", "->", "grade", "!==", "null", "&&", "$", "grade", "->", "grade", ">=", "0", ")", ";", "}", "return", "false", ";", "}" ]
See if this assignment has a grade yet. @param int $userid @return bool
[ "See", "if", "this", "assignment", "has", "a", "grade", "yet", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L4731-L4737
214,993
moodle/moodle
mod/assign/locallib.php
assign.view_plugin_grading_batch_operation
protected function view_plugin_grading_batch_operation($mform) { require_capability('mod/assign:grade', $this->context); $prefix = 'plugingradingbatchoperation_'; if ($data = $mform->get_data()) { $tail = substr($data->operation, strlen($prefix)); list($plugintype, $action) = explode('_', $tail, 2); $plugin = $this->get_feedback_plugin_by_type($plugintype); if ($plugin) { $users = $data->selectedusers; $userlist = explode(',', $users); echo $plugin->grading_batch_operation($action, $userlist); return; } } print_error('invalidformdata', ''); }
php
protected function view_plugin_grading_batch_operation($mform) { require_capability('mod/assign:grade', $this->context); $prefix = 'plugingradingbatchoperation_'; if ($data = $mform->get_data()) { $tail = substr($data->operation, strlen($prefix)); list($plugintype, $action) = explode('_', $tail, 2); $plugin = $this->get_feedback_plugin_by_type($plugintype); if ($plugin) { $users = $data->selectedusers; $userlist = explode(',', $users); echo $plugin->grading_batch_operation($action, $userlist); return; } } print_error('invalidformdata', ''); }
[ "protected", "function", "view_plugin_grading_batch_operation", "(", "$", "mform", ")", "{", "require_capability", "(", "'mod/assign:grade'", ",", "$", "this", "->", "context", ")", ";", "$", "prefix", "=", "'plugingradingbatchoperation_'", ";", "if", "(", "$", "data", "=", "$", "mform", "->", "get_data", "(", ")", ")", "{", "$", "tail", "=", "substr", "(", "$", "data", "->", "operation", ",", "strlen", "(", "$", "prefix", ")", ")", ";", "list", "(", "$", "plugintype", ",", "$", "action", ")", "=", "explode", "(", "'_'", ",", "$", "tail", ",", "2", ")", ";", "$", "plugin", "=", "$", "this", "->", "get_feedback_plugin_by_type", "(", "$", "plugintype", ")", ";", "if", "(", "$", "plugin", ")", "{", "$", "users", "=", "$", "data", "->", "selectedusers", ";", "$", "userlist", "=", "explode", "(", "','", ",", "$", "users", ")", ";", "echo", "$", "plugin", "->", "grading_batch_operation", "(", "$", "action", ",", "$", "userlist", ")", ";", "return", ";", "}", "}", "print_error", "(", "'invalidformdata'", ",", "''", ")", ";", "}" ]
Allows the plugin to show a batch grading operation page. @param moodleform $mform @return none
[ "Allows", "the", "plugin", "to", "show", "a", "batch", "grading", "operation", "page", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L4807-L4824
214,994
moodle/moodle
mod/assign/locallib.php
assign.view_batch_set_workflow_state
protected function view_batch_set_workflow_state($mform) { global $CFG, $DB; require_once($CFG->dirroot . '/mod/assign/batchsetmarkingworkflowstateform.php'); $o = ''; $submitteddata = $mform->get_data(); $users = $submitteddata->selectedusers; $userlist = explode(',', $users); $formdata = array('id' => $this->get_course_module()->id, 'selectedusers' => $users); $usershtml = ''; $usercount = 0; $extrauserfields = get_extra_user_fields($this->get_context()); $viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_context()); foreach ($userlist as $userid) { if ($usercount >= 5) { $usershtml .= get_string('moreusers', 'assign', count($userlist) - 5); break; } $user = $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST); $usershtml .= $this->get_renderer()->render(new assign_user_summary($user, $this->get_course()->id, $viewfullnames, $this->is_blind_marking(), $this->get_uniqueid_for_user($user->id), $extrauserfields, !$this->is_active_user($userid))); $usercount += 1; } $formparams = array( 'userscount' => count($userlist), 'usershtml' => $usershtml, 'markingworkflowstates' => $this->get_marking_workflow_states_for_current_user() ); $mform = new mod_assign_batch_set_marking_workflow_state_form(null, $formparams); $mform->set_data($formdata); // Initialises the hidden elements. $header = new assign_header($this->get_instance(), $this->get_context(), $this->show_intro(), $this->get_course_module()->id, get_string('setmarkingworkflowstate', 'assign')); $o .= $this->get_renderer()->render($header); $o .= $this->get_renderer()->render(new assign_form('setworkflowstate', $mform)); $o .= $this->view_footer(); \mod_assign\event\batch_set_workflow_state_viewed::create_from_assign($this)->trigger(); return $o; }
php
protected function view_batch_set_workflow_state($mform) { global $CFG, $DB; require_once($CFG->dirroot . '/mod/assign/batchsetmarkingworkflowstateform.php'); $o = ''; $submitteddata = $mform->get_data(); $users = $submitteddata->selectedusers; $userlist = explode(',', $users); $formdata = array('id' => $this->get_course_module()->id, 'selectedusers' => $users); $usershtml = ''; $usercount = 0; $extrauserfields = get_extra_user_fields($this->get_context()); $viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_context()); foreach ($userlist as $userid) { if ($usercount >= 5) { $usershtml .= get_string('moreusers', 'assign', count($userlist) - 5); break; } $user = $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST); $usershtml .= $this->get_renderer()->render(new assign_user_summary($user, $this->get_course()->id, $viewfullnames, $this->is_blind_marking(), $this->get_uniqueid_for_user($user->id), $extrauserfields, !$this->is_active_user($userid))); $usercount += 1; } $formparams = array( 'userscount' => count($userlist), 'usershtml' => $usershtml, 'markingworkflowstates' => $this->get_marking_workflow_states_for_current_user() ); $mform = new mod_assign_batch_set_marking_workflow_state_form(null, $formparams); $mform->set_data($formdata); // Initialises the hidden elements. $header = new assign_header($this->get_instance(), $this->get_context(), $this->show_intro(), $this->get_course_module()->id, get_string('setmarkingworkflowstate', 'assign')); $o .= $this->get_renderer()->render($header); $o .= $this->get_renderer()->render(new assign_form('setworkflowstate', $mform)); $o .= $this->view_footer(); \mod_assign\event\batch_set_workflow_state_viewed::create_from_assign($this)->trigger(); return $o; }
[ "protected", "function", "view_batch_set_workflow_state", "(", "$", "mform", ")", "{", "global", "$", "CFG", ",", "$", "DB", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/mod/assign/batchsetmarkingworkflowstateform.php'", ")", ";", "$", "o", "=", "''", ";", "$", "submitteddata", "=", "$", "mform", "->", "get_data", "(", ")", ";", "$", "users", "=", "$", "submitteddata", "->", "selectedusers", ";", "$", "userlist", "=", "explode", "(", "','", ",", "$", "users", ")", ";", "$", "formdata", "=", "array", "(", "'id'", "=>", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "'selectedusers'", "=>", "$", "users", ")", ";", "$", "usershtml", "=", "''", ";", "$", "usercount", "=", "0", ";", "$", "extrauserfields", "=", "get_extra_user_fields", "(", "$", "this", "->", "get_context", "(", ")", ")", ";", "$", "viewfullnames", "=", "has_capability", "(", "'moodle/site:viewfullnames'", ",", "$", "this", "->", "get_context", "(", ")", ")", ";", "foreach", "(", "$", "userlist", "as", "$", "userid", ")", "{", "if", "(", "$", "usercount", ">=", "5", ")", "{", "$", "usershtml", ".=", "get_string", "(", "'moreusers'", ",", "'assign'", ",", "count", "(", "$", "userlist", ")", "-", "5", ")", ";", "break", ";", "}", "$", "user", "=", "$", "DB", "->", "get_record", "(", "'user'", ",", "array", "(", "'id'", "=>", "$", "userid", ")", ",", "'*'", ",", "MUST_EXIST", ")", ";", "$", "usershtml", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "new", "assign_user_summary", "(", "$", "user", ",", "$", "this", "->", "get_course", "(", ")", "->", "id", ",", "$", "viewfullnames", ",", "$", "this", "->", "is_blind_marking", "(", ")", ",", "$", "this", "->", "get_uniqueid_for_user", "(", "$", "user", "->", "id", ")", ",", "$", "extrauserfields", ",", "!", "$", "this", "->", "is_active_user", "(", "$", "userid", ")", ")", ")", ";", "$", "usercount", "+=", "1", ";", "}", "$", "formparams", "=", "array", "(", "'userscount'", "=>", "count", "(", "$", "userlist", ")", ",", "'usershtml'", "=>", "$", "usershtml", ",", "'markingworkflowstates'", "=>", "$", "this", "->", "get_marking_workflow_states_for_current_user", "(", ")", ")", ";", "$", "mform", "=", "new", "mod_assign_batch_set_marking_workflow_state_form", "(", "null", ",", "$", "formparams", ")", ";", "$", "mform", "->", "set_data", "(", "$", "formdata", ")", ";", "// Initialises the hidden elements.", "$", "header", "=", "new", "assign_header", "(", "$", "this", "->", "get_instance", "(", ")", ",", "$", "this", "->", "get_context", "(", ")", ",", "$", "this", "->", "show_intro", "(", ")", ",", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "get_string", "(", "'setmarkingworkflowstate'", ",", "'assign'", ")", ")", ";", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "$", "header", ")", ";", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "new", "assign_form", "(", "'setworkflowstate'", ",", "$", "mform", ")", ")", ";", "$", "o", ".=", "$", "this", "->", "view_footer", "(", ")", ";", "\\", "mod_assign", "\\", "event", "\\", "batch_set_workflow_state_viewed", "::", "create_from_assign", "(", "$", "this", ")", "->", "trigger", "(", ")", ";", "return", "$", "o", ";", "}" ]
Shows a form that allows the workflow state for selected submissions to be changed. @param moodleform $mform Set to a grading batch operations form @return string - the page to view after processing these actions
[ "Shows", "a", "form", "that", "allows", "the", "workflow", "state", "for", "selected", "submissions", "to", "be", "changed", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L4915-L4971
214,995
moodle/moodle
mod/assign/locallib.php
assign.view_batch_markingallocation
public function view_batch_markingallocation($mform) { global $CFG, $DB; require_once($CFG->dirroot . '/mod/assign/batchsetallocatedmarkerform.php'); $o = ''; $submitteddata = $mform->get_data(); $users = $submitteddata->selectedusers; $userlist = explode(',', $users); $formdata = array('id' => $this->get_course_module()->id, 'selectedusers' => $users); $usershtml = ''; $usercount = 0; $extrauserfields = get_extra_user_fields($this->get_context()); $viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_context()); foreach ($userlist as $userid) { if ($usercount >= 5) { $usershtml .= get_string('moreusers', 'assign', count($userlist) - 5); break; } $user = $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST); $usershtml .= $this->get_renderer()->render(new assign_user_summary($user, $this->get_course()->id, $viewfullnames, $this->is_blind_marking(), $this->get_uniqueid_for_user($user->id), $extrauserfields, !$this->is_active_user($userid))); $usercount += 1; } $formparams = array( 'userscount' => count($userlist), 'usershtml' => $usershtml, ); 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); $mform->set_data($formdata); // Initialises the hidden elements. $header = new assign_header($this->get_instance(), $this->get_context(), $this->show_intro(), $this->get_course_module()->id, get_string('setmarkingallocation', 'assign')); $o .= $this->get_renderer()->render($header); $o .= $this->get_renderer()->render(new assign_form('setworkflowstate', $mform)); $o .= $this->view_footer(); \mod_assign\event\batch_set_marker_allocation_viewed::create_from_assign($this)->trigger(); return $o; }
php
public function view_batch_markingallocation($mform) { global $CFG, $DB; require_once($CFG->dirroot . '/mod/assign/batchsetallocatedmarkerform.php'); $o = ''; $submitteddata = $mform->get_data(); $users = $submitteddata->selectedusers; $userlist = explode(',', $users); $formdata = array('id' => $this->get_course_module()->id, 'selectedusers' => $users); $usershtml = ''; $usercount = 0; $extrauserfields = get_extra_user_fields($this->get_context()); $viewfullnames = has_capability('moodle/site:viewfullnames', $this->get_context()); foreach ($userlist as $userid) { if ($usercount >= 5) { $usershtml .= get_string('moreusers', 'assign', count($userlist) - 5); break; } $user = $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST); $usershtml .= $this->get_renderer()->render(new assign_user_summary($user, $this->get_course()->id, $viewfullnames, $this->is_blind_marking(), $this->get_uniqueid_for_user($user->id), $extrauserfields, !$this->is_active_user($userid))); $usercount += 1; } $formparams = array( 'userscount' => count($userlist), 'usershtml' => $usershtml, ); 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); $mform->set_data($formdata); // Initialises the hidden elements. $header = new assign_header($this->get_instance(), $this->get_context(), $this->show_intro(), $this->get_course_module()->id, get_string('setmarkingallocation', 'assign')); $o .= $this->get_renderer()->render($header); $o .= $this->get_renderer()->render(new assign_form('setworkflowstate', $mform)); $o .= $this->view_footer(); \mod_assign\event\batch_set_marker_allocation_viewed::create_from_assign($this)->trigger(); return $o; }
[ "public", "function", "view_batch_markingallocation", "(", "$", "mform", ")", "{", "global", "$", "CFG", ",", "$", "DB", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/mod/assign/batchsetallocatedmarkerform.php'", ")", ";", "$", "o", "=", "''", ";", "$", "submitteddata", "=", "$", "mform", "->", "get_data", "(", ")", ";", "$", "users", "=", "$", "submitteddata", "->", "selectedusers", ";", "$", "userlist", "=", "explode", "(", "','", ",", "$", "users", ")", ";", "$", "formdata", "=", "array", "(", "'id'", "=>", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "'selectedusers'", "=>", "$", "users", ")", ";", "$", "usershtml", "=", "''", ";", "$", "usercount", "=", "0", ";", "$", "extrauserfields", "=", "get_extra_user_fields", "(", "$", "this", "->", "get_context", "(", ")", ")", ";", "$", "viewfullnames", "=", "has_capability", "(", "'moodle/site:viewfullnames'", ",", "$", "this", "->", "get_context", "(", ")", ")", ";", "foreach", "(", "$", "userlist", "as", "$", "userid", ")", "{", "if", "(", "$", "usercount", ">=", "5", ")", "{", "$", "usershtml", ".=", "get_string", "(", "'moreusers'", ",", "'assign'", ",", "count", "(", "$", "userlist", ")", "-", "5", ")", ";", "break", ";", "}", "$", "user", "=", "$", "DB", "->", "get_record", "(", "'user'", ",", "array", "(", "'id'", "=>", "$", "userid", ")", ",", "'*'", ",", "MUST_EXIST", ")", ";", "$", "usershtml", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "new", "assign_user_summary", "(", "$", "user", ",", "$", "this", "->", "get_course", "(", ")", "->", "id", ",", "$", "viewfullnames", ",", "$", "this", "->", "is_blind_marking", "(", ")", ",", "$", "this", "->", "get_uniqueid_for_user", "(", "$", "user", "->", "id", ")", ",", "$", "extrauserfields", ",", "!", "$", "this", "->", "is_active_user", "(", "$", "userid", ")", ")", ")", ";", "$", "usercount", "+=", "1", ";", "}", "$", "formparams", "=", "array", "(", "'userscount'", "=>", "count", "(", "$", "userlist", ")", ",", "'usershtml'", "=>", "$", "usershtml", ",", ")", ";", "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", ")", ";", "$", "mform", "->", "set_data", "(", "$", "formdata", ")", ";", "// Initialises the hidden elements.", "$", "header", "=", "new", "assign_header", "(", "$", "this", "->", "get_instance", "(", ")", ",", "$", "this", "->", "get_context", "(", ")", ",", "$", "this", "->", "show_intro", "(", ")", ",", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "get_string", "(", "'setmarkingallocation'", ",", "'assign'", ")", ")", ";", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "$", "header", ")", ";", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "new", "assign_form", "(", "'setworkflowstate'", ",", "$", "mform", ")", ")", ";", "$", "o", ".=", "$", "this", "->", "view_footer", "(", ")", ";", "\\", "mod_assign", "\\", "event", "\\", "batch_set_marker_allocation_viewed", "::", "create_from_assign", "(", "$", "this", ")", "->", "trigger", "(", ")", ";", "return", "$", "o", ";", "}" ]
Shows a form that allows the allocated marker for selected submissions to be changed. @param moodleform $mform Set to a grading batch operations form @return string - the page to view after processing these actions
[ "Shows", "a", "form", "that", "allows", "the", "allocated", "marker", "for", "selected", "submissions", "to", "be", "changed", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L4979-L5044
214,996
moodle/moodle
mod/assign/locallib.php
assign.check_submit_for_grading
protected function check_submit_for_grading($mform) { global $USER, $CFG; require_once($CFG->dirroot . '/mod/assign/submissionconfirmform.php'); // Check that all of the submission plugins are ready for this submission. $notifications = array(); $submission = $this->get_user_submission($USER->id, false); $plugins = $this->get_submission_plugins(); foreach ($plugins as $plugin) { if ($plugin->is_enabled() && $plugin->is_visible()) { $check = $plugin->precheck_submission($submission); if ($check !== true) { $notifications[] = $check; } } } $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)); } $o = ''; $o .= $this->get_renderer()->render(new assign_header($this->get_instance(), $this->get_context(), $this->show_intro(), $this->get_course_module()->id, get_string('confirmsubmissionheading', 'assign'))); $submitforgradingpage = new assign_submit_for_grading_page($notifications, $this->get_course_module()->id, $mform); $o .= $this->get_renderer()->render($submitforgradingpage); $o .= $this->view_footer(); \mod_assign\event\submission_confirmation_form_viewed::create_from_assign($this)->trigger(); return $o; }
php
protected function check_submit_for_grading($mform) { global $USER, $CFG; require_once($CFG->dirroot . '/mod/assign/submissionconfirmform.php'); // Check that all of the submission plugins are ready for this submission. $notifications = array(); $submission = $this->get_user_submission($USER->id, false); $plugins = $this->get_submission_plugins(); foreach ($plugins as $plugin) { if ($plugin->is_enabled() && $plugin->is_visible()) { $check = $plugin->precheck_submission($submission); if ($check !== true) { $notifications[] = $check; } } } $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)); } $o = ''; $o .= $this->get_renderer()->render(new assign_header($this->get_instance(), $this->get_context(), $this->show_intro(), $this->get_course_module()->id, get_string('confirmsubmissionheading', 'assign'))); $submitforgradingpage = new assign_submit_for_grading_page($notifications, $this->get_course_module()->id, $mform); $o .= $this->get_renderer()->render($submitforgradingpage); $o .= $this->view_footer(); \mod_assign\event\submission_confirmation_form_viewed::create_from_assign($this)->trigger(); return $o; }
[ "protected", "function", "check_submit_for_grading", "(", "$", "mform", ")", "{", "global", "$", "USER", ",", "$", "CFG", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/mod/assign/submissionconfirmform.php'", ")", ";", "// Check that all of the submission plugins are ready for this submission.", "$", "notifications", "=", "array", "(", ")", ";", "$", "submission", "=", "$", "this", "->", "get_user_submission", "(", "$", "USER", "->", "id", ",", "false", ")", ";", "$", "plugins", "=", "$", "this", "->", "get_submission_plugins", "(", ")", ";", "foreach", "(", "$", "plugins", "as", "$", "plugin", ")", "{", "if", "(", "$", "plugin", "->", "is_enabled", "(", ")", "&&", "$", "plugin", "->", "is_visible", "(", ")", ")", "{", "$", "check", "=", "$", "plugin", "->", "precheck_submission", "(", "$", "submission", ")", ";", "if", "(", "$", "check", "!==", "true", ")", "{", "$", "notifications", "[", "]", "=", "$", "check", ";", "}", "}", "}", "$", "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", ")", ")", ";", "}", "$", "o", "=", "''", ";", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "new", "assign_header", "(", "$", "this", "->", "get_instance", "(", ")", ",", "$", "this", "->", "get_context", "(", ")", ",", "$", "this", "->", "show_intro", "(", ")", ",", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "get_string", "(", "'confirmsubmissionheading'", ",", "'assign'", ")", ")", ")", ";", "$", "submitforgradingpage", "=", "new", "assign_submit_for_grading_page", "(", "$", "notifications", ",", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "$", "mform", ")", ";", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "$", "submitforgradingpage", ")", ";", "$", "o", ".=", "$", "this", "->", "view_footer", "(", ")", ";", "\\", "mod_assign", "\\", "event", "\\", "submission_confirmation_form_viewed", "::", "create_from_assign", "(", "$", "this", ")", "->", "trigger", "(", ")", ";", "return", "$", "o", ";", "}" ]
Ask the user to confirm they want to submit their work for grading. @param moodleform $mform - null unless form validation has failed @return string
[ "Ask", "the", "user", "to", "confirm", "they", "want", "to", "submit", "their", "work", "for", "grading", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L5052-L5106
214,997
moodle/moodle
mod/assign/locallib.php
assign.get_assign_attempt_history_renderable
public function get_assign_attempt_history_renderable($user) { $allsubmissions = $this->get_all_submissions($user->id); $allgrades = $this->get_all_grades($user->id); $history = new assign_attempt_history($allsubmissions, $allgrades, $this->get_submission_plugins(), $this->get_feedback_plugins(), $this->get_course_module()->id, $this->get_return_action(), $this->get_return_params(), false, 0, 0); return $history; }
php
public function get_assign_attempt_history_renderable($user) { $allsubmissions = $this->get_all_submissions($user->id); $allgrades = $this->get_all_grades($user->id); $history = new assign_attempt_history($allsubmissions, $allgrades, $this->get_submission_plugins(), $this->get_feedback_plugins(), $this->get_course_module()->id, $this->get_return_action(), $this->get_return_params(), false, 0, 0); return $history; }
[ "public", "function", "get_assign_attempt_history_renderable", "(", "$", "user", ")", "{", "$", "allsubmissions", "=", "$", "this", "->", "get_all_submissions", "(", "$", "user", "->", "id", ")", ";", "$", "allgrades", "=", "$", "this", "->", "get_all_grades", "(", "$", "user", "->", "id", ")", ";", "$", "history", "=", "new", "assign_attempt_history", "(", "$", "allsubmissions", ",", "$", "allgrades", ",", "$", "this", "->", "get_submission_plugins", "(", ")", ",", "$", "this", "->", "get_feedback_plugins", "(", ")", ",", "$", "this", "->", "get_course_module", "(", ")", "->", "id", ",", "$", "this", "->", "get_return_action", "(", ")", ",", "$", "this", "->", "get_return_params", "(", ")", ",", "false", ",", "0", ",", "0", ")", ";", "return", "$", "history", ";", "}" ]
Creates an assign_attempt_history renderable. @param stdClass $user the user to get the report for @return assign_attempt_history renderable object
[ "Creates", "an", "assign_attempt_history", "renderable", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L5310-L5326
214,998
moodle/moodle
mod/assign/locallib.php
assign.view_student_summary
public function view_student_summary($user, $showlinks) { $o = ''; if ($this->can_view_submission($user->id)) { if (has_capability('mod/assign:submit', $this->get_context(), $user, false)) { $submissionstatus = $this->get_assign_submission_status_renderable($user, $showlinks); $o .= $this->get_renderer()->render($submissionstatus); } // If there is a visible grade, show the feedback. $feedbackstatus = $this->get_assign_feedback_status_renderable($user); if ($feedbackstatus) { $o .= $this->get_renderer()->render($feedbackstatus); } // If there is more than one submission, show the history. $history = $this->get_assign_attempt_history_renderable($user); if (count($history->submissions) > 1) { $o .= $this->get_renderer()->render($history); } } return $o; }
php
public function view_student_summary($user, $showlinks) { $o = ''; if ($this->can_view_submission($user->id)) { if (has_capability('mod/assign:submit', $this->get_context(), $user, false)) { $submissionstatus = $this->get_assign_submission_status_renderable($user, $showlinks); $o .= $this->get_renderer()->render($submissionstatus); } // If there is a visible grade, show the feedback. $feedbackstatus = $this->get_assign_feedback_status_renderable($user); if ($feedbackstatus) { $o .= $this->get_renderer()->render($feedbackstatus); } // If there is more than one submission, show the history. $history = $this->get_assign_attempt_history_renderable($user); if (count($history->submissions) > 1) { $o .= $this->get_renderer()->render($history); } } return $o; }
[ "public", "function", "view_student_summary", "(", "$", "user", ",", "$", "showlinks", ")", "{", "$", "o", "=", "''", ";", "if", "(", "$", "this", "->", "can_view_submission", "(", "$", "user", "->", "id", ")", ")", "{", "if", "(", "has_capability", "(", "'mod/assign:submit'", ",", "$", "this", "->", "get_context", "(", ")", ",", "$", "user", ",", "false", ")", ")", "{", "$", "submissionstatus", "=", "$", "this", "->", "get_assign_submission_status_renderable", "(", "$", "user", ",", "$", "showlinks", ")", ";", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "$", "submissionstatus", ")", ";", "}", "// If there is a visible grade, show the feedback.", "$", "feedbackstatus", "=", "$", "this", "->", "get_assign_feedback_status_renderable", "(", "$", "user", ")", ";", "if", "(", "$", "feedbackstatus", ")", "{", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "$", "feedbackstatus", ")", ";", "}", "// If there is more than one submission, show the history.", "$", "history", "=", "$", "this", "->", "get_assign_attempt_history_renderable", "(", "$", "user", ")", ";", "if", "(", "count", "(", "$", "history", "->", "submissions", ")", ">", "1", ")", "{", "$", "o", ".=", "$", "this", "->", "get_renderer", "(", ")", "->", "render", "(", "$", "history", ")", ";", "}", "}", "return", "$", "o", ";", "}" ]
Print 2 tables of information with no action links - the submission summary and the grading summary. @param stdClass $user the user to print the report for @param bool $showlinks - Return plain text or links to the profile @return string - the html summary
[ "Print", "2", "tables", "of", "information", "with", "no", "action", "links", "-", "the", "submission", "summary", "and", "the", "grading", "summary", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L5336-L5360
214,999
moodle/moodle
mod/assign/locallib.php
assign.show_submit_button
protected function show_submit_button($submission = null, $teamsubmission = null, $userid = null) { if ($teamsubmission) { if ($teamsubmission->status === ASSIGN_SUBMISSION_STATUS_SUBMITTED) { // The assignment submission has been completed. return false; } else if ($this->submission_empty($teamsubmission)) { // There is nothing to submit yet. return false; } else if ($submission && $submission->status === ASSIGN_SUBMISSION_STATUS_SUBMITTED) { // The user has already clicked the submit button on the team submission. return false; } else if ( !empty($this->get_instance()->preventsubmissionnotingroup) && $this->get_submission_group($userid) == false ) { return false; } } else if ($submission) { if ($submission->status === ASSIGN_SUBMISSION_STATUS_SUBMITTED) { // The assignment submission has been completed. return false; } else if ($this->submission_empty($submission)) { // There is nothing to submit. return false; } } else { // We've not got a valid submission or team submission. return false; } // Last check is that this instance allows drafts. return $this->get_instance()->submissiondrafts; }
php
protected function show_submit_button($submission = null, $teamsubmission = null, $userid = null) { if ($teamsubmission) { if ($teamsubmission->status === ASSIGN_SUBMISSION_STATUS_SUBMITTED) { // The assignment submission has been completed. return false; } else if ($this->submission_empty($teamsubmission)) { // There is nothing to submit yet. return false; } else if ($submission && $submission->status === ASSIGN_SUBMISSION_STATUS_SUBMITTED) { // The user has already clicked the submit button on the team submission. return false; } else if ( !empty($this->get_instance()->preventsubmissionnotingroup) && $this->get_submission_group($userid) == false ) { return false; } } else if ($submission) { if ($submission->status === ASSIGN_SUBMISSION_STATUS_SUBMITTED) { // The assignment submission has been completed. return false; } else if ($this->submission_empty($submission)) { // There is nothing to submit. return false; } } else { // We've not got a valid submission or team submission. return false; } // Last check is that this instance allows drafts. return $this->get_instance()->submissiondrafts; }
[ "protected", "function", "show_submit_button", "(", "$", "submission", "=", "null", ",", "$", "teamsubmission", "=", "null", ",", "$", "userid", "=", "null", ")", "{", "if", "(", "$", "teamsubmission", ")", "{", "if", "(", "$", "teamsubmission", "->", "status", "===", "ASSIGN_SUBMISSION_STATUS_SUBMITTED", ")", "{", "// The assignment submission has been completed.", "return", "false", ";", "}", "else", "if", "(", "$", "this", "->", "submission_empty", "(", "$", "teamsubmission", ")", ")", "{", "// There is nothing to submit yet.", "return", "false", ";", "}", "else", "if", "(", "$", "submission", "&&", "$", "submission", "->", "status", "===", "ASSIGN_SUBMISSION_STATUS_SUBMITTED", ")", "{", "// The user has already clicked the submit button on the team submission.", "return", "false", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "this", "->", "get_instance", "(", ")", "->", "preventsubmissionnotingroup", ")", "&&", "$", "this", "->", "get_submission_group", "(", "$", "userid", ")", "==", "false", ")", "{", "return", "false", ";", "}", "}", "else", "if", "(", "$", "submission", ")", "{", "if", "(", "$", "submission", "->", "status", "===", "ASSIGN_SUBMISSION_STATUS_SUBMITTED", ")", "{", "// The assignment submission has been completed.", "return", "false", ";", "}", "else", "if", "(", "$", "this", "->", "submission_empty", "(", "$", "submission", ")", ")", "{", "// There is nothing to submit.", "return", "false", ";", "}", "}", "else", "{", "// We've not got a valid submission or team submission.", "return", "false", ";", "}", "// Last check is that this instance allows drafts.", "return", "$", "this", "->", "get_instance", "(", ")", "->", "submissiondrafts", ";", "}" ]
Returns true if the submit subsission button should be shown to the user. @param stdClass $submission The users own submission record. @param stdClass $teamsubmission The users team submission record if there is one @param int $userid The user @return bool
[ "Returns", "true", "if", "the", "submit", "subsission", "button", "should", "be", "shown", "to", "the", "user", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/locallib.php#L5370-L5401