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
216,400
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.quiz_information
public function quiz_information(structure $structure) { list($currentstatus, $explanation) = $structure->get_dates_summary(); $output = html_writer::span( get_string('numquestionsx', 'quiz', $structure->get_question_count()), 'numberofquestions') . ' | ' . html_writer::span($currentstatus, 'quizopeningstatus', array('title' => $explanation)); return html_writer::div($output, 'statusbar'); }
php
public function quiz_information(structure $structure) { list($currentstatus, $explanation) = $structure->get_dates_summary(); $output = html_writer::span( get_string('numquestionsx', 'quiz', $structure->get_question_count()), 'numberofquestions') . ' | ' . html_writer::span($currentstatus, 'quizopeningstatus', array('title' => $explanation)); return html_writer::div($output, 'statusbar'); }
[ "public", "function", "quiz_information", "(", "structure", "$", "structure", ")", "{", "list", "(", "$", "currentstatus", ",", "$", "explanation", ")", "=", "$", "structure", "->", "get_dates_summary", "(", ")", ";", "$", "output", "=", "html_writer", "::", "span", "(", "get_string", "(", "'numquestionsx'", ",", "'quiz'", ",", "$", "structure", "->", "get_question_count", "(", ")", ")", ",", "'numberofquestions'", ")", ".", "' | '", ".", "html_writer", "::", "span", "(", "$", "currentstatus", ",", "'quizopeningstatus'", ",", "array", "(", "'title'", "=>", "$", "explanation", ")", ")", ";", "return", "html_writer", "::", "div", "(", "$", "output", ",", "'statusbar'", ")", ";", "}" ]
Render the status bar. @param structure $structure the quiz structure. @return string HTML to output.
[ "Render", "the", "status", "bar", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L148-L158
216,401
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.maximum_grade_input
public function maximum_grade_input($structure, \moodle_url $pageurl) { $output = ''; $output .= html_writer::start_div('maxgrade'); $output .= html_writer::start_tag('form', array('method' => 'post', 'action' => 'edit.php', 'class' => 'quizsavegradesform form-inline')); $output .= html_writer::start_tag('fieldset', array('class' => 'invisiblefieldset')); $output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey())); $output .= html_writer::input_hidden_params($pageurl); $output .= html_writer::tag('label', get_string('maximumgrade') . ' ', array('for' => 'inputmaxgrade')); $output .= html_writer::empty_tag('input', array('type' => 'text', 'id' => 'inputmaxgrade', 'name' => 'maxgrade', 'size' => ($structure->get_decimal_places_for_grades() + 2), 'value' => $structure->formatted_quiz_grade(), 'class' => 'form-control')); $output .= html_writer::empty_tag('input', array('type' => 'submit', 'class' => 'btn btn-secondary ml-1', 'name' => 'savechanges', 'value' => get_string('save', 'quiz'))); $output .= html_writer::end_tag('fieldset'); $output .= html_writer::end_tag('form'); $output .= html_writer::end_tag('div'); return $output; }
php
public function maximum_grade_input($structure, \moodle_url $pageurl) { $output = ''; $output .= html_writer::start_div('maxgrade'); $output .= html_writer::start_tag('form', array('method' => 'post', 'action' => 'edit.php', 'class' => 'quizsavegradesform form-inline')); $output .= html_writer::start_tag('fieldset', array('class' => 'invisiblefieldset')); $output .= html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey())); $output .= html_writer::input_hidden_params($pageurl); $output .= html_writer::tag('label', get_string('maximumgrade') . ' ', array('for' => 'inputmaxgrade')); $output .= html_writer::empty_tag('input', array('type' => 'text', 'id' => 'inputmaxgrade', 'name' => 'maxgrade', 'size' => ($structure->get_decimal_places_for_grades() + 2), 'value' => $structure->formatted_quiz_grade(), 'class' => 'form-control')); $output .= html_writer::empty_tag('input', array('type' => 'submit', 'class' => 'btn btn-secondary ml-1', 'name' => 'savechanges', 'value' => get_string('save', 'quiz'))); $output .= html_writer::end_tag('fieldset'); $output .= html_writer::end_tag('form'); $output .= html_writer::end_tag('div'); return $output; }
[ "public", "function", "maximum_grade_input", "(", "$", "structure", ",", "\\", "moodle_url", "$", "pageurl", ")", "{", "$", "output", "=", "''", ";", "$", "output", ".=", "html_writer", "::", "start_div", "(", "'maxgrade'", ")", ";", "$", "output", ".=", "html_writer", "::", "start_tag", "(", "'form'", ",", "array", "(", "'method'", "=>", "'post'", ",", "'action'", "=>", "'edit.php'", ",", "'class'", "=>", "'quizsavegradesform form-inline'", ")", ")", ";", "$", "output", ".=", "html_writer", "::", "start_tag", "(", "'fieldset'", ",", "array", "(", "'class'", "=>", "'invisiblefieldset'", ")", ")", ";", "$", "output", ".=", "html_writer", "::", "empty_tag", "(", "'input'", ",", "array", "(", "'type'", "=>", "'hidden'", ",", "'name'", "=>", "'sesskey'", ",", "'value'", "=>", "sesskey", "(", ")", ")", ")", ";", "$", "output", ".=", "html_writer", "::", "input_hidden_params", "(", "$", "pageurl", ")", ";", "$", "output", ".=", "html_writer", "::", "tag", "(", "'label'", ",", "get_string", "(", "'maximumgrade'", ")", ".", "' '", ",", "array", "(", "'for'", "=>", "'inputmaxgrade'", ")", ")", ";", "$", "output", ".=", "html_writer", "::", "empty_tag", "(", "'input'", ",", "array", "(", "'type'", "=>", "'text'", ",", "'id'", "=>", "'inputmaxgrade'", ",", "'name'", "=>", "'maxgrade'", ",", "'size'", "=>", "(", "$", "structure", "->", "get_decimal_places_for_grades", "(", ")", "+", "2", ")", ",", "'value'", "=>", "$", "structure", "->", "formatted_quiz_grade", "(", ")", ",", "'class'", "=>", "'form-control'", ")", ")", ";", "$", "output", ".=", "html_writer", "::", "empty_tag", "(", "'input'", ",", "array", "(", "'type'", "=>", "'submit'", ",", "'class'", "=>", "'btn btn-secondary ml-1'", ",", "'name'", "=>", "'savechanges'", ",", "'value'", "=>", "get_string", "(", "'save'", ",", "'quiz'", ")", ")", ")", ";", "$", "output", ".=", "html_writer", "::", "end_tag", "(", "'fieldset'", ")", ";", "$", "output", ".=", "html_writer", "::", "end_tag", "(", "'form'", ")", ";", "$", "output", ".=", "html_writer", "::", "end_tag", "(", "'div'", ")", ";", "return", "$", "output", ";", "}" ]
Render the form for setting a quiz' overall grade @param structure $structure the quiz structure. @param \moodle_url $pageurl the canonical URL of this page. @return string HTML to output.
[ "Render", "the", "form", "for", "setting", "a", "quiz", "overall", "grade" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L167-L187
216,402
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.repaginate_button
protected function repaginate_button(structure $structure, \moodle_url $pageurl) { $header = html_writer::tag('span', get_string('repaginatecommand', 'quiz'), array('class' => 'repaginatecommand')); $form = $this->repaginate_form($structure, $pageurl); $buttonoptions = array( 'type' => 'submit', 'name' => 'repaginate', 'id' => 'repaginatecommand', 'value' => get_string('repaginatecommand', 'quiz'), 'class' => 'btn btn-secondary mb-1', 'data-header' => $header, 'data-form' => $form, ); if (!$structure->can_be_repaginated()) { $buttonoptions['disabled'] = 'disabled'; } else { $this->page->requires->js_call_amd('mod_quiz/repaginate', 'init'); } return html_writer::empty_tag('input', $buttonoptions); }
php
protected function repaginate_button(structure $structure, \moodle_url $pageurl) { $header = html_writer::tag('span', get_string('repaginatecommand', 'quiz'), array('class' => 'repaginatecommand')); $form = $this->repaginate_form($structure, $pageurl); $buttonoptions = array( 'type' => 'submit', 'name' => 'repaginate', 'id' => 'repaginatecommand', 'value' => get_string('repaginatecommand', 'quiz'), 'class' => 'btn btn-secondary mb-1', 'data-header' => $header, 'data-form' => $form, ); if (!$structure->can_be_repaginated()) { $buttonoptions['disabled'] = 'disabled'; } else { $this->page->requires->js_call_amd('mod_quiz/repaginate', 'init'); } return html_writer::empty_tag('input', $buttonoptions); }
[ "protected", "function", "repaginate_button", "(", "structure", "$", "structure", ",", "\\", "moodle_url", "$", "pageurl", ")", "{", "$", "header", "=", "html_writer", "::", "tag", "(", "'span'", ",", "get_string", "(", "'repaginatecommand'", ",", "'quiz'", ")", ",", "array", "(", "'class'", "=>", "'repaginatecommand'", ")", ")", ";", "$", "form", "=", "$", "this", "->", "repaginate_form", "(", "$", "structure", ",", "$", "pageurl", ")", ";", "$", "buttonoptions", "=", "array", "(", "'type'", "=>", "'submit'", ",", "'name'", "=>", "'repaginate'", ",", "'id'", "=>", "'repaginatecommand'", ",", "'value'", "=>", "get_string", "(", "'repaginatecommand'", ",", "'quiz'", ")", ",", "'class'", "=>", "'btn btn-secondary mb-1'", ",", "'data-header'", "=>", "$", "header", ",", "'data-form'", "=>", "$", "form", ",", ")", ";", "if", "(", "!", "$", "structure", "->", "can_be_repaginated", "(", ")", ")", "{", "$", "buttonoptions", "[", "'disabled'", "]", "=", "'disabled'", ";", "}", "else", "{", "$", "this", "->", "page", "->", "requires", "->", "js_call_amd", "(", "'mod_quiz/repaginate'", ",", "'init'", ")", ";", "}", "return", "html_writer", "::", "empty_tag", "(", "'input'", ",", "$", "buttonoptions", ")", ";", "}" ]
Return the repaginate button @param structure $structure the structure of the quiz being edited. @param \moodle_url $pageurl the canonical URL of this page. @return string HTML to output.
[ "Return", "the", "repaginate", "button" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L195-L215
216,403
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.selectmultiple_button
protected function selectmultiple_button(structure $structure) { $buttonoptions = array( 'type' => 'button', 'name' => 'selectmultiple', 'id' => 'selectmultiplecommand', 'value' => get_string('selectmultipleitems', 'quiz'), 'class' => 'btn btn-secondary mb-1' ); if (!$structure->can_be_edited()) { $buttonoptions['disabled'] = 'disabled'; } return html_writer::tag('button', get_string('selectmultipleitems', 'quiz'), $buttonoptions); }
php
protected function selectmultiple_button(structure $structure) { $buttonoptions = array( 'type' => 'button', 'name' => 'selectmultiple', 'id' => 'selectmultiplecommand', 'value' => get_string('selectmultipleitems', 'quiz'), 'class' => 'btn btn-secondary mb-1' ); if (!$structure->can_be_edited()) { $buttonoptions['disabled'] = 'disabled'; } return html_writer::tag('button', get_string('selectmultipleitems', 'quiz'), $buttonoptions); }
[ "protected", "function", "selectmultiple_button", "(", "structure", "$", "structure", ")", "{", "$", "buttonoptions", "=", "array", "(", "'type'", "=>", "'button'", ",", "'name'", "=>", "'selectmultiple'", ",", "'id'", "=>", "'selectmultiplecommand'", ",", "'value'", "=>", "get_string", "(", "'selectmultipleitems'", ",", "'quiz'", ")", ",", "'class'", "=>", "'btn btn-secondary mb-1'", ")", ";", "if", "(", "!", "$", "structure", "->", "can_be_edited", "(", ")", ")", "{", "$", "buttonoptions", "[", "'disabled'", "]", "=", "'disabled'", ";", "}", "return", "html_writer", "::", "tag", "(", "'button'", ",", "get_string", "(", "'selectmultipleitems'", ",", "'quiz'", ")", ",", "$", "buttonoptions", ")", ";", "}" ]
Generate the bulk action button. @param structure $structure the structure of the quiz being edited. @return string HTML to output.
[ "Generate", "the", "bulk", "action", "button", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L223-L236
216,404
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.selectmultiple_controls
protected function selectmultiple_controls(structure $structure) { $output = ''; // Bulk action button delete and bulk action button cancel. $buttondeleteoptions = array( 'type' => 'button', 'id' => 'selectmultipledeletecommand', 'value' => get_string('deleteselected', 'mod_quiz'), 'class' => 'btn btn-secondary' ); $buttoncanceloptions = array( 'type' => 'button', 'id' => 'selectmultiplecancelcommand', 'value' => get_string('cancel', 'moodle'), 'class' => 'btn btn-secondary' ); $groupoptions = array( 'class' => 'btn-group selectmultiplecommand actions', 'role' => 'group' ); $output .= html_writer::tag('div', html_writer::tag('button', get_string('deleteselected', 'mod_quiz'), $buttondeleteoptions) . " " . html_writer::tag('button', get_string('cancel', 'moodle'), $buttoncanceloptions), $groupoptions); $toolbaroptions = array( 'class' => 'btn-toolbar', 'role' => 'toolbar', 'aria-label' => get_string('selectmultipletoolbar', 'quiz'), ); // Select all/deselect all questions. $buttonselectalloptions = array( 'role' => 'button', 'id' => 'questionselectall', 'class' => 'btn btn-link' ); $buttondeselectalloptions = array( 'role' => 'button', 'id' => 'questiondeselectall', 'class' => 'btn btn-link' ); $output .= html_writer::tag('div', html_writer::tag('div', html_writer::link('#', get_string('selectall', 'quiz'), $buttonselectalloptions) . html_writer::tag('span', "/", ['class' => 'separator']) . html_writer::link('#', get_string('selectnone', 'quiz'), $buttondeselectalloptions), array('class' => 'btn-group selectmultiplecommandbuttons')), $toolbaroptions); return $output; }
php
protected function selectmultiple_controls(structure $structure) { $output = ''; // Bulk action button delete and bulk action button cancel. $buttondeleteoptions = array( 'type' => 'button', 'id' => 'selectmultipledeletecommand', 'value' => get_string('deleteselected', 'mod_quiz'), 'class' => 'btn btn-secondary' ); $buttoncanceloptions = array( 'type' => 'button', 'id' => 'selectmultiplecancelcommand', 'value' => get_string('cancel', 'moodle'), 'class' => 'btn btn-secondary' ); $groupoptions = array( 'class' => 'btn-group selectmultiplecommand actions', 'role' => 'group' ); $output .= html_writer::tag('div', html_writer::tag('button', get_string('deleteselected', 'mod_quiz'), $buttondeleteoptions) . " " . html_writer::tag('button', get_string('cancel', 'moodle'), $buttoncanceloptions), $groupoptions); $toolbaroptions = array( 'class' => 'btn-toolbar', 'role' => 'toolbar', 'aria-label' => get_string('selectmultipletoolbar', 'quiz'), ); // Select all/deselect all questions. $buttonselectalloptions = array( 'role' => 'button', 'id' => 'questionselectall', 'class' => 'btn btn-link' ); $buttondeselectalloptions = array( 'role' => 'button', 'id' => 'questiondeselectall', 'class' => 'btn btn-link' ); $output .= html_writer::tag('div', html_writer::tag('div', html_writer::link('#', get_string('selectall', 'quiz'), $buttonselectalloptions) . html_writer::tag('span', "/", ['class' => 'separator']) . html_writer::link('#', get_string('selectnone', 'quiz'), $buttondeselectalloptions), array('class' => 'btn-group selectmultiplecommandbuttons')), $toolbaroptions); return $output; }
[ "protected", "function", "selectmultiple_controls", "(", "structure", "$", "structure", ")", "{", "$", "output", "=", "''", ";", "// Bulk action button delete and bulk action button cancel.", "$", "buttondeleteoptions", "=", "array", "(", "'type'", "=>", "'button'", ",", "'id'", "=>", "'selectmultipledeletecommand'", ",", "'value'", "=>", "get_string", "(", "'deleteselected'", ",", "'mod_quiz'", ")", ",", "'class'", "=>", "'btn btn-secondary'", ")", ";", "$", "buttoncanceloptions", "=", "array", "(", "'type'", "=>", "'button'", ",", "'id'", "=>", "'selectmultiplecancelcommand'", ",", "'value'", "=>", "get_string", "(", "'cancel'", ",", "'moodle'", ")", ",", "'class'", "=>", "'btn btn-secondary'", ")", ";", "$", "groupoptions", "=", "array", "(", "'class'", "=>", "'btn-group selectmultiplecommand actions'", ",", "'role'", "=>", "'group'", ")", ";", "$", "output", ".=", "html_writer", "::", "tag", "(", "'div'", ",", "html_writer", "::", "tag", "(", "'button'", ",", "get_string", "(", "'deleteselected'", ",", "'mod_quiz'", ")", ",", "$", "buttondeleteoptions", ")", ".", "\" \"", ".", "html_writer", "::", "tag", "(", "'button'", ",", "get_string", "(", "'cancel'", ",", "'moodle'", ")", ",", "$", "buttoncanceloptions", ")", ",", "$", "groupoptions", ")", ";", "$", "toolbaroptions", "=", "array", "(", "'class'", "=>", "'btn-toolbar'", ",", "'role'", "=>", "'toolbar'", ",", "'aria-label'", "=>", "get_string", "(", "'selectmultipletoolbar'", ",", "'quiz'", ")", ",", ")", ";", "// Select all/deselect all questions.", "$", "buttonselectalloptions", "=", "array", "(", "'role'", "=>", "'button'", ",", "'id'", "=>", "'questionselectall'", ",", "'class'", "=>", "'btn btn-link'", ")", ";", "$", "buttondeselectalloptions", "=", "array", "(", "'role'", "=>", "'button'", ",", "'id'", "=>", "'questiondeselectall'", ",", "'class'", "=>", "'btn btn-link'", ")", ";", "$", "output", ".=", "html_writer", "::", "tag", "(", "'div'", ",", "html_writer", "::", "tag", "(", "'div'", ",", "html_writer", "::", "link", "(", "'#'", ",", "get_string", "(", "'selectall'", ",", "'quiz'", ")", ",", "$", "buttonselectalloptions", ")", ".", "html_writer", "::", "tag", "(", "'span'", ",", "\"/\"", ",", "[", "'class'", "=>", "'separator'", "]", ")", ".", "html_writer", "::", "link", "(", "'#'", ",", "get_string", "(", "'selectnone'", ",", "'quiz'", ")", ",", "$", "buttondeselectalloptions", ")", ",", "array", "(", "'class'", "=>", "'btn-group selectmultiplecommandbuttons'", ")", ")", ",", "$", "toolbaroptions", ")", ";", "return", "$", "output", ";", "}" ]
Generate the controls that appear when the bulk action button is pressed. @param structure $structure the structure of the quiz being edited. @return string HTML to output.
[ "Generate", "the", "controls", "that", "appear", "when", "the", "bulk", "action", "button", "is", "pressed", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L244-L297
216,405
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.repaginate_form
protected function repaginate_form(structure $structure, \moodle_url $pageurl) { $perpage = array(); $perpage[0] = get_string('allinone', 'quiz'); for ($i = 1; $i <= 50; ++$i) { $perpage[$i] = $i; } $hiddenurl = clone($pageurl); $hiddenurl->param('sesskey', sesskey()); $select = html_writer::select($perpage, 'questionsperpage', $structure->get_questions_per_page(), false, array('class' => 'custom-select')); $buttonattributes = array( 'type' => 'submit', 'name' => 'repaginate', 'value' => get_string('go'), 'class' => 'btn btn-secondary ml-1' ); $formcontent = html_writer::tag('form', html_writer::div( html_writer::input_hidden_params($hiddenurl) . get_string('repaginate', 'quiz', $select) . html_writer::empty_tag('input', $buttonattributes) ), array('action' => 'edit.php', 'method' => 'post')); return html_writer::div($formcontent, '', array('id' => 'repaginatedialog')); }
php
protected function repaginate_form(structure $structure, \moodle_url $pageurl) { $perpage = array(); $perpage[0] = get_string('allinone', 'quiz'); for ($i = 1; $i <= 50; ++$i) { $perpage[$i] = $i; } $hiddenurl = clone($pageurl); $hiddenurl->param('sesskey', sesskey()); $select = html_writer::select($perpage, 'questionsperpage', $structure->get_questions_per_page(), false, array('class' => 'custom-select')); $buttonattributes = array( 'type' => 'submit', 'name' => 'repaginate', 'value' => get_string('go'), 'class' => 'btn btn-secondary ml-1' ); $formcontent = html_writer::tag('form', html_writer::div( html_writer::input_hidden_params($hiddenurl) . get_string('repaginate', 'quiz', $select) . html_writer::empty_tag('input', $buttonattributes) ), array('action' => 'edit.php', 'method' => 'post')); return html_writer::div($formcontent, '', array('id' => 'repaginatedialog')); }
[ "protected", "function", "repaginate_form", "(", "structure", "$", "structure", ",", "\\", "moodle_url", "$", "pageurl", ")", "{", "$", "perpage", "=", "array", "(", ")", ";", "$", "perpage", "[", "0", "]", "=", "get_string", "(", "'allinone'", ",", "'quiz'", ")", ";", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<=", "50", ";", "++", "$", "i", ")", "{", "$", "perpage", "[", "$", "i", "]", "=", "$", "i", ";", "}", "$", "hiddenurl", "=", "clone", "(", "$", "pageurl", ")", ";", "$", "hiddenurl", "->", "param", "(", "'sesskey'", ",", "sesskey", "(", ")", ")", ";", "$", "select", "=", "html_writer", "::", "select", "(", "$", "perpage", ",", "'questionsperpage'", ",", "$", "structure", "->", "get_questions_per_page", "(", ")", ",", "false", ",", "array", "(", "'class'", "=>", "'custom-select'", ")", ")", ";", "$", "buttonattributes", "=", "array", "(", "'type'", "=>", "'submit'", ",", "'name'", "=>", "'repaginate'", ",", "'value'", "=>", "get_string", "(", "'go'", ")", ",", "'class'", "=>", "'btn btn-secondary ml-1'", ")", ";", "$", "formcontent", "=", "html_writer", "::", "tag", "(", "'form'", ",", "html_writer", "::", "div", "(", "html_writer", "::", "input_hidden_params", "(", "$", "hiddenurl", ")", ".", "get_string", "(", "'repaginate'", ",", "'quiz'", ",", "$", "select", ")", ".", "html_writer", "::", "empty_tag", "(", "'input'", ",", "$", "buttonattributes", ")", ")", ",", "array", "(", "'action'", "=>", "'edit.php'", ",", "'method'", "=>", "'post'", ")", ")", ";", "return", "html_writer", "::", "div", "(", "$", "formcontent", ",", "''", ",", "array", "(", "'id'", "=>", "'repaginatedialog'", ")", ")", ";", "}" ]
Return the repaginate form @param structure $structure the structure of the quiz being edited. @param \moodle_url $pageurl the canonical URL of this page. @return string HTML to output.
[ "Return", "the", "repaginate", "form" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L305-L332
216,406
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.total_marks
public function total_marks($quiz) { $totalmark = html_writer::span(quiz_format_grade($quiz, $quiz->sumgrades), 'mod_quiz_summarks'); return html_writer::tag('span', get_string('totalmarksx', 'quiz', $totalmark), array('class' => 'totalpoints')); }
php
public function total_marks($quiz) { $totalmark = html_writer::span(quiz_format_grade($quiz, $quiz->sumgrades), 'mod_quiz_summarks'); return html_writer::tag('span', get_string('totalmarksx', 'quiz', $totalmark), array('class' => 'totalpoints')); }
[ "public", "function", "total_marks", "(", "$", "quiz", ")", "{", "$", "totalmark", "=", "html_writer", "::", "span", "(", "quiz_format_grade", "(", "$", "quiz", ",", "$", "quiz", "->", "sumgrades", ")", ",", "'mod_quiz_summarks'", ")", ";", "return", "html_writer", "::", "tag", "(", "'span'", ",", "get_string", "(", "'totalmarksx'", ",", "'quiz'", ",", "$", "totalmark", ")", ",", "array", "(", "'class'", "=>", "'totalpoints'", ")", ")", ";", "}" ]
Render the total marks available for the quiz. @param \stdClass $quiz the quiz settings from the database. @return string HTML to output.
[ "Render", "the", "total", "marks", "available", "for", "the", "quiz", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L340-L345
216,407
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.start_section
protected function start_section($structure, $section) { $output = ''; $sectionstyle = ''; if ($structure->is_only_one_slot_in_section($section)) { $sectionstyle = ' only-has-one-slot'; } $output .= html_writer::start_tag('li', array('id' => 'section-'.$section->id, 'class' => 'section main clearfix'.$sectionstyle, 'role' => 'region', 'aria-label' => $section->heading)); $output .= html_writer::start_div('content'); $output .= html_writer::start_div('section-heading'); $headingtext = $this->heading(html_writer::span( html_writer::span($section->heading, 'instancesection'), 'sectioninstance'), 3); if (!$structure->can_be_edited()) { $editsectionheadingicon = ''; } else { $editsectionheadingicon = html_writer::link(new \moodle_url('#'), $this->pix_icon('t/editstring', get_string('sectionheadingedit', 'quiz', $section->heading), 'moodle', array('class' => 'editicon visibleifjs')), array('class' => 'editing_section', 'data-action' => 'edit_section_title')); } $output .= html_writer::div($headingtext . $editsectionheadingicon, 'instancesectioncontainer'); if (!$structure->is_first_section($section) && $structure->can_be_edited()) { $output .= $this->section_remove_icon($section); } $output .= $this->section_shuffle_questions($structure, $section); $output .= html_writer::end_div($output, 'section-heading'); return $output; }
php
protected function start_section($structure, $section) { $output = ''; $sectionstyle = ''; if ($structure->is_only_one_slot_in_section($section)) { $sectionstyle = ' only-has-one-slot'; } $output .= html_writer::start_tag('li', array('id' => 'section-'.$section->id, 'class' => 'section main clearfix'.$sectionstyle, 'role' => 'region', 'aria-label' => $section->heading)); $output .= html_writer::start_div('content'); $output .= html_writer::start_div('section-heading'); $headingtext = $this->heading(html_writer::span( html_writer::span($section->heading, 'instancesection'), 'sectioninstance'), 3); if (!$structure->can_be_edited()) { $editsectionheadingicon = ''; } else { $editsectionheadingicon = html_writer::link(new \moodle_url('#'), $this->pix_icon('t/editstring', get_string('sectionheadingedit', 'quiz', $section->heading), 'moodle', array('class' => 'editicon visibleifjs')), array('class' => 'editing_section', 'data-action' => 'edit_section_title')); } $output .= html_writer::div($headingtext . $editsectionheadingicon, 'instancesectioncontainer'); if (!$structure->is_first_section($section) && $structure->can_be_edited()) { $output .= $this->section_remove_icon($section); } $output .= $this->section_shuffle_questions($structure, $section); $output .= html_writer::end_div($output, 'section-heading'); return $output; }
[ "protected", "function", "start_section", "(", "$", "structure", ",", "$", "section", ")", "{", "$", "output", "=", "''", ";", "$", "sectionstyle", "=", "''", ";", "if", "(", "$", "structure", "->", "is_only_one_slot_in_section", "(", "$", "section", ")", ")", "{", "$", "sectionstyle", "=", "' only-has-one-slot'", ";", "}", "$", "output", ".=", "html_writer", "::", "start_tag", "(", "'li'", ",", "array", "(", "'id'", "=>", "'section-'", ".", "$", "section", "->", "id", ",", "'class'", "=>", "'section main clearfix'", ".", "$", "sectionstyle", ",", "'role'", "=>", "'region'", ",", "'aria-label'", "=>", "$", "section", "->", "heading", ")", ")", ";", "$", "output", ".=", "html_writer", "::", "start_div", "(", "'content'", ")", ";", "$", "output", ".=", "html_writer", "::", "start_div", "(", "'section-heading'", ")", ";", "$", "headingtext", "=", "$", "this", "->", "heading", "(", "html_writer", "::", "span", "(", "html_writer", "::", "span", "(", "$", "section", "->", "heading", ",", "'instancesection'", ")", ",", "'sectioninstance'", ")", ",", "3", ")", ";", "if", "(", "!", "$", "structure", "->", "can_be_edited", "(", ")", ")", "{", "$", "editsectionheadingicon", "=", "''", ";", "}", "else", "{", "$", "editsectionheadingicon", "=", "html_writer", "::", "link", "(", "new", "\\", "moodle_url", "(", "'#'", ")", ",", "$", "this", "->", "pix_icon", "(", "'t/editstring'", ",", "get_string", "(", "'sectionheadingedit'", ",", "'quiz'", ",", "$", "section", "->", "heading", ")", ",", "'moodle'", ",", "array", "(", "'class'", "=>", "'editicon visibleifjs'", ")", ")", ",", "array", "(", "'class'", "=>", "'editing_section'", ",", "'data-action'", "=>", "'edit_section_title'", ")", ")", ";", "}", "$", "output", ".=", "html_writer", "::", "div", "(", "$", "headingtext", ".", "$", "editsectionheadingicon", ",", "'instancesectioncontainer'", ")", ";", "if", "(", "!", "$", "structure", "->", "is_first_section", "(", "$", "section", ")", "&&", "$", "structure", "->", "can_be_edited", "(", ")", ")", "{", "$", "output", ".=", "$", "this", "->", "section_remove_icon", "(", "$", "section", ")", ";", "}", "$", "output", ".=", "$", "this", "->", "section_shuffle_questions", "(", "$", "structure", ",", "$", "section", ")", ";", "$", "output", ".=", "html_writer", "::", "end_div", "(", "$", "output", ",", "'section-heading'", ")", ";", "return", "$", "output", ";", "}" ]
Display the start of a section, before the questions. @param structure $structure the structure of the quiz being edited. @param \stdClass $section The quiz_section entry from DB @return string HTML to output.
[ "Display", "the", "start", "of", "a", "section", "before", "the", "questions", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L375-L413
216,408
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.section_shuffle_questions
public function section_shuffle_questions(structure $structure, $section) { $checkboxattributes = array( 'type' => 'checkbox', 'id' => 'shuffle-' . $section->id, 'value' => 1, 'data-action' => 'shuffle_questions', 'class' => 'cm-edit-action', ); if (!$structure->can_be_edited()) { $checkboxattributes['disabled'] = 'disabled'; } if ($section->shufflequestions) { $checkboxattributes['checked'] = 'checked'; } if ($structure->is_first_section($section)) { $help = $this->help_icon('shufflequestions', 'quiz'); } else { $help = ''; } $helpspan = html_writer::span($help, 'shuffle-help-tip'); $progressspan = html_writer::span('', 'shuffle-progress'); $checkbox = html_writer::empty_tag('input', $checkboxattributes); $label = html_writer::label(get_string('shufflequestions', 'quiz'), $checkboxattributes['id'], false); return html_writer::span($progressspan . $checkbox . $label. ' ' . $helpspan, 'instanceshufflequestions', array('data-action' => 'shuffle_questions')); }
php
public function section_shuffle_questions(structure $structure, $section) { $checkboxattributes = array( 'type' => 'checkbox', 'id' => 'shuffle-' . $section->id, 'value' => 1, 'data-action' => 'shuffle_questions', 'class' => 'cm-edit-action', ); if (!$structure->can_be_edited()) { $checkboxattributes['disabled'] = 'disabled'; } if ($section->shufflequestions) { $checkboxattributes['checked'] = 'checked'; } if ($structure->is_first_section($section)) { $help = $this->help_icon('shufflequestions', 'quiz'); } else { $help = ''; } $helpspan = html_writer::span($help, 'shuffle-help-tip'); $progressspan = html_writer::span('', 'shuffle-progress'); $checkbox = html_writer::empty_tag('input', $checkboxattributes); $label = html_writer::label(get_string('shufflequestions', 'quiz'), $checkboxattributes['id'], false); return html_writer::span($progressspan . $checkbox . $label. ' ' . $helpspan, 'instanceshufflequestions', array('data-action' => 'shuffle_questions')); }
[ "public", "function", "section_shuffle_questions", "(", "structure", "$", "structure", ",", "$", "section", ")", "{", "$", "checkboxattributes", "=", "array", "(", "'type'", "=>", "'checkbox'", ",", "'id'", "=>", "'shuffle-'", ".", "$", "section", "->", "id", ",", "'value'", "=>", "1", ",", "'data-action'", "=>", "'shuffle_questions'", ",", "'class'", "=>", "'cm-edit-action'", ",", ")", ";", "if", "(", "!", "$", "structure", "->", "can_be_edited", "(", ")", ")", "{", "$", "checkboxattributes", "[", "'disabled'", "]", "=", "'disabled'", ";", "}", "if", "(", "$", "section", "->", "shufflequestions", ")", "{", "$", "checkboxattributes", "[", "'checked'", "]", "=", "'checked'", ";", "}", "if", "(", "$", "structure", "->", "is_first_section", "(", "$", "section", ")", ")", "{", "$", "help", "=", "$", "this", "->", "help_icon", "(", "'shufflequestions'", ",", "'quiz'", ")", ";", "}", "else", "{", "$", "help", "=", "''", ";", "}", "$", "helpspan", "=", "html_writer", "::", "span", "(", "$", "help", ",", "'shuffle-help-tip'", ")", ";", "$", "progressspan", "=", "html_writer", "::", "span", "(", "''", ",", "'shuffle-progress'", ")", ";", "$", "checkbox", "=", "html_writer", "::", "empty_tag", "(", "'input'", ",", "$", "checkboxattributes", ")", ";", "$", "label", "=", "html_writer", "::", "label", "(", "get_string", "(", "'shufflequestions'", ",", "'quiz'", ")", ",", "$", "checkboxattributes", "[", "'id'", "]", ",", "false", ")", ";", "return", "html_writer", "::", "span", "(", "$", "progressspan", ".", "$", "checkbox", ".", "$", "label", ".", "' '", ".", "$", "helpspan", ",", "'instanceshufflequestions'", ",", "array", "(", "'data-action'", "=>", "'shuffle_questions'", ")", ")", ";", "}" ]
Display a checkbox for shuffling question within a section. @param structure $structure object containing the structure of the quiz. @param \stdClass $section data from the quiz_section table. @return string HTML to output.
[ "Display", "a", "checkbox", "for", "shuffling", "question", "within", "a", "section", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L422-L451
216,409
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.section_remove_icon
public function section_remove_icon($section) { $title = get_string('sectionheadingremove', 'quiz', $section->heading); $url = new \moodle_url('/mod/quiz/edit.php', array('sesskey' => sesskey(), 'removesection' => '1', 'sectionid' => $section->id)); $image = $this->pix_icon('t/delete', $title); return $this->action_link($url, $image, null, array( 'class' => 'cm-edit-action editing_delete', 'data-action' => 'deletesection')); }
php
public function section_remove_icon($section) { $title = get_string('sectionheadingremove', 'quiz', $section->heading); $url = new \moodle_url('/mod/quiz/edit.php', array('sesskey' => sesskey(), 'removesection' => '1', 'sectionid' => $section->id)); $image = $this->pix_icon('t/delete', $title); return $this->action_link($url, $image, null, array( 'class' => 'cm-edit-action editing_delete', 'data-action' => 'deletesection')); }
[ "public", "function", "section_remove_icon", "(", "$", "section", ")", "{", "$", "title", "=", "get_string", "(", "'sectionheadingremove'", ",", "'quiz'", ",", "$", "section", "->", "heading", ")", ";", "$", "url", "=", "new", "\\", "moodle_url", "(", "'/mod/quiz/edit.php'", ",", "array", "(", "'sesskey'", "=>", "sesskey", "(", ")", ",", "'removesection'", "=>", "'1'", ",", "'sectionid'", "=>", "$", "section", "->", "id", ")", ")", ";", "$", "image", "=", "$", "this", "->", "pix_icon", "(", "'t/delete'", ",", "$", "title", ")", ";", "return", "$", "this", "->", "action_link", "(", "$", "url", ",", "$", "image", ",", "null", ",", "array", "(", "'class'", "=>", "'cm-edit-action editing_delete'", ",", "'data-action'", "=>", "'deletesection'", ")", ")", ";", "}" ]
Render an icon to remove a section from the quiz. @param object $section the section to be removed. @return string HTML to output.
[ "Render", "an", "icon", "to", "remove", "a", "section", "from", "the", "quiz", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L471-L478
216,410
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.questions_in_section
public function questions_in_section(structure $structure, $section, $contexts, $pagevars, $pageurl) { $output = ''; foreach ($structure->get_slots_in_section($section->id) as $slot) { $output .= $this->question_row($structure, $slot, $contexts, $pagevars, $pageurl); } return html_writer::tag('ul', $output, array('class' => 'section img-text')); }
php
public function questions_in_section(structure $structure, $section, $contexts, $pagevars, $pageurl) { $output = ''; foreach ($structure->get_slots_in_section($section->id) as $slot) { $output .= $this->question_row($structure, $slot, $contexts, $pagevars, $pageurl); } return html_writer::tag('ul', $output, array('class' => 'section img-text')); }
[ "public", "function", "questions_in_section", "(", "structure", "$", "structure", ",", "$", "section", ",", "$", "contexts", ",", "$", "pagevars", ",", "$", "pageurl", ")", "{", "$", "output", "=", "''", ";", "foreach", "(", "$", "structure", "->", "get_slots_in_section", "(", "$", "section", "->", "id", ")", "as", "$", "slot", ")", "{", "$", "output", ".=", "$", "this", "->", "question_row", "(", "$", "structure", ",", "$", "slot", ",", "$", "contexts", ",", "$", "pagevars", ",", "$", "pageurl", ")", ";", "}", "return", "html_writer", "::", "tag", "(", "'ul'", ",", "$", "output", ",", "array", "(", "'class'", "=>", "'section img-text'", ")", ")", ";", "}" ]
Renders HTML to display the questions in a section of the quiz. This function calls {@link core_course_renderer::quiz_section_question()} @param structure $structure object containing the structure of the quiz. @param \stdClass $section information about the section. @param \question_edit_contexts $contexts the relevant question bank contexts. @param array $pagevars the variables from {@link \question_edit_setup()}. @param \moodle_url $pageurl the canonical URL of this page. @return string HTML to output.
[ "Renders", "HTML", "to", "display", "the", "questions", "in", "a", "section", "of", "the", "quiz", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L492-L500
216,411
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.add_menu_actions
public function add_menu_actions(structure $structure, $page, \moodle_url $pageurl, \question_edit_contexts $contexts, array $pagevars) { $actions = $this->edit_menu_actions($structure, $page, $pageurl, $pagevars); if (empty($actions)) { return ''; } $menu = new \action_menu(); $menu->set_alignment(\action_menu::TR, \action_menu::TR); $menu->set_constraint('.mod-quiz-edit-content'); $trigger = html_writer::tag('span', get_string('add', 'quiz'), array('class' => 'add-menu')); $menu->set_menu_trigger($trigger); // The menu appears within an absolutely positioned element causing width problems. // Make sure no-wrap is set so that we don't get a squashed menu. $menu->set_nowrap_on_items(true); // Disable the link if quiz has attempts. if (!$structure->can_be_edited()) { return $this->render($menu); } foreach ($actions as $action) { if ($action instanceof \action_menu_link) { $action->add_class('add-menu'); } $menu->add($action); } $menu->attributes['class'] .= ' page-add-actions commands'; // Prioritise the menu ahead of all other actions. $menu->prioritise = true; return $this->render($menu); }
php
public function add_menu_actions(structure $structure, $page, \moodle_url $pageurl, \question_edit_contexts $contexts, array $pagevars) { $actions = $this->edit_menu_actions($structure, $page, $pageurl, $pagevars); if (empty($actions)) { return ''; } $menu = new \action_menu(); $menu->set_alignment(\action_menu::TR, \action_menu::TR); $menu->set_constraint('.mod-quiz-edit-content'); $trigger = html_writer::tag('span', get_string('add', 'quiz'), array('class' => 'add-menu')); $menu->set_menu_trigger($trigger); // The menu appears within an absolutely positioned element causing width problems. // Make sure no-wrap is set so that we don't get a squashed menu. $menu->set_nowrap_on_items(true); // Disable the link if quiz has attempts. if (!$structure->can_be_edited()) { return $this->render($menu); } foreach ($actions as $action) { if ($action instanceof \action_menu_link) { $action->add_class('add-menu'); } $menu->add($action); } $menu->attributes['class'] .= ' page-add-actions commands'; // Prioritise the menu ahead of all other actions. $menu->prioritise = true; return $this->render($menu); }
[ "public", "function", "add_menu_actions", "(", "structure", "$", "structure", ",", "$", "page", ",", "\\", "moodle_url", "$", "pageurl", ",", "\\", "question_edit_contexts", "$", "contexts", ",", "array", "$", "pagevars", ")", "{", "$", "actions", "=", "$", "this", "->", "edit_menu_actions", "(", "$", "structure", ",", "$", "page", ",", "$", "pageurl", ",", "$", "pagevars", ")", ";", "if", "(", "empty", "(", "$", "actions", ")", ")", "{", "return", "''", ";", "}", "$", "menu", "=", "new", "\\", "action_menu", "(", ")", ";", "$", "menu", "->", "set_alignment", "(", "\\", "action_menu", "::", "TR", ",", "\\", "action_menu", "::", "TR", ")", ";", "$", "menu", "->", "set_constraint", "(", "'.mod-quiz-edit-content'", ")", ";", "$", "trigger", "=", "html_writer", "::", "tag", "(", "'span'", ",", "get_string", "(", "'add'", ",", "'quiz'", ")", ",", "array", "(", "'class'", "=>", "'add-menu'", ")", ")", ";", "$", "menu", "->", "set_menu_trigger", "(", "$", "trigger", ")", ";", "// The menu appears within an absolutely positioned element causing width problems.", "// Make sure no-wrap is set so that we don't get a squashed menu.", "$", "menu", "->", "set_nowrap_on_items", "(", "true", ")", ";", "// Disable the link if quiz has attempts.", "if", "(", "!", "$", "structure", "->", "can_be_edited", "(", ")", ")", "{", "return", "$", "this", "->", "render", "(", "$", "menu", ")", ";", "}", "foreach", "(", "$", "actions", "as", "$", "action", ")", "{", "if", "(", "$", "action", "instanceof", "\\", "action_menu_link", ")", "{", "$", "action", "->", "add_class", "(", "'add-menu'", ")", ";", "}", "$", "menu", "->", "add", "(", "$", "action", ")", ";", "}", "$", "menu", "->", "attributes", "[", "'class'", "]", ".=", "' page-add-actions commands'", ";", "// Prioritise the menu ahead of all other actions.", "$", "menu", "->", "prioritise", "=", "true", ";", "return", "$", "this", "->", "render", "(", "$", "menu", ")", ";", "}" ]
Returns the add menu that is output once per page. @param structure $structure object containing the structure of the quiz. @param int $page the page number that this menu will add to. @param \moodle_url $pageurl the canonical URL of this page. @param \question_edit_contexts $contexts the relevant question bank contexts. @param array $pagevars the variables from {@link \question_edit_setup()}. @return string HTML to output.
[ "Returns", "the", "add", "menu", "that", "is", "output", "once", "per", "page", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L578-L611
216,412
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.add_question_form
protected function add_question_form(structure $structure, $page, \moodle_url $pageurl, array $pagevars) { $questioncategoryid = question_get_category_id_from_pagevars($pagevars); $output = html_writer::tag('input', null, array('type' => 'hidden', 'name' => 'returnurl', 'value' => $pageurl->out_as_local_url(false, array('addonpage' => $page)))); $output .= html_writer::tag('input', null, array('type' => 'hidden', 'name' => 'cmid', 'value' => $structure->get_cmid())); $output .= html_writer::tag('input', null, array('type' => 'hidden', 'name' => 'appendqnumstring', 'value' => 'addquestion')); $output .= html_writer::tag('input', null, array('type' => 'hidden', 'name' => 'category', 'value' => $questioncategoryid)); return html_writer::tag('form', html_writer::div($output), array('class' => 'addnewquestion', 'method' => 'post', 'action' => new \moodle_url('/question/addquestion.php'))); }
php
protected function add_question_form(structure $structure, $page, \moodle_url $pageurl, array $pagevars) { $questioncategoryid = question_get_category_id_from_pagevars($pagevars); $output = html_writer::tag('input', null, array('type' => 'hidden', 'name' => 'returnurl', 'value' => $pageurl->out_as_local_url(false, array('addonpage' => $page)))); $output .= html_writer::tag('input', null, array('type' => 'hidden', 'name' => 'cmid', 'value' => $structure->get_cmid())); $output .= html_writer::tag('input', null, array('type' => 'hidden', 'name' => 'appendqnumstring', 'value' => 'addquestion')); $output .= html_writer::tag('input', null, array('type' => 'hidden', 'name' => 'category', 'value' => $questioncategoryid)); return html_writer::tag('form', html_writer::div($output), array('class' => 'addnewquestion', 'method' => 'post', 'action' => new \moodle_url('/question/addquestion.php'))); }
[ "protected", "function", "add_question_form", "(", "structure", "$", "structure", ",", "$", "page", ",", "\\", "moodle_url", "$", "pageurl", ",", "array", "$", "pagevars", ")", "{", "$", "questioncategoryid", "=", "question_get_category_id_from_pagevars", "(", "$", "pagevars", ")", ";", "$", "output", "=", "html_writer", "::", "tag", "(", "'input'", ",", "null", ",", "array", "(", "'type'", "=>", "'hidden'", ",", "'name'", "=>", "'returnurl'", ",", "'value'", "=>", "$", "pageurl", "->", "out_as_local_url", "(", "false", ",", "array", "(", "'addonpage'", "=>", "$", "page", ")", ")", ")", ")", ";", "$", "output", ".=", "html_writer", "::", "tag", "(", "'input'", ",", "null", ",", "array", "(", "'type'", "=>", "'hidden'", ",", "'name'", "=>", "'cmid'", ",", "'value'", "=>", "$", "structure", "->", "get_cmid", "(", ")", ")", ")", ";", "$", "output", ".=", "html_writer", "::", "tag", "(", "'input'", ",", "null", ",", "array", "(", "'type'", "=>", "'hidden'", ",", "'name'", "=>", "'appendqnumstring'", ",", "'value'", "=>", "'addquestion'", ")", ")", ";", "$", "output", ".=", "html_writer", "::", "tag", "(", "'input'", ",", "null", ",", "array", "(", "'type'", "=>", "'hidden'", ",", "'name'", "=>", "'category'", ",", "'value'", "=>", "$", "questioncategoryid", ")", ")", ";", "return", "html_writer", "::", "tag", "(", "'form'", ",", "html_writer", "::", "div", "(", "$", "output", ")", ",", "array", "(", "'class'", "=>", "'addnewquestion'", ",", "'method'", "=>", "'post'", ",", "'action'", "=>", "new", "\\", "moodle_url", "(", "'/question/addquestion.php'", ")", ")", ")", ";", "}" ]
Render the form that contains the data for adding a new question to the quiz. @param structure $structure object containing the structure of the quiz. @param int $page the page number that this menu will add to. @param \moodle_url $pageurl the canonical URL of this page. @param array $pagevars the variables from {@link \question_edit_setup()}. @return string HTML to output.
[ "Render", "the", "form", "that", "contains", "the", "data", "for", "adding", "a", "new", "question", "to", "the", "quiz", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L693-L710
216,413
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.question
public function question(structure $structure, $slot, \moodle_url $pageurl) { $output = ''; $output .= html_writer::start_tag('div'); if ($structure->can_be_edited()) { $output .= $this->question_move_icon($structure, $slot); } $output .= html_writer::start_div('mod-indent-outer'); $output .= html_writer::tag('input', '', array('id' => 'selectquestion-' . $structure->get_displayed_number_for_slot($slot), 'name' => 'selectquestion[]', 'type' => 'checkbox', 'class' => 'select-multiple-checkbox', 'value' => $structure->get_displayed_number_for_slot($slot))); $output .= $this->question_number($structure->get_displayed_number_for_slot($slot)); // This div is used to indent the content. $output .= html_writer::div('', 'mod-indent'); // Display the link to the question (or do nothing if question has no url). if ($structure->get_question_type_for_slot($slot) == 'random') { $questionname = $this->random_question($structure, $slot, $pageurl); } else { $questionname = $this->question_name($structure, $slot, $pageurl); } // Start the div for the activity title, excluding the edit icons. $output .= html_writer::start_div('activityinstance'); $output .= $questionname; // Closing the tag which contains everything but edit icons. Content part of the module should not be part of this. $output .= html_writer::end_tag('div'); // .activityinstance. // Action icons. $questionicons = ''; $questionicons .= $this->question_preview_icon($structure->get_quiz(), $structure->get_question_in_slot($slot)); if ($structure->can_be_edited()) { $questionicons .= $this->question_remove_icon($structure, $slot, $pageurl); } $questionicons .= $this->marked_out_of_field($structure, $slot); $output .= html_writer::span($questionicons, 'actions'); // Required to add js spinner icon. if ($structure->can_be_edited()) { $output .= $this->question_dependency_icon($structure, $slot); } // End of indentation div. $output .= html_writer::end_tag('div'); $output .= html_writer::end_tag('div'); return $output; }
php
public function question(structure $structure, $slot, \moodle_url $pageurl) { $output = ''; $output .= html_writer::start_tag('div'); if ($structure->can_be_edited()) { $output .= $this->question_move_icon($structure, $slot); } $output .= html_writer::start_div('mod-indent-outer'); $output .= html_writer::tag('input', '', array('id' => 'selectquestion-' . $structure->get_displayed_number_for_slot($slot), 'name' => 'selectquestion[]', 'type' => 'checkbox', 'class' => 'select-multiple-checkbox', 'value' => $structure->get_displayed_number_for_slot($slot))); $output .= $this->question_number($structure->get_displayed_number_for_slot($slot)); // This div is used to indent the content. $output .= html_writer::div('', 'mod-indent'); // Display the link to the question (or do nothing if question has no url). if ($structure->get_question_type_for_slot($slot) == 'random') { $questionname = $this->random_question($structure, $slot, $pageurl); } else { $questionname = $this->question_name($structure, $slot, $pageurl); } // Start the div for the activity title, excluding the edit icons. $output .= html_writer::start_div('activityinstance'); $output .= $questionname; // Closing the tag which contains everything but edit icons. Content part of the module should not be part of this. $output .= html_writer::end_tag('div'); // .activityinstance. // Action icons. $questionicons = ''; $questionicons .= $this->question_preview_icon($structure->get_quiz(), $structure->get_question_in_slot($slot)); if ($structure->can_be_edited()) { $questionicons .= $this->question_remove_icon($structure, $slot, $pageurl); } $questionicons .= $this->marked_out_of_field($structure, $slot); $output .= html_writer::span($questionicons, 'actions'); // Required to add js spinner icon. if ($structure->can_be_edited()) { $output .= $this->question_dependency_icon($structure, $slot); } // End of indentation div. $output .= html_writer::end_tag('div'); $output .= html_writer::end_tag('div'); return $output; }
[ "public", "function", "question", "(", "structure", "$", "structure", ",", "$", "slot", ",", "\\", "moodle_url", "$", "pageurl", ")", "{", "$", "output", "=", "''", ";", "$", "output", ".=", "html_writer", "::", "start_tag", "(", "'div'", ")", ";", "if", "(", "$", "structure", "->", "can_be_edited", "(", ")", ")", "{", "$", "output", ".=", "$", "this", "->", "question_move_icon", "(", "$", "structure", ",", "$", "slot", ")", ";", "}", "$", "output", ".=", "html_writer", "::", "start_div", "(", "'mod-indent-outer'", ")", ";", "$", "output", ".=", "html_writer", "::", "tag", "(", "'input'", ",", "''", ",", "array", "(", "'id'", "=>", "'selectquestion-'", ".", "$", "structure", "->", "get_displayed_number_for_slot", "(", "$", "slot", ")", ",", "'name'", "=>", "'selectquestion[]'", ",", "'type'", "=>", "'checkbox'", ",", "'class'", "=>", "'select-multiple-checkbox'", ",", "'value'", "=>", "$", "structure", "->", "get_displayed_number_for_slot", "(", "$", "slot", ")", ")", ")", ";", "$", "output", ".=", "$", "this", "->", "question_number", "(", "$", "structure", "->", "get_displayed_number_for_slot", "(", "$", "slot", ")", ")", ";", "// This div is used to indent the content.", "$", "output", ".=", "html_writer", "::", "div", "(", "''", ",", "'mod-indent'", ")", ";", "// Display the link to the question (or do nothing if question has no url).", "if", "(", "$", "structure", "->", "get_question_type_for_slot", "(", "$", "slot", ")", "==", "'random'", ")", "{", "$", "questionname", "=", "$", "this", "->", "random_question", "(", "$", "structure", ",", "$", "slot", ",", "$", "pageurl", ")", ";", "}", "else", "{", "$", "questionname", "=", "$", "this", "->", "question_name", "(", "$", "structure", ",", "$", "slot", ",", "$", "pageurl", ")", ";", "}", "// Start the div for the activity title, excluding the edit icons.", "$", "output", ".=", "html_writer", "::", "start_div", "(", "'activityinstance'", ")", ";", "$", "output", ".=", "$", "questionname", ";", "// Closing the tag which contains everything but edit icons. Content part of the module should not be part of this.", "$", "output", ".=", "html_writer", "::", "end_tag", "(", "'div'", ")", ";", "// .activityinstance.", "// Action icons.", "$", "questionicons", "=", "''", ";", "$", "questionicons", ".=", "$", "this", "->", "question_preview_icon", "(", "$", "structure", "->", "get_quiz", "(", ")", ",", "$", "structure", "->", "get_question_in_slot", "(", "$", "slot", ")", ")", ";", "if", "(", "$", "structure", "->", "can_be_edited", "(", ")", ")", "{", "$", "questionicons", ".=", "$", "this", "->", "question_remove_icon", "(", "$", "structure", ",", "$", "slot", ",", "$", "pageurl", ")", ";", "}", "$", "questionicons", ".=", "$", "this", "->", "marked_out_of_field", "(", "$", "structure", ",", "$", "slot", ")", ";", "$", "output", ".=", "html_writer", "::", "span", "(", "$", "questionicons", ",", "'actions'", ")", ";", "// Required to add js spinner icon.", "if", "(", "$", "structure", "->", "can_be_edited", "(", ")", ")", "{", "$", "output", ".=", "$", "this", "->", "question_dependency_icon", "(", "$", "structure", ",", "$", "slot", ")", ";", "}", "// End of indentation div.", "$", "output", ".=", "html_writer", "::", "end_tag", "(", "'div'", ")", ";", "$", "output", ".=", "html_writer", "::", "end_tag", "(", "'div'", ")", ";", "return", "$", "output", ";", "}" ]
Display a question. @param structure $structure object containing the structure of the quiz. @param int $slot the first slot on the page we are outputting. @param \moodle_url $pageurl the canonical URL of this page. @return string HTML to output.
[ "Display", "a", "question", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L720-L769
216,414
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.question_move_icon
public function question_move_icon(structure $structure, $slot) { return html_writer::link(new \moodle_url('#'), $this->pix_icon('i/dragdrop', get_string('move'), 'moodle', array('class' => 'iconsmall', 'title' => '')), array('class' => 'editing_move', 'data-action' => 'move') ); }
php
public function question_move_icon(structure $structure, $slot) { return html_writer::link(new \moodle_url('#'), $this->pix_icon('i/dragdrop', get_string('move'), 'moodle', array('class' => 'iconsmall', 'title' => '')), array('class' => 'editing_move', 'data-action' => 'move') ); }
[ "public", "function", "question_move_icon", "(", "structure", "$", "structure", ",", "$", "slot", ")", "{", "return", "html_writer", "::", "link", "(", "new", "\\", "moodle_url", "(", "'#'", ")", ",", "$", "this", "->", "pix_icon", "(", "'i/dragdrop'", ",", "get_string", "(", "'move'", ")", ",", "'moodle'", ",", "array", "(", "'class'", "=>", "'iconsmall'", ",", "'title'", "=>", "''", ")", ")", ",", "array", "(", "'class'", "=>", "'editing_move'", ",", "'data-action'", "=>", "'move'", ")", ")", ";", "}" ]
Render the move icon. @param structure $structure object containing the structure of the quiz. @param int $slot the first slot on the page we are outputting. @return string The markup for the move action.
[ "Render", "the", "move", "icon", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L778-L783
216,415
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.question_number
public function question_number($number) { if (is_numeric($number)) { $number = html_writer::span(get_string('question'), 'accesshide') . ' ' . $number; } return html_writer::tag('span', $number, array('class' => 'slotnumber')); }
php
public function question_number($number) { if (is_numeric($number)) { $number = html_writer::span(get_string('question'), 'accesshide') . ' ' . $number; } return html_writer::tag('span', $number, array('class' => 'slotnumber')); }
[ "public", "function", "question_number", "(", "$", "number", ")", "{", "if", "(", "is_numeric", "(", "$", "number", ")", ")", "{", "$", "number", "=", "html_writer", "::", "span", "(", "get_string", "(", "'question'", ")", ",", "'accesshide'", ")", ".", "' '", ".", "$", "number", ";", "}", "return", "html_writer", "::", "tag", "(", "'span'", ",", "$", "number", ",", "array", "(", "'class'", "=>", "'slotnumber'", ")", ")", ";", "}" ]
Output the question number. @param string $number The number, or 'i'. @return string HTML to output.
[ "Output", "the", "question", "number", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L790-L795
216,416
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.question_preview_icon
public function question_preview_icon($quiz, $question, $label = null, $variant = null) { $url = quiz_question_preview_url($quiz, $question, $variant); // Do we want a label? $strpreviewlabel = ''; if ($label) { $strpreviewlabel = ' ' . get_string('preview', 'quiz'); } // Build the icon. $strpreviewquestion = get_string('previewquestion', 'quiz'); $image = $this->pix_icon('t/preview', $strpreviewquestion); $action = new \popup_action('click', $url, 'questionpreview', question_preview_popup_params()); return $this->action_link($url, $image . $strpreviewlabel, $action, array('title' => $strpreviewquestion, 'class' => 'preview')); }
php
public function question_preview_icon($quiz, $question, $label = null, $variant = null) { $url = quiz_question_preview_url($quiz, $question, $variant); // Do we want a label? $strpreviewlabel = ''; if ($label) { $strpreviewlabel = ' ' . get_string('preview', 'quiz'); } // Build the icon. $strpreviewquestion = get_string('previewquestion', 'quiz'); $image = $this->pix_icon('t/preview', $strpreviewquestion); $action = new \popup_action('click', $url, 'questionpreview', question_preview_popup_params()); return $this->action_link($url, $image . $strpreviewlabel, $action, array('title' => $strpreviewquestion, 'class' => 'preview')); }
[ "public", "function", "question_preview_icon", "(", "$", "quiz", ",", "$", "question", ",", "$", "label", "=", "null", ",", "$", "variant", "=", "null", ")", "{", "$", "url", "=", "quiz_question_preview_url", "(", "$", "quiz", ",", "$", "question", ",", "$", "variant", ")", ";", "// Do we want a label?", "$", "strpreviewlabel", "=", "''", ";", "if", "(", "$", "label", ")", "{", "$", "strpreviewlabel", "=", "' '", ".", "get_string", "(", "'preview'", ",", "'quiz'", ")", ";", "}", "// Build the icon.", "$", "strpreviewquestion", "=", "get_string", "(", "'previewquestion'", ",", "'quiz'", ")", ";", "$", "image", "=", "$", "this", "->", "pix_icon", "(", "'t/preview'", ",", "$", "strpreviewquestion", ")", ";", "$", "action", "=", "new", "\\", "popup_action", "(", "'click'", ",", "$", "url", ",", "'questionpreview'", ",", "question_preview_popup_params", "(", ")", ")", ";", "return", "$", "this", "->", "action_link", "(", "$", "url", ",", "$", "image", ".", "$", "strpreviewlabel", ",", "$", "action", ",", "array", "(", "'title'", "=>", "$", "strpreviewquestion", ",", "'class'", "=>", "'preview'", ")", ")", ";", "}" ]
Render the preview icon. @param \stdClass $quiz the quiz settings from the database. @param \stdClass $question data from the question and quiz_slots tables. @param bool $label if true, show the preview question label after the icon @param int $variant which question variant to preview (optional). @return string HTML to output.
[ "Render", "the", "preview", "icon", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L806-L824
216,417
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.question_remove_icon
public function question_remove_icon(structure $structure, $slot, $pageurl) { $url = new \moodle_url($pageurl, array('sesskey' => sesskey(), 'remove' => $slot)); $strdelete = get_string('delete'); $image = $this->pix_icon('t/delete', $strdelete); return $this->action_link($url, $image, null, array('title' => $strdelete, 'class' => 'cm-edit-action editing_delete', 'data-action' => 'delete')); }
php
public function question_remove_icon(structure $structure, $slot, $pageurl) { $url = new \moodle_url($pageurl, array('sesskey' => sesskey(), 'remove' => $slot)); $strdelete = get_string('delete'); $image = $this->pix_icon('t/delete', $strdelete); return $this->action_link($url, $image, null, array('title' => $strdelete, 'class' => 'cm-edit-action editing_delete', 'data-action' => 'delete')); }
[ "public", "function", "question_remove_icon", "(", "structure", "$", "structure", ",", "$", "slot", ",", "$", "pageurl", ")", "{", "$", "url", "=", "new", "\\", "moodle_url", "(", "$", "pageurl", ",", "array", "(", "'sesskey'", "=>", "sesskey", "(", ")", ",", "'remove'", "=>", "$", "slot", ")", ")", ";", "$", "strdelete", "=", "get_string", "(", "'delete'", ")", ";", "$", "image", "=", "$", "this", "->", "pix_icon", "(", "'t/delete'", ",", "$", "strdelete", ")", ";", "return", "$", "this", "->", "action_link", "(", "$", "url", ",", "$", "image", ",", "null", ",", "array", "(", "'title'", "=>", "$", "strdelete", ",", "'class'", "=>", "'cm-edit-action editing_delete'", ",", "'data-action'", "=>", "'delete'", ")", ")", ";", "}" ]
Render an icon to remove a question from the quiz. @param structure $structure object containing the structure of the quiz. @param int $slot the first slot on the page we are outputting. @param \moodle_url $pageurl the canonical URL of the edit page. @return string HTML to output.
[ "Render", "an", "icon", "to", "remove", "a", "question", "from", "the", "quiz", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L834-L842
216,418
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.page_split_join_button
public function page_split_join_button($structure, $slot) { $insertpagebreak = !$structure->is_last_slot_on_page($slot); $url = new \moodle_url('repaginate.php', array('quizid' => $structure->get_quizid(), 'slot' => $slot, 'repag' => $insertpagebreak ? 2 : 1, 'sesskey' => sesskey())); if ($insertpagebreak) { $title = get_string('addpagebreak', 'quiz'); $image = $this->image_icon('e/insert_page_break', $title); $action = 'addpagebreak'; } else { $title = get_string('removepagebreak', 'quiz'); $image = $this->image_icon('e/remove_page_break', $title); $action = 'removepagebreak'; } // Disable the link if quiz has attempts. $disabled = null; if (!$structure->can_be_edited()) { $disabled = 'disabled'; } return html_writer::span($this->action_link($url, $image, null, array('title' => $title, 'class' => 'page_split_join cm-edit-action', 'disabled' => $disabled, 'data-action' => $action)), 'page_split_join_wrapper'); }
php
public function page_split_join_button($structure, $slot) { $insertpagebreak = !$structure->is_last_slot_on_page($slot); $url = new \moodle_url('repaginate.php', array('quizid' => $structure->get_quizid(), 'slot' => $slot, 'repag' => $insertpagebreak ? 2 : 1, 'sesskey' => sesskey())); if ($insertpagebreak) { $title = get_string('addpagebreak', 'quiz'); $image = $this->image_icon('e/insert_page_break', $title); $action = 'addpagebreak'; } else { $title = get_string('removepagebreak', 'quiz'); $image = $this->image_icon('e/remove_page_break', $title); $action = 'removepagebreak'; } // Disable the link if quiz has attempts. $disabled = null; if (!$structure->can_be_edited()) { $disabled = 'disabled'; } return html_writer::span($this->action_link($url, $image, null, array('title' => $title, 'class' => 'page_split_join cm-edit-action', 'disabled' => $disabled, 'data-action' => $action)), 'page_split_join_wrapper'); }
[ "public", "function", "page_split_join_button", "(", "$", "structure", ",", "$", "slot", ")", "{", "$", "insertpagebreak", "=", "!", "$", "structure", "->", "is_last_slot_on_page", "(", "$", "slot", ")", ";", "$", "url", "=", "new", "\\", "moodle_url", "(", "'repaginate.php'", ",", "array", "(", "'quizid'", "=>", "$", "structure", "->", "get_quizid", "(", ")", ",", "'slot'", "=>", "$", "slot", ",", "'repag'", "=>", "$", "insertpagebreak", "?", "2", ":", "1", ",", "'sesskey'", "=>", "sesskey", "(", ")", ")", ")", ";", "if", "(", "$", "insertpagebreak", ")", "{", "$", "title", "=", "get_string", "(", "'addpagebreak'", ",", "'quiz'", ")", ";", "$", "image", "=", "$", "this", "->", "image_icon", "(", "'e/insert_page_break'", ",", "$", "title", ")", ";", "$", "action", "=", "'addpagebreak'", ";", "}", "else", "{", "$", "title", "=", "get_string", "(", "'removepagebreak'", ",", "'quiz'", ")", ";", "$", "image", "=", "$", "this", "->", "image_icon", "(", "'e/remove_page_break'", ",", "$", "title", ")", ";", "$", "action", "=", "'removepagebreak'", ";", "}", "// Disable the link if quiz has attempts.", "$", "disabled", "=", "null", ";", "if", "(", "!", "$", "structure", "->", "can_be_edited", "(", ")", ")", "{", "$", "disabled", "=", "'disabled'", ";", "}", "return", "html_writer", "::", "span", "(", "$", "this", "->", "action_link", "(", "$", "url", ",", "$", "image", ",", "null", ",", "array", "(", "'title'", "=>", "$", "title", ",", "'class'", "=>", "'page_split_join cm-edit-action'", ",", "'disabled'", "=>", "$", "disabled", ",", "'data-action'", "=>", "$", "action", ")", ")", ",", "'page_split_join_wrapper'", ")", ";", "}" ]
Display an icon to split or join two pages of the quiz. @param structure $structure object containing the structure of the quiz. @param int $slot the first slot on the page we are outputting. @return string HTML to output.
[ "Display", "an", "icon", "to", "split", "or", "join", "two", "pages", "of", "the", "quiz", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L851-L874
216,419
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.question_dependency_icon
public function question_dependency_icon($structure, $slot) { $a = array( 'thisq' => $structure->get_displayed_number_for_slot($slot), 'previousq' => $structure->get_displayed_number_for_slot(max($slot - 1, 1)), ); if ($structure->is_question_dependent_on_previous_slot($slot)) { $title = get_string('questiondependencyremove', 'quiz', $a); $image = $this->pix_icon('t/locked', get_string('questiondependsonprevious', 'quiz'), 'moodle', array('title' => '')); $action = 'removedependency'; } else { $title = get_string('questiondependencyadd', 'quiz', $a); $image = $this->pix_icon('t/unlocked', get_string('questiondependencyfree', 'quiz'), 'moodle', array('title' => '')); $action = 'adddependency'; } // Disable the link if quiz has attempts. $disabled = null; if (!$structure->can_be_edited()) { $disabled = 'disabled'; } $extraclass = ''; if (!$structure->can_question_depend_on_previous_slot($slot)) { $extraclass = ' question_dependency_cannot_depend'; } return html_writer::span($this->action_link('#', $image, null, array('title' => $title, 'class' => 'cm-edit-action', 'disabled' => $disabled, 'data-action' => $action)), 'question_dependency_wrapper' . $extraclass); }
php
public function question_dependency_icon($structure, $slot) { $a = array( 'thisq' => $structure->get_displayed_number_for_slot($slot), 'previousq' => $structure->get_displayed_number_for_slot(max($slot - 1, 1)), ); if ($structure->is_question_dependent_on_previous_slot($slot)) { $title = get_string('questiondependencyremove', 'quiz', $a); $image = $this->pix_icon('t/locked', get_string('questiondependsonprevious', 'quiz'), 'moodle', array('title' => '')); $action = 'removedependency'; } else { $title = get_string('questiondependencyadd', 'quiz', $a); $image = $this->pix_icon('t/unlocked', get_string('questiondependencyfree', 'quiz'), 'moodle', array('title' => '')); $action = 'adddependency'; } // Disable the link if quiz has attempts. $disabled = null; if (!$structure->can_be_edited()) { $disabled = 'disabled'; } $extraclass = ''; if (!$structure->can_question_depend_on_previous_slot($slot)) { $extraclass = ' question_dependency_cannot_depend'; } return html_writer::span($this->action_link('#', $image, null, array('title' => $title, 'class' => 'cm-edit-action', 'disabled' => $disabled, 'data-action' => $action)), 'question_dependency_wrapper' . $extraclass); }
[ "public", "function", "question_dependency_icon", "(", "$", "structure", ",", "$", "slot", ")", "{", "$", "a", "=", "array", "(", "'thisq'", "=>", "$", "structure", "->", "get_displayed_number_for_slot", "(", "$", "slot", ")", ",", "'previousq'", "=>", "$", "structure", "->", "get_displayed_number_for_slot", "(", "max", "(", "$", "slot", "-", "1", ",", "1", ")", ")", ",", ")", ";", "if", "(", "$", "structure", "->", "is_question_dependent_on_previous_slot", "(", "$", "slot", ")", ")", "{", "$", "title", "=", "get_string", "(", "'questiondependencyremove'", ",", "'quiz'", ",", "$", "a", ")", ";", "$", "image", "=", "$", "this", "->", "pix_icon", "(", "'t/locked'", ",", "get_string", "(", "'questiondependsonprevious'", ",", "'quiz'", ")", ",", "'moodle'", ",", "array", "(", "'title'", "=>", "''", ")", ")", ";", "$", "action", "=", "'removedependency'", ";", "}", "else", "{", "$", "title", "=", "get_string", "(", "'questiondependencyadd'", ",", "'quiz'", ",", "$", "a", ")", ";", "$", "image", "=", "$", "this", "->", "pix_icon", "(", "'t/unlocked'", ",", "get_string", "(", "'questiondependencyfree'", ",", "'quiz'", ")", ",", "'moodle'", ",", "array", "(", "'title'", "=>", "''", ")", ")", ";", "$", "action", "=", "'adddependency'", ";", "}", "// Disable the link if quiz has attempts.", "$", "disabled", "=", "null", ";", "if", "(", "!", "$", "structure", "->", "can_be_edited", "(", ")", ")", "{", "$", "disabled", "=", "'disabled'", ";", "}", "$", "extraclass", "=", "''", ";", "if", "(", "!", "$", "structure", "->", "can_question_depend_on_previous_slot", "(", "$", "slot", ")", ")", "{", "$", "extraclass", "=", "' question_dependency_cannot_depend'", ";", "}", "return", "html_writer", "::", "span", "(", "$", "this", "->", "action_link", "(", "'#'", ",", "$", "image", ",", "null", ",", "array", "(", "'title'", "=>", "$", "title", ",", "'class'", "=>", "'cm-edit-action'", ",", "'disabled'", "=>", "$", "disabled", ",", "'data-action'", "=>", "$", "action", ")", ")", ",", "'question_dependency_wrapper'", ".", "$", "extraclass", ")", ";", "}" ]
Display the icon for whether this question can only be seen if the previous one has been answered. @param structure $structure object containing the structure of the quiz. @param int $slot the first slot on the page we are outputting. @return string HTML to output.
[ "Display", "the", "icon", "for", "whether", "this", "question", "can", "only", "be", "seen", "if", "the", "previous", "one", "has", "been", "answered", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L884-L913
216,420
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.question_name
public function question_name(structure $structure, $slot, $pageurl) { $output = ''; $question = $structure->get_question_in_slot($slot); $editurl = new \moodle_url('/question/question.php', array( 'returnurl' => $pageurl->out_as_local_url(), 'cmid' => $structure->get_cmid(), 'id' => $question->id)); $instancename = quiz_question_tostring($question); $qtype = \question_bank::get_qtype($question->qtype, false); $namestr = $qtype->local_name(); $icon = $this->pix_icon('icon', $namestr, $qtype->plugin_name(), array('title' => $namestr, 'class' => 'icon activityicon', 'alt' => ' ', 'role' => 'presentation')); $editicon = $this->pix_icon('t/edit', '', 'moodle', array('title' => '')); // Need plain question name without html tags for link title. $title = shorten_text(format_string($question->name), 100); // Display the link itself. $activitylink = $icon . html_writer::tag('span', $editicon . $instancename, array('class' => 'instancename')); $output .= html_writer::link($editurl, $activitylink, array('title' => get_string('editquestion', 'quiz').' '.$title)); return $output; }
php
public function question_name(structure $structure, $slot, $pageurl) { $output = ''; $question = $structure->get_question_in_slot($slot); $editurl = new \moodle_url('/question/question.php', array( 'returnurl' => $pageurl->out_as_local_url(), 'cmid' => $structure->get_cmid(), 'id' => $question->id)); $instancename = quiz_question_tostring($question); $qtype = \question_bank::get_qtype($question->qtype, false); $namestr = $qtype->local_name(); $icon = $this->pix_icon('icon', $namestr, $qtype->plugin_name(), array('title' => $namestr, 'class' => 'icon activityicon', 'alt' => ' ', 'role' => 'presentation')); $editicon = $this->pix_icon('t/edit', '', 'moodle', array('title' => '')); // Need plain question name without html tags for link title. $title = shorten_text(format_string($question->name), 100); // Display the link itself. $activitylink = $icon . html_writer::tag('span', $editicon . $instancename, array('class' => 'instancename')); $output .= html_writer::link($editurl, $activitylink, array('title' => get_string('editquestion', 'quiz').' '.$title)); return $output; }
[ "public", "function", "question_name", "(", "structure", "$", "structure", ",", "$", "slot", ",", "$", "pageurl", ")", "{", "$", "output", "=", "''", ";", "$", "question", "=", "$", "structure", "->", "get_question_in_slot", "(", "$", "slot", ")", ";", "$", "editurl", "=", "new", "\\", "moodle_url", "(", "'/question/question.php'", ",", "array", "(", "'returnurl'", "=>", "$", "pageurl", "->", "out_as_local_url", "(", ")", ",", "'cmid'", "=>", "$", "structure", "->", "get_cmid", "(", ")", ",", "'id'", "=>", "$", "question", "->", "id", ")", ")", ";", "$", "instancename", "=", "quiz_question_tostring", "(", "$", "question", ")", ";", "$", "qtype", "=", "\\", "question_bank", "::", "get_qtype", "(", "$", "question", "->", "qtype", ",", "false", ")", ";", "$", "namestr", "=", "$", "qtype", "->", "local_name", "(", ")", ";", "$", "icon", "=", "$", "this", "->", "pix_icon", "(", "'icon'", ",", "$", "namestr", ",", "$", "qtype", "->", "plugin_name", "(", ")", ",", "array", "(", "'title'", "=>", "$", "namestr", ",", "'class'", "=>", "'icon activityicon'", ",", "'alt'", "=>", "' '", ",", "'role'", "=>", "'presentation'", ")", ")", ";", "$", "editicon", "=", "$", "this", "->", "pix_icon", "(", "'t/edit'", ",", "''", ",", "'moodle'", ",", "array", "(", "'title'", "=>", "''", ")", ")", ";", "// Need plain question name without html tags for link title.", "$", "title", "=", "shorten_text", "(", "format_string", "(", "$", "question", "->", "name", ")", ",", "100", ")", ";", "// Display the link itself.", "$", "activitylink", "=", "$", "icon", ".", "html_writer", "::", "tag", "(", "'span'", ",", "$", "editicon", ".", "$", "instancename", ",", "array", "(", "'class'", "=>", "'instancename'", ")", ")", ";", "$", "output", ".=", "html_writer", "::", "link", "(", "$", "editurl", ",", "$", "activitylink", ",", "array", "(", "'title'", "=>", "get_string", "(", "'editquestion'", ",", "'quiz'", ")", ".", "' '", ".", "$", "title", ")", ")", ";", "return", "$", "output", ";", "}" ]
Renders html to display a name with the link to the question on a quiz edit page If the user does not have permission to edi the question, it is rendered without a link @param structure $structure object containing the structure of the quiz. @param int $slot which slot we are outputting. @param \moodle_url $pageurl the canonical URL of this page. @return string HTML to output.
[ "Renders", "html", "to", "display", "a", "name", "with", "the", "link", "to", "the", "question", "on", "a", "quiz", "edit", "page" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L926-L953
216,421
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.random_question
public function random_question(structure $structure, $slotnumber, $pageurl) { $question = $structure->get_question_in_slot($slotnumber); $slot = $structure->get_slot_by_number($slotnumber); $slottags = $structure->get_slot_tags_for_slot_id($slot->id); $editurl = new \moodle_url('/mod/quiz/editrandom.php', array('returnurl' => $pageurl->out_as_local_url(), 'slotid' => $slot->id)); $temp = clone($question); $temp->questiontext = ''; $instancename = quiz_question_tostring($temp); $configuretitle = get_string('configurerandomquestion', 'quiz'); $qtype = \question_bank::get_qtype($question->qtype, false); $namestr = $qtype->local_name(); $icon = $this->pix_icon('icon', $namestr, $qtype->plugin_name(), array('title' => $namestr, 'class' => 'icon activityicon', 'alt' => ' ', 'role' => 'presentation')); $editicon = $this->pix_icon('t/edit', $configuretitle, 'moodle', array('title' => '')); $qbankurlparams = array( 'cmid' => $structure->get_cmid(), 'cat' => $question->category . ',' . $question->contextid, 'recurse' => !empty($question->questiontext) ); foreach ($slottags as $index => $slottag) { $qbankurlparams["qtagids[{$index}]"] = $slottag->tagid; } // If this is a random question, display a link to show the questions // selected from in the question bank. $qbankurl = new \moodle_url('/question/edit.php', $qbankurlparams); $qbanklink = ' ' . \html_writer::link($qbankurl, get_string('seequestions', 'quiz'), array('class' => 'mod_quiz_random_qbank_link')); return html_writer::link($editurl, $icon . $editicon, array('title' => $configuretitle)) . ' ' . $instancename . ' ' . $qbanklink; }
php
public function random_question(structure $structure, $slotnumber, $pageurl) { $question = $structure->get_question_in_slot($slotnumber); $slot = $structure->get_slot_by_number($slotnumber); $slottags = $structure->get_slot_tags_for_slot_id($slot->id); $editurl = new \moodle_url('/mod/quiz/editrandom.php', array('returnurl' => $pageurl->out_as_local_url(), 'slotid' => $slot->id)); $temp = clone($question); $temp->questiontext = ''; $instancename = quiz_question_tostring($temp); $configuretitle = get_string('configurerandomquestion', 'quiz'); $qtype = \question_bank::get_qtype($question->qtype, false); $namestr = $qtype->local_name(); $icon = $this->pix_icon('icon', $namestr, $qtype->plugin_name(), array('title' => $namestr, 'class' => 'icon activityicon', 'alt' => ' ', 'role' => 'presentation')); $editicon = $this->pix_icon('t/edit', $configuretitle, 'moodle', array('title' => '')); $qbankurlparams = array( 'cmid' => $structure->get_cmid(), 'cat' => $question->category . ',' . $question->contextid, 'recurse' => !empty($question->questiontext) ); foreach ($slottags as $index => $slottag) { $qbankurlparams["qtagids[{$index}]"] = $slottag->tagid; } // If this is a random question, display a link to show the questions // selected from in the question bank. $qbankurl = new \moodle_url('/question/edit.php', $qbankurlparams); $qbanklink = ' ' . \html_writer::link($qbankurl, get_string('seequestions', 'quiz'), array('class' => 'mod_quiz_random_qbank_link')); return html_writer::link($editurl, $icon . $editicon, array('title' => $configuretitle)) . ' ' . $instancename . ' ' . $qbanklink; }
[ "public", "function", "random_question", "(", "structure", "$", "structure", ",", "$", "slotnumber", ",", "$", "pageurl", ")", "{", "$", "question", "=", "$", "structure", "->", "get_question_in_slot", "(", "$", "slotnumber", ")", ";", "$", "slot", "=", "$", "structure", "->", "get_slot_by_number", "(", "$", "slotnumber", ")", ";", "$", "slottags", "=", "$", "structure", "->", "get_slot_tags_for_slot_id", "(", "$", "slot", "->", "id", ")", ";", "$", "editurl", "=", "new", "\\", "moodle_url", "(", "'/mod/quiz/editrandom.php'", ",", "array", "(", "'returnurl'", "=>", "$", "pageurl", "->", "out_as_local_url", "(", ")", ",", "'slotid'", "=>", "$", "slot", "->", "id", ")", ")", ";", "$", "temp", "=", "clone", "(", "$", "question", ")", ";", "$", "temp", "->", "questiontext", "=", "''", ";", "$", "instancename", "=", "quiz_question_tostring", "(", "$", "temp", ")", ";", "$", "configuretitle", "=", "get_string", "(", "'configurerandomquestion'", ",", "'quiz'", ")", ";", "$", "qtype", "=", "\\", "question_bank", "::", "get_qtype", "(", "$", "question", "->", "qtype", ",", "false", ")", ";", "$", "namestr", "=", "$", "qtype", "->", "local_name", "(", ")", ";", "$", "icon", "=", "$", "this", "->", "pix_icon", "(", "'icon'", ",", "$", "namestr", ",", "$", "qtype", "->", "plugin_name", "(", ")", ",", "array", "(", "'title'", "=>", "$", "namestr", ",", "'class'", "=>", "'icon activityicon'", ",", "'alt'", "=>", "' '", ",", "'role'", "=>", "'presentation'", ")", ")", ";", "$", "editicon", "=", "$", "this", "->", "pix_icon", "(", "'t/edit'", ",", "$", "configuretitle", ",", "'moodle'", ",", "array", "(", "'title'", "=>", "''", ")", ")", ";", "$", "qbankurlparams", "=", "array", "(", "'cmid'", "=>", "$", "structure", "->", "get_cmid", "(", ")", ",", "'cat'", "=>", "$", "question", "->", "category", ".", "','", ".", "$", "question", "->", "contextid", ",", "'recurse'", "=>", "!", "empty", "(", "$", "question", "->", "questiontext", ")", ")", ";", "foreach", "(", "$", "slottags", "as", "$", "index", "=>", "$", "slottag", ")", "{", "$", "qbankurlparams", "[", "\"qtagids[{$index}]\"", "]", "=", "$", "slottag", "->", "tagid", ";", "}", "// If this is a random question, display a link to show the questions", "// selected from in the question bank.", "$", "qbankurl", "=", "new", "\\", "moodle_url", "(", "'/question/edit.php'", ",", "$", "qbankurlparams", ")", ";", "$", "qbanklink", "=", "' '", ".", "\\", "html_writer", "::", "link", "(", "$", "qbankurl", ",", "get_string", "(", "'seequestions'", ",", "'quiz'", ")", ",", "array", "(", "'class'", "=>", "'mod_quiz_random_qbank_link'", ")", ")", ";", "return", "html_writer", "::", "link", "(", "$", "editurl", ",", "$", "icon", ".", "$", "editicon", ",", "array", "(", "'title'", "=>", "$", "configuretitle", ")", ")", ".", "' '", ".", "$", "instancename", ".", "' '", ".", "$", "qbanklink", ";", "}" ]
Renders html to display a random question the link to edit the configuration and also to see that category in the question bank. @param structure $structure object containing the structure of the quiz. @param int $slotnumber which slot we are outputting. @param \moodle_url $pageurl the canonical URL of this page. @return string HTML to output.
[ "Renders", "html", "to", "display", "a", "random", "question", "the", "link", "to", "edit", "the", "configuration", "and", "also", "to", "see", "that", "category", "in", "the", "question", "bank", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L964-L1001
216,422
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.marked_out_of_field
public function marked_out_of_field(structure $structure, $slot) { if (!$structure->is_real_question($slot)) { $output = html_writer::span('', 'instancemaxmark decimalplaces_' . $structure->get_decimal_places_for_question_marks()); $output .= html_writer::span( $this->pix_icon('spacer', '', 'moodle', array('class' => 'editicon visibleifjs', 'title' => '')), 'editing_maxmark'); return html_writer::span($output, 'instancemaxmarkcontainer infoitem'); } $output = html_writer::span($structure->formatted_question_grade($slot), 'instancemaxmark decimalplaces_' . $structure->get_decimal_places_for_question_marks(), array('title' => get_string('maxmark', 'quiz'))); $output .= html_writer::span( html_writer::link( new \moodle_url('#'), $this->pix_icon('t/editstring', '', 'moodle', array('class' => 'editicon visibleifjs', 'title' => '')), array( 'class' => 'editing_maxmark', 'data-action' => 'editmaxmark', 'title' => get_string('editmaxmark', 'quiz'), ) ) ); return html_writer::span($output, 'instancemaxmarkcontainer'); }
php
public function marked_out_of_field(structure $structure, $slot) { if (!$structure->is_real_question($slot)) { $output = html_writer::span('', 'instancemaxmark decimalplaces_' . $structure->get_decimal_places_for_question_marks()); $output .= html_writer::span( $this->pix_icon('spacer', '', 'moodle', array('class' => 'editicon visibleifjs', 'title' => '')), 'editing_maxmark'); return html_writer::span($output, 'instancemaxmarkcontainer infoitem'); } $output = html_writer::span($structure->formatted_question_grade($slot), 'instancemaxmark decimalplaces_' . $structure->get_decimal_places_for_question_marks(), array('title' => get_string('maxmark', 'quiz'))); $output .= html_writer::span( html_writer::link( new \moodle_url('#'), $this->pix_icon('t/editstring', '', 'moodle', array('class' => 'editicon visibleifjs', 'title' => '')), array( 'class' => 'editing_maxmark', 'data-action' => 'editmaxmark', 'title' => get_string('editmaxmark', 'quiz'), ) ) ); return html_writer::span($output, 'instancemaxmarkcontainer'); }
[ "public", "function", "marked_out_of_field", "(", "structure", "$", "structure", ",", "$", "slot", ")", "{", "if", "(", "!", "$", "structure", "->", "is_real_question", "(", "$", "slot", ")", ")", "{", "$", "output", "=", "html_writer", "::", "span", "(", "''", ",", "'instancemaxmark decimalplaces_'", ".", "$", "structure", "->", "get_decimal_places_for_question_marks", "(", ")", ")", ";", "$", "output", ".=", "html_writer", "::", "span", "(", "$", "this", "->", "pix_icon", "(", "'spacer'", ",", "''", ",", "'moodle'", ",", "array", "(", "'class'", "=>", "'editicon visibleifjs'", ",", "'title'", "=>", "''", ")", ")", ",", "'editing_maxmark'", ")", ";", "return", "html_writer", "::", "span", "(", "$", "output", ",", "'instancemaxmarkcontainer infoitem'", ")", ";", "}", "$", "output", "=", "html_writer", "::", "span", "(", "$", "structure", "->", "formatted_question_grade", "(", "$", "slot", ")", ",", "'instancemaxmark decimalplaces_'", ".", "$", "structure", "->", "get_decimal_places_for_question_marks", "(", ")", ",", "array", "(", "'title'", "=>", "get_string", "(", "'maxmark'", ",", "'quiz'", ")", ")", ")", ";", "$", "output", ".=", "html_writer", "::", "span", "(", "html_writer", "::", "link", "(", "new", "\\", "moodle_url", "(", "'#'", ")", ",", "$", "this", "->", "pix_icon", "(", "'t/editstring'", ",", "''", ",", "'moodle'", ",", "array", "(", "'class'", "=>", "'editicon visibleifjs'", ",", "'title'", "=>", "''", ")", ")", ",", "array", "(", "'class'", "=>", "'editing_maxmark'", ",", "'data-action'", "=>", "'editmaxmark'", ",", "'title'", "=>", "get_string", "(", "'editmaxmark'", ",", "'quiz'", ")", ",", ")", ")", ")", ";", "return", "html_writer", "::", "span", "(", "$", "output", ",", "'instancemaxmarkcontainer'", ")", ";", "}" ]
Display the 'marked out of' information for a question. Along with the regrade action. @param structure $structure object containing the structure of the quiz. @param int $slot which slot we are outputting. @return string HTML to output.
[ "Display", "the", "marked", "out", "of", "information", "for", "a", "question", ".", "Along", "with", "the", "regrade", "action", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L1010-L1037
216,423
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.question_chooser
public function question_chooser() { $chooser = \mod_quiz\output\question_chooser::get($this->page->course, [], null); $container = html_writer::div($this->render($chooser), '', array('id' => 'qtypechoicecontainer')); return html_writer::div($container, 'createnewquestion'); }
php
public function question_chooser() { $chooser = \mod_quiz\output\question_chooser::get($this->page->course, [], null); $container = html_writer::div($this->render($chooser), '', array('id' => 'qtypechoicecontainer')); return html_writer::div($container, 'createnewquestion'); }
[ "public", "function", "question_chooser", "(", ")", "{", "$", "chooser", "=", "\\", "mod_quiz", "\\", "output", "\\", "question_chooser", "::", "get", "(", "$", "this", "->", "page", "->", "course", ",", "[", "]", ",", "null", ")", ";", "$", "container", "=", "html_writer", "::", "div", "(", "$", "this", "->", "render", "(", "$", "chooser", ")", ",", "''", ",", "array", "(", "'id'", "=>", "'qtypechoicecontainer'", ")", ")", ";", "return", "html_writer", "::", "div", "(", "$", "container", ",", "'createnewquestion'", ")", ";", "}" ]
Render the question type chooser dialogue. @return string HTML to output.
[ "Render", "the", "question", "type", "chooser", "dialogue", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L1053-L1057
216,424
moodle/moodle
mod/quiz/classes/output/edit_renderer.php
edit_renderer.question_bank_contents
public function question_bank_contents(\mod_quiz\question\bank\custom_view $questionbank, array $pagevars) { $qbank = $questionbank->render('editq', $pagevars['qpage'], $pagevars['qperpage'], $pagevars['cat'], $pagevars['recurse'], $pagevars['showhidden'], $pagevars['qbshowtext'], $pagevars['qtagids']); return html_writer::div(html_writer::div($qbank, 'bd'), 'questionbankformforpopup'); }
php
public function question_bank_contents(\mod_quiz\question\bank\custom_view $questionbank, array $pagevars) { $qbank = $questionbank->render('editq', $pagevars['qpage'], $pagevars['qperpage'], $pagevars['cat'], $pagevars['recurse'], $pagevars['showhidden'], $pagevars['qbshowtext'], $pagevars['qtagids']); return html_writer::div(html_writer::div($qbank, 'bd'), 'questionbankformforpopup'); }
[ "public", "function", "question_bank_contents", "(", "\\", "mod_quiz", "\\", "question", "\\", "bank", "\\", "custom_view", "$", "questionbank", ",", "array", "$", "pagevars", ")", "{", "$", "qbank", "=", "$", "questionbank", "->", "render", "(", "'editq'", ",", "$", "pagevars", "[", "'qpage'", "]", ",", "$", "pagevars", "[", "'qperpage'", "]", ",", "$", "pagevars", "[", "'cat'", "]", ",", "$", "pagevars", "[", "'recurse'", "]", ",", "$", "pagevars", "[", "'showhidden'", "]", ",", "$", "pagevars", "[", "'qbshowtext'", "]", ",", "$", "pagevars", "[", "'qtagids'", "]", ")", ";", "return", "html_writer", "::", "div", "(", "html_writer", "::", "div", "(", "$", "qbank", ",", "'bd'", ")", ",", "'questionbankformforpopup'", ")", ";", "}" ]
Return the contents of the question bank, to be displayed in the question-bank pop-up. @param \mod_quiz\question\bank\custom_view $questionbank the question bank view object. @param array $pagevars the variables from {@link \question_edit_setup()}. @return string HTML to output / send back in response to an AJAX request.
[ "Return", "the", "contents", "of", "the", "question", "bank", "to", "be", "displayed", "in", "the", "question", "-", "bank", "pop", "-", "up", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/classes/output/edit_renderer.php#L1232-L1238
216,425
moodle/moodle
mod/forum/classes/privacy/provider.php
provider.export_discussion_data
protected static function export_discussion_data(int $userid, array $mappings) { global $DB; // Find all of the discussions, and discussion subscriptions for this forum. list($foruminsql, $forumparams) = $DB->get_in_or_equal(array_keys($mappings), SQL_PARAMS_NAMED); $sql = "SELECT d.*, g.name as groupname, dsub.preference FROM {forum} f JOIN {forum_discussions} d ON d.forum = f.id LEFT JOIN {groups} g ON g.id = d.groupid LEFT JOIN {forum_discussion_subs} dsub ON dsub.discussion = d.id AND dsub.userid = :dsubuserid LEFT JOIN {forum_posts} p ON p.discussion = d.id WHERE f.id ${foruminsql} AND ( d.userid = :discussionuserid OR p.userid = :postuserid OR dsub.id IS NOT NULL ) "; $params = [ 'postuserid' => $userid, 'discussionuserid' => $userid, 'dsubuserid' => $userid, ]; $params += $forumparams; // Keep track of the forums which have data. $forumswithdata = []; $discussions = $DB->get_recordset_sql($sql, $params); foreach ($discussions as $discussion) { // No need to take timestart into account as the user has some involvement already. // Ignore discussion timeend as it should not block access to user data. $forumswithdata[$discussion->forum] = true; $context = \context::instance_by_id($mappings[$discussion->forum]); // Store related metadata for this discussion. static::export_discussion_subscription_data($userid, $context, $discussion); $discussiondata = (object) [ 'name' => format_string($discussion->name, true), 'pinned' => transform::yesno((bool) $discussion->pinned), 'timemodified' => transform::datetime($discussion->timemodified), 'usermodified' => transform::datetime($discussion->usermodified), 'creator_was_you' => transform::yesno($discussion->userid == $userid), ]; // Store the discussion content. writer::with_context($context) ->export_data(static::get_discussion_area($discussion), $discussiondata); // Forum discussions do not have any files associately directly with them. } $discussions->close(); return $forumswithdata; }
php
protected static function export_discussion_data(int $userid, array $mappings) { global $DB; // Find all of the discussions, and discussion subscriptions for this forum. list($foruminsql, $forumparams) = $DB->get_in_or_equal(array_keys($mappings), SQL_PARAMS_NAMED); $sql = "SELECT d.*, g.name as groupname, dsub.preference FROM {forum} f JOIN {forum_discussions} d ON d.forum = f.id LEFT JOIN {groups} g ON g.id = d.groupid LEFT JOIN {forum_discussion_subs} dsub ON dsub.discussion = d.id AND dsub.userid = :dsubuserid LEFT JOIN {forum_posts} p ON p.discussion = d.id WHERE f.id ${foruminsql} AND ( d.userid = :discussionuserid OR p.userid = :postuserid OR dsub.id IS NOT NULL ) "; $params = [ 'postuserid' => $userid, 'discussionuserid' => $userid, 'dsubuserid' => $userid, ]; $params += $forumparams; // Keep track of the forums which have data. $forumswithdata = []; $discussions = $DB->get_recordset_sql($sql, $params); foreach ($discussions as $discussion) { // No need to take timestart into account as the user has some involvement already. // Ignore discussion timeend as it should not block access to user data. $forumswithdata[$discussion->forum] = true; $context = \context::instance_by_id($mappings[$discussion->forum]); // Store related metadata for this discussion. static::export_discussion_subscription_data($userid, $context, $discussion); $discussiondata = (object) [ 'name' => format_string($discussion->name, true), 'pinned' => transform::yesno((bool) $discussion->pinned), 'timemodified' => transform::datetime($discussion->timemodified), 'usermodified' => transform::datetime($discussion->usermodified), 'creator_was_you' => transform::yesno($discussion->userid == $userid), ]; // Store the discussion content. writer::with_context($context) ->export_data(static::get_discussion_area($discussion), $discussiondata); // Forum discussions do not have any files associately directly with them. } $discussions->close(); return $forumswithdata; }
[ "protected", "static", "function", "export_discussion_data", "(", "int", "$", "userid", ",", "array", "$", "mappings", ")", "{", "global", "$", "DB", ";", "// Find all of the discussions, and discussion subscriptions for this forum.", "list", "(", "$", "foruminsql", ",", "$", "forumparams", ")", "=", "$", "DB", "->", "get_in_or_equal", "(", "array_keys", "(", "$", "mappings", ")", ",", "SQL_PARAMS_NAMED", ")", ";", "$", "sql", "=", "\"SELECT\n d.*,\n g.name as groupname,\n dsub.preference\n FROM {forum} f\n JOIN {forum_discussions} d ON d.forum = f.id\n LEFT JOIN {groups} g ON g.id = d.groupid\n LEFT JOIN {forum_discussion_subs} dsub ON dsub.discussion = d.id AND dsub.userid = :dsubuserid\n LEFT JOIN {forum_posts} p ON p.discussion = d.id\n WHERE f.id ${foruminsql}\n AND (\n d.userid = :discussionuserid OR\n p.userid = :postuserid OR\n dsub.id IS NOT NULL\n )\n \"", ";", "$", "params", "=", "[", "'postuserid'", "=>", "$", "userid", ",", "'discussionuserid'", "=>", "$", "userid", ",", "'dsubuserid'", "=>", "$", "userid", ",", "]", ";", "$", "params", "+=", "$", "forumparams", ";", "// Keep track of the forums which have data.", "$", "forumswithdata", "=", "[", "]", ";", "$", "discussions", "=", "$", "DB", "->", "get_recordset_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "foreach", "(", "$", "discussions", "as", "$", "discussion", ")", "{", "// No need to take timestart into account as the user has some involvement already.", "// Ignore discussion timeend as it should not block access to user data.", "$", "forumswithdata", "[", "$", "discussion", "->", "forum", "]", "=", "true", ";", "$", "context", "=", "\\", "context", "::", "instance_by_id", "(", "$", "mappings", "[", "$", "discussion", "->", "forum", "]", ")", ";", "// Store related metadata for this discussion.", "static", "::", "export_discussion_subscription_data", "(", "$", "userid", ",", "$", "context", ",", "$", "discussion", ")", ";", "$", "discussiondata", "=", "(", "object", ")", "[", "'name'", "=>", "format_string", "(", "$", "discussion", "->", "name", ",", "true", ")", ",", "'pinned'", "=>", "transform", "::", "yesno", "(", "(", "bool", ")", "$", "discussion", "->", "pinned", ")", ",", "'timemodified'", "=>", "transform", "::", "datetime", "(", "$", "discussion", "->", "timemodified", ")", ",", "'usermodified'", "=>", "transform", "::", "datetime", "(", "$", "discussion", "->", "usermodified", ")", ",", "'creator_was_you'", "=>", "transform", "::", "yesno", "(", "$", "discussion", "->", "userid", "==", "$", "userid", ")", ",", "]", ";", "// Store the discussion content.", "writer", "::", "with_context", "(", "$", "context", ")", "->", "export_data", "(", "static", "::", "get_discussion_area", "(", "$", "discussion", ")", ",", "$", "discussiondata", ")", ";", "// Forum discussions do not have any files associately directly with them.", "}", "$", "discussions", "->", "close", "(", ")", ";", "return", "$", "forumswithdata", ";", "}" ]
Store all information about all discussions that we have detected this user to have access to. @param int $userid The userid of the user whose data is to be exported. @param array $mappings A list of mappings from forumid => contextid. @return array Which forums had data written for them.
[ "Store", "all", "information", "about", "all", "discussions", "that", "we", "have", "detected", "this", "user", "to", "have", "access", "to", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/privacy/provider.php#L572-L632
216,426
moodle/moodle
mod/forum/classes/privacy/provider.php
provider.export_posts_in_structure
protected static function export_posts_in_structure(int $userid, \context $context, $parentarea, \stdClass $structure) { foreach ($structure->children as $post) { if (!$post->hasdata) { // This tree has no content belonging to the user. Skip it and all children. continue; } $postarea = array_merge($parentarea, static::get_post_area($post)); // Store the post content. static::export_post_data($userid, $context, $postarea, $post); if (isset($post->children)) { // Now export children of this post. static::export_posts_in_structure($userid, $context, $postarea, $post); } } }
php
protected static function export_posts_in_structure(int $userid, \context $context, $parentarea, \stdClass $structure) { foreach ($structure->children as $post) { if (!$post->hasdata) { // This tree has no content belonging to the user. Skip it and all children. continue; } $postarea = array_merge($parentarea, static::get_post_area($post)); // Store the post content. static::export_post_data($userid, $context, $postarea, $post); if (isset($post->children)) { // Now export children of this post. static::export_posts_in_structure($userid, $context, $postarea, $post); } } }
[ "protected", "static", "function", "export_posts_in_structure", "(", "int", "$", "userid", ",", "\\", "context", "$", "context", ",", "$", "parentarea", ",", "\\", "stdClass", "$", "structure", ")", "{", "foreach", "(", "$", "structure", "->", "children", "as", "$", "post", ")", "{", "if", "(", "!", "$", "post", "->", "hasdata", ")", "{", "// This tree has no content belonging to the user. Skip it and all children.", "continue", ";", "}", "$", "postarea", "=", "array_merge", "(", "$", "parentarea", ",", "static", "::", "get_post_area", "(", "$", "post", ")", ")", ";", "// Store the post content.", "static", "::", "export_post_data", "(", "$", "userid", ",", "$", "context", ",", "$", "postarea", ",", "$", "post", ")", ";", "if", "(", "isset", "(", "$", "post", "->", "children", ")", ")", "{", "// Now export children of this post.", "static", "::", "export_posts_in_structure", "(", "$", "userid", ",", "$", "context", ",", "$", "postarea", ",", "$", "post", ")", ";", "}", "}", "}" ]
Export all posts in the provided structure. @param int $userid The userid of the user whose data is to be exported. @param \context $context The instance of the forum context. @param array $parentarea The subcontext of the parent. @param \stdClass $structure The post structure and all of its children
[ "Export", "all", "posts", "in", "the", "provided", "structure", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/privacy/provider.php#L768-L785
216,427
moodle/moodle
mod/forum/classes/privacy/provider.php
provider.export_post_data
protected static function export_post_data(int $userid, \context $context, $postarea, $post) { // Store related metadata. static::export_read_data($userid, $context, $postarea, $post); $postdata = (object) [ 'subject' => format_string($post->subject, true), 'created' => transform::datetime($post->created), 'modified' => transform::datetime($post->modified), 'author_was_you' => transform::yesno($post->userid == $userid), ]; if (!empty($post->privatereplyto)) { $postdata->privatereply = transform::yesno(true); } $postdata->message = writer::with_context($context) ->rewrite_pluginfile_urls($postarea, 'mod_forum', 'post', $post->id, $post->message); $postdata->message = format_text($postdata->message, $post->messageformat, (object) [ 'para' => false, 'trusted' => $post->messagetrust, 'context' => $context, ]); writer::with_context($context) // Store the post. ->export_data($postarea, $postdata) // Store the associated files. ->export_area_files($postarea, 'mod_forum', 'post', $post->id); if ($post->userid == $userid) { // Store all ratings against this post as the post belongs to the user. All ratings on it are ratings of their content. \core_rating\privacy\provider::export_area_ratings($userid, $context, $postarea, 'mod_forum', 'post', $post->id, false); // Store all tags against this post as the tag belongs to the user. \core_tag\privacy\provider::export_item_tags($userid, $context, $postarea, 'mod_forum', 'forum_posts', $post->id); // Export all user data stored for this post from the plagiarism API. $coursecontext = $context->get_course_context(); \core_plagiarism\privacy\provider::export_plagiarism_user_data($userid, $context, $postarea, [ 'cmid' => $context->instanceid, 'course' => $coursecontext->instanceid, 'forum' => $post->forumid, 'discussionid' => $post->discussion, 'postid' => $post->id, ]); } // Check for any ratings that the user has made on this post. \core_rating\privacy\provider::export_area_ratings($userid, $context, $postarea, 'mod_forum', 'post', $post->id, $userid, true ); }
php
protected static function export_post_data(int $userid, \context $context, $postarea, $post) { // Store related metadata. static::export_read_data($userid, $context, $postarea, $post); $postdata = (object) [ 'subject' => format_string($post->subject, true), 'created' => transform::datetime($post->created), 'modified' => transform::datetime($post->modified), 'author_was_you' => transform::yesno($post->userid == $userid), ]; if (!empty($post->privatereplyto)) { $postdata->privatereply = transform::yesno(true); } $postdata->message = writer::with_context($context) ->rewrite_pluginfile_urls($postarea, 'mod_forum', 'post', $post->id, $post->message); $postdata->message = format_text($postdata->message, $post->messageformat, (object) [ 'para' => false, 'trusted' => $post->messagetrust, 'context' => $context, ]); writer::with_context($context) // Store the post. ->export_data($postarea, $postdata) // Store the associated files. ->export_area_files($postarea, 'mod_forum', 'post', $post->id); if ($post->userid == $userid) { // Store all ratings against this post as the post belongs to the user. All ratings on it are ratings of their content. \core_rating\privacy\provider::export_area_ratings($userid, $context, $postarea, 'mod_forum', 'post', $post->id, false); // Store all tags against this post as the tag belongs to the user. \core_tag\privacy\provider::export_item_tags($userid, $context, $postarea, 'mod_forum', 'forum_posts', $post->id); // Export all user data stored for this post from the plagiarism API. $coursecontext = $context->get_course_context(); \core_plagiarism\privacy\provider::export_plagiarism_user_data($userid, $context, $postarea, [ 'cmid' => $context->instanceid, 'course' => $coursecontext->instanceid, 'forum' => $post->forumid, 'discussionid' => $post->discussion, 'postid' => $post->id, ]); } // Check for any ratings that the user has made on this post. \core_rating\privacy\provider::export_area_ratings($userid, $context, $postarea, 'mod_forum', 'post', $post->id, $userid, true ); }
[ "protected", "static", "function", "export_post_data", "(", "int", "$", "userid", ",", "\\", "context", "$", "context", ",", "$", "postarea", ",", "$", "post", ")", "{", "// Store related metadata.", "static", "::", "export_read_data", "(", "$", "userid", ",", "$", "context", ",", "$", "postarea", ",", "$", "post", ")", ";", "$", "postdata", "=", "(", "object", ")", "[", "'subject'", "=>", "format_string", "(", "$", "post", "->", "subject", ",", "true", ")", ",", "'created'", "=>", "transform", "::", "datetime", "(", "$", "post", "->", "created", ")", ",", "'modified'", "=>", "transform", "::", "datetime", "(", "$", "post", "->", "modified", ")", ",", "'author_was_you'", "=>", "transform", "::", "yesno", "(", "$", "post", "->", "userid", "==", "$", "userid", ")", ",", "]", ";", "if", "(", "!", "empty", "(", "$", "post", "->", "privatereplyto", ")", ")", "{", "$", "postdata", "->", "privatereply", "=", "transform", "::", "yesno", "(", "true", ")", ";", "}", "$", "postdata", "->", "message", "=", "writer", "::", "with_context", "(", "$", "context", ")", "->", "rewrite_pluginfile_urls", "(", "$", "postarea", ",", "'mod_forum'", ",", "'post'", ",", "$", "post", "->", "id", ",", "$", "post", "->", "message", ")", ";", "$", "postdata", "->", "message", "=", "format_text", "(", "$", "postdata", "->", "message", ",", "$", "post", "->", "messageformat", ",", "(", "object", ")", "[", "'para'", "=>", "false", ",", "'trusted'", "=>", "$", "post", "->", "messagetrust", ",", "'context'", "=>", "$", "context", ",", "]", ")", ";", "writer", "::", "with_context", "(", "$", "context", ")", "// Store the post.", "->", "export_data", "(", "$", "postarea", ",", "$", "postdata", ")", "// Store the associated files.", "->", "export_area_files", "(", "$", "postarea", ",", "'mod_forum'", ",", "'post'", ",", "$", "post", "->", "id", ")", ";", "if", "(", "$", "post", "->", "userid", "==", "$", "userid", ")", "{", "// Store all ratings against this post as the post belongs to the user. All ratings on it are ratings of their content.", "\\", "core_rating", "\\", "privacy", "\\", "provider", "::", "export_area_ratings", "(", "$", "userid", ",", "$", "context", ",", "$", "postarea", ",", "'mod_forum'", ",", "'post'", ",", "$", "post", "->", "id", ",", "false", ")", ";", "// Store all tags against this post as the tag belongs to the user.", "\\", "core_tag", "\\", "privacy", "\\", "provider", "::", "export_item_tags", "(", "$", "userid", ",", "$", "context", ",", "$", "postarea", ",", "'mod_forum'", ",", "'forum_posts'", ",", "$", "post", "->", "id", ")", ";", "// Export all user data stored for this post from the plagiarism API.", "$", "coursecontext", "=", "$", "context", "->", "get_course_context", "(", ")", ";", "\\", "core_plagiarism", "\\", "privacy", "\\", "provider", "::", "export_plagiarism_user_data", "(", "$", "userid", ",", "$", "context", ",", "$", "postarea", ",", "[", "'cmid'", "=>", "$", "context", "->", "instanceid", ",", "'course'", "=>", "$", "coursecontext", "->", "instanceid", ",", "'forum'", "=>", "$", "post", "->", "forumid", ",", "'discussionid'", "=>", "$", "post", "->", "discussion", ",", "'postid'", "=>", "$", "post", "->", "id", ",", "]", ")", ";", "}", "// Check for any ratings that the user has made on this post.", "\\", "core_rating", "\\", "privacy", "\\", "provider", "::", "export_area_ratings", "(", "$", "userid", ",", "$", "context", ",", "$", "postarea", ",", "'mod_forum'", ",", "'post'", ",", "$", "post", "->", "id", ",", "$", "userid", ",", "true", ")", ";", "}" ]
Export all data in the post. @param int $userid The userid of the user whose data is to be exported. @param \context $context The instance of the forum context. @param array $postarea The subcontext of the parent. @param \stdClass $post The post structure and all of its children
[ "Export", "all", "data", "in", "the", "post", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/privacy/provider.php#L795-L854
216,428
moodle/moodle
mod/forum/classes/privacy/provider.php
provider.export_digest_data
protected static function export_digest_data(int $userid, \stdClass $forum, int $maildigest) { if (null !== $maildigest) { // The user has a specific maildigest preference for this forum. $a = (object) [ 'forum' => format_string($forum->name, true), ]; switch ($maildigest) { case 0: $a->type = get_string('emaildigestoffshort', 'mod_forum'); break; case 1: $a->type = get_string('emaildigestcompleteshort', 'mod_forum'); break; case 2: $a->type = get_string('emaildigestsubjectsshort', 'mod_forum'); break; } writer::with_context(\context_module::instance($forum->cmid)) ->export_metadata([], 'digestpreference', $maildigest, get_string('privacy:digesttypepreference', 'mod_forum', $a)); return true; } return false; }
php
protected static function export_digest_data(int $userid, \stdClass $forum, int $maildigest) { if (null !== $maildigest) { // The user has a specific maildigest preference for this forum. $a = (object) [ 'forum' => format_string($forum->name, true), ]; switch ($maildigest) { case 0: $a->type = get_string('emaildigestoffshort', 'mod_forum'); break; case 1: $a->type = get_string('emaildigestcompleteshort', 'mod_forum'); break; case 2: $a->type = get_string('emaildigestsubjectsshort', 'mod_forum'); break; } writer::with_context(\context_module::instance($forum->cmid)) ->export_metadata([], 'digestpreference', $maildigest, get_string('privacy:digesttypepreference', 'mod_forum', $a)); return true; } return false; }
[ "protected", "static", "function", "export_digest_data", "(", "int", "$", "userid", ",", "\\", "stdClass", "$", "forum", ",", "int", "$", "maildigest", ")", "{", "if", "(", "null", "!==", "$", "maildigest", ")", "{", "// The user has a specific maildigest preference for this forum.", "$", "a", "=", "(", "object", ")", "[", "'forum'", "=>", "format_string", "(", "$", "forum", "->", "name", ",", "true", ")", ",", "]", ";", "switch", "(", "$", "maildigest", ")", "{", "case", "0", ":", "$", "a", "->", "type", "=", "get_string", "(", "'emaildigestoffshort'", ",", "'mod_forum'", ")", ";", "break", ";", "case", "1", ":", "$", "a", "->", "type", "=", "get_string", "(", "'emaildigestcompleteshort'", ",", "'mod_forum'", ")", ";", "break", ";", "case", "2", ":", "$", "a", "->", "type", "=", "get_string", "(", "'emaildigestsubjectsshort'", ",", "'mod_forum'", ")", ";", "break", ";", "}", "writer", "::", "with_context", "(", "\\", "context_module", "::", "instance", "(", "$", "forum", "->", "cmid", ")", ")", "->", "export_metadata", "(", "[", "]", ",", "'digestpreference'", ",", "$", "maildigest", ",", "get_string", "(", "'privacy:digesttypepreference'", ",", "'mod_forum'", ",", "$", "a", ")", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Store data about daily digest preferences @param int $userid The userid of the user whose data is to be exported. @param \stdClass $forum The forum whose data is being exported. @param int $maildigest The mail digest setting for this forum. @return bool Whether any data was stored.
[ "Store", "data", "about", "daily", "digest", "preferences" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/privacy/provider.php#L864-L891
216,429
moodle/moodle
mod/forum/classes/privacy/provider.php
provider.export_subscription_data
protected static function export_subscription_data(int $userid, \stdClass $forum, int $subscribed) { if (null !== $subscribed) { // The user is subscribed to this forum. writer::with_context(\context_module::instance($forum->cmid)) ->export_metadata([], 'subscriptionpreference', 1, get_string('privacy:subscribedtoforum', 'mod_forum')); return true; } return false; }
php
protected static function export_subscription_data(int $userid, \stdClass $forum, int $subscribed) { if (null !== $subscribed) { // The user is subscribed to this forum. writer::with_context(\context_module::instance($forum->cmid)) ->export_metadata([], 'subscriptionpreference', 1, get_string('privacy:subscribedtoforum', 'mod_forum')); return true; } return false; }
[ "protected", "static", "function", "export_subscription_data", "(", "int", "$", "userid", ",", "\\", "stdClass", "$", "forum", ",", "int", "$", "subscribed", ")", "{", "if", "(", "null", "!==", "$", "subscribed", ")", "{", "// The user is subscribed to this forum.", "writer", "::", "with_context", "(", "\\", "context_module", "::", "instance", "(", "$", "forum", "->", "cmid", ")", ")", "->", "export_metadata", "(", "[", "]", ",", "'subscriptionpreference'", ",", "1", ",", "get_string", "(", "'privacy:subscribedtoforum'", ",", "'mod_forum'", ")", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Store data about whether the user subscribes to forum. @param int $userid The userid of the user whose data is to be exported. @param \stdClass $forum The forum whose data is being exported. @param int $subscribed if the user is subscribed @return bool Whether any data was stored.
[ "Store", "data", "about", "whether", "the", "user", "subscribes", "to", "forum", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/privacy/provider.php#L901-L911
216,430
moodle/moodle
mod/forum/classes/privacy/provider.php
provider.export_discussion_subscription_data
protected static function export_discussion_subscription_data(int $userid, \context_module $context, \stdClass $discussion) { $area = static::get_discussion_area($discussion); if (null !== $discussion->preference) { // The user has a specific subscription preference for this discussion. $a = (object) []; switch ($discussion->preference) { case \mod_forum\subscriptions::FORUM_DISCUSSION_UNSUBSCRIBED: $a->preference = get_string('unsubscribed', 'mod_forum'); break; default: $a->preference = get_string('subscribed', 'mod_forum'); break; } writer::with_context($context) ->export_metadata( $area, 'subscriptionpreference', $discussion->preference, get_string('privacy:discussionsubscriptionpreference', 'mod_forum', $a) ); return true; } return true; }
php
protected static function export_discussion_subscription_data(int $userid, \context_module $context, \stdClass $discussion) { $area = static::get_discussion_area($discussion); if (null !== $discussion->preference) { // The user has a specific subscription preference for this discussion. $a = (object) []; switch ($discussion->preference) { case \mod_forum\subscriptions::FORUM_DISCUSSION_UNSUBSCRIBED: $a->preference = get_string('unsubscribed', 'mod_forum'); break; default: $a->preference = get_string('subscribed', 'mod_forum'); break; } writer::with_context($context) ->export_metadata( $area, 'subscriptionpreference', $discussion->preference, get_string('privacy:discussionsubscriptionpreference', 'mod_forum', $a) ); return true; } return true; }
[ "protected", "static", "function", "export_discussion_subscription_data", "(", "int", "$", "userid", ",", "\\", "context_module", "$", "context", ",", "\\", "stdClass", "$", "discussion", ")", "{", "$", "area", "=", "static", "::", "get_discussion_area", "(", "$", "discussion", ")", ";", "if", "(", "null", "!==", "$", "discussion", "->", "preference", ")", "{", "// The user has a specific subscription preference for this discussion.", "$", "a", "=", "(", "object", ")", "[", "]", ";", "switch", "(", "$", "discussion", "->", "preference", ")", "{", "case", "\\", "mod_forum", "\\", "subscriptions", "::", "FORUM_DISCUSSION_UNSUBSCRIBED", ":", "$", "a", "->", "preference", "=", "get_string", "(", "'unsubscribed'", ",", "'mod_forum'", ")", ";", "break", ";", "default", ":", "$", "a", "->", "preference", "=", "get_string", "(", "'subscribed'", ",", "'mod_forum'", ")", ";", "break", ";", "}", "writer", "::", "with_context", "(", "$", "context", ")", "->", "export_metadata", "(", "$", "area", ",", "'subscriptionpreference'", ",", "$", "discussion", "->", "preference", ",", "get_string", "(", "'privacy:discussionsubscriptionpreference'", ",", "'mod_forum'", ",", "$", "a", ")", ")", ";", "return", "true", ";", "}", "return", "true", ";", "}" ]
Store data about whether the user subscribes to this particular discussion. @param int $userid The userid of the user whose data is to be exported. @param \context_module $context The instance of the forum context. @param \stdClass $discussion The discussion whose data is being exported. @return bool Whether any data was stored.
[ "Store", "data", "about", "whether", "the", "user", "subscribes", "to", "this", "particular", "discussion", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/privacy/provider.php#L921-L948
216,431
moodle/moodle
mod/forum/classes/privacy/provider.php
provider.export_tracking_data
protected static function export_tracking_data(int $userid, \stdClass $forum, int $tracked) { if (null !== $tracked) { // The user has a main preference to track all forums, but has opted out of this one. writer::with_context(\context_module::instance($forum->cmid)) ->export_metadata([], 'trackreadpreference', 0, get_string('privacy:readtrackingdisabled', 'mod_forum')); return true; } return false; }
php
protected static function export_tracking_data(int $userid, \stdClass $forum, int $tracked) { if (null !== $tracked) { // The user has a main preference to track all forums, but has opted out of this one. writer::with_context(\context_module::instance($forum->cmid)) ->export_metadata([], 'trackreadpreference', 0, get_string('privacy:readtrackingdisabled', 'mod_forum')); return true; } return false; }
[ "protected", "static", "function", "export_tracking_data", "(", "int", "$", "userid", ",", "\\", "stdClass", "$", "forum", ",", "int", "$", "tracked", ")", "{", "if", "(", "null", "!==", "$", "tracked", ")", "{", "// The user has a main preference to track all forums, but has opted out of this one.", "writer", "::", "with_context", "(", "\\", "context_module", "::", "instance", "(", "$", "forum", "->", "cmid", ")", ")", "->", "export_metadata", "(", "[", "]", ",", "'trackreadpreference'", ",", "0", ",", "get_string", "(", "'privacy:readtrackingdisabled'", ",", "'mod_forum'", ")", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Store forum read-tracking data about a particular forum. This is whether a forum has read-tracking enabled or not. @param int $userid The userid of the user whose data is to be exported. @param \stdClass $forum The forum whose data is being exported. @param int $tracke if the user is subscribed @return bool Whether any data was stored.
[ "Store", "forum", "read", "-", "tracking", "data", "about", "a", "particular", "forum", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/privacy/provider.php#L960-L970
216,432
moodle/moodle
mod/forum/classes/privacy/provider.php
provider.export_read_data
protected static function export_read_data(int $userid, \context_module $context, array $postarea, \stdClass $post) { if (null !== $post->firstread) { $a = (object) [ 'firstread' => $post->firstread, 'lastread' => $post->lastread, ]; writer::with_context($context) ->export_metadata( $postarea, 'postread', (object) [ 'firstread' => $post->firstread, 'lastread' => $post->lastread, ], get_string('privacy:postwasread', 'mod_forum', $a) ); return true; } return false; }
php
protected static function export_read_data(int $userid, \context_module $context, array $postarea, \stdClass $post) { if (null !== $post->firstread) { $a = (object) [ 'firstread' => $post->firstread, 'lastread' => $post->lastread, ]; writer::with_context($context) ->export_metadata( $postarea, 'postread', (object) [ 'firstread' => $post->firstread, 'lastread' => $post->lastread, ], get_string('privacy:postwasread', 'mod_forum', $a) ); return true; } return false; }
[ "protected", "static", "function", "export_read_data", "(", "int", "$", "userid", ",", "\\", "context_module", "$", "context", ",", "array", "$", "postarea", ",", "\\", "stdClass", "$", "post", ")", "{", "if", "(", "null", "!==", "$", "post", "->", "firstread", ")", "{", "$", "a", "=", "(", "object", ")", "[", "'firstread'", "=>", "$", "post", "->", "firstread", ",", "'lastread'", "=>", "$", "post", "->", "lastread", ",", "]", ";", "writer", "::", "with_context", "(", "$", "context", ")", "->", "export_metadata", "(", "$", "postarea", ",", "'postread'", ",", "(", "object", ")", "[", "'firstread'", "=>", "$", "post", "->", "firstread", ",", "'lastread'", "=>", "$", "post", "->", "lastread", ",", "]", ",", "get_string", "(", "'privacy:postwasread'", ",", "'mod_forum'", ",", "$", "a", ")", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Store read-tracking information about a particular forum post. @param int $userid The userid of the user whose data is to be exported. @param \context_module $context The instance of the forum context. @param array $postarea The subcontext for this post. @param \stdClass $post The post whose data is being exported. @return bool Whether any data was stored.
[ "Store", "read", "-", "tracking", "information", "about", "a", "particular", "forum", "post", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/privacy/provider.php#L981-L1003
216,433
moodle/moodle
grade/report/history/classes/output/tablelog.php
tablelog.define_table_columns
protected function define_table_columns() { $extrafields = get_extra_user_fields($this->context); // Define headers and columns. $cols = array( 'timemodified' => get_string('datetime', 'gradereport_history'), 'fullname' => get_string('name') ); // Add headers for extra user fields. foreach ($extrafields as $field) { if (get_string_manager()->string_exists($field, 'moodle')) { $cols[$field] = get_string($field); } else { $cols[$field] = $field; } } // Add remaining headers. $cols = array_merge($cols, array( 'itemname' => get_string('gradeitem', 'grades'), 'prevgrade' => get_string('gradeold', 'gradereport_history'), 'finalgrade' => get_string('gradenew', 'gradereport_history'), 'grader' => get_string('grader', 'gradereport_history'), 'source' => get_string('source', 'gradereport_history'), 'overridden' => get_string('overridden', 'grades'), 'locked' => get_string('locked', 'grades'), 'excluded' => get_string('excluded', 'gradereport_history'), 'feedback' => get_string('feedbacktext', 'gradereport_history') ) ); $this->define_columns(array_keys($cols)); $this->define_headers(array_values($cols)); }
php
protected function define_table_columns() { $extrafields = get_extra_user_fields($this->context); // Define headers and columns. $cols = array( 'timemodified' => get_string('datetime', 'gradereport_history'), 'fullname' => get_string('name') ); // Add headers for extra user fields. foreach ($extrafields as $field) { if (get_string_manager()->string_exists($field, 'moodle')) { $cols[$field] = get_string($field); } else { $cols[$field] = $field; } } // Add remaining headers. $cols = array_merge($cols, array( 'itemname' => get_string('gradeitem', 'grades'), 'prevgrade' => get_string('gradeold', 'gradereport_history'), 'finalgrade' => get_string('gradenew', 'gradereport_history'), 'grader' => get_string('grader', 'gradereport_history'), 'source' => get_string('source', 'gradereport_history'), 'overridden' => get_string('overridden', 'grades'), 'locked' => get_string('locked', 'grades'), 'excluded' => get_string('excluded', 'gradereport_history'), 'feedback' => get_string('feedbacktext', 'gradereport_history') ) ); $this->define_columns(array_keys($cols)); $this->define_headers(array_values($cols)); }
[ "protected", "function", "define_table_columns", "(", ")", "{", "$", "extrafields", "=", "get_extra_user_fields", "(", "$", "this", "->", "context", ")", ";", "// Define headers and columns.", "$", "cols", "=", "array", "(", "'timemodified'", "=>", "get_string", "(", "'datetime'", ",", "'gradereport_history'", ")", ",", "'fullname'", "=>", "get_string", "(", "'name'", ")", ")", ";", "// Add headers for extra user fields.", "foreach", "(", "$", "extrafields", "as", "$", "field", ")", "{", "if", "(", "get_string_manager", "(", ")", "->", "string_exists", "(", "$", "field", ",", "'moodle'", ")", ")", "{", "$", "cols", "[", "$", "field", "]", "=", "get_string", "(", "$", "field", ")", ";", "}", "else", "{", "$", "cols", "[", "$", "field", "]", "=", "$", "field", ";", "}", "}", "// Add remaining headers.", "$", "cols", "=", "array_merge", "(", "$", "cols", ",", "array", "(", "'itemname'", "=>", "get_string", "(", "'gradeitem'", ",", "'grades'", ")", ",", "'prevgrade'", "=>", "get_string", "(", "'gradeold'", ",", "'gradereport_history'", ")", ",", "'finalgrade'", "=>", "get_string", "(", "'gradenew'", ",", "'gradereport_history'", ")", ",", "'grader'", "=>", "get_string", "(", "'grader'", ",", "'gradereport_history'", ")", ",", "'source'", "=>", "get_string", "(", "'source'", ",", "'gradereport_history'", ")", ",", "'overridden'", "=>", "get_string", "(", "'overridden'", ",", "'grades'", ")", ",", "'locked'", "=>", "get_string", "(", "'locked'", ",", "'grades'", ")", ",", "'excluded'", "=>", "get_string", "(", "'excluded'", ",", "'gradereport_history'", ")", ",", "'feedback'", "=>", "get_string", "(", "'feedbacktext'", ",", "'gradereport_history'", ")", ")", ")", ";", "$", "this", "->", "define_columns", "(", "array_keys", "(", "$", "cols", ")", ")", ";", "$", "this", "->", "define_headers", "(", "array_values", "(", "$", "cols", ")", ")", ";", "}" ]
Setup the headers for the html table.
[ "Setup", "the", "headers", "for", "the", "html", "table", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/report/history/classes/output/tablelog.php#L142-L176
216,434
moodle/moodle
grade/report/history/classes/output/tablelog.php
tablelog.col_finalgrade
public function col_finalgrade(\stdClass $history) { if (!empty($this->gradeitems[$history->itemid])) { $decimalpoints = $this->gradeitems[$history->itemid]->get_decimals(); } else { $decimalpoints = $this->defaultdecimalpoints; } return format_float($history->finalgrade, $decimalpoints); }
php
public function col_finalgrade(\stdClass $history) { if (!empty($this->gradeitems[$history->itemid])) { $decimalpoints = $this->gradeitems[$history->itemid]->get_decimals(); } else { $decimalpoints = $this->defaultdecimalpoints; } return format_float($history->finalgrade, $decimalpoints); }
[ "public", "function", "col_finalgrade", "(", "\\", "stdClass", "$", "history", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "gradeitems", "[", "$", "history", "->", "itemid", "]", ")", ")", "{", "$", "decimalpoints", "=", "$", "this", "->", "gradeitems", "[", "$", "history", "->", "itemid", "]", "->", "get_decimals", "(", ")", ";", "}", "else", "{", "$", "decimalpoints", "=", "$", "this", "->", "defaultdecimalpoints", ";", "}", "return", "format_float", "(", "$", "history", "->", "finalgrade", ",", "$", "decimalpoints", ")", ";", "}" ]
Method to display the final grade. @param \stdClass $history an entry of history record. @return string HTML to display
[ "Method", "to", "display", "the", "final", "grade", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/report/history/classes/output/tablelog.php#L185-L193
216,435
moodle/moodle
grade/report/history/classes/output/tablelog.php
tablelog.col_prevgrade
public function col_prevgrade(\stdClass $history) { if (!empty($this->gradeitems[$history->itemid])) { $decimalpoints = $this->gradeitems[$history->itemid]->get_decimals(); } else { $decimalpoints = $this->defaultdecimalpoints; } return format_float($history->prevgrade, $decimalpoints); }
php
public function col_prevgrade(\stdClass $history) { if (!empty($this->gradeitems[$history->itemid])) { $decimalpoints = $this->gradeitems[$history->itemid]->get_decimals(); } else { $decimalpoints = $this->defaultdecimalpoints; } return format_float($history->prevgrade, $decimalpoints); }
[ "public", "function", "col_prevgrade", "(", "\\", "stdClass", "$", "history", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "gradeitems", "[", "$", "history", "->", "itemid", "]", ")", ")", "{", "$", "decimalpoints", "=", "$", "this", "->", "gradeitems", "[", "$", "history", "->", "itemid", "]", "->", "get_decimals", "(", ")", ";", "}", "else", "{", "$", "decimalpoints", "=", "$", "this", "->", "defaultdecimalpoints", ";", "}", "return", "format_float", "(", "$", "history", "->", "prevgrade", ",", "$", "decimalpoints", ")", ";", "}" ]
Method to display the previous grade. @param \stdClass $history an entry of history record. @return string HTML to display
[ "Method", "to", "display", "the", "previous", "grade", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/report/history/classes/output/tablelog.php#L202-L210
216,436
moodle/moodle
grade/report/history/classes/output/tablelog.php
tablelog.col_itemname
public function col_itemname(\stdClass $history) { // Make sure grade item is still present and link it to the module if possible. $itemid = $history->itemid; if (!empty($this->gradeitems[$itemid])) { if ($history->itemtype === 'mod' && !$this->is_downloading()) { if (!empty($this->cms->instances[$history->itemmodule][$history->iteminstance])) { $cm = $this->cms->instances[$history->itemmodule][$history->iteminstance]; $url = new \moodle_url('/mod/' . $history->itemmodule . '/view.php', array('id' => $cm->id)); return \html_writer::link($url, $this->gradeitems[$itemid]->get_name()); } } return $this->gradeitems[$itemid]->get_name(); } return get_string('deleteditemid', 'gradereport_history', $history->itemid); }
php
public function col_itemname(\stdClass $history) { // Make sure grade item is still present and link it to the module if possible. $itemid = $history->itemid; if (!empty($this->gradeitems[$itemid])) { if ($history->itemtype === 'mod' && !$this->is_downloading()) { if (!empty($this->cms->instances[$history->itemmodule][$history->iteminstance])) { $cm = $this->cms->instances[$history->itemmodule][$history->iteminstance]; $url = new \moodle_url('/mod/' . $history->itemmodule . '/view.php', array('id' => $cm->id)); return \html_writer::link($url, $this->gradeitems[$itemid]->get_name()); } } return $this->gradeitems[$itemid]->get_name(); } return get_string('deleteditemid', 'gradereport_history', $history->itemid); }
[ "public", "function", "col_itemname", "(", "\\", "stdClass", "$", "history", ")", "{", "// Make sure grade item is still present and link it to the module if possible.", "$", "itemid", "=", "$", "history", "->", "itemid", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "gradeitems", "[", "$", "itemid", "]", ")", ")", "{", "if", "(", "$", "history", "->", "itemtype", "===", "'mod'", "&&", "!", "$", "this", "->", "is_downloading", "(", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "cms", "->", "instances", "[", "$", "history", "->", "itemmodule", "]", "[", "$", "history", "->", "iteminstance", "]", ")", ")", "{", "$", "cm", "=", "$", "this", "->", "cms", "->", "instances", "[", "$", "history", "->", "itemmodule", "]", "[", "$", "history", "->", "iteminstance", "]", ";", "$", "url", "=", "new", "\\", "moodle_url", "(", "'/mod/'", ".", "$", "history", "->", "itemmodule", ".", "'/view.php'", ",", "array", "(", "'id'", "=>", "$", "cm", "->", "id", ")", ")", ";", "return", "\\", "html_writer", "::", "link", "(", "$", "url", ",", "$", "this", "->", "gradeitems", "[", "$", "itemid", "]", "->", "get_name", "(", ")", ")", ";", "}", "}", "return", "$", "this", "->", "gradeitems", "[", "$", "itemid", "]", "->", "get_name", "(", ")", ";", "}", "return", "get_string", "(", "'deleteditemid'", ",", "'gradereport_history'", ",", "$", "history", "->", "itemid", ")", ";", "}" ]
Method to display column itemname. @param \stdClass $history an entry of history record. @return string HTML to display
[ "Method", "to", "display", "column", "itemname", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/report/history/classes/output/tablelog.php#L230-L244
216,437
moodle/moodle
grade/report/history/classes/output/tablelog.php
tablelog.col_grader
public function col_grader(\stdClass $history) { if (empty($history->usermodified)) { // Not every row has a valid usermodified. return ''; } $grader = new \stdClass(); $grader = username_load_fields_from_object($grader, $history, 'grader'); $name = fullname($grader); if ($this->download) { return $name; } $userid = $history->usermodified; $profileurl = new \moodle_url('/user/view.php', array('id' => $userid, 'course' => $this->courseid)); return \html_writer::link($profileurl, $name); }
php
public function col_grader(\stdClass $history) { if (empty($history->usermodified)) { // Not every row has a valid usermodified. return ''; } $grader = new \stdClass(); $grader = username_load_fields_from_object($grader, $history, 'grader'); $name = fullname($grader); if ($this->download) { return $name; } $userid = $history->usermodified; $profileurl = new \moodle_url('/user/view.php', array('id' => $userid, 'course' => $this->courseid)); return \html_writer::link($profileurl, $name); }
[ "public", "function", "col_grader", "(", "\\", "stdClass", "$", "history", ")", "{", "if", "(", "empty", "(", "$", "history", "->", "usermodified", ")", ")", "{", "// Not every row has a valid usermodified.", "return", "''", ";", "}", "$", "grader", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "grader", "=", "username_load_fields_from_object", "(", "$", "grader", ",", "$", "history", ",", "'grader'", ")", ";", "$", "name", "=", "fullname", "(", "$", "grader", ")", ";", "if", "(", "$", "this", "->", "download", ")", "{", "return", "$", "name", ";", "}", "$", "userid", "=", "$", "history", "->", "usermodified", ";", "$", "profileurl", "=", "new", "\\", "moodle_url", "(", "'/user/view.php'", ",", "array", "(", "'id'", "=>", "$", "userid", ",", "'course'", "=>", "$", "this", "->", "courseid", ")", ")", ";", "return", "\\", "html_writer", "::", "link", "(", "$", "profileurl", ",", "$", "name", ")", ";", "}" ]
Method to display column grader. @param \stdClass $history an entry of history record. @return string HTML to display
[ "Method", "to", "display", "column", "grader", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/report/history/classes/output/tablelog.php#L253-L271
216,438
moodle/moodle
grade/report/history/classes/output/tablelog.php
tablelog.col_feedback
public function col_feedback(\stdClass $history) { if ($this->is_downloading()) { return $history->feedback; } else { // We need the activity context, not the course context. $gradeitem = $this->gradeitems[$history->itemid]; $context = $gradeitem->get_context(); $feedback = file_rewrite_pluginfile_urls( $history->feedback, 'pluginfile.php', $context->id, GRADE_FILE_COMPONENT, GRADE_HISTORY_FEEDBACK_FILEAREA, $history->id ); return format_text($feedback, $history->feedbackformat, array('context' => $context)); } }
php
public function col_feedback(\stdClass $history) { if ($this->is_downloading()) { return $history->feedback; } else { // We need the activity context, not the course context. $gradeitem = $this->gradeitems[$history->itemid]; $context = $gradeitem->get_context(); $feedback = file_rewrite_pluginfile_urls( $history->feedback, 'pluginfile.php', $context->id, GRADE_FILE_COMPONENT, GRADE_HISTORY_FEEDBACK_FILEAREA, $history->id ); return format_text($feedback, $history->feedbackformat, array('context' => $context)); } }
[ "public", "function", "col_feedback", "(", "\\", "stdClass", "$", "history", ")", "{", "if", "(", "$", "this", "->", "is_downloading", "(", ")", ")", "{", "return", "$", "history", "->", "feedback", ";", "}", "else", "{", "// We need the activity context, not the course context.", "$", "gradeitem", "=", "$", "this", "->", "gradeitems", "[", "$", "history", "->", "itemid", "]", ";", "$", "context", "=", "$", "gradeitem", "->", "get_context", "(", ")", ";", "$", "feedback", "=", "file_rewrite_pluginfile_urls", "(", "$", "history", "->", "feedback", ",", "'pluginfile.php'", ",", "$", "context", "->", "id", ",", "GRADE_FILE_COMPONENT", ",", "GRADE_HISTORY_FEEDBACK_FILEAREA", ",", "$", "history", "->", "id", ")", ";", "return", "format_text", "(", "$", "feedback", ",", "$", "history", "->", "feedbackformat", ",", "array", "(", "'context'", "=>", "$", "context", ")", ")", ";", "}", "}" ]
Method to display column feedback. @param \stdClass $history an entry of history record. @return string HTML to display
[ "Method", "to", "display", "column", "feedback", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/report/history/classes/output/tablelog.php#L313-L332
216,439
moodle/moodle
grade/report/history/classes/output/tablelog.php
tablelog.get_filters_sql_and_params
protected function get_filters_sql_and_params() { global $DB; $coursecontext = $this->context; $filter = 'gi.courseid = :courseid'; $params = array( 'courseid' => $coursecontext->instanceid, ); if (!empty($this->filters->itemid)) { $filter .= ' AND ggh.itemid = :itemid'; $params['itemid'] = $this->filters->itemid; } if (!empty($this->filters->userids)) { $list = explode(',', $this->filters->userids); list($insql, $plist) = $DB->get_in_or_equal($list, SQL_PARAMS_NAMED); $filter .= " AND ggh.userid $insql"; $params += $plist; } if (!empty($this->filters->datefrom)) { $filter .= " AND ggh.timemodified >= :datefrom"; $params += array('datefrom' => $this->filters->datefrom); } if (!empty($this->filters->datetill)) { $filter .= " AND ggh.timemodified <= :datetill"; $params += array('datetill' => $this->filters->datetill); } if (!empty($this->filters->grader)) { $filter .= " AND ggh.usermodified = :grader"; $params += array('grader' => $this->filters->grader); } return array($filter, $params); }
php
protected function get_filters_sql_and_params() { global $DB; $coursecontext = $this->context; $filter = 'gi.courseid = :courseid'; $params = array( 'courseid' => $coursecontext->instanceid, ); if (!empty($this->filters->itemid)) { $filter .= ' AND ggh.itemid = :itemid'; $params['itemid'] = $this->filters->itemid; } if (!empty($this->filters->userids)) { $list = explode(',', $this->filters->userids); list($insql, $plist) = $DB->get_in_or_equal($list, SQL_PARAMS_NAMED); $filter .= " AND ggh.userid $insql"; $params += $plist; } if (!empty($this->filters->datefrom)) { $filter .= " AND ggh.timemodified >= :datefrom"; $params += array('datefrom' => $this->filters->datefrom); } if (!empty($this->filters->datetill)) { $filter .= " AND ggh.timemodified <= :datetill"; $params += array('datetill' => $this->filters->datetill); } if (!empty($this->filters->grader)) { $filter .= " AND ggh.usermodified = :grader"; $params += array('grader' => $this->filters->grader); } return array($filter, $params); }
[ "protected", "function", "get_filters_sql_and_params", "(", ")", "{", "global", "$", "DB", ";", "$", "coursecontext", "=", "$", "this", "->", "context", ";", "$", "filter", "=", "'gi.courseid = :courseid'", ";", "$", "params", "=", "array", "(", "'courseid'", "=>", "$", "coursecontext", "->", "instanceid", ",", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "filters", "->", "itemid", ")", ")", "{", "$", "filter", ".=", "' AND ggh.itemid = :itemid'", ";", "$", "params", "[", "'itemid'", "]", "=", "$", "this", "->", "filters", "->", "itemid", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "filters", "->", "userids", ")", ")", "{", "$", "list", "=", "explode", "(", "','", ",", "$", "this", "->", "filters", "->", "userids", ")", ";", "list", "(", "$", "insql", ",", "$", "plist", ")", "=", "$", "DB", "->", "get_in_or_equal", "(", "$", "list", ",", "SQL_PARAMS_NAMED", ")", ";", "$", "filter", ".=", "\" AND ggh.userid $insql\"", ";", "$", "params", "+=", "$", "plist", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "filters", "->", "datefrom", ")", ")", "{", "$", "filter", ".=", "\" AND ggh.timemodified >= :datefrom\"", ";", "$", "params", "+=", "array", "(", "'datefrom'", "=>", "$", "this", "->", "filters", "->", "datefrom", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "filters", "->", "datetill", ")", ")", "{", "$", "filter", ".=", "\" AND ggh.timemodified <= :datetill\"", ";", "$", "params", "+=", "array", "(", "'datetill'", "=>", "$", "this", "->", "filters", "->", "datetill", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "filters", "->", "grader", ")", ")", "{", "$", "filter", ".=", "\" AND ggh.usermodified = :grader\"", ";", "$", "params", "+=", "array", "(", "'grader'", "=>", "$", "this", "->", "filters", "->", "grader", ")", ";", "}", "return", "array", "(", "$", "filter", ",", "$", "params", ")", ";", "}" ]
Builds the sql and param list needed, based on the user selected filters. @return array containing sql to use and an array of params.
[ "Builds", "the", "sql", "and", "param", "list", "needed", "based", "on", "the", "user", "selected", "filters", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/report/history/classes/output/tablelog.php#L339-L372
216,440
moodle/moodle
grade/report/history/classes/output/tablelog.php
tablelog.get_sql_and_params
protected function get_sql_and_params($count = false) { $fields = 'ggh.id, ggh.timemodified, ggh.itemid, ggh.userid, ggh.finalgrade, ggh.usermodified, ggh.source, ggh.overridden, ggh.locked, ggh.excluded, ggh.feedback, ggh.feedbackformat, gi.itemtype, gi.itemmodule, gi.iteminstance, gi.itemnumber, '; // Add extra user fields that we need for the graded user. $extrafields = get_extra_user_fields($this->context); foreach ($extrafields as $field) { $fields .= 'u.' . $field . ', '; } $gradeduserfields = get_all_user_name_fields(true, 'u'); $fields .= $gradeduserfields . ', '; $groupby = $fields; // Add extra user fields that we need for the grader user. $fields .= get_all_user_name_fields(true, 'ug', '', 'grader'); $groupby .= get_all_user_name_fields(true, 'ug'); // Filtering on revised grades only. $revisedonly = !empty($this->filters->revisedonly); if ($count && !$revisedonly) { // We can only directly use count when not using the filter revised only. $select = "COUNT(1)"; } else { // Fetching the previous grade. We use MAX() to ensure that we only get one result if // more than one histories happened at the same second. $prevgrade = "SELECT MAX(finalgrade) FROM {grade_grades_history} h WHERE h.itemid = ggh.itemid AND h.userid = ggh.userid AND h.timemodified < ggh.timemodified AND NOT EXISTS ( SELECT 1 FROM {grade_grades_history} h2 WHERE h2.itemid = ggh.itemid AND h2.userid = ggh.userid AND h2.timemodified < ggh.timemodified AND h.timemodified < h2.timemodified)"; $select = "$fields, ($prevgrade) AS prevgrade, CASE WHEN gi.itemname IS NULL THEN gi.itemtype ELSE gi.itemname END AS itemname"; } list($where, $params) = $this->get_filters_sql_and_params(); $sql = "SELECT $select FROM {grade_grades_history} ggh JOIN {grade_items} gi ON gi.id = ggh.itemid JOIN {user} u ON u.id = ggh.userid LEFT JOIN {user} ug ON ug.id = ggh.usermodified WHERE $where"; // As prevgrade is a dynamic field, we need to wrap the query. This is the only filtering // that should be defined outside the method self::get_filters_sql_and_params(). if ($revisedonly) { $allorcount = $count ? 'COUNT(1)' : '*'; $sql = "SELECT $allorcount FROM ($sql) pg WHERE pg.finalgrade != pg.prevgrade OR (pg.prevgrade IS NULL AND pg.finalgrade IS NOT NULL) OR (pg.prevgrade IS NOT NULL AND pg.finalgrade IS NULL)"; } // Add order by if needed. if (!$count && $sqlsort = $this->get_sql_sort()) { $sql .= " ORDER BY " . $sqlsort; } return array($sql, $params); }
php
protected function get_sql_and_params($count = false) { $fields = 'ggh.id, ggh.timemodified, ggh.itemid, ggh.userid, ggh.finalgrade, ggh.usermodified, ggh.source, ggh.overridden, ggh.locked, ggh.excluded, ggh.feedback, ggh.feedbackformat, gi.itemtype, gi.itemmodule, gi.iteminstance, gi.itemnumber, '; // Add extra user fields that we need for the graded user. $extrafields = get_extra_user_fields($this->context); foreach ($extrafields as $field) { $fields .= 'u.' . $field . ', '; } $gradeduserfields = get_all_user_name_fields(true, 'u'); $fields .= $gradeduserfields . ', '; $groupby = $fields; // Add extra user fields that we need for the grader user. $fields .= get_all_user_name_fields(true, 'ug', '', 'grader'); $groupby .= get_all_user_name_fields(true, 'ug'); // Filtering on revised grades only. $revisedonly = !empty($this->filters->revisedonly); if ($count && !$revisedonly) { // We can only directly use count when not using the filter revised only. $select = "COUNT(1)"; } else { // Fetching the previous grade. We use MAX() to ensure that we only get one result if // more than one histories happened at the same second. $prevgrade = "SELECT MAX(finalgrade) FROM {grade_grades_history} h WHERE h.itemid = ggh.itemid AND h.userid = ggh.userid AND h.timemodified < ggh.timemodified AND NOT EXISTS ( SELECT 1 FROM {grade_grades_history} h2 WHERE h2.itemid = ggh.itemid AND h2.userid = ggh.userid AND h2.timemodified < ggh.timemodified AND h.timemodified < h2.timemodified)"; $select = "$fields, ($prevgrade) AS prevgrade, CASE WHEN gi.itemname IS NULL THEN gi.itemtype ELSE gi.itemname END AS itemname"; } list($where, $params) = $this->get_filters_sql_and_params(); $sql = "SELECT $select FROM {grade_grades_history} ggh JOIN {grade_items} gi ON gi.id = ggh.itemid JOIN {user} u ON u.id = ggh.userid LEFT JOIN {user} ug ON ug.id = ggh.usermodified WHERE $where"; // As prevgrade is a dynamic field, we need to wrap the query. This is the only filtering // that should be defined outside the method self::get_filters_sql_and_params(). if ($revisedonly) { $allorcount = $count ? 'COUNT(1)' : '*'; $sql = "SELECT $allorcount FROM ($sql) pg WHERE pg.finalgrade != pg.prevgrade OR (pg.prevgrade IS NULL AND pg.finalgrade IS NOT NULL) OR (pg.prevgrade IS NOT NULL AND pg.finalgrade IS NULL)"; } // Add order by if needed. if (!$count && $sqlsort = $this->get_sql_sort()) { $sql .= " ORDER BY " . $sqlsort; } return array($sql, $params); }
[ "protected", "function", "get_sql_and_params", "(", "$", "count", "=", "false", ")", "{", "$", "fields", "=", "'ggh.id, ggh.timemodified, ggh.itemid, ggh.userid, ggh.finalgrade, ggh.usermodified,\n ggh.source, ggh.overridden, ggh.locked, ggh.excluded, ggh.feedback, ggh.feedbackformat,\n gi.itemtype, gi.itemmodule, gi.iteminstance, gi.itemnumber, '", ";", "// Add extra user fields that we need for the graded user.", "$", "extrafields", "=", "get_extra_user_fields", "(", "$", "this", "->", "context", ")", ";", "foreach", "(", "$", "extrafields", "as", "$", "field", ")", "{", "$", "fields", ".=", "'u.'", ".", "$", "field", ".", "', '", ";", "}", "$", "gradeduserfields", "=", "get_all_user_name_fields", "(", "true", ",", "'u'", ")", ";", "$", "fields", ".=", "$", "gradeduserfields", ".", "', '", ";", "$", "groupby", "=", "$", "fields", ";", "// Add extra user fields that we need for the grader user.", "$", "fields", ".=", "get_all_user_name_fields", "(", "true", ",", "'ug'", ",", "''", ",", "'grader'", ")", ";", "$", "groupby", ".=", "get_all_user_name_fields", "(", "true", ",", "'ug'", ")", ";", "// Filtering on revised grades only.", "$", "revisedonly", "=", "!", "empty", "(", "$", "this", "->", "filters", "->", "revisedonly", ")", ";", "if", "(", "$", "count", "&&", "!", "$", "revisedonly", ")", "{", "// We can only directly use count when not using the filter revised only.", "$", "select", "=", "\"COUNT(1)\"", ";", "}", "else", "{", "// Fetching the previous grade. We use MAX() to ensure that we only get one result if", "// more than one histories happened at the same second.", "$", "prevgrade", "=", "\"SELECT MAX(finalgrade)\n FROM {grade_grades_history} h\n WHERE h.itemid = ggh.itemid\n AND h.userid = ggh.userid\n AND h.timemodified < ggh.timemodified\n AND NOT EXISTS (\n SELECT 1\n FROM {grade_grades_history} h2\n WHERE h2.itemid = ggh.itemid\n AND h2.userid = ggh.userid\n AND h2.timemodified < ggh.timemodified\n AND h.timemodified < h2.timemodified)\"", ";", "$", "select", "=", "\"$fields, ($prevgrade) AS prevgrade,\n CASE WHEN gi.itemname IS NULL THEN gi.itemtype ELSE gi.itemname END AS itemname\"", ";", "}", "list", "(", "$", "where", ",", "$", "params", ")", "=", "$", "this", "->", "get_filters_sql_and_params", "(", ")", ";", "$", "sql", "=", "\"SELECT $select\n FROM {grade_grades_history} ggh\n JOIN {grade_items} gi ON gi.id = ggh.itemid\n JOIN {user} u ON u.id = ggh.userid\n LEFT JOIN {user} ug ON ug.id = ggh.usermodified\n WHERE $where\"", ";", "// As prevgrade is a dynamic field, we need to wrap the query. This is the only filtering", "// that should be defined outside the method self::get_filters_sql_and_params().", "if", "(", "$", "revisedonly", ")", "{", "$", "allorcount", "=", "$", "count", "?", "'COUNT(1)'", ":", "'*'", ";", "$", "sql", "=", "\"SELECT $allorcount FROM ($sql) pg\n WHERE pg.finalgrade != pg.prevgrade\n OR (pg.prevgrade IS NULL AND pg.finalgrade IS NOT NULL)\n OR (pg.prevgrade IS NOT NULL AND pg.finalgrade IS NULL)\"", ";", "}", "// Add order by if needed.", "if", "(", "!", "$", "count", "&&", "$", "sqlsort", "=", "$", "this", "->", "get_sql_sort", "(", ")", ")", "{", "$", "sql", ".=", "\" ORDER BY \"", ".", "$", "sqlsort", ";", "}", "return", "array", "(", "$", "sql", ",", "$", "params", ")", ";", "}" ]
Builds the complete sql with all the joins to get the grade history data. @param bool $count setting this to true, returns an sql to get count only instead of the complete data records. @return array containing sql to use and an array of params.
[ "Builds", "the", "complete", "sql", "with", "all", "the", "joins", "to", "get", "the", "grade", "history", "data", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/report/history/classes/output/tablelog.php#L381-L450
216,441
moodle/moodle
grade/report/history/classes/output/tablelog.php
tablelog.get_sql_sort
public function get_sql_sort() { $columns = $this->get_sort_columns(); if (count($columns) == 1 && isset($columns['timemodified']) && $columns['timemodified'] == SORT_DESC) { // Add the 'id' column when we are using the default sorting. $columns['id'] = SORT_DESC; return self::construct_order_by($columns); } return parent::get_sql_sort(); }
php
public function get_sql_sort() { $columns = $this->get_sort_columns(); if (count($columns) == 1 && isset($columns['timemodified']) && $columns['timemodified'] == SORT_DESC) { // Add the 'id' column when we are using the default sorting. $columns['id'] = SORT_DESC; return self::construct_order_by($columns); } return parent::get_sql_sort(); }
[ "public", "function", "get_sql_sort", "(", ")", "{", "$", "columns", "=", "$", "this", "->", "get_sort_columns", "(", ")", ";", "if", "(", "count", "(", "$", "columns", ")", "==", "1", "&&", "isset", "(", "$", "columns", "[", "'timemodified'", "]", ")", "&&", "$", "columns", "[", "'timemodified'", "]", "==", "SORT_DESC", ")", "{", "// Add the 'id' column when we are using the default sorting.", "$", "columns", "[", "'id'", "]", "=", "SORT_DESC", ";", "return", "self", "::", "construct_order_by", "(", "$", "columns", ")", ";", "}", "return", "parent", "::", "get_sql_sort", "(", ")", ";", "}" ]
Get the SQL fragment to sort by. This is overridden to sort by timemodified and ID by default. Many items happen at the same time and a second sorting by ID is valuable to distinguish the order in which the history happened. @return string SQL fragment.
[ "Get", "the", "SQL", "fragment", "to", "sort", "by", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/report/history/classes/output/tablelog.php#L460-L468
216,442
moodle/moodle
grade/report/history/classes/output/tablelog.php
tablelog.get_selected_users
public function get_selected_users() { global $DB; $idlist = array(); if (!empty($this->filters->userids)) { $idlist = explode(',', $this->filters->userids); list($where, $params) = $DB->get_in_or_equal($idlist); return $DB->get_records_select('user', "id $where", $params); } return $idlist; }
php
public function get_selected_users() { global $DB; $idlist = array(); if (!empty($this->filters->userids)) { $idlist = explode(',', $this->filters->userids); list($where, $params) = $DB->get_in_or_equal($idlist); return $DB->get_records_select('user', "id $where", $params); } return $idlist; }
[ "public", "function", "get_selected_users", "(", ")", "{", "global", "$", "DB", ";", "$", "idlist", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "filters", "->", "userids", ")", ")", "{", "$", "idlist", "=", "explode", "(", "','", ",", "$", "this", "->", "filters", "->", "userids", ")", ";", "list", "(", "$", "where", ",", "$", "params", ")", "=", "$", "DB", "->", "get_in_or_equal", "(", "$", "idlist", ")", ";", "return", "$", "DB", "->", "get_records_select", "(", "'user'", ",", "\"id $where\"", ",", "$", "params", ")", ";", "}", "return", "$", "idlist", ";", "}" ]
Returns a list of selected users. @return array returns an array in the format $userid => $userid
[ "Returns", "a", "list", "of", "selected", "users", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/report/history/classes/output/tablelog.php#L502-L513
216,443
moodle/moodle
lib/dml/oci_native_moodle_temptables.php
oci_native_moodle_temptables.add_temptable
public function add_temptable($tablename) { // TODO: throw exception if exists: if ($this->is_temptable... $this->temptables[$tablename] = $this->prefix . $this->unique_session_id . $this->counter; $this->counter++; }
php
public function add_temptable($tablename) { // TODO: throw exception if exists: if ($this->is_temptable... $this->temptables[$tablename] = $this->prefix . $this->unique_session_id . $this->counter; $this->counter++; }
[ "public", "function", "add_temptable", "(", "$", "tablename", ")", "{", "// TODO: throw exception if exists: if ($this->is_temptable...", "$", "this", "->", "temptables", "[", "$", "tablename", "]", "=", "$", "this", "->", "prefix", ".", "$", "this", "->", "unique_session_id", ".", "$", "this", "->", "counter", ";", "$", "this", "->", "counter", "++", ";", "}" ]
Add one temptable to the store. Overridden because OCI only support global temptables, so we need to change completely the name, based in unique session identifier, to get local-like temp tables support tables before the prefix. Given one moodle temptable name (without prefix), add it to the store, with the key being the original moodle name and the value being the real db temptable name already prefixed Override and use this *only* if the database requires modification in the table name. @param string $tablename name without prefix of the table created as temptable
[ "Add", "one", "temptable", "to", "the", "store", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/dml/oci_native_moodle_temptables.php#L65-L69
216,444
moodle/moodle
mod/forum/classes/local/data_mappers/legacy/discussion.php
discussion.to_legacy_objects
public function to_legacy_objects(array $discussions) : array { return array_map(function(discussion_entity $discussion) { return (object) [ 'id' => $discussion->get_id(), 'course' => $discussion->get_course_id(), 'forum' => $discussion->get_forum_id(), 'name' => $discussion->get_name(), 'firstpost' => $discussion->get_first_post_id(), 'userid' => $discussion->get_user_id(), 'groupid' => $discussion->get_group_id(), 'assessed' => $discussion->is_assessed(), 'timemodified' => $discussion->get_time_modified(), 'usermodified' => $discussion->get_user_modified(), 'timestart' => $discussion->get_time_start(), 'timeend' => $discussion->get_time_end(), 'pinned' => $discussion->is_pinned(), 'timelocked' => $discussion->get_locked() ]; }, $discussions); }
php
public function to_legacy_objects(array $discussions) : array { return array_map(function(discussion_entity $discussion) { return (object) [ 'id' => $discussion->get_id(), 'course' => $discussion->get_course_id(), 'forum' => $discussion->get_forum_id(), 'name' => $discussion->get_name(), 'firstpost' => $discussion->get_first_post_id(), 'userid' => $discussion->get_user_id(), 'groupid' => $discussion->get_group_id(), 'assessed' => $discussion->is_assessed(), 'timemodified' => $discussion->get_time_modified(), 'usermodified' => $discussion->get_user_modified(), 'timestart' => $discussion->get_time_start(), 'timeend' => $discussion->get_time_end(), 'pinned' => $discussion->is_pinned(), 'timelocked' => $discussion->get_locked() ]; }, $discussions); }
[ "public", "function", "to_legacy_objects", "(", "array", "$", "discussions", ")", ":", "array", "{", "return", "array_map", "(", "function", "(", "discussion_entity", "$", "discussion", ")", "{", "return", "(", "object", ")", "[", "'id'", "=>", "$", "discussion", "->", "get_id", "(", ")", ",", "'course'", "=>", "$", "discussion", "->", "get_course_id", "(", ")", ",", "'forum'", "=>", "$", "discussion", "->", "get_forum_id", "(", ")", ",", "'name'", "=>", "$", "discussion", "->", "get_name", "(", ")", ",", "'firstpost'", "=>", "$", "discussion", "->", "get_first_post_id", "(", ")", ",", "'userid'", "=>", "$", "discussion", "->", "get_user_id", "(", ")", ",", "'groupid'", "=>", "$", "discussion", "->", "get_group_id", "(", ")", ",", "'assessed'", "=>", "$", "discussion", "->", "is_assessed", "(", ")", ",", "'timemodified'", "=>", "$", "discussion", "->", "get_time_modified", "(", ")", ",", "'usermodified'", "=>", "$", "discussion", "->", "get_user_modified", "(", ")", ",", "'timestart'", "=>", "$", "discussion", "->", "get_time_start", "(", ")", ",", "'timeend'", "=>", "$", "discussion", "->", "get_time_end", "(", ")", ",", "'pinned'", "=>", "$", "discussion", "->", "is_pinned", "(", ")", ",", "'timelocked'", "=>", "$", "discussion", "->", "get_locked", "(", ")", "]", ";", "}", ",", "$", "discussions", ")", ";", "}" ]
Convert a list of discussion entities into stdClasses. @param discussion_entity[] $authors The authors to convert. @return stdClass[]
[ "Convert", "a", "list", "of", "discussion", "entities", "into", "stdClasses", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/forum/classes/local/data_mappers/legacy/discussion.php#L45-L64
216,445
moodle/moodle
my/lib.php
my_syspage_block_manager.load_blocks
public function load_blocks($includeinvisible = null) { $origcontext = $this->page->context; $this->page->context = context_system::instance(); parent::load_blocks($includeinvisible); $this->page->context = $origcontext; }
php
public function load_blocks($includeinvisible = null) { $origcontext = $this->page->context; $this->page->context = context_system::instance(); parent::load_blocks($includeinvisible); $this->page->context = $origcontext; }
[ "public", "function", "load_blocks", "(", "$", "includeinvisible", "=", "null", ")", "{", "$", "origcontext", "=", "$", "this", "->", "page", "->", "context", ";", "$", "this", "->", "page", "->", "context", "=", "context_system", "::", "instance", "(", ")", ";", "parent", "::", "load_blocks", "(", "$", "includeinvisible", ")", ";", "$", "this", "->", "page", "->", "context", "=", "$", "origcontext", ";", "}" ]
Load blocks using the system context, rather than the user's context. This is needed because the My Moodle pages set the page context to the user's context for access control, etc. But the blocks for the system pages are stored in the system context.
[ "Load", "blocks", "using", "the", "system", "context", "rather", "than", "the", "user", "s", "context", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/my/lib.php#L226-L231
216,446
moodle/moodle
lib/componentlib.class.php
component_installer.check_requisites
function check_requisites() { global $CFG; $this->requisitesok = false; /// Check that everything we need is present if (empty($this->sourcebase) || empty($this->zipfilename)) { $this->errorstring='missingrequiredfield'; return false; } /// Check for correct sourcebase (this will be out in the future) if (!PHPUNIT_TEST and $this->sourcebase != 'https://download.moodle.org') { $this->errorstring='wrongsourcebase'; return false; } /// Check the zip file is a correct one (by extension) if (stripos($this->zipfilename, '.zip') === false) { $this->errorstring='wrongzipfilename'; return false; } /// Check that exists under dataroot if (!empty($this->destpath)) { if (!file_exists($CFG->dataroot.'/'.$this->destpath)) { $this->errorstring='wrongdestpath'; return false; } } /// Calculate the componentname $pos = stripos($this->zipfilename, '.zip'); $this->componentname = substr($this->zipfilename, 0, $pos); /// Calculate md5filename if it's empty if (empty($this->md5filename)) { $this->md5filename = $this->componentname.'.md5'; } /// Set the requisites passed flag $this->requisitesok = true; return true; }
php
function check_requisites() { global $CFG; $this->requisitesok = false; /// Check that everything we need is present if (empty($this->sourcebase) || empty($this->zipfilename)) { $this->errorstring='missingrequiredfield'; return false; } /// Check for correct sourcebase (this will be out in the future) if (!PHPUNIT_TEST and $this->sourcebase != 'https://download.moodle.org') { $this->errorstring='wrongsourcebase'; return false; } /// Check the zip file is a correct one (by extension) if (stripos($this->zipfilename, '.zip') === false) { $this->errorstring='wrongzipfilename'; return false; } /// Check that exists under dataroot if (!empty($this->destpath)) { if (!file_exists($CFG->dataroot.'/'.$this->destpath)) { $this->errorstring='wrongdestpath'; return false; } } /// Calculate the componentname $pos = stripos($this->zipfilename, '.zip'); $this->componentname = substr($this->zipfilename, 0, $pos); /// Calculate md5filename if it's empty if (empty($this->md5filename)) { $this->md5filename = $this->componentname.'.md5'; } /// Set the requisites passed flag $this->requisitesok = true; return true; }
[ "function", "check_requisites", "(", ")", "{", "global", "$", "CFG", ";", "$", "this", "->", "requisitesok", "=", "false", ";", "/// Check that everything we need is present", "if", "(", "empty", "(", "$", "this", "->", "sourcebase", ")", "||", "empty", "(", "$", "this", "->", "zipfilename", ")", ")", "{", "$", "this", "->", "errorstring", "=", "'missingrequiredfield'", ";", "return", "false", ";", "}", "/// Check for correct sourcebase (this will be out in the future)", "if", "(", "!", "PHPUNIT_TEST", "and", "$", "this", "->", "sourcebase", "!=", "'https://download.moodle.org'", ")", "{", "$", "this", "->", "errorstring", "=", "'wrongsourcebase'", ";", "return", "false", ";", "}", "/// Check the zip file is a correct one (by extension)", "if", "(", "stripos", "(", "$", "this", "->", "zipfilename", ",", "'.zip'", ")", "===", "false", ")", "{", "$", "this", "->", "errorstring", "=", "'wrongzipfilename'", ";", "return", "false", ";", "}", "/// Check that exists under dataroot", "if", "(", "!", "empty", "(", "$", "this", "->", "destpath", ")", ")", "{", "if", "(", "!", "file_exists", "(", "$", "CFG", "->", "dataroot", ".", "'/'", ".", "$", "this", "->", "destpath", ")", ")", "{", "$", "this", "->", "errorstring", "=", "'wrongdestpath'", ";", "return", "false", ";", "}", "}", "/// Calculate the componentname", "$", "pos", "=", "stripos", "(", "$", "this", "->", "zipfilename", ",", "'.zip'", ")", ";", "$", "this", "->", "componentname", "=", "substr", "(", "$", "this", "->", "zipfilename", ",", "0", ",", "$", "pos", ")", ";", "/// Calculate md5filename if it's empty", "if", "(", "empty", "(", "$", "this", "->", "md5filename", ")", ")", "{", "$", "this", "->", "md5filename", "=", "$", "this", "->", "componentname", ".", "'.md5'", ";", "}", "/// Set the requisites passed flag", "$", "this", "->", "requisitesok", "=", "true", ";", "return", "true", ";", "}" ]
This function will check if everything is properly set to begin one installation. Also, it will check for required settings and will fill everything as needed. @global object @return boolean true/false (plus detailed error in errorstring)
[ "This", "function", "will", "check", "if", "everything", "is", "properly", "set", "to", "begin", "one", "installation", ".", "Also", "it", "will", "check", "for", "required", "settings", "and", "will", "fill", "everything", "as", "needed", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/componentlib.class.php#L227-L264
216,447
moodle/moodle
lib/componentlib.class.php
component_installer.need_upgrade
function need_upgrade() { /// Check requisites are passed if (!$this->requisitesok) { return COMPONENT_ERROR; } /// Get local md5 $local_md5 = $this->get_local_md5(); /// Get remote md5 if (!$remote_md5 = $this->get_component_md5()) { return COMPONENT_ERROR; } /// Return result if ($local_md5 == $remote_md5) { return COMPONENT_UPTODATE; } else { return COMPONENT_NEEDUPDATE; } }
php
function need_upgrade() { /// Check requisites are passed if (!$this->requisitesok) { return COMPONENT_ERROR; } /// Get local md5 $local_md5 = $this->get_local_md5(); /// Get remote md5 if (!$remote_md5 = $this->get_component_md5()) { return COMPONENT_ERROR; } /// Return result if ($local_md5 == $remote_md5) { return COMPONENT_UPTODATE; } else { return COMPONENT_NEEDUPDATE; } }
[ "function", "need_upgrade", "(", ")", "{", "/// Check requisites are passed", "if", "(", "!", "$", "this", "->", "requisitesok", ")", "{", "return", "COMPONENT_ERROR", ";", "}", "/// Get local md5", "$", "local_md5", "=", "$", "this", "->", "get_local_md5", "(", ")", ";", "/// Get remote md5", "if", "(", "!", "$", "remote_md5", "=", "$", "this", "->", "get_component_md5", "(", ")", ")", "{", "return", "COMPONENT_ERROR", ";", "}", "/// Return result", "if", "(", "$", "local_md5", "==", "$", "remote_md5", ")", "{", "return", "COMPONENT_UPTODATE", ";", "}", "else", "{", "return", "COMPONENT_NEEDUPDATE", ";", "}", "}" ]
This function will detect if remote component needs to be installed because it's different from the local one @uses COMPONENT_ERROR @uses COMPONENT_UPTODATE @uses COMPONENT_NEEDUPDATE @return int COMPONENT_(ERROR | UPTODATE | NEEDUPDATE)
[ "This", "function", "will", "detect", "if", "remote", "component", "needs", "to", "be", "installed", "because", "it", "s", "different", "from", "the", "local", "one" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/componentlib.class.php#L381-L399
216,448
moodle/moodle
lib/componentlib.class.php
component_installer.get_local_md5
function get_local_md5() { global $CFG; /// Check requisites are passed if (!$this->requisitesok) { return false; } $return_value = 'needtobeinstalled'; /// Fake value to force new installation /// Calculate source to read $source = $CFG->dataroot.'/'.$this->destpath.'/'.$this->componentname.'/'.$this->componentname.'.md5'; /// Read md5 value stored (if exists) if (file_exists($source)) { if ($temp = file_get_contents($source)) { $return_value = $temp; } } return $return_value; }
php
function get_local_md5() { global $CFG; /// Check requisites are passed if (!$this->requisitesok) { return false; } $return_value = 'needtobeinstalled'; /// Fake value to force new installation /// Calculate source to read $source = $CFG->dataroot.'/'.$this->destpath.'/'.$this->componentname.'/'.$this->componentname.'.md5'; /// Read md5 value stored (if exists) if (file_exists($source)) { if ($temp = file_get_contents($source)) { $return_value = $temp; } } return $return_value; }
[ "function", "get_local_md5", "(", ")", "{", "global", "$", "CFG", ";", "/// Check requisites are passed", "if", "(", "!", "$", "this", "->", "requisitesok", ")", "{", "return", "false", ";", "}", "$", "return_value", "=", "'needtobeinstalled'", ";", "/// Fake value to force new installation", "/// Calculate source to read", "$", "source", "=", "$", "CFG", "->", "dataroot", ".", "'/'", ".", "$", "this", "->", "destpath", ".", "'/'", ".", "$", "this", "->", "componentname", ".", "'/'", ".", "$", "this", "->", "componentname", ".", "'.md5'", ";", "/// Read md5 value stored (if exists)", "if", "(", "file_exists", "(", "$", "source", ")", ")", "{", "if", "(", "$", "temp", "=", "file_get_contents", "(", "$", "source", ")", ")", "{", "$", "return_value", "=", "$", "temp", ";", "}", "}", "return", "$", "return_value", ";", "}" ]
This function will get the local md5 value of the installed component. @global object @return bool|string md5 of the local component (false on error)
[ "This", "function", "will", "get", "the", "local", "md5", "value", "of", "the", "installed", "component", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/componentlib.class.php#L422-L441
216,449
moodle/moodle
lib/componentlib.class.php
component_installer.get_component_md5
function get_component_md5() { /// Check requisites are passed if (!$this->requisitesok) { return false; } /// Get all components of md5 file if (!$comp_arr = $this->get_all_components_md5()) { if (empty($this->errorstring)) { $this->errorstring='cannotdownloadcomponents'; } return false; } /// Search for the componentname component if (empty($comp_arr[$this->componentname]) || !$component = $comp_arr[$this->componentname]) { $this->errorstring='cannotfindcomponent'; return false; } /// Check we have a valid md5 if (empty($component[1]) || strlen($component[1]) != 32) { $this->errorstring='invalidmd5'; return false; } /// Set the extramd5info field if (!empty($component[2])) { $this->extramd5info = $component[2]; } return $component[1]; }
php
function get_component_md5() { /// Check requisites are passed if (!$this->requisitesok) { return false; } /// Get all components of md5 file if (!$comp_arr = $this->get_all_components_md5()) { if (empty($this->errorstring)) { $this->errorstring='cannotdownloadcomponents'; } return false; } /// Search for the componentname component if (empty($comp_arr[$this->componentname]) || !$component = $comp_arr[$this->componentname]) { $this->errorstring='cannotfindcomponent'; return false; } /// Check we have a valid md5 if (empty($component[1]) || strlen($component[1]) != 32) { $this->errorstring='invalidmd5'; return false; } /// Set the extramd5info field if (!empty($component[2])) { $this->extramd5info = $component[2]; } return $component[1]; }
[ "function", "get_component_md5", "(", ")", "{", "/// Check requisites are passed", "if", "(", "!", "$", "this", "->", "requisitesok", ")", "{", "return", "false", ";", "}", "/// Get all components of md5 file", "if", "(", "!", "$", "comp_arr", "=", "$", "this", "->", "get_all_components_md5", "(", ")", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "errorstring", ")", ")", "{", "$", "this", "->", "errorstring", "=", "'cannotdownloadcomponents'", ";", "}", "return", "false", ";", "}", "/// Search for the componentname component", "if", "(", "empty", "(", "$", "comp_arr", "[", "$", "this", "->", "componentname", "]", ")", "||", "!", "$", "component", "=", "$", "comp_arr", "[", "$", "this", "->", "componentname", "]", ")", "{", "$", "this", "->", "errorstring", "=", "'cannotfindcomponent'", ";", "return", "false", ";", "}", "/// Check we have a valid md5", "if", "(", "empty", "(", "$", "component", "[", "1", "]", ")", "||", "strlen", "(", "$", "component", "[", "1", "]", ")", "!=", "32", ")", "{", "$", "this", "->", "errorstring", "=", "'invalidmd5'", ";", "return", "false", ";", "}", "/// Set the extramd5info field", "if", "(", "!", "empty", "(", "$", "component", "[", "2", "]", ")", ")", "{", "$", "this", "->", "extramd5info", "=", "$", "component", "[", "2", "]", ";", "}", "return", "$", "component", "[", "1", "]", ";", "}" ]
This function will download the specified md5 file, looking for the current componentname, returning its md5 field and storing extramd5info if present. Also it caches results to cachedmd5components for better performance in the same request. @return mixed md5 present in server (or false if error)
[ "This", "function", "will", "download", "the", "specified", "md5", "file", "looking", "for", "the", "current", "componentname", "returning", "its", "md5", "field", "and", "storing", "extramd5info", "if", "present", ".", "Also", "it", "caches", "results", "to", "cachedmd5components", "for", "better", "performance", "in", "the", "same", "request", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/componentlib.class.php#L451-L479
216,450
moodle/moodle
lib/componentlib.class.php
component_installer.get_all_components_md5
function get_all_components_md5() { /// Check requisites are passed if (!$this->requisitesok) { return false; } /// Initialize components array $comp_arr = array(); /// Define and retrieve the full md5 file if ($this->zippath) { $source = $this->sourcebase.'/'.$this->zippath.'/'.$this->md5filename; } else { $source = $this->sourcebase.'/'.$this->md5filename; } /// Check if we have downloaded the md5 file before (per request cache) if (!empty($this->cachedmd5components[$source])) { $comp_arr = $this->cachedmd5components[$source]; } else { /// Not downloaded, let's do it now $availablecomponents = array(); if ($contents = download_file_content($source)) { /// Split text into lines $lines=preg_split('/\r?\n/',$contents); /// Each line will be one component foreach($lines as $line) { $availablecomponents[] = explode(',', $line); } /// If no components have been found, return error if (empty($availablecomponents)) { $this->errorstring='cannotdownloadcomponents'; return false; } /// Build an associative array of components for easily search /// applying trim to avoid linefeeds and other... $comp_arr = array(); foreach ($availablecomponents as $component) { /// Avoid sometimes empty lines if (empty($component[0])) { continue; } $component[0]=trim($component[0]); if (!empty($component[1])) { $component[1]=trim($component[1]); } if (!empty($component[2])) { $component[2]=trim($component[2]); } $comp_arr[$component[0]] = $component; } /// Cache components $this->cachedmd5components[$source] = $comp_arr; } else { /// Return error $this->errorstring='remotedownloaderror'; return false; } } /// If there is no commponents or erros found, error if (!empty($this->errorstring)) { return false; } else if (empty($comp_arr)) { $this->errorstring='cannotdownloadcomponents'; return false; } return $comp_arr; }
php
function get_all_components_md5() { /// Check requisites are passed if (!$this->requisitesok) { return false; } /// Initialize components array $comp_arr = array(); /// Define and retrieve the full md5 file if ($this->zippath) { $source = $this->sourcebase.'/'.$this->zippath.'/'.$this->md5filename; } else { $source = $this->sourcebase.'/'.$this->md5filename; } /// Check if we have downloaded the md5 file before (per request cache) if (!empty($this->cachedmd5components[$source])) { $comp_arr = $this->cachedmd5components[$source]; } else { /// Not downloaded, let's do it now $availablecomponents = array(); if ($contents = download_file_content($source)) { /// Split text into lines $lines=preg_split('/\r?\n/',$contents); /// Each line will be one component foreach($lines as $line) { $availablecomponents[] = explode(',', $line); } /// If no components have been found, return error if (empty($availablecomponents)) { $this->errorstring='cannotdownloadcomponents'; return false; } /// Build an associative array of components for easily search /// applying trim to avoid linefeeds and other... $comp_arr = array(); foreach ($availablecomponents as $component) { /// Avoid sometimes empty lines if (empty($component[0])) { continue; } $component[0]=trim($component[0]); if (!empty($component[1])) { $component[1]=trim($component[1]); } if (!empty($component[2])) { $component[2]=trim($component[2]); } $comp_arr[$component[0]] = $component; } /// Cache components $this->cachedmd5components[$source] = $comp_arr; } else { /// Return error $this->errorstring='remotedownloaderror'; return false; } } /// If there is no commponents or erros found, error if (!empty($this->errorstring)) { return false; } else if (empty($comp_arr)) { $this->errorstring='cannotdownloadcomponents'; return false; } return $comp_arr; }
[ "function", "get_all_components_md5", "(", ")", "{", "/// Check requisites are passed", "if", "(", "!", "$", "this", "->", "requisitesok", ")", "{", "return", "false", ";", "}", "/// Initialize components array", "$", "comp_arr", "=", "array", "(", ")", ";", "/// Define and retrieve the full md5 file", "if", "(", "$", "this", "->", "zippath", ")", "{", "$", "source", "=", "$", "this", "->", "sourcebase", ".", "'/'", ".", "$", "this", "->", "zippath", ".", "'/'", ".", "$", "this", "->", "md5filename", ";", "}", "else", "{", "$", "source", "=", "$", "this", "->", "sourcebase", ".", "'/'", ".", "$", "this", "->", "md5filename", ";", "}", "/// Check if we have downloaded the md5 file before (per request cache)", "if", "(", "!", "empty", "(", "$", "this", "->", "cachedmd5components", "[", "$", "source", "]", ")", ")", "{", "$", "comp_arr", "=", "$", "this", "->", "cachedmd5components", "[", "$", "source", "]", ";", "}", "else", "{", "/// Not downloaded, let's do it now", "$", "availablecomponents", "=", "array", "(", ")", ";", "if", "(", "$", "contents", "=", "download_file_content", "(", "$", "source", ")", ")", "{", "/// Split text into lines", "$", "lines", "=", "preg_split", "(", "'/\\r?\\n/'", ",", "$", "contents", ")", ";", "/// Each line will be one component", "foreach", "(", "$", "lines", "as", "$", "line", ")", "{", "$", "availablecomponents", "[", "]", "=", "explode", "(", "','", ",", "$", "line", ")", ";", "}", "/// If no components have been found, return error", "if", "(", "empty", "(", "$", "availablecomponents", ")", ")", "{", "$", "this", "->", "errorstring", "=", "'cannotdownloadcomponents'", ";", "return", "false", ";", "}", "/// Build an associative array of components for easily search", "/// applying trim to avoid linefeeds and other...", "$", "comp_arr", "=", "array", "(", ")", ";", "foreach", "(", "$", "availablecomponents", "as", "$", "component", ")", "{", "/// Avoid sometimes empty lines", "if", "(", "empty", "(", "$", "component", "[", "0", "]", ")", ")", "{", "continue", ";", "}", "$", "component", "[", "0", "]", "=", "trim", "(", "$", "component", "[", "0", "]", ")", ";", "if", "(", "!", "empty", "(", "$", "component", "[", "1", "]", ")", ")", "{", "$", "component", "[", "1", "]", "=", "trim", "(", "$", "component", "[", "1", "]", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "component", "[", "2", "]", ")", ")", "{", "$", "component", "[", "2", "]", "=", "trim", "(", "$", "component", "[", "2", "]", ")", ";", "}", "$", "comp_arr", "[", "$", "component", "[", "0", "]", "]", "=", "$", "component", ";", "}", "/// Cache components", "$", "this", "->", "cachedmd5components", "[", "$", "source", "]", "=", "$", "comp_arr", ";", "}", "else", "{", "/// Return error", "$", "this", "->", "errorstring", "=", "'remotedownloaderror'", ";", "return", "false", ";", "}", "}", "/// If there is no commponents or erros found, error", "if", "(", "!", "empty", "(", "$", "this", "->", "errorstring", ")", ")", "{", "return", "false", ";", "}", "else", "if", "(", "empty", "(", "$", "comp_arr", ")", ")", "{", "$", "this", "->", "errorstring", "=", "'cannotdownloadcomponents'", ";", "return", "false", ";", "}", "return", "$", "comp_arr", ";", "}" ]
This function allows you to retrieve the complete array of components found in the md5filename @return bool|array array of components in md5 file or false if error
[ "This", "function", "allows", "you", "to", "retrieve", "the", "complete", "array", "of", "components", "found", "in", "the", "md5filename" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/componentlib.class.php#L487-L557
216,451
moodle/moodle
lib/componentlib.class.php
lang_installer.set_queue
public function set_queue($langcodes) { if (is_array($langcodes)) { $this->queue = $langcodes; } else if (!empty($langcodes)) { $this->queue = array($langcodes); } }
php
public function set_queue($langcodes) { if (is_array($langcodes)) { $this->queue = $langcodes; } else if (!empty($langcodes)) { $this->queue = array($langcodes); } }
[ "public", "function", "set_queue", "(", "$", "langcodes", ")", "{", "if", "(", "is_array", "(", "$", "langcodes", ")", ")", "{", "$", "this", "->", "queue", "=", "$", "langcodes", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "langcodes", ")", ")", "{", "$", "this", "->", "queue", "=", "array", "(", "$", "langcodes", ")", ";", "}", "}" ]
Sets the queue of language packs to be installed @param string|array $langcodes language code like 'cs' or a list of them
[ "Sets", "the", "queue", "of", "language", "packs", "to", "be", "installed" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/componentlib.class.php#L633-L639
216,452
moodle/moodle
lib/componentlib.class.php
lang_installer.get_remote_list_of_languages
public function get_remote_list_of_languages() { $source = 'https://download.moodle.org/langpack/' . $this->version . '/languages.md5'; $availablelangs = array(); if ($content = download_file_content($source)) { $alllines = explode("\n", $content); foreach($alllines as $line) { if (!empty($line)){ $availablelangs[] = explode(',', $line); } } return $availablelangs; } else { return false; } }
php
public function get_remote_list_of_languages() { $source = 'https://download.moodle.org/langpack/' . $this->version . '/languages.md5'; $availablelangs = array(); if ($content = download_file_content($source)) { $alllines = explode("\n", $content); foreach($alllines as $line) { if (!empty($line)){ $availablelangs[] = explode(',', $line); } } return $availablelangs; } else { return false; } }
[ "public", "function", "get_remote_list_of_languages", "(", ")", "{", "$", "source", "=", "'https://download.moodle.org/langpack/'", ".", "$", "this", "->", "version", ".", "'/languages.md5'", ";", "$", "availablelangs", "=", "array", "(", ")", ";", "if", "(", "$", "content", "=", "download_file_content", "(", "$", "source", ")", ")", "{", "$", "alllines", "=", "explode", "(", "\"\\n\"", ",", "$", "content", ")", ";", "foreach", "(", "$", "alllines", "as", "$", "line", ")", "{", "if", "(", "!", "empty", "(", "$", "line", ")", ")", "{", "$", "availablelangs", "[", "]", "=", "explode", "(", "','", ",", "$", "line", ")", ";", "}", "}", "return", "$", "availablelangs", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Returns the list of available language packs from download.moodle.org @return array|bool false if can not download
[ "Returns", "the", "list", "of", "available", "language", "packs", "from", "download", ".", "moodle", ".", "org" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/componentlib.class.php#L704-L720
216,453
moodle/moodle
lib/componentlib.class.php
lang_installer.is_queued
protected function is_queued($langcode = '') { if (empty($langcode)) { return !empty($this->queue); } else { return in_array($langcode, $this->queue); } }
php
protected function is_queued($langcode = '') { if (empty($langcode)) { return !empty($this->queue); } else { return in_array($langcode, $this->queue); } }
[ "protected", "function", "is_queued", "(", "$", "langcode", "=", "''", ")", "{", "if", "(", "empty", "(", "$", "langcode", ")", ")", "{", "return", "!", "empty", "(", "$", "this", "->", "queue", ")", ";", "}", "else", "{", "return", "in_array", "(", "$", "langcode", ",", "$", "this", "->", "queue", ")", ";", "}", "}" ]
Checks if the given language is queued or if the queue is empty @example $installer->is_queued('es'); // is Spanish going to be installed? @example $installer->is_queued(); // is there a language queued? @param string $langcode language code or empty string for "any" @return boolean
[ "Checks", "if", "the", "given", "language", "is", "queued", "or", "if", "the", "queue", "is", "empty" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/componentlib.class.php#L746-L754
216,454
moodle/moodle
lib/componentlib.class.php
lang_installer.install_language_pack
protected function install_language_pack($langcode) { // initialise new component installer to process this language $installer = new component_installer('https://download.moodle.org', 'download.php/direct/langpack/' . $this->version, $langcode . '.zip', 'languages.md5', 'lang'); if (!$installer->requisitesok) { throw new lang_installer_exception('installer_requisites_check_failed'); } $status = $installer->install(); if ($status == COMPONENT_ERROR) { if ($installer->get_error() === 'remotedownloaderror') { return self::RESULT_DOWNLOADERROR; } else { throw new lang_installer_exception($installer->get_error(), $langcode); } } else if ($status == COMPONENT_UPTODATE) { return self::RESULT_UPTODATE; } else if ($status == COMPONENT_INSTALLED) { return self::RESULT_INSTALLED; } else { throw new lang_installer_exception('unexpected_installer_result', $status); } }
php
protected function install_language_pack($langcode) { // initialise new component installer to process this language $installer = new component_installer('https://download.moodle.org', 'download.php/direct/langpack/' . $this->version, $langcode . '.zip', 'languages.md5', 'lang'); if (!$installer->requisitesok) { throw new lang_installer_exception('installer_requisites_check_failed'); } $status = $installer->install(); if ($status == COMPONENT_ERROR) { if ($installer->get_error() === 'remotedownloaderror') { return self::RESULT_DOWNLOADERROR; } else { throw new lang_installer_exception($installer->get_error(), $langcode); } } else if ($status == COMPONENT_UPTODATE) { return self::RESULT_UPTODATE; } else if ($status == COMPONENT_INSTALLED) { return self::RESULT_INSTALLED; } else { throw new lang_installer_exception('unexpected_installer_result', $status); } }
[ "protected", "function", "install_language_pack", "(", "$", "langcode", ")", "{", "// initialise new component installer to process this language", "$", "installer", "=", "new", "component_installer", "(", "'https://download.moodle.org'", ",", "'download.php/direct/langpack/'", ".", "$", "this", "->", "version", ",", "$", "langcode", ".", "'.zip'", ",", "'languages.md5'", ",", "'lang'", ")", ";", "if", "(", "!", "$", "installer", "->", "requisitesok", ")", "{", "throw", "new", "lang_installer_exception", "(", "'installer_requisites_check_failed'", ")", ";", "}", "$", "status", "=", "$", "installer", "->", "install", "(", ")", ";", "if", "(", "$", "status", "==", "COMPONENT_ERROR", ")", "{", "if", "(", "$", "installer", "->", "get_error", "(", ")", "===", "'remotedownloaderror'", ")", "{", "return", "self", "::", "RESULT_DOWNLOADERROR", ";", "}", "else", "{", "throw", "new", "lang_installer_exception", "(", "$", "installer", "->", "get_error", "(", ")", ",", "$", "langcode", ")", ";", "}", "}", "else", "if", "(", "$", "status", "==", "COMPONENT_UPTODATE", ")", "{", "return", "self", "::", "RESULT_UPTODATE", ";", "}", "else", "if", "(", "$", "status", "==", "COMPONENT_INSTALLED", ")", "{", "return", "self", "::", "RESULT_INSTALLED", ";", "}", "else", "{", "throw", "new", "lang_installer_exception", "(", "'unexpected_installer_result'", ",", "$", "status", ")", ";", "}", "}" ]
Perform the actual language pack installation @uses component_installer @param string $langcode @return int return status
[ "Perform", "the", "actual", "language", "pack", "installation" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/componentlib.class.php#L794-L822
216,455
moodle/moodle
auth/cas/CAS/CAS/PGTStorage/Db.php
CAS_PGTStorage_Db.init
public function init() { phpCAS::traceBegin(); // if the storage has already been initialized, return immediatly if ($this->isInitialized()) { return; } // initialize the base object parent::init(); // create the PDO object if it doesn't exist already if (!($this->_pdo instanceof PDO)) { try { $this->_pdo = new PDO( $this->_dsn, $this->_username, $this->_password, $this->_driver_options ); } catch(PDOException $e) { phpCAS::error('Database connection error: ' . $e->getMessage()); } } phpCAS::traceEnd(); }
php
public function init() { phpCAS::traceBegin(); // if the storage has already been initialized, return immediatly if ($this->isInitialized()) { return; } // initialize the base object parent::init(); // create the PDO object if it doesn't exist already if (!($this->_pdo instanceof PDO)) { try { $this->_pdo = new PDO( $this->_dsn, $this->_username, $this->_password, $this->_driver_options ); } catch(PDOException $e) { phpCAS::error('Database connection error: ' . $e->getMessage()); } } phpCAS::traceEnd(); }
[ "public", "function", "init", "(", ")", "{", "phpCAS", "::", "traceBegin", "(", ")", ";", "// if the storage has already been initialized, return immediatly", "if", "(", "$", "this", "->", "isInitialized", "(", ")", ")", "{", "return", ";", "}", "// initialize the base object", "parent", "::", "init", "(", ")", ";", "// create the PDO object if it doesn't exist already", "if", "(", "!", "(", "$", "this", "->", "_pdo", "instanceof", "PDO", ")", ")", "{", "try", "{", "$", "this", "->", "_pdo", "=", "new", "PDO", "(", "$", "this", "->", "_dsn", ",", "$", "this", "->", "_username", ",", "$", "this", "->", "_password", ",", "$", "this", "->", "_driver_options", ")", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "phpCAS", "::", "error", "(", "'Database connection error: '", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "}", "phpCAS", "::", "traceEnd", "(", ")", ";", "}" ]
This method is used to initialize the storage. Halts on error. @return void
[ "This", "method", "is", "used", "to", "initialize", "the", "storage", ".", "Halts", "on", "error", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/auth/cas/CAS/CAS/PGTStorage/Db.php#L179-L204
216,456
moodle/moodle
auth/cas/CAS/CAS/PGTStorage/Db.php
CAS_PGTStorage_Db._setErrorMode
private function _setErrorMode() { // get PDO object and enable exception error mode $pdo = $this->_getPdo(); $this->_errMode = $pdo->getAttribute(PDO::ATTR_ERRMODE); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); }
php
private function _setErrorMode() { // get PDO object and enable exception error mode $pdo = $this->_getPdo(); $this->_errMode = $pdo->getAttribute(PDO::ATTR_ERRMODE); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); }
[ "private", "function", "_setErrorMode", "(", ")", "{", "// get PDO object and enable exception error mode", "$", "pdo", "=", "$", "this", "->", "_getPdo", "(", ")", ";", "$", "this", "->", "_errMode", "=", "$", "pdo", "->", "getAttribute", "(", "PDO", "::", "ATTR_ERRMODE", ")", ";", "$", "pdo", "->", "setAttribute", "(", "PDO", "::", "ATTR_ERRMODE", ",", "PDO", "::", "ERRMODE_EXCEPTION", ")", ";", "}" ]
This method will enable the Exception error mode on the PDO object @return void
[ "This", "method", "will", "enable", "the", "Exception", "error", "mode", "on", "the", "PDO", "object" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/auth/cas/CAS/CAS/PGTStorage/Db.php#L221-L227
216,457
moodle/moodle
auth/cas/CAS/CAS/PGTStorage/Db.php
CAS_PGTStorage_Db._resetErrorMode
private function _resetErrorMode() { // get PDO object and reset the error mode to what it was originally $pdo = $this->_getPdo(); $pdo->setAttribute(PDO::ATTR_ERRMODE, $this->_errMode); }
php
private function _resetErrorMode() { // get PDO object and reset the error mode to what it was originally $pdo = $this->_getPdo(); $pdo->setAttribute(PDO::ATTR_ERRMODE, $this->_errMode); }
[ "private", "function", "_resetErrorMode", "(", ")", "{", "// get PDO object and reset the error mode to what it was originally", "$", "pdo", "=", "$", "this", "->", "_getPdo", "(", ")", ";", "$", "pdo", "->", "setAttribute", "(", "PDO", "::", "ATTR_ERRMODE", ",", "$", "this", "->", "_errMode", ")", ";", "}" ]
this method will reset the error mode on the PDO object @return void
[ "this", "method", "will", "reset", "the", "error", "mode", "on", "the", "PDO", "object" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/auth/cas/CAS/CAS/PGTStorage/Db.php#L234-L239
216,458
moodle/moodle
auth/cas/CAS/CAS/PGTStorage/Db.php
CAS_PGTStorage_Db.createTable
public function createTable() { phpCAS::traceBegin(); // initialize this PGTStorage object if it hasn't been initialized yet if ( !$this->isInitialized() ) { $this->init(); } // initialize the PDO object for this method $pdo = $this->_getPdo(); $this->_setErrorMode(); try { $pdo->beginTransaction(); $query = $pdo->query($this->createTableSQL()); $query->closeCursor(); $pdo->commit(); } catch(PDOException $e) { // attempt rolling back the transaction before throwing a phpCAS error try { $pdo->rollBack(); } catch(PDOException $e) { } phpCAS::error('error creating PGT storage table: ' . $e->getMessage()); } // reset the PDO object $this->_resetErrorMode(); phpCAS::traceEnd(); }
php
public function createTable() { phpCAS::traceBegin(); // initialize this PGTStorage object if it hasn't been initialized yet if ( !$this->isInitialized() ) { $this->init(); } // initialize the PDO object for this method $pdo = $this->_getPdo(); $this->_setErrorMode(); try { $pdo->beginTransaction(); $query = $pdo->query($this->createTableSQL()); $query->closeCursor(); $pdo->commit(); } catch(PDOException $e) { // attempt rolling back the transaction before throwing a phpCAS error try { $pdo->rollBack(); } catch(PDOException $e) { } phpCAS::error('error creating PGT storage table: ' . $e->getMessage()); } // reset the PDO object $this->_resetErrorMode(); phpCAS::traceEnd(); }
[ "public", "function", "createTable", "(", ")", "{", "phpCAS", "::", "traceBegin", "(", ")", ";", "// initialize this PGTStorage object if it hasn't been initialized yet", "if", "(", "!", "$", "this", "->", "isInitialized", "(", ")", ")", "{", "$", "this", "->", "init", "(", ")", ";", "}", "// initialize the PDO object for this method", "$", "pdo", "=", "$", "this", "->", "_getPdo", "(", ")", ";", "$", "this", "->", "_setErrorMode", "(", ")", ";", "try", "{", "$", "pdo", "->", "beginTransaction", "(", ")", ";", "$", "query", "=", "$", "pdo", "->", "query", "(", "$", "this", "->", "createTableSQL", "(", ")", ")", ";", "$", "query", "->", "closeCursor", "(", ")", ";", "$", "pdo", "->", "commit", "(", ")", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "// attempt rolling back the transaction before throwing a phpCAS error", "try", "{", "$", "pdo", "->", "rollBack", "(", ")", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "}", "phpCAS", "::", "error", "(", "'error creating PGT storage table: '", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "// reset the PDO object", "$", "this", "->", "_resetErrorMode", "(", ")", ";", "phpCAS", "::", "traceEnd", "(", ")", ";", "}" ]
This method creates the database table used to store pgt's and pgtiou's @return void
[ "This", "method", "creates", "the", "database", "table", "used", "to", "store", "pgt", "s", "and", "pgtiou", "s" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/auth/cas/CAS/CAS/PGTStorage/Db.php#L303-L338
216,459
moodle/moodle
auth/cas/CAS/CAS/PGTStorage/Db.php
CAS_PGTStorage_Db.write
public function write($pgt, $pgt_iou) { phpCAS::traceBegin(); // initialize the PDO object for this method $pdo = $this->_getPdo(); $this->_setErrorMode(); try { $pdo->beginTransaction(); $query = $pdo->prepare($this->storePgtSql()); $query->bindValue(':pgt', $pgt, PDO::PARAM_STR); $query->bindValue(':pgt_iou', $pgt_iou, PDO::PARAM_STR); $query->execute(); $query->closeCursor(); $pdo->commit(); } catch(PDOException $e) { // attempt rolling back the transaction before throwing a phpCAS error try { $pdo->rollBack(); } catch(PDOException $e) { } phpCAS::error('error writing PGT to database: ' . $e->getMessage()); } // reset the PDO object $this->_resetErrorMode(); phpCAS::traceEnd(); }
php
public function write($pgt, $pgt_iou) { phpCAS::traceBegin(); // initialize the PDO object for this method $pdo = $this->_getPdo(); $this->_setErrorMode(); try { $pdo->beginTransaction(); $query = $pdo->prepare($this->storePgtSql()); $query->bindValue(':pgt', $pgt, PDO::PARAM_STR); $query->bindValue(':pgt_iou', $pgt_iou, PDO::PARAM_STR); $query->execute(); $query->closeCursor(); $pdo->commit(); } catch(PDOException $e) { // attempt rolling back the transaction before throwing a phpCAS error try { $pdo->rollBack(); } catch(PDOException $e) { } phpCAS::error('error writing PGT to database: ' . $e->getMessage()); } // reset the PDO object $this->_resetErrorMode(); phpCAS::traceEnd(); }
[ "public", "function", "write", "(", "$", "pgt", ",", "$", "pgt_iou", ")", "{", "phpCAS", "::", "traceBegin", "(", ")", ";", "// initialize the PDO object for this method", "$", "pdo", "=", "$", "this", "->", "_getPdo", "(", ")", ";", "$", "this", "->", "_setErrorMode", "(", ")", ";", "try", "{", "$", "pdo", "->", "beginTransaction", "(", ")", ";", "$", "query", "=", "$", "pdo", "->", "prepare", "(", "$", "this", "->", "storePgtSql", "(", ")", ")", ";", "$", "query", "->", "bindValue", "(", "':pgt'", ",", "$", "pgt", ",", "PDO", "::", "PARAM_STR", ")", ";", "$", "query", "->", "bindValue", "(", "':pgt_iou'", ",", "$", "pgt_iou", ",", "PDO", "::", "PARAM_STR", ")", ";", "$", "query", "->", "execute", "(", ")", ";", "$", "query", "->", "closeCursor", "(", ")", ";", "$", "pdo", "->", "commit", "(", ")", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "// attempt rolling back the transaction before throwing a phpCAS error", "try", "{", "$", "pdo", "->", "rollBack", "(", ")", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "}", "phpCAS", "::", "error", "(", "'error writing PGT to database: '", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "// reset the PDO object", "$", "this", "->", "_resetErrorMode", "(", ")", ";", "phpCAS", "::", "traceEnd", "(", ")", ";", "}" ]
This method stores a PGT and its corresponding PGT Iou in the database. Echoes a warning on error. @param string $pgt the PGT @param string $pgt_iou the PGT iou @return void
[ "This", "method", "stores", "a", "PGT", "and", "its", "corresponding", "PGT", "Iou", "in", "the", "database", ".", "Echoes", "a", "warning", "on", "error", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/auth/cas/CAS/CAS/PGTStorage/Db.php#L349-L382
216,460
moodle/moodle
auth/cas/CAS/CAS/PGTStorage/Db.php
CAS_PGTStorage_Db.read
public function read($pgt_iou) { phpCAS::traceBegin(); $pgt = false; // initialize the PDO object for this method $pdo = $this->_getPdo(); $this->_setErrorMode(); try { $pdo->beginTransaction(); // fetch the pgt for the specified pgt_iou $query = $pdo->prepare($this->retrievePgtSql()); $query->bindValue(':pgt_iou', $pgt_iou, PDO::PARAM_STR); $query->execute(); $pgt = $query->fetchColumn(0); $query->closeCursor(); // delete the specified pgt_iou from the database $query = $pdo->prepare($this->deletePgtSql()); $query->bindValue(':pgt_iou', $pgt_iou, PDO::PARAM_STR); $query->execute(); $query->closeCursor(); $pdo->commit(); } catch(PDOException $e) { // attempt rolling back the transaction before throwing a phpCAS error try { $pdo->rollBack(); } catch(PDOException $e) { } phpCAS::trace('error reading PGT from database: ' . $e->getMessage()); } // reset the PDO object $this->_resetErrorMode(); phpCAS::traceEnd(); return $pgt; }
php
public function read($pgt_iou) { phpCAS::traceBegin(); $pgt = false; // initialize the PDO object for this method $pdo = $this->_getPdo(); $this->_setErrorMode(); try { $pdo->beginTransaction(); // fetch the pgt for the specified pgt_iou $query = $pdo->prepare($this->retrievePgtSql()); $query->bindValue(':pgt_iou', $pgt_iou, PDO::PARAM_STR); $query->execute(); $pgt = $query->fetchColumn(0); $query->closeCursor(); // delete the specified pgt_iou from the database $query = $pdo->prepare($this->deletePgtSql()); $query->bindValue(':pgt_iou', $pgt_iou, PDO::PARAM_STR); $query->execute(); $query->closeCursor(); $pdo->commit(); } catch(PDOException $e) { // attempt rolling back the transaction before throwing a phpCAS error try { $pdo->rollBack(); } catch(PDOException $e) { } phpCAS::trace('error reading PGT from database: ' . $e->getMessage()); } // reset the PDO object $this->_resetErrorMode(); phpCAS::traceEnd(); return $pgt; }
[ "public", "function", "read", "(", "$", "pgt_iou", ")", "{", "phpCAS", "::", "traceBegin", "(", ")", ";", "$", "pgt", "=", "false", ";", "// initialize the PDO object for this method", "$", "pdo", "=", "$", "this", "->", "_getPdo", "(", ")", ";", "$", "this", "->", "_setErrorMode", "(", ")", ";", "try", "{", "$", "pdo", "->", "beginTransaction", "(", ")", ";", "// fetch the pgt for the specified pgt_iou", "$", "query", "=", "$", "pdo", "->", "prepare", "(", "$", "this", "->", "retrievePgtSql", "(", ")", ")", ";", "$", "query", "->", "bindValue", "(", "':pgt_iou'", ",", "$", "pgt_iou", ",", "PDO", "::", "PARAM_STR", ")", ";", "$", "query", "->", "execute", "(", ")", ";", "$", "pgt", "=", "$", "query", "->", "fetchColumn", "(", "0", ")", ";", "$", "query", "->", "closeCursor", "(", ")", ";", "// delete the specified pgt_iou from the database", "$", "query", "=", "$", "pdo", "->", "prepare", "(", "$", "this", "->", "deletePgtSql", "(", ")", ")", ";", "$", "query", "->", "bindValue", "(", "':pgt_iou'", ",", "$", "pgt_iou", ",", "PDO", "::", "PARAM_STR", ")", ";", "$", "query", "->", "execute", "(", ")", ";", "$", "query", "->", "closeCursor", "(", ")", ";", "$", "pdo", "->", "commit", "(", ")", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "// attempt rolling back the transaction before throwing a phpCAS error", "try", "{", "$", "pdo", "->", "rollBack", "(", ")", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "}", "phpCAS", "::", "trace", "(", "'error reading PGT from database: '", ".", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "// reset the PDO object", "$", "this", "->", "_resetErrorMode", "(", ")", ";", "phpCAS", "::", "traceEnd", "(", ")", ";", "return", "$", "pgt", ";", "}" ]
This method reads a PGT corresponding to a PGT Iou and deletes the corresponding db entry. @param string $pgt_iou the PGT iou @return the corresponding PGT, or FALSE on error
[ "This", "method", "reads", "a", "PGT", "corresponding", "to", "a", "PGT", "Iou", "and", "deletes", "the", "corresponding", "db", "entry", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/auth/cas/CAS/CAS/PGTStorage/Db.php#L392-L434
216,461
moodle/moodle
mod/feedback/classes/external.php
mod_feedback_external.get_feedbacks_by_courses
public static function get_feedbacks_by_courses($courseids = array()) { global $PAGE; $warnings = array(); $returnedfeedbacks = array(); $params = array( 'courseids' => $courseids, ); $params = self::validate_parameters(self::get_feedbacks_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 feedbacks in this course, this function checks users visibility permissions. // We can avoid then additional validate_context calls. $feedbacks = get_all_instances_in_courses("feedback", $courses); foreach ($feedbacks as $feedback) { $context = context_module::instance($feedback->coursemodule); // Remove fields that are not from the feedback (added by get_all_instances_in_courses). unset($feedback->coursemodule, $feedback->context, $feedback->visible, $feedback->section, $feedback->groupmode, $feedback->groupingid); // Check permissions. if (!has_capability('mod/feedback:edititems', $context)) { // Don't return the optional properties. $properties = feedback_summary_exporter::properties_definition(); foreach ($properties as $property => $config) { if (!empty($config['optional'])) { unset($feedback->{$property}); } } } $exporter = new feedback_summary_exporter($feedback, array('context' => $context)); $returnedfeedbacks[] = $exporter->export($output); } } $result = array( 'feedbacks' => $returnedfeedbacks, 'warnings' => $warnings ); return $result; }
php
public static function get_feedbacks_by_courses($courseids = array()) { global $PAGE; $warnings = array(); $returnedfeedbacks = array(); $params = array( 'courseids' => $courseids, ); $params = self::validate_parameters(self::get_feedbacks_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 feedbacks in this course, this function checks users visibility permissions. // We can avoid then additional validate_context calls. $feedbacks = get_all_instances_in_courses("feedback", $courses); foreach ($feedbacks as $feedback) { $context = context_module::instance($feedback->coursemodule); // Remove fields that are not from the feedback (added by get_all_instances_in_courses). unset($feedback->coursemodule, $feedback->context, $feedback->visible, $feedback->section, $feedback->groupmode, $feedback->groupingid); // Check permissions. if (!has_capability('mod/feedback:edititems', $context)) { // Don't return the optional properties. $properties = feedback_summary_exporter::properties_definition(); foreach ($properties as $property => $config) { if (!empty($config['optional'])) { unset($feedback->{$property}); } } } $exporter = new feedback_summary_exporter($feedback, array('context' => $context)); $returnedfeedbacks[] = $exporter->export($output); } } $result = array( 'feedbacks' => $returnedfeedbacks, 'warnings' => $warnings ); return $result; }
[ "public", "static", "function", "get_feedbacks_by_courses", "(", "$", "courseids", "=", "array", "(", ")", ")", "{", "global", "$", "PAGE", ";", "$", "warnings", "=", "array", "(", ")", ";", "$", "returnedfeedbacks", "=", "array", "(", ")", ";", "$", "params", "=", "array", "(", "'courseids'", "=>", "$", "courseids", ",", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_feedbacks_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 feedbacks in this course, this function checks users visibility permissions.", "// We can avoid then additional validate_context calls.", "$", "feedbacks", "=", "get_all_instances_in_courses", "(", "\"feedback\"", ",", "$", "courses", ")", ";", "foreach", "(", "$", "feedbacks", "as", "$", "feedback", ")", "{", "$", "context", "=", "context_module", "::", "instance", "(", "$", "feedback", "->", "coursemodule", ")", ";", "// Remove fields that are not from the feedback (added by get_all_instances_in_courses).", "unset", "(", "$", "feedback", "->", "coursemodule", ",", "$", "feedback", "->", "context", ",", "$", "feedback", "->", "visible", ",", "$", "feedback", "->", "section", ",", "$", "feedback", "->", "groupmode", ",", "$", "feedback", "->", "groupingid", ")", ";", "// Check permissions.", "if", "(", "!", "has_capability", "(", "'mod/feedback:edititems'", ",", "$", "context", ")", ")", "{", "// Don't return the optional properties.", "$", "properties", "=", "feedback_summary_exporter", "::", "properties_definition", "(", ")", ";", "foreach", "(", "$", "properties", "as", "$", "property", "=>", "$", "config", ")", "{", "if", "(", "!", "empty", "(", "$", "config", "[", "'optional'", "]", ")", ")", "{", "unset", "(", "$", "feedback", "->", "{", "$", "property", "}", ")", ";", "}", "}", "}", "$", "exporter", "=", "new", "feedback_summary_exporter", "(", "$", "feedback", ",", "array", "(", "'context'", "=>", "$", "context", ")", ")", ";", "$", "returnedfeedbacks", "[", "]", "=", "$", "exporter", "->", "export", "(", "$", "output", ")", ";", "}", "}", "$", "result", "=", "array", "(", "'feedbacks'", "=>", "$", "returnedfeedbacks", ",", "'warnings'", "=>", "$", "warnings", ")", ";", "return", "$", "result", ";", "}" ]
Returns a list of feedbacks in a provided list of courses. If no list is provided all feedbacks that the user can view will be returned. @param array $courseids course ids @return array of warnings and feedbacks @since Moodle 3.3
[ "Returns", "a", "list", "of", "feedbacks", "in", "a", "provided", "list", "of", "courses", ".", "If", "no", "list", "is", "provided", "all", "feedbacks", "that", "the", "user", "can", "view", "will", "be", "returned", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/external.php#L73-L127
216,462
moodle/moodle
mod/feedback/classes/external.php
mod_feedback_external.validate_feedback
protected static function validate_feedback($feedbackid, $courseid = 0) { global $DB, $USER; // Request and permission validation. $feedback = $DB->get_record('feedback', array('id' => $feedbackid), '*', MUST_EXIST); list($feedbackcourse, $cm) = get_course_and_cm_from_instance($feedback, 'feedback'); $context = context_module::instance($cm->id); self::validate_context($context); // Set default completion course. $completioncourse = (object) array('id' => 0); if ($feedbackcourse->id == SITEID && $courseid) { $completioncourse = get_course($courseid); self::validate_context(context_course::instance($courseid)); $feedbackcompletion = new mod_feedback_completion($feedback, $cm, $courseid); if (!$feedbackcompletion->check_course_is_mapped()) { throw new moodle_exception('cannotaccess', 'mod_feedback'); } } return array($feedback, $feedbackcourse, $cm, $context, $completioncourse); }
php
protected static function validate_feedback($feedbackid, $courseid = 0) { global $DB, $USER; // Request and permission validation. $feedback = $DB->get_record('feedback', array('id' => $feedbackid), '*', MUST_EXIST); list($feedbackcourse, $cm) = get_course_and_cm_from_instance($feedback, 'feedback'); $context = context_module::instance($cm->id); self::validate_context($context); // Set default completion course. $completioncourse = (object) array('id' => 0); if ($feedbackcourse->id == SITEID && $courseid) { $completioncourse = get_course($courseid); self::validate_context(context_course::instance($courseid)); $feedbackcompletion = new mod_feedback_completion($feedback, $cm, $courseid); if (!$feedbackcompletion->check_course_is_mapped()) { throw new moodle_exception('cannotaccess', 'mod_feedback'); } } return array($feedback, $feedbackcourse, $cm, $context, $completioncourse); }
[ "protected", "static", "function", "validate_feedback", "(", "$", "feedbackid", ",", "$", "courseid", "=", "0", ")", "{", "global", "$", "DB", ",", "$", "USER", ";", "// Request and permission validation.", "$", "feedback", "=", "$", "DB", "->", "get_record", "(", "'feedback'", ",", "array", "(", "'id'", "=>", "$", "feedbackid", ")", ",", "'*'", ",", "MUST_EXIST", ")", ";", "list", "(", "$", "feedbackcourse", ",", "$", "cm", ")", "=", "get_course_and_cm_from_instance", "(", "$", "feedback", ",", "'feedback'", ")", ";", "$", "context", "=", "context_module", "::", "instance", "(", "$", "cm", "->", "id", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "// Set default completion course.", "$", "completioncourse", "=", "(", "object", ")", "array", "(", "'id'", "=>", "0", ")", ";", "if", "(", "$", "feedbackcourse", "->", "id", "==", "SITEID", "&&", "$", "courseid", ")", "{", "$", "completioncourse", "=", "get_course", "(", "$", "courseid", ")", ";", "self", "::", "validate_context", "(", "context_course", "::", "instance", "(", "$", "courseid", ")", ")", ";", "$", "feedbackcompletion", "=", "new", "mod_feedback_completion", "(", "$", "feedback", ",", "$", "cm", ",", "$", "courseid", ")", ";", "if", "(", "!", "$", "feedbackcompletion", "->", "check_course_is_mapped", "(", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'cannotaccess'", ",", "'mod_feedback'", ")", ";", "}", "}", "return", "array", "(", "$", "feedback", ",", "$", "feedbackcourse", ",", "$", "cm", ",", "$", "context", ",", "$", "completioncourse", ")", ";", "}" ]
Utility function for validating a feedback. @param int $feedbackid feedback instance id @param int $courseid courseid course where user completes the feedback (for site feedbacks only) @return array containing the feedback, feedback course, context, course module and the course where is being completed. @throws moodle_exception @since Moodle 3.3
[ "Utility", "function", "for", "validating", "a", "feedback", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/external.php#L155-L178
216,463
moodle/moodle
mod/feedback/classes/external.php
mod_feedback_external.validate_feedback_access
protected static function validate_feedback_access($feedback, $course, $cm, $context, $checksubmit = false) { $feedbackcompletion = new mod_feedback_completion($feedback, $cm, $course->id); if (!$feedbackcompletion->can_complete()) { throw new required_capability_exception($context, 'mod/feedback:complete', 'nopermission', ''); } if (!$feedbackcompletion->is_open()) { throw new moodle_exception('feedback_is_not_open', 'feedback'); } if ($feedbackcompletion->is_empty()) { throw new moodle_exception('no_items_available_yet', 'feedback'); } if ($checksubmit && !$feedbackcompletion->can_submit()) { throw new moodle_exception('this_feedback_is_already_submitted', 'feedback'); } return $feedbackcompletion; }
php
protected static function validate_feedback_access($feedback, $course, $cm, $context, $checksubmit = false) { $feedbackcompletion = new mod_feedback_completion($feedback, $cm, $course->id); if (!$feedbackcompletion->can_complete()) { throw new required_capability_exception($context, 'mod/feedback:complete', 'nopermission', ''); } if (!$feedbackcompletion->is_open()) { throw new moodle_exception('feedback_is_not_open', 'feedback'); } if ($feedbackcompletion->is_empty()) { throw new moodle_exception('no_items_available_yet', 'feedback'); } if ($checksubmit && !$feedbackcompletion->can_submit()) { throw new moodle_exception('this_feedback_is_already_submitted', 'feedback'); } return $feedbackcompletion; }
[ "protected", "static", "function", "validate_feedback_access", "(", "$", "feedback", ",", "$", "course", ",", "$", "cm", ",", "$", "context", ",", "$", "checksubmit", "=", "false", ")", "{", "$", "feedbackcompletion", "=", "new", "mod_feedback_completion", "(", "$", "feedback", ",", "$", "cm", ",", "$", "course", "->", "id", ")", ";", "if", "(", "!", "$", "feedbackcompletion", "->", "can_complete", "(", ")", ")", "{", "throw", "new", "required_capability_exception", "(", "$", "context", ",", "'mod/feedback:complete'", ",", "'nopermission'", ",", "''", ")", ";", "}", "if", "(", "!", "$", "feedbackcompletion", "->", "is_open", "(", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'feedback_is_not_open'", ",", "'feedback'", ")", ";", "}", "if", "(", "$", "feedbackcompletion", "->", "is_empty", "(", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'no_items_available_yet'", ",", "'feedback'", ")", ";", "}", "if", "(", "$", "checksubmit", "&&", "!", "$", "feedbackcompletion", "->", "can_submit", "(", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'this_feedback_is_already_submitted'", ",", "'feedback'", ")", ";", "}", "return", "$", "feedbackcompletion", ";", "}" ]
Utility function for validating access to feedback. @param stdClass $feedback feedback object @param stdClass $course course where user completes the feedback (for site feedbacks only) @param stdClass $cm course module @param stdClass $context context object @throws moodle_exception @return mod_feedback_completion feedback completion instance @since Moodle 3.3
[ "Utility", "function", "for", "validating", "access", "to", "feedback", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/external.php#L191-L210
216,464
moodle/moodle
mod/feedback/classes/external.php
mod_feedback_external.get_feedback_access_information
public static function get_feedback_access_information($feedbackid, $courseid = 0) { global $PAGE; $params = array( 'feedbackid' => $feedbackid, 'courseid' => $courseid, ); $params = self::validate_parameters(self::get_feedback_access_information_parameters(), $params); list($feedback, $course, $cm, $context, $completioncourse) = self::validate_feedback($params['feedbackid'], $params['courseid']); $feedbackcompletion = new mod_feedback_completion($feedback, $cm, $completioncourse->id); $result = array(); // Capabilities first. $result['canviewanalysis'] = $feedbackcompletion->can_view_analysis(); $result['cancomplete'] = $feedbackcompletion->can_complete(); $result['cansubmit'] = $feedbackcompletion->can_submit(); $result['candeletesubmissions'] = has_capability('mod/feedback:deletesubmissions', $context); $result['canviewreports'] = has_capability('mod/feedback:viewreports', $context); $result['canedititems'] = has_capability('mod/feedback:edititems', $context); // Status information. $result['isempty'] = $feedbackcompletion->is_empty(); $result['isopen'] = $feedbackcompletion->is_open(); $anycourse = ($course->id == SITEID); $result['isalreadysubmitted'] = $feedbackcompletion->is_already_submitted($anycourse); $result['isanonymous'] = $feedbackcompletion->is_anonymous(); $result['warnings'] = []; return $result; }
php
public static function get_feedback_access_information($feedbackid, $courseid = 0) { global $PAGE; $params = array( 'feedbackid' => $feedbackid, 'courseid' => $courseid, ); $params = self::validate_parameters(self::get_feedback_access_information_parameters(), $params); list($feedback, $course, $cm, $context, $completioncourse) = self::validate_feedback($params['feedbackid'], $params['courseid']); $feedbackcompletion = new mod_feedback_completion($feedback, $cm, $completioncourse->id); $result = array(); // Capabilities first. $result['canviewanalysis'] = $feedbackcompletion->can_view_analysis(); $result['cancomplete'] = $feedbackcompletion->can_complete(); $result['cansubmit'] = $feedbackcompletion->can_submit(); $result['candeletesubmissions'] = has_capability('mod/feedback:deletesubmissions', $context); $result['canviewreports'] = has_capability('mod/feedback:viewreports', $context); $result['canedititems'] = has_capability('mod/feedback:edititems', $context); // Status information. $result['isempty'] = $feedbackcompletion->is_empty(); $result['isopen'] = $feedbackcompletion->is_open(); $anycourse = ($course->id == SITEID); $result['isalreadysubmitted'] = $feedbackcompletion->is_already_submitted($anycourse); $result['isanonymous'] = $feedbackcompletion->is_anonymous(); $result['warnings'] = []; return $result; }
[ "public", "static", "function", "get_feedback_access_information", "(", "$", "feedbackid", ",", "$", "courseid", "=", "0", ")", "{", "global", "$", "PAGE", ";", "$", "params", "=", "array", "(", "'feedbackid'", "=>", "$", "feedbackid", ",", "'courseid'", "=>", "$", "courseid", ",", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_feedback_access_information_parameters", "(", ")", ",", "$", "params", ")", ";", "list", "(", "$", "feedback", ",", "$", "course", ",", "$", "cm", ",", "$", "context", ",", "$", "completioncourse", ")", "=", "self", "::", "validate_feedback", "(", "$", "params", "[", "'feedbackid'", "]", ",", "$", "params", "[", "'courseid'", "]", ")", ";", "$", "feedbackcompletion", "=", "new", "mod_feedback_completion", "(", "$", "feedback", ",", "$", "cm", ",", "$", "completioncourse", "->", "id", ")", ";", "$", "result", "=", "array", "(", ")", ";", "// Capabilities first.", "$", "result", "[", "'canviewanalysis'", "]", "=", "$", "feedbackcompletion", "->", "can_view_analysis", "(", ")", ";", "$", "result", "[", "'cancomplete'", "]", "=", "$", "feedbackcompletion", "->", "can_complete", "(", ")", ";", "$", "result", "[", "'cansubmit'", "]", "=", "$", "feedbackcompletion", "->", "can_submit", "(", ")", ";", "$", "result", "[", "'candeletesubmissions'", "]", "=", "has_capability", "(", "'mod/feedback:deletesubmissions'", ",", "$", "context", ")", ";", "$", "result", "[", "'canviewreports'", "]", "=", "has_capability", "(", "'mod/feedback:viewreports'", ",", "$", "context", ")", ";", "$", "result", "[", "'canedititems'", "]", "=", "has_capability", "(", "'mod/feedback:edititems'", ",", "$", "context", ")", ";", "// Status information.", "$", "result", "[", "'isempty'", "]", "=", "$", "feedbackcompletion", "->", "is_empty", "(", ")", ";", "$", "result", "[", "'isopen'", "]", "=", "$", "feedbackcompletion", "->", "is_open", "(", ")", ";", "$", "anycourse", "=", "(", "$", "course", "->", "id", "==", "SITEID", ")", ";", "$", "result", "[", "'isalreadysubmitted'", "]", "=", "$", "feedbackcompletion", "->", "is_already_submitted", "(", "$", "anycourse", ")", ";", "$", "result", "[", "'isanonymous'", "]", "=", "$", "feedbackcompletion", "->", "is_anonymous", "(", ")", ";", "$", "result", "[", "'warnings'", "]", "=", "[", "]", ";", "return", "$", "result", ";", "}" ]
Return access information for a given feedback. @param int $feedbackid feedback instance id @param int $courseid course where user completes the feedback (for site feedbacks only) @return array of warnings and the access information @since Moodle 3.3 @throws moodle_exception
[ "Return", "access", "information", "for", "a", "given", "feedback", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/external.php#L237-L268
216,465
moodle/moodle
mod/feedback/classes/external.php
mod_feedback_external.get_feedback_access_information_returns
public static function get_feedback_access_information_returns() { return new external_single_structure( array( 'canviewanalysis' => new external_value(PARAM_BOOL, 'Whether the user can view the analysis or not.'), 'cancomplete' => new external_value(PARAM_BOOL, 'Whether the user can complete the feedback or not.'), 'cansubmit' => new external_value(PARAM_BOOL, 'Whether the user can submit the feedback or not.'), 'candeletesubmissions' => new external_value(PARAM_BOOL, 'Whether the user can delete submissions or not.'), 'canviewreports' => new external_value(PARAM_BOOL, 'Whether the user can view the feedback reports or not.'), 'canedititems' => new external_value(PARAM_BOOL, 'Whether the user can edit feedback items or not.'), 'isempty' => new external_value(PARAM_BOOL, 'Whether the feedback has questions or not.'), 'isopen' => new external_value(PARAM_BOOL, 'Whether the feedback has active access time restrictions or not.'), 'isalreadysubmitted' => new external_value(PARAM_BOOL, 'Whether the feedback is already submitted or not.'), 'isanonymous' => new external_value(PARAM_BOOL, 'Whether the feedback is anonymous or not.'), 'warnings' => new external_warnings(), ) ); }
php
public static function get_feedback_access_information_returns() { return new external_single_structure( array( 'canviewanalysis' => new external_value(PARAM_BOOL, 'Whether the user can view the analysis or not.'), 'cancomplete' => new external_value(PARAM_BOOL, 'Whether the user can complete the feedback or not.'), 'cansubmit' => new external_value(PARAM_BOOL, 'Whether the user can submit the feedback or not.'), 'candeletesubmissions' => new external_value(PARAM_BOOL, 'Whether the user can delete submissions or not.'), 'canviewreports' => new external_value(PARAM_BOOL, 'Whether the user can view the feedback reports or not.'), 'canedititems' => new external_value(PARAM_BOOL, 'Whether the user can edit feedback items or not.'), 'isempty' => new external_value(PARAM_BOOL, 'Whether the feedback has questions or not.'), 'isopen' => new external_value(PARAM_BOOL, 'Whether the feedback has active access time restrictions or not.'), 'isalreadysubmitted' => new external_value(PARAM_BOOL, 'Whether the feedback is already submitted or not.'), 'isanonymous' => new external_value(PARAM_BOOL, 'Whether the feedback is anonymous or not.'), 'warnings' => new external_warnings(), ) ); }
[ "public", "static", "function", "get_feedback_access_information_returns", "(", ")", "{", "return", "new", "external_single_structure", "(", "array", "(", "'canviewanalysis'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'Whether the user can view the analysis or not.'", ")", ",", "'cancomplete'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'Whether the user can complete the feedback or not.'", ")", ",", "'cansubmit'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'Whether the user can submit the feedback or not.'", ")", ",", "'candeletesubmissions'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'Whether the user can delete submissions or not.'", ")", ",", "'canviewreports'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'Whether the user can view the feedback reports or not.'", ")", ",", "'canedititems'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'Whether the user can edit feedback items or not.'", ")", ",", "'isempty'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'Whether the feedback has questions or not.'", ")", ",", "'isopen'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'Whether the feedback has active access time restrictions or not.'", ")", ",", "'isalreadysubmitted'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'Whether the feedback is already submitted or not.'", ")", ",", "'isanonymous'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'Whether the feedback is anonymous or not.'", ")", ",", "'warnings'", "=>", "new", "external_warnings", "(", ")", ",", ")", ")", ";", "}" ]
Describes the get_feedback_access_information return value. @return external_single_structure @since Moodle 3.3
[ "Describes", "the", "get_feedback_access_information", "return", "value", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/external.php#L276-L292
216,466
moodle/moodle
mod/feedback/classes/external.php
mod_feedback_external.view_feedback_parameters
public static function view_feedback_parameters() { return new external_function_parameters ( array( 'feedbackid' => new external_value(PARAM_INT, 'Feedback instance id'), 'moduleviewed' => new external_value(PARAM_BOOL, 'If we need to mark the module as viewed for completion', VALUE_DEFAULT, false), 'courseid' => new external_value(PARAM_INT, 'Course where user completes the feedback (for site feedbacks only).', VALUE_DEFAULT, 0), ) ); }
php
public static function view_feedback_parameters() { return new external_function_parameters ( array( 'feedbackid' => new external_value(PARAM_INT, 'Feedback instance id'), 'moduleviewed' => new external_value(PARAM_BOOL, 'If we need to mark the module as viewed for completion', VALUE_DEFAULT, false), 'courseid' => new external_value(PARAM_INT, 'Course where user completes the feedback (for site feedbacks only).', VALUE_DEFAULT, 0), ) ); }
[ "public", "static", "function", "view_feedback_parameters", "(", ")", "{", "return", "new", "external_function_parameters", "(", "array", "(", "'feedbackid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Feedback instance id'", ")", ",", "'moduleviewed'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'If we need to mark the module as viewed for completion'", ",", "VALUE_DEFAULT", ",", "false", ")", ",", "'courseid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Course where user completes the feedback (for site feedbacks only).'", ",", "VALUE_DEFAULT", ",", "0", ")", ",", ")", ")", ";", "}" ]
Describes the parameters for view_feedback. @return external_function_parameters @since Moodle 3.3
[ "Describes", "the", "parameters", "for", "view_feedback", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/external.php#L300-L310
216,467
moodle/moodle
mod/feedback/classes/external.php
mod_feedback_external.get_current_completed_tmp
public static function get_current_completed_tmp($feedbackid, $courseid = 0) { global $PAGE; $params = array('feedbackid' => $feedbackid, 'courseid' => $courseid); $params = self::validate_parameters(self::get_current_completed_tmp_parameters(), $params); $warnings = array(); list($feedback, $course, $cm, $context, $completioncourse) = self::validate_feedback($params['feedbackid'], $params['courseid']); $feedbackcompletion = new mod_feedback_completion($feedback, $cm, $completioncourse->id); if ($completed = $feedbackcompletion->get_current_completed_tmp()) { $exporter = new feedback_completedtmp_exporter($completed); return array( 'feedback' => $exporter->export($PAGE->get_renderer('core')), 'warnings' => $warnings, ); } throw new moodle_exception('not_started', 'feedback'); }
php
public static function get_current_completed_tmp($feedbackid, $courseid = 0) { global $PAGE; $params = array('feedbackid' => $feedbackid, 'courseid' => $courseid); $params = self::validate_parameters(self::get_current_completed_tmp_parameters(), $params); $warnings = array(); list($feedback, $course, $cm, $context, $completioncourse) = self::validate_feedback($params['feedbackid'], $params['courseid']); $feedbackcompletion = new mod_feedback_completion($feedback, $cm, $completioncourse->id); if ($completed = $feedbackcompletion->get_current_completed_tmp()) { $exporter = new feedback_completedtmp_exporter($completed); return array( 'feedback' => $exporter->export($PAGE->get_renderer('core')), 'warnings' => $warnings, ); } throw new moodle_exception('not_started', 'feedback'); }
[ "public", "static", "function", "get_current_completed_tmp", "(", "$", "feedbackid", ",", "$", "courseid", "=", "0", ")", "{", "global", "$", "PAGE", ";", "$", "params", "=", "array", "(", "'feedbackid'", "=>", "$", "feedbackid", ",", "'courseid'", "=>", "$", "courseid", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_current_completed_tmp_parameters", "(", ")", ",", "$", "params", ")", ";", "$", "warnings", "=", "array", "(", ")", ";", "list", "(", "$", "feedback", ",", "$", "course", ",", "$", "cm", ",", "$", "context", ",", "$", "completioncourse", ")", "=", "self", "::", "validate_feedback", "(", "$", "params", "[", "'feedbackid'", "]", ",", "$", "params", "[", "'courseid'", "]", ")", ";", "$", "feedbackcompletion", "=", "new", "mod_feedback_completion", "(", "$", "feedback", ",", "$", "cm", ",", "$", "completioncourse", "->", "id", ")", ";", "if", "(", "$", "completed", "=", "$", "feedbackcompletion", "->", "get_current_completed_tmp", "(", ")", ")", "{", "$", "exporter", "=", "new", "feedback_completedtmp_exporter", "(", "$", "completed", ")", ";", "return", "array", "(", "'feedback'", "=>", "$", "exporter", "->", "export", "(", "$", "PAGE", "->", "get_renderer", "(", "'core'", ")", ")", ",", "'warnings'", "=>", "$", "warnings", ",", ")", ";", "}", "throw", "new", "moodle_exception", "(", "'not_started'", ",", "'feedback'", ")", ";", "}" ]
Returns the temporary completion record for the current user. @param int $feedbackid feedback instance id @param int $courseid course where user completes the feedback (for site feedbacks only) @return array of warnings and status result @since Moodle 3.3 @throws moodle_exception
[ "Returns", "the", "temporary", "completion", "record", "for", "the", "current", "user", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/external.php#L389-L408
216,468
moodle/moodle
mod/feedback/classes/external.php
mod_feedback_external.launch_feedback
public static function launch_feedback($feedbackid, $courseid = 0) { global $PAGE; $params = array('feedbackid' => $feedbackid, 'courseid' => $courseid); $params = self::validate_parameters(self::launch_feedback_parameters(), $params); $warnings = array(); list($feedback, $course, $cm, $context, $completioncourse) = self::validate_feedback($params['feedbackid'], $params['courseid']); // Check we can do a new submission (or continue an existing). $feedbackcompletion = self::validate_feedback_access($feedback, $completioncourse, $cm, $context, true); $gopage = $feedbackcompletion->get_resume_page(); if ($gopage === null) { $gopage = -1; // Last page. } $result = array( 'gopage' => $gopage, 'warnings' => $warnings ); return $result; }
php
public static function launch_feedback($feedbackid, $courseid = 0) { global $PAGE; $params = array('feedbackid' => $feedbackid, 'courseid' => $courseid); $params = self::validate_parameters(self::launch_feedback_parameters(), $params); $warnings = array(); list($feedback, $course, $cm, $context, $completioncourse) = self::validate_feedback($params['feedbackid'], $params['courseid']); // Check we can do a new submission (or continue an existing). $feedbackcompletion = self::validate_feedback_access($feedback, $completioncourse, $cm, $context, true); $gopage = $feedbackcompletion->get_resume_page(); if ($gopage === null) { $gopage = -1; // Last page. } $result = array( 'gopage' => $gopage, 'warnings' => $warnings ); return $result; }
[ "public", "static", "function", "launch_feedback", "(", "$", "feedbackid", ",", "$", "courseid", "=", "0", ")", "{", "global", "$", "PAGE", ";", "$", "params", "=", "array", "(", "'feedbackid'", "=>", "$", "feedbackid", ",", "'courseid'", "=>", "$", "courseid", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "launch_feedback_parameters", "(", ")", ",", "$", "params", ")", ";", "$", "warnings", "=", "array", "(", ")", ";", "list", "(", "$", "feedback", ",", "$", "course", ",", "$", "cm", ",", "$", "context", ",", "$", "completioncourse", ")", "=", "self", "::", "validate_feedback", "(", "$", "params", "[", "'feedbackid'", "]", ",", "$", "params", "[", "'courseid'", "]", ")", ";", "// Check we can do a new submission (or continue an existing).", "$", "feedbackcompletion", "=", "self", "::", "validate_feedback_access", "(", "$", "feedback", ",", "$", "completioncourse", ",", "$", "cm", ",", "$", "context", ",", "true", ")", ";", "$", "gopage", "=", "$", "feedbackcompletion", "->", "get_resume_page", "(", ")", ";", "if", "(", "$", "gopage", "===", "null", ")", "{", "$", "gopage", "=", "-", "1", ";", "// Last page.", "}", "$", "result", "=", "array", "(", "'gopage'", "=>", "$", "gopage", ",", "'warnings'", "=>", "$", "warnings", ")", ";", "return", "$", "result", ";", "}" ]
Starts or continues a feedback submission @param array $feedbackid feedback instance id @param int $courseid course where user completes a feedback (for site feedbacks only). @return array of warnings and launch information @since Moodle 3.3
[ "Starts", "or", "continues", "a", "feedback", "submission" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/external.php#L518-L540
216,469
moodle/moodle
mod/feedback/classes/external.php
mod_feedback_external.get_page_items
public static function get_page_items($feedbackid, $page, $courseid = 0) { global $PAGE; $params = array('feedbackid' => $feedbackid, 'page' => $page, 'courseid' => $courseid); $params = self::validate_parameters(self::get_page_items_parameters(), $params); $warnings = array(); list($feedback, $course, $cm, $context, $completioncourse) = self::validate_feedback($params['feedbackid'], $params['courseid']); $feedbackcompletion = new mod_feedback_completion($feedback, $cm, $completioncourse->id); $page = $params['page']; $pages = $feedbackcompletion->get_pages(); $pageitems = $pages[$page]; $hasnextpage = $page < count($pages) - 1; // Until we complete this page we can not trust get_next_page(). $hasprevpage = $page && ($feedbackcompletion->get_previous_page($page, false) !== null); $returneditems = array(); foreach ($pageitems as $item) { $itemnumber = empty($item->itemnr) ? null : $item->itemnr; unset($item->itemnr); // Added by the function, not part of the record. $exporter = new feedback_item_exporter($item, array('context' => $context, 'itemnumber' => $itemnumber)); $returneditems[] = $exporter->export($PAGE->get_renderer('core')); } $result = array( 'items' => $returneditems, 'hasprevpage' => $hasprevpage, 'hasnextpage' => $hasnextpage, 'warnings' => $warnings ); return $result; }
php
public static function get_page_items($feedbackid, $page, $courseid = 0) { global $PAGE; $params = array('feedbackid' => $feedbackid, 'page' => $page, 'courseid' => $courseid); $params = self::validate_parameters(self::get_page_items_parameters(), $params); $warnings = array(); list($feedback, $course, $cm, $context, $completioncourse) = self::validate_feedback($params['feedbackid'], $params['courseid']); $feedbackcompletion = new mod_feedback_completion($feedback, $cm, $completioncourse->id); $page = $params['page']; $pages = $feedbackcompletion->get_pages(); $pageitems = $pages[$page]; $hasnextpage = $page < count($pages) - 1; // Until we complete this page we can not trust get_next_page(). $hasprevpage = $page && ($feedbackcompletion->get_previous_page($page, false) !== null); $returneditems = array(); foreach ($pageitems as $item) { $itemnumber = empty($item->itemnr) ? null : $item->itemnr; unset($item->itemnr); // Added by the function, not part of the record. $exporter = new feedback_item_exporter($item, array('context' => $context, 'itemnumber' => $itemnumber)); $returneditems[] = $exporter->export($PAGE->get_renderer('core')); } $result = array( 'items' => $returneditems, 'hasprevpage' => $hasprevpage, 'hasnextpage' => $hasnextpage, 'warnings' => $warnings ); return $result; }
[ "public", "static", "function", "get_page_items", "(", "$", "feedbackid", ",", "$", "page", ",", "$", "courseid", "=", "0", ")", "{", "global", "$", "PAGE", ";", "$", "params", "=", "array", "(", "'feedbackid'", "=>", "$", "feedbackid", ",", "'page'", "=>", "$", "page", ",", "'courseid'", "=>", "$", "courseid", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_page_items_parameters", "(", ")", ",", "$", "params", ")", ";", "$", "warnings", "=", "array", "(", ")", ";", "list", "(", "$", "feedback", ",", "$", "course", ",", "$", "cm", ",", "$", "context", ",", "$", "completioncourse", ")", "=", "self", "::", "validate_feedback", "(", "$", "params", "[", "'feedbackid'", "]", ",", "$", "params", "[", "'courseid'", "]", ")", ";", "$", "feedbackcompletion", "=", "new", "mod_feedback_completion", "(", "$", "feedback", ",", "$", "cm", ",", "$", "completioncourse", "->", "id", ")", ";", "$", "page", "=", "$", "params", "[", "'page'", "]", ";", "$", "pages", "=", "$", "feedbackcompletion", "->", "get_pages", "(", ")", ";", "$", "pageitems", "=", "$", "pages", "[", "$", "page", "]", ";", "$", "hasnextpage", "=", "$", "page", "<", "count", "(", "$", "pages", ")", "-", "1", ";", "// Until we complete this page we can not trust get_next_page().", "$", "hasprevpage", "=", "$", "page", "&&", "(", "$", "feedbackcompletion", "->", "get_previous_page", "(", "$", "page", ",", "false", ")", "!==", "null", ")", ";", "$", "returneditems", "=", "array", "(", ")", ";", "foreach", "(", "$", "pageitems", "as", "$", "item", ")", "{", "$", "itemnumber", "=", "empty", "(", "$", "item", "->", "itemnr", ")", "?", "null", ":", "$", "item", "->", "itemnr", ";", "unset", "(", "$", "item", "->", "itemnr", ")", ";", "// Added by the function, not part of the record.", "$", "exporter", "=", "new", "feedback_item_exporter", "(", "$", "item", ",", "array", "(", "'context'", "=>", "$", "context", ",", "'itemnumber'", "=>", "$", "itemnumber", ")", ")", ";", "$", "returneditems", "[", "]", "=", "$", "exporter", "->", "export", "(", "$", "PAGE", "->", "get_renderer", "(", "'core'", ")", ")", ";", "}", "$", "result", "=", "array", "(", "'items'", "=>", "$", "returneditems", ",", "'hasprevpage'", "=>", "$", "hasprevpage", ",", "'hasnextpage'", "=>", "$", "hasnextpage", ",", "'warnings'", "=>", "$", "warnings", ")", ";", "return", "$", "result", ";", "}" ]
Get a single feedback page items. @param int $feedbackid feedback instance id @param int $page the page to get starting by 0 @param int $courseid course where user completes the feedback (for site feedbacks only) @return array of warnings and launch information @since Moodle 3.3
[ "Get", "a", "single", "feedback", "page", "items", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/external.php#L583-L616
216,470
moodle/moodle
mod/feedback/classes/external.php
mod_feedback_external.get_page_items_returns
public static function get_page_items_returns() { return new external_single_structure( array( 'items' => new external_multiple_structure( feedback_item_exporter::get_read_structure() ), 'hasprevpage' => new external_value(PARAM_BOOL, 'Whether is a previous page.'), 'hasnextpage' => new external_value(PARAM_BOOL, 'Whether there are more pages.'), 'warnings' => new external_warnings(), ) ); }
php
public static function get_page_items_returns() { return new external_single_structure( array( 'items' => new external_multiple_structure( feedback_item_exporter::get_read_structure() ), 'hasprevpage' => new external_value(PARAM_BOOL, 'Whether is a previous page.'), 'hasnextpage' => new external_value(PARAM_BOOL, 'Whether there are more pages.'), 'warnings' => new external_warnings(), ) ); }
[ "public", "static", "function", "get_page_items_returns", "(", ")", "{", "return", "new", "external_single_structure", "(", "array", "(", "'items'", "=>", "new", "external_multiple_structure", "(", "feedback_item_exporter", "::", "get_read_structure", "(", ")", ")", ",", "'hasprevpage'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'Whether is a previous page.'", ")", ",", "'hasnextpage'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'Whether there are more pages.'", ")", ",", "'warnings'", "=>", "new", "external_warnings", "(", ")", ",", ")", ")", ";", "}" ]
Describes the get_page_items return value. @return external_single_structure @since Moodle 3.3
[ "Describes", "the", "get_page_items", "return", "value", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/external.php#L624-L635
216,471
moodle/moodle
mod/feedback/classes/external.php
mod_feedback_external.process_page
public static function process_page($feedbackid, $page, $responses = [], $goprevious = false, $courseid = 0) { global $USER, $SESSION; $params = array('feedbackid' => $feedbackid, 'page' => $page, 'responses' => $responses, 'goprevious' => $goprevious, 'courseid' => $courseid); $params = self::validate_parameters(self::process_page_parameters(), $params); $warnings = array(); $siteaftersubmit = $completionpagecontents = ''; list($feedback, $course, $cm, $context, $completioncourse) = self::validate_feedback($params['feedbackid'], $params['courseid']); // Check we can do a new submission (or continue an existing). $feedbackcompletion = self::validate_feedback_access($feedback, $completioncourse, $cm, $context, true); // Create the $_POST object required by the feedback question engine. $_POST = array(); foreach ($responses as $response) { // First check if we are handling array parameters. if (preg_match('/(.+)\[(.+)\]$/', $response['name'], $matches)) { $_POST[$matches[1]][$matches[2]] = $response['value']; } else { $_POST[$response['name']] = $response['value']; } } // Force fields. $_POST['id'] = $cm->id; $_POST['courseid'] = $courseid; $_POST['gopage'] = $params['page']; $_POST['_qf__mod_feedback_complete_form'] = 1; // Determine where to go, backwards or forward. if (!$params['goprevious']) { $_POST['gonextpage'] = 1; // Even if we are saving values we need this set. if ($feedbackcompletion->get_next_page($params['page'], false) === null) { $_POST['savevalues'] = 1; // If there is no next page, it means we are finishing the feedback. } } // Ignore sesskey (deep in some APIs), the request is already validated. $USER->ignoresesskey = true; feedback_init_feedback_session(); $SESSION->feedback->is_started = true; $feedbackcompletion->process_page($params['page'], $params['goprevious']); $completed = $feedbackcompletion->just_completed(); if ($completed) { $jumpto = 0; if ($feedback->page_after_submit) { $completionpagecontents = $feedbackcompletion->page_after_submit(); } if ($feedback->site_after_submit) { $siteaftersubmit = feedback_encode_target_url($feedback->site_after_submit); } } else { $jumpto = $feedbackcompletion->get_jumpto(); } $result = array( 'jumpto' => $jumpto, 'completed' => $completed, 'completionpagecontents' => $completionpagecontents, 'siteaftersubmit' => $siteaftersubmit, 'warnings' => $warnings ); return $result; }
php
public static function process_page($feedbackid, $page, $responses = [], $goprevious = false, $courseid = 0) { global $USER, $SESSION; $params = array('feedbackid' => $feedbackid, 'page' => $page, 'responses' => $responses, 'goprevious' => $goprevious, 'courseid' => $courseid); $params = self::validate_parameters(self::process_page_parameters(), $params); $warnings = array(); $siteaftersubmit = $completionpagecontents = ''; list($feedback, $course, $cm, $context, $completioncourse) = self::validate_feedback($params['feedbackid'], $params['courseid']); // Check we can do a new submission (or continue an existing). $feedbackcompletion = self::validate_feedback_access($feedback, $completioncourse, $cm, $context, true); // Create the $_POST object required by the feedback question engine. $_POST = array(); foreach ($responses as $response) { // First check if we are handling array parameters. if (preg_match('/(.+)\[(.+)\]$/', $response['name'], $matches)) { $_POST[$matches[1]][$matches[2]] = $response['value']; } else { $_POST[$response['name']] = $response['value']; } } // Force fields. $_POST['id'] = $cm->id; $_POST['courseid'] = $courseid; $_POST['gopage'] = $params['page']; $_POST['_qf__mod_feedback_complete_form'] = 1; // Determine where to go, backwards or forward. if (!$params['goprevious']) { $_POST['gonextpage'] = 1; // Even if we are saving values we need this set. if ($feedbackcompletion->get_next_page($params['page'], false) === null) { $_POST['savevalues'] = 1; // If there is no next page, it means we are finishing the feedback. } } // Ignore sesskey (deep in some APIs), the request is already validated. $USER->ignoresesskey = true; feedback_init_feedback_session(); $SESSION->feedback->is_started = true; $feedbackcompletion->process_page($params['page'], $params['goprevious']); $completed = $feedbackcompletion->just_completed(); if ($completed) { $jumpto = 0; if ($feedback->page_after_submit) { $completionpagecontents = $feedbackcompletion->page_after_submit(); } if ($feedback->site_after_submit) { $siteaftersubmit = feedback_encode_target_url($feedback->site_after_submit); } } else { $jumpto = $feedbackcompletion->get_jumpto(); } $result = array( 'jumpto' => $jumpto, 'completed' => $completed, 'completionpagecontents' => $completionpagecontents, 'siteaftersubmit' => $siteaftersubmit, 'warnings' => $warnings ); return $result; }
[ "public", "static", "function", "process_page", "(", "$", "feedbackid", ",", "$", "page", ",", "$", "responses", "=", "[", "]", ",", "$", "goprevious", "=", "false", ",", "$", "courseid", "=", "0", ")", "{", "global", "$", "USER", ",", "$", "SESSION", ";", "$", "params", "=", "array", "(", "'feedbackid'", "=>", "$", "feedbackid", ",", "'page'", "=>", "$", "page", ",", "'responses'", "=>", "$", "responses", ",", "'goprevious'", "=>", "$", "goprevious", ",", "'courseid'", "=>", "$", "courseid", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "process_page_parameters", "(", ")", ",", "$", "params", ")", ";", "$", "warnings", "=", "array", "(", ")", ";", "$", "siteaftersubmit", "=", "$", "completionpagecontents", "=", "''", ";", "list", "(", "$", "feedback", ",", "$", "course", ",", "$", "cm", ",", "$", "context", ",", "$", "completioncourse", ")", "=", "self", "::", "validate_feedback", "(", "$", "params", "[", "'feedbackid'", "]", ",", "$", "params", "[", "'courseid'", "]", ")", ";", "// Check we can do a new submission (or continue an existing).", "$", "feedbackcompletion", "=", "self", "::", "validate_feedback_access", "(", "$", "feedback", ",", "$", "completioncourse", ",", "$", "cm", ",", "$", "context", ",", "true", ")", ";", "// Create the $_POST object required by the feedback question engine.", "$", "_POST", "=", "array", "(", ")", ";", "foreach", "(", "$", "responses", "as", "$", "response", ")", "{", "// First check if we are handling array parameters.", "if", "(", "preg_match", "(", "'/(.+)\\[(.+)\\]$/'", ",", "$", "response", "[", "'name'", "]", ",", "$", "matches", ")", ")", "{", "$", "_POST", "[", "$", "matches", "[", "1", "]", "]", "[", "$", "matches", "[", "2", "]", "]", "=", "$", "response", "[", "'value'", "]", ";", "}", "else", "{", "$", "_POST", "[", "$", "response", "[", "'name'", "]", "]", "=", "$", "response", "[", "'value'", "]", ";", "}", "}", "// Force fields.", "$", "_POST", "[", "'id'", "]", "=", "$", "cm", "->", "id", ";", "$", "_POST", "[", "'courseid'", "]", "=", "$", "courseid", ";", "$", "_POST", "[", "'gopage'", "]", "=", "$", "params", "[", "'page'", "]", ";", "$", "_POST", "[", "'_qf__mod_feedback_complete_form'", "]", "=", "1", ";", "// Determine where to go, backwards or forward.", "if", "(", "!", "$", "params", "[", "'goprevious'", "]", ")", "{", "$", "_POST", "[", "'gonextpage'", "]", "=", "1", ";", "// Even if we are saving values we need this set.", "if", "(", "$", "feedbackcompletion", "->", "get_next_page", "(", "$", "params", "[", "'page'", "]", ",", "false", ")", "===", "null", ")", "{", "$", "_POST", "[", "'savevalues'", "]", "=", "1", ";", "// If there is no next page, it means we are finishing the feedback.", "}", "}", "// Ignore sesskey (deep in some APIs), the request is already validated.", "$", "USER", "->", "ignoresesskey", "=", "true", ";", "feedback_init_feedback_session", "(", ")", ";", "$", "SESSION", "->", "feedback", "->", "is_started", "=", "true", ";", "$", "feedbackcompletion", "->", "process_page", "(", "$", "params", "[", "'page'", "]", ",", "$", "params", "[", "'goprevious'", "]", ")", ";", "$", "completed", "=", "$", "feedbackcompletion", "->", "just_completed", "(", ")", ";", "if", "(", "$", "completed", ")", "{", "$", "jumpto", "=", "0", ";", "if", "(", "$", "feedback", "->", "page_after_submit", ")", "{", "$", "completionpagecontents", "=", "$", "feedbackcompletion", "->", "page_after_submit", "(", ")", ";", "}", "if", "(", "$", "feedback", "->", "site_after_submit", ")", "{", "$", "siteaftersubmit", "=", "feedback_encode_target_url", "(", "$", "feedback", "->", "site_after_submit", ")", ";", "}", "}", "else", "{", "$", "jumpto", "=", "$", "feedbackcompletion", "->", "get_jumpto", "(", ")", ";", "}", "$", "result", "=", "array", "(", "'jumpto'", "=>", "$", "jumpto", ",", "'completed'", "=>", "$", "completed", ",", "'completionpagecontents'", "=>", "$", "completionpagecontents", ",", "'siteaftersubmit'", "=>", "$", "siteaftersubmit", ",", "'warnings'", "=>", "$", "warnings", ")", ";", "return", "$", "result", ";", "}" ]
Process a jump between pages. @param array $feedbackid feedback instance id @param array $page the page being processed @param array $responses the responses to be processed @param bool $goprevious whether we want to jump to previous page @param int $courseid course where user completes the feedback (for site feedbacks only) @return array of warnings and launch information @since Moodle 3.3
[ "Process", "a", "jump", "between", "pages", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/external.php#L674-L740
216,472
moodle/moodle
mod/feedback/classes/external.php
mod_feedback_external.get_analysis_parameters
public static function get_analysis_parameters() { return new external_function_parameters ( array( 'feedbackid' => new external_value(PARAM_INT, 'Feedback instance id'), 'groupid' => new external_value(PARAM_INT, 'Group id, 0 means that the function will determine the user group', VALUE_DEFAULT, 0), 'courseid' => new external_value(PARAM_INT, 'Course where user completes the feedback (for site feedbacks only).', VALUE_DEFAULT, 0), ) ); }
php
public static function get_analysis_parameters() { return new external_function_parameters ( array( 'feedbackid' => new external_value(PARAM_INT, 'Feedback instance id'), 'groupid' => new external_value(PARAM_INT, 'Group id, 0 means that the function will determine the user group', VALUE_DEFAULT, 0), 'courseid' => new external_value(PARAM_INT, 'Course where user completes the feedback (for site feedbacks only).', VALUE_DEFAULT, 0), ) ); }
[ "public", "static", "function", "get_analysis_parameters", "(", ")", "{", "return", "new", "external_function_parameters", "(", "array", "(", "'feedbackid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Feedback instance id'", ")", ",", "'groupid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Group id, 0 means that the function will determine the user group'", ",", "VALUE_DEFAULT", ",", "0", ")", ",", "'courseid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Course where user completes the feedback (for site feedbacks only).'", ",", "VALUE_DEFAULT", ",", "0", ")", ",", ")", ")", ";", "}" ]
Describes the parameters for get_analysis. @return external_function_parameters @since Moodle 3.3
[ "Describes", "the", "parameters", "for", "get_analysis", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/external.php#L766-L776
216,473
moodle/moodle
mod/feedback/classes/external.php
mod_feedback_external.get_analysis_returns
public static function get_analysis_returns() { return new external_single_structure( array( 'completedcount' => new external_value(PARAM_INT, 'Number of completed submissions.'), 'itemscount' => new external_value(PARAM_INT, 'Number of items (questions).'), 'itemsdata' => new external_multiple_structure( new external_single_structure( array( 'item' => feedback_item_exporter::get_read_structure(), 'data' => new external_multiple_structure( new external_value(PARAM_RAW, 'The analysis data (can be json encoded)') ), ) ) ), 'warnings' => new external_warnings(), ) ); }
php
public static function get_analysis_returns() { return new external_single_structure( array( 'completedcount' => new external_value(PARAM_INT, 'Number of completed submissions.'), 'itemscount' => new external_value(PARAM_INT, 'Number of items (questions).'), 'itemsdata' => new external_multiple_structure( new external_single_structure( array( 'item' => feedback_item_exporter::get_read_structure(), 'data' => new external_multiple_structure( new external_value(PARAM_RAW, 'The analysis data (can be json encoded)') ), ) ) ), 'warnings' => new external_warnings(), ) ); }
[ "public", "static", "function", "get_analysis_returns", "(", ")", "{", "return", "new", "external_single_structure", "(", "array", "(", "'completedcount'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Number of completed submissions.'", ")", ",", "'itemscount'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Number of items (questions).'", ")", ",", "'itemsdata'", "=>", "new", "external_multiple_structure", "(", "new", "external_single_structure", "(", "array", "(", "'item'", "=>", "feedback_item_exporter", "::", "get_read_structure", "(", ")", ",", "'data'", "=>", "new", "external_multiple_structure", "(", "new", "external_value", "(", "PARAM_RAW", ",", "'The analysis data (can be json encoded)'", ")", ")", ",", ")", ")", ")", ",", "'warnings'", "=>", "new", "external_warnings", "(", ")", ",", ")", ")", ";", "}" ]
Describes the get_analysis return value. @return external_single_structure @since Moodle 3.3
[ "Describes", "the", "get_analysis", "return", "value", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/external.php#L872-L890
216,474
moodle/moodle
mod/feedback/classes/external.php
mod_feedback_external.get_unfinished_responses
public static function get_unfinished_responses($feedbackid, $courseid = 0) { global $PAGE; $params = array('feedbackid' => $feedbackid, 'courseid' => $courseid); $params = self::validate_parameters(self::get_unfinished_responses_parameters(), $params); $warnings = $itemsdata = array(); list($feedback, $course, $cm, $context, $completioncourse) = self::validate_feedback($params['feedbackid'], $params['courseid']); $feedbackcompletion = new mod_feedback_completion($feedback, $cm, $completioncourse->id); $responses = array(); $unfinished = $feedbackcompletion->get_unfinished_responses(); foreach ($unfinished as $u) { $exporter = new feedback_valuetmp_exporter($u); $responses[] = $exporter->export($PAGE->get_renderer('core')); } $result = array( 'responses' => $responses, 'warnings' => $warnings ); return $result; }
php
public static function get_unfinished_responses($feedbackid, $courseid = 0) { global $PAGE; $params = array('feedbackid' => $feedbackid, 'courseid' => $courseid); $params = self::validate_parameters(self::get_unfinished_responses_parameters(), $params); $warnings = $itemsdata = array(); list($feedback, $course, $cm, $context, $completioncourse) = self::validate_feedback($params['feedbackid'], $params['courseid']); $feedbackcompletion = new mod_feedback_completion($feedback, $cm, $completioncourse->id); $responses = array(); $unfinished = $feedbackcompletion->get_unfinished_responses(); foreach ($unfinished as $u) { $exporter = new feedback_valuetmp_exporter($u); $responses[] = $exporter->export($PAGE->get_renderer('core')); } $result = array( 'responses' => $responses, 'warnings' => $warnings ); return $result; }
[ "public", "static", "function", "get_unfinished_responses", "(", "$", "feedbackid", ",", "$", "courseid", "=", "0", ")", "{", "global", "$", "PAGE", ";", "$", "params", "=", "array", "(", "'feedbackid'", "=>", "$", "feedbackid", ",", "'courseid'", "=>", "$", "courseid", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_unfinished_responses_parameters", "(", ")", ",", "$", "params", ")", ";", "$", "warnings", "=", "$", "itemsdata", "=", "array", "(", ")", ";", "list", "(", "$", "feedback", ",", "$", "course", ",", "$", "cm", ",", "$", "context", ",", "$", "completioncourse", ")", "=", "self", "::", "validate_feedback", "(", "$", "params", "[", "'feedbackid'", "]", ",", "$", "params", "[", "'courseid'", "]", ")", ";", "$", "feedbackcompletion", "=", "new", "mod_feedback_completion", "(", "$", "feedback", ",", "$", "cm", ",", "$", "completioncourse", "->", "id", ")", ";", "$", "responses", "=", "array", "(", ")", ";", "$", "unfinished", "=", "$", "feedbackcompletion", "->", "get_unfinished_responses", "(", ")", ";", "foreach", "(", "$", "unfinished", "as", "$", "u", ")", "{", "$", "exporter", "=", "new", "feedback_valuetmp_exporter", "(", "$", "u", ")", ";", "$", "responses", "[", "]", "=", "$", "exporter", "->", "export", "(", "$", "PAGE", "->", "get_renderer", "(", "'core'", ")", ")", ";", "}", "$", "result", "=", "array", "(", "'responses'", "=>", "$", "responses", ",", "'warnings'", "=>", "$", "warnings", ")", ";", "return", "$", "result", ";", "}" ]
Retrieves responses from the current unfinished attempt. @param array $feedbackid feedback instance id @param int $courseid course where user completes the feedback (for site feedbacks only) @return array of warnings and launch information @since Moodle 3.3
[ "Retrieves", "responses", "from", "the", "current", "unfinished", "attempt", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/external.php#L916-L939
216,475
moodle/moodle
mod/feedback/classes/external.php
mod_feedback_external.get_finished_responses
public static function get_finished_responses($feedbackid, $courseid = 0) { global $PAGE; $params = array('feedbackid' => $feedbackid, 'courseid' => $courseid); $params = self::validate_parameters(self::get_finished_responses_parameters(), $params); $warnings = $itemsdata = array(); list($feedback, $course, $cm, $context, $completioncourse) = self::validate_feedback($params['feedbackid'], $params['courseid']); $feedbackcompletion = new mod_feedback_completion($feedback, $cm, $completioncourse->id); $responses = array(); // Load and get the responses from the last completed feedback. $feedbackcompletion->find_last_completed(); $unfinished = $feedbackcompletion->get_finished_responses(); foreach ($unfinished as $u) { $exporter = new feedback_value_exporter($u); $responses[] = $exporter->export($PAGE->get_renderer('core')); } $result = array( 'responses' => $responses, 'warnings' => $warnings ); return $result; }
php
public static function get_finished_responses($feedbackid, $courseid = 0) { global $PAGE; $params = array('feedbackid' => $feedbackid, 'courseid' => $courseid); $params = self::validate_parameters(self::get_finished_responses_parameters(), $params); $warnings = $itemsdata = array(); list($feedback, $course, $cm, $context, $completioncourse) = self::validate_feedback($params['feedbackid'], $params['courseid']); $feedbackcompletion = new mod_feedback_completion($feedback, $cm, $completioncourse->id); $responses = array(); // Load and get the responses from the last completed feedback. $feedbackcompletion->find_last_completed(); $unfinished = $feedbackcompletion->get_finished_responses(); foreach ($unfinished as $u) { $exporter = new feedback_value_exporter($u); $responses[] = $exporter->export($PAGE->get_renderer('core')); } $result = array( 'responses' => $responses, 'warnings' => $warnings ); return $result; }
[ "public", "static", "function", "get_finished_responses", "(", "$", "feedbackid", ",", "$", "courseid", "=", "0", ")", "{", "global", "$", "PAGE", ";", "$", "params", "=", "array", "(", "'feedbackid'", "=>", "$", "feedbackid", ",", "'courseid'", "=>", "$", "courseid", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_finished_responses_parameters", "(", ")", ",", "$", "params", ")", ";", "$", "warnings", "=", "$", "itemsdata", "=", "array", "(", ")", ";", "list", "(", "$", "feedback", ",", "$", "course", ",", "$", "cm", ",", "$", "context", ",", "$", "completioncourse", ")", "=", "self", "::", "validate_feedback", "(", "$", "params", "[", "'feedbackid'", "]", ",", "$", "params", "[", "'courseid'", "]", ")", ";", "$", "feedbackcompletion", "=", "new", "mod_feedback_completion", "(", "$", "feedback", ",", "$", "cm", ",", "$", "completioncourse", "->", "id", ")", ";", "$", "responses", "=", "array", "(", ")", ";", "// Load and get the responses from the last completed feedback.", "$", "feedbackcompletion", "->", "find_last_completed", "(", ")", ";", "$", "unfinished", "=", "$", "feedbackcompletion", "->", "get_finished_responses", "(", ")", ";", "foreach", "(", "$", "unfinished", "as", "$", "u", ")", "{", "$", "exporter", "=", "new", "feedback_value_exporter", "(", "$", "u", ")", ";", "$", "responses", "[", "]", "=", "$", "exporter", "->", "export", "(", "$", "PAGE", "->", "get_renderer", "(", "'core'", ")", ")", ";", "}", "$", "result", "=", "array", "(", "'responses'", "=>", "$", "responses", ",", "'warnings'", "=>", "$", "warnings", ")", ";", "return", "$", "result", ";", "}" ]
Retrieves responses from the last finished attempt. @param array $feedbackid feedback instance id @param int $courseid course where user completes the feedback (for site feedbacks only) @return array of warnings and the responses @since Moodle 3.3
[ "Retrieves", "responses", "from", "the", "last", "finished", "attempt", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/external.php#L982-L1007
216,476
moodle/moodle
mod/feedback/classes/external.php
mod_feedback_external.get_non_respondents_parameters
public static function get_non_respondents_parameters() { return new external_function_parameters ( array( 'feedbackid' => new external_value(PARAM_INT, 'Feedback instance id'), 'groupid' => new external_value(PARAM_INT, 'Group id, 0 means that the function will determine the user group.', VALUE_DEFAULT, 0), 'sort' => new external_value(PARAM_ALPHA, 'Sort param, must be firstname, lastname or lastaccess (default).', VALUE_DEFAULT, 'lastaccess'), 'page' => new external_value(PARAM_INT, 'The page of records to return.', VALUE_DEFAULT, 0), 'perpage' => new external_value(PARAM_INT, 'The number of records to return per page.', VALUE_DEFAULT, 0), 'courseid' => new external_value(PARAM_INT, 'Course where user completes the feedback (for site feedbacks only).', VALUE_DEFAULT, 0), ) ); }
php
public static function get_non_respondents_parameters() { return new external_function_parameters ( array( 'feedbackid' => new external_value(PARAM_INT, 'Feedback instance id'), 'groupid' => new external_value(PARAM_INT, 'Group id, 0 means that the function will determine the user group.', VALUE_DEFAULT, 0), 'sort' => new external_value(PARAM_ALPHA, 'Sort param, must be firstname, lastname or lastaccess (default).', VALUE_DEFAULT, 'lastaccess'), 'page' => new external_value(PARAM_INT, 'The page of records to return.', VALUE_DEFAULT, 0), 'perpage' => new external_value(PARAM_INT, 'The number of records to return per page.', VALUE_DEFAULT, 0), 'courseid' => new external_value(PARAM_INT, 'Course where user completes the feedback (for site feedbacks only).', VALUE_DEFAULT, 0), ) ); }
[ "public", "static", "function", "get_non_respondents_parameters", "(", ")", "{", "return", "new", "external_function_parameters", "(", "array", "(", "'feedbackid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Feedback instance id'", ")", ",", "'groupid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Group id, 0 means that the function will determine the user group.'", ",", "VALUE_DEFAULT", ",", "0", ")", ",", "'sort'", "=>", "new", "external_value", "(", "PARAM_ALPHA", ",", "'Sort param, must be firstname, lastname or lastaccess (default).'", ",", "VALUE_DEFAULT", ",", "'lastaccess'", ")", ",", "'page'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'The page of records to return.'", ",", "VALUE_DEFAULT", ",", "0", ")", ",", "'perpage'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'The number of records to return per page.'", ",", "VALUE_DEFAULT", ",", "0", ")", ",", "'courseid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Course where user completes the feedback (for site feedbacks only).'", ",", "VALUE_DEFAULT", ",", "0", ")", ",", ")", ")", ";", "}" ]
Describes the parameters for get_non_respondents. @return external_function_parameters @since Moodle 3.3
[ "Describes", "the", "parameters", "for", "get_non_respondents", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/external.php#L1032-L1046
216,477
moodle/moodle
mod/feedback/classes/external.php
mod_feedback_external.get_non_respondents
public static function get_non_respondents($feedbackid, $groupid = 0, $sort = 'lastaccess', $page = 0, $perpage = 0, $courseid = 0) { global $CFG; require_once($CFG->dirroot . '/mod/feedback/lib.php'); $params = array('feedbackid' => $feedbackid, 'groupid' => $groupid, 'sort' => $sort, 'page' => $page, 'perpage' => $perpage, 'courseid' => $courseid); $params = self::validate_parameters(self::get_non_respondents_parameters(), $params); $warnings = $nonrespondents = array(); list($feedback, $course, $cm, $context, $completioncourse) = self::validate_feedback($params['feedbackid'], $params['courseid']); $feedbackcompletion = new mod_feedback_completion($feedback, $cm, $completioncourse->id); $completioncourseid = $feedbackcompletion->get_courseid(); if ($feedback->anonymous != FEEDBACK_ANONYMOUS_NO || $feedback->course == SITEID) { throw new moodle_exception('anonymous', 'feedback'); } // Check permissions. require_capability('mod/feedback:viewreports', $context); if (!empty($params['groupid'])) { $groupid = $params['groupid']; // Determine is the group is visible to user. if (!groups_group_visible($groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } else { // Check to see if groups are being used here. if ($groupmode = groups_get_activity_groupmode($cm)) { $groupid = groups_get_activity_group($cm); // Determine is the group is visible to user (this is particullary for the group 0 -> all groups). if (!groups_group_visible($groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } else { $groupid = 0; } } if ($params['sort'] !== 'firstname' && $params['sort'] !== 'lastname' && $params['sort'] !== 'lastaccess') { throw new invalid_parameter_exception('Invalid sort param, must be firstname, lastname or lastaccess.'); } // Check if we are page filtering. if ($params['perpage'] == 0) { $page = $params['page']; $perpage = FEEDBACK_DEFAULT_PAGE_COUNT; } else { $perpage = $params['perpage']; $page = $perpage * $params['page']; } $users = feedback_get_incomplete_users($cm, $groupid, $params['sort'], $page, $perpage, true); foreach ($users as $user) { $nonrespondents[] = [ 'courseid' => $completioncourseid, 'userid' => $user->id, 'fullname' => fullname($user), 'started' => $user->feedbackstarted ]; } $result = array( 'users' => $nonrespondents, 'total' => feedback_count_incomplete_users($cm, $groupid), 'warnings' => $warnings ); return $result; }
php
public static function get_non_respondents($feedbackid, $groupid = 0, $sort = 'lastaccess', $page = 0, $perpage = 0, $courseid = 0) { global $CFG; require_once($CFG->dirroot . '/mod/feedback/lib.php'); $params = array('feedbackid' => $feedbackid, 'groupid' => $groupid, 'sort' => $sort, 'page' => $page, 'perpage' => $perpage, 'courseid' => $courseid); $params = self::validate_parameters(self::get_non_respondents_parameters(), $params); $warnings = $nonrespondents = array(); list($feedback, $course, $cm, $context, $completioncourse) = self::validate_feedback($params['feedbackid'], $params['courseid']); $feedbackcompletion = new mod_feedback_completion($feedback, $cm, $completioncourse->id); $completioncourseid = $feedbackcompletion->get_courseid(); if ($feedback->anonymous != FEEDBACK_ANONYMOUS_NO || $feedback->course == SITEID) { throw new moodle_exception('anonymous', 'feedback'); } // Check permissions. require_capability('mod/feedback:viewreports', $context); if (!empty($params['groupid'])) { $groupid = $params['groupid']; // Determine is the group is visible to user. if (!groups_group_visible($groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } else { // Check to see if groups are being used here. if ($groupmode = groups_get_activity_groupmode($cm)) { $groupid = groups_get_activity_group($cm); // Determine is the group is visible to user (this is particullary for the group 0 -> all groups). if (!groups_group_visible($groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } else { $groupid = 0; } } if ($params['sort'] !== 'firstname' && $params['sort'] !== 'lastname' && $params['sort'] !== 'lastaccess') { throw new invalid_parameter_exception('Invalid sort param, must be firstname, lastname or lastaccess.'); } // Check if we are page filtering. if ($params['perpage'] == 0) { $page = $params['page']; $perpage = FEEDBACK_DEFAULT_PAGE_COUNT; } else { $perpage = $params['perpage']; $page = $perpage * $params['page']; } $users = feedback_get_incomplete_users($cm, $groupid, $params['sort'], $page, $perpage, true); foreach ($users as $user) { $nonrespondents[] = [ 'courseid' => $completioncourseid, 'userid' => $user->id, 'fullname' => fullname($user), 'started' => $user->feedbackstarted ]; } $result = array( 'users' => $nonrespondents, 'total' => feedback_count_incomplete_users($cm, $groupid), 'warnings' => $warnings ); return $result; }
[ "public", "static", "function", "get_non_respondents", "(", "$", "feedbackid", ",", "$", "groupid", "=", "0", ",", "$", "sort", "=", "'lastaccess'", ",", "$", "page", "=", "0", ",", "$", "perpage", "=", "0", ",", "$", "courseid", "=", "0", ")", "{", "global", "$", "CFG", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/mod/feedback/lib.php'", ")", ";", "$", "params", "=", "array", "(", "'feedbackid'", "=>", "$", "feedbackid", ",", "'groupid'", "=>", "$", "groupid", ",", "'sort'", "=>", "$", "sort", ",", "'page'", "=>", "$", "page", ",", "'perpage'", "=>", "$", "perpage", ",", "'courseid'", "=>", "$", "courseid", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_non_respondents_parameters", "(", ")", ",", "$", "params", ")", ";", "$", "warnings", "=", "$", "nonrespondents", "=", "array", "(", ")", ";", "list", "(", "$", "feedback", ",", "$", "course", ",", "$", "cm", ",", "$", "context", ",", "$", "completioncourse", ")", "=", "self", "::", "validate_feedback", "(", "$", "params", "[", "'feedbackid'", "]", ",", "$", "params", "[", "'courseid'", "]", ")", ";", "$", "feedbackcompletion", "=", "new", "mod_feedback_completion", "(", "$", "feedback", ",", "$", "cm", ",", "$", "completioncourse", "->", "id", ")", ";", "$", "completioncourseid", "=", "$", "feedbackcompletion", "->", "get_courseid", "(", ")", ";", "if", "(", "$", "feedback", "->", "anonymous", "!=", "FEEDBACK_ANONYMOUS_NO", "||", "$", "feedback", "->", "course", "==", "SITEID", ")", "{", "throw", "new", "moodle_exception", "(", "'anonymous'", ",", "'feedback'", ")", ";", "}", "// Check permissions.", "require_capability", "(", "'mod/feedback:viewreports'", ",", "$", "context", ")", ";", "if", "(", "!", "empty", "(", "$", "params", "[", "'groupid'", "]", ")", ")", "{", "$", "groupid", "=", "$", "params", "[", "'groupid'", "]", ";", "// Determine is the group is visible to user.", "if", "(", "!", "groups_group_visible", "(", "$", "groupid", ",", "$", "course", ",", "$", "cm", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'notingroup'", ")", ";", "}", "}", "else", "{", "// Check to see if groups are being used here.", "if", "(", "$", "groupmode", "=", "groups_get_activity_groupmode", "(", "$", "cm", ")", ")", "{", "$", "groupid", "=", "groups_get_activity_group", "(", "$", "cm", ")", ";", "// Determine is the group is visible to user (this is particullary for the group 0 -> all groups).", "if", "(", "!", "groups_group_visible", "(", "$", "groupid", ",", "$", "course", ",", "$", "cm", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'notingroup'", ")", ";", "}", "}", "else", "{", "$", "groupid", "=", "0", ";", "}", "}", "if", "(", "$", "params", "[", "'sort'", "]", "!==", "'firstname'", "&&", "$", "params", "[", "'sort'", "]", "!==", "'lastname'", "&&", "$", "params", "[", "'sort'", "]", "!==", "'lastaccess'", ")", "{", "throw", "new", "invalid_parameter_exception", "(", "'Invalid sort param, must be firstname, lastname or lastaccess.'", ")", ";", "}", "// Check if we are page filtering.", "if", "(", "$", "params", "[", "'perpage'", "]", "==", "0", ")", "{", "$", "page", "=", "$", "params", "[", "'page'", "]", ";", "$", "perpage", "=", "FEEDBACK_DEFAULT_PAGE_COUNT", ";", "}", "else", "{", "$", "perpage", "=", "$", "params", "[", "'perpage'", "]", ";", "$", "page", "=", "$", "perpage", "*", "$", "params", "[", "'page'", "]", ";", "}", "$", "users", "=", "feedback_get_incomplete_users", "(", "$", "cm", ",", "$", "groupid", ",", "$", "params", "[", "'sort'", "]", ",", "$", "page", ",", "$", "perpage", ",", "true", ")", ";", "foreach", "(", "$", "users", "as", "$", "user", ")", "{", "$", "nonrespondents", "[", "]", "=", "[", "'courseid'", "=>", "$", "completioncourseid", ",", "'userid'", "=>", "$", "user", "->", "id", ",", "'fullname'", "=>", "fullname", "(", "$", "user", ")", ",", "'started'", "=>", "$", "user", "->", "feedbackstarted", "]", ";", "}", "$", "result", "=", "array", "(", "'users'", "=>", "$", "nonrespondents", ",", "'total'", "=>", "feedback_count_incomplete_users", "(", "$", "cm", ",", "$", "groupid", ")", ",", "'warnings'", "=>", "$", "warnings", ")", ";", "return", "$", "result", ";", "}" ]
Retrieves a list of students who didn't submit the feedback. @param int $feedbackid feedback instance id @param int $groupid Group id, 0 means that the function will determine the user group' @param str $sort sort param, must be firstname, lastname or lastaccess (default) @param int $page the page of records to return @param int $perpage the number of records to return per page @param int $courseid course where user completes the feedback (for site feedbacks only) @return array of warnings and users ids @since Moodle 3.3
[ "Retrieves", "a", "list", "of", "students", "who", "didn", "t", "submit", "the", "feedback", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/external.php#L1060-L1130
216,478
moodle/moodle
mod/feedback/classes/external.php
mod_feedback_external.get_non_respondents_returns
public static function get_non_respondents_returns() { return new external_single_structure( array( 'users' => new external_multiple_structure( new external_single_structure( array( 'courseid' => new external_value(PARAM_INT, 'Course id'), 'userid' => new external_value(PARAM_INT, 'The user id'), 'fullname' => new external_value(PARAM_TEXT, 'User full name'), 'started' => new external_value(PARAM_BOOL, 'If the user has started the attempt'), ) ) ), 'total' => new external_value(PARAM_INT, 'Total number of non respondents'), 'warnings' => new external_warnings(), ) ); }
php
public static function get_non_respondents_returns() { return new external_single_structure( array( 'users' => new external_multiple_structure( new external_single_structure( array( 'courseid' => new external_value(PARAM_INT, 'Course id'), 'userid' => new external_value(PARAM_INT, 'The user id'), 'fullname' => new external_value(PARAM_TEXT, 'User full name'), 'started' => new external_value(PARAM_BOOL, 'If the user has started the attempt'), ) ) ), 'total' => new external_value(PARAM_INT, 'Total number of non respondents'), 'warnings' => new external_warnings(), ) ); }
[ "public", "static", "function", "get_non_respondents_returns", "(", ")", "{", "return", "new", "external_single_structure", "(", "array", "(", "'users'", "=>", "new", "external_multiple_structure", "(", "new", "external_single_structure", "(", "array", "(", "'courseid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Course id'", ")", ",", "'userid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'The user id'", ")", ",", "'fullname'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'User full name'", ")", ",", "'started'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'If the user has started the attempt'", ")", ",", ")", ")", ")", ",", "'total'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Total number of non respondents'", ")", ",", "'warnings'", "=>", "new", "external_warnings", "(", ")", ",", ")", ")", ";", "}" ]
Describes the get_non_respondents return value. @return external_single_structure @since Moodle 3.3
[ "Describes", "the", "get_non_respondents", "return", "value", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/external.php#L1138-L1155
216,479
moodle/moodle
mod/feedback/classes/external.php
mod_feedback_external.get_responses_analysis_parameters
public static function get_responses_analysis_parameters() { return new external_function_parameters ( array( 'feedbackid' => new external_value(PARAM_INT, 'Feedback instance id'), 'groupid' => new external_value(PARAM_INT, 'Group id, 0 means that the function will determine the user group', VALUE_DEFAULT, 0), 'page' => new external_value(PARAM_INT, 'The page of records to return.', VALUE_DEFAULT, 0), 'perpage' => new external_value(PARAM_INT, 'The number of records to return per page', VALUE_DEFAULT, 0), 'courseid' => new external_value(PARAM_INT, 'Course where user completes the feedback (for site feedbacks only).', VALUE_DEFAULT, 0), ) ); }
php
public static function get_responses_analysis_parameters() { return new external_function_parameters ( array( 'feedbackid' => new external_value(PARAM_INT, 'Feedback instance id'), 'groupid' => new external_value(PARAM_INT, 'Group id, 0 means that the function will determine the user group', VALUE_DEFAULT, 0), 'page' => new external_value(PARAM_INT, 'The page of records to return.', VALUE_DEFAULT, 0), 'perpage' => new external_value(PARAM_INT, 'The number of records to return per page', VALUE_DEFAULT, 0), 'courseid' => new external_value(PARAM_INT, 'Course where user completes the feedback (for site feedbacks only).', VALUE_DEFAULT, 0), ) ); }
[ "public", "static", "function", "get_responses_analysis_parameters", "(", ")", "{", "return", "new", "external_function_parameters", "(", "array", "(", "'feedbackid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Feedback instance id'", ")", ",", "'groupid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Group id, 0 means that the function will determine the user group'", ",", "VALUE_DEFAULT", ",", "0", ")", ",", "'page'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'The page of records to return.'", ",", "VALUE_DEFAULT", ",", "0", ")", ",", "'perpage'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'The number of records to return per page'", ",", "VALUE_DEFAULT", ",", "0", ")", ",", "'courseid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Course where user completes the feedback (for site feedbacks only).'", ",", "VALUE_DEFAULT", ",", "0", ")", ",", ")", ")", ";", "}" ]
Describes the parameters for get_responses_analysis. @return external_function_parameters @since Moodle 3.3
[ "Describes", "the", "parameters", "for", "get_responses_analysis", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/external.php#L1163-L1175
216,480
moodle/moodle
mod/feedback/classes/external.php
mod_feedback_external.get_responses_analysis
public static function get_responses_analysis($feedbackid, $groupid = 0, $page = 0, $perpage = 0, $courseid = 0) { $params = array('feedbackid' => $feedbackid, 'groupid' => $groupid, 'page' => $page, 'perpage' => $perpage, 'courseid' => $courseid); $params = self::validate_parameters(self::get_responses_analysis_parameters(), $params); $warnings = $itemsdata = array(); list($feedback, $course, $cm, $context, $completioncourse) = self::validate_feedback($params['feedbackid'], $params['courseid']); // Check permissions. require_capability('mod/feedback:viewreports', $context); if (!empty($params['groupid'])) { $groupid = $params['groupid']; // Determine is the group is visible to user. if (!groups_group_visible($groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } else { // Check to see if groups are being used here. if ($groupmode = groups_get_activity_groupmode($cm)) { $groupid = groups_get_activity_group($cm); // Determine is the group is visible to user (this is particullary for the group 0 -> all groups). if (!groups_group_visible($groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } else { $groupid = 0; } } $feedbackstructure = new mod_feedback_structure($feedback, $cm, $completioncourse->id); $responsestable = new mod_feedback_responses_table($feedbackstructure, $groupid); // Ensure responses number is correct prior returning them. $feedbackstructure->shuffle_anonym_responses(); $anonresponsestable = new mod_feedback_responses_anon_table($feedbackstructure, $groupid); $result = array( 'attempts' => $responsestable->export_external_structure($params['page'], $params['perpage']), 'totalattempts' => $responsestable->get_total_responses_count(), 'anonattempts' => $anonresponsestable->export_external_structure($params['page'], $params['perpage']), 'totalanonattempts' => $anonresponsestable->get_total_responses_count(), 'warnings' => $warnings ); return $result; }
php
public static function get_responses_analysis($feedbackid, $groupid = 0, $page = 0, $perpage = 0, $courseid = 0) { $params = array('feedbackid' => $feedbackid, 'groupid' => $groupid, 'page' => $page, 'perpage' => $perpage, 'courseid' => $courseid); $params = self::validate_parameters(self::get_responses_analysis_parameters(), $params); $warnings = $itemsdata = array(); list($feedback, $course, $cm, $context, $completioncourse) = self::validate_feedback($params['feedbackid'], $params['courseid']); // Check permissions. require_capability('mod/feedback:viewreports', $context); if (!empty($params['groupid'])) { $groupid = $params['groupid']; // Determine is the group is visible to user. if (!groups_group_visible($groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } else { // Check to see if groups are being used here. if ($groupmode = groups_get_activity_groupmode($cm)) { $groupid = groups_get_activity_group($cm); // Determine is the group is visible to user (this is particullary for the group 0 -> all groups). if (!groups_group_visible($groupid, $course, $cm)) { throw new moodle_exception('notingroup'); } } else { $groupid = 0; } } $feedbackstructure = new mod_feedback_structure($feedback, $cm, $completioncourse->id); $responsestable = new mod_feedback_responses_table($feedbackstructure, $groupid); // Ensure responses number is correct prior returning them. $feedbackstructure->shuffle_anonym_responses(); $anonresponsestable = new mod_feedback_responses_anon_table($feedbackstructure, $groupid); $result = array( 'attempts' => $responsestable->export_external_structure($params['page'], $params['perpage']), 'totalattempts' => $responsestable->get_total_responses_count(), 'anonattempts' => $anonresponsestable->export_external_structure($params['page'], $params['perpage']), 'totalanonattempts' => $anonresponsestable->get_total_responses_count(), 'warnings' => $warnings ); return $result; }
[ "public", "static", "function", "get_responses_analysis", "(", "$", "feedbackid", ",", "$", "groupid", "=", "0", ",", "$", "page", "=", "0", ",", "$", "perpage", "=", "0", ",", "$", "courseid", "=", "0", ")", "{", "$", "params", "=", "array", "(", "'feedbackid'", "=>", "$", "feedbackid", ",", "'groupid'", "=>", "$", "groupid", ",", "'page'", "=>", "$", "page", ",", "'perpage'", "=>", "$", "perpage", ",", "'courseid'", "=>", "$", "courseid", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_responses_analysis_parameters", "(", ")", ",", "$", "params", ")", ";", "$", "warnings", "=", "$", "itemsdata", "=", "array", "(", ")", ";", "list", "(", "$", "feedback", ",", "$", "course", ",", "$", "cm", ",", "$", "context", ",", "$", "completioncourse", ")", "=", "self", "::", "validate_feedback", "(", "$", "params", "[", "'feedbackid'", "]", ",", "$", "params", "[", "'courseid'", "]", ")", ";", "// Check permissions.", "require_capability", "(", "'mod/feedback:viewreports'", ",", "$", "context", ")", ";", "if", "(", "!", "empty", "(", "$", "params", "[", "'groupid'", "]", ")", ")", "{", "$", "groupid", "=", "$", "params", "[", "'groupid'", "]", ";", "// Determine is the group is visible to user.", "if", "(", "!", "groups_group_visible", "(", "$", "groupid", ",", "$", "course", ",", "$", "cm", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'notingroup'", ")", ";", "}", "}", "else", "{", "// Check to see if groups are being used here.", "if", "(", "$", "groupmode", "=", "groups_get_activity_groupmode", "(", "$", "cm", ")", ")", "{", "$", "groupid", "=", "groups_get_activity_group", "(", "$", "cm", ")", ";", "// Determine is the group is visible to user (this is particullary for the group 0 -> all groups).", "if", "(", "!", "groups_group_visible", "(", "$", "groupid", ",", "$", "course", ",", "$", "cm", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'notingroup'", ")", ";", "}", "}", "else", "{", "$", "groupid", "=", "0", ";", "}", "}", "$", "feedbackstructure", "=", "new", "mod_feedback_structure", "(", "$", "feedback", ",", "$", "cm", ",", "$", "completioncourse", "->", "id", ")", ";", "$", "responsestable", "=", "new", "mod_feedback_responses_table", "(", "$", "feedbackstructure", ",", "$", "groupid", ")", ";", "// Ensure responses number is correct prior returning them.", "$", "feedbackstructure", "->", "shuffle_anonym_responses", "(", ")", ";", "$", "anonresponsestable", "=", "new", "mod_feedback_responses_anon_table", "(", "$", "feedbackstructure", ",", "$", "groupid", ")", ";", "$", "result", "=", "array", "(", "'attempts'", "=>", "$", "responsestable", "->", "export_external_structure", "(", "$", "params", "[", "'page'", "]", ",", "$", "params", "[", "'perpage'", "]", ")", ",", "'totalattempts'", "=>", "$", "responsestable", "->", "get_total_responses_count", "(", ")", ",", "'anonattempts'", "=>", "$", "anonresponsestable", "->", "export_external_structure", "(", "$", "params", "[", "'page'", "]", ",", "$", "params", "[", "'perpage'", "]", ")", ",", "'totalanonattempts'", "=>", "$", "anonresponsestable", "->", "get_total_responses_count", "(", ")", ",", "'warnings'", "=>", "$", "warnings", ")", ";", "return", "$", "result", ";", "}" ]
Return the feedback user responses. @param int $feedbackid feedback instance id @param int $groupid Group id, 0 means that the function will determine the user group @param int $page the page of records to return @param int $perpage the number of records to return per page @param int $courseid course where user completes the feedback (for site feedbacks only) @return array of warnings and users attemps and responses @throws moodle_exception @since Moodle 3.3
[ "Return", "the", "feedback", "user", "responses", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/external.php#L1189-L1235
216,481
moodle/moodle
mod/feedback/classes/external.php
mod_feedback_external.get_responses_analysis_returns
public static function get_responses_analysis_returns() { $responsestructure = new external_multiple_structure( new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'Response id'), 'name' => new external_value(PARAM_RAW, 'Response name'), 'printval' => new external_value(PARAM_RAW, 'Response ready for output'), 'rawval' => new external_value(PARAM_RAW, 'Response raw value'), ) ) ); return new external_single_structure( array( 'attempts' => new external_multiple_structure( new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'Completed id'), 'courseid' => new external_value(PARAM_INT, 'Course id'), 'userid' => new external_value(PARAM_INT, 'User who responded'), 'timemodified' => new external_value(PARAM_INT, 'Time modified for the response'), 'fullname' => new external_value(PARAM_TEXT, 'User full name'), 'responses' => $responsestructure ) ) ), 'totalattempts' => new external_value(PARAM_INT, 'Total responses count.'), 'anonattempts' => new external_multiple_structure( new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'Completed id'), 'courseid' => new external_value(PARAM_INT, 'Course id'), 'number' => new external_value(PARAM_INT, 'Response number'), 'responses' => $responsestructure ) ) ), 'totalanonattempts' => new external_value(PARAM_INT, 'Total anonymous responses count.'), 'warnings' => new external_warnings(), ) ); }
php
public static function get_responses_analysis_returns() { $responsestructure = new external_multiple_structure( new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'Response id'), 'name' => new external_value(PARAM_RAW, 'Response name'), 'printval' => new external_value(PARAM_RAW, 'Response ready for output'), 'rawval' => new external_value(PARAM_RAW, 'Response raw value'), ) ) ); return new external_single_structure( array( 'attempts' => new external_multiple_structure( new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'Completed id'), 'courseid' => new external_value(PARAM_INT, 'Course id'), 'userid' => new external_value(PARAM_INT, 'User who responded'), 'timemodified' => new external_value(PARAM_INT, 'Time modified for the response'), 'fullname' => new external_value(PARAM_TEXT, 'User full name'), 'responses' => $responsestructure ) ) ), 'totalattempts' => new external_value(PARAM_INT, 'Total responses count.'), 'anonattempts' => new external_multiple_structure( new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'Completed id'), 'courseid' => new external_value(PARAM_INT, 'Course id'), 'number' => new external_value(PARAM_INT, 'Response number'), 'responses' => $responsestructure ) ) ), 'totalanonattempts' => new external_value(PARAM_INT, 'Total anonymous responses count.'), 'warnings' => new external_warnings(), ) ); }
[ "public", "static", "function", "get_responses_analysis_returns", "(", ")", "{", "$", "responsestructure", "=", "new", "external_multiple_structure", "(", "new", "external_single_structure", "(", "array", "(", "'id'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Response id'", ")", ",", "'name'", "=>", "new", "external_value", "(", "PARAM_RAW", ",", "'Response name'", ")", ",", "'printval'", "=>", "new", "external_value", "(", "PARAM_RAW", ",", "'Response ready for output'", ")", ",", "'rawval'", "=>", "new", "external_value", "(", "PARAM_RAW", ",", "'Response raw value'", ")", ",", ")", ")", ")", ";", "return", "new", "external_single_structure", "(", "array", "(", "'attempts'", "=>", "new", "external_multiple_structure", "(", "new", "external_single_structure", "(", "array", "(", "'id'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Completed id'", ")", ",", "'courseid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Course id'", ")", ",", "'userid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'User who responded'", ")", ",", "'timemodified'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Time modified for the response'", ")", ",", "'fullname'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'User full name'", ")", ",", "'responses'", "=>", "$", "responsestructure", ")", ")", ")", ",", "'totalattempts'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Total responses count.'", ")", ",", "'anonattempts'", "=>", "new", "external_multiple_structure", "(", "new", "external_single_structure", "(", "array", "(", "'id'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Completed id'", ")", ",", "'courseid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Course id'", ")", ",", "'number'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Response number'", ")", ",", "'responses'", "=>", "$", "responsestructure", ")", ")", ")", ",", "'totalanonattempts'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Total anonymous responses count.'", ")", ",", "'warnings'", "=>", "new", "external_warnings", "(", ")", ",", ")", ")", ";", "}" ]
Describes the get_responses_analysis return value. @return external_single_structure @since Moodle 3.3
[ "Describes", "the", "get_responses_analysis", "return", "value", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/external.php#L1243-L1284
216,482
moodle/moodle
mod/feedback/classes/external.php
mod_feedback_external.get_last_completed
public static function get_last_completed($feedbackid, $courseid = 0) { global $PAGE; $params = array('feedbackid' => $feedbackid, 'courseid' => $courseid); $params = self::validate_parameters(self::get_last_completed_parameters(), $params); $warnings = array(); list($feedback, $course, $cm, $context, $completioncourse) = self::validate_feedback($params['feedbackid'], $params['courseid']); $feedbackcompletion = new mod_feedback_completion($feedback, $cm, $completioncourse->id); if ($feedbackcompletion->is_anonymous()) { throw new moodle_exception('anonymous', 'feedback'); } if ($completed = $feedbackcompletion->find_last_completed()) { $exporter = new feedback_completed_exporter($completed); return array( 'completed' => $exporter->export($PAGE->get_renderer('core')), 'warnings' => $warnings, ); } throw new moodle_exception('not_completed_yet', 'feedback'); }
php
public static function get_last_completed($feedbackid, $courseid = 0) { global $PAGE; $params = array('feedbackid' => $feedbackid, 'courseid' => $courseid); $params = self::validate_parameters(self::get_last_completed_parameters(), $params); $warnings = array(); list($feedback, $course, $cm, $context, $completioncourse) = self::validate_feedback($params['feedbackid'], $params['courseid']); $feedbackcompletion = new mod_feedback_completion($feedback, $cm, $completioncourse->id); if ($feedbackcompletion->is_anonymous()) { throw new moodle_exception('anonymous', 'feedback'); } if ($completed = $feedbackcompletion->find_last_completed()) { $exporter = new feedback_completed_exporter($completed); return array( 'completed' => $exporter->export($PAGE->get_renderer('core')), 'warnings' => $warnings, ); } throw new moodle_exception('not_completed_yet', 'feedback'); }
[ "public", "static", "function", "get_last_completed", "(", "$", "feedbackid", ",", "$", "courseid", "=", "0", ")", "{", "global", "$", "PAGE", ";", "$", "params", "=", "array", "(", "'feedbackid'", "=>", "$", "feedbackid", ",", "'courseid'", "=>", "$", "courseid", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_last_completed_parameters", "(", ")", ",", "$", "params", ")", ";", "$", "warnings", "=", "array", "(", ")", ";", "list", "(", "$", "feedback", ",", "$", "course", ",", "$", "cm", ",", "$", "context", ",", "$", "completioncourse", ")", "=", "self", "::", "validate_feedback", "(", "$", "params", "[", "'feedbackid'", "]", ",", "$", "params", "[", "'courseid'", "]", ")", ";", "$", "feedbackcompletion", "=", "new", "mod_feedback_completion", "(", "$", "feedback", ",", "$", "cm", ",", "$", "completioncourse", "->", "id", ")", ";", "if", "(", "$", "feedbackcompletion", "->", "is_anonymous", "(", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'anonymous'", ",", "'feedback'", ")", ";", "}", "if", "(", "$", "completed", "=", "$", "feedbackcompletion", "->", "find_last_completed", "(", ")", ")", "{", "$", "exporter", "=", "new", "feedback_completed_exporter", "(", "$", "completed", ")", ";", "return", "array", "(", "'completed'", "=>", "$", "exporter", "->", "export", "(", "$", "PAGE", "->", "get_renderer", "(", "'core'", ")", ")", ",", "'warnings'", "=>", "$", "warnings", ",", ")", ";", "}", "throw", "new", "moodle_exception", "(", "'not_completed_yet'", ",", "'feedback'", ")", ";", "}" ]
Retrieves the last completion record for the current user. @param int $feedbackid feedback instance id @return array of warnings and the last completed record @since Moodle 3.3 @throws moodle_exception
[ "Retrieves", "the", "last", "completion", "record", "for", "the", "current", "user", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/feedback/classes/external.php#L1310-L1332
216,483
moodle/moodle
lib/ltiprovider/src/ToolProvider/ContentItem.php
ContentItem.setTitle
public function setTitle($title) { if (!empty($title)) { $this->title = $title; } else if (isset($this->title)) { unset($this->title); } }
php
public function setTitle($title) { if (!empty($title)) { $this->title = $title; } else if (isset($this->title)) { unset($this->title); } }
[ "public", "function", "setTitle", "(", "$", "title", ")", "{", "if", "(", "!", "empty", "(", "$", "title", ")", ")", "{", "$", "this", "->", "title", "=", "$", "title", ";", "}", "else", "if", "(", "isset", "(", "$", "this", "->", "title", ")", ")", "{", "unset", "(", "$", "this", "->", "title", ")", ";", "}", "}" ]
Set a title value for the content-item. @param string $title Title value
[ "Set", "a", "title", "value", "for", "the", "content", "-", "item", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ltiprovider/src/ToolProvider/ContentItem.php#L79-L88
216,484
moodle/moodle
lib/ltiprovider/src/ToolProvider/ContentItem.php
ContentItem.setText
public function setText($text) { if (!empty($text)) { $this->text = $text; } else if (isset($this->text)) { unset($this->text); } }
php
public function setText($text) { if (!empty($text)) { $this->text = $text; } else if (isset($this->text)) { unset($this->text); } }
[ "public", "function", "setText", "(", "$", "text", ")", "{", "if", "(", "!", "empty", "(", "$", "text", ")", ")", "{", "$", "this", "->", "text", "=", "$", "text", ";", "}", "else", "if", "(", "isset", "(", "$", "this", "->", "text", ")", ")", "{", "unset", "(", "$", "this", "->", "text", ")", ";", "}", "}" ]
Set a link text value for the content-item. @param string $text Link text value
[ "Set", "a", "link", "text", "value", "for", "the", "content", "-", "item", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/ltiprovider/src/ToolProvider/ContentItem.php#L95-L104
216,485
moodle/moodle
cache/stores/mongodb/MongoDB/Operation/Distinct.php
Distinct.createCommandDocument
private function createCommandDocument() { $cmd = [ 'distinct' => $this->collectionName, 'key' => $this->fieldName, ]; if ( ! empty($this->filter)) { $cmd['query'] = (object) $this->filter; } if (isset($this->options['collation'])) { $cmd['collation'] = (object) $this->options['collation']; } if (isset($this->options['maxTimeMS'])) { $cmd['maxTimeMS'] = $this->options['maxTimeMS']; } return $cmd; }
php
private function createCommandDocument() { $cmd = [ 'distinct' => $this->collectionName, 'key' => $this->fieldName, ]; if ( ! empty($this->filter)) { $cmd['query'] = (object) $this->filter; } if (isset($this->options['collation'])) { $cmd['collation'] = (object) $this->options['collation']; } if (isset($this->options['maxTimeMS'])) { $cmd['maxTimeMS'] = $this->options['maxTimeMS']; } return $cmd; }
[ "private", "function", "createCommandDocument", "(", ")", "{", "$", "cmd", "=", "[", "'distinct'", "=>", "$", "this", "->", "collectionName", ",", "'key'", "=>", "$", "this", "->", "fieldName", ",", "]", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "filter", ")", ")", "{", "$", "cmd", "[", "'query'", "]", "=", "(", "object", ")", "$", "this", "->", "filter", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "'collation'", "]", ")", ")", "{", "$", "cmd", "[", "'collation'", "]", "=", "(", "object", ")", "$", "this", "->", "options", "[", "'collation'", "]", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "'maxTimeMS'", "]", ")", ")", "{", "$", "cmd", "[", "'maxTimeMS'", "]", "=", "$", "this", "->", "options", "[", "'maxTimeMS'", "]", ";", "}", "return", "$", "cmd", ";", "}" ]
Create the distinct command document. @return array
[ "Create", "the", "distinct", "command", "document", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/Operation/Distinct.php#L156-L176
216,486
moodle/moodle
analytics/classes/local/time_splitting/equal_parts.php
equal_parts.define_ranges
protected function define_ranges() { $nparts = $this->get_number_parts(); $rangeduration = ($this->analysable->get_end() - $this->analysable->get_start()) / $nparts; if ($rangeduration < $nparts) { // It is interesting to avoid having a single timestamp belonging to multiple time ranges // because of things like community of inquiry indicators, where activities have a due date // that, ideally, would fall only into 1 time range. If the analysable duration is very short // it is because the model doesn't contain indicators that depend so heavily on time and therefore // we don't need to worry about timestamps being present in multiple time ranges. $allowmultipleranges = true; } $ranges = array(); for ($i = 0; $i < $nparts; $i++) { $start = $this->analysable->get_start() + intval($rangeduration * $i); $end = $this->analysable->get_start() + intval($rangeduration * ($i + 1)); if (empty($allowmultipleranges) && $i > 0 && $start === $ranges[$i - 1]['end']) { // We add 1 second so each timestamp only belongs to 1 range. $start = $start + 1; } if ($i === ($nparts - 1)) { // Better to use the end for the last one as we are using floor above. $end = $this->analysable->get_end(); } $ranges[$i] = array( 'start' => $start, 'end' => $end, 'time' => $end ); } return $ranges; }
php
protected function define_ranges() { $nparts = $this->get_number_parts(); $rangeduration = ($this->analysable->get_end() - $this->analysable->get_start()) / $nparts; if ($rangeduration < $nparts) { // It is interesting to avoid having a single timestamp belonging to multiple time ranges // because of things like community of inquiry indicators, where activities have a due date // that, ideally, would fall only into 1 time range. If the analysable duration is very short // it is because the model doesn't contain indicators that depend so heavily on time and therefore // we don't need to worry about timestamps being present in multiple time ranges. $allowmultipleranges = true; } $ranges = array(); for ($i = 0; $i < $nparts; $i++) { $start = $this->analysable->get_start() + intval($rangeduration * $i); $end = $this->analysable->get_start() + intval($rangeduration * ($i + 1)); if (empty($allowmultipleranges) && $i > 0 && $start === $ranges[$i - 1]['end']) { // We add 1 second so each timestamp only belongs to 1 range. $start = $start + 1; } if ($i === ($nparts - 1)) { // Better to use the end for the last one as we are using floor above. $end = $this->analysable->get_end(); } $ranges[$i] = array( 'start' => $start, 'end' => $end, 'time' => $end ); } return $ranges; }
[ "protected", "function", "define_ranges", "(", ")", "{", "$", "nparts", "=", "$", "this", "->", "get_number_parts", "(", ")", ";", "$", "rangeduration", "=", "(", "$", "this", "->", "analysable", "->", "get_end", "(", ")", "-", "$", "this", "->", "analysable", "->", "get_start", "(", ")", ")", "/", "$", "nparts", ";", "if", "(", "$", "rangeduration", "<", "$", "nparts", ")", "{", "// It is interesting to avoid having a single timestamp belonging to multiple time ranges", "// because of things like community of inquiry indicators, where activities have a due date", "// that, ideally, would fall only into 1 time range. If the analysable duration is very short", "// it is because the model doesn't contain indicators that depend so heavily on time and therefore", "// we don't need to worry about timestamps being present in multiple time ranges.", "$", "allowmultipleranges", "=", "true", ";", "}", "$", "ranges", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "nparts", ";", "$", "i", "++", ")", "{", "$", "start", "=", "$", "this", "->", "analysable", "->", "get_start", "(", ")", "+", "intval", "(", "$", "rangeduration", "*", "$", "i", ")", ";", "$", "end", "=", "$", "this", "->", "analysable", "->", "get_start", "(", ")", "+", "intval", "(", "$", "rangeduration", "*", "(", "$", "i", "+", "1", ")", ")", ";", "if", "(", "empty", "(", "$", "allowmultipleranges", ")", "&&", "$", "i", ">", "0", "&&", "$", "start", "===", "$", "ranges", "[", "$", "i", "-", "1", "]", "[", "'end'", "]", ")", "{", "// We add 1 second so each timestamp only belongs to 1 range.", "$", "start", "=", "$", "start", "+", "1", ";", "}", "if", "(", "$", "i", "===", "(", "$", "nparts", "-", "1", ")", ")", "{", "// Better to use the end for the last one as we are using floor above.", "$", "end", "=", "$", "this", "->", "analysable", "->", "get_end", "(", ")", ";", "}", "$", "ranges", "[", "$", "i", "]", "=", "array", "(", "'start'", "=>", "$", "start", ",", "'end'", "=>", "$", "end", ",", "'time'", "=>", "$", "end", ")", ";", "}", "return", "$", "ranges", ";", "}" ]
Splits the analysable duration in X equal parts from the start to the end. @return array
[ "Splits", "the", "analysable", "duration", "in", "X", "equal", "parts", "from", "the", "start", "to", "the", "end", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/analytics/classes/local/time_splitting/equal_parts.php#L50-L87
216,487
moodle/moodle
cache/classes/factory.php
cache_factory.instance
public static function instance($forcereload = false) { global $CFG; if ($forcereload || self::$instance === null) { // Initialise a new factory to facilitate our needs. if (defined('CACHE_DISABLE_ALL') && CACHE_DISABLE_ALL !== false) { // The cache has been disabled. Load disabledlib and start using the factory designed to handle this // situation. It will use disabled alternatives where available. require_once($CFG->dirroot.'/cache/disabledlib.php'); self::$instance = new cache_factory_disabled(); } else if ((defined('PHPUNIT_TEST') && PHPUNIT_TEST) || defined('BEHAT_SITE_RUNNING')) { // We're using the test factory. require_once($CFG->dirroot.'/cache/tests/fixtures/lib.php'); self::$instance = new cache_phpunit_factory(); if (defined('CACHE_DISABLE_STORES') && CACHE_DISABLE_STORES !== false) { // The cache stores have been disabled. self::$instance->set_state(self::STATE_STORES_DISABLED); } } else { // We're using the regular factory. self::$instance = new cache_factory(); if (defined('CACHE_DISABLE_STORES') && CACHE_DISABLE_STORES !== false) { // The cache stores have been disabled. self::$instance->set_state(self::STATE_STORES_DISABLED); } } } return self::$instance; }
php
public static function instance($forcereload = false) { global $CFG; if ($forcereload || self::$instance === null) { // Initialise a new factory to facilitate our needs. if (defined('CACHE_DISABLE_ALL') && CACHE_DISABLE_ALL !== false) { // The cache has been disabled. Load disabledlib and start using the factory designed to handle this // situation. It will use disabled alternatives where available. require_once($CFG->dirroot.'/cache/disabledlib.php'); self::$instance = new cache_factory_disabled(); } else if ((defined('PHPUNIT_TEST') && PHPUNIT_TEST) || defined('BEHAT_SITE_RUNNING')) { // We're using the test factory. require_once($CFG->dirroot.'/cache/tests/fixtures/lib.php'); self::$instance = new cache_phpunit_factory(); if (defined('CACHE_DISABLE_STORES') && CACHE_DISABLE_STORES !== false) { // The cache stores have been disabled. self::$instance->set_state(self::STATE_STORES_DISABLED); } } else { // We're using the regular factory. self::$instance = new cache_factory(); if (defined('CACHE_DISABLE_STORES') && CACHE_DISABLE_STORES !== false) { // The cache stores have been disabled. self::$instance->set_state(self::STATE_STORES_DISABLED); } } } return self::$instance; }
[ "public", "static", "function", "instance", "(", "$", "forcereload", "=", "false", ")", "{", "global", "$", "CFG", ";", "if", "(", "$", "forcereload", "||", "self", "::", "$", "instance", "===", "null", ")", "{", "// Initialise a new factory to facilitate our needs.", "if", "(", "defined", "(", "'CACHE_DISABLE_ALL'", ")", "&&", "CACHE_DISABLE_ALL", "!==", "false", ")", "{", "// The cache has been disabled. Load disabledlib and start using the factory designed to handle this", "// situation. It will use disabled alternatives where available.", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/cache/disabledlib.php'", ")", ";", "self", "::", "$", "instance", "=", "new", "cache_factory_disabled", "(", ")", ";", "}", "else", "if", "(", "(", "defined", "(", "'PHPUNIT_TEST'", ")", "&&", "PHPUNIT_TEST", ")", "||", "defined", "(", "'BEHAT_SITE_RUNNING'", ")", ")", "{", "// We're using the test factory.", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/cache/tests/fixtures/lib.php'", ")", ";", "self", "::", "$", "instance", "=", "new", "cache_phpunit_factory", "(", ")", ";", "if", "(", "defined", "(", "'CACHE_DISABLE_STORES'", ")", "&&", "CACHE_DISABLE_STORES", "!==", "false", ")", "{", "// The cache stores have been disabled.", "self", "::", "$", "instance", "->", "set_state", "(", "self", "::", "STATE_STORES_DISABLED", ")", ";", "}", "}", "else", "{", "// We're using the regular factory.", "self", "::", "$", "instance", "=", "new", "cache_factory", "(", ")", ";", "if", "(", "defined", "(", "'CACHE_DISABLE_STORES'", ")", "&&", "CACHE_DISABLE_STORES", "!==", "false", ")", "{", "// The cache stores have been disabled.", "self", "::", "$", "instance", "->", "set_state", "(", "self", "::", "STATE_STORES_DISABLED", ")", ";", "}", "}", "}", "return", "self", "::", "$", "instance", ";", "}" ]
Returns an instance of the cache_factor method. @param bool $forcereload If set to true a new cache_factory instance will be created and used. @return cache_factory
[ "Returns", "an", "instance", "of", "the", "cache_factor", "method", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/classes/factory.php#L120-L147
216,488
moodle/moodle
cache/classes/factory.php
cache_factory.reset
public static function reset() { $factory = self::instance(); $factory->reset_cache_instances(); $factory->configs = array(); $factory->definitions = array(); $factory->definitionstores = array(); $factory->lockplugins = array(); // MUST be null in order to force its regeneration. // Reset the state to uninitialised. $factory->state = self::STATE_UNINITIALISED; }
php
public static function reset() { $factory = self::instance(); $factory->reset_cache_instances(); $factory->configs = array(); $factory->definitions = array(); $factory->definitionstores = array(); $factory->lockplugins = array(); // MUST be null in order to force its regeneration. // Reset the state to uninitialised. $factory->state = self::STATE_UNINITIALISED; }
[ "public", "static", "function", "reset", "(", ")", "{", "$", "factory", "=", "self", "::", "instance", "(", ")", ";", "$", "factory", "->", "reset_cache_instances", "(", ")", ";", "$", "factory", "->", "configs", "=", "array", "(", ")", ";", "$", "factory", "->", "definitions", "=", "array", "(", ")", ";", "$", "factory", "->", "definitionstores", "=", "array", "(", ")", ";", "$", "factory", "->", "lockplugins", "=", "array", "(", ")", ";", "// MUST be null in order to force its regeneration.", "// Reset the state to uninitialised.", "$", "factory", "->", "state", "=", "self", "::", "STATE_UNINITIALISED", ";", "}" ]
Resets the arrays containing instantiated caches, stores, and config instances.
[ "Resets", "the", "arrays", "containing", "instantiated", "caches", "stores", "and", "config", "instances", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/classes/factory.php#L159-L168
216,489
moodle/moodle
cache/classes/factory.php
cache_factory.create_cache
public function create_cache(cache_definition $definition) { $class = $definition->get_cache_class(); $stores = cache_helper::get_stores_suitable_for_definition($definition); foreach ($stores as $key => $store) { if (!$store::are_requirements_met()) { unset($stores[$key]); } } if (count($stores) === 0) { // Hmm still no stores, better provide a dummy store to mimic functionality. The dev will be none the wiser. $stores[] = $this->create_dummy_store($definition); } $loader = null; if ($definition->has_data_source()) { $loader = $definition->get_data_source(); } while (($store = array_pop($stores)) !== null) { $loader = new $class($definition, $store, $loader); } return $loader; }
php
public function create_cache(cache_definition $definition) { $class = $definition->get_cache_class(); $stores = cache_helper::get_stores_suitable_for_definition($definition); foreach ($stores as $key => $store) { if (!$store::are_requirements_met()) { unset($stores[$key]); } } if (count($stores) === 0) { // Hmm still no stores, better provide a dummy store to mimic functionality. The dev will be none the wiser. $stores[] = $this->create_dummy_store($definition); } $loader = null; if ($definition->has_data_source()) { $loader = $definition->get_data_source(); } while (($store = array_pop($stores)) !== null) { $loader = new $class($definition, $store, $loader); } return $loader; }
[ "public", "function", "create_cache", "(", "cache_definition", "$", "definition", ")", "{", "$", "class", "=", "$", "definition", "->", "get_cache_class", "(", ")", ";", "$", "stores", "=", "cache_helper", "::", "get_stores_suitable_for_definition", "(", "$", "definition", ")", ";", "foreach", "(", "$", "stores", "as", "$", "key", "=>", "$", "store", ")", "{", "if", "(", "!", "$", "store", "::", "are_requirements_met", "(", ")", ")", "{", "unset", "(", "$", "stores", "[", "$", "key", "]", ")", ";", "}", "}", "if", "(", "count", "(", "$", "stores", ")", "===", "0", ")", "{", "// Hmm still no stores, better provide a dummy store to mimic functionality. The dev will be none the wiser.", "$", "stores", "[", "]", "=", "$", "this", "->", "create_dummy_store", "(", "$", "definition", ")", ";", "}", "$", "loader", "=", "null", ";", "if", "(", "$", "definition", "->", "has_data_source", "(", ")", ")", "{", "$", "loader", "=", "$", "definition", "->", "get_data_source", "(", ")", ";", "}", "while", "(", "(", "$", "store", "=", "array_pop", "(", "$", "stores", ")", ")", "!==", "null", ")", "{", "$", "loader", "=", "new", "$", "class", "(", "$", "definition", ",", "$", "store", ",", "$", "loader", ")", ";", "}", "return", "$", "loader", ";", "}" ]
Common public method to create a cache instance given a definition. This is used by the static make methods. @param cache_definition $definition @return cache_application|cache_session|cache_store @throws coding_exception
[ "Common", "public", "method", "to", "create", "a", "cache", "instance", "given", "a", "definition", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/classes/factory.php#L252-L272
216,490
moodle/moodle
cache/classes/factory.php
cache_factory.create_store_from_config
public function create_store_from_config($name, array $details, cache_definition $definition) { if (!array_key_exists($name, $this->stores)) { // Properties: name, plugin, configuration, class. $class = $details['class']; if (!$class::are_requirements_met()) { return false; } $store = new $class($details['name'], $details['configuration']); $this->stores[$name] = $store; } /* @var cache_store $store */ $store = $this->stores[$name]; // We check are_requirements_met although we expect is_ready is going to check as well. if (!$store::are_requirements_met() || !$store->is_ready() || !$store->is_supported_mode($definition->get_mode())) { return false; } // We always create a clone of the original store. // If we were to clone a store that had already been initialised with a definition then // we'd run into a myriad of issues. // We use a method of the store to create a clone rather than just creating it ourselves // so that if any store out there doesn't handle cloning they can override this method in // order to address the issues. $store = $this->stores[$name]->create_clone($details); $store->initialise($definition); $definitionid = $definition->get_id(); if (!isset($this->definitionstores[$definitionid])) { $this->definitionstores[$definitionid] = array(); } $this->definitionstores[$definitionid][] = $store; return $store; }
php
public function create_store_from_config($name, array $details, cache_definition $definition) { if (!array_key_exists($name, $this->stores)) { // Properties: name, plugin, configuration, class. $class = $details['class']; if (!$class::are_requirements_met()) { return false; } $store = new $class($details['name'], $details['configuration']); $this->stores[$name] = $store; } /* @var cache_store $store */ $store = $this->stores[$name]; // We check are_requirements_met although we expect is_ready is going to check as well. if (!$store::are_requirements_met() || !$store->is_ready() || !$store->is_supported_mode($definition->get_mode())) { return false; } // We always create a clone of the original store. // If we were to clone a store that had already been initialised with a definition then // we'd run into a myriad of issues. // We use a method of the store to create a clone rather than just creating it ourselves // so that if any store out there doesn't handle cloning they can override this method in // order to address the issues. $store = $this->stores[$name]->create_clone($details); $store->initialise($definition); $definitionid = $definition->get_id(); if (!isset($this->definitionstores[$definitionid])) { $this->definitionstores[$definitionid] = array(); } $this->definitionstores[$definitionid][] = $store; return $store; }
[ "public", "function", "create_store_from_config", "(", "$", "name", ",", "array", "$", "details", ",", "cache_definition", "$", "definition", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "stores", ")", ")", "{", "// Properties: name, plugin, configuration, class.", "$", "class", "=", "$", "details", "[", "'class'", "]", ";", "if", "(", "!", "$", "class", "::", "are_requirements_met", "(", ")", ")", "{", "return", "false", ";", "}", "$", "store", "=", "new", "$", "class", "(", "$", "details", "[", "'name'", "]", ",", "$", "details", "[", "'configuration'", "]", ")", ";", "$", "this", "->", "stores", "[", "$", "name", "]", "=", "$", "store", ";", "}", "/* @var cache_store $store */", "$", "store", "=", "$", "this", "->", "stores", "[", "$", "name", "]", ";", "// We check are_requirements_met although we expect is_ready is going to check as well.", "if", "(", "!", "$", "store", "::", "are_requirements_met", "(", ")", "||", "!", "$", "store", "->", "is_ready", "(", ")", "||", "!", "$", "store", "->", "is_supported_mode", "(", "$", "definition", "->", "get_mode", "(", ")", ")", ")", "{", "return", "false", ";", "}", "// We always create a clone of the original store.", "// If we were to clone a store that had already been initialised with a definition then", "// we'd run into a myriad of issues.", "// We use a method of the store to create a clone rather than just creating it ourselves", "// so that if any store out there doesn't handle cloning they can override this method in", "// order to address the issues.", "$", "store", "=", "$", "this", "->", "stores", "[", "$", "name", "]", "->", "create_clone", "(", "$", "details", ")", ";", "$", "store", "->", "initialise", "(", "$", "definition", ")", ";", "$", "definitionid", "=", "$", "definition", "->", "get_id", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "definitionstores", "[", "$", "definitionid", "]", ")", ")", "{", "$", "this", "->", "definitionstores", "[", "$", "definitionid", "]", "=", "array", "(", ")", ";", "}", "$", "this", "->", "definitionstores", "[", "$", "definitionid", "]", "[", "]", "=", "$", "store", ";", "return", "$", "store", ";", "}" ]
Creates a store instance given its name and configuration. If the store has already been instantiated then the original object will be returned. (reused) @param string $name The name of the store (must be unique remember) @param array $details @param cache_definition $definition The definition to instantiate it for. @return boolean|cache_store
[ "Creates", "a", "store", "instance", "given", "its", "name", "and", "configuration", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/classes/factory.php#L284-L314
216,491
moodle/moodle
cache/classes/factory.php
cache_factory.get_store_instances_in_use
public function get_store_instances_in_use(cache_definition $definition) { $id = $definition->get_id(); if (!isset($this->definitionstores[$id])) { return array(); } return $this->definitionstores[$id]; }
php
public function get_store_instances_in_use(cache_definition $definition) { $id = $definition->get_id(); if (!isset($this->definitionstores[$id])) { return array(); } return $this->definitionstores[$id]; }
[ "public", "function", "get_store_instances_in_use", "(", "cache_definition", "$", "definition", ")", "{", "$", "id", "=", "$", "definition", "->", "get_id", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "definitionstores", "[", "$", "id", "]", ")", ")", "{", "return", "array", "(", ")", ";", "}", "return", "$", "this", "->", "definitionstores", "[", "$", "id", "]", ";", "}" ]
Returns an array of cache stores that have been initialised for use in definitions. @param cache_definition $definition @return array
[ "Returns", "an", "array", "of", "cache", "stores", "that", "have", "been", "initialised", "for", "use", "in", "definitions", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/classes/factory.php#L321-L327
216,492
moodle/moodle
cache/classes/factory.php
cache_factory.create_dummy_store
protected function create_dummy_store(cache_definition $definition) { global $CFG; require_once($CFG->dirroot.'/cache/classes/dummystore.php'); $store = new cachestore_dummy(); $store->initialise($definition); return $store; }
php
protected function create_dummy_store(cache_definition $definition) { global $CFG; require_once($CFG->dirroot.'/cache/classes/dummystore.php'); $store = new cachestore_dummy(); $store->initialise($definition); return $store; }
[ "protected", "function", "create_dummy_store", "(", "cache_definition", "$", "definition", ")", "{", "global", "$", "CFG", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/cache/classes/dummystore.php'", ")", ";", "$", "store", "=", "new", "cachestore_dummy", "(", ")", ";", "$", "store", "->", "initialise", "(", "$", "definition", ")", ";", "return", "$", "store", ";", "}" ]
Creates a dummy store object for use when a loader has no potential stores to use. @param cache_definition $definition @return cachestore_dummy
[ "Creates", "a", "dummy", "store", "object", "for", "use", "when", "a", "loader", "has", "no", "potential", "stores", "to", "use", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/classes/factory.php#L473-L479
216,493
moodle/moodle
cache/classes/factory.php
cache_factory.create_lock_instance
public function create_lock_instance(array $config) { global $CFG; if (!array_key_exists('name', $config) || !array_key_exists('type', $config)) { throw new coding_exception('Invalid cache lock instance provided'); } $name = $config['name']; $type = $config['type']; unset($config['name']); unset($config['type']); if (!isset($this->lockplugins[$type])) { $pluginname = substr($type, 10); $file = $CFG->dirroot."/cache/locks/{$pluginname}/lib.php"; if (file_exists($file) && is_readable($file)) { require_once($file); } if (!class_exists($type)) { throw new coding_exception('Invalid lock plugin requested.'); } $this->lockplugins[$type] = $type; } if (!array_key_exists($type, $this->lockplugins)) { throw new coding_exception('Invalid cache lock type.'); } $class = $this->lockplugins[$type]; return new $class($name, $config); }
php
public function create_lock_instance(array $config) { global $CFG; if (!array_key_exists('name', $config) || !array_key_exists('type', $config)) { throw new coding_exception('Invalid cache lock instance provided'); } $name = $config['name']; $type = $config['type']; unset($config['name']); unset($config['type']); if (!isset($this->lockplugins[$type])) { $pluginname = substr($type, 10); $file = $CFG->dirroot."/cache/locks/{$pluginname}/lib.php"; if (file_exists($file) && is_readable($file)) { require_once($file); } if (!class_exists($type)) { throw new coding_exception('Invalid lock plugin requested.'); } $this->lockplugins[$type] = $type; } if (!array_key_exists($type, $this->lockplugins)) { throw new coding_exception('Invalid cache lock type.'); } $class = $this->lockplugins[$type]; return new $class($name, $config); }
[ "public", "function", "create_lock_instance", "(", "array", "$", "config", ")", "{", "global", "$", "CFG", ";", "if", "(", "!", "array_key_exists", "(", "'name'", ",", "$", "config", ")", "||", "!", "array_key_exists", "(", "'type'", ",", "$", "config", ")", ")", "{", "throw", "new", "coding_exception", "(", "'Invalid cache lock instance provided'", ")", ";", "}", "$", "name", "=", "$", "config", "[", "'name'", "]", ";", "$", "type", "=", "$", "config", "[", "'type'", "]", ";", "unset", "(", "$", "config", "[", "'name'", "]", ")", ";", "unset", "(", "$", "config", "[", "'type'", "]", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "lockplugins", "[", "$", "type", "]", ")", ")", "{", "$", "pluginname", "=", "substr", "(", "$", "type", ",", "10", ")", ";", "$", "file", "=", "$", "CFG", "->", "dirroot", ".", "\"/cache/locks/{$pluginname}/lib.php\"", ";", "if", "(", "file_exists", "(", "$", "file", ")", "&&", "is_readable", "(", "$", "file", ")", ")", "{", "require_once", "(", "$", "file", ")", ";", "}", "if", "(", "!", "class_exists", "(", "$", "type", ")", ")", "{", "throw", "new", "coding_exception", "(", "'Invalid lock plugin requested.'", ")", ";", "}", "$", "this", "->", "lockplugins", "[", "$", "type", "]", "=", "$", "type", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "type", ",", "$", "this", "->", "lockplugins", ")", ")", "{", "throw", "new", "coding_exception", "(", "'Invalid cache lock type.'", ")", ";", "}", "$", "class", "=", "$", "this", "->", "lockplugins", "[", "$", "type", "]", ";", "return", "new", "$", "class", "(", "$", "name", ",", "$", "config", ")", ";", "}" ]
Returns a lock instance ready for use. @param array $config @return cache_lock_interface
[ "Returns", "a", "lock", "instance", "ready", "for", "use", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/classes/factory.php#L487-L513
216,494
moodle/moodle
cache/classes/factory.php
cache_factory.set_state
public function set_state($state) { if ($state <= $this->state) { return false; } $this->state = $state; return true; }
php
public function set_state($state) { if ($state <= $this->state) { return false; } $this->state = $state; return true; }
[ "public", "function", "set_state", "(", "$", "state", ")", "{", "if", "(", "$", "state", "<=", "$", "this", "->", "state", ")", "{", "return", "false", ";", "}", "$", "this", "->", "state", "=", "$", "state", ";", "return", "true", ";", "}" ]
Updates the state fo the cache API. @param int $state @return bool
[ "Updates", "the", "state", "fo", "the", "cache", "API", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/classes/factory.php#L530-L536
216,495
moodle/moodle
cache/classes/factory.php
cache_factory.updating_started
public function updating_started() { if ($this->state !== self::STATE_READY) { return false; } $this->state = self::STATE_UPDATING; return true; }
php
public function updating_started() { if ($this->state !== self::STATE_READY) { return false; } $this->state = self::STATE_UPDATING; return true; }
[ "public", "function", "updating_started", "(", ")", "{", "if", "(", "$", "this", "->", "state", "!==", "self", "::", "STATE_READY", ")", "{", "return", "false", ";", "}", "$", "this", "->", "state", "=", "self", "::", "STATE_UPDATING", ";", "return", "true", ";", "}" ]
Informs the factory that the cache is currently updating itself. This forces the state to upgrading and can only be called once the cache is ready to use. Calling it ensure we don't try to reinstantite things when requesting cache definitions that don't exist yet.
[ "Informs", "the", "factory", "that", "the", "cache", "is", "currently", "updating", "itself", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/classes/factory.php#L544-L550
216,496
moodle/moodle
cache/classes/factory.php
cache_factory.disable_stores
public static function disable_stores() { // First reset to clear any static acceleration array. $factory = self::instance(); $factory->reset_cache_instances(); $factory->set_state(self::STATE_STORES_DISABLED); }
php
public static function disable_stores() { // First reset to clear any static acceleration array. $factory = self::instance(); $factory->reset_cache_instances(); $factory->set_state(self::STATE_STORES_DISABLED); }
[ "public", "static", "function", "disable_stores", "(", ")", "{", "// First reset to clear any static acceleration array.", "$", "factory", "=", "self", "::", "instance", "(", ")", ";", "$", "factory", "->", "reset_cache_instances", "(", ")", ";", "$", "factory", "->", "set_state", "(", "self", "::", "STATE_STORES_DISABLED", ")", ";", "}" ]
Disables cache stores. The cache API will continue to function however none of the actual stores will be used. Instead the dummy store will be provided for all cache requests. This is useful in situations where you cannot be sure any stores are working. In order to re-enable the cache you must call the cache factories static reset method: <code> // Disable the cache factory. cache_factory::disable_stores(); // Re-enable the cache factory by resetting it. cache_factory::reset(); </code>
[ "Disables", "cache", "stores", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/classes/factory.php#L632-L637
216,497
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Cache/Backend/Hashtable.php
Horde_Imap_Client_Cache_Backend_Hashtable._loadMailbox
protected function _loadMailbox($mailbox, $uidvalid = null) { if (!isset($this->_mbox[$mailbox]) && ($ob = $this->_hash->get($this->_getCid($mailbox)))) { try { $this->_mbox[$mailbox] = $this->_pack->unpack($ob); } catch (Horde_Pack_Exception $e) {} } if (isset($this->_mbox[$mailbox])) { if (is_null($uidvalid) || ($uidvalid == $this->_mbox[$mailbox]['d']['uidvalid'])) { return; } $this->deleteMailbox($mailbox); } $this->_mbox[$mailbox] = array( // Metadata storage // By default includes UIDVALIDITY of mailbox. 'd' => array('uidvalid' => $uidvalid), // List of UIDs 'u' => new Horde_Imap_Client_Ids() ); }
php
protected function _loadMailbox($mailbox, $uidvalid = null) { if (!isset($this->_mbox[$mailbox]) && ($ob = $this->_hash->get($this->_getCid($mailbox)))) { try { $this->_mbox[$mailbox] = $this->_pack->unpack($ob); } catch (Horde_Pack_Exception $e) {} } if (isset($this->_mbox[$mailbox])) { if (is_null($uidvalid) || ($uidvalid == $this->_mbox[$mailbox]['d']['uidvalid'])) { return; } $this->deleteMailbox($mailbox); } $this->_mbox[$mailbox] = array( // Metadata storage // By default includes UIDVALIDITY of mailbox. 'd' => array('uidvalid' => $uidvalid), // List of UIDs 'u' => new Horde_Imap_Client_Ids() ); }
[ "protected", "function", "_loadMailbox", "(", "$", "mailbox", ",", "$", "uidvalid", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_mbox", "[", "$", "mailbox", "]", ")", "&&", "(", "$", "ob", "=", "$", "this", "->", "_hash", "->", "get", "(", "$", "this", "->", "_getCid", "(", "$", "mailbox", ")", ")", ")", ")", "{", "try", "{", "$", "this", "->", "_mbox", "[", "$", "mailbox", "]", "=", "$", "this", "->", "_pack", "->", "unpack", "(", "$", "ob", ")", ";", "}", "catch", "(", "Horde_Pack_Exception", "$", "e", ")", "{", "}", "}", "if", "(", "isset", "(", "$", "this", "->", "_mbox", "[", "$", "mailbox", "]", ")", ")", "{", "if", "(", "is_null", "(", "$", "uidvalid", ")", "||", "(", "$", "uidvalid", "==", "$", "this", "->", "_mbox", "[", "$", "mailbox", "]", "[", "'d'", "]", "[", "'uidvalid'", "]", ")", ")", "{", "return", ";", "}", "$", "this", "->", "deleteMailbox", "(", "$", "mailbox", ")", ";", "}", "$", "this", "->", "_mbox", "[", "$", "mailbox", "]", "=", "array", "(", "// Metadata storage", "// By default includes UIDVALIDITY of mailbox.", "'d'", "=>", "array", "(", "'uidvalid'", "=>", "$", "uidvalid", ")", ",", "// List of UIDs", "'u'", "=>", "new", "Horde_Imap_Client_Ids", "(", ")", ")", ";", "}" ]
Loads basic mailbox information. @param string $mailbox The mailbox to load. @param integer $uidvalid The IMAP uidvalidity value of the mailbox.
[ "Loads", "basic", "mailbox", "information", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Cache/Backend/Hashtable.php#L321-L345
216,498
moodle/moodle
lib/horde/framework/Horde/Imap/Client/Cache/Backend/Hashtable.php
Horde_Imap_Client_Cache_Backend_Hashtable._getCid
protected function _getCid($mailbox) { return implode(self::CID_SEPARATOR, array( 'horde_imap_client', $this->_params['username'], $mailbox, $this->_params['hostspec'], $this->_params['port'] )); }
php
protected function _getCid($mailbox) { return implode(self::CID_SEPARATOR, array( 'horde_imap_client', $this->_params['username'], $mailbox, $this->_params['hostspec'], $this->_params['port'] )); }
[ "protected", "function", "_getCid", "(", "$", "mailbox", ")", "{", "return", "implode", "(", "self", "::", "CID_SEPARATOR", ",", "array", "(", "'horde_imap_client'", ",", "$", "this", "->", "_params", "[", "'username'", "]", ",", "$", "mailbox", ",", "$", "this", "->", "_params", "[", "'hostspec'", "]", ",", "$", "this", "->", "_params", "[", "'port'", "]", ")", ")", ";", "}" ]
Create the unique ID used to store the mailbox data in the cache. @param string $mailbox The mailbox to cache. @return string The cache ID.
[ "Create", "the", "unique", "ID", "used", "to", "store", "the", "mailbox", "data", "in", "the", "cache", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Cache/Backend/Hashtable.php#L390-L399
216,499
moodle/moodle
repository/filesystem/lib.php
repository_filesystem.get_listing
public function get_listing($fullpath = '', $page = '') { global $OUTPUT; $list = array( 'list' => array(), 'manage' => false, 'dynload' => true, 'nologin' => true, 'path' => array() ); // We analyse the path to extract what to browse. $fullpath = empty($fullpath) ? $this->build_node_path('root') : $fullpath; $trail = explode('|', $fullpath); $trail = array_pop($trail); list($mode, $path, $unused) = $this->explode_node_path($trail); // Is that a search? if ($mode === 'search') { return $this->search($path, $page); } // Cleaning up the requested path. $path = trim($path, '/'); if (!$this->is_in_repository($path)) { // In case of doubt on the path, reset to default. $path = ''; } $rootpath = $this->get_rootpath(); $abspath = rtrim($rootpath . $path, '/') . '/'; // Retrieve list of files and directories and sort them. $fileslist = array(); $dirslist = array(); if ($dh = opendir($abspath)) { while (($file = readdir($dh)) != false) { if ($file != '.' and $file != '..') { if (is_file($abspath . $file)) { $fileslist[] = $file; } else { $dirslist[] = $file; } } } } core_collator::asort($fileslist, core_collator::SORT_NATURAL); core_collator::asort($dirslist, core_collator::SORT_NATURAL); // Fill the results. foreach ($dirslist as $file) { $list['list'][] = $this->build_node($rootpath, $path, $file, true, $fullpath); } foreach ($fileslist as $file) { $list['list'][] = $this->build_node($rootpath, $path, $file, false, $fullpath); } $list['path'] = $this->build_breadcrumb($fullpath); $list['list'] = array_filter($list['list'], array($this, 'filter')); return $list; }
php
public function get_listing($fullpath = '', $page = '') { global $OUTPUT; $list = array( 'list' => array(), 'manage' => false, 'dynload' => true, 'nologin' => true, 'path' => array() ); // We analyse the path to extract what to browse. $fullpath = empty($fullpath) ? $this->build_node_path('root') : $fullpath; $trail = explode('|', $fullpath); $trail = array_pop($trail); list($mode, $path, $unused) = $this->explode_node_path($trail); // Is that a search? if ($mode === 'search') { return $this->search($path, $page); } // Cleaning up the requested path. $path = trim($path, '/'); if (!$this->is_in_repository($path)) { // In case of doubt on the path, reset to default. $path = ''; } $rootpath = $this->get_rootpath(); $abspath = rtrim($rootpath . $path, '/') . '/'; // Retrieve list of files and directories and sort them. $fileslist = array(); $dirslist = array(); if ($dh = opendir($abspath)) { while (($file = readdir($dh)) != false) { if ($file != '.' and $file != '..') { if (is_file($abspath . $file)) { $fileslist[] = $file; } else { $dirslist[] = $file; } } } } core_collator::asort($fileslist, core_collator::SORT_NATURAL); core_collator::asort($dirslist, core_collator::SORT_NATURAL); // Fill the results. foreach ($dirslist as $file) { $list['list'][] = $this->build_node($rootpath, $path, $file, true, $fullpath); } foreach ($fileslist as $file) { $list['list'][] = $this->build_node($rootpath, $path, $file, false, $fullpath); } $list['path'] = $this->build_breadcrumb($fullpath); $list['list'] = array_filter($list['list'], array($this, 'filter')); return $list; }
[ "public", "function", "get_listing", "(", "$", "fullpath", "=", "''", ",", "$", "page", "=", "''", ")", "{", "global", "$", "OUTPUT", ";", "$", "list", "=", "array", "(", "'list'", "=>", "array", "(", ")", ",", "'manage'", "=>", "false", ",", "'dynload'", "=>", "true", ",", "'nologin'", "=>", "true", ",", "'path'", "=>", "array", "(", ")", ")", ";", "// We analyse the path to extract what to browse.", "$", "fullpath", "=", "empty", "(", "$", "fullpath", ")", "?", "$", "this", "->", "build_node_path", "(", "'root'", ")", ":", "$", "fullpath", ";", "$", "trail", "=", "explode", "(", "'|'", ",", "$", "fullpath", ")", ";", "$", "trail", "=", "array_pop", "(", "$", "trail", ")", ";", "list", "(", "$", "mode", ",", "$", "path", ",", "$", "unused", ")", "=", "$", "this", "->", "explode_node_path", "(", "$", "trail", ")", ";", "// Is that a search?", "if", "(", "$", "mode", "===", "'search'", ")", "{", "return", "$", "this", "->", "search", "(", "$", "path", ",", "$", "page", ")", ";", "}", "// Cleaning up the requested path.", "$", "path", "=", "trim", "(", "$", "path", ",", "'/'", ")", ";", "if", "(", "!", "$", "this", "->", "is_in_repository", "(", "$", "path", ")", ")", "{", "// In case of doubt on the path, reset to default.", "$", "path", "=", "''", ";", "}", "$", "rootpath", "=", "$", "this", "->", "get_rootpath", "(", ")", ";", "$", "abspath", "=", "rtrim", "(", "$", "rootpath", ".", "$", "path", ",", "'/'", ")", ".", "'/'", ";", "// Retrieve list of files and directories and sort them.", "$", "fileslist", "=", "array", "(", ")", ";", "$", "dirslist", "=", "array", "(", ")", ";", "if", "(", "$", "dh", "=", "opendir", "(", "$", "abspath", ")", ")", "{", "while", "(", "(", "$", "file", "=", "readdir", "(", "$", "dh", ")", ")", "!=", "false", ")", "{", "if", "(", "$", "file", "!=", "'.'", "and", "$", "file", "!=", "'..'", ")", "{", "if", "(", "is_file", "(", "$", "abspath", ".", "$", "file", ")", ")", "{", "$", "fileslist", "[", "]", "=", "$", "file", ";", "}", "else", "{", "$", "dirslist", "[", "]", "=", "$", "file", ";", "}", "}", "}", "}", "core_collator", "::", "asort", "(", "$", "fileslist", ",", "core_collator", "::", "SORT_NATURAL", ")", ";", "core_collator", "::", "asort", "(", "$", "dirslist", ",", "core_collator", "::", "SORT_NATURAL", ")", ";", "// Fill the results.", "foreach", "(", "$", "dirslist", "as", "$", "file", ")", "{", "$", "list", "[", "'list'", "]", "[", "]", "=", "$", "this", "->", "build_node", "(", "$", "rootpath", ",", "$", "path", ",", "$", "file", ",", "true", ",", "$", "fullpath", ")", ";", "}", "foreach", "(", "$", "fileslist", "as", "$", "file", ")", "{", "$", "list", "[", "'list'", "]", "[", "]", "=", "$", "this", "->", "build_node", "(", "$", "rootpath", ",", "$", "path", ",", "$", "file", ",", "false", ",", "$", "fullpath", ")", ";", "}", "$", "list", "[", "'path'", "]", "=", "$", "this", "->", "build_breadcrumb", "(", "$", "fullpath", ")", ";", "$", "list", "[", "'list'", "]", "=", "array_filter", "(", "$", "list", "[", "'list'", "]", ",", "array", "(", "$", "this", ",", "'filter'", ")", ")", ";", "return", "$", "list", ";", "}" ]
Get the list of files and directories in that repository. @param string $fullpath Path to explore. This is assembled by {@link self::build_node_path()}. @param string $page Page number. @return array List of files and folders.
[ "Get", "the", "list", "of", "files", "and", "directories", "in", "that", "repository", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/repository/filesystem/lib.php#L67-L127