id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
214,600 | moodle/moodle | lib/badgeslib.php | badge.get_related_badges | public function get_related_badges(bool $activeonly = false) {
global $DB;
$params = array('badgeid' => $this->id, 'badgeid2' => $this->id, 'badgeid3' => $this->id);
$query = "SELECT DISTINCT b.id, b.name, b.version, b.language, b.type
FROM {badge_related} br
JOIN {badge} b ON (br.relatedbadgeid = b.id OR br.badgeid = b.id)
WHERE (br.badgeid = :badgeid OR br.relatedbadgeid = :badgeid2) AND b.id != :badgeid3";
if ($activeonly) {
$query .= " AND b.status <> :status";
$params['status'] = BADGE_STATUS_INACTIVE;
}
$relatedbadges = $DB->get_records_sql($query, $params);
return $relatedbadges;
} | php | public function get_related_badges(bool $activeonly = false) {
global $DB;
$params = array('badgeid' => $this->id, 'badgeid2' => $this->id, 'badgeid3' => $this->id);
$query = "SELECT DISTINCT b.id, b.name, b.version, b.language, b.type
FROM {badge_related} br
JOIN {badge} b ON (br.relatedbadgeid = b.id OR br.badgeid = b.id)
WHERE (br.badgeid = :badgeid OR br.relatedbadgeid = :badgeid2) AND b.id != :badgeid3";
if ($activeonly) {
$query .= " AND b.status <> :status";
$params['status'] = BADGE_STATUS_INACTIVE;
}
$relatedbadges = $DB->get_records_sql($query, $params);
return $relatedbadges;
} | [
"public",
"function",
"get_related_badges",
"(",
"bool",
"$",
"activeonly",
"=",
"false",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"params",
"=",
"array",
"(",
"'badgeid'",
"=>",
"$",
"this",
"->",
"id",
",",
"'badgeid2'",
"=>",
"$",
"this",
"->",
"id",
",",
"'badgeid3'",
"=>",
"$",
"this",
"->",
"id",
")",
";",
"$",
"query",
"=",
"\"SELECT DISTINCT b.id, b.name, b.version, b.language, b.type\n FROM {badge_related} br\n JOIN {badge} b ON (br.relatedbadgeid = b.id OR br.badgeid = b.id)\n WHERE (br.badgeid = :badgeid OR br.relatedbadgeid = :badgeid2) AND b.id != :badgeid3\"",
";",
"if",
"(",
"$",
"activeonly",
")",
"{",
"$",
"query",
".=",
"\" AND b.status <> :status\"",
";",
"$",
"params",
"[",
"'status'",
"]",
"=",
"BADGE_STATUS_INACTIVE",
";",
"}",
"$",
"relatedbadges",
"=",
"$",
"DB",
"->",
"get_records_sql",
"(",
"$",
"query",
",",
"$",
"params",
")",
";",
"return",
"$",
"relatedbadges",
";",
"}"
] | Get related badges of badge.
@param bool $activeonly Do not get the inactive badges when is true.
@return array Related badges information. | [
"Get",
"related",
"badges",
"of",
"badge",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/badgeslib.php#L822-L836 |
214,601 | moodle/moodle | lib/badgeslib.php | badge.markdown_badge_criteria | public function markdown_badge_criteria() {
$agg = $this->get_aggregation_methods();
if (empty($this->criteria)) {
return get_string('nocriteria', 'badges');
}
$overalldescr = '';
$overall = $this->criteria[BADGE_CRITERIA_TYPE_OVERALL];
if (!empty($overall->description)) {
$overalldescr = format_text($overall->description, $overall->descriptionformat,
array('context' => $this->get_context())) . '\n';
}
// Get the condition string.
if (count($this->criteria) == 2) {
$condition = get_string('criteria_descr', 'badges');
} else {
$condition = get_string('criteria_descr_' . BADGE_CRITERIA_TYPE_OVERALL, 'badges',
core_text::strtoupper($agg[$this->get_aggregation_method()]));
}
unset($this->criteria[BADGE_CRITERIA_TYPE_OVERALL]);
$items = array();
// If only one criterion left, make sure its description goe to the top.
if (count($this->criteria) == 1) {
$c = reset($this->criteria);
if (!empty($c->description)) {
$overalldescr = $c->description . '\n';
}
if (count($c->params) == 1) {
$items[] = ' * ' . get_string('criteria_descr_single_' . $c->criteriatype, 'badges') .
$c->get_details();
} else {
$items[] = '* ' . get_string('criteria_descr_' . $c->criteriatype, 'badges',
core_text::strtoupper($agg[$this->get_aggregation_method($c->criteriatype)])) .
$c->get_details();
}
} else {
foreach ($this->criteria as $type => $c) {
$criteriadescr = '';
if (!empty($c->description)) {
$criteriadescr = $c->description;
}
if (count($c->params) == 1) {
$items[] = ' * ' . get_string('criteria_descr_single_' . $type, 'badges') .
$c->get_details() . $criteriadescr;
} else {
$items[] = '* ' . get_string('criteria_descr_' . $type, 'badges',
core_text::strtoupper($agg[$this->get_aggregation_method($type)])) .
$c->get_details() . $criteriadescr;
}
}
}
return strip_tags($overalldescr . $condition . html_writer::alist($items, array(), 'ul'));
} | php | public function markdown_badge_criteria() {
$agg = $this->get_aggregation_methods();
if (empty($this->criteria)) {
return get_string('nocriteria', 'badges');
}
$overalldescr = '';
$overall = $this->criteria[BADGE_CRITERIA_TYPE_OVERALL];
if (!empty($overall->description)) {
$overalldescr = format_text($overall->description, $overall->descriptionformat,
array('context' => $this->get_context())) . '\n';
}
// Get the condition string.
if (count($this->criteria) == 2) {
$condition = get_string('criteria_descr', 'badges');
} else {
$condition = get_string('criteria_descr_' . BADGE_CRITERIA_TYPE_OVERALL, 'badges',
core_text::strtoupper($agg[$this->get_aggregation_method()]));
}
unset($this->criteria[BADGE_CRITERIA_TYPE_OVERALL]);
$items = array();
// If only one criterion left, make sure its description goe to the top.
if (count($this->criteria) == 1) {
$c = reset($this->criteria);
if (!empty($c->description)) {
$overalldescr = $c->description . '\n';
}
if (count($c->params) == 1) {
$items[] = ' * ' . get_string('criteria_descr_single_' . $c->criteriatype, 'badges') .
$c->get_details();
} else {
$items[] = '* ' . get_string('criteria_descr_' . $c->criteriatype, 'badges',
core_text::strtoupper($agg[$this->get_aggregation_method($c->criteriatype)])) .
$c->get_details();
}
} else {
foreach ($this->criteria as $type => $c) {
$criteriadescr = '';
if (!empty($c->description)) {
$criteriadescr = $c->description;
}
if (count($c->params) == 1) {
$items[] = ' * ' . get_string('criteria_descr_single_' . $type, 'badges') .
$c->get_details() . $criteriadescr;
} else {
$items[] = '* ' . get_string('criteria_descr_' . $type, 'badges',
core_text::strtoupper($agg[$this->get_aggregation_method($type)])) .
$c->get_details() . $criteriadescr;
}
}
}
return strip_tags($overalldescr . $condition . html_writer::alist($items, array(), 'ul'));
} | [
"public",
"function",
"markdown_badge_criteria",
"(",
")",
"{",
"$",
"agg",
"=",
"$",
"this",
"->",
"get_aggregation_methods",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"criteria",
")",
")",
"{",
"return",
"get_string",
"(",
"'nocriteria'",
",",
"'badges'",
")",
";",
"}",
"$",
"overalldescr",
"=",
"''",
";",
"$",
"overall",
"=",
"$",
"this",
"->",
"criteria",
"[",
"BADGE_CRITERIA_TYPE_OVERALL",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"overall",
"->",
"description",
")",
")",
"{",
"$",
"overalldescr",
"=",
"format_text",
"(",
"$",
"overall",
"->",
"description",
",",
"$",
"overall",
"->",
"descriptionformat",
",",
"array",
"(",
"'context'",
"=>",
"$",
"this",
"->",
"get_context",
"(",
")",
")",
")",
".",
"'\\n'",
";",
"}",
"// Get the condition string.",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"criteria",
")",
"==",
"2",
")",
"{",
"$",
"condition",
"=",
"get_string",
"(",
"'criteria_descr'",
",",
"'badges'",
")",
";",
"}",
"else",
"{",
"$",
"condition",
"=",
"get_string",
"(",
"'criteria_descr_'",
".",
"BADGE_CRITERIA_TYPE_OVERALL",
",",
"'badges'",
",",
"core_text",
"::",
"strtoupper",
"(",
"$",
"agg",
"[",
"$",
"this",
"->",
"get_aggregation_method",
"(",
")",
"]",
")",
")",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"criteria",
"[",
"BADGE_CRITERIA_TYPE_OVERALL",
"]",
")",
";",
"$",
"items",
"=",
"array",
"(",
")",
";",
"// If only one criterion left, make sure its description goe to the top.",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"criteria",
")",
"==",
"1",
")",
"{",
"$",
"c",
"=",
"reset",
"(",
"$",
"this",
"->",
"criteria",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"c",
"->",
"description",
")",
")",
"{",
"$",
"overalldescr",
"=",
"$",
"c",
"->",
"description",
".",
"'\\n'",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"c",
"->",
"params",
")",
"==",
"1",
")",
"{",
"$",
"items",
"[",
"]",
"=",
"' * '",
".",
"get_string",
"(",
"'criteria_descr_single_'",
".",
"$",
"c",
"->",
"criteriatype",
",",
"'badges'",
")",
".",
"$",
"c",
"->",
"get_details",
"(",
")",
";",
"}",
"else",
"{",
"$",
"items",
"[",
"]",
"=",
"'* '",
".",
"get_string",
"(",
"'criteria_descr_'",
".",
"$",
"c",
"->",
"criteriatype",
",",
"'badges'",
",",
"core_text",
"::",
"strtoupper",
"(",
"$",
"agg",
"[",
"$",
"this",
"->",
"get_aggregation_method",
"(",
"$",
"c",
"->",
"criteriatype",
")",
"]",
")",
")",
".",
"$",
"c",
"->",
"get_details",
"(",
")",
";",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"->",
"criteria",
"as",
"$",
"type",
"=>",
"$",
"c",
")",
"{",
"$",
"criteriadescr",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"c",
"->",
"description",
")",
")",
"{",
"$",
"criteriadescr",
"=",
"$",
"c",
"->",
"description",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"c",
"->",
"params",
")",
"==",
"1",
")",
"{",
"$",
"items",
"[",
"]",
"=",
"' * '",
".",
"get_string",
"(",
"'criteria_descr_single_'",
".",
"$",
"type",
",",
"'badges'",
")",
".",
"$",
"c",
"->",
"get_details",
"(",
")",
".",
"$",
"criteriadescr",
";",
"}",
"else",
"{",
"$",
"items",
"[",
"]",
"=",
"'* '",
".",
"get_string",
"(",
"'criteria_descr_'",
".",
"$",
"type",
",",
"'badges'",
",",
"core_text",
"::",
"strtoupper",
"(",
"$",
"agg",
"[",
"$",
"this",
"->",
"get_aggregation_method",
"(",
"$",
"type",
")",
"]",
")",
")",
".",
"$",
"c",
"->",
"get_details",
"(",
")",
".",
"$",
"criteriadescr",
";",
"}",
"}",
"}",
"return",
"strip_tags",
"(",
"$",
"overalldescr",
".",
"$",
"condition",
".",
"html_writer",
"::",
"alist",
"(",
"$",
"items",
",",
"array",
"(",
")",
",",
"'ul'",
")",
")",
";",
"}"
] | Markdown language support for criteria.
@return string $output Markdown content to output. | [
"Markdown",
"language",
"support",
"for",
"criteria",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/badgeslib.php#L922-L973 |
214,602 | moodle/moodle | lib/badgeslib.php | badge.get_badge_issuer | public function get_badge_issuer() {
$issuer = array();
$issuerurl = new moodle_url('/badges/badge_json.php', array('id' => $this->id, 'action' => 0));
$issuer['name'] = $this->issuername;
$issuer['url'] = $this->issuerurl;
$issuer['email'] = $this->issuercontact;
$issuer['@context'] = OPEN_BADGES_V2_CONTEXT;
$issuer['id'] = $issuerurl->out(false);
$issuer['type'] = OPEN_BADGES_V2_TYPE_ISSUER;
return $issuer;
} | php | public function get_badge_issuer() {
$issuer = array();
$issuerurl = new moodle_url('/badges/badge_json.php', array('id' => $this->id, 'action' => 0));
$issuer['name'] = $this->issuername;
$issuer['url'] = $this->issuerurl;
$issuer['email'] = $this->issuercontact;
$issuer['@context'] = OPEN_BADGES_V2_CONTEXT;
$issuer['id'] = $issuerurl->out(false);
$issuer['type'] = OPEN_BADGES_V2_TYPE_ISSUER;
return $issuer;
} | [
"public",
"function",
"get_badge_issuer",
"(",
")",
"{",
"$",
"issuer",
"=",
"array",
"(",
")",
";",
"$",
"issuerurl",
"=",
"new",
"moodle_url",
"(",
"'/badges/badge_json.php'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"this",
"->",
"id",
",",
"'action'",
"=>",
"0",
")",
")",
";",
"$",
"issuer",
"[",
"'name'",
"]",
"=",
"$",
"this",
"->",
"issuername",
";",
"$",
"issuer",
"[",
"'url'",
"]",
"=",
"$",
"this",
"->",
"issuerurl",
";",
"$",
"issuer",
"[",
"'email'",
"]",
"=",
"$",
"this",
"->",
"issuercontact",
";",
"$",
"issuer",
"[",
"'@context'",
"]",
"=",
"OPEN_BADGES_V2_CONTEXT",
";",
"$",
"issuer",
"[",
"'id'",
"]",
"=",
"$",
"issuerurl",
"->",
"out",
"(",
"false",
")",
";",
"$",
"issuer",
"[",
"'type'",
"]",
"=",
"OPEN_BADGES_V2_TYPE_ISSUER",
";",
"return",
"$",
"issuer",
";",
"}"
] | Define issuer information by format Open Badges specification version 2.
@return array Issuer informations of the badge. | [
"Define",
"issuer",
"information",
"by",
"format",
"Open",
"Badges",
"specification",
"version",
"2",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/badgeslib.php#L980-L990 |
214,603 | moodle/moodle | mod/wiki/pagelib.php | page_wiki.print_header | function print_header() {
global $OUTPUT, $PAGE, $CFG, $USER, $SESSION;
$PAGE->set_heading($PAGE->course->fullname);
$this->set_url();
if (isset($SESSION->wikipreviousurl) && is_array($SESSION->wikipreviousurl)) {
$this->process_session_url();
}
$this->set_session_url();
$this->create_navbar();
$this->setup_tabs();
echo $OUTPUT->header();
$wiki = $PAGE->activityrecord;
echo $OUTPUT->heading(format_string($wiki->name));
echo $this->wikioutput->wiki_info();
// tabs are associated with pageid, so if page is empty, tabs should be disabled
if (!empty($this->page) && !empty($this->tabs)) {
echo $this->wikioutput->tabs($this->page, $this->tabs, $this->tabs_options);
}
} | php | function print_header() {
global $OUTPUT, $PAGE, $CFG, $USER, $SESSION;
$PAGE->set_heading($PAGE->course->fullname);
$this->set_url();
if (isset($SESSION->wikipreviousurl) && is_array($SESSION->wikipreviousurl)) {
$this->process_session_url();
}
$this->set_session_url();
$this->create_navbar();
$this->setup_tabs();
echo $OUTPUT->header();
$wiki = $PAGE->activityrecord;
echo $OUTPUT->heading(format_string($wiki->name));
echo $this->wikioutput->wiki_info();
// tabs are associated with pageid, so if page is empty, tabs should be disabled
if (!empty($this->page) && !empty($this->tabs)) {
echo $this->wikioutput->tabs($this->page, $this->tabs, $this->tabs_options);
}
} | [
"function",
"print_header",
"(",
")",
"{",
"global",
"$",
"OUTPUT",
",",
"$",
"PAGE",
",",
"$",
"CFG",
",",
"$",
"USER",
",",
"$",
"SESSION",
";",
"$",
"PAGE",
"->",
"set_heading",
"(",
"$",
"PAGE",
"->",
"course",
"->",
"fullname",
")",
";",
"$",
"this",
"->",
"set_url",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"SESSION",
"->",
"wikipreviousurl",
")",
"&&",
"is_array",
"(",
"$",
"SESSION",
"->",
"wikipreviousurl",
")",
")",
"{",
"$",
"this",
"->",
"process_session_url",
"(",
")",
";",
"}",
"$",
"this",
"->",
"set_session_url",
"(",
")",
";",
"$",
"this",
"->",
"create_navbar",
"(",
")",
";",
"$",
"this",
"->",
"setup_tabs",
"(",
")",
";",
"echo",
"$",
"OUTPUT",
"->",
"header",
"(",
")",
";",
"$",
"wiki",
"=",
"$",
"PAGE",
"->",
"activityrecord",
";",
"echo",
"$",
"OUTPUT",
"->",
"heading",
"(",
"format_string",
"(",
"$",
"wiki",
"->",
"name",
")",
")",
";",
"echo",
"$",
"this",
"->",
"wikioutput",
"->",
"wiki_info",
"(",
")",
";",
"// tabs are associated with pageid, so if page is empty, tabs should be disabled",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"page",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"tabs",
")",
")",
"{",
"echo",
"$",
"this",
"->",
"wikioutput",
"->",
"tabs",
"(",
"$",
"this",
"->",
"page",
",",
"$",
"this",
"->",
"tabs",
",",
"$",
"this",
"->",
"tabs_options",
")",
";",
"}",
"}"
] | This method prints the top of the page. | [
"This",
"method",
"prints",
"the",
"top",
"of",
"the",
"page",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/pagelib.php#L123-L148 |
214,604 | moodle/moodle | mod/wiki/pagelib.php | page_wiki.setup_tabs | protected function setup_tabs($options = array()) {
global $CFG, $PAGE;
$groupmode = groups_get_activity_groupmode($this->cm);
if (empty($CFG->usecomments) || !has_capability('mod/wiki:viewcomment', $PAGE->context)){
unset($this->tabs['comments']);
}
if (!has_capability('mod/wiki:editpage', $PAGE->context)){
unset($this->tabs['edit']);
}
if ($groupmode and $groupmode == VISIBLEGROUPS) {
$currentgroup = groups_get_activity_group($this->cm);
$manage = has_capability('mod/wiki:managewiki', $this->modcontext);
$edit = has_capability('mod/wiki:editpage', $PAGE->context);
if (!$manage and !($edit and groups_is_member($currentgroup))) {
unset($this->tabs['edit']);
}
}
if (empty($options)) {
$this->tabs_options = array('activetab' => substr(get_class($this), 10));
} else {
$this->tabs_options = $options;
}
} | php | protected function setup_tabs($options = array()) {
global $CFG, $PAGE;
$groupmode = groups_get_activity_groupmode($this->cm);
if (empty($CFG->usecomments) || !has_capability('mod/wiki:viewcomment', $PAGE->context)){
unset($this->tabs['comments']);
}
if (!has_capability('mod/wiki:editpage', $PAGE->context)){
unset($this->tabs['edit']);
}
if ($groupmode and $groupmode == VISIBLEGROUPS) {
$currentgroup = groups_get_activity_group($this->cm);
$manage = has_capability('mod/wiki:managewiki', $this->modcontext);
$edit = has_capability('mod/wiki:editpage', $PAGE->context);
if (!$manage and !($edit and groups_is_member($currentgroup))) {
unset($this->tabs['edit']);
}
}
if (empty($options)) {
$this->tabs_options = array('activetab' => substr(get_class($this), 10));
} else {
$this->tabs_options = $options;
}
} | [
"protected",
"function",
"setup_tabs",
"(",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"PAGE",
";",
"$",
"groupmode",
"=",
"groups_get_activity_groupmode",
"(",
"$",
"this",
"->",
"cm",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"CFG",
"->",
"usecomments",
")",
"||",
"!",
"has_capability",
"(",
"'mod/wiki:viewcomment'",
",",
"$",
"PAGE",
"->",
"context",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"tabs",
"[",
"'comments'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"has_capability",
"(",
"'mod/wiki:editpage'",
",",
"$",
"PAGE",
"->",
"context",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"tabs",
"[",
"'edit'",
"]",
")",
";",
"}",
"if",
"(",
"$",
"groupmode",
"and",
"$",
"groupmode",
"==",
"VISIBLEGROUPS",
")",
"{",
"$",
"currentgroup",
"=",
"groups_get_activity_group",
"(",
"$",
"this",
"->",
"cm",
")",
";",
"$",
"manage",
"=",
"has_capability",
"(",
"'mod/wiki:managewiki'",
",",
"$",
"this",
"->",
"modcontext",
")",
";",
"$",
"edit",
"=",
"has_capability",
"(",
"'mod/wiki:editpage'",
",",
"$",
"PAGE",
"->",
"context",
")",
";",
"if",
"(",
"!",
"$",
"manage",
"and",
"!",
"(",
"$",
"edit",
"and",
"groups_is_member",
"(",
"$",
"currentgroup",
")",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"tabs",
"[",
"'edit'",
"]",
")",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"options",
")",
")",
"{",
"$",
"this",
"->",
"tabs_options",
"=",
"array",
"(",
"'activetab'",
"=>",
"substr",
"(",
"get_class",
"(",
"$",
"this",
")",
",",
"10",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"tabs_options",
"=",
"$",
"options",
";",
"}",
"}"
] | Setup page tabs, if options is empty, will set up active tab automatically
@param array $options, tabs options | [
"Setup",
"page",
"tabs",
"if",
"options",
"is",
"empty",
"will",
"set",
"up",
"active",
"tab",
"automatically"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/pagelib.php#L167-L194 |
214,605 | moodle/moodle | mod/wiki/pagelib.php | page_wiki.set_page | function set_page($page) {
global $PAGE;
$this->page = $page;
$this->title = $page->title;
// set_title calls format_string itself so no probs there
$PAGE->set_title($this->title);
} | php | function set_page($page) {
global $PAGE;
$this->page = $page;
$this->title = $page->title;
// set_title calls format_string itself so no probs there
$PAGE->set_title($this->title);
} | [
"function",
"set_page",
"(",
"$",
"page",
")",
"{",
"global",
"$",
"PAGE",
";",
"$",
"this",
"->",
"page",
"=",
"$",
"page",
";",
"$",
"this",
"->",
"title",
"=",
"$",
"page",
"->",
"title",
";",
"// set_title calls format_string itself so no probs there",
"$",
"PAGE",
"->",
"set_title",
"(",
"$",
"this",
"->",
"title",
")",
";",
"}"
] | Method to set the current page
@param object $page Current page | [
"Method",
"to",
"set",
"the",
"current",
"page"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/pagelib.php#L208-L215 |
214,606 | moodle/moodle | mod/wiki/pagelib.php | page_wiki.set_title | function set_title($title) {
global $PAGE;
$this->page = null;
$this->title = $title;
// set_title calls format_string itself so no probs there
$PAGE->set_title($this->title);
} | php | function set_title($title) {
global $PAGE;
$this->page = null;
$this->title = $title;
// set_title calls format_string itself so no probs there
$PAGE->set_title($this->title);
} | [
"function",
"set_title",
"(",
"$",
"title",
")",
"{",
"global",
"$",
"PAGE",
";",
"$",
"this",
"->",
"page",
"=",
"null",
";",
"$",
"this",
"->",
"title",
"=",
"$",
"title",
";",
"// set_title calls format_string itself so no probs there",
"$",
"PAGE",
"->",
"set_title",
"(",
"$",
"this",
"->",
"title",
")",
";",
"}"
] | Method to set the current page title.
This method must be called when the current page is not created yet.
@param string $title Current page title. | [
"Method",
"to",
"set",
"the",
"current",
"page",
"title",
".",
"This",
"method",
"must",
"be",
"called",
"when",
"the",
"current",
"page",
"is",
"not",
"created",
"yet",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/pagelib.php#L222-L229 |
214,607 | moodle/moodle | mod/wiki/pagelib.php | page_wiki.create_navbar | protected function create_navbar() {
global $PAGE, $CFG;
$PAGE->navbar->add(format_string($this->title), $CFG->wwwroot . '/mod/wiki/view.php?pageid=' . $this->page->id);
} | php | protected function create_navbar() {
global $PAGE, $CFG;
$PAGE->navbar->add(format_string($this->title), $CFG->wwwroot . '/mod/wiki/view.php?pageid=' . $this->page->id);
} | [
"protected",
"function",
"create_navbar",
"(",
")",
"{",
"global",
"$",
"PAGE",
",",
"$",
"CFG",
";",
"$",
"PAGE",
"->",
"navbar",
"->",
"add",
"(",
"format_string",
"(",
"$",
"this",
"->",
"title",
")",
",",
"$",
"CFG",
"->",
"wwwroot",
".",
"'/mod/wiki/view.php?pageid='",
".",
"$",
"this",
"->",
"page",
"->",
"id",
")",
";",
"}"
] | Protected method to create the common items of the navbar in every page type. | [
"Protected",
"method",
"to",
"create",
"the",
"common",
"items",
"of",
"the",
"navbar",
"in",
"every",
"page",
"type",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/pagelib.php#L258-L262 |
214,608 | moodle/moodle | mod/wiki/pagelib.php | page_wiki_diff.print_diff_content | private function print_diff_content() {
global $CFG, $OUTPUT, $PAGE;
$pageid = $this->page->id;
$total = wiki_count_wiki_page_versions($pageid) - 1;
$oldversion = wiki_get_wiki_page_version($pageid, $this->compare);
$newversion = wiki_get_wiki_page_version($pageid, $this->comparewith);
if ($oldversion && $newversion) {
$oldtext = format_text(file_rewrite_pluginfile_urls($oldversion->content, 'pluginfile.php', $this->modcontext->id, 'mod_wiki', 'attachments', $this->subwiki->id));
$newtext = format_text(file_rewrite_pluginfile_urls($newversion->content, 'pluginfile.php', $this->modcontext->id, 'mod_wiki', 'attachments', $this->subwiki->id));
list($diff1, $diff2) = ouwiki_diff_html($oldtext, $newtext);
$oldversion->diff = $diff1;
$oldversion->user = wiki_get_user_info($oldversion->userid);
$newversion->diff = $diff2;
$newversion->user = wiki_get_user_info($newversion->userid);
echo $this->wikioutput->diff($pageid, $oldversion, $newversion, array('total' => $total));
} else {
print_error('versionerror', 'wiki');
}
} | php | private function print_diff_content() {
global $CFG, $OUTPUT, $PAGE;
$pageid = $this->page->id;
$total = wiki_count_wiki_page_versions($pageid) - 1;
$oldversion = wiki_get_wiki_page_version($pageid, $this->compare);
$newversion = wiki_get_wiki_page_version($pageid, $this->comparewith);
if ($oldversion && $newversion) {
$oldtext = format_text(file_rewrite_pluginfile_urls($oldversion->content, 'pluginfile.php', $this->modcontext->id, 'mod_wiki', 'attachments', $this->subwiki->id));
$newtext = format_text(file_rewrite_pluginfile_urls($newversion->content, 'pluginfile.php', $this->modcontext->id, 'mod_wiki', 'attachments', $this->subwiki->id));
list($diff1, $diff2) = ouwiki_diff_html($oldtext, $newtext);
$oldversion->diff = $diff1;
$oldversion->user = wiki_get_user_info($oldversion->userid);
$newversion->diff = $diff2;
$newversion->user = wiki_get_user_info($newversion->userid);
echo $this->wikioutput->diff($pageid, $oldversion, $newversion, array('total' => $total));
} else {
print_error('versionerror', 'wiki');
}
} | [
"private",
"function",
"print_diff_content",
"(",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"OUTPUT",
",",
"$",
"PAGE",
";",
"$",
"pageid",
"=",
"$",
"this",
"->",
"page",
"->",
"id",
";",
"$",
"total",
"=",
"wiki_count_wiki_page_versions",
"(",
"$",
"pageid",
")",
"-",
"1",
";",
"$",
"oldversion",
"=",
"wiki_get_wiki_page_version",
"(",
"$",
"pageid",
",",
"$",
"this",
"->",
"compare",
")",
";",
"$",
"newversion",
"=",
"wiki_get_wiki_page_version",
"(",
"$",
"pageid",
",",
"$",
"this",
"->",
"comparewith",
")",
";",
"if",
"(",
"$",
"oldversion",
"&&",
"$",
"newversion",
")",
"{",
"$",
"oldtext",
"=",
"format_text",
"(",
"file_rewrite_pluginfile_urls",
"(",
"$",
"oldversion",
"->",
"content",
",",
"'pluginfile.php'",
",",
"$",
"this",
"->",
"modcontext",
"->",
"id",
",",
"'mod_wiki'",
",",
"'attachments'",
",",
"$",
"this",
"->",
"subwiki",
"->",
"id",
")",
")",
";",
"$",
"newtext",
"=",
"format_text",
"(",
"file_rewrite_pluginfile_urls",
"(",
"$",
"newversion",
"->",
"content",
",",
"'pluginfile.php'",
",",
"$",
"this",
"->",
"modcontext",
"->",
"id",
",",
"'mod_wiki'",
",",
"'attachments'",
",",
"$",
"this",
"->",
"subwiki",
"->",
"id",
")",
")",
";",
"list",
"(",
"$",
"diff1",
",",
"$",
"diff2",
")",
"=",
"ouwiki_diff_html",
"(",
"$",
"oldtext",
",",
"$",
"newtext",
")",
";",
"$",
"oldversion",
"->",
"diff",
"=",
"$",
"diff1",
";",
"$",
"oldversion",
"->",
"user",
"=",
"wiki_get_user_info",
"(",
"$",
"oldversion",
"->",
"userid",
")",
";",
"$",
"newversion",
"->",
"diff",
"=",
"$",
"diff2",
";",
"$",
"newversion",
"->",
"user",
"=",
"wiki_get_user_info",
"(",
"$",
"newversion",
"->",
"userid",
")",
";",
"echo",
"$",
"this",
"->",
"wikioutput",
"->",
"diff",
"(",
"$",
"pageid",
",",
"$",
"oldversion",
",",
"$",
"newversion",
",",
"array",
"(",
"'total'",
"=>",
"$",
"total",
")",
")",
";",
"}",
"else",
"{",
"print_error",
"(",
"'versionerror'",
",",
"'wiki'",
")",
";",
"}",
"}"
] | Given two versions of a page, prints a page displaying the differences between them.
@global object $CFG
@global object $OUTPUT
@global object $PAGE | [
"Given",
"two",
"versions",
"of",
"a",
"page",
"prints",
"a",
"page",
"displaying",
"the",
"differences",
"between",
"them",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/pagelib.php#L1136-L1160 |
214,609 | moodle/moodle | mod/wiki/pagelib.php | page_wiki_history.choose_from_radio | private function choose_from_radio($options, $name, $onclick = '', $checked = '', $return = false) {
static $idcounter = 0;
if (!$name) {
$name = 'unnamed';
}
$output = '<span class="radiogroup ' . $name . "\">\n";
if (!empty($options)) {
$currentradio = 0;
foreach ($options as $value => $label) {
$htmlid = 'auto-rb' . sprintf('%04d', ++$idcounter);
$output .= ' <span class="radioelement ' . $name . ' rb' . $currentradio . "\">";
$output .= '<input name="' . $name . '" id="' . $htmlid . '" type="radio" value="' . $value . '"';
if ($value == $checked) {
$output .= ' checked="checked"';
}
if ($onclick) {
$output .= ' onclick="' . $onclick . '"';
}
if ($label === '') {
$output .= ' /> <label for="' . $htmlid . '">' . $value . '</label></span>' . "\n";
} else {
$output .= ' /> <label for="' . $htmlid . '">' . $label . '</label></span>' . "\n";
}
$currentradio = ($currentradio + 1) % 2;
}
}
$output .= '</span>' . "\n";
if ($return) {
return $output;
} else {
echo $output;
}
} | php | private function choose_from_radio($options, $name, $onclick = '', $checked = '', $return = false) {
static $idcounter = 0;
if (!$name) {
$name = 'unnamed';
}
$output = '<span class="radiogroup ' . $name . "\">\n";
if (!empty($options)) {
$currentradio = 0;
foreach ($options as $value => $label) {
$htmlid = 'auto-rb' . sprintf('%04d', ++$idcounter);
$output .= ' <span class="radioelement ' . $name . ' rb' . $currentradio . "\">";
$output .= '<input name="' . $name . '" id="' . $htmlid . '" type="radio" value="' . $value . '"';
if ($value == $checked) {
$output .= ' checked="checked"';
}
if ($onclick) {
$output .= ' onclick="' . $onclick . '"';
}
if ($label === '') {
$output .= ' /> <label for="' . $htmlid . '">' . $value . '</label></span>' . "\n";
} else {
$output .= ' /> <label for="' . $htmlid . '">' . $label . '</label></span>' . "\n";
}
$currentradio = ($currentradio + 1) % 2;
}
}
$output .= '</span>' . "\n";
if ($return) {
return $output;
} else {
echo $output;
}
} | [
"private",
"function",
"choose_from_radio",
"(",
"$",
"options",
",",
"$",
"name",
",",
"$",
"onclick",
"=",
"''",
",",
"$",
"checked",
"=",
"''",
",",
"$",
"return",
"=",
"false",
")",
"{",
"static",
"$",
"idcounter",
"=",
"0",
";",
"if",
"(",
"!",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"'unnamed'",
";",
"}",
"$",
"output",
"=",
"'<span class=\"radiogroup '",
".",
"$",
"name",
".",
"\"\\\">\\n\"",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
")",
")",
"{",
"$",
"currentradio",
"=",
"0",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"value",
"=>",
"$",
"label",
")",
"{",
"$",
"htmlid",
"=",
"'auto-rb'",
".",
"sprintf",
"(",
"'%04d'",
",",
"++",
"$",
"idcounter",
")",
";",
"$",
"output",
".=",
"' <span class=\"radioelement '",
".",
"$",
"name",
".",
"' rb'",
".",
"$",
"currentradio",
".",
"\"\\\">\"",
";",
"$",
"output",
".=",
"'<input name=\"'",
".",
"$",
"name",
".",
"'\" id=\"'",
".",
"$",
"htmlid",
".",
"'\" type=\"radio\" value=\"'",
".",
"$",
"value",
".",
"'\"'",
";",
"if",
"(",
"$",
"value",
"==",
"$",
"checked",
")",
"{",
"$",
"output",
".=",
"' checked=\"checked\"'",
";",
"}",
"if",
"(",
"$",
"onclick",
")",
"{",
"$",
"output",
".=",
"' onclick=\"'",
".",
"$",
"onclick",
".",
"'\"'",
";",
"}",
"if",
"(",
"$",
"label",
"===",
"''",
")",
"{",
"$",
"output",
".=",
"' /> <label for=\"'",
".",
"$",
"htmlid",
".",
"'\">'",
".",
"$",
"value",
".",
"'</label></span>'",
".",
"\"\\n\"",
";",
"}",
"else",
"{",
"$",
"output",
".=",
"' /> <label for=\"'",
".",
"$",
"htmlid",
".",
"'\">'",
".",
"$",
"label",
".",
"'</label></span>'",
".",
"\"\\n\"",
";",
"}",
"$",
"currentradio",
"=",
"(",
"$",
"currentradio",
"+",
"1",
")",
"%",
"2",
";",
"}",
"}",
"$",
"output",
".=",
"'</span>'",
".",
"\"\\n\"",
";",
"if",
"(",
"$",
"return",
")",
"{",
"return",
"$",
"output",
";",
"}",
"else",
"{",
"echo",
"$",
"output",
";",
"}",
"}"
] | Given an array of values, creates a group of radio buttons to be part of a form
@param array $options An array of value-label pairs for the radio group (values as keys).
@param string $name Name of the radiogroup (unique in the form).
@param string $onclick Function to be executed when the radios are clicked.
@param string $checked The value that is already checked.
@param bool $return If true, return the HTML as a string, otherwise print it.
@return mixed If $return is false, returns nothing, otherwise returns a string of HTML. | [
"Given",
"an",
"array",
"of",
"values",
"creates",
"a",
"group",
"of",
"radio",
"buttons",
"to",
"be",
"part",
"of",
"a",
"form"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/pagelib.php#L1357-L1395 |
214,610 | moodle/moodle | mod/wiki/pagelib.php | page_wiki_map.print_contributions_content | private function print_contributions_content() {
global $CFG, $OUTPUT, $USER;
$page = $this->page;
if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
$fresh = wiki_refresh_cachedcontent($page);
$page = $fresh['page'];
}
$swid = $this->subwiki->id;
$table = new html_table();
$table->head = array(get_string('contributions', 'wiki') . $OUTPUT->help_icon('contributions', 'wiki'));
$table->attributes['class'] = 'generalbox table';
$table->data = array();
$table->rowclasses = array();
$lastversions = array();
$pages = array();
$users = array();
if ($contribs = wiki_get_contributions($swid, $USER->id)) {
foreach ($contribs as $contrib) {
if (!array_key_exists($contrib->pageid, $pages)) {
$page = wiki_get_page($contrib->pageid);
$pages[$contrib->pageid] = $page;
} else {
continue;
}
if (!array_key_exists($page->id, $lastversions)) {
$version = wiki_get_last_version($page->id);
$lastversions[$page->id] = $version;
} else {
$version = $lastversions[$page->id];
}
if (!array_key_exists($version->userid, $users)) {
$user = wiki_get_user_info($version->userid);
$users[$version->userid] = $user;
} else {
$user = $users[$version->userid];
}
$link = wiki_parser_link($page->title, array('swid' => $swid));
$class = ($link['new']) ? 'class="wiki_newentry"' : '';
$linkpage = '<a href="' . $link['url'] . '"' . $class . '>' . format_string($link['content'], true, array('context' => $this->modcontext)) . '</a>';
$icon = $OUTPUT->user_picture($user, array('popup' => true));
$table->data[] = array("$icon $linkpage");
}
} else {
$table->data[] = array(get_string('nocontribs', 'wiki'));
}
echo html_writer::table($table);
} | php | private function print_contributions_content() {
global $CFG, $OUTPUT, $USER;
$page = $this->page;
if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
$fresh = wiki_refresh_cachedcontent($page);
$page = $fresh['page'];
}
$swid = $this->subwiki->id;
$table = new html_table();
$table->head = array(get_string('contributions', 'wiki') . $OUTPUT->help_icon('contributions', 'wiki'));
$table->attributes['class'] = 'generalbox table';
$table->data = array();
$table->rowclasses = array();
$lastversions = array();
$pages = array();
$users = array();
if ($contribs = wiki_get_contributions($swid, $USER->id)) {
foreach ($contribs as $contrib) {
if (!array_key_exists($contrib->pageid, $pages)) {
$page = wiki_get_page($contrib->pageid);
$pages[$contrib->pageid] = $page;
} else {
continue;
}
if (!array_key_exists($page->id, $lastversions)) {
$version = wiki_get_last_version($page->id);
$lastversions[$page->id] = $version;
} else {
$version = $lastversions[$page->id];
}
if (!array_key_exists($version->userid, $users)) {
$user = wiki_get_user_info($version->userid);
$users[$version->userid] = $user;
} else {
$user = $users[$version->userid];
}
$link = wiki_parser_link($page->title, array('swid' => $swid));
$class = ($link['new']) ? 'class="wiki_newentry"' : '';
$linkpage = '<a href="' . $link['url'] . '"' . $class . '>' . format_string($link['content'], true, array('context' => $this->modcontext)) . '</a>';
$icon = $OUTPUT->user_picture($user, array('popup' => true));
$table->data[] = array("$icon $linkpage");
}
} else {
$table->data[] = array(get_string('nocontribs', 'wiki'));
}
echo html_writer::table($table);
} | [
"private",
"function",
"print_contributions_content",
"(",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"OUTPUT",
",",
"$",
"USER",
";",
"$",
"page",
"=",
"$",
"this",
"->",
"page",
";",
"if",
"(",
"$",
"page",
"->",
"timerendered",
"+",
"WIKI_REFRESH_CACHE_TIME",
"<",
"time",
"(",
")",
")",
"{",
"$",
"fresh",
"=",
"wiki_refresh_cachedcontent",
"(",
"$",
"page",
")",
";",
"$",
"page",
"=",
"$",
"fresh",
"[",
"'page'",
"]",
";",
"}",
"$",
"swid",
"=",
"$",
"this",
"->",
"subwiki",
"->",
"id",
";",
"$",
"table",
"=",
"new",
"html_table",
"(",
")",
";",
"$",
"table",
"->",
"head",
"=",
"array",
"(",
"get_string",
"(",
"'contributions'",
",",
"'wiki'",
")",
".",
"$",
"OUTPUT",
"->",
"help_icon",
"(",
"'contributions'",
",",
"'wiki'",
")",
")",
";",
"$",
"table",
"->",
"attributes",
"[",
"'class'",
"]",
"=",
"'generalbox table'",
";",
"$",
"table",
"->",
"data",
"=",
"array",
"(",
")",
";",
"$",
"table",
"->",
"rowclasses",
"=",
"array",
"(",
")",
";",
"$",
"lastversions",
"=",
"array",
"(",
")",
";",
"$",
"pages",
"=",
"array",
"(",
")",
";",
"$",
"users",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"contribs",
"=",
"wiki_get_contributions",
"(",
"$",
"swid",
",",
"$",
"USER",
"->",
"id",
")",
")",
"{",
"foreach",
"(",
"$",
"contribs",
"as",
"$",
"contrib",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"contrib",
"->",
"pageid",
",",
"$",
"pages",
")",
")",
"{",
"$",
"page",
"=",
"wiki_get_page",
"(",
"$",
"contrib",
"->",
"pageid",
")",
";",
"$",
"pages",
"[",
"$",
"contrib",
"->",
"pageid",
"]",
"=",
"$",
"page",
";",
"}",
"else",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"page",
"->",
"id",
",",
"$",
"lastversions",
")",
")",
"{",
"$",
"version",
"=",
"wiki_get_last_version",
"(",
"$",
"page",
"->",
"id",
")",
";",
"$",
"lastversions",
"[",
"$",
"page",
"->",
"id",
"]",
"=",
"$",
"version",
";",
"}",
"else",
"{",
"$",
"version",
"=",
"$",
"lastversions",
"[",
"$",
"page",
"->",
"id",
"]",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"version",
"->",
"userid",
",",
"$",
"users",
")",
")",
"{",
"$",
"user",
"=",
"wiki_get_user_info",
"(",
"$",
"version",
"->",
"userid",
")",
";",
"$",
"users",
"[",
"$",
"version",
"->",
"userid",
"]",
"=",
"$",
"user",
";",
"}",
"else",
"{",
"$",
"user",
"=",
"$",
"users",
"[",
"$",
"version",
"->",
"userid",
"]",
";",
"}",
"$",
"link",
"=",
"wiki_parser_link",
"(",
"$",
"page",
"->",
"title",
",",
"array",
"(",
"'swid'",
"=>",
"$",
"swid",
")",
")",
";",
"$",
"class",
"=",
"(",
"$",
"link",
"[",
"'new'",
"]",
")",
"?",
"'class=\"wiki_newentry\"'",
":",
"''",
";",
"$",
"linkpage",
"=",
"'<a href=\"'",
".",
"$",
"link",
"[",
"'url'",
"]",
".",
"'\"'",
".",
"$",
"class",
".",
"'>'",
".",
"format_string",
"(",
"$",
"link",
"[",
"'content'",
"]",
",",
"true",
",",
"array",
"(",
"'context'",
"=>",
"$",
"this",
"->",
"modcontext",
")",
")",
".",
"'</a>'",
";",
"$",
"icon",
"=",
"$",
"OUTPUT",
"->",
"user_picture",
"(",
"$",
"user",
",",
"array",
"(",
"'popup'",
"=>",
"true",
")",
")",
";",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"array",
"(",
"\"$icon $linkpage\"",
")",
";",
"}",
"}",
"else",
"{",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"array",
"(",
"get_string",
"(",
"'nocontribs'",
",",
"'wiki'",
")",
")",
";",
"}",
"echo",
"html_writer",
"::",
"table",
"(",
"$",
"table",
")",
";",
"}"
] | Prints the contributions tab content
@uses $OUTPUT, $USER | [
"Prints",
"the",
"contributions",
"tab",
"content"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/pagelib.php#L1473-L1529 |
214,611 | moodle/moodle | mod/wiki/pagelib.php | page_wiki_map.print_navigation_content | private function print_navigation_content() {
global $OUTPUT;
$page = $this->page;
if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
$fresh = wiki_refresh_cachedcontent($page);
$page = $fresh['page'];
}
$tolinks = wiki_get_linked_to_pages($page->id);
$fromlinks = wiki_get_linked_from_pages($page->id);
$table = new html_table();
$table->attributes['class'] = 'wiki_navigation_from table';
$table->head = array(get_string('navigationfrom', 'wiki') . $OUTPUT->help_icon('navigationfrom', 'wiki') . ':');
$table->data = array();
$table->rowclasses = array();
foreach ($fromlinks as $link) {
$lpage = wiki_get_page($link->frompageid);
$link = new moodle_url('/mod/wiki/view.php', array('pageid' => $lpage->id));
$table->data[] = array(html_writer::link($link->out(false), format_string($lpage->title)));
}
$table_left = $OUTPUT->container(html_writer::table($table), 'col-md-6');
$table = new html_table();
$table->attributes['class'] = 'wiki_navigation_to table';
$table->head = array(get_string('navigationto', 'wiki') . $OUTPUT->help_icon('navigationto', 'wiki') . ':');
$table->data = array();
$table->rowclasses = array();
foreach ($tolinks as $link) {
if ($link->tomissingpage) {
$viewlink = new moodle_url('/mod/wiki/create.php', array('swid' => $page->subwikiid, 'title' => $link->tomissingpage, 'action' => 'new'));
$table->data[] = array(html_writer::link($viewlink->out(false), format_string($link->tomissingpage), array('class' => 'wiki_newentry')));
} else {
$lpage = wiki_get_page($link->topageid);
$viewlink = new moodle_url('/mod/wiki/view.php', array('pageid' => $lpage->id));
$table->data[] = array(html_writer::link($viewlink->out(false), format_string($lpage->title)));
}
}
$table_right = $OUTPUT->container(html_writer::table($table), 'col-md-6');
echo $OUTPUT->container($table_left . $table_right, 'wiki_navigation_container row');
} | php | private function print_navigation_content() {
global $OUTPUT;
$page = $this->page;
if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
$fresh = wiki_refresh_cachedcontent($page);
$page = $fresh['page'];
}
$tolinks = wiki_get_linked_to_pages($page->id);
$fromlinks = wiki_get_linked_from_pages($page->id);
$table = new html_table();
$table->attributes['class'] = 'wiki_navigation_from table';
$table->head = array(get_string('navigationfrom', 'wiki') . $OUTPUT->help_icon('navigationfrom', 'wiki') . ':');
$table->data = array();
$table->rowclasses = array();
foreach ($fromlinks as $link) {
$lpage = wiki_get_page($link->frompageid);
$link = new moodle_url('/mod/wiki/view.php', array('pageid' => $lpage->id));
$table->data[] = array(html_writer::link($link->out(false), format_string($lpage->title)));
}
$table_left = $OUTPUT->container(html_writer::table($table), 'col-md-6');
$table = new html_table();
$table->attributes['class'] = 'wiki_navigation_to table';
$table->head = array(get_string('navigationto', 'wiki') . $OUTPUT->help_icon('navigationto', 'wiki') . ':');
$table->data = array();
$table->rowclasses = array();
foreach ($tolinks as $link) {
if ($link->tomissingpage) {
$viewlink = new moodle_url('/mod/wiki/create.php', array('swid' => $page->subwikiid, 'title' => $link->tomissingpage, 'action' => 'new'));
$table->data[] = array(html_writer::link($viewlink->out(false), format_string($link->tomissingpage), array('class' => 'wiki_newentry')));
} else {
$lpage = wiki_get_page($link->topageid);
$viewlink = new moodle_url('/mod/wiki/view.php', array('pageid' => $lpage->id));
$table->data[] = array(html_writer::link($viewlink->out(false), format_string($lpage->title)));
}
}
$table_right = $OUTPUT->container(html_writer::table($table), 'col-md-6');
echo $OUTPUT->container($table_left . $table_right, 'wiki_navigation_container row');
} | [
"private",
"function",
"print_navigation_content",
"(",
")",
"{",
"global",
"$",
"OUTPUT",
";",
"$",
"page",
"=",
"$",
"this",
"->",
"page",
";",
"if",
"(",
"$",
"page",
"->",
"timerendered",
"+",
"WIKI_REFRESH_CACHE_TIME",
"<",
"time",
"(",
")",
")",
"{",
"$",
"fresh",
"=",
"wiki_refresh_cachedcontent",
"(",
"$",
"page",
")",
";",
"$",
"page",
"=",
"$",
"fresh",
"[",
"'page'",
"]",
";",
"}",
"$",
"tolinks",
"=",
"wiki_get_linked_to_pages",
"(",
"$",
"page",
"->",
"id",
")",
";",
"$",
"fromlinks",
"=",
"wiki_get_linked_from_pages",
"(",
"$",
"page",
"->",
"id",
")",
";",
"$",
"table",
"=",
"new",
"html_table",
"(",
")",
";",
"$",
"table",
"->",
"attributes",
"[",
"'class'",
"]",
"=",
"'wiki_navigation_from table'",
";",
"$",
"table",
"->",
"head",
"=",
"array",
"(",
"get_string",
"(",
"'navigationfrom'",
",",
"'wiki'",
")",
".",
"$",
"OUTPUT",
"->",
"help_icon",
"(",
"'navigationfrom'",
",",
"'wiki'",
")",
".",
"':'",
")",
";",
"$",
"table",
"->",
"data",
"=",
"array",
"(",
")",
";",
"$",
"table",
"->",
"rowclasses",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"fromlinks",
"as",
"$",
"link",
")",
"{",
"$",
"lpage",
"=",
"wiki_get_page",
"(",
"$",
"link",
"->",
"frompageid",
")",
";",
"$",
"link",
"=",
"new",
"moodle_url",
"(",
"'/mod/wiki/view.php'",
",",
"array",
"(",
"'pageid'",
"=>",
"$",
"lpage",
"->",
"id",
")",
")",
";",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"array",
"(",
"html_writer",
"::",
"link",
"(",
"$",
"link",
"->",
"out",
"(",
"false",
")",
",",
"format_string",
"(",
"$",
"lpage",
"->",
"title",
")",
")",
")",
";",
"}",
"$",
"table_left",
"=",
"$",
"OUTPUT",
"->",
"container",
"(",
"html_writer",
"::",
"table",
"(",
"$",
"table",
")",
",",
"'col-md-6'",
")",
";",
"$",
"table",
"=",
"new",
"html_table",
"(",
")",
";",
"$",
"table",
"->",
"attributes",
"[",
"'class'",
"]",
"=",
"'wiki_navigation_to table'",
";",
"$",
"table",
"->",
"head",
"=",
"array",
"(",
"get_string",
"(",
"'navigationto'",
",",
"'wiki'",
")",
".",
"$",
"OUTPUT",
"->",
"help_icon",
"(",
"'navigationto'",
",",
"'wiki'",
")",
".",
"':'",
")",
";",
"$",
"table",
"->",
"data",
"=",
"array",
"(",
")",
";",
"$",
"table",
"->",
"rowclasses",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"tolinks",
"as",
"$",
"link",
")",
"{",
"if",
"(",
"$",
"link",
"->",
"tomissingpage",
")",
"{",
"$",
"viewlink",
"=",
"new",
"moodle_url",
"(",
"'/mod/wiki/create.php'",
",",
"array",
"(",
"'swid'",
"=>",
"$",
"page",
"->",
"subwikiid",
",",
"'title'",
"=>",
"$",
"link",
"->",
"tomissingpage",
",",
"'action'",
"=>",
"'new'",
")",
")",
";",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"array",
"(",
"html_writer",
"::",
"link",
"(",
"$",
"viewlink",
"->",
"out",
"(",
"false",
")",
",",
"format_string",
"(",
"$",
"link",
"->",
"tomissingpage",
")",
",",
"array",
"(",
"'class'",
"=>",
"'wiki_newentry'",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"lpage",
"=",
"wiki_get_page",
"(",
"$",
"link",
"->",
"topageid",
")",
";",
"$",
"viewlink",
"=",
"new",
"moodle_url",
"(",
"'/mod/wiki/view.php'",
",",
"array",
"(",
"'pageid'",
"=>",
"$",
"lpage",
"->",
"id",
")",
")",
";",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"array",
"(",
"html_writer",
"::",
"link",
"(",
"$",
"viewlink",
"->",
"out",
"(",
"false",
")",
",",
"format_string",
"(",
"$",
"lpage",
"->",
"title",
")",
")",
")",
";",
"}",
"}",
"$",
"table_right",
"=",
"$",
"OUTPUT",
"->",
"container",
"(",
"html_writer",
"::",
"table",
"(",
"$",
"table",
")",
",",
"'col-md-6'",
")",
";",
"echo",
"$",
"OUTPUT",
"->",
"container",
"(",
"$",
"table_left",
".",
"$",
"table_right",
",",
"'wiki_navigation_container row'",
")",
";",
"}"
] | Prints the navigation tab content
@uses $OUTPUT | [
"Prints",
"the",
"navigation",
"tab",
"content"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/pagelib.php#L1537-L1579 |
214,612 | moodle/moodle | mod/wiki/pagelib.php | page_wiki_map.print_index_content | private function print_index_content() {
global $OUTPUT;
$page = $this->page;
if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
$fresh = wiki_refresh_cachedcontent($page);
$page = $fresh['page'];
}
// navigation_node get_content calls format string for us
$node = new navigation_node($page->title);
$keys = array();
$tree = array();
$tree = wiki_build_tree($page, $node, $keys);
$table = new html_table();
$table->head = array(get_string('pageindex', 'wiki') . $OUTPUT->help_icon('pageindex', 'wiki'));
$table->attributes['class'] = 'generalbox table';
$table->data[] = array($this->render_navigation_node($tree));
echo html_writer::table($table);
} | php | private function print_index_content() {
global $OUTPUT;
$page = $this->page;
if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
$fresh = wiki_refresh_cachedcontent($page);
$page = $fresh['page'];
}
// navigation_node get_content calls format string for us
$node = new navigation_node($page->title);
$keys = array();
$tree = array();
$tree = wiki_build_tree($page, $node, $keys);
$table = new html_table();
$table->head = array(get_string('pageindex', 'wiki') . $OUTPUT->help_icon('pageindex', 'wiki'));
$table->attributes['class'] = 'generalbox table';
$table->data[] = array($this->render_navigation_node($tree));
echo html_writer::table($table);
} | [
"private",
"function",
"print_index_content",
"(",
")",
"{",
"global",
"$",
"OUTPUT",
";",
"$",
"page",
"=",
"$",
"this",
"->",
"page",
";",
"if",
"(",
"$",
"page",
"->",
"timerendered",
"+",
"WIKI_REFRESH_CACHE_TIME",
"<",
"time",
"(",
")",
")",
"{",
"$",
"fresh",
"=",
"wiki_refresh_cachedcontent",
"(",
"$",
"page",
")",
";",
"$",
"page",
"=",
"$",
"fresh",
"[",
"'page'",
"]",
";",
"}",
"// navigation_node get_content calls format string for us",
"$",
"node",
"=",
"new",
"navigation_node",
"(",
"$",
"page",
"->",
"title",
")",
";",
"$",
"keys",
"=",
"array",
"(",
")",
";",
"$",
"tree",
"=",
"array",
"(",
")",
";",
"$",
"tree",
"=",
"wiki_build_tree",
"(",
"$",
"page",
",",
"$",
"node",
",",
"$",
"keys",
")",
";",
"$",
"table",
"=",
"new",
"html_table",
"(",
")",
";",
"$",
"table",
"->",
"head",
"=",
"array",
"(",
"get_string",
"(",
"'pageindex'",
",",
"'wiki'",
")",
".",
"$",
"OUTPUT",
"->",
"help_icon",
"(",
"'pageindex'",
",",
"'wiki'",
")",
")",
";",
"$",
"table",
"->",
"attributes",
"[",
"'class'",
"]",
"=",
"'generalbox table'",
";",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"array",
"(",
"$",
"this",
"->",
"render_navigation_node",
"(",
"$",
"tree",
")",
")",
";",
"echo",
"html_writer",
"::",
"table",
"(",
"$",
"table",
")",
";",
"}"
] | Prints the index page tab content | [
"Prints",
"the",
"index",
"page",
"tab",
"content"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/pagelib.php#L1586-L1608 |
214,613 | moodle/moodle | mod/wiki/pagelib.php | page_wiki_map.print_page_list_content | private function print_page_list_content() {
global $OUTPUT;
$page = $this->page;
if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
$fresh = wiki_refresh_cachedcontent($page);
$page = $fresh['page'];
}
$pages = wiki_get_page_list($this->subwiki->id);
$stdaux = new stdClass();
$strspecial = get_string('special', 'wiki');
foreach ($pages as $page) {
// We need to format the title here to account for any filtering
$letter = format_string($page->title, true, array('context' => $this->modcontext));
$letter = core_text::substr($letter, 0, 1);
if (preg_match('/^[a-zA-Z]$/', $letter)) {
$letter = core_text::strtoupper($letter);
$stdaux->{$letter}[] = wiki_parser_link($page);
} else {
$stdaux->{$strspecial}[] = wiki_parser_link($page);
}
}
$table = new html_table();
$table->head = array(get_string('pagelist', 'wiki') . $OUTPUT->help_icon('pagelist', 'wiki'));
$table->attributes['class'] = 'generalbox table';
foreach ($stdaux as $key => $elem) {
$table->data[] = array($key);
foreach ($elem as $e) {
$table->data[] = array(html_writer::link($e['url'], format_string($e['content'], true, array('context' => $this->modcontext))));
}
}
echo html_writer::table($table);
} | php | private function print_page_list_content() {
global $OUTPUT;
$page = $this->page;
if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
$fresh = wiki_refresh_cachedcontent($page);
$page = $fresh['page'];
}
$pages = wiki_get_page_list($this->subwiki->id);
$stdaux = new stdClass();
$strspecial = get_string('special', 'wiki');
foreach ($pages as $page) {
// We need to format the title here to account for any filtering
$letter = format_string($page->title, true, array('context' => $this->modcontext));
$letter = core_text::substr($letter, 0, 1);
if (preg_match('/^[a-zA-Z]$/', $letter)) {
$letter = core_text::strtoupper($letter);
$stdaux->{$letter}[] = wiki_parser_link($page);
} else {
$stdaux->{$strspecial}[] = wiki_parser_link($page);
}
}
$table = new html_table();
$table->head = array(get_string('pagelist', 'wiki') . $OUTPUT->help_icon('pagelist', 'wiki'));
$table->attributes['class'] = 'generalbox table';
foreach ($stdaux as $key => $elem) {
$table->data[] = array($key);
foreach ($elem as $e) {
$table->data[] = array(html_writer::link($e['url'], format_string($e['content'], true, array('context' => $this->modcontext))));
}
}
echo html_writer::table($table);
} | [
"private",
"function",
"print_page_list_content",
"(",
")",
"{",
"global",
"$",
"OUTPUT",
";",
"$",
"page",
"=",
"$",
"this",
"->",
"page",
";",
"if",
"(",
"$",
"page",
"->",
"timerendered",
"+",
"WIKI_REFRESH_CACHE_TIME",
"<",
"time",
"(",
")",
")",
"{",
"$",
"fresh",
"=",
"wiki_refresh_cachedcontent",
"(",
"$",
"page",
")",
";",
"$",
"page",
"=",
"$",
"fresh",
"[",
"'page'",
"]",
";",
"}",
"$",
"pages",
"=",
"wiki_get_page_list",
"(",
"$",
"this",
"->",
"subwiki",
"->",
"id",
")",
";",
"$",
"stdaux",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"strspecial",
"=",
"get_string",
"(",
"'special'",
",",
"'wiki'",
")",
";",
"foreach",
"(",
"$",
"pages",
"as",
"$",
"page",
")",
"{",
"// We need to format the title here to account for any filtering",
"$",
"letter",
"=",
"format_string",
"(",
"$",
"page",
"->",
"title",
",",
"true",
",",
"array",
"(",
"'context'",
"=>",
"$",
"this",
"->",
"modcontext",
")",
")",
";",
"$",
"letter",
"=",
"core_text",
"::",
"substr",
"(",
"$",
"letter",
",",
"0",
",",
"1",
")",
";",
"if",
"(",
"preg_match",
"(",
"'/^[a-zA-Z]$/'",
",",
"$",
"letter",
")",
")",
"{",
"$",
"letter",
"=",
"core_text",
"::",
"strtoupper",
"(",
"$",
"letter",
")",
";",
"$",
"stdaux",
"->",
"{",
"$",
"letter",
"}",
"[",
"]",
"=",
"wiki_parser_link",
"(",
"$",
"page",
")",
";",
"}",
"else",
"{",
"$",
"stdaux",
"->",
"{",
"$",
"strspecial",
"}",
"[",
"]",
"=",
"wiki_parser_link",
"(",
"$",
"page",
")",
";",
"}",
"}",
"$",
"table",
"=",
"new",
"html_table",
"(",
")",
";",
"$",
"table",
"->",
"head",
"=",
"array",
"(",
"get_string",
"(",
"'pagelist'",
",",
"'wiki'",
")",
".",
"$",
"OUTPUT",
"->",
"help_icon",
"(",
"'pagelist'",
",",
"'wiki'",
")",
")",
";",
"$",
"table",
"->",
"attributes",
"[",
"'class'",
"]",
"=",
"'generalbox table'",
";",
"foreach",
"(",
"$",
"stdaux",
"as",
"$",
"key",
"=>",
"$",
"elem",
")",
"{",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"array",
"(",
"$",
"key",
")",
";",
"foreach",
"(",
"$",
"elem",
"as",
"$",
"e",
")",
"{",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"array",
"(",
"html_writer",
"::",
"link",
"(",
"$",
"e",
"[",
"'url'",
"]",
",",
"format_string",
"(",
"$",
"e",
"[",
"'content'",
"]",
",",
"true",
",",
"array",
"(",
"'context'",
"=>",
"$",
"this",
"->",
"modcontext",
")",
")",
")",
")",
";",
"}",
"}",
"echo",
"html_writer",
"::",
"table",
"(",
"$",
"table",
")",
";",
"}"
] | Prints the page list tab content | [
"Prints",
"the",
"page",
"list",
"tab",
"content"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/pagelib.php#L1615-L1651 |
214,614 | moodle/moodle | mod/wiki/pagelib.php | page_wiki_map.print_orphaned_content | private function print_orphaned_content() {
global $OUTPUT;
$page = $this->page;
if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
$fresh = wiki_refresh_cachedcontent($page);
$page = $fresh['page'];
}
$swid = $this->subwiki->id;
$table = new html_table();
$table->head = array(get_string('orphaned', 'wiki') . $OUTPUT->help_icon('orphaned', 'wiki'));
$table->attributes['class'] = 'generalbox table';
$table->data = array();
$table->rowclasses = array();
if ($orphanedpages = wiki_get_orphaned_pages($swid)) {
foreach ($orphanedpages as $page) {
$link = wiki_parser_link($page->title, array('swid' => $swid));
$class = ($link['new']) ? 'class="wiki_newentry"' : '';
$table->data[] = array('<a href="' . $link['url'] . '"' . $class . '>' . format_string($link['content']) . '</a>');
}
} else {
$table->data[] = array(get_string('noorphanedpages', 'wiki'));
}
echo html_writer::table($table);
} | php | private function print_orphaned_content() {
global $OUTPUT;
$page = $this->page;
if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
$fresh = wiki_refresh_cachedcontent($page);
$page = $fresh['page'];
}
$swid = $this->subwiki->id;
$table = new html_table();
$table->head = array(get_string('orphaned', 'wiki') . $OUTPUT->help_icon('orphaned', 'wiki'));
$table->attributes['class'] = 'generalbox table';
$table->data = array();
$table->rowclasses = array();
if ($orphanedpages = wiki_get_orphaned_pages($swid)) {
foreach ($orphanedpages as $page) {
$link = wiki_parser_link($page->title, array('swid' => $swid));
$class = ($link['new']) ? 'class="wiki_newentry"' : '';
$table->data[] = array('<a href="' . $link['url'] . '"' . $class . '>' . format_string($link['content']) . '</a>');
}
} else {
$table->data[] = array(get_string('noorphanedpages', 'wiki'));
}
echo html_writer::table($table);
} | [
"private",
"function",
"print_orphaned_content",
"(",
")",
"{",
"global",
"$",
"OUTPUT",
";",
"$",
"page",
"=",
"$",
"this",
"->",
"page",
";",
"if",
"(",
"$",
"page",
"->",
"timerendered",
"+",
"WIKI_REFRESH_CACHE_TIME",
"<",
"time",
"(",
")",
")",
"{",
"$",
"fresh",
"=",
"wiki_refresh_cachedcontent",
"(",
"$",
"page",
")",
";",
"$",
"page",
"=",
"$",
"fresh",
"[",
"'page'",
"]",
";",
"}",
"$",
"swid",
"=",
"$",
"this",
"->",
"subwiki",
"->",
"id",
";",
"$",
"table",
"=",
"new",
"html_table",
"(",
")",
";",
"$",
"table",
"->",
"head",
"=",
"array",
"(",
"get_string",
"(",
"'orphaned'",
",",
"'wiki'",
")",
".",
"$",
"OUTPUT",
"->",
"help_icon",
"(",
"'orphaned'",
",",
"'wiki'",
")",
")",
";",
"$",
"table",
"->",
"attributes",
"[",
"'class'",
"]",
"=",
"'generalbox table'",
";",
"$",
"table",
"->",
"data",
"=",
"array",
"(",
")",
";",
"$",
"table",
"->",
"rowclasses",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"orphanedpages",
"=",
"wiki_get_orphaned_pages",
"(",
"$",
"swid",
")",
")",
"{",
"foreach",
"(",
"$",
"orphanedpages",
"as",
"$",
"page",
")",
"{",
"$",
"link",
"=",
"wiki_parser_link",
"(",
"$",
"page",
"->",
"title",
",",
"array",
"(",
"'swid'",
"=>",
"$",
"swid",
")",
")",
";",
"$",
"class",
"=",
"(",
"$",
"link",
"[",
"'new'",
"]",
")",
"?",
"'class=\"wiki_newentry\"'",
":",
"''",
";",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"array",
"(",
"'<a href=\"'",
".",
"$",
"link",
"[",
"'url'",
"]",
".",
"'\"'",
".",
"$",
"class",
".",
"'>'",
".",
"format_string",
"(",
"$",
"link",
"[",
"'content'",
"]",
")",
".",
"'</a>'",
")",
";",
"}",
"}",
"else",
"{",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"array",
"(",
"get_string",
"(",
"'noorphanedpages'",
",",
"'wiki'",
")",
")",
";",
"}",
"echo",
"html_writer",
"::",
"table",
"(",
"$",
"table",
")",
";",
"}"
] | Prints the orphaned tab content | [
"Prints",
"the",
"orphaned",
"tab",
"content"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/pagelib.php#L1658-L1687 |
214,615 | moodle/moodle | mod/wiki/pagelib.php | page_wiki_map.print_updated_content | private function print_updated_content() {
global $COURSE, $OUTPUT;
$page = $this->page;
if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
$fresh = wiki_refresh_cachedcontent($page);
$page = $fresh['page'];
}
$swid = $this->subwiki->id;
$table = new html_table();
$table->head = array(get_string('updatedpages', 'wiki') . $OUTPUT->help_icon('updatedpages', 'wiki'));
$table->attributes['class'] = 'generalbox table';
$table->data = array();
$table->rowclasses = array();
if ($pages = wiki_get_updated_pages_by_subwiki($swid)) {
$strdataux = '';
foreach ($pages as $page) {
$user = wiki_get_user_info($page->userid);
$strdata = strftime('%d %b %Y', $page->timemodified);
if ($strdata != $strdataux) {
$table->data[] = array($OUTPUT->heading($strdata, 4));
$strdataux = $strdata;
}
$link = wiki_parser_link($page->title, array('swid' => $swid));
$class = ($link['new']) ? 'class="wiki_newentry"' : '';
$linkpage = '<a href="' . $link['url'] . '"' . $class . '>' . format_string($link['content']) . '</a>';
$icon = $OUTPUT->user_picture($user, array($COURSE->id));
$table->data[] = array("$icon $linkpage");
}
} else {
$table->data[] = array(get_string('noupdatedpages', 'wiki'));
}
echo html_writer::table($table);
} | php | private function print_updated_content() {
global $COURSE, $OUTPUT;
$page = $this->page;
if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
$fresh = wiki_refresh_cachedcontent($page);
$page = $fresh['page'];
}
$swid = $this->subwiki->id;
$table = new html_table();
$table->head = array(get_string('updatedpages', 'wiki') . $OUTPUT->help_icon('updatedpages', 'wiki'));
$table->attributes['class'] = 'generalbox table';
$table->data = array();
$table->rowclasses = array();
if ($pages = wiki_get_updated_pages_by_subwiki($swid)) {
$strdataux = '';
foreach ($pages as $page) {
$user = wiki_get_user_info($page->userid);
$strdata = strftime('%d %b %Y', $page->timemodified);
if ($strdata != $strdataux) {
$table->data[] = array($OUTPUT->heading($strdata, 4));
$strdataux = $strdata;
}
$link = wiki_parser_link($page->title, array('swid' => $swid));
$class = ($link['new']) ? 'class="wiki_newentry"' : '';
$linkpage = '<a href="' . $link['url'] . '"' . $class . '>' . format_string($link['content']) . '</a>';
$icon = $OUTPUT->user_picture($user, array($COURSE->id));
$table->data[] = array("$icon $linkpage");
}
} else {
$table->data[] = array(get_string('noupdatedpages', 'wiki'));
}
echo html_writer::table($table);
} | [
"private",
"function",
"print_updated_content",
"(",
")",
"{",
"global",
"$",
"COURSE",
",",
"$",
"OUTPUT",
";",
"$",
"page",
"=",
"$",
"this",
"->",
"page",
";",
"if",
"(",
"$",
"page",
"->",
"timerendered",
"+",
"WIKI_REFRESH_CACHE_TIME",
"<",
"time",
"(",
")",
")",
"{",
"$",
"fresh",
"=",
"wiki_refresh_cachedcontent",
"(",
"$",
"page",
")",
";",
"$",
"page",
"=",
"$",
"fresh",
"[",
"'page'",
"]",
";",
"}",
"$",
"swid",
"=",
"$",
"this",
"->",
"subwiki",
"->",
"id",
";",
"$",
"table",
"=",
"new",
"html_table",
"(",
")",
";",
"$",
"table",
"->",
"head",
"=",
"array",
"(",
"get_string",
"(",
"'updatedpages'",
",",
"'wiki'",
")",
".",
"$",
"OUTPUT",
"->",
"help_icon",
"(",
"'updatedpages'",
",",
"'wiki'",
")",
")",
";",
"$",
"table",
"->",
"attributes",
"[",
"'class'",
"]",
"=",
"'generalbox table'",
";",
"$",
"table",
"->",
"data",
"=",
"array",
"(",
")",
";",
"$",
"table",
"->",
"rowclasses",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"pages",
"=",
"wiki_get_updated_pages_by_subwiki",
"(",
"$",
"swid",
")",
")",
"{",
"$",
"strdataux",
"=",
"''",
";",
"foreach",
"(",
"$",
"pages",
"as",
"$",
"page",
")",
"{",
"$",
"user",
"=",
"wiki_get_user_info",
"(",
"$",
"page",
"->",
"userid",
")",
";",
"$",
"strdata",
"=",
"strftime",
"(",
"'%d %b %Y'",
",",
"$",
"page",
"->",
"timemodified",
")",
";",
"if",
"(",
"$",
"strdata",
"!=",
"$",
"strdataux",
")",
"{",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"array",
"(",
"$",
"OUTPUT",
"->",
"heading",
"(",
"$",
"strdata",
",",
"4",
")",
")",
";",
"$",
"strdataux",
"=",
"$",
"strdata",
";",
"}",
"$",
"link",
"=",
"wiki_parser_link",
"(",
"$",
"page",
"->",
"title",
",",
"array",
"(",
"'swid'",
"=>",
"$",
"swid",
")",
")",
";",
"$",
"class",
"=",
"(",
"$",
"link",
"[",
"'new'",
"]",
")",
"?",
"'class=\"wiki_newentry\"'",
":",
"''",
";",
"$",
"linkpage",
"=",
"'<a href=\"'",
".",
"$",
"link",
"[",
"'url'",
"]",
".",
"'\"'",
".",
"$",
"class",
".",
"'>'",
".",
"format_string",
"(",
"$",
"link",
"[",
"'content'",
"]",
")",
".",
"'</a>'",
";",
"$",
"icon",
"=",
"$",
"OUTPUT",
"->",
"user_picture",
"(",
"$",
"user",
",",
"array",
"(",
"$",
"COURSE",
"->",
"id",
")",
")",
";",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"array",
"(",
"\"$icon $linkpage\"",
")",
";",
"}",
"}",
"else",
"{",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"array",
"(",
"get_string",
"(",
"'noupdatedpages'",
",",
"'wiki'",
")",
")",
";",
"}",
"echo",
"html_writer",
"::",
"table",
"(",
"$",
"table",
")",
";",
"}"
] | Prints the updated tab content
@uses $COURSE, $OUTPUT | [
"Prints",
"the",
"updated",
"tab",
"content"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/pagelib.php#L1695-L1733 |
214,616 | moodle/moodle | mod/wiki/pagelib.php | page_wiki_restoreversion.print_restoreversion | private function print_restoreversion() {
global $OUTPUT;
$version = wiki_get_version($this->version->id);
$optionsyes = array('confirm'=>1, 'pageid'=>$this->page->id, 'versionid'=>$version->id, 'sesskey'=>sesskey());
$restoreurl = new moodle_url('/mod/wiki/restoreversion.php', $optionsyes);
$return = new moodle_url('/mod/wiki/viewversion.php', array('pageid'=>$this->page->id, 'versionid'=>$version->id));
echo $OUTPUT->container_start();
echo html_writer::tag('div', get_string('restoreconfirm', 'wiki', $version->version));
echo $OUTPUT->container_start(false, 'wiki_restoreform');
echo '<form class="wiki_restore_yes" action="' . $restoreurl . '" method="post" id="restoreversion">';
echo '<div><input type="submit" class="btn btn-secondary" name="confirm" value="' . get_string('yes') . '" /></div>';
echo '</form>';
echo '<form class="wiki_restore_no" action="' . $return . '" method="post">';
echo '<div><input type="submit" class="btn btn-secondary" name="norestore" value="' . get_string('no') . '" /></div>';
echo '</form>';
echo $OUTPUT->container_end();
echo $OUTPUT->container_end();
} | php | private function print_restoreversion() {
global $OUTPUT;
$version = wiki_get_version($this->version->id);
$optionsyes = array('confirm'=>1, 'pageid'=>$this->page->id, 'versionid'=>$version->id, 'sesskey'=>sesskey());
$restoreurl = new moodle_url('/mod/wiki/restoreversion.php', $optionsyes);
$return = new moodle_url('/mod/wiki/viewversion.php', array('pageid'=>$this->page->id, 'versionid'=>$version->id));
echo $OUTPUT->container_start();
echo html_writer::tag('div', get_string('restoreconfirm', 'wiki', $version->version));
echo $OUTPUT->container_start(false, 'wiki_restoreform');
echo '<form class="wiki_restore_yes" action="' . $restoreurl . '" method="post" id="restoreversion">';
echo '<div><input type="submit" class="btn btn-secondary" name="confirm" value="' . get_string('yes') . '" /></div>';
echo '</form>';
echo '<form class="wiki_restore_no" action="' . $return . '" method="post">';
echo '<div><input type="submit" class="btn btn-secondary" name="norestore" value="' . get_string('no') . '" /></div>';
echo '</form>';
echo $OUTPUT->container_end();
echo $OUTPUT->container_end();
} | [
"private",
"function",
"print_restoreversion",
"(",
")",
"{",
"global",
"$",
"OUTPUT",
";",
"$",
"version",
"=",
"wiki_get_version",
"(",
"$",
"this",
"->",
"version",
"->",
"id",
")",
";",
"$",
"optionsyes",
"=",
"array",
"(",
"'confirm'",
"=>",
"1",
",",
"'pageid'",
"=>",
"$",
"this",
"->",
"page",
"->",
"id",
",",
"'versionid'",
"=>",
"$",
"version",
"->",
"id",
",",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
")",
";",
"$",
"restoreurl",
"=",
"new",
"moodle_url",
"(",
"'/mod/wiki/restoreversion.php'",
",",
"$",
"optionsyes",
")",
";",
"$",
"return",
"=",
"new",
"moodle_url",
"(",
"'/mod/wiki/viewversion.php'",
",",
"array",
"(",
"'pageid'",
"=>",
"$",
"this",
"->",
"page",
"->",
"id",
",",
"'versionid'",
"=>",
"$",
"version",
"->",
"id",
")",
")",
";",
"echo",
"$",
"OUTPUT",
"->",
"container_start",
"(",
")",
";",
"echo",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"get_string",
"(",
"'restoreconfirm'",
",",
"'wiki'",
",",
"$",
"version",
"->",
"version",
")",
")",
";",
"echo",
"$",
"OUTPUT",
"->",
"container_start",
"(",
"false",
",",
"'wiki_restoreform'",
")",
";",
"echo",
"'<form class=\"wiki_restore_yes\" action=\"'",
".",
"$",
"restoreurl",
".",
"'\" method=\"post\" id=\"restoreversion\">'",
";",
"echo",
"'<div><input type=\"submit\" class=\"btn btn-secondary\" name=\"confirm\" value=\"'",
".",
"get_string",
"(",
"'yes'",
")",
".",
"'\" /></div>'",
";",
"echo",
"'</form>'",
";",
"echo",
"'<form class=\"wiki_restore_no\" action=\"'",
".",
"$",
"return",
".",
"'\" method=\"post\">'",
";",
"echo",
"'<div><input type=\"submit\" class=\"btn btn-secondary\" name=\"norestore\" value=\"'",
".",
"get_string",
"(",
"'no'",
")",
".",
"'\" /></div>'",
";",
"echo",
"'</form>'",
";",
"echo",
"$",
"OUTPUT",
"->",
"container_end",
"(",
")",
";",
"echo",
"$",
"OUTPUT",
"->",
"container_end",
"(",
")",
";",
"}"
] | Prints the restore version content
@uses $CFG
@param page $page The page whose version will be restored
@param int $versionid The version to be restored
@param bool $confirm If false, shows a yes/no confirmation page.
If true, restores the old version and redirects the user to the 'view' tab. | [
"Prints",
"the",
"restore",
"version",
"content"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/pagelib.php#L1884-L1904 |
214,617 | moodle/moodle | mod/wiki/pagelib.php | page_wiki_deletecomment.printconfirmdelete | private function printconfirmdelete() {
global $OUTPUT;
$strdeletecheck = get_string('deletecommentcheck', 'wiki');
$strdeletecheckfull = get_string('deletecommentcheckfull', 'wiki');
//ask confirmation
$optionsyes = array('confirm'=>1, 'pageid'=>$this->page->id, 'action'=>'delete', 'commentid'=>$this->commentid, 'sesskey'=>sesskey());
$deleteurl = new moodle_url('/mod/wiki/instancecomments.php', $optionsyes);
$return = new moodle_url('/mod/wiki/comments.php', array('pageid'=>$this->page->id));
echo $OUTPUT->container_start();
echo html_writer::tag('p', $strdeletecheckfull);
echo $OUTPUT->container_start(false, 'wiki_deletecommentform');
echo '<form class="wiki_deletecomment_yes" action="' . $deleteurl . '" method="post" id="deletecomment">';
echo '<div><input type="submit" class="btn btn-secondary" name="confirmdeletecomment" value="'
. get_string('yes') . '" /></div>';
echo '</form>';
echo '<form class="wiki_deletecomment_no" action="' . $return . '" method="post">';
echo '<div><input type="submit" class="btn btn-secondary" name="norestore" value="' . get_string('no') . '" /></div>';
echo '</form>';
echo $OUTPUT->container_end();
echo $OUTPUT->container_end();
} | php | private function printconfirmdelete() {
global $OUTPUT;
$strdeletecheck = get_string('deletecommentcheck', 'wiki');
$strdeletecheckfull = get_string('deletecommentcheckfull', 'wiki');
//ask confirmation
$optionsyes = array('confirm'=>1, 'pageid'=>$this->page->id, 'action'=>'delete', 'commentid'=>$this->commentid, 'sesskey'=>sesskey());
$deleteurl = new moodle_url('/mod/wiki/instancecomments.php', $optionsyes);
$return = new moodle_url('/mod/wiki/comments.php', array('pageid'=>$this->page->id));
echo $OUTPUT->container_start();
echo html_writer::tag('p', $strdeletecheckfull);
echo $OUTPUT->container_start(false, 'wiki_deletecommentform');
echo '<form class="wiki_deletecomment_yes" action="' . $deleteurl . '" method="post" id="deletecomment">';
echo '<div><input type="submit" class="btn btn-secondary" name="confirmdeletecomment" value="'
. get_string('yes') . '" /></div>';
echo '</form>';
echo '<form class="wiki_deletecomment_no" action="' . $return . '" method="post">';
echo '<div><input type="submit" class="btn btn-secondary" name="norestore" value="' . get_string('no') . '" /></div>';
echo '</form>';
echo $OUTPUT->container_end();
echo $OUTPUT->container_end();
} | [
"private",
"function",
"printconfirmdelete",
"(",
")",
"{",
"global",
"$",
"OUTPUT",
";",
"$",
"strdeletecheck",
"=",
"get_string",
"(",
"'deletecommentcheck'",
",",
"'wiki'",
")",
";",
"$",
"strdeletecheckfull",
"=",
"get_string",
"(",
"'deletecommentcheckfull'",
",",
"'wiki'",
")",
";",
"//ask confirmation",
"$",
"optionsyes",
"=",
"array",
"(",
"'confirm'",
"=>",
"1",
",",
"'pageid'",
"=>",
"$",
"this",
"->",
"page",
"->",
"id",
",",
"'action'",
"=>",
"'delete'",
",",
"'commentid'",
"=>",
"$",
"this",
"->",
"commentid",
",",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
")",
";",
"$",
"deleteurl",
"=",
"new",
"moodle_url",
"(",
"'/mod/wiki/instancecomments.php'",
",",
"$",
"optionsyes",
")",
";",
"$",
"return",
"=",
"new",
"moodle_url",
"(",
"'/mod/wiki/comments.php'",
",",
"array",
"(",
"'pageid'",
"=>",
"$",
"this",
"->",
"page",
"->",
"id",
")",
")",
";",
"echo",
"$",
"OUTPUT",
"->",
"container_start",
"(",
")",
";",
"echo",
"html_writer",
"::",
"tag",
"(",
"'p'",
",",
"$",
"strdeletecheckfull",
")",
";",
"echo",
"$",
"OUTPUT",
"->",
"container_start",
"(",
"false",
",",
"'wiki_deletecommentform'",
")",
";",
"echo",
"'<form class=\"wiki_deletecomment_yes\" action=\"'",
".",
"$",
"deleteurl",
".",
"'\" method=\"post\" id=\"deletecomment\">'",
";",
"echo",
"'<div><input type=\"submit\" class=\"btn btn-secondary\" name=\"confirmdeletecomment\" value=\"'",
".",
"get_string",
"(",
"'yes'",
")",
".",
"'\" /></div>'",
";",
"echo",
"'</form>'",
";",
"echo",
"'<form class=\"wiki_deletecomment_no\" action=\"'",
".",
"$",
"return",
".",
"'\" method=\"post\">'",
";",
"echo",
"'<div><input type=\"submit\" class=\"btn btn-secondary\" name=\"norestore\" value=\"'",
".",
"get_string",
"(",
"'no'",
")",
".",
"'\" /></div>'",
";",
"echo",
"'</form>'",
";",
"echo",
"$",
"OUTPUT",
"->",
"container_end",
"(",
")",
";",
"echo",
"$",
"OUTPUT",
"->",
"container_end",
"(",
")",
";",
"}"
] | Prints the comment deletion confirmation form
@param page $page The page whose version will be restored
@param int $versionid The version to be restored
@param bool $confirm If false, shows a yes/no confirmation page.
If true, restores the old version and redirects the user to the 'view' tab. | [
"Prints",
"the",
"comment",
"deletion",
"confirmation",
"form"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/pagelib.php#L1952-L1975 |
214,618 | moodle/moodle | mod/wiki/pagelib.php | page_wiki_viewversion.print_version_view | private function print_version_view() {
global $CFG, $OUTPUT, $PAGE;
$pageversion = wiki_get_version($this->version->id);
if ($pageversion) {
$restorelink = new moodle_url('/mod/wiki/restoreversion.php', array('pageid' => $this->page->id, 'versionid' => $this->version->id));
echo html_writer::tag('div', get_string('viewversion', 'wiki', $pageversion->version) . '<br />' .
html_writer::link($restorelink->out(false), '(' . get_string('restorethis', 'wiki') .
')', array('class' => 'wiki_restore')) . ' ', array('class' => 'wiki_headingtitle'));
$userinfo = wiki_get_user_info($pageversion->userid);
$heading = '<p><strong>' . get_string('modified', 'wiki') . ':</strong> ' . userdate($pageversion->timecreated, get_string('strftimedatetime', 'langconfig'));
$viewlink = new moodle_url('/user/view.php', array('id' => $userinfo->id));
$heading .= ' <strong>' . get_string('user') . ':</strong> ' . html_writer::link($viewlink->out(false), fullname($userinfo));
$heading .= ' → ' . $OUTPUT->user_picture(wiki_get_user_info($pageversion->userid), array('popup' => true)) . '</p>';
echo $OUTPUT->container($heading, 'wiki_headingtime', 'wiki_modifieduser');
$options = array('swid' => $this->subwiki->id, 'pretty_print' => true, 'pageid' => $this->page->id);
$pageversion->content = file_rewrite_pluginfile_urls($pageversion->content, 'pluginfile.php', $this->modcontext->id, 'mod_wiki', 'attachments', $this->subwiki->id);
$parseroutput = wiki_parse_content($pageversion->contentformat, $pageversion->content, $options);
$content = $OUTPUT->container(format_text($parseroutput['parsed_text'], FORMAT_HTML, array('overflowdiv'=>true)), false, '', '', true);
echo $OUTPUT->box($content, 'generalbox wiki_contentbox');
} else {
print_error('versionerror', 'wiki');
}
} | php | private function print_version_view() {
global $CFG, $OUTPUT, $PAGE;
$pageversion = wiki_get_version($this->version->id);
if ($pageversion) {
$restorelink = new moodle_url('/mod/wiki/restoreversion.php', array('pageid' => $this->page->id, 'versionid' => $this->version->id));
echo html_writer::tag('div', get_string('viewversion', 'wiki', $pageversion->version) . '<br />' .
html_writer::link($restorelink->out(false), '(' . get_string('restorethis', 'wiki') .
')', array('class' => 'wiki_restore')) . ' ', array('class' => 'wiki_headingtitle'));
$userinfo = wiki_get_user_info($pageversion->userid);
$heading = '<p><strong>' . get_string('modified', 'wiki') . ':</strong> ' . userdate($pageversion->timecreated, get_string('strftimedatetime', 'langconfig'));
$viewlink = new moodle_url('/user/view.php', array('id' => $userinfo->id));
$heading .= ' <strong>' . get_string('user') . ':</strong> ' . html_writer::link($viewlink->out(false), fullname($userinfo));
$heading .= ' → ' . $OUTPUT->user_picture(wiki_get_user_info($pageversion->userid), array('popup' => true)) . '</p>';
echo $OUTPUT->container($heading, 'wiki_headingtime', 'wiki_modifieduser');
$options = array('swid' => $this->subwiki->id, 'pretty_print' => true, 'pageid' => $this->page->id);
$pageversion->content = file_rewrite_pluginfile_urls($pageversion->content, 'pluginfile.php', $this->modcontext->id, 'mod_wiki', 'attachments', $this->subwiki->id);
$parseroutput = wiki_parse_content($pageversion->contentformat, $pageversion->content, $options);
$content = $OUTPUT->container(format_text($parseroutput['parsed_text'], FORMAT_HTML, array('overflowdiv'=>true)), false, '', '', true);
echo $OUTPUT->box($content, 'generalbox wiki_contentbox');
} else {
print_error('versionerror', 'wiki');
}
} | [
"private",
"function",
"print_version_view",
"(",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"OUTPUT",
",",
"$",
"PAGE",
";",
"$",
"pageversion",
"=",
"wiki_get_version",
"(",
"$",
"this",
"->",
"version",
"->",
"id",
")",
";",
"if",
"(",
"$",
"pageversion",
")",
"{",
"$",
"restorelink",
"=",
"new",
"moodle_url",
"(",
"'/mod/wiki/restoreversion.php'",
",",
"array",
"(",
"'pageid'",
"=>",
"$",
"this",
"->",
"page",
"->",
"id",
",",
"'versionid'",
"=>",
"$",
"this",
"->",
"version",
"->",
"id",
")",
")",
";",
"echo",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"get_string",
"(",
"'viewversion'",
",",
"'wiki'",
",",
"$",
"pageversion",
"->",
"version",
")",
".",
"'<br />'",
".",
"html_writer",
"::",
"link",
"(",
"$",
"restorelink",
"->",
"out",
"(",
"false",
")",
",",
"'('",
".",
"get_string",
"(",
"'restorethis'",
",",
"'wiki'",
")",
".",
"')'",
",",
"array",
"(",
"'class'",
"=>",
"'wiki_restore'",
")",
")",
".",
"' '",
",",
"array",
"(",
"'class'",
"=>",
"'wiki_headingtitle'",
")",
")",
";",
"$",
"userinfo",
"=",
"wiki_get_user_info",
"(",
"$",
"pageversion",
"->",
"userid",
")",
";",
"$",
"heading",
"=",
"'<p><strong>'",
".",
"get_string",
"(",
"'modified'",
",",
"'wiki'",
")",
".",
"':</strong> '",
".",
"userdate",
"(",
"$",
"pageversion",
"->",
"timecreated",
",",
"get_string",
"(",
"'strftimedatetime'",
",",
"'langconfig'",
")",
")",
";",
"$",
"viewlink",
"=",
"new",
"moodle_url",
"(",
"'/user/view.php'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"userinfo",
"->",
"id",
")",
")",
";",
"$",
"heading",
".=",
"' <strong>'",
".",
"get_string",
"(",
"'user'",
")",
".",
"':</strong> '",
".",
"html_writer",
"::",
"link",
"(",
"$",
"viewlink",
"->",
"out",
"(",
"false",
")",
",",
"fullname",
"(",
"$",
"userinfo",
")",
")",
";",
"$",
"heading",
".=",
"' → '",
".",
"$",
"OUTPUT",
"->",
"user_picture",
"(",
"wiki_get_user_info",
"(",
"$",
"pageversion",
"->",
"userid",
")",
",",
"array",
"(",
"'popup'",
"=>",
"true",
")",
")",
".",
"'</p>'",
";",
"echo",
"$",
"OUTPUT",
"->",
"container",
"(",
"$",
"heading",
",",
"'wiki_headingtime'",
",",
"'wiki_modifieduser'",
")",
";",
"$",
"options",
"=",
"array",
"(",
"'swid'",
"=>",
"$",
"this",
"->",
"subwiki",
"->",
"id",
",",
"'pretty_print'",
"=>",
"true",
",",
"'pageid'",
"=>",
"$",
"this",
"->",
"page",
"->",
"id",
")",
";",
"$",
"pageversion",
"->",
"content",
"=",
"file_rewrite_pluginfile_urls",
"(",
"$",
"pageversion",
"->",
"content",
",",
"'pluginfile.php'",
",",
"$",
"this",
"->",
"modcontext",
"->",
"id",
",",
"'mod_wiki'",
",",
"'attachments'",
",",
"$",
"this",
"->",
"subwiki",
"->",
"id",
")",
";",
"$",
"parseroutput",
"=",
"wiki_parse_content",
"(",
"$",
"pageversion",
"->",
"contentformat",
",",
"$",
"pageversion",
"->",
"content",
",",
"$",
"options",
")",
";",
"$",
"content",
"=",
"$",
"OUTPUT",
"->",
"container",
"(",
"format_text",
"(",
"$",
"parseroutput",
"[",
"'parsed_text'",
"]",
",",
"FORMAT_HTML",
",",
"array",
"(",
"'overflowdiv'",
"=>",
"true",
")",
")",
",",
"false",
",",
"''",
",",
"''",
",",
"true",
")",
";",
"echo",
"$",
"OUTPUT",
"->",
"box",
"(",
"$",
"content",
",",
"'generalbox wiki_contentbox'",
")",
";",
"}",
"else",
"{",
"print_error",
"(",
"'versionerror'",
",",
"'wiki'",
")",
";",
"}",
"}"
] | Given an old page version, output the version content
@global object $CFG
@global object $OUTPUT
@global object $PAGE | [
"Given",
"an",
"old",
"page",
"version",
"output",
"the",
"version",
"content"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/pagelib.php#L2123-L2149 |
214,619 | moodle/moodle | mod/wiki/pagelib.php | page_wiki_admin.print_content | function print_content() {
//make sure anyone trying to access this page has managewiki capabilities
require_capability('mod/wiki:managewiki', $this->modcontext, NULL, true, 'noviewpagepermission', 'wiki');
//update wiki cache if timedout
$page = $this->page;
if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
$fresh = wiki_refresh_cachedcontent($page);
$page = $fresh['page'];
}
//dispaly admin menu
echo $this->wikioutput->menu_admin($this->page->id, $this->view);
//Display appropriate admin view
switch ($this->view) {
case 1: //delete page view
$this->print_delete_content($this->listorphan);
break;
case 2: //delete version view
$this->print_delete_version();
break;
default: //default is delete view
$this->print_delete_content($this->listorphan);
break;
}
} | php | function print_content() {
//make sure anyone trying to access this page has managewiki capabilities
require_capability('mod/wiki:managewiki', $this->modcontext, NULL, true, 'noviewpagepermission', 'wiki');
//update wiki cache if timedout
$page = $this->page;
if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
$fresh = wiki_refresh_cachedcontent($page);
$page = $fresh['page'];
}
//dispaly admin menu
echo $this->wikioutput->menu_admin($this->page->id, $this->view);
//Display appropriate admin view
switch ($this->view) {
case 1: //delete page view
$this->print_delete_content($this->listorphan);
break;
case 2: //delete version view
$this->print_delete_version();
break;
default: //default is delete view
$this->print_delete_content($this->listorphan);
break;
}
} | [
"function",
"print_content",
"(",
")",
"{",
"//make sure anyone trying to access this page has managewiki capabilities",
"require_capability",
"(",
"'mod/wiki:managewiki'",
",",
"$",
"this",
"->",
"modcontext",
",",
"NULL",
",",
"true",
",",
"'noviewpagepermission'",
",",
"'wiki'",
")",
";",
"//update wiki cache if timedout",
"$",
"page",
"=",
"$",
"this",
"->",
"page",
";",
"if",
"(",
"$",
"page",
"->",
"timerendered",
"+",
"WIKI_REFRESH_CACHE_TIME",
"<",
"time",
"(",
")",
")",
"{",
"$",
"fresh",
"=",
"wiki_refresh_cachedcontent",
"(",
"$",
"page",
")",
";",
"$",
"page",
"=",
"$",
"fresh",
"[",
"'page'",
"]",
";",
"}",
"//dispaly admin menu",
"echo",
"$",
"this",
"->",
"wikioutput",
"->",
"menu_admin",
"(",
"$",
"this",
"->",
"page",
"->",
"id",
",",
"$",
"this",
"->",
"view",
")",
";",
"//Display appropriate admin view",
"switch",
"(",
"$",
"this",
"->",
"view",
")",
"{",
"case",
"1",
":",
"//delete page view",
"$",
"this",
"->",
"print_delete_content",
"(",
"$",
"this",
"->",
"listorphan",
")",
";",
"break",
";",
"case",
"2",
":",
"//delete version view",
"$",
"this",
"->",
"print_delete_version",
"(",
")",
";",
"break",
";",
"default",
":",
"//default is delete view",
"$",
"this",
"->",
"print_delete_content",
"(",
"$",
"this",
"->",
"listorphan",
")",
";",
"break",
";",
"}",
"}"
] | This function will display administration view to users with managewiki capability | [
"This",
"function",
"will",
"display",
"administration",
"view",
"to",
"users",
"with",
"managewiki",
"capability"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/pagelib.php#L2438-L2464 |
214,620 | moodle/moodle | mod/wiki/pagelib.php | page_wiki_admin.set_view | public function set_view($view, $listorphan = true) {
$this->view = $view;
$this->listorphan = $listorphan;
} | php | public function set_view($view, $listorphan = true) {
$this->view = $view;
$this->listorphan = $listorphan;
} | [
"public",
"function",
"set_view",
"(",
"$",
"view",
",",
"$",
"listorphan",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"view",
"=",
"$",
"view",
";",
"$",
"this",
"->",
"listorphan",
"=",
"$",
"listorphan",
";",
"}"
] | Sets admin view option
@param int $view page view id
@param bool $listorphan is only valid for view 1. | [
"Sets",
"admin",
"view",
"option"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/pagelib.php#L2472-L2475 |
214,621 | moodle/moodle | mod/wiki/pagelib.php | page_wiki_admin.print_delete_content | protected function print_delete_content($showorphan = true) {
$contents = array();
$table = new html_table();
$table->head = array('', get_string('pagename','wiki'));
$table->attributes['class'] = 'table generaltable';
$swid = $this->subwiki->id;
if ($showorphan) {
if ($orphanedpages = wiki_get_orphaned_pages($swid)) {
$this->add_page_delete_options($orphanedpages, $swid, $table);
} else {
$table->data[] = array('', get_string('noorphanedpages', 'wiki'));
}
} else {
if ($pages = wiki_get_page_list($swid)) {
$this->add_page_delete_options($pages, $swid, $table);
} else {
$table->data[] = array('', get_string('nopages', 'wiki'));
}
}
///Print the form
echo html_writer::start_tag('form', array(
'action' => new moodle_url('/mod/wiki/admin.php'),
'method' => 'post'));
echo html_writer::tag('div', html_writer::empty_tag('input', array(
'type' => 'hidden',
'name' => 'pageid',
'value' => $this->page->id)));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'option', 'value' => $this->view));
echo html_writer::table($table);
echo html_writer::start_tag('div');
if (!$showorphan) {
echo html_writer::empty_tag('input', array(
'type' => 'submit',
'class' => 'wiki_form-button',
'value' => get_string('listorphan', 'wiki'),
'sesskey' => sesskey()));
} else {
echo html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'listall', 'value'=>'1'));
echo html_writer::empty_tag('input', array(
'type' => 'submit',
'class' => 'wiki_form-button btn btn-secondary',
'value' => get_string('listall', 'wiki'),
'sesskey' => sesskey()));
}
echo html_writer::end_tag('div');
echo html_writer::end_tag('form');
} | php | protected function print_delete_content($showorphan = true) {
$contents = array();
$table = new html_table();
$table->head = array('', get_string('pagename','wiki'));
$table->attributes['class'] = 'table generaltable';
$swid = $this->subwiki->id;
if ($showorphan) {
if ($orphanedpages = wiki_get_orphaned_pages($swid)) {
$this->add_page_delete_options($orphanedpages, $swid, $table);
} else {
$table->data[] = array('', get_string('noorphanedpages', 'wiki'));
}
} else {
if ($pages = wiki_get_page_list($swid)) {
$this->add_page_delete_options($pages, $swid, $table);
} else {
$table->data[] = array('', get_string('nopages', 'wiki'));
}
}
///Print the form
echo html_writer::start_tag('form', array(
'action' => new moodle_url('/mod/wiki/admin.php'),
'method' => 'post'));
echo html_writer::tag('div', html_writer::empty_tag('input', array(
'type' => 'hidden',
'name' => 'pageid',
'value' => $this->page->id)));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'option', 'value' => $this->view));
echo html_writer::table($table);
echo html_writer::start_tag('div');
if (!$showorphan) {
echo html_writer::empty_tag('input', array(
'type' => 'submit',
'class' => 'wiki_form-button',
'value' => get_string('listorphan', 'wiki'),
'sesskey' => sesskey()));
} else {
echo html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'listall', 'value'=>'1'));
echo html_writer::empty_tag('input', array(
'type' => 'submit',
'class' => 'wiki_form-button btn btn-secondary',
'value' => get_string('listall', 'wiki'),
'sesskey' => sesskey()));
}
echo html_writer::end_tag('div');
echo html_writer::end_tag('form');
} | [
"protected",
"function",
"print_delete_content",
"(",
"$",
"showorphan",
"=",
"true",
")",
"{",
"$",
"contents",
"=",
"array",
"(",
")",
";",
"$",
"table",
"=",
"new",
"html_table",
"(",
")",
";",
"$",
"table",
"->",
"head",
"=",
"array",
"(",
"''",
",",
"get_string",
"(",
"'pagename'",
",",
"'wiki'",
")",
")",
";",
"$",
"table",
"->",
"attributes",
"[",
"'class'",
"]",
"=",
"'table generaltable'",
";",
"$",
"swid",
"=",
"$",
"this",
"->",
"subwiki",
"->",
"id",
";",
"if",
"(",
"$",
"showorphan",
")",
"{",
"if",
"(",
"$",
"orphanedpages",
"=",
"wiki_get_orphaned_pages",
"(",
"$",
"swid",
")",
")",
"{",
"$",
"this",
"->",
"add_page_delete_options",
"(",
"$",
"orphanedpages",
",",
"$",
"swid",
",",
"$",
"table",
")",
";",
"}",
"else",
"{",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"array",
"(",
"''",
",",
"get_string",
"(",
"'noorphanedpages'",
",",
"'wiki'",
")",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"pages",
"=",
"wiki_get_page_list",
"(",
"$",
"swid",
")",
")",
"{",
"$",
"this",
"->",
"add_page_delete_options",
"(",
"$",
"pages",
",",
"$",
"swid",
",",
"$",
"table",
")",
";",
"}",
"else",
"{",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"array",
"(",
"''",
",",
"get_string",
"(",
"'nopages'",
",",
"'wiki'",
")",
")",
";",
"}",
"}",
"///Print the form",
"echo",
"html_writer",
"::",
"start_tag",
"(",
"'form'",
",",
"array",
"(",
"'action'",
"=>",
"new",
"moodle_url",
"(",
"'/mod/wiki/admin.php'",
")",
",",
"'method'",
"=>",
"'post'",
")",
")",
";",
"echo",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"html_writer",
"::",
"empty_tag",
"(",
"'input'",
",",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'name'",
"=>",
"'pageid'",
",",
"'value'",
"=>",
"$",
"this",
"->",
"page",
"->",
"id",
")",
")",
")",
";",
"echo",
"html_writer",
"::",
"empty_tag",
"(",
"'input'",
",",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'name'",
"=>",
"'option'",
",",
"'value'",
"=>",
"$",
"this",
"->",
"view",
")",
")",
";",
"echo",
"html_writer",
"::",
"table",
"(",
"$",
"table",
")",
";",
"echo",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
")",
";",
"if",
"(",
"!",
"$",
"showorphan",
")",
"{",
"echo",
"html_writer",
"::",
"empty_tag",
"(",
"'input'",
",",
"array",
"(",
"'type'",
"=>",
"'submit'",
",",
"'class'",
"=>",
"'wiki_form-button'",
",",
"'value'",
"=>",
"get_string",
"(",
"'listorphan'",
",",
"'wiki'",
")",
",",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"echo",
"html_writer",
"::",
"empty_tag",
"(",
"'input'",
",",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'name'",
"=>",
"'listall'",
",",
"'value'",
"=>",
"'1'",
")",
")",
";",
"echo",
"html_writer",
"::",
"empty_tag",
"(",
"'input'",
",",
"array",
"(",
"'type'",
"=>",
"'submit'",
",",
"'class'",
"=>",
"'wiki_form-button btn btn-secondary'",
",",
"'value'",
"=>",
"get_string",
"(",
"'listall'",
",",
"'wiki'",
")",
",",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
")",
")",
";",
"}",
"echo",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"echo",
"html_writer",
"::",
"end_tag",
"(",
"'form'",
")",
";",
"}"
] | Show wiki page delete options
@param bool $showorphan | [
"Show",
"wiki",
"page",
"delete",
"options"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/pagelib.php#L2505-L2553 |
214,622 | moodle/moodle | mod/wiki/pagelib.php | page_wiki_admin.add_page_delete_options | protected function add_page_delete_options($pages, $swid, &$table) {
global $OUTPUT;
foreach ($pages as $page) {
$link = wiki_parser_link($page->title, array('swid' => $swid));
$class = ($link['new']) ? 'class="wiki_newentry"' : '';
$pagelink = '<a href="' . $link['url'] . '"' . $class . '>' . format_string($link['content']) . '</a>';
$urledit = new moodle_url('/mod/wiki/edit.php', array('pageid' => $page->id, 'sesskey' => sesskey()));
$urldelete = new moodle_url('/mod/wiki/admin.php', array(
'pageid' => $this->page->id,
'delete' => $page->id,
'option' => $this->view,
'listall' => !$this->listorphan?'1': '',
'sesskey' => sesskey()));
$editlinks = $OUTPUT->action_icon($urledit, new pix_icon('t/edit', get_string('edit')));
$editlinks .= $OUTPUT->action_icon($urldelete, new pix_icon('t/delete', get_string('delete')));
$table->data[] = array($editlinks, $pagelink);
}
} | php | protected function add_page_delete_options($pages, $swid, &$table) {
global $OUTPUT;
foreach ($pages as $page) {
$link = wiki_parser_link($page->title, array('swid' => $swid));
$class = ($link['new']) ? 'class="wiki_newentry"' : '';
$pagelink = '<a href="' . $link['url'] . '"' . $class . '>' . format_string($link['content']) . '</a>';
$urledit = new moodle_url('/mod/wiki/edit.php', array('pageid' => $page->id, 'sesskey' => sesskey()));
$urldelete = new moodle_url('/mod/wiki/admin.php', array(
'pageid' => $this->page->id,
'delete' => $page->id,
'option' => $this->view,
'listall' => !$this->listorphan?'1': '',
'sesskey' => sesskey()));
$editlinks = $OUTPUT->action_icon($urledit, new pix_icon('t/edit', get_string('edit')));
$editlinks .= $OUTPUT->action_icon($urldelete, new pix_icon('t/delete', get_string('delete')));
$table->data[] = array($editlinks, $pagelink);
}
} | [
"protected",
"function",
"add_page_delete_options",
"(",
"$",
"pages",
",",
"$",
"swid",
",",
"&",
"$",
"table",
")",
"{",
"global",
"$",
"OUTPUT",
";",
"foreach",
"(",
"$",
"pages",
"as",
"$",
"page",
")",
"{",
"$",
"link",
"=",
"wiki_parser_link",
"(",
"$",
"page",
"->",
"title",
",",
"array",
"(",
"'swid'",
"=>",
"$",
"swid",
")",
")",
";",
"$",
"class",
"=",
"(",
"$",
"link",
"[",
"'new'",
"]",
")",
"?",
"'class=\"wiki_newentry\"'",
":",
"''",
";",
"$",
"pagelink",
"=",
"'<a href=\"'",
".",
"$",
"link",
"[",
"'url'",
"]",
".",
"'\"'",
".",
"$",
"class",
".",
"'>'",
".",
"format_string",
"(",
"$",
"link",
"[",
"'content'",
"]",
")",
".",
"'</a>'",
";",
"$",
"urledit",
"=",
"new",
"moodle_url",
"(",
"'/mod/wiki/edit.php'",
",",
"array",
"(",
"'pageid'",
"=>",
"$",
"page",
"->",
"id",
",",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
")",
")",
";",
"$",
"urldelete",
"=",
"new",
"moodle_url",
"(",
"'/mod/wiki/admin.php'",
",",
"array",
"(",
"'pageid'",
"=>",
"$",
"this",
"->",
"page",
"->",
"id",
",",
"'delete'",
"=>",
"$",
"page",
"->",
"id",
",",
"'option'",
"=>",
"$",
"this",
"->",
"view",
",",
"'listall'",
"=>",
"!",
"$",
"this",
"->",
"listorphan",
"?",
"'1'",
":",
"''",
",",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
")",
")",
";",
"$",
"editlinks",
"=",
"$",
"OUTPUT",
"->",
"action_icon",
"(",
"$",
"urledit",
",",
"new",
"pix_icon",
"(",
"'t/edit'",
",",
"get_string",
"(",
"'edit'",
")",
")",
")",
";",
"$",
"editlinks",
".=",
"$",
"OUTPUT",
"->",
"action_icon",
"(",
"$",
"urldelete",
",",
"new",
"pix_icon",
"(",
"'t/delete'",
",",
"get_string",
"(",
"'delete'",
")",
")",
")",
";",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"array",
"(",
"$",
"editlinks",
",",
"$",
"pagelink",
")",
";",
"}",
"}"
] | helper function for print_delete_content. This will add data to the table.
@global object $OUTPUT
@param array $pages objects of wiki pages in subwiki
@param int $swid id of subwiki
@param object $table reference to the table in which data needs to be added | [
"helper",
"function",
"for",
"print_delete_content",
".",
"This",
"will",
"add",
"data",
"to",
"the",
"table",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/wiki/pagelib.php#L2563-L2581 |
214,623 | moodle/moodle | completion/classes/external.php | core_completion_external.update_activity_completion_status_manually | public static function update_activity_completion_status_manually($cmid, $completed) {
// Validate and normalize parameters.
$params = self::validate_parameters(self::update_activity_completion_status_manually_parameters(),
array('cmid' => $cmid, 'completed' => $completed));
$cmid = $params['cmid'];
$completed = $params['completed'];
$warnings = array();
$context = context_module::instance($cmid);
self::validate_context($context);
require_capability('moodle/course:togglecompletion', $context);
list($course, $cm) = get_course_and_cm_from_cmid($cmid);
// Set up completion object and check it is enabled.
$completion = new completion_info($course);
if (!$completion->is_enabled()) {
throw new moodle_exception('completionnotenabled', 'completion');
}
// Check completion state is manual.
if ($cm->completion != COMPLETION_TRACKING_MANUAL) {
throw new moodle_exception('cannotmanualctrack', 'error');
}
$targetstate = ($completed) ? COMPLETION_COMPLETE : COMPLETION_INCOMPLETE;
$completion->update_state($cm, $targetstate);
$result = array();
$result['status'] = true;
$result['warnings'] = $warnings;
return $result;
} | php | public static function update_activity_completion_status_manually($cmid, $completed) {
// Validate and normalize parameters.
$params = self::validate_parameters(self::update_activity_completion_status_manually_parameters(),
array('cmid' => $cmid, 'completed' => $completed));
$cmid = $params['cmid'];
$completed = $params['completed'];
$warnings = array();
$context = context_module::instance($cmid);
self::validate_context($context);
require_capability('moodle/course:togglecompletion', $context);
list($course, $cm) = get_course_and_cm_from_cmid($cmid);
// Set up completion object and check it is enabled.
$completion = new completion_info($course);
if (!$completion->is_enabled()) {
throw new moodle_exception('completionnotenabled', 'completion');
}
// Check completion state is manual.
if ($cm->completion != COMPLETION_TRACKING_MANUAL) {
throw new moodle_exception('cannotmanualctrack', 'error');
}
$targetstate = ($completed) ? COMPLETION_COMPLETE : COMPLETION_INCOMPLETE;
$completion->update_state($cm, $targetstate);
$result = array();
$result['status'] = true;
$result['warnings'] = $warnings;
return $result;
} | [
"public",
"static",
"function",
"update_activity_completion_status_manually",
"(",
"$",
"cmid",
",",
"$",
"completed",
")",
"{",
"// Validate and normalize parameters.",
"$",
"params",
"=",
"self",
"::",
"validate_parameters",
"(",
"self",
"::",
"update_activity_completion_status_manually_parameters",
"(",
")",
",",
"array",
"(",
"'cmid'",
"=>",
"$",
"cmid",
",",
"'completed'",
"=>",
"$",
"completed",
")",
")",
";",
"$",
"cmid",
"=",
"$",
"params",
"[",
"'cmid'",
"]",
";",
"$",
"completed",
"=",
"$",
"params",
"[",
"'completed'",
"]",
";",
"$",
"warnings",
"=",
"array",
"(",
")",
";",
"$",
"context",
"=",
"context_module",
"::",
"instance",
"(",
"$",
"cmid",
")",
";",
"self",
"::",
"validate_context",
"(",
"$",
"context",
")",
";",
"require_capability",
"(",
"'moodle/course:togglecompletion'",
",",
"$",
"context",
")",
";",
"list",
"(",
"$",
"course",
",",
"$",
"cm",
")",
"=",
"get_course_and_cm_from_cmid",
"(",
"$",
"cmid",
")",
";",
"// Set up completion object and check it is enabled.",
"$",
"completion",
"=",
"new",
"completion_info",
"(",
"$",
"course",
")",
";",
"if",
"(",
"!",
"$",
"completion",
"->",
"is_enabled",
"(",
")",
")",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'completionnotenabled'",
",",
"'completion'",
")",
";",
"}",
"// Check completion state is manual.",
"if",
"(",
"$",
"cm",
"->",
"completion",
"!=",
"COMPLETION_TRACKING_MANUAL",
")",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'cannotmanualctrack'",
",",
"'error'",
")",
";",
"}",
"$",
"targetstate",
"=",
"(",
"$",
"completed",
")",
"?",
"COMPLETION_COMPLETE",
":",
"COMPLETION_INCOMPLETE",
";",
"$",
"completion",
"->",
"update_state",
"(",
"$",
"cm",
",",
"$",
"targetstate",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"result",
"[",
"'status'",
"]",
"=",
"true",
";",
"$",
"result",
"[",
"'warnings'",
"]",
"=",
"$",
"warnings",
";",
"return",
"$",
"result",
";",
"}"
] | Update completion status for the current user in an activity, only for activities with manual tracking.
@param int $cmid Course module id
@param bool $completed Activity completed or not
@return array Result and possible warnings
@since Moodle 2.9
@throws moodle_exception | [
"Update",
"completion",
"status",
"for",
"the",
"current",
"user",
"in",
"an",
"activity",
"only",
"for",
"activities",
"with",
"manual",
"tracking",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/completion/classes/external.php#L66-L100 |
214,624 | moodle/moodle | completion/classes/external.php | core_completion_external.override_activity_completion_status | public static function override_activity_completion_status($userid, $cmid, $newstate) {
// Validate and normalize parameters.
$params = self::validate_parameters(self::override_activity_completion_status_parameters(),
array('userid' => $userid, 'cmid' => $cmid, 'newstate' => $newstate));
$userid = $params['userid'];
$cmid = $params['cmid'];
$newstate = $params['newstate'];
$context = context_module::instance($cmid);
self::validate_context($context);
list($course, $cm) = get_course_and_cm_from_cmid($cmid);
// Set up completion object and check it is enabled.
$completion = new completion_info($course);
if (!$completion->is_enabled()) {
throw new moodle_exception('completionnotenabled', 'completion');
}
// Update completion state and get the new state back.
$completion->update_state($cm, $newstate, $userid, true);
$completiondata = $completion->get_data($cm, false, $userid);
// Return the current state of completion.
return [
'cmid' => $completiondata->coursemoduleid,
'userid' => $completiondata->userid,
'state' => $completiondata->completionstate,
'timecompleted' => $completiondata->timemodified,
'overrideby' => $completiondata->overrideby,
'tracking' => $completion->is_enabled($cm)
];
} | php | public static function override_activity_completion_status($userid, $cmid, $newstate) {
// Validate and normalize parameters.
$params = self::validate_parameters(self::override_activity_completion_status_parameters(),
array('userid' => $userid, 'cmid' => $cmid, 'newstate' => $newstate));
$userid = $params['userid'];
$cmid = $params['cmid'];
$newstate = $params['newstate'];
$context = context_module::instance($cmid);
self::validate_context($context);
list($course, $cm) = get_course_and_cm_from_cmid($cmid);
// Set up completion object and check it is enabled.
$completion = new completion_info($course);
if (!$completion->is_enabled()) {
throw new moodle_exception('completionnotenabled', 'completion');
}
// Update completion state and get the new state back.
$completion->update_state($cm, $newstate, $userid, true);
$completiondata = $completion->get_data($cm, false, $userid);
// Return the current state of completion.
return [
'cmid' => $completiondata->coursemoduleid,
'userid' => $completiondata->userid,
'state' => $completiondata->completionstate,
'timecompleted' => $completiondata->timemodified,
'overrideby' => $completiondata->overrideby,
'tracking' => $completion->is_enabled($cm)
];
} | [
"public",
"static",
"function",
"override_activity_completion_status",
"(",
"$",
"userid",
",",
"$",
"cmid",
",",
"$",
"newstate",
")",
"{",
"// Validate and normalize parameters.",
"$",
"params",
"=",
"self",
"::",
"validate_parameters",
"(",
"self",
"::",
"override_activity_completion_status_parameters",
"(",
")",
",",
"array",
"(",
"'userid'",
"=>",
"$",
"userid",
",",
"'cmid'",
"=>",
"$",
"cmid",
",",
"'newstate'",
"=>",
"$",
"newstate",
")",
")",
";",
"$",
"userid",
"=",
"$",
"params",
"[",
"'userid'",
"]",
";",
"$",
"cmid",
"=",
"$",
"params",
"[",
"'cmid'",
"]",
";",
"$",
"newstate",
"=",
"$",
"params",
"[",
"'newstate'",
"]",
";",
"$",
"context",
"=",
"context_module",
"::",
"instance",
"(",
"$",
"cmid",
")",
";",
"self",
"::",
"validate_context",
"(",
"$",
"context",
")",
";",
"list",
"(",
"$",
"course",
",",
"$",
"cm",
")",
"=",
"get_course_and_cm_from_cmid",
"(",
"$",
"cmid",
")",
";",
"// Set up completion object and check it is enabled.",
"$",
"completion",
"=",
"new",
"completion_info",
"(",
"$",
"course",
")",
";",
"if",
"(",
"!",
"$",
"completion",
"->",
"is_enabled",
"(",
")",
")",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'completionnotenabled'",
",",
"'completion'",
")",
";",
"}",
"// Update completion state and get the new state back.",
"$",
"completion",
"->",
"update_state",
"(",
"$",
"cm",
",",
"$",
"newstate",
",",
"$",
"userid",
",",
"true",
")",
";",
"$",
"completiondata",
"=",
"$",
"completion",
"->",
"get_data",
"(",
"$",
"cm",
",",
"false",
",",
"$",
"userid",
")",
";",
"// Return the current state of completion.",
"return",
"[",
"'cmid'",
"=>",
"$",
"completiondata",
"->",
"coursemoduleid",
",",
"'userid'",
"=>",
"$",
"completiondata",
"->",
"userid",
",",
"'state'",
"=>",
"$",
"completiondata",
"->",
"completionstate",
",",
"'timecompleted'",
"=>",
"$",
"completiondata",
"->",
"timemodified",
",",
"'overrideby'",
"=>",
"$",
"completiondata",
"->",
"overrideby",
",",
"'tracking'",
"=>",
"$",
"completion",
"->",
"is_enabled",
"(",
"$",
"cm",
")",
"]",
";",
"}"
] | Update completion status for a user in an activity.
@param int $userid User id
@param int $cmid Course module id
@param int $newstate Activity completion
@return array Array containing the current (updated) completion status.
@since Moodle 3.4
@throws moodle_exception | [
"Update",
"completion",
"status",
"for",
"a",
"user",
"in",
"an",
"activity",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/completion/classes/external.php#L143-L175 |
214,625 | moodle/moodle | completion/classes/external.php | core_completion_external.override_activity_completion_status_returns | public static function override_activity_completion_status_returns() {
return new external_single_structure(
array(
'cmid' => new external_value(PARAM_INT, 'The course module id'),
'userid' => new external_value(PARAM_INT, 'The user id to which the completion info belongs'),
'state' => new external_value(PARAM_INT, 'The current completion state.'),
'timecompleted' => new external_value(PARAM_INT, 'time of completion'),
'overrideby' => new external_value(PARAM_INT, 'The user id who has overriden the status, or null'),
'tracking' => new external_value(PARAM_INT, 'type of tracking:
0 means none, 1 manual, 2 automatic'),
)
);
} | php | public static function override_activity_completion_status_returns() {
return new external_single_structure(
array(
'cmid' => new external_value(PARAM_INT, 'The course module id'),
'userid' => new external_value(PARAM_INT, 'The user id to which the completion info belongs'),
'state' => new external_value(PARAM_INT, 'The current completion state.'),
'timecompleted' => new external_value(PARAM_INT, 'time of completion'),
'overrideby' => new external_value(PARAM_INT, 'The user id who has overriden the status, or null'),
'tracking' => new external_value(PARAM_INT, 'type of tracking:
0 means none, 1 manual, 2 automatic'),
)
);
} | [
"public",
"static",
"function",
"override_activity_completion_status_returns",
"(",
")",
"{",
"return",
"new",
"external_single_structure",
"(",
"array",
"(",
"'cmid'",
"=>",
"new",
"external_value",
"(",
"PARAM_INT",
",",
"'The course module id'",
")",
",",
"'userid'",
"=>",
"new",
"external_value",
"(",
"PARAM_INT",
",",
"'The user id to which the completion info belongs'",
")",
",",
"'state'",
"=>",
"new",
"external_value",
"(",
"PARAM_INT",
",",
"'The current completion state.'",
")",
",",
"'timecompleted'",
"=>",
"new",
"external_value",
"(",
"PARAM_INT",
",",
"'time of completion'",
")",
",",
"'overrideby'",
"=>",
"new",
"external_value",
"(",
"PARAM_INT",
",",
"'The user id who has overriden the status, or null'",
")",
",",
"'tracking'",
"=>",
"new",
"external_value",
"(",
"PARAM_INT",
",",
"'type of tracking:\n 0 means none, 1 manual, 2 automatic'",
")",
",",
")",
")",
";",
"}"
] | Describes the override_activity_completion_status return value.
@return external_single_structure
@since Moodle 3.4 | [
"Describes",
"the",
"override_activity_completion_status",
"return",
"value",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/completion/classes/external.php#L183-L196 |
214,626 | moodle/moodle | completion/classes/external.php | core_completion_external.get_activities_completion_status | public static function get_activities_completion_status($courseid, $userid) {
global $CFG, $USER;
require_once($CFG->libdir . '/grouplib.php');
$warnings = array();
$arrayparams = array(
'courseid' => $courseid,
'userid' => $userid,
);
$params = self::validate_parameters(self::get_activities_completion_status_parameters(), $arrayparams);
$course = get_course($params['courseid']);
$user = core_user::get_user($params['userid'], '*', MUST_EXIST);
core_user::require_active_user($user);
$context = context_course::instance($course->id);
self::validate_context($context);
// Check that current user have permissions to see this user's activities.
if ($user->id != $USER->id) {
require_capability('report/progress:view', $context);
if (!groups_user_groups_visible($course, $user->id)) {
// We are not in the same group!
throw new moodle_exception('accessdenied', 'admin');
}
}
$completion = new completion_info($course);
$activities = $completion->get_activities();
$results = array();
foreach ($activities as $activity) {
// Check if current user has visibility on this activity.
if (!$activity->uservisible) {
continue;
}
// Get progress information and state (we must use get_data because it works for all user roles in course).
$activitycompletiondata = $completion->get_data($activity, true, $user->id);
$results[] = array(
'cmid' => $activity->id,
'modname' => $activity->modname,
'instance' => $activity->instance,
'state' => $activitycompletiondata->completionstate,
'timecompleted' => $activitycompletiondata->timemodified,
'tracking' => $activity->completion,
'overrideby' => $activitycompletiondata->overrideby,
'valueused' => core_availability\info::completion_value_used($course, $activity->id)
);
}
$results = array(
'statuses' => $results,
'warnings' => $warnings
);
return $results;
} | php | public static function get_activities_completion_status($courseid, $userid) {
global $CFG, $USER;
require_once($CFG->libdir . '/grouplib.php');
$warnings = array();
$arrayparams = array(
'courseid' => $courseid,
'userid' => $userid,
);
$params = self::validate_parameters(self::get_activities_completion_status_parameters(), $arrayparams);
$course = get_course($params['courseid']);
$user = core_user::get_user($params['userid'], '*', MUST_EXIST);
core_user::require_active_user($user);
$context = context_course::instance($course->id);
self::validate_context($context);
// Check that current user have permissions to see this user's activities.
if ($user->id != $USER->id) {
require_capability('report/progress:view', $context);
if (!groups_user_groups_visible($course, $user->id)) {
// We are not in the same group!
throw new moodle_exception('accessdenied', 'admin');
}
}
$completion = new completion_info($course);
$activities = $completion->get_activities();
$results = array();
foreach ($activities as $activity) {
// Check if current user has visibility on this activity.
if (!$activity->uservisible) {
continue;
}
// Get progress information and state (we must use get_data because it works for all user roles in course).
$activitycompletiondata = $completion->get_data($activity, true, $user->id);
$results[] = array(
'cmid' => $activity->id,
'modname' => $activity->modname,
'instance' => $activity->instance,
'state' => $activitycompletiondata->completionstate,
'timecompleted' => $activitycompletiondata->timemodified,
'tracking' => $activity->completion,
'overrideby' => $activitycompletiondata->overrideby,
'valueused' => core_availability\info::completion_value_used($course, $activity->id)
);
}
$results = array(
'statuses' => $results,
'warnings' => $warnings
);
return $results;
} | [
"public",
"static",
"function",
"get_activities_completion_status",
"(",
"$",
"courseid",
",",
"$",
"userid",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"USER",
";",
"require_once",
"(",
"$",
"CFG",
"->",
"libdir",
".",
"'/grouplib.php'",
")",
";",
"$",
"warnings",
"=",
"array",
"(",
")",
";",
"$",
"arrayparams",
"=",
"array",
"(",
"'courseid'",
"=>",
"$",
"courseid",
",",
"'userid'",
"=>",
"$",
"userid",
",",
")",
";",
"$",
"params",
"=",
"self",
"::",
"validate_parameters",
"(",
"self",
"::",
"get_activities_completion_status_parameters",
"(",
")",
",",
"$",
"arrayparams",
")",
";",
"$",
"course",
"=",
"get_course",
"(",
"$",
"params",
"[",
"'courseid'",
"]",
")",
";",
"$",
"user",
"=",
"core_user",
"::",
"get_user",
"(",
"$",
"params",
"[",
"'userid'",
"]",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"core_user",
"::",
"require_active_user",
"(",
"$",
"user",
")",
";",
"$",
"context",
"=",
"context_course",
"::",
"instance",
"(",
"$",
"course",
"->",
"id",
")",
";",
"self",
"::",
"validate_context",
"(",
"$",
"context",
")",
";",
"// Check that current user have permissions to see this user's activities.",
"if",
"(",
"$",
"user",
"->",
"id",
"!=",
"$",
"USER",
"->",
"id",
")",
"{",
"require_capability",
"(",
"'report/progress:view'",
",",
"$",
"context",
")",
";",
"if",
"(",
"!",
"groups_user_groups_visible",
"(",
"$",
"course",
",",
"$",
"user",
"->",
"id",
")",
")",
"{",
"// We are not in the same group!",
"throw",
"new",
"moodle_exception",
"(",
"'accessdenied'",
",",
"'admin'",
")",
";",
"}",
"}",
"$",
"completion",
"=",
"new",
"completion_info",
"(",
"$",
"course",
")",
";",
"$",
"activities",
"=",
"$",
"completion",
"->",
"get_activities",
"(",
")",
";",
"$",
"results",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"activities",
"as",
"$",
"activity",
")",
"{",
"// Check if current user has visibility on this activity.",
"if",
"(",
"!",
"$",
"activity",
"->",
"uservisible",
")",
"{",
"continue",
";",
"}",
"// Get progress information and state (we must use get_data because it works for all user roles in course).",
"$",
"activitycompletiondata",
"=",
"$",
"completion",
"->",
"get_data",
"(",
"$",
"activity",
",",
"true",
",",
"$",
"user",
"->",
"id",
")",
";",
"$",
"results",
"[",
"]",
"=",
"array",
"(",
"'cmid'",
"=>",
"$",
"activity",
"->",
"id",
",",
"'modname'",
"=>",
"$",
"activity",
"->",
"modname",
",",
"'instance'",
"=>",
"$",
"activity",
"->",
"instance",
",",
"'state'",
"=>",
"$",
"activitycompletiondata",
"->",
"completionstate",
",",
"'timecompleted'",
"=>",
"$",
"activitycompletiondata",
"->",
"timemodified",
",",
"'tracking'",
"=>",
"$",
"activity",
"->",
"completion",
",",
"'overrideby'",
"=>",
"$",
"activitycompletiondata",
"->",
"overrideby",
",",
"'valueused'",
"=>",
"core_availability",
"\\",
"info",
"::",
"completion_value_used",
"(",
"$",
"course",
",",
"$",
"activity",
"->",
"id",
")",
")",
";",
"}",
"$",
"results",
"=",
"array",
"(",
"'statuses'",
"=>",
"$",
"results",
",",
"'warnings'",
"=>",
"$",
"warnings",
")",
";",
"return",
"$",
"results",
";",
"}"
] | Get Activities completion status
@param int $courseid ID of the Course
@param int $userid ID of the User
@return array of activities progress and warnings
@throws moodle_exception
@since Moodle 2.9
@throws moodle_exception | [
"Get",
"Activities",
"completion",
"status"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/completion/classes/external.php#L223-L282 |
214,627 | moodle/moodle | completion/classes/external.php | core_completion_external.get_course_completion_status | public static function get_course_completion_status($courseid, $userid) {
global $CFG, $USER;
require_once($CFG->libdir . '/grouplib.php');
$warnings = array();
$arrayparams = array(
'courseid' => $courseid,
'userid' => $userid,
);
$params = self::validate_parameters(self::get_course_completion_status_parameters(), $arrayparams);
$course = get_course($params['courseid']);
$user = core_user::get_user($params['userid'], '*', MUST_EXIST);
core_user::require_active_user($user);
$context = context_course::instance($course->id);
self::validate_context($context);
// Can current user see user's course completion status?
// This check verifies if completion is enabled because $course is mandatory.
if (!completion_can_view_data($user->id, $course)) {
throw new moodle_exception('cannotviewreport');
}
// The previous function doesn't check groups.
if ($user->id != $USER->id) {
if (!groups_user_groups_visible($course, $user->id)) {
// We are not in the same group!
throw new moodle_exception('accessdenied', 'admin');
}
}
$info = new completion_info($course);
// Check this user is enroled.
if (!$info->is_tracked_user($user->id)) {
if ($USER->id == $user->id) {
throw new moodle_exception('notenroled', 'completion');
} else {
throw new moodle_exception('usernotenroled', 'completion');
}
}
$completions = $info->get_completions($user->id);
if (empty($completions)) {
throw new moodle_exception('nocriteriaset', 'completion');
}
// Load course completion.
$completionparams = array(
'userid' => $user->id,
'course' => $course->id,
);
$ccompletion = new completion_completion($completionparams);
$completionrows = array();
// Loop through course criteria.
foreach ($completions as $completion) {
$criteria = $completion->get_criteria();
$completionrow = array();
$completionrow['type'] = $criteria->criteriatype;
$completionrow['title'] = $criteria->get_title();
$completionrow['status'] = $completion->get_status();
$completionrow['complete'] = $completion->is_complete();
$completionrow['timecompleted'] = $completion->timecompleted;
$completionrow['details'] = $criteria->get_details($completion);
$completionrows[] = $completionrow;
}
$result = array(
'completed' => $info->is_course_complete($user->id),
'aggregation' => $info->get_aggregation_method(),
'completions' => $completionrows
);
$results = array(
'completionstatus' => $result,
'warnings' => $warnings
);
return $results;
} | php | public static function get_course_completion_status($courseid, $userid) {
global $CFG, $USER;
require_once($CFG->libdir . '/grouplib.php');
$warnings = array();
$arrayparams = array(
'courseid' => $courseid,
'userid' => $userid,
);
$params = self::validate_parameters(self::get_course_completion_status_parameters(), $arrayparams);
$course = get_course($params['courseid']);
$user = core_user::get_user($params['userid'], '*', MUST_EXIST);
core_user::require_active_user($user);
$context = context_course::instance($course->id);
self::validate_context($context);
// Can current user see user's course completion status?
// This check verifies if completion is enabled because $course is mandatory.
if (!completion_can_view_data($user->id, $course)) {
throw new moodle_exception('cannotviewreport');
}
// The previous function doesn't check groups.
if ($user->id != $USER->id) {
if (!groups_user_groups_visible($course, $user->id)) {
// We are not in the same group!
throw new moodle_exception('accessdenied', 'admin');
}
}
$info = new completion_info($course);
// Check this user is enroled.
if (!$info->is_tracked_user($user->id)) {
if ($USER->id == $user->id) {
throw new moodle_exception('notenroled', 'completion');
} else {
throw new moodle_exception('usernotenroled', 'completion');
}
}
$completions = $info->get_completions($user->id);
if (empty($completions)) {
throw new moodle_exception('nocriteriaset', 'completion');
}
// Load course completion.
$completionparams = array(
'userid' => $user->id,
'course' => $course->id,
);
$ccompletion = new completion_completion($completionparams);
$completionrows = array();
// Loop through course criteria.
foreach ($completions as $completion) {
$criteria = $completion->get_criteria();
$completionrow = array();
$completionrow['type'] = $criteria->criteriatype;
$completionrow['title'] = $criteria->get_title();
$completionrow['status'] = $completion->get_status();
$completionrow['complete'] = $completion->is_complete();
$completionrow['timecompleted'] = $completion->timecompleted;
$completionrow['details'] = $criteria->get_details($completion);
$completionrows[] = $completionrow;
}
$result = array(
'completed' => $info->is_course_complete($user->id),
'aggregation' => $info->get_aggregation_method(),
'completions' => $completionrows
);
$results = array(
'completionstatus' => $result,
'warnings' => $warnings
);
return $results;
} | [
"public",
"static",
"function",
"get_course_completion_status",
"(",
"$",
"courseid",
",",
"$",
"userid",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"USER",
";",
"require_once",
"(",
"$",
"CFG",
"->",
"libdir",
".",
"'/grouplib.php'",
")",
";",
"$",
"warnings",
"=",
"array",
"(",
")",
";",
"$",
"arrayparams",
"=",
"array",
"(",
"'courseid'",
"=>",
"$",
"courseid",
",",
"'userid'",
"=>",
"$",
"userid",
",",
")",
";",
"$",
"params",
"=",
"self",
"::",
"validate_parameters",
"(",
"self",
"::",
"get_course_completion_status_parameters",
"(",
")",
",",
"$",
"arrayparams",
")",
";",
"$",
"course",
"=",
"get_course",
"(",
"$",
"params",
"[",
"'courseid'",
"]",
")",
";",
"$",
"user",
"=",
"core_user",
"::",
"get_user",
"(",
"$",
"params",
"[",
"'userid'",
"]",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"core_user",
"::",
"require_active_user",
"(",
"$",
"user",
")",
";",
"$",
"context",
"=",
"context_course",
"::",
"instance",
"(",
"$",
"course",
"->",
"id",
")",
";",
"self",
"::",
"validate_context",
"(",
"$",
"context",
")",
";",
"// Can current user see user's course completion status?",
"// This check verifies if completion is enabled because $course is mandatory.",
"if",
"(",
"!",
"completion_can_view_data",
"(",
"$",
"user",
"->",
"id",
",",
"$",
"course",
")",
")",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'cannotviewreport'",
")",
";",
"}",
"// The previous function doesn't check groups.",
"if",
"(",
"$",
"user",
"->",
"id",
"!=",
"$",
"USER",
"->",
"id",
")",
"{",
"if",
"(",
"!",
"groups_user_groups_visible",
"(",
"$",
"course",
",",
"$",
"user",
"->",
"id",
")",
")",
"{",
"// We are not in the same group!",
"throw",
"new",
"moodle_exception",
"(",
"'accessdenied'",
",",
"'admin'",
")",
";",
"}",
"}",
"$",
"info",
"=",
"new",
"completion_info",
"(",
"$",
"course",
")",
";",
"// Check this user is enroled.",
"if",
"(",
"!",
"$",
"info",
"->",
"is_tracked_user",
"(",
"$",
"user",
"->",
"id",
")",
")",
"{",
"if",
"(",
"$",
"USER",
"->",
"id",
"==",
"$",
"user",
"->",
"id",
")",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'notenroled'",
",",
"'completion'",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'usernotenroled'",
",",
"'completion'",
")",
";",
"}",
"}",
"$",
"completions",
"=",
"$",
"info",
"->",
"get_completions",
"(",
"$",
"user",
"->",
"id",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"completions",
")",
")",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'nocriteriaset'",
",",
"'completion'",
")",
";",
"}",
"// Load course completion.",
"$",
"completionparams",
"=",
"array",
"(",
"'userid'",
"=>",
"$",
"user",
"->",
"id",
",",
"'course'",
"=>",
"$",
"course",
"->",
"id",
",",
")",
";",
"$",
"ccompletion",
"=",
"new",
"completion_completion",
"(",
"$",
"completionparams",
")",
";",
"$",
"completionrows",
"=",
"array",
"(",
")",
";",
"// Loop through course criteria.",
"foreach",
"(",
"$",
"completions",
"as",
"$",
"completion",
")",
"{",
"$",
"criteria",
"=",
"$",
"completion",
"->",
"get_criteria",
"(",
")",
";",
"$",
"completionrow",
"=",
"array",
"(",
")",
";",
"$",
"completionrow",
"[",
"'type'",
"]",
"=",
"$",
"criteria",
"->",
"criteriatype",
";",
"$",
"completionrow",
"[",
"'title'",
"]",
"=",
"$",
"criteria",
"->",
"get_title",
"(",
")",
";",
"$",
"completionrow",
"[",
"'status'",
"]",
"=",
"$",
"completion",
"->",
"get_status",
"(",
")",
";",
"$",
"completionrow",
"[",
"'complete'",
"]",
"=",
"$",
"completion",
"->",
"is_complete",
"(",
")",
";",
"$",
"completionrow",
"[",
"'timecompleted'",
"]",
"=",
"$",
"completion",
"->",
"timecompleted",
";",
"$",
"completionrow",
"[",
"'details'",
"]",
"=",
"$",
"criteria",
"->",
"get_details",
"(",
"$",
"completion",
")",
";",
"$",
"completionrows",
"[",
"]",
"=",
"$",
"completionrow",
";",
"}",
"$",
"result",
"=",
"array",
"(",
"'completed'",
"=>",
"$",
"info",
"->",
"is_course_complete",
"(",
"$",
"user",
"->",
"id",
")",
",",
"'aggregation'",
"=>",
"$",
"info",
"->",
"get_aggregation_method",
"(",
")",
",",
"'completions'",
"=>",
"$",
"completionrows",
")",
";",
"$",
"results",
"=",
"array",
"(",
"'completionstatus'",
"=>",
"$",
"result",
",",
"'warnings'",
"=>",
"$",
"warnings",
")",
";",
"return",
"$",
"results",
";",
"}"
] | Get Course completion status
@param int $courseid ID of the Course
@param int $userid ID of the User
@return array of course completion status and warnings
@since Moodle 2.9
@throws moodle_exception | [
"Get",
"Course",
"completion",
"status"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/completion/classes/external.php#L340-L422 |
214,628 | moodle/moodle | lib/classes/requirejs.php | core_requirejs.find_one_amd_module | public static function find_one_amd_module($component, $jsfilename, $debug = false) {
$jsfileroot = core_component::get_component_directory($component);
if (!$jsfileroot) {
return array();
}
$module = str_replace('.js', '', $jsfilename);
$srcdir = $jsfileroot . '/amd/build';
$minpart = '.min';
if ($debug) {
$srcdir = $jsfileroot . '/amd/src';
$minpart = '';
}
$filename = $srcdir . '/' . $module . $minpart . '.js';
if (!file_exists($filename)) {
return array();
}
$fullmodulename = $component . '/' . $module;
return array($fullmodulename => $filename);
} | php | public static function find_one_amd_module($component, $jsfilename, $debug = false) {
$jsfileroot = core_component::get_component_directory($component);
if (!$jsfileroot) {
return array();
}
$module = str_replace('.js', '', $jsfilename);
$srcdir = $jsfileroot . '/amd/build';
$minpart = '.min';
if ($debug) {
$srcdir = $jsfileroot . '/amd/src';
$minpart = '';
}
$filename = $srcdir . '/' . $module . $minpart . '.js';
if (!file_exists($filename)) {
return array();
}
$fullmodulename = $component . '/' . $module;
return array($fullmodulename => $filename);
} | [
"public",
"static",
"function",
"find_one_amd_module",
"(",
"$",
"component",
",",
"$",
"jsfilename",
",",
"$",
"debug",
"=",
"false",
")",
"{",
"$",
"jsfileroot",
"=",
"core_component",
"::",
"get_component_directory",
"(",
"$",
"component",
")",
";",
"if",
"(",
"!",
"$",
"jsfileroot",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"module",
"=",
"str_replace",
"(",
"'.js'",
",",
"''",
",",
"$",
"jsfilename",
")",
";",
"$",
"srcdir",
"=",
"$",
"jsfileroot",
".",
"'/amd/build'",
";",
"$",
"minpart",
"=",
"'.min'",
";",
"if",
"(",
"$",
"debug",
")",
"{",
"$",
"srcdir",
"=",
"$",
"jsfileroot",
".",
"'/amd/src'",
";",
"$",
"minpart",
"=",
"''",
";",
"}",
"$",
"filename",
"=",
"$",
"srcdir",
".",
"'/'",
".",
"$",
"module",
".",
"$",
"minpart",
".",
"'.js'",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"fullmodulename",
"=",
"$",
"component",
".",
"'/'",
".",
"$",
"module",
";",
"return",
"array",
"(",
"$",
"fullmodulename",
"=>",
"$",
"filename",
")",
";",
"}"
] | Check a single module exists and return the full path to it.
The expected location for amd modules is:
<componentdir>/amd/src/modulename.js
@param string $component The component determines the folder the js file should be in.
@param string $jsfilename The filename for the module (with the js extension).
@param boolean $debug If true, returns the paths to the original (unminified) source files.
@return array $files An array of mappings from module names to file paths.
Empty array if the file does not exist. | [
"Check",
"a",
"single",
"module",
"exists",
"and",
"return",
"the",
"full",
"path",
"to",
"it",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/requirejs.php#L47-L69 |
214,629 | moodle/moodle | lib/classes/requirejs.php | core_requirejs.find_all_amd_modules | public static function find_all_amd_modules($debug = false) {
global $CFG;
$jsdirs = array();
$jsfiles = array();
$dir = $CFG->libdir . '/amd';
if (!empty($dir) && is_dir($dir)) {
$jsdirs['core'] = $dir;
}
$subsystems = core_component::get_core_subsystems();
foreach ($subsystems as $subsystem => $dir) {
if (!empty($dir) && is_dir($dir . '/amd')) {
$jsdirs['core_' . $subsystem] = $dir . '/amd';
}
}
$plugintypes = core_component::get_plugin_types();
foreach ($plugintypes as $type => $dir) {
$plugins = core_component::get_plugin_list_with_file($type, 'amd', false);
foreach ($plugins as $plugin => $dir) {
if (!empty($dir) && is_dir($dir)) {
$jsdirs[$type . '_' . $plugin] = $dir;
}
}
}
foreach ($jsdirs as $component => $dir) {
$srcdir = $dir . '/build';
if ($debug) {
$srcdir = $dir . '/src';
}
if (!is_dir($srcdir) || !is_readable($srcdir)) {
// This is probably an empty amd directory without src or build.
// Skip it - RecursiveDirectoryIterator fatals if the directory is not readable as an iterator.
continue;
}
$items = new RecursiveDirectoryIterator($srcdir);
foreach ($items as $item) {
$extension = $item->getExtension();
if ($extension === 'js') {
$filename = str_replace('.min', '', $item->getBaseName('.js'));
// We skip lazy loaded modules.
if (strpos($filename, '-lazy') === false) {
$modulename = $component . '/' . $filename;
$jsfiles[$modulename] = $item->getRealPath();
}
}
unset($item);
}
unset($items);
}
return $jsfiles;
} | php | public static function find_all_amd_modules($debug = false) {
global $CFG;
$jsdirs = array();
$jsfiles = array();
$dir = $CFG->libdir . '/amd';
if (!empty($dir) && is_dir($dir)) {
$jsdirs['core'] = $dir;
}
$subsystems = core_component::get_core_subsystems();
foreach ($subsystems as $subsystem => $dir) {
if (!empty($dir) && is_dir($dir . '/amd')) {
$jsdirs['core_' . $subsystem] = $dir . '/amd';
}
}
$plugintypes = core_component::get_plugin_types();
foreach ($plugintypes as $type => $dir) {
$plugins = core_component::get_plugin_list_with_file($type, 'amd', false);
foreach ($plugins as $plugin => $dir) {
if (!empty($dir) && is_dir($dir)) {
$jsdirs[$type . '_' . $plugin] = $dir;
}
}
}
foreach ($jsdirs as $component => $dir) {
$srcdir = $dir . '/build';
if ($debug) {
$srcdir = $dir . '/src';
}
if (!is_dir($srcdir) || !is_readable($srcdir)) {
// This is probably an empty amd directory without src or build.
// Skip it - RecursiveDirectoryIterator fatals if the directory is not readable as an iterator.
continue;
}
$items = new RecursiveDirectoryIterator($srcdir);
foreach ($items as $item) {
$extension = $item->getExtension();
if ($extension === 'js') {
$filename = str_replace('.min', '', $item->getBaseName('.js'));
// We skip lazy loaded modules.
if (strpos($filename, '-lazy') === false) {
$modulename = $component . '/' . $filename;
$jsfiles[$modulename] = $item->getRealPath();
}
}
unset($item);
}
unset($items);
}
return $jsfiles;
} | [
"public",
"static",
"function",
"find_all_amd_modules",
"(",
"$",
"debug",
"=",
"false",
")",
"{",
"global",
"$",
"CFG",
";",
"$",
"jsdirs",
"=",
"array",
"(",
")",
";",
"$",
"jsfiles",
"=",
"array",
"(",
")",
";",
"$",
"dir",
"=",
"$",
"CFG",
"->",
"libdir",
".",
"'/amd'",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"dir",
")",
"&&",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"$",
"jsdirs",
"[",
"'core'",
"]",
"=",
"$",
"dir",
";",
"}",
"$",
"subsystems",
"=",
"core_component",
"::",
"get_core_subsystems",
"(",
")",
";",
"foreach",
"(",
"$",
"subsystems",
"as",
"$",
"subsystem",
"=>",
"$",
"dir",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"dir",
")",
"&&",
"is_dir",
"(",
"$",
"dir",
".",
"'/amd'",
")",
")",
"{",
"$",
"jsdirs",
"[",
"'core_'",
".",
"$",
"subsystem",
"]",
"=",
"$",
"dir",
".",
"'/amd'",
";",
"}",
"}",
"$",
"plugintypes",
"=",
"core_component",
"::",
"get_plugin_types",
"(",
")",
";",
"foreach",
"(",
"$",
"plugintypes",
"as",
"$",
"type",
"=>",
"$",
"dir",
")",
"{",
"$",
"plugins",
"=",
"core_component",
"::",
"get_plugin_list_with_file",
"(",
"$",
"type",
",",
"'amd'",
",",
"false",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"plugin",
"=>",
"$",
"dir",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"dir",
")",
"&&",
"is_dir",
"(",
"$",
"dir",
")",
")",
"{",
"$",
"jsdirs",
"[",
"$",
"type",
".",
"'_'",
".",
"$",
"plugin",
"]",
"=",
"$",
"dir",
";",
"}",
"}",
"}",
"foreach",
"(",
"$",
"jsdirs",
"as",
"$",
"component",
"=>",
"$",
"dir",
")",
"{",
"$",
"srcdir",
"=",
"$",
"dir",
".",
"'/build'",
";",
"if",
"(",
"$",
"debug",
")",
"{",
"$",
"srcdir",
"=",
"$",
"dir",
".",
"'/src'",
";",
"}",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"srcdir",
")",
"||",
"!",
"is_readable",
"(",
"$",
"srcdir",
")",
")",
"{",
"// This is probably an empty amd directory without src or build.",
"// Skip it - RecursiveDirectoryIterator fatals if the directory is not readable as an iterator.",
"continue",
";",
"}",
"$",
"items",
"=",
"new",
"RecursiveDirectoryIterator",
"(",
"$",
"srcdir",
")",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"extension",
"=",
"$",
"item",
"->",
"getExtension",
"(",
")",
";",
"if",
"(",
"$",
"extension",
"===",
"'js'",
")",
"{",
"$",
"filename",
"=",
"str_replace",
"(",
"'.min'",
",",
"''",
",",
"$",
"item",
"->",
"getBaseName",
"(",
"'.js'",
")",
")",
";",
"// We skip lazy loaded modules.",
"if",
"(",
"strpos",
"(",
"$",
"filename",
",",
"'-lazy'",
")",
"===",
"false",
")",
"{",
"$",
"modulename",
"=",
"$",
"component",
".",
"'/'",
".",
"$",
"filename",
";",
"$",
"jsfiles",
"[",
"$",
"modulename",
"]",
"=",
"$",
"item",
"->",
"getRealPath",
"(",
")",
";",
"}",
"}",
"unset",
"(",
"$",
"item",
")",
";",
"}",
"unset",
"(",
"$",
"items",
")",
";",
"}",
"return",
"$",
"jsfiles",
";",
"}"
] | Scan the source for AMD modules and return them all.
The expected location for amd modules is:
<componentdir>/amd/src/modulename.js
@param boolean $debug If true, returns the paths to the original (unminified) source files.
@return array $files An array of mappings from module names to file paths. | [
"Scan",
"the",
"source",
"for",
"AMD",
"modules",
"and",
"return",
"them",
"all",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/requirejs.php#L80-L133 |
214,630 | moodle/moodle | mod/workshop/classes/external.php | mod_workshop_external.get_workshops_by_courses | public static function get_workshops_by_courses($courseids = array()) {
global $PAGE;
$warnings = array();
$returnedworkshops = array();
$params = array(
'courseids' => $courseids,
);
$params = self::validate_parameters(self::get_workshops_by_courses_parameters(), $params);
$mycourses = array();
if (empty($params['courseids'])) {
$mycourses = enrol_get_my_courses();
$params['courseids'] = array_keys($mycourses);
}
// Ensure there are courseids to loop through.
if (!empty($params['courseids'])) {
list($courses, $warnings) = external_util::validate_courses($params['courseids'], $mycourses);
$output = $PAGE->get_renderer('core');
// Get the workshops in this course, this function checks users visibility permissions.
// We can avoid then additional validate_context calls.
$workshops = get_all_instances_in_courses("workshop", $courses);
foreach ($workshops as $workshop) {
$context = context_module::instance($workshop->coursemodule);
// Remove fields that are not from the workshop (added by get_all_instances_in_courses).
unset($workshop->coursemodule, $workshop->context, $workshop->visible, $workshop->section, $workshop->groupmode,
$workshop->groupingid);
$exporter = new workshop_summary_exporter($workshop, array('context' => $context));
$returnedworkshops[] = $exporter->export($output);
}
}
$result = array(
'workshops' => $returnedworkshops,
'warnings' => $warnings
);
return $result;
} | php | public static function get_workshops_by_courses($courseids = array()) {
global $PAGE;
$warnings = array();
$returnedworkshops = array();
$params = array(
'courseids' => $courseids,
);
$params = self::validate_parameters(self::get_workshops_by_courses_parameters(), $params);
$mycourses = array();
if (empty($params['courseids'])) {
$mycourses = enrol_get_my_courses();
$params['courseids'] = array_keys($mycourses);
}
// Ensure there are courseids to loop through.
if (!empty($params['courseids'])) {
list($courses, $warnings) = external_util::validate_courses($params['courseids'], $mycourses);
$output = $PAGE->get_renderer('core');
// Get the workshops in this course, this function checks users visibility permissions.
// We can avoid then additional validate_context calls.
$workshops = get_all_instances_in_courses("workshop", $courses);
foreach ($workshops as $workshop) {
$context = context_module::instance($workshop->coursemodule);
// Remove fields that are not from the workshop (added by get_all_instances_in_courses).
unset($workshop->coursemodule, $workshop->context, $workshop->visible, $workshop->section, $workshop->groupmode,
$workshop->groupingid);
$exporter = new workshop_summary_exporter($workshop, array('context' => $context));
$returnedworkshops[] = $exporter->export($output);
}
}
$result = array(
'workshops' => $returnedworkshops,
'warnings' => $warnings
);
return $result;
} | [
"public",
"static",
"function",
"get_workshops_by_courses",
"(",
"$",
"courseids",
"=",
"array",
"(",
")",
")",
"{",
"global",
"$",
"PAGE",
";",
"$",
"warnings",
"=",
"array",
"(",
")",
";",
"$",
"returnedworkshops",
"=",
"array",
"(",
")",
";",
"$",
"params",
"=",
"array",
"(",
"'courseids'",
"=>",
"$",
"courseids",
",",
")",
";",
"$",
"params",
"=",
"self",
"::",
"validate_parameters",
"(",
"self",
"::",
"get_workshops_by_courses_parameters",
"(",
")",
",",
"$",
"params",
")",
";",
"$",
"mycourses",
"=",
"array",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"params",
"[",
"'courseids'",
"]",
")",
")",
"{",
"$",
"mycourses",
"=",
"enrol_get_my_courses",
"(",
")",
";",
"$",
"params",
"[",
"'courseids'",
"]",
"=",
"array_keys",
"(",
"$",
"mycourses",
")",
";",
"}",
"// Ensure there are courseids to loop through.",
"if",
"(",
"!",
"empty",
"(",
"$",
"params",
"[",
"'courseids'",
"]",
")",
")",
"{",
"list",
"(",
"$",
"courses",
",",
"$",
"warnings",
")",
"=",
"external_util",
"::",
"validate_courses",
"(",
"$",
"params",
"[",
"'courseids'",
"]",
",",
"$",
"mycourses",
")",
";",
"$",
"output",
"=",
"$",
"PAGE",
"->",
"get_renderer",
"(",
"'core'",
")",
";",
"// Get the workshops in this course, this function checks users visibility permissions.",
"// We can avoid then additional validate_context calls.",
"$",
"workshops",
"=",
"get_all_instances_in_courses",
"(",
"\"workshop\"",
",",
"$",
"courses",
")",
";",
"foreach",
"(",
"$",
"workshops",
"as",
"$",
"workshop",
")",
"{",
"$",
"context",
"=",
"context_module",
"::",
"instance",
"(",
"$",
"workshop",
"->",
"coursemodule",
")",
";",
"// Remove fields that are not from the workshop (added by get_all_instances_in_courses).",
"unset",
"(",
"$",
"workshop",
"->",
"coursemodule",
",",
"$",
"workshop",
"->",
"context",
",",
"$",
"workshop",
"->",
"visible",
",",
"$",
"workshop",
"->",
"section",
",",
"$",
"workshop",
"->",
"groupmode",
",",
"$",
"workshop",
"->",
"groupingid",
")",
";",
"$",
"exporter",
"=",
"new",
"workshop_summary_exporter",
"(",
"$",
"workshop",
",",
"array",
"(",
"'context'",
"=>",
"$",
"context",
")",
")",
";",
"$",
"returnedworkshops",
"[",
"]",
"=",
"$",
"exporter",
"->",
"export",
"(",
"$",
"output",
")",
";",
"}",
"}",
"$",
"result",
"=",
"array",
"(",
"'workshops'",
"=>",
"$",
"returnedworkshops",
",",
"'warnings'",
"=>",
"$",
"warnings",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Returns a list of workshops in a provided list of courses.
If no list is provided all workshops that the user can view will be returned.
@param array $courseids course ids
@return array of warnings and workshops
@since Moodle 3.4 | [
"Returns",
"a",
"list",
"of",
"workshops",
"in",
"a",
"provided",
"list",
"of",
"courses",
".",
"If",
"no",
"list",
"is",
"provided",
"all",
"workshops",
"that",
"the",
"user",
"can",
"view",
"will",
"be",
"returned",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/classes/external.php#L71-L114 |
214,631 | moodle/moodle | mod/workshop/classes/external.php | mod_workshop_external.validate_workshop | protected static function validate_workshop($workshopid) {
global $DB, $USER;
// Request and permission validation.
$workshop = $DB->get_record('workshop', array('id' => $workshopid), '*', MUST_EXIST);
list($course, $cm) = get_course_and_cm_from_instance($workshop, 'workshop');
$context = context_module::instance($cm->id);
self::validate_context($context);
$workshop = new workshop($workshop, $cm, $course);
return array($workshop, $course, $cm, $context);
} | php | protected static function validate_workshop($workshopid) {
global $DB, $USER;
// Request and permission validation.
$workshop = $DB->get_record('workshop', array('id' => $workshopid), '*', MUST_EXIST);
list($course, $cm) = get_course_and_cm_from_instance($workshop, 'workshop');
$context = context_module::instance($cm->id);
self::validate_context($context);
$workshop = new workshop($workshop, $cm, $course);
return array($workshop, $course, $cm, $context);
} | [
"protected",
"static",
"function",
"validate_workshop",
"(",
"$",
"workshopid",
")",
"{",
"global",
"$",
"DB",
",",
"$",
"USER",
";",
"// Request and permission validation.",
"$",
"workshop",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'workshop'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"workshopid",
")",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"list",
"(",
"$",
"course",
",",
"$",
"cm",
")",
"=",
"get_course_and_cm_from_instance",
"(",
"$",
"workshop",
",",
"'workshop'",
")",
";",
"$",
"context",
"=",
"context_module",
"::",
"instance",
"(",
"$",
"cm",
"->",
"id",
")",
";",
"self",
"::",
"validate_context",
"(",
"$",
"context",
")",
";",
"$",
"workshop",
"=",
"new",
"workshop",
"(",
"$",
"workshop",
",",
"$",
"cm",
",",
"$",
"course",
")",
";",
"return",
"array",
"(",
"$",
"workshop",
",",
"$",
"course",
",",
"$",
"cm",
",",
"$",
"context",
")",
";",
"}"
] | Utility function for validating a workshop.
@param int $workshopid workshop instance id
@return array array containing the workshop object, course, context and course module objects
@since Moodle 3.4 | [
"Utility",
"function",
"for",
"validating",
"a",
"workshop",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/classes/external.php#L140-L153 |
214,632 | moodle/moodle | mod/workshop/classes/external.php | mod_workshop_external.get_workshop_access_information | public static function get_workshop_access_information($workshopid) {
global $USER;
$params = self::validate_parameters(self::get_workshop_access_information_parameters(), array('workshopid' => $workshopid));
list($workshop, $course, $cm, $context) = self::validate_workshop($params['workshopid']);
$result = array();
// Return all the available capabilities.
$capabilities = load_capability_def('mod_workshop');
foreach ($capabilities as $capname => $capdata) {
// Get fields like cansubmit so it is consistent with the access_information function implemented in other modules.
$field = 'can' . str_replace('mod/workshop:', '', $capname);
$result[$field] = has_capability($capname, $context);
}
// Now, specific features access information.
$result['creatingsubmissionallowed'] = $workshop->creating_submission_allowed($USER->id);
$result['modifyingsubmissionallowed'] = $workshop->modifying_submission_allowed($USER->id);
$result['assessingallowed'] = $workshop->assessing_allowed($USER->id);
$result['assessingexamplesallowed'] = $workshop->assessing_examples_allowed();
if (is_null($result['assessingexamplesallowed'])) {
$result['assessingexamplesallowed'] = false;
}
$result['examplesassessedbeforesubmission'] = $workshop->check_examples_assessed_before_submission($USER->id);
list($result['examplesassessedbeforeassessment'], $code) = $workshop->check_examples_assessed_before_assessment($USER->id);
$result['warnings'] = array();
return $result;
} | php | public static function get_workshop_access_information($workshopid) {
global $USER;
$params = self::validate_parameters(self::get_workshop_access_information_parameters(), array('workshopid' => $workshopid));
list($workshop, $course, $cm, $context) = self::validate_workshop($params['workshopid']);
$result = array();
// Return all the available capabilities.
$capabilities = load_capability_def('mod_workshop');
foreach ($capabilities as $capname => $capdata) {
// Get fields like cansubmit so it is consistent with the access_information function implemented in other modules.
$field = 'can' . str_replace('mod/workshop:', '', $capname);
$result[$field] = has_capability($capname, $context);
}
// Now, specific features access information.
$result['creatingsubmissionallowed'] = $workshop->creating_submission_allowed($USER->id);
$result['modifyingsubmissionallowed'] = $workshop->modifying_submission_allowed($USER->id);
$result['assessingallowed'] = $workshop->assessing_allowed($USER->id);
$result['assessingexamplesallowed'] = $workshop->assessing_examples_allowed();
if (is_null($result['assessingexamplesallowed'])) {
$result['assessingexamplesallowed'] = false;
}
$result['examplesassessedbeforesubmission'] = $workshop->check_examples_assessed_before_submission($USER->id);
list($result['examplesassessedbeforeassessment'], $code) = $workshop->check_examples_assessed_before_assessment($USER->id);
$result['warnings'] = array();
return $result;
} | [
"public",
"static",
"function",
"get_workshop_access_information",
"(",
"$",
"workshopid",
")",
"{",
"global",
"$",
"USER",
";",
"$",
"params",
"=",
"self",
"::",
"validate_parameters",
"(",
"self",
"::",
"get_workshop_access_information_parameters",
"(",
")",
",",
"array",
"(",
"'workshopid'",
"=>",
"$",
"workshopid",
")",
")",
";",
"list",
"(",
"$",
"workshop",
",",
"$",
"course",
",",
"$",
"cm",
",",
"$",
"context",
")",
"=",
"self",
"::",
"validate_workshop",
"(",
"$",
"params",
"[",
"'workshopid'",
"]",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"// Return all the available capabilities.",
"$",
"capabilities",
"=",
"load_capability_def",
"(",
"'mod_workshop'",
")",
";",
"foreach",
"(",
"$",
"capabilities",
"as",
"$",
"capname",
"=>",
"$",
"capdata",
")",
"{",
"// Get fields like cansubmit so it is consistent with the access_information function implemented in other modules.",
"$",
"field",
"=",
"'can'",
".",
"str_replace",
"(",
"'mod/workshop:'",
",",
"''",
",",
"$",
"capname",
")",
";",
"$",
"result",
"[",
"$",
"field",
"]",
"=",
"has_capability",
"(",
"$",
"capname",
",",
"$",
"context",
")",
";",
"}",
"// Now, specific features access information.",
"$",
"result",
"[",
"'creatingsubmissionallowed'",
"]",
"=",
"$",
"workshop",
"->",
"creating_submission_allowed",
"(",
"$",
"USER",
"->",
"id",
")",
";",
"$",
"result",
"[",
"'modifyingsubmissionallowed'",
"]",
"=",
"$",
"workshop",
"->",
"modifying_submission_allowed",
"(",
"$",
"USER",
"->",
"id",
")",
";",
"$",
"result",
"[",
"'assessingallowed'",
"]",
"=",
"$",
"workshop",
"->",
"assessing_allowed",
"(",
"$",
"USER",
"->",
"id",
")",
";",
"$",
"result",
"[",
"'assessingexamplesallowed'",
"]",
"=",
"$",
"workshop",
"->",
"assessing_examples_allowed",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"result",
"[",
"'assessingexamplesallowed'",
"]",
")",
")",
"{",
"$",
"result",
"[",
"'assessingexamplesallowed'",
"]",
"=",
"false",
";",
"}",
"$",
"result",
"[",
"'examplesassessedbeforesubmission'",
"]",
"=",
"$",
"workshop",
"->",
"check_examples_assessed_before_submission",
"(",
"$",
"USER",
"->",
"id",
")",
";",
"list",
"(",
"$",
"result",
"[",
"'examplesassessedbeforeassessment'",
"]",
",",
"$",
"code",
")",
"=",
"$",
"workshop",
"->",
"check_examples_assessed_before_assessment",
"(",
"$",
"USER",
"->",
"id",
")",
";",
"$",
"result",
"[",
"'warnings'",
"]",
"=",
"array",
"(",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Return access information for a given workshop.
@param int $workshopid workshop instance id
@return array of warnings and the access information
@since Moodle 3.4
@throws moodle_exception | [
"Return",
"access",
"information",
"for",
"a",
"given",
"workshop",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/classes/external.php#L178-L207 |
214,633 | moodle/moodle | mod/workshop/classes/external.php | mod_workshop_external.get_workshop_access_information_returns | public static function get_workshop_access_information_returns() {
$structure = array(
'creatingsubmissionallowed' => new external_value(PARAM_BOOL,
'Is the given user allowed to create their submission?'),
'modifyingsubmissionallowed' => new external_value(PARAM_BOOL,
'Is the user allowed to modify his existing submission?'),
'assessingallowed' => new external_value(PARAM_BOOL,
'Is the user allowed to create/edit his assessments?'),
'assessingexamplesallowed' => new external_value(PARAM_BOOL,
'Are reviewers allowed to create/edit their assessments of the example submissions?.'),
'examplesassessedbeforesubmission' => new external_value(PARAM_BOOL,
'Whether the given user has assessed all his required examples before submission
(always true if there are not examples to assess or not configured to check before submission).'),
'examplesassessedbeforeassessment' => new external_value(PARAM_BOOL,
'Whether the given user has assessed all his required examples before assessment
(always true if there are not examples to assessor not configured to check before assessment).'),
'warnings' => new external_warnings()
);
$capabilities = load_capability_def('mod_workshop');
foreach ($capabilities as $capname => $capdata) {
// Get fields like cansubmit so it is consistent with the access_information function implemented in other modules.
$field = 'can' . str_replace('mod/workshop:', '', $capname);
$structure[$field] = new external_value(PARAM_BOOL, 'Whether the user has the capability ' . $capname . ' allowed.');
}
return new external_single_structure($structure);
} | php | public static function get_workshop_access_information_returns() {
$structure = array(
'creatingsubmissionallowed' => new external_value(PARAM_BOOL,
'Is the given user allowed to create their submission?'),
'modifyingsubmissionallowed' => new external_value(PARAM_BOOL,
'Is the user allowed to modify his existing submission?'),
'assessingallowed' => new external_value(PARAM_BOOL,
'Is the user allowed to create/edit his assessments?'),
'assessingexamplesallowed' => new external_value(PARAM_BOOL,
'Are reviewers allowed to create/edit their assessments of the example submissions?.'),
'examplesassessedbeforesubmission' => new external_value(PARAM_BOOL,
'Whether the given user has assessed all his required examples before submission
(always true if there are not examples to assess or not configured to check before submission).'),
'examplesassessedbeforeassessment' => new external_value(PARAM_BOOL,
'Whether the given user has assessed all his required examples before assessment
(always true if there are not examples to assessor not configured to check before assessment).'),
'warnings' => new external_warnings()
);
$capabilities = load_capability_def('mod_workshop');
foreach ($capabilities as $capname => $capdata) {
// Get fields like cansubmit so it is consistent with the access_information function implemented in other modules.
$field = 'can' . str_replace('mod/workshop:', '', $capname);
$structure[$field] = new external_value(PARAM_BOOL, 'Whether the user has the capability ' . $capname . ' allowed.');
}
return new external_single_structure($structure);
} | [
"public",
"static",
"function",
"get_workshop_access_information_returns",
"(",
")",
"{",
"$",
"structure",
"=",
"array",
"(",
"'creatingsubmissionallowed'",
"=>",
"new",
"external_value",
"(",
"PARAM_BOOL",
",",
"'Is the given user allowed to create their submission?'",
")",
",",
"'modifyingsubmissionallowed'",
"=>",
"new",
"external_value",
"(",
"PARAM_BOOL",
",",
"'Is the user allowed to modify his existing submission?'",
")",
",",
"'assessingallowed'",
"=>",
"new",
"external_value",
"(",
"PARAM_BOOL",
",",
"'Is the user allowed to create/edit his assessments?'",
")",
",",
"'assessingexamplesallowed'",
"=>",
"new",
"external_value",
"(",
"PARAM_BOOL",
",",
"'Are reviewers allowed to create/edit their assessments of the example submissions?.'",
")",
",",
"'examplesassessedbeforesubmission'",
"=>",
"new",
"external_value",
"(",
"PARAM_BOOL",
",",
"'Whether the given user has assessed all his required examples before submission\n (always true if there are not examples to assess or not configured to check before submission).'",
")",
",",
"'examplesassessedbeforeassessment'",
"=>",
"new",
"external_value",
"(",
"PARAM_BOOL",
",",
"'Whether the given user has assessed all his required examples before assessment\n (always true if there are not examples to assessor not configured to check before assessment).'",
")",
",",
"'warnings'",
"=>",
"new",
"external_warnings",
"(",
")",
")",
";",
"$",
"capabilities",
"=",
"load_capability_def",
"(",
"'mod_workshop'",
")",
";",
"foreach",
"(",
"$",
"capabilities",
"as",
"$",
"capname",
"=>",
"$",
"capdata",
")",
"{",
"// Get fields like cansubmit so it is consistent with the access_information function implemented in other modules.",
"$",
"field",
"=",
"'can'",
".",
"str_replace",
"(",
"'mod/workshop:'",
",",
"''",
",",
"$",
"capname",
")",
";",
"$",
"structure",
"[",
"$",
"field",
"]",
"=",
"new",
"external_value",
"(",
"PARAM_BOOL",
",",
"'Whether the user has the capability '",
".",
"$",
"capname",
".",
"' allowed.'",
")",
";",
"}",
"return",
"new",
"external_single_structure",
"(",
"$",
"structure",
")",
";",
"}"
] | Describes the get_workshop_access_information return value.
@return external_single_structure
@since Moodle 3.4 | [
"Describes",
"the",
"get_workshop_access_information",
"return",
"value",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/classes/external.php#L215-L243 |
214,634 | moodle/moodle | mod/workshop/classes/external.php | mod_workshop_external.get_user_plan | public static function get_user_plan($workshopid, $userid = 0) {
global $USER;
$params = array(
'workshopid' => $workshopid,
'userid' => $userid,
);
$params = self::validate_parameters(self::get_user_plan_parameters(), $params);
list($workshop, $course, $cm, $context) = self::validate_workshop($params['workshopid']);
// Extra checks so only users with permissions can view other users plans.
if (empty($params['userid']) || $params['userid'] == $USER->id) {
$userid = $USER->id;
} else {
require_capability('moodle/course:manageactivities', $context);
$user = core_user::get_user($params['userid'], '*', MUST_EXIST);
core_user::require_active_user($user);
if (!$workshop->check_group_membership($user->id)) {
throw new moodle_exception('notingroup');
}
$userid = $user->id;
}
// Get the user plan information ready for external functions.
$userplan = new workshop_user_plan($workshop, $userid);
$userplan = array('phases' => $userplan->phases, 'examples' => $userplan->get_examples());
foreach ($userplan['phases'] as $phasecode => $phase) {
$phase->code = $phasecode;
$userplan['phases'][$phasecode] = (array) $phase;
foreach ($userplan['phases'][$phasecode]['tasks'] as $taskcode => $task) {
$task->code = $taskcode;
if ($task->link instanceof moodle_url) {
$task->link = $task->link->out(false);
}
$userplan['phases'][$phasecode]['tasks'][$taskcode] = (array) $task;
}
foreach ($userplan['phases'][$phasecode]['actions'] as $actioncode => $action) {
if ($action->url instanceof moodle_url) {
$action->url = $action->url->out(false);
}
$userplan['phases'][$phasecode]['actions'][$actioncode] = (array) $action;
}
}
$result['userplan'] = $userplan;
$result['warnings'] = array();
return $result;
} | php | public static function get_user_plan($workshopid, $userid = 0) {
global $USER;
$params = array(
'workshopid' => $workshopid,
'userid' => $userid,
);
$params = self::validate_parameters(self::get_user_plan_parameters(), $params);
list($workshop, $course, $cm, $context) = self::validate_workshop($params['workshopid']);
// Extra checks so only users with permissions can view other users plans.
if (empty($params['userid']) || $params['userid'] == $USER->id) {
$userid = $USER->id;
} else {
require_capability('moodle/course:manageactivities', $context);
$user = core_user::get_user($params['userid'], '*', MUST_EXIST);
core_user::require_active_user($user);
if (!$workshop->check_group_membership($user->id)) {
throw new moodle_exception('notingroup');
}
$userid = $user->id;
}
// Get the user plan information ready for external functions.
$userplan = new workshop_user_plan($workshop, $userid);
$userplan = array('phases' => $userplan->phases, 'examples' => $userplan->get_examples());
foreach ($userplan['phases'] as $phasecode => $phase) {
$phase->code = $phasecode;
$userplan['phases'][$phasecode] = (array) $phase;
foreach ($userplan['phases'][$phasecode]['tasks'] as $taskcode => $task) {
$task->code = $taskcode;
if ($task->link instanceof moodle_url) {
$task->link = $task->link->out(false);
}
$userplan['phases'][$phasecode]['tasks'][$taskcode] = (array) $task;
}
foreach ($userplan['phases'][$phasecode]['actions'] as $actioncode => $action) {
if ($action->url instanceof moodle_url) {
$action->url = $action->url->out(false);
}
$userplan['phases'][$phasecode]['actions'][$actioncode] = (array) $action;
}
}
$result['userplan'] = $userplan;
$result['warnings'] = array();
return $result;
} | [
"public",
"static",
"function",
"get_user_plan",
"(",
"$",
"workshopid",
",",
"$",
"userid",
"=",
"0",
")",
"{",
"global",
"$",
"USER",
";",
"$",
"params",
"=",
"array",
"(",
"'workshopid'",
"=>",
"$",
"workshopid",
",",
"'userid'",
"=>",
"$",
"userid",
",",
")",
";",
"$",
"params",
"=",
"self",
"::",
"validate_parameters",
"(",
"self",
"::",
"get_user_plan_parameters",
"(",
")",
",",
"$",
"params",
")",
";",
"list",
"(",
"$",
"workshop",
",",
"$",
"course",
",",
"$",
"cm",
",",
"$",
"context",
")",
"=",
"self",
"::",
"validate_workshop",
"(",
"$",
"params",
"[",
"'workshopid'",
"]",
")",
";",
"// Extra checks so only users with permissions can view other users plans.",
"if",
"(",
"empty",
"(",
"$",
"params",
"[",
"'userid'",
"]",
")",
"||",
"$",
"params",
"[",
"'userid'",
"]",
"==",
"$",
"USER",
"->",
"id",
")",
"{",
"$",
"userid",
"=",
"$",
"USER",
"->",
"id",
";",
"}",
"else",
"{",
"require_capability",
"(",
"'moodle/course:manageactivities'",
",",
"$",
"context",
")",
";",
"$",
"user",
"=",
"core_user",
"::",
"get_user",
"(",
"$",
"params",
"[",
"'userid'",
"]",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"core_user",
"::",
"require_active_user",
"(",
"$",
"user",
")",
";",
"if",
"(",
"!",
"$",
"workshop",
"->",
"check_group_membership",
"(",
"$",
"user",
"->",
"id",
")",
")",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'notingroup'",
")",
";",
"}",
"$",
"userid",
"=",
"$",
"user",
"->",
"id",
";",
"}",
"// Get the user plan information ready for external functions.",
"$",
"userplan",
"=",
"new",
"workshop_user_plan",
"(",
"$",
"workshop",
",",
"$",
"userid",
")",
";",
"$",
"userplan",
"=",
"array",
"(",
"'phases'",
"=>",
"$",
"userplan",
"->",
"phases",
",",
"'examples'",
"=>",
"$",
"userplan",
"->",
"get_examples",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"userplan",
"[",
"'phases'",
"]",
"as",
"$",
"phasecode",
"=>",
"$",
"phase",
")",
"{",
"$",
"phase",
"->",
"code",
"=",
"$",
"phasecode",
";",
"$",
"userplan",
"[",
"'phases'",
"]",
"[",
"$",
"phasecode",
"]",
"=",
"(",
"array",
")",
"$",
"phase",
";",
"foreach",
"(",
"$",
"userplan",
"[",
"'phases'",
"]",
"[",
"$",
"phasecode",
"]",
"[",
"'tasks'",
"]",
"as",
"$",
"taskcode",
"=>",
"$",
"task",
")",
"{",
"$",
"task",
"->",
"code",
"=",
"$",
"taskcode",
";",
"if",
"(",
"$",
"task",
"->",
"link",
"instanceof",
"moodle_url",
")",
"{",
"$",
"task",
"->",
"link",
"=",
"$",
"task",
"->",
"link",
"->",
"out",
"(",
"false",
")",
";",
"}",
"$",
"userplan",
"[",
"'phases'",
"]",
"[",
"$",
"phasecode",
"]",
"[",
"'tasks'",
"]",
"[",
"$",
"taskcode",
"]",
"=",
"(",
"array",
")",
"$",
"task",
";",
"}",
"foreach",
"(",
"$",
"userplan",
"[",
"'phases'",
"]",
"[",
"$",
"phasecode",
"]",
"[",
"'actions'",
"]",
"as",
"$",
"actioncode",
"=>",
"$",
"action",
")",
"{",
"if",
"(",
"$",
"action",
"->",
"url",
"instanceof",
"moodle_url",
")",
"{",
"$",
"action",
"->",
"url",
"=",
"$",
"action",
"->",
"url",
"->",
"out",
"(",
"false",
")",
";",
"}",
"$",
"userplan",
"[",
"'phases'",
"]",
"[",
"$",
"phasecode",
"]",
"[",
"'actions'",
"]",
"[",
"$",
"actioncode",
"]",
"=",
"(",
"array",
")",
"$",
"action",
";",
"}",
"}",
"$",
"result",
"[",
"'userplan'",
"]",
"=",
"$",
"userplan",
";",
"$",
"result",
"[",
"'warnings'",
"]",
"=",
"array",
"(",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Return the planner information for the given user.
@param int $workshopid workshop instance id
@param int $userid user id
@return array of warnings and the user plan
@since Moodle 3.4
@throws moodle_exception | [
"Return",
"the",
"planner",
"information",
"for",
"the",
"given",
"user",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/classes/external.php#L269-L317 |
214,635 | moodle/moodle | mod/workshop/classes/external.php | mod_workshop_external.get_user_plan_returns | public static function get_user_plan_returns() {
return new external_single_structure(
array(
'userplan' => new external_single_structure(
array(
'phases' => new external_multiple_structure(
new external_single_structure(
array(
'code' => new external_value(PARAM_INT, 'Phase code.'),
'title' => new external_value(PARAM_NOTAGS, 'Phase title.'),
'active' => new external_value(PARAM_BOOL, 'Whether is the active task.'),
'tasks' => new external_multiple_structure(
new external_single_structure(
array(
'code' => new external_value(PARAM_ALPHA, 'Task code.'),
'title' => new external_value(PARAM_RAW, 'Task title.'),
'link' => new external_value(PARAM_URL, 'Link to task.'),
'details' => new external_value(PARAM_RAW, 'Task details.', VALUE_OPTIONAL),
'completed' => new external_value(PARAM_NOTAGS,
'Completion information (maybe empty, maybe a boolean or generic info.'),
)
)
),
'actions' => new external_multiple_structure(
new external_single_structure(
array(
'type' => new external_value(PARAM_ALPHA, 'Action type.', VALUE_OPTIONAL),
'label' => new external_value(PARAM_RAW, 'Action label.', VALUE_OPTIONAL),
'url' => new external_value(PARAM_URL, 'Link to action.'),
'method' => new external_value(PARAM_ALPHA, 'Get or post.', VALUE_OPTIONAL),
)
)
),
)
)
),
'examples' => new external_multiple_structure(
new external_single_structure(
array(
'id' => new external_value(PARAM_INT, 'Example submission id.'),
'title' => new external_value(PARAM_RAW, 'Example submission title.'),
'assessmentid' => new external_value(PARAM_INT, 'Example submission assessment id.'),
'grade' => new external_value(PARAM_FLOAT, 'The submission grade.'),
'gradinggrade' => new external_value(PARAM_FLOAT, 'The assessment grade.'),
)
)
),
)
),
'warnings' => new external_warnings(),
)
);
} | php | public static function get_user_plan_returns() {
return new external_single_structure(
array(
'userplan' => new external_single_structure(
array(
'phases' => new external_multiple_structure(
new external_single_structure(
array(
'code' => new external_value(PARAM_INT, 'Phase code.'),
'title' => new external_value(PARAM_NOTAGS, 'Phase title.'),
'active' => new external_value(PARAM_BOOL, 'Whether is the active task.'),
'tasks' => new external_multiple_structure(
new external_single_structure(
array(
'code' => new external_value(PARAM_ALPHA, 'Task code.'),
'title' => new external_value(PARAM_RAW, 'Task title.'),
'link' => new external_value(PARAM_URL, 'Link to task.'),
'details' => new external_value(PARAM_RAW, 'Task details.', VALUE_OPTIONAL),
'completed' => new external_value(PARAM_NOTAGS,
'Completion information (maybe empty, maybe a boolean or generic info.'),
)
)
),
'actions' => new external_multiple_structure(
new external_single_structure(
array(
'type' => new external_value(PARAM_ALPHA, 'Action type.', VALUE_OPTIONAL),
'label' => new external_value(PARAM_RAW, 'Action label.', VALUE_OPTIONAL),
'url' => new external_value(PARAM_URL, 'Link to action.'),
'method' => new external_value(PARAM_ALPHA, 'Get or post.', VALUE_OPTIONAL),
)
)
),
)
)
),
'examples' => new external_multiple_structure(
new external_single_structure(
array(
'id' => new external_value(PARAM_INT, 'Example submission id.'),
'title' => new external_value(PARAM_RAW, 'Example submission title.'),
'assessmentid' => new external_value(PARAM_INT, 'Example submission assessment id.'),
'grade' => new external_value(PARAM_FLOAT, 'The submission grade.'),
'gradinggrade' => new external_value(PARAM_FLOAT, 'The assessment grade.'),
)
)
),
)
),
'warnings' => new external_warnings(),
)
);
} | [
"public",
"static",
"function",
"get_user_plan_returns",
"(",
")",
"{",
"return",
"new",
"external_single_structure",
"(",
"array",
"(",
"'userplan'",
"=>",
"new",
"external_single_structure",
"(",
"array",
"(",
"'phases'",
"=>",
"new",
"external_multiple_structure",
"(",
"new",
"external_single_structure",
"(",
"array",
"(",
"'code'",
"=>",
"new",
"external_value",
"(",
"PARAM_INT",
",",
"'Phase code.'",
")",
",",
"'title'",
"=>",
"new",
"external_value",
"(",
"PARAM_NOTAGS",
",",
"'Phase title.'",
")",
",",
"'active'",
"=>",
"new",
"external_value",
"(",
"PARAM_BOOL",
",",
"'Whether is the active task.'",
")",
",",
"'tasks'",
"=>",
"new",
"external_multiple_structure",
"(",
"new",
"external_single_structure",
"(",
"array",
"(",
"'code'",
"=>",
"new",
"external_value",
"(",
"PARAM_ALPHA",
",",
"'Task code.'",
")",
",",
"'title'",
"=>",
"new",
"external_value",
"(",
"PARAM_RAW",
",",
"'Task title.'",
")",
",",
"'link'",
"=>",
"new",
"external_value",
"(",
"PARAM_URL",
",",
"'Link to task.'",
")",
",",
"'details'",
"=>",
"new",
"external_value",
"(",
"PARAM_RAW",
",",
"'Task details.'",
",",
"VALUE_OPTIONAL",
")",
",",
"'completed'",
"=>",
"new",
"external_value",
"(",
"PARAM_NOTAGS",
",",
"'Completion information (maybe empty, maybe a boolean or generic info.'",
")",
",",
")",
")",
")",
",",
"'actions'",
"=>",
"new",
"external_multiple_structure",
"(",
"new",
"external_single_structure",
"(",
"array",
"(",
"'type'",
"=>",
"new",
"external_value",
"(",
"PARAM_ALPHA",
",",
"'Action type.'",
",",
"VALUE_OPTIONAL",
")",
",",
"'label'",
"=>",
"new",
"external_value",
"(",
"PARAM_RAW",
",",
"'Action label.'",
",",
"VALUE_OPTIONAL",
")",
",",
"'url'",
"=>",
"new",
"external_value",
"(",
"PARAM_URL",
",",
"'Link to action.'",
")",
",",
"'method'",
"=>",
"new",
"external_value",
"(",
"PARAM_ALPHA",
",",
"'Get or post.'",
",",
"VALUE_OPTIONAL",
")",
",",
")",
")",
")",
",",
")",
")",
")",
",",
"'examples'",
"=>",
"new",
"external_multiple_structure",
"(",
"new",
"external_single_structure",
"(",
"array",
"(",
"'id'",
"=>",
"new",
"external_value",
"(",
"PARAM_INT",
",",
"'Example submission id.'",
")",
",",
"'title'",
"=>",
"new",
"external_value",
"(",
"PARAM_RAW",
",",
"'Example submission title.'",
")",
",",
"'assessmentid'",
"=>",
"new",
"external_value",
"(",
"PARAM_INT",
",",
"'Example submission assessment id.'",
")",
",",
"'grade'",
"=>",
"new",
"external_value",
"(",
"PARAM_FLOAT",
",",
"'The submission grade.'",
")",
",",
"'gradinggrade'",
"=>",
"new",
"external_value",
"(",
"PARAM_FLOAT",
",",
"'The assessment grade.'",
")",
",",
")",
")",
")",
",",
")",
")",
",",
"'warnings'",
"=>",
"new",
"external_warnings",
"(",
")",
",",
")",
")",
";",
"}"
] | Describes the get_user_plan return value.
@return external_single_structure
@since Moodle 3.4 | [
"Describes",
"the",
"get_user_plan",
"return",
"value",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/classes/external.php#L325-L377 |
214,636 | moodle/moodle | mod/workshop/classes/external.php | mod_workshop_external.add_submission | public static function add_submission($workshopid, $title, $content = '', $contentformat = FORMAT_MOODLE,
$inlineattachmentsid = 0, $attachmentsid = 0) {
global $USER;
$params = self::validate_parameters(self::add_submission_parameters(), array(
'workshopid' => $workshopid,
'title' => $title,
'content' => $content,
'contentformat' => $contentformat,
'inlineattachmentsid' => $inlineattachmentsid,
'attachmentsid' => $attachmentsid,
));
$warnings = array();
// Get and validate the workshop.
list($workshop, $course, $cm, $context) = self::validate_workshop($params['workshopid']);
require_capability('mod/workshop:submit', $context);
// Check if we can submit now.
$canaddsubmission = $workshop->creating_submission_allowed($USER->id);
$canaddsubmission = $canaddsubmission && $workshop->check_examples_assessed_before_submission($USER->id);
if (!$canaddsubmission) {
throw new moodle_exception('nopermissions', 'error', '', 'add submission');
}
// Prepare the submission object.
$submission = new stdClass;
$submission->id = null;
$submission->cmid = $cm->id;
$submission->example = 0;
$submission->title = trim($params['title']);
$submission->content_editor = array(
'text' => $params['content'],
'format' => $params['contentformat'],
'itemid' => $params['inlineattachmentsid'],
);
$submission->attachment_filemanager = $params['attachmentsid'];
if (empty($submission->title)) {
throw new moodle_exception('errorinvalidparam', 'webservice', '', 'title');
}
$errors = $workshop->validate_submission_data((array) $submission);
// We can get several errors, return them in warnings.
if (!empty($errors)) {
$submission->id = 0;
foreach ($errors as $itemname => $message) {
$warnings[] = array(
'item' => $itemname,
'itemid' => 0,
'warningcode' => 'fielderror',
'message' => s($message)
);
}
return array(
'status' => false,
'warnings' => $warnings
);
} else {
$submission->id = $workshop->edit_submission($submission);
return array(
'status' => true,
'submissionid' => $submission->id,
'warnings' => $warnings
);
}
} | php | public static function add_submission($workshopid, $title, $content = '', $contentformat = FORMAT_MOODLE,
$inlineattachmentsid = 0, $attachmentsid = 0) {
global $USER;
$params = self::validate_parameters(self::add_submission_parameters(), array(
'workshopid' => $workshopid,
'title' => $title,
'content' => $content,
'contentformat' => $contentformat,
'inlineattachmentsid' => $inlineattachmentsid,
'attachmentsid' => $attachmentsid,
));
$warnings = array();
// Get and validate the workshop.
list($workshop, $course, $cm, $context) = self::validate_workshop($params['workshopid']);
require_capability('mod/workshop:submit', $context);
// Check if we can submit now.
$canaddsubmission = $workshop->creating_submission_allowed($USER->id);
$canaddsubmission = $canaddsubmission && $workshop->check_examples_assessed_before_submission($USER->id);
if (!$canaddsubmission) {
throw new moodle_exception('nopermissions', 'error', '', 'add submission');
}
// Prepare the submission object.
$submission = new stdClass;
$submission->id = null;
$submission->cmid = $cm->id;
$submission->example = 0;
$submission->title = trim($params['title']);
$submission->content_editor = array(
'text' => $params['content'],
'format' => $params['contentformat'],
'itemid' => $params['inlineattachmentsid'],
);
$submission->attachment_filemanager = $params['attachmentsid'];
if (empty($submission->title)) {
throw new moodle_exception('errorinvalidparam', 'webservice', '', 'title');
}
$errors = $workshop->validate_submission_data((array) $submission);
// We can get several errors, return them in warnings.
if (!empty($errors)) {
$submission->id = 0;
foreach ($errors as $itemname => $message) {
$warnings[] = array(
'item' => $itemname,
'itemid' => 0,
'warningcode' => 'fielderror',
'message' => s($message)
);
}
return array(
'status' => false,
'warnings' => $warnings
);
} else {
$submission->id = $workshop->edit_submission($submission);
return array(
'status' => true,
'submissionid' => $submission->id,
'warnings' => $warnings
);
}
} | [
"public",
"static",
"function",
"add_submission",
"(",
"$",
"workshopid",
",",
"$",
"title",
",",
"$",
"content",
"=",
"''",
",",
"$",
"contentformat",
"=",
"FORMAT_MOODLE",
",",
"$",
"inlineattachmentsid",
"=",
"0",
",",
"$",
"attachmentsid",
"=",
"0",
")",
"{",
"global",
"$",
"USER",
";",
"$",
"params",
"=",
"self",
"::",
"validate_parameters",
"(",
"self",
"::",
"add_submission_parameters",
"(",
")",
",",
"array",
"(",
"'workshopid'",
"=>",
"$",
"workshopid",
",",
"'title'",
"=>",
"$",
"title",
",",
"'content'",
"=>",
"$",
"content",
",",
"'contentformat'",
"=>",
"$",
"contentformat",
",",
"'inlineattachmentsid'",
"=>",
"$",
"inlineattachmentsid",
",",
"'attachmentsid'",
"=>",
"$",
"attachmentsid",
",",
")",
")",
";",
"$",
"warnings",
"=",
"array",
"(",
")",
";",
"// Get and validate the workshop.",
"list",
"(",
"$",
"workshop",
",",
"$",
"course",
",",
"$",
"cm",
",",
"$",
"context",
")",
"=",
"self",
"::",
"validate_workshop",
"(",
"$",
"params",
"[",
"'workshopid'",
"]",
")",
";",
"require_capability",
"(",
"'mod/workshop:submit'",
",",
"$",
"context",
")",
";",
"// Check if we can submit now.",
"$",
"canaddsubmission",
"=",
"$",
"workshop",
"->",
"creating_submission_allowed",
"(",
"$",
"USER",
"->",
"id",
")",
";",
"$",
"canaddsubmission",
"=",
"$",
"canaddsubmission",
"&&",
"$",
"workshop",
"->",
"check_examples_assessed_before_submission",
"(",
"$",
"USER",
"->",
"id",
")",
";",
"if",
"(",
"!",
"$",
"canaddsubmission",
")",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'nopermissions'",
",",
"'error'",
",",
"''",
",",
"'add submission'",
")",
";",
"}",
"// Prepare the submission object.",
"$",
"submission",
"=",
"new",
"stdClass",
";",
"$",
"submission",
"->",
"id",
"=",
"null",
";",
"$",
"submission",
"->",
"cmid",
"=",
"$",
"cm",
"->",
"id",
";",
"$",
"submission",
"->",
"example",
"=",
"0",
";",
"$",
"submission",
"->",
"title",
"=",
"trim",
"(",
"$",
"params",
"[",
"'title'",
"]",
")",
";",
"$",
"submission",
"->",
"content_editor",
"=",
"array",
"(",
"'text'",
"=>",
"$",
"params",
"[",
"'content'",
"]",
",",
"'format'",
"=>",
"$",
"params",
"[",
"'contentformat'",
"]",
",",
"'itemid'",
"=>",
"$",
"params",
"[",
"'inlineattachmentsid'",
"]",
",",
")",
";",
"$",
"submission",
"->",
"attachment_filemanager",
"=",
"$",
"params",
"[",
"'attachmentsid'",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"submission",
"->",
"title",
")",
")",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'errorinvalidparam'",
",",
"'webservice'",
",",
"''",
",",
"'title'",
")",
";",
"}",
"$",
"errors",
"=",
"$",
"workshop",
"->",
"validate_submission_data",
"(",
"(",
"array",
")",
"$",
"submission",
")",
";",
"// We can get several errors, return them in warnings.",
"if",
"(",
"!",
"empty",
"(",
"$",
"errors",
")",
")",
"{",
"$",
"submission",
"->",
"id",
"=",
"0",
";",
"foreach",
"(",
"$",
"errors",
"as",
"$",
"itemname",
"=>",
"$",
"message",
")",
"{",
"$",
"warnings",
"[",
"]",
"=",
"array",
"(",
"'item'",
"=>",
"$",
"itemname",
",",
"'itemid'",
"=>",
"0",
",",
"'warningcode'",
"=>",
"'fielderror'",
",",
"'message'",
"=>",
"s",
"(",
"$",
"message",
")",
")",
";",
"}",
"return",
"array",
"(",
"'status'",
"=>",
"false",
",",
"'warnings'",
"=>",
"$",
"warnings",
")",
";",
"}",
"else",
"{",
"$",
"submission",
"->",
"id",
"=",
"$",
"workshop",
"->",
"edit_submission",
"(",
"$",
"submission",
")",
";",
"return",
"array",
"(",
"'status'",
"=>",
"true",
",",
"'submissionid'",
"=>",
"$",
"submission",
"->",
"id",
",",
"'warnings'",
"=>",
"$",
"warnings",
")",
";",
"}",
"}"
] | Add a new submission to a given workshop.
@param int $workshopid the workshop id
@param string $title the submission title
@param string $content the submission text content
@param int $contentformat the format used for the content
@param int $inlineattachmentsid the draft file area id for inline attachments in the content
@param int $attachmentsid the draft file area id for attachments
@return array Containing the new created submission id and warnings.
@since Moodle 3.4
@throws moodle_exception | [
"Add",
"a",
"new",
"submission",
"to",
"a",
"given",
"workshop",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/classes/external.php#L464-L530 |
214,637 | moodle/moodle | mod/workshop/classes/external.php | mod_workshop_external.update_submission | public static function update_submission($submissionid, $title, $content = '', $contentformat = FORMAT_MOODLE,
$inlineattachmentsid = 0, $attachmentsid = 0) {
global $USER, $DB;
$params = self::validate_parameters(self::update_submission_parameters(), array(
'submissionid' => $submissionid,
'title' => $title,
'content' => $content,
'contentformat' => $contentformat,
'inlineattachmentsid' => $inlineattachmentsid,
'attachmentsid' => $attachmentsid,
));
$warnings = array();
// Get and validate the submission and workshop.
$submission = $DB->get_record('workshop_submissions', array('id' => $params['submissionid']), '*', MUST_EXIST);
list($workshop, $course, $cm, $context) = self::validate_workshop($submission->workshopid);
require_capability('mod/workshop:submit', $context);
// Check if we can update the submission.
$canupdatesubmission = $submission->authorid == $USER->id;
$canupdatesubmission = $canupdatesubmission && $workshop->modifying_submission_allowed($USER->id);
$canupdatesubmission = $canupdatesubmission && $workshop->check_examples_assessed_before_submission($USER->id);
if (!$canupdatesubmission) {
throw new moodle_exception('nopermissions', 'error', '', 'update submission');
}
// Prepare the submission object.
$submission->title = trim($params['title']);
if (empty($submission->title)) {
throw new moodle_exception('errorinvalidparam', 'webservice', '', 'title');
}
$submission->content_editor = array(
'text' => $params['content'],
'format' => $params['contentformat'],
'itemid' => $params['inlineattachmentsid'],
);
$submission->attachment_filemanager = $params['attachmentsid'];
$errors = $workshop->validate_submission_data((array) $submission);
// We can get several errors, return them in warnings.
if (!empty($errors)) {
$status = false;
foreach ($errors as $itemname => $message) {
$warnings[] = array(
'item' => $itemname,
'itemid' => 0,
'warningcode' => 'fielderror',
'message' => s($message)
);
}
} else {
$status = true;
$submission->id = $workshop->edit_submission($submission);
}
return array(
'status' => $status,
'warnings' => $warnings
);
} | php | public static function update_submission($submissionid, $title, $content = '', $contentformat = FORMAT_MOODLE,
$inlineattachmentsid = 0, $attachmentsid = 0) {
global $USER, $DB;
$params = self::validate_parameters(self::update_submission_parameters(), array(
'submissionid' => $submissionid,
'title' => $title,
'content' => $content,
'contentformat' => $contentformat,
'inlineattachmentsid' => $inlineattachmentsid,
'attachmentsid' => $attachmentsid,
));
$warnings = array();
// Get and validate the submission and workshop.
$submission = $DB->get_record('workshop_submissions', array('id' => $params['submissionid']), '*', MUST_EXIST);
list($workshop, $course, $cm, $context) = self::validate_workshop($submission->workshopid);
require_capability('mod/workshop:submit', $context);
// Check if we can update the submission.
$canupdatesubmission = $submission->authorid == $USER->id;
$canupdatesubmission = $canupdatesubmission && $workshop->modifying_submission_allowed($USER->id);
$canupdatesubmission = $canupdatesubmission && $workshop->check_examples_assessed_before_submission($USER->id);
if (!$canupdatesubmission) {
throw new moodle_exception('nopermissions', 'error', '', 'update submission');
}
// Prepare the submission object.
$submission->title = trim($params['title']);
if (empty($submission->title)) {
throw new moodle_exception('errorinvalidparam', 'webservice', '', 'title');
}
$submission->content_editor = array(
'text' => $params['content'],
'format' => $params['contentformat'],
'itemid' => $params['inlineattachmentsid'],
);
$submission->attachment_filemanager = $params['attachmentsid'];
$errors = $workshop->validate_submission_data((array) $submission);
// We can get several errors, return them in warnings.
if (!empty($errors)) {
$status = false;
foreach ($errors as $itemname => $message) {
$warnings[] = array(
'item' => $itemname,
'itemid' => 0,
'warningcode' => 'fielderror',
'message' => s($message)
);
}
} else {
$status = true;
$submission->id = $workshop->edit_submission($submission);
}
return array(
'status' => $status,
'warnings' => $warnings
);
} | [
"public",
"static",
"function",
"update_submission",
"(",
"$",
"submissionid",
",",
"$",
"title",
",",
"$",
"content",
"=",
"''",
",",
"$",
"contentformat",
"=",
"FORMAT_MOODLE",
",",
"$",
"inlineattachmentsid",
"=",
"0",
",",
"$",
"attachmentsid",
"=",
"0",
")",
"{",
"global",
"$",
"USER",
",",
"$",
"DB",
";",
"$",
"params",
"=",
"self",
"::",
"validate_parameters",
"(",
"self",
"::",
"update_submission_parameters",
"(",
")",
",",
"array",
"(",
"'submissionid'",
"=>",
"$",
"submissionid",
",",
"'title'",
"=>",
"$",
"title",
",",
"'content'",
"=>",
"$",
"content",
",",
"'contentformat'",
"=>",
"$",
"contentformat",
",",
"'inlineattachmentsid'",
"=>",
"$",
"inlineattachmentsid",
",",
"'attachmentsid'",
"=>",
"$",
"attachmentsid",
",",
")",
")",
";",
"$",
"warnings",
"=",
"array",
"(",
")",
";",
"// Get and validate the submission and workshop.",
"$",
"submission",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'workshop_submissions'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"params",
"[",
"'submissionid'",
"]",
")",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"list",
"(",
"$",
"workshop",
",",
"$",
"course",
",",
"$",
"cm",
",",
"$",
"context",
")",
"=",
"self",
"::",
"validate_workshop",
"(",
"$",
"submission",
"->",
"workshopid",
")",
";",
"require_capability",
"(",
"'mod/workshop:submit'",
",",
"$",
"context",
")",
";",
"// Check if we can update the submission.",
"$",
"canupdatesubmission",
"=",
"$",
"submission",
"->",
"authorid",
"==",
"$",
"USER",
"->",
"id",
";",
"$",
"canupdatesubmission",
"=",
"$",
"canupdatesubmission",
"&&",
"$",
"workshop",
"->",
"modifying_submission_allowed",
"(",
"$",
"USER",
"->",
"id",
")",
";",
"$",
"canupdatesubmission",
"=",
"$",
"canupdatesubmission",
"&&",
"$",
"workshop",
"->",
"check_examples_assessed_before_submission",
"(",
"$",
"USER",
"->",
"id",
")",
";",
"if",
"(",
"!",
"$",
"canupdatesubmission",
")",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'nopermissions'",
",",
"'error'",
",",
"''",
",",
"'update submission'",
")",
";",
"}",
"// Prepare the submission object.",
"$",
"submission",
"->",
"title",
"=",
"trim",
"(",
"$",
"params",
"[",
"'title'",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"submission",
"->",
"title",
")",
")",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'errorinvalidparam'",
",",
"'webservice'",
",",
"''",
",",
"'title'",
")",
";",
"}",
"$",
"submission",
"->",
"content_editor",
"=",
"array",
"(",
"'text'",
"=>",
"$",
"params",
"[",
"'content'",
"]",
",",
"'format'",
"=>",
"$",
"params",
"[",
"'contentformat'",
"]",
",",
"'itemid'",
"=>",
"$",
"params",
"[",
"'inlineattachmentsid'",
"]",
",",
")",
";",
"$",
"submission",
"->",
"attachment_filemanager",
"=",
"$",
"params",
"[",
"'attachmentsid'",
"]",
";",
"$",
"errors",
"=",
"$",
"workshop",
"->",
"validate_submission_data",
"(",
"(",
"array",
")",
"$",
"submission",
")",
";",
"// We can get several errors, return them in warnings.",
"if",
"(",
"!",
"empty",
"(",
"$",
"errors",
")",
")",
"{",
"$",
"status",
"=",
"false",
";",
"foreach",
"(",
"$",
"errors",
"as",
"$",
"itemname",
"=>",
"$",
"message",
")",
"{",
"$",
"warnings",
"[",
"]",
"=",
"array",
"(",
"'item'",
"=>",
"$",
"itemname",
",",
"'itemid'",
"=>",
"0",
",",
"'warningcode'",
"=>",
"'fielderror'",
",",
"'message'",
"=>",
"s",
"(",
"$",
"message",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"status",
"=",
"true",
";",
"$",
"submission",
"->",
"id",
"=",
"$",
"workshop",
"->",
"edit_submission",
"(",
"$",
"submission",
")",
";",
"}",
"return",
"array",
"(",
"'status'",
"=>",
"$",
"status",
",",
"'warnings'",
"=>",
"$",
"warnings",
")",
";",
"}"
] | Updates the given submission.
@param int $submissionid the submission id
@param string $title the submission title
@param string $content the submission text content
@param int $contentformat the format used for the content
@param int $inlineattachmentsid the draft file area id for inline attachments in the content
@param int $attachmentsid the draft file area id for attachments
@return array whether the submission was updated and warnings.
@since Moodle 3.4
@throws moodle_exception | [
"Updates",
"the",
"given",
"submission",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/classes/external.php#L578-L638 |
214,638 | moodle/moodle | mod/workshop/classes/external.php | mod_workshop_external.delete_submission | public static function delete_submission($submissionid) {
global $USER, $DB;
$params = self::validate_parameters(self::delete_submission_parameters(), array('submissionid' => $submissionid));
$warnings = array();
// Get and validate the submission and workshop.
$submission = $DB->get_record('workshop_submissions', array('id' => $params['submissionid']), '*', MUST_EXIST);
list($workshop, $course, $cm, $context) = self::validate_workshop($submission->workshopid);
// Check if we can delete the submission.
if (!has_capability('mod/workshop:deletesubmissions', $context)) {
require_capability('mod/workshop:submit', $context);
// We can delete our own submission, on time and not yet assessed.
$candeletesubmission = $submission->authorid == $USER->id;
$candeletesubmission = $candeletesubmission && $workshop->modifying_submission_allowed($USER->id);
$candeletesubmission = $candeletesubmission && count($workshop->get_assessments_of_submission($submission->id)) == 0;
if (!$candeletesubmission) {
throw new moodle_exception('nopermissions', 'error', '', 'delete submission');
}
}
$workshop->delete_submission($submission);
return array(
'status' => true,
'warnings' => $warnings
);
} | php | public static function delete_submission($submissionid) {
global $USER, $DB;
$params = self::validate_parameters(self::delete_submission_parameters(), array('submissionid' => $submissionid));
$warnings = array();
// Get and validate the submission and workshop.
$submission = $DB->get_record('workshop_submissions', array('id' => $params['submissionid']), '*', MUST_EXIST);
list($workshop, $course, $cm, $context) = self::validate_workshop($submission->workshopid);
// Check if we can delete the submission.
if (!has_capability('mod/workshop:deletesubmissions', $context)) {
require_capability('mod/workshop:submit', $context);
// We can delete our own submission, on time and not yet assessed.
$candeletesubmission = $submission->authorid == $USER->id;
$candeletesubmission = $candeletesubmission && $workshop->modifying_submission_allowed($USER->id);
$candeletesubmission = $candeletesubmission && count($workshop->get_assessments_of_submission($submission->id)) == 0;
if (!$candeletesubmission) {
throw new moodle_exception('nopermissions', 'error', '', 'delete submission');
}
}
$workshop->delete_submission($submission);
return array(
'status' => true,
'warnings' => $warnings
);
} | [
"public",
"static",
"function",
"delete_submission",
"(",
"$",
"submissionid",
")",
"{",
"global",
"$",
"USER",
",",
"$",
"DB",
";",
"$",
"params",
"=",
"self",
"::",
"validate_parameters",
"(",
"self",
"::",
"delete_submission_parameters",
"(",
")",
",",
"array",
"(",
"'submissionid'",
"=>",
"$",
"submissionid",
")",
")",
";",
"$",
"warnings",
"=",
"array",
"(",
")",
";",
"// Get and validate the submission and workshop.",
"$",
"submission",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'workshop_submissions'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"params",
"[",
"'submissionid'",
"]",
")",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"list",
"(",
"$",
"workshop",
",",
"$",
"course",
",",
"$",
"cm",
",",
"$",
"context",
")",
"=",
"self",
"::",
"validate_workshop",
"(",
"$",
"submission",
"->",
"workshopid",
")",
";",
"// Check if we can delete the submission.",
"if",
"(",
"!",
"has_capability",
"(",
"'mod/workshop:deletesubmissions'",
",",
"$",
"context",
")",
")",
"{",
"require_capability",
"(",
"'mod/workshop:submit'",
",",
"$",
"context",
")",
";",
"// We can delete our own submission, on time and not yet assessed.",
"$",
"candeletesubmission",
"=",
"$",
"submission",
"->",
"authorid",
"==",
"$",
"USER",
"->",
"id",
";",
"$",
"candeletesubmission",
"=",
"$",
"candeletesubmission",
"&&",
"$",
"workshop",
"->",
"modifying_submission_allowed",
"(",
"$",
"USER",
"->",
"id",
")",
";",
"$",
"candeletesubmission",
"=",
"$",
"candeletesubmission",
"&&",
"count",
"(",
"$",
"workshop",
"->",
"get_assessments_of_submission",
"(",
"$",
"submission",
"->",
"id",
")",
")",
"==",
"0",
";",
"if",
"(",
"!",
"$",
"candeletesubmission",
")",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'nopermissions'",
",",
"'error'",
",",
"''",
",",
"'delete submission'",
")",
";",
"}",
"}",
"$",
"workshop",
"->",
"delete_submission",
"(",
"$",
"submission",
")",
";",
"return",
"array",
"(",
"'status'",
"=>",
"true",
",",
"'warnings'",
"=>",
"$",
"warnings",
")",
";",
"}"
] | Deletes the given submission.
@param int $submissionid the submission id.
@return array containing the result status and warnings.
@since Moodle 3.4
@throws moodle_exception | [
"Deletes",
"the",
"given",
"submission",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/classes/external.php#L676-L704 |
214,639 | moodle/moodle | mod/workshop/classes/external.php | mod_workshop_external.prepare_submission_for_external | protected static function prepare_submission_for_external($submission, workshop $workshop, $canviewauthorpublished = null,
$canviewauthornames = null, $canviewallsubmissions = null) {
global $USER;
if (is_null($canviewauthorpublished)) {
$canviewauthorpublished = has_capability('mod/workshop:viewauthorpublished', $workshop->context);
}
if (is_null($canviewauthornames)) {
$canviewauthornames = has_capability('mod/workshop:viewauthornames', $workshop->context);
}
if (is_null($canviewallsubmissions)) {
$canviewallsubmissions = has_capability('mod/workshop:viewallsubmissions', $workshop->context);
}
$ownsubmission = $submission->authorid == $USER->id;
if (!$canviewauthornames && !$ownsubmission) {
$submission->authorid = 0;
}
// Remove grade, gradeover, gradeoverby, feedbackauthor and timegraded for non-teachers or invalid phase.
// WS mod_workshop_external::get_grades should be used for retrieving grades by students.
if ($workshop->phase < workshop::PHASE_EVALUATION || !$canviewallsubmissions) {
$properties = submission_exporter::properties_definition();
foreach ($properties as $attribute => $settings) {
// Special case, the feedbackauthor (and who did it) should be returned if the workshop is closed and
// the user can view it.
if (($attribute == 'feedbackauthor' || $attribute == 'gradeoverby') &&
$workshop->phase == workshop::PHASE_CLOSED && $ownsubmission) {
continue;
}
if (!empty($settings['optional'])) {
unset($submission->{$attribute});
}
}
}
return $submission;
} | php | protected static function prepare_submission_for_external($submission, workshop $workshop, $canviewauthorpublished = null,
$canviewauthornames = null, $canviewallsubmissions = null) {
global $USER;
if (is_null($canviewauthorpublished)) {
$canviewauthorpublished = has_capability('mod/workshop:viewauthorpublished', $workshop->context);
}
if (is_null($canviewauthornames)) {
$canviewauthornames = has_capability('mod/workshop:viewauthornames', $workshop->context);
}
if (is_null($canviewallsubmissions)) {
$canviewallsubmissions = has_capability('mod/workshop:viewallsubmissions', $workshop->context);
}
$ownsubmission = $submission->authorid == $USER->id;
if (!$canviewauthornames && !$ownsubmission) {
$submission->authorid = 0;
}
// Remove grade, gradeover, gradeoverby, feedbackauthor and timegraded for non-teachers or invalid phase.
// WS mod_workshop_external::get_grades should be used for retrieving grades by students.
if ($workshop->phase < workshop::PHASE_EVALUATION || !$canviewallsubmissions) {
$properties = submission_exporter::properties_definition();
foreach ($properties as $attribute => $settings) {
// Special case, the feedbackauthor (and who did it) should be returned if the workshop is closed and
// the user can view it.
if (($attribute == 'feedbackauthor' || $attribute == 'gradeoverby') &&
$workshop->phase == workshop::PHASE_CLOSED && $ownsubmission) {
continue;
}
if (!empty($settings['optional'])) {
unset($submission->{$attribute});
}
}
}
return $submission;
} | [
"protected",
"static",
"function",
"prepare_submission_for_external",
"(",
"$",
"submission",
",",
"workshop",
"$",
"workshop",
",",
"$",
"canviewauthorpublished",
"=",
"null",
",",
"$",
"canviewauthornames",
"=",
"null",
",",
"$",
"canviewallsubmissions",
"=",
"null",
")",
"{",
"global",
"$",
"USER",
";",
"if",
"(",
"is_null",
"(",
"$",
"canviewauthorpublished",
")",
")",
"{",
"$",
"canviewauthorpublished",
"=",
"has_capability",
"(",
"'mod/workshop:viewauthorpublished'",
",",
"$",
"workshop",
"->",
"context",
")",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"canviewauthornames",
")",
")",
"{",
"$",
"canviewauthornames",
"=",
"has_capability",
"(",
"'mod/workshop:viewauthornames'",
",",
"$",
"workshop",
"->",
"context",
")",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"canviewallsubmissions",
")",
")",
"{",
"$",
"canviewallsubmissions",
"=",
"has_capability",
"(",
"'mod/workshop:viewallsubmissions'",
",",
"$",
"workshop",
"->",
"context",
")",
";",
"}",
"$",
"ownsubmission",
"=",
"$",
"submission",
"->",
"authorid",
"==",
"$",
"USER",
"->",
"id",
";",
"if",
"(",
"!",
"$",
"canviewauthornames",
"&&",
"!",
"$",
"ownsubmission",
")",
"{",
"$",
"submission",
"->",
"authorid",
"=",
"0",
";",
"}",
"// Remove grade, gradeover, gradeoverby, feedbackauthor and timegraded for non-teachers or invalid phase.",
"// WS mod_workshop_external::get_grades should be used for retrieving grades by students.",
"if",
"(",
"$",
"workshop",
"->",
"phase",
"<",
"workshop",
"::",
"PHASE_EVALUATION",
"||",
"!",
"$",
"canviewallsubmissions",
")",
"{",
"$",
"properties",
"=",
"submission_exporter",
"::",
"properties_definition",
"(",
")",
";",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"attribute",
"=>",
"$",
"settings",
")",
"{",
"// Special case, the feedbackauthor (and who did it) should be returned if the workshop is closed and",
"// the user can view it.",
"if",
"(",
"(",
"$",
"attribute",
"==",
"'feedbackauthor'",
"||",
"$",
"attribute",
"==",
"'gradeoverby'",
")",
"&&",
"$",
"workshop",
"->",
"phase",
"==",
"workshop",
"::",
"PHASE_CLOSED",
"&&",
"$",
"ownsubmission",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"settings",
"[",
"'optional'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"submission",
"->",
"{",
"$",
"attribute",
"}",
")",
";",
"}",
"}",
"}",
"return",
"$",
"submission",
";",
"}"
] | Helper method for returning the submission data according the current user capabilities and current phase.
@param stdClass $submission the submission data
@param workshop $workshop the workshop class
@param bool $canviewauthorpublished whether the user has the capability mod/workshop:viewauthorpublished on
@param bool $canviewauthornames whether the user has the capability mod/workshop:vviewauthornames on
@param bool $canviewallsubmissions whether the user has the capability mod/workshop:viewallsubmissions on
@return stdClass object with the submission data filtered
@since Moodle 3.4 | [
"Helper",
"method",
"for",
"returning",
"the",
"submission",
"data",
"according",
"the",
"current",
"user",
"capabilities",
"and",
"current",
"phase",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/classes/external.php#L730-L766 |
214,640 | moodle/moodle | mod/workshop/classes/external.php | mod_workshop_external.validate_submission | protected static function validate_submission($submission, workshop $workshop) {
global $USER;
$workshopclosed = $workshop->phase == workshop::PHASE_CLOSED;
$canviewpublished = has_capability('mod/workshop:viewpublishedsubmissions', $workshop->context);
$canview = $submission->authorid == $USER->id; // I did it.
$canview = $canview || !empty($workshop->get_assessment_of_submission_by_user($submission->id, $USER->id)); // I reviewed.
$canview = $canview || has_capability('mod/workshop:viewallsubmissions', $workshop->context); // I can view all.
$canview = $canview || ($submission->published && $workshopclosed && $canviewpublished); // It has been published.
if ($canview) {
// Here we should check if the user share group.
if ($submission->authorid != $USER->id &&
!groups_user_groups_visible($workshop->course, $submission->authorid, $workshop->cm)) {
throw new moodle_exception('notingroup');
}
} else {
throw new moodle_exception('nopermissions', 'error', '', 'view submission');
}
} | php | protected static function validate_submission($submission, workshop $workshop) {
global $USER;
$workshopclosed = $workshop->phase == workshop::PHASE_CLOSED;
$canviewpublished = has_capability('mod/workshop:viewpublishedsubmissions', $workshop->context);
$canview = $submission->authorid == $USER->id; // I did it.
$canview = $canview || !empty($workshop->get_assessment_of_submission_by_user($submission->id, $USER->id)); // I reviewed.
$canview = $canview || has_capability('mod/workshop:viewallsubmissions', $workshop->context); // I can view all.
$canview = $canview || ($submission->published && $workshopclosed && $canviewpublished); // It has been published.
if ($canview) {
// Here we should check if the user share group.
if ($submission->authorid != $USER->id &&
!groups_user_groups_visible($workshop->course, $submission->authorid, $workshop->cm)) {
throw new moodle_exception('notingroup');
}
} else {
throw new moodle_exception('nopermissions', 'error', '', 'view submission');
}
} | [
"protected",
"static",
"function",
"validate_submission",
"(",
"$",
"submission",
",",
"workshop",
"$",
"workshop",
")",
"{",
"global",
"$",
"USER",
";",
"$",
"workshopclosed",
"=",
"$",
"workshop",
"->",
"phase",
"==",
"workshop",
"::",
"PHASE_CLOSED",
";",
"$",
"canviewpublished",
"=",
"has_capability",
"(",
"'mod/workshop:viewpublishedsubmissions'",
",",
"$",
"workshop",
"->",
"context",
")",
";",
"$",
"canview",
"=",
"$",
"submission",
"->",
"authorid",
"==",
"$",
"USER",
"->",
"id",
";",
"// I did it.",
"$",
"canview",
"=",
"$",
"canview",
"||",
"!",
"empty",
"(",
"$",
"workshop",
"->",
"get_assessment_of_submission_by_user",
"(",
"$",
"submission",
"->",
"id",
",",
"$",
"USER",
"->",
"id",
")",
")",
";",
"// I reviewed.",
"$",
"canview",
"=",
"$",
"canview",
"||",
"has_capability",
"(",
"'mod/workshop:viewallsubmissions'",
",",
"$",
"workshop",
"->",
"context",
")",
";",
"// I can view all.",
"$",
"canview",
"=",
"$",
"canview",
"||",
"(",
"$",
"submission",
"->",
"published",
"&&",
"$",
"workshopclosed",
"&&",
"$",
"canviewpublished",
")",
";",
"// It has been published.",
"if",
"(",
"$",
"canview",
")",
"{",
"// Here we should check if the user share group.",
"if",
"(",
"$",
"submission",
"->",
"authorid",
"!=",
"$",
"USER",
"->",
"id",
"&&",
"!",
"groups_user_groups_visible",
"(",
"$",
"workshop",
"->",
"course",
",",
"$",
"submission",
"->",
"authorid",
",",
"$",
"workshop",
"->",
"cm",
")",
")",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'notingroup'",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'nopermissions'",
",",
"'error'",
",",
"''",
",",
"'view submission'",
")",
";",
"}",
"}"
] | Helper method for validating a submission.
@param stdClass $submission submission object
@param workshop $workshop workshop instance
@return void
@since Moodle 3.4 | [
"Helper",
"method",
"for",
"validating",
"a",
"submission",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/classes/external.php#L898-L918 |
214,641 | moodle/moodle | mod/workshop/classes/external.php | mod_workshop_external.get_submission | public static function get_submission($submissionid) {
global $USER, $DB, $PAGE;
$params = self::validate_parameters(self::get_submission_parameters(), array('submissionid' => $submissionid));
$warnings = array();
// Get and validate the submission and workshop.
$submission = $DB->get_record('workshop_submissions', array('id' => $params['submissionid']), '*', MUST_EXIST);
list($workshop, $course, $cm, $context) = self::validate_workshop($submission->workshopid);
self::validate_submission($submission, $workshop);
$submission = self::prepare_submission_for_external($submission, $workshop);
$related = array('context' => $context);
$exporter = new submission_exporter($submission, $related);
return array(
'submission' => $exporter->export($PAGE->get_renderer('core')),
'warnings' => $warnings
);
} | php | public static function get_submission($submissionid) {
global $USER, $DB, $PAGE;
$params = self::validate_parameters(self::get_submission_parameters(), array('submissionid' => $submissionid));
$warnings = array();
// Get and validate the submission and workshop.
$submission = $DB->get_record('workshop_submissions', array('id' => $params['submissionid']), '*', MUST_EXIST);
list($workshop, $course, $cm, $context) = self::validate_workshop($submission->workshopid);
self::validate_submission($submission, $workshop);
$submission = self::prepare_submission_for_external($submission, $workshop);
$related = array('context' => $context);
$exporter = new submission_exporter($submission, $related);
return array(
'submission' => $exporter->export($PAGE->get_renderer('core')),
'warnings' => $warnings
);
} | [
"public",
"static",
"function",
"get_submission",
"(",
"$",
"submissionid",
")",
"{",
"global",
"$",
"USER",
",",
"$",
"DB",
",",
"$",
"PAGE",
";",
"$",
"params",
"=",
"self",
"::",
"validate_parameters",
"(",
"self",
"::",
"get_submission_parameters",
"(",
")",
",",
"array",
"(",
"'submissionid'",
"=>",
"$",
"submissionid",
")",
")",
";",
"$",
"warnings",
"=",
"array",
"(",
")",
";",
"// Get and validate the submission and workshop.",
"$",
"submission",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'workshop_submissions'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"params",
"[",
"'submissionid'",
"]",
")",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"list",
"(",
"$",
"workshop",
",",
"$",
"course",
",",
"$",
"cm",
",",
"$",
"context",
")",
"=",
"self",
"::",
"validate_workshop",
"(",
"$",
"submission",
"->",
"workshopid",
")",
";",
"self",
"::",
"validate_submission",
"(",
"$",
"submission",
",",
"$",
"workshop",
")",
";",
"$",
"submission",
"=",
"self",
"::",
"prepare_submission_for_external",
"(",
"$",
"submission",
",",
"$",
"workshop",
")",
";",
"$",
"related",
"=",
"array",
"(",
"'context'",
"=>",
"$",
"context",
")",
";",
"$",
"exporter",
"=",
"new",
"submission_exporter",
"(",
"$",
"submission",
",",
"$",
"related",
")",
";",
"return",
"array",
"(",
"'submission'",
"=>",
"$",
"exporter",
"->",
"export",
"(",
"$",
"PAGE",
"->",
"get_renderer",
"(",
"'core'",
")",
")",
",",
"'warnings'",
"=>",
"$",
"warnings",
")",
";",
"}"
] | Retrieves the given submission.
@param int $submissionid the submission id
@return array containing the submission and warnings.
@since Moodle 3.4
@throws moodle_exception | [
"Retrieves",
"the",
"given",
"submission",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/classes/external.php#L943-L963 |
214,642 | moodle/moodle | mod/workshop/classes/external.php | mod_workshop_external.check_view_submission_assessments | protected static function check_view_submission_assessments($submission, workshop $workshop) {
global $USER;
$ownsubmission = $submission->authorid == $USER->id;
$canview = has_capability('mod/workshop:viewallassessments', $workshop->context) ||
($ownsubmission && $workshop->assessments_available());
if ($canview) {
// Here we should check if the user share group.
if ($submission->authorid != $USER->id &&
!groups_user_groups_visible($workshop->course, $submission->authorid, $workshop->cm)) {
throw new moodle_exception('notingroup');
}
} else {
throw new moodle_exception('nopermissions', 'error', '', 'view assessment');
}
} | php | protected static function check_view_submission_assessments($submission, workshop $workshop) {
global $USER;
$ownsubmission = $submission->authorid == $USER->id;
$canview = has_capability('mod/workshop:viewallassessments', $workshop->context) ||
($ownsubmission && $workshop->assessments_available());
if ($canview) {
// Here we should check if the user share group.
if ($submission->authorid != $USER->id &&
!groups_user_groups_visible($workshop->course, $submission->authorid, $workshop->cm)) {
throw new moodle_exception('notingroup');
}
} else {
throw new moodle_exception('nopermissions', 'error', '', 'view assessment');
}
} | [
"protected",
"static",
"function",
"check_view_submission_assessments",
"(",
"$",
"submission",
",",
"workshop",
"$",
"workshop",
")",
"{",
"global",
"$",
"USER",
";",
"$",
"ownsubmission",
"=",
"$",
"submission",
"->",
"authorid",
"==",
"$",
"USER",
"->",
"id",
";",
"$",
"canview",
"=",
"has_capability",
"(",
"'mod/workshop:viewallassessments'",
",",
"$",
"workshop",
"->",
"context",
")",
"||",
"(",
"$",
"ownsubmission",
"&&",
"$",
"workshop",
"->",
"assessments_available",
"(",
")",
")",
";",
"if",
"(",
"$",
"canview",
")",
"{",
"// Here we should check if the user share group.",
"if",
"(",
"$",
"submission",
"->",
"authorid",
"!=",
"$",
"USER",
"->",
"id",
"&&",
"!",
"groups_user_groups_visible",
"(",
"$",
"workshop",
"->",
"course",
",",
"$",
"submission",
"->",
"authorid",
",",
"$",
"workshop",
"->",
"cm",
")",
")",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'notingroup'",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'nopermissions'",
",",
"'error'",
",",
"''",
",",
"'view assessment'",
")",
";",
"}",
"}"
] | Helper method for validating if the current user can view the submission assessments.
@param stdClass $submission submission object
@param workshop $workshop workshop instance
@return void
@since Moodle 3.4 | [
"Helper",
"method",
"for",
"validating",
"if",
"the",
"current",
"user",
"can",
"view",
"the",
"submission",
"assessments",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/classes/external.php#L988-L1004 |
214,643 | moodle/moodle | mod/workshop/classes/external.php | mod_workshop_external.prepare_assessment_for_external | protected static function prepare_assessment_for_external($assessment, workshop $workshop) {
global $USER;
static $canviewallassessments = null;
static $canviewreviewers = null;
static $canoverridegrades = null;
// Remove all the properties that does not belong to the assessment table.
$properties = assessment_exporter::properties_definition();
foreach ($assessment as $key => $value) {
if (!isset($properties[$key])) {
unset($assessment->{$key});
}
}
if (is_null($canviewallassessments)) {
$canviewallassessments = has_capability('mod/workshop:viewallassessments', $workshop->context);
}
if (is_null($canviewreviewers)) {
$canviewreviewers = has_capability('mod/workshop:viewreviewernames', $workshop->context);
}
if (is_null($canoverridegrades)) {
$canoverridegrades = has_capability('mod/workshop:overridegrades', $workshop->context);
}
$isreviewer = $assessment->reviewerid == $USER->id;
if (!$isreviewer && is_null($assessment->grade) && !$canviewallassessments) {
// Students do not see peer-assessment that are not graded yet.
return null;
}
// Remove the feedback for the reviewer if:
// I can't see it in the evaluation phase because I'm not a teacher or the reviewer AND
// I can't see it in the assessment phase because I'm not a teacher.
if (($workshop->phase < workshop::PHASE_EVALUATION || !($isreviewer || $canviewallassessments)) &&
($workshop->phase < workshop::PHASE_ASSESSMENT || !$canviewallassessments) ) {
// Remove all the feedback information (all the optional fields).
foreach ($properties as $attribute => $settings) {
if (!empty($settings['optional'])) {
unset($assessment->{$attribute});
}
}
}
if (!$isreviewer && !$canviewreviewers) {
$assessment->reviewerid = 0;
}
return $assessment;
} | php | protected static function prepare_assessment_for_external($assessment, workshop $workshop) {
global $USER;
static $canviewallassessments = null;
static $canviewreviewers = null;
static $canoverridegrades = null;
// Remove all the properties that does not belong to the assessment table.
$properties = assessment_exporter::properties_definition();
foreach ($assessment as $key => $value) {
if (!isset($properties[$key])) {
unset($assessment->{$key});
}
}
if (is_null($canviewallassessments)) {
$canviewallassessments = has_capability('mod/workshop:viewallassessments', $workshop->context);
}
if (is_null($canviewreviewers)) {
$canviewreviewers = has_capability('mod/workshop:viewreviewernames', $workshop->context);
}
if (is_null($canoverridegrades)) {
$canoverridegrades = has_capability('mod/workshop:overridegrades', $workshop->context);
}
$isreviewer = $assessment->reviewerid == $USER->id;
if (!$isreviewer && is_null($assessment->grade) && !$canviewallassessments) {
// Students do not see peer-assessment that are not graded yet.
return null;
}
// Remove the feedback for the reviewer if:
// I can't see it in the evaluation phase because I'm not a teacher or the reviewer AND
// I can't see it in the assessment phase because I'm not a teacher.
if (($workshop->phase < workshop::PHASE_EVALUATION || !($isreviewer || $canviewallassessments)) &&
($workshop->phase < workshop::PHASE_ASSESSMENT || !$canviewallassessments) ) {
// Remove all the feedback information (all the optional fields).
foreach ($properties as $attribute => $settings) {
if (!empty($settings['optional'])) {
unset($assessment->{$attribute});
}
}
}
if (!$isreviewer && !$canviewreviewers) {
$assessment->reviewerid = 0;
}
return $assessment;
} | [
"protected",
"static",
"function",
"prepare_assessment_for_external",
"(",
"$",
"assessment",
",",
"workshop",
"$",
"workshop",
")",
"{",
"global",
"$",
"USER",
";",
"static",
"$",
"canviewallassessments",
"=",
"null",
";",
"static",
"$",
"canviewreviewers",
"=",
"null",
";",
"static",
"$",
"canoverridegrades",
"=",
"null",
";",
"// Remove all the properties that does not belong to the assessment table.",
"$",
"properties",
"=",
"assessment_exporter",
"::",
"properties_definition",
"(",
")",
";",
"foreach",
"(",
"$",
"assessment",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"properties",
"[",
"$",
"key",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"assessment",
"->",
"{",
"$",
"key",
"}",
")",
";",
"}",
"}",
"if",
"(",
"is_null",
"(",
"$",
"canviewallassessments",
")",
")",
"{",
"$",
"canviewallassessments",
"=",
"has_capability",
"(",
"'mod/workshop:viewallassessments'",
",",
"$",
"workshop",
"->",
"context",
")",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"canviewreviewers",
")",
")",
"{",
"$",
"canviewreviewers",
"=",
"has_capability",
"(",
"'mod/workshop:viewreviewernames'",
",",
"$",
"workshop",
"->",
"context",
")",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"canoverridegrades",
")",
")",
"{",
"$",
"canoverridegrades",
"=",
"has_capability",
"(",
"'mod/workshop:overridegrades'",
",",
"$",
"workshop",
"->",
"context",
")",
";",
"}",
"$",
"isreviewer",
"=",
"$",
"assessment",
"->",
"reviewerid",
"==",
"$",
"USER",
"->",
"id",
";",
"if",
"(",
"!",
"$",
"isreviewer",
"&&",
"is_null",
"(",
"$",
"assessment",
"->",
"grade",
")",
"&&",
"!",
"$",
"canviewallassessments",
")",
"{",
"// Students do not see peer-assessment that are not graded yet.",
"return",
"null",
";",
"}",
"// Remove the feedback for the reviewer if:",
"// I can't see it in the evaluation phase because I'm not a teacher or the reviewer AND",
"// I can't see it in the assessment phase because I'm not a teacher.",
"if",
"(",
"(",
"$",
"workshop",
"->",
"phase",
"<",
"workshop",
"::",
"PHASE_EVALUATION",
"||",
"!",
"(",
"$",
"isreviewer",
"||",
"$",
"canviewallassessments",
")",
")",
"&&",
"(",
"$",
"workshop",
"->",
"phase",
"<",
"workshop",
"::",
"PHASE_ASSESSMENT",
"||",
"!",
"$",
"canviewallassessments",
")",
")",
"{",
"// Remove all the feedback information (all the optional fields).",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"attribute",
"=>",
"$",
"settings",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"settings",
"[",
"'optional'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"assessment",
"->",
"{",
"$",
"attribute",
"}",
")",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"$",
"isreviewer",
"&&",
"!",
"$",
"canviewreviewers",
")",
"{",
"$",
"assessment",
"->",
"reviewerid",
"=",
"0",
";",
"}",
"return",
"$",
"assessment",
";",
"}"
] | Helper method for returning the assessment data according the current user capabilities and current phase.
@param stdClass $assessment the assessment data
@param workshop $workshop the workshop class
@return stdClass object with the assessment data filtered or null if is not viewable yet
@since Moodle 3.4 | [
"Helper",
"method",
"for",
"returning",
"the",
"assessment",
"data",
"according",
"the",
"current",
"user",
"capabilities",
"and",
"current",
"phase",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/classes/external.php#L1014-L1063 |
214,644 | moodle/moodle | mod/workshop/classes/external.php | mod_workshop_external.get_submission_assessments | public static function get_submission_assessments($submissionid) {
global $USER, $DB, $PAGE;
$params = self::validate_parameters(self::get_submission_assessments_parameters(), array('submissionid' => $submissionid));
$warnings = $assessments = array();
// Get and validate the submission and workshop.
$submission = $DB->get_record('workshop_submissions', array('id' => $params['submissionid']), '*', MUST_EXIST);
list($workshop, $course, $cm, $context) = self::validate_workshop($submission->workshopid);
// Check that we can get the assessments and get them.
self::check_view_submission_assessments($submission, $workshop);
$assessmentsrecords = $workshop->get_assessments_of_submission($submission->id);
$related = array('context' => $context);
foreach ($assessmentsrecords as $assessment) {
$assessment = self::prepare_assessment_for_external($assessment, $workshop);
if (empty($assessment)) {
continue;
}
$exporter = new assessment_exporter($assessment, $related);
$assessments[] = $exporter->export($PAGE->get_renderer('core'));
}
return array(
'assessments' => $assessments,
'warnings' => $warnings
);
} | php | public static function get_submission_assessments($submissionid) {
global $USER, $DB, $PAGE;
$params = self::validate_parameters(self::get_submission_assessments_parameters(), array('submissionid' => $submissionid));
$warnings = $assessments = array();
// Get and validate the submission and workshop.
$submission = $DB->get_record('workshop_submissions', array('id' => $params['submissionid']), '*', MUST_EXIST);
list($workshop, $course, $cm, $context) = self::validate_workshop($submission->workshopid);
// Check that we can get the assessments and get them.
self::check_view_submission_assessments($submission, $workshop);
$assessmentsrecords = $workshop->get_assessments_of_submission($submission->id);
$related = array('context' => $context);
foreach ($assessmentsrecords as $assessment) {
$assessment = self::prepare_assessment_for_external($assessment, $workshop);
if (empty($assessment)) {
continue;
}
$exporter = new assessment_exporter($assessment, $related);
$assessments[] = $exporter->export($PAGE->get_renderer('core'));
}
return array(
'assessments' => $assessments,
'warnings' => $warnings
);
} | [
"public",
"static",
"function",
"get_submission_assessments",
"(",
"$",
"submissionid",
")",
"{",
"global",
"$",
"USER",
",",
"$",
"DB",
",",
"$",
"PAGE",
";",
"$",
"params",
"=",
"self",
"::",
"validate_parameters",
"(",
"self",
"::",
"get_submission_assessments_parameters",
"(",
")",
",",
"array",
"(",
"'submissionid'",
"=>",
"$",
"submissionid",
")",
")",
";",
"$",
"warnings",
"=",
"$",
"assessments",
"=",
"array",
"(",
")",
";",
"// Get and validate the submission and workshop.",
"$",
"submission",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'workshop_submissions'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"params",
"[",
"'submissionid'",
"]",
")",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"list",
"(",
"$",
"workshop",
",",
"$",
"course",
",",
"$",
"cm",
",",
"$",
"context",
")",
"=",
"self",
"::",
"validate_workshop",
"(",
"$",
"submission",
"->",
"workshopid",
")",
";",
"// Check that we can get the assessments and get them.",
"self",
"::",
"check_view_submission_assessments",
"(",
"$",
"submission",
",",
"$",
"workshop",
")",
";",
"$",
"assessmentsrecords",
"=",
"$",
"workshop",
"->",
"get_assessments_of_submission",
"(",
"$",
"submission",
"->",
"id",
")",
";",
"$",
"related",
"=",
"array",
"(",
"'context'",
"=>",
"$",
"context",
")",
";",
"foreach",
"(",
"$",
"assessmentsrecords",
"as",
"$",
"assessment",
")",
"{",
"$",
"assessment",
"=",
"self",
"::",
"prepare_assessment_for_external",
"(",
"$",
"assessment",
",",
"$",
"workshop",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"assessment",
")",
")",
"{",
"continue",
";",
"}",
"$",
"exporter",
"=",
"new",
"assessment_exporter",
"(",
"$",
"assessment",
",",
"$",
"related",
")",
";",
"$",
"assessments",
"[",
"]",
"=",
"$",
"exporter",
"->",
"export",
"(",
"$",
"PAGE",
"->",
"get_renderer",
"(",
"'core'",
")",
")",
";",
"}",
"return",
"array",
"(",
"'assessments'",
"=>",
"$",
"assessments",
",",
"'warnings'",
"=>",
"$",
"warnings",
")",
";",
"}"
] | Retrieves the given submission assessments.
@param int $submissionid the submission id
@return array containing the assessments and warnings.
@since Moodle 3.4
@throws moodle_exception | [
"Retrieves",
"the",
"given",
"submission",
"assessments",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/classes/external.php#L1088-L1116 |
214,645 | moodle/moodle | mod/workshop/classes/external.php | mod_workshop_external.get_assessment | public static function get_assessment($assessmentid) {
global $DB, $PAGE;
$params = self::validate_parameters(self::get_assessment_parameters(), array('assessmentid' => $assessmentid));
$warnings = array();
// Get and validate the assessment, submission and workshop.
$assessment = $DB->get_record('workshop_assessments', array('id' => $params['assessmentid']), '*', MUST_EXIST);
$submission = $DB->get_record('workshop_submissions', array('id' => $assessment->submissionid), '*', MUST_EXIST);
list($workshop, $course, $cm, $context) = self::validate_workshop($submission->workshopid);
// Check that we can get the assessment.
$workshop->check_view_assessment($assessment, $submission);
$assessment = $workshop->get_assessment_by_id($assessment->id);
$assessment = self::prepare_assessment_for_external($assessment, $workshop);
if (empty($assessment)) {
throw new moodle_exception('nopermissions', 'error', '', 'view assessment');
}
$related = array('context' => $context);
$exporter = new assessment_exporter($assessment, $related);
return array(
'assessment' => $exporter->export($PAGE->get_renderer('core')),
'warnings' => $warnings
);
} | php | public static function get_assessment($assessmentid) {
global $DB, $PAGE;
$params = self::validate_parameters(self::get_assessment_parameters(), array('assessmentid' => $assessmentid));
$warnings = array();
// Get and validate the assessment, submission and workshop.
$assessment = $DB->get_record('workshop_assessments', array('id' => $params['assessmentid']), '*', MUST_EXIST);
$submission = $DB->get_record('workshop_submissions', array('id' => $assessment->submissionid), '*', MUST_EXIST);
list($workshop, $course, $cm, $context) = self::validate_workshop($submission->workshopid);
// Check that we can get the assessment.
$workshop->check_view_assessment($assessment, $submission);
$assessment = $workshop->get_assessment_by_id($assessment->id);
$assessment = self::prepare_assessment_for_external($assessment, $workshop);
if (empty($assessment)) {
throw new moodle_exception('nopermissions', 'error', '', 'view assessment');
}
$related = array('context' => $context);
$exporter = new assessment_exporter($assessment, $related);
return array(
'assessment' => $exporter->export($PAGE->get_renderer('core')),
'warnings' => $warnings
);
} | [
"public",
"static",
"function",
"get_assessment",
"(",
"$",
"assessmentid",
")",
"{",
"global",
"$",
"DB",
",",
"$",
"PAGE",
";",
"$",
"params",
"=",
"self",
"::",
"validate_parameters",
"(",
"self",
"::",
"get_assessment_parameters",
"(",
")",
",",
"array",
"(",
"'assessmentid'",
"=>",
"$",
"assessmentid",
")",
")",
";",
"$",
"warnings",
"=",
"array",
"(",
")",
";",
"// Get and validate the assessment, submission and workshop.",
"$",
"assessment",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'workshop_assessments'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"params",
"[",
"'assessmentid'",
"]",
")",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"$",
"submission",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'workshop_submissions'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"assessment",
"->",
"submissionid",
")",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"list",
"(",
"$",
"workshop",
",",
"$",
"course",
",",
"$",
"cm",
",",
"$",
"context",
")",
"=",
"self",
"::",
"validate_workshop",
"(",
"$",
"submission",
"->",
"workshopid",
")",
";",
"// Check that we can get the assessment.",
"$",
"workshop",
"->",
"check_view_assessment",
"(",
"$",
"assessment",
",",
"$",
"submission",
")",
";",
"$",
"assessment",
"=",
"$",
"workshop",
"->",
"get_assessment_by_id",
"(",
"$",
"assessment",
"->",
"id",
")",
";",
"$",
"assessment",
"=",
"self",
"::",
"prepare_assessment_for_external",
"(",
"$",
"assessment",
",",
"$",
"workshop",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"assessment",
")",
")",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'nopermissions'",
",",
"'error'",
",",
"''",
",",
"'view assessment'",
")",
";",
"}",
"$",
"related",
"=",
"array",
"(",
"'context'",
"=>",
"$",
"context",
")",
";",
"$",
"exporter",
"=",
"new",
"assessment_exporter",
"(",
"$",
"assessment",
",",
"$",
"related",
")",
";",
"return",
"array",
"(",
"'assessment'",
"=>",
"$",
"exporter",
"->",
"export",
"(",
"$",
"PAGE",
"->",
"get_renderer",
"(",
"'core'",
")",
")",
",",
"'warnings'",
"=>",
"$",
"warnings",
")",
";",
"}"
] | Retrieves the given assessment.
@param int $assessmentid the assessment id
@return array containing the assessment and warnings.
@since Moodle 3.4
@throws moodle_exception | [
"Retrieves",
"the",
"given",
"assessment",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/classes/external.php#L1158-L1184 |
214,646 | moodle/moodle | mod/workshop/classes/external.php | mod_workshop_external.get_reviewer_assessments | public static function get_reviewer_assessments($workshopid, $userid = 0) {
global $USER, $DB, $PAGE;
$params = self::validate_parameters(
self::get_reviewer_assessments_parameters(), array('workshopid' => $workshopid, 'userid' => $userid)
);
$warnings = $assessments = array();
// Get and validate the submission and workshop.
list($workshop, $course, $cm, $context) = self::validate_workshop($params['workshopid']);
// Extra checks so only users with permissions can view other users assessments.
if (empty($params['userid']) || $params['userid'] == $USER->id) {
$userid = $USER->id;
list($assessed, $notice) = $workshop->check_examples_assessed_before_assessment($userid);
if (!$assessed) {
throw new moodle_exception($notice, 'mod_workshop');
}
if ($workshop->phase < workshop::PHASE_ASSESSMENT) { // Can view assessments only in assessment phase onwards.
throw new moodle_exception('nopermissions', 'error', '', 'view assessments');
}
} else {
require_capability('mod/workshop:viewallassessments', $context);
$user = core_user::get_user($params['userid'], '*', MUST_EXIST);
core_user::require_active_user($user);
if (!$workshop->check_group_membership($user->id)) {
throw new moodle_exception('notingroup');
}
$userid = $user->id;
}
// Now get all my assessments (includes those pending review).
$assessmentsrecords = $workshop->get_assessments_by_reviewer($userid);
$related = array('context' => $context);
foreach ($assessmentsrecords as $assessment) {
$assessment = self::prepare_assessment_for_external($assessment, $workshop);
if (empty($assessment)) {
continue;
}
$exporter = new assessment_exporter($assessment, $related);
$assessments[] = $exporter->export($PAGE->get_renderer('core'));
}
return array(
'assessments' => $assessments,
'warnings' => $warnings
);
} | php | public static function get_reviewer_assessments($workshopid, $userid = 0) {
global $USER, $DB, $PAGE;
$params = self::validate_parameters(
self::get_reviewer_assessments_parameters(), array('workshopid' => $workshopid, 'userid' => $userid)
);
$warnings = $assessments = array();
// Get and validate the submission and workshop.
list($workshop, $course, $cm, $context) = self::validate_workshop($params['workshopid']);
// Extra checks so only users with permissions can view other users assessments.
if (empty($params['userid']) || $params['userid'] == $USER->id) {
$userid = $USER->id;
list($assessed, $notice) = $workshop->check_examples_assessed_before_assessment($userid);
if (!$assessed) {
throw new moodle_exception($notice, 'mod_workshop');
}
if ($workshop->phase < workshop::PHASE_ASSESSMENT) { // Can view assessments only in assessment phase onwards.
throw new moodle_exception('nopermissions', 'error', '', 'view assessments');
}
} else {
require_capability('mod/workshop:viewallassessments', $context);
$user = core_user::get_user($params['userid'], '*', MUST_EXIST);
core_user::require_active_user($user);
if (!$workshop->check_group_membership($user->id)) {
throw new moodle_exception('notingroup');
}
$userid = $user->id;
}
// Now get all my assessments (includes those pending review).
$assessmentsrecords = $workshop->get_assessments_by_reviewer($userid);
$related = array('context' => $context);
foreach ($assessmentsrecords as $assessment) {
$assessment = self::prepare_assessment_for_external($assessment, $workshop);
if (empty($assessment)) {
continue;
}
$exporter = new assessment_exporter($assessment, $related);
$assessments[] = $exporter->export($PAGE->get_renderer('core'));
}
return array(
'assessments' => $assessments,
'warnings' => $warnings
);
} | [
"public",
"static",
"function",
"get_reviewer_assessments",
"(",
"$",
"workshopid",
",",
"$",
"userid",
"=",
"0",
")",
"{",
"global",
"$",
"USER",
",",
"$",
"DB",
",",
"$",
"PAGE",
";",
"$",
"params",
"=",
"self",
"::",
"validate_parameters",
"(",
"self",
"::",
"get_reviewer_assessments_parameters",
"(",
")",
",",
"array",
"(",
"'workshopid'",
"=>",
"$",
"workshopid",
",",
"'userid'",
"=>",
"$",
"userid",
")",
")",
";",
"$",
"warnings",
"=",
"$",
"assessments",
"=",
"array",
"(",
")",
";",
"// Get and validate the submission and workshop.",
"list",
"(",
"$",
"workshop",
",",
"$",
"course",
",",
"$",
"cm",
",",
"$",
"context",
")",
"=",
"self",
"::",
"validate_workshop",
"(",
"$",
"params",
"[",
"'workshopid'",
"]",
")",
";",
"// Extra checks so only users with permissions can view other users assessments.",
"if",
"(",
"empty",
"(",
"$",
"params",
"[",
"'userid'",
"]",
")",
"||",
"$",
"params",
"[",
"'userid'",
"]",
"==",
"$",
"USER",
"->",
"id",
")",
"{",
"$",
"userid",
"=",
"$",
"USER",
"->",
"id",
";",
"list",
"(",
"$",
"assessed",
",",
"$",
"notice",
")",
"=",
"$",
"workshop",
"->",
"check_examples_assessed_before_assessment",
"(",
"$",
"userid",
")",
";",
"if",
"(",
"!",
"$",
"assessed",
")",
"{",
"throw",
"new",
"moodle_exception",
"(",
"$",
"notice",
",",
"'mod_workshop'",
")",
";",
"}",
"if",
"(",
"$",
"workshop",
"->",
"phase",
"<",
"workshop",
"::",
"PHASE_ASSESSMENT",
")",
"{",
"// Can view assessments only in assessment phase onwards.",
"throw",
"new",
"moodle_exception",
"(",
"'nopermissions'",
",",
"'error'",
",",
"''",
",",
"'view assessments'",
")",
";",
"}",
"}",
"else",
"{",
"require_capability",
"(",
"'mod/workshop:viewallassessments'",
",",
"$",
"context",
")",
";",
"$",
"user",
"=",
"core_user",
"::",
"get_user",
"(",
"$",
"params",
"[",
"'userid'",
"]",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"core_user",
"::",
"require_active_user",
"(",
"$",
"user",
")",
";",
"if",
"(",
"!",
"$",
"workshop",
"->",
"check_group_membership",
"(",
"$",
"user",
"->",
"id",
")",
")",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'notingroup'",
")",
";",
"}",
"$",
"userid",
"=",
"$",
"user",
"->",
"id",
";",
"}",
"// Now get all my assessments (includes those pending review).",
"$",
"assessmentsrecords",
"=",
"$",
"workshop",
"->",
"get_assessments_by_reviewer",
"(",
"$",
"userid",
")",
";",
"$",
"related",
"=",
"array",
"(",
"'context'",
"=>",
"$",
"context",
")",
";",
"foreach",
"(",
"$",
"assessmentsrecords",
"as",
"$",
"assessment",
")",
"{",
"$",
"assessment",
"=",
"self",
"::",
"prepare_assessment_for_external",
"(",
"$",
"assessment",
",",
"$",
"workshop",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"assessment",
")",
")",
"{",
"continue",
";",
"}",
"$",
"exporter",
"=",
"new",
"assessment_exporter",
"(",
"$",
"assessment",
",",
"$",
"related",
")",
";",
"$",
"assessments",
"[",
"]",
"=",
"$",
"exporter",
"->",
"export",
"(",
"$",
"PAGE",
"->",
"get_renderer",
"(",
"'core'",
")",
")",
";",
"}",
"return",
"array",
"(",
"'assessments'",
"=>",
"$",
"assessments",
",",
"'warnings'",
"=>",
"$",
"warnings",
")",
";",
"}"
] | Retrieves all the assessments reviewed by the given user.
@param int $workshopid the workshop instance id
@param int $userid the reviewer user id
@return array containing the user assessments and warnings.
@since Moodle 3.4
@throws moodle_exception | [
"Retrieves",
"all",
"the",
"assessments",
"reviewed",
"by",
"the",
"given",
"user",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/classes/external.php#L1375-L1422 |
214,647 | moodle/moodle | mod/workshop/classes/external.php | mod_workshop_external.update_assessment | public static function update_assessment($assessmentid, $data) {
global $DB, $USER;
$params = self::validate_parameters(
self::update_assessment_parameters(), array('assessmentid' => $assessmentid, 'data' => $data)
);
$warnings = array();
// Get and validate the assessment, submission and workshop.
$assessment = $DB->get_record('workshop_assessments', array('id' => $params['assessmentid']), '*', MUST_EXIST);
$submission = $DB->get_record('workshop_submissions', array('id' => $assessment->submissionid), '*', MUST_EXIST);
list($workshop, $course, $cm, $context) = self::validate_workshop($submission->workshopid);
// Check we can edit the assessment.
$workshop->check_edit_assessment($assessment, $submission);
// Process data.
$data = new stdClass;
$data->feedbackauthor_editor = array();
foreach ($params['data'] as $wsdata) {
$name = trim($wsdata['name']);
switch ($name) {
case 'feedbackauthor':
$data->feedbackauthor_editor['text'] = $wsdata['value'];
break;
case 'feedbackauthorformat':
$data->feedbackauthor_editor['format'] = clean_param($wsdata['value'], PARAM_FORMAT);
break;
case 'feedbackauthorinlineattachmentsid':
$data->feedbackauthor_editor['itemid'] = clean_param($wsdata['value'], PARAM_INT);
break;
case 'feedbackauthorattachmentsid':
$data->feedbackauthorattachment_filemanager = clean_param($wsdata['value'], PARAM_INT);
break;
default:
$data->{$wsdata['name']} = $wsdata['value']; // Validation will be done in the form->validation.
}
}
$cansetassessmentweight = has_capability('mod/workshop:allocate', $context);
$pending = $workshop->get_pending_assessments_by_reviewer($assessment->reviewerid, $assessment->id);
// Retrieve the data from the strategy plugin.
$strategy = $workshop->grading_strategy_instance();
$mform = $strategy->get_assessment_form(null, 'assessment', $assessment, true,
array('editableweight' => $cansetassessmentweight, 'pending' => !empty($pending)));
$errors = $mform->validation((array) $data, array());
// We can get several errors, return them in warnings.
if (!empty($errors)) {
$status = false;
$rawgrade = null;
foreach ($errors as $itemname => $message) {
$warnings[] = array(
'item' => $itemname,
'itemid' => 0,
'warningcode' => 'fielderror',
'message' => s($message)
);
}
} else {
$rawgrade = $workshop->edit_assessment($assessment, $submission, $data, $strategy);
$status = true;
}
return array(
'status' => $status,
'rawgrade' => $rawgrade,
'warnings' => $warnings,
);
} | php | public static function update_assessment($assessmentid, $data) {
global $DB, $USER;
$params = self::validate_parameters(
self::update_assessment_parameters(), array('assessmentid' => $assessmentid, 'data' => $data)
);
$warnings = array();
// Get and validate the assessment, submission and workshop.
$assessment = $DB->get_record('workshop_assessments', array('id' => $params['assessmentid']), '*', MUST_EXIST);
$submission = $DB->get_record('workshop_submissions', array('id' => $assessment->submissionid), '*', MUST_EXIST);
list($workshop, $course, $cm, $context) = self::validate_workshop($submission->workshopid);
// Check we can edit the assessment.
$workshop->check_edit_assessment($assessment, $submission);
// Process data.
$data = new stdClass;
$data->feedbackauthor_editor = array();
foreach ($params['data'] as $wsdata) {
$name = trim($wsdata['name']);
switch ($name) {
case 'feedbackauthor':
$data->feedbackauthor_editor['text'] = $wsdata['value'];
break;
case 'feedbackauthorformat':
$data->feedbackauthor_editor['format'] = clean_param($wsdata['value'], PARAM_FORMAT);
break;
case 'feedbackauthorinlineattachmentsid':
$data->feedbackauthor_editor['itemid'] = clean_param($wsdata['value'], PARAM_INT);
break;
case 'feedbackauthorattachmentsid':
$data->feedbackauthorattachment_filemanager = clean_param($wsdata['value'], PARAM_INT);
break;
default:
$data->{$wsdata['name']} = $wsdata['value']; // Validation will be done in the form->validation.
}
}
$cansetassessmentweight = has_capability('mod/workshop:allocate', $context);
$pending = $workshop->get_pending_assessments_by_reviewer($assessment->reviewerid, $assessment->id);
// Retrieve the data from the strategy plugin.
$strategy = $workshop->grading_strategy_instance();
$mform = $strategy->get_assessment_form(null, 'assessment', $assessment, true,
array('editableweight' => $cansetassessmentweight, 'pending' => !empty($pending)));
$errors = $mform->validation((array) $data, array());
// We can get several errors, return them in warnings.
if (!empty($errors)) {
$status = false;
$rawgrade = null;
foreach ($errors as $itemname => $message) {
$warnings[] = array(
'item' => $itemname,
'itemid' => 0,
'warningcode' => 'fielderror',
'message' => s($message)
);
}
} else {
$rawgrade = $workshop->edit_assessment($assessment, $submission, $data, $strategy);
$status = true;
}
return array(
'status' => $status,
'rawgrade' => $rawgrade,
'warnings' => $warnings,
);
} | [
"public",
"static",
"function",
"update_assessment",
"(",
"$",
"assessmentid",
",",
"$",
"data",
")",
"{",
"global",
"$",
"DB",
",",
"$",
"USER",
";",
"$",
"params",
"=",
"self",
"::",
"validate_parameters",
"(",
"self",
"::",
"update_assessment_parameters",
"(",
")",
",",
"array",
"(",
"'assessmentid'",
"=>",
"$",
"assessmentid",
",",
"'data'",
"=>",
"$",
"data",
")",
")",
";",
"$",
"warnings",
"=",
"array",
"(",
")",
";",
"// Get and validate the assessment, submission and workshop.",
"$",
"assessment",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'workshop_assessments'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"params",
"[",
"'assessmentid'",
"]",
")",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"$",
"submission",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'workshop_submissions'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"assessment",
"->",
"submissionid",
")",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"list",
"(",
"$",
"workshop",
",",
"$",
"course",
",",
"$",
"cm",
",",
"$",
"context",
")",
"=",
"self",
"::",
"validate_workshop",
"(",
"$",
"submission",
"->",
"workshopid",
")",
";",
"// Check we can edit the assessment.",
"$",
"workshop",
"->",
"check_edit_assessment",
"(",
"$",
"assessment",
",",
"$",
"submission",
")",
";",
"// Process data.",
"$",
"data",
"=",
"new",
"stdClass",
";",
"$",
"data",
"->",
"feedbackauthor_editor",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"params",
"[",
"'data'",
"]",
"as",
"$",
"wsdata",
")",
"{",
"$",
"name",
"=",
"trim",
"(",
"$",
"wsdata",
"[",
"'name'",
"]",
")",
";",
"switch",
"(",
"$",
"name",
")",
"{",
"case",
"'feedbackauthor'",
":",
"$",
"data",
"->",
"feedbackauthor_editor",
"[",
"'text'",
"]",
"=",
"$",
"wsdata",
"[",
"'value'",
"]",
";",
"break",
";",
"case",
"'feedbackauthorformat'",
":",
"$",
"data",
"->",
"feedbackauthor_editor",
"[",
"'format'",
"]",
"=",
"clean_param",
"(",
"$",
"wsdata",
"[",
"'value'",
"]",
",",
"PARAM_FORMAT",
")",
";",
"break",
";",
"case",
"'feedbackauthorinlineattachmentsid'",
":",
"$",
"data",
"->",
"feedbackauthor_editor",
"[",
"'itemid'",
"]",
"=",
"clean_param",
"(",
"$",
"wsdata",
"[",
"'value'",
"]",
",",
"PARAM_INT",
")",
";",
"break",
";",
"case",
"'feedbackauthorattachmentsid'",
":",
"$",
"data",
"->",
"feedbackauthorattachment_filemanager",
"=",
"clean_param",
"(",
"$",
"wsdata",
"[",
"'value'",
"]",
",",
"PARAM_INT",
")",
";",
"break",
";",
"default",
":",
"$",
"data",
"->",
"{",
"$",
"wsdata",
"[",
"'name'",
"]",
"}",
"=",
"$",
"wsdata",
"[",
"'value'",
"]",
";",
"// Validation will be done in the form->validation.",
"}",
"}",
"$",
"cansetassessmentweight",
"=",
"has_capability",
"(",
"'mod/workshop:allocate'",
",",
"$",
"context",
")",
";",
"$",
"pending",
"=",
"$",
"workshop",
"->",
"get_pending_assessments_by_reviewer",
"(",
"$",
"assessment",
"->",
"reviewerid",
",",
"$",
"assessment",
"->",
"id",
")",
";",
"// Retrieve the data from the strategy plugin.",
"$",
"strategy",
"=",
"$",
"workshop",
"->",
"grading_strategy_instance",
"(",
")",
";",
"$",
"mform",
"=",
"$",
"strategy",
"->",
"get_assessment_form",
"(",
"null",
",",
"'assessment'",
",",
"$",
"assessment",
",",
"true",
",",
"array",
"(",
"'editableweight'",
"=>",
"$",
"cansetassessmentweight",
",",
"'pending'",
"=>",
"!",
"empty",
"(",
"$",
"pending",
")",
")",
")",
";",
"$",
"errors",
"=",
"$",
"mform",
"->",
"validation",
"(",
"(",
"array",
")",
"$",
"data",
",",
"array",
"(",
")",
")",
";",
"// We can get several errors, return them in warnings.",
"if",
"(",
"!",
"empty",
"(",
"$",
"errors",
")",
")",
"{",
"$",
"status",
"=",
"false",
";",
"$",
"rawgrade",
"=",
"null",
";",
"foreach",
"(",
"$",
"errors",
"as",
"$",
"itemname",
"=>",
"$",
"message",
")",
"{",
"$",
"warnings",
"[",
"]",
"=",
"array",
"(",
"'item'",
"=>",
"$",
"itemname",
",",
"'itemid'",
"=>",
"0",
",",
"'warningcode'",
"=>",
"'fielderror'",
",",
"'message'",
"=>",
"s",
"(",
"$",
"message",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"rawgrade",
"=",
"$",
"workshop",
"->",
"edit_assessment",
"(",
"$",
"assessment",
",",
"$",
"submission",
",",
"$",
"data",
",",
"$",
"strategy",
")",
";",
"$",
"status",
"=",
"true",
";",
"}",
"return",
"array",
"(",
"'status'",
"=>",
"$",
"status",
",",
"'rawgrade'",
"=>",
"$",
"rawgrade",
",",
"'warnings'",
"=>",
"$",
"warnings",
",",
")",
";",
"}"
] | Updates an assessment.
@param int $assessmentid the assessment id
@param array $data the assessment data
@return array indicates if the assessment was updated, the new raw grade and possible warnings.
@since Moodle 3.4
@throws moodle_exception | [
"Updates",
"an",
"assessment",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/classes/external.php#L1480-L1550 |
214,648 | moodle/moodle | mod/workshop/classes/external.php | mod_workshop_external.get_grades | public static function get_grades($workshopid, $userid = 0) {
global $USER;
$params = array(
'workshopid' => $workshopid,
'userid' => $userid,
);
$params = self::validate_parameters(self::get_grades_parameters(), $params);
$warnings = array();
list($workshop, $course, $cm, $context) = self::validate_workshop($params['workshopid']);
// Extra checks so only users with permissions can view other users plans.
if (empty($params['userid']) || $params['userid'] == $USER->id) {
$userid = $USER->id;
} else {
require_capability('mod/workshop:viewallassessments', $context);
$user = core_user::get_user($params['userid'], '*', MUST_EXIST);
core_user::require_active_user($user);
if (!$workshop->check_group_membership($user->id)) {
throw new moodle_exception('notingroup');
}
$userid = $user->id;
}
$finalgrades = $workshop->get_gradebook_grades($userid);
$result = array('warnings' => $warnings);
if ($finalgrades !== false) {
if (!empty($finalgrades->submissiongrade)) {
if (is_numeric($finalgrades->submissiongrade->grade)) {
$result['submissionrawgrade'] = $finalgrades->submissiongrade->grade;
}
$result['submissionlongstrgrade'] = $finalgrades->submissiongrade->str_long_grade;
$result['submissiongradehidden'] = $finalgrades->submissiongrade->hidden;
}
if (!empty($finalgrades->assessmentgrade)) {
if (is_numeric($finalgrades->assessmentgrade->grade)) {
$result['assessmentrawgrade'] = $finalgrades->assessmentgrade->grade;
}
$result['assessmentlongstrgrade'] = $finalgrades->assessmentgrade->str_long_grade;
$result['assessmentgradehidden'] = $finalgrades->assessmentgrade->hidden;
}
}
return $result;
} | php | public static function get_grades($workshopid, $userid = 0) {
global $USER;
$params = array(
'workshopid' => $workshopid,
'userid' => $userid,
);
$params = self::validate_parameters(self::get_grades_parameters(), $params);
$warnings = array();
list($workshop, $course, $cm, $context) = self::validate_workshop($params['workshopid']);
// Extra checks so only users with permissions can view other users plans.
if (empty($params['userid']) || $params['userid'] == $USER->id) {
$userid = $USER->id;
} else {
require_capability('mod/workshop:viewallassessments', $context);
$user = core_user::get_user($params['userid'], '*', MUST_EXIST);
core_user::require_active_user($user);
if (!$workshop->check_group_membership($user->id)) {
throw new moodle_exception('notingroup');
}
$userid = $user->id;
}
$finalgrades = $workshop->get_gradebook_grades($userid);
$result = array('warnings' => $warnings);
if ($finalgrades !== false) {
if (!empty($finalgrades->submissiongrade)) {
if (is_numeric($finalgrades->submissiongrade->grade)) {
$result['submissionrawgrade'] = $finalgrades->submissiongrade->grade;
}
$result['submissionlongstrgrade'] = $finalgrades->submissiongrade->str_long_grade;
$result['submissiongradehidden'] = $finalgrades->submissiongrade->hidden;
}
if (!empty($finalgrades->assessmentgrade)) {
if (is_numeric($finalgrades->assessmentgrade->grade)) {
$result['assessmentrawgrade'] = $finalgrades->assessmentgrade->grade;
}
$result['assessmentlongstrgrade'] = $finalgrades->assessmentgrade->str_long_grade;
$result['assessmentgradehidden'] = $finalgrades->assessmentgrade->hidden;
}
}
return $result;
} | [
"public",
"static",
"function",
"get_grades",
"(",
"$",
"workshopid",
",",
"$",
"userid",
"=",
"0",
")",
"{",
"global",
"$",
"USER",
";",
"$",
"params",
"=",
"array",
"(",
"'workshopid'",
"=>",
"$",
"workshopid",
",",
"'userid'",
"=>",
"$",
"userid",
",",
")",
";",
"$",
"params",
"=",
"self",
"::",
"validate_parameters",
"(",
"self",
"::",
"get_grades_parameters",
"(",
")",
",",
"$",
"params",
")",
";",
"$",
"warnings",
"=",
"array",
"(",
")",
";",
"list",
"(",
"$",
"workshop",
",",
"$",
"course",
",",
"$",
"cm",
",",
"$",
"context",
")",
"=",
"self",
"::",
"validate_workshop",
"(",
"$",
"params",
"[",
"'workshopid'",
"]",
")",
";",
"// Extra checks so only users with permissions can view other users plans.",
"if",
"(",
"empty",
"(",
"$",
"params",
"[",
"'userid'",
"]",
")",
"||",
"$",
"params",
"[",
"'userid'",
"]",
"==",
"$",
"USER",
"->",
"id",
")",
"{",
"$",
"userid",
"=",
"$",
"USER",
"->",
"id",
";",
"}",
"else",
"{",
"require_capability",
"(",
"'mod/workshop:viewallassessments'",
",",
"$",
"context",
")",
";",
"$",
"user",
"=",
"core_user",
"::",
"get_user",
"(",
"$",
"params",
"[",
"'userid'",
"]",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"core_user",
"::",
"require_active_user",
"(",
"$",
"user",
")",
";",
"if",
"(",
"!",
"$",
"workshop",
"->",
"check_group_membership",
"(",
"$",
"user",
"->",
"id",
")",
")",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'notingroup'",
")",
";",
"}",
"$",
"userid",
"=",
"$",
"user",
"->",
"id",
";",
"}",
"$",
"finalgrades",
"=",
"$",
"workshop",
"->",
"get_gradebook_grades",
"(",
"$",
"userid",
")",
";",
"$",
"result",
"=",
"array",
"(",
"'warnings'",
"=>",
"$",
"warnings",
")",
";",
"if",
"(",
"$",
"finalgrades",
"!==",
"false",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"finalgrades",
"->",
"submissiongrade",
")",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"finalgrades",
"->",
"submissiongrade",
"->",
"grade",
")",
")",
"{",
"$",
"result",
"[",
"'submissionrawgrade'",
"]",
"=",
"$",
"finalgrades",
"->",
"submissiongrade",
"->",
"grade",
";",
"}",
"$",
"result",
"[",
"'submissionlongstrgrade'",
"]",
"=",
"$",
"finalgrades",
"->",
"submissiongrade",
"->",
"str_long_grade",
";",
"$",
"result",
"[",
"'submissiongradehidden'",
"]",
"=",
"$",
"finalgrades",
"->",
"submissiongrade",
"->",
"hidden",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"finalgrades",
"->",
"assessmentgrade",
")",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"finalgrades",
"->",
"assessmentgrade",
"->",
"grade",
")",
")",
"{",
"$",
"result",
"[",
"'assessmentrawgrade'",
"]",
"=",
"$",
"finalgrades",
"->",
"assessmentgrade",
"->",
"grade",
";",
"}",
"$",
"result",
"[",
"'assessmentlongstrgrade'",
"]",
"=",
"$",
"finalgrades",
"->",
"assessmentgrade",
"->",
"str_long_grade",
";",
"$",
"result",
"[",
"'assessmentgradehidden'",
"]",
"=",
"$",
"finalgrades",
"->",
"assessmentgrade",
"->",
"hidden",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns the grades information for the given workshop and user.
@param int $workshopid workshop instance id
@param int $userid user id
@return array of warnings and the user plan
@since Moodle 3.4
@throws moodle_exception | [
"Returns",
"the",
"grades",
"information",
"for",
"the",
"given",
"workshop",
"and",
"user",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/classes/external.php#L1593-L1639 |
214,649 | moodle/moodle | mod/workshop/classes/external.php | mod_workshop_external.view_submission | public static function view_submission($submissionid) {
global $DB;
$params = self::validate_parameters(self::view_submission_parameters(), array('submissionid' => $submissionid));
$warnings = array();
// Get and validate the submission and workshop.
$submission = $DB->get_record('workshop_submissions', array('id' => $params['submissionid']), '*', MUST_EXIST);
list($workshop, $course, $cm, $context) = self::validate_workshop($submission->workshopid);
self::validate_submission($submission, $workshop);
$workshop->set_submission_viewed($submission);
$result = array(
'status' => true,
'warnings' => $warnings,
);
return $result;
} | php | public static function view_submission($submissionid) {
global $DB;
$params = self::validate_parameters(self::view_submission_parameters(), array('submissionid' => $submissionid));
$warnings = array();
// Get and validate the submission and workshop.
$submission = $DB->get_record('workshop_submissions', array('id' => $params['submissionid']), '*', MUST_EXIST);
list($workshop, $course, $cm, $context) = self::validate_workshop($submission->workshopid);
self::validate_submission($submission, $workshop);
$workshop->set_submission_viewed($submission);
$result = array(
'status' => true,
'warnings' => $warnings,
);
return $result;
} | [
"public",
"static",
"function",
"view_submission",
"(",
"$",
"submissionid",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"params",
"=",
"self",
"::",
"validate_parameters",
"(",
"self",
"::",
"view_submission_parameters",
"(",
")",
",",
"array",
"(",
"'submissionid'",
"=>",
"$",
"submissionid",
")",
")",
";",
"$",
"warnings",
"=",
"array",
"(",
")",
";",
"// Get and validate the submission and workshop.",
"$",
"submission",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'workshop_submissions'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"params",
"[",
"'submissionid'",
"]",
")",
",",
"'*'",
",",
"MUST_EXIST",
")",
";",
"list",
"(",
"$",
"workshop",
",",
"$",
"course",
",",
"$",
"cm",
",",
"$",
"context",
")",
"=",
"self",
"::",
"validate_workshop",
"(",
"$",
"submission",
"->",
"workshopid",
")",
";",
"self",
"::",
"validate_submission",
"(",
"$",
"submission",
",",
"$",
"workshop",
")",
";",
"$",
"workshop",
"->",
"set_submission_viewed",
"(",
"$",
"submission",
")",
";",
"$",
"result",
"=",
"array",
"(",
"'status'",
"=>",
"true",
",",
"'warnings'",
"=>",
"$",
"warnings",
",",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Trigger the submission viewed event.
@param int $submissionid submission id
@return array of warnings and status result
@since Moodle 3.4
@throws moodle_exception | [
"Trigger",
"the",
"submission",
"viewed",
"event",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/workshop/classes/external.php#L1981-L2000 |
214,650 | moodle/moodle | cache/renderer.php | core_cache_renderer.store_plugin_summaries | public function store_plugin_summaries(array $plugins) {
$table = new html_table();
$table->head = array(
get_string('plugin', 'cache'),
get_string('storeready', 'cache'),
get_string('stores', 'cache'),
get_string('modes', 'cache'),
get_string('supports', 'cache'),
get_string('actions', 'cache'),
);
$table->colclasses = array(
'plugin',
'storeready',
'stores',
'modes',
'supports',
'actions'
);
$table->data = array();
foreach ($plugins as $name => $plugin) {
$actions = cache_administration_helper::get_store_plugin_actions($name, $plugin);
$modes = array();
foreach ($plugin['modes'] as $mode => $enabled) {
if ($enabled) {
$modes[] = get_string('mode_'.$mode, 'cache');
}
}
$supports = array();
foreach ($plugin['supports'] as $support => $enabled) {
if ($enabled) {
$supports[] = get_string('supports_'.$support, 'cache');
}
}
$htmlactions = array();
foreach ($actions as $action) {
$htmlactions[] = $this->output->action_link($action['url'], $action['text']);
}
$row = new html_table_row(array(
$plugin['name'],
($plugin['requirementsmet']) ? $this->output->pix_icon('i/valid', '1') : '',
$plugin['instances'],
join(', ', $modes),
join(', ', $supports),
join(', ', $htmlactions)
));
$row->attributes['class'] = 'plugin-'.$name;
$table->data[] = $row;
}
$html = html_writer::start_tag('div', array('id' => 'core-cache-plugin-summaries'));
$html .= $this->output->heading(get_string('pluginsummaries', 'cache'), 3);
$html .= html_writer::table($table);
$html .= html_writer::end_tag('div');
return $html;
} | php | public function store_plugin_summaries(array $plugins) {
$table = new html_table();
$table->head = array(
get_string('plugin', 'cache'),
get_string('storeready', 'cache'),
get_string('stores', 'cache'),
get_string('modes', 'cache'),
get_string('supports', 'cache'),
get_string('actions', 'cache'),
);
$table->colclasses = array(
'plugin',
'storeready',
'stores',
'modes',
'supports',
'actions'
);
$table->data = array();
foreach ($plugins as $name => $plugin) {
$actions = cache_administration_helper::get_store_plugin_actions($name, $plugin);
$modes = array();
foreach ($plugin['modes'] as $mode => $enabled) {
if ($enabled) {
$modes[] = get_string('mode_'.$mode, 'cache');
}
}
$supports = array();
foreach ($plugin['supports'] as $support => $enabled) {
if ($enabled) {
$supports[] = get_string('supports_'.$support, 'cache');
}
}
$htmlactions = array();
foreach ($actions as $action) {
$htmlactions[] = $this->output->action_link($action['url'], $action['text']);
}
$row = new html_table_row(array(
$plugin['name'],
($plugin['requirementsmet']) ? $this->output->pix_icon('i/valid', '1') : '',
$plugin['instances'],
join(', ', $modes),
join(', ', $supports),
join(', ', $htmlactions)
));
$row->attributes['class'] = 'plugin-'.$name;
$table->data[] = $row;
}
$html = html_writer::start_tag('div', array('id' => 'core-cache-plugin-summaries'));
$html .= $this->output->heading(get_string('pluginsummaries', 'cache'), 3);
$html .= html_writer::table($table);
$html .= html_writer::end_tag('div');
return $html;
} | [
"public",
"function",
"store_plugin_summaries",
"(",
"array",
"$",
"plugins",
")",
"{",
"$",
"table",
"=",
"new",
"html_table",
"(",
")",
";",
"$",
"table",
"->",
"head",
"=",
"array",
"(",
"get_string",
"(",
"'plugin'",
",",
"'cache'",
")",
",",
"get_string",
"(",
"'storeready'",
",",
"'cache'",
")",
",",
"get_string",
"(",
"'stores'",
",",
"'cache'",
")",
",",
"get_string",
"(",
"'modes'",
",",
"'cache'",
")",
",",
"get_string",
"(",
"'supports'",
",",
"'cache'",
")",
",",
"get_string",
"(",
"'actions'",
",",
"'cache'",
")",
",",
")",
";",
"$",
"table",
"->",
"colclasses",
"=",
"array",
"(",
"'plugin'",
",",
"'storeready'",
",",
"'stores'",
",",
"'modes'",
",",
"'supports'",
",",
"'actions'",
")",
";",
"$",
"table",
"->",
"data",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"name",
"=>",
"$",
"plugin",
")",
"{",
"$",
"actions",
"=",
"cache_administration_helper",
"::",
"get_store_plugin_actions",
"(",
"$",
"name",
",",
"$",
"plugin",
")",
";",
"$",
"modes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"plugin",
"[",
"'modes'",
"]",
"as",
"$",
"mode",
"=>",
"$",
"enabled",
")",
"{",
"if",
"(",
"$",
"enabled",
")",
"{",
"$",
"modes",
"[",
"]",
"=",
"get_string",
"(",
"'mode_'",
".",
"$",
"mode",
",",
"'cache'",
")",
";",
"}",
"}",
"$",
"supports",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"plugin",
"[",
"'supports'",
"]",
"as",
"$",
"support",
"=>",
"$",
"enabled",
")",
"{",
"if",
"(",
"$",
"enabled",
")",
"{",
"$",
"supports",
"[",
"]",
"=",
"get_string",
"(",
"'supports_'",
".",
"$",
"support",
",",
"'cache'",
")",
";",
"}",
"}",
"$",
"htmlactions",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"actions",
"as",
"$",
"action",
")",
"{",
"$",
"htmlactions",
"[",
"]",
"=",
"$",
"this",
"->",
"output",
"->",
"action_link",
"(",
"$",
"action",
"[",
"'url'",
"]",
",",
"$",
"action",
"[",
"'text'",
"]",
")",
";",
"}",
"$",
"row",
"=",
"new",
"html_table_row",
"(",
"array",
"(",
"$",
"plugin",
"[",
"'name'",
"]",
",",
"(",
"$",
"plugin",
"[",
"'requirementsmet'",
"]",
")",
"?",
"$",
"this",
"->",
"output",
"->",
"pix_icon",
"(",
"'i/valid'",
",",
"'1'",
")",
":",
"''",
",",
"$",
"plugin",
"[",
"'instances'",
"]",
",",
"join",
"(",
"', '",
",",
"$",
"modes",
")",
",",
"join",
"(",
"', '",
",",
"$",
"supports",
")",
",",
"join",
"(",
"', '",
",",
"$",
"htmlactions",
")",
")",
")",
";",
"$",
"row",
"->",
"attributes",
"[",
"'class'",
"]",
"=",
"'plugin-'",
".",
"$",
"name",
";",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"$",
"row",
";",
"}",
"$",
"html",
"=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'id'",
"=>",
"'core-cache-plugin-summaries'",
")",
")",
";",
"$",
"html",
".=",
"$",
"this",
"->",
"output",
"->",
"heading",
"(",
"get_string",
"(",
"'pluginsummaries'",
",",
"'cache'",
")",
",",
"3",
")",
";",
"$",
"html",
".=",
"html_writer",
"::",
"table",
"(",
"$",
"table",
")",
";",
"$",
"html",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"return",
"$",
"html",
";",
"}"
] | Displays plugin summaries
@param array $plugins
@return string HTML | [
"Displays",
"plugin",
"summaries"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/renderer.php#L148-L208 |
214,651 | moodle/moodle | cache/renderer.php | core_cache_renderer.definition_summaries | public function definition_summaries(array $definitions, context $context) {
$table = new html_table();
$table->head = array(
get_string('definition', 'cache'),
get_string('mode', 'cache'),
get_string('component', 'cache'),
get_string('area', 'cache'),
get_string('mappings', 'cache'),
get_string('sharing', 'cache'),
get_string('actions', 'cache'),
);
$table->colclasses = array(
'definition',
'mode',
'component',
'area',
'mappings',
'sharing',
'actions'
);
$table->data = array();
core_collator::asort_array_of_arrays_by_key($definitions, 'name');
$none = new lang_string('none', 'cache');
foreach ($definitions as $id => $definition) {
$actions = cache_administration_helper::get_definition_actions($context, $definition);
$htmlactions = array();
foreach ($actions as $action) {
$action['url']->param('definition', $id);
$htmlactions[] = $this->output->action_link($action['url'], $action['text']);
}
if (!empty($definition['mappings'])) {
$mapping = join(', ', $definition['mappings']);
} else {
$mapping = '<em>'.$none.'</em>';
}
$row = new html_table_row(array(
$definition['name'],
get_string('mode_'.$definition['mode'], 'cache'),
$definition['component'],
$definition['area'],
$mapping,
join(', ', $definition['selectedsharingoption']),
join(', ', $htmlactions)
));
$row->attributes['class'] = 'definition-'.$definition['component'].'-'.$definition['area'];
$table->data[] = $row;
}
$html = html_writer::start_tag('div', array('id' => 'core-cache-definition-summaries'));
$html .= $this->output->heading(get_string('definitionsummaries', 'cache'), 3);
$html .= html_writer::table($table);
$url = new moodle_url('/cache/admin.php', array('action' => 'rescandefinitions', 'sesskey' => sesskey()));
$link = html_writer::link($url, get_string('rescandefinitions', 'cache'));
$html .= html_writer::tag('div', $link, array('id' => 'core-cache-rescan-definitions'));
$html .= html_writer::end_tag('div');
return $html;
} | php | public function definition_summaries(array $definitions, context $context) {
$table = new html_table();
$table->head = array(
get_string('definition', 'cache'),
get_string('mode', 'cache'),
get_string('component', 'cache'),
get_string('area', 'cache'),
get_string('mappings', 'cache'),
get_string('sharing', 'cache'),
get_string('actions', 'cache'),
);
$table->colclasses = array(
'definition',
'mode',
'component',
'area',
'mappings',
'sharing',
'actions'
);
$table->data = array();
core_collator::asort_array_of_arrays_by_key($definitions, 'name');
$none = new lang_string('none', 'cache');
foreach ($definitions as $id => $definition) {
$actions = cache_administration_helper::get_definition_actions($context, $definition);
$htmlactions = array();
foreach ($actions as $action) {
$action['url']->param('definition', $id);
$htmlactions[] = $this->output->action_link($action['url'], $action['text']);
}
if (!empty($definition['mappings'])) {
$mapping = join(', ', $definition['mappings']);
} else {
$mapping = '<em>'.$none.'</em>';
}
$row = new html_table_row(array(
$definition['name'],
get_string('mode_'.$definition['mode'], 'cache'),
$definition['component'],
$definition['area'],
$mapping,
join(', ', $definition['selectedsharingoption']),
join(', ', $htmlactions)
));
$row->attributes['class'] = 'definition-'.$definition['component'].'-'.$definition['area'];
$table->data[] = $row;
}
$html = html_writer::start_tag('div', array('id' => 'core-cache-definition-summaries'));
$html .= $this->output->heading(get_string('definitionsummaries', 'cache'), 3);
$html .= html_writer::table($table);
$url = new moodle_url('/cache/admin.php', array('action' => 'rescandefinitions', 'sesskey' => sesskey()));
$link = html_writer::link($url, get_string('rescandefinitions', 'cache'));
$html .= html_writer::tag('div', $link, array('id' => 'core-cache-rescan-definitions'));
$html .= html_writer::end_tag('div');
return $html;
} | [
"public",
"function",
"definition_summaries",
"(",
"array",
"$",
"definitions",
",",
"context",
"$",
"context",
")",
"{",
"$",
"table",
"=",
"new",
"html_table",
"(",
")",
";",
"$",
"table",
"->",
"head",
"=",
"array",
"(",
"get_string",
"(",
"'definition'",
",",
"'cache'",
")",
",",
"get_string",
"(",
"'mode'",
",",
"'cache'",
")",
",",
"get_string",
"(",
"'component'",
",",
"'cache'",
")",
",",
"get_string",
"(",
"'area'",
",",
"'cache'",
")",
",",
"get_string",
"(",
"'mappings'",
",",
"'cache'",
")",
",",
"get_string",
"(",
"'sharing'",
",",
"'cache'",
")",
",",
"get_string",
"(",
"'actions'",
",",
"'cache'",
")",
",",
")",
";",
"$",
"table",
"->",
"colclasses",
"=",
"array",
"(",
"'definition'",
",",
"'mode'",
",",
"'component'",
",",
"'area'",
",",
"'mappings'",
",",
"'sharing'",
",",
"'actions'",
")",
";",
"$",
"table",
"->",
"data",
"=",
"array",
"(",
")",
";",
"core_collator",
"::",
"asort_array_of_arrays_by_key",
"(",
"$",
"definitions",
",",
"'name'",
")",
";",
"$",
"none",
"=",
"new",
"lang_string",
"(",
"'none'",
",",
"'cache'",
")",
";",
"foreach",
"(",
"$",
"definitions",
"as",
"$",
"id",
"=>",
"$",
"definition",
")",
"{",
"$",
"actions",
"=",
"cache_administration_helper",
"::",
"get_definition_actions",
"(",
"$",
"context",
",",
"$",
"definition",
")",
";",
"$",
"htmlactions",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"actions",
"as",
"$",
"action",
")",
"{",
"$",
"action",
"[",
"'url'",
"]",
"->",
"param",
"(",
"'definition'",
",",
"$",
"id",
")",
";",
"$",
"htmlactions",
"[",
"]",
"=",
"$",
"this",
"->",
"output",
"->",
"action_link",
"(",
"$",
"action",
"[",
"'url'",
"]",
",",
"$",
"action",
"[",
"'text'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"definition",
"[",
"'mappings'",
"]",
")",
")",
"{",
"$",
"mapping",
"=",
"join",
"(",
"', '",
",",
"$",
"definition",
"[",
"'mappings'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"mapping",
"=",
"'<em>'",
".",
"$",
"none",
".",
"'</em>'",
";",
"}",
"$",
"row",
"=",
"new",
"html_table_row",
"(",
"array",
"(",
"$",
"definition",
"[",
"'name'",
"]",
",",
"get_string",
"(",
"'mode_'",
".",
"$",
"definition",
"[",
"'mode'",
"]",
",",
"'cache'",
")",
",",
"$",
"definition",
"[",
"'component'",
"]",
",",
"$",
"definition",
"[",
"'area'",
"]",
",",
"$",
"mapping",
",",
"join",
"(",
"', '",
",",
"$",
"definition",
"[",
"'selectedsharingoption'",
"]",
")",
",",
"join",
"(",
"', '",
",",
"$",
"htmlactions",
")",
")",
")",
";",
"$",
"row",
"->",
"attributes",
"[",
"'class'",
"]",
"=",
"'definition-'",
".",
"$",
"definition",
"[",
"'component'",
"]",
".",
"'-'",
".",
"$",
"definition",
"[",
"'area'",
"]",
";",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"$",
"row",
";",
"}",
"$",
"html",
"=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'id'",
"=>",
"'core-cache-definition-summaries'",
")",
")",
";",
"$",
"html",
".=",
"$",
"this",
"->",
"output",
"->",
"heading",
"(",
"get_string",
"(",
"'definitionsummaries'",
",",
"'cache'",
")",
",",
"3",
")",
";",
"$",
"html",
".=",
"html_writer",
"::",
"table",
"(",
"$",
"table",
")",
";",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"'/cache/admin.php'",
",",
"array",
"(",
"'action'",
"=>",
"'rescandefinitions'",
",",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
")",
")",
";",
"$",
"link",
"=",
"html_writer",
"::",
"link",
"(",
"$",
"url",
",",
"get_string",
"(",
"'rescandefinitions'",
",",
"'cache'",
")",
")",
";",
"$",
"html",
".=",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"$",
"link",
",",
"array",
"(",
"'id'",
"=>",
"'core-cache-rescan-definitions'",
")",
")",
";",
"$",
"html",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"return",
"$",
"html",
";",
"}"
] | Displays definition summaries
@param array $definitions
@return string HTML | [
"Displays",
"definition",
"summaries"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/renderer.php#L216-L277 |
214,652 | moodle/moodle | cache/renderer.php | core_cache_renderer.mode_mappings | public function mode_mappings($applicationstore, $sessionstore, $requeststore, moodle_url $editurl) {
$table = new html_table();
$table->colclasses = array(
'mode',
'mapping',
);
$table->rowclasses = array(
'mode_application',
'mode_session',
'mode_request'
);
$table->head = array(
get_string('mode', 'cache'),
get_string('mappings', 'cache'),
);
$table->data = array(
array(get_string('mode_'.cache_store::MODE_APPLICATION, 'cache'), $applicationstore),
array(get_string('mode_'.cache_store::MODE_SESSION, 'cache'), $sessionstore),
array(get_string('mode_'.cache_store::MODE_REQUEST, 'cache'), $requeststore)
);
$html = html_writer::start_tag('div', array('id' => 'core-cache-mode-mappings'));
$html .= $this->output->heading(get_string('defaultmappings', 'cache'), 3);
$html .= html_writer::table($table);
$link = html_writer::link($editurl, get_string('editmappings', 'cache'));
$html .= html_writer::tag('div', $link, array('class' => 'edit-link'));
$html .= html_writer::end_tag('div');
return $html;
} | php | public function mode_mappings($applicationstore, $sessionstore, $requeststore, moodle_url $editurl) {
$table = new html_table();
$table->colclasses = array(
'mode',
'mapping',
);
$table->rowclasses = array(
'mode_application',
'mode_session',
'mode_request'
);
$table->head = array(
get_string('mode', 'cache'),
get_string('mappings', 'cache'),
);
$table->data = array(
array(get_string('mode_'.cache_store::MODE_APPLICATION, 'cache'), $applicationstore),
array(get_string('mode_'.cache_store::MODE_SESSION, 'cache'), $sessionstore),
array(get_string('mode_'.cache_store::MODE_REQUEST, 'cache'), $requeststore)
);
$html = html_writer::start_tag('div', array('id' => 'core-cache-mode-mappings'));
$html .= $this->output->heading(get_string('defaultmappings', 'cache'), 3);
$html .= html_writer::table($table);
$link = html_writer::link($editurl, get_string('editmappings', 'cache'));
$html .= html_writer::tag('div', $link, array('class' => 'edit-link'));
$html .= html_writer::end_tag('div');
return $html;
} | [
"public",
"function",
"mode_mappings",
"(",
"$",
"applicationstore",
",",
"$",
"sessionstore",
",",
"$",
"requeststore",
",",
"moodle_url",
"$",
"editurl",
")",
"{",
"$",
"table",
"=",
"new",
"html_table",
"(",
")",
";",
"$",
"table",
"->",
"colclasses",
"=",
"array",
"(",
"'mode'",
",",
"'mapping'",
",",
")",
";",
"$",
"table",
"->",
"rowclasses",
"=",
"array",
"(",
"'mode_application'",
",",
"'mode_session'",
",",
"'mode_request'",
")",
";",
"$",
"table",
"->",
"head",
"=",
"array",
"(",
"get_string",
"(",
"'mode'",
",",
"'cache'",
")",
",",
"get_string",
"(",
"'mappings'",
",",
"'cache'",
")",
",",
")",
";",
"$",
"table",
"->",
"data",
"=",
"array",
"(",
"array",
"(",
"get_string",
"(",
"'mode_'",
".",
"cache_store",
"::",
"MODE_APPLICATION",
",",
"'cache'",
")",
",",
"$",
"applicationstore",
")",
",",
"array",
"(",
"get_string",
"(",
"'mode_'",
".",
"cache_store",
"::",
"MODE_SESSION",
",",
"'cache'",
")",
",",
"$",
"sessionstore",
")",
",",
"array",
"(",
"get_string",
"(",
"'mode_'",
".",
"cache_store",
"::",
"MODE_REQUEST",
",",
"'cache'",
")",
",",
"$",
"requeststore",
")",
")",
";",
"$",
"html",
"=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'id'",
"=>",
"'core-cache-mode-mappings'",
")",
")",
";",
"$",
"html",
".=",
"$",
"this",
"->",
"output",
"->",
"heading",
"(",
"get_string",
"(",
"'defaultmappings'",
",",
"'cache'",
")",
",",
"3",
")",
";",
"$",
"html",
".=",
"html_writer",
"::",
"table",
"(",
"$",
"table",
")",
";",
"$",
"link",
"=",
"html_writer",
"::",
"link",
"(",
"$",
"editurl",
",",
"get_string",
"(",
"'editmappings'",
",",
"'cache'",
")",
")",
";",
"$",
"html",
".=",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"$",
"link",
",",
"array",
"(",
"'class'",
"=>",
"'edit-link'",
")",
")",
";",
"$",
"html",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"return",
"$",
"html",
";",
"}"
] | Displays mode mappings
@param string $applicationstore
@param string $sessionstore
@param string $requeststore
@param moodle_url $editurl
@return string HTML | [
"Displays",
"mode",
"mappings"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/renderer.php#L288-L316 |
214,653 | moodle/moodle | cache/renderer.php | core_cache_renderer.lock_summaries | public function lock_summaries(array $locks) {
$table = new html_table();
$table->colclasses = array(
'name',
'type',
'default',
'uses',
'actions'
);
$table->rowclasses = array(
'lock_name',
'lock_type',
'lock_default',
'lock_uses',
'lock_actions',
);
$table->head = array(
get_string('lockname', 'cache'),
get_string('locktype', 'cache'),
get_string('lockdefault', 'cache'),
get_string('lockuses', 'cache'),
get_string('actions', 'cache')
);
$table->data = array();
$tick = $this->output->pix_icon('i/valid', '');
foreach ($locks as $lock) {
$actions = array();
if ($lock['uses'] === 0 && !$lock['default']) {
$url = new moodle_url('/cache/admin.php', array('lock' => $lock['name'], 'action' => 'deletelock', 'sesskey' => sesskey()));
$actions[] = html_writer::link($url, get_string('delete', 'cache'));
}
$table->data[] = new html_table_row(array(
new html_table_cell($lock['name']),
new html_table_cell($lock['type']),
new html_table_cell($lock['default'] ? $tick : ''),
new html_table_cell($lock['uses']),
new html_table_cell(join(' ', $actions))
));
}
$url = new moodle_url('/cache/admin.php', array('action' => 'newlockinstance', 'sesskey' => sesskey()));
$select = new single_select($url, 'lock', cache_administration_helper::get_addable_lock_options());
$select->label = get_string('addnewlockinstance', 'cache');
$html = html_writer::start_tag('div', array('id' => 'core-cache-lock-summary'));
$html .= $this->output->heading(get_string('locksummary', 'cache'), 3);
$html .= html_writer::table($table);
$html .= html_writer::tag('div', $this->output->render($select), array('class' => 'new-instance'));
$html .= html_writer::end_tag('div');
return $html;
} | php | public function lock_summaries(array $locks) {
$table = new html_table();
$table->colclasses = array(
'name',
'type',
'default',
'uses',
'actions'
);
$table->rowclasses = array(
'lock_name',
'lock_type',
'lock_default',
'lock_uses',
'lock_actions',
);
$table->head = array(
get_string('lockname', 'cache'),
get_string('locktype', 'cache'),
get_string('lockdefault', 'cache'),
get_string('lockuses', 'cache'),
get_string('actions', 'cache')
);
$table->data = array();
$tick = $this->output->pix_icon('i/valid', '');
foreach ($locks as $lock) {
$actions = array();
if ($lock['uses'] === 0 && !$lock['default']) {
$url = new moodle_url('/cache/admin.php', array('lock' => $lock['name'], 'action' => 'deletelock', 'sesskey' => sesskey()));
$actions[] = html_writer::link($url, get_string('delete', 'cache'));
}
$table->data[] = new html_table_row(array(
new html_table_cell($lock['name']),
new html_table_cell($lock['type']),
new html_table_cell($lock['default'] ? $tick : ''),
new html_table_cell($lock['uses']),
new html_table_cell(join(' ', $actions))
));
}
$url = new moodle_url('/cache/admin.php', array('action' => 'newlockinstance', 'sesskey' => sesskey()));
$select = new single_select($url, 'lock', cache_administration_helper::get_addable_lock_options());
$select->label = get_string('addnewlockinstance', 'cache');
$html = html_writer::start_tag('div', array('id' => 'core-cache-lock-summary'));
$html .= $this->output->heading(get_string('locksummary', 'cache'), 3);
$html .= html_writer::table($table);
$html .= html_writer::tag('div', $this->output->render($select), array('class' => 'new-instance'));
$html .= html_writer::end_tag('div');
return $html;
} | [
"public",
"function",
"lock_summaries",
"(",
"array",
"$",
"locks",
")",
"{",
"$",
"table",
"=",
"new",
"html_table",
"(",
")",
";",
"$",
"table",
"->",
"colclasses",
"=",
"array",
"(",
"'name'",
",",
"'type'",
",",
"'default'",
",",
"'uses'",
",",
"'actions'",
")",
";",
"$",
"table",
"->",
"rowclasses",
"=",
"array",
"(",
"'lock_name'",
",",
"'lock_type'",
",",
"'lock_default'",
",",
"'lock_uses'",
",",
"'lock_actions'",
",",
")",
";",
"$",
"table",
"->",
"head",
"=",
"array",
"(",
"get_string",
"(",
"'lockname'",
",",
"'cache'",
")",
",",
"get_string",
"(",
"'locktype'",
",",
"'cache'",
")",
",",
"get_string",
"(",
"'lockdefault'",
",",
"'cache'",
")",
",",
"get_string",
"(",
"'lockuses'",
",",
"'cache'",
")",
",",
"get_string",
"(",
"'actions'",
",",
"'cache'",
")",
")",
";",
"$",
"table",
"->",
"data",
"=",
"array",
"(",
")",
";",
"$",
"tick",
"=",
"$",
"this",
"->",
"output",
"->",
"pix_icon",
"(",
"'i/valid'",
",",
"''",
")",
";",
"foreach",
"(",
"$",
"locks",
"as",
"$",
"lock",
")",
"{",
"$",
"actions",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"lock",
"[",
"'uses'",
"]",
"===",
"0",
"&&",
"!",
"$",
"lock",
"[",
"'default'",
"]",
")",
"{",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"'/cache/admin.php'",
",",
"array",
"(",
"'lock'",
"=>",
"$",
"lock",
"[",
"'name'",
"]",
",",
"'action'",
"=>",
"'deletelock'",
",",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
")",
")",
";",
"$",
"actions",
"[",
"]",
"=",
"html_writer",
"::",
"link",
"(",
"$",
"url",
",",
"get_string",
"(",
"'delete'",
",",
"'cache'",
")",
")",
";",
"}",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"new",
"html_table_row",
"(",
"array",
"(",
"new",
"html_table_cell",
"(",
"$",
"lock",
"[",
"'name'",
"]",
")",
",",
"new",
"html_table_cell",
"(",
"$",
"lock",
"[",
"'type'",
"]",
")",
",",
"new",
"html_table_cell",
"(",
"$",
"lock",
"[",
"'default'",
"]",
"?",
"$",
"tick",
":",
"''",
")",
",",
"new",
"html_table_cell",
"(",
"$",
"lock",
"[",
"'uses'",
"]",
")",
",",
"new",
"html_table_cell",
"(",
"join",
"(",
"' '",
",",
"$",
"actions",
")",
")",
")",
")",
";",
"}",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"'/cache/admin.php'",
",",
"array",
"(",
"'action'",
"=>",
"'newlockinstance'",
",",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
")",
")",
";",
"$",
"select",
"=",
"new",
"single_select",
"(",
"$",
"url",
",",
"'lock'",
",",
"cache_administration_helper",
"::",
"get_addable_lock_options",
"(",
")",
")",
";",
"$",
"select",
"->",
"label",
"=",
"get_string",
"(",
"'addnewlockinstance'",
",",
"'cache'",
")",
";",
"$",
"html",
"=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'id'",
"=>",
"'core-cache-lock-summary'",
")",
")",
";",
"$",
"html",
".=",
"$",
"this",
"->",
"output",
"->",
"heading",
"(",
"get_string",
"(",
"'locksummary'",
",",
"'cache'",
")",
",",
"3",
")",
";",
"$",
"html",
".=",
"html_writer",
"::",
"table",
"(",
"$",
"table",
")",
";",
"$",
"html",
".=",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"$",
"this",
"->",
"output",
"->",
"render",
"(",
"$",
"select",
")",
",",
"array",
"(",
"'class'",
"=>",
"'new-instance'",
")",
")",
";",
"$",
"html",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"return",
"$",
"html",
";",
"}"
] | Display basic information about lock instances.
@todo Add some actions so that people can configure lock instances.
@param array $locks
@return string | [
"Display",
"basic",
"information",
"about",
"lock",
"instances",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/renderer.php#L326-L376 |
214,654 | moodle/moodle | cache/renderer.php | core_cache_renderer.notifications | public function notifications(array $notifications = array()) {
if (count($notifications) === 0) {
// There are no notifications to render.
return '';
}
$html = html_writer::start_div('notifications');
foreach ($notifications as $notification) {
list($message, $notifysuccess) = $notification;
$html .= $this->notification($message, ($notifysuccess) ? 'notifysuccess' : 'notifyproblem');
}
$html .= html_writer::end_div();
return $html;
} | php | public function notifications(array $notifications = array()) {
if (count($notifications) === 0) {
// There are no notifications to render.
return '';
}
$html = html_writer::start_div('notifications');
foreach ($notifications as $notification) {
list($message, $notifysuccess) = $notification;
$html .= $this->notification($message, ($notifysuccess) ? 'notifysuccess' : 'notifyproblem');
}
$html .= html_writer::end_div();
return $html;
} | [
"public",
"function",
"notifications",
"(",
"array",
"$",
"notifications",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"notifications",
")",
"===",
"0",
")",
"{",
"// There are no notifications to render.",
"return",
"''",
";",
"}",
"$",
"html",
"=",
"html_writer",
"::",
"start_div",
"(",
"'notifications'",
")",
";",
"foreach",
"(",
"$",
"notifications",
"as",
"$",
"notification",
")",
"{",
"list",
"(",
"$",
"message",
",",
"$",
"notifysuccess",
")",
"=",
"$",
"notification",
";",
"$",
"html",
".=",
"$",
"this",
"->",
"notification",
"(",
"$",
"message",
",",
"(",
"$",
"notifysuccess",
")",
"?",
"'notifysuccess'",
":",
"'notifyproblem'",
")",
";",
"}",
"$",
"html",
".=",
"html_writer",
"::",
"end_div",
"(",
")",
";",
"return",
"$",
"html",
";",
"}"
] | Renders an array of notifications for the cache configuration screen.
Takes an array of notifications with the form:
$notifications = array(
array('This is a success message', true),
array('This is a failure message', false),
);
@param array $notifications
@return string | [
"Renders",
"an",
"array",
"of",
"notifications",
"for",
"the",
"cache",
"configuration",
"screen",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/renderer.php#L390-L402 |
214,655 | moodle/moodle | auth/cas/CAS/CAS/ProxyChain.php | CAS_ProxyChain.matches | public function matches(array $list)
{
$list = array_values($list); // Ensure that we have an indexed array
if ($this->isSizeValid($list)) {
$mismatch = false;
foreach ($this->chain as $i => $search) {
$proxy_url = $list[$i];
if (preg_match('/^\/.*\/[ixASUXu]*$/s', $search)) {
if (preg_match($search, $proxy_url)) {
phpCAS::trace(
"Found regexp " . $search . " matching " . $proxy_url
);
} else {
phpCAS::trace(
"No regexp match " . $search . " != " . $proxy_url
);
$mismatch = true;
break;
}
} else {
if (strncasecmp($search, $proxy_url, strlen($search)) == 0) {
phpCAS::trace(
"Found string " . $search . " matching " . $proxy_url
);
} else {
phpCAS::trace(
"No match " . $search . " != " . $proxy_url
);
$mismatch = true;
break;
}
}
}
if (!$mismatch) {
phpCAS::trace("Proxy chain matches");
return true;
}
} else {
phpCAS::trace("Proxy chain skipped: size mismatch");
}
return false;
} | php | public function matches(array $list)
{
$list = array_values($list); // Ensure that we have an indexed array
if ($this->isSizeValid($list)) {
$mismatch = false;
foreach ($this->chain as $i => $search) {
$proxy_url = $list[$i];
if (preg_match('/^\/.*\/[ixASUXu]*$/s', $search)) {
if (preg_match($search, $proxy_url)) {
phpCAS::trace(
"Found regexp " . $search . " matching " . $proxy_url
);
} else {
phpCAS::trace(
"No regexp match " . $search . " != " . $proxy_url
);
$mismatch = true;
break;
}
} else {
if (strncasecmp($search, $proxy_url, strlen($search)) == 0) {
phpCAS::trace(
"Found string " . $search . " matching " . $proxy_url
);
} else {
phpCAS::trace(
"No match " . $search . " != " . $proxy_url
);
$mismatch = true;
break;
}
}
}
if (!$mismatch) {
phpCAS::trace("Proxy chain matches");
return true;
}
} else {
phpCAS::trace("Proxy chain skipped: size mismatch");
}
return false;
} | [
"public",
"function",
"matches",
"(",
"array",
"$",
"list",
")",
"{",
"$",
"list",
"=",
"array_values",
"(",
"$",
"list",
")",
";",
"// Ensure that we have an indexed array",
"if",
"(",
"$",
"this",
"->",
"isSizeValid",
"(",
"$",
"list",
")",
")",
"{",
"$",
"mismatch",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"chain",
"as",
"$",
"i",
"=>",
"$",
"search",
")",
"{",
"$",
"proxy_url",
"=",
"$",
"list",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"preg_match",
"(",
"'/^\\/.*\\/[ixASUXu]*$/s'",
",",
"$",
"search",
")",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"search",
",",
"$",
"proxy_url",
")",
")",
"{",
"phpCAS",
"::",
"trace",
"(",
"\"Found regexp \"",
".",
"$",
"search",
".",
"\" matching \"",
".",
"$",
"proxy_url",
")",
";",
"}",
"else",
"{",
"phpCAS",
"::",
"trace",
"(",
"\"No regexp match \"",
".",
"$",
"search",
".",
"\" != \"",
".",
"$",
"proxy_url",
")",
";",
"$",
"mismatch",
"=",
"true",
";",
"break",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"strncasecmp",
"(",
"$",
"search",
",",
"$",
"proxy_url",
",",
"strlen",
"(",
"$",
"search",
")",
")",
"==",
"0",
")",
"{",
"phpCAS",
"::",
"trace",
"(",
"\"Found string \"",
".",
"$",
"search",
".",
"\" matching \"",
".",
"$",
"proxy_url",
")",
";",
"}",
"else",
"{",
"phpCAS",
"::",
"trace",
"(",
"\"No match \"",
".",
"$",
"search",
".",
"\" != \"",
".",
"$",
"proxy_url",
")",
";",
"$",
"mismatch",
"=",
"true",
";",
"break",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"$",
"mismatch",
")",
"{",
"phpCAS",
"::",
"trace",
"(",
"\"Proxy chain matches\"",
")",
";",
"return",
"true",
";",
"}",
"}",
"else",
"{",
"phpCAS",
"::",
"trace",
"(",
"\"Proxy chain skipped: size mismatch\"",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Match a list of proxies.
@param array $list The list of proxies in front of this service.
@return bool | [
"Match",
"a",
"list",
"of",
"proxies",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/auth/cas/CAS/CAS/ProxyChain.php#L73-L114 |
214,656 | moodle/moodle | admin/roles/classes/privacy/provider.php | provider.get_contexts_for_userid | public static function get_contexts_for_userid(int $userid) : contextlist {
global $DB;
$contextlist = new contextlist();
// The role_capabilities table contains user data.
$contexts = [
CONTEXT_SYSTEM,
CONTEXT_USER,
CONTEXT_COURSECAT,
CONTEXT_COURSE,
CONTEXT_MODULE,
CONTEXT_BLOCK
];
list($insql, $inparams) = $DB->get_in_or_equal($contexts, SQL_PARAMS_NAMED);
$sql = "SELECT ctx.id
FROM {context} ctx
JOIN {role_capabilities} rc
ON rc.contextid = ctx.id
AND ((ctx.contextlevel {$insql} AND rc.modifierid = :modifierid)
OR (ctx.contextlevel = :contextlevel AND ctx.instanceid = :userid))";
$params = [
'modifierid' => $userid,
'contextlevel' => CONTEXT_USER,
'userid' => $userid
];
$params += $inparams;
$contextlist->add_from_sql($sql, $params);
// The role_assignments table contains user data.
$contexts = [
CONTEXT_SYSTEM,
CONTEXT_USER,
CONTEXT_COURSECAT,
CONTEXT_COURSE,
CONTEXT_MODULE,
CONTEXT_BLOCK
];
list($insql, $inparams) = $DB->get_in_or_equal($contexts, SQL_PARAMS_NAMED);
$params = [
'userid' => $userid,
'modifierid' => $userid
];
$params += $inparams;
$sql = "SELECT ctx.id
FROM {role_assignments} ra
JOIN {context} ctx
ON ctx.id = ra.contextid
AND ctx.contextlevel {$insql}
WHERE (ra.userid = :userid
OR ra.modifierid = :modifierid)
AND ra.component != 'tool_cohortroles'";
$contextlist->add_from_sql($sql, $params);
return $contextlist;
} | php | public static function get_contexts_for_userid(int $userid) : contextlist {
global $DB;
$contextlist = new contextlist();
// The role_capabilities table contains user data.
$contexts = [
CONTEXT_SYSTEM,
CONTEXT_USER,
CONTEXT_COURSECAT,
CONTEXT_COURSE,
CONTEXT_MODULE,
CONTEXT_BLOCK
];
list($insql, $inparams) = $DB->get_in_or_equal($contexts, SQL_PARAMS_NAMED);
$sql = "SELECT ctx.id
FROM {context} ctx
JOIN {role_capabilities} rc
ON rc.contextid = ctx.id
AND ((ctx.contextlevel {$insql} AND rc.modifierid = :modifierid)
OR (ctx.contextlevel = :contextlevel AND ctx.instanceid = :userid))";
$params = [
'modifierid' => $userid,
'contextlevel' => CONTEXT_USER,
'userid' => $userid
];
$params += $inparams;
$contextlist->add_from_sql($sql, $params);
// The role_assignments table contains user data.
$contexts = [
CONTEXT_SYSTEM,
CONTEXT_USER,
CONTEXT_COURSECAT,
CONTEXT_COURSE,
CONTEXT_MODULE,
CONTEXT_BLOCK
];
list($insql, $inparams) = $DB->get_in_or_equal($contexts, SQL_PARAMS_NAMED);
$params = [
'userid' => $userid,
'modifierid' => $userid
];
$params += $inparams;
$sql = "SELECT ctx.id
FROM {role_assignments} ra
JOIN {context} ctx
ON ctx.id = ra.contextid
AND ctx.contextlevel {$insql}
WHERE (ra.userid = :userid
OR ra.modifierid = :modifierid)
AND ra.component != 'tool_cohortroles'";
$contextlist->add_from_sql($sql, $params);
return $contextlist;
} | [
"public",
"static",
"function",
"get_contexts_for_userid",
"(",
"int",
"$",
"userid",
")",
":",
"contextlist",
"{",
"global",
"$",
"DB",
";",
"$",
"contextlist",
"=",
"new",
"contextlist",
"(",
")",
";",
"// The role_capabilities table contains user data.",
"$",
"contexts",
"=",
"[",
"CONTEXT_SYSTEM",
",",
"CONTEXT_USER",
",",
"CONTEXT_COURSECAT",
",",
"CONTEXT_COURSE",
",",
"CONTEXT_MODULE",
",",
"CONTEXT_BLOCK",
"]",
";",
"list",
"(",
"$",
"insql",
",",
"$",
"inparams",
")",
"=",
"$",
"DB",
"->",
"get_in_or_equal",
"(",
"$",
"contexts",
",",
"SQL_PARAMS_NAMED",
")",
";",
"$",
"sql",
"=",
"\"SELECT ctx.id\n FROM {context} ctx\n JOIN {role_capabilities} rc\n ON rc.contextid = ctx.id\n AND ((ctx.contextlevel {$insql} AND rc.modifierid = :modifierid)\n OR (ctx.contextlevel = :contextlevel AND ctx.instanceid = :userid))\"",
";",
"$",
"params",
"=",
"[",
"'modifierid'",
"=>",
"$",
"userid",
",",
"'contextlevel'",
"=>",
"CONTEXT_USER",
",",
"'userid'",
"=>",
"$",
"userid",
"]",
";",
"$",
"params",
"+=",
"$",
"inparams",
";",
"$",
"contextlist",
"->",
"add_from_sql",
"(",
"$",
"sql",
",",
"$",
"params",
")",
";",
"// The role_assignments table contains user data.",
"$",
"contexts",
"=",
"[",
"CONTEXT_SYSTEM",
",",
"CONTEXT_USER",
",",
"CONTEXT_COURSECAT",
",",
"CONTEXT_COURSE",
",",
"CONTEXT_MODULE",
",",
"CONTEXT_BLOCK",
"]",
";",
"list",
"(",
"$",
"insql",
",",
"$",
"inparams",
")",
"=",
"$",
"DB",
"->",
"get_in_or_equal",
"(",
"$",
"contexts",
",",
"SQL_PARAMS_NAMED",
")",
";",
"$",
"params",
"=",
"[",
"'userid'",
"=>",
"$",
"userid",
",",
"'modifierid'",
"=>",
"$",
"userid",
"]",
";",
"$",
"params",
"+=",
"$",
"inparams",
";",
"$",
"sql",
"=",
"\"SELECT ctx.id\n FROM {role_assignments} ra\n JOIN {context} ctx\n ON ctx.id = ra.contextid\n AND ctx.contextlevel {$insql}\n WHERE (ra.userid = :userid\n OR ra.modifierid = :modifierid)\n AND ra.component != 'tool_cohortroles'\"",
";",
"$",
"contextlist",
"->",
"add_from_sql",
"(",
"$",
"sql",
",",
"$",
"params",
")",
";",
"return",
"$",
"contextlist",
";",
"}"
] | Return all contexts for this userid.
@param int $userid The user ID.
@return contextlist The list of context IDs. | [
"Return",
"all",
"contexts",
"for",
"this",
"userid",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/roles/classes/privacy/provider.php#L103-L159 |
214,657 | moodle/moodle | admin/roles/classes/privacy/provider.php | provider.export_user_role_to_cohort | public static function export_user_role_to_cohort(int $userid) {
global $DB;
$rolesnames = self::get_roles_name();
$sql = "SELECT ra.id, ra.contextid, ra.roleid, ra.userid, ra.timemodified, ra.modifierid, r.id as roleid
FROM {role_assignments} ra
JOIN {context} ctx
ON ctx.id = ra.contextid
AND ctx.contextlevel = :contextlevel
AND ra.component = 'tool_cohortroles'
JOIN {role} r
ON r.id = ra.roleid
WHERE ctx.instanceid = :instanceid
OR ra.userid = :userid";
$params = ['userid' => $userid, 'instanceid' => $userid, 'contextlevel' => CONTEXT_USER];
$assignments = $DB->get_recordset_sql($sql, $params);
foreach ($assignments as $assignment) {
$alldata[$assignment->contextid][$rolesnames[$assignment->roleid]][] = (object)[
'timemodified' => transform::datetime($assignment->timemodified),
'userid' => transform::user($assignment->userid),
'modifierid' => transform::user($assignment->modifierid)
];
}
$assignments->close();
if (!empty($alldata)) {
array_walk($alldata, function($roledata, $contextid) {
$context = \context::instance_by_id($contextid);
array_walk($roledata, function($data, $rolename) use ($context) {
writer::with_context($context)->export_related_data(
[get_string('privacy:metadata:role_cohortroles', 'core_role'), $rolename], 'cohortroles',
(object)$data);
});
});
}
} | php | public static function export_user_role_to_cohort(int $userid) {
global $DB;
$rolesnames = self::get_roles_name();
$sql = "SELECT ra.id, ra.contextid, ra.roleid, ra.userid, ra.timemodified, ra.modifierid, r.id as roleid
FROM {role_assignments} ra
JOIN {context} ctx
ON ctx.id = ra.contextid
AND ctx.contextlevel = :contextlevel
AND ra.component = 'tool_cohortroles'
JOIN {role} r
ON r.id = ra.roleid
WHERE ctx.instanceid = :instanceid
OR ra.userid = :userid";
$params = ['userid' => $userid, 'instanceid' => $userid, 'contextlevel' => CONTEXT_USER];
$assignments = $DB->get_recordset_sql($sql, $params);
foreach ($assignments as $assignment) {
$alldata[$assignment->contextid][$rolesnames[$assignment->roleid]][] = (object)[
'timemodified' => transform::datetime($assignment->timemodified),
'userid' => transform::user($assignment->userid),
'modifierid' => transform::user($assignment->modifierid)
];
}
$assignments->close();
if (!empty($alldata)) {
array_walk($alldata, function($roledata, $contextid) {
$context = \context::instance_by_id($contextid);
array_walk($roledata, function($data, $rolename) use ($context) {
writer::with_context($context)->export_related_data(
[get_string('privacy:metadata:role_cohortroles', 'core_role'), $rolename], 'cohortroles',
(object)$data);
});
});
}
} | [
"public",
"static",
"function",
"export_user_role_to_cohort",
"(",
"int",
"$",
"userid",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"rolesnames",
"=",
"self",
"::",
"get_roles_name",
"(",
")",
";",
"$",
"sql",
"=",
"\"SELECT ra.id, ra.contextid, ra.roleid, ra.userid, ra.timemodified, ra.modifierid, r.id as roleid\n FROM {role_assignments} ra\n JOIN {context} ctx\n ON ctx.id = ra.contextid\n AND ctx.contextlevel = :contextlevel\n AND ra.component = 'tool_cohortroles'\n JOIN {role} r\n ON r.id = ra.roleid\n WHERE ctx.instanceid = :instanceid\n OR ra.userid = :userid\"",
";",
"$",
"params",
"=",
"[",
"'userid'",
"=>",
"$",
"userid",
",",
"'instanceid'",
"=>",
"$",
"userid",
",",
"'contextlevel'",
"=>",
"CONTEXT_USER",
"]",
";",
"$",
"assignments",
"=",
"$",
"DB",
"->",
"get_recordset_sql",
"(",
"$",
"sql",
",",
"$",
"params",
")",
";",
"foreach",
"(",
"$",
"assignments",
"as",
"$",
"assignment",
")",
"{",
"$",
"alldata",
"[",
"$",
"assignment",
"->",
"contextid",
"]",
"[",
"$",
"rolesnames",
"[",
"$",
"assignment",
"->",
"roleid",
"]",
"]",
"[",
"]",
"=",
"(",
"object",
")",
"[",
"'timemodified'",
"=>",
"transform",
"::",
"datetime",
"(",
"$",
"assignment",
"->",
"timemodified",
")",
",",
"'userid'",
"=>",
"transform",
"::",
"user",
"(",
"$",
"assignment",
"->",
"userid",
")",
",",
"'modifierid'",
"=>",
"transform",
"::",
"user",
"(",
"$",
"assignment",
"->",
"modifierid",
")",
"]",
";",
"}",
"$",
"assignments",
"->",
"close",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"alldata",
")",
")",
"{",
"array_walk",
"(",
"$",
"alldata",
",",
"function",
"(",
"$",
"roledata",
",",
"$",
"contextid",
")",
"{",
"$",
"context",
"=",
"\\",
"context",
"::",
"instance_by_id",
"(",
"$",
"contextid",
")",
";",
"array_walk",
"(",
"$",
"roledata",
",",
"function",
"(",
"$",
"data",
",",
"$",
"rolename",
")",
"use",
"(",
"$",
"context",
")",
"{",
"writer",
"::",
"with_context",
"(",
"$",
"context",
")",
"->",
"export_related_data",
"(",
"[",
"get_string",
"(",
"'privacy:metadata:role_cohortroles'",
",",
"'core_role'",
")",
",",
"$",
"rolename",
"]",
",",
"'cohortroles'",
",",
"(",
"object",
")",
"$",
"data",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}",
"}"
] | Exports the data relating to tool_cohortroles component on role assignments by
Assign user roles to cohort feature.
@param int $userid The user ID. | [
"Exports",
"the",
"data",
"relating",
"to",
"tool_cohortroles",
"component",
"on",
"role",
"assignments",
"by",
"Assign",
"user",
"roles",
"to",
"cohort",
"feature",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/roles/classes/privacy/provider.php#L318-L352 |
214,658 | moodle/moodle | admin/roles/classes/privacy/provider.php | provider.delete_data_for_user | public static function delete_data_for_user(approved_contextlist $contextlist) {
global $DB;
// Don't remove data from role_capabilities.
// Because this data affects the whole Moodle, there are override capabilities.
// Don't belong to the modifier user.
// Remove data from role_assignments.
if (empty($contextlist->count())) {
return;
}
$userid = $contextlist->get_user()->id;
$contextids = $contextlist->get_contextids();
list($contextsql, $contextparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED);
$params = ['userid' => $userid] + $contextparams;
// Only delete the roles assignments where the user is assigned in all contexts.
$DB->delete_records_select('role_assignments',
"userid = :userid AND contextid {$contextsql}", $params);
} | php | public static function delete_data_for_user(approved_contextlist $contextlist) {
global $DB;
// Don't remove data from role_capabilities.
// Because this data affects the whole Moodle, there are override capabilities.
// Don't belong to the modifier user.
// Remove data from role_assignments.
if (empty($contextlist->count())) {
return;
}
$userid = $contextlist->get_user()->id;
$contextids = $contextlist->get_contextids();
list($contextsql, $contextparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED);
$params = ['userid' => $userid] + $contextparams;
// Only delete the roles assignments where the user is assigned in all contexts.
$DB->delete_records_select('role_assignments',
"userid = :userid AND contextid {$contextsql}", $params);
} | [
"public",
"static",
"function",
"delete_data_for_user",
"(",
"approved_contextlist",
"$",
"contextlist",
")",
"{",
"global",
"$",
"DB",
";",
"// Don't remove data from role_capabilities.",
"// Because this data affects the whole Moodle, there are override capabilities.",
"// Don't belong to the modifier user.",
"// Remove data from role_assignments.",
"if",
"(",
"empty",
"(",
"$",
"contextlist",
"->",
"count",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"$",
"userid",
"=",
"$",
"contextlist",
"->",
"get_user",
"(",
")",
"->",
"id",
";",
"$",
"contextids",
"=",
"$",
"contextlist",
"->",
"get_contextids",
"(",
")",
";",
"list",
"(",
"$",
"contextsql",
",",
"$",
"contextparams",
")",
"=",
"$",
"DB",
"->",
"get_in_or_equal",
"(",
"$",
"contextids",
",",
"SQL_PARAMS_NAMED",
")",
";",
"$",
"params",
"=",
"[",
"'userid'",
"=>",
"$",
"userid",
"]",
"+",
"$",
"contextparams",
";",
"// Only delete the roles assignments where the user is assigned in all contexts.",
"$",
"DB",
"->",
"delete_records_select",
"(",
"'role_assignments'",
",",
"\"userid = :userid AND contextid {$contextsql}\"",
",",
"$",
"params",
")",
";",
"}"
] | Delete all user data for this user only.
@param approved_contextlist $contextlist The list of approved contexts for a user. | [
"Delete",
"all",
"user",
"data",
"for",
"this",
"user",
"only",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/roles/classes/privacy/provider.php#L399-L419 |
214,659 | moodle/moodle | admin/roles/classes/privacy/provider.php | provider.get_roles_name | protected static function get_roles_name() {
$roles = role_fix_names(get_all_roles(), \context_system::instance(), ROLENAME_ORIGINAL);
$rolesnames = array();
foreach ($roles as $role) {
$rolesnames[$role->id] = $role->localname;
}
return $rolesnames;
} | php | protected static function get_roles_name() {
$roles = role_fix_names(get_all_roles(), \context_system::instance(), ROLENAME_ORIGINAL);
$rolesnames = array();
foreach ($roles as $role) {
$rolesnames[$role->id] = $role->localname;
}
return $rolesnames;
} | [
"protected",
"static",
"function",
"get_roles_name",
"(",
")",
"{",
"$",
"roles",
"=",
"role_fix_names",
"(",
"get_all_roles",
"(",
")",
",",
"\\",
"context_system",
"::",
"instance",
"(",
")",
",",
"ROLENAME_ORIGINAL",
")",
";",
"$",
"rolesnames",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"roles",
"as",
"$",
"role",
")",
"{",
"$",
"rolesnames",
"[",
"$",
"role",
"->",
"id",
"]",
"=",
"$",
"role",
"->",
"localname",
";",
"}",
"return",
"$",
"rolesnames",
";",
"}"
] | Get all the localised roles name in a simple array.
@return array Array of name of the roles by roleid. | [
"Get",
"all",
"the",
"localised",
"roles",
"name",
"in",
"a",
"simple",
"array",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/roles/classes/privacy/provider.php#L437-L444 |
214,660 | moodle/moodle | admin/roles/classes/privacy/provider.php | provider.get_permissions_name | protected static function get_permissions_name() {
$strpermissions = array(
CAP_INHERIT => get_string('inherit', 'role'),
CAP_ALLOW => get_string('allow', 'role'),
CAP_PREVENT => get_string('prevent', 'role'),
CAP_PROHIBIT => get_string('prohibit', 'role')
);
return $strpermissions;
} | php | protected static function get_permissions_name() {
$strpermissions = array(
CAP_INHERIT => get_string('inherit', 'role'),
CAP_ALLOW => get_string('allow', 'role'),
CAP_PREVENT => get_string('prevent', 'role'),
CAP_PROHIBIT => get_string('prohibit', 'role')
);
return $strpermissions;
} | [
"protected",
"static",
"function",
"get_permissions_name",
"(",
")",
"{",
"$",
"strpermissions",
"=",
"array",
"(",
"CAP_INHERIT",
"=>",
"get_string",
"(",
"'inherit'",
",",
"'role'",
")",
",",
"CAP_ALLOW",
"=>",
"get_string",
"(",
"'allow'",
",",
"'role'",
")",
",",
"CAP_PREVENT",
"=>",
"get_string",
"(",
"'prevent'",
",",
"'role'",
")",
",",
"CAP_PROHIBIT",
"=>",
"get_string",
"(",
"'prohibit'",
",",
"'role'",
")",
")",
";",
"return",
"$",
"strpermissions",
";",
"}"
] | Get all the permissions name in a simple array.
@return array Array of permissions name. | [
"Get",
"all",
"the",
"permissions",
"name",
"in",
"a",
"simple",
"array",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/roles/classes/privacy/provider.php#L450-L458 |
214,661 | moodle/moodle | webservice/xmlrpc/locallib.php | webservice_xmlrpc_server.prepare_response | protected function prepare_response() {
try {
if (!empty($this->function->returns_desc)) {
$validatedvalues = external_api::clean_returnvalue($this->function->returns_desc, $this->returns);
$encodingoptions = array(
"encoding" => "UTF-8",
"verbosity" => "no_white_space",
// See MDL-54868.
"escaping" => ["markup"]
);
// We can now convert the response to the requested XML-RPC format.
$this->response = xmlrpc_encode_request(null, $validatedvalues, $encodingoptions);
}
} catch (invalid_response_exception $ex) {
$this->response = $this->generate_error($ex);
}
} | php | protected function prepare_response() {
try {
if (!empty($this->function->returns_desc)) {
$validatedvalues = external_api::clean_returnvalue($this->function->returns_desc, $this->returns);
$encodingoptions = array(
"encoding" => "UTF-8",
"verbosity" => "no_white_space",
// See MDL-54868.
"escaping" => ["markup"]
);
// We can now convert the response to the requested XML-RPC format.
$this->response = xmlrpc_encode_request(null, $validatedvalues, $encodingoptions);
}
} catch (invalid_response_exception $ex) {
$this->response = $this->generate_error($ex);
}
} | [
"protected",
"function",
"prepare_response",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"function",
"->",
"returns_desc",
")",
")",
"{",
"$",
"validatedvalues",
"=",
"external_api",
"::",
"clean_returnvalue",
"(",
"$",
"this",
"->",
"function",
"->",
"returns_desc",
",",
"$",
"this",
"->",
"returns",
")",
";",
"$",
"encodingoptions",
"=",
"array",
"(",
"\"encoding\"",
"=>",
"\"UTF-8\"",
",",
"\"verbosity\"",
"=>",
"\"no_white_space\"",
",",
"// See MDL-54868.",
"\"escaping\"",
"=>",
"[",
"\"markup\"",
"]",
")",
";",
"// We can now convert the response to the requested XML-RPC format.",
"$",
"this",
"->",
"response",
"=",
"xmlrpc_encode_request",
"(",
"null",
",",
"$",
"validatedvalues",
",",
"$",
"encodingoptions",
")",
";",
"}",
"}",
"catch",
"(",
"invalid_response_exception",
"$",
"ex",
")",
"{",
"$",
"this",
"->",
"response",
"=",
"$",
"this",
"->",
"generate_error",
"(",
"$",
"ex",
")",
";",
"}",
"}"
] | Prepares the response. | [
"Prepares",
"the",
"response",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/webservice/xmlrpc/locallib.php#L103-L119 |
214,662 | moodle/moodle | webservice/xmlrpc/locallib.php | webservice_xmlrpc_server.send_error | protected function send_error($ex = null) {
$this->response = $this->generate_error($ex);
$this->send_headers();
echo $this->response;
} | php | protected function send_error($ex = null) {
$this->response = $this->generate_error($ex);
$this->send_headers();
echo $this->response;
} | [
"protected",
"function",
"send_error",
"(",
"$",
"ex",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"response",
"=",
"$",
"this",
"->",
"generate_error",
"(",
"$",
"ex",
")",
";",
"$",
"this",
"->",
"send_headers",
"(",
")",
";",
"echo",
"$",
"this",
"->",
"response",
";",
"}"
] | Send the error information to the WS client.
@param Exception $ex | [
"Send",
"the",
"error",
"information",
"to",
"the",
"WS",
"client",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/webservice/xmlrpc/locallib.php#L135-L139 |
214,663 | moodle/moodle | webservice/xmlrpc/locallib.php | webservice_xmlrpc_server.generate_error | protected function generate_error($ex, $faultcode = 404) {
$error = $ex->getMessage();
if (!empty($ex->errorcode)) {
// The faultCode must be an int, so we obtain a hash of the errorcode then get an integer value of the hash.
$faultcode = base_convert(md5($ex->errorcode), 16, 10);
// We strip the $code to 8 digits (and hope for no error code collisions).
// Collisions should be pretty rare, and if needed the client can retrieve
// the accurate errorcode from the last | in the exception message.
$faultcode = substr($faultcode, 0, 8);
// Add the debuginfo to the exception message if debuginfo must be returned.
if (debugging() and isset($ex->debuginfo)) {
$error .= ' | DEBUG INFO: ' . $ex->debuginfo . ' | ERRORCODE: ' . $ex->errorcode;
} else {
$error .= ' | ERRORCODE: ' . $ex->errorcode;
}
}
$fault = array(
'faultCode' => (int) $faultcode,
'faultString' => $error
);
$encodingoptions = array(
"encoding" => "UTF-8",
"verbosity" => "no_white_space",
// See MDL-54868.
"escaping" => ["markup"]
);
return xmlrpc_encode_request(null, $fault, $encodingoptions);
} | php | protected function generate_error($ex, $faultcode = 404) {
$error = $ex->getMessage();
if (!empty($ex->errorcode)) {
// The faultCode must be an int, so we obtain a hash of the errorcode then get an integer value of the hash.
$faultcode = base_convert(md5($ex->errorcode), 16, 10);
// We strip the $code to 8 digits (and hope for no error code collisions).
// Collisions should be pretty rare, and if needed the client can retrieve
// the accurate errorcode from the last | in the exception message.
$faultcode = substr($faultcode, 0, 8);
// Add the debuginfo to the exception message if debuginfo must be returned.
if (debugging() and isset($ex->debuginfo)) {
$error .= ' | DEBUG INFO: ' . $ex->debuginfo . ' | ERRORCODE: ' . $ex->errorcode;
} else {
$error .= ' | ERRORCODE: ' . $ex->errorcode;
}
}
$fault = array(
'faultCode' => (int) $faultcode,
'faultString' => $error
);
$encodingoptions = array(
"encoding" => "UTF-8",
"verbosity" => "no_white_space",
// See MDL-54868.
"escaping" => ["markup"]
);
return xmlrpc_encode_request(null, $fault, $encodingoptions);
} | [
"protected",
"function",
"generate_error",
"(",
"$",
"ex",
",",
"$",
"faultcode",
"=",
"404",
")",
"{",
"$",
"error",
"=",
"$",
"ex",
"->",
"getMessage",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"ex",
"->",
"errorcode",
")",
")",
"{",
"// The faultCode must be an int, so we obtain a hash of the errorcode then get an integer value of the hash.",
"$",
"faultcode",
"=",
"base_convert",
"(",
"md5",
"(",
"$",
"ex",
"->",
"errorcode",
")",
",",
"16",
",",
"10",
")",
";",
"// We strip the $code to 8 digits (and hope for no error code collisions).",
"// Collisions should be pretty rare, and if needed the client can retrieve",
"// the accurate errorcode from the last | in the exception message.",
"$",
"faultcode",
"=",
"substr",
"(",
"$",
"faultcode",
",",
"0",
",",
"8",
")",
";",
"// Add the debuginfo to the exception message if debuginfo must be returned.",
"if",
"(",
"debugging",
"(",
")",
"and",
"isset",
"(",
"$",
"ex",
"->",
"debuginfo",
")",
")",
"{",
"$",
"error",
".=",
"' | DEBUG INFO: '",
".",
"$",
"ex",
"->",
"debuginfo",
".",
"' | ERRORCODE: '",
".",
"$",
"ex",
"->",
"errorcode",
";",
"}",
"else",
"{",
"$",
"error",
".=",
"' | ERRORCODE: '",
".",
"$",
"ex",
"->",
"errorcode",
";",
"}",
"}",
"$",
"fault",
"=",
"array",
"(",
"'faultCode'",
"=>",
"(",
"int",
")",
"$",
"faultcode",
",",
"'faultString'",
"=>",
"$",
"error",
")",
";",
"$",
"encodingoptions",
"=",
"array",
"(",
"\"encoding\"",
"=>",
"\"UTF-8\"",
",",
"\"verbosity\"",
"=>",
"\"no_white_space\"",
",",
"// See MDL-54868.",
"\"escaping\"",
"=>",
"[",
"\"markup\"",
"]",
")",
";",
"return",
"xmlrpc_encode_request",
"(",
"null",
",",
"$",
"fault",
",",
"$",
"encodingoptions",
")",
";",
"}"
] | Generate the XML-RPC fault response.
@param Exception|Throwable $ex The exception.
@param int $faultcode The faultCode to be included in the fault response
@return string The XML-RPC fault response xml containing the faultCode and faultString. | [
"Generate",
"the",
"XML",
"-",
"RPC",
"fault",
"response",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/webservice/xmlrpc/locallib.php#L169-L202 |
214,664 | moodle/moodle | admin/tool/task/classes/edit_scheduled_task_form.php | tool_task_edit_scheduled_task_form.validate_fields | public static function validate_fields($field, $value) {
switch ($field) {
case 'minute' :
case 'hour' :
$regex = "/\A\*\z|\A[0-5]?[0-9]\z|\A\*\/[0-5]?[0-9]\z|\A[0-5]?[0-9](,[0-5]?[0-9])*\z|\A[0-5]?[0-9]-[0-5]?[0-9]\z/";
break;
case 'day':
$regex = "/\A\*\z|\A([1-2]?[0-9]|3[0-1])\z|\A\*\/([1-2]?[0-9]|3[0-1])\z|";
$regex .= "\A([1-2]?[0-9]|3[0-1])(,([1-2]?[0-9]|3[0-1]))*\z|\A([1-2]?[0-9]|3[0-1])-([1-2]?[0-9]|3[0-1])\z/";
break;
case 'month':
$regex = "/\A\*\z|\A([0-9]|1[0-2])\z|\A\*\/([0-9]|1[0-2])\z|\A([0-9]|1[0-2])(,([0-9]|1[0-2]))*\z|";
$regex .= "\A([0-9]|1[0-2])-([0-9]|1[0-2])\z/";
break;
case 'dayofweek':
$regex = "/\A\*\z|\A[0-6]\z|\A\*\/[0-6]\z|\A[0-6](,[0-6])*\z|\A[0-6]-[0-6]\z/";
break;
default:
return false;
}
return (bool)preg_match($regex, $value);
} | php | public static function validate_fields($field, $value) {
switch ($field) {
case 'minute' :
case 'hour' :
$regex = "/\A\*\z|\A[0-5]?[0-9]\z|\A\*\/[0-5]?[0-9]\z|\A[0-5]?[0-9](,[0-5]?[0-9])*\z|\A[0-5]?[0-9]-[0-5]?[0-9]\z/";
break;
case 'day':
$regex = "/\A\*\z|\A([1-2]?[0-9]|3[0-1])\z|\A\*\/([1-2]?[0-9]|3[0-1])\z|";
$regex .= "\A([1-2]?[0-9]|3[0-1])(,([1-2]?[0-9]|3[0-1]))*\z|\A([1-2]?[0-9]|3[0-1])-([1-2]?[0-9]|3[0-1])\z/";
break;
case 'month':
$regex = "/\A\*\z|\A([0-9]|1[0-2])\z|\A\*\/([0-9]|1[0-2])\z|\A([0-9]|1[0-2])(,([0-9]|1[0-2]))*\z|";
$regex .= "\A([0-9]|1[0-2])-([0-9]|1[0-2])\z/";
break;
case 'dayofweek':
$regex = "/\A\*\z|\A[0-6]\z|\A\*\/[0-6]\z|\A[0-6](,[0-6])*\z|\A[0-6]-[0-6]\z/";
break;
default:
return false;
}
return (bool)preg_match($regex, $value);
} | [
"public",
"static",
"function",
"validate_fields",
"(",
"$",
"field",
",",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"field",
")",
"{",
"case",
"'minute'",
":",
"case",
"'hour'",
":",
"$",
"regex",
"=",
"\"/\\A\\*\\z|\\A[0-5]?[0-9]\\z|\\A\\*\\/[0-5]?[0-9]\\z|\\A[0-5]?[0-9](,[0-5]?[0-9])*\\z|\\A[0-5]?[0-9]-[0-5]?[0-9]\\z/\"",
";",
"break",
";",
"case",
"'day'",
":",
"$",
"regex",
"=",
"\"/\\A\\*\\z|\\A([1-2]?[0-9]|3[0-1])\\z|\\A\\*\\/([1-2]?[0-9]|3[0-1])\\z|\"",
";",
"$",
"regex",
".=",
"\"\\A([1-2]?[0-9]|3[0-1])(,([1-2]?[0-9]|3[0-1]))*\\z|\\A([1-2]?[0-9]|3[0-1])-([1-2]?[0-9]|3[0-1])\\z/\"",
";",
"break",
";",
"case",
"'month'",
":",
"$",
"regex",
"=",
"\"/\\A\\*\\z|\\A([0-9]|1[0-2])\\z|\\A\\*\\/([0-9]|1[0-2])\\z|\\A([0-9]|1[0-2])(,([0-9]|1[0-2]))*\\z|\"",
";",
"$",
"regex",
".=",
"\"\\A([0-9]|1[0-2])-([0-9]|1[0-2])\\z/\"",
";",
"break",
";",
"case",
"'dayofweek'",
":",
"$",
"regex",
"=",
"\"/\\A\\*\\z|\\A[0-6]\\z|\\A\\*\\/[0-6]\\z|\\A[0-6](,[0-6])*\\z|\\A[0-6]-[0-6]\\z/\"",
";",
"break",
";",
"default",
":",
"return",
"false",
";",
"}",
"return",
"(",
"bool",
")",
"preg_match",
"(",
"$",
"regex",
",",
"$",
"value",
")",
";",
"}"
] | Helper function that validates the submitted data.
Explanation of the regex:-
\A\*\z - matches *
\A[0-5]?[0-9]\z - matches entries like 23
\A\*\/[0-5]?[0-9]\z - matches entries like * / 5
\A[0-5]?[0-9](,[0-5]?[0-9])*\z - matches entries like 1,2,3
\A[0-5]?[0-9]-[0-5]?[0-9]\z - matches entries like 2-10
@param string $field field to validate
@param string $value value
@return bool true if validation passes, false other wise. | [
"Helper",
"function",
"that",
"validates",
"the",
"submitted",
"data",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/task/classes/edit_scheduled_task_form.php#L136-L157 |
214,665 | moodle/moodle | lib/classes/filetypes.php | core_filetypes.get_file_extension | public static function get_file_extension($mimetype) {
$types = self::get_types();
foreach ($types as $extension => $info) {
if ($info['type'] == $mimetype) {
return $extension;
}
}
return false;
} | php | public static function get_file_extension($mimetype) {
$types = self::get_types();
foreach ($types as $extension => $info) {
if ($info['type'] == $mimetype) {
return $extension;
}
}
return false;
} | [
"public",
"static",
"function",
"get_file_extension",
"(",
"$",
"mimetype",
")",
"{",
"$",
"types",
"=",
"self",
"::",
"get_types",
"(",
")",
";",
"foreach",
"(",
"$",
"types",
"as",
"$",
"extension",
"=>",
"$",
"info",
")",
"{",
"if",
"(",
"$",
"info",
"[",
"'type'",
"]",
"==",
"$",
"mimetype",
")",
"{",
"return",
"$",
"extension",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Given a mimetype - return a valid file extension for it.
@param $mimetype string
@return string|bool False if the mimetype was not known, a string indicating a valid file extension otherwise. It may not
be the only valid file extension - just the first one found. | [
"Given",
"a",
"mimetype",
"-",
"return",
"a",
"valid",
"file",
"extension",
"for",
"it",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/filetypes.php#L316-L324 |
214,666 | moodle/moodle | lib/classes/filetypes.php | core_filetypes.& | public static function &get_types() {
// If it was already done in this request, use cache.
if (self::$cachedtypes) {
return self::$cachedtypes;
}
// Get defaults.
$mimetypes = self::get_default_types();
// Get custom file types.
$custom = self::get_custom_types();
// Check value is an array.
if (!is_array($custom)) {
debugging('Invalid $CFG->customfiletypes (not array)', DEBUG_DEVELOPER);
$custom = array();
}
foreach ($custom as $customentry) {
// Each entry is a stdClass object similar to the array values above.
if (empty($customentry->extension)) {
debugging('Invalid $CFG->customfiletypes entry (extension field required)',
DEBUG_DEVELOPER);
continue;
}
// To delete a standard entry, set 'deleted' to true.
if (!empty($customentry->deleted)) {
unset($mimetypes[$customentry->extension]);
continue;
}
// Check required fields.
if (empty($customentry->type) || empty($customentry->icon)) {
debugging('Invalid $CFG->customfiletypes entry ' . $customentry->extension .
' (type and icon fields required)', DEBUG_DEVELOPER);
continue;
}
// Build result array.
$result = array('type' => $customentry->type, 'icon' => $customentry->icon);
if (!empty($customentry->groups)) {
if (!is_array($customentry->groups)) {
debugging('Invalid $CFG->customfiletypes entry ' . $customentry->extension .
' (groups field not array)', DEBUG_DEVELOPER);
continue;
}
$result['groups'] = $customentry->groups;
}
if (!empty($customentry->string)) {
if (!is_string($customentry->string)) {
debugging('Invalid $CFG->customfiletypes entry ' . $customentry->extension .
' (string field not string)', DEBUG_DEVELOPER);
continue;
}
$result['string'] = $customentry->string;
}
if (!empty($customentry->defaulticon)) {
if (!is_bool($customentry->defaulticon)) {
debugging('Invalid $CFG->customfiletypes entry ' . $customentry->extension .
' (defaulticon field not bool)', DEBUG_DEVELOPER);
continue;
}
$result['defaulticon'] = $customentry->defaulticon;
}
if (!empty($customentry->customdescription)) {
if (!is_string($customentry->customdescription)) {
debugging('Invalid $CFG->customfiletypes entry ' . $customentry->extension .
' (customdescription field not string)', DEBUG_DEVELOPER);
continue;
}
// As the name suggests, this field is used only for custom entries.
$result['customdescription'] = $customentry->customdescription;
}
// Track whether it is a custom filetype or a modified existing
// filetype.
if (array_key_exists($customentry->extension, $mimetypes)) {
$result['modified'] = true;
} else {
$result['custom'] = true;
}
// Add result array to list.
$mimetypes[$customentry->extension] = $result;
}
self::$cachedtypes = $mimetypes;
return self::$cachedtypes;
} | php | public static function &get_types() {
// If it was already done in this request, use cache.
if (self::$cachedtypes) {
return self::$cachedtypes;
}
// Get defaults.
$mimetypes = self::get_default_types();
// Get custom file types.
$custom = self::get_custom_types();
// Check value is an array.
if (!is_array($custom)) {
debugging('Invalid $CFG->customfiletypes (not array)', DEBUG_DEVELOPER);
$custom = array();
}
foreach ($custom as $customentry) {
// Each entry is a stdClass object similar to the array values above.
if (empty($customentry->extension)) {
debugging('Invalid $CFG->customfiletypes entry (extension field required)',
DEBUG_DEVELOPER);
continue;
}
// To delete a standard entry, set 'deleted' to true.
if (!empty($customentry->deleted)) {
unset($mimetypes[$customentry->extension]);
continue;
}
// Check required fields.
if (empty($customentry->type) || empty($customentry->icon)) {
debugging('Invalid $CFG->customfiletypes entry ' . $customentry->extension .
' (type and icon fields required)', DEBUG_DEVELOPER);
continue;
}
// Build result array.
$result = array('type' => $customentry->type, 'icon' => $customentry->icon);
if (!empty($customentry->groups)) {
if (!is_array($customentry->groups)) {
debugging('Invalid $CFG->customfiletypes entry ' . $customentry->extension .
' (groups field not array)', DEBUG_DEVELOPER);
continue;
}
$result['groups'] = $customentry->groups;
}
if (!empty($customentry->string)) {
if (!is_string($customentry->string)) {
debugging('Invalid $CFG->customfiletypes entry ' . $customentry->extension .
' (string field not string)', DEBUG_DEVELOPER);
continue;
}
$result['string'] = $customentry->string;
}
if (!empty($customentry->defaulticon)) {
if (!is_bool($customentry->defaulticon)) {
debugging('Invalid $CFG->customfiletypes entry ' . $customentry->extension .
' (defaulticon field not bool)', DEBUG_DEVELOPER);
continue;
}
$result['defaulticon'] = $customentry->defaulticon;
}
if (!empty($customentry->customdescription)) {
if (!is_string($customentry->customdescription)) {
debugging('Invalid $CFG->customfiletypes entry ' . $customentry->extension .
' (customdescription field not string)', DEBUG_DEVELOPER);
continue;
}
// As the name suggests, this field is used only for custom entries.
$result['customdescription'] = $customentry->customdescription;
}
// Track whether it is a custom filetype or a modified existing
// filetype.
if (array_key_exists($customentry->extension, $mimetypes)) {
$result['modified'] = true;
} else {
$result['custom'] = true;
}
// Add result array to list.
$mimetypes[$customentry->extension] = $result;
}
self::$cachedtypes = $mimetypes;
return self::$cachedtypes;
} | [
"public",
"static",
"function",
"&",
"get_types",
"(",
")",
"{",
"// If it was already done in this request, use cache.",
"if",
"(",
"self",
"::",
"$",
"cachedtypes",
")",
"{",
"return",
"self",
"::",
"$",
"cachedtypes",
";",
"}",
"// Get defaults.",
"$",
"mimetypes",
"=",
"self",
"::",
"get_default_types",
"(",
")",
";",
"// Get custom file types.",
"$",
"custom",
"=",
"self",
"::",
"get_custom_types",
"(",
")",
";",
"// Check value is an array.",
"if",
"(",
"!",
"is_array",
"(",
"$",
"custom",
")",
")",
"{",
"debugging",
"(",
"'Invalid $CFG->customfiletypes (not array)'",
",",
"DEBUG_DEVELOPER",
")",
";",
"$",
"custom",
"=",
"array",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"custom",
"as",
"$",
"customentry",
")",
"{",
"// Each entry is a stdClass object similar to the array values above.",
"if",
"(",
"empty",
"(",
"$",
"customentry",
"->",
"extension",
")",
")",
"{",
"debugging",
"(",
"'Invalid $CFG->customfiletypes entry (extension field required)'",
",",
"DEBUG_DEVELOPER",
")",
";",
"continue",
";",
"}",
"// To delete a standard entry, set 'deleted' to true.",
"if",
"(",
"!",
"empty",
"(",
"$",
"customentry",
"->",
"deleted",
")",
")",
"{",
"unset",
"(",
"$",
"mimetypes",
"[",
"$",
"customentry",
"->",
"extension",
"]",
")",
";",
"continue",
";",
"}",
"// Check required fields.",
"if",
"(",
"empty",
"(",
"$",
"customentry",
"->",
"type",
")",
"||",
"empty",
"(",
"$",
"customentry",
"->",
"icon",
")",
")",
"{",
"debugging",
"(",
"'Invalid $CFG->customfiletypes entry '",
".",
"$",
"customentry",
"->",
"extension",
".",
"' (type and icon fields required)'",
",",
"DEBUG_DEVELOPER",
")",
";",
"continue",
";",
"}",
"// Build result array.",
"$",
"result",
"=",
"array",
"(",
"'type'",
"=>",
"$",
"customentry",
"->",
"type",
",",
"'icon'",
"=>",
"$",
"customentry",
"->",
"icon",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"customentry",
"->",
"groups",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"customentry",
"->",
"groups",
")",
")",
"{",
"debugging",
"(",
"'Invalid $CFG->customfiletypes entry '",
".",
"$",
"customentry",
"->",
"extension",
".",
"' (groups field not array)'",
",",
"DEBUG_DEVELOPER",
")",
";",
"continue",
";",
"}",
"$",
"result",
"[",
"'groups'",
"]",
"=",
"$",
"customentry",
"->",
"groups",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"customentry",
"->",
"string",
")",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"customentry",
"->",
"string",
")",
")",
"{",
"debugging",
"(",
"'Invalid $CFG->customfiletypes entry '",
".",
"$",
"customentry",
"->",
"extension",
".",
"' (string field not string)'",
",",
"DEBUG_DEVELOPER",
")",
";",
"continue",
";",
"}",
"$",
"result",
"[",
"'string'",
"]",
"=",
"$",
"customentry",
"->",
"string",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"customentry",
"->",
"defaulticon",
")",
")",
"{",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"customentry",
"->",
"defaulticon",
")",
")",
"{",
"debugging",
"(",
"'Invalid $CFG->customfiletypes entry '",
".",
"$",
"customentry",
"->",
"extension",
".",
"' (defaulticon field not bool)'",
",",
"DEBUG_DEVELOPER",
")",
";",
"continue",
";",
"}",
"$",
"result",
"[",
"'defaulticon'",
"]",
"=",
"$",
"customentry",
"->",
"defaulticon",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"customentry",
"->",
"customdescription",
")",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"customentry",
"->",
"customdescription",
")",
")",
"{",
"debugging",
"(",
"'Invalid $CFG->customfiletypes entry '",
".",
"$",
"customentry",
"->",
"extension",
".",
"' (customdescription field not string)'",
",",
"DEBUG_DEVELOPER",
")",
";",
"continue",
";",
"}",
"// As the name suggests, this field is used only for custom entries.",
"$",
"result",
"[",
"'customdescription'",
"]",
"=",
"$",
"customentry",
"->",
"customdescription",
";",
"}",
"// Track whether it is a custom filetype or a modified existing",
"// filetype.",
"if",
"(",
"array_key_exists",
"(",
"$",
"customentry",
"->",
"extension",
",",
"$",
"mimetypes",
")",
")",
"{",
"$",
"result",
"[",
"'modified'",
"]",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"'custom'",
"]",
"=",
"true",
";",
"}",
"// Add result array to list.",
"$",
"mimetypes",
"[",
"$",
"customentry",
"->",
"extension",
"]",
"=",
"$",
"result",
";",
"}",
"self",
"::",
"$",
"cachedtypes",
"=",
"$",
"mimetypes",
";",
"return",
"self",
"::",
"$",
"cachedtypes",
";",
"}"
] | Gets all the current types.
@return array Associative array from extension to array of data about type | [
"Gets",
"all",
"the",
"current",
"types",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/filetypes.php#L331-L420 |
214,667 | moodle/moodle | lib/classes/filetypes.php | core_filetypes.get_custom_types | protected static function get_custom_types() {
global $CFG;
if (!empty($CFG->customfiletypes)) {
if (is_array($CFG->customfiletypes)) {
// You can define this as an array in config.php...
return $CFG->customfiletypes;
} else {
// Or as a JSON string in the config table.
return json_decode($CFG->customfiletypes);
}
} else {
return array();
}
} | php | protected static function get_custom_types() {
global $CFG;
if (!empty($CFG->customfiletypes)) {
if (is_array($CFG->customfiletypes)) {
// You can define this as an array in config.php...
return $CFG->customfiletypes;
} else {
// Or as a JSON string in the config table.
return json_decode($CFG->customfiletypes);
}
} else {
return array();
}
} | [
"protected",
"static",
"function",
"get_custom_types",
"(",
")",
"{",
"global",
"$",
"CFG",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"CFG",
"->",
"customfiletypes",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"CFG",
"->",
"customfiletypes",
")",
")",
"{",
"// You can define this as an array in config.php...",
"return",
"$",
"CFG",
"->",
"customfiletypes",
";",
"}",
"else",
"{",
"// Or as a JSON string in the config table.",
"return",
"json_decode",
"(",
"$",
"CFG",
"->",
"customfiletypes",
")",
";",
"}",
"}",
"else",
"{",
"return",
"array",
"(",
")",
";",
"}",
"}"
] | Gets custom types from config variable, after decoding the JSON if required.
@return array Array of custom types (empty array if none) | [
"Gets",
"custom",
"types",
"from",
"config",
"variable",
"after",
"decoding",
"the",
"JSON",
"if",
"required",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/filetypes.php#L427-L440 |
214,668 | moodle/moodle | lib/classes/filetypes.php | core_filetypes.set_custom_types | protected static function set_custom_types(array $types) {
global $CFG;
// Check the setting hasn't been forced.
if (array_key_exists('customfiletypes', $CFG->config_php_settings)) {
throw new coding_exception('Cannot set custom filetypes because they ' .
'are defined in config.php');
}
if (empty($types)) {
unset_config('customfiletypes');
} else {
set_config('customfiletypes', json_encode(array_values($types)));
}
// Clear the cached type list.
self::reset_caches();
} | php | protected static function set_custom_types(array $types) {
global $CFG;
// Check the setting hasn't been forced.
if (array_key_exists('customfiletypes', $CFG->config_php_settings)) {
throw new coding_exception('Cannot set custom filetypes because they ' .
'are defined in config.php');
}
if (empty($types)) {
unset_config('customfiletypes');
} else {
set_config('customfiletypes', json_encode(array_values($types)));
}
// Clear the cached type list.
self::reset_caches();
} | [
"protected",
"static",
"function",
"set_custom_types",
"(",
"array",
"$",
"types",
")",
"{",
"global",
"$",
"CFG",
";",
"// Check the setting hasn't been forced.",
"if",
"(",
"array_key_exists",
"(",
"'customfiletypes'",
",",
"$",
"CFG",
"->",
"config_php_settings",
")",
")",
"{",
"throw",
"new",
"coding_exception",
"(",
"'Cannot set custom filetypes because they '",
".",
"'are defined in config.php'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"types",
")",
")",
"{",
"unset_config",
"(",
"'customfiletypes'",
")",
";",
"}",
"else",
"{",
"set_config",
"(",
"'customfiletypes'",
",",
"json_encode",
"(",
"array_values",
"(",
"$",
"types",
")",
")",
")",
";",
"}",
"// Clear the cached type list.",
"self",
"::",
"reset_caches",
"(",
")",
";",
"}"
] | Sets the custom types into config variable, encoding into JSON.
@param array $types Array of custom types
@throws coding_exception If the custom types are fixed in config.php. | [
"Sets",
"the",
"custom",
"types",
"into",
"config",
"variable",
"encoding",
"into",
"JSON",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/filetypes.php#L448-L463 |
214,669 | moodle/moodle | lib/classes/filetypes.php | core_filetypes.get_deleted_types | public static function get_deleted_types() {
$defaults = self::get_default_types();
$deleted = array();
foreach (self::get_custom_types() as $customentry) {
if (!empty($customentry->deleted)) {
$deleted[$customentry->extension] = $defaults[$customentry->extension];
}
}
return $deleted;
} | php | public static function get_deleted_types() {
$defaults = self::get_default_types();
$deleted = array();
foreach (self::get_custom_types() as $customentry) {
if (!empty($customentry->deleted)) {
$deleted[$customentry->extension] = $defaults[$customentry->extension];
}
}
return $deleted;
} | [
"public",
"static",
"function",
"get_deleted_types",
"(",
")",
"{",
"$",
"defaults",
"=",
"self",
"::",
"get_default_types",
"(",
")",
";",
"$",
"deleted",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"self",
"::",
"get_custom_types",
"(",
")",
"as",
"$",
"customentry",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"customentry",
"->",
"deleted",
")",
")",
"{",
"$",
"deleted",
"[",
"$",
"customentry",
"->",
"extension",
"]",
"=",
"$",
"defaults",
"[",
"$",
"customentry",
"->",
"extension",
"]",
";",
"}",
"}",
"return",
"$",
"deleted",
";",
"}"
] | Gets the default types that have been deleted. Returns an array containing
the defaults of all those types.
@return array Array (same format as get_mimetypes_array) | [
"Gets",
"the",
"default",
"types",
"that",
"have",
"been",
"deleted",
".",
"Returns",
"an",
"array",
"containing",
"the",
"defaults",
"of",
"all",
"those",
"types",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/filetypes.php#L480-L489 |
214,670 | moodle/moodle | lib/classes/filetypes.php | core_filetypes.add_type | public static function add_type($extension, $mimetype, $coreicon,
array $groups = array(), $corestring = '', $customdescription = '',
$defaulticon = false) {
// Check for blank extensions or incorrectly including the dot.
$extension = (string)$extension;
if ($extension === '' || $extension[0] === '.') {
throw new coding_exception('Invalid extension .' . $extension);
}
// Check extension not already used.
$mimetypes = get_mimetypes_array();
if (array_key_exists($extension, $mimetypes)) {
throw new coding_exception('Extension ' . $extension . ' already exists');
}
// For default icon, check there isn't already something with default icon
// set for that MIME type.
if ($defaulticon) {
foreach ($mimetypes as $type) {
if ($type['type'] === $mimetype && !empty($type['defaulticon'])) {
throw new coding_exception('MIME type ' . $mimetype .
' already has a default icon set');
}
}
}
// Get existing custom filetype list.
$customs = self::get_custom_types();
// Check if there's a 'deleted' entry for the extension, if so then get
// rid of it.
foreach ($customs as $key => $custom) {
if ($custom->extension === $extension) {
unset($customs[$key]);
}
}
// Set up config record for new type.
$newtype = self::create_config_record($extension, $mimetype, $coreicon, $groups,
$corestring, $customdescription, $defaulticon);
// See if there's a default value with this extension.
$needsadding = true;
$defaults = self::get_default_types();
if (array_key_exists($extension, $defaults)) {
// If it has the same values, we don't need to add it.
$defaultvalue = $defaults[$extension];
$modified = (array)$newtype;
unset($modified['extension']);
ksort($defaultvalue);
ksort($modified);
if ($modified === $defaultvalue) {
$needsadding = false;
}
}
// Add to array and set in config.
if ($needsadding) {
$customs[] = $newtype;
}
self::set_custom_types($customs);
} | php | public static function add_type($extension, $mimetype, $coreicon,
array $groups = array(), $corestring = '', $customdescription = '',
$defaulticon = false) {
// Check for blank extensions or incorrectly including the dot.
$extension = (string)$extension;
if ($extension === '' || $extension[0] === '.') {
throw new coding_exception('Invalid extension .' . $extension);
}
// Check extension not already used.
$mimetypes = get_mimetypes_array();
if (array_key_exists($extension, $mimetypes)) {
throw new coding_exception('Extension ' . $extension . ' already exists');
}
// For default icon, check there isn't already something with default icon
// set for that MIME type.
if ($defaulticon) {
foreach ($mimetypes as $type) {
if ($type['type'] === $mimetype && !empty($type['defaulticon'])) {
throw new coding_exception('MIME type ' . $mimetype .
' already has a default icon set');
}
}
}
// Get existing custom filetype list.
$customs = self::get_custom_types();
// Check if there's a 'deleted' entry for the extension, if so then get
// rid of it.
foreach ($customs as $key => $custom) {
if ($custom->extension === $extension) {
unset($customs[$key]);
}
}
// Set up config record for new type.
$newtype = self::create_config_record($extension, $mimetype, $coreicon, $groups,
$corestring, $customdescription, $defaulticon);
// See if there's a default value with this extension.
$needsadding = true;
$defaults = self::get_default_types();
if (array_key_exists($extension, $defaults)) {
// If it has the same values, we don't need to add it.
$defaultvalue = $defaults[$extension];
$modified = (array)$newtype;
unset($modified['extension']);
ksort($defaultvalue);
ksort($modified);
if ($modified === $defaultvalue) {
$needsadding = false;
}
}
// Add to array and set in config.
if ($needsadding) {
$customs[] = $newtype;
}
self::set_custom_types($customs);
} | [
"public",
"static",
"function",
"add_type",
"(",
"$",
"extension",
",",
"$",
"mimetype",
",",
"$",
"coreicon",
",",
"array",
"$",
"groups",
"=",
"array",
"(",
")",
",",
"$",
"corestring",
"=",
"''",
",",
"$",
"customdescription",
"=",
"''",
",",
"$",
"defaulticon",
"=",
"false",
")",
"{",
"// Check for blank extensions or incorrectly including the dot.",
"$",
"extension",
"=",
"(",
"string",
")",
"$",
"extension",
";",
"if",
"(",
"$",
"extension",
"===",
"''",
"||",
"$",
"extension",
"[",
"0",
"]",
"===",
"'.'",
")",
"{",
"throw",
"new",
"coding_exception",
"(",
"'Invalid extension .'",
".",
"$",
"extension",
")",
";",
"}",
"// Check extension not already used.",
"$",
"mimetypes",
"=",
"get_mimetypes_array",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"extension",
",",
"$",
"mimetypes",
")",
")",
"{",
"throw",
"new",
"coding_exception",
"(",
"'Extension '",
".",
"$",
"extension",
".",
"' already exists'",
")",
";",
"}",
"// For default icon, check there isn't already something with default icon",
"// set for that MIME type.",
"if",
"(",
"$",
"defaulticon",
")",
"{",
"foreach",
"(",
"$",
"mimetypes",
"as",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"type",
"[",
"'type'",
"]",
"===",
"$",
"mimetype",
"&&",
"!",
"empty",
"(",
"$",
"type",
"[",
"'defaulticon'",
"]",
")",
")",
"{",
"throw",
"new",
"coding_exception",
"(",
"'MIME type '",
".",
"$",
"mimetype",
".",
"' already has a default icon set'",
")",
";",
"}",
"}",
"}",
"// Get existing custom filetype list.",
"$",
"customs",
"=",
"self",
"::",
"get_custom_types",
"(",
")",
";",
"// Check if there's a 'deleted' entry for the extension, if so then get",
"// rid of it.",
"foreach",
"(",
"$",
"customs",
"as",
"$",
"key",
"=>",
"$",
"custom",
")",
"{",
"if",
"(",
"$",
"custom",
"->",
"extension",
"===",
"$",
"extension",
")",
"{",
"unset",
"(",
"$",
"customs",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"// Set up config record for new type.",
"$",
"newtype",
"=",
"self",
"::",
"create_config_record",
"(",
"$",
"extension",
",",
"$",
"mimetype",
",",
"$",
"coreicon",
",",
"$",
"groups",
",",
"$",
"corestring",
",",
"$",
"customdescription",
",",
"$",
"defaulticon",
")",
";",
"// See if there's a default value with this extension.",
"$",
"needsadding",
"=",
"true",
";",
"$",
"defaults",
"=",
"self",
"::",
"get_default_types",
"(",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"extension",
",",
"$",
"defaults",
")",
")",
"{",
"// If it has the same values, we don't need to add it.",
"$",
"defaultvalue",
"=",
"$",
"defaults",
"[",
"$",
"extension",
"]",
";",
"$",
"modified",
"=",
"(",
"array",
")",
"$",
"newtype",
";",
"unset",
"(",
"$",
"modified",
"[",
"'extension'",
"]",
")",
";",
"ksort",
"(",
"$",
"defaultvalue",
")",
";",
"ksort",
"(",
"$",
"modified",
")",
";",
"if",
"(",
"$",
"modified",
"===",
"$",
"defaultvalue",
")",
"{",
"$",
"needsadding",
"=",
"false",
";",
"}",
"}",
"// Add to array and set in config.",
"if",
"(",
"$",
"needsadding",
")",
"{",
"$",
"customs",
"[",
"]",
"=",
"$",
"newtype",
";",
"}",
"self",
"::",
"set_custom_types",
"(",
"$",
"customs",
")",
";",
"}"
] | Adds a new entry to the list of custom filetypes.
@param string $extension File extension without dot, e.g. 'doc'
@param string $mimetype MIME type e.g. 'application/msword'
@param string $coreicon Core icon to use e.g. 'document'
@param array $groups Array of group strings that this type belongs to
@param string $corestring Custom lang string name in mimetypes.php
@param string $customdescription Custom description (plain text/multilang)
@param bool $defaulticon True if this should be the default icon for the type
@throws coding_exception If the extension already exists, or otherwise invalid | [
"Adds",
"a",
"new",
"entry",
"to",
"the",
"list",
"of",
"custom",
"filetypes",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/filetypes.php#L503-L564 |
214,671 | moodle/moodle | lib/classes/filetypes.php | core_filetypes.update_type | public static function update_type($extension, $newextension, $mimetype, $coreicon,
array $groups = array(), $corestring = '', $customdescription = '',
$defaulticon = false) {
// Extension must exist.
$extension = (string)$extension;
$mimetypes = get_mimetypes_array();
if (!array_key_exists($extension, $mimetypes)) {
throw new coding_exception('Extension ' . $extension . ' not found');
}
// If there's a new extension then this must not exist.
$newextension = (string)$newextension;
if ($newextension !== $extension) {
if ($newextension === '' || $newextension[0] === '.') {
throw new coding_exception('Invalid extension .' . $newextension);
}
if (array_key_exists($newextension, $mimetypes)) {
throw new coding_exception('Extension ' . $newextension . ' already exists');
}
}
// For default icon, check there isn't already something with default icon
// set for that MIME type (unless it's this).
if ($defaulticon) {
foreach ($mimetypes as $ext => $type) {
if ($ext !== $extension && $type['type'] === $mimetype &&
!empty($type['defaulticon'])) {
throw new coding_exception('MIME type ' . $mimetype .
' already has a default icon set');
}
}
}
// Delete the old extension and then add the new one (may be same). This
// will correctly handle cases when a default type is involved.
self::delete_type($extension);
self::add_type($newextension, $mimetype, $coreicon, $groups, $corestring,
$customdescription, $defaulticon);
} | php | public static function update_type($extension, $newextension, $mimetype, $coreicon,
array $groups = array(), $corestring = '', $customdescription = '',
$defaulticon = false) {
// Extension must exist.
$extension = (string)$extension;
$mimetypes = get_mimetypes_array();
if (!array_key_exists($extension, $mimetypes)) {
throw new coding_exception('Extension ' . $extension . ' not found');
}
// If there's a new extension then this must not exist.
$newextension = (string)$newextension;
if ($newextension !== $extension) {
if ($newextension === '' || $newextension[0] === '.') {
throw new coding_exception('Invalid extension .' . $newextension);
}
if (array_key_exists($newextension, $mimetypes)) {
throw new coding_exception('Extension ' . $newextension . ' already exists');
}
}
// For default icon, check there isn't already something with default icon
// set for that MIME type (unless it's this).
if ($defaulticon) {
foreach ($mimetypes as $ext => $type) {
if ($ext !== $extension && $type['type'] === $mimetype &&
!empty($type['defaulticon'])) {
throw new coding_exception('MIME type ' . $mimetype .
' already has a default icon set');
}
}
}
// Delete the old extension and then add the new one (may be same). This
// will correctly handle cases when a default type is involved.
self::delete_type($extension);
self::add_type($newextension, $mimetype, $coreicon, $groups, $corestring,
$customdescription, $defaulticon);
} | [
"public",
"static",
"function",
"update_type",
"(",
"$",
"extension",
",",
"$",
"newextension",
",",
"$",
"mimetype",
",",
"$",
"coreicon",
",",
"array",
"$",
"groups",
"=",
"array",
"(",
")",
",",
"$",
"corestring",
"=",
"''",
",",
"$",
"customdescription",
"=",
"''",
",",
"$",
"defaulticon",
"=",
"false",
")",
"{",
"// Extension must exist.",
"$",
"extension",
"=",
"(",
"string",
")",
"$",
"extension",
";",
"$",
"mimetypes",
"=",
"get_mimetypes_array",
"(",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"extension",
",",
"$",
"mimetypes",
")",
")",
"{",
"throw",
"new",
"coding_exception",
"(",
"'Extension '",
".",
"$",
"extension",
".",
"' not found'",
")",
";",
"}",
"// If there's a new extension then this must not exist.",
"$",
"newextension",
"=",
"(",
"string",
")",
"$",
"newextension",
";",
"if",
"(",
"$",
"newextension",
"!==",
"$",
"extension",
")",
"{",
"if",
"(",
"$",
"newextension",
"===",
"''",
"||",
"$",
"newextension",
"[",
"0",
"]",
"===",
"'.'",
")",
"{",
"throw",
"new",
"coding_exception",
"(",
"'Invalid extension .'",
".",
"$",
"newextension",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"newextension",
",",
"$",
"mimetypes",
")",
")",
"{",
"throw",
"new",
"coding_exception",
"(",
"'Extension '",
".",
"$",
"newextension",
".",
"' already exists'",
")",
";",
"}",
"}",
"// For default icon, check there isn't already something with default icon",
"// set for that MIME type (unless it's this).",
"if",
"(",
"$",
"defaulticon",
")",
"{",
"foreach",
"(",
"$",
"mimetypes",
"as",
"$",
"ext",
"=>",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"ext",
"!==",
"$",
"extension",
"&&",
"$",
"type",
"[",
"'type'",
"]",
"===",
"$",
"mimetype",
"&&",
"!",
"empty",
"(",
"$",
"type",
"[",
"'defaulticon'",
"]",
")",
")",
"{",
"throw",
"new",
"coding_exception",
"(",
"'MIME type '",
".",
"$",
"mimetype",
".",
"' already has a default icon set'",
")",
";",
"}",
"}",
"}",
"// Delete the old extension and then add the new one (may be same). This",
"// will correctly handle cases when a default type is involved.",
"self",
"::",
"delete_type",
"(",
"$",
"extension",
")",
";",
"self",
"::",
"add_type",
"(",
"$",
"newextension",
",",
"$",
"mimetype",
",",
"$",
"coreicon",
",",
"$",
"groups",
",",
"$",
"corestring",
",",
"$",
"customdescription",
",",
"$",
"defaulticon",
")",
";",
"}"
] | Updates an entry in the list of filetypes in config.
@param string $extension File extension without dot, e.g. 'doc'
@param string $newextension New file extension (same if not changing)
@param string $mimetype MIME type e.g. 'application/msword'
@param string $coreicon Core icon to use e.g. 'document'
@param array $groups Array of group strings that this type belongs to
@param string $corestring Custom lang string name in mimetypes.php
@param string $customdescription Custom description (plain text/multilang)
@param bool $defaulticon True if this should be the default icon for the type
@throws coding_exception If the new extension already exists, or otherwise invalid | [
"Updates",
"an",
"entry",
"in",
"the",
"list",
"of",
"filetypes",
"in",
"config",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/filetypes.php#L579-L618 |
214,672 | moodle/moodle | lib/classes/filetypes.php | core_filetypes.revert_type_to_default | public static function revert_type_to_default($extension) {
$extension = (string)$extension;
// Check it actually is a default type.
$defaults = self::get_default_types();
if (!array_key_exists($extension, $defaults)) {
throw new coding_exception('Extension ' . $extension . ' is not a default type');
}
// Loop through all the custom settings.
$changed = false;
$customs = self::get_custom_types();
foreach ($customs as $key => $customentry) {
if ($customentry->extension === $extension) {
unset($customs[$key]);
$changed = true;
}
}
// Save changes if any.
if ($changed) {
self::set_custom_types($customs);
}
return $changed;
} | php | public static function revert_type_to_default($extension) {
$extension = (string)$extension;
// Check it actually is a default type.
$defaults = self::get_default_types();
if (!array_key_exists($extension, $defaults)) {
throw new coding_exception('Extension ' . $extension . ' is not a default type');
}
// Loop through all the custom settings.
$changed = false;
$customs = self::get_custom_types();
foreach ($customs as $key => $customentry) {
if ($customentry->extension === $extension) {
unset($customs[$key]);
$changed = true;
}
}
// Save changes if any.
if ($changed) {
self::set_custom_types($customs);
}
return $changed;
} | [
"public",
"static",
"function",
"revert_type_to_default",
"(",
"$",
"extension",
")",
"{",
"$",
"extension",
"=",
"(",
"string",
")",
"$",
"extension",
";",
"// Check it actually is a default type.",
"$",
"defaults",
"=",
"self",
"::",
"get_default_types",
"(",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"extension",
",",
"$",
"defaults",
")",
")",
"{",
"throw",
"new",
"coding_exception",
"(",
"'Extension '",
".",
"$",
"extension",
".",
"' is not a default type'",
")",
";",
"}",
"// Loop through all the custom settings.",
"$",
"changed",
"=",
"false",
";",
"$",
"customs",
"=",
"self",
"::",
"get_custom_types",
"(",
")",
";",
"foreach",
"(",
"$",
"customs",
"as",
"$",
"key",
"=>",
"$",
"customentry",
")",
"{",
"if",
"(",
"$",
"customentry",
"->",
"extension",
"===",
"$",
"extension",
")",
"{",
"unset",
"(",
"$",
"customs",
"[",
"$",
"key",
"]",
")",
";",
"$",
"changed",
"=",
"true",
";",
"}",
"}",
"// Save changes if any.",
"if",
"(",
"$",
"changed",
")",
"{",
"self",
"::",
"set_custom_types",
"(",
"$",
"customs",
")",
";",
"}",
"return",
"$",
"changed",
";",
"}"
] | Reverts a file type to the default. May only be called on types that have
default values. This will undelete the type if necessary or set its values.
If the type is already at default values, does nothing.
@param string $extension File extension without dot, e.g. 'doc'
@return bool True if anything was changed, false if it was already default
@throws coding_exception If the extension is not a default type. | [
"Reverts",
"a",
"file",
"type",
"to",
"the",
"default",
".",
"May",
"only",
"be",
"called",
"on",
"types",
"that",
"have",
"default",
"values",
".",
"This",
"will",
"undelete",
"the",
"type",
"if",
"necessary",
"or",
"set",
"its",
"values",
".",
"If",
"the",
"type",
"is",
"already",
"at",
"default",
"values",
"does",
"nothing",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/filetypes.php#L663-L687 |
214,673 | moodle/moodle | lib/classes/filetypes.php | core_filetypes.create_config_record | protected static function create_config_record($extension, $mimetype,
$coreicon, array $groups, $corestring, $customdescription, $defaulticon) {
// Construct new entry.
$newentry = (object)array('extension' => (string)$extension, 'type' => (string)$mimetype,
'icon' => (string)$coreicon);
if ($groups) {
if (!is_array($groups)) {
throw new coding_exception('Groups must be an array');
}
foreach ($groups as $group) {
if (!is_string($group)) {
throw new coding_exception('Groups must be an array of strings');
}
}
$newentry->groups = $groups;
}
if ($corestring) {
$newentry->string = (string)$corestring;
}
if ($customdescription) {
$newentry->customdescription = (string)$customdescription;
}
if ($defaulticon) {
$newentry->defaulticon = true;
}
return $newentry;
} | php | protected static function create_config_record($extension, $mimetype,
$coreicon, array $groups, $corestring, $customdescription, $defaulticon) {
// Construct new entry.
$newentry = (object)array('extension' => (string)$extension, 'type' => (string)$mimetype,
'icon' => (string)$coreicon);
if ($groups) {
if (!is_array($groups)) {
throw new coding_exception('Groups must be an array');
}
foreach ($groups as $group) {
if (!is_string($group)) {
throw new coding_exception('Groups must be an array of strings');
}
}
$newentry->groups = $groups;
}
if ($corestring) {
$newentry->string = (string)$corestring;
}
if ($customdescription) {
$newentry->customdescription = (string)$customdescription;
}
if ($defaulticon) {
$newentry->defaulticon = true;
}
return $newentry;
} | [
"protected",
"static",
"function",
"create_config_record",
"(",
"$",
"extension",
",",
"$",
"mimetype",
",",
"$",
"coreicon",
",",
"array",
"$",
"groups",
",",
"$",
"corestring",
",",
"$",
"customdescription",
",",
"$",
"defaulticon",
")",
"{",
"// Construct new entry.",
"$",
"newentry",
"=",
"(",
"object",
")",
"array",
"(",
"'extension'",
"=>",
"(",
"string",
")",
"$",
"extension",
",",
"'type'",
"=>",
"(",
"string",
")",
"$",
"mimetype",
",",
"'icon'",
"=>",
"(",
"string",
")",
"$",
"coreicon",
")",
";",
"if",
"(",
"$",
"groups",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"groups",
")",
")",
"{",
"throw",
"new",
"coding_exception",
"(",
"'Groups must be an array'",
")",
";",
"}",
"foreach",
"(",
"$",
"groups",
"as",
"$",
"group",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"group",
")",
")",
"{",
"throw",
"new",
"coding_exception",
"(",
"'Groups must be an array of strings'",
")",
";",
"}",
"}",
"$",
"newentry",
"->",
"groups",
"=",
"$",
"groups",
";",
"}",
"if",
"(",
"$",
"corestring",
")",
"{",
"$",
"newentry",
"->",
"string",
"=",
"(",
"string",
")",
"$",
"corestring",
";",
"}",
"if",
"(",
"$",
"customdescription",
")",
"{",
"$",
"newentry",
"->",
"customdescription",
"=",
"(",
"string",
")",
"$",
"customdescription",
";",
"}",
"if",
"(",
"$",
"defaulticon",
")",
"{",
"$",
"newentry",
"->",
"defaulticon",
"=",
"true",
";",
"}",
"return",
"$",
"newentry",
";",
"}"
] | Converts function parameters into a record for storing in the JSON value.
@param string $extension File extension without dot, e.g. 'doc'
@param string $mimetype MIME type e.g. 'application/msword'
@param string $coreicon Core icon to use e.g. 'document'
@param array $groups Array of group strings that this type belongs to
@param string $corestring Custom lang string name in mimetypes.php
@param string $customdescription Custom description (plain text/multilang)
@param bool $defaulticon True if this should be the default icon for the type
@return stdClass Record matching the parameters | [
"Converts",
"function",
"parameters",
"into",
"a",
"record",
"for",
"storing",
"in",
"the",
"JSON",
"value",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/filetypes.php#L701-L727 |
214,674 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.review_page | public function review_page(quiz_attempt $attemptobj, $slots, $page, $showall,
$lastpage, mod_quiz_display_options $displayoptions,
$summarydata) {
$output = '';
$output .= $this->header();
$output .= $this->review_summary_table($summarydata, $page);
$output .= $this->review_form($page, $showall, $displayoptions,
$this->questions($attemptobj, true, $slots, $page, $showall, $displayoptions),
$attemptobj);
$output .= $this->review_next_navigation($attemptobj, $page, $lastpage, $showall);
$output .= $this->footer();
return $output;
} | php | public function review_page(quiz_attempt $attemptobj, $slots, $page, $showall,
$lastpage, mod_quiz_display_options $displayoptions,
$summarydata) {
$output = '';
$output .= $this->header();
$output .= $this->review_summary_table($summarydata, $page);
$output .= $this->review_form($page, $showall, $displayoptions,
$this->questions($attemptobj, true, $slots, $page, $showall, $displayoptions),
$attemptobj);
$output .= $this->review_next_navigation($attemptobj, $page, $lastpage, $showall);
$output .= $this->footer();
return $output;
} | [
"public",
"function",
"review_page",
"(",
"quiz_attempt",
"$",
"attemptobj",
",",
"$",
"slots",
",",
"$",
"page",
",",
"$",
"showall",
",",
"$",
"lastpage",
",",
"mod_quiz_display_options",
"$",
"displayoptions",
",",
"$",
"summarydata",
")",
"{",
"$",
"output",
"=",
"''",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"header",
"(",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"review_summary_table",
"(",
"$",
"summarydata",
",",
"$",
"page",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"review_form",
"(",
"$",
"page",
",",
"$",
"showall",
",",
"$",
"displayoptions",
",",
"$",
"this",
"->",
"questions",
"(",
"$",
"attemptobj",
",",
"true",
",",
"$",
"slots",
",",
"$",
"page",
",",
"$",
"showall",
",",
"$",
"displayoptions",
")",
",",
"$",
"attemptobj",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"review_next_navigation",
"(",
"$",
"attemptobj",
",",
"$",
"page",
",",
"$",
"lastpage",
",",
"$",
"showall",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"footer",
"(",
")",
";",
"return",
"$",
"output",
";",
"}"
] | Builds the review page
@param quiz_attempt $attemptobj an instance of quiz_attempt.
@param array $slots an array of intgers relating to questions.
@param int $page the current page number
@param bool $showall whether to show entire attempt on one page.
@param bool $lastpage if true the current page is the last page.
@param mod_quiz_display_options $displayoptions instance of mod_quiz_display_options.
@param array $summarydata contains all table data
@return $output containing html data. | [
"Builds",
"the",
"review",
"page"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L48-L62 |
214,675 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.filter_review_summary_table | protected function filter_review_summary_table($summarydata, $page) {
if ($page == 0) {
return $summarydata;
}
// Only show some of summary table on subsequent pages.
foreach ($summarydata as $key => $rowdata) {
if (!in_array($key, array('user', 'attemptlist'))) {
unset($summarydata[$key]);
}
}
return $summarydata;
} | php | protected function filter_review_summary_table($summarydata, $page) {
if ($page == 0) {
return $summarydata;
}
// Only show some of summary table on subsequent pages.
foreach ($summarydata as $key => $rowdata) {
if (!in_array($key, array('user', 'attemptlist'))) {
unset($summarydata[$key]);
}
}
return $summarydata;
} | [
"protected",
"function",
"filter_review_summary_table",
"(",
"$",
"summarydata",
",",
"$",
"page",
")",
"{",
"if",
"(",
"$",
"page",
"==",
"0",
")",
"{",
"return",
"$",
"summarydata",
";",
"}",
"// Only show some of summary table on subsequent pages.",
"foreach",
"(",
"$",
"summarydata",
"as",
"$",
"key",
"=>",
"$",
"rowdata",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"key",
",",
"array",
"(",
"'user'",
",",
"'attemptlist'",
")",
")",
")",
"{",
"unset",
"(",
"$",
"summarydata",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"return",
"$",
"summarydata",
";",
"}"
] | Filters the summarydata array.
@param array $summarydata contains row data for table
@param int $page the current page number
@return $summarydata containing filtered row data | [
"Filters",
"the",
"summarydata",
"array",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L117-L130 |
214,676 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.review_summary_table | public function review_summary_table($summarydata, $page) {
$summarydata = $this->filter_review_summary_table($summarydata, $page);
if (empty($summarydata)) {
return '';
}
$output = '';
$output .= html_writer::start_tag('table', array(
'class' => 'generaltable generalbox quizreviewsummary'));
$output .= html_writer::start_tag('tbody');
foreach ($summarydata as $rowdata) {
if ($rowdata['title'] instanceof renderable) {
$title = $this->render($rowdata['title']);
} else {
$title = $rowdata['title'];
}
if ($rowdata['content'] instanceof renderable) {
$content = $this->render($rowdata['content']);
} else {
$content = $rowdata['content'];
}
$output .= html_writer::tag('tr',
html_writer::tag('th', $title, array('class' => 'cell', 'scope' => 'row')) .
html_writer::tag('td', $content, array('class' => 'cell'))
);
}
$output .= html_writer::end_tag('tbody');
$output .= html_writer::end_tag('table');
return $output;
} | php | public function review_summary_table($summarydata, $page) {
$summarydata = $this->filter_review_summary_table($summarydata, $page);
if (empty($summarydata)) {
return '';
}
$output = '';
$output .= html_writer::start_tag('table', array(
'class' => 'generaltable generalbox quizreviewsummary'));
$output .= html_writer::start_tag('tbody');
foreach ($summarydata as $rowdata) {
if ($rowdata['title'] instanceof renderable) {
$title = $this->render($rowdata['title']);
} else {
$title = $rowdata['title'];
}
if ($rowdata['content'] instanceof renderable) {
$content = $this->render($rowdata['content']);
} else {
$content = $rowdata['content'];
}
$output .= html_writer::tag('tr',
html_writer::tag('th', $title, array('class' => 'cell', 'scope' => 'row')) .
html_writer::tag('td', $content, array('class' => 'cell'))
);
}
$output .= html_writer::end_tag('tbody');
$output .= html_writer::end_tag('table');
return $output;
} | [
"public",
"function",
"review_summary_table",
"(",
"$",
"summarydata",
",",
"$",
"page",
")",
"{",
"$",
"summarydata",
"=",
"$",
"this",
"->",
"filter_review_summary_table",
"(",
"$",
"summarydata",
",",
"$",
"page",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"summarydata",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"output",
"=",
"''",
";",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'table'",
",",
"array",
"(",
"'class'",
"=>",
"'generaltable generalbox quizreviewsummary'",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'tbody'",
")",
";",
"foreach",
"(",
"$",
"summarydata",
"as",
"$",
"rowdata",
")",
"{",
"if",
"(",
"$",
"rowdata",
"[",
"'title'",
"]",
"instanceof",
"renderable",
")",
"{",
"$",
"title",
"=",
"$",
"this",
"->",
"render",
"(",
"$",
"rowdata",
"[",
"'title'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"title",
"=",
"$",
"rowdata",
"[",
"'title'",
"]",
";",
"}",
"if",
"(",
"$",
"rowdata",
"[",
"'content'",
"]",
"instanceof",
"renderable",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"render",
"(",
"$",
"rowdata",
"[",
"'content'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"content",
"=",
"$",
"rowdata",
"[",
"'content'",
"]",
";",
"}",
"$",
"output",
".=",
"html_writer",
"::",
"tag",
"(",
"'tr'",
",",
"html_writer",
"::",
"tag",
"(",
"'th'",
",",
"$",
"title",
",",
"array",
"(",
"'class'",
"=>",
"'cell'",
",",
"'scope'",
"=>",
"'row'",
")",
")",
".",
"html_writer",
"::",
"tag",
"(",
"'td'",
",",
"$",
"content",
",",
"array",
"(",
"'class'",
"=>",
"'cell'",
")",
")",
")",
";",
"}",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'tbody'",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'table'",
")",
";",
"return",
"$",
"output",
";",
"}"
] | Outputs the table containing data from summary data array
@param array $summarydata contains row data for table
@param int $page contains the current page number | [
"Outputs",
"the",
"table",
"containing",
"data",
"from",
"summary",
"data",
"array"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L138-L170 |
214,677 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.questions | public function questions(quiz_attempt $attemptobj, $reviewing, $slots, $page, $showall,
mod_quiz_display_options $displayoptions) {
$output = '';
foreach ($slots as $slot) {
$output .= $attemptobj->render_question($slot, $reviewing, $this,
$attemptobj->review_url($slot, $page, $showall));
}
return $output;
} | php | public function questions(quiz_attempt $attemptobj, $reviewing, $slots, $page, $showall,
mod_quiz_display_options $displayoptions) {
$output = '';
foreach ($slots as $slot) {
$output .= $attemptobj->render_question($slot, $reviewing, $this,
$attemptobj->review_url($slot, $page, $showall));
}
return $output;
} | [
"public",
"function",
"questions",
"(",
"quiz_attempt",
"$",
"attemptobj",
",",
"$",
"reviewing",
",",
"$",
"slots",
",",
"$",
"page",
",",
"$",
"showall",
",",
"mod_quiz_display_options",
"$",
"displayoptions",
")",
"{",
"$",
"output",
"=",
"''",
";",
"foreach",
"(",
"$",
"slots",
"as",
"$",
"slot",
")",
"{",
"$",
"output",
".=",
"$",
"attemptobj",
"->",
"render_question",
"(",
"$",
"slot",
",",
"$",
"reviewing",
",",
"$",
"this",
",",
"$",
"attemptobj",
"->",
"review_url",
"(",
"$",
"slot",
",",
"$",
"page",
",",
"$",
"showall",
")",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] | Renders each question
@param quiz_attempt $attemptobj instance of quiz_attempt
@param bool $reviewing
@param array $slots array of intgers relating to questions
@param int $page current page number
@param bool $showall if true shows attempt on single page
@param mod_quiz_display_options $displayoptions instance of mod_quiz_display_options | [
"Renders",
"each",
"question"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L182-L190 |
214,678 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.review_form | public function review_form($page, $showall, $displayoptions, $content, $attemptobj) {
if ($displayoptions->flags != question_display_options::EDITABLE) {
return $content;
}
$this->page->requires->js_init_call('M.mod_quiz.init_review_form', null, false,
quiz_get_js_module());
$output = '';
$output .= html_writer::start_tag('form', array('action' => $attemptobj->review_url(null,
$page, $showall), 'method' => 'post', 'class' => 'questionflagsaveform'));
$output .= html_writer::start_tag('div');
$output .= $content;
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey',
'value' => sesskey()));
$output .= html_writer::start_tag('div', array('class' => 'submitbtns'));
$output .= html_writer::empty_tag('input', array('type' => 'submit',
'class' => 'questionflagsavebutton btn btn-secondary', 'name' => 'savingflags',
'value' => get_string('saveflags', 'question')));
$output .= html_writer::end_tag('div');
$output .= html_writer::end_tag('div');
$output .= html_writer::end_tag('form');
return $output;
} | php | public function review_form($page, $showall, $displayoptions, $content, $attemptobj) {
if ($displayoptions->flags != question_display_options::EDITABLE) {
return $content;
}
$this->page->requires->js_init_call('M.mod_quiz.init_review_form', null, false,
quiz_get_js_module());
$output = '';
$output .= html_writer::start_tag('form', array('action' => $attemptobj->review_url(null,
$page, $showall), 'method' => 'post', 'class' => 'questionflagsaveform'));
$output .= html_writer::start_tag('div');
$output .= $content;
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey',
'value' => sesskey()));
$output .= html_writer::start_tag('div', array('class' => 'submitbtns'));
$output .= html_writer::empty_tag('input', array('type' => 'submit',
'class' => 'questionflagsavebutton btn btn-secondary', 'name' => 'savingflags',
'value' => get_string('saveflags', 'question')));
$output .= html_writer::end_tag('div');
$output .= html_writer::end_tag('div');
$output .= html_writer::end_tag('form');
return $output;
} | [
"public",
"function",
"review_form",
"(",
"$",
"page",
",",
"$",
"showall",
",",
"$",
"displayoptions",
",",
"$",
"content",
",",
"$",
"attemptobj",
")",
"{",
"if",
"(",
"$",
"displayoptions",
"->",
"flags",
"!=",
"question_display_options",
"::",
"EDITABLE",
")",
"{",
"return",
"$",
"content",
";",
"}",
"$",
"this",
"->",
"page",
"->",
"requires",
"->",
"js_init_call",
"(",
"'M.mod_quiz.init_review_form'",
",",
"null",
",",
"false",
",",
"quiz_get_js_module",
"(",
")",
")",
";",
"$",
"output",
"=",
"''",
";",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'form'",
",",
"array",
"(",
"'action'",
"=>",
"$",
"attemptobj",
"->",
"review_url",
"(",
"null",
",",
"$",
"page",
",",
"$",
"showall",
")",
",",
"'method'",
"=>",
"'post'",
",",
"'class'",
"=>",
"'questionflagsaveform'",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
")",
";",
"$",
"output",
".=",
"$",
"content",
";",
"$",
"output",
".=",
"html_writer",
"::",
"empty_tag",
"(",
"'input'",
",",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'name'",
"=>",
"'sesskey'",
",",
"'value'",
"=>",
"sesskey",
"(",
")",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"'submitbtns'",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"empty_tag",
"(",
"'input'",
",",
"array",
"(",
"'type'",
"=>",
"'submit'",
",",
"'class'",
"=>",
"'questionflagsavebutton btn btn-secondary'",
",",
"'name'",
"=>",
"'savingflags'",
",",
"'value'",
"=>",
"get_string",
"(",
"'saveflags'",
",",
"'question'",
")",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'form'",
")",
";",
"return",
"$",
"output",
";",
"}"
] | Renders the main bit of the review page.
@param array $summarydata contain row data for table
@param int $page current page number
@param mod_quiz_display_options $displayoptions instance of mod_quiz_display_options
@param $content contains each question
@param quiz_attempt $attemptobj instance of quiz_attempt
@param bool $showall if true display attempt on one page | [
"Renders",
"the",
"main",
"bit",
"of",
"the",
"review",
"page",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L202-L226 |
214,679 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.finish_review_link | public function finish_review_link(quiz_attempt $attemptobj) {
$url = $attemptobj->view_url();
if ($attemptobj->get_access_manager(time())->attempt_must_be_in_popup()) {
$this->page->requires->js_init_call('M.mod_quiz.secure_window.init_close_button',
array($url), false, quiz_get_js_module());
return html_writer::empty_tag('input', array('type' => 'button',
'value' => get_string('finishreview', 'quiz'),
'id' => 'secureclosebutton',
'class' => 'mod_quiz-next-nav btn btn-primary'));
} else {
return html_writer::link($url, get_string('finishreview', 'quiz'),
array('class' => 'mod_quiz-next-nav'));
}
} | php | public function finish_review_link(quiz_attempt $attemptobj) {
$url = $attemptobj->view_url();
if ($attemptobj->get_access_manager(time())->attempt_must_be_in_popup()) {
$this->page->requires->js_init_call('M.mod_quiz.secure_window.init_close_button',
array($url), false, quiz_get_js_module());
return html_writer::empty_tag('input', array('type' => 'button',
'value' => get_string('finishreview', 'quiz'),
'id' => 'secureclosebutton',
'class' => 'mod_quiz-next-nav btn btn-primary'));
} else {
return html_writer::link($url, get_string('finishreview', 'quiz'),
array('class' => 'mod_quiz-next-nav'));
}
} | [
"public",
"function",
"finish_review_link",
"(",
"quiz_attempt",
"$",
"attemptobj",
")",
"{",
"$",
"url",
"=",
"$",
"attemptobj",
"->",
"view_url",
"(",
")",
";",
"if",
"(",
"$",
"attemptobj",
"->",
"get_access_manager",
"(",
"time",
"(",
")",
")",
"->",
"attempt_must_be_in_popup",
"(",
")",
")",
"{",
"$",
"this",
"->",
"page",
"->",
"requires",
"->",
"js_init_call",
"(",
"'M.mod_quiz.secure_window.init_close_button'",
",",
"array",
"(",
"$",
"url",
")",
",",
"false",
",",
"quiz_get_js_module",
"(",
")",
")",
";",
"return",
"html_writer",
"::",
"empty_tag",
"(",
"'input'",
",",
"array",
"(",
"'type'",
"=>",
"'button'",
",",
"'value'",
"=>",
"get_string",
"(",
"'finishreview'",
",",
"'quiz'",
")",
",",
"'id'",
"=>",
"'secureclosebutton'",
",",
"'class'",
"=>",
"'mod_quiz-next-nav btn btn-primary'",
")",
")",
";",
"}",
"else",
"{",
"return",
"html_writer",
"::",
"link",
"(",
"$",
"url",
",",
"get_string",
"(",
"'finishreview'",
",",
"'quiz'",
")",
",",
"array",
"(",
"'class'",
"=>",
"'mod_quiz-next-nav'",
")",
")",
";",
"}",
"}"
] | Returns either a liink or button
@param quiz_attempt $attemptobj instance of quiz_attempt | [
"Returns",
"either",
"a",
"liink",
"or",
"button"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L233-L248 |
214,680 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.countdown_timer | public function countdown_timer(quiz_attempt $attemptobj, $timenow) {
$timeleft = $attemptobj->get_time_left_display($timenow);
if ($timeleft !== false) {
$ispreview = $attemptobj->is_preview();
$timerstartvalue = $timeleft;
if (!$ispreview) {
// Make sure the timer starts just above zero. If $timeleft was <= 0, then
// this will just have the effect of causing the quiz to be submitted immediately.
$timerstartvalue = max($timerstartvalue, 1);
}
$this->initialise_timer($timerstartvalue, $ispreview);
}
return html_writer::tag('div', get_string('timeleft', 'quiz') . ' ' .
html_writer::tag('span', '', array('id' => 'quiz-time-left')),
array('id' => 'quiz-timer', 'role' => 'timer',
'aria-atomic' => 'true', 'aria-relevant' => 'text'));
} | php | public function countdown_timer(quiz_attempt $attemptobj, $timenow) {
$timeleft = $attemptobj->get_time_left_display($timenow);
if ($timeleft !== false) {
$ispreview = $attemptobj->is_preview();
$timerstartvalue = $timeleft;
if (!$ispreview) {
// Make sure the timer starts just above zero. If $timeleft was <= 0, then
// this will just have the effect of causing the quiz to be submitted immediately.
$timerstartvalue = max($timerstartvalue, 1);
}
$this->initialise_timer($timerstartvalue, $ispreview);
}
return html_writer::tag('div', get_string('timeleft', 'quiz') . ' ' .
html_writer::tag('span', '', array('id' => 'quiz-time-left')),
array('id' => 'quiz-timer', 'role' => 'timer',
'aria-atomic' => 'true', 'aria-relevant' => 'text'));
} | [
"public",
"function",
"countdown_timer",
"(",
"quiz_attempt",
"$",
"attemptobj",
",",
"$",
"timenow",
")",
"{",
"$",
"timeleft",
"=",
"$",
"attemptobj",
"->",
"get_time_left_display",
"(",
"$",
"timenow",
")",
";",
"if",
"(",
"$",
"timeleft",
"!==",
"false",
")",
"{",
"$",
"ispreview",
"=",
"$",
"attemptobj",
"->",
"is_preview",
"(",
")",
";",
"$",
"timerstartvalue",
"=",
"$",
"timeleft",
";",
"if",
"(",
"!",
"$",
"ispreview",
")",
"{",
"// Make sure the timer starts just above zero. If $timeleft was <= 0, then",
"// this will just have the effect of causing the quiz to be submitted immediately.",
"$",
"timerstartvalue",
"=",
"max",
"(",
"$",
"timerstartvalue",
",",
"1",
")",
";",
"}",
"$",
"this",
"->",
"initialise_timer",
"(",
"$",
"timerstartvalue",
",",
"$",
"ispreview",
")",
";",
"}",
"return",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"get_string",
"(",
"'timeleft'",
",",
"'quiz'",
")",
".",
"' '",
".",
"html_writer",
"::",
"tag",
"(",
"'span'",
",",
"''",
",",
"array",
"(",
"'id'",
"=>",
"'quiz-time-left'",
")",
")",
",",
"array",
"(",
"'id'",
"=>",
"'quiz-timer'",
",",
"'role'",
"=>",
"'timer'",
",",
"'aria-atomic'",
"=>",
"'true'",
",",
"'aria-relevant'",
"=>",
"'text'",
")",
")",
";",
"}"
] | Return the HTML of the quiz timer.
@return string HTML content. | [
"Return",
"the",
"HTML",
"of",
"the",
"quiz",
"timer",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L283-L301 |
214,681 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.navigation_panel | public function navigation_panel(quiz_nav_panel_base $panel) {
$output = '';
$userpicture = $panel->user_picture();
if ($userpicture) {
$fullname = fullname($userpicture->user);
if ($userpicture->size === true) {
$fullname = html_writer::div($fullname);
}
$output .= html_writer::tag('div', $this->render($userpicture) . $fullname,
array('id' => 'user-picture', 'class' => 'clearfix'));
}
$output .= $panel->render_before_button_bits($this);
$bcc = $panel->get_button_container_class();
$output .= html_writer::start_tag('div', array('class' => "qn_buttons clearfix $bcc"));
foreach ($panel->get_question_buttons() as $button) {
$output .= $this->render($button);
}
$output .= html_writer::end_tag('div');
$output .= html_writer::tag('div', $panel->render_end_bits($this),
array('class' => 'othernav'));
$this->page->requires->js_init_call('M.mod_quiz.nav.init', null, false,
quiz_get_js_module());
return $output;
} | php | public function navigation_panel(quiz_nav_panel_base $panel) {
$output = '';
$userpicture = $panel->user_picture();
if ($userpicture) {
$fullname = fullname($userpicture->user);
if ($userpicture->size === true) {
$fullname = html_writer::div($fullname);
}
$output .= html_writer::tag('div', $this->render($userpicture) . $fullname,
array('id' => 'user-picture', 'class' => 'clearfix'));
}
$output .= $panel->render_before_button_bits($this);
$bcc = $panel->get_button_container_class();
$output .= html_writer::start_tag('div', array('class' => "qn_buttons clearfix $bcc"));
foreach ($panel->get_question_buttons() as $button) {
$output .= $this->render($button);
}
$output .= html_writer::end_tag('div');
$output .= html_writer::tag('div', $panel->render_end_bits($this),
array('class' => 'othernav'));
$this->page->requires->js_init_call('M.mod_quiz.nav.init', null, false,
quiz_get_js_module());
return $output;
} | [
"public",
"function",
"navigation_panel",
"(",
"quiz_nav_panel_base",
"$",
"panel",
")",
"{",
"$",
"output",
"=",
"''",
";",
"$",
"userpicture",
"=",
"$",
"panel",
"->",
"user_picture",
"(",
")",
";",
"if",
"(",
"$",
"userpicture",
")",
"{",
"$",
"fullname",
"=",
"fullname",
"(",
"$",
"userpicture",
"->",
"user",
")",
";",
"if",
"(",
"$",
"userpicture",
"->",
"size",
"===",
"true",
")",
"{",
"$",
"fullname",
"=",
"html_writer",
"::",
"div",
"(",
"$",
"fullname",
")",
";",
"}",
"$",
"output",
".=",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"$",
"this",
"->",
"render",
"(",
"$",
"userpicture",
")",
".",
"$",
"fullname",
",",
"array",
"(",
"'id'",
"=>",
"'user-picture'",
",",
"'class'",
"=>",
"'clearfix'",
")",
")",
";",
"}",
"$",
"output",
".=",
"$",
"panel",
"->",
"render_before_button_bits",
"(",
"$",
"this",
")",
";",
"$",
"bcc",
"=",
"$",
"panel",
"->",
"get_button_container_class",
"(",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"\"qn_buttons clearfix $bcc\"",
")",
")",
";",
"foreach",
"(",
"$",
"panel",
"->",
"get_question_buttons",
"(",
")",
"as",
"$",
"button",
")",
"{",
"$",
"output",
".=",
"$",
"this",
"->",
"render",
"(",
"$",
"button",
")",
";",
"}",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"$",
"panel",
"->",
"render_end_bits",
"(",
"$",
"this",
")",
",",
"array",
"(",
"'class'",
"=>",
"'othernav'",
")",
")",
";",
"$",
"this",
"->",
"page",
"->",
"requires",
"->",
"js_init_call",
"(",
"'M.mod_quiz.nav.init'",
",",
"null",
",",
"false",
",",
"quiz_get_js_module",
"(",
")",
")",
";",
"return",
"$",
"output",
";",
"}"
] | Outputs the navigation block panel
@param quiz_nav_panel_base $panel instance of quiz_nav_panel_base | [
"Outputs",
"the",
"navigation",
"block",
"panel"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L317-L345 |
214,682 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.render_quiz_nav_question_button | protected function render_quiz_nav_question_button(quiz_nav_question_button $button) {
$classes = array('qnbutton', $button->stateclass, $button->navmethod, 'btn', 'btn-secondary');
$extrainfo = array();
if ($button->currentpage) {
$classes[] = 'thispage';
$extrainfo[] = get_string('onthispage', 'quiz');
}
// Flagged?
if ($button->flagged) {
$classes[] = 'flagged';
$flaglabel = get_string('flagged', 'question');
} else {
$flaglabel = '';
}
$extrainfo[] = html_writer::tag('span', $flaglabel, array('class' => 'flagstate'));
if (is_numeric($button->number)) {
$qnostring = 'questionnonav';
} else {
$qnostring = 'questionnonavinfo';
}
$a = new stdClass();
$a->number = $button->number;
$a->attributes = implode(' ', $extrainfo);
$tagcontents = html_writer::tag('span', '', array('class' => 'thispageholder')) .
html_writer::tag('span', '', array('class' => 'trafficlight')) .
get_string($qnostring, 'quiz', $a);
$tagattributes = array('class' => implode(' ', $classes), 'id' => $button->id,
'title' => $button->statestring, 'data-quiz-page' => $button->page);
if ($button->url) {
return html_writer::link($button->url, $tagcontents, $tagattributes);
} else {
return html_writer::tag('span', $tagcontents, $tagattributes);
}
} | php | protected function render_quiz_nav_question_button(quiz_nav_question_button $button) {
$classes = array('qnbutton', $button->stateclass, $button->navmethod, 'btn', 'btn-secondary');
$extrainfo = array();
if ($button->currentpage) {
$classes[] = 'thispage';
$extrainfo[] = get_string('onthispage', 'quiz');
}
// Flagged?
if ($button->flagged) {
$classes[] = 'flagged';
$flaglabel = get_string('flagged', 'question');
} else {
$flaglabel = '';
}
$extrainfo[] = html_writer::tag('span', $flaglabel, array('class' => 'flagstate'));
if (is_numeric($button->number)) {
$qnostring = 'questionnonav';
} else {
$qnostring = 'questionnonavinfo';
}
$a = new stdClass();
$a->number = $button->number;
$a->attributes = implode(' ', $extrainfo);
$tagcontents = html_writer::tag('span', '', array('class' => 'thispageholder')) .
html_writer::tag('span', '', array('class' => 'trafficlight')) .
get_string($qnostring, 'quiz', $a);
$tagattributes = array('class' => implode(' ', $classes), 'id' => $button->id,
'title' => $button->statestring, 'data-quiz-page' => $button->page);
if ($button->url) {
return html_writer::link($button->url, $tagcontents, $tagattributes);
} else {
return html_writer::tag('span', $tagcontents, $tagattributes);
}
} | [
"protected",
"function",
"render_quiz_nav_question_button",
"(",
"quiz_nav_question_button",
"$",
"button",
")",
"{",
"$",
"classes",
"=",
"array",
"(",
"'qnbutton'",
",",
"$",
"button",
"->",
"stateclass",
",",
"$",
"button",
"->",
"navmethod",
",",
"'btn'",
",",
"'btn-secondary'",
")",
";",
"$",
"extrainfo",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"button",
"->",
"currentpage",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"'thispage'",
";",
"$",
"extrainfo",
"[",
"]",
"=",
"get_string",
"(",
"'onthispage'",
",",
"'quiz'",
")",
";",
"}",
"// Flagged?",
"if",
"(",
"$",
"button",
"->",
"flagged",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"'flagged'",
";",
"$",
"flaglabel",
"=",
"get_string",
"(",
"'flagged'",
",",
"'question'",
")",
";",
"}",
"else",
"{",
"$",
"flaglabel",
"=",
"''",
";",
"}",
"$",
"extrainfo",
"[",
"]",
"=",
"html_writer",
"::",
"tag",
"(",
"'span'",
",",
"$",
"flaglabel",
",",
"array",
"(",
"'class'",
"=>",
"'flagstate'",
")",
")",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"button",
"->",
"number",
")",
")",
"{",
"$",
"qnostring",
"=",
"'questionnonav'",
";",
"}",
"else",
"{",
"$",
"qnostring",
"=",
"'questionnonavinfo'",
";",
"}",
"$",
"a",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"a",
"->",
"number",
"=",
"$",
"button",
"->",
"number",
";",
"$",
"a",
"->",
"attributes",
"=",
"implode",
"(",
"' '",
",",
"$",
"extrainfo",
")",
";",
"$",
"tagcontents",
"=",
"html_writer",
"::",
"tag",
"(",
"'span'",
",",
"''",
",",
"array",
"(",
"'class'",
"=>",
"'thispageholder'",
")",
")",
".",
"html_writer",
"::",
"tag",
"(",
"'span'",
",",
"''",
",",
"array",
"(",
"'class'",
"=>",
"'trafficlight'",
")",
")",
".",
"get_string",
"(",
"$",
"qnostring",
",",
"'quiz'",
",",
"$",
"a",
")",
";",
"$",
"tagattributes",
"=",
"array",
"(",
"'class'",
"=>",
"implode",
"(",
"' '",
",",
"$",
"classes",
")",
",",
"'id'",
"=>",
"$",
"button",
"->",
"id",
",",
"'title'",
"=>",
"$",
"button",
"->",
"statestring",
",",
"'data-quiz-page'",
"=>",
"$",
"button",
"->",
"page",
")",
";",
"if",
"(",
"$",
"button",
"->",
"url",
")",
"{",
"return",
"html_writer",
"::",
"link",
"(",
"$",
"button",
"->",
"url",
",",
"$",
"tagcontents",
",",
"$",
"tagattributes",
")",
";",
"}",
"else",
"{",
"return",
"html_writer",
"::",
"tag",
"(",
"'span'",
",",
"$",
"tagcontents",
",",
"$",
"tagattributes",
")",
";",
"}",
"}"
] | Display a quiz navigation button.
@param quiz_nav_question_button $button
@return string HTML fragment. | [
"Display",
"a",
"quiz",
"navigation",
"button",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L353-L391 |
214,683 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.render_mod_quiz_links_to_other_attempts | protected function render_mod_quiz_links_to_other_attempts(
mod_quiz_links_to_other_attempts $links) {
$attemptlinks = array();
foreach ($links->links as $attempt => $url) {
if (!$url) {
$attemptlinks[] = html_writer::tag('strong', $attempt);
} else if ($url instanceof renderable) {
$attemptlinks[] = $this->render($url);
} else {
$attemptlinks[] = html_writer::link($url, $attempt);
}
}
return implode(', ', $attemptlinks);
} | php | protected function render_mod_quiz_links_to_other_attempts(
mod_quiz_links_to_other_attempts $links) {
$attemptlinks = array();
foreach ($links->links as $attempt => $url) {
if (!$url) {
$attemptlinks[] = html_writer::tag('strong', $attempt);
} else if ($url instanceof renderable) {
$attemptlinks[] = $this->render($url);
} else {
$attemptlinks[] = html_writer::link($url, $attempt);
}
}
return implode(', ', $attemptlinks);
} | [
"protected",
"function",
"render_mod_quiz_links_to_other_attempts",
"(",
"mod_quiz_links_to_other_attempts",
"$",
"links",
")",
"{",
"$",
"attemptlinks",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"links",
"->",
"links",
"as",
"$",
"attempt",
"=>",
"$",
"url",
")",
"{",
"if",
"(",
"!",
"$",
"url",
")",
"{",
"$",
"attemptlinks",
"[",
"]",
"=",
"html_writer",
"::",
"tag",
"(",
"'strong'",
",",
"$",
"attempt",
")",
";",
"}",
"else",
"if",
"(",
"$",
"url",
"instanceof",
"renderable",
")",
"{",
"$",
"attemptlinks",
"[",
"]",
"=",
"$",
"this",
"->",
"render",
"(",
"$",
"url",
")",
";",
"}",
"else",
"{",
"$",
"attemptlinks",
"[",
"]",
"=",
"html_writer",
"::",
"link",
"(",
"$",
"url",
",",
"$",
"attempt",
")",
";",
"}",
"}",
"return",
"implode",
"(",
"', '",
",",
"$",
"attemptlinks",
")",
";",
"}"
] | outputs the link the other attempts.
@param mod_quiz_links_to_other_attempts $links | [
"outputs",
"the",
"link",
"the",
"other",
"attempts",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L408-L421 |
214,684 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.quiz_notices | public function quiz_notices($messages) {
if (!$messages) {
return '';
}
return $this->box($this->heading(get_string('accessnoticesheader', 'quiz'), 3) .
$this->access_messages($messages), 'quizaccessnotices');
} | php | public function quiz_notices($messages) {
if (!$messages) {
return '';
}
return $this->box($this->heading(get_string('accessnoticesheader', 'quiz'), 3) .
$this->access_messages($messages), 'quizaccessnotices');
} | [
"public",
"function",
"quiz_notices",
"(",
"$",
"messages",
")",
"{",
"if",
"(",
"!",
"$",
"messages",
")",
"{",
"return",
"''",
";",
"}",
"return",
"$",
"this",
"->",
"box",
"(",
"$",
"this",
"->",
"heading",
"(",
"get_string",
"(",
"'accessnoticesheader'",
",",
"'quiz'",
")",
",",
"3",
")",
".",
"$",
"this",
"->",
"access_messages",
"(",
"$",
"messages",
")",
",",
"'quizaccessnotices'",
")",
";",
"}"
] | Returns any notices.
@param array $messages | [
"Returns",
"any",
"notices",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L460-L466 |
214,685 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.attempt_form | public function attempt_form($attemptobj, $page, $slots, $id, $nextpage) {
$output = '';
// Start the form.
$output .= html_writer::start_tag('form',
array('action' => new moodle_url($attemptobj->processattempt_url(),
array('cmid' => $attemptobj->get_cmid())), 'method' => 'post',
'enctype' => 'multipart/form-data', 'accept-charset' => 'utf-8',
'id' => 'responseform'));
$output .= html_writer::start_tag('div');
// Print all the questions.
foreach ($slots as $slot) {
$output .= $attemptobj->render_question($slot, false, $this,
$attemptobj->attempt_url($slot, $page), $this);
}
$navmethod = $attemptobj->get_quiz()->navmethod;
$output .= $this->attempt_navigation_buttons($page, $attemptobj->is_last_page($page), $navmethod);
// Some hidden fields to trach what is going on.
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'attempt',
'value' => $attemptobj->get_attemptid()));
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'thispage',
'value' => $page, 'id' => 'followingpage'));
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'nextpage',
'value' => $nextpage));
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'timeup',
'value' => '0', 'id' => 'timeup'));
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey',
'value' => sesskey()));
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'scrollpos',
'value' => '', 'id' => 'scrollpos'));
// Add a hidden field with questionids. Do this at the end of the form, so
// if you navigate before the form has finished loading, it does not wipe all
// the student's answers.
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'slots',
'value' => implode(',', $attemptobj->get_active_slots($page))));
// Finish the form.
$output .= html_writer::end_tag('div');
$output .= html_writer::end_tag('form');
$output .= $this->connection_warning();
return $output;
} | php | public function attempt_form($attemptobj, $page, $slots, $id, $nextpage) {
$output = '';
// Start the form.
$output .= html_writer::start_tag('form',
array('action' => new moodle_url($attemptobj->processattempt_url(),
array('cmid' => $attemptobj->get_cmid())), 'method' => 'post',
'enctype' => 'multipart/form-data', 'accept-charset' => 'utf-8',
'id' => 'responseform'));
$output .= html_writer::start_tag('div');
// Print all the questions.
foreach ($slots as $slot) {
$output .= $attemptobj->render_question($slot, false, $this,
$attemptobj->attempt_url($slot, $page), $this);
}
$navmethod = $attemptobj->get_quiz()->navmethod;
$output .= $this->attempt_navigation_buttons($page, $attemptobj->is_last_page($page), $navmethod);
// Some hidden fields to trach what is going on.
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'attempt',
'value' => $attemptobj->get_attemptid()));
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'thispage',
'value' => $page, 'id' => 'followingpage'));
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'nextpage',
'value' => $nextpage));
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'timeup',
'value' => '0', 'id' => 'timeup'));
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey',
'value' => sesskey()));
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'scrollpos',
'value' => '', 'id' => 'scrollpos'));
// Add a hidden field with questionids. Do this at the end of the form, so
// if you navigate before the form has finished loading, it does not wipe all
// the student's answers.
$output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'slots',
'value' => implode(',', $attemptobj->get_active_slots($page))));
// Finish the form.
$output .= html_writer::end_tag('div');
$output .= html_writer::end_tag('form');
$output .= $this->connection_warning();
return $output;
} | [
"public",
"function",
"attempt_form",
"(",
"$",
"attemptobj",
",",
"$",
"page",
",",
"$",
"slots",
",",
"$",
"id",
",",
"$",
"nextpage",
")",
"{",
"$",
"output",
"=",
"''",
";",
"// Start the form.",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'form'",
",",
"array",
"(",
"'action'",
"=>",
"new",
"moodle_url",
"(",
"$",
"attemptobj",
"->",
"processattempt_url",
"(",
")",
",",
"array",
"(",
"'cmid'",
"=>",
"$",
"attemptobj",
"->",
"get_cmid",
"(",
")",
")",
")",
",",
"'method'",
"=>",
"'post'",
",",
"'enctype'",
"=>",
"'multipart/form-data'",
",",
"'accept-charset'",
"=>",
"'utf-8'",
",",
"'id'",
"=>",
"'responseform'",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
")",
";",
"// Print all the questions.",
"foreach",
"(",
"$",
"slots",
"as",
"$",
"slot",
")",
"{",
"$",
"output",
".=",
"$",
"attemptobj",
"->",
"render_question",
"(",
"$",
"slot",
",",
"false",
",",
"$",
"this",
",",
"$",
"attemptobj",
"->",
"attempt_url",
"(",
"$",
"slot",
",",
"$",
"page",
")",
",",
"$",
"this",
")",
";",
"}",
"$",
"navmethod",
"=",
"$",
"attemptobj",
"->",
"get_quiz",
"(",
")",
"->",
"navmethod",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"attempt_navigation_buttons",
"(",
"$",
"page",
",",
"$",
"attemptobj",
"->",
"is_last_page",
"(",
"$",
"page",
")",
",",
"$",
"navmethod",
")",
";",
"// Some hidden fields to trach what is going on.",
"$",
"output",
".=",
"html_writer",
"::",
"empty_tag",
"(",
"'input'",
",",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'name'",
"=>",
"'attempt'",
",",
"'value'",
"=>",
"$",
"attemptobj",
"->",
"get_attemptid",
"(",
")",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"empty_tag",
"(",
"'input'",
",",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'name'",
"=>",
"'thispage'",
",",
"'value'",
"=>",
"$",
"page",
",",
"'id'",
"=>",
"'followingpage'",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"empty_tag",
"(",
"'input'",
",",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'name'",
"=>",
"'nextpage'",
",",
"'value'",
"=>",
"$",
"nextpage",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"empty_tag",
"(",
"'input'",
",",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'name'",
"=>",
"'timeup'",
",",
"'value'",
"=>",
"'0'",
",",
"'id'",
"=>",
"'timeup'",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"empty_tag",
"(",
"'input'",
",",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'name'",
"=>",
"'sesskey'",
",",
"'value'",
"=>",
"sesskey",
"(",
")",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"empty_tag",
"(",
"'input'",
",",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'name'",
"=>",
"'scrollpos'",
",",
"'value'",
"=>",
"''",
",",
"'id'",
"=>",
"'scrollpos'",
")",
")",
";",
"// Add a hidden field with questionids. Do this at the end of the form, so",
"// if you navigate before the form has finished loading, it does not wipe all",
"// the student's answers.",
"$",
"output",
".=",
"html_writer",
"::",
"empty_tag",
"(",
"'input'",
",",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'name'",
"=>",
"'slots'",
",",
"'value'",
"=>",
"implode",
"(",
"','",
",",
"$",
"attemptobj",
"->",
"get_active_slots",
"(",
"$",
"page",
")",
")",
")",
")",
";",
"// Finish the form.",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'form'",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"connection_warning",
"(",
")",
";",
"return",
"$",
"output",
";",
"}"
] | Ouputs the form for making an attempt
@param quiz_attempt $attemptobj
@param int $page Current page number
@param array $slots Array of integers relating to questions
@param int $id ID of the attempt
@param int $nextpage Next page number | [
"Ouputs",
"the",
"form",
"for",
"making",
"an",
"attempt"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L477-L524 |
214,686 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.redo_question_button | public function redo_question_button($slot, $disabled) {
$attributes = array('type' => 'submit', 'name' => 'redoslot' . $slot,
'value' => get_string('redoquestion', 'quiz'), 'class' => 'mod_quiz-redo_question_button');
if ($disabled) {
$attributes['disabled'] = 'disabled';
}
return html_writer::div(html_writer::empty_tag('input', $attributes));
} | php | public function redo_question_button($slot, $disabled) {
$attributes = array('type' => 'submit', 'name' => 'redoslot' . $slot,
'value' => get_string('redoquestion', 'quiz'), 'class' => 'mod_quiz-redo_question_button');
if ($disabled) {
$attributes['disabled'] = 'disabled';
}
return html_writer::div(html_writer::empty_tag('input', $attributes));
} | [
"public",
"function",
"redo_question_button",
"(",
"$",
"slot",
",",
"$",
"disabled",
")",
"{",
"$",
"attributes",
"=",
"array",
"(",
"'type'",
"=>",
"'submit'",
",",
"'name'",
"=>",
"'redoslot'",
".",
"$",
"slot",
",",
"'value'",
"=>",
"get_string",
"(",
"'redoquestion'",
",",
"'quiz'",
")",
",",
"'class'",
"=>",
"'mod_quiz-redo_question_button'",
")",
";",
"if",
"(",
"$",
"disabled",
")",
"{",
"$",
"attributes",
"[",
"'disabled'",
"]",
"=",
"'disabled'",
";",
"}",
"return",
"html_writer",
"::",
"div",
"(",
"html_writer",
"::",
"empty_tag",
"(",
"'input'",
",",
"$",
"attributes",
")",
")",
";",
"}"
] | Render a button which allows students to redo a question in the attempt.
@param int $slot the number of the slot to generate the button for.
@param bool $disabled if true, output the button disabled.
@return string HTML fragment. | [
"Render",
"a",
"button",
"which",
"allows",
"students",
"to",
"redo",
"a",
"question",
"in",
"the",
"attempt",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L561-L568 |
214,687 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.initialise_timer | public function initialise_timer($timerstartvalue, $ispreview) {
$options = array($timerstartvalue, (bool)$ispreview);
$this->page->requires->js_init_call('M.mod_quiz.timer.init', $options, false, quiz_get_js_module());
} | php | public function initialise_timer($timerstartvalue, $ispreview) {
$options = array($timerstartvalue, (bool)$ispreview);
$this->page->requires->js_init_call('M.mod_quiz.timer.init', $options, false, quiz_get_js_module());
} | [
"public",
"function",
"initialise_timer",
"(",
"$",
"timerstartvalue",
",",
"$",
"ispreview",
")",
"{",
"$",
"options",
"=",
"array",
"(",
"$",
"timerstartvalue",
",",
"(",
"bool",
")",
"$",
"ispreview",
")",
";",
"$",
"this",
"->",
"page",
"->",
"requires",
"->",
"js_init_call",
"(",
"'M.mod_quiz.timer.init'",
",",
"$",
"options",
",",
"false",
",",
"quiz_get_js_module",
"(",
")",
")",
";",
"}"
] | Output the JavaScript required to initialise the countdown timer.
@param int $timerstartvalue time remaining, in seconds. | [
"Output",
"the",
"JavaScript",
"required",
"to",
"initialise",
"the",
"countdown",
"timer",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L574-L577 |
214,688 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.close_attempt_popup | public function close_attempt_popup($url, $message = '') {
$output = '';
$output .= $this->header();
$output .= $this->box_start();
if ($message) {
$output .= html_writer::tag('p', $message);
$output .= html_writer::tag('p', get_string('windowclosing', 'quiz'));
$delay = 5;
} else {
$output .= html_writer::tag('p', get_string('pleaseclose', 'quiz'));
$delay = 0;
}
$this->page->requires->js_init_call('M.mod_quiz.secure_window.close',
array($url, $delay), false, quiz_get_js_module());
$output .= $this->box_end();
$output .= $this->footer();
return $output;
} | php | public function close_attempt_popup($url, $message = '') {
$output = '';
$output .= $this->header();
$output .= $this->box_start();
if ($message) {
$output .= html_writer::tag('p', $message);
$output .= html_writer::tag('p', get_string('windowclosing', 'quiz'));
$delay = 5;
} else {
$output .= html_writer::tag('p', get_string('pleaseclose', 'quiz'));
$delay = 0;
}
$this->page->requires->js_init_call('M.mod_quiz.secure_window.close',
array($url, $delay), false, quiz_get_js_module());
$output .= $this->box_end();
$output .= $this->footer();
return $output;
} | [
"public",
"function",
"close_attempt_popup",
"(",
"$",
"url",
",",
"$",
"message",
"=",
"''",
")",
"{",
"$",
"output",
"=",
"''",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"header",
"(",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"box_start",
"(",
")",
";",
"if",
"(",
"$",
"message",
")",
"{",
"$",
"output",
".=",
"html_writer",
"::",
"tag",
"(",
"'p'",
",",
"$",
"message",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"tag",
"(",
"'p'",
",",
"get_string",
"(",
"'windowclosing'",
",",
"'quiz'",
")",
")",
";",
"$",
"delay",
"=",
"5",
";",
"}",
"else",
"{",
"$",
"output",
".=",
"html_writer",
"::",
"tag",
"(",
"'p'",
",",
"get_string",
"(",
"'pleaseclose'",
",",
"'quiz'",
")",
")",
";",
"$",
"delay",
"=",
"0",
";",
"}",
"$",
"this",
"->",
"page",
"->",
"requires",
"->",
"js_init_call",
"(",
"'M.mod_quiz.secure_window.close'",
",",
"array",
"(",
"$",
"url",
",",
"$",
"delay",
")",
",",
"false",
",",
"quiz_get_js_module",
"(",
")",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"box_end",
"(",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"footer",
"(",
")",
";",
"return",
"$",
"output",
";",
"}"
] | Output a page with an optional message, and JavaScript code to close the
current window and redirect the parent window to a new URL.
@param moodle_url $url the URL to redirect the parent window to.
@param string $message message to display before closing the window. (optional)
@return string HTML to output. | [
"Output",
"a",
"page",
"with",
"an",
"optional",
"message",
"and",
"JavaScript",
"code",
"to",
"close",
"the",
"current",
"window",
"and",
"redirect",
"the",
"parent",
"window",
"to",
"a",
"new",
"URL",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L586-L605 |
214,689 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.summary_page | public function summary_page($attemptobj, $displayoptions) {
$output = '';
$output .= $this->header();
$output .= $this->heading(format_string($attemptobj->get_quiz_name()));
$output .= $this->heading(get_string('summaryofattempt', 'quiz'), 3);
$output .= $this->summary_table($attemptobj, $displayoptions);
$output .= $this->summary_page_controls($attemptobj);
$output .= $this->footer();
return $output;
} | php | public function summary_page($attemptobj, $displayoptions) {
$output = '';
$output .= $this->header();
$output .= $this->heading(format_string($attemptobj->get_quiz_name()));
$output .= $this->heading(get_string('summaryofattempt', 'quiz'), 3);
$output .= $this->summary_table($attemptobj, $displayoptions);
$output .= $this->summary_page_controls($attemptobj);
$output .= $this->footer();
return $output;
} | [
"public",
"function",
"summary_page",
"(",
"$",
"attemptobj",
",",
"$",
"displayoptions",
")",
"{",
"$",
"output",
"=",
"''",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"header",
"(",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"heading",
"(",
"format_string",
"(",
"$",
"attemptobj",
"->",
"get_quiz_name",
"(",
")",
")",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"heading",
"(",
"get_string",
"(",
"'summaryofattempt'",
",",
"'quiz'",
")",
",",
"3",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"summary_table",
"(",
"$",
"attemptobj",
",",
"$",
"displayoptions",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"summary_page_controls",
"(",
"$",
"attemptobj",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"footer",
"(",
")",
";",
"return",
"$",
"output",
";",
"}"
] | Create the summary page
@param quiz_attempt $attemptobj
@param mod_quiz_display_options $displayoptions | [
"Create",
"the",
"summary",
"page"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L632-L641 |
214,690 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.summary_table | public function summary_table($attemptobj, $displayoptions) {
// Prepare the summary table header.
$table = new html_table();
$table->attributes['class'] = 'generaltable quizsummaryofattempt boxaligncenter';
$table->head = array(get_string('question', 'quiz'), get_string('status', 'quiz'));
$table->align = array('left', 'left');
$table->size = array('', '');
$markscolumn = $displayoptions->marks >= question_display_options::MARK_AND_MAX;
if ($markscolumn) {
$table->head[] = get_string('marks', 'quiz');
$table->align[] = 'left';
$table->size[] = '';
}
$tablewidth = count($table->align);
$table->data = array();
// Get the summary info for each question.
$slots = $attemptobj->get_slots();
foreach ($slots as $slot) {
// Add a section headings if we need one here.
$heading = $attemptobj->get_heading_before_slot($slot);
if ($heading) {
$cell = new html_table_cell(format_string($heading));
$cell->header = true;
$cell->colspan = $tablewidth;
$table->data[] = array($cell);
$table->rowclasses[] = 'quizsummaryheading';
}
// Don't display information items.
if (!$attemptobj->is_real_question($slot)) {
continue;
}
// Real question, show it.
$flag = '';
if ($attemptobj->is_question_flagged($slot)) {
// Quiz has custom JS manipulating these image tags - so we can't use the pix_icon method here.
$flag = html_writer::empty_tag('img', array('src' => $this->image_url('i/flagged'),
'alt' => get_string('flagged', 'question'), 'class' => 'questionflag icon-post'));
}
if ($attemptobj->can_navigate_to($slot)) {
$row = array(html_writer::link($attemptobj->attempt_url($slot),
$attemptobj->get_question_number($slot) . $flag),
$attemptobj->get_question_status($slot, $displayoptions->correctness));
} else {
$row = array($attemptobj->get_question_number($slot) . $flag,
$attemptobj->get_question_status($slot, $displayoptions->correctness));
}
if ($markscolumn) {
$row[] = $attemptobj->get_question_mark($slot);
}
$table->data[] = $row;
$table->rowclasses[] = 'quizsummary' . $slot . ' ' . $attemptobj->get_question_state_class(
$slot, $displayoptions->correctness);
}
// Print the summary table.
$output = html_writer::table($table);
return $output;
} | php | public function summary_table($attemptobj, $displayoptions) {
// Prepare the summary table header.
$table = new html_table();
$table->attributes['class'] = 'generaltable quizsummaryofattempt boxaligncenter';
$table->head = array(get_string('question', 'quiz'), get_string('status', 'quiz'));
$table->align = array('left', 'left');
$table->size = array('', '');
$markscolumn = $displayoptions->marks >= question_display_options::MARK_AND_MAX;
if ($markscolumn) {
$table->head[] = get_string('marks', 'quiz');
$table->align[] = 'left';
$table->size[] = '';
}
$tablewidth = count($table->align);
$table->data = array();
// Get the summary info for each question.
$slots = $attemptobj->get_slots();
foreach ($slots as $slot) {
// Add a section headings if we need one here.
$heading = $attemptobj->get_heading_before_slot($slot);
if ($heading) {
$cell = new html_table_cell(format_string($heading));
$cell->header = true;
$cell->colspan = $tablewidth;
$table->data[] = array($cell);
$table->rowclasses[] = 'quizsummaryheading';
}
// Don't display information items.
if (!$attemptobj->is_real_question($slot)) {
continue;
}
// Real question, show it.
$flag = '';
if ($attemptobj->is_question_flagged($slot)) {
// Quiz has custom JS manipulating these image tags - so we can't use the pix_icon method here.
$flag = html_writer::empty_tag('img', array('src' => $this->image_url('i/flagged'),
'alt' => get_string('flagged', 'question'), 'class' => 'questionflag icon-post'));
}
if ($attemptobj->can_navigate_to($slot)) {
$row = array(html_writer::link($attemptobj->attempt_url($slot),
$attemptobj->get_question_number($slot) . $flag),
$attemptobj->get_question_status($slot, $displayoptions->correctness));
} else {
$row = array($attemptobj->get_question_number($slot) . $flag,
$attemptobj->get_question_status($slot, $displayoptions->correctness));
}
if ($markscolumn) {
$row[] = $attemptobj->get_question_mark($slot);
}
$table->data[] = $row;
$table->rowclasses[] = 'quizsummary' . $slot . ' ' . $attemptobj->get_question_state_class(
$slot, $displayoptions->correctness);
}
// Print the summary table.
$output = html_writer::table($table);
return $output;
} | [
"public",
"function",
"summary_table",
"(",
"$",
"attemptobj",
",",
"$",
"displayoptions",
")",
"{",
"// Prepare the summary table header.",
"$",
"table",
"=",
"new",
"html_table",
"(",
")",
";",
"$",
"table",
"->",
"attributes",
"[",
"'class'",
"]",
"=",
"'generaltable quizsummaryofattempt boxaligncenter'",
";",
"$",
"table",
"->",
"head",
"=",
"array",
"(",
"get_string",
"(",
"'question'",
",",
"'quiz'",
")",
",",
"get_string",
"(",
"'status'",
",",
"'quiz'",
")",
")",
";",
"$",
"table",
"->",
"align",
"=",
"array",
"(",
"'left'",
",",
"'left'",
")",
";",
"$",
"table",
"->",
"size",
"=",
"array",
"(",
"''",
",",
"''",
")",
";",
"$",
"markscolumn",
"=",
"$",
"displayoptions",
"->",
"marks",
">=",
"question_display_options",
"::",
"MARK_AND_MAX",
";",
"if",
"(",
"$",
"markscolumn",
")",
"{",
"$",
"table",
"->",
"head",
"[",
"]",
"=",
"get_string",
"(",
"'marks'",
",",
"'quiz'",
")",
";",
"$",
"table",
"->",
"align",
"[",
"]",
"=",
"'left'",
";",
"$",
"table",
"->",
"size",
"[",
"]",
"=",
"''",
";",
"}",
"$",
"tablewidth",
"=",
"count",
"(",
"$",
"table",
"->",
"align",
")",
";",
"$",
"table",
"->",
"data",
"=",
"array",
"(",
")",
";",
"// Get the summary info for each question.",
"$",
"slots",
"=",
"$",
"attemptobj",
"->",
"get_slots",
"(",
")",
";",
"foreach",
"(",
"$",
"slots",
"as",
"$",
"slot",
")",
"{",
"// Add a section headings if we need one here.",
"$",
"heading",
"=",
"$",
"attemptobj",
"->",
"get_heading_before_slot",
"(",
"$",
"slot",
")",
";",
"if",
"(",
"$",
"heading",
")",
"{",
"$",
"cell",
"=",
"new",
"html_table_cell",
"(",
"format_string",
"(",
"$",
"heading",
")",
")",
";",
"$",
"cell",
"->",
"header",
"=",
"true",
";",
"$",
"cell",
"->",
"colspan",
"=",
"$",
"tablewidth",
";",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"array",
"(",
"$",
"cell",
")",
";",
"$",
"table",
"->",
"rowclasses",
"[",
"]",
"=",
"'quizsummaryheading'",
";",
"}",
"// Don't display information items.",
"if",
"(",
"!",
"$",
"attemptobj",
"->",
"is_real_question",
"(",
"$",
"slot",
")",
")",
"{",
"continue",
";",
"}",
"// Real question, show it.",
"$",
"flag",
"=",
"''",
";",
"if",
"(",
"$",
"attemptobj",
"->",
"is_question_flagged",
"(",
"$",
"slot",
")",
")",
"{",
"// Quiz has custom JS manipulating these image tags - so we can't use the pix_icon method here.",
"$",
"flag",
"=",
"html_writer",
"::",
"empty_tag",
"(",
"'img'",
",",
"array",
"(",
"'src'",
"=>",
"$",
"this",
"->",
"image_url",
"(",
"'i/flagged'",
")",
",",
"'alt'",
"=>",
"get_string",
"(",
"'flagged'",
",",
"'question'",
")",
",",
"'class'",
"=>",
"'questionflag icon-post'",
")",
")",
";",
"}",
"if",
"(",
"$",
"attemptobj",
"->",
"can_navigate_to",
"(",
"$",
"slot",
")",
")",
"{",
"$",
"row",
"=",
"array",
"(",
"html_writer",
"::",
"link",
"(",
"$",
"attemptobj",
"->",
"attempt_url",
"(",
"$",
"slot",
")",
",",
"$",
"attemptobj",
"->",
"get_question_number",
"(",
"$",
"slot",
")",
".",
"$",
"flag",
")",
",",
"$",
"attemptobj",
"->",
"get_question_status",
"(",
"$",
"slot",
",",
"$",
"displayoptions",
"->",
"correctness",
")",
")",
";",
"}",
"else",
"{",
"$",
"row",
"=",
"array",
"(",
"$",
"attemptobj",
"->",
"get_question_number",
"(",
"$",
"slot",
")",
".",
"$",
"flag",
",",
"$",
"attemptobj",
"->",
"get_question_status",
"(",
"$",
"slot",
",",
"$",
"displayoptions",
"->",
"correctness",
")",
")",
";",
"}",
"if",
"(",
"$",
"markscolumn",
")",
"{",
"$",
"row",
"[",
"]",
"=",
"$",
"attemptobj",
"->",
"get_question_mark",
"(",
"$",
"slot",
")",
";",
"}",
"$",
"table",
"->",
"data",
"[",
"]",
"=",
"$",
"row",
";",
"$",
"table",
"->",
"rowclasses",
"[",
"]",
"=",
"'quizsummary'",
".",
"$",
"slot",
".",
"' '",
".",
"$",
"attemptobj",
"->",
"get_question_state_class",
"(",
"$",
"slot",
",",
"$",
"displayoptions",
"->",
"correctness",
")",
";",
"}",
"// Print the summary table.",
"$",
"output",
"=",
"html_writer",
"::",
"table",
"(",
"$",
"table",
")",
";",
"return",
"$",
"output",
";",
"}"
] | Generates the table of summarydata
@param quiz_attempt $attemptobj
@param mod_quiz_display_options $displayoptions | [
"Generates",
"the",
"table",
"of",
"summarydata"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L649-L710 |
214,691 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.summary_page_controls | public function summary_page_controls($attemptobj) {
$output = '';
// Return to place button.
if ($attemptobj->get_state() == quiz_attempt::IN_PROGRESS) {
$button = new single_button(
new moodle_url($attemptobj->attempt_url(null, $attemptobj->get_currentpage())),
get_string('returnattempt', 'quiz'));
$output .= $this->container($this->container($this->render($button),
'controls'), 'submitbtns mdl-align');
}
// Finish attempt button.
$options = array(
'attempt' => $attemptobj->get_attemptid(),
'finishattempt' => 1,
'timeup' => 0,
'slots' => '',
'cmid' => $attemptobj->get_cmid(),
'sesskey' => sesskey(),
);
$button = new single_button(
new moodle_url($attemptobj->processattempt_url(), $options),
get_string('submitallandfinish', 'quiz'));
$button->id = 'responseform';
if ($attemptobj->get_state() == quiz_attempt::IN_PROGRESS) {
$button->add_action(new confirm_action(get_string('confirmclose', 'quiz'), null,
get_string('submitallandfinish', 'quiz')));
}
$duedate = $attemptobj->get_due_date();
$message = '';
if ($attemptobj->get_state() == quiz_attempt::OVERDUE) {
$message = get_string('overduemustbesubmittedby', 'quiz', userdate($duedate));
} else if ($duedate) {
$message = get_string('mustbesubmittedby', 'quiz', userdate($duedate));
}
$output .= $this->countdown_timer($attemptobj, time());
$output .= $this->container($message . $this->container(
$this->render($button), 'controls'), 'submitbtns mdl-align');
return $output;
} | php | public function summary_page_controls($attemptobj) {
$output = '';
// Return to place button.
if ($attemptobj->get_state() == quiz_attempt::IN_PROGRESS) {
$button = new single_button(
new moodle_url($attemptobj->attempt_url(null, $attemptobj->get_currentpage())),
get_string('returnattempt', 'quiz'));
$output .= $this->container($this->container($this->render($button),
'controls'), 'submitbtns mdl-align');
}
// Finish attempt button.
$options = array(
'attempt' => $attemptobj->get_attemptid(),
'finishattempt' => 1,
'timeup' => 0,
'slots' => '',
'cmid' => $attemptobj->get_cmid(),
'sesskey' => sesskey(),
);
$button = new single_button(
new moodle_url($attemptobj->processattempt_url(), $options),
get_string('submitallandfinish', 'quiz'));
$button->id = 'responseform';
if ($attemptobj->get_state() == quiz_attempt::IN_PROGRESS) {
$button->add_action(new confirm_action(get_string('confirmclose', 'quiz'), null,
get_string('submitallandfinish', 'quiz')));
}
$duedate = $attemptobj->get_due_date();
$message = '';
if ($attemptobj->get_state() == quiz_attempt::OVERDUE) {
$message = get_string('overduemustbesubmittedby', 'quiz', userdate($duedate));
} else if ($duedate) {
$message = get_string('mustbesubmittedby', 'quiz', userdate($duedate));
}
$output .= $this->countdown_timer($attemptobj, time());
$output .= $this->container($message . $this->container(
$this->render($button), 'controls'), 'submitbtns mdl-align');
return $output;
} | [
"public",
"function",
"summary_page_controls",
"(",
"$",
"attemptobj",
")",
"{",
"$",
"output",
"=",
"''",
";",
"// Return to place button.",
"if",
"(",
"$",
"attemptobj",
"->",
"get_state",
"(",
")",
"==",
"quiz_attempt",
"::",
"IN_PROGRESS",
")",
"{",
"$",
"button",
"=",
"new",
"single_button",
"(",
"new",
"moodle_url",
"(",
"$",
"attemptobj",
"->",
"attempt_url",
"(",
"null",
",",
"$",
"attemptobj",
"->",
"get_currentpage",
"(",
")",
")",
")",
",",
"get_string",
"(",
"'returnattempt'",
",",
"'quiz'",
")",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"container",
"(",
"$",
"this",
"->",
"container",
"(",
"$",
"this",
"->",
"render",
"(",
"$",
"button",
")",
",",
"'controls'",
")",
",",
"'submitbtns mdl-align'",
")",
";",
"}",
"// Finish attempt button.",
"$",
"options",
"=",
"array",
"(",
"'attempt'",
"=>",
"$",
"attemptobj",
"->",
"get_attemptid",
"(",
")",
",",
"'finishattempt'",
"=>",
"1",
",",
"'timeup'",
"=>",
"0",
",",
"'slots'",
"=>",
"''",
",",
"'cmid'",
"=>",
"$",
"attemptobj",
"->",
"get_cmid",
"(",
")",
",",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
",",
")",
";",
"$",
"button",
"=",
"new",
"single_button",
"(",
"new",
"moodle_url",
"(",
"$",
"attemptobj",
"->",
"processattempt_url",
"(",
")",
",",
"$",
"options",
")",
",",
"get_string",
"(",
"'submitallandfinish'",
",",
"'quiz'",
")",
")",
";",
"$",
"button",
"->",
"id",
"=",
"'responseform'",
";",
"if",
"(",
"$",
"attemptobj",
"->",
"get_state",
"(",
")",
"==",
"quiz_attempt",
"::",
"IN_PROGRESS",
")",
"{",
"$",
"button",
"->",
"add_action",
"(",
"new",
"confirm_action",
"(",
"get_string",
"(",
"'confirmclose'",
",",
"'quiz'",
")",
",",
"null",
",",
"get_string",
"(",
"'submitallandfinish'",
",",
"'quiz'",
")",
")",
")",
";",
"}",
"$",
"duedate",
"=",
"$",
"attemptobj",
"->",
"get_due_date",
"(",
")",
";",
"$",
"message",
"=",
"''",
";",
"if",
"(",
"$",
"attemptobj",
"->",
"get_state",
"(",
")",
"==",
"quiz_attempt",
"::",
"OVERDUE",
")",
"{",
"$",
"message",
"=",
"get_string",
"(",
"'overduemustbesubmittedby'",
",",
"'quiz'",
",",
"userdate",
"(",
"$",
"duedate",
")",
")",
";",
"}",
"else",
"if",
"(",
"$",
"duedate",
")",
"{",
"$",
"message",
"=",
"get_string",
"(",
"'mustbesubmittedby'",
",",
"'quiz'",
",",
"userdate",
"(",
"$",
"duedate",
")",
")",
";",
"}",
"$",
"output",
".=",
"$",
"this",
"->",
"countdown_timer",
"(",
"$",
"attemptobj",
",",
"time",
"(",
")",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"container",
"(",
"$",
"message",
".",
"$",
"this",
"->",
"container",
"(",
"$",
"this",
"->",
"render",
"(",
"$",
"button",
")",
",",
"'controls'",
")",
",",
"'submitbtns mdl-align'",
")",
";",
"return",
"$",
"output",
";",
"}"
] | Creates any controls a the page should have.
@param quiz_attempt $attemptobj | [
"Creates",
"any",
"controls",
"a",
"the",
"page",
"should",
"have",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L717-L762 |
214,692 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.view_page | public function view_page($course, $quiz, $cm, $context, $viewobj) {
$output = '';
$output .= $this->view_information($quiz, $cm, $context, $viewobj->infomessages);
$output .= $this->view_table($quiz, $context, $viewobj);
$output .= $this->view_result_info($quiz, $context, $cm, $viewobj);
$output .= $this->box($this->view_page_buttons($viewobj), 'quizattempt');
return $output;
} | php | public function view_page($course, $quiz, $cm, $context, $viewobj) {
$output = '';
$output .= $this->view_information($quiz, $cm, $context, $viewobj->infomessages);
$output .= $this->view_table($quiz, $context, $viewobj);
$output .= $this->view_result_info($quiz, $context, $cm, $viewobj);
$output .= $this->box($this->view_page_buttons($viewobj), 'quizattempt');
return $output;
} | [
"public",
"function",
"view_page",
"(",
"$",
"course",
",",
"$",
"quiz",
",",
"$",
"cm",
",",
"$",
"context",
",",
"$",
"viewobj",
")",
"{",
"$",
"output",
"=",
"''",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"view_information",
"(",
"$",
"quiz",
",",
"$",
"cm",
",",
"$",
"context",
",",
"$",
"viewobj",
"->",
"infomessages",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"view_table",
"(",
"$",
"quiz",
",",
"$",
"context",
",",
"$",
"viewobj",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"view_result_info",
"(",
"$",
"quiz",
",",
"$",
"context",
",",
"$",
"cm",
",",
"$",
"viewobj",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"box",
"(",
"$",
"this",
"->",
"view_page_buttons",
"(",
"$",
"viewobj",
")",
",",
"'quizattempt'",
")",
";",
"return",
"$",
"output",
";",
"}"
] | Generates the view page
@param int $course The id of the course
@param array $quiz Array conting quiz data
@param int $cm Course Module ID
@param int $context The page context ID
@param array $infomessages information about this quiz
@param mod_quiz_view_object $viewobj
@param string $buttontext text for the start/continue attempt button, if
it should be shown.
@param array $infomessages further information about why the student cannot
attempt this quiz now, if appicable this quiz | [
"Generates",
"the",
"view",
"page"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L781-L788 |
214,693 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.view_page_buttons | public function view_page_buttons(mod_quiz_view_object $viewobj) {
global $CFG;
$output = '';
if (!$viewobj->quizhasquestions) {
$output .= $this->no_questions_message($viewobj->canedit, $viewobj->editurl);
}
$output .= $this->access_messages($viewobj->preventmessages);
if ($viewobj->buttontext) {
$output .= $this->start_attempt_button($viewobj->buttontext,
$viewobj->startattempturl, $viewobj->preflightcheckform,
$viewobj->popuprequired, $viewobj->popupoptions);
}
if ($viewobj->showbacktocourse) {
$output .= $this->single_button($viewobj->backtocourseurl,
get_string('backtocourse', 'quiz'), 'get',
array('class' => 'continuebutton'));
}
return $output;
} | php | public function view_page_buttons(mod_quiz_view_object $viewobj) {
global $CFG;
$output = '';
if (!$viewobj->quizhasquestions) {
$output .= $this->no_questions_message($viewobj->canedit, $viewobj->editurl);
}
$output .= $this->access_messages($viewobj->preventmessages);
if ($viewobj->buttontext) {
$output .= $this->start_attempt_button($viewobj->buttontext,
$viewobj->startattempturl, $viewobj->preflightcheckform,
$viewobj->popuprequired, $viewobj->popupoptions);
}
if ($viewobj->showbacktocourse) {
$output .= $this->single_button($viewobj->backtocourseurl,
get_string('backtocourse', 'quiz'), 'get',
array('class' => 'continuebutton'));
}
return $output;
} | [
"public",
"function",
"view_page_buttons",
"(",
"mod_quiz_view_object",
"$",
"viewobj",
")",
"{",
"global",
"$",
"CFG",
";",
"$",
"output",
"=",
"''",
";",
"if",
"(",
"!",
"$",
"viewobj",
"->",
"quizhasquestions",
")",
"{",
"$",
"output",
".=",
"$",
"this",
"->",
"no_questions_message",
"(",
"$",
"viewobj",
"->",
"canedit",
",",
"$",
"viewobj",
"->",
"editurl",
")",
";",
"}",
"$",
"output",
".=",
"$",
"this",
"->",
"access_messages",
"(",
"$",
"viewobj",
"->",
"preventmessages",
")",
";",
"if",
"(",
"$",
"viewobj",
"->",
"buttontext",
")",
"{",
"$",
"output",
".=",
"$",
"this",
"->",
"start_attempt_button",
"(",
"$",
"viewobj",
"->",
"buttontext",
",",
"$",
"viewobj",
"->",
"startattempturl",
",",
"$",
"viewobj",
"->",
"preflightcheckform",
",",
"$",
"viewobj",
"->",
"popuprequired",
",",
"$",
"viewobj",
"->",
"popupoptions",
")",
";",
"}",
"if",
"(",
"$",
"viewobj",
"->",
"showbacktocourse",
")",
"{",
"$",
"output",
".=",
"$",
"this",
"->",
"single_button",
"(",
"$",
"viewobj",
"->",
"backtocourseurl",
",",
"get_string",
"(",
"'backtocourse'",
",",
"'quiz'",
")",
",",
"'get'",
",",
"array",
"(",
"'class'",
"=>",
"'continuebutton'",
")",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] | Work out, and render, whatever buttons, and surrounding info, should appear
at the end of the review page.
@param mod_quiz_view_object $viewobj the information required to display
the view page.
@return string HTML to output. | [
"Work",
"out",
"and",
"render",
"whatever",
"buttons",
"and",
"surrounding",
"info",
"should",
"appear",
"at",
"the",
"end",
"of",
"the",
"review",
"page",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L797-L820 |
214,694 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.start_attempt_button | public function start_attempt_button($buttontext, moodle_url $url,
mod_quiz_preflight_check_form $preflightcheckform = null,
$popuprequired = false, $popupoptions = null) {
if (is_string($preflightcheckform)) {
// Calling code was not updated since the API change.
debugging('The third argument to start_attempt_button should now be the ' .
'mod_quiz_preflight_check_form from ' .
'quiz_access_manager::get_preflight_check_form, not a warning message string.');
}
$button = new single_button($url, $buttontext);
$button->class .= ' quizstartbuttondiv';
if ($popuprequired) {
$button->class .= ' quizsecuremoderequired';
}
$popupjsoptions = null;
if ($popuprequired && $popupoptions) {
$action = new popup_action('click', $url, 'popup', $popupoptions);
$popupjsoptions = $action->get_js_options();
}
if ($preflightcheckform) {
$checkform = $preflightcheckform->render();
} else {
$checkform = null;
}
$this->page->requires->js_call_amd('mod_quiz/preflightcheck', 'init',
array('.quizstartbuttondiv [type=submit]', get_string('startattempt', 'quiz'),
'#mod_quiz_preflight_form', $popupjsoptions));
return $this->render($button) . $checkform;
} | php | public function start_attempt_button($buttontext, moodle_url $url,
mod_quiz_preflight_check_form $preflightcheckform = null,
$popuprequired = false, $popupoptions = null) {
if (is_string($preflightcheckform)) {
// Calling code was not updated since the API change.
debugging('The third argument to start_attempt_button should now be the ' .
'mod_quiz_preflight_check_form from ' .
'quiz_access_manager::get_preflight_check_form, not a warning message string.');
}
$button = new single_button($url, $buttontext);
$button->class .= ' quizstartbuttondiv';
if ($popuprequired) {
$button->class .= ' quizsecuremoderequired';
}
$popupjsoptions = null;
if ($popuprequired && $popupoptions) {
$action = new popup_action('click', $url, 'popup', $popupoptions);
$popupjsoptions = $action->get_js_options();
}
if ($preflightcheckform) {
$checkform = $preflightcheckform->render();
} else {
$checkform = null;
}
$this->page->requires->js_call_amd('mod_quiz/preflightcheck', 'init',
array('.quizstartbuttondiv [type=submit]', get_string('startattempt', 'quiz'),
'#mod_quiz_preflight_form', $popupjsoptions));
return $this->render($button) . $checkform;
} | [
"public",
"function",
"start_attempt_button",
"(",
"$",
"buttontext",
",",
"moodle_url",
"$",
"url",
",",
"mod_quiz_preflight_check_form",
"$",
"preflightcheckform",
"=",
"null",
",",
"$",
"popuprequired",
"=",
"false",
",",
"$",
"popupoptions",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"preflightcheckform",
")",
")",
"{",
"// Calling code was not updated since the API change.",
"debugging",
"(",
"'The third argument to start_attempt_button should now be the '",
".",
"'mod_quiz_preflight_check_form from '",
".",
"'quiz_access_manager::get_preflight_check_form, not a warning message string.'",
")",
";",
"}",
"$",
"button",
"=",
"new",
"single_button",
"(",
"$",
"url",
",",
"$",
"buttontext",
")",
";",
"$",
"button",
"->",
"class",
".=",
"' quizstartbuttondiv'",
";",
"if",
"(",
"$",
"popuprequired",
")",
"{",
"$",
"button",
"->",
"class",
".=",
"' quizsecuremoderequired'",
";",
"}",
"$",
"popupjsoptions",
"=",
"null",
";",
"if",
"(",
"$",
"popuprequired",
"&&",
"$",
"popupoptions",
")",
"{",
"$",
"action",
"=",
"new",
"popup_action",
"(",
"'click'",
",",
"$",
"url",
",",
"'popup'",
",",
"$",
"popupoptions",
")",
";",
"$",
"popupjsoptions",
"=",
"$",
"action",
"->",
"get_js_options",
"(",
")",
";",
"}",
"if",
"(",
"$",
"preflightcheckform",
")",
"{",
"$",
"checkform",
"=",
"$",
"preflightcheckform",
"->",
"render",
"(",
")",
";",
"}",
"else",
"{",
"$",
"checkform",
"=",
"null",
";",
"}",
"$",
"this",
"->",
"page",
"->",
"requires",
"->",
"js_call_amd",
"(",
"'mod_quiz/preflightcheck'",
",",
"'init'",
",",
"array",
"(",
"'.quizstartbuttondiv [type=submit]'",
",",
"get_string",
"(",
"'startattempt'",
",",
"'quiz'",
")",
",",
"'#mod_quiz_preflight_form'",
",",
"$",
"popupjsoptions",
")",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"button",
")",
".",
"$",
"checkform",
";",
"}"
] | Generates the view attempt button
@param string $buttontext the label to display on the button.
@param moodle_url $url The URL to POST to in order to start the attempt.
@param mod_quiz_preflight_check_form $preflightcheckform deprecated.
@param bool $popuprequired whether the attempt needs to be opened in a pop-up.
@param array $popupoptions the options to use if we are opening a popup.
@return string HTML fragment. | [
"Generates",
"the",
"view",
"attempt",
"button"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L832-L866 |
214,695 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.no_questions_message | public function no_questions_message($canedit, $editurl) {
$output = '';
$output .= $this->notification(get_string('noquestions', 'quiz'));
if ($canedit) {
$output .= $this->single_button($editurl, get_string('editquiz', 'quiz'), 'get');
}
return $output;
} | php | public function no_questions_message($canedit, $editurl) {
$output = '';
$output .= $this->notification(get_string('noquestions', 'quiz'));
if ($canedit) {
$output .= $this->single_button($editurl, get_string('editquiz', 'quiz'), 'get');
}
return $output;
} | [
"public",
"function",
"no_questions_message",
"(",
"$",
"canedit",
",",
"$",
"editurl",
")",
"{",
"$",
"output",
"=",
"''",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"notification",
"(",
"get_string",
"(",
"'noquestions'",
",",
"'quiz'",
")",
")",
";",
"if",
"(",
"$",
"canedit",
")",
"{",
"$",
"output",
".=",
"$",
"this",
"->",
"single_button",
"(",
"$",
"editurl",
",",
"get_string",
"(",
"'editquiz'",
",",
"'quiz'",
")",
",",
"'get'",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] | Generate a message saying that this quiz has no questions, with a button to
go to the edit page, if the user has the right capability.
@param object $quiz the quiz settings.
@param object $cm the course_module object.
@param object $context the quiz context.
@return string HTML to output. | [
"Generate",
"a",
"message",
"saying",
"that",
"this",
"quiz",
"has",
"no",
"questions",
"with",
"a",
"button",
"to",
"go",
"to",
"the",
"edit",
"page",
"if",
"the",
"user",
"has",
"the",
"right",
"capability",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L876-L884 |
214,696 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.view_page_guest | public function view_page_guest($course, $quiz, $cm, $context, $messages) {
$output = '';
$output .= $this->view_information($quiz, $cm, $context, $messages);
$guestno = html_writer::tag('p', get_string('guestsno', 'quiz'));
$liketologin = html_writer::tag('p', get_string('liketologin'));
$referer = get_local_referer(false);
$output .= $this->confirm($guestno."\n\n".$liketologin."\n", get_login_url(), $referer);
return $output;
} | php | public function view_page_guest($course, $quiz, $cm, $context, $messages) {
$output = '';
$output .= $this->view_information($quiz, $cm, $context, $messages);
$guestno = html_writer::tag('p', get_string('guestsno', 'quiz'));
$liketologin = html_writer::tag('p', get_string('liketologin'));
$referer = get_local_referer(false);
$output .= $this->confirm($guestno."\n\n".$liketologin."\n", get_login_url(), $referer);
return $output;
} | [
"public",
"function",
"view_page_guest",
"(",
"$",
"course",
",",
"$",
"quiz",
",",
"$",
"cm",
",",
"$",
"context",
",",
"$",
"messages",
")",
"{",
"$",
"output",
"=",
"''",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"view_information",
"(",
"$",
"quiz",
",",
"$",
"cm",
",",
"$",
"context",
",",
"$",
"messages",
")",
";",
"$",
"guestno",
"=",
"html_writer",
"::",
"tag",
"(",
"'p'",
",",
"get_string",
"(",
"'guestsno'",
",",
"'quiz'",
")",
")",
";",
"$",
"liketologin",
"=",
"html_writer",
"::",
"tag",
"(",
"'p'",
",",
"get_string",
"(",
"'liketologin'",
")",
")",
";",
"$",
"referer",
"=",
"get_local_referer",
"(",
"false",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"confirm",
"(",
"$",
"guestno",
".",
"\"\\n\\n\"",
".",
"$",
"liketologin",
".",
"\"\\n\"",
",",
"get_login_url",
"(",
")",
",",
"$",
"referer",
")",
";",
"return",
"$",
"output",
";",
"}"
] | Outputs an error message for any guests accessing the quiz
@param int $course The course ID
@param array $quiz Array contingin quiz data
@param int $cm Course Module ID
@param int $context The page contect ID
@param array $messages Array containing any messages | [
"Outputs",
"an",
"error",
"message",
"for",
"any",
"guests",
"accessing",
"the",
"quiz"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L895-L903 |
214,697 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.view_page_notenrolled | public function view_page_notenrolled($course, $quiz, $cm, $context, $messages) {
global $CFG;
$output = '';
$output .= $this->view_information($quiz, $cm, $context, $messages);
$youneedtoenrol = html_writer::tag('p', get_string('youneedtoenrol', 'quiz'));
$button = html_writer::tag('p',
$this->continue_button($CFG->wwwroot . '/course/view.php?id=' . $course->id));
$output .= $this->box($youneedtoenrol."\n\n".$button."\n", 'generalbox', 'notice');
return $output;
} | php | public function view_page_notenrolled($course, $quiz, $cm, $context, $messages) {
global $CFG;
$output = '';
$output .= $this->view_information($quiz, $cm, $context, $messages);
$youneedtoenrol = html_writer::tag('p', get_string('youneedtoenrol', 'quiz'));
$button = html_writer::tag('p',
$this->continue_button($CFG->wwwroot . '/course/view.php?id=' . $course->id));
$output .= $this->box($youneedtoenrol."\n\n".$button."\n", 'generalbox', 'notice');
return $output;
} | [
"public",
"function",
"view_page_notenrolled",
"(",
"$",
"course",
",",
"$",
"quiz",
",",
"$",
"cm",
",",
"$",
"context",
",",
"$",
"messages",
")",
"{",
"global",
"$",
"CFG",
";",
"$",
"output",
"=",
"''",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"view_information",
"(",
"$",
"quiz",
",",
"$",
"cm",
",",
"$",
"context",
",",
"$",
"messages",
")",
";",
"$",
"youneedtoenrol",
"=",
"html_writer",
"::",
"tag",
"(",
"'p'",
",",
"get_string",
"(",
"'youneedtoenrol'",
",",
"'quiz'",
")",
")",
";",
"$",
"button",
"=",
"html_writer",
"::",
"tag",
"(",
"'p'",
",",
"$",
"this",
"->",
"continue_button",
"(",
"$",
"CFG",
"->",
"wwwroot",
".",
"'/course/view.php?id='",
".",
"$",
"course",
"->",
"id",
")",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"box",
"(",
"$",
"youneedtoenrol",
".",
"\"\\n\\n\"",
".",
"$",
"button",
".",
"\"\\n\"",
",",
"'generalbox'",
",",
"'notice'",
")",
";",
"return",
"$",
"output",
";",
"}"
] | Outputs and error message for anyone who is not enrolle don the course
@param int $course The course ID
@param array $quiz Array contingin quiz data
@param int $cm Course Module ID
@param int $context The page contect ID
@param array $messages Array containing any messages | [
"Outputs",
"and",
"error",
"message",
"for",
"anyone",
"who",
"is",
"not",
"enrolle",
"don",
"the",
"course"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L914-L923 |
214,698 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.view_information | public function view_information($quiz, $cm, $context, $messages) {
global $CFG;
$output = '';
// Print quiz name and description.
$output .= $this->heading(format_string($quiz->name));
$output .= $this->quiz_intro($quiz, $cm);
// Output any access messages.
if ($messages) {
$output .= $this->box($this->access_messages($messages), 'quizinfo');
}
// Show number of attempts summary to those who can view reports.
if (has_capability('mod/quiz:viewreports', $context)) {
if ($strattemptnum = $this->quiz_attempt_summary_link_to_reports($quiz, $cm,
$context)) {
$output .= html_writer::tag('div', $strattemptnum,
array('class' => 'quizattemptcounts'));
}
}
return $output;
} | php | public function view_information($quiz, $cm, $context, $messages) {
global $CFG;
$output = '';
// Print quiz name and description.
$output .= $this->heading(format_string($quiz->name));
$output .= $this->quiz_intro($quiz, $cm);
// Output any access messages.
if ($messages) {
$output .= $this->box($this->access_messages($messages), 'quizinfo');
}
// Show number of attempts summary to those who can view reports.
if (has_capability('mod/quiz:viewreports', $context)) {
if ($strattemptnum = $this->quiz_attempt_summary_link_to_reports($quiz, $cm,
$context)) {
$output .= html_writer::tag('div', $strattemptnum,
array('class' => 'quizattemptcounts'));
}
}
return $output;
} | [
"public",
"function",
"view_information",
"(",
"$",
"quiz",
",",
"$",
"cm",
",",
"$",
"context",
",",
"$",
"messages",
")",
"{",
"global",
"$",
"CFG",
";",
"$",
"output",
"=",
"''",
";",
"// Print quiz name and description.",
"$",
"output",
".=",
"$",
"this",
"->",
"heading",
"(",
"format_string",
"(",
"$",
"quiz",
"->",
"name",
")",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"quiz_intro",
"(",
"$",
"quiz",
",",
"$",
"cm",
")",
";",
"// Output any access messages.",
"if",
"(",
"$",
"messages",
")",
"{",
"$",
"output",
".=",
"$",
"this",
"->",
"box",
"(",
"$",
"this",
"->",
"access_messages",
"(",
"$",
"messages",
")",
",",
"'quizinfo'",
")",
";",
"}",
"// Show number of attempts summary to those who can view reports.",
"if",
"(",
"has_capability",
"(",
"'mod/quiz:viewreports'",
",",
"$",
"context",
")",
")",
"{",
"if",
"(",
"$",
"strattemptnum",
"=",
"$",
"this",
"->",
"quiz_attempt_summary_link_to_reports",
"(",
"$",
"quiz",
",",
"$",
"cm",
",",
"$",
"context",
")",
")",
"{",
"$",
"output",
".=",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"$",
"strattemptnum",
",",
"array",
"(",
"'class'",
"=>",
"'quizattemptcounts'",
")",
")",
";",
"}",
"}",
"return",
"$",
"output",
";",
"}"
] | Output the page information
@param object $quiz the quiz settings.
@param object $cm the course_module object.
@param object $context the quiz context.
@param array $messages any access messages that should be described.
@return string HTML to output. | [
"Output",
"the",
"page",
"information"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L934-L957 |
214,699 | moodle/moodle | mod/quiz/renderer.php | mod_quiz_renderer.quiz_intro | public function quiz_intro($quiz, $cm) {
if (html_is_blank($quiz->intro)) {
return '';
}
return $this->box(format_module_intro('quiz', $quiz, $cm->id), 'generalbox', 'intro');
} | php | public function quiz_intro($quiz, $cm) {
if (html_is_blank($quiz->intro)) {
return '';
}
return $this->box(format_module_intro('quiz', $quiz, $cm->id), 'generalbox', 'intro');
} | [
"public",
"function",
"quiz_intro",
"(",
"$",
"quiz",
",",
"$",
"cm",
")",
"{",
"if",
"(",
"html_is_blank",
"(",
"$",
"quiz",
"->",
"intro",
")",
")",
"{",
"return",
"''",
";",
"}",
"return",
"$",
"this",
"->",
"box",
"(",
"format_module_intro",
"(",
"'quiz'",
",",
"$",
"quiz",
",",
"$",
"cm",
"->",
"id",
")",
",",
"'generalbox'",
",",
"'intro'",
")",
";",
"}"
] | Output the quiz intro.
@param object $quiz the quiz settings.
@param object $cm the course_module object.
@return string HTML to output. | [
"Output",
"the",
"quiz",
"intro",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/renderer.php#L965-L971 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.