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
217,300
moodle/moodle
competency/classes/api.php
api.list_evidence_in_course
public static function list_evidence_in_course($userid = 0, $courseid = 0, $competencyid = 0, $sort = 'timecreated', $order = 'DESC', $skip = 0, $limit = 0) { static::require_enabled(); if (!user_competency::can_read_user_in_course($userid, $courseid)) { $context = context_user::instance($userid); throw new required_capability_exception($context, 'moodle/competency:usercompetencyview', 'nopermissions', ''); } $usercompetency = user_competency::get_record(array('userid' => $userid, 'competencyid' => $competencyid)); if (!$usercompetency) { return array(); } $context = context_course::instance($courseid); return evidence::get_records_for_usercompetency($usercompetency->get('id'), $context, $sort, $order, $skip, $limit); }
php
public static function list_evidence_in_course($userid = 0, $courseid = 0, $competencyid = 0, $sort = 'timecreated', $order = 'DESC', $skip = 0, $limit = 0) { static::require_enabled(); if (!user_competency::can_read_user_in_course($userid, $courseid)) { $context = context_user::instance($userid); throw new required_capability_exception($context, 'moodle/competency:usercompetencyview', 'nopermissions', ''); } $usercompetency = user_competency::get_record(array('userid' => $userid, 'competencyid' => $competencyid)); if (!$usercompetency) { return array(); } $context = context_course::instance($courseid); return evidence::get_records_for_usercompetency($usercompetency->get('id'), $context, $sort, $order, $skip, $limit); }
[ "public", "static", "function", "list_evidence_in_course", "(", "$", "userid", "=", "0", ",", "$", "courseid", "=", "0", ",", "$", "competencyid", "=", "0", ",", "$", "sort", "=", "'timecreated'", ",", "$", "order", "=", "'DESC'", ",", "$", "skip", "=", "0", ",", "$", "limit", "=", "0", ")", "{", "static", "::", "require_enabled", "(", ")", ";", "if", "(", "!", "user_competency", "::", "can_read_user_in_course", "(", "$", "userid", ",", "$", "courseid", ")", ")", "{", "$", "context", "=", "context_user", "::", "instance", "(", "$", "userid", ")", ";", "throw", "new", "required_capability_exception", "(", "$", "context", ",", "'moodle/competency:usercompetencyview'", ",", "'nopermissions'", ",", "''", ")", ";", "}", "$", "usercompetency", "=", "user_competency", "::", "get_record", "(", "array", "(", "'userid'", "=>", "$", "userid", ",", "'competencyid'", "=>", "$", "competencyid", ")", ")", ";", "if", "(", "!", "$", "usercompetency", ")", "{", "return", "array", "(", ")", ";", "}", "$", "context", "=", "context_course", "::", "instance", "(", "$", "courseid", ")", ";", "return", "evidence", "::", "get_records_for_usercompetency", "(", "$", "usercompetency", "->", "get", "(", "'id'", ")", ",", "$", "context", ",", "$", "sort", ",", "$", "order", ",", "$", "skip", ",", "$", "limit", ")", ";", "}" ]
List all the evidence for a user competency in a course. @param int $userid The user ID. @param int $courseid The course ID. @param int $competencyid The competency ID. @param string $sort The field to sort the evidence by. @param string $order The ordering of the sorting. @param int $skip Number of records to skip. @param int $limit Number of records to return. @return \core_competency\evidence[]
[ "List", "all", "the", "evidence", "for", "a", "user", "competency", "in", "a", "course", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/api.php#L4213-L4229
217,301
moodle/moodle
competency/classes/api.php
api.read_evidence
public static function read_evidence($evidenceid) { static::require_enabled(); $evidence = new evidence($evidenceid); $uc = new user_competency($evidence->get('usercompetencyid')); if (!$uc->can_read()) { throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyview', 'nopermissions', ''); } return $evidence; }
php
public static function read_evidence($evidenceid) { static::require_enabled(); $evidence = new evidence($evidenceid); $uc = new user_competency($evidence->get('usercompetencyid')); if (!$uc->can_read()) { throw new required_capability_exception($uc->get_context(), 'moodle/competency:usercompetencyview', 'nopermissions', ''); } return $evidence; }
[ "public", "static", "function", "read_evidence", "(", "$", "evidenceid", ")", "{", "static", "::", "require_enabled", "(", ")", ";", "$", "evidence", "=", "new", "evidence", "(", "$", "evidenceid", ")", ";", "$", "uc", "=", "new", "user_competency", "(", "$", "evidence", "->", "get", "(", "'usercompetencyid'", ")", ")", ";", "if", "(", "!", "$", "uc", "->", "can_read", "(", ")", ")", "{", "throw", "new", "required_capability_exception", "(", "$", "uc", "->", "get_context", "(", ")", ",", "'moodle/competency:usercompetencyview'", ",", "'nopermissions'", ",", "''", ")", ";", "}", "return", "$", "evidence", ";", "}" ]
Read an evidence. @param int $evidenceid The evidence ID. @return evidence
[ "Read", "an", "evidence", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/api.php#L4487-L4498
217,302
moodle/moodle
competency/classes/api.php
api.delete_evidence
public static function delete_evidence($evidenceorid) { $evidence = $evidenceorid; if (!is_object($evidence)) { $evidence = new evidence($evidenceorid); } $uc = new user_competency($evidence->get('usercompetencyid')); if (!evidence::can_delete_user($uc->get('userid'))) { throw new required_capability_exception($uc->get_context(), 'moodle/competency:evidencedelete', 'nopermissions', ''); } return $evidence->delete(); }
php
public static function delete_evidence($evidenceorid) { $evidence = $evidenceorid; if (!is_object($evidence)) { $evidence = new evidence($evidenceorid); } $uc = new user_competency($evidence->get('usercompetencyid')); if (!evidence::can_delete_user($uc->get('userid'))) { throw new required_capability_exception($uc->get_context(), 'moodle/competency:evidencedelete', 'nopermissions', ''); } return $evidence->delete(); }
[ "public", "static", "function", "delete_evidence", "(", "$", "evidenceorid", ")", "{", "$", "evidence", "=", "$", "evidenceorid", ";", "if", "(", "!", "is_object", "(", "$", "evidence", ")", ")", "{", "$", "evidence", "=", "new", "evidence", "(", "$", "evidenceorid", ")", ";", "}", "$", "uc", "=", "new", "user_competency", "(", "$", "evidence", "->", "get", "(", "'usercompetencyid'", ")", ")", ";", "if", "(", "!", "evidence", "::", "can_delete_user", "(", "$", "uc", "->", "get", "(", "'userid'", ")", ")", ")", "{", "throw", "new", "required_capability_exception", "(", "$", "uc", "->", "get_context", "(", ")", ",", "'moodle/competency:evidencedelete'", ",", "'nopermissions'", ",", "''", ")", ";", "}", "return", "$", "evidence", "->", "delete", "(", ")", ";", "}" ]
Delete an evidence. @param evidence|int $evidenceorid The evidence, or its ID. @return bool
[ "Delete", "an", "evidence", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/api.php#L4506-L4518
217,303
moodle/moodle
competency/classes/api.php
api.apply_competency_rules_from_usercompetency
protected static function apply_competency_rules_from_usercompetency(user_competency $usercompetency, competency $competency = null) { // Perform some basic checks. if (!$usercompetency->get('proficiency')) { throw new coding_exception('The user competency passed is not completed.'); } if ($competency === null) { $competency = $usercompetency->get_competency(); } if ($competency->get('id') != $usercompetency->get('competencyid')) { throw new coding_exception('Mismatch between user competency and competency.'); } // Fetch the parent. $parent = $competency->get_parent(); if ($parent === null) { return; } // The parent should have a rule, and a meaningful outcome. $ruleoutcome = $parent->get('ruleoutcome'); if ($ruleoutcome == competency::OUTCOME_NONE) { return; } $rule = $parent->get_rule_object(); if ($rule === null) { return; } // Fetch or create the user competency for the parent. $userid = $usercompetency->get('userid'); $parentuc = user_competency::get_record(array('userid' => $userid, 'competencyid' => $parent->get('id'))); if (!$parentuc) { $parentuc = user_competency::create_relation($userid, $parent->get('id')); $parentuc->create(); } // Does the rule match? if (!$rule->matches($parentuc)) { return; } // Figuring out what to do. $recommend = false; if ($ruleoutcome == competency::OUTCOME_EVIDENCE) { $action = evidence::ACTION_LOG; } else if ($ruleoutcome == competency::OUTCOME_RECOMMEND) { $action = evidence::ACTION_LOG; $recommend = true; } else if ($ruleoutcome == competency::OUTCOME_COMPLETE) { $action = evidence::ACTION_COMPLETE; } else { throw new moodle_exception('Unexpected rule outcome: ' + $ruleoutcome); } // Finally add an evidence. static::add_evidence( $userid, $parent, $parent->get_context()->id, $action, 'evidence_competencyrule', 'core_competency', null, $recommend ); }
php
protected static function apply_competency_rules_from_usercompetency(user_competency $usercompetency, competency $competency = null) { // Perform some basic checks. if (!$usercompetency->get('proficiency')) { throw new coding_exception('The user competency passed is not completed.'); } if ($competency === null) { $competency = $usercompetency->get_competency(); } if ($competency->get('id') != $usercompetency->get('competencyid')) { throw new coding_exception('Mismatch between user competency and competency.'); } // Fetch the parent. $parent = $competency->get_parent(); if ($parent === null) { return; } // The parent should have a rule, and a meaningful outcome. $ruleoutcome = $parent->get('ruleoutcome'); if ($ruleoutcome == competency::OUTCOME_NONE) { return; } $rule = $parent->get_rule_object(); if ($rule === null) { return; } // Fetch or create the user competency for the parent. $userid = $usercompetency->get('userid'); $parentuc = user_competency::get_record(array('userid' => $userid, 'competencyid' => $parent->get('id'))); if (!$parentuc) { $parentuc = user_competency::create_relation($userid, $parent->get('id')); $parentuc->create(); } // Does the rule match? if (!$rule->matches($parentuc)) { return; } // Figuring out what to do. $recommend = false; if ($ruleoutcome == competency::OUTCOME_EVIDENCE) { $action = evidence::ACTION_LOG; } else if ($ruleoutcome == competency::OUTCOME_RECOMMEND) { $action = evidence::ACTION_LOG; $recommend = true; } else if ($ruleoutcome == competency::OUTCOME_COMPLETE) { $action = evidence::ACTION_COMPLETE; } else { throw new moodle_exception('Unexpected rule outcome: ' + $ruleoutcome); } // Finally add an evidence. static::add_evidence( $userid, $parent, $parent->get_context()->id, $action, 'evidence_competencyrule', 'core_competency', null, $recommend ); }
[ "protected", "static", "function", "apply_competency_rules_from_usercompetency", "(", "user_competency", "$", "usercompetency", ",", "competency", "$", "competency", "=", "null", ")", "{", "// Perform some basic checks.", "if", "(", "!", "$", "usercompetency", "->", "get", "(", "'proficiency'", ")", ")", "{", "throw", "new", "coding_exception", "(", "'The user competency passed is not completed.'", ")", ";", "}", "if", "(", "$", "competency", "===", "null", ")", "{", "$", "competency", "=", "$", "usercompetency", "->", "get_competency", "(", ")", ";", "}", "if", "(", "$", "competency", "->", "get", "(", "'id'", ")", "!=", "$", "usercompetency", "->", "get", "(", "'competencyid'", ")", ")", "{", "throw", "new", "coding_exception", "(", "'Mismatch between user competency and competency.'", ")", ";", "}", "// Fetch the parent.", "$", "parent", "=", "$", "competency", "->", "get_parent", "(", ")", ";", "if", "(", "$", "parent", "===", "null", ")", "{", "return", ";", "}", "// The parent should have a rule, and a meaningful outcome.", "$", "ruleoutcome", "=", "$", "parent", "->", "get", "(", "'ruleoutcome'", ")", ";", "if", "(", "$", "ruleoutcome", "==", "competency", "::", "OUTCOME_NONE", ")", "{", "return", ";", "}", "$", "rule", "=", "$", "parent", "->", "get_rule_object", "(", ")", ";", "if", "(", "$", "rule", "===", "null", ")", "{", "return", ";", "}", "// Fetch or create the user competency for the parent.", "$", "userid", "=", "$", "usercompetency", "->", "get", "(", "'userid'", ")", ";", "$", "parentuc", "=", "user_competency", "::", "get_record", "(", "array", "(", "'userid'", "=>", "$", "userid", ",", "'competencyid'", "=>", "$", "parent", "->", "get", "(", "'id'", ")", ")", ")", ";", "if", "(", "!", "$", "parentuc", ")", "{", "$", "parentuc", "=", "user_competency", "::", "create_relation", "(", "$", "userid", ",", "$", "parent", "->", "get", "(", "'id'", ")", ")", ";", "$", "parentuc", "->", "create", "(", ")", ";", "}", "// Does the rule match?", "if", "(", "!", "$", "rule", "->", "matches", "(", "$", "parentuc", ")", ")", "{", "return", ";", "}", "// Figuring out what to do.", "$", "recommend", "=", "false", ";", "if", "(", "$", "ruleoutcome", "==", "competency", "::", "OUTCOME_EVIDENCE", ")", "{", "$", "action", "=", "evidence", "::", "ACTION_LOG", ";", "}", "else", "if", "(", "$", "ruleoutcome", "==", "competency", "::", "OUTCOME_RECOMMEND", ")", "{", "$", "action", "=", "evidence", "::", "ACTION_LOG", ";", "$", "recommend", "=", "true", ";", "}", "else", "if", "(", "$", "ruleoutcome", "==", "competency", "::", "OUTCOME_COMPLETE", ")", "{", "$", "action", "=", "evidence", "::", "ACTION_COMPLETE", ";", "}", "else", "{", "throw", "new", "moodle_exception", "(", "'Unexpected rule outcome: '", "+", "$", "ruleoutcome", ")", ";", "}", "// Finally add an evidence.", "static", "::", "add_evidence", "(", "$", "userid", ",", "$", "parent", ",", "$", "parent", "->", "get_context", "(", ")", "->", "id", ",", "$", "action", ",", "'evidence_competencyrule'", ",", "'core_competency'", ",", "null", ",", "$", "recommend", ")", ";", "}" ]
Apply the competency rules from a user competency. The user competency passed should be one that was recently marked as complete. A user competency is considered 'complete' when it's proficiency value is true. This method will check if the parent of this usercompetency's competency has any rules and if so will see if they match. When matched it will take the required step to add evidence and trigger completion, etc... @param user_competency $usercompetency The user competency recently completed. @param competency|null $competency The competency of the user competency, useful to avoid unnecessary read. @return void
[ "Apply", "the", "competency", "rules", "from", "a", "user", "competency", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/api.php#L4534-L4604
217,304
moodle/moodle
competency/classes/api.php
api.observe_course_module_completion_updated
public static function observe_course_module_completion_updated(\core\event\course_module_completion_updated $event) { if (!static::is_enabled()) { return; } $eventdata = $event->get_record_snapshot('course_modules_completion', $event->objectid); if ($eventdata->completionstate == COMPLETION_COMPLETE || $eventdata->completionstate == COMPLETION_COMPLETE_PASS) { $coursemodulecompetencies = course_module_competency::list_course_module_competencies($eventdata->coursemoduleid); $cm = get_coursemodule_from_id(null, $eventdata->coursemoduleid); $fastmodinfo = get_fast_modinfo($cm->course)->cms[$cm->id]; $cmname = $fastmodinfo->name; $url = $fastmodinfo->url; foreach ($coursemodulecompetencies as $coursemodulecompetency) { $outcome = $coursemodulecompetency->get('ruleoutcome'); $action = null; $recommend = false; $strdesc = 'evidence_coursemodulecompleted'; if ($outcome == course_module_competency::OUTCOME_EVIDENCE) { $action = evidence::ACTION_LOG; } else if ($outcome == course_module_competency::OUTCOME_RECOMMEND) { $action = evidence::ACTION_LOG; $recommend = true; } else if ($outcome == course_module_competency::OUTCOME_COMPLETE) { $action = evidence::ACTION_COMPLETE; } else { throw new moodle_exception('Unexpected rule outcome: ' + $outcome); } static::add_evidence( $event->relateduserid, $coursemodulecompetency->get('competencyid'), $event->contextid, $action, $strdesc, 'core_competency', $cmname, $recommend, $url ); } } }
php
public static function observe_course_module_completion_updated(\core\event\course_module_completion_updated $event) { if (!static::is_enabled()) { return; } $eventdata = $event->get_record_snapshot('course_modules_completion', $event->objectid); if ($eventdata->completionstate == COMPLETION_COMPLETE || $eventdata->completionstate == COMPLETION_COMPLETE_PASS) { $coursemodulecompetencies = course_module_competency::list_course_module_competencies($eventdata->coursemoduleid); $cm = get_coursemodule_from_id(null, $eventdata->coursemoduleid); $fastmodinfo = get_fast_modinfo($cm->course)->cms[$cm->id]; $cmname = $fastmodinfo->name; $url = $fastmodinfo->url; foreach ($coursemodulecompetencies as $coursemodulecompetency) { $outcome = $coursemodulecompetency->get('ruleoutcome'); $action = null; $recommend = false; $strdesc = 'evidence_coursemodulecompleted'; if ($outcome == course_module_competency::OUTCOME_EVIDENCE) { $action = evidence::ACTION_LOG; } else if ($outcome == course_module_competency::OUTCOME_RECOMMEND) { $action = evidence::ACTION_LOG; $recommend = true; } else if ($outcome == course_module_competency::OUTCOME_COMPLETE) { $action = evidence::ACTION_COMPLETE; } else { throw new moodle_exception('Unexpected rule outcome: ' + $outcome); } static::add_evidence( $event->relateduserid, $coursemodulecompetency->get('competencyid'), $event->contextid, $action, $strdesc, 'core_competency', $cmname, $recommend, $url ); } } }
[ "public", "static", "function", "observe_course_module_completion_updated", "(", "\\", "core", "\\", "event", "\\", "course_module_completion_updated", "$", "event", ")", "{", "if", "(", "!", "static", "::", "is_enabled", "(", ")", ")", "{", "return", ";", "}", "$", "eventdata", "=", "$", "event", "->", "get_record_snapshot", "(", "'course_modules_completion'", ",", "$", "event", "->", "objectid", ")", ";", "if", "(", "$", "eventdata", "->", "completionstate", "==", "COMPLETION_COMPLETE", "||", "$", "eventdata", "->", "completionstate", "==", "COMPLETION_COMPLETE_PASS", ")", "{", "$", "coursemodulecompetencies", "=", "course_module_competency", "::", "list_course_module_competencies", "(", "$", "eventdata", "->", "coursemoduleid", ")", ";", "$", "cm", "=", "get_coursemodule_from_id", "(", "null", ",", "$", "eventdata", "->", "coursemoduleid", ")", ";", "$", "fastmodinfo", "=", "get_fast_modinfo", "(", "$", "cm", "->", "course", ")", "->", "cms", "[", "$", "cm", "->", "id", "]", ";", "$", "cmname", "=", "$", "fastmodinfo", "->", "name", ";", "$", "url", "=", "$", "fastmodinfo", "->", "url", ";", "foreach", "(", "$", "coursemodulecompetencies", "as", "$", "coursemodulecompetency", ")", "{", "$", "outcome", "=", "$", "coursemodulecompetency", "->", "get", "(", "'ruleoutcome'", ")", ";", "$", "action", "=", "null", ";", "$", "recommend", "=", "false", ";", "$", "strdesc", "=", "'evidence_coursemodulecompleted'", ";", "if", "(", "$", "outcome", "==", "course_module_competency", "::", "OUTCOME_EVIDENCE", ")", "{", "$", "action", "=", "evidence", "::", "ACTION_LOG", ";", "}", "else", "if", "(", "$", "outcome", "==", "course_module_competency", "::", "OUTCOME_RECOMMEND", ")", "{", "$", "action", "=", "evidence", "::", "ACTION_LOG", ";", "$", "recommend", "=", "true", ";", "}", "else", "if", "(", "$", "outcome", "==", "course_module_competency", "::", "OUTCOME_COMPLETE", ")", "{", "$", "action", "=", "evidence", "::", "ACTION_COMPLETE", ";", "}", "else", "{", "throw", "new", "moodle_exception", "(", "'Unexpected rule outcome: '", "+", "$", "outcome", ")", ";", "}", "static", "::", "add_evidence", "(", "$", "event", "->", "relateduserid", ",", "$", "coursemodulecompetency", "->", "get", "(", "'competencyid'", ")", ",", "$", "event", "->", "contextid", ",", "$", "action", ",", "$", "strdesc", ",", "'core_competency'", ",", "$", "cmname", ",", "$", "recommend", ",", "$", "url", ")", ";", "}", "}", "}" ]
Observe when a course module is marked as completed. Note that the user being logged in while this happens may be anyone. Do not rely on capability checks here! @param \core\event\course_module_completion_updated $event @return void
[ "Observe", "when", "a", "course", "module", "is", "marked", "as", "completed", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/api.php#L4615-L4665
217,305
moodle/moodle
competency/classes/api.php
api.observe_course_completed
public static function observe_course_completed(\core\event\course_completed $event) { if (!static::is_enabled()) { return; } $sql = 'courseid = :courseid AND ruleoutcome != :nooutcome'; $params = array( 'courseid' => $event->courseid, 'nooutcome' => course_competency::OUTCOME_NONE ); $coursecompetencies = course_competency::get_records_select($sql, $params); $course = get_course($event->courseid); $courseshortname = format_string($course->shortname, null, array('context' => $event->contextid)); foreach ($coursecompetencies as $coursecompetency) { $outcome = $coursecompetency->get('ruleoutcome'); $action = null; $recommend = false; $strdesc = 'evidence_coursecompleted'; if ($outcome == course_competency::OUTCOME_EVIDENCE) { $action = evidence::ACTION_LOG; } else if ($outcome == course_competency::OUTCOME_RECOMMEND) { $action = evidence::ACTION_LOG; $recommend = true; } else if ($outcome == course_competency::OUTCOME_COMPLETE) { $action = evidence::ACTION_COMPLETE; } else { throw new moodle_exception('Unexpected rule outcome: ' + $outcome); } static::add_evidence( $event->relateduserid, $coursecompetency->get('competencyid'), $event->contextid, $action, $strdesc, 'core_competency', $courseshortname, $recommend, $event->get_url() ); } }
php
public static function observe_course_completed(\core\event\course_completed $event) { if (!static::is_enabled()) { return; } $sql = 'courseid = :courseid AND ruleoutcome != :nooutcome'; $params = array( 'courseid' => $event->courseid, 'nooutcome' => course_competency::OUTCOME_NONE ); $coursecompetencies = course_competency::get_records_select($sql, $params); $course = get_course($event->courseid); $courseshortname = format_string($course->shortname, null, array('context' => $event->contextid)); foreach ($coursecompetencies as $coursecompetency) { $outcome = $coursecompetency->get('ruleoutcome'); $action = null; $recommend = false; $strdesc = 'evidence_coursecompleted'; if ($outcome == course_competency::OUTCOME_EVIDENCE) { $action = evidence::ACTION_LOG; } else if ($outcome == course_competency::OUTCOME_RECOMMEND) { $action = evidence::ACTION_LOG; $recommend = true; } else if ($outcome == course_competency::OUTCOME_COMPLETE) { $action = evidence::ACTION_COMPLETE; } else { throw new moodle_exception('Unexpected rule outcome: ' + $outcome); } static::add_evidence( $event->relateduserid, $coursecompetency->get('competencyid'), $event->contextid, $action, $strdesc, 'core_competency', $courseshortname, $recommend, $event->get_url() ); } }
[ "public", "static", "function", "observe_course_completed", "(", "\\", "core", "\\", "event", "\\", "course_completed", "$", "event", ")", "{", "if", "(", "!", "static", "::", "is_enabled", "(", ")", ")", "{", "return", ";", "}", "$", "sql", "=", "'courseid = :courseid AND ruleoutcome != :nooutcome'", ";", "$", "params", "=", "array", "(", "'courseid'", "=>", "$", "event", "->", "courseid", ",", "'nooutcome'", "=>", "course_competency", "::", "OUTCOME_NONE", ")", ";", "$", "coursecompetencies", "=", "course_competency", "::", "get_records_select", "(", "$", "sql", ",", "$", "params", ")", ";", "$", "course", "=", "get_course", "(", "$", "event", "->", "courseid", ")", ";", "$", "courseshortname", "=", "format_string", "(", "$", "course", "->", "shortname", ",", "null", ",", "array", "(", "'context'", "=>", "$", "event", "->", "contextid", ")", ")", ";", "foreach", "(", "$", "coursecompetencies", "as", "$", "coursecompetency", ")", "{", "$", "outcome", "=", "$", "coursecompetency", "->", "get", "(", "'ruleoutcome'", ")", ";", "$", "action", "=", "null", ";", "$", "recommend", "=", "false", ";", "$", "strdesc", "=", "'evidence_coursecompleted'", ";", "if", "(", "$", "outcome", "==", "course_competency", "::", "OUTCOME_EVIDENCE", ")", "{", "$", "action", "=", "evidence", "::", "ACTION_LOG", ";", "}", "else", "if", "(", "$", "outcome", "==", "course_competency", "::", "OUTCOME_RECOMMEND", ")", "{", "$", "action", "=", "evidence", "::", "ACTION_LOG", ";", "$", "recommend", "=", "true", ";", "}", "else", "if", "(", "$", "outcome", "==", "course_competency", "::", "OUTCOME_COMPLETE", ")", "{", "$", "action", "=", "evidence", "::", "ACTION_COMPLETE", ";", "}", "else", "{", "throw", "new", "moodle_exception", "(", "'Unexpected rule outcome: '", "+", "$", "outcome", ")", ";", "}", "static", "::", "add_evidence", "(", "$", "event", "->", "relateduserid", ",", "$", "coursecompetency", "->", "get", "(", "'competencyid'", ")", ",", "$", "event", "->", "contextid", ",", "$", "action", ",", "$", "strdesc", ",", "'core_competency'", ",", "$", "courseshortname", ",", "$", "recommend", ",", "$", "event", "->", "get_url", "(", ")", ")", ";", "}", "}" ]
Observe when a course is marked as completed. Note that the user being logged in while this happens may be anyone. Do not rely on capability checks here! @param \core\event\course_completed $event @return void
[ "Observe", "when", "a", "course", "is", "marked", "as", "completed", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/api.php#L4676-L4724
217,306
moodle/moodle
competency/classes/api.php
api.hook_course_module_deleted
public static function hook_course_module_deleted(stdClass $cm) { global $DB; $DB->delete_records(course_module_competency::TABLE, array('cmid' => $cm->id)); }
php
public static function hook_course_module_deleted(stdClass $cm) { global $DB; $DB->delete_records(course_module_competency::TABLE, array('cmid' => $cm->id)); }
[ "public", "static", "function", "hook_course_module_deleted", "(", "stdClass", "$", "cm", ")", "{", "global", "$", "DB", ";", "$", "DB", "->", "delete_records", "(", "course_module_competency", "::", "TABLE", ",", "array", "(", "'cmid'", "=>", "$", "cm", "->", "id", ")", ")", ";", "}" ]
Action to perform when a course module is deleted. Do not call this directly, this is reserved for core use. @param stdClass $cm The CM object. @return void
[ "Action", "to", "perform", "when", "a", "course", "module", "is", "deleted", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/api.php#L4734-L4737
217,307
moodle/moodle
competency/classes/api.php
api.hook_course_deleted
public static function hook_course_deleted(stdClass $course) { global $DB; $DB->delete_records(course_competency::TABLE, array('courseid' => $course->id)); $DB->delete_records(course_competency_settings::TABLE, array('courseid' => $course->id)); $DB->delete_records(user_competency_course::TABLE, array('courseid' => $course->id)); }
php
public static function hook_course_deleted(stdClass $course) { global $DB; $DB->delete_records(course_competency::TABLE, array('courseid' => $course->id)); $DB->delete_records(course_competency_settings::TABLE, array('courseid' => $course->id)); $DB->delete_records(user_competency_course::TABLE, array('courseid' => $course->id)); }
[ "public", "static", "function", "hook_course_deleted", "(", "stdClass", "$", "course", ")", "{", "global", "$", "DB", ";", "$", "DB", "->", "delete_records", "(", "course_competency", "::", "TABLE", ",", "array", "(", "'courseid'", "=>", "$", "course", "->", "id", ")", ")", ";", "$", "DB", "->", "delete_records", "(", "course_competency_settings", "::", "TABLE", ",", "array", "(", "'courseid'", "=>", "$", "course", "->", "id", ")", ")", ";", "$", "DB", "->", "delete_records", "(", "user_competency_course", "::", "TABLE", ",", "array", "(", "'courseid'", "=>", "$", "course", "->", "id", ")", ")", ";", "}" ]
Action to perform when a course is deleted. Do not call this directly, this is reserved for core use. @param stdClass $course The course object. @return void
[ "Action", "to", "perform", "when", "a", "course", "is", "deleted", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/api.php#L4747-L4752
217,308
moodle/moodle
competency/classes/api.php
api.hook_cohort_deleted
public static function hook_cohort_deleted(\stdClass $cohort) { global $DB; $DB->delete_records(template_cohort::TABLE, array('cohortid' => $cohort->id)); }
php
public static function hook_cohort_deleted(\stdClass $cohort) { global $DB; $DB->delete_records(template_cohort::TABLE, array('cohortid' => $cohort->id)); }
[ "public", "static", "function", "hook_cohort_deleted", "(", "\\", "stdClass", "$", "cohort", ")", "{", "global", "$", "DB", ";", "$", "DB", "->", "delete_records", "(", "template_cohort", "::", "TABLE", ",", "array", "(", "'cohortid'", "=>", "$", "cohort", "->", "id", ")", ")", ";", "}" ]
Action to perform when a cohort is deleted. Do not call this directly, this is reserved for core use. @param \stdClass $cohort The cohort object. @return void
[ "Action", "to", "perform", "when", "a", "cohort", "is", "deleted", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/api.php#L4775-L4778
217,309
moodle/moodle
competency/classes/api.php
api.grade_competency
public static function grade_competency($userid, $competencyid, $grade, $note = null) { global $USER; static::require_enabled(); $uc = static::get_user_competency($userid, $competencyid); $context = $uc->get_context(); if (!user_competency::can_grade_user($uc->get('userid'))) { throw new required_capability_exception($context, 'moodle/competency:competencygrade', 'nopermissions', ''); } // Throws exception if competency not in plan. $competency = $uc->get_competency(); $competencycontext = $competency->get_context(); if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $competencycontext)) { throw new required_capability_exception($competencycontext, 'moodle/competency:competencyview', 'nopermissions', ''); } $action = evidence::ACTION_OVERRIDE; $desckey = 'evidence_manualoverride'; $result = self::add_evidence($uc->get('userid'), $competency, $context->id, $action, $desckey, 'core_competency', null, false, null, $grade, $USER->id, $note); if ($result) { $uc->read(); $event = \core\event\competency_user_competency_rated::create_from_user_competency($uc); $event->trigger(); } return $result; }
php
public static function grade_competency($userid, $competencyid, $grade, $note = null) { global $USER; static::require_enabled(); $uc = static::get_user_competency($userid, $competencyid); $context = $uc->get_context(); if (!user_competency::can_grade_user($uc->get('userid'))) { throw new required_capability_exception($context, 'moodle/competency:competencygrade', 'nopermissions', ''); } // Throws exception if competency not in plan. $competency = $uc->get_competency(); $competencycontext = $competency->get_context(); if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $competencycontext)) { throw new required_capability_exception($competencycontext, 'moodle/competency:competencyview', 'nopermissions', ''); } $action = evidence::ACTION_OVERRIDE; $desckey = 'evidence_manualoverride'; $result = self::add_evidence($uc->get('userid'), $competency, $context->id, $action, $desckey, 'core_competency', null, false, null, $grade, $USER->id, $note); if ($result) { $uc->read(); $event = \core\event\competency_user_competency_rated::create_from_user_competency($uc); $event->trigger(); } return $result; }
[ "public", "static", "function", "grade_competency", "(", "$", "userid", ",", "$", "competencyid", ",", "$", "grade", ",", "$", "note", "=", "null", ")", "{", "global", "$", "USER", ";", "static", "::", "require_enabled", "(", ")", ";", "$", "uc", "=", "static", "::", "get_user_competency", "(", "$", "userid", ",", "$", "competencyid", ")", ";", "$", "context", "=", "$", "uc", "->", "get_context", "(", ")", ";", "if", "(", "!", "user_competency", "::", "can_grade_user", "(", "$", "uc", "->", "get", "(", "'userid'", ")", ")", ")", "{", "throw", "new", "required_capability_exception", "(", "$", "context", ",", "'moodle/competency:competencygrade'", ",", "'nopermissions'", ",", "''", ")", ";", "}", "// Throws exception if competency not in plan.", "$", "competency", "=", "$", "uc", "->", "get_competency", "(", ")", ";", "$", "competencycontext", "=", "$", "competency", "->", "get_context", "(", ")", ";", "if", "(", "!", "has_any_capability", "(", "array", "(", "'moodle/competency:competencyview'", ",", "'moodle/competency:competencymanage'", ")", ",", "$", "competencycontext", ")", ")", "{", "throw", "new", "required_capability_exception", "(", "$", "competencycontext", ",", "'moodle/competency:competencyview'", ",", "'nopermissions'", ",", "''", ")", ";", "}", "$", "action", "=", "evidence", "::", "ACTION_OVERRIDE", ";", "$", "desckey", "=", "'evidence_manualoverride'", ";", "$", "result", "=", "self", "::", "add_evidence", "(", "$", "uc", "->", "get", "(", "'userid'", ")", ",", "$", "competency", ",", "$", "context", "->", "id", ",", "$", "action", ",", "$", "desckey", ",", "'core_competency'", ",", "null", ",", "false", ",", "null", ",", "$", "grade", ",", "$", "USER", "->", "id", ",", "$", "note", ")", ";", "if", "(", "$", "result", ")", "{", "$", "uc", "->", "read", "(", ")", ";", "$", "event", "=", "\\", "core", "\\", "event", "\\", "competency_user_competency_rated", "::", "create_from_user_competency", "(", "$", "uc", ")", ";", "$", "event", "->", "trigger", "(", ")", ";", "}", "return", "$", "result", ";", "}" ]
Manually grade a user competency. @param int $userid @param int $competencyid @param int $grade @param string $note A note to attach to the evidence @return array of \core_competency\user_competency
[ "Manually", "grade", "a", "user", "competency", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/api.php#L4789-L4828
217,310
moodle/moodle
competency/classes/api.php
api.grade_competency_in_plan
public static function grade_competency_in_plan($planorid, $competencyid, $grade, $note = null) { global $USER; static::require_enabled(); $plan = $planorid; if (!is_object($planorid)) { $plan = new plan($planorid); } $context = $plan->get_context(); if (!user_competency::can_grade_user($plan->get('userid'))) { throw new required_capability_exception($context, 'moodle/competency:competencygrade', 'nopermissions', ''); } // Throws exception if competency not in plan. $competency = $plan->get_competency($competencyid); $competencycontext = $competency->get_context(); if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $competencycontext)) { throw new required_capability_exception($competencycontext, 'moodle/competency:competencyview', 'nopermissions', ''); } $action = evidence::ACTION_OVERRIDE; $desckey = 'evidence_manualoverrideinplan'; $result = self::add_evidence($plan->get('userid'), $competency, $context->id, $action, $desckey, 'core_competency', $plan->get('name'), false, null, $grade, $USER->id, $note); if ($result) { $uc = static::get_user_competency($plan->get('userid'), $competency->get('id')); $event = \core\event\competency_user_competency_rated_in_plan::create_from_user_competency($uc, $plan->get('id')); $event->trigger(); } return $result; }
php
public static function grade_competency_in_plan($planorid, $competencyid, $grade, $note = null) { global $USER; static::require_enabled(); $plan = $planorid; if (!is_object($planorid)) { $plan = new plan($planorid); } $context = $plan->get_context(); if (!user_competency::can_grade_user($plan->get('userid'))) { throw new required_capability_exception($context, 'moodle/competency:competencygrade', 'nopermissions', ''); } // Throws exception if competency not in plan. $competency = $plan->get_competency($competencyid); $competencycontext = $competency->get_context(); if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $competencycontext)) { throw new required_capability_exception($competencycontext, 'moodle/competency:competencyview', 'nopermissions', ''); } $action = evidence::ACTION_OVERRIDE; $desckey = 'evidence_manualoverrideinplan'; $result = self::add_evidence($plan->get('userid'), $competency, $context->id, $action, $desckey, 'core_competency', $plan->get('name'), false, null, $grade, $USER->id, $note); if ($result) { $uc = static::get_user_competency($plan->get('userid'), $competency->get('id')); $event = \core\event\competency_user_competency_rated_in_plan::create_from_user_competency($uc, $plan->get('id')); $event->trigger(); } return $result; }
[ "public", "static", "function", "grade_competency_in_plan", "(", "$", "planorid", ",", "$", "competencyid", ",", "$", "grade", ",", "$", "note", "=", "null", ")", "{", "global", "$", "USER", ";", "static", "::", "require_enabled", "(", ")", ";", "$", "plan", "=", "$", "planorid", ";", "if", "(", "!", "is_object", "(", "$", "planorid", ")", ")", "{", "$", "plan", "=", "new", "plan", "(", "$", "planorid", ")", ";", "}", "$", "context", "=", "$", "plan", "->", "get_context", "(", ")", ";", "if", "(", "!", "user_competency", "::", "can_grade_user", "(", "$", "plan", "->", "get", "(", "'userid'", ")", ")", ")", "{", "throw", "new", "required_capability_exception", "(", "$", "context", ",", "'moodle/competency:competencygrade'", ",", "'nopermissions'", ",", "''", ")", ";", "}", "// Throws exception if competency not in plan.", "$", "competency", "=", "$", "plan", "->", "get_competency", "(", "$", "competencyid", ")", ";", "$", "competencycontext", "=", "$", "competency", "->", "get_context", "(", ")", ";", "if", "(", "!", "has_any_capability", "(", "array", "(", "'moodle/competency:competencyview'", ",", "'moodle/competency:competencymanage'", ")", ",", "$", "competencycontext", ")", ")", "{", "throw", "new", "required_capability_exception", "(", "$", "competencycontext", ",", "'moodle/competency:competencyview'", ",", "'nopermissions'", ",", "''", ")", ";", "}", "$", "action", "=", "evidence", "::", "ACTION_OVERRIDE", ";", "$", "desckey", "=", "'evidence_manualoverrideinplan'", ";", "$", "result", "=", "self", "::", "add_evidence", "(", "$", "plan", "->", "get", "(", "'userid'", ")", ",", "$", "competency", ",", "$", "context", "->", "id", ",", "$", "action", ",", "$", "desckey", ",", "'core_competency'", ",", "$", "plan", "->", "get", "(", "'name'", ")", ",", "false", ",", "null", ",", "$", "grade", ",", "$", "USER", "->", "id", ",", "$", "note", ")", ";", "if", "(", "$", "result", ")", "{", "$", "uc", "=", "static", "::", "get_user_competency", "(", "$", "plan", "->", "get", "(", "'userid'", ")", ",", "$", "competency", "->", "get", "(", "'id'", ")", ")", ";", "$", "event", "=", "\\", "core", "\\", "event", "\\", "competency_user_competency_rated_in_plan", "::", "create_from_user_competency", "(", "$", "uc", ",", "$", "plan", "->", "get", "(", "'id'", ")", ")", ";", "$", "event", "->", "trigger", "(", ")", ";", "}", "return", "$", "result", ";", "}" ]
Manually grade a user competency from the plans page. @param mixed $planorid @param int $competencyid @param int $grade @param string $note A note to attach to the evidence @return array of \core_competency\user_competency
[ "Manually", "grade", "a", "user", "competency", "from", "the", "plans", "page", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/api.php#L4839-L4882
217,311
moodle/moodle
competency/classes/api.php
api.grade_competency_in_course
public static function grade_competency_in_course($courseorid, $userid, $competencyid, $grade, $note = null) { global $USER, $DB; static::require_enabled(); $course = $courseorid; if (!is_object($courseorid)) { $course = $DB->get_record('course', array('id' => $courseorid)); } $context = context_course::instance($course->id); // Check that we can view the user competency details in the course. if (!user_competency::can_read_user_in_course($userid, $course->id)) { throw new required_capability_exception($context, 'moodle/competency:usercompetencyview', 'nopermissions', ''); } // Validate the permission to grade. if (!user_competency::can_grade_user_in_course($userid, $course->id)) { throw new required_capability_exception($context, 'moodle/competency:competencygrade', 'nopermissions', ''); } // Check that competency is in course and visible to the current user. $competency = course_competency::get_competency($course->id, $competencyid); $competencycontext = $competency->get_context(); if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $competencycontext)) { throw new required_capability_exception($competencycontext, 'moodle/competency:competencyview', 'nopermissions', ''); } // Check that the user is enrolled in the course, and is "gradable". if (!is_enrolled($context, $userid, 'moodle/competency:coursecompetencygradable')) { throw new coding_exception('The competency may not be rated at this time.'); } $action = evidence::ACTION_OVERRIDE; $desckey = 'evidence_manualoverrideincourse'; $result = self::add_evidence($userid, $competency, $context->id, $action, $desckey, 'core_competency', $context->get_context_name(), false, null, $grade, $USER->id, $note); if ($result) { $all = user_competency_course::get_multiple($userid, $course->id, array($competency->get('id'))); $uc = reset($all); $event = \core\event\competency_user_competency_rated_in_course::create_from_user_competency_course($uc); $event->trigger(); } return $result; }
php
public static function grade_competency_in_course($courseorid, $userid, $competencyid, $grade, $note = null) { global $USER, $DB; static::require_enabled(); $course = $courseorid; if (!is_object($courseorid)) { $course = $DB->get_record('course', array('id' => $courseorid)); } $context = context_course::instance($course->id); // Check that we can view the user competency details in the course. if (!user_competency::can_read_user_in_course($userid, $course->id)) { throw new required_capability_exception($context, 'moodle/competency:usercompetencyview', 'nopermissions', ''); } // Validate the permission to grade. if (!user_competency::can_grade_user_in_course($userid, $course->id)) { throw new required_capability_exception($context, 'moodle/competency:competencygrade', 'nopermissions', ''); } // Check that competency is in course and visible to the current user. $competency = course_competency::get_competency($course->id, $competencyid); $competencycontext = $competency->get_context(); if (!has_any_capability(array('moodle/competency:competencyview', 'moodle/competency:competencymanage'), $competencycontext)) { throw new required_capability_exception($competencycontext, 'moodle/competency:competencyview', 'nopermissions', ''); } // Check that the user is enrolled in the course, and is "gradable". if (!is_enrolled($context, $userid, 'moodle/competency:coursecompetencygradable')) { throw new coding_exception('The competency may not be rated at this time.'); } $action = evidence::ACTION_OVERRIDE; $desckey = 'evidence_manualoverrideincourse'; $result = self::add_evidence($userid, $competency, $context->id, $action, $desckey, 'core_competency', $context->get_context_name(), false, null, $grade, $USER->id, $note); if ($result) { $all = user_competency_course::get_multiple($userid, $course->id, array($competency->get('id'))); $uc = reset($all); $event = \core\event\competency_user_competency_rated_in_course::create_from_user_competency_course($uc); $event->trigger(); } return $result; }
[ "public", "static", "function", "grade_competency_in_course", "(", "$", "courseorid", ",", "$", "userid", ",", "$", "competencyid", ",", "$", "grade", ",", "$", "note", "=", "null", ")", "{", "global", "$", "USER", ",", "$", "DB", ";", "static", "::", "require_enabled", "(", ")", ";", "$", "course", "=", "$", "courseorid", ";", "if", "(", "!", "is_object", "(", "$", "courseorid", ")", ")", "{", "$", "course", "=", "$", "DB", "->", "get_record", "(", "'course'", ",", "array", "(", "'id'", "=>", "$", "courseorid", ")", ")", ";", "}", "$", "context", "=", "context_course", "::", "instance", "(", "$", "course", "->", "id", ")", ";", "// Check that we can view the user competency details in the course.", "if", "(", "!", "user_competency", "::", "can_read_user_in_course", "(", "$", "userid", ",", "$", "course", "->", "id", ")", ")", "{", "throw", "new", "required_capability_exception", "(", "$", "context", ",", "'moodle/competency:usercompetencyview'", ",", "'nopermissions'", ",", "''", ")", ";", "}", "// Validate the permission to grade.", "if", "(", "!", "user_competency", "::", "can_grade_user_in_course", "(", "$", "userid", ",", "$", "course", "->", "id", ")", ")", "{", "throw", "new", "required_capability_exception", "(", "$", "context", ",", "'moodle/competency:competencygrade'", ",", "'nopermissions'", ",", "''", ")", ";", "}", "// Check that competency is in course and visible to the current user.", "$", "competency", "=", "course_competency", "::", "get_competency", "(", "$", "course", "->", "id", ",", "$", "competencyid", ")", ";", "$", "competencycontext", "=", "$", "competency", "->", "get_context", "(", ")", ";", "if", "(", "!", "has_any_capability", "(", "array", "(", "'moodle/competency:competencyview'", ",", "'moodle/competency:competencymanage'", ")", ",", "$", "competencycontext", ")", ")", "{", "throw", "new", "required_capability_exception", "(", "$", "competencycontext", ",", "'moodle/competency:competencyview'", ",", "'nopermissions'", ",", "''", ")", ";", "}", "// Check that the user is enrolled in the course, and is \"gradable\".", "if", "(", "!", "is_enrolled", "(", "$", "context", ",", "$", "userid", ",", "'moodle/competency:coursecompetencygradable'", ")", ")", "{", "throw", "new", "coding_exception", "(", "'The competency may not be rated at this time.'", ")", ";", "}", "$", "action", "=", "evidence", "::", "ACTION_OVERRIDE", ";", "$", "desckey", "=", "'evidence_manualoverrideincourse'", ";", "$", "result", "=", "self", "::", "add_evidence", "(", "$", "userid", ",", "$", "competency", ",", "$", "context", "->", "id", ",", "$", "action", ",", "$", "desckey", ",", "'core_competency'", ",", "$", "context", "->", "get_context_name", "(", ")", ",", "false", ",", "null", ",", "$", "grade", ",", "$", "USER", "->", "id", ",", "$", "note", ")", ";", "if", "(", "$", "result", ")", "{", "$", "all", "=", "user_competency_course", "::", "get_multiple", "(", "$", "userid", ",", "$", "course", "->", "id", ",", "array", "(", "$", "competency", "->", "get", "(", "'id'", ")", ")", ")", ";", "$", "uc", "=", "reset", "(", "$", "all", ")", ";", "$", "event", "=", "\\", "core", "\\", "event", "\\", "competency_user_competency_rated_in_course", "::", "create_from_user_competency_course", "(", "$", "uc", ")", ";", "$", "event", "->", "trigger", "(", ")", ";", "}", "return", "$", "result", ";", "}" ]
Manually grade a user course competency from the course page. This may push the rating to the user competency if the course is configured this way. @param mixed $courseorid @param int $userid @param int $competencyid @param int $grade @param string $note A note to attach to the evidence @return array of \core_competency\user_competency
[ "Manually", "grade", "a", "user", "course", "competency", "from", "the", "course", "page", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/api.php#L4897-L4952
217,312
moodle/moodle
competency/classes/api.php
api.count_plans_for_template
public static function count_plans_for_template($templateorid, $status = 0) { static::require_enabled(); $template = $templateorid; if (!is_object($template)) { $template = new template($template); } // First we do a permissions check. if (!$template->can_read()) { throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', ''); } return plan::count_records_for_template($template->get('id'), $status); }
php
public static function count_plans_for_template($templateorid, $status = 0) { static::require_enabled(); $template = $templateorid; if (!is_object($template)) { $template = new template($template); } // First we do a permissions check. if (!$template->can_read()) { throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', ''); } return plan::count_records_for_template($template->get('id'), $status); }
[ "public", "static", "function", "count_plans_for_template", "(", "$", "templateorid", ",", "$", "status", "=", "0", ")", "{", "static", "::", "require_enabled", "(", ")", ";", "$", "template", "=", "$", "templateorid", ";", "if", "(", "!", "is_object", "(", "$", "template", ")", ")", "{", "$", "template", "=", "new", "template", "(", "$", "template", ")", ";", "}", "// First we do a permissions check.", "if", "(", "!", "$", "template", "->", "can_read", "(", ")", ")", "{", "throw", "new", "required_capability_exception", "(", "$", "template", "->", "get_context", "(", ")", ",", "'moodle/competency:templateview'", ",", "'nopermissions'", ",", "''", ")", ";", "}", "return", "plan", "::", "count_records_for_template", "(", "$", "template", "->", "get", "(", "'id'", ")", ",", "$", "status", ")", ";", "}" ]
Count the plans in the template, filtered by status. Requires moodle/competency:templateview capability at the system context. @param mixed $templateorid The id or the template. @param int $status One of the plan status constants (or 0 for all plans). @return int
[ "Count", "the", "plans", "in", "the", "template", "filtered", "by", "status", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/api.php#L4963-L4977
217,313
moodle/moodle
competency/classes/api.php
api.count_user_competency_plans_for_template
public static function count_user_competency_plans_for_template($templateorid, $proficiency = null) { static::require_enabled(); $template = $templateorid; if (!is_object($template)) { $template = new template($template); } // First we do a permissions check. if (!$template->can_read()) { throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', ''); } return user_competency_plan::count_records_for_template($template->get('id'), $proficiency); }
php
public static function count_user_competency_plans_for_template($templateorid, $proficiency = null) { static::require_enabled(); $template = $templateorid; if (!is_object($template)) { $template = new template($template); } // First we do a permissions check. if (!$template->can_read()) { throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', ''); } return user_competency_plan::count_records_for_template($template->get('id'), $proficiency); }
[ "public", "static", "function", "count_user_competency_plans_for_template", "(", "$", "templateorid", ",", "$", "proficiency", "=", "null", ")", "{", "static", "::", "require_enabled", "(", ")", ";", "$", "template", "=", "$", "templateorid", ";", "if", "(", "!", "is_object", "(", "$", "template", ")", ")", "{", "$", "template", "=", "new", "template", "(", "$", "template", ")", ";", "}", "// First we do a permissions check.", "if", "(", "!", "$", "template", "->", "can_read", "(", ")", ")", "{", "throw", "new", "required_capability_exception", "(", "$", "template", "->", "get_context", "(", ")", ",", "'moodle/competency:templateview'", ",", "'nopermissions'", ",", "''", ")", ";", "}", "return", "user_competency_plan", "::", "count_records_for_template", "(", "$", "template", "->", "get", "(", "'id'", ")", ",", "$", "proficiency", ")", ";", "}" ]
Count the user-completency-plans in the template, optionally filtered by proficiency. Requires moodle/competency:templateview capability at the system context. @param mixed $templateorid The id or the template. @param mixed $proficiency If true, filter by proficiency, if false filter by not proficient, if null - no filter. @return int
[ "Count", "the", "user", "-", "completency", "-", "plans", "in", "the", "template", "optionally", "filtered", "by", "proficiency", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/api.php#L4988-L5002
217,314
moodle/moodle
competency/classes/api.php
api.list_plans_for_template
public static function list_plans_for_template($templateorid, $status = 0, $skip = 0, $limit = 100) { $template = $templateorid; if (!is_object($template)) { $template = new template($template); } // First we do a permissions check. if (!$template->can_read()) { throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', ''); } return plan::get_records_for_template($template->get('id'), $status, $skip, $limit); }
php
public static function list_plans_for_template($templateorid, $status = 0, $skip = 0, $limit = 100) { $template = $templateorid; if (!is_object($template)) { $template = new template($template); } // First we do a permissions check. if (!$template->can_read()) { throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', ''); } return plan::get_records_for_template($template->get('id'), $status, $skip, $limit); }
[ "public", "static", "function", "list_plans_for_template", "(", "$", "templateorid", ",", "$", "status", "=", "0", ",", "$", "skip", "=", "0", ",", "$", "limit", "=", "100", ")", "{", "$", "template", "=", "$", "templateorid", ";", "if", "(", "!", "is_object", "(", "$", "template", ")", ")", "{", "$", "template", "=", "new", "template", "(", "$", "template", ")", ";", "}", "// First we do a permissions check.", "if", "(", "!", "$", "template", "->", "can_read", "(", ")", ")", "{", "throw", "new", "required_capability_exception", "(", "$", "template", "->", "get_context", "(", ")", ",", "'moodle/competency:templateview'", ",", "'nopermissions'", ",", "''", ")", ";", "}", "return", "plan", "::", "get_records_for_template", "(", "$", "template", "->", "get", "(", "'id'", ")", ",", "$", "status", ",", "$", "skip", ",", "$", "limit", ")", ";", "}" ]
List the plans in the template, filtered by status. Requires moodle/competency:templateview capability at the system context. @param mixed $templateorid The id or the template. @param int $status One of the plan status constants (or 0 for all plans). @param int $skip The number of records to skip @param int $limit The max number of records to return @return plan[]
[ "List", "the", "plans", "in", "the", "template", "filtered", "by", "status", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/api.php#L5015-L5028
217,315
moodle/moodle
competency/classes/api.php
api.get_least_proficient_competencies_for_course
public static function get_least_proficient_competencies_for_course($courseid, $skip = 0, $limit = 100) { static::require_enabled(); $coursecontext = context_course::instance($courseid); if (!has_any_capability(array('moodle/competency:coursecompetencyview', 'moodle/competency:coursecompetencymanage'), $coursecontext)) { throw new required_capability_exception($coursecontext, 'moodle/competency:coursecompetencyview', 'nopermissions', ''); } return user_competency_course::get_least_proficient_competencies_for_course($courseid, $skip, $limit); }
php
public static function get_least_proficient_competencies_for_course($courseid, $skip = 0, $limit = 100) { static::require_enabled(); $coursecontext = context_course::instance($courseid); if (!has_any_capability(array('moodle/competency:coursecompetencyview', 'moodle/competency:coursecompetencymanage'), $coursecontext)) { throw new required_capability_exception($coursecontext, 'moodle/competency:coursecompetencyview', 'nopermissions', ''); } return user_competency_course::get_least_proficient_competencies_for_course($courseid, $skip, $limit); }
[ "public", "static", "function", "get_least_proficient_competencies_for_course", "(", "$", "courseid", ",", "$", "skip", "=", "0", ",", "$", "limit", "=", "100", ")", "{", "static", "::", "require_enabled", "(", ")", ";", "$", "coursecontext", "=", "context_course", "::", "instance", "(", "$", "courseid", ")", ";", "if", "(", "!", "has_any_capability", "(", "array", "(", "'moodle/competency:coursecompetencyview'", ",", "'moodle/competency:coursecompetencymanage'", ")", ",", "$", "coursecontext", ")", ")", "{", "throw", "new", "required_capability_exception", "(", "$", "coursecontext", ",", "'moodle/competency:coursecompetencyview'", ",", "'nopermissions'", ",", "''", ")", ";", "}", "return", "user_competency_course", "::", "get_least_proficient_competencies_for_course", "(", "$", "courseid", ",", "$", "skip", ",", "$", "limit", ")", ";", "}" ]
Get the most often not completed competency for this course. Requires moodle/competency:coursecompetencyview capability at the course context. @param int $courseid The course id @param int $skip The number of records to skip @param int $limit The max number of records to return @return competency[]
[ "Get", "the", "most", "often", "not", "completed", "competency", "for", "this", "course", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/api.php#L5040-L5050
217,316
moodle/moodle
competency/classes/api.php
api.get_least_proficient_competencies_for_template
public static function get_least_proficient_competencies_for_template($templateorid, $skip = 0, $limit = 100) { static::require_enabled(); $template = $templateorid; if (!is_object($template)) { $template = new template($template); } // First we do a permissions check. if (!$template->can_read()) { throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', ''); } return user_competency_plan::get_least_proficient_competencies_for_template($template->get('id'), $skip, $limit); }
php
public static function get_least_proficient_competencies_for_template($templateorid, $skip = 0, $limit = 100) { static::require_enabled(); $template = $templateorid; if (!is_object($template)) { $template = new template($template); } // First we do a permissions check. if (!$template->can_read()) { throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', ''); } return user_competency_plan::get_least_proficient_competencies_for_template($template->get('id'), $skip, $limit); }
[ "public", "static", "function", "get_least_proficient_competencies_for_template", "(", "$", "templateorid", ",", "$", "skip", "=", "0", ",", "$", "limit", "=", "100", ")", "{", "static", "::", "require_enabled", "(", ")", ";", "$", "template", "=", "$", "templateorid", ";", "if", "(", "!", "is_object", "(", "$", "template", ")", ")", "{", "$", "template", "=", "new", "template", "(", "$", "template", ")", ";", "}", "// First we do a permissions check.", "if", "(", "!", "$", "template", "->", "can_read", "(", ")", ")", "{", "throw", "new", "required_capability_exception", "(", "$", "template", "->", "get_context", "(", ")", ",", "'moodle/competency:templateview'", ",", "'nopermissions'", ",", "''", ")", ";", "}", "return", "user_competency_plan", "::", "get_least_proficient_competencies_for_template", "(", "$", "template", "->", "get", "(", "'id'", ")", ",", "$", "skip", ",", "$", "limit", ")", ";", "}" ]
Get the most often not completed competency for this template. Requires moodle/competency:templateview capability at the system context. @param mixed $templateorid The id or the template. @param int $skip The number of records to skip @param int $limit The max number of records to return @return competency[]
[ "Get", "the", "most", "often", "not", "completed", "competency", "for", "this", "template", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/api.php#L5062-L5076
217,317
moodle/moodle
competency/classes/api.php
api.template_viewed
public static function template_viewed($templateorid) { static::require_enabled(); $template = $templateorid; if (!is_object($template)) { $template = new template($template); } // First we do a permissions check. if (!$template->can_read()) { throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', ''); } // Trigger a template viewed event. \core\event\competency_template_viewed::create_from_template($template)->trigger(); return true; }
php
public static function template_viewed($templateorid) { static::require_enabled(); $template = $templateorid; if (!is_object($template)) { $template = new template($template); } // First we do a permissions check. if (!$template->can_read()) { throw new required_capability_exception($template->get_context(), 'moodle/competency:templateview', 'nopermissions', ''); } // Trigger a template viewed event. \core\event\competency_template_viewed::create_from_template($template)->trigger(); return true; }
[ "public", "static", "function", "template_viewed", "(", "$", "templateorid", ")", "{", "static", "::", "require_enabled", "(", ")", ";", "$", "template", "=", "$", "templateorid", ";", "if", "(", "!", "is_object", "(", "$", "template", ")", ")", "{", "$", "template", "=", "new", "template", "(", "$", "template", ")", ";", "}", "// First we do a permissions check.", "if", "(", "!", "$", "template", "->", "can_read", "(", ")", ")", "{", "throw", "new", "required_capability_exception", "(", "$", "template", "->", "get_context", "(", ")", ",", "'moodle/competency:templateview'", ",", "'nopermissions'", ",", "''", ")", ";", "}", "// Trigger a template viewed event.", "\\", "core", "\\", "event", "\\", "competency_template_viewed", "::", "create_from_template", "(", "$", "template", ")", "->", "trigger", "(", ")", ";", "return", "true", ";", "}" ]
Template event viewed. Requires moodle/competency:templateview capability at the system context. @param mixed $templateorid The id or the template. @return boolean
[ "Template", "event", "viewed", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/api.php#L5086-L5103
217,318
moodle/moodle
competency/classes/api.php
api.read_course_competency_settings
public static function read_course_competency_settings($courseid) { static::require_enabled(); // First we do a permissions check. if (!course_competency_settings::can_read($courseid)) { $context = context_course::instance($courseid); throw new required_capability_exception($context, 'moodle/competency:coursecompetencyview', 'nopermissions', ''); } return course_competency_settings::get_by_courseid($courseid); }
php
public static function read_course_competency_settings($courseid) { static::require_enabled(); // First we do a permissions check. if (!course_competency_settings::can_read($courseid)) { $context = context_course::instance($courseid); throw new required_capability_exception($context, 'moodle/competency:coursecompetencyview', 'nopermissions', ''); } return course_competency_settings::get_by_courseid($courseid); }
[ "public", "static", "function", "read_course_competency_settings", "(", "$", "courseid", ")", "{", "static", "::", "require_enabled", "(", ")", ";", "// First we do a permissions check.", "if", "(", "!", "course_competency_settings", "::", "can_read", "(", "$", "courseid", ")", ")", "{", "$", "context", "=", "context_course", "::", "instance", "(", "$", "courseid", ")", ";", "throw", "new", "required_capability_exception", "(", "$", "context", ",", "'moodle/competency:coursecompetencyview'", ",", "'nopermissions'", ",", "''", ")", ";", "}", "return", "course_competency_settings", "::", "get_by_courseid", "(", "$", "courseid", ")", ";", "}" ]
Get the competency settings for a course. Requires moodle/competency:coursecompetencyview capability at the course context. @param int $courseid The course id @return course_competency_settings
[ "Get", "the", "competency", "settings", "for", "a", "course", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/api.php#L5113-L5123
217,319
moodle/moodle
competency/classes/api.php
api.update_course_competency_settings
public static function update_course_competency_settings($courseid, $settings) { static::require_enabled(); $settings = (object) $settings; // Get all the valid settings. $pushratingstouserplans = isset($settings->pushratingstouserplans) ? $settings->pushratingstouserplans : false; // First we do a permissions check. if (!course_competency_settings::can_manage_course($courseid)) { $context = context_course::instance($courseid); throw new required_capability_exception($context, 'moodle/competency:coursecompetencyconfigure', 'nopermissions', ''); } $exists = course_competency_settings::get_record(array('courseid' => $courseid)); // Now update or insert. if ($exists) { $settings = $exists; $settings->set('pushratingstouserplans', $pushratingstouserplans); return $settings->update(); } else { $data = (object) array('courseid' => $courseid, 'pushratingstouserplans' => $pushratingstouserplans); $settings = new course_competency_settings(0, $data); $result = $settings->create(); return !empty($result); } }
php
public static function update_course_competency_settings($courseid, $settings) { static::require_enabled(); $settings = (object) $settings; // Get all the valid settings. $pushratingstouserplans = isset($settings->pushratingstouserplans) ? $settings->pushratingstouserplans : false; // First we do a permissions check. if (!course_competency_settings::can_manage_course($courseid)) { $context = context_course::instance($courseid); throw new required_capability_exception($context, 'moodle/competency:coursecompetencyconfigure', 'nopermissions', ''); } $exists = course_competency_settings::get_record(array('courseid' => $courseid)); // Now update or insert. if ($exists) { $settings = $exists; $settings->set('pushratingstouserplans', $pushratingstouserplans); return $settings->update(); } else { $data = (object) array('courseid' => $courseid, 'pushratingstouserplans' => $pushratingstouserplans); $settings = new course_competency_settings(0, $data); $result = $settings->create(); return !empty($result); } }
[ "public", "static", "function", "update_course_competency_settings", "(", "$", "courseid", ",", "$", "settings", ")", "{", "static", "::", "require_enabled", "(", ")", ";", "$", "settings", "=", "(", "object", ")", "$", "settings", ";", "// Get all the valid settings.", "$", "pushratingstouserplans", "=", "isset", "(", "$", "settings", "->", "pushratingstouserplans", ")", "?", "$", "settings", "->", "pushratingstouserplans", ":", "false", ";", "// First we do a permissions check.", "if", "(", "!", "course_competency_settings", "::", "can_manage_course", "(", "$", "courseid", ")", ")", "{", "$", "context", "=", "context_course", "::", "instance", "(", "$", "courseid", ")", ";", "throw", "new", "required_capability_exception", "(", "$", "context", ",", "'moodle/competency:coursecompetencyconfigure'", ",", "'nopermissions'", ",", "''", ")", ";", "}", "$", "exists", "=", "course_competency_settings", "::", "get_record", "(", "array", "(", "'courseid'", "=>", "$", "courseid", ")", ")", ";", "// Now update or insert.", "if", "(", "$", "exists", ")", "{", "$", "settings", "=", "$", "exists", ";", "$", "settings", "->", "set", "(", "'pushratingstouserplans'", ",", "$", "pushratingstouserplans", ")", ";", "return", "$", "settings", "->", "update", "(", ")", ";", "}", "else", "{", "$", "data", "=", "(", "object", ")", "array", "(", "'courseid'", "=>", "$", "courseid", ",", "'pushratingstouserplans'", "=>", "$", "pushratingstouserplans", ")", ";", "$", "settings", "=", "new", "course_competency_settings", "(", "0", ",", "$", "data", ")", ";", "$", "result", "=", "$", "settings", "->", "create", "(", ")", ";", "return", "!", "empty", "(", "$", "result", ")", ";", "}", "}" ]
Update the competency settings for a course. Requires moodle/competency:coursecompetencyconfigure capability at the course context. @param int $courseid The course id @param stdClass $settings List of settings. The only valid setting ATM is pushratginstouserplans (boolean). @return bool
[ "Update", "the", "competency", "settings", "for", "a", "course", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/competency/classes/api.php#L5134-L5161
217,320
moodle/moodle
backup/util/ui/renderer.php
core_backup_renderer.progress_bar
public function progress_bar(array $items) { foreach ($items as &$item) { $text = $item['text']; unset($item['text']); if (array_key_exists('link', $item)) { $link = $item['link']; unset($item['link']); $item = html_writer::link($link, $text, $item); } else { $item = html_writer::tag('span', $text, $item); } } return html_writer::tag('div', join(get_separator(), $items), array('class' => 'backup_progress clearfix')); }
php
public function progress_bar(array $items) { foreach ($items as &$item) { $text = $item['text']; unset($item['text']); if (array_key_exists('link', $item)) { $link = $item['link']; unset($item['link']); $item = html_writer::link($link, $text, $item); } else { $item = html_writer::tag('span', $text, $item); } } return html_writer::tag('div', join(get_separator(), $items), array('class' => 'backup_progress clearfix')); }
[ "public", "function", "progress_bar", "(", "array", "$", "items", ")", "{", "foreach", "(", "$", "items", "as", "&", "$", "item", ")", "{", "$", "text", "=", "$", "item", "[", "'text'", "]", ";", "unset", "(", "$", "item", "[", "'text'", "]", ")", ";", "if", "(", "array_key_exists", "(", "'link'", ",", "$", "item", ")", ")", "{", "$", "link", "=", "$", "item", "[", "'link'", "]", ";", "unset", "(", "$", "item", "[", "'link'", "]", ")", ";", "$", "item", "=", "html_writer", "::", "link", "(", "$", "link", ",", "$", "text", ",", "$", "item", ")", ";", "}", "else", "{", "$", "item", "=", "html_writer", "::", "tag", "(", "'span'", ",", "$", "text", ",", "$", "item", ")", ";", "}", "}", "return", "html_writer", "::", "tag", "(", "'div'", ",", "join", "(", "get_separator", "(", ")", ",", "$", "items", ")", ",", "array", "(", "'class'", "=>", "'backup_progress clearfix'", ")", ")", ";", "}" ]
Renderers a progress bar for the backup or restore given the items that make it up. @param array $items An array of items @return string
[ "Renderers", "a", "progress", "bar", "for", "the", "backup", "or", "restore", "given", "the", "items", "that", "make", "it", "up", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/ui/renderer.php#L52-L65
217,321
moodle/moodle
backup/util/ui/renderer.php
core_backup_renderer.backup_details_nonstandard
public function backup_details_nonstandard($nextstageurl, array $details) { $html = html_writer::start_tag('div', array('class' => 'backup-restore nonstandardformat')); $html .= html_writer::start_tag('div', array('class' => 'backup-section')); $html .= $this->output->heading(get_string('backupdetails', 'backup'), 2, 'header'); $html .= $this->output->box(get_string('backupdetailsnonstandardinfo', 'backup'), 'noticebox'); $html .= $this->backup_detail_pair( get_string('backupformat', 'backup'), get_string('backupformat'.$details['format'], 'backup')); $html .= $this->backup_detail_pair( get_string('backuptype', 'backup'), get_string('backuptype'.$details['type'], 'backup')); $html .= html_writer::end_tag('div'); $html .= $this->output->single_button($nextstageurl, get_string('continue'), 'post'); $html .= html_writer::end_tag('div'); return $html; }
php
public function backup_details_nonstandard($nextstageurl, array $details) { $html = html_writer::start_tag('div', array('class' => 'backup-restore nonstandardformat')); $html .= html_writer::start_tag('div', array('class' => 'backup-section')); $html .= $this->output->heading(get_string('backupdetails', 'backup'), 2, 'header'); $html .= $this->output->box(get_string('backupdetailsnonstandardinfo', 'backup'), 'noticebox'); $html .= $this->backup_detail_pair( get_string('backupformat', 'backup'), get_string('backupformat'.$details['format'], 'backup')); $html .= $this->backup_detail_pair( get_string('backuptype', 'backup'), get_string('backuptype'.$details['type'], 'backup')); $html .= html_writer::end_tag('div'); $html .= $this->output->single_button($nextstageurl, get_string('continue'), 'post'); $html .= html_writer::end_tag('div'); return $html; }
[ "public", "function", "backup_details_nonstandard", "(", "$", "nextstageurl", ",", "array", "$", "details", ")", "{", "$", "html", "=", "html_writer", "::", "start_tag", "(", "'div'", ",", "array", "(", "'class'", "=>", "'backup-restore nonstandardformat'", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "start_tag", "(", "'div'", ",", "array", "(", "'class'", "=>", "'backup-section'", ")", ")", ";", "$", "html", ".=", "$", "this", "->", "output", "->", "heading", "(", "get_string", "(", "'backupdetails'", ",", "'backup'", ")", ",", "2", ",", "'header'", ")", ";", "$", "html", ".=", "$", "this", "->", "output", "->", "box", "(", "get_string", "(", "'backupdetailsnonstandardinfo'", ",", "'backup'", ")", ",", "'noticebox'", ")", ";", "$", "html", ".=", "$", "this", "->", "backup_detail_pair", "(", "get_string", "(", "'backupformat'", ",", "'backup'", ")", ",", "get_string", "(", "'backupformat'", ".", "$", "details", "[", "'format'", "]", ",", "'backup'", ")", ")", ";", "$", "html", ".=", "$", "this", "->", "backup_detail_pair", "(", "get_string", "(", "'backuptype'", ",", "'backup'", ")", ",", "get_string", "(", "'backuptype'", ".", "$", "details", "[", "'type'", "]", ",", "'backup'", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "end_tag", "(", "'div'", ")", ";", "$", "html", ".=", "$", "this", "->", "output", "->", "single_button", "(", "$", "nextstageurl", ",", "get_string", "(", "'continue'", ")", ",", "'post'", ")", ";", "$", "html", ".=", "html_writer", "::", "end_tag", "(", "'div'", ")", ";", "return", "$", "html", ";", "}" ]
Displays the general information about a backup file with non-standard format @param moodle_url $nextstageurl URL to send user to @param array $details basic info about the file (format, type) @return string HTML code to display
[ "Displays", "the", "general", "information", "about", "a", "backup", "file", "with", "non", "-", "standard", "format" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/ui/renderer.php#L209-L226
217,322
moodle/moodle
backup/util/ui/renderer.php
core_backup_renderer.backup_details_unknown
public function backup_details_unknown(moodle_url $nextstageurl) { $html = html_writer::start_div('unknownformat'); $html .= $this->output->heading(get_string('errorinvalidformat', 'backup'), 2); $html .= $this->output->notification(get_string('errorinvalidformatinfo', 'backup'), 'notifyproblem'); $html .= $this->output->single_button($nextstageurl, get_string('continue'), 'post'); $html .= html_writer::end_div(); return $html; }
php
public function backup_details_unknown(moodle_url $nextstageurl) { $html = html_writer::start_div('unknownformat'); $html .= $this->output->heading(get_string('errorinvalidformat', 'backup'), 2); $html .= $this->output->notification(get_string('errorinvalidformatinfo', 'backup'), 'notifyproblem'); $html .= $this->output->single_button($nextstageurl, get_string('continue'), 'post'); $html .= html_writer::end_div(); return $html; }
[ "public", "function", "backup_details_unknown", "(", "moodle_url", "$", "nextstageurl", ")", "{", "$", "html", "=", "html_writer", "::", "start_div", "(", "'unknownformat'", ")", ";", "$", "html", ".=", "$", "this", "->", "output", "->", "heading", "(", "get_string", "(", "'errorinvalidformat'", ",", "'backup'", ")", ",", "2", ")", ";", "$", "html", ".=", "$", "this", "->", "output", "->", "notification", "(", "get_string", "(", "'errorinvalidformatinfo'", ",", "'backup'", ")", ",", "'notifyproblem'", ")", ";", "$", "html", ".=", "$", "this", "->", "output", "->", "single_button", "(", "$", "nextstageurl", ",", "get_string", "(", "'continue'", ")", ",", "'post'", ")", ";", "$", "html", ".=", "html_writer", "::", "end_div", "(", ")", ";", "return", "$", "html", ";", "}" ]
Displays the general information about a backup file with unknown format @param moodle_url $nextstageurl URL to send user to @return string HTML code to display
[ "Displays", "the", "general", "information", "about", "a", "backup", "file", "with", "unknown", "format" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/ui/renderer.php#L234-L243
217,323
moodle/moodle
backup/util/ui/renderer.php
core_backup_renderer.import_course_selector
public function import_course_selector(moodle_url $nextstageurl, import_course_search $courses = null) { $html = html_writer::start_tag('div', array('class' => 'import-course-selector backup-restore')); $html .= html_writer::start_tag('form', array('method' => 'post', 'action' => $nextstageurl->out_omit_querystring())); foreach ($nextstageurl->params() as $key => $value) { $html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $key, 'value' => $value)); } // We only allow import adding for now. Enforce it here. $html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'target', 'value' => backup::TARGET_CURRENT_ADDING)); $html .= html_writer::start_tag('div', array('class' => 'ics-existing-course backup-section')); $html .= $this->output->heading(get_string('importdatafrom'), 2, array('class' => 'header')); $html .= $this->backup_detail_pair(get_string('selectacourse', 'backup'), $this->render($courses)); $attrs = array('type' => 'submit', 'value' => get_string('continue'), 'class' => 'btn btn-primary'); $html .= $this->backup_detail_pair('', html_writer::empty_tag('input', $attrs)); $html .= html_writer::end_tag('div'); $html .= html_writer::end_tag('form'); $html .= html_writer::end_tag('div'); return $html; }
php
public function import_course_selector(moodle_url $nextstageurl, import_course_search $courses = null) { $html = html_writer::start_tag('div', array('class' => 'import-course-selector backup-restore')); $html .= html_writer::start_tag('form', array('method' => 'post', 'action' => $nextstageurl->out_omit_querystring())); foreach ($nextstageurl->params() as $key => $value) { $html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => $key, 'value' => $value)); } // We only allow import adding for now. Enforce it here. $html .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'target', 'value' => backup::TARGET_CURRENT_ADDING)); $html .= html_writer::start_tag('div', array('class' => 'ics-existing-course backup-section')); $html .= $this->output->heading(get_string('importdatafrom'), 2, array('class' => 'header')); $html .= $this->backup_detail_pair(get_string('selectacourse', 'backup'), $this->render($courses)); $attrs = array('type' => 'submit', 'value' => get_string('continue'), 'class' => 'btn btn-primary'); $html .= $this->backup_detail_pair('', html_writer::empty_tag('input', $attrs)); $html .= html_writer::end_tag('div'); $html .= html_writer::end_tag('form'); $html .= html_writer::end_tag('div'); return $html; }
[ "public", "function", "import_course_selector", "(", "moodle_url", "$", "nextstageurl", ",", "import_course_search", "$", "courses", "=", "null", ")", "{", "$", "html", "=", "html_writer", "::", "start_tag", "(", "'div'", ",", "array", "(", "'class'", "=>", "'import-course-selector backup-restore'", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "start_tag", "(", "'form'", ",", "array", "(", "'method'", "=>", "'post'", ",", "'action'", "=>", "$", "nextstageurl", "->", "out_omit_querystring", "(", ")", ")", ")", ";", "foreach", "(", "$", "nextstageurl", "->", "params", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "html", ".=", "html_writer", "::", "empty_tag", "(", "'input'", ",", "array", "(", "'type'", "=>", "'hidden'", ",", "'name'", "=>", "$", "key", ",", "'value'", "=>", "$", "value", ")", ")", ";", "}", "// We only allow import adding for now. Enforce it here.", "$", "html", ".=", "html_writer", "::", "empty_tag", "(", "'input'", ",", "array", "(", "'type'", "=>", "'hidden'", ",", "'name'", "=>", "'target'", ",", "'value'", "=>", "backup", "::", "TARGET_CURRENT_ADDING", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "start_tag", "(", "'div'", ",", "array", "(", "'class'", "=>", "'ics-existing-course backup-section'", ")", ")", ";", "$", "html", ".=", "$", "this", "->", "output", "->", "heading", "(", "get_string", "(", "'importdatafrom'", ")", ",", "2", ",", "array", "(", "'class'", "=>", "'header'", ")", ")", ";", "$", "html", ".=", "$", "this", "->", "backup_detail_pair", "(", "get_string", "(", "'selectacourse'", ",", "'backup'", ")", ",", "$", "this", "->", "render", "(", "$", "courses", ")", ")", ";", "$", "attrs", "=", "array", "(", "'type'", "=>", "'submit'", ",", "'value'", "=>", "get_string", "(", "'continue'", ")", ",", "'class'", "=>", "'btn btn-primary'", ")", ";", "$", "html", ".=", "$", "this", "->", "backup_detail_pair", "(", "''", ",", "html_writer", "::", "empty_tag", "(", "'input'", ",", "$", "attrs", ")", ")", ";", "$", "html", ".=", "html_writer", "::", "end_tag", "(", "'div'", ")", ";", "$", "html", ".=", "html_writer", "::", "end_tag", "(", "'form'", ")", ";", "$", "html", ".=", "html_writer", "::", "end_tag", "(", "'div'", ")", ";", "return", "$", "html", ";", "}" ]
Displays the import course selector @param moodle_url $nextstageurl @param import_course_search $courses @return string
[ "Displays", "the", "import", "course", "selector" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/ui/renderer.php#L372-L389
217,324
moodle/moodle
backup/util/ui/renderer.php
core_backup_renderer.backup_detail_input
protected function backup_detail_input($label, $type, $name, $value, array $attributes = array(), $description = null) { if (!empty($description)) { $description = html_writer::tag('span', $description, array('class' => 'description')); } else { $description = ''; } return $this->backup_detail_pair( $label, html_writer::empty_tag('input', $attributes + array('name' => $name, 'type' => $type, 'value' => $value)) . $description ); }
php
protected function backup_detail_input($label, $type, $name, $value, array $attributes = array(), $description = null) { if (!empty($description)) { $description = html_writer::tag('span', $description, array('class' => 'description')); } else { $description = ''; } return $this->backup_detail_pair( $label, html_writer::empty_tag('input', $attributes + array('name' => $name, 'type' => $type, 'value' => $value)) . $description ); }
[ "protected", "function", "backup_detail_input", "(", "$", "label", ",", "$", "type", ",", "$", "name", ",", "$", "value", ",", "array", "$", "attributes", "=", "array", "(", ")", ",", "$", "description", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "description", ")", ")", "{", "$", "description", "=", "html_writer", "::", "tag", "(", "'span'", ",", "$", "description", ",", "array", "(", "'class'", "=>", "'description'", ")", ")", ";", "}", "else", "{", "$", "description", "=", "''", ";", "}", "return", "$", "this", "->", "backup_detail_pair", "(", "$", "label", ",", "html_writer", "::", "empty_tag", "(", "'input'", ",", "$", "attributes", "+", "array", "(", "'name'", "=>", "$", "name", ",", "'type'", "=>", "$", "type", ",", "'value'", "=>", "$", "value", ")", ")", ".", "$", "description", ")", ";", "}" ]
Created a detailed pairing with an input @param string $label @param string $type @param string $name @param string $value @param array $attributes @param string|null $description @return string
[ "Created", "a", "detailed", "pairing", "with", "an", "input" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/ui/renderer.php#L420-L430
217,325
moodle/moodle
backup/util/ui/renderer.php
core_backup_renderer.backup_detail_select
protected function backup_detail_select($label, $name, $options, $selected = '', $nothing = false, array $attributes = array(), $description = null) { if (!empty ($description)) { $description = html_writer::tag('span', $description, array('class' => 'description')); } else { $description = ''; } return $this->backup_detail_pair($label, html_writer::select($options, $name, $selected, false, $attributes).$description); }
php
protected function backup_detail_select($label, $name, $options, $selected = '', $nothing = false, array $attributes = array(), $description = null) { if (!empty ($description)) { $description = html_writer::tag('span', $description, array('class' => 'description')); } else { $description = ''; } return $this->backup_detail_pair($label, html_writer::select($options, $name, $selected, false, $attributes).$description); }
[ "protected", "function", "backup_detail_select", "(", "$", "label", ",", "$", "name", ",", "$", "options", ",", "$", "selected", "=", "''", ",", "$", "nothing", "=", "false", ",", "array", "$", "attributes", "=", "array", "(", ")", ",", "$", "description", "=", "null", ")", "{", "if", "(", "!", "empty", "(", "$", "description", ")", ")", "{", "$", "description", "=", "html_writer", "::", "tag", "(", "'span'", ",", "$", "description", ",", "array", "(", "'class'", "=>", "'description'", ")", ")", ";", "}", "else", "{", "$", "description", "=", "''", ";", "}", "return", "$", "this", "->", "backup_detail_pair", "(", "$", "label", ",", "html_writer", "::", "select", "(", "$", "options", ",", "$", "name", ",", "$", "selected", ",", "false", ",", "$", "attributes", ")", ".", "$", "description", ")", ";", "}" ]
Creates a detailed pairing with a select @param string $label @param string $name @param array $options @param string $selected @param bool $nothing @param array $attributes @param string|null $description @return string
[ "Creates", "a", "detailed", "pairing", "with", "a", "select" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/ui/renderer.php#L444-L451
217,326
moodle/moodle
backup/util/ui/renderer.php
core_backup_renderer.precheck_notices
public function precheck_notices($results) { $output = html_writer::start_tag('div', array('class' => 'restore-precheck-notices')); if (array_key_exists('errors', $results)) { foreach ($results['errors'] as $error) { $output .= $this->output->notification($error); } } if (array_key_exists('warnings', $results)) { foreach ($results['warnings'] as $warning) { $output .= $this->output->notification($warning, 'notifyproblem'); } } return $output.html_writer::end_tag('div'); }
php
public function precheck_notices($results) { $output = html_writer::start_tag('div', array('class' => 'restore-precheck-notices')); if (array_key_exists('errors', $results)) { foreach ($results['errors'] as $error) { $output .= $this->output->notification($error); } } if (array_key_exists('warnings', $results)) { foreach ($results['warnings'] as $warning) { $output .= $this->output->notification($warning, 'notifyproblem'); } } return $output.html_writer::end_tag('div'); }
[ "public", "function", "precheck_notices", "(", "$", "results", ")", "{", "$", "output", "=", "html_writer", "::", "start_tag", "(", "'div'", ",", "array", "(", "'class'", "=>", "'restore-precheck-notices'", ")", ")", ";", "if", "(", "array_key_exists", "(", "'errors'", ",", "$", "results", ")", ")", "{", "foreach", "(", "$", "results", "[", "'errors'", "]", "as", "$", "error", ")", "{", "$", "output", ".=", "$", "this", "->", "output", "->", "notification", "(", "$", "error", ")", ";", "}", "}", "if", "(", "array_key_exists", "(", "'warnings'", ",", "$", "results", ")", ")", "{", "foreach", "(", "$", "results", "[", "'warnings'", "]", "as", "$", "warning", ")", "{", "$", "output", ".=", "$", "this", "->", "output", "->", "notification", "(", "$", "warning", ",", "'notifyproblem'", ")", ";", "}", "}", "return", "$", "output", ".", "html_writer", "::", "end_tag", "(", "'div'", ")", ";", "}" ]
Displays precheck notices @param array $results @return string
[ "Displays", "precheck", "notices" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/ui/renderer.php#L459-L472
217,327
moodle/moodle
backup/util/ui/renderer.php
core_backup_renderer.substage_buttons
public function substage_buttons($haserrors) { $output = html_writer::start_tag('div', array('continuebutton')); if (!$haserrors) { $attrs = array('type' => 'submit', 'value' => get_string('continue'), 'class' => 'btn btn-primary'); $output .= html_writer::empty_tag('input', $attrs); } $attrs = array('type' => 'submit', 'name' => 'cancel', 'value' => get_string('cancel'), 'class' => 'btn btn-secondary'); $output .= html_writer::empty_tag('input', $attrs); $output .= html_writer::end_tag('div'); return $output; }
php
public function substage_buttons($haserrors) { $output = html_writer::start_tag('div', array('continuebutton')); if (!$haserrors) { $attrs = array('type' => 'submit', 'value' => get_string('continue'), 'class' => 'btn btn-primary'); $output .= html_writer::empty_tag('input', $attrs); } $attrs = array('type' => 'submit', 'name' => 'cancel', 'value' => get_string('cancel'), 'class' => 'btn btn-secondary'); $output .= html_writer::empty_tag('input', $attrs); $output .= html_writer::end_tag('div'); return $output; }
[ "public", "function", "substage_buttons", "(", "$", "haserrors", ")", "{", "$", "output", "=", "html_writer", "::", "start_tag", "(", "'div'", ",", "array", "(", "'continuebutton'", ")", ")", ";", "if", "(", "!", "$", "haserrors", ")", "{", "$", "attrs", "=", "array", "(", "'type'", "=>", "'submit'", ",", "'value'", "=>", "get_string", "(", "'continue'", ")", ",", "'class'", "=>", "'btn btn-primary'", ")", ";", "$", "output", ".=", "html_writer", "::", "empty_tag", "(", "'input'", ",", "$", "attrs", ")", ";", "}", "$", "attrs", "=", "array", "(", "'type'", "=>", "'submit'", ",", "'name'", "=>", "'cancel'", ",", "'value'", "=>", "get_string", "(", "'cancel'", ")", ",", "'class'", "=>", "'btn btn-secondary'", ")", ";", "$", "output", ".=", "html_writer", "::", "empty_tag", "(", "'input'", ",", "$", "attrs", ")", ";", "$", "output", ".=", "html_writer", "::", "end_tag", "(", "'div'", ")", ";", "return", "$", "output", ";", "}" ]
Displays substage buttons @param bool $haserrors @return string
[ "Displays", "substage", "buttons" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/ui/renderer.php#L480-L490
217,328
moodle/moodle
backup/util/ui/renderer.php
core_backup_renderer.role_mappings
public function role_mappings($rolemappings, $roles) { $roles[0] = get_string('none'); $output = html_writer::start_tag('div', array('class' => 'restore-rolemappings')); $output .= $this->output->heading(get_string('restorerolemappings', 'backup'), 2); foreach ($rolemappings as $id => $mapping) { $label = $mapping->name; $name = 'mapping'.$id; $selected = $mapping->targetroleid; $output .= $this->backup_detail_select($label, $name, $roles, $mapping->targetroleid, false, array(), $mapping->description); } $output .= html_writer::end_tag('div'); return $output; }
php
public function role_mappings($rolemappings, $roles) { $roles[0] = get_string('none'); $output = html_writer::start_tag('div', array('class' => 'restore-rolemappings')); $output .= $this->output->heading(get_string('restorerolemappings', 'backup'), 2); foreach ($rolemappings as $id => $mapping) { $label = $mapping->name; $name = 'mapping'.$id; $selected = $mapping->targetroleid; $output .= $this->backup_detail_select($label, $name, $roles, $mapping->targetroleid, false, array(), $mapping->description); } $output .= html_writer::end_tag('div'); return $output; }
[ "public", "function", "role_mappings", "(", "$", "rolemappings", ",", "$", "roles", ")", "{", "$", "roles", "[", "0", "]", "=", "get_string", "(", "'none'", ")", ";", "$", "output", "=", "html_writer", "::", "start_tag", "(", "'div'", ",", "array", "(", "'class'", "=>", "'restore-rolemappings'", ")", ")", ";", "$", "output", ".=", "$", "this", "->", "output", "->", "heading", "(", "get_string", "(", "'restorerolemappings'", ",", "'backup'", ")", ",", "2", ")", ";", "foreach", "(", "$", "rolemappings", "as", "$", "id", "=>", "$", "mapping", ")", "{", "$", "label", "=", "$", "mapping", "->", "name", ";", "$", "name", "=", "'mapping'", ".", "$", "id", ";", "$", "selected", "=", "$", "mapping", "->", "targetroleid", ";", "$", "output", ".=", "$", "this", "->", "backup_detail_select", "(", "$", "label", ",", "$", "name", ",", "$", "roles", ",", "$", "mapping", "->", "targetroleid", ",", "false", ",", "array", "(", ")", ",", "$", "mapping", "->", "description", ")", ";", "}", "$", "output", ".=", "html_writer", "::", "end_tag", "(", "'div'", ")", ";", "return", "$", "output", ";", "}" ]
Displays a role mapping interface @param array $rolemappings @param array $roles @return string
[ "Displays", "a", "role", "mapping", "interface" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/ui/renderer.php#L499-L511
217,329
moodle/moodle
backup/util/ui/renderer.php
core_backup_renderer.continue_button
public function continue_button($url, $method = 'post') { if (!($url instanceof moodle_url)) { $url = new moodle_url($url); } if ($method != 'post') { $method = 'get'; } $url->param('sesskey', sesskey()); $button = new single_button($url, get_string('continue'), $method, true); $button->class = 'continuebutton'; return $this->render($button); }
php
public function continue_button($url, $method = 'post') { if (!($url instanceof moodle_url)) { $url = new moodle_url($url); } if ($method != 'post') { $method = 'get'; } $url->param('sesskey', sesskey()); $button = new single_button($url, get_string('continue'), $method, true); $button->class = 'continuebutton'; return $this->render($button); }
[ "public", "function", "continue_button", "(", "$", "url", ",", "$", "method", "=", "'post'", ")", "{", "if", "(", "!", "(", "$", "url", "instanceof", "moodle_url", ")", ")", "{", "$", "url", "=", "new", "moodle_url", "(", "$", "url", ")", ";", "}", "if", "(", "$", "method", "!=", "'post'", ")", "{", "$", "method", "=", "'get'", ";", "}", "$", "url", "->", "param", "(", "'sesskey'", ",", "sesskey", "(", ")", ")", ";", "$", "button", "=", "new", "single_button", "(", "$", "url", ",", "get_string", "(", "'continue'", ")", ",", "$", "method", ",", "true", ")", ";", "$", "button", "->", "class", "=", "'continuebutton'", ";", "return", "$", "this", "->", "render", "(", "$", "button", ")", ";", "}" ]
Displays a continue button @param string|moodle_url $url @param string $method @return string
[ "Displays", "a", "continue", "button" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/ui/renderer.php#L520-L531
217,330
moodle/moodle
backup/util/ui/renderer.php
core_backup_renderer.get_status_display
public function get_status_display($statuscode, $backupid) { if ($statuscode == backup::STATUS_AWAITING || $statuscode == backup::STATUS_EXECUTING) { // Inprogress. $progresssetup = array( 'backupid' => $backupid, 'width' => '100' ); $status = $this->render_from_template('core/async_backup_progress', $progresssetup); } else if ($statuscode == backup::STATUS_FINISHED_ERR) { // Error. $icon = $this->output->render(new \pix_icon('i/delete', get_string('failed', 'backup'))); $status = \html_writer::span($icon, 'action-icon'); } else if ($statuscode == backup::STATUS_FINISHED_OK) { // Complete. $icon = $this->output->render(new \pix_icon('i/checked', get_string('successful', 'backup'))); $status = \html_writer::span($icon, 'action-icon'); } return $status; }
php
public function get_status_display($statuscode, $backupid) { if ($statuscode == backup::STATUS_AWAITING || $statuscode == backup::STATUS_EXECUTING) { // Inprogress. $progresssetup = array( 'backupid' => $backupid, 'width' => '100' ); $status = $this->render_from_template('core/async_backup_progress', $progresssetup); } else if ($statuscode == backup::STATUS_FINISHED_ERR) { // Error. $icon = $this->output->render(new \pix_icon('i/delete', get_string('failed', 'backup'))); $status = \html_writer::span($icon, 'action-icon'); } else if ($statuscode == backup::STATUS_FINISHED_OK) { // Complete. $icon = $this->output->render(new \pix_icon('i/checked', get_string('successful', 'backup'))); $status = \html_writer::span($icon, 'action-icon'); } return $status; }
[ "public", "function", "get_status_display", "(", "$", "statuscode", ",", "$", "backupid", ")", "{", "if", "(", "$", "statuscode", "==", "backup", "::", "STATUS_AWAITING", "||", "$", "statuscode", "==", "backup", "::", "STATUS_EXECUTING", ")", "{", "// Inprogress.", "$", "progresssetup", "=", "array", "(", "'backupid'", "=>", "$", "backupid", ",", "'width'", "=>", "'100'", ")", ";", "$", "status", "=", "$", "this", "->", "render_from_template", "(", "'core/async_backup_progress'", ",", "$", "progresssetup", ")", ";", "}", "else", "if", "(", "$", "statuscode", "==", "backup", "::", "STATUS_FINISHED_ERR", ")", "{", "// Error.", "$", "icon", "=", "$", "this", "->", "output", "->", "render", "(", "new", "\\", "pix_icon", "(", "'i/delete'", ",", "get_string", "(", "'failed'", ",", "'backup'", ")", ")", ")", ";", "$", "status", "=", "\\", "html_writer", "::", "span", "(", "$", "icon", ",", "'action-icon'", ")", ";", "}", "else", "if", "(", "$", "statuscode", "==", "backup", "::", "STATUS_FINISHED_OK", ")", "{", "// Complete.", "$", "icon", "=", "$", "this", "->", "output", "->", "render", "(", "new", "\\", "pix_icon", "(", "'i/checked'", ",", "get_string", "(", "'successful'", ",", "'backup'", ")", ")", ")", ";", "$", "status", "=", "\\", "html_writer", "::", "span", "(", "$", "icon", ",", "'action-icon'", ")", ";", "}", "return", "$", "status", ";", "}" ]
Generate the status indicator markup for display in the backup restore file area UI. @param int $statuscode The status code of the backup. @param string $backupid The backup record id. @return string|boolean $status The status indicator for the operation.
[ "Generate", "the", "status", "indicator", "markup", "for", "display", "in", "the", "backup", "restore", "file", "area", "UI", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/ui/renderer.php#L550-L566
217,331
moodle/moodle
backup/util/ui/renderer.php
core_backup_renderer.restore_progress_viewer
public function restore_progress_viewer ($userid, $context) { $tablehead = array(get_string('course'), get_string('time'), get_string('status', 'backup')); $table = new html_table(); $table->attributes['class'] = 'backup-files-table generaltable'; $table->head = $tablehead; $tabledata = array(); // Get all in progress async restores for this user. $restores = \async_helper::get_async_restores($userid); // For each backup get, new item name, time restore created and progress. foreach ($restores as $restore) { $restorename = \async_helper::get_restore_name($context); $timecreated = $restore->timecreated; $status = $this->get_status_display($restore->status, $restore->backupid); $tablerow = array($restorename, userdate($timecreated), $status); $tabledata[] = $tablerow; } $table->data = $tabledata; $html = html_writer::table($table); return $html; }
php
public function restore_progress_viewer ($userid, $context) { $tablehead = array(get_string('course'), get_string('time'), get_string('status', 'backup')); $table = new html_table(); $table->attributes['class'] = 'backup-files-table generaltable'; $table->head = $tablehead; $tabledata = array(); // Get all in progress async restores for this user. $restores = \async_helper::get_async_restores($userid); // For each backup get, new item name, time restore created and progress. foreach ($restores as $restore) { $restorename = \async_helper::get_restore_name($context); $timecreated = $restore->timecreated; $status = $this->get_status_display($restore->status, $restore->backupid); $tablerow = array($restorename, userdate($timecreated), $status); $tabledata[] = $tablerow; } $table->data = $tabledata; $html = html_writer::table($table); return $html; }
[ "public", "function", "restore_progress_viewer", "(", "$", "userid", ",", "$", "context", ")", "{", "$", "tablehead", "=", "array", "(", "get_string", "(", "'course'", ")", ",", "get_string", "(", "'time'", ")", ",", "get_string", "(", "'status'", ",", "'backup'", ")", ")", ";", "$", "table", "=", "new", "html_table", "(", ")", ";", "$", "table", "->", "attributes", "[", "'class'", "]", "=", "'backup-files-table generaltable'", ";", "$", "table", "->", "head", "=", "$", "tablehead", ";", "$", "tabledata", "=", "array", "(", ")", ";", "// Get all in progress async restores for this user.", "$", "restores", "=", "\\", "async_helper", "::", "get_async_restores", "(", "$", "userid", ")", ";", "// For each backup get, new item name, time restore created and progress.", "foreach", "(", "$", "restores", "as", "$", "restore", ")", "{", "$", "restorename", "=", "\\", "async_helper", "::", "get_restore_name", "(", "$", "context", ")", ";", "$", "timecreated", "=", "$", "restore", "->", "timecreated", ";", "$", "status", "=", "$", "this", "->", "get_status_display", "(", "$", "restore", "->", "status", ",", "$", "restore", "->", "backupid", ")", ";", "$", "tablerow", "=", "array", "(", "$", "restorename", ",", "userdate", "(", "$", "timecreated", ")", ",", "$", "status", ")", ";", "$", "tabledata", "[", "]", "=", "$", "tablerow", ";", "}", "$", "table", "->", "data", "=", "$", "tabledata", ";", "$", "html", "=", "html_writer", "::", "table", "(", "$", "table", ")", ";", "return", "$", "html", ";", "}" ]
Get markup to render table for all of a users async in progress restores. @param int $userid The Moodle user id. @param \context $context The Moodle context for these restores. @return string $html The table HTML.
[ "Get", "markup", "to", "render", "table", "for", "all", "of", "a", "users", "async", "in", "progress", "restores", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/ui/renderer.php#L925-L951
217,332
moodle/moodle
tag/classes/collection.php
core_tag_collection.get_collections
public static function get_collections($onlysearchable = false) { global $DB; $cache = cache::make('core', 'tags'); if (($tagcolls = $cache->get('tag_coll')) === false) { // Retrieve records from DB and create a default one if it is not present. $tagcolls = $DB->get_records('tag_coll', null, 'isdefault DESC, sortorder, id'); if (empty($tagcolls)) { // When this method is called for the first time it automatically creates the default tag collection. $DB->insert_record('tag_coll', array('isdefault' => 1, 'sortorder' => 0)); $tagcolls = $DB->get_records('tag_coll'); } else { // Make sure sortorder is correct. $idx = 0; foreach ($tagcolls as $id => $tagcoll) { if ($tagcoll->sortorder != $idx) { $DB->update_record('tag_coll', array('sortorder' => $idx, 'id' => $id)); $tagcolls[$id]->sortorder = $idx; } $idx++; } } $cache->set('tag_coll', $tagcolls); } if ($onlysearchable) { $rv = array(); foreach ($tagcolls as $id => $tagcoll) { if ($tagcoll->searchable) { $rv[$id] = $tagcoll; } } return $rv; } return $tagcolls; }
php
public static function get_collections($onlysearchable = false) { global $DB; $cache = cache::make('core', 'tags'); if (($tagcolls = $cache->get('tag_coll')) === false) { // Retrieve records from DB and create a default one if it is not present. $tagcolls = $DB->get_records('tag_coll', null, 'isdefault DESC, sortorder, id'); if (empty($tagcolls)) { // When this method is called for the first time it automatically creates the default tag collection. $DB->insert_record('tag_coll', array('isdefault' => 1, 'sortorder' => 0)); $tagcolls = $DB->get_records('tag_coll'); } else { // Make sure sortorder is correct. $idx = 0; foreach ($tagcolls as $id => $tagcoll) { if ($tagcoll->sortorder != $idx) { $DB->update_record('tag_coll', array('sortorder' => $idx, 'id' => $id)); $tagcolls[$id]->sortorder = $idx; } $idx++; } } $cache->set('tag_coll', $tagcolls); } if ($onlysearchable) { $rv = array(); foreach ($tagcolls as $id => $tagcoll) { if ($tagcoll->searchable) { $rv[$id] = $tagcoll; } } return $rv; } return $tagcolls; }
[ "public", "static", "function", "get_collections", "(", "$", "onlysearchable", "=", "false", ")", "{", "global", "$", "DB", ";", "$", "cache", "=", "cache", "::", "make", "(", "'core'", ",", "'tags'", ")", ";", "if", "(", "(", "$", "tagcolls", "=", "$", "cache", "->", "get", "(", "'tag_coll'", ")", ")", "===", "false", ")", "{", "// Retrieve records from DB and create a default one if it is not present.", "$", "tagcolls", "=", "$", "DB", "->", "get_records", "(", "'tag_coll'", ",", "null", ",", "'isdefault DESC, sortorder, id'", ")", ";", "if", "(", "empty", "(", "$", "tagcolls", ")", ")", "{", "// When this method is called for the first time it automatically creates the default tag collection.", "$", "DB", "->", "insert_record", "(", "'tag_coll'", ",", "array", "(", "'isdefault'", "=>", "1", ",", "'sortorder'", "=>", "0", ")", ")", ";", "$", "tagcolls", "=", "$", "DB", "->", "get_records", "(", "'tag_coll'", ")", ";", "}", "else", "{", "// Make sure sortorder is correct.", "$", "idx", "=", "0", ";", "foreach", "(", "$", "tagcolls", "as", "$", "id", "=>", "$", "tagcoll", ")", "{", "if", "(", "$", "tagcoll", "->", "sortorder", "!=", "$", "idx", ")", "{", "$", "DB", "->", "update_record", "(", "'tag_coll'", ",", "array", "(", "'sortorder'", "=>", "$", "idx", ",", "'id'", "=>", "$", "id", ")", ")", ";", "$", "tagcolls", "[", "$", "id", "]", "->", "sortorder", "=", "$", "idx", ";", "}", "$", "idx", "++", ";", "}", "}", "$", "cache", "->", "set", "(", "'tag_coll'", ",", "$", "tagcolls", ")", ";", "}", "if", "(", "$", "onlysearchable", ")", "{", "$", "rv", "=", "array", "(", ")", ";", "foreach", "(", "$", "tagcolls", "as", "$", "id", "=>", "$", "tagcoll", ")", "{", "if", "(", "$", "tagcoll", "->", "searchable", ")", "{", "$", "rv", "[", "$", "id", "]", "=", "$", "tagcoll", ";", "}", "}", "return", "$", "rv", ";", "}", "return", "$", "tagcolls", ";", "}" ]
Returns the list of tag collections defined in the system. @param bool $onlysearchable only return collections that can be searched. @return array array of objects where each object has properties: id, name, isdefault, itemtypes, sortorder
[ "Returns", "the", "list", "of", "tag", "collections", "defined", "in", "the", "system", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/tag/classes/collection.php#L45-L78
217,333
moodle/moodle
tag/classes/collection.php
core_tag_collection.get_by_id
public static function get_by_id($tagcollid) { $tagcolls = self::get_collections(); if (array_key_exists($tagcollid, $tagcolls)) { return $tagcolls[$tagcollid]; } return null; }
php
public static function get_by_id($tagcollid) { $tagcolls = self::get_collections(); if (array_key_exists($tagcollid, $tagcolls)) { return $tagcolls[$tagcollid]; } return null; }
[ "public", "static", "function", "get_by_id", "(", "$", "tagcollid", ")", "{", "$", "tagcolls", "=", "self", "::", "get_collections", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "tagcollid", ",", "$", "tagcolls", ")", ")", "{", "return", "$", "tagcolls", "[", "$", "tagcollid", "]", ";", "}", "return", "null", ";", "}" ]
Returns the tag collection object @param int $tagcollid @return stdClass
[ "Returns", "the", "tag", "collection", "object" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/tag/classes/collection.php#L86-L92
217,334
moodle/moodle
tag/classes/collection.php
core_tag_collection.get_collections_menu
public static function get_collections_menu($unlockedonly = false, $onlysearchable = false, $selectalllabel = null) { $tagcolls = self::get_collections($onlysearchable); $options = array(); foreach ($tagcolls as $id => $tagcoll) { if (!$unlockedonly || empty($tagcoll->component)) { $options[$id] = self::display_name($tagcoll); } } if (count($options) > 1 && $selectalllabel) { $options = array(0 => $selectalllabel) + $options; } return $options; }
php
public static function get_collections_menu($unlockedonly = false, $onlysearchable = false, $selectalllabel = null) { $tagcolls = self::get_collections($onlysearchable); $options = array(); foreach ($tagcolls as $id => $tagcoll) { if (!$unlockedonly || empty($tagcoll->component)) { $options[$id] = self::display_name($tagcoll); } } if (count($options) > 1 && $selectalllabel) { $options = array(0 => $selectalllabel) + $options; } return $options; }
[ "public", "static", "function", "get_collections_menu", "(", "$", "unlockedonly", "=", "false", ",", "$", "onlysearchable", "=", "false", ",", "$", "selectalllabel", "=", "null", ")", "{", "$", "tagcolls", "=", "self", "::", "get_collections", "(", "$", "onlysearchable", ")", ";", "$", "options", "=", "array", "(", ")", ";", "foreach", "(", "$", "tagcolls", "as", "$", "id", "=>", "$", "tagcoll", ")", "{", "if", "(", "!", "$", "unlockedonly", "||", "empty", "(", "$", "tagcoll", "->", "component", ")", ")", "{", "$", "options", "[", "$", "id", "]", "=", "self", "::", "display_name", "(", "$", "tagcoll", ")", ";", "}", "}", "if", "(", "count", "(", "$", "options", ")", ">", "1", "&&", "$", "selectalllabel", ")", "{", "$", "options", "=", "array", "(", "0", "=>", "$", "selectalllabel", ")", "+", "$", "options", ";", "}", "return", "$", "options", ";", "}" ]
Returns the list of existing tag collections as id=>name @param bool $unlockedonly @param bool $onlysearchable @param string $selectalllabel @return array
[ "Returns", "the", "list", "of", "existing", "tag", "collections", "as", "id", "=", ">", "name" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/tag/classes/collection.php#L102-L115
217,335
moodle/moodle
tag/classes/collection.php
core_tag_collection.display_name
public static function display_name($record) { $syscontext = context_system::instance(); if (!empty($record->component)) { $identifier = 'tagcollection_' . clean_param($record->name, PARAM_STRINGID); $component = $record->component; if ($component === 'core') { $component = 'tag'; } return get_string($identifier, $component); } if (!empty($record->name)) { return format_string($record->name, true, array('context' => $syscontext)); } else if ($record->isdefault) { return get_string('defautltagcoll', 'tag'); } else { return $record->id; } }
php
public static function display_name($record) { $syscontext = context_system::instance(); if (!empty($record->component)) { $identifier = 'tagcollection_' . clean_param($record->name, PARAM_STRINGID); $component = $record->component; if ($component === 'core') { $component = 'tag'; } return get_string($identifier, $component); } if (!empty($record->name)) { return format_string($record->name, true, array('context' => $syscontext)); } else if ($record->isdefault) { return get_string('defautltagcoll', 'tag'); } else { return $record->id; } }
[ "public", "static", "function", "display_name", "(", "$", "record", ")", "{", "$", "syscontext", "=", "context_system", "::", "instance", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "record", "->", "component", ")", ")", "{", "$", "identifier", "=", "'tagcollection_'", ".", "clean_param", "(", "$", "record", "->", "name", ",", "PARAM_STRINGID", ")", ";", "$", "component", "=", "$", "record", "->", "component", ";", "if", "(", "$", "component", "===", "'core'", ")", "{", "$", "component", "=", "'tag'", ";", "}", "return", "get_string", "(", "$", "identifier", ",", "$", "component", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "record", "->", "name", ")", ")", "{", "return", "format_string", "(", "$", "record", "->", "name", ",", "true", ",", "array", "(", "'context'", "=>", "$", "syscontext", ")", ")", ";", "}", "else", "if", "(", "$", "record", "->", "isdefault", ")", "{", "return", "get_string", "(", "'defautltagcoll'", ",", "'tag'", ")", ";", "}", "else", "{", "return", "$", "record", "->", "id", ";", "}", "}" ]
Returns formatted name of the tag collection @param stdClass $record record from DB table tag_coll @return string
[ "Returns", "formatted", "name", "of", "the", "tag", "collection" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/tag/classes/collection.php#L134-L152
217,336
moodle/moodle
tag/classes/collection.php
core_tag_collection.get_areas
public static function get_areas($tagcollid) { $allitemtypes = core_tag_area::get_areas($tagcollid, true); $itemtypes = array(); foreach ($allitemtypes as $itemtype => $it) { foreach ($it as $component => $v) { $itemtypes[$v->id] = $v; } } return $itemtypes; }
php
public static function get_areas($tagcollid) { $allitemtypes = core_tag_area::get_areas($tagcollid, true); $itemtypes = array(); foreach ($allitemtypes as $itemtype => $it) { foreach ($it as $component => $v) { $itemtypes[$v->id] = $v; } } return $itemtypes; }
[ "public", "static", "function", "get_areas", "(", "$", "tagcollid", ")", "{", "$", "allitemtypes", "=", "core_tag_area", "::", "get_areas", "(", "$", "tagcollid", ",", "true", ")", ";", "$", "itemtypes", "=", "array", "(", ")", ";", "foreach", "(", "$", "allitemtypes", "as", "$", "itemtype", "=>", "$", "it", ")", "{", "foreach", "(", "$", "it", "as", "$", "component", "=>", "$", "v", ")", "{", "$", "itemtypes", "[", "$", "v", "->", "id", "]", "=", "$", "v", ";", "}", "}", "return", "$", "itemtypes", ";", "}" ]
Returns all tag areas in the given tag collection @param int $tagcollid @return array
[ "Returns", "all", "tag", "areas", "in", "the", "given", "tag", "collection" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/tag/classes/collection.php#L160-L169
217,337
moodle/moodle
tag/classes/collection.php
core_tag_collection.create
public static function create($data) { global $DB; $data = (object)$data; $tagcolls = self::get_collections(); $tagcoll = (object)array( 'name' => $data->name, 'isdefault' => 0, 'component' => !empty($data->component) ? $data->component : null, 'sortorder' => count($tagcolls), 'searchable' => isset($data->searchable) ? (int)(bool)$data->searchable : 1, 'customurl' => !empty($data->customurl) ? $data->customurl : null, ); $tagcoll->id = $DB->insert_record('tag_coll', $tagcoll); // Reset cache. cache::make('core', 'tags')->delete('tag_coll'); \core\event\tag_collection_created::create_from_record($tagcoll)->trigger(); return $tagcoll; }
php
public static function create($data) { global $DB; $data = (object)$data; $tagcolls = self::get_collections(); $tagcoll = (object)array( 'name' => $data->name, 'isdefault' => 0, 'component' => !empty($data->component) ? $data->component : null, 'sortorder' => count($tagcolls), 'searchable' => isset($data->searchable) ? (int)(bool)$data->searchable : 1, 'customurl' => !empty($data->customurl) ? $data->customurl : null, ); $tagcoll->id = $DB->insert_record('tag_coll', $tagcoll); // Reset cache. cache::make('core', 'tags')->delete('tag_coll'); \core\event\tag_collection_created::create_from_record($tagcoll)->trigger(); return $tagcoll; }
[ "public", "static", "function", "create", "(", "$", "data", ")", "{", "global", "$", "DB", ";", "$", "data", "=", "(", "object", ")", "$", "data", ";", "$", "tagcolls", "=", "self", "::", "get_collections", "(", ")", ";", "$", "tagcoll", "=", "(", "object", ")", "array", "(", "'name'", "=>", "$", "data", "->", "name", ",", "'isdefault'", "=>", "0", ",", "'component'", "=>", "!", "empty", "(", "$", "data", "->", "component", ")", "?", "$", "data", "->", "component", ":", "null", ",", "'sortorder'", "=>", "count", "(", "$", "tagcolls", ")", ",", "'searchable'", "=>", "isset", "(", "$", "data", "->", "searchable", ")", "?", "(", "int", ")", "(", "bool", ")", "$", "data", "->", "searchable", ":", "1", ",", "'customurl'", "=>", "!", "empty", "(", "$", "data", "->", "customurl", ")", "?", "$", "data", "->", "customurl", ":", "null", ",", ")", ";", "$", "tagcoll", "->", "id", "=", "$", "DB", "->", "insert_record", "(", "'tag_coll'", ",", "$", "tagcoll", ")", ";", "// Reset cache.", "cache", "::", "make", "(", "'core'", ",", "'tags'", ")", "->", "delete", "(", "'tag_coll'", ")", ";", "\\", "core", "\\", "event", "\\", "tag_collection_created", "::", "create_from_record", "(", "$", "tagcoll", ")", "->", "trigger", "(", ")", ";", "return", "$", "tagcoll", ";", "}" ]
Creates a new tag collection @param stdClass $data data from form core_tag_collection_form @return int|false id of created tag collection or false if failed
[ "Creates", "a", "new", "tag", "collection" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/tag/classes/collection.php#L194-L213
217,338
moodle/moodle
tag/classes/collection.php
core_tag_collection.update
public static function update($tagcoll, $data) { global $DB; $defaulttagcollid = self::get_default(); $allowedfields = array('name', 'searchable', 'customurl'); if ($tagcoll->id == $defaulttagcollid) { $allowedfields = array('name'); } $updatedata = array(); $data = (array)$data; foreach ($allowedfields as $key) { if (array_key_exists($key, $data) && $data[$key] !== $tagcoll->$key) { $updatedata[$key] = $data[$key]; } } if (!$updatedata) { // Nothing to update. return false; } if (isset($updatedata['searchable'])) { $updatedata['searchable'] = (int)(bool)$updatedata['searchable']; } foreach ($updatedata as $key => $value) { $tagcoll->$key = $value; } $updatedata['id'] = $tagcoll->id; $DB->update_record('tag_coll', $updatedata); // Reset cache. cache::make('core', 'tags')->delete('tag_coll'); \core\event\tag_collection_updated::create_from_record($tagcoll)->trigger(); return true; }
php
public static function update($tagcoll, $data) { global $DB; $defaulttagcollid = self::get_default(); $allowedfields = array('name', 'searchable', 'customurl'); if ($tagcoll->id == $defaulttagcollid) { $allowedfields = array('name'); } $updatedata = array(); $data = (array)$data; foreach ($allowedfields as $key) { if (array_key_exists($key, $data) && $data[$key] !== $tagcoll->$key) { $updatedata[$key] = $data[$key]; } } if (!$updatedata) { // Nothing to update. return false; } if (isset($updatedata['searchable'])) { $updatedata['searchable'] = (int)(bool)$updatedata['searchable']; } foreach ($updatedata as $key => $value) { $tagcoll->$key = $value; } $updatedata['id'] = $tagcoll->id; $DB->update_record('tag_coll', $updatedata); // Reset cache. cache::make('core', 'tags')->delete('tag_coll'); \core\event\tag_collection_updated::create_from_record($tagcoll)->trigger(); return true; }
[ "public", "static", "function", "update", "(", "$", "tagcoll", ",", "$", "data", ")", "{", "global", "$", "DB", ";", "$", "defaulttagcollid", "=", "self", "::", "get_default", "(", ")", ";", "$", "allowedfields", "=", "array", "(", "'name'", ",", "'searchable'", ",", "'customurl'", ")", ";", "if", "(", "$", "tagcoll", "->", "id", "==", "$", "defaulttagcollid", ")", "{", "$", "allowedfields", "=", "array", "(", "'name'", ")", ";", "}", "$", "updatedata", "=", "array", "(", ")", ";", "$", "data", "=", "(", "array", ")", "$", "data", ";", "foreach", "(", "$", "allowedfields", "as", "$", "key", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "data", ")", "&&", "$", "data", "[", "$", "key", "]", "!==", "$", "tagcoll", "->", "$", "key", ")", "{", "$", "updatedata", "[", "$", "key", "]", "=", "$", "data", "[", "$", "key", "]", ";", "}", "}", "if", "(", "!", "$", "updatedata", ")", "{", "// Nothing to update.", "return", "false", ";", "}", "if", "(", "isset", "(", "$", "updatedata", "[", "'searchable'", "]", ")", ")", "{", "$", "updatedata", "[", "'searchable'", "]", "=", "(", "int", ")", "(", "bool", ")", "$", "updatedata", "[", "'searchable'", "]", ";", "}", "foreach", "(", "$", "updatedata", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "tagcoll", "->", "$", "key", "=", "$", "value", ";", "}", "$", "updatedata", "[", "'id'", "]", "=", "$", "tagcoll", "->", "id", ";", "$", "DB", "->", "update_record", "(", "'tag_coll'", ",", "$", "updatedata", ")", ";", "// Reset cache.", "cache", "::", "make", "(", "'core'", ",", "'tags'", ")", "->", "delete", "(", "'tag_coll'", ")", ";", "\\", "core", "\\", "event", "\\", "tag_collection_updated", "::", "create_from_record", "(", "$", "tagcoll", ")", "->", "trigger", "(", ")", ";", "return", "true", ";", "}" ]
Updates the tag collection information @param stdClass $tagcoll existing record in DB table tag_coll @param stdClass $data data to update @return bool wether the record was updated
[ "Updates", "the", "tag", "collection", "information" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/tag/classes/collection.php#L222-L258
217,339
moodle/moodle
tag/classes/collection.php
core_tag_collection.delete
public static function delete($tagcoll) { global $DB, $CFG; $defaulttagcollid = self::get_default(); if ($tagcoll->id == $defaulttagcollid) { return false; } // Move all tags from this tag collection to the default one. $allitemtypes = core_tag_area::get_areas($tagcoll->id); foreach ($allitemtypes as $it) { foreach ($it as $v) { core_tag_area::update($v, array('tagcollid' => $defaulttagcollid)); } } // Delete tags from this tag_coll. core_tag_tag::delete_tags($DB->get_fieldset_select('tag', 'id', 'tagcollid = ?', array($tagcoll->id))); // Delete the tag collection. $DB->delete_records('tag_coll', array('id' => $tagcoll->id)); // Reset cache. cache::make('core', 'tags')->delete('tag_coll'); \core\event\tag_collection_deleted::create_from_record($tagcoll)->trigger(); return true; }
php
public static function delete($tagcoll) { global $DB, $CFG; $defaulttagcollid = self::get_default(); if ($tagcoll->id == $defaulttagcollid) { return false; } // Move all tags from this tag collection to the default one. $allitemtypes = core_tag_area::get_areas($tagcoll->id); foreach ($allitemtypes as $it) { foreach ($it as $v) { core_tag_area::update($v, array('tagcollid' => $defaulttagcollid)); } } // Delete tags from this tag_coll. core_tag_tag::delete_tags($DB->get_fieldset_select('tag', 'id', 'tagcollid = ?', array($tagcoll->id))); // Delete the tag collection. $DB->delete_records('tag_coll', array('id' => $tagcoll->id)); // Reset cache. cache::make('core', 'tags')->delete('tag_coll'); \core\event\tag_collection_deleted::create_from_record($tagcoll)->trigger(); return true; }
[ "public", "static", "function", "delete", "(", "$", "tagcoll", ")", "{", "global", "$", "DB", ",", "$", "CFG", ";", "$", "defaulttagcollid", "=", "self", "::", "get_default", "(", ")", ";", "if", "(", "$", "tagcoll", "->", "id", "==", "$", "defaulttagcollid", ")", "{", "return", "false", ";", "}", "// Move all tags from this tag collection to the default one.", "$", "allitemtypes", "=", "core_tag_area", "::", "get_areas", "(", "$", "tagcoll", "->", "id", ")", ";", "foreach", "(", "$", "allitemtypes", "as", "$", "it", ")", "{", "foreach", "(", "$", "it", "as", "$", "v", ")", "{", "core_tag_area", "::", "update", "(", "$", "v", ",", "array", "(", "'tagcollid'", "=>", "$", "defaulttagcollid", ")", ")", ";", "}", "}", "// Delete tags from this tag_coll.", "core_tag_tag", "::", "delete_tags", "(", "$", "DB", "->", "get_fieldset_select", "(", "'tag'", ",", "'id'", ",", "'tagcollid = ?'", ",", "array", "(", "$", "tagcoll", "->", "id", ")", ")", ")", ";", "// Delete the tag collection.", "$", "DB", "->", "delete_records", "(", "'tag_coll'", ",", "array", "(", "'id'", "=>", "$", "tagcoll", "->", "id", ")", ")", ";", "// Reset cache.", "cache", "::", "make", "(", "'core'", ",", "'tags'", ")", "->", "delete", "(", "'tag_coll'", ")", ";", "\\", "core", "\\", "event", "\\", "tag_collection_deleted", "::", "create_from_record", "(", "$", "tagcoll", ")", "->", "trigger", "(", ")", ";", "return", "true", ";", "}" ]
Deletes a custom tag collection @param stdClass $tagcoll existing record in DB table tag_coll @return bool wether the tag collection was deleted
[ "Deletes", "a", "custom", "tag", "collection" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/tag/classes/collection.php#L266-L294
217,340
moodle/moodle
tag/classes/collection.php
core_tag_collection.change_sortorder
public static function change_sortorder($tagcoll, $direction) { global $DB; if ($direction != -1 && $direction != 1) { throw new coding_exception('Second argument in tag_coll_change_sortorder() can be only 1 or -1'); } $tagcolls = self::get_collections(); $keys = array_keys($tagcolls); $idx = array_search($tagcoll->id, $keys); if ($idx === false || $idx == 0 || $idx + $direction < 1 || $idx + $direction >= count($tagcolls)) { return false; } $otherid = $keys[$idx + $direction]; $DB->update_record('tag_coll', array('id' => $tagcoll->id, 'sortorder' => $idx + $direction)); $DB->update_record('tag_coll', array('id' => $otherid, 'sortorder' => $idx)); // Reset cache. cache::make('core', 'tags')->delete('tag_coll'); return true; }
php
public static function change_sortorder($tagcoll, $direction) { global $DB; if ($direction != -1 && $direction != 1) { throw new coding_exception('Second argument in tag_coll_change_sortorder() can be only 1 or -1'); } $tagcolls = self::get_collections(); $keys = array_keys($tagcolls); $idx = array_search($tagcoll->id, $keys); if ($idx === false || $idx == 0 || $idx + $direction < 1 || $idx + $direction >= count($tagcolls)) { return false; } $otherid = $keys[$idx + $direction]; $DB->update_record('tag_coll', array('id' => $tagcoll->id, 'sortorder' => $idx + $direction)); $DB->update_record('tag_coll', array('id' => $otherid, 'sortorder' => $idx)); // Reset cache. cache::make('core', 'tags')->delete('tag_coll'); return true; }
[ "public", "static", "function", "change_sortorder", "(", "$", "tagcoll", ",", "$", "direction", ")", "{", "global", "$", "DB", ";", "if", "(", "$", "direction", "!=", "-", "1", "&&", "$", "direction", "!=", "1", ")", "{", "throw", "new", "coding_exception", "(", "'Second argument in tag_coll_change_sortorder() can be only 1 or -1'", ")", ";", "}", "$", "tagcolls", "=", "self", "::", "get_collections", "(", ")", ";", "$", "keys", "=", "array_keys", "(", "$", "tagcolls", ")", ";", "$", "idx", "=", "array_search", "(", "$", "tagcoll", "->", "id", ",", "$", "keys", ")", ";", "if", "(", "$", "idx", "===", "false", "||", "$", "idx", "==", "0", "||", "$", "idx", "+", "$", "direction", "<", "1", "||", "$", "idx", "+", "$", "direction", ">=", "count", "(", "$", "tagcolls", ")", ")", "{", "return", "false", ";", "}", "$", "otherid", "=", "$", "keys", "[", "$", "idx", "+", "$", "direction", "]", ";", "$", "DB", "->", "update_record", "(", "'tag_coll'", ",", "array", "(", "'id'", "=>", "$", "tagcoll", "->", "id", ",", "'sortorder'", "=>", "$", "idx", "+", "$", "direction", ")", ")", ";", "$", "DB", "->", "update_record", "(", "'tag_coll'", ",", "array", "(", "'id'", "=>", "$", "otherid", ",", "'sortorder'", "=>", "$", "idx", ")", ")", ";", "// Reset cache.", "cache", "::", "make", "(", "'core'", ",", "'tags'", ")", "->", "delete", "(", "'tag_coll'", ")", ";", "return", "true", ";", "}" ]
Moves the tag collection in the list one position up or down @param stdClass $tagcoll existing record in DB table tag_coll @param int $direction move direction: +1 or -1 @return bool
[ "Moves", "the", "tag", "collection", "in", "the", "list", "one", "position", "up", "or", "down" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/tag/classes/collection.php#L303-L320
217,341
moodle/moodle
tag/classes/collection.php
core_tag_collection.cleanup_unused_tags
public static function cleanup_unused_tags($collections = null) { global $DB, $CFG; $params = array(); $sql = "SELECT tg.id FROM {tag} tg LEFT OUTER JOIN {tag_instance} ti ON ti.tagid = tg.id WHERE ti.id IS NULL AND tg.isstandard = 0"; if ($collections) { list($sqlcoll, $params) = $DB->get_in_or_equal($collections, SQL_PARAMS_NAMED); $sql .= " AND tg.tagcollid " . $sqlcoll; } if ($unusedtags = $DB->get_fieldset_sql($sql, $params)) { core_tag_tag::delete_tags($unusedtags); } }
php
public static function cleanup_unused_tags($collections = null) { global $DB, $CFG; $params = array(); $sql = "SELECT tg.id FROM {tag} tg LEFT OUTER JOIN {tag_instance} ti ON ti.tagid = tg.id WHERE ti.id IS NULL AND tg.isstandard = 0"; if ($collections) { list($sqlcoll, $params) = $DB->get_in_or_equal($collections, SQL_PARAMS_NAMED); $sql .= " AND tg.tagcollid " . $sqlcoll; } if ($unusedtags = $DB->get_fieldset_sql($sql, $params)) { core_tag_tag::delete_tags($unusedtags); } }
[ "public", "static", "function", "cleanup_unused_tags", "(", "$", "collections", "=", "null", ")", "{", "global", "$", "DB", ",", "$", "CFG", ";", "$", "params", "=", "array", "(", ")", ";", "$", "sql", "=", "\"SELECT tg.id FROM {tag} tg LEFT OUTER JOIN {tag_instance} ti ON ti.tagid = tg.id\n WHERE ti.id IS NULL AND tg.isstandard = 0\"", ";", "if", "(", "$", "collections", ")", "{", "list", "(", "$", "sqlcoll", ",", "$", "params", ")", "=", "$", "DB", "->", "get_in_or_equal", "(", "$", "collections", ",", "SQL_PARAMS_NAMED", ")", ";", "$", "sql", ".=", "\" AND tg.tagcollid \"", ".", "$", "sqlcoll", ";", "}", "if", "(", "$", "unusedtags", "=", "$", "DB", "->", "get_fieldset_sql", "(", "$", "sql", ",", "$", "params", ")", ")", "{", "core_tag_tag", "::", "delete_tags", "(", "$", "unusedtags", ")", ";", "}", "}" ]
Permanently deletes all non-standard tags that no longer have any instances pointing to them @param array $collections optional list of tag collections ids to cleanup
[ "Permanently", "deletes", "all", "non", "-", "standard", "tags", "that", "no", "longer", "have", "any", "instances", "pointing", "to", "them" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/tag/classes/collection.php#L327-L340
217,342
moodle/moodle
tag/classes/collection.php
core_tag_collection.get_tag_cloud
public static function get_tag_cloud($tagcollid, $isstandard = false, $limit = 150, $sort = 'name', $search = '', $fromctx = 0, $ctx = 0, $rec = 1) { global $DB; $fromclause = 'FROM {tag_instance} ti JOIN {tag} tg ON tg.id = ti.tagid'; $whereclause = 'WHERE ti.itemtype <> \'tag\''; list($sql, $params) = $DB->get_in_or_equal($tagcollid ? array($tagcollid) : array_keys(self::get_collections(true))); $whereclause .= ' AND tg.tagcollid ' . $sql; if ($isstandard) { $whereclause .= ' AND tg.isstandard = 1'; } $context = $ctx ? context::instance_by_id($ctx) : context_system::instance(); if ($rec && $context->contextlevel != CONTEXT_SYSTEM) { $fromclause .= ' JOIN {context} ctx ON ctx.id = ti.contextid '; $whereclause .= ' AND ctx.path LIKE ?'; $params[] = $context->path . '%'; } else if (!$rec) { $whereclause .= ' AND ti.contextid = ?'; $params[] = $context->id; } if (strval($search) !== '') { $whereclause .= ' AND tg.name LIKE ?'; $params[] = '%' . core_text::strtolower($search) . '%'; } $tagsincloud = $DB->get_records_sql( "SELECT tg.id, tg.rawname, tg.name, tg.isstandard, COUNT(ti.id) AS count, tg.flag, tg.tagcollid $fromclause $whereclause GROUP BY tg.id, tg.rawname, tg.name, tg.flag, tg.isstandard, tg.tagcollid ORDER BY count DESC, tg.name ASC", $params, 0, $limit); $tagscount = count($tagsincloud); if ($tagscount == $limit) { $tagscount = $DB->get_field_sql("SELECT COUNT(DISTINCT tg.id) $fromclause $whereclause", $params); } self::$cloudsortfield = $sort; usort($tagsincloud, "self::cloud_sort"); return new core_tag\output\tagcloud($tagsincloud, $tagscount, $fromctx, $ctx, $rec); }
php
public static function get_tag_cloud($tagcollid, $isstandard = false, $limit = 150, $sort = 'name', $search = '', $fromctx = 0, $ctx = 0, $rec = 1) { global $DB; $fromclause = 'FROM {tag_instance} ti JOIN {tag} tg ON tg.id = ti.tagid'; $whereclause = 'WHERE ti.itemtype <> \'tag\''; list($sql, $params) = $DB->get_in_or_equal($tagcollid ? array($tagcollid) : array_keys(self::get_collections(true))); $whereclause .= ' AND tg.tagcollid ' . $sql; if ($isstandard) { $whereclause .= ' AND tg.isstandard = 1'; } $context = $ctx ? context::instance_by_id($ctx) : context_system::instance(); if ($rec && $context->contextlevel != CONTEXT_SYSTEM) { $fromclause .= ' JOIN {context} ctx ON ctx.id = ti.contextid '; $whereclause .= ' AND ctx.path LIKE ?'; $params[] = $context->path . '%'; } else if (!$rec) { $whereclause .= ' AND ti.contextid = ?'; $params[] = $context->id; } if (strval($search) !== '') { $whereclause .= ' AND tg.name LIKE ?'; $params[] = '%' . core_text::strtolower($search) . '%'; } $tagsincloud = $DB->get_records_sql( "SELECT tg.id, tg.rawname, tg.name, tg.isstandard, COUNT(ti.id) AS count, tg.flag, tg.tagcollid $fromclause $whereclause GROUP BY tg.id, tg.rawname, tg.name, tg.flag, tg.isstandard, tg.tagcollid ORDER BY count DESC, tg.name ASC", $params, 0, $limit); $tagscount = count($tagsincloud); if ($tagscount == $limit) { $tagscount = $DB->get_field_sql("SELECT COUNT(DISTINCT tg.id) $fromclause $whereclause", $params); } self::$cloudsortfield = $sort; usort($tagsincloud, "self::cloud_sort"); return new core_tag\output\tagcloud($tagsincloud, $tagscount, $fromctx, $ctx, $rec); }
[ "public", "static", "function", "get_tag_cloud", "(", "$", "tagcollid", ",", "$", "isstandard", "=", "false", ",", "$", "limit", "=", "150", ",", "$", "sort", "=", "'name'", ",", "$", "search", "=", "''", ",", "$", "fromctx", "=", "0", ",", "$", "ctx", "=", "0", ",", "$", "rec", "=", "1", ")", "{", "global", "$", "DB", ";", "$", "fromclause", "=", "'FROM {tag_instance} ti JOIN {tag} tg ON tg.id = ti.tagid'", ";", "$", "whereclause", "=", "'WHERE ti.itemtype <> \\'tag\\''", ";", "list", "(", "$", "sql", ",", "$", "params", ")", "=", "$", "DB", "->", "get_in_or_equal", "(", "$", "tagcollid", "?", "array", "(", "$", "tagcollid", ")", ":", "array_keys", "(", "self", "::", "get_collections", "(", "true", ")", ")", ")", ";", "$", "whereclause", ".=", "' AND tg.tagcollid '", ".", "$", "sql", ";", "if", "(", "$", "isstandard", ")", "{", "$", "whereclause", ".=", "' AND tg.isstandard = 1'", ";", "}", "$", "context", "=", "$", "ctx", "?", "context", "::", "instance_by_id", "(", "$", "ctx", ")", ":", "context_system", "::", "instance", "(", ")", ";", "if", "(", "$", "rec", "&&", "$", "context", "->", "contextlevel", "!=", "CONTEXT_SYSTEM", ")", "{", "$", "fromclause", ".=", "' JOIN {context} ctx ON ctx.id = ti.contextid '", ";", "$", "whereclause", ".=", "' AND ctx.path LIKE ?'", ";", "$", "params", "[", "]", "=", "$", "context", "->", "path", ".", "'%'", ";", "}", "else", "if", "(", "!", "$", "rec", ")", "{", "$", "whereclause", ".=", "' AND ti.contextid = ?'", ";", "$", "params", "[", "]", "=", "$", "context", "->", "id", ";", "}", "if", "(", "strval", "(", "$", "search", ")", "!==", "''", ")", "{", "$", "whereclause", ".=", "' AND tg.name LIKE ?'", ";", "$", "params", "[", "]", "=", "'%'", ".", "core_text", "::", "strtolower", "(", "$", "search", ")", ".", "'%'", ";", "}", "$", "tagsincloud", "=", "$", "DB", "->", "get_records_sql", "(", "\"SELECT tg.id, tg.rawname, tg.name, tg.isstandard, COUNT(ti.id) AS count, tg.flag, tg.tagcollid\n $fromclause\n $whereclause\n GROUP BY tg.id, tg.rawname, tg.name, tg.flag, tg.isstandard, tg.tagcollid\n ORDER BY count DESC, tg.name ASC\"", ",", "$", "params", ",", "0", ",", "$", "limit", ")", ";", "$", "tagscount", "=", "count", "(", "$", "tagsincloud", ")", ";", "if", "(", "$", "tagscount", "==", "$", "limit", ")", "{", "$", "tagscount", "=", "$", "DB", "->", "get_field_sql", "(", "\"SELECT COUNT(DISTINCT tg.id) $fromclause $whereclause\"", ",", "$", "params", ")", ";", "}", "self", "::", "$", "cloudsortfield", "=", "$", "sort", ";", "usort", "(", "$", "tagsincloud", ",", "\"self::cloud_sort\"", ")", ";", "return", "new", "core_tag", "\\", "output", "\\", "tagcloud", "(", "$", "tagsincloud", ",", "$", "tagscount", ",", "$", "fromctx", ",", "$", "ctx", ",", "$", "rec", ")", ";", "}" ]
Returns the list of tags with number of items tagged @param int $tagcollid @param null|bool $isstandard return only standard tags @param int $limit maximum number of tags to retrieve, tags are sorted by the instance count descending here regardless of $sort parameter @param string $sort sort order for display, default 'name' - tags will be sorted after they are retrieved @param string $search search string @param int $fromctx context id where this tag cloud is displayed @param int $ctx only retrieve tag instances in this context @param int $rec retrieve tag instances in the $ctx context and it's children (default 1) @return \core_tag\output\tagcloud
[ "Returns", "the", "list", "of", "tags", "with", "number", "of", "items", "tagged" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/tag/classes/collection.php#L356-L398
217,343
moodle/moodle
tag/classes/collection.php
core_tag_collection.cloud_sort
public static function cloud_sort($a, $b) { $tagsort = self::$cloudsortfield ?: 'name'; if (is_numeric($a->$tagsort)) { return ($a->$tagsort == $b->$tagsort) ? 0 : ($a->$tagsort > $b->$tagsort) ? 1 : -1; } else if (is_string($a->$tagsort)) { return strcmp($a->$tagsort, $b->$tagsort); } else { return 0; } }
php
public static function cloud_sort($a, $b) { $tagsort = self::$cloudsortfield ?: 'name'; if (is_numeric($a->$tagsort)) { return ($a->$tagsort == $b->$tagsort) ? 0 : ($a->$tagsort > $b->$tagsort) ? 1 : -1; } else if (is_string($a->$tagsort)) { return strcmp($a->$tagsort, $b->$tagsort); } else { return 0; } }
[ "public", "static", "function", "cloud_sort", "(", "$", "a", ",", "$", "b", ")", "{", "$", "tagsort", "=", "self", "::", "$", "cloudsortfield", "?", ":", "'name'", ";", "if", "(", "is_numeric", "(", "$", "a", "->", "$", "tagsort", ")", ")", "{", "return", "(", "$", "a", "->", "$", "tagsort", "==", "$", "b", "->", "$", "tagsort", ")", "?", "0", ":", "(", "$", "a", "->", "$", "tagsort", ">", "$", "b", "->", "$", "tagsort", ")", "?", "1", ":", "-", "1", ";", "}", "else", "if", "(", "is_string", "(", "$", "a", "->", "$", "tagsort", ")", ")", "{", "return", "strcmp", "(", "$", "a", "->", "$", "tagsort", ",", "$", "b", "->", "$", "tagsort", ")", ";", "}", "else", "{", "return", "0", ";", "}", "}" ]
This function is used to sort the tags in the cloud. @param string $a Tag name to compare against $b @param string $b Tag name to compare against $a @return int The result of the comparison/validation 1, 0 or -1
[ "This", "function", "is", "used", "to", "sort", "the", "tags", "in", "the", "cloud", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/tag/classes/collection.php#L407-L417
217,344
moodle/moodle
privacy/classes/local/request/helper.php
helper.export_data_for_null_provider
public static function export_data_for_null_provider(approved_contextlist $contextlist) { $user = $contextlist->get_user(); foreach ($contextlist as $context) { $data = static::get_context_data($context, $user); static::export_context_files($context, $user); writer::with_context($context)->export_data([], $data); } }
php
public static function export_data_for_null_provider(approved_contextlist $contextlist) { $user = $contextlist->get_user(); foreach ($contextlist as $context) { $data = static::get_context_data($context, $user); static::export_context_files($context, $user); writer::with_context($context)->export_data([], $data); } }
[ "public", "static", "function", "export_data_for_null_provider", "(", "approved_contextlist", "$", "contextlist", ")", "{", "$", "user", "=", "$", "contextlist", "->", "get_user", "(", ")", ";", "foreach", "(", "$", "contextlist", "as", "$", "context", ")", "{", "$", "data", "=", "static", "::", "get_context_data", "(", "$", "context", ",", "$", "user", ")", ";", "static", "::", "export_context_files", "(", "$", "context", ",", "$", "user", ")", ";", "writer", "::", "with_context", "(", "$", "context", ")", "->", "export_data", "(", "[", "]", ",", "$", "data", ")", ";", "}", "}" ]
Handle export of standard data for a plugin which implements the null provider and does not normally store data of its own. This is used in cases such as activities like mod_resource, which do not store their own data, but may still have data on them (like Activity Completion). Any context provided in a contextlist should have base data exported as a minimum. @param approved_contextlist $contextlist The approved contexts to export information for.
[ "Handle", "export", "of", "standard", "data", "for", "a", "plugin", "which", "implements", "the", "null", "provider", "and", "does", "not", "normally", "store", "data", "of", "its", "own", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/privacy/classes/local/request/helper.php#L86-L94
217,345
moodle/moodle
privacy/classes/local/request/helper.php
helper.get_context_data
public static function get_context_data(\context $context, \stdClass $user) : \stdClass { global $DB; $basedata = (object) []; if ($context instanceof \context_module) { return static::get_context_module_data($context, $user); } if ($context instanceof \context_block) { return static::get_context_block_data($context, $user); } return $basedata; }
php
public static function get_context_data(\context $context, \stdClass $user) : \stdClass { global $DB; $basedata = (object) []; if ($context instanceof \context_module) { return static::get_context_module_data($context, $user); } if ($context instanceof \context_block) { return static::get_context_block_data($context, $user); } return $basedata; }
[ "public", "static", "function", "get_context_data", "(", "\\", "context", "$", "context", ",", "\\", "stdClass", "$", "user", ")", ":", "\\", "stdClass", "{", "global", "$", "DB", ";", "$", "basedata", "=", "(", "object", ")", "[", "]", ";", "if", "(", "$", "context", "instanceof", "\\", "context_module", ")", "{", "return", "static", "::", "get_context_module_data", "(", "$", "context", ",", "$", "user", ")", ";", "}", "if", "(", "$", "context", "instanceof", "\\", "context_block", ")", "{", "return", "static", "::", "get_context_block_data", "(", "$", "context", ",", "$", "user", ")", ";", "}", "return", "$", "basedata", ";", "}" ]
Get all general data for this context. @param \context $context The context to retrieve data for. @param \stdClass $user The user being written. @return \stdClass
[ "Get", "all", "general", "data", "for", "this", "context", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/privacy/classes/local/request/helper.php#L130-L142
217,346
moodle/moodle
privacy/classes/local/request/helper.php
helper.export_context_files
public static function export_context_files(\context $context, \stdClass $user) { if ($context instanceof \context_module) { return static::export_context_module_files($context, $user); } }
php
public static function export_context_files(\context $context, \stdClass $user) { if ($context instanceof \context_module) { return static::export_context_module_files($context, $user); } }
[ "public", "static", "function", "export_context_files", "(", "\\", "context", "$", "context", ",", "\\", "stdClass", "$", "user", ")", "{", "if", "(", "$", "context", "instanceof", "\\", "context_module", ")", "{", "return", "static", "::", "export_context_module_files", "(", "$", "context", ",", "$", "user", ")", ";", "}", "}" ]
Export all files for this context. @param \context $context The context to export files for. @param \stdClass $user The user being written. @return \stdClass
[ "Export", "all", "files", "for", "this", "context", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/privacy/classes/local/request/helper.php#L151-L155
217,347
moodle/moodle
privacy/classes/local/request/helper.php
helper.get_context_block_data
protected static function get_context_block_data(\context_block $context, \stdClass $user) : \stdClass { global $DB; $block = $DB->get_record('block_instances', ['id' => $context->instanceid]); $basedata = (object) [ 'blocktype' => get_string('pluginname', 'block_' . $block->blockname) ]; return $basedata; }
php
protected static function get_context_block_data(\context_block $context, \stdClass $user) : \stdClass { global $DB; $block = $DB->get_record('block_instances', ['id' => $context->instanceid]); $basedata = (object) [ 'blocktype' => get_string('pluginname', 'block_' . $block->blockname) ]; return $basedata; }
[ "protected", "static", "function", "get_context_block_data", "(", "\\", "context_block", "$", "context", ",", "\\", "stdClass", "$", "user", ")", ":", "\\", "stdClass", "{", "global", "$", "DB", ";", "$", "block", "=", "$", "DB", "->", "get_record", "(", "'block_instances'", ",", "[", "'id'", "=>", "$", "context", "->", "instanceid", "]", ")", ";", "$", "basedata", "=", "(", "object", ")", "[", "'blocktype'", "=>", "get_string", "(", "'pluginname'", ",", "'block_'", ".", "$", "block", "->", "blockname", ")", "]", ";", "return", "$", "basedata", ";", "}" ]
Get all general data for the block at this context. @param \context_block $context The context to retrieve data for. @param \stdClass $user The user being written. @return \stdClass General data about this block instance.
[ "Get", "all", "general", "data", "for", "the", "block", "at", "this", "context", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/privacy/classes/local/request/helper.php#L243-L253
217,348
moodle/moodle
privacy/classes/local/request/helper.php
helper.delete_data_for_all_users_in_context_course_module
public static function delete_data_for_all_users_in_context_course_module(string $component, \context $context) { global $DB; if ($context instanceof \context_module) { // Delete course completion data for this context. \core_completion\privacy\provider::delete_completion(null, null, $context->instanceid); } }
php
public static function delete_data_for_all_users_in_context_course_module(string $component, \context $context) { global $DB; if ($context instanceof \context_module) { // Delete course completion data for this context. \core_completion\privacy\provider::delete_completion(null, null, $context->instanceid); } }
[ "public", "static", "function", "delete_data_for_all_users_in_context_course_module", "(", "string", "$", "component", ",", "\\", "context", "$", "context", ")", "{", "global", "$", "DB", ";", "if", "(", "$", "context", "instanceof", "\\", "context_module", ")", "{", "// Delete course completion data for this context.", "\\", "core_completion", "\\", "privacy", "\\", "provider", "::", "delete_completion", "(", "null", ",", "null", ",", "$", "context", "->", "instanceid", ")", ";", "}", "}" ]
Handle removal of 'standard' data for course modules. This will handle deletion for things such as activity completion. @param string $component The component being deleted for. @param \context $context The context to delete all data for.
[ "Handle", "removal", "of", "standard", "data", "for", "course", "modules", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/privacy/classes/local/request/helper.php#L281-L288
217,349
moodle/moodle
privacy/classes/local/request/helper.php
helper.delete_data_for_user_in_course_module
protected static function delete_data_for_user_in_course_module(approved_contextlist $contextlist) { global $DB; foreach ($contextlist as $context) { if ($context instanceof \context_module) { // Delete course completion data for this context. \core_completion\privacy\provider::delete_completion($contextlist->get_user(), null, $context->instanceid); } } }
php
protected static function delete_data_for_user_in_course_module(approved_contextlist $contextlist) { global $DB; foreach ($contextlist as $context) { if ($context instanceof \context_module) { // Delete course completion data for this context. \core_completion\privacy\provider::delete_completion($contextlist->get_user(), null, $context->instanceid); } } }
[ "protected", "static", "function", "delete_data_for_user_in_course_module", "(", "approved_contextlist", "$", "contextlist", ")", "{", "global", "$", "DB", ";", "foreach", "(", "$", "contextlist", "as", "$", "context", ")", "{", "if", "(", "$", "context", "instanceof", "\\", "context_module", ")", "{", "// Delete course completion data for this context.", "\\", "core_completion", "\\", "privacy", "\\", "provider", "::", "delete_completion", "(", "$", "contextlist", "->", "get_user", "(", ")", ",", "null", ",", "$", "context", "->", "instanceid", ")", ";", "}", "}", "}" ]
Delete all 'standard' user data for the specified user in course modules. This will handle deletion for things such as activity completion. @param approved_contextlist $contextlist The approved contexts and user information to delete information for.
[ "Delete", "all", "standard", "user", "data", "for", "the", "specified", "user", "in", "course", "modules", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/privacy/classes/local/request/helper.php#L297-L307
217,350
moodle/moodle
mod/quiz/report/attemptsreport_options.php
mod_quiz_attempts_report_options.get_url_params
protected function get_url_params() { $params = array( 'id' => $this->cm->id, 'mode' => $this->mode, 'attempts' => $this->attempts, 'onlygraded' => $this->onlygraded, ); if ($this->states) { $params['states'] = implode('-', $this->states); } if (groups_get_activity_groupmode($this->cm, $this->course)) { $params['group'] = $this->group; } return $params; }
php
protected function get_url_params() { $params = array( 'id' => $this->cm->id, 'mode' => $this->mode, 'attempts' => $this->attempts, 'onlygraded' => $this->onlygraded, ); if ($this->states) { $params['states'] = implode('-', $this->states); } if (groups_get_activity_groupmode($this->cm, $this->course)) { $params['group'] = $this->group; } return $params; }
[ "protected", "function", "get_url_params", "(", ")", "{", "$", "params", "=", "array", "(", "'id'", "=>", "$", "this", "->", "cm", "->", "id", ",", "'mode'", "=>", "$", "this", "->", "mode", ",", "'attempts'", "=>", "$", "this", "->", "attempts", ",", "'onlygraded'", "=>", "$", "this", "->", "onlygraded", ",", ")", ";", "if", "(", "$", "this", "->", "states", ")", "{", "$", "params", "[", "'states'", "]", "=", "implode", "(", "'-'", ",", "$", "this", "->", "states", ")", ";", "}", "if", "(", "groups_get_activity_groupmode", "(", "$", "this", "->", "cm", ",", "$", "this", "->", "course", ")", ")", "{", "$", "params", "[", "'group'", "]", "=", "$", "this", "->", "group", ";", "}", "return", "$", "params", ";", "}" ]
Get the URL parameters required to show the report with these options. @return array URL parameter name => value.
[ "Get", "the", "URL", "parameters", "required", "to", "show", "the", "report", "with", "these", "options", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/attemptsreport_options.php#L115-L131
217,351
moodle/moodle
mod/quiz/report/attemptsreport_options.php
mod_quiz_attempts_report_options.get_initial_form_data
public function get_initial_form_data() { $toform = new stdClass(); $toform->attempts = $this->attempts; $toform->onlygraded = $this->onlygraded; $toform->pagesize = $this->pagesize; if ($this->states) { foreach (self::$statefields as $field => $state) { $toform->$field = in_array($state, $this->states); } } return $toform; }
php
public function get_initial_form_data() { $toform = new stdClass(); $toform->attempts = $this->attempts; $toform->onlygraded = $this->onlygraded; $toform->pagesize = $this->pagesize; if ($this->states) { foreach (self::$statefields as $field => $state) { $toform->$field = in_array($state, $this->states); } } return $toform; }
[ "public", "function", "get_initial_form_data", "(", ")", "{", "$", "toform", "=", "new", "stdClass", "(", ")", ";", "$", "toform", "->", "attempts", "=", "$", "this", "->", "attempts", ";", "$", "toform", "->", "onlygraded", "=", "$", "this", "->", "onlygraded", ";", "$", "toform", "->", "pagesize", "=", "$", "this", "->", "pagesize", ";", "if", "(", "$", "this", "->", "states", ")", "{", "foreach", "(", "self", "::", "$", "statefields", "as", "$", "field", "=>", "$", "state", ")", "{", "$", "toform", "->", "$", "field", "=", "in_array", "(", "$", "state", ",", "$", "this", "->", "states", ")", ";", "}", "}", "return", "$", "toform", ";", "}" ]
Get the current value of the settings to pass to the settings form.
[ "Get", "the", "current", "value", "of", "the", "settings", "to", "pass", "to", "the", "settings", "form", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/attemptsreport_options.php#L166-L179
217,352
moodle/moodle
mod/quiz/report/attemptsreport_options.php
mod_quiz_attempts_report_options.setup_from_form_data
public function setup_from_form_data($fromform) { $this->attempts = $fromform->attempts; $this->group = groups_get_activity_group($this->cm, true); $this->onlygraded = !empty($fromform->onlygraded); $this->pagesize = $fromform->pagesize; $this->states = array(); foreach (self::$statefields as $field => $state) { if (!empty($fromform->$field)) { $this->states[] = $state; } } }
php
public function setup_from_form_data($fromform) { $this->attempts = $fromform->attempts; $this->group = groups_get_activity_group($this->cm, true); $this->onlygraded = !empty($fromform->onlygraded); $this->pagesize = $fromform->pagesize; $this->states = array(); foreach (self::$statefields as $field => $state) { if (!empty($fromform->$field)) { $this->states[] = $state; } } }
[ "public", "function", "setup_from_form_data", "(", "$", "fromform", ")", "{", "$", "this", "->", "attempts", "=", "$", "fromform", "->", "attempts", ";", "$", "this", "->", "group", "=", "groups_get_activity_group", "(", "$", "this", "->", "cm", ",", "true", ")", ";", "$", "this", "->", "onlygraded", "=", "!", "empty", "(", "$", "fromform", "->", "onlygraded", ")", ";", "$", "this", "->", "pagesize", "=", "$", "fromform", "->", "pagesize", ";", "$", "this", "->", "states", "=", "array", "(", ")", ";", "foreach", "(", "self", "::", "$", "statefields", "as", "$", "field", "=>", "$", "state", ")", "{", "if", "(", "!", "empty", "(", "$", "fromform", "->", "$", "field", ")", ")", "{", "$", "this", "->", "states", "[", "]", "=", "$", "state", ";", "}", "}", "}" ]
Set the fields of this object from the form data. @param object $fromform The data from $mform->get_data() from the settings form.
[ "Set", "the", "fields", "of", "this", "object", "from", "the", "form", "data", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/attemptsreport_options.php#L185-L197
217,353
moodle/moodle
mod/quiz/report/attemptsreport_options.php
mod_quiz_attempts_report_options.setup_from_params
public function setup_from_params() { $this->attempts = optional_param('attempts', $this->attempts, PARAM_ALPHAEXT); $this->group = groups_get_activity_group($this->cm, true); $this->onlygraded = optional_param('onlygraded', $this->onlygraded, PARAM_BOOL); $this->pagesize = optional_param('pagesize', $this->pagesize, PARAM_INT); $states = optional_param('states', '', PARAM_ALPHAEXT); if (!empty($states)) { $this->states = explode('-', $states); } $this->download = optional_param('download', $this->download, PARAM_ALPHA); }
php
public function setup_from_params() { $this->attempts = optional_param('attempts', $this->attempts, PARAM_ALPHAEXT); $this->group = groups_get_activity_group($this->cm, true); $this->onlygraded = optional_param('onlygraded', $this->onlygraded, PARAM_BOOL); $this->pagesize = optional_param('pagesize', $this->pagesize, PARAM_INT); $states = optional_param('states', '', PARAM_ALPHAEXT); if (!empty($states)) { $this->states = explode('-', $states); } $this->download = optional_param('download', $this->download, PARAM_ALPHA); }
[ "public", "function", "setup_from_params", "(", ")", "{", "$", "this", "->", "attempts", "=", "optional_param", "(", "'attempts'", ",", "$", "this", "->", "attempts", ",", "PARAM_ALPHAEXT", ")", ";", "$", "this", "->", "group", "=", "groups_get_activity_group", "(", "$", "this", "->", "cm", ",", "true", ")", ";", "$", "this", "->", "onlygraded", "=", "optional_param", "(", "'onlygraded'", ",", "$", "this", "->", "onlygraded", ",", "PARAM_BOOL", ")", ";", "$", "this", "->", "pagesize", "=", "optional_param", "(", "'pagesize'", ",", "$", "this", "->", "pagesize", ",", "PARAM_INT", ")", ";", "$", "states", "=", "optional_param", "(", "'states'", ",", "''", ",", "PARAM_ALPHAEXT", ")", ";", "if", "(", "!", "empty", "(", "$", "states", ")", ")", "{", "$", "this", "->", "states", "=", "explode", "(", "'-'", ",", "$", "states", ")", ";", "}", "$", "this", "->", "download", "=", "optional_param", "(", "'download'", ",", "$", "this", "->", "download", ",", "PARAM_ALPHA", ")", ";", "}" ]
Set the fields of this object from the URL parameters.
[ "Set", "the", "fields", "of", "this", "object", "from", "the", "URL", "parameters", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/attemptsreport_options.php#L202-L214
217,354
moodle/moodle
mod/quiz/report/attemptsreport_options.php
mod_quiz_attempts_report_options.resolve_dependencies
public function resolve_dependencies() { if ($this->group) { // Default for when a group is selected. if ($this->attempts === null || $this->attempts == quiz_attempts_report::ALL_WITH) { $this->attempts = quiz_attempts_report::ENROLLED_WITH; } } else if (!$this->group && $this->course->id == SITEID) { // Force report on front page to show all, unless a group is selected. $this->attempts = quiz_attempts_report::ALL_WITH; } else if (!in_array($this->attempts, array(quiz_attempts_report::ALL_WITH, quiz_attempts_report::ENROLLED_WITH, quiz_attempts_report::ENROLLED_WITHOUT, quiz_attempts_report::ENROLLED_ALL))) { $this->attempts = quiz_attempts_report::ENROLLED_WITH; } $cleanstates = array(); foreach (self::$statefields as $state) { if (in_array($state, $this->states)) { $cleanstates[] = $state; } } $this->states = $cleanstates; if (count($this->states) == count(self::$statefields)) { // If all states have been selected, then there is no constraint // required in the SQL, so clear the array. $this->states = null; } if (!quiz_report_can_filter_only_graded($this->quiz)) { // A grading mode like 'average' has been selected, so we cannot do // the show the attempt that gave the final grade thing. $this->onlygraded = false; } if ($this->attempts == quiz_attempts_report::ENROLLED_WITHOUT) { $this->states = null; $this->onlygraded = false; } if (!$this->is_showing_finished_attempts()) { $this->onlygraded = false; } if ($this->pagesize < 1) { $this->pagesize = quiz_attempts_report::DEFAULT_PAGE_SIZE; } }
php
public function resolve_dependencies() { if ($this->group) { // Default for when a group is selected. if ($this->attempts === null || $this->attempts == quiz_attempts_report::ALL_WITH) { $this->attempts = quiz_attempts_report::ENROLLED_WITH; } } else if (!$this->group && $this->course->id == SITEID) { // Force report on front page to show all, unless a group is selected. $this->attempts = quiz_attempts_report::ALL_WITH; } else if (!in_array($this->attempts, array(quiz_attempts_report::ALL_WITH, quiz_attempts_report::ENROLLED_WITH, quiz_attempts_report::ENROLLED_WITHOUT, quiz_attempts_report::ENROLLED_ALL))) { $this->attempts = quiz_attempts_report::ENROLLED_WITH; } $cleanstates = array(); foreach (self::$statefields as $state) { if (in_array($state, $this->states)) { $cleanstates[] = $state; } } $this->states = $cleanstates; if (count($this->states) == count(self::$statefields)) { // If all states have been selected, then there is no constraint // required in the SQL, so clear the array. $this->states = null; } if (!quiz_report_can_filter_only_graded($this->quiz)) { // A grading mode like 'average' has been selected, so we cannot do // the show the attempt that gave the final grade thing. $this->onlygraded = false; } if ($this->attempts == quiz_attempts_report::ENROLLED_WITHOUT) { $this->states = null; $this->onlygraded = false; } if (!$this->is_showing_finished_attempts()) { $this->onlygraded = false; } if ($this->pagesize < 1) { $this->pagesize = quiz_attempts_report::DEFAULT_PAGE_SIZE; } }
[ "public", "function", "resolve_dependencies", "(", ")", "{", "if", "(", "$", "this", "->", "group", ")", "{", "// Default for when a group is selected.", "if", "(", "$", "this", "->", "attempts", "===", "null", "||", "$", "this", "->", "attempts", "==", "quiz_attempts_report", "::", "ALL_WITH", ")", "{", "$", "this", "->", "attempts", "=", "quiz_attempts_report", "::", "ENROLLED_WITH", ";", "}", "}", "else", "if", "(", "!", "$", "this", "->", "group", "&&", "$", "this", "->", "course", "->", "id", "==", "SITEID", ")", "{", "// Force report on front page to show all, unless a group is selected.", "$", "this", "->", "attempts", "=", "quiz_attempts_report", "::", "ALL_WITH", ";", "}", "else", "if", "(", "!", "in_array", "(", "$", "this", "->", "attempts", ",", "array", "(", "quiz_attempts_report", "::", "ALL_WITH", ",", "quiz_attempts_report", "::", "ENROLLED_WITH", ",", "quiz_attempts_report", "::", "ENROLLED_WITHOUT", ",", "quiz_attempts_report", "::", "ENROLLED_ALL", ")", ")", ")", "{", "$", "this", "->", "attempts", "=", "quiz_attempts_report", "::", "ENROLLED_WITH", ";", "}", "$", "cleanstates", "=", "array", "(", ")", ";", "foreach", "(", "self", "::", "$", "statefields", "as", "$", "state", ")", "{", "if", "(", "in_array", "(", "$", "state", ",", "$", "this", "->", "states", ")", ")", "{", "$", "cleanstates", "[", "]", "=", "$", "state", ";", "}", "}", "$", "this", "->", "states", "=", "$", "cleanstates", ";", "if", "(", "count", "(", "$", "this", "->", "states", ")", "==", "count", "(", "self", "::", "$", "statefields", ")", ")", "{", "// If all states have been selected, then there is no constraint", "// required in the SQL, so clear the array.", "$", "this", "->", "states", "=", "null", ";", "}", "if", "(", "!", "quiz_report_can_filter_only_graded", "(", "$", "this", "->", "quiz", ")", ")", "{", "// A grading mode like 'average' has been selected, so we cannot do", "// the show the attempt that gave the final grade thing.", "$", "this", "->", "onlygraded", "=", "false", ";", "}", "if", "(", "$", "this", "->", "attempts", "==", "quiz_attempts_report", "::", "ENROLLED_WITHOUT", ")", "{", "$", "this", "->", "states", "=", "null", ";", "$", "this", "->", "onlygraded", "=", "false", ";", "}", "if", "(", "!", "$", "this", "->", "is_showing_finished_attempts", "(", ")", ")", "{", "$", "this", "->", "onlygraded", "=", "false", ";", "}", "if", "(", "$", "this", "->", "pagesize", "<", "1", ")", "{", "$", "this", "->", "pagesize", "=", "quiz_attempts_report", "::", "DEFAULT_PAGE_SIZE", ";", "}", "}" ]
Check the settings, and remove any 'impossible' combinations.
[ "Check", "the", "settings", "and", "remove", "any", "impossible", "combinations", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/attemptsreport_options.php#L235-L282
217,355
moodle/moodle
user/profile/field/textarea/field.class.php
profile_field_textarea.edit_field_add
public function edit_field_add($mform) { // Create the form field. $mform->addElement('editor', $this->inputname, format_string($this->field->name), null, null); $mform->setType($this->inputname, PARAM_RAW); // We MUST clean this before display! }
php
public function edit_field_add($mform) { // Create the form field. $mform->addElement('editor', $this->inputname, format_string($this->field->name), null, null); $mform->setType($this->inputname, PARAM_RAW); // We MUST clean this before display! }
[ "public", "function", "edit_field_add", "(", "$", "mform", ")", "{", "// Create the form field.", "$", "mform", "->", "addElement", "(", "'editor'", ",", "$", "this", "->", "inputname", ",", "format_string", "(", "$", "this", "->", "field", "->", "name", ")", ",", "null", ",", "null", ")", ";", "$", "mform", "->", "setType", "(", "$", "this", "->", "inputname", ",", "PARAM_RAW", ")", ";", "// We MUST clean this before display!", "}" ]
Adds elements for this field type to the edit form. @param moodleform $mform
[ "Adds", "elements", "for", "this", "field", "type", "to", "the", "edit", "form", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/profile/field/textarea/field.class.php#L37-L41
217,356
moodle/moodle
user/profile/field/textarea/field.class.php
profile_field_textarea.edit_save_data_preprocess
public function edit_save_data_preprocess($data, $datarecord) { if (is_array($data)) { $datarecord->dataformat = $data['format']; $data = $data['text']; } return $data; }
php
public function edit_save_data_preprocess($data, $datarecord) { if (is_array($data)) { $datarecord->dataformat = $data['format']; $data = $data['text']; } return $data; }
[ "public", "function", "edit_save_data_preprocess", "(", "$", "data", ",", "$", "datarecord", ")", "{", "if", "(", "is_array", "(", "$", "data", ")", ")", "{", "$", "datarecord", "->", "dataformat", "=", "$", "data", "[", "'format'", "]", ";", "$", "data", "=", "$", "data", "[", "'text'", "]", ";", "}", "return", "$", "data", ";", "}" ]
Process incoming data for the field. @param stdClass $data @param stdClass $datarecord @return mixed|stdClass
[ "Process", "incoming", "data", "for", "the", "field", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/profile/field/textarea/field.class.php#L57-L63
217,357
moodle/moodle
user/profile/field/textarea/field.class.php
profile_field_textarea.edit_load_user_data
public function edit_load_user_data($user) { if ($this->data !== null) { $this->data = clean_text($this->data, $this->dataformat); $user->{$this->inputname} = array('text' => $this->data, 'format' => $this->dataformat); } }
php
public function edit_load_user_data($user) { if ($this->data !== null) { $this->data = clean_text($this->data, $this->dataformat); $user->{$this->inputname} = array('text' => $this->data, 'format' => $this->dataformat); } }
[ "public", "function", "edit_load_user_data", "(", "$", "user", ")", "{", "if", "(", "$", "this", "->", "data", "!==", "null", ")", "{", "$", "this", "->", "data", "=", "clean_text", "(", "$", "this", "->", "data", ",", "$", "this", "->", "dataformat", ")", ";", "$", "user", "->", "{", "$", "this", "->", "inputname", "}", "=", "array", "(", "'text'", "=>", "$", "this", "->", "data", ",", "'format'", "=>", "$", "this", "->", "dataformat", ")", ";", "}", "}" ]
Load user data for this profile field, ready for editing. @param stdClass $user
[ "Load", "user", "data", "for", "this", "profile", "field", "ready", "for", "editing", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/profile/field/textarea/field.class.php#L69-L74
217,358
moodle/moodle
lib/mlbackend/php/phpml/src/Phpml/Math/Matrix.php
Matrix._add
protected function _add(Matrix $other, $sign = 1) { $a1 = $this->toArray(); $a2 = $other->toArray(); $newMatrix = []; for ($i = 0; $i < $this->rows; ++$i) { for ($k = 0; $k < $this->columns; ++$k) { $newMatrix[$i][$k] = $a1[$i][$k] + $sign * $a2[$i][$k]; } } return new self($newMatrix, false); }
php
protected function _add(Matrix $other, $sign = 1) { $a1 = $this->toArray(); $a2 = $other->toArray(); $newMatrix = []; for ($i = 0; $i < $this->rows; ++$i) { for ($k = 0; $k < $this->columns; ++$k) { $newMatrix[$i][$k] = $a1[$i][$k] + $sign * $a2[$i][$k]; } } return new self($newMatrix, false); }
[ "protected", "function", "_add", "(", "Matrix", "$", "other", ",", "$", "sign", "=", "1", ")", "{", "$", "a1", "=", "$", "this", "->", "toArray", "(", ")", ";", "$", "a2", "=", "$", "other", "->", "toArray", "(", ")", ";", "$", "newMatrix", "=", "[", "]", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "this", "->", "rows", ";", "++", "$", "i", ")", "{", "for", "(", "$", "k", "=", "0", ";", "$", "k", "<", "$", "this", "->", "columns", ";", "++", "$", "k", ")", "{", "$", "newMatrix", "[", "$", "i", "]", "[", "$", "k", "]", "=", "$", "a1", "[", "$", "i", "]", "[", "$", "k", "]", "+", "$", "sign", "*", "$", "a2", "[", "$", "i", "]", "[", "$", "k", "]", ";", "}", "}", "return", "new", "self", "(", "$", "newMatrix", ",", "false", ")", ";", "}" ]
Element-wise addition or substraction depending on the given sign parameter @param Matrix $other @param int $sign @return Matrix
[ "Element", "-", "wise", "addition", "or", "substraction", "depending", "on", "the", "given", "sign", "parameter" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/mlbackend/php/phpml/src/Phpml/Math/Matrix.php#L264-L277
217,359
moodle/moodle
admin/tool/messageinbound/classes/privacy/provider.php
provider.delete_user_data
protected static function delete_user_data($userid) { global $DB; $DB->delete_records_select('messageinbound_messagelist', 'userid = :userid', ['userid' => $userid]); \core_userkey\privacy\provider::delete_userkeys('messageinbound_handler', $userid); }
php
protected static function delete_user_data($userid) { global $DB; $DB->delete_records_select('messageinbound_messagelist', 'userid = :userid', ['userid' => $userid]); \core_userkey\privacy\provider::delete_userkeys('messageinbound_handler', $userid); }
[ "protected", "static", "function", "delete_user_data", "(", "$", "userid", ")", "{", "global", "$", "DB", ";", "$", "DB", "->", "delete_records_select", "(", "'messageinbound_messagelist'", ",", "'userid = :userid'", ",", "[", "'userid'", "=>", "$", "userid", "]", ")", ";", "\\", "core_userkey", "\\", "privacy", "\\", "provider", "::", "delete_userkeys", "(", "'messageinbound_handler'", ",", "$", "userid", ")", ";", "}" ]
Delete a user's data. @param int $userid The user ID. @return void
[ "Delete", "a", "user", "s", "data", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/messageinbound/classes/privacy/provider.php#L195-L199
217,360
moodle/moodle
admin/tool/messageinbound/classes/privacy/provider.php
provider.approved_contextlist_contains_my_context
protected static function approved_contextlist_contains_my_context(approved_contextlist $contextlist) { $userid = $contextlist->get_user()->id; foreach ($contextlist->get_contexts() as $context) { if ($context->contextlevel == CONTEXT_USER && $context->instanceid == $userid) { return true; } } return false; }
php
protected static function approved_contextlist_contains_my_context(approved_contextlist $contextlist) { $userid = $contextlist->get_user()->id; foreach ($contextlist->get_contexts() as $context) { if ($context->contextlevel == CONTEXT_USER && $context->instanceid == $userid) { return true; } } return false; }
[ "protected", "static", "function", "approved_contextlist_contains_my_context", "(", "approved_contextlist", "$", "contextlist", ")", "{", "$", "userid", "=", "$", "contextlist", "->", "get_user", "(", ")", "->", "id", ";", "foreach", "(", "$", "contextlist", "->", "get_contexts", "(", ")", "as", "$", "context", ")", "{", "if", "(", "$", "context", "->", "contextlevel", "==", "CONTEXT_USER", "&&", "$", "context", "->", "instanceid", "==", "$", "userid", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Return whether the contextlist contains our own context. @param approved_contextlist $contextlist The contextlist @return bool
[ "Return", "whether", "the", "contextlist", "contains", "our", "own", "context", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/messageinbound/classes/privacy/provider.php#L207-L215
217,361
moodle/moodle
admin/tool/uploadcourse/classes/course.php
tool_uploadcourse_course.can_create
public function can_create() { return in_array($this->mode, array(tool_uploadcourse_processor::MODE_CREATE_ALL, tool_uploadcourse_processor::MODE_CREATE_NEW, tool_uploadcourse_processor::MODE_CREATE_OR_UPDATE) ); }
php
public function can_create() { return in_array($this->mode, array(tool_uploadcourse_processor::MODE_CREATE_ALL, tool_uploadcourse_processor::MODE_CREATE_NEW, tool_uploadcourse_processor::MODE_CREATE_OR_UPDATE) ); }
[ "public", "function", "can_create", "(", ")", "{", "return", "in_array", "(", "$", "this", "->", "mode", ",", "array", "(", "tool_uploadcourse_processor", "::", "MODE_CREATE_ALL", ",", "tool_uploadcourse_processor", "::", "MODE_CREATE_NEW", ",", "tool_uploadcourse_processor", "::", "MODE_CREATE_OR_UPDATE", ")", ")", ";", "}" ]
Does the mode allow for course creation? @return bool
[ "Does", "the", "mode", "allow", "for", "course", "creation?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/uploadcourse/classes/course.php#L159-L164
217,362
moodle/moodle
admin/tool/uploadcourse/classes/course.php
tool_uploadcourse_course.can_update
public function can_update() { return in_array($this->mode, array( tool_uploadcourse_processor::MODE_UPDATE_ONLY, tool_uploadcourse_processor::MODE_CREATE_OR_UPDATE) ) && $this->updatemode != tool_uploadcourse_processor::UPDATE_NOTHING; }
php
public function can_update() { return in_array($this->mode, array( tool_uploadcourse_processor::MODE_UPDATE_ONLY, tool_uploadcourse_processor::MODE_CREATE_OR_UPDATE) ) && $this->updatemode != tool_uploadcourse_processor::UPDATE_NOTHING; }
[ "public", "function", "can_update", "(", ")", "{", "return", "in_array", "(", "$", "this", "->", "mode", ",", "array", "(", "tool_uploadcourse_processor", "::", "MODE_UPDATE_ONLY", ",", "tool_uploadcourse_processor", "::", "MODE_CREATE_OR_UPDATE", ")", ")", "&&", "$", "this", "->", "updatemode", "!=", "tool_uploadcourse_processor", "::", "UPDATE_NOTHING", ";", "}" ]
Does the mode allow for course update? @return bool
[ "Does", "the", "mode", "allow", "for", "course", "update?" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/uploadcourse/classes/course.php#L208-L214
217,363
moodle/moodle
admin/tool/uploadcourse/classes/course.php
tool_uploadcourse_course.delete
protected function delete() { global $DB; $this->id = $DB->get_field_select('course', 'id', 'shortname = :shortname', array('shortname' => $this->shortname), MUST_EXIST); return delete_course($this->id, false); }
php
protected function delete() { global $DB; $this->id = $DB->get_field_select('course', 'id', 'shortname = :shortname', array('shortname' => $this->shortname), MUST_EXIST); return delete_course($this->id, false); }
[ "protected", "function", "delete", "(", ")", "{", "global", "$", "DB", ";", "$", "this", "->", "id", "=", "$", "DB", "->", "get_field_select", "(", "'course'", ",", "'id'", ",", "'shortname = :shortname'", ",", "array", "(", "'shortname'", "=>", "$", "this", "->", "shortname", ")", ",", "MUST_EXIST", ")", ";", "return", "delete_course", "(", "$", "this", "->", "id", ",", "false", ")", ";", "}" ]
Delete the current course. @return bool
[ "Delete", "the", "current", "course", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/uploadcourse/classes/course.php#L231-L236
217,364
moodle/moodle
admin/tool/uploadcourse/classes/course.php
tool_uploadcourse_course.exists
protected function exists($shortname = null) { global $DB; if (is_null($shortname)) { $shortname = $this->shortname; } if (!empty($shortname) || is_numeric($shortname)) { return $DB->record_exists('course', array('shortname' => $shortname)); } return false; }
php
protected function exists($shortname = null) { global $DB; if (is_null($shortname)) { $shortname = $this->shortname; } if (!empty($shortname) || is_numeric($shortname)) { return $DB->record_exists('course', array('shortname' => $shortname)); } return false; }
[ "protected", "function", "exists", "(", "$", "shortname", "=", "null", ")", "{", "global", "$", "DB", ";", "if", "(", "is_null", "(", "$", "shortname", ")", ")", "{", "$", "shortname", "=", "$", "this", "->", "shortname", ";", "}", "if", "(", "!", "empty", "(", "$", "shortname", ")", "||", "is_numeric", "(", "$", "shortname", ")", ")", "{", "return", "$", "DB", "->", "record_exists", "(", "'course'", ",", "array", "(", "'shortname'", "=>", "$", "shortname", ")", ")", ";", "}", "return", "false", ";", "}" ]
Return whether the course exists or not. @param string $shortname the shortname to use to check if the course exists. Falls back on $this->shortname if empty. @return bool
[ "Return", "whether", "the", "course", "exists", "or", "not", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/uploadcourse/classes/course.php#L258-L267
217,365
moodle/moodle
admin/tool/uploadcourse/classes/course.php
tool_uploadcourse_course.proceed
public function proceed() { global $CFG, $USER; if (!$this->prepared) { throw new coding_exception('The course has not been prepared.'); } else if ($this->has_errors()) { throw new moodle_exception('Cannot proceed, errors were detected.'); } else if ($this->processstarted) { throw new coding_exception('The process has already been started.'); } $this->processstarted = true; if ($this->do === self::DO_DELETE) { if ($this->delete()) { $this->status('coursedeleted', new lang_string('coursedeleted', 'tool_uploadcourse')); } else { $this->error('errorwhiledeletingcourse', new lang_string('errorwhiledeletingcourse', 'tool_uploadcourse')); } return true; } else if ($this->do === self::DO_CREATE) { $course = create_course((object) $this->data); $this->id = $course->id; $this->status('coursecreated', new lang_string('coursecreated', 'tool_uploadcourse')); } else if ($this->do === self::DO_UPDATE) { $course = (object) $this->data; update_course($course); $this->id = $course->id; $this->status('courseupdated', new lang_string('courseupdated', 'tool_uploadcourse')); } else { // Strangely the outcome has not been defined, or is unknown! throw new coding_exception('Unknown outcome!'); } // Restore a course. if (!empty($this->restoredata)) { $rc = new restore_controller($this->restoredata, $course->id, backup::INTERACTIVE_NO, backup::MODE_IMPORT, $USER->id, backup::TARGET_CURRENT_ADDING); // Check if the format conversion must happen first. if ($rc->get_status() == backup::STATUS_REQUIRE_CONV) { $rc->convert(); } if ($rc->execute_precheck()) { $rc->execute_plan(); $this->status('courserestored', new lang_string('courserestored', 'tool_uploadcourse')); } else { $this->error('errorwhilerestoringcourse', new lang_string('errorwhilerestoringthecourse', 'tool_uploadcourse')); } $rc->destroy(); } // Proceed with enrolment data. $this->process_enrolment_data($course); // Reset the course. if ($this->importoptions['reset'] || $this->options['reset']) { if ($this->do === self::DO_UPDATE && $this->can_reset()) { $this->reset($course); $this->status('coursereset', new lang_string('coursereset', 'tool_uploadcourse')); } } // Mark context as dirty. $context = context_course::instance($course->id); $context->mark_dirty(); }
php
public function proceed() { global $CFG, $USER; if (!$this->prepared) { throw new coding_exception('The course has not been prepared.'); } else if ($this->has_errors()) { throw new moodle_exception('Cannot proceed, errors were detected.'); } else if ($this->processstarted) { throw new coding_exception('The process has already been started.'); } $this->processstarted = true; if ($this->do === self::DO_DELETE) { if ($this->delete()) { $this->status('coursedeleted', new lang_string('coursedeleted', 'tool_uploadcourse')); } else { $this->error('errorwhiledeletingcourse', new lang_string('errorwhiledeletingcourse', 'tool_uploadcourse')); } return true; } else if ($this->do === self::DO_CREATE) { $course = create_course((object) $this->data); $this->id = $course->id; $this->status('coursecreated', new lang_string('coursecreated', 'tool_uploadcourse')); } else if ($this->do === self::DO_UPDATE) { $course = (object) $this->data; update_course($course); $this->id = $course->id; $this->status('courseupdated', new lang_string('courseupdated', 'tool_uploadcourse')); } else { // Strangely the outcome has not been defined, or is unknown! throw new coding_exception('Unknown outcome!'); } // Restore a course. if (!empty($this->restoredata)) { $rc = new restore_controller($this->restoredata, $course->id, backup::INTERACTIVE_NO, backup::MODE_IMPORT, $USER->id, backup::TARGET_CURRENT_ADDING); // Check if the format conversion must happen first. if ($rc->get_status() == backup::STATUS_REQUIRE_CONV) { $rc->convert(); } if ($rc->execute_precheck()) { $rc->execute_plan(); $this->status('courserestored', new lang_string('courserestored', 'tool_uploadcourse')); } else { $this->error('errorwhilerestoringcourse', new lang_string('errorwhilerestoringthecourse', 'tool_uploadcourse')); } $rc->destroy(); } // Proceed with enrolment data. $this->process_enrolment_data($course); // Reset the course. if ($this->importoptions['reset'] || $this->options['reset']) { if ($this->do === self::DO_UPDATE && $this->can_reset()) { $this->reset($course); $this->status('coursereset', new lang_string('coursereset', 'tool_uploadcourse')); } } // Mark context as dirty. $context = context_course::instance($course->id); $context->mark_dirty(); }
[ "public", "function", "proceed", "(", ")", "{", "global", "$", "CFG", ",", "$", "USER", ";", "if", "(", "!", "$", "this", "->", "prepared", ")", "{", "throw", "new", "coding_exception", "(", "'The course has not been prepared.'", ")", ";", "}", "else", "if", "(", "$", "this", "->", "has_errors", "(", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'Cannot proceed, errors were detected.'", ")", ";", "}", "else", "if", "(", "$", "this", "->", "processstarted", ")", "{", "throw", "new", "coding_exception", "(", "'The process has already been started.'", ")", ";", "}", "$", "this", "->", "processstarted", "=", "true", ";", "if", "(", "$", "this", "->", "do", "===", "self", "::", "DO_DELETE", ")", "{", "if", "(", "$", "this", "->", "delete", "(", ")", ")", "{", "$", "this", "->", "status", "(", "'coursedeleted'", ",", "new", "lang_string", "(", "'coursedeleted'", ",", "'tool_uploadcourse'", ")", ")", ";", "}", "else", "{", "$", "this", "->", "error", "(", "'errorwhiledeletingcourse'", ",", "new", "lang_string", "(", "'errorwhiledeletingcourse'", ",", "'tool_uploadcourse'", ")", ")", ";", "}", "return", "true", ";", "}", "else", "if", "(", "$", "this", "->", "do", "===", "self", "::", "DO_CREATE", ")", "{", "$", "course", "=", "create_course", "(", "(", "object", ")", "$", "this", "->", "data", ")", ";", "$", "this", "->", "id", "=", "$", "course", "->", "id", ";", "$", "this", "->", "status", "(", "'coursecreated'", ",", "new", "lang_string", "(", "'coursecreated'", ",", "'tool_uploadcourse'", ")", ")", ";", "}", "else", "if", "(", "$", "this", "->", "do", "===", "self", "::", "DO_UPDATE", ")", "{", "$", "course", "=", "(", "object", ")", "$", "this", "->", "data", ";", "update_course", "(", "$", "course", ")", ";", "$", "this", "->", "id", "=", "$", "course", "->", "id", ";", "$", "this", "->", "status", "(", "'courseupdated'", ",", "new", "lang_string", "(", "'courseupdated'", ",", "'tool_uploadcourse'", ")", ")", ";", "}", "else", "{", "// Strangely the outcome has not been defined, or is unknown!", "throw", "new", "coding_exception", "(", "'Unknown outcome!'", ")", ";", "}", "// Restore a course.", "if", "(", "!", "empty", "(", "$", "this", "->", "restoredata", ")", ")", "{", "$", "rc", "=", "new", "restore_controller", "(", "$", "this", "->", "restoredata", ",", "$", "course", "->", "id", ",", "backup", "::", "INTERACTIVE_NO", ",", "backup", "::", "MODE_IMPORT", ",", "$", "USER", "->", "id", ",", "backup", "::", "TARGET_CURRENT_ADDING", ")", ";", "// Check if the format conversion must happen first.", "if", "(", "$", "rc", "->", "get_status", "(", ")", "==", "backup", "::", "STATUS_REQUIRE_CONV", ")", "{", "$", "rc", "->", "convert", "(", ")", ";", "}", "if", "(", "$", "rc", "->", "execute_precheck", "(", ")", ")", "{", "$", "rc", "->", "execute_plan", "(", ")", ";", "$", "this", "->", "status", "(", "'courserestored'", ",", "new", "lang_string", "(", "'courserestored'", ",", "'tool_uploadcourse'", ")", ")", ";", "}", "else", "{", "$", "this", "->", "error", "(", "'errorwhilerestoringcourse'", ",", "new", "lang_string", "(", "'errorwhilerestoringthecourse'", ",", "'tool_uploadcourse'", ")", ")", ";", "}", "$", "rc", "->", "destroy", "(", ")", ";", "}", "// Proceed with enrolment data.", "$", "this", "->", "process_enrolment_data", "(", "$", "course", ")", ";", "// Reset the course.", "if", "(", "$", "this", "->", "importoptions", "[", "'reset'", "]", "||", "$", "this", "->", "options", "[", "'reset'", "]", ")", "{", "if", "(", "$", "this", "->", "do", "===", "self", "::", "DO_UPDATE", "&&", "$", "this", "->", "can_reset", "(", ")", ")", "{", "$", "this", "->", "reset", "(", "$", "course", ")", ";", "$", "this", "->", "status", "(", "'coursereset'", ",", "new", "lang_string", "(", "'coursereset'", ",", "'tool_uploadcourse'", ")", ")", ";", "}", "}", "// Mark context as dirty.", "$", "context", "=", "context_course", "::", "instance", "(", "$", "course", "->", "id", ")", ";", "$", "context", "->", "mark_dirty", "(", ")", ";", "}" ]
Proceed with the import of the course. @return void
[ "Proceed", "with", "the", "import", "of", "the", "course", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/uploadcourse/classes/course.php#L751-L816
217,366
moodle/moodle
admin/tool/uploadcourse/classes/course.php
tool_uploadcourse_course.reset
protected function reset($course) { global $DB; $resetdata = new stdClass(); $resetdata->id = $course->id; $resetdata->reset_start_date = time(); $resetdata->reset_events = true; $resetdata->reset_notes = true; $resetdata->delete_blog_associations = true; $resetdata->reset_completion = true; $resetdata->reset_roles_overrides = true; $resetdata->reset_roles_local = true; $resetdata->reset_groups_members = true; $resetdata->reset_groups_remove = true; $resetdata->reset_groupings_members = true; $resetdata->reset_groupings_remove = true; $resetdata->reset_gradebook_items = true; $resetdata->reset_gradebook_grades = true; $resetdata->reset_comments = true; if (empty($course->startdate)) { $course->startdate = $DB->get_field_select('course', 'startdate', 'id = :id', array('id' => $course->id)); } $resetdata->reset_start_date_old = $course->startdate; if (empty($course->enddate)) { $course->enddate = $DB->get_field_select('course', 'enddate', 'id = :id', array('id' => $course->id)); } $resetdata->reset_end_date_old = $course->enddate; // Add roles. $roles = tool_uploadcourse_helper::get_role_ids(); $resetdata->unenrol_users = array_values($roles); $resetdata->unenrol_users[] = 0; // Enrolled without role. return reset_course_userdata($resetdata); }
php
protected function reset($course) { global $DB; $resetdata = new stdClass(); $resetdata->id = $course->id; $resetdata->reset_start_date = time(); $resetdata->reset_events = true; $resetdata->reset_notes = true; $resetdata->delete_blog_associations = true; $resetdata->reset_completion = true; $resetdata->reset_roles_overrides = true; $resetdata->reset_roles_local = true; $resetdata->reset_groups_members = true; $resetdata->reset_groups_remove = true; $resetdata->reset_groupings_members = true; $resetdata->reset_groupings_remove = true; $resetdata->reset_gradebook_items = true; $resetdata->reset_gradebook_grades = true; $resetdata->reset_comments = true; if (empty($course->startdate)) { $course->startdate = $DB->get_field_select('course', 'startdate', 'id = :id', array('id' => $course->id)); } $resetdata->reset_start_date_old = $course->startdate; if (empty($course->enddate)) { $course->enddate = $DB->get_field_select('course', 'enddate', 'id = :id', array('id' => $course->id)); } $resetdata->reset_end_date_old = $course->enddate; // Add roles. $roles = tool_uploadcourse_helper::get_role_ids(); $resetdata->unenrol_users = array_values($roles); $resetdata->unenrol_users[] = 0; // Enrolled without role. return reset_course_userdata($resetdata); }
[ "protected", "function", "reset", "(", "$", "course", ")", "{", "global", "$", "DB", ";", "$", "resetdata", "=", "new", "stdClass", "(", ")", ";", "$", "resetdata", "->", "id", "=", "$", "course", "->", "id", ";", "$", "resetdata", "->", "reset_start_date", "=", "time", "(", ")", ";", "$", "resetdata", "->", "reset_events", "=", "true", ";", "$", "resetdata", "->", "reset_notes", "=", "true", ";", "$", "resetdata", "->", "delete_blog_associations", "=", "true", ";", "$", "resetdata", "->", "reset_completion", "=", "true", ";", "$", "resetdata", "->", "reset_roles_overrides", "=", "true", ";", "$", "resetdata", "->", "reset_roles_local", "=", "true", ";", "$", "resetdata", "->", "reset_groups_members", "=", "true", ";", "$", "resetdata", "->", "reset_groups_remove", "=", "true", ";", "$", "resetdata", "->", "reset_groupings_members", "=", "true", ";", "$", "resetdata", "->", "reset_groupings_remove", "=", "true", ";", "$", "resetdata", "->", "reset_gradebook_items", "=", "true", ";", "$", "resetdata", "->", "reset_gradebook_grades", "=", "true", ";", "$", "resetdata", "->", "reset_comments", "=", "true", ";", "if", "(", "empty", "(", "$", "course", "->", "startdate", ")", ")", "{", "$", "course", "->", "startdate", "=", "$", "DB", "->", "get_field_select", "(", "'course'", ",", "'startdate'", ",", "'id = :id'", ",", "array", "(", "'id'", "=>", "$", "course", "->", "id", ")", ")", ";", "}", "$", "resetdata", "->", "reset_start_date_old", "=", "$", "course", "->", "startdate", ";", "if", "(", "empty", "(", "$", "course", "->", "enddate", ")", ")", "{", "$", "course", "->", "enddate", "=", "$", "DB", "->", "get_field_select", "(", "'course'", ",", "'enddate'", ",", "'id = :id'", ",", "array", "(", "'id'", "=>", "$", "course", "->", "id", ")", ")", ";", "}", "$", "resetdata", "->", "reset_end_date_old", "=", "$", "course", "->", "enddate", ";", "// Add roles.", "$", "roles", "=", "tool_uploadcourse_helper", "::", "get_role_ids", "(", ")", ";", "$", "resetdata", "->", "unenrol_users", "=", "array_values", "(", "$", "roles", ")", ";", "$", "resetdata", "->", "unenrol_users", "[", "]", "=", "0", ";", "// Enrolled without role.", "return", "reset_course_userdata", "(", "$", "resetdata", ")", ";", "}" ]
Reset the current course. This does not reset any of the content of the activities. @param stdClass $course the course object of the course to reset. @return array status array of array component, item, error.
[ "Reset", "the", "current", "course", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/uploadcourse/classes/course.php#L932-L968
217,367
moodle/moodle
admin/tool/uploadcourse/classes/course.php
tool_uploadcourse_course.status
protected function status($code, lang_string $message) { if (array_key_exists($code, $this->statuses)) { throw new coding_exception('Status code already defined'); } $this->statuses[$code] = $message; }
php
protected function status($code, lang_string $message) { if (array_key_exists($code, $this->statuses)) { throw new coding_exception('Status code already defined'); } $this->statuses[$code] = $message; }
[ "protected", "function", "status", "(", "$", "code", ",", "lang_string", "$", "message", ")", "{", "if", "(", "array_key_exists", "(", "$", "code", ",", "$", "this", "->", "statuses", ")", ")", "{", "throw", "new", "coding_exception", "(", "'Status code already defined'", ")", ";", "}", "$", "this", "->", "statuses", "[", "$", "code", "]", "=", "$", "message", ";", "}" ]
Log a status @param string $code status code. @param lang_string $message status message. @return void
[ "Log", "a", "status" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/uploadcourse/classes/course.php#L977-L982
217,368
moodle/moodle
question/type/ddimageortext/question.php
qtype_ddimageortext_drop_zone.summarise
public function summarise() { if (trim($this->text) != '') { $summariseplace = get_string('summariseplace', 'qtype_ddimageortext', $this); } else { $summariseplace = get_string('summariseplaceno', 'qtype_ddimageortext', $this->no); } return $summariseplace; }
php
public function summarise() { if (trim($this->text) != '') { $summariseplace = get_string('summariseplace', 'qtype_ddimageortext', $this); } else { $summariseplace = get_string('summariseplaceno', 'qtype_ddimageortext', $this->no); } return $summariseplace; }
[ "public", "function", "summarise", "(", ")", "{", "if", "(", "trim", "(", "$", "this", "->", "text", ")", "!=", "''", ")", "{", "$", "summariseplace", "=", "get_string", "(", "'summariseplace'", ",", "'qtype_ddimageortext'", ",", "$", "this", ")", ";", "}", "else", "{", "$", "summariseplace", "=", "get_string", "(", "'summariseplaceno'", ",", "'qtype_ddimageortext'", ",", "$", "this", "->", "no", ")", ";", "}", "return", "$", "summariseplace", ";", "}" ]
Creates summary text of for the drop zone @return string
[ "Creates", "summary", "text", "of", "for", "the", "drop", "zone" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/type/ddimageortext/question.php#L143-L152
217,369
moodle/moodle
mod/scorm/renderer.php
mod_scorm_renderer.render_mod_scorm_attempt_bar
protected function render_mod_scorm_attempt_bar(mod_scorm_attempt_bar $attemptbar) { $output = ''; $attemptbar = clone($attemptbar); $attemptbar->prepare($this, $this->page, $this->target); if (count($attemptbar->attemptids) > 1) { $output .= get_string('attempt', 'scorm') . ':'; if (!empty($attemptbar->previouslink)) { $output .= '&#160;(' . $attemptbar->previouslink . ')&#160;'; } foreach ($attemptbar->attemptlinks as $link) { $output .= "&#160;&#160;$link"; } if (!empty($attemptbar->nextlink)) { $output .= '&#160;&#160;(' . $attemptbar->nextlink . ')'; } } return html_writer::tag('div', $output, array('class' => 'paging')); }
php
protected function render_mod_scorm_attempt_bar(mod_scorm_attempt_bar $attemptbar) { $output = ''; $attemptbar = clone($attemptbar); $attemptbar->prepare($this, $this->page, $this->target); if (count($attemptbar->attemptids) > 1) { $output .= get_string('attempt', 'scorm') . ':'; if (!empty($attemptbar->previouslink)) { $output .= '&#160;(' . $attemptbar->previouslink . ')&#160;'; } foreach ($attemptbar->attemptlinks as $link) { $output .= "&#160;&#160;$link"; } if (!empty($attemptbar->nextlink)) { $output .= '&#160;&#160;(' . $attemptbar->nextlink . ')'; } } return html_writer::tag('div', $output, array('class' => 'paging')); }
[ "protected", "function", "render_mod_scorm_attempt_bar", "(", "mod_scorm_attempt_bar", "$", "attemptbar", ")", "{", "$", "output", "=", "''", ";", "$", "attemptbar", "=", "clone", "(", "$", "attemptbar", ")", ";", "$", "attemptbar", "->", "prepare", "(", "$", "this", ",", "$", "this", "->", "page", ",", "$", "this", "->", "target", ")", ";", "if", "(", "count", "(", "$", "attemptbar", "->", "attemptids", ")", ">", "1", ")", "{", "$", "output", ".=", "get_string", "(", "'attempt'", ",", "'scorm'", ")", ".", "':'", ";", "if", "(", "!", "empty", "(", "$", "attemptbar", "->", "previouslink", ")", ")", "{", "$", "output", ".=", "'&#160;('", ".", "$", "attemptbar", "->", "previouslink", ".", "')&#160;'", ";", "}", "foreach", "(", "$", "attemptbar", "->", "attemptlinks", "as", "$", "link", ")", "{", "$", "output", ".=", "\"&#160;&#160;$link\"", ";", "}", "if", "(", "!", "empty", "(", "$", "attemptbar", "->", "nextlink", ")", ")", "{", "$", "output", ".=", "'&#160;&#160;('", ".", "$", "attemptbar", "->", "nextlink", ".", "')'", ";", "}", "}", "return", "html_writer", "::", "tag", "(", "'div'", ",", "$", "output", ",", "array", "(", "'class'", "=>", "'paging'", ")", ")", ";", "}" ]
scorm attempt bar renderer @param mod_scorm_attempt_bar $attemptbar @return string
[ "scorm", "attempt", "bar", "renderer" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/scorm/renderer.php#L55-L77
217,370
moodle/moodle
mod/scorm/renderer.php
mod_scorm_attempt_bar.prepare
public function prepare(renderer_base $output, moodle_page $page, $target) { if (empty($this->attemptids)) { throw new coding_exception('mod_scorm_attempt_bar requires a attemptids value.'); } if (!isset($this->attempt) || is_null($this->attempt)) { throw new coding_exception('mod_scorm_attempt_bar requires a attempt value.'); } if (empty($this->baseurl)) { throw new coding_exception('mod_scorm_attempt_bar requires a baseurl value.'); } if (count($this->attemptids) > 1) { $lastattempt = end($this->attemptids); // Get last attempt. $firstattempt = reset($this->attemptids); // get first attempt. $nextattempt = 0; $prevattempt = null; $previous = 0; foreach ($this->attemptids as $attemptid) { if ($this->attempt == $attemptid) { $this->attemptlinks[] = $attemptid; $prevattempt = $previous; } else { $attemptlink = html_writer::link( new moodle_url($this->baseurl, array($this->pagevar => $attemptid)), $attemptid); $this->attemptlinks[] = $attemptlink; if (empty($nextattempt) && $prevattempt !== null) { // Set the nextattempt var as we have set previous attempt earlier. $nextattempt = $attemptid; } } $previous = $attemptid; // Store this attempt as previous in case we need it. } if ($this->attempt != $firstattempt) { $this->previouslink = html_writer::link( new moodle_url($this->baseurl, array($this->pagevar => $prevattempt)), get_string('previous'), array('class' => 'previous')); } if ($this->attempt != $lastattempt) { $this->nextlink = html_writer::link( new moodle_url($this->baseurl, array($this->pagevar => $nextattempt)), get_string('next'), array('class' => 'next')); } } }
php
public function prepare(renderer_base $output, moodle_page $page, $target) { if (empty($this->attemptids)) { throw new coding_exception('mod_scorm_attempt_bar requires a attemptids value.'); } if (!isset($this->attempt) || is_null($this->attempt)) { throw new coding_exception('mod_scorm_attempt_bar requires a attempt value.'); } if (empty($this->baseurl)) { throw new coding_exception('mod_scorm_attempt_bar requires a baseurl value.'); } if (count($this->attemptids) > 1) { $lastattempt = end($this->attemptids); // Get last attempt. $firstattempt = reset($this->attemptids); // get first attempt. $nextattempt = 0; $prevattempt = null; $previous = 0; foreach ($this->attemptids as $attemptid) { if ($this->attempt == $attemptid) { $this->attemptlinks[] = $attemptid; $prevattempt = $previous; } else { $attemptlink = html_writer::link( new moodle_url($this->baseurl, array($this->pagevar => $attemptid)), $attemptid); $this->attemptlinks[] = $attemptlink; if (empty($nextattempt) && $prevattempt !== null) { // Set the nextattempt var as we have set previous attempt earlier. $nextattempt = $attemptid; } } $previous = $attemptid; // Store this attempt as previous in case we need it. } if ($this->attempt != $firstattempt) { $this->previouslink = html_writer::link( new moodle_url($this->baseurl, array($this->pagevar => $prevattempt)), get_string('previous'), array('class' => 'previous')); } if ($this->attempt != $lastattempt) { $this->nextlink = html_writer::link( new moodle_url($this->baseurl, array($this->pagevar => $nextattempt)), get_string('next'), array('class' => 'next')); } } }
[ "public", "function", "prepare", "(", "renderer_base", "$", "output", ",", "moodle_page", "$", "page", ",", "$", "target", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "attemptids", ")", ")", "{", "throw", "new", "coding_exception", "(", "'mod_scorm_attempt_bar requires a attemptids value.'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "attempt", ")", "||", "is_null", "(", "$", "this", "->", "attempt", ")", ")", "{", "throw", "new", "coding_exception", "(", "'mod_scorm_attempt_bar requires a attempt value.'", ")", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "baseurl", ")", ")", "{", "throw", "new", "coding_exception", "(", "'mod_scorm_attempt_bar requires a baseurl value.'", ")", ";", "}", "if", "(", "count", "(", "$", "this", "->", "attemptids", ")", ">", "1", ")", "{", "$", "lastattempt", "=", "end", "(", "$", "this", "->", "attemptids", ")", ";", "// Get last attempt.", "$", "firstattempt", "=", "reset", "(", "$", "this", "->", "attemptids", ")", ";", "// get first attempt.", "$", "nextattempt", "=", "0", ";", "$", "prevattempt", "=", "null", ";", "$", "previous", "=", "0", ";", "foreach", "(", "$", "this", "->", "attemptids", "as", "$", "attemptid", ")", "{", "if", "(", "$", "this", "->", "attempt", "==", "$", "attemptid", ")", "{", "$", "this", "->", "attemptlinks", "[", "]", "=", "$", "attemptid", ";", "$", "prevattempt", "=", "$", "previous", ";", "}", "else", "{", "$", "attemptlink", "=", "html_writer", "::", "link", "(", "new", "moodle_url", "(", "$", "this", "->", "baseurl", ",", "array", "(", "$", "this", "->", "pagevar", "=>", "$", "attemptid", ")", ")", ",", "$", "attemptid", ")", ";", "$", "this", "->", "attemptlinks", "[", "]", "=", "$", "attemptlink", ";", "if", "(", "empty", "(", "$", "nextattempt", ")", "&&", "$", "prevattempt", "!==", "null", ")", "{", "// Set the nextattempt var as we have set previous attempt earlier.", "$", "nextattempt", "=", "$", "attemptid", ";", "}", "}", "$", "previous", "=", "$", "attemptid", ";", "// Store this attempt as previous in case we need it.", "}", "if", "(", "$", "this", "->", "attempt", "!=", "$", "firstattempt", ")", "{", "$", "this", "->", "previouslink", "=", "html_writer", "::", "link", "(", "new", "moodle_url", "(", "$", "this", "->", "baseurl", ",", "array", "(", "$", "this", "->", "pagevar", "=>", "$", "prevattempt", ")", ")", ",", "get_string", "(", "'previous'", ")", ",", "array", "(", "'class'", "=>", "'previous'", ")", ")", ";", "}", "if", "(", "$", "this", "->", "attempt", "!=", "$", "lastattempt", ")", "{", "$", "this", "->", "nextlink", "=", "html_writer", "::", "link", "(", "new", "moodle_url", "(", "$", "this", "->", "baseurl", ",", "array", "(", "$", "this", "->", "pagevar", "=>", "$", "nextattempt", ")", ")", ",", "get_string", "(", "'next'", ")", ",", "array", "(", "'class'", "=>", "'next'", ")", ")", ";", "}", "}", "}" ]
Prepares the scorm attempt bar for output. This method validates the arguments set up for the scorm attempt bar and then produces fragments of HTML to assist display later on. @param renderer_base $output @param moodle_page $page @param string $target @throws coding_exception
[ "Prepares", "the", "scorm", "attempt", "bar", "for", "output", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/scorm/renderer.php#L155-L201
217,371
moodle/moodle
backup/util/xml/parser/processors/grouped_parser_processor.class.php
grouped_parser_processor.before_path
public function before_path($path) { if ($this->path_is_grouped($path) and !isset($this->currentdata[$path])) { // If the grouped element itself does not contain any final tags, // we would not get any chunk data for it. So we add an artificial // empty data chunk here that will be eventually replaced with // real data later in {@link self::postprocess_chunk()}. $this->currentdata[$path] = array( 'path' => $path, 'level' => substr_count($path, '/') + 1, 'tags' => array(), ); } if (!$this->grouped_parent_exists($path)) { parent::before_path($path); } }
php
public function before_path($path) { if ($this->path_is_grouped($path) and !isset($this->currentdata[$path])) { // If the grouped element itself does not contain any final tags, // we would not get any chunk data for it. So we add an artificial // empty data chunk here that will be eventually replaced with // real data later in {@link self::postprocess_chunk()}. $this->currentdata[$path] = array( 'path' => $path, 'level' => substr_count($path, '/') + 1, 'tags' => array(), ); } if (!$this->grouped_parent_exists($path)) { parent::before_path($path); } }
[ "public", "function", "before_path", "(", "$", "path", ")", "{", "if", "(", "$", "this", "->", "path_is_grouped", "(", "$", "path", ")", "and", "!", "isset", "(", "$", "this", "->", "currentdata", "[", "$", "path", "]", ")", ")", "{", "// If the grouped element itself does not contain any final tags,", "// we would not get any chunk data for it. So we add an artificial", "// empty data chunk here that will be eventually replaced with", "// real data later in {@link self::postprocess_chunk()}.", "$", "this", "->", "currentdata", "[", "$", "path", "]", "=", "array", "(", "'path'", "=>", "$", "path", ",", "'level'", "=>", "substr_count", "(", "$", "path", ",", "'/'", ")", "+", "1", ",", "'tags'", "=>", "array", "(", ")", ",", ")", ";", "}", "if", "(", "!", "$", "this", "->", "grouped_parent_exists", "(", "$", "path", ")", ")", "{", "parent", "::", "before_path", "(", "$", "path", ")", ";", "}", "}" ]
The parser fires this each time one path is going to be parsed @param string $path xml path which parsing has started
[ "The", "parser", "fires", "this", "each", "time", "one", "path", "is", "going", "to", "be", "parsed" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/xml/parser/processors/grouped_parser_processor.class.php#L117-L132
217,372
moodle/moodle
backup/util/xml/parser/processors/grouped_parser_processor.class.php
grouped_parser_processor.grouped_parent_exists
protected function grouped_parent_exists($path) { // Search the tree structure to find out if one of the paths // above the $path is a grouped path. $patharray = explode('/', $this->get_parent_path($path)); $groupedpath = ''; $currentpos = &$this->groupedparentprefixtree; foreach ($patharray as $item) { // When the item isn't set in the array we know // there is no parent grouped path. if (!isset($currentpos[$item])) { return false; } // When we aren't at the start of the path, continue to build // a string representation of the path that is traversed. We will // return the grouped path to the caller if we find one. if ($item != '') { $groupedpath .= '/'.$item; } if ($currentpos[$item] == array()) { return $groupedpath; } $currentpos = &$currentpos[$item]; } return false; }
php
protected function grouped_parent_exists($path) { // Search the tree structure to find out if one of the paths // above the $path is a grouped path. $patharray = explode('/', $this->get_parent_path($path)); $groupedpath = ''; $currentpos = &$this->groupedparentprefixtree; foreach ($patharray as $item) { // When the item isn't set in the array we know // there is no parent grouped path. if (!isset($currentpos[$item])) { return false; } // When we aren't at the start of the path, continue to build // a string representation of the path that is traversed. We will // return the grouped path to the caller if we find one. if ($item != '') { $groupedpath .= '/'.$item; } if ($currentpos[$item] == array()) { return $groupedpath; } $currentpos = &$currentpos[$item]; } return false; }
[ "protected", "function", "grouped_parent_exists", "(", "$", "path", ")", "{", "// Search the tree structure to find out if one of the paths", "// above the $path is a grouped path.", "$", "patharray", "=", "explode", "(", "'/'", ",", "$", "this", "->", "get_parent_path", "(", "$", "path", ")", ")", ";", "$", "groupedpath", "=", "''", ";", "$", "currentpos", "=", "&", "$", "this", "->", "groupedparentprefixtree", ";", "foreach", "(", "$", "patharray", "as", "$", "item", ")", "{", "// When the item isn't set in the array we know", "// there is no parent grouped path.", "if", "(", "!", "isset", "(", "$", "currentpos", "[", "$", "item", "]", ")", ")", "{", "return", "false", ";", "}", "// When we aren't at the start of the path, continue to build", "// a string representation of the path that is traversed. We will", "// return the grouped path to the caller if we find one.", "if", "(", "$", "item", "!=", "''", ")", "{", "$", "groupedpath", ".=", "'/'", ".", "$", "item", ";", "}", "if", "(", "$", "currentpos", "[", "$", "item", "]", "==", "array", "(", ")", ")", "{", "return", "$", "groupedpath", ";", "}", "$", "currentpos", "=", "&", "$", "currentpos", "[", "$", "item", "]", ";", "}", "return", "false", ";", "}" ]
Function that will look for any grouped parent for the given path, returning it if found, false if not
[ "Function", "that", "will", "look", "for", "any", "grouped", "parent", "for", "the", "given", "path", "returning", "it", "if", "found", "false", "if", "not" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/xml/parser/processors/grouped_parser_processor.class.php#L191-L217
217,373
moodle/moodle
backup/util/xml/parser/processors/grouped_parser_processor.class.php
grouped_parser_processor.get_parent_path
protected function get_parent_path($path) { if (!isset($this->parentcache[$path])) { $this->parentcache[$path] = progressive_parser::dirname($path); $this->parentcacheavailablesize--; if ($this->parentcacheavailablesize < 0) { // Older first is cheaper than LRU. We use 10% as items are grouped together and the large quiz // restore from MDL-40585 used only 600 parent paths. This is an XML heirarchy, so common paths // are grouped near each other. eg; /question_bank/question_category/question/element. After keeping // question_bank paths in the cache when we move to another area and the question_bank cache is not // useful any longer. $this->parentcache = array_slice($this->parentcache, 200, null, true); $this->parentcacheavailablesize += 200; } } return $this->parentcache[$path]; }
php
protected function get_parent_path($path) { if (!isset($this->parentcache[$path])) { $this->parentcache[$path] = progressive_parser::dirname($path); $this->parentcacheavailablesize--; if ($this->parentcacheavailablesize < 0) { // Older first is cheaper than LRU. We use 10% as items are grouped together and the large quiz // restore from MDL-40585 used only 600 parent paths. This is an XML heirarchy, so common paths // are grouped near each other. eg; /question_bank/question_category/question/element. After keeping // question_bank paths in the cache when we move to another area and the question_bank cache is not // useful any longer. $this->parentcache = array_slice($this->parentcache, 200, null, true); $this->parentcacheavailablesize += 200; } } return $this->parentcache[$path]; }
[ "protected", "function", "get_parent_path", "(", "$", "path", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "parentcache", "[", "$", "path", "]", ")", ")", "{", "$", "this", "->", "parentcache", "[", "$", "path", "]", "=", "progressive_parser", "::", "dirname", "(", "$", "path", ")", ";", "$", "this", "->", "parentcacheavailablesize", "--", ";", "if", "(", "$", "this", "->", "parentcacheavailablesize", "<", "0", ")", "{", "// Older first is cheaper than LRU. We use 10% as items are grouped together and the large quiz", "// restore from MDL-40585 used only 600 parent paths. This is an XML heirarchy, so common paths", "// are grouped near each other. eg; /question_bank/question_category/question/element. After keeping", "// question_bank paths in the cache when we move to another area and the question_bank cache is not", "// useful any longer.", "$", "this", "->", "parentcache", "=", "array_slice", "(", "$", "this", "->", "parentcache", ",", "200", ",", "null", ",", "true", ")", ";", "$", "this", "->", "parentcacheavailablesize", "+=", "200", ";", "}", "}", "return", "$", "this", "->", "parentcache", "[", "$", "path", "]", ";", "}" ]
Get the parent path using a local cache for performance. @param $path string The pathname you wish to obtain the parent name for. @return string The parent pathname.
[ "Get", "the", "parent", "path", "using", "a", "local", "cache", "for", "performance", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/xml/parser/processors/grouped_parser_processor.class.php#L225-L240
217,374
moodle/moodle
backup/util/xml/parser/processors/grouped_parser_processor.class.php
grouped_parser_processor.grouped_child_exists
protected function grouped_child_exists($path) { $childpath = $path . '/'; foreach ($this->groupedpaths as $groupedpath => $set) { if (strpos($groupedpath, $childpath) === 0) { return $groupedpath; } } return false; }
php
protected function grouped_child_exists($path) { $childpath = $path . '/'; foreach ($this->groupedpaths as $groupedpath => $set) { if (strpos($groupedpath, $childpath) === 0) { return $groupedpath; } } return false; }
[ "protected", "function", "grouped_child_exists", "(", "$", "path", ")", "{", "$", "childpath", "=", "$", "path", ".", "'/'", ";", "foreach", "(", "$", "this", "->", "groupedpaths", "as", "$", "groupedpath", "=>", "$", "set", ")", "{", "if", "(", "strpos", "(", "$", "groupedpath", ",", "$", "childpath", ")", "===", "0", ")", "{", "return", "$", "groupedpath", ";", "}", "}", "return", "false", ";", "}" ]
Function that will look for any grouped child for the given path, returning it if found, false if not
[ "Function", "that", "will", "look", "for", "any", "grouped", "child", "for", "the", "given", "path", "returning", "it", "if", "found", "false", "if", "not" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/xml/parser/processors/grouped_parser_processor.class.php#L248-L256
217,375
moodle/moodle
backup/util/xml/parser/processors/grouped_parser_processor.class.php
grouped_parser_processor.build_currentdata
protected function build_currentdata($grouped, $data) { // Check the grouped already exists into currentdata if (!is_array($this->currentdata) or !array_key_exists($grouped, $this->currentdata)) { $a = new stdclass(); $a->grouped = $grouped; $a->child = $data['path']; throw new progressive_parser_exception('xml_cannot_add_to_grouped', $a); } $this->add_missing_sub($grouped, $data['path'], $data['tags']); }
php
protected function build_currentdata($grouped, $data) { // Check the grouped already exists into currentdata if (!is_array($this->currentdata) or !array_key_exists($grouped, $this->currentdata)) { $a = new stdclass(); $a->grouped = $grouped; $a->child = $data['path']; throw new progressive_parser_exception('xml_cannot_add_to_grouped', $a); } $this->add_missing_sub($grouped, $data['path'], $data['tags']); }
[ "protected", "function", "build_currentdata", "(", "$", "grouped", ",", "$", "data", ")", "{", "// Check the grouped already exists into currentdata", "if", "(", "!", "is_array", "(", "$", "this", "->", "currentdata", ")", "or", "!", "array_key_exists", "(", "$", "grouped", ",", "$", "this", "->", "currentdata", ")", ")", "{", "$", "a", "=", "new", "stdclass", "(", ")", ";", "$", "a", "->", "grouped", "=", "$", "grouped", ";", "$", "a", "->", "child", "=", "$", "data", "[", "'path'", "]", ";", "throw", "new", "progressive_parser_exception", "(", "'xml_cannot_add_to_grouped'", ",", "$", "a", ")", ";", "}", "$", "this", "->", "add_missing_sub", "(", "$", "grouped", ",", "$", "data", "[", "'path'", "]", ",", "$", "data", "[", "'tags'", "]", ")", ";", "}" ]
This function will accumulate the chunk into the specified grouped element for later dispatching once it is complete
[ "This", "function", "will", "accumulate", "the", "chunk", "into", "the", "specified", "grouped", "element", "for", "later", "dispatching", "once", "it", "is", "complete" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/xml/parser/processors/grouped_parser_processor.class.php#L262-L271
217,376
moodle/moodle
backup/util/xml/parser/processors/grouped_parser_processor.class.php
grouped_parser_processor.add_missing_sub
protected function add_missing_sub($grouped, $path, $tags) { // Remember tag being processed $processedtag = basename($path); $info =& $this->currentdata[$grouped]['tags']; $hierarchyarr = explode('/', str_replace($grouped . '/', '', $path)); $previouselement = ''; $currentpath = ''; foreach ($hierarchyarr as $index => $element) { $currentpath = $currentpath . '/' . $element; // If element is already set and it's not // the processed one (with tags) fast move the $info // pointer and continue if ($element !== $processedtag && isset($info[$element])) { $previouselement = $element; $info =& $info[$element]; continue; } // If previous element already has occurrences // we move $info pointer there (only if last is // numeric occurrence) if (!empty($previouselement) && is_array($info) && count($info) > 0) { end($info); $key = key($info); if ((int) $key === $key) { $info =& $info[$key]; } } // Create element if not defined if (!isset($info[$element])) { // First into last element if present $info[$element] = array(); } // If element is the current one, add information if ($element === $processedtag) { $info[$element][] = $tags; } $previouselement = $element; $info =& $info[$element]; } }
php
protected function add_missing_sub($grouped, $path, $tags) { // Remember tag being processed $processedtag = basename($path); $info =& $this->currentdata[$grouped]['tags']; $hierarchyarr = explode('/', str_replace($grouped . '/', '', $path)); $previouselement = ''; $currentpath = ''; foreach ($hierarchyarr as $index => $element) { $currentpath = $currentpath . '/' . $element; // If element is already set and it's not // the processed one (with tags) fast move the $info // pointer and continue if ($element !== $processedtag && isset($info[$element])) { $previouselement = $element; $info =& $info[$element]; continue; } // If previous element already has occurrences // we move $info pointer there (only if last is // numeric occurrence) if (!empty($previouselement) && is_array($info) && count($info) > 0) { end($info); $key = key($info); if ((int) $key === $key) { $info =& $info[$key]; } } // Create element if not defined if (!isset($info[$element])) { // First into last element if present $info[$element] = array(); } // If element is the current one, add information if ($element === $processedtag) { $info[$element][] = $tags; } $previouselement = $element; $info =& $info[$element]; } }
[ "protected", "function", "add_missing_sub", "(", "$", "grouped", ",", "$", "path", ",", "$", "tags", ")", "{", "// Remember tag being processed", "$", "processedtag", "=", "basename", "(", "$", "path", ")", ";", "$", "info", "=", "&", "$", "this", "->", "currentdata", "[", "$", "grouped", "]", "[", "'tags'", "]", ";", "$", "hierarchyarr", "=", "explode", "(", "'/'", ",", "str_replace", "(", "$", "grouped", ".", "'/'", ",", "''", ",", "$", "path", ")", ")", ";", "$", "previouselement", "=", "''", ";", "$", "currentpath", "=", "''", ";", "foreach", "(", "$", "hierarchyarr", "as", "$", "index", "=>", "$", "element", ")", "{", "$", "currentpath", "=", "$", "currentpath", ".", "'/'", ".", "$", "element", ";", "// If element is already set and it's not", "// the processed one (with tags) fast move the $info", "// pointer and continue", "if", "(", "$", "element", "!==", "$", "processedtag", "&&", "isset", "(", "$", "info", "[", "$", "element", "]", ")", ")", "{", "$", "previouselement", "=", "$", "element", ";", "$", "info", "=", "&", "$", "info", "[", "$", "element", "]", ";", "continue", ";", "}", "// If previous element already has occurrences", "// we move $info pointer there (only if last is", "// numeric occurrence)", "if", "(", "!", "empty", "(", "$", "previouselement", ")", "&&", "is_array", "(", "$", "info", ")", "&&", "count", "(", "$", "info", ")", ">", "0", ")", "{", "end", "(", "$", "info", ")", ";", "$", "key", "=", "key", "(", "$", "info", ")", ";", "if", "(", "(", "int", ")", "$", "key", "===", "$", "key", ")", "{", "$", "info", "=", "&", "$", "info", "[", "$", "key", "]", ";", "}", "}", "// Create element if not defined", "if", "(", "!", "isset", "(", "$", "info", "[", "$", "element", "]", ")", ")", "{", "// First into last element if present", "$", "info", "[", "$", "element", "]", "=", "array", "(", ")", ";", "}", "// If element is the current one, add information", "if", "(", "$", "element", "===", "$", "processedtag", ")", "{", "$", "info", "[", "$", "element", "]", "[", "]", "=", "$", "tags", ";", "}", "$", "previouselement", "=", "$", "element", ";", "$", "info", "=", "&", "$", "info", "[", "$", "element", "]", ";", "}", "}" ]
Add non-existing subarray elements
[ "Add", "non", "-", "existing", "subarray", "elements" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/util/xml/parser/processors/grouped_parser_processor.class.php#L276-L325
217,377
moodle/moodle
mod/data/classes/external.php
mod_data_external.get_databases_by_courses
public static function get_databases_by_courses($courseids = array()) { global $PAGE; $params = self::validate_parameters(self::get_databases_by_courses_parameters(), array('courseids' => $courseids)); $warnings = array(); $mycourses = array(); if (empty($params['courseids'])) { $mycourses = enrol_get_my_courses(); $params['courseids'] = array_keys($mycourses); } // Array to store the databases to return. $arrdatabases = array(); // Ensure there are courseids to loop through. if (!empty($params['courseids'])) { list($dbcourses, $warnings) = external_util::validate_courses($params['courseids'], $mycourses); // Get the databases in this course, this function checks users visibility permissions. // We can avoid then additional validate_context calls. $databases = get_all_instances_in_courses("data", $dbcourses); foreach ($databases as $database) { $context = context_module::instance($database->coursemodule); // Remove fields added by get_all_instances_in_courses. unset($database->coursemodule, $database->section, $database->visible, $database->groupmode, $database->groupingid); // This information should be only available if the user can see the database entries. if (!has_capability('mod/data:viewentry', $context)) { $fields = array('comments', 'timeavailablefrom', 'timeavailableto', 'timeviewfrom', 'timeviewto', 'requiredentries', 'requiredentriestoview', 'maxentries', 'rssarticles', 'singletemplate', 'listtemplate', 'listtemplateheader', 'listtemplatefooter', 'addtemplate', 'rsstemplate', 'rsstitletemplate', 'csstemplate', 'jstemplate', 'asearchtemplate', 'approval', 'manageapproved', 'defaultsort', 'defaultsortdir'); foreach ($fields as $field) { unset($database->{$field}); } } // Check additional permissions for returning optional private settings. // I avoid intentionally to use can_[add|update]_moduleinfo. if (!has_capability('moodle/course:manageactivities', $context)) { $fields = array('scale', 'assessed', 'assesstimestart', 'assesstimefinish', 'editany', 'notification', 'timemodified'); foreach ($fields as $field) { unset($database->{$field}); } } $exporter = new database_summary_exporter($database, array('context' => $context)); $arrdatabases[] = $exporter->export($PAGE->get_renderer('core')); } } $result = array(); $result['databases'] = $arrdatabases; $result['warnings'] = $warnings; return $result; }
php
public static function get_databases_by_courses($courseids = array()) { global $PAGE; $params = self::validate_parameters(self::get_databases_by_courses_parameters(), array('courseids' => $courseids)); $warnings = array(); $mycourses = array(); if (empty($params['courseids'])) { $mycourses = enrol_get_my_courses(); $params['courseids'] = array_keys($mycourses); } // Array to store the databases to return. $arrdatabases = array(); // Ensure there are courseids to loop through. if (!empty($params['courseids'])) { list($dbcourses, $warnings) = external_util::validate_courses($params['courseids'], $mycourses); // Get the databases in this course, this function checks users visibility permissions. // We can avoid then additional validate_context calls. $databases = get_all_instances_in_courses("data", $dbcourses); foreach ($databases as $database) { $context = context_module::instance($database->coursemodule); // Remove fields added by get_all_instances_in_courses. unset($database->coursemodule, $database->section, $database->visible, $database->groupmode, $database->groupingid); // This information should be only available if the user can see the database entries. if (!has_capability('mod/data:viewentry', $context)) { $fields = array('comments', 'timeavailablefrom', 'timeavailableto', 'timeviewfrom', 'timeviewto', 'requiredentries', 'requiredentriestoview', 'maxentries', 'rssarticles', 'singletemplate', 'listtemplate', 'listtemplateheader', 'listtemplatefooter', 'addtemplate', 'rsstemplate', 'rsstitletemplate', 'csstemplate', 'jstemplate', 'asearchtemplate', 'approval', 'manageapproved', 'defaultsort', 'defaultsortdir'); foreach ($fields as $field) { unset($database->{$field}); } } // Check additional permissions for returning optional private settings. // I avoid intentionally to use can_[add|update]_moduleinfo. if (!has_capability('moodle/course:manageactivities', $context)) { $fields = array('scale', 'assessed', 'assesstimestart', 'assesstimefinish', 'editany', 'notification', 'timemodified'); foreach ($fields as $field) { unset($database->{$field}); } } $exporter = new database_summary_exporter($database, array('context' => $context)); $arrdatabases[] = $exporter->export($PAGE->get_renderer('core')); } } $result = array(); $result['databases'] = $arrdatabases; $result['warnings'] = $warnings; return $result; }
[ "public", "static", "function", "get_databases_by_courses", "(", "$", "courseids", "=", "array", "(", ")", ")", "{", "global", "$", "PAGE", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_databases_by_courses_parameters", "(", ")", ",", "array", "(", "'courseids'", "=>", "$", "courseids", ")", ")", ";", "$", "warnings", "=", "array", "(", ")", ";", "$", "mycourses", "=", "array", "(", ")", ";", "if", "(", "empty", "(", "$", "params", "[", "'courseids'", "]", ")", ")", "{", "$", "mycourses", "=", "enrol_get_my_courses", "(", ")", ";", "$", "params", "[", "'courseids'", "]", "=", "array_keys", "(", "$", "mycourses", ")", ";", "}", "// Array to store the databases to return.", "$", "arrdatabases", "=", "array", "(", ")", ";", "// Ensure there are courseids to loop through.", "if", "(", "!", "empty", "(", "$", "params", "[", "'courseids'", "]", ")", ")", "{", "list", "(", "$", "dbcourses", ",", "$", "warnings", ")", "=", "external_util", "::", "validate_courses", "(", "$", "params", "[", "'courseids'", "]", ",", "$", "mycourses", ")", ";", "// Get the databases in this course, this function checks users visibility permissions.", "// We can avoid then additional validate_context calls.", "$", "databases", "=", "get_all_instances_in_courses", "(", "\"data\"", ",", "$", "dbcourses", ")", ";", "foreach", "(", "$", "databases", "as", "$", "database", ")", "{", "$", "context", "=", "context_module", "::", "instance", "(", "$", "database", "->", "coursemodule", ")", ";", "// Remove fields added by get_all_instances_in_courses.", "unset", "(", "$", "database", "->", "coursemodule", ",", "$", "database", "->", "section", ",", "$", "database", "->", "visible", ",", "$", "database", "->", "groupmode", ",", "$", "database", "->", "groupingid", ")", ";", "// This information should be only available if the user can see the database entries.", "if", "(", "!", "has_capability", "(", "'mod/data:viewentry'", ",", "$", "context", ")", ")", "{", "$", "fields", "=", "array", "(", "'comments'", ",", "'timeavailablefrom'", ",", "'timeavailableto'", ",", "'timeviewfrom'", ",", "'timeviewto'", ",", "'requiredentries'", ",", "'requiredentriestoview'", ",", "'maxentries'", ",", "'rssarticles'", ",", "'singletemplate'", ",", "'listtemplate'", ",", "'listtemplateheader'", ",", "'listtemplatefooter'", ",", "'addtemplate'", ",", "'rsstemplate'", ",", "'rsstitletemplate'", ",", "'csstemplate'", ",", "'jstemplate'", ",", "'asearchtemplate'", ",", "'approval'", ",", "'manageapproved'", ",", "'defaultsort'", ",", "'defaultsortdir'", ")", ";", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "unset", "(", "$", "database", "->", "{", "$", "field", "}", ")", ";", "}", "}", "// Check additional permissions for returning optional private settings.", "// I avoid intentionally to use can_[add|update]_moduleinfo.", "if", "(", "!", "has_capability", "(", "'moodle/course:manageactivities'", ",", "$", "context", ")", ")", "{", "$", "fields", "=", "array", "(", "'scale'", ",", "'assessed'", ",", "'assesstimestart'", ",", "'assesstimefinish'", ",", "'editany'", ",", "'notification'", ",", "'timemodified'", ")", ";", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "unset", "(", "$", "database", "->", "{", "$", "field", "}", ")", ";", "}", "}", "$", "exporter", "=", "new", "database_summary_exporter", "(", "$", "database", ",", "array", "(", "'context'", "=>", "$", "context", ")", ")", ";", "$", "arrdatabases", "[", "]", "=", "$", "exporter", "->", "export", "(", "$", "PAGE", "->", "get_renderer", "(", "'core'", ")", ")", ";", "}", "}", "$", "result", "=", "array", "(", ")", ";", "$", "result", "[", "'databases'", "]", "=", "$", "arrdatabases", ";", "$", "result", "[", "'warnings'", "]", "=", "$", "warnings", ";", "return", "$", "result", ";", "}" ]
Returns a list of databases in a provided list of courses, if no list is provided all databases that the user can view will be returned. @param array $courseids the course ids @return array the database details @since Moodle 2.9
[ "Returns", "a", "list", "of", "databases", "in", "a", "provided", "list", "of", "courses", "if", "no", "list", "is", "provided", "all", "databases", "that", "the", "user", "can", "view", "will", "be", "returned", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/data/classes/external.php#L73-L136
217,378
moodle/moodle
mod/data/classes/external.php
mod_data_external.validate_database
protected static function validate_database($databaseid) { global $DB; // Request and permission validation. $database = $DB->get_record('data', array('id' => $databaseid), '*', MUST_EXIST); list($course, $cm) = get_course_and_cm_from_instance($database, 'data'); $context = context_module::instance($cm->id); self::validate_context($context); require_capability('mod/data:viewentry', $context); return array($database, $course, $cm, $context); }
php
protected static function validate_database($databaseid) { global $DB; // Request and permission validation. $database = $DB->get_record('data', array('id' => $databaseid), '*', MUST_EXIST); list($course, $cm) = get_course_and_cm_from_instance($database, 'data'); $context = context_module::instance($cm->id); self::validate_context($context); require_capability('mod/data:viewentry', $context); return array($database, $course, $cm, $context); }
[ "protected", "static", "function", "validate_database", "(", "$", "databaseid", ")", "{", "global", "$", "DB", ";", "// Request and permission validation.", "$", "database", "=", "$", "DB", "->", "get_record", "(", "'data'", ",", "array", "(", "'id'", "=>", "$", "databaseid", ")", ",", "'*'", ",", "MUST_EXIST", ")", ";", "list", "(", "$", "course", ",", "$", "cm", ")", "=", "get_course_and_cm_from_instance", "(", "$", "database", ",", "'data'", ")", ";", "$", "context", "=", "context_module", "::", "instance", "(", "$", "cm", "->", "id", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "require_capability", "(", "'mod/data:viewentry'", ",", "$", "context", ")", ";", "return", "array", "(", "$", "database", ",", "$", "course", ",", "$", "cm", ",", "$", "context", ")", ";", "}" ]
Utility function for validating a database. @param int $databaseid database instance id @return array array containing the database object, course, context and course module objects @since Moodle 3.3
[ "Utility", "function", "for", "validating", "a", "database", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/data/classes/external.php#L163-L175
217,379
moodle/moodle
mod/data/classes/external.php
mod_data_external.get_data_access_information
public static function get_data_access_information($databaseid, $groupid = 0) { $params = array('databaseid' => $databaseid, 'groupid' => $groupid); $params = self::validate_parameters(self::get_data_access_information_parameters(), $params); $warnings = array(); list($database, $course, $cm, $context) = self::validate_database($params['databaseid']); $result = array( 'warnings' => $warnings ); if (!empty($params['groupid'])) { $groupid = $params['groupid']; // Determine is the group is visible to user. if (!groups_group_visible($groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } else { // Check to see if groups are being used here. $groupmode = groups_get_activity_groupmode($cm); if ($groupmode) { $groupid = groups_get_activity_group($cm); } else { $groupid = 0; } } // Group related information. $result['groupid'] = $groupid; $result['canaddentry'] = data_user_can_add_entry($database, $groupid, $groupmode, $context); // Now capabilities. $result['canmanageentries'] = has_capability('mod/data:manageentries', $context); $result['canapprove'] = has_capability('mod/data:approve', $context); // Now time access restrictions. list($result['timeavailable'], $warnings) = data_get_time_availability_status($database, $result['canmanageentries']); // Other information. $result['numentries'] = data_numentries($database); $result['entrieslefttoadd'] = data_get_entries_left_to_add($database, $result['numentries'], $result['canmanageentries']); $result['entrieslefttoview'] = data_get_entries_left_to_view($database, $result['numentries'], $result['canmanageentries']); $result['inreadonlyperiod'] = data_in_readonly_period($database); return $result; }
php
public static function get_data_access_information($databaseid, $groupid = 0) { $params = array('databaseid' => $databaseid, 'groupid' => $groupid); $params = self::validate_parameters(self::get_data_access_information_parameters(), $params); $warnings = array(); list($database, $course, $cm, $context) = self::validate_database($params['databaseid']); $result = array( 'warnings' => $warnings ); if (!empty($params['groupid'])) { $groupid = $params['groupid']; // Determine is the group is visible to user. if (!groups_group_visible($groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } else { // Check to see if groups are being used here. $groupmode = groups_get_activity_groupmode($cm); if ($groupmode) { $groupid = groups_get_activity_group($cm); } else { $groupid = 0; } } // Group related information. $result['groupid'] = $groupid; $result['canaddentry'] = data_user_can_add_entry($database, $groupid, $groupmode, $context); // Now capabilities. $result['canmanageentries'] = has_capability('mod/data:manageentries', $context); $result['canapprove'] = has_capability('mod/data:approve', $context); // Now time access restrictions. list($result['timeavailable'], $warnings) = data_get_time_availability_status($database, $result['canmanageentries']); // Other information. $result['numentries'] = data_numentries($database); $result['entrieslefttoadd'] = data_get_entries_left_to_add($database, $result['numentries'], $result['canmanageentries']); $result['entrieslefttoview'] = data_get_entries_left_to_view($database, $result['numentries'], $result['canmanageentries']); $result['inreadonlyperiod'] = data_in_readonly_period($database); return $result; }
[ "public", "static", "function", "get_data_access_information", "(", "$", "databaseid", ",", "$", "groupid", "=", "0", ")", "{", "$", "params", "=", "array", "(", "'databaseid'", "=>", "$", "databaseid", ",", "'groupid'", "=>", "$", "groupid", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_data_access_information_parameters", "(", ")", ",", "$", "params", ")", ";", "$", "warnings", "=", "array", "(", ")", ";", "list", "(", "$", "database", ",", "$", "course", ",", "$", "cm", ",", "$", "context", ")", "=", "self", "::", "validate_database", "(", "$", "params", "[", "'databaseid'", "]", ")", ";", "$", "result", "=", "array", "(", "'warnings'", "=>", "$", "warnings", ")", ";", "if", "(", "!", "empty", "(", "$", "params", "[", "'groupid'", "]", ")", ")", "{", "$", "groupid", "=", "$", "params", "[", "'groupid'", "]", ";", "// Determine is the group is visible to user.", "if", "(", "!", "groups_group_visible", "(", "$", "groupid", ",", "$", "course", ",", "$", "cm", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'notingroup'", ")", ";", "}", "}", "else", "{", "// Check to see if groups are being used here.", "$", "groupmode", "=", "groups_get_activity_groupmode", "(", "$", "cm", ")", ";", "if", "(", "$", "groupmode", ")", "{", "$", "groupid", "=", "groups_get_activity_group", "(", "$", "cm", ")", ";", "}", "else", "{", "$", "groupid", "=", "0", ";", "}", "}", "// Group related information.", "$", "result", "[", "'groupid'", "]", "=", "$", "groupid", ";", "$", "result", "[", "'canaddentry'", "]", "=", "data_user_can_add_entry", "(", "$", "database", ",", "$", "groupid", ",", "$", "groupmode", ",", "$", "context", ")", ";", "// Now capabilities.", "$", "result", "[", "'canmanageentries'", "]", "=", "has_capability", "(", "'mod/data:manageentries'", ",", "$", "context", ")", ";", "$", "result", "[", "'canapprove'", "]", "=", "has_capability", "(", "'mod/data:approve'", ",", "$", "context", ")", ";", "// Now time access restrictions.", "list", "(", "$", "result", "[", "'timeavailable'", "]", ",", "$", "warnings", ")", "=", "data_get_time_availability_status", "(", "$", "database", ",", "$", "result", "[", "'canmanageentries'", "]", ")", ";", "// Other information.", "$", "result", "[", "'numentries'", "]", "=", "data_numentries", "(", "$", "database", ")", ";", "$", "result", "[", "'entrieslefttoadd'", "]", "=", "data_get_entries_left_to_add", "(", "$", "database", ",", "$", "result", "[", "'numentries'", "]", ",", "$", "result", "[", "'canmanageentries'", "]", ")", ";", "$", "result", "[", "'entrieslefttoview'", "]", "=", "data_get_entries_left_to_view", "(", "$", "database", ",", "$", "result", "[", "'numentries'", "]", ",", "$", "result", "[", "'canmanageentries'", "]", ")", ";", "$", "result", "[", "'inreadonlyperiod'", "]", "=", "data_in_readonly_period", "(", "$", "database", ")", ";", "return", "$", "result", ";", "}" ]
Return access information for a given database. @param int $databaseid the database instance id @param int $groupid (optional) group id, 0 means that the function will determine the user group @return array of warnings and access information @since Moodle 3.3 @throws moodle_exception
[ "Return", "access", "information", "for", "a", "given", "database", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/data/classes/external.php#L255-L300
217,380
moodle/moodle
mod/data/classes/external.php
mod_data_external.get_entry
public static function get_entry($entryid, $returncontents = false) { global $PAGE, $DB; $params = array('entryid' => $entryid, 'returncontents' => $returncontents); $params = self::validate_parameters(self::get_entry_parameters(), $params); $warnings = array(); $record = $DB->get_record('data_records', array('id' => $params['entryid']), '*', MUST_EXIST); list($database, $course, $cm, $context) = self::validate_database($record->dataid); // Check database is open in time. $canmanageentries = has_capability('mod/data:manageentries', $context); data_require_time_available($database, $canmanageentries); if ($record->groupid != 0) { if (!groups_group_visible($record->groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } // Check correct record entry. Group check was done before. if (!data_can_view_record($database, $record, $record->groupid, $canmanageentries)) { throw new moodle_exception('notapproved', 'data'); } $related = array('context' => $context, 'database' => $database, 'user' => null); if ($params['returncontents']) { $related['contents'] = $DB->get_records('data_content', array('recordid' => $record->id)); } else { $related['contents'] = null; } $exporter = new record_exporter($record, $related); $entry = $exporter->export($PAGE->get_renderer('core')); $result = array( 'entry' => $entry, 'ratinginfo' => \core_rating\external\util::get_rating_info($database, $context, 'mod_data', 'entry', array($record)), 'warnings' => $warnings ); // Check if we should return the entry rendered. if ($params['returncontents']) { $records = [$record]; $result['entryviewcontents'] = data_print_template('singletemplate', $records, $database, '', 0, true); } return $result; }
php
public static function get_entry($entryid, $returncontents = false) { global $PAGE, $DB; $params = array('entryid' => $entryid, 'returncontents' => $returncontents); $params = self::validate_parameters(self::get_entry_parameters(), $params); $warnings = array(); $record = $DB->get_record('data_records', array('id' => $params['entryid']), '*', MUST_EXIST); list($database, $course, $cm, $context) = self::validate_database($record->dataid); // Check database is open in time. $canmanageentries = has_capability('mod/data:manageentries', $context); data_require_time_available($database, $canmanageentries); if ($record->groupid != 0) { if (!groups_group_visible($record->groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } // Check correct record entry. Group check was done before. if (!data_can_view_record($database, $record, $record->groupid, $canmanageentries)) { throw new moodle_exception('notapproved', 'data'); } $related = array('context' => $context, 'database' => $database, 'user' => null); if ($params['returncontents']) { $related['contents'] = $DB->get_records('data_content', array('recordid' => $record->id)); } else { $related['contents'] = null; } $exporter = new record_exporter($record, $related); $entry = $exporter->export($PAGE->get_renderer('core')); $result = array( 'entry' => $entry, 'ratinginfo' => \core_rating\external\util::get_rating_info($database, $context, 'mod_data', 'entry', array($record)), 'warnings' => $warnings ); // Check if we should return the entry rendered. if ($params['returncontents']) { $records = [$record]; $result['entryviewcontents'] = data_print_template('singletemplate', $records, $database, '', 0, true); } return $result; }
[ "public", "static", "function", "get_entry", "(", "$", "entryid", ",", "$", "returncontents", "=", "false", ")", "{", "global", "$", "PAGE", ",", "$", "DB", ";", "$", "params", "=", "array", "(", "'entryid'", "=>", "$", "entryid", ",", "'returncontents'", "=>", "$", "returncontents", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_entry_parameters", "(", ")", ",", "$", "params", ")", ";", "$", "warnings", "=", "array", "(", ")", ";", "$", "record", "=", "$", "DB", "->", "get_record", "(", "'data_records'", ",", "array", "(", "'id'", "=>", "$", "params", "[", "'entryid'", "]", ")", ",", "'*'", ",", "MUST_EXIST", ")", ";", "list", "(", "$", "database", ",", "$", "course", ",", "$", "cm", ",", "$", "context", ")", "=", "self", "::", "validate_database", "(", "$", "record", "->", "dataid", ")", ";", "// Check database is open in time.", "$", "canmanageentries", "=", "has_capability", "(", "'mod/data:manageentries'", ",", "$", "context", ")", ";", "data_require_time_available", "(", "$", "database", ",", "$", "canmanageentries", ")", ";", "if", "(", "$", "record", "->", "groupid", "!=", "0", ")", "{", "if", "(", "!", "groups_group_visible", "(", "$", "record", "->", "groupid", ",", "$", "course", ",", "$", "cm", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'notingroup'", ")", ";", "}", "}", "// Check correct record entry. Group check was done before.", "if", "(", "!", "data_can_view_record", "(", "$", "database", ",", "$", "record", ",", "$", "record", "->", "groupid", ",", "$", "canmanageentries", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'notapproved'", ",", "'data'", ")", ";", "}", "$", "related", "=", "array", "(", "'context'", "=>", "$", "context", ",", "'database'", "=>", "$", "database", ",", "'user'", "=>", "null", ")", ";", "if", "(", "$", "params", "[", "'returncontents'", "]", ")", "{", "$", "related", "[", "'contents'", "]", "=", "$", "DB", "->", "get_records", "(", "'data_content'", ",", "array", "(", "'recordid'", "=>", "$", "record", "->", "id", ")", ")", ";", "}", "else", "{", "$", "related", "[", "'contents'", "]", "=", "null", ";", "}", "$", "exporter", "=", "new", "record_exporter", "(", "$", "record", ",", "$", "related", ")", ";", "$", "entry", "=", "$", "exporter", "->", "export", "(", "$", "PAGE", "->", "get_renderer", "(", "'core'", ")", ")", ";", "$", "result", "=", "array", "(", "'entry'", "=>", "$", "entry", ",", "'ratinginfo'", "=>", "\\", "core_rating", "\\", "external", "\\", "util", "::", "get_rating_info", "(", "$", "database", ",", "$", "context", ",", "'mod_data'", ",", "'entry'", ",", "array", "(", "$", "record", ")", ")", ",", "'warnings'", "=>", "$", "warnings", ")", ";", "// Check if we should return the entry rendered.", "if", "(", "$", "params", "[", "'returncontents'", "]", ")", "{", "$", "records", "=", "[", "$", "record", "]", ";", "$", "result", "[", "'entryviewcontents'", "]", "=", "data_print_template", "(", "'singletemplate'", ",", "$", "records", ",", "$", "database", ",", "''", ",", "0", ",", "true", ")", ";", "}", "return", "$", "result", ";", "}" ]
Return one entry record from the database, including contents optionally. @param int $entryid the record entry id id @param bool $returncontents whether to return the entries contents or not @return array of warnings and the entries @since Moodle 3.3 @throws moodle_exception
[ "Return", "one", "entry", "record", "from", "the", "database", "including", "contents", "optionally", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/data/classes/external.php#L502-L548
217,381
moodle/moodle
mod/data/classes/external.php
mod_data_external.get_fields
public static function get_fields($databaseid) { global $PAGE; $params = array('databaseid' => $databaseid); $params = self::validate_parameters(self::get_fields_parameters(), $params); $fields = $warnings = array(); list($database, $course, $cm, $context) = self::validate_database($params['databaseid']); // Check database is open in time. $canmanageentries = has_capability('mod/data:manageentries', $context); data_require_time_available($database, $canmanageentries); $fieldinstances = data_get_field_instances($database); foreach ($fieldinstances as $fieldinstance) { $record = $fieldinstance->field; // Now get the configs the user can see with his current permissions. $configs = $fieldinstance->get_config_for_external(); foreach ($configs as $name => $value) { // Overwrite. $record->{$name} = $value; } $exporter = new field_exporter($record, array('context' => $context)); $fields[] = $exporter->export($PAGE->get_renderer('core')); } $result = array( 'fields' => $fields, 'warnings' => $warnings ); return $result; }
php
public static function get_fields($databaseid) { global $PAGE; $params = array('databaseid' => $databaseid); $params = self::validate_parameters(self::get_fields_parameters(), $params); $fields = $warnings = array(); list($database, $course, $cm, $context) = self::validate_database($params['databaseid']); // Check database is open in time. $canmanageentries = has_capability('mod/data:manageentries', $context); data_require_time_available($database, $canmanageentries); $fieldinstances = data_get_field_instances($database); foreach ($fieldinstances as $fieldinstance) { $record = $fieldinstance->field; // Now get the configs the user can see with his current permissions. $configs = $fieldinstance->get_config_for_external(); foreach ($configs as $name => $value) { // Overwrite. $record->{$name} = $value; } $exporter = new field_exporter($record, array('context' => $context)); $fields[] = $exporter->export($PAGE->get_renderer('core')); } $result = array( 'fields' => $fields, 'warnings' => $warnings ); return $result; }
[ "public", "static", "function", "get_fields", "(", "$", "databaseid", ")", "{", "global", "$", "PAGE", ";", "$", "params", "=", "array", "(", "'databaseid'", "=>", "$", "databaseid", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_fields_parameters", "(", ")", ",", "$", "params", ")", ";", "$", "fields", "=", "$", "warnings", "=", "array", "(", ")", ";", "list", "(", "$", "database", ",", "$", "course", ",", "$", "cm", ",", "$", "context", ")", "=", "self", "::", "validate_database", "(", "$", "params", "[", "'databaseid'", "]", ")", ";", "// Check database is open in time.", "$", "canmanageentries", "=", "has_capability", "(", "'mod/data:manageentries'", ",", "$", "context", ")", ";", "data_require_time_available", "(", "$", "database", ",", "$", "canmanageentries", ")", ";", "$", "fieldinstances", "=", "data_get_field_instances", "(", "$", "database", ")", ";", "foreach", "(", "$", "fieldinstances", "as", "$", "fieldinstance", ")", "{", "$", "record", "=", "$", "fieldinstance", "->", "field", ";", "// Now get the configs the user can see with his current permissions.", "$", "configs", "=", "$", "fieldinstance", "->", "get_config_for_external", "(", ")", ";", "foreach", "(", "$", "configs", "as", "$", "name", "=>", "$", "value", ")", "{", "// Overwrite.", "$", "record", "->", "{", "$", "name", "}", "=", "$", "value", ";", "}", "$", "exporter", "=", "new", "field_exporter", "(", "$", "record", ",", "array", "(", "'context'", "=>", "$", "context", ")", ")", ";", "$", "fields", "[", "]", "=", "$", "exporter", "->", "export", "(", "$", "PAGE", "->", "get_renderer", "(", "'core'", ")", ")", ";", "}", "$", "result", "=", "array", "(", "'fields'", "=>", "$", "fields", ",", "'warnings'", "=>", "$", "warnings", ")", ";", "return", "$", "result", ";", "}" ]
Return the list of configured fields for the given database. @param int $databaseid the database id @return array of warnings and the fields @since Moodle 3.3 @throws moodle_exception
[ "Return", "the", "list", "of", "configured", "fields", "for", "the", "given", "database", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/data/classes/external.php#L589-L622
217,382
moodle/moodle
mod/data/classes/external.php
mod_data_external.approve_entry
public static function approve_entry($entryid, $approve = true) { global $PAGE, $DB; $params = array('entryid' => $entryid, 'approve' => $approve); $params = self::validate_parameters(self::approve_entry_parameters(), $params); $warnings = array(); $record = $DB->get_record('data_records', array('id' => $params['entryid']), '*', MUST_EXIST); list($database, $course, $cm, $context) = self::validate_database($record->dataid); // Check database is open in time. data_require_time_available($database, null, $context); // Check specific capabilities. require_capability('mod/data:approve', $context); data_approve_entry($record->id, $params['approve']); $result = array( 'status' => true, 'warnings' => $warnings ); return $result; }
php
public static function approve_entry($entryid, $approve = true) { global $PAGE, $DB; $params = array('entryid' => $entryid, 'approve' => $approve); $params = self::validate_parameters(self::approve_entry_parameters(), $params); $warnings = array(); $record = $DB->get_record('data_records', array('id' => $params['entryid']), '*', MUST_EXIST); list($database, $course, $cm, $context) = self::validate_database($record->dataid); // Check database is open in time. data_require_time_available($database, null, $context); // Check specific capabilities. require_capability('mod/data:approve', $context); data_approve_entry($record->id, $params['approve']); $result = array( 'status' => true, 'warnings' => $warnings ); return $result; }
[ "public", "static", "function", "approve_entry", "(", "$", "entryid", ",", "$", "approve", "=", "true", ")", "{", "global", "$", "PAGE", ",", "$", "DB", ";", "$", "params", "=", "array", "(", "'entryid'", "=>", "$", "entryid", ",", "'approve'", "=>", "$", "approve", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "approve_entry_parameters", "(", ")", ",", "$", "params", ")", ";", "$", "warnings", "=", "array", "(", ")", ";", "$", "record", "=", "$", "DB", "->", "get_record", "(", "'data_records'", ",", "array", "(", "'id'", "=>", "$", "params", "[", "'entryid'", "]", ")", ",", "'*'", ",", "MUST_EXIST", ")", ";", "list", "(", "$", "database", ",", "$", "course", ",", "$", "cm", ",", "$", "context", ")", "=", "self", "::", "validate_database", "(", "$", "record", "->", "dataid", ")", ";", "// Check database is open in time.", "data_require_time_available", "(", "$", "database", ",", "null", ",", "$", "context", ")", ";", "// Check specific capabilities.", "require_capability", "(", "'mod/data:approve'", ",", "$", "context", ")", ";", "data_approve_entry", "(", "$", "record", "->", "id", ",", "$", "params", "[", "'approve'", "]", ")", ";", "$", "result", "=", "array", "(", "'status'", "=>", "true", ",", "'warnings'", "=>", "$", "warnings", ")", ";", "return", "$", "result", ";", "}" ]
Approves or unapproves an entry. @param int $entryid the record entry id id @param bool $approve whether to approve (true) or unapprove the entry @return array of warnings and the entries @since Moodle 3.3 @throws moodle_exception
[ "Approves", "or", "unapproves", "an", "entry", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/data/classes/external.php#L837-L858
217,383
moodle/moodle
mod/data/classes/external.php
mod_data_external.delete_entry
public static function delete_entry($entryid) { global $PAGE, $DB; $params = array('entryid' => $entryid); $params = self::validate_parameters(self::delete_entry_parameters(), $params); $warnings = array(); $record = $DB->get_record('data_records', array('id' => $params['entryid']), '*', MUST_EXIST); list($database, $course, $cm, $context) = self::validate_database($record->dataid); if (data_user_can_manage_entry($record, $database, $context)) { data_delete_record($record->id, $database, $course->id, $cm->id); } else { throw new moodle_exception('noaccess', 'data'); } $result = array( 'status' => true, 'warnings' => $warnings ); return $result; }
php
public static function delete_entry($entryid) { global $PAGE, $DB; $params = array('entryid' => $entryid); $params = self::validate_parameters(self::delete_entry_parameters(), $params); $warnings = array(); $record = $DB->get_record('data_records', array('id' => $params['entryid']), '*', MUST_EXIST); list($database, $course, $cm, $context) = self::validate_database($record->dataid); if (data_user_can_manage_entry($record, $database, $context)) { data_delete_record($record->id, $database, $course->id, $cm->id); } else { throw new moodle_exception('noaccess', 'data'); } $result = array( 'status' => true, 'warnings' => $warnings ); return $result; }
[ "public", "static", "function", "delete_entry", "(", "$", "entryid", ")", "{", "global", "$", "PAGE", ",", "$", "DB", ";", "$", "params", "=", "array", "(", "'entryid'", "=>", "$", "entryid", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "delete_entry_parameters", "(", ")", ",", "$", "params", ")", ";", "$", "warnings", "=", "array", "(", ")", ";", "$", "record", "=", "$", "DB", "->", "get_record", "(", "'data_records'", ",", "array", "(", "'id'", "=>", "$", "params", "[", "'entryid'", "]", ")", ",", "'*'", ",", "MUST_EXIST", ")", ";", "list", "(", "$", "database", ",", "$", "course", ",", "$", "cm", ",", "$", "context", ")", "=", "self", "::", "validate_database", "(", "$", "record", "->", "dataid", ")", ";", "if", "(", "data_user_can_manage_entry", "(", "$", "record", ",", "$", "database", ",", "$", "context", ")", ")", "{", "data_delete_record", "(", "$", "record", "->", "id", ",", "$", "database", ",", "$", "course", "->", "id", ",", "$", "cm", "->", "id", ")", ";", "}", "else", "{", "throw", "new", "moodle_exception", "(", "'noaccess'", ",", "'data'", ")", ";", "}", "$", "result", "=", "array", "(", "'status'", "=>", "true", ",", "'warnings'", "=>", "$", "warnings", ")", ";", "return", "$", "result", ";", "}" ]
Deletes an entry. @param int $entryid the record entry id @return array of warnings success status @since Moodle 3.3 @throws moodle_exception
[ "Deletes", "an", "entry", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/data/classes/external.php#L897-L918
217,384
moodle/moodle
mod/data/classes/external.php
mod_data_external.add_entry
public static function add_entry($databaseid, $groupid, $data) { global $DB; $params = array('databaseid' => $databaseid, 'groupid' => $groupid, 'data' => $data); $params = self::validate_parameters(self::add_entry_parameters(), $params); $warnings = array(); $fieldnotifications = array(); list($database, $course, $cm, $context) = self::validate_database($params['databaseid']); // Check database is open in time. data_require_time_available($database, null, $context); // Determine default group. if (empty($params['groupid'])) { // Check to see if groups are being used here. $groupmode = groups_get_activity_groupmode($cm); if ($groupmode) { $groupid = groups_get_activity_group($cm); } else { $groupid = 0; } } // Group is validated inside the function. if (!data_user_can_add_entry($database, $groupid, $groupmode, $context)) { throw new moodle_exception('noaccess', 'data'); } // Prepare the data as is expected by the API. $datarecord = new stdClass; foreach ($params['data'] as $data) { $subfield = ($data['subfield'] !== '') ? '_' . $data['subfield'] : ''; // We ask for JSON encoded values because of multiple choice forms or checkboxes that use array parameters. $datarecord->{'field_' . $data['fieldid'] . $subfield} = json_decode($data['value']); } // Validate to ensure that enough data was submitted. $fields = $DB->get_records('data_fields', array('dataid' => $database->id)); $processeddata = data_process_submission($database, $fields, $datarecord); // Format notifications. if (!empty($processeddata->fieldnotifications)) { foreach ($processeddata->fieldnotifications as $field => $notififications) { foreach ($notififications as $notif) { $fieldnotifications[] = [ 'fieldname' => $field, 'notification' => $notif, ]; } } } // Create a new (empty) record. $newentryid = 0; if ($processeddata->validated && $recordid = data_add_record($database, $groupid)) { $newentryid = $recordid; // Now populate the fields contents of the new record. data_add_fields_contents_to_new_record($database, $context, $recordid, $fields, $datarecord, $processeddata); } $result = array( 'newentryid' => $newentryid, 'generalnotifications' => $processeddata->generalnotifications, 'fieldnotifications' => $fieldnotifications, ); return $result; }
php
public static function add_entry($databaseid, $groupid, $data) { global $DB; $params = array('databaseid' => $databaseid, 'groupid' => $groupid, 'data' => $data); $params = self::validate_parameters(self::add_entry_parameters(), $params); $warnings = array(); $fieldnotifications = array(); list($database, $course, $cm, $context) = self::validate_database($params['databaseid']); // Check database is open in time. data_require_time_available($database, null, $context); // Determine default group. if (empty($params['groupid'])) { // Check to see if groups are being used here. $groupmode = groups_get_activity_groupmode($cm); if ($groupmode) { $groupid = groups_get_activity_group($cm); } else { $groupid = 0; } } // Group is validated inside the function. if (!data_user_can_add_entry($database, $groupid, $groupmode, $context)) { throw new moodle_exception('noaccess', 'data'); } // Prepare the data as is expected by the API. $datarecord = new stdClass; foreach ($params['data'] as $data) { $subfield = ($data['subfield'] !== '') ? '_' . $data['subfield'] : ''; // We ask for JSON encoded values because of multiple choice forms or checkboxes that use array parameters. $datarecord->{'field_' . $data['fieldid'] . $subfield} = json_decode($data['value']); } // Validate to ensure that enough data was submitted. $fields = $DB->get_records('data_fields', array('dataid' => $database->id)); $processeddata = data_process_submission($database, $fields, $datarecord); // Format notifications. if (!empty($processeddata->fieldnotifications)) { foreach ($processeddata->fieldnotifications as $field => $notififications) { foreach ($notififications as $notif) { $fieldnotifications[] = [ 'fieldname' => $field, 'notification' => $notif, ]; } } } // Create a new (empty) record. $newentryid = 0; if ($processeddata->validated && $recordid = data_add_record($database, $groupid)) { $newentryid = $recordid; // Now populate the fields contents of the new record. data_add_fields_contents_to_new_record($database, $context, $recordid, $fields, $datarecord, $processeddata); } $result = array( 'newentryid' => $newentryid, 'generalnotifications' => $processeddata->generalnotifications, 'fieldnotifications' => $fieldnotifications, ); return $result; }
[ "public", "static", "function", "add_entry", "(", "$", "databaseid", ",", "$", "groupid", ",", "$", "data", ")", "{", "global", "$", "DB", ";", "$", "params", "=", "array", "(", "'databaseid'", "=>", "$", "databaseid", ",", "'groupid'", "=>", "$", "groupid", ",", "'data'", "=>", "$", "data", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "add_entry_parameters", "(", ")", ",", "$", "params", ")", ";", "$", "warnings", "=", "array", "(", ")", ";", "$", "fieldnotifications", "=", "array", "(", ")", ";", "list", "(", "$", "database", ",", "$", "course", ",", "$", "cm", ",", "$", "context", ")", "=", "self", "::", "validate_database", "(", "$", "params", "[", "'databaseid'", "]", ")", ";", "// Check database is open in time.", "data_require_time_available", "(", "$", "database", ",", "null", ",", "$", "context", ")", ";", "// Determine default group.", "if", "(", "empty", "(", "$", "params", "[", "'groupid'", "]", ")", ")", "{", "// Check to see if groups are being used here.", "$", "groupmode", "=", "groups_get_activity_groupmode", "(", "$", "cm", ")", ";", "if", "(", "$", "groupmode", ")", "{", "$", "groupid", "=", "groups_get_activity_group", "(", "$", "cm", ")", ";", "}", "else", "{", "$", "groupid", "=", "0", ";", "}", "}", "// Group is validated inside the function.", "if", "(", "!", "data_user_can_add_entry", "(", "$", "database", ",", "$", "groupid", ",", "$", "groupmode", ",", "$", "context", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'noaccess'", ",", "'data'", ")", ";", "}", "// Prepare the data as is expected by the API.", "$", "datarecord", "=", "new", "stdClass", ";", "foreach", "(", "$", "params", "[", "'data'", "]", "as", "$", "data", ")", "{", "$", "subfield", "=", "(", "$", "data", "[", "'subfield'", "]", "!==", "''", ")", "?", "'_'", ".", "$", "data", "[", "'subfield'", "]", ":", "''", ";", "// We ask for JSON encoded values because of multiple choice forms or checkboxes that use array parameters.", "$", "datarecord", "->", "{", "'field_'", ".", "$", "data", "[", "'fieldid'", "]", ".", "$", "subfield", "}", "=", "json_decode", "(", "$", "data", "[", "'value'", "]", ")", ";", "}", "// Validate to ensure that enough data was submitted.", "$", "fields", "=", "$", "DB", "->", "get_records", "(", "'data_fields'", ",", "array", "(", "'dataid'", "=>", "$", "database", "->", "id", ")", ")", ";", "$", "processeddata", "=", "data_process_submission", "(", "$", "database", ",", "$", "fields", ",", "$", "datarecord", ")", ";", "// Format notifications.", "if", "(", "!", "empty", "(", "$", "processeddata", "->", "fieldnotifications", ")", ")", "{", "foreach", "(", "$", "processeddata", "->", "fieldnotifications", "as", "$", "field", "=>", "$", "notififications", ")", "{", "foreach", "(", "$", "notififications", "as", "$", "notif", ")", "{", "$", "fieldnotifications", "[", "]", "=", "[", "'fieldname'", "=>", "$", "field", ",", "'notification'", "=>", "$", "notif", ",", "]", ";", "}", "}", "}", "// Create a new (empty) record.", "$", "newentryid", "=", "0", ";", "if", "(", "$", "processeddata", "->", "validated", "&&", "$", "recordid", "=", "data_add_record", "(", "$", "database", ",", "$", "groupid", ")", ")", "{", "$", "newentryid", "=", "$", "recordid", ";", "// Now populate the fields contents of the new record.", "data_add_fields_contents_to_new_record", "(", "$", "database", ",", "$", "context", ",", "$", "recordid", ",", "$", "fields", ",", "$", "datarecord", ",", "$", "processeddata", ")", ";", "}", "$", "result", "=", "array", "(", "'newentryid'", "=>", "$", "newentryid", ",", "'generalnotifications'", "=>", "$", "processeddata", "->", "generalnotifications", ",", "'fieldnotifications'", "=>", "$", "fieldnotifications", ",", ")", ";", "return", "$", "result", ";", "}" ]
Adds a new entry to a database @param int $databaseid the data instance id @param int $groupid (optional) group id, 0 means that the function will determine the user group @param array $data the fields data to be created @return array of warnings and status result @since Moodle 3.3 @throws moodle_exception
[ "Adds", "a", "new", "entry", "to", "a", "database" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/data/classes/external.php#L970-L1035
217,385
moodle/moodle
mod/data/classes/external.php
mod_data_external.update_entry
public static function update_entry($entryid, $data) { global $DB; $params = array('entryid' => $entryid, 'data' => $data); $params = self::validate_parameters(self::update_entry_parameters(), $params); $warnings = array(); $fieldnotifications = array(); $updated = false; $record = $DB->get_record('data_records', array('id' => $params['entryid']), '*', MUST_EXIST); list($database, $course, $cm, $context) = self::validate_database($record->dataid); // Check database is open in time. data_require_time_available($database, null, $context); if (!data_user_can_manage_entry($record, $database, $context)) { throw new moodle_exception('noaccess', 'data'); } // Prepare the data as is expected by the API. $datarecord = new stdClass; foreach ($params['data'] as $data) { $subfield = ($data['subfield'] !== '') ? '_' . $data['subfield'] : ''; // We ask for JSON encoded values because of multiple choice forms or checkboxes that use array parameters. $datarecord->{'field_' . $data['fieldid'] . $subfield} = json_decode($data['value']); } // Validate to ensure that enough data was submitted. $fields = $DB->get_records('data_fields', array('dataid' => $database->id)); $processeddata = data_process_submission($database, $fields, $datarecord); // Format notifications. if (!empty($processeddata->fieldnotifications)) { foreach ($processeddata->fieldnotifications as $field => $notififications) { foreach ($notififications as $notif) { $fieldnotifications[] = [ 'fieldname' => $field, 'notification' => $notif, ]; } } } if ($processeddata->validated) { // Now update the fields contents. data_update_record_fields_contents($database, $record, $context, $datarecord, $processeddata); $updated = true; } $result = array( 'updated' => $updated, 'generalnotifications' => $processeddata->generalnotifications, 'fieldnotifications' => $fieldnotifications, 'warnings' => $warnings, ); return $result; }
php
public static function update_entry($entryid, $data) { global $DB; $params = array('entryid' => $entryid, 'data' => $data); $params = self::validate_parameters(self::update_entry_parameters(), $params); $warnings = array(); $fieldnotifications = array(); $updated = false; $record = $DB->get_record('data_records', array('id' => $params['entryid']), '*', MUST_EXIST); list($database, $course, $cm, $context) = self::validate_database($record->dataid); // Check database is open in time. data_require_time_available($database, null, $context); if (!data_user_can_manage_entry($record, $database, $context)) { throw new moodle_exception('noaccess', 'data'); } // Prepare the data as is expected by the API. $datarecord = new stdClass; foreach ($params['data'] as $data) { $subfield = ($data['subfield'] !== '') ? '_' . $data['subfield'] : ''; // We ask for JSON encoded values because of multiple choice forms or checkboxes that use array parameters. $datarecord->{'field_' . $data['fieldid'] . $subfield} = json_decode($data['value']); } // Validate to ensure that enough data was submitted. $fields = $DB->get_records('data_fields', array('dataid' => $database->id)); $processeddata = data_process_submission($database, $fields, $datarecord); // Format notifications. if (!empty($processeddata->fieldnotifications)) { foreach ($processeddata->fieldnotifications as $field => $notififications) { foreach ($notififications as $notif) { $fieldnotifications[] = [ 'fieldname' => $field, 'notification' => $notif, ]; } } } if ($processeddata->validated) { // Now update the fields contents. data_update_record_fields_contents($database, $record, $context, $datarecord, $processeddata); $updated = true; } $result = array( 'updated' => $updated, 'generalnotifications' => $processeddata->generalnotifications, 'fieldnotifications' => $fieldnotifications, 'warnings' => $warnings, ); return $result; }
[ "public", "static", "function", "update_entry", "(", "$", "entryid", ",", "$", "data", ")", "{", "global", "$", "DB", ";", "$", "params", "=", "array", "(", "'entryid'", "=>", "$", "entryid", ",", "'data'", "=>", "$", "data", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "update_entry_parameters", "(", ")", ",", "$", "params", ")", ";", "$", "warnings", "=", "array", "(", ")", ";", "$", "fieldnotifications", "=", "array", "(", ")", ";", "$", "updated", "=", "false", ";", "$", "record", "=", "$", "DB", "->", "get_record", "(", "'data_records'", ",", "array", "(", "'id'", "=>", "$", "params", "[", "'entryid'", "]", ")", ",", "'*'", ",", "MUST_EXIST", ")", ";", "list", "(", "$", "database", ",", "$", "course", ",", "$", "cm", ",", "$", "context", ")", "=", "self", "::", "validate_database", "(", "$", "record", "->", "dataid", ")", ";", "// Check database is open in time.", "data_require_time_available", "(", "$", "database", ",", "null", ",", "$", "context", ")", ";", "if", "(", "!", "data_user_can_manage_entry", "(", "$", "record", ",", "$", "database", ",", "$", "context", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'noaccess'", ",", "'data'", ")", ";", "}", "// Prepare the data as is expected by the API.", "$", "datarecord", "=", "new", "stdClass", ";", "foreach", "(", "$", "params", "[", "'data'", "]", "as", "$", "data", ")", "{", "$", "subfield", "=", "(", "$", "data", "[", "'subfield'", "]", "!==", "''", ")", "?", "'_'", ".", "$", "data", "[", "'subfield'", "]", ":", "''", ";", "// We ask for JSON encoded values because of multiple choice forms or checkboxes that use array parameters.", "$", "datarecord", "->", "{", "'field_'", ".", "$", "data", "[", "'fieldid'", "]", ".", "$", "subfield", "}", "=", "json_decode", "(", "$", "data", "[", "'value'", "]", ")", ";", "}", "// Validate to ensure that enough data was submitted.", "$", "fields", "=", "$", "DB", "->", "get_records", "(", "'data_fields'", ",", "array", "(", "'dataid'", "=>", "$", "database", "->", "id", ")", ")", ";", "$", "processeddata", "=", "data_process_submission", "(", "$", "database", ",", "$", "fields", ",", "$", "datarecord", ")", ";", "// Format notifications.", "if", "(", "!", "empty", "(", "$", "processeddata", "->", "fieldnotifications", ")", ")", "{", "foreach", "(", "$", "processeddata", "->", "fieldnotifications", "as", "$", "field", "=>", "$", "notififications", ")", "{", "foreach", "(", "$", "notififications", "as", "$", "notif", ")", "{", "$", "fieldnotifications", "[", "]", "=", "[", "'fieldname'", "=>", "$", "field", ",", "'notification'", "=>", "$", "notif", ",", "]", ";", "}", "}", "}", "if", "(", "$", "processeddata", "->", "validated", ")", "{", "// Now update the fields contents.", "data_update_record_fields_contents", "(", "$", "database", ",", "$", "record", ",", "$", "context", ",", "$", "datarecord", ",", "$", "processeddata", ")", ";", "$", "updated", "=", "true", ";", "}", "$", "result", "=", "array", "(", "'updated'", "=>", "$", "updated", ",", "'generalnotifications'", "=>", "$", "processeddata", "->", "generalnotifications", ",", "'fieldnotifications'", "=>", "$", "fieldnotifications", ",", "'warnings'", "=>", "$", "warnings", ",", ")", ";", "return", "$", "result", ";", "}" ]
Updates an existing entry. @param int $entryid the data instance id @param array $data the fields data to be created @return array of warnings and status result @since Moodle 3.3 @throws moodle_exception
[ "Updates", "an", "existing", "entry", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/data/classes/external.php#L1095-L1149
217,386
moodle/moodle
mod/lti/backup/moodle2/restore_lti_stepslib.php
restore_lti_activity_structure_step.process_ltitype
protected function process_ltitype($data) { global $DB, $USER; $data = (object)$data; $oldid = $data->id; if (!empty($data->createdby)) { $data->createdby = $this->get_mappingid('user', $data->createdby) ?: $USER->id; } $courseid = $this->get_courseid(); $data->course = ($this->get_mappingid('course', $data->course) == $courseid) ? $courseid : SITEID; // Try to find existing lti type with the same properties. $ltitypeid = $this->find_existing_lti_type($data); $this->newltitype = false; if (!$ltitypeid && $data->course == $courseid) { unset($data->toolproxyid); // Course tools can not use LTI2. $ltitypeid = $DB->insert_record('lti_types', $data); $this->newltitype = true; $this->set_mapping('ltitype', $oldid, $ltitypeid); } // Add the typeid entry back to LTI module. $DB->update_record('lti', ['id' => $this->get_new_parentid('lti'), 'typeid' => $ltitypeid]); }
php
protected function process_ltitype($data) { global $DB, $USER; $data = (object)$data; $oldid = $data->id; if (!empty($data->createdby)) { $data->createdby = $this->get_mappingid('user', $data->createdby) ?: $USER->id; } $courseid = $this->get_courseid(); $data->course = ($this->get_mappingid('course', $data->course) == $courseid) ? $courseid : SITEID; // Try to find existing lti type with the same properties. $ltitypeid = $this->find_existing_lti_type($data); $this->newltitype = false; if (!$ltitypeid && $data->course == $courseid) { unset($data->toolproxyid); // Course tools can not use LTI2. $ltitypeid = $DB->insert_record('lti_types', $data); $this->newltitype = true; $this->set_mapping('ltitype', $oldid, $ltitypeid); } // Add the typeid entry back to LTI module. $DB->update_record('lti', ['id' => $this->get_new_parentid('lti'), 'typeid' => $ltitypeid]); }
[ "protected", "function", "process_ltitype", "(", "$", "data", ")", "{", "global", "$", "DB", ",", "$", "USER", ";", "$", "data", "=", "(", "object", ")", "$", "data", ";", "$", "oldid", "=", "$", "data", "->", "id", ";", "if", "(", "!", "empty", "(", "$", "data", "->", "createdby", ")", ")", "{", "$", "data", "->", "createdby", "=", "$", "this", "->", "get_mappingid", "(", "'user'", ",", "$", "data", "->", "createdby", ")", "?", ":", "$", "USER", "->", "id", ";", "}", "$", "courseid", "=", "$", "this", "->", "get_courseid", "(", ")", ";", "$", "data", "->", "course", "=", "(", "$", "this", "->", "get_mappingid", "(", "'course'", ",", "$", "data", "->", "course", ")", "==", "$", "courseid", ")", "?", "$", "courseid", ":", "SITEID", ";", "// Try to find existing lti type with the same properties.", "$", "ltitypeid", "=", "$", "this", "->", "find_existing_lti_type", "(", "$", "data", ")", ";", "$", "this", "->", "newltitype", "=", "false", ";", "if", "(", "!", "$", "ltitypeid", "&&", "$", "data", "->", "course", "==", "$", "courseid", ")", "{", "unset", "(", "$", "data", "->", "toolproxyid", ")", ";", "// Course tools can not use LTI2.", "$", "ltitypeid", "=", "$", "DB", "->", "insert_record", "(", "'lti_types'", ",", "$", "data", ")", ";", "$", "this", "->", "newltitype", "=", "true", ";", "$", "this", "->", "set_mapping", "(", "'ltitype'", ",", "$", "oldid", ",", "$", "ltitypeid", ")", ";", "}", "// Add the typeid entry back to LTI module.", "$", "DB", "->", "update_record", "(", "'lti'", ",", "[", "'id'", "=>", "$", "this", "->", "get_new_parentid", "(", "'lti'", ")", ",", "'typeid'", "=>", "$", "ltitypeid", "]", ")", ";", "}" ]
Process an lti type restore @param mixed $data The data from backup XML file @return void
[ "Process", "an", "lti", "type", "restore" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lti/backup/moodle2/restore_lti_stepslib.php#L119-L144
217,387
moodle/moodle
mod/lti/backup/moodle2/restore_lti_stepslib.php
restore_lti_activity_structure_step.find_existing_lti_type
protected function find_existing_lti_type($data) { global $DB; if ($ltitypeid = $this->get_mappingid('ltitype', $data->id)) { return $ltitypeid; } $ltitype = null; $params = (array)$data; if ($this->task->is_samesite()) { // If we are restoring on the same site try to find lti type with the same id. $sql = 'id = :id AND course = :course'; $sql .= ($data->toolproxyid) ? ' AND toolproxyid = :toolproxyid' : ' AND toolproxyid IS NULL'; if ($DB->record_exists_select('lti_types', $sql, $params)) { $this->set_mapping('ltitype', $data->id, $data->id); if ($data->toolproxyid) { $this->set_mapping('ltitoolproxy', $data->toolproxyid, $data->toolproxyid); } return $data->id; } } if ($data->course != $this->get_courseid()) { // Site tools are not backed up and are not restored. return null; } // Now try to find the same type on the current site available in this course. // Compare only fields baseurl, course and name, if they are the same we assume it is the same tool. // LTI2 is not possible in the course so we add "lt.toolproxyid IS NULL" to the query. $sql = 'SELECT id FROM {lti_types} WHERE ' . $DB->sql_compare_text('baseurl', 255) . ' = ' . $DB->sql_compare_text(':baseurl', 255) . ' AND course = :course AND name = :name AND toolproxyid IS NULL'; if ($ltitype = $DB->get_record_sql($sql, $params, IGNORE_MULTIPLE)) { $this->set_mapping('ltitype', $data->id, $ltitype->id); return $ltitype->id; } return null; }
php
protected function find_existing_lti_type($data) { global $DB; if ($ltitypeid = $this->get_mappingid('ltitype', $data->id)) { return $ltitypeid; } $ltitype = null; $params = (array)$data; if ($this->task->is_samesite()) { // If we are restoring on the same site try to find lti type with the same id. $sql = 'id = :id AND course = :course'; $sql .= ($data->toolproxyid) ? ' AND toolproxyid = :toolproxyid' : ' AND toolproxyid IS NULL'; if ($DB->record_exists_select('lti_types', $sql, $params)) { $this->set_mapping('ltitype', $data->id, $data->id); if ($data->toolproxyid) { $this->set_mapping('ltitoolproxy', $data->toolproxyid, $data->toolproxyid); } return $data->id; } } if ($data->course != $this->get_courseid()) { // Site tools are not backed up and are not restored. return null; } // Now try to find the same type on the current site available in this course. // Compare only fields baseurl, course and name, if they are the same we assume it is the same tool. // LTI2 is not possible in the course so we add "lt.toolproxyid IS NULL" to the query. $sql = 'SELECT id FROM {lti_types} WHERE ' . $DB->sql_compare_text('baseurl', 255) . ' = ' . $DB->sql_compare_text(':baseurl', 255) . ' AND course = :course AND name = :name AND toolproxyid IS NULL'; if ($ltitype = $DB->get_record_sql($sql, $params, IGNORE_MULTIPLE)) { $this->set_mapping('ltitype', $data->id, $ltitype->id); return $ltitype->id; } return null; }
[ "protected", "function", "find_existing_lti_type", "(", "$", "data", ")", "{", "global", "$", "DB", ";", "if", "(", "$", "ltitypeid", "=", "$", "this", "->", "get_mappingid", "(", "'ltitype'", ",", "$", "data", "->", "id", ")", ")", "{", "return", "$", "ltitypeid", ";", "}", "$", "ltitype", "=", "null", ";", "$", "params", "=", "(", "array", ")", "$", "data", ";", "if", "(", "$", "this", "->", "task", "->", "is_samesite", "(", ")", ")", "{", "// If we are restoring on the same site try to find lti type with the same id.", "$", "sql", "=", "'id = :id AND course = :course'", ";", "$", "sql", ".=", "(", "$", "data", "->", "toolproxyid", ")", "?", "' AND toolproxyid = :toolproxyid'", ":", "' AND toolproxyid IS NULL'", ";", "if", "(", "$", "DB", "->", "record_exists_select", "(", "'lti_types'", ",", "$", "sql", ",", "$", "params", ")", ")", "{", "$", "this", "->", "set_mapping", "(", "'ltitype'", ",", "$", "data", "->", "id", ",", "$", "data", "->", "id", ")", ";", "if", "(", "$", "data", "->", "toolproxyid", ")", "{", "$", "this", "->", "set_mapping", "(", "'ltitoolproxy'", ",", "$", "data", "->", "toolproxyid", ",", "$", "data", "->", "toolproxyid", ")", ";", "}", "return", "$", "data", "->", "id", ";", "}", "}", "if", "(", "$", "data", "->", "course", "!=", "$", "this", "->", "get_courseid", "(", ")", ")", "{", "// Site tools are not backed up and are not restored.", "return", "null", ";", "}", "// Now try to find the same type on the current site available in this course.", "// Compare only fields baseurl, course and name, if they are the same we assume it is the same tool.", "// LTI2 is not possible in the course so we add \"lt.toolproxyid IS NULL\" to the query.", "$", "sql", "=", "'SELECT id\n FROM {lti_types}\n WHERE '", ".", "$", "DB", "->", "sql_compare_text", "(", "'baseurl'", ",", "255", ")", ".", "' = '", ".", "$", "DB", "->", "sql_compare_text", "(", "':baseurl'", ",", "255", ")", ".", "' AND\n course = :course AND name = :name AND toolproxyid IS NULL'", ";", "if", "(", "$", "ltitype", "=", "$", "DB", "->", "get_record_sql", "(", "$", "sql", ",", "$", "params", ",", "IGNORE_MULTIPLE", ")", ")", "{", "$", "this", "->", "set_mapping", "(", "'ltitype'", ",", "$", "data", "->", "id", ",", "$", "ltitype", "->", "id", ")", ";", "return", "$", "ltitype", "->", "id", ";", "}", "return", "null", ";", "}" ]
Attempts to find existing record in lti_type @param stdClass $data @return int|null field lti_types.id or null if tool is not found
[ "Attempts", "to", "find", "existing", "record", "in", "lti_type" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lti/backup/moodle2/restore_lti_stepslib.php#L151-L190
217,388
moodle/moodle
lib/horde/framework/Horde/Support/Numerizer/Locale/De.php
Horde_Support_Numerizer_Locale_De._replaceTenPrefixes
protected function _replaceTenPrefixes($string) { foreach ($this->TEN_PREFIXES as $tp => $tp_replacement) { $string = preg_replace_callback( "/(?:$tp)( *\d(?=[^\d]|\$))*/i", function ($m) use ($tp_replacement) { return $tp_replacement + (isset($m[1]) ? (int)$m[1] : 0); }, $string ); } return $string; }
php
protected function _replaceTenPrefixes($string) { foreach ($this->TEN_PREFIXES as $tp => $tp_replacement) { $string = preg_replace_callback( "/(?:$tp)( *\d(?=[^\d]|\$))*/i", function ($m) use ($tp_replacement) { return $tp_replacement + (isset($m[1]) ? (int)$m[1] : 0); }, $string ); } return $string; }
[ "protected", "function", "_replaceTenPrefixes", "(", "$", "string", ")", "{", "foreach", "(", "$", "this", "->", "TEN_PREFIXES", "as", "$", "tp", "=>", "$", "tp_replacement", ")", "{", "$", "string", "=", "preg_replace_callback", "(", "\"/(?:$tp)( *\\d(?=[^\\d]|\\$))*/i\"", ",", "function", "(", "$", "m", ")", "use", "(", "$", "tp_replacement", ")", "{", "return", "$", "tp_replacement", "+", "(", "isset", "(", "$", "m", "[", "1", "]", ")", "?", "(", "int", ")", "$", "m", "[", "1", "]", ":", "0", ")", ";", "}", ",", "$", "string", ")", ";", "}", "return", "$", "string", ";", "}" ]
ten, twenty, etc.
[ "ten", "twenty", "etc", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Support/Numerizer/Locale/De.php#L84-L96
217,389
moodle/moodle
lib/horde/framework/Horde/Support/Numerizer/Locale/De.php
Horde_Support_Numerizer_Locale_De._replaceBigPrefixes
protected function _replaceBigPrefixes($string) { foreach ($this->BIG_PREFIXES as $bp => $bp_replacement) { $string = preg_replace_callback( '/(\d*) *' . $bp . '(\d?)/i', function ($m) use ($bp_replacement) { $factor = (int)$m[1]; if (!$factor) { $factor = 1; } return ($bp_replacement * $factor) . ($bp_replacement == 100 ? ($m[2] ? 'und' : '') : 'und') . $m[2]; }, $string ); $string = $this->_andition($string); } return $string; }
php
protected function _replaceBigPrefixes($string) { foreach ($this->BIG_PREFIXES as $bp => $bp_replacement) { $string = preg_replace_callback( '/(\d*) *' . $bp . '(\d?)/i', function ($m) use ($bp_replacement) { $factor = (int)$m[1]; if (!$factor) { $factor = 1; } return ($bp_replacement * $factor) . ($bp_replacement == 100 ? ($m[2] ? 'und' : '') : 'und') . $m[2]; }, $string ); $string = $this->_andition($string); } return $string; }
[ "protected", "function", "_replaceBigPrefixes", "(", "$", "string", ")", "{", "foreach", "(", "$", "this", "->", "BIG_PREFIXES", "as", "$", "bp", "=>", "$", "bp_replacement", ")", "{", "$", "string", "=", "preg_replace_callback", "(", "'/(\\d*) *'", ".", "$", "bp", ".", "'(\\d?)/i'", ",", "function", "(", "$", "m", ")", "use", "(", "$", "bp_replacement", ")", "{", "$", "factor", "=", "(", "int", ")", "$", "m", "[", "1", "]", ";", "if", "(", "!", "$", "factor", ")", "{", "$", "factor", "=", "1", ";", "}", "return", "(", "$", "bp_replacement", "*", "$", "factor", ")", ".", "(", "$", "bp_replacement", "==", "100", "?", "(", "$", "m", "[", "2", "]", "?", "'und'", ":", "''", ")", ":", "'und'", ")", ".", "$", "m", "[", "2", "]", ";", "}", ",", "$", "string", ")", ";", "$", "string", "=", "$", "this", "->", "_andition", "(", "$", "string", ")", ";", "}", "return", "$", "string", ";", "}" ]
hundreds, thousands, millions, etc.
[ "hundreds", "thousands", "millions", "etc", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Support/Numerizer/Locale/De.php#L101-L120
217,390
moodle/moodle
question/classes/bank/column_base.php
column_base.display_header
public function display_header() { echo '<th class="header ' . $this->get_classes() . '" scope="col">'; $sortable = $this->is_sortable(); $name = get_class($this); $title = $this->get_title(); $tip = $this->get_title_tip(); if (is_array($sortable)) { if ($title) { echo '<div class="title">' . $title . '</div>'; } $links = array(); foreach ($sortable as $subsort => $details) { $links[] = $this->make_sort_link($name . '-' . $subsort, $details['title'], isset($details['tip']) ? $details['tip'] : '', !empty($details['reverse'])); } echo '<div class="sorters">' . implode(' / ', $links) . '</div>'; } else if ($sortable) { echo $this->make_sort_link($name, $title, $tip); } else { if ($tip) { echo '<span title="' . $tip . '">'; } echo $title; if ($tip) { echo '</span>'; } } echo "</th>\n"; }
php
public function display_header() { echo '<th class="header ' . $this->get_classes() . '" scope="col">'; $sortable = $this->is_sortable(); $name = get_class($this); $title = $this->get_title(); $tip = $this->get_title_tip(); if (is_array($sortable)) { if ($title) { echo '<div class="title">' . $title . '</div>'; } $links = array(); foreach ($sortable as $subsort => $details) { $links[] = $this->make_sort_link($name . '-' . $subsort, $details['title'], isset($details['tip']) ? $details['tip'] : '', !empty($details['reverse'])); } echo '<div class="sorters">' . implode(' / ', $links) . '</div>'; } else if ($sortable) { echo $this->make_sort_link($name, $title, $tip); } else { if ($tip) { echo '<span title="' . $tip . '">'; } echo $title; if ($tip) { echo '</span>'; } } echo "</th>\n"; }
[ "public", "function", "display_header", "(", ")", "{", "echo", "'<th class=\"header '", ".", "$", "this", "->", "get_classes", "(", ")", ".", "'\" scope=\"col\">'", ";", "$", "sortable", "=", "$", "this", "->", "is_sortable", "(", ")", ";", "$", "name", "=", "get_class", "(", "$", "this", ")", ";", "$", "title", "=", "$", "this", "->", "get_title", "(", ")", ";", "$", "tip", "=", "$", "this", "->", "get_title_tip", "(", ")", ";", "if", "(", "is_array", "(", "$", "sortable", ")", ")", "{", "if", "(", "$", "title", ")", "{", "echo", "'<div class=\"title\">'", ".", "$", "title", ".", "'</div>'", ";", "}", "$", "links", "=", "array", "(", ")", ";", "foreach", "(", "$", "sortable", "as", "$", "subsort", "=>", "$", "details", ")", "{", "$", "links", "[", "]", "=", "$", "this", "->", "make_sort_link", "(", "$", "name", ".", "'-'", ".", "$", "subsort", ",", "$", "details", "[", "'title'", "]", ",", "isset", "(", "$", "details", "[", "'tip'", "]", ")", "?", "$", "details", "[", "'tip'", "]", ":", "''", ",", "!", "empty", "(", "$", "details", "[", "'reverse'", "]", ")", ")", ";", "}", "echo", "'<div class=\"sorters\">'", ".", "implode", "(", "' / '", ",", "$", "links", ")", ".", "'</div>'", ";", "}", "else", "if", "(", "$", "sortable", ")", "{", "echo", "$", "this", "->", "make_sort_link", "(", "$", "name", ",", "$", "title", ",", "$", "tip", ")", ";", "}", "else", "{", "if", "(", "$", "tip", ")", "{", "echo", "'<span title=\"'", ".", "$", "tip", ".", "'\">'", ";", "}", "echo", "$", "title", ";", "if", "(", "$", "tip", ")", "{", "echo", "'</span>'", ";", "}", "}", "echo", "\"</th>\\n\"", ";", "}" ]
Output the column header cell.
[ "Output", "the", "column", "header", "cell", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/bank/column_base.php#L74-L102
217,391
moodle/moodle
question/classes/bank/column_base.php
column_base.make_sort_link
protected function make_sort_link($sort, $title, $tip, $defaultreverse = false) { $currentsort = $this->qbank->get_primary_sort_order($sort); $newsortreverse = $defaultreverse; if ($currentsort) { $newsortreverse = $currentsort > 0; } if (!$tip) { $tip = $title; } if ($newsortreverse) { $tip = get_string('sortbyxreverse', '', $tip); } else { $tip = get_string('sortbyx', '', $tip); } $link = '<a href="' . $this->qbank->new_sort_url($sort, $newsortreverse) . '" title="' . $tip . '">'; $link .= $title; if ($currentsort) { $link .= $this->get_sort_icon($currentsort < 0); } $link .= '</a>'; return $link; }
php
protected function make_sort_link($sort, $title, $tip, $defaultreverse = false) { $currentsort = $this->qbank->get_primary_sort_order($sort); $newsortreverse = $defaultreverse; if ($currentsort) { $newsortreverse = $currentsort > 0; } if (!$tip) { $tip = $title; } if ($newsortreverse) { $tip = get_string('sortbyxreverse', '', $tip); } else { $tip = get_string('sortbyx', '', $tip); } $link = '<a href="' . $this->qbank->new_sort_url($sort, $newsortreverse) . '" title="' . $tip . '">'; $link .= $title; if ($currentsort) { $link .= $this->get_sort_icon($currentsort < 0); } $link .= '</a>'; return $link; }
[ "protected", "function", "make_sort_link", "(", "$", "sort", ",", "$", "title", ",", "$", "tip", ",", "$", "defaultreverse", "=", "false", ")", "{", "$", "currentsort", "=", "$", "this", "->", "qbank", "->", "get_primary_sort_order", "(", "$", "sort", ")", ";", "$", "newsortreverse", "=", "$", "defaultreverse", ";", "if", "(", "$", "currentsort", ")", "{", "$", "newsortreverse", "=", "$", "currentsort", ">", "0", ";", "}", "if", "(", "!", "$", "tip", ")", "{", "$", "tip", "=", "$", "title", ";", "}", "if", "(", "$", "newsortreverse", ")", "{", "$", "tip", "=", "get_string", "(", "'sortbyxreverse'", ",", "''", ",", "$", "tip", ")", ";", "}", "else", "{", "$", "tip", "=", "get_string", "(", "'sortbyx'", ",", "''", ",", "$", "tip", ")", ";", "}", "$", "link", "=", "'<a href=\"'", ".", "$", "this", "->", "qbank", "->", "new_sort_url", "(", "$", "sort", ",", "$", "newsortreverse", ")", ".", "'\" title=\"'", ".", "$", "tip", ".", "'\">'", ";", "$", "link", ".=", "$", "title", ";", "if", "(", "$", "currentsort", ")", "{", "$", "link", ".=", "$", "this", "->", "get_sort_icon", "(", "$", "currentsort", "<", "0", ")", ";", "}", "$", "link", ".=", "'</a>'", ";", "return", "$", "link", ";", "}" ]
Get a link that changes the sort order, and indicates the current sort state. @param $name internal name used for this type of sorting. @param $currentsort the current sort order -1, 0, 1 for descending, none, ascending. @param $title the link text. @param $defaultreverse whether the default sort order for this column is descending, rather than ascending. @return string HTML fragment.
[ "Get", "a", "link", "that", "changes", "the", "sort", "order", "and", "indicates", "the", "current", "sort", "state", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/bank/column_base.php#L127-L148
217,392
moodle/moodle
question/classes/bank/column_base.php
column_base.get_sort_icon
protected function get_sort_icon($reverse) { global $OUTPUT; if ($reverse) { return $OUTPUT->pix_icon('t/sort_desc', get_string('desc'), '', array('class' => 'iconsort')); } else { return $OUTPUT->pix_icon('t/sort_asc', get_string('asc'), '', array('class' => 'iconsort')); } }
php
protected function get_sort_icon($reverse) { global $OUTPUT; if ($reverse) { return $OUTPUT->pix_icon('t/sort_desc', get_string('desc'), '', array('class' => 'iconsort')); } else { return $OUTPUT->pix_icon('t/sort_asc', get_string('asc'), '', array('class' => 'iconsort')); } }
[ "protected", "function", "get_sort_icon", "(", "$", "reverse", ")", "{", "global", "$", "OUTPUT", ";", "if", "(", "$", "reverse", ")", "{", "return", "$", "OUTPUT", "->", "pix_icon", "(", "'t/sort_desc'", ",", "get_string", "(", "'desc'", ")", ",", "''", ",", "array", "(", "'class'", "=>", "'iconsort'", ")", ")", ";", "}", "else", "{", "return", "$", "OUTPUT", "->", "pix_icon", "(", "'t/sort_asc'", ",", "get_string", "(", "'asc'", ")", ",", "''", ",", "array", "(", "'class'", "=>", "'iconsort'", ")", ")", ";", "}", "}" ]
Get an icon representing the corrent sort state. @param $reverse sort is descending, not ascending. @return string HTML image tag.
[ "Get", "an", "icon", "representing", "the", "corrent", "sort", "state", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/bank/column_base.php#L155-L162
217,393
moodle/moodle
question/classes/bank/column_base.php
column_base.display
public function display($question, $rowclasses) { $this->display_start($question, $rowclasses); $this->display_content($question, $rowclasses); $this->display_end($question, $rowclasses); }
php
public function display($question, $rowclasses) { $this->display_start($question, $rowclasses); $this->display_content($question, $rowclasses); $this->display_end($question, $rowclasses); }
[ "public", "function", "display", "(", "$", "question", ",", "$", "rowclasses", ")", "{", "$", "this", "->", "display_start", "(", "$", "question", ",", "$", "rowclasses", ")", ";", "$", "this", "->", "display_content", "(", "$", "question", ",", "$", "rowclasses", ")", ";", "$", "this", "->", "display_end", "(", "$", "question", ",", "$", "rowclasses", ")", ";", "}" ]
Output this column. @param object $question the row from the $question table, augmented with extra information. @param string $rowclasses CSS class names that should be applied to this row of output.
[ "Output", "this", "column", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/bank/column_base.php#L169-L173
217,394
moodle/moodle
question/classes/bank/column_base.php
column_base.display_end
protected function display_end($question, $rowclasses) { $tag = 'td'; if ($this->isheading) { $tag = 'th'; } echo \html_writer::end_tag($tag); }
php
protected function display_end($question, $rowclasses) { $tag = 'td'; if ($this->isheading) { $tag = 'th'; } echo \html_writer::end_tag($tag); }
[ "protected", "function", "display_end", "(", "$", "question", ",", "$", "rowclasses", ")", "{", "$", "tag", "=", "'td'", ";", "if", "(", "$", "this", "->", "isheading", ")", "{", "$", "tag", "=", "'th'", ";", "}", "echo", "\\", "html_writer", "::", "end_tag", "(", "$", "tag", ")", ";", "}" ]
Output the closing column tag @param object $question @param string $rowclasses
[ "Output", "the", "closing", "column", "tag" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/classes/bank/column_base.php#L227-L233
217,395
moodle/moodle
blocks/online_users/classes/fetcher.php
fetcher.get_users
public function get_users($userlimit = 0) { global $DB; $users = $DB->get_records_sql($this->sql, $this->params, 0, $userlimit); return $users; }
php
public function get_users($userlimit = 0) { global $DB; $users = $DB->get_records_sql($this->sql, $this->params, 0, $userlimit); return $users; }
[ "public", "function", "get_users", "(", "$", "userlimit", "=", "0", ")", "{", "global", "$", "DB", ";", "$", "users", "=", "$", "DB", "->", "get_records_sql", "(", "$", "this", "->", "sql", ",", "$", "this", "->", "params", ",", "0", ",", "$", "userlimit", ")", ";", "return", "$", "users", ";", "}" ]
Get a list of the most recent online users @param int $userlimit The maximum number of users that will be returned (optional, unlimited if not set) @return array
[ "Get", "a", "list", "of", "the", "most", "recent", "online", "users" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/blocks/online_users/classes/fetcher.php#L175-L179
217,396
moodle/moodle
mod/lesson/backup/moodle1/lib.php
moodle1_mod_lesson_handler.write_single_page_xml
protected function write_single_page_xml($page, $prevpageid=0, $nextpageid=0) { //mince nextpageid and prevpageid $page->data['nextpageid'] = $nextpageid; $page->data['prevpageid'] = $prevpageid; // write out each page data $this->xmlwriter->begin_tag('page', array('id' => $page->id)); foreach ($page->data as $field => $value) { $this->xmlwriter->full_tag($field, $value); } //effectively on_lesson_answers_end(), where we write out answers for current page. $answers = $page->answers; $this->xmlwriter->begin_tag('answers'); $numanswers = count($answers); if ($numanswers) { //if there are any answers (possible there are none!) if ($numanswers > 3 && $page->data['qtype'] == 5) { //fix only jumpto only for matching question types. if ($answers[0]['jumpto'] !== '0' || $answers[1]['jumpto'] !== '0') { if ($answers[2]['jumpto'] !== '0') { $answers[0]['jumpto'] = $answers[2]['jumpto']; $answers[2]['jumpto'] = '0'; } if ($answers[3]['jumpto'] !== '0') { $answers[1]['jumpto'] = $answers[3]['jumpto']; $answers[3]['jumpto'] = '0'; } } } foreach ($answers as $data) { $this->write_xml('answer', $data, array('/answer/id')); } } $this->xmlwriter->end_tag('answers'); // answers is now closed for current page. Ending the page. $this->xmlwriter->end_tag('page'); }
php
protected function write_single_page_xml($page, $prevpageid=0, $nextpageid=0) { //mince nextpageid and prevpageid $page->data['nextpageid'] = $nextpageid; $page->data['prevpageid'] = $prevpageid; // write out each page data $this->xmlwriter->begin_tag('page', array('id' => $page->id)); foreach ($page->data as $field => $value) { $this->xmlwriter->full_tag($field, $value); } //effectively on_lesson_answers_end(), where we write out answers for current page. $answers = $page->answers; $this->xmlwriter->begin_tag('answers'); $numanswers = count($answers); if ($numanswers) { //if there are any answers (possible there are none!) if ($numanswers > 3 && $page->data['qtype'] == 5) { //fix only jumpto only for matching question types. if ($answers[0]['jumpto'] !== '0' || $answers[1]['jumpto'] !== '0') { if ($answers[2]['jumpto'] !== '0') { $answers[0]['jumpto'] = $answers[2]['jumpto']; $answers[2]['jumpto'] = '0'; } if ($answers[3]['jumpto'] !== '0') { $answers[1]['jumpto'] = $answers[3]['jumpto']; $answers[3]['jumpto'] = '0'; } } } foreach ($answers as $data) { $this->write_xml('answer', $data, array('/answer/id')); } } $this->xmlwriter->end_tag('answers'); // answers is now closed for current page. Ending the page. $this->xmlwriter->end_tag('page'); }
[ "protected", "function", "write_single_page_xml", "(", "$", "page", ",", "$", "prevpageid", "=", "0", ",", "$", "nextpageid", "=", "0", ")", "{", "//mince nextpageid and prevpageid", "$", "page", "->", "data", "[", "'nextpageid'", "]", "=", "$", "nextpageid", ";", "$", "page", "->", "data", "[", "'prevpageid'", "]", "=", "$", "prevpageid", ";", "// write out each page data", "$", "this", "->", "xmlwriter", "->", "begin_tag", "(", "'page'", ",", "array", "(", "'id'", "=>", "$", "page", "->", "id", ")", ")", ";", "foreach", "(", "$", "page", "->", "data", "as", "$", "field", "=>", "$", "value", ")", "{", "$", "this", "->", "xmlwriter", "->", "full_tag", "(", "$", "field", ",", "$", "value", ")", ";", "}", "//effectively on_lesson_answers_end(), where we write out answers for current page.", "$", "answers", "=", "$", "page", "->", "answers", ";", "$", "this", "->", "xmlwriter", "->", "begin_tag", "(", "'answers'", ")", ";", "$", "numanswers", "=", "count", "(", "$", "answers", ")", ";", "if", "(", "$", "numanswers", ")", "{", "//if there are any answers (possible there are none!)", "if", "(", "$", "numanswers", ">", "3", "&&", "$", "page", "->", "data", "[", "'qtype'", "]", "==", "5", ")", "{", "//fix only jumpto only for matching question types.", "if", "(", "$", "answers", "[", "0", "]", "[", "'jumpto'", "]", "!==", "'0'", "||", "$", "answers", "[", "1", "]", "[", "'jumpto'", "]", "!==", "'0'", ")", "{", "if", "(", "$", "answers", "[", "2", "]", "[", "'jumpto'", "]", "!==", "'0'", ")", "{", "$", "answers", "[", "0", "]", "[", "'jumpto'", "]", "=", "$", "answers", "[", "2", "]", "[", "'jumpto'", "]", ";", "$", "answers", "[", "2", "]", "[", "'jumpto'", "]", "=", "'0'", ";", "}", "if", "(", "$", "answers", "[", "3", "]", "[", "'jumpto'", "]", "!==", "'0'", ")", "{", "$", "answers", "[", "1", "]", "[", "'jumpto'", "]", "=", "$", "answers", "[", "3", "]", "[", "'jumpto'", "]", ";", "$", "answers", "[", "3", "]", "[", "'jumpto'", "]", "=", "'0'", ";", "}", "}", "}", "foreach", "(", "$", "answers", "as", "$", "data", ")", "{", "$", "this", "->", "write_xml", "(", "'answer'", ",", "$", "data", ",", "array", "(", "'/answer/id'", ")", ")", ";", "}", "}", "$", "this", "->", "xmlwriter", "->", "end_tag", "(", "'answers'", ")", ";", "// answers is now closed for current page. Ending the page.", "$", "this", "->", "xmlwriter", "->", "end_tag", "(", "'page'", ")", ";", "}" ]
writes out the given page into the open xml handle @param type $page @param type $prevpageid @param type $nextpageid
[ "writes", "out", "the", "given", "page", "into", "the", "open", "xml", "handle" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/backup/moodle1/lib.php#L262-L302
217,397
moodle/moodle
lib/htmlpurifier/HTMLPurifier/Printer/HTMLDefinition.php
HTMLPurifier_Printer_HTMLDefinition.renderDoctype
protected function renderDoctype() { $doctype = $this->def->doctype; $ret = ''; $ret .= $this->start('table'); $ret .= $this->element('caption', 'Doctype'); $ret .= $this->row('Name', $doctype->name); $ret .= $this->row('XML', $doctype->xml ? 'Yes' : 'No'); $ret .= $this->row('Default Modules', implode($doctype->modules, ', ')); $ret .= $this->row('Default Tidy Modules', implode($doctype->tidyModules, ', ')); $ret .= $this->end('table'); return $ret; }
php
protected function renderDoctype() { $doctype = $this->def->doctype; $ret = ''; $ret .= $this->start('table'); $ret .= $this->element('caption', 'Doctype'); $ret .= $this->row('Name', $doctype->name); $ret .= $this->row('XML', $doctype->xml ? 'Yes' : 'No'); $ret .= $this->row('Default Modules', implode($doctype->modules, ', ')); $ret .= $this->row('Default Tidy Modules', implode($doctype->tidyModules, ', ')); $ret .= $this->end('table'); return $ret; }
[ "protected", "function", "renderDoctype", "(", ")", "{", "$", "doctype", "=", "$", "this", "->", "def", "->", "doctype", ";", "$", "ret", "=", "''", ";", "$", "ret", ".=", "$", "this", "->", "start", "(", "'table'", ")", ";", "$", "ret", ".=", "$", "this", "->", "element", "(", "'caption'", ",", "'Doctype'", ")", ";", "$", "ret", ".=", "$", "this", "->", "row", "(", "'Name'", ",", "$", "doctype", "->", "name", ")", ";", "$", "ret", ".=", "$", "this", "->", "row", "(", "'XML'", ",", "$", "doctype", "->", "xml", "?", "'Yes'", ":", "'No'", ")", ";", "$", "ret", ".=", "$", "this", "->", "row", "(", "'Default Modules'", ",", "implode", "(", "$", "doctype", "->", "modules", ",", "', '", ")", ")", ";", "$", "ret", ".=", "$", "this", "->", "row", "(", "'Default Tidy Modules'", ",", "implode", "(", "$", "doctype", "->", "tidyModules", ",", "', '", ")", ")", ";", "$", "ret", ".=", "$", "this", "->", "end", "(", "'table'", ")", ";", "return", "$", "ret", ";", "}" ]
Renders the Doctype table @return string
[ "Renders", "the", "Doctype", "table" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/htmlpurifier/HTMLPurifier/Printer/HTMLDefinition.php#L38-L50
217,398
moodle/moodle
lib/htmlpurifier/HTMLPurifier/Printer/HTMLDefinition.php
HTMLPurifier_Printer_HTMLDefinition.renderEnvironment
protected function renderEnvironment() { $def = $this->def; $ret = ''; $ret .= $this->start('table'); $ret .= $this->element('caption', 'Environment'); $ret .= $this->row('Parent of fragment', $def->info_parent); $ret .= $this->renderChildren($def->info_parent_def->child); $ret .= $this->row('Block wrap name', $def->info_block_wrapper); $ret .= $this->start('tr'); $ret .= $this->element('th', 'Global attributes'); $ret .= $this->element('td', $this->listifyAttr($def->info_global_attr), null, 0); $ret .= $this->end('tr'); $ret .= $this->start('tr'); $ret .= $this->element('th', 'Tag transforms'); $list = array(); foreach ($def->info_tag_transform as $old => $new) { $new = $this->getClass($new, 'TagTransform_'); $list[] = "<$old> with $new"; } $ret .= $this->element('td', $this->listify($list)); $ret .= $this->end('tr'); $ret .= $this->start('tr'); $ret .= $this->element('th', 'Pre-AttrTransform'); $ret .= $this->element('td', $this->listifyObjectList($def->info_attr_transform_pre)); $ret .= $this->end('tr'); $ret .= $this->start('tr'); $ret .= $this->element('th', 'Post-AttrTransform'); $ret .= $this->element('td', $this->listifyObjectList($def->info_attr_transform_post)); $ret .= $this->end('tr'); $ret .= $this->end('table'); return $ret; }
php
protected function renderEnvironment() { $def = $this->def; $ret = ''; $ret .= $this->start('table'); $ret .= $this->element('caption', 'Environment'); $ret .= $this->row('Parent of fragment', $def->info_parent); $ret .= $this->renderChildren($def->info_parent_def->child); $ret .= $this->row('Block wrap name', $def->info_block_wrapper); $ret .= $this->start('tr'); $ret .= $this->element('th', 'Global attributes'); $ret .= $this->element('td', $this->listifyAttr($def->info_global_attr), null, 0); $ret .= $this->end('tr'); $ret .= $this->start('tr'); $ret .= $this->element('th', 'Tag transforms'); $list = array(); foreach ($def->info_tag_transform as $old => $new) { $new = $this->getClass($new, 'TagTransform_'); $list[] = "<$old> with $new"; } $ret .= $this->element('td', $this->listify($list)); $ret .= $this->end('tr'); $ret .= $this->start('tr'); $ret .= $this->element('th', 'Pre-AttrTransform'); $ret .= $this->element('td', $this->listifyObjectList($def->info_attr_transform_pre)); $ret .= $this->end('tr'); $ret .= $this->start('tr'); $ret .= $this->element('th', 'Post-AttrTransform'); $ret .= $this->element('td', $this->listifyObjectList($def->info_attr_transform_post)); $ret .= $this->end('tr'); $ret .= $this->end('table'); return $ret; }
[ "protected", "function", "renderEnvironment", "(", ")", "{", "$", "def", "=", "$", "this", "->", "def", ";", "$", "ret", "=", "''", ";", "$", "ret", ".=", "$", "this", "->", "start", "(", "'table'", ")", ";", "$", "ret", ".=", "$", "this", "->", "element", "(", "'caption'", ",", "'Environment'", ")", ";", "$", "ret", ".=", "$", "this", "->", "row", "(", "'Parent of fragment'", ",", "$", "def", "->", "info_parent", ")", ";", "$", "ret", ".=", "$", "this", "->", "renderChildren", "(", "$", "def", "->", "info_parent_def", "->", "child", ")", ";", "$", "ret", ".=", "$", "this", "->", "row", "(", "'Block wrap name'", ",", "$", "def", "->", "info_block_wrapper", ")", ";", "$", "ret", ".=", "$", "this", "->", "start", "(", "'tr'", ")", ";", "$", "ret", ".=", "$", "this", "->", "element", "(", "'th'", ",", "'Global attributes'", ")", ";", "$", "ret", ".=", "$", "this", "->", "element", "(", "'td'", ",", "$", "this", "->", "listifyAttr", "(", "$", "def", "->", "info_global_attr", ")", ",", "null", ",", "0", ")", ";", "$", "ret", ".=", "$", "this", "->", "end", "(", "'tr'", ")", ";", "$", "ret", ".=", "$", "this", "->", "start", "(", "'tr'", ")", ";", "$", "ret", ".=", "$", "this", "->", "element", "(", "'th'", ",", "'Tag transforms'", ")", ";", "$", "list", "=", "array", "(", ")", ";", "foreach", "(", "$", "def", "->", "info_tag_transform", "as", "$", "old", "=>", "$", "new", ")", "{", "$", "new", "=", "$", "this", "->", "getClass", "(", "$", "new", ",", "'TagTransform_'", ")", ";", "$", "list", "[", "]", "=", "\"<$old> with $new\"", ";", "}", "$", "ret", ".=", "$", "this", "->", "element", "(", "'td'", ",", "$", "this", "->", "listify", "(", "$", "list", ")", ")", ";", "$", "ret", ".=", "$", "this", "->", "end", "(", "'tr'", ")", ";", "$", "ret", ".=", "$", "this", "->", "start", "(", "'tr'", ")", ";", "$", "ret", ".=", "$", "this", "->", "element", "(", "'th'", ",", "'Pre-AttrTransform'", ")", ";", "$", "ret", ".=", "$", "this", "->", "element", "(", "'td'", ",", "$", "this", "->", "listifyObjectList", "(", "$", "def", "->", "info_attr_transform_pre", ")", ")", ";", "$", "ret", ".=", "$", "this", "->", "end", "(", "'tr'", ")", ";", "$", "ret", ".=", "$", "this", "->", "start", "(", "'tr'", ")", ";", "$", "ret", ".=", "$", "this", "->", "element", "(", "'th'", ",", "'Post-AttrTransform'", ")", ";", "$", "ret", ".=", "$", "this", "->", "element", "(", "'td'", ",", "$", "this", "->", "listifyObjectList", "(", "$", "def", "->", "info_attr_transform_post", ")", ")", ";", "$", "ret", ".=", "$", "this", "->", "end", "(", "'tr'", ")", ";", "$", "ret", ".=", "$", "this", "->", "end", "(", "'table'", ")", ";", "return", "$", "ret", ";", "}" ]
Renders environment table, which is miscellaneous info @return string
[ "Renders", "environment", "table", "which", "is", "miscellaneous", "info" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/htmlpurifier/HTMLPurifier/Printer/HTMLDefinition.php#L57-L97
217,399
moodle/moodle
lib/htmlpurifier/HTMLPurifier/Printer/HTMLDefinition.php
HTMLPurifier_Printer_HTMLDefinition.renderContentSets
protected function renderContentSets() { $ret = ''; $ret .= $this->start('table'); $ret .= $this->element('caption', 'Content Sets'); foreach ($this->def->info_content_sets as $name => $lookup) { $ret .= $this->heavyHeader($name); $ret .= $this->start('tr'); $ret .= $this->element('td', $this->listifyTagLookup($lookup)); $ret .= $this->end('tr'); } $ret .= $this->end('table'); return $ret; }
php
protected function renderContentSets() { $ret = ''; $ret .= $this->start('table'); $ret .= $this->element('caption', 'Content Sets'); foreach ($this->def->info_content_sets as $name => $lookup) { $ret .= $this->heavyHeader($name); $ret .= $this->start('tr'); $ret .= $this->element('td', $this->listifyTagLookup($lookup)); $ret .= $this->end('tr'); } $ret .= $this->end('table'); return $ret; }
[ "protected", "function", "renderContentSets", "(", ")", "{", "$", "ret", "=", "''", ";", "$", "ret", ".=", "$", "this", "->", "start", "(", "'table'", ")", ";", "$", "ret", ".=", "$", "this", "->", "element", "(", "'caption'", ",", "'Content Sets'", ")", ";", "foreach", "(", "$", "this", "->", "def", "->", "info_content_sets", "as", "$", "name", "=>", "$", "lookup", ")", "{", "$", "ret", ".=", "$", "this", "->", "heavyHeader", "(", "$", "name", ")", ";", "$", "ret", ".=", "$", "this", "->", "start", "(", "'tr'", ")", ";", "$", "ret", ".=", "$", "this", "->", "element", "(", "'td'", ",", "$", "this", "->", "listifyTagLookup", "(", "$", "lookup", ")", ")", ";", "$", "ret", ".=", "$", "this", "->", "end", "(", "'tr'", ")", ";", "}", "$", "ret", ".=", "$", "this", "->", "end", "(", "'table'", ")", ";", "return", "$", "ret", ";", "}" ]
Renders the Content Sets table @return string
[ "Renders", "the", "Content", "Sets", "table" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/htmlpurifier/HTMLPurifier/Printer/HTMLDefinition.php#L103-L116