id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
214,400
moodle/moodle
lib/adodb/adodb-pager.inc.php
ADODB_Pager.RenderNav
function RenderNav() { ob_start(); if (!$this->rs->AtFirstPage()) { $this->Render_First(); $this->Render_Prev(); } else { $this->Render_First(false); $this->Render_Prev(false); } if ($this->showPageLinks){ $this->Render_PageLinks(); } if (!$this->rs->AtLastPage()) { $this->Render_Next(); $this->Render_Last(); } else { $this->Render_Next(false); $this->Render_Last(false); } $s = ob_get_contents(); ob_end_clean(); return $s; }
php
function RenderNav() { ob_start(); if (!$this->rs->AtFirstPage()) { $this->Render_First(); $this->Render_Prev(); } else { $this->Render_First(false); $this->Render_Prev(false); } if ($this->showPageLinks){ $this->Render_PageLinks(); } if (!$this->rs->AtLastPage()) { $this->Render_Next(); $this->Render_Last(); } else { $this->Render_Next(false); $this->Render_Last(false); } $s = ob_get_contents(); ob_end_clean(); return $s; }
[ "function", "RenderNav", "(", ")", "{", "ob_start", "(", ")", ";", "if", "(", "!", "$", "this", "->", "rs", "->", "AtFirstPage", "(", ")", ")", "{", "$", "this", "->", "Render_First", "(", ")", ";", "$", "this", "->", "Render_Prev", "(", ")", ";", "}", "else", "{", "$", "this", "->", "Render_First", "(", "false", ")", ";", "$", "this", "->", "Render_Prev", "(", "false", ")", ";", "}", "if", "(", "$", "this", "->", "showPageLinks", ")", "{", "$", "this", "->", "Render_PageLinks", "(", ")", ";", "}", "if", "(", "!", "$", "this", "->", "rs", "->", "AtLastPage", "(", ")", ")", "{", "$", "this", "->", "Render_Next", "(", ")", ";", "$", "this", "->", "Render_Last", "(", ")", ";", "}", "else", "{", "$", "this", "->", "Render_Next", "(", "false", ")", ";", "$", "this", "->", "Render_Last", "(", "false", ")", ";", "}", "$", "s", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "return", "$", "s", ";", "}" ]
we use output buffering to keep the code easy to read.
[ "we", "use", "output", "buffering", "to", "keep", "the", "code", "easy", "to", "read", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adodb/adodb-pager.inc.php#L203-L226
214,401
moodle/moodle
lib/adodb/adodb-pager.inc.php
ADODB_Pager.RenderPageCount
function RenderPageCount() { if (!$this->db->pageExecuteCountRows) return ''; $lastPage = $this->rs->LastPageNo(); if ($lastPage == -1) $lastPage = 1; // check for empty rs. if ($this->curr_page > $lastPage) $this->curr_page = 1; return "<font size=-1>$this->page ".$this->curr_page."/".$lastPage."</font>"; }
php
function RenderPageCount() { if (!$this->db->pageExecuteCountRows) return ''; $lastPage = $this->rs->LastPageNo(); if ($lastPage == -1) $lastPage = 1; // check for empty rs. if ($this->curr_page > $lastPage) $this->curr_page = 1; return "<font size=-1>$this->page ".$this->curr_page."/".$lastPage."</font>"; }
[ "function", "RenderPageCount", "(", ")", "{", "if", "(", "!", "$", "this", "->", "db", "->", "pageExecuteCountRows", ")", "return", "''", ";", "$", "lastPage", "=", "$", "this", "->", "rs", "->", "LastPageNo", "(", ")", ";", "if", "(", "$", "lastPage", "==", "-", "1", ")", "$", "lastPage", "=", "1", ";", "// check for empty rs.", "if", "(", "$", "this", "->", "curr_page", ">", "$", "lastPage", ")", "$", "this", "->", "curr_page", "=", "1", ";", "return", "\"<font size=-1>$this->page \"", ".", "$", "this", "->", "curr_page", ".", "\"/\"", ".", "$", "lastPage", ".", "\"</font>\"", ";", "}" ]
This is the footer
[ "This", "is", "the", "footer" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adodb/adodb-pager.inc.php#L230-L237
214,402
moodle/moodle
lib/adodb/adodb-pager.inc.php
ADODB_Pager.Render
function Render($rows=10) { global $ADODB_COUNTRECS; $this->rows = $rows; if ($this->db->dataProvider == 'informix') $this->db->cursorType = IFX_SCROLL; $savec = $ADODB_COUNTRECS; if ($this->db->pageExecuteCountRows) $ADODB_COUNTRECS = true; if ($this->cache) $rs = $this->db->CachePageExecute($this->cache,$this->sql,$rows,$this->curr_page); else $rs = $this->db->PageExecute($this->sql,$rows,$this->curr_page); $ADODB_COUNTRECS = $savec; $this->rs = $rs; if (!$rs) { print "<h3>Query failed: $this->sql</h3>"; return; } if (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage())) $header = $this->RenderNav(); else $header = "&nbsp;"; $grid = $this->RenderGrid(); $footer = $this->RenderPageCount(); $this->RenderLayout($header,$grid,$footer); $rs->Close(); $this->rs = false; }
php
function Render($rows=10) { global $ADODB_COUNTRECS; $this->rows = $rows; if ($this->db->dataProvider == 'informix') $this->db->cursorType = IFX_SCROLL; $savec = $ADODB_COUNTRECS; if ($this->db->pageExecuteCountRows) $ADODB_COUNTRECS = true; if ($this->cache) $rs = $this->db->CachePageExecute($this->cache,$this->sql,$rows,$this->curr_page); else $rs = $this->db->PageExecute($this->sql,$rows,$this->curr_page); $ADODB_COUNTRECS = $savec; $this->rs = $rs; if (!$rs) { print "<h3>Query failed: $this->sql</h3>"; return; } if (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage())) $header = $this->RenderNav(); else $header = "&nbsp;"; $grid = $this->RenderGrid(); $footer = $this->RenderPageCount(); $this->RenderLayout($header,$grid,$footer); $rs->Close(); $this->rs = false; }
[ "function", "Render", "(", "$", "rows", "=", "10", ")", "{", "global", "$", "ADODB_COUNTRECS", ";", "$", "this", "->", "rows", "=", "$", "rows", ";", "if", "(", "$", "this", "->", "db", "->", "dataProvider", "==", "'informix'", ")", "$", "this", "->", "db", "->", "cursorType", "=", "IFX_SCROLL", ";", "$", "savec", "=", "$", "ADODB_COUNTRECS", ";", "if", "(", "$", "this", "->", "db", "->", "pageExecuteCountRows", ")", "$", "ADODB_COUNTRECS", "=", "true", ";", "if", "(", "$", "this", "->", "cache", ")", "$", "rs", "=", "$", "this", "->", "db", "->", "CachePageExecute", "(", "$", "this", "->", "cache", ",", "$", "this", "->", "sql", ",", "$", "rows", ",", "$", "this", "->", "curr_page", ")", ";", "else", "$", "rs", "=", "$", "this", "->", "db", "->", "PageExecute", "(", "$", "this", "->", "sql", ",", "$", "rows", ",", "$", "this", "->", "curr_page", ")", ";", "$", "ADODB_COUNTRECS", "=", "$", "savec", ";", "$", "this", "->", "rs", "=", "$", "rs", ";", "if", "(", "!", "$", "rs", ")", "{", "print", "\"<h3>Query failed: $this->sql</h3>\"", ";", "return", ";", "}", "if", "(", "!", "$", "rs", "->", "EOF", "&&", "(", "!", "$", "rs", "->", "AtFirstPage", "(", ")", "||", "!", "$", "rs", "->", "AtLastPage", "(", ")", ")", ")", "$", "header", "=", "$", "this", "->", "RenderNav", "(", ")", ";", "else", "$", "header", "=", "\"&nbsp;\"", ";", "$", "grid", "=", "$", "this", "->", "RenderGrid", "(", ")", ";", "$", "footer", "=", "$", "this", "->", "RenderPageCount", "(", ")", ";", "$", "this", "->", "RenderLayout", "(", "$", "header", ",", "$", "grid", ",", "$", "footer", ")", ";", "$", "rs", "->", "Close", "(", ")", ";", "$", "this", "->", "rs", "=", "false", ";", "}" ]
Call this class to draw everything.
[ "Call", "this", "class", "to", "draw", "everything", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adodb/adodb-pager.inc.php#L241-L275
214,403
moodle/moodle
lib/classes/dml/recordset_walk.php
recordset_walk.current
public function current() { if (!$this->recordset->valid()) { return false; } if (!$record = $this->recordset->current()) { return false; } // Apply callback and return. if (!is_null($this->callbackextra)) { return call_user_func($this->callback, $record, $this->callbackextra); } else { return call_user_func($this->callback, $record); } }
php
public function current() { if (!$this->recordset->valid()) { return false; } if (!$record = $this->recordset->current()) { return false; } // Apply callback and return. if (!is_null($this->callbackextra)) { return call_user_func($this->callback, $record, $this->callbackextra); } else { return call_user_func($this->callback, $record); } }
[ "public", "function", "current", "(", ")", "{", "if", "(", "!", "$", "this", "->", "recordset", "->", "valid", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "$", "record", "=", "$", "this", "->", "recordset", "->", "current", "(", ")", ")", "{", "return", "false", ";", "}", "// Apply callback and return.", "if", "(", "!", "is_null", "(", "$", "this", "->", "callbackextra", ")", ")", "{", "return", "call_user_func", "(", "$", "this", "->", "callback", ",", "$", "record", ",", "$", "this", "->", "callbackextra", ")", ";", "}", "else", "{", "return", "call_user_func", "(", "$", "this", "->", "callback", ",", "$", "record", ")", ";", "}", "}" ]
Returns the current element after applying the callback. @return mixed|bool The returned value type will depend on the callback.
[ "Returns", "the", "current", "element", "after", "applying", "the", "callback", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/dml/recordset_walk.php#L91-L107
214,404
moodle/moodle
lib/lessphp/Output.php
Less_Output.add
public function add($chunk, $fileInfo = null, $index = 0, $mapLines = null){ $this->strs[] = $chunk; }
php
public function add($chunk, $fileInfo = null, $index = 0, $mapLines = null){ $this->strs[] = $chunk; }
[ "public", "function", "add", "(", "$", "chunk", ",", "$", "fileInfo", "=", "null", ",", "$", "index", "=", "0", ",", "$", "mapLines", "=", "null", ")", "{", "$", "this", "->", "strs", "[", "]", "=", "$", "chunk", ";", "}" ]
Adds a chunk to the stack @param string $chunk The chunk to output @param Less_FileInfo $fileInfo The file information @param integer $index The index @param mixed $mapLines
[ "Adds", "a", "chunk", "to", "the", "stack" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/lessphp/Output.php#L26-L28
214,405
moodle/moodle
question/behaviour/adaptive/renderer.php
qbehaviour_adaptive_renderer.render_adaptive_marks
public function render_adaptive_marks(qbehaviour_adaptive_mark_details $details, question_display_options $options) { if ($details->state == question_state::$todo || $options->marks < question_display_options::MARK_AND_MAX) { // No grades yet. return ''; } // Display the grading details from the last graded state. $class = $details->state->get_feedback_class(); return html_writer::tag('div', get_string($class, 'question'), array('class' => 'correctness ' . $class)) . html_writer::tag('div', $this->grading_details($details, $options), array('class' => 'gradingdetails')); }
php
public function render_adaptive_marks(qbehaviour_adaptive_mark_details $details, question_display_options $options) { if ($details->state == question_state::$todo || $options->marks < question_display_options::MARK_AND_MAX) { // No grades yet. return ''; } // Display the grading details from the last graded state. $class = $details->state->get_feedback_class(); return html_writer::tag('div', get_string($class, 'question'), array('class' => 'correctness ' . $class)) . html_writer::tag('div', $this->grading_details($details, $options), array('class' => 'gradingdetails')); }
[ "public", "function", "render_adaptive_marks", "(", "qbehaviour_adaptive_mark_details", "$", "details", ",", "question_display_options", "$", "options", ")", "{", "if", "(", "$", "details", "->", "state", "==", "question_state", "::", "$", "todo", "||", "$", "options", "->", "marks", "<", "question_display_options", "::", "MARK_AND_MAX", ")", "{", "// No grades yet.", "return", "''", ";", "}", "// Display the grading details from the last graded state.", "$", "class", "=", "$", "details", "->", "state", "->", "get_feedback_class", "(", ")", ";", "return", "html_writer", "::", "tag", "(", "'div'", ",", "get_string", "(", "$", "class", ",", "'question'", ")", ",", "array", "(", "'class'", "=>", "'correctness '", ".", "$", "class", ")", ")", ".", "html_writer", "::", "tag", "(", "'div'", ",", "$", "this", "->", "grading_details", "(", "$", "details", ",", "$", "options", ")", ",", "array", "(", "'class'", "=>", "'gradingdetails'", ")", ")", ";", "}" ]
Display the scoring information about an adaptive attempt. @param qbehaviour_adaptive_mark_details contains all the score details we need. @param question_display_options $options display options.
[ "Display", "the", "scoring", "information", "about", "an", "adaptive", "attempt", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/behaviour/adaptive/renderer.php#L62-L74
214,406
moodle/moodle
question/behaviour/adaptive/renderer.php
qbehaviour_adaptive_renderer.grading_details
protected function grading_details(qbehaviour_adaptive_mark_details $details, question_display_options $options) { $mark = $details->get_formatted_marks($options->markdp); if ($details->currentpenalty == 0 && $details->totalpenalty == 0) { return get_string('gradingdetails', 'qbehaviour_adaptive', $mark); } $output = ''; // Print details of grade adjustment due to penalties if ($details->rawmark != $details->actualmark) { if (!$details->improvable) { return get_string('gradingdetailswithadjustment', 'qbehaviour_adaptive', $mark); } else if ($details->totalpenalty > $details->currentpenalty) { return get_string('gradingdetailswithadjustmenttotalpenalty', 'qbehaviour_adaptive', $mark); } else { return get_string('gradingdetailswithadjustmentpenalty', 'qbehaviour_adaptive', $mark); } } else { if (!$details->improvable) { return get_string('gradingdetails', 'qbehaviour_adaptive', $mark); } else if ($details->totalpenalty > $details->currentpenalty) { return get_string('gradingdetailswithtotalpenalty', 'qbehaviour_adaptive', $mark); } else { return get_string('gradingdetailswithpenalty', 'qbehaviour_adaptive', $mark); } } return $output; }
php
protected function grading_details(qbehaviour_adaptive_mark_details $details, question_display_options $options) { $mark = $details->get_formatted_marks($options->markdp); if ($details->currentpenalty == 0 && $details->totalpenalty == 0) { return get_string('gradingdetails', 'qbehaviour_adaptive', $mark); } $output = ''; // Print details of grade adjustment due to penalties if ($details->rawmark != $details->actualmark) { if (!$details->improvable) { return get_string('gradingdetailswithadjustment', 'qbehaviour_adaptive', $mark); } else if ($details->totalpenalty > $details->currentpenalty) { return get_string('gradingdetailswithadjustmenttotalpenalty', 'qbehaviour_adaptive', $mark); } else { return get_string('gradingdetailswithadjustmentpenalty', 'qbehaviour_adaptive', $mark); } } else { if (!$details->improvable) { return get_string('gradingdetails', 'qbehaviour_adaptive', $mark); } else if ($details->totalpenalty > $details->currentpenalty) { return get_string('gradingdetailswithtotalpenalty', 'qbehaviour_adaptive', $mark); } else { return get_string('gradingdetailswithpenalty', 'qbehaviour_adaptive', $mark); } } return $output; }
[ "protected", "function", "grading_details", "(", "qbehaviour_adaptive_mark_details", "$", "details", ",", "question_display_options", "$", "options", ")", "{", "$", "mark", "=", "$", "details", "->", "get_formatted_marks", "(", "$", "options", "->", "markdp", ")", ";", "if", "(", "$", "details", "->", "currentpenalty", "==", "0", "&&", "$", "details", "->", "totalpenalty", "==", "0", ")", "{", "return", "get_string", "(", "'gradingdetails'", ",", "'qbehaviour_adaptive'", ",", "$", "mark", ")", ";", "}", "$", "output", "=", "''", ";", "// Print details of grade adjustment due to penalties", "if", "(", "$", "details", "->", "rawmark", "!=", "$", "details", "->", "actualmark", ")", "{", "if", "(", "!", "$", "details", "->", "improvable", ")", "{", "return", "get_string", "(", "'gradingdetailswithadjustment'", ",", "'qbehaviour_adaptive'", ",", "$", "mark", ")", ";", "}", "else", "if", "(", "$", "details", "->", "totalpenalty", ">", "$", "details", "->", "currentpenalty", ")", "{", "return", "get_string", "(", "'gradingdetailswithadjustmenttotalpenalty'", ",", "'qbehaviour_adaptive'", ",", "$", "mark", ")", ";", "}", "else", "{", "return", "get_string", "(", "'gradingdetailswithadjustmentpenalty'", ",", "'qbehaviour_adaptive'", ",", "$", "mark", ")", ";", "}", "}", "else", "{", "if", "(", "!", "$", "details", "->", "improvable", ")", "{", "return", "get_string", "(", "'gradingdetails'", ",", "'qbehaviour_adaptive'", ",", "$", "mark", ")", ";", "}", "else", "if", "(", "$", "details", "->", "totalpenalty", ">", "$", "details", "->", "currentpenalty", ")", "{", "return", "get_string", "(", "'gradingdetailswithtotalpenalty'", ",", "'qbehaviour_adaptive'", ",", "$", "mark", ")", ";", "}", "else", "{", "return", "get_string", "(", "'gradingdetailswithpenalty'", ",", "'qbehaviour_adaptive'", ",", "$", "mark", ")", ";", "}", "}", "return", "$", "output", ";", "}" ]
Display the information about the penalty calculations. @param qbehaviour_adaptive_mark_details contains all the score details we need. @param question_display_options $options display options. @return string html fragment
[ "Display", "the", "information", "about", "the", "penalty", "calculations", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/behaviour/adaptive/renderer.php#L82-L113
214,407
moodle/moodle
mod/lti/classes/external.php
mod_lti_external.tool_type_return_structure
private static function tool_type_return_structure() { return new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'Tool type id'), 'name' => new external_value(PARAM_NOTAGS, 'Tool type name'), 'description' => new external_value(PARAM_NOTAGS, 'Tool type description'), 'urls' => new external_single_structure( array( 'icon' => new external_value(PARAM_URL, 'Tool type icon URL'), 'edit' => new external_value(PARAM_URL, 'Tool type edit URL'), 'course' => new external_value(PARAM_URL, 'Tool type edit URL', VALUE_OPTIONAL), ) ), 'state' => new external_single_structure( array( 'text' => new external_value(PARAM_TEXT, 'Tool type state name string'), 'pending' => new external_value(PARAM_BOOL, 'Is the state pending'), 'configured' => new external_value(PARAM_BOOL, 'Is the state configured'), 'rejected' => new external_value(PARAM_BOOL, 'Is the state rejected'), 'unknown' => new external_value(PARAM_BOOL, 'Is the state unknown'), ) ), 'hascapabilitygroups' => new external_value(PARAM_BOOL, 'Indicate if capabilitygroups is populated'), 'capabilitygroups' => new external_multiple_structure( new external_value(PARAM_TEXT, 'Tool type capability groups enabled'), 'Array of capability groups', VALUE_DEFAULT, array() ), 'courseid' => new external_value(PARAM_INT, 'Tool type course', VALUE_DEFAULT, 0), 'instanceids' => new external_multiple_structure( new external_value(PARAM_INT, 'LTI instance ID'), 'IDs for the LTI instances using this type', VALUE_DEFAULT, array() ), 'instancecount' => new external_value(PARAM_INT, 'The number of times this tool is being used') ), 'Tool' ); }
php
private static function tool_type_return_structure() { return new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'Tool type id'), 'name' => new external_value(PARAM_NOTAGS, 'Tool type name'), 'description' => new external_value(PARAM_NOTAGS, 'Tool type description'), 'urls' => new external_single_structure( array( 'icon' => new external_value(PARAM_URL, 'Tool type icon URL'), 'edit' => new external_value(PARAM_URL, 'Tool type edit URL'), 'course' => new external_value(PARAM_URL, 'Tool type edit URL', VALUE_OPTIONAL), ) ), 'state' => new external_single_structure( array( 'text' => new external_value(PARAM_TEXT, 'Tool type state name string'), 'pending' => new external_value(PARAM_BOOL, 'Is the state pending'), 'configured' => new external_value(PARAM_BOOL, 'Is the state configured'), 'rejected' => new external_value(PARAM_BOOL, 'Is the state rejected'), 'unknown' => new external_value(PARAM_BOOL, 'Is the state unknown'), ) ), 'hascapabilitygroups' => new external_value(PARAM_BOOL, 'Indicate if capabilitygroups is populated'), 'capabilitygroups' => new external_multiple_structure( new external_value(PARAM_TEXT, 'Tool type capability groups enabled'), 'Array of capability groups', VALUE_DEFAULT, array() ), 'courseid' => new external_value(PARAM_INT, 'Tool type course', VALUE_DEFAULT, 0), 'instanceids' => new external_multiple_structure( new external_value(PARAM_INT, 'LTI instance ID'), 'IDs for the LTI instances using this type', VALUE_DEFAULT, array() ), 'instancecount' => new external_value(PARAM_INT, 'The number of times this tool is being used') ), 'Tool' ); }
[ "private", "static", "function", "tool_type_return_structure", "(", ")", "{", "return", "new", "external_single_structure", "(", "array", "(", "'id'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Tool type id'", ")", ",", "'name'", "=>", "new", "external_value", "(", "PARAM_NOTAGS", ",", "'Tool type name'", ")", ",", "'description'", "=>", "new", "external_value", "(", "PARAM_NOTAGS", ",", "'Tool type description'", ")", ",", "'urls'", "=>", "new", "external_single_structure", "(", "array", "(", "'icon'", "=>", "new", "external_value", "(", "PARAM_URL", ",", "'Tool type icon URL'", ")", ",", "'edit'", "=>", "new", "external_value", "(", "PARAM_URL", ",", "'Tool type edit URL'", ")", ",", "'course'", "=>", "new", "external_value", "(", "PARAM_URL", ",", "'Tool type edit URL'", ",", "VALUE_OPTIONAL", ")", ",", ")", ")", ",", "'state'", "=>", "new", "external_single_structure", "(", "array", "(", "'text'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'Tool type state name string'", ")", ",", "'pending'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'Is the state pending'", ")", ",", "'configured'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'Is the state configured'", ")", ",", "'rejected'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'Is the state rejected'", ")", ",", "'unknown'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'Is the state unknown'", ")", ",", ")", ")", ",", "'hascapabilitygroups'", "=>", "new", "external_value", "(", "PARAM_BOOL", ",", "'Indicate if capabilitygroups is populated'", ")", ",", "'capabilitygroups'", "=>", "new", "external_multiple_structure", "(", "new", "external_value", "(", "PARAM_TEXT", ",", "'Tool type capability groups enabled'", ")", ",", "'Array of capability groups'", ",", "VALUE_DEFAULT", ",", "array", "(", ")", ")", ",", "'courseid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Tool type course'", ",", "VALUE_DEFAULT", ",", "0", ")", ",", "'instanceids'", "=>", "new", "external_multiple_structure", "(", "new", "external_value", "(", "PARAM_INT", ",", "'LTI instance ID'", ")", ",", "'IDs for the LTI instances using this type'", ",", "VALUE_DEFAULT", ",", "array", "(", ")", ")", ",", "'instancecount'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'The number of times this tool is being used'", ")", ")", ",", "'Tool'", ")", ";", "}" ]
Returns structure be used for returning a tool type from a web service. @return external_function_parameters @since Moodle 3.1
[ "Returns", "structure", "be", "used", "for", "returning", "a", "tool", "type", "from", "a", "web", "service", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lti/classes/external.php#L50-L85
214,408
moodle/moodle
mod/lti/classes/external.php
mod_lti_external.tool_proxy_return_structure
private static function tool_proxy_return_structure() { return new external_function_parameters( array( 'id' => new external_value(PARAM_INT, 'Tool proxy id'), 'name' => new external_value(PARAM_TEXT, 'Tool proxy name'), 'regurl' => new external_value(PARAM_URL, 'Tool proxy registration URL'), 'state' => new external_value(PARAM_INT, 'Tool proxy state'), 'guid' => new external_value(PARAM_TEXT, 'Tool proxy globally unique identifier'), 'secret' => new external_value(PARAM_TEXT, 'Tool proxy shared secret'), 'vendorcode' => new external_value(PARAM_TEXT, 'Tool proxy consumer code'), 'capabilityoffered' => new external_value(PARAM_TEXT, 'Tool proxy capabilities offered'), 'serviceoffered' => new external_value(PARAM_TEXT, 'Tool proxy services offered'), 'toolproxy' => new external_value(PARAM_TEXT, 'Tool proxy'), 'timecreated' => new external_value(PARAM_INT, 'Tool proxy time created'), 'timemodified' => new external_value(PARAM_INT, 'Tool proxy modified'), ) ); }
php
private static function tool_proxy_return_structure() { return new external_function_parameters( array( 'id' => new external_value(PARAM_INT, 'Tool proxy id'), 'name' => new external_value(PARAM_TEXT, 'Tool proxy name'), 'regurl' => new external_value(PARAM_URL, 'Tool proxy registration URL'), 'state' => new external_value(PARAM_INT, 'Tool proxy state'), 'guid' => new external_value(PARAM_TEXT, 'Tool proxy globally unique identifier'), 'secret' => new external_value(PARAM_TEXT, 'Tool proxy shared secret'), 'vendorcode' => new external_value(PARAM_TEXT, 'Tool proxy consumer code'), 'capabilityoffered' => new external_value(PARAM_TEXT, 'Tool proxy capabilities offered'), 'serviceoffered' => new external_value(PARAM_TEXT, 'Tool proxy services offered'), 'toolproxy' => new external_value(PARAM_TEXT, 'Tool proxy'), 'timecreated' => new external_value(PARAM_INT, 'Tool proxy time created'), 'timemodified' => new external_value(PARAM_INT, 'Tool proxy modified'), ) ); }
[ "private", "static", "function", "tool_proxy_return_structure", "(", ")", "{", "return", "new", "external_function_parameters", "(", "array", "(", "'id'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Tool proxy id'", ")", ",", "'name'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'Tool proxy name'", ")", ",", "'regurl'", "=>", "new", "external_value", "(", "PARAM_URL", ",", "'Tool proxy registration URL'", ")", ",", "'state'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Tool proxy state'", ")", ",", "'guid'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'Tool proxy globally unique identifier'", ")", ",", "'secret'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'Tool proxy shared secret'", ")", ",", "'vendorcode'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'Tool proxy consumer code'", ")", ",", "'capabilityoffered'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'Tool proxy capabilities offered'", ")", ",", "'serviceoffered'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'Tool proxy services offered'", ")", ",", "'toolproxy'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'Tool proxy'", ")", ",", "'timecreated'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Tool proxy time created'", ")", ",", "'timemodified'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Tool proxy modified'", ")", ",", ")", ")", ";", "}" ]
Returns description of a tool proxy @return external_function_parameters @since Moodle 3.1
[ "Returns", "description", "of", "a", "tool", "proxy" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lti/classes/external.php#L93-L110
214,409
moodle/moodle
mod/lti/classes/external.php
mod_lti_external.get_tool_launch_data
public static function get_tool_launch_data($toolid) { global $DB, $CFG; require_once($CFG->dirroot . '/mod/lti/lib.php'); $params = self::validate_parameters(self::get_tool_launch_data_parameters(), array( 'toolid' => $toolid )); $warnings = array(); // Request and permission validation. $lti = $DB->get_record('lti', array('id' => $params['toolid']), '*', MUST_EXIST); list($course, $cm) = get_course_and_cm_from_instance($lti, 'lti'); $context = context_module::instance($cm->id); self::validate_context($context); require_capability('mod/lti:view', $context); $lti->cmid = $cm->id; list($endpoint, $parms) = lti_get_launch_data($lti); $parameters = array(); foreach ($parms as $name => $value) { $parameters[] = array( 'name' => $name, 'value' => $value ); } $result = array(); $result['endpoint'] = $endpoint; $result['parameters'] = $parameters; $result['warnings'] = $warnings; return $result; }
php
public static function get_tool_launch_data($toolid) { global $DB, $CFG; require_once($CFG->dirroot . '/mod/lti/lib.php'); $params = self::validate_parameters(self::get_tool_launch_data_parameters(), array( 'toolid' => $toolid )); $warnings = array(); // Request and permission validation. $lti = $DB->get_record('lti', array('id' => $params['toolid']), '*', MUST_EXIST); list($course, $cm) = get_course_and_cm_from_instance($lti, 'lti'); $context = context_module::instance($cm->id); self::validate_context($context); require_capability('mod/lti:view', $context); $lti->cmid = $cm->id; list($endpoint, $parms) = lti_get_launch_data($lti); $parameters = array(); foreach ($parms as $name => $value) { $parameters[] = array( 'name' => $name, 'value' => $value ); } $result = array(); $result['endpoint'] = $endpoint; $result['parameters'] = $parameters; $result['warnings'] = $warnings; return $result; }
[ "public", "static", "function", "get_tool_launch_data", "(", "$", "toolid", ")", "{", "global", "$", "DB", ",", "$", "CFG", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/mod/lti/lib.php'", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_tool_launch_data_parameters", "(", ")", ",", "array", "(", "'toolid'", "=>", "$", "toolid", ")", ")", ";", "$", "warnings", "=", "array", "(", ")", ";", "// Request and permission validation.", "$", "lti", "=", "$", "DB", "->", "get_record", "(", "'lti'", ",", "array", "(", "'id'", "=>", "$", "params", "[", "'toolid'", "]", ")", ",", "'*'", ",", "MUST_EXIST", ")", ";", "list", "(", "$", "course", ",", "$", "cm", ")", "=", "get_course_and_cm_from_instance", "(", "$", "lti", ",", "'lti'", ")", ";", "$", "context", "=", "context_module", "::", "instance", "(", "$", "cm", "->", "id", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "require_capability", "(", "'mod/lti:view'", ",", "$", "context", ")", ";", "$", "lti", "->", "cmid", "=", "$", "cm", "->", "id", ";", "list", "(", "$", "endpoint", ",", "$", "parms", ")", "=", "lti_get_launch_data", "(", "$", "lti", ")", ";", "$", "parameters", "=", "array", "(", ")", ";", "foreach", "(", "$", "parms", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "parameters", "[", "]", "=", "array", "(", "'name'", "=>", "$", "name", ",", "'value'", "=>", "$", "value", ")", ";", "}", "$", "result", "=", "array", "(", ")", ";", "$", "result", "[", "'endpoint'", "]", "=", "$", "endpoint", ";", "$", "result", "[", "'parameters'", "]", "=", "$", "parameters", ";", "$", "result", "[", "'warnings'", "]", "=", "$", "warnings", ";", "return", "$", "result", ";", "}" ]
Return the launch data for a given external tool. @param int $toolid the external tool instance id @return array of warnings and launch data @since Moodle 3.0 @throws moodle_exception
[ "Return", "the", "launch", "data", "for", "a", "given", "external", "tool", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lti/classes/external.php#L187-L222
214,410
moodle/moodle
mod/lti/classes/external.php
mod_lti_external.get_ltis_by_courses
public static function get_ltis_by_courses($courseids = array()) { global $CFG; $returnedltis = array(); $warnings = array(); $params = self::validate_parameters(self::get_ltis_by_courses_parameters(), array('courseids' => $courseids)); $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); // Get the ltis in this course, this function checks users visibility permissions. // We can avoid then additional validate_context calls. $ltis = get_all_instances_in_courses("lti", $courses); foreach ($ltis as $lti) { $context = context_module::instance($lti->coursemodule); // Entry to return. $module = array(); // First, we return information that any user can see in (or can deduce from) the web interface. $module['id'] = $lti->id; $module['coursemodule'] = $lti->coursemodule; $module['course'] = $lti->course; $module['name'] = external_format_string($lti->name, $context->id); $viewablefields = []; if (has_capability('mod/lti:view', $context)) { list($module['intro'], $module['introformat']) = external_format_text($lti->intro, $lti->introformat, $context->id, 'mod_lti', 'intro', null); $module['introfiles'] = external_util::get_area_files($context->id, 'mod_lti', 'intro', false, false); $viewablefields = array('launchcontainer', 'showtitlelaunch', 'showdescriptionlaunch', 'icon', 'secureicon'); } // Check additional permissions for returning optional private settings. if (has_capability('moodle/course:manageactivities', $context)) { $additionalfields = array('timecreated', 'timemodified', 'typeid', 'toolurl', 'securetoolurl', 'instructorchoicesendname', 'instructorchoicesendemailaddr', 'instructorchoiceallowroster', 'instructorchoiceallowsetting', 'instructorcustomparameters', 'instructorchoiceacceptgrades', 'grade', 'resourcekey', 'password', 'debuglaunch', 'servicesalt', 'visible', 'groupmode', 'groupingid'); $viewablefields = array_merge($viewablefields, $additionalfields); } foreach ($viewablefields as $field) { $module[$field] = $lti->{$field}; } $returnedltis[] = $module; } } $result = array(); $result['ltis'] = $returnedltis; $result['warnings'] = $warnings; return $result; }
php
public static function get_ltis_by_courses($courseids = array()) { global $CFG; $returnedltis = array(); $warnings = array(); $params = self::validate_parameters(self::get_ltis_by_courses_parameters(), array('courseids' => $courseids)); $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); // Get the ltis in this course, this function checks users visibility permissions. // We can avoid then additional validate_context calls. $ltis = get_all_instances_in_courses("lti", $courses); foreach ($ltis as $lti) { $context = context_module::instance($lti->coursemodule); // Entry to return. $module = array(); // First, we return information that any user can see in (or can deduce from) the web interface. $module['id'] = $lti->id; $module['coursemodule'] = $lti->coursemodule; $module['course'] = $lti->course; $module['name'] = external_format_string($lti->name, $context->id); $viewablefields = []; if (has_capability('mod/lti:view', $context)) { list($module['intro'], $module['introformat']) = external_format_text($lti->intro, $lti->introformat, $context->id, 'mod_lti', 'intro', null); $module['introfiles'] = external_util::get_area_files($context->id, 'mod_lti', 'intro', false, false); $viewablefields = array('launchcontainer', 'showtitlelaunch', 'showdescriptionlaunch', 'icon', 'secureicon'); } // Check additional permissions for returning optional private settings. if (has_capability('moodle/course:manageactivities', $context)) { $additionalfields = array('timecreated', 'timemodified', 'typeid', 'toolurl', 'securetoolurl', 'instructorchoicesendname', 'instructorchoicesendemailaddr', 'instructorchoiceallowroster', 'instructorchoiceallowsetting', 'instructorcustomparameters', 'instructorchoiceacceptgrades', 'grade', 'resourcekey', 'password', 'debuglaunch', 'servicesalt', 'visible', 'groupmode', 'groupingid'); $viewablefields = array_merge($viewablefields, $additionalfields); } foreach ($viewablefields as $field) { $module[$field] = $lti->{$field}; } $returnedltis[] = $module; } } $result = array(); $result['ltis'] = $returnedltis; $result['warnings'] = $warnings; return $result; }
[ "public", "static", "function", "get_ltis_by_courses", "(", "$", "courseids", "=", "array", "(", ")", ")", "{", "global", "$", "CFG", ";", "$", "returnedltis", "=", "array", "(", ")", ";", "$", "warnings", "=", "array", "(", ")", ";", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_ltis_by_courses_parameters", "(", ")", ",", "array", "(", "'courseids'", "=>", "$", "courseids", ")", ")", ";", "$", "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", ")", ";", "// Get the ltis in this course, this function checks users visibility permissions.", "// We can avoid then additional validate_context calls.", "$", "ltis", "=", "get_all_instances_in_courses", "(", "\"lti\"", ",", "$", "courses", ")", ";", "foreach", "(", "$", "ltis", "as", "$", "lti", ")", "{", "$", "context", "=", "context_module", "::", "instance", "(", "$", "lti", "->", "coursemodule", ")", ";", "// Entry to return.", "$", "module", "=", "array", "(", ")", ";", "// First, we return information that any user can see in (or can deduce from) the web interface.", "$", "module", "[", "'id'", "]", "=", "$", "lti", "->", "id", ";", "$", "module", "[", "'coursemodule'", "]", "=", "$", "lti", "->", "coursemodule", ";", "$", "module", "[", "'course'", "]", "=", "$", "lti", "->", "course", ";", "$", "module", "[", "'name'", "]", "=", "external_format_string", "(", "$", "lti", "->", "name", ",", "$", "context", "->", "id", ")", ";", "$", "viewablefields", "=", "[", "]", ";", "if", "(", "has_capability", "(", "'mod/lti:view'", ",", "$", "context", ")", ")", "{", "list", "(", "$", "module", "[", "'intro'", "]", ",", "$", "module", "[", "'introformat'", "]", ")", "=", "external_format_text", "(", "$", "lti", "->", "intro", ",", "$", "lti", "->", "introformat", ",", "$", "context", "->", "id", ",", "'mod_lti'", ",", "'intro'", ",", "null", ")", ";", "$", "module", "[", "'introfiles'", "]", "=", "external_util", "::", "get_area_files", "(", "$", "context", "->", "id", ",", "'mod_lti'", ",", "'intro'", ",", "false", ",", "false", ")", ";", "$", "viewablefields", "=", "array", "(", "'launchcontainer'", ",", "'showtitlelaunch'", ",", "'showdescriptionlaunch'", ",", "'icon'", ",", "'secureicon'", ")", ";", "}", "// Check additional permissions for returning optional private settings.", "if", "(", "has_capability", "(", "'moodle/course:manageactivities'", ",", "$", "context", ")", ")", "{", "$", "additionalfields", "=", "array", "(", "'timecreated'", ",", "'timemodified'", ",", "'typeid'", ",", "'toolurl'", ",", "'securetoolurl'", ",", "'instructorchoicesendname'", ",", "'instructorchoicesendemailaddr'", ",", "'instructorchoiceallowroster'", ",", "'instructorchoiceallowsetting'", ",", "'instructorcustomparameters'", ",", "'instructorchoiceacceptgrades'", ",", "'grade'", ",", "'resourcekey'", ",", "'password'", ",", "'debuglaunch'", ",", "'servicesalt'", ",", "'visible'", ",", "'groupmode'", ",", "'groupingid'", ")", ";", "$", "viewablefields", "=", "array_merge", "(", "$", "viewablefields", ",", "$", "additionalfields", ")", ";", "}", "foreach", "(", "$", "viewablefields", "as", "$", "field", ")", "{", "$", "module", "[", "$", "field", "]", "=", "$", "lti", "->", "{", "$", "field", "}", ";", "}", "$", "returnedltis", "[", "]", "=", "$", "module", ";", "}", "}", "$", "result", "=", "array", "(", ")", ";", "$", "result", "[", "'ltis'", "]", "=", "$", "returnedltis", ";", "$", "result", "[", "'warnings'", "]", "=", "$", "warnings", ";", "return", "$", "result", ";", "}" ]
Returns a list of external tools in a provided list of courses, if no list is provided all external tools that the user can view will be returned. @param array $courseids the course ids @return array the lti details @since Moodle 3.0
[ "Returns", "a", "list", "of", "external", "tools", "in", "a", "provided", "list", "of", "courses", "if", "no", "list", "is", "provided", "all", "external", "tools", "that", "the", "user", "can", "view", "will", "be", "returned", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lti/classes/external.php#L271-L339
214,411
moodle/moodle
mod/lti/classes/external.php
mod_lti_external.get_ltis_by_courses_returns
public static function get_ltis_by_courses_returns() { return new external_single_structure( array( 'ltis' => new external_multiple_structure( new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'External tool id'), 'coursemodule' => new external_value(PARAM_INT, 'Course module id'), 'course' => new external_value(PARAM_INT, 'Course id'), 'name' => new external_value(PARAM_RAW, 'LTI name'), 'intro' => new external_value(PARAM_RAW, 'The LTI intro', VALUE_OPTIONAL), 'introformat' => new external_format_value('intro', VALUE_OPTIONAL), 'introfiles' => new external_files('Files in the introduction text', VALUE_OPTIONAL), 'timecreated' => new external_value(PARAM_INT, 'Time of creation', VALUE_OPTIONAL), 'timemodified' => new external_value(PARAM_INT, 'Time of last modification', VALUE_OPTIONAL), 'typeid' => new external_value(PARAM_INT, 'Type id', VALUE_OPTIONAL), 'toolurl' => new external_value(PARAM_URL, 'Tool url', VALUE_OPTIONAL), 'securetoolurl' => new external_value(PARAM_RAW, 'Secure tool url', VALUE_OPTIONAL), 'instructorchoicesendname' => new external_value(PARAM_TEXT, 'Instructor choice send name', VALUE_OPTIONAL), 'instructorchoicesendemailaddr' => new external_value(PARAM_INT, 'instructor choice send mail address', VALUE_OPTIONAL), 'instructorchoiceallowroster' => new external_value(PARAM_INT, 'Instructor choice allow roster', VALUE_OPTIONAL), 'instructorchoiceallowsetting' => new external_value(PARAM_INT, 'Instructor choice allow setting', VALUE_OPTIONAL), 'instructorcustomparameters' => new external_value(PARAM_RAW, 'instructor custom parameters', VALUE_OPTIONAL), 'instructorchoiceacceptgrades' => new external_value(PARAM_INT, 'instructor choice accept grades', VALUE_OPTIONAL), 'grade' => new external_value(PARAM_INT, 'Enable grades', VALUE_OPTIONAL), 'launchcontainer' => new external_value(PARAM_INT, 'Launch container mode', VALUE_OPTIONAL), 'resourcekey' => new external_value(PARAM_RAW, 'Resource key', VALUE_OPTIONAL), 'password' => new external_value(PARAM_RAW, 'Shared secret', VALUE_OPTIONAL), 'debuglaunch' => new external_value(PARAM_INT, 'Debug launch', VALUE_OPTIONAL), 'showtitlelaunch' => new external_value(PARAM_INT, 'Show title launch', VALUE_OPTIONAL), 'showdescriptionlaunch' => new external_value(PARAM_INT, 'Show description launch', VALUE_OPTIONAL), 'servicesalt' => new external_value(PARAM_RAW, 'Service salt', VALUE_OPTIONAL), 'icon' => new external_value(PARAM_URL, 'Alternative icon URL', VALUE_OPTIONAL), 'secureicon' => new external_value(PARAM_URL, 'Secure icon URL', VALUE_OPTIONAL), 'section' => new external_value(PARAM_INT, 'course section id', VALUE_OPTIONAL), 'visible' => new external_value(PARAM_INT, 'visible', VALUE_OPTIONAL), 'groupmode' => new external_value(PARAM_INT, 'group mode', VALUE_OPTIONAL), 'groupingid' => new external_value(PARAM_INT, 'group id', VALUE_OPTIONAL), ), 'Tool' ) ), 'warnings' => new external_warnings(), ) ); }
php
public static function get_ltis_by_courses_returns() { return new external_single_structure( array( 'ltis' => new external_multiple_structure( new external_single_structure( array( 'id' => new external_value(PARAM_INT, 'External tool id'), 'coursemodule' => new external_value(PARAM_INT, 'Course module id'), 'course' => new external_value(PARAM_INT, 'Course id'), 'name' => new external_value(PARAM_RAW, 'LTI name'), 'intro' => new external_value(PARAM_RAW, 'The LTI intro', VALUE_OPTIONAL), 'introformat' => new external_format_value('intro', VALUE_OPTIONAL), 'introfiles' => new external_files('Files in the introduction text', VALUE_OPTIONAL), 'timecreated' => new external_value(PARAM_INT, 'Time of creation', VALUE_OPTIONAL), 'timemodified' => new external_value(PARAM_INT, 'Time of last modification', VALUE_OPTIONAL), 'typeid' => new external_value(PARAM_INT, 'Type id', VALUE_OPTIONAL), 'toolurl' => new external_value(PARAM_URL, 'Tool url', VALUE_OPTIONAL), 'securetoolurl' => new external_value(PARAM_RAW, 'Secure tool url', VALUE_OPTIONAL), 'instructorchoicesendname' => new external_value(PARAM_TEXT, 'Instructor choice send name', VALUE_OPTIONAL), 'instructorchoicesendemailaddr' => new external_value(PARAM_INT, 'instructor choice send mail address', VALUE_OPTIONAL), 'instructorchoiceallowroster' => new external_value(PARAM_INT, 'Instructor choice allow roster', VALUE_OPTIONAL), 'instructorchoiceallowsetting' => new external_value(PARAM_INT, 'Instructor choice allow setting', VALUE_OPTIONAL), 'instructorcustomparameters' => new external_value(PARAM_RAW, 'instructor custom parameters', VALUE_OPTIONAL), 'instructorchoiceacceptgrades' => new external_value(PARAM_INT, 'instructor choice accept grades', VALUE_OPTIONAL), 'grade' => new external_value(PARAM_INT, 'Enable grades', VALUE_OPTIONAL), 'launchcontainer' => new external_value(PARAM_INT, 'Launch container mode', VALUE_OPTIONAL), 'resourcekey' => new external_value(PARAM_RAW, 'Resource key', VALUE_OPTIONAL), 'password' => new external_value(PARAM_RAW, 'Shared secret', VALUE_OPTIONAL), 'debuglaunch' => new external_value(PARAM_INT, 'Debug launch', VALUE_OPTIONAL), 'showtitlelaunch' => new external_value(PARAM_INT, 'Show title launch', VALUE_OPTIONAL), 'showdescriptionlaunch' => new external_value(PARAM_INT, 'Show description launch', VALUE_OPTIONAL), 'servicesalt' => new external_value(PARAM_RAW, 'Service salt', VALUE_OPTIONAL), 'icon' => new external_value(PARAM_URL, 'Alternative icon URL', VALUE_OPTIONAL), 'secureicon' => new external_value(PARAM_URL, 'Secure icon URL', VALUE_OPTIONAL), 'section' => new external_value(PARAM_INT, 'course section id', VALUE_OPTIONAL), 'visible' => new external_value(PARAM_INT, 'visible', VALUE_OPTIONAL), 'groupmode' => new external_value(PARAM_INT, 'group mode', VALUE_OPTIONAL), 'groupingid' => new external_value(PARAM_INT, 'group id', VALUE_OPTIONAL), ), 'Tool' ) ), 'warnings' => new external_warnings(), ) ); }
[ "public", "static", "function", "get_ltis_by_courses_returns", "(", ")", "{", "return", "new", "external_single_structure", "(", "array", "(", "'ltis'", "=>", "new", "external_multiple_structure", "(", "new", "external_single_structure", "(", "array", "(", "'id'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'External tool id'", ")", ",", "'coursemodule'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Course module id'", ")", ",", "'course'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Course id'", ")", ",", "'name'", "=>", "new", "external_value", "(", "PARAM_RAW", ",", "'LTI name'", ")", ",", "'intro'", "=>", "new", "external_value", "(", "PARAM_RAW", ",", "'The LTI intro'", ",", "VALUE_OPTIONAL", ")", ",", "'introformat'", "=>", "new", "external_format_value", "(", "'intro'", ",", "VALUE_OPTIONAL", ")", ",", "'introfiles'", "=>", "new", "external_files", "(", "'Files in the introduction text'", ",", "VALUE_OPTIONAL", ")", ",", "'timecreated'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Time of creation'", ",", "VALUE_OPTIONAL", ")", ",", "'timemodified'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Time of last modification'", ",", "VALUE_OPTIONAL", ")", ",", "'typeid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Type id'", ",", "VALUE_OPTIONAL", ")", ",", "'toolurl'", "=>", "new", "external_value", "(", "PARAM_URL", ",", "'Tool url'", ",", "VALUE_OPTIONAL", ")", ",", "'securetoolurl'", "=>", "new", "external_value", "(", "PARAM_RAW", ",", "'Secure tool url'", ",", "VALUE_OPTIONAL", ")", ",", "'instructorchoicesendname'", "=>", "new", "external_value", "(", "PARAM_TEXT", ",", "'Instructor choice send name'", ",", "VALUE_OPTIONAL", ")", ",", "'instructorchoicesendemailaddr'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'instructor choice send mail address'", ",", "VALUE_OPTIONAL", ")", ",", "'instructorchoiceallowroster'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Instructor choice allow roster'", ",", "VALUE_OPTIONAL", ")", ",", "'instructorchoiceallowsetting'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Instructor choice allow setting'", ",", "VALUE_OPTIONAL", ")", ",", "'instructorcustomparameters'", "=>", "new", "external_value", "(", "PARAM_RAW", ",", "'instructor custom parameters'", ",", "VALUE_OPTIONAL", ")", ",", "'instructorchoiceacceptgrades'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'instructor choice accept grades'", ",", "VALUE_OPTIONAL", ")", ",", "'grade'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Enable grades'", ",", "VALUE_OPTIONAL", ")", ",", "'launchcontainer'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Launch container mode'", ",", "VALUE_OPTIONAL", ")", ",", "'resourcekey'", "=>", "new", "external_value", "(", "PARAM_RAW", ",", "'Resource key'", ",", "VALUE_OPTIONAL", ")", ",", "'password'", "=>", "new", "external_value", "(", "PARAM_RAW", ",", "'Shared secret'", ",", "VALUE_OPTIONAL", ")", ",", "'debuglaunch'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Debug launch'", ",", "VALUE_OPTIONAL", ")", ",", "'showtitlelaunch'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Show title launch'", ",", "VALUE_OPTIONAL", ")", ",", "'showdescriptionlaunch'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'Show description launch'", ",", "VALUE_OPTIONAL", ")", ",", "'servicesalt'", "=>", "new", "external_value", "(", "PARAM_RAW", ",", "'Service salt'", ",", "VALUE_OPTIONAL", ")", ",", "'icon'", "=>", "new", "external_value", "(", "PARAM_URL", ",", "'Alternative icon URL'", ",", "VALUE_OPTIONAL", ")", ",", "'secureicon'", "=>", "new", "external_value", "(", "PARAM_URL", ",", "'Secure icon URL'", ",", "VALUE_OPTIONAL", ")", ",", "'section'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'course section id'", ",", "VALUE_OPTIONAL", ")", ",", "'visible'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'visible'", ",", "VALUE_OPTIONAL", ")", ",", "'groupmode'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'group mode'", ",", "VALUE_OPTIONAL", ")", ",", "'groupingid'", "=>", "new", "external_value", "(", "PARAM_INT", ",", "'group id'", ",", "VALUE_OPTIONAL", ")", ",", ")", ",", "'Tool'", ")", ")", ",", "'warnings'", "=>", "new", "external_warnings", "(", ")", ",", ")", ")", ";", "}" ]
Describes the get_ltis_by_courses return value. @return external_single_structure @since Moodle 3.0
[ "Describes", "the", "get_ltis_by_courses", "return", "value", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lti/classes/external.php#L347-L398
214,412
moodle/moodle
mod/lti/classes/external.php
mod_lti_external.create_tool_proxy
public static function create_tool_proxy($name, $registrationurl, $capabilityoffered, $serviceoffered) { $params = self::validate_parameters(self::create_tool_proxy_parameters(), array( 'name' => $name, 'regurl' => $registrationurl, 'capabilityoffered' => $capabilityoffered, 'serviceoffered' => $serviceoffered )); $name = $params['name']; $regurl = $params['regurl']; $capabilityoffered = $params['capabilityoffered']; $serviceoffered = $params['serviceoffered']; $context = context_system::instance(); self::validate_context($context); require_capability('moodle/site:config', $context); // Can't create duplicate proxies with the same URL. $duplicates = lti_get_tool_proxies_from_registration_url($registrationurl); if (!empty($duplicates)) { throw new moodle_exception('duplicateregurl', 'mod_lti'); } $config = new stdClass(); $config->lti_registrationurl = $registrationurl; if (!empty($name)) { $config->lti_registrationname = $name; } if (!empty($capabilityoffered)) { $config->lti_capabilities = $capabilityoffered; } if (!empty($serviceoffered)) { $config->lti_services = $serviceoffered; } $id = lti_add_tool_proxy($config); $toolproxy = lti_get_tool_proxy($id); // Pending makes more sense than configured as the first state, since // the next step is to register, which requires the state be pending. $toolproxy->state = LTI_TOOL_PROXY_STATE_PENDING; lti_update_tool_proxy($toolproxy); return $toolproxy; }
php
public static function create_tool_proxy($name, $registrationurl, $capabilityoffered, $serviceoffered) { $params = self::validate_parameters(self::create_tool_proxy_parameters(), array( 'name' => $name, 'regurl' => $registrationurl, 'capabilityoffered' => $capabilityoffered, 'serviceoffered' => $serviceoffered )); $name = $params['name']; $regurl = $params['regurl']; $capabilityoffered = $params['capabilityoffered']; $serviceoffered = $params['serviceoffered']; $context = context_system::instance(); self::validate_context($context); require_capability('moodle/site:config', $context); // Can't create duplicate proxies with the same URL. $duplicates = lti_get_tool_proxies_from_registration_url($registrationurl); if (!empty($duplicates)) { throw new moodle_exception('duplicateregurl', 'mod_lti'); } $config = new stdClass(); $config->lti_registrationurl = $registrationurl; if (!empty($name)) { $config->lti_registrationname = $name; } if (!empty($capabilityoffered)) { $config->lti_capabilities = $capabilityoffered; } if (!empty($serviceoffered)) { $config->lti_services = $serviceoffered; } $id = lti_add_tool_proxy($config); $toolproxy = lti_get_tool_proxy($id); // Pending makes more sense than configured as the first state, since // the next step is to register, which requires the state be pending. $toolproxy->state = LTI_TOOL_PROXY_STATE_PENDING; lti_update_tool_proxy($toolproxy); return $toolproxy; }
[ "public", "static", "function", "create_tool_proxy", "(", "$", "name", ",", "$", "registrationurl", ",", "$", "capabilityoffered", ",", "$", "serviceoffered", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "create_tool_proxy_parameters", "(", ")", ",", "array", "(", "'name'", "=>", "$", "name", ",", "'regurl'", "=>", "$", "registrationurl", ",", "'capabilityoffered'", "=>", "$", "capabilityoffered", ",", "'serviceoffered'", "=>", "$", "serviceoffered", ")", ")", ";", "$", "name", "=", "$", "params", "[", "'name'", "]", ";", "$", "regurl", "=", "$", "params", "[", "'regurl'", "]", ";", "$", "capabilityoffered", "=", "$", "params", "[", "'capabilityoffered'", "]", ";", "$", "serviceoffered", "=", "$", "params", "[", "'serviceoffered'", "]", ";", "$", "context", "=", "context_system", "::", "instance", "(", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "require_capability", "(", "'moodle/site:config'", ",", "$", "context", ")", ";", "// Can't create duplicate proxies with the same URL.", "$", "duplicates", "=", "lti_get_tool_proxies_from_registration_url", "(", "$", "registrationurl", ")", ";", "if", "(", "!", "empty", "(", "$", "duplicates", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'duplicateregurl'", ",", "'mod_lti'", ")", ";", "}", "$", "config", "=", "new", "stdClass", "(", ")", ";", "$", "config", "->", "lti_registrationurl", "=", "$", "registrationurl", ";", "if", "(", "!", "empty", "(", "$", "name", ")", ")", "{", "$", "config", "->", "lti_registrationname", "=", "$", "name", ";", "}", "if", "(", "!", "empty", "(", "$", "capabilityoffered", ")", ")", "{", "$", "config", "->", "lti_capabilities", "=", "$", "capabilityoffered", ";", "}", "if", "(", "!", "empty", "(", "$", "serviceoffered", ")", ")", "{", "$", "config", "->", "lti_services", "=", "$", "serviceoffered", ";", "}", "$", "id", "=", "lti_add_tool_proxy", "(", "$", "config", ")", ";", "$", "toolproxy", "=", "lti_get_tool_proxy", "(", "$", "id", ")", ";", "// Pending makes more sense than configured as the first state, since", "// the next step is to register, which requires the state be pending.", "$", "toolproxy", "->", "state", "=", "LTI_TOOL_PROXY_STATE_PENDING", ";", "lti_update_tool_proxy", "(", "$", "toolproxy", ")", ";", "return", "$", "toolproxy", ";", "}" ]
Creates a new tool proxy @param string $name Tool proxy name @param string $registrationurl Registration url @param string[] $capabilityoffered List of capabilities this tool proxy should be offered @param string[] $serviceoffered List of services this tool proxy should be offered @return object The new tool proxy @since Moodle 3.1 @throws moodle_exception
[ "Creates", "a", "new", "tool", "proxy" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lti/classes/external.php#L497-L544
214,413
moodle/moodle
mod/lti/classes/external.php
mod_lti_external.get_tool_proxy_registration_request
public static function get_tool_proxy_registration_request($id) { $params = self::validate_parameters(self::get_tool_proxy_registration_request_parameters(), array( 'id' => $id, )); $id = $params['id']; $context = context_system::instance(); self::validate_context($context); require_capability('moodle/site:config', $context); $toolproxy = lti_get_tool_proxy($id); return lti_build_registration_request($toolproxy); }
php
public static function get_tool_proxy_registration_request($id) { $params = self::validate_parameters(self::get_tool_proxy_registration_request_parameters(), array( 'id' => $id, )); $id = $params['id']; $context = context_system::instance(); self::validate_context($context); require_capability('moodle/site:config', $context); $toolproxy = lti_get_tool_proxy($id); return lti_build_registration_request($toolproxy); }
[ "public", "static", "function", "get_tool_proxy_registration_request", "(", "$", "id", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "get_tool_proxy_registration_request_parameters", "(", ")", ",", "array", "(", "'id'", "=>", "$", "id", ",", ")", ")", ";", "$", "id", "=", "$", "params", "[", "'id'", "]", ";", "$", "context", "=", "context_system", "::", "instance", "(", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "require_capability", "(", "'moodle/site:config'", ",", "$", "context", ")", ";", "$", "toolproxy", "=", "lti_get_tool_proxy", "(", "$", "id", ")", ";", "return", "lti_build_registration_request", "(", "$", "toolproxy", ")", ";", "}" ]
Returns the registration request for a tool proxy. @param int $id the lti instance id @return array of registration parameters @since Moodle 3.1 @throws moodle_exception
[ "Returns", "the", "registration", "request", "for", "a", "tool", "proxy", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lti/classes/external.php#L628-L641
214,414
moodle/moodle
mod/lti/classes/external.php
mod_lti_external.create_tool_type
public static function create_tool_type($cartridgeurl, $key, $secret) { $params = self::validate_parameters(self::create_tool_type_parameters(), array( 'cartridgeurl' => $cartridgeurl, 'key' => $key, 'secret' => $secret )); $cartridgeurl = $params['cartridgeurl']; $key = $params['key']; $secret = $params['secret']; $context = context_system::instance(); self::validate_context($context); require_capability('moodle/site:config', $context); $id = null; if (!empty($cartridgeurl)) { $type = new stdClass(); $data = new stdClass(); $type->state = LTI_TOOL_STATE_CONFIGURED; $data->lti_coursevisible = 1; $data->lti_sendname = LTI_SETTING_DELEGATE; $data->lti_sendemailaddr = LTI_SETTING_DELEGATE; $data->lti_acceptgrades = LTI_SETTING_DELEGATE; $data->lti_forcessl = 0; if (!empty($key)) { $data->lti_resourcekey = $key; } if (!empty($secret)) { $data->lti_password = $secret; } lti_load_type_from_cartridge($cartridgeurl, $data); if (empty($data->lti_toolurl)) { throw new moodle_exception('unabletocreatetooltype', 'mod_lti'); } else { $id = lti_add_type($type, $data); } } if (!empty($id)) { $type = lti_get_type($id); return serialise_tool_type($type); } else { throw new moodle_exception('unabletocreatetooltype', 'mod_lti'); } }
php
public static function create_tool_type($cartridgeurl, $key, $secret) { $params = self::validate_parameters(self::create_tool_type_parameters(), array( 'cartridgeurl' => $cartridgeurl, 'key' => $key, 'secret' => $secret )); $cartridgeurl = $params['cartridgeurl']; $key = $params['key']; $secret = $params['secret']; $context = context_system::instance(); self::validate_context($context); require_capability('moodle/site:config', $context); $id = null; if (!empty($cartridgeurl)) { $type = new stdClass(); $data = new stdClass(); $type->state = LTI_TOOL_STATE_CONFIGURED; $data->lti_coursevisible = 1; $data->lti_sendname = LTI_SETTING_DELEGATE; $data->lti_sendemailaddr = LTI_SETTING_DELEGATE; $data->lti_acceptgrades = LTI_SETTING_DELEGATE; $data->lti_forcessl = 0; if (!empty($key)) { $data->lti_resourcekey = $key; } if (!empty($secret)) { $data->lti_password = $secret; } lti_load_type_from_cartridge($cartridgeurl, $data); if (empty($data->lti_toolurl)) { throw new moodle_exception('unabletocreatetooltype', 'mod_lti'); } else { $id = lti_add_type($type, $data); } } if (!empty($id)) { $type = lti_get_type($id); return serialise_tool_type($type); } else { throw new moodle_exception('unabletocreatetooltype', 'mod_lti'); } }
[ "public", "static", "function", "create_tool_type", "(", "$", "cartridgeurl", ",", "$", "key", ",", "$", "secret", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "create_tool_type_parameters", "(", ")", ",", "array", "(", "'cartridgeurl'", "=>", "$", "cartridgeurl", ",", "'key'", "=>", "$", "key", ",", "'secret'", "=>", "$", "secret", ")", ")", ";", "$", "cartridgeurl", "=", "$", "params", "[", "'cartridgeurl'", "]", ";", "$", "key", "=", "$", "params", "[", "'key'", "]", ";", "$", "secret", "=", "$", "params", "[", "'secret'", "]", ";", "$", "context", "=", "context_system", "::", "instance", "(", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "require_capability", "(", "'moodle/site:config'", ",", "$", "context", ")", ";", "$", "id", "=", "null", ";", "if", "(", "!", "empty", "(", "$", "cartridgeurl", ")", ")", "{", "$", "type", "=", "new", "stdClass", "(", ")", ";", "$", "data", "=", "new", "stdClass", "(", ")", ";", "$", "type", "->", "state", "=", "LTI_TOOL_STATE_CONFIGURED", ";", "$", "data", "->", "lti_coursevisible", "=", "1", ";", "$", "data", "->", "lti_sendname", "=", "LTI_SETTING_DELEGATE", ";", "$", "data", "->", "lti_sendemailaddr", "=", "LTI_SETTING_DELEGATE", ";", "$", "data", "->", "lti_acceptgrades", "=", "LTI_SETTING_DELEGATE", ";", "$", "data", "->", "lti_forcessl", "=", "0", ";", "if", "(", "!", "empty", "(", "$", "key", ")", ")", "{", "$", "data", "->", "lti_resourcekey", "=", "$", "key", ";", "}", "if", "(", "!", "empty", "(", "$", "secret", ")", ")", "{", "$", "data", "->", "lti_password", "=", "$", "secret", ";", "}", "lti_load_type_from_cartridge", "(", "$", "cartridgeurl", ",", "$", "data", ")", ";", "if", "(", "empty", "(", "$", "data", "->", "lti_toolurl", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'unabletocreatetooltype'", ",", "'mod_lti'", ")", ";", "}", "else", "{", "$", "id", "=", "lti_add_type", "(", "$", "type", ",", "$", "data", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "id", ")", ")", "{", "$", "type", "=", "lti_get_type", "(", "$", "id", ")", ";", "return", "serialise_tool_type", "(", "$", "type", ")", ";", "}", "else", "{", "throw", "new", "moodle_exception", "(", "'unabletocreatetooltype'", ",", "'mod_lti'", ")", ";", "}", "}" ]
Creates a tool type. @param string $cartridgeurl Url of the xml cartridge representing the LTI tool @param string $key The consumer key to identify this consumer @param string $secret The secret @return array created tool type @since Moodle 3.1 @throws moodle_exception If the tool type could not be created
[ "Creates", "a", "tool", "type", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lti/classes/external.php#L746-L795
214,415
moodle/moodle
mod/lti/classes/external.php
mod_lti_external.update_tool_type
public static function update_tool_type($id, $name, $description, $state) { $params = self::validate_parameters(self::update_tool_type_parameters(), array( 'id' => $id, 'name' => $name, 'description' => $description, 'state' => $state, )); $id = $params['id']; $name = $params['name']; $description = $params['description']; $state = $params['state']; $context = context_system::instance(); self::validate_context($context); require_capability('moodle/site:config', $context); $type = lti_get_type($id); if (empty($type)) { throw new moodle_exception('unabletofindtooltype', 'mod_lti', '', array('id' => $id)); } if (!empty($name)) { $type->name = $name; } if (!empty($description)) { $type->description = $description; } if (!empty($state)) { // Valid state range. if (in_array($state, array(1, 2, 3))) { $type->state = $state; } else { throw new moodle_exception("Invalid state: $state - must be 1, 2, or 3"); } } lti_update_type($type, new stdClass()); return serialise_tool_type($type); }
php
public static function update_tool_type($id, $name, $description, $state) { $params = self::validate_parameters(self::update_tool_type_parameters(), array( 'id' => $id, 'name' => $name, 'description' => $description, 'state' => $state, )); $id = $params['id']; $name = $params['name']; $description = $params['description']; $state = $params['state']; $context = context_system::instance(); self::validate_context($context); require_capability('moodle/site:config', $context); $type = lti_get_type($id); if (empty($type)) { throw new moodle_exception('unabletofindtooltype', 'mod_lti', '', array('id' => $id)); } if (!empty($name)) { $type->name = $name; } if (!empty($description)) { $type->description = $description; } if (!empty($state)) { // Valid state range. if (in_array($state, array(1, 2, 3))) { $type->state = $state; } else { throw new moodle_exception("Invalid state: $state - must be 1, 2, or 3"); } } lti_update_type($type, new stdClass()); return serialise_tool_type($type); }
[ "public", "static", "function", "update_tool_type", "(", "$", "id", ",", "$", "name", ",", "$", "description", ",", "$", "state", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "update_tool_type_parameters", "(", ")", ",", "array", "(", "'id'", "=>", "$", "id", ",", "'name'", "=>", "$", "name", ",", "'description'", "=>", "$", "description", ",", "'state'", "=>", "$", "state", ",", ")", ")", ";", "$", "id", "=", "$", "params", "[", "'id'", "]", ";", "$", "name", "=", "$", "params", "[", "'name'", "]", ";", "$", "description", "=", "$", "params", "[", "'description'", "]", ";", "$", "state", "=", "$", "params", "[", "'state'", "]", ";", "$", "context", "=", "context_system", "::", "instance", "(", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "require_capability", "(", "'moodle/site:config'", ",", "$", "context", ")", ";", "$", "type", "=", "lti_get_type", "(", "$", "id", ")", ";", "if", "(", "empty", "(", "$", "type", ")", ")", "{", "throw", "new", "moodle_exception", "(", "'unabletofindtooltype'", ",", "'mod_lti'", ",", "''", ",", "array", "(", "'id'", "=>", "$", "id", ")", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "name", ")", ")", "{", "$", "type", "->", "name", "=", "$", "name", ";", "}", "if", "(", "!", "empty", "(", "$", "description", ")", ")", "{", "$", "type", "->", "description", "=", "$", "description", ";", "}", "if", "(", "!", "empty", "(", "$", "state", ")", ")", "{", "// Valid state range.", "if", "(", "in_array", "(", "$", "state", ",", "array", "(", "1", ",", "2", ",", "3", ")", ")", ")", "{", "$", "type", "->", "state", "=", "$", "state", ";", "}", "else", "{", "throw", "new", "moodle_exception", "(", "\"Invalid state: $state - must be 1, 2, or 3\"", ")", ";", "}", "}", "lti_update_type", "(", "$", "type", ",", "new", "stdClass", "(", ")", ")", ";", "return", "serialise_tool_type", "(", "$", "type", ")", ";", "}" ]
Update a tool type. @param int $id The id of the tool type to update @param string $name The name of the tool type @param string $description The name of the tool type @param int $state The state of the tool type @return array updated tool type @since Moodle 3.1 @throws moodle_exception
[ "Update", "a", "tool", "type", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lti/classes/external.php#L835-L878
214,416
moodle/moodle
mod/lti/classes/external.php
mod_lti_external.delete_tool_type
public static function delete_tool_type($id) { $params = self::validate_parameters(self::delete_tool_type_parameters(), array( 'id' => $id, )); $id = $params['id']; $context = context_system::instance(); self::validate_context($context); require_capability('moodle/site:config', $context); $type = lti_get_type($id); if (!empty($type)) { lti_delete_type($id); // If this is the last type for this proxy then remove the proxy // as well so that it isn't orphaned. $types = lti_get_lti_types_from_proxy_id($type->toolproxyid); if (empty($types)) { lti_delete_tool_proxy($type->toolproxyid); } } return array('id' => $id); }
php
public static function delete_tool_type($id) { $params = self::validate_parameters(self::delete_tool_type_parameters(), array( 'id' => $id, )); $id = $params['id']; $context = context_system::instance(); self::validate_context($context); require_capability('moodle/site:config', $context); $type = lti_get_type($id); if (!empty($type)) { lti_delete_type($id); // If this is the last type for this proxy then remove the proxy // as well so that it isn't orphaned. $types = lti_get_lti_types_from_proxy_id($type->toolproxyid); if (empty($types)) { lti_delete_tool_proxy($type->toolproxyid); } } return array('id' => $id); }
[ "public", "static", "function", "delete_tool_type", "(", "$", "id", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "delete_tool_type_parameters", "(", ")", ",", "array", "(", "'id'", "=>", "$", "id", ",", ")", ")", ";", "$", "id", "=", "$", "params", "[", "'id'", "]", ";", "$", "context", "=", "context_system", "::", "instance", "(", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "require_capability", "(", "'moodle/site:config'", ",", "$", "context", ")", ";", "$", "type", "=", "lti_get_type", "(", "$", "id", ")", ";", "if", "(", "!", "empty", "(", "$", "type", ")", ")", "{", "lti_delete_type", "(", "$", "id", ")", ";", "// If this is the last type for this proxy then remove the proxy", "// as well so that it isn't orphaned.", "$", "types", "=", "lti_get_lti_types_from_proxy_id", "(", "$", "type", "->", "toolproxyid", ")", ";", "if", "(", "empty", "(", "$", "types", ")", ")", "{", "lti_delete_tool_proxy", "(", "$", "type", "->", "toolproxyid", ")", ";", "}", "}", "return", "array", "(", "'id'", "=>", "$", "id", ")", ";", "}" ]
Delete a tool type. @param int $id The id of the tool type to be deleted @return array deleted tool type @since Moodle 3.1 @throws moodle_exception
[ "Delete", "a", "tool", "type", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lti/classes/external.php#L912-L937
214,417
moodle/moodle
mod/lti/classes/external.php
mod_lti_external.is_cartridge
public static function is_cartridge($url) { $params = self::validate_parameters(self::is_cartridge_parameters(), array( 'url' => $url, )); $url = $params['url']; $context = context_system::instance(); self::validate_context($context); require_capability('moodle/site:config', $context); $iscartridge = lti_is_cartridge($url); return array('iscartridge' => $iscartridge); }
php
public static function is_cartridge($url) { $params = self::validate_parameters(self::is_cartridge_parameters(), array( 'url' => $url, )); $url = $params['url']; $context = context_system::instance(); self::validate_context($context); require_capability('moodle/site:config', $context); $iscartridge = lti_is_cartridge($url); return array('iscartridge' => $iscartridge); }
[ "public", "static", "function", "is_cartridge", "(", "$", "url", ")", "{", "$", "params", "=", "self", "::", "validate_parameters", "(", "self", "::", "is_cartridge_parameters", "(", ")", ",", "array", "(", "'url'", "=>", "$", "url", ",", ")", ")", ";", "$", "url", "=", "$", "params", "[", "'url'", "]", ";", "$", "context", "=", "context_system", "::", "instance", "(", ")", ";", "self", "::", "validate_context", "(", "$", "context", ")", ";", "require_capability", "(", "'moodle/site:config'", ",", "$", "context", ")", ";", "$", "iscartridge", "=", "lti_is_cartridge", "(", "$", "url", ")", ";", "return", "array", "(", "'iscartridge'", "=>", "$", "iscartridge", ")", ";", "}" ]
Determine if the url to a tool is for a cartridge. @param string $url Url that may or may not be an xml cartridge @return bool True if the url is for a cartridge. @since Moodle 3.1 @throws moodle_exception
[ "Determine", "if", "the", "url", "to", "a", "tool", "is", "for", "a", "cartridge", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lti/classes/external.php#L975-L989
214,418
moodle/moodle
grade/grading/pick_form.php
grading_search_template_form.definition
public function definition() { $mform = $this->_form; $mform->addElement('header', 'searchheader', get_string('searchtemplate', 'core_grading')); $mform->addHelpButton('searchheader', 'searchtemplate', 'core_grading'); $mform->addGroup(array( $mform->createElement('checkbox', 'mode', '', get_string('searchownforms', 'core_grading')), $mform->createElement('text', 'needle', '', array('size' => 30)), $mform->createElement('submit', 'submitbutton', get_string('search')), ), 'buttonar', '', array(' '), false); $mform->setType('needle', PARAM_TEXT); $mform->setType('buttonar', PARAM_RAW); }
php
public function definition() { $mform = $this->_form; $mform->addElement('header', 'searchheader', get_string('searchtemplate', 'core_grading')); $mform->addHelpButton('searchheader', 'searchtemplate', 'core_grading'); $mform->addGroup(array( $mform->createElement('checkbox', 'mode', '', get_string('searchownforms', 'core_grading')), $mform->createElement('text', 'needle', '', array('size' => 30)), $mform->createElement('submit', 'submitbutton', get_string('search')), ), 'buttonar', '', array(' '), false); $mform->setType('needle', PARAM_TEXT); $mform->setType('buttonar', PARAM_RAW); }
[ "public", "function", "definition", "(", ")", "{", "$", "mform", "=", "$", "this", "->", "_form", ";", "$", "mform", "->", "addElement", "(", "'header'", ",", "'searchheader'", ",", "get_string", "(", "'searchtemplate'", ",", "'core_grading'", ")", ")", ";", "$", "mform", "->", "addHelpButton", "(", "'searchheader'", ",", "'searchtemplate'", ",", "'core_grading'", ")", ";", "$", "mform", "->", "addGroup", "(", "array", "(", "$", "mform", "->", "createElement", "(", "'checkbox'", ",", "'mode'", ",", "''", ",", "get_string", "(", "'searchownforms'", ",", "'core_grading'", ")", ")", ",", "$", "mform", "->", "createElement", "(", "'text'", ",", "'needle'", ",", "''", ",", "array", "(", "'size'", "=>", "30", ")", ")", ",", "$", "mform", "->", "createElement", "(", "'submit'", ",", "'submitbutton'", ",", "get_string", "(", "'search'", ")", ")", ",", ")", ",", "'buttonar'", ",", "''", ",", "array", "(", "' '", ")", ",", "false", ")", ";", "$", "mform", "->", "setType", "(", "'needle'", ",", "PARAM_TEXT", ")", ";", "$", "mform", "->", "setType", "(", "'buttonar'", ",", "PARAM_RAW", ")", ";", "}" ]
Pretty simple search box
[ "Pretty", "simple", "search", "box" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/grade/grading/pick_form.php#L41-L52
214,419
moodle/moodle
user/classes/output/myprofile/renderer.php
renderer.render_category
public function render_category(category $category) { $classes = $category->classes; if (empty($classes)) { $return = \html_writer::start_tag('section', array('class' => 'node_category')); } else { $return = \html_writer::start_tag('section', array('class' => 'node_category ' . $classes)); } $return .= \html_writer::tag('h3', $category->title); $nodes = $category->nodes; if (empty($nodes)) { // No nodes, nothing to render. return ''; } $return .= \html_writer::start_tag('ul'); foreach ($nodes as $node) { $return .= $this->render($node); } $return .= \html_writer::end_tag('ul'); $return .= \html_writer::end_tag('section'); return $return; }
php
public function render_category(category $category) { $classes = $category->classes; if (empty($classes)) { $return = \html_writer::start_tag('section', array('class' => 'node_category')); } else { $return = \html_writer::start_tag('section', array('class' => 'node_category ' . $classes)); } $return .= \html_writer::tag('h3', $category->title); $nodes = $category->nodes; if (empty($nodes)) { // No nodes, nothing to render. return ''; } $return .= \html_writer::start_tag('ul'); foreach ($nodes as $node) { $return .= $this->render($node); } $return .= \html_writer::end_tag('ul'); $return .= \html_writer::end_tag('section'); return $return; }
[ "public", "function", "render_category", "(", "category", "$", "category", ")", "{", "$", "classes", "=", "$", "category", "->", "classes", ";", "if", "(", "empty", "(", "$", "classes", ")", ")", "{", "$", "return", "=", "\\", "html_writer", "::", "start_tag", "(", "'section'", ",", "array", "(", "'class'", "=>", "'node_category'", ")", ")", ";", "}", "else", "{", "$", "return", "=", "\\", "html_writer", "::", "start_tag", "(", "'section'", ",", "array", "(", "'class'", "=>", "'node_category '", ".", "$", "classes", ")", ")", ";", "}", "$", "return", ".=", "\\", "html_writer", "::", "tag", "(", "'h3'", ",", "$", "category", "->", "title", ")", ";", "$", "nodes", "=", "$", "category", "->", "nodes", ";", "if", "(", "empty", "(", "$", "nodes", ")", ")", "{", "// No nodes, nothing to render.", "return", "''", ";", "}", "$", "return", ".=", "\\", "html_writer", "::", "start_tag", "(", "'ul'", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "$", "return", ".=", "$", "this", "->", "render", "(", "$", "node", ")", ";", "}", "$", "return", ".=", "\\", "html_writer", "::", "end_tag", "(", "'ul'", ")", ";", "$", "return", ".=", "\\", "html_writer", "::", "end_tag", "(", "'section'", ")", ";", "return", "$", "return", ";", "}" ]
Render a category. @param category $category @return string
[ "Render", "a", "category", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/classes/output/myprofile/renderer.php#L60-L80
214,420
moodle/moodle
user/classes/output/myprofile/renderer.php
renderer.render_node
public function render_node(node $node) { $return = ''; if (is_object($node->url)) { $header = \html_writer::link($node->url, $node->title); } else { $header = $node->title; } $icon = $node->icon; if (!empty($icon)) { $header .= $this->render($icon); } $content = $node->content; $classes = $node->classes; if (!empty($content)) { if ($header) { // There is some content to display below this make this a header. $return = \html_writer::tag('dt', $header); $return .= \html_writer::tag('dd', $content); $return = \html_writer::tag('dl', $return); } else { $return = \html_writer::span($content); } if ($classes) { $return = \html_writer::tag('li', $return, array('class' => 'contentnode ' . $classes)); } else { $return = \html_writer::tag('li', $return, array('class' => 'contentnode')); } } else { $return = \html_writer::span($header); $return = \html_writer::tag('li', $return, array('class' => $classes)); } return $return; }
php
public function render_node(node $node) { $return = ''; if (is_object($node->url)) { $header = \html_writer::link($node->url, $node->title); } else { $header = $node->title; } $icon = $node->icon; if (!empty($icon)) { $header .= $this->render($icon); } $content = $node->content; $classes = $node->classes; if (!empty($content)) { if ($header) { // There is some content to display below this make this a header. $return = \html_writer::tag('dt', $header); $return .= \html_writer::tag('dd', $content); $return = \html_writer::tag('dl', $return); } else { $return = \html_writer::span($content); } if ($classes) { $return = \html_writer::tag('li', $return, array('class' => 'contentnode ' . $classes)); } else { $return = \html_writer::tag('li', $return, array('class' => 'contentnode')); } } else { $return = \html_writer::span($header); $return = \html_writer::tag('li', $return, array('class' => $classes)); } return $return; }
[ "public", "function", "render_node", "(", "node", "$", "node", ")", "{", "$", "return", "=", "''", ";", "if", "(", "is_object", "(", "$", "node", "->", "url", ")", ")", "{", "$", "header", "=", "\\", "html_writer", "::", "link", "(", "$", "node", "->", "url", ",", "$", "node", "->", "title", ")", ";", "}", "else", "{", "$", "header", "=", "$", "node", "->", "title", ";", "}", "$", "icon", "=", "$", "node", "->", "icon", ";", "if", "(", "!", "empty", "(", "$", "icon", ")", ")", "{", "$", "header", ".=", "$", "this", "->", "render", "(", "$", "icon", ")", ";", "}", "$", "content", "=", "$", "node", "->", "content", ";", "$", "classes", "=", "$", "node", "->", "classes", ";", "if", "(", "!", "empty", "(", "$", "content", ")", ")", "{", "if", "(", "$", "header", ")", "{", "// There is some content to display below this make this a header.", "$", "return", "=", "\\", "html_writer", "::", "tag", "(", "'dt'", ",", "$", "header", ")", ";", "$", "return", ".=", "\\", "html_writer", "::", "tag", "(", "'dd'", ",", "$", "content", ")", ";", "$", "return", "=", "\\", "html_writer", "::", "tag", "(", "'dl'", ",", "$", "return", ")", ";", "}", "else", "{", "$", "return", "=", "\\", "html_writer", "::", "span", "(", "$", "content", ")", ";", "}", "if", "(", "$", "classes", ")", "{", "$", "return", "=", "\\", "html_writer", "::", "tag", "(", "'li'", ",", "$", "return", ",", "array", "(", "'class'", "=>", "'contentnode '", ".", "$", "classes", ")", ")", ";", "}", "else", "{", "$", "return", "=", "\\", "html_writer", "::", "tag", "(", "'li'", ",", "$", "return", ",", "array", "(", "'class'", "=>", "'contentnode'", ")", ")", ";", "}", "}", "else", "{", "$", "return", "=", "\\", "html_writer", "::", "span", "(", "$", "header", ")", ";", "$", "return", "=", "\\", "html_writer", "::", "tag", "(", "'li'", ",", "$", "return", ",", "array", "(", "'class'", "=>", "$", "classes", ")", ")", ";", "}", "return", "$", "return", ";", "}" ]
Render a node. @param node $node @return string
[ "Render", "a", "node", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/user/classes/output/myprofile/renderer.php#L89-L123
214,421
moodle/moodle
admin/tool/messageinbound/renderer.php
tool_messageinbound_renderer.messageinbound_handlers_table
public function messageinbound_handlers_table(array $handlers) { global $CFG; $table = new html_table(); $handlername = new html_table_cell(get_string('name', 'tool_messageinbound') . "\n" . html_writer::tag('span', get_string('classname', 'tool_messageinbound'), array('class' => 'handler-function'))); // Prepare some of the rows with additional styling. $enabled = new html_table_cell(get_string('enabled', 'tool_messageinbound')); $enabled->attributes['class'] = 'state'; $edit = new html_table_cell(get_string('edit', 'tool_messageinbound')); $edit->attributes['class'] = 'edit'; $table->head = array( $handlername, get_string('description', 'tool_messageinbound'), $enabled, $edit, ); $table->attributes['class'] = 'admintable generaltable messageinboundhandlers'; $yes = get_string('yes'); $no = get_string('no'); $data = array(); // Options for description formatting. $descriptionoptions = new stdClass(); $descriptionoptions->trusted = false; $descriptionoptions->noclean = false; $descriptionoptions->smiley = false; $descriptionoptions->filter = false; $descriptionoptions->para = true; $descriptionoptions->newlines = false; $descriptionoptions->overflowdiv = true; $editurlbase = new moodle_url('/admin/tool/messageinbound/index.php'); foreach ($handlers as $handler) { $handlername = new html_table_cell($handler->name . "\n" . html_writer::tag('span', $handler->classname, array('class' => 'handler-function'))); $handlername->header = true; $editurl = new moodle_url($editurlbase, array('classname' => $handler->classname)); $editlink = $this->action_icon($editurl, new pix_icon('t/edit', get_string('edithandler', 'tool_messageinbound', $handler->classname))); // Prepare some of the rows with additional styling. $enabled = new html_table_cell($handler->enabled ? $yes : $no); $enabled->attributes['class'] = 'state'; $edit = new html_table_cell($editlink); $edit->attributes['class'] = 'edit'; // Add the row. $row = new html_table_row(array( $handlername, format_text($handler->description, FORMAT_MARKDOWN, $descriptionoptions), $enabled, $edit, )); if (!$handler->enabled) { $row->attributes['class'] = 'disabled'; } $data[] = $row; } $table->data = $data; return html_writer::table($table); }
php
public function messageinbound_handlers_table(array $handlers) { global $CFG; $table = new html_table(); $handlername = new html_table_cell(get_string('name', 'tool_messageinbound') . "\n" . html_writer::tag('span', get_string('classname', 'tool_messageinbound'), array('class' => 'handler-function'))); // Prepare some of the rows with additional styling. $enabled = new html_table_cell(get_string('enabled', 'tool_messageinbound')); $enabled->attributes['class'] = 'state'; $edit = new html_table_cell(get_string('edit', 'tool_messageinbound')); $edit->attributes['class'] = 'edit'; $table->head = array( $handlername, get_string('description', 'tool_messageinbound'), $enabled, $edit, ); $table->attributes['class'] = 'admintable generaltable messageinboundhandlers'; $yes = get_string('yes'); $no = get_string('no'); $data = array(); // Options for description formatting. $descriptionoptions = new stdClass(); $descriptionoptions->trusted = false; $descriptionoptions->noclean = false; $descriptionoptions->smiley = false; $descriptionoptions->filter = false; $descriptionoptions->para = true; $descriptionoptions->newlines = false; $descriptionoptions->overflowdiv = true; $editurlbase = new moodle_url('/admin/tool/messageinbound/index.php'); foreach ($handlers as $handler) { $handlername = new html_table_cell($handler->name . "\n" . html_writer::tag('span', $handler->classname, array('class' => 'handler-function'))); $handlername->header = true; $editurl = new moodle_url($editurlbase, array('classname' => $handler->classname)); $editlink = $this->action_icon($editurl, new pix_icon('t/edit', get_string('edithandler', 'tool_messageinbound', $handler->classname))); // Prepare some of the rows with additional styling. $enabled = new html_table_cell($handler->enabled ? $yes : $no); $enabled->attributes['class'] = 'state'; $edit = new html_table_cell($editlink); $edit->attributes['class'] = 'edit'; // Add the row. $row = new html_table_row(array( $handlername, format_text($handler->description, FORMAT_MARKDOWN, $descriptionoptions), $enabled, $edit, )); if (!$handler->enabled) { $row->attributes['class'] = 'disabled'; } $data[] = $row; } $table->data = $data; return html_writer::table($table); }
[ "public", "function", "messageinbound_handlers_table", "(", "array", "$", "handlers", ")", "{", "global", "$", "CFG", ";", "$", "table", "=", "new", "html_table", "(", ")", ";", "$", "handlername", "=", "new", "html_table_cell", "(", "get_string", "(", "'name'", ",", "'tool_messageinbound'", ")", ".", "\"\\n\"", ".", "html_writer", "::", "tag", "(", "'span'", ",", "get_string", "(", "'classname'", ",", "'tool_messageinbound'", ")", ",", "array", "(", "'class'", "=>", "'handler-function'", ")", ")", ")", ";", "// Prepare some of the rows with additional styling.", "$", "enabled", "=", "new", "html_table_cell", "(", "get_string", "(", "'enabled'", ",", "'tool_messageinbound'", ")", ")", ";", "$", "enabled", "->", "attributes", "[", "'class'", "]", "=", "'state'", ";", "$", "edit", "=", "new", "html_table_cell", "(", "get_string", "(", "'edit'", ",", "'tool_messageinbound'", ")", ")", ";", "$", "edit", "->", "attributes", "[", "'class'", "]", "=", "'edit'", ";", "$", "table", "->", "head", "=", "array", "(", "$", "handlername", ",", "get_string", "(", "'description'", ",", "'tool_messageinbound'", ")", ",", "$", "enabled", ",", "$", "edit", ",", ")", ";", "$", "table", "->", "attributes", "[", "'class'", "]", "=", "'admintable generaltable messageinboundhandlers'", ";", "$", "yes", "=", "get_string", "(", "'yes'", ")", ";", "$", "no", "=", "get_string", "(", "'no'", ")", ";", "$", "data", "=", "array", "(", ")", ";", "// Options for description formatting.", "$", "descriptionoptions", "=", "new", "stdClass", "(", ")", ";", "$", "descriptionoptions", "->", "trusted", "=", "false", ";", "$", "descriptionoptions", "->", "noclean", "=", "false", ";", "$", "descriptionoptions", "->", "smiley", "=", "false", ";", "$", "descriptionoptions", "->", "filter", "=", "false", ";", "$", "descriptionoptions", "->", "para", "=", "true", ";", "$", "descriptionoptions", "->", "newlines", "=", "false", ";", "$", "descriptionoptions", "->", "overflowdiv", "=", "true", ";", "$", "editurlbase", "=", "new", "moodle_url", "(", "'/admin/tool/messageinbound/index.php'", ")", ";", "foreach", "(", "$", "handlers", "as", "$", "handler", ")", "{", "$", "handlername", "=", "new", "html_table_cell", "(", "$", "handler", "->", "name", ".", "\"\\n\"", ".", "html_writer", "::", "tag", "(", "'span'", ",", "$", "handler", "->", "classname", ",", "array", "(", "'class'", "=>", "'handler-function'", ")", ")", ")", ";", "$", "handlername", "->", "header", "=", "true", ";", "$", "editurl", "=", "new", "moodle_url", "(", "$", "editurlbase", ",", "array", "(", "'classname'", "=>", "$", "handler", "->", "classname", ")", ")", ";", "$", "editlink", "=", "$", "this", "->", "action_icon", "(", "$", "editurl", ",", "new", "pix_icon", "(", "'t/edit'", ",", "get_string", "(", "'edithandler'", ",", "'tool_messageinbound'", ",", "$", "handler", "->", "classname", ")", ")", ")", ";", "// Prepare some of the rows with additional styling.", "$", "enabled", "=", "new", "html_table_cell", "(", "$", "handler", "->", "enabled", "?", "$", "yes", ":", "$", "no", ")", ";", "$", "enabled", "->", "attributes", "[", "'class'", "]", "=", "'state'", ";", "$", "edit", "=", "new", "html_table_cell", "(", "$", "editlink", ")", ";", "$", "edit", "->", "attributes", "[", "'class'", "]", "=", "'edit'", ";", "// Add the row.", "$", "row", "=", "new", "html_table_row", "(", "array", "(", "$", "handlername", ",", "format_text", "(", "$", "handler", "->", "description", ",", "FORMAT_MARKDOWN", ",", "$", "descriptionoptions", ")", ",", "$", "enabled", ",", "$", "edit", ",", ")", ")", ";", "if", "(", "!", "$", "handler", "->", "enabled", ")", "{", "$", "row", "->", "attributes", "[", "'class'", "]", "=", "'disabled'", ";", "}", "$", "data", "[", "]", "=", "$", "row", ";", "}", "$", "table", "->", "data", "=", "$", "data", ";", "return", "html_writer", "::", "table", "(", "$", "table", ")", ";", "}" ]
Render a table listing all of the Inbound Message handlers. @param array $handlers - list of all messageinbound handlers. @return string HTML to output.
[ "Render", "a", "table", "listing", "all", "of", "the", "Inbound", "Message", "handlers", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/admin/tool/messageinbound/renderer.php#L41-L107
214,422
moodle/moodle
comment/lib.php
comment.init
public static function init(moodle_page $page = null) { global $PAGE; if (empty($page)) { $page = $PAGE; } // setup variables for non-js interface self::$nonjs = optional_param('nonjscomment', '', PARAM_ALPHANUM); self::$comment_itemid = optional_param('comment_itemid', '', PARAM_INT); self::$comment_component = optional_param('comment_component', '', PARAM_COMPONENT); self::$comment_context = optional_param('comment_context', '', PARAM_INT); self::$comment_page = optional_param('comment_page', '', PARAM_INT); self::$comment_area = optional_param('comment_area', '', PARAM_AREA); $page->requires->strings_for_js(array( 'addcomment', 'comments', 'commentscount', 'commentsrequirelogin', 'deletecommentbyon' ), 'moodle' ); }
php
public static function init(moodle_page $page = null) { global $PAGE; if (empty($page)) { $page = $PAGE; } // setup variables for non-js interface self::$nonjs = optional_param('nonjscomment', '', PARAM_ALPHANUM); self::$comment_itemid = optional_param('comment_itemid', '', PARAM_INT); self::$comment_component = optional_param('comment_component', '', PARAM_COMPONENT); self::$comment_context = optional_param('comment_context', '', PARAM_INT); self::$comment_page = optional_param('comment_page', '', PARAM_INT); self::$comment_area = optional_param('comment_area', '', PARAM_AREA); $page->requires->strings_for_js(array( 'addcomment', 'comments', 'commentscount', 'commentsrequirelogin', 'deletecommentbyon' ), 'moodle' ); }
[ "public", "static", "function", "init", "(", "moodle_page", "$", "page", "=", "null", ")", "{", "global", "$", "PAGE", ";", "if", "(", "empty", "(", "$", "page", ")", ")", "{", "$", "page", "=", "$", "PAGE", ";", "}", "// setup variables for non-js interface", "self", "::", "$", "nonjs", "=", "optional_param", "(", "'nonjscomment'", ",", "''", ",", "PARAM_ALPHANUM", ")", ";", "self", "::", "$", "comment_itemid", "=", "optional_param", "(", "'comment_itemid'", ",", "''", ",", "PARAM_INT", ")", ";", "self", "::", "$", "comment_component", "=", "optional_param", "(", "'comment_component'", ",", "''", ",", "PARAM_COMPONENT", ")", ";", "self", "::", "$", "comment_context", "=", "optional_param", "(", "'comment_context'", ",", "''", ",", "PARAM_INT", ")", ";", "self", "::", "$", "comment_page", "=", "optional_param", "(", "'comment_page'", ",", "''", ",", "PARAM_INT", ")", ";", "self", "::", "$", "comment_area", "=", "optional_param", "(", "'comment_area'", ",", "''", ",", "PARAM_AREA", ")", ";", "$", "page", "->", "requires", "->", "strings_for_js", "(", "array", "(", "'addcomment'", ",", "'comments'", ",", "'commentscount'", ",", "'commentsrequirelogin'", ",", "'deletecommentbyon'", ")", ",", "'moodle'", ")", ";", "}" ]
Receive nonjs comment parameters @param moodle_page $page The page object to initialise comments within If not provided the global $PAGE is used
[ "Receive", "nonjs", "comment", "parameters" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/comment/lib.php#L247-L270
214,423
moodle/moodle
comment/lib.php
comment.set_component
public function set_component($component) { if (!empty($this->component) && $this->component !== $component) { throw new coding_exception('You cannot change the component of a comment once it has been set'); } $this->component = $component; list($this->plugintype, $this->pluginname) = core_component::normalize_component($component); }
php
public function set_component($component) { if (!empty($this->component) && $this->component !== $component) { throw new coding_exception('You cannot change the component of a comment once it has been set'); } $this->component = $component; list($this->plugintype, $this->pluginname) = core_component::normalize_component($component); }
[ "public", "function", "set_component", "(", "$", "component", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "component", ")", "&&", "$", "this", "->", "component", "!==", "$", "component", ")", "{", "throw", "new", "coding_exception", "(", "'You cannot change the component of a comment once it has been set'", ")", ";", "}", "$", "this", "->", "component", "=", "$", "component", ";", "list", "(", "$", "this", "->", "plugintype", ",", "$", "this", "->", "pluginname", ")", "=", "core_component", "::", "normalize_component", "(", "$", "component", ")", ";", "}" ]
Sets the component. This method shouldn't be public, changing the component once it has been set potentially invalidates permission checks. A coding_error is now thrown if code attempts to change the component. @throws coding_exception if you try to change the component after it has been set. @param string $component
[ "Sets", "the", "component", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/comment/lib.php#L282-L288
214,424
moodle/moodle
comment/lib.php
comment.get_nojslink
public function get_nojslink(moodle_page $page = null) { if ($page === null) { global $PAGE; $page = $PAGE; } $link = new moodle_url($page->url, array( 'nonjscomment' => true, 'comment_itemid' => $this->itemid, 'comment_context' => $this->context->id, 'comment_component' => $this->get_component(), 'comment_area' => $this->commentarea, )); $link->remove_params(array('comment_page')); return $link; }
php
public function get_nojslink(moodle_page $page = null) { if ($page === null) { global $PAGE; $page = $PAGE; } $link = new moodle_url($page->url, array( 'nonjscomment' => true, 'comment_itemid' => $this->itemid, 'comment_context' => $this->context->id, 'comment_component' => $this->get_component(), 'comment_area' => $this->commentarea, )); $link->remove_params(array('comment_page')); return $link; }
[ "public", "function", "get_nojslink", "(", "moodle_page", "$", "page", "=", "null", ")", "{", "if", "(", "$", "page", "===", "null", ")", "{", "global", "$", "PAGE", ";", "$", "page", "=", "$", "PAGE", ";", "}", "$", "link", "=", "new", "moodle_url", "(", "$", "page", "->", "url", ",", "array", "(", "'nonjscomment'", "=>", "true", ",", "'comment_itemid'", "=>", "$", "this", "->", "itemid", ",", "'comment_context'", "=>", "$", "this", "->", "context", "->", "id", ",", "'comment_component'", "=>", "$", "this", "->", "get_component", "(", ")", ",", "'comment_area'", "=>", "$", "this", "->", "commentarea", ",", ")", ")", ";", "$", "link", "->", "remove_params", "(", "array", "(", "'comment_page'", ")", ")", ";", "return", "$", "link", ";", "}" ]
Gets a link for this page that will work with JS disabled. @global moodle_page $PAGE @param moodle_page $page @return moodle_url
[ "Gets", "a", "link", "for", "this", "page", "that", "will", "work", "with", "JS", "disabled", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/comment/lib.php#L331-L346
214,425
moodle/moodle
comment/lib.php
comment.initialise_javascript
public function initialise_javascript(moodle_page $page) { $options = new stdClass; $options->client_id = $this->cid; $options->commentarea = $this->commentarea; $options->itemid = $this->itemid; $options->page = 0; $options->courseid = $this->courseid; $options->contextid = $this->contextid; $options->component = $this->component; $options->notoggle = $this->notoggle; $options->autostart = $this->autostart; $page->requires->js_init_call('M.core_comment.init', array($options), true); return true; }
php
public function initialise_javascript(moodle_page $page) { $options = new stdClass; $options->client_id = $this->cid; $options->commentarea = $this->commentarea; $options->itemid = $this->itemid; $options->page = 0; $options->courseid = $this->courseid; $options->contextid = $this->contextid; $options->component = $this->component; $options->notoggle = $this->notoggle; $options->autostart = $this->autostart; $page->requires->js_init_call('M.core_comment.init', array($options), true); return true; }
[ "public", "function", "initialise_javascript", "(", "moodle_page", "$", "page", ")", "{", "$", "options", "=", "new", "stdClass", ";", "$", "options", "->", "client_id", "=", "$", "this", "->", "cid", ";", "$", "options", "->", "commentarea", "=", "$", "this", "->", "commentarea", ";", "$", "options", "->", "itemid", "=", "$", "this", "->", "itemid", ";", "$", "options", "->", "page", "=", "0", ";", "$", "options", "->", "courseid", "=", "$", "this", "->", "courseid", ";", "$", "options", "->", "contextid", "=", "$", "this", "->", "contextid", ";", "$", "options", "->", "component", "=", "$", "this", "->", "component", ";", "$", "options", "->", "notoggle", "=", "$", "this", "->", "notoggle", ";", "$", "options", "->", "autostart", "=", "$", "this", "->", "autostart", ";", "$", "page", "->", "requires", "->", "js_init_call", "(", "'M.core_comment.init'", ",", "array", "(", "$", "options", ")", ",", "true", ")", ";", "return", "true", ";", "}" ]
Initialises the JavaScript that enchances the comment API. @param moodle_page $page The moodle page object that the JavaScript should be initialised for.
[ "Initialises", "the", "JavaScript", "that", "enchances", "the", "comment", "API", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/comment/lib.php#L402-L418
214,426
moodle/moodle
comment/lib.php
comment.get_component_select_sql
protected function get_component_select_sql($alias = '') { $component = $this->get_component(); if ($alias) { $alias = $alias.'.'; } if (empty($component)) { $componentwhere = "{$alias}component IS NULL"; $component = null; } else { $componentwhere = "({$alias}component IS NULL OR {$alias}component = :component)"; } return array($componentwhere, $component); }
php
protected function get_component_select_sql($alias = '') { $component = $this->get_component(); if ($alias) { $alias = $alias.'.'; } if (empty($component)) { $componentwhere = "{$alias}component IS NULL"; $component = null; } else { $componentwhere = "({$alias}component IS NULL OR {$alias}component = :component)"; } return array($componentwhere, $component); }
[ "protected", "function", "get_component_select_sql", "(", "$", "alias", "=", "''", ")", "{", "$", "component", "=", "$", "this", "->", "get_component", "(", ")", ";", "if", "(", "$", "alias", ")", "{", "$", "alias", "=", "$", "alias", ".", "'.'", ";", "}", "if", "(", "empty", "(", "$", "component", ")", ")", "{", "$", "componentwhere", "=", "\"{$alias}component IS NULL\"", ";", "$", "component", "=", "null", ";", "}", "else", "{", "$", "componentwhere", "=", "\"({$alias}component IS NULL OR {$alias}component = :component)\"", ";", "}", "return", "array", "(", "$", "componentwhere", ",", "$", "component", ")", ";", "}" ]
Returns an SQL fragment and param for selecting on component. @param string $alias @return array
[ "Returns", "an", "SQL", "fragment", "and", "param", "for", "selecting", "on", "component", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/comment/lib.php#L611-L623
214,427
moodle/moodle
comment/lib.php
comment.count
public function count() { global $DB; if ($this->totalcommentcount === null) { list($where, $component) = $this->get_component_select_sql(); $where .= ' AND itemid = :itemid AND commentarea = :commentarea AND contextid = :contextid'; $params = array( 'itemid' => $this->itemid, 'commentarea' => $this->commentarea, 'contextid' => $this->context->id, ); if ($component) { $params['component'] = $component; } $this->totalcommentcount = $DB->count_records_select('comments', $where, $params); } return $this->totalcommentcount; }
php
public function count() { global $DB; if ($this->totalcommentcount === null) { list($where, $component) = $this->get_component_select_sql(); $where .= ' AND itemid = :itemid AND commentarea = :commentarea AND contextid = :contextid'; $params = array( 'itemid' => $this->itemid, 'commentarea' => $this->commentarea, 'contextid' => $this->context->id, ); if ($component) { $params['component'] = $component; } $this->totalcommentcount = $DB->count_records_select('comments', $where, $params); } return $this->totalcommentcount; }
[ "public", "function", "count", "(", ")", "{", "global", "$", "DB", ";", "if", "(", "$", "this", "->", "totalcommentcount", "===", "null", ")", "{", "list", "(", "$", "where", ",", "$", "component", ")", "=", "$", "this", "->", "get_component_select_sql", "(", ")", ";", "$", "where", ".=", "' AND itemid = :itemid AND commentarea = :commentarea AND contextid = :contextid'", ";", "$", "params", "=", "array", "(", "'itemid'", "=>", "$", "this", "->", "itemid", ",", "'commentarea'", "=>", "$", "this", "->", "commentarea", ",", "'contextid'", "=>", "$", "this", "->", "context", "->", "id", ",", ")", ";", "if", "(", "$", "component", ")", "{", "$", "params", "[", "'component'", "]", "=", "$", "component", ";", "}", "$", "this", "->", "totalcommentcount", "=", "$", "DB", "->", "count_records_select", "(", "'comments'", ",", "$", "where", ",", "$", "params", ")", ";", "}", "return", "$", "this", "->", "totalcommentcount", ";", "}" ]
Returns the number of comments associated with the details of this object @global moodle_database $DB @return int
[ "Returns", "the", "number", "of", "comments", "associated", "with", "the", "details", "of", "this", "object" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/comment/lib.php#L631-L648
214,428
moodle/moodle
comment/lib.php
comment.get_pagination
public function get_pagination($page = 0) { global $CFG, $OUTPUT; $count = $this->count(); $perpage = (!empty($CFG->commentsperpage))?$CFG->commentsperpage:15; $pages = (int)ceil($count/$perpage); if ($pages == 1 || $pages == 0) { return html_writer::tag('div', '', array('id' => 'comment-pagination-'.$this->cid, 'class' => 'comment-pagination')); } if (!empty(self::$nonjs)) { // used in non-js interface return $OUTPUT->paging_bar($count, $page, $perpage, $this->get_nojslink(), 'comment_page'); } else { // return ajax paging bar $str = ''; $str .= '<div class="comment-paging" id="comment-pagination-'.$this->cid.'">'; for ($p=0; $p<$pages; $p++) { if ($p == $page) { $class = 'curpage'; } else { $class = 'pageno'; } $str .= '<a href="#" class="'.$class.'" id="comment-page-'.$this->cid.'-'.$p.'">'.($p+1).'</a> '; } $str .= '</div>'; } return $str; }
php
public function get_pagination($page = 0) { global $CFG, $OUTPUT; $count = $this->count(); $perpage = (!empty($CFG->commentsperpage))?$CFG->commentsperpage:15; $pages = (int)ceil($count/$perpage); if ($pages == 1 || $pages == 0) { return html_writer::tag('div', '', array('id' => 'comment-pagination-'.$this->cid, 'class' => 'comment-pagination')); } if (!empty(self::$nonjs)) { // used in non-js interface return $OUTPUT->paging_bar($count, $page, $perpage, $this->get_nojslink(), 'comment_page'); } else { // return ajax paging bar $str = ''; $str .= '<div class="comment-paging" id="comment-pagination-'.$this->cid.'">'; for ($p=0; $p<$pages; $p++) { if ($p == $page) { $class = 'curpage'; } else { $class = 'pageno'; } $str .= '<a href="#" class="'.$class.'" id="comment-page-'.$this->cid.'-'.$p.'">'.($p+1).'</a> '; } $str .= '</div>'; } return $str; }
[ "public", "function", "get_pagination", "(", "$", "page", "=", "0", ")", "{", "global", "$", "CFG", ",", "$", "OUTPUT", ";", "$", "count", "=", "$", "this", "->", "count", "(", ")", ";", "$", "perpage", "=", "(", "!", "empty", "(", "$", "CFG", "->", "commentsperpage", ")", ")", "?", "$", "CFG", "->", "commentsperpage", ":", "15", ";", "$", "pages", "=", "(", "int", ")", "ceil", "(", "$", "count", "/", "$", "perpage", ")", ";", "if", "(", "$", "pages", "==", "1", "||", "$", "pages", "==", "0", ")", "{", "return", "html_writer", "::", "tag", "(", "'div'", ",", "''", ",", "array", "(", "'id'", "=>", "'comment-pagination-'", ".", "$", "this", "->", "cid", ",", "'class'", "=>", "'comment-pagination'", ")", ")", ";", "}", "if", "(", "!", "empty", "(", "self", "::", "$", "nonjs", ")", ")", "{", "// used in non-js interface", "return", "$", "OUTPUT", "->", "paging_bar", "(", "$", "count", ",", "$", "page", ",", "$", "perpage", ",", "$", "this", "->", "get_nojslink", "(", ")", ",", "'comment_page'", ")", ";", "}", "else", "{", "// return ajax paging bar", "$", "str", "=", "''", ";", "$", "str", ".=", "'<div class=\"comment-paging\" id=\"comment-pagination-'", ".", "$", "this", "->", "cid", ".", "'\">'", ";", "for", "(", "$", "p", "=", "0", ";", "$", "p", "<", "$", "pages", ";", "$", "p", "++", ")", "{", "if", "(", "$", "p", "==", "$", "page", ")", "{", "$", "class", "=", "'curpage'", ";", "}", "else", "{", "$", "class", "=", "'pageno'", ";", "}", "$", "str", ".=", "'<a href=\"#\" class=\"'", ".", "$", "class", ".", "'\" id=\"comment-page-'", ".", "$", "this", "->", "cid", ".", "'-'", ".", "$", "p", ".", "'\">'", ".", "(", "$", "p", "+", "1", ")", ".", "'</a> '", ";", "}", "$", "str", ".=", "'</div>'", ";", "}", "return", "$", "str", ";", "}" ]
Returns HTML to display a pagination bar @global stdClass $CFG @global core_renderer $OUTPUT @param int $page @return string
[ "Returns", "HTML", "to", "display", "a", "pagination", "bar" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/comment/lib.php#L658-L684
214,429
moodle/moodle
comment/lib.php
comment.delete_comments
public static function delete_comments($param) { global $DB; $param = (array)$param; if (empty($param['contextid'])) { return false; } $DB->delete_records('comments', $param); return true; }
php
public static function delete_comments($param) { global $DB; $param = (array)$param; if (empty($param['contextid'])) { return false; } $DB->delete_records('comments', $param); return true; }
[ "public", "static", "function", "delete_comments", "(", "$", "param", ")", "{", "global", "$", "DB", ";", "$", "param", "=", "(", "array", ")", "$", "param", ";", "if", "(", "empty", "(", "$", "param", "[", "'contextid'", "]", ")", ")", "{", "return", "false", ";", "}", "$", "DB", "->", "delete_records", "(", "'comments'", ",", "$", "param", ")", ";", "return", "true", ";", "}" ]
delete by context, commentarea and itemid @param stdClass|array $param { contextid => int the context in which the comments exist [required] commentarea => string the comment area [optional] itemid => int comment itemid [optional] } @return boolean
[ "delete", "by", "context", "commentarea", "and", "itemid" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/comment/lib.php#L771-L779
214,430
moodle/moodle
comment/lib.php
comment.reset_course_page_comments
public static function reset_course_page_comments($context) { global $DB; $contexts = array(); $contexts[] = $context->id; $children = $context->get_child_contexts(); foreach ($children as $c) { $contexts[] = $c->id; } list($ids, $params) = $DB->get_in_or_equal($contexts); $DB->delete_records_select('comments', "commentarea='page_comments' AND contextid $ids", $params); }
php
public static function reset_course_page_comments($context) { global $DB; $contexts = array(); $contexts[] = $context->id; $children = $context->get_child_contexts(); foreach ($children as $c) { $contexts[] = $c->id; } list($ids, $params) = $DB->get_in_or_equal($contexts); $DB->delete_records_select('comments', "commentarea='page_comments' AND contextid $ids", $params); }
[ "public", "static", "function", "reset_course_page_comments", "(", "$", "context", ")", "{", "global", "$", "DB", ";", "$", "contexts", "=", "array", "(", ")", ";", "$", "contexts", "[", "]", "=", "$", "context", "->", "id", ";", "$", "children", "=", "$", "context", "->", "get_child_contexts", "(", ")", ";", "foreach", "(", "$", "children", "as", "$", "c", ")", "{", "$", "contexts", "[", "]", "=", "$", "c", "->", "id", ";", "}", "list", "(", "$", "ids", ",", "$", "params", ")", "=", "$", "DB", "->", "get_in_or_equal", "(", "$", "contexts", ")", ";", "$", "DB", "->", "delete_records_select", "(", "'comments'", ",", "\"commentarea='page_comments' AND contextid $ids\"", ",", "$", "params", ")", ";", "}" ]
Delete page_comments in whole course, used by course reset @param stdClass $context course context
[ "Delete", "page_comments", "in", "whole", "course", "used", "by", "course", "reset" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/comment/lib.php#L786-L796
214,431
moodle/moodle
comment/lib.php
comment.print_comment
public function print_comment($cmt, $nonjs = true) { global $OUTPUT; $patterns = array(); $replacements = array(); if (!empty($cmt->delete) && empty($nonjs)) { $strdelete = get_string('deletecommentbyon', 'moodle', (object)['user' => $cmt->fullname, 'time' => $cmt->time]); $deletelink = html_writer::start_tag('div', array('class'=>'comment-delete')); $deletelink .= html_writer::start_tag('a', array('href' => '#', 'id' => 'comment-delete-'.$this->cid.'-'.$cmt->id, 'title' => $strdelete)); $deletelink .= $OUTPUT->pix_icon('t/delete', get_string('delete')); $deletelink .= html_writer::end_tag('a'); $deletelink .= html_writer::end_tag('div'); $cmt->content = $deletelink . $cmt->content; } $patterns[] = '___picture___'; $patterns[] = '___name___'; $patterns[] = '___content___'; $patterns[] = '___time___'; $replacements[] = $cmt->avatar; $replacements[] = html_writer::link($cmt->profileurl, $cmt->fullname); $replacements[] = $cmt->content; $replacements[] = $cmt->time; // use html template to format a single comment. return str_replace($patterns, $replacements, $this->template); }
php
public function print_comment($cmt, $nonjs = true) { global $OUTPUT; $patterns = array(); $replacements = array(); if (!empty($cmt->delete) && empty($nonjs)) { $strdelete = get_string('deletecommentbyon', 'moodle', (object)['user' => $cmt->fullname, 'time' => $cmt->time]); $deletelink = html_writer::start_tag('div', array('class'=>'comment-delete')); $deletelink .= html_writer::start_tag('a', array('href' => '#', 'id' => 'comment-delete-'.$this->cid.'-'.$cmt->id, 'title' => $strdelete)); $deletelink .= $OUTPUT->pix_icon('t/delete', get_string('delete')); $deletelink .= html_writer::end_tag('a'); $deletelink .= html_writer::end_tag('div'); $cmt->content = $deletelink . $cmt->content; } $patterns[] = '___picture___'; $patterns[] = '___name___'; $patterns[] = '___content___'; $patterns[] = '___time___'; $replacements[] = $cmt->avatar; $replacements[] = html_writer::link($cmt->profileurl, $cmt->fullname); $replacements[] = $cmt->content; $replacements[] = $cmt->time; // use html template to format a single comment. return str_replace($patterns, $replacements, $this->template); }
[ "public", "function", "print_comment", "(", "$", "cmt", ",", "$", "nonjs", "=", "true", ")", "{", "global", "$", "OUTPUT", ";", "$", "patterns", "=", "array", "(", ")", ";", "$", "replacements", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "cmt", "->", "delete", ")", "&&", "empty", "(", "$", "nonjs", ")", ")", "{", "$", "strdelete", "=", "get_string", "(", "'deletecommentbyon'", ",", "'moodle'", ",", "(", "object", ")", "[", "'user'", "=>", "$", "cmt", "->", "fullname", ",", "'time'", "=>", "$", "cmt", "->", "time", "]", ")", ";", "$", "deletelink", "=", "html_writer", "::", "start_tag", "(", "'div'", ",", "array", "(", "'class'", "=>", "'comment-delete'", ")", ")", ";", "$", "deletelink", ".=", "html_writer", "::", "start_tag", "(", "'a'", ",", "array", "(", "'href'", "=>", "'#'", ",", "'id'", "=>", "'comment-delete-'", ".", "$", "this", "->", "cid", ".", "'-'", ".", "$", "cmt", "->", "id", ",", "'title'", "=>", "$", "strdelete", ")", ")", ";", "$", "deletelink", ".=", "$", "OUTPUT", "->", "pix_icon", "(", "'t/delete'", ",", "get_string", "(", "'delete'", ")", ")", ";", "$", "deletelink", ".=", "html_writer", "::", "end_tag", "(", "'a'", ")", ";", "$", "deletelink", ".=", "html_writer", "::", "end_tag", "(", "'div'", ")", ";", "$", "cmt", "->", "content", "=", "$", "deletelink", ".", "$", "cmt", "->", "content", ";", "}", "$", "patterns", "[", "]", "=", "'___picture___'", ";", "$", "patterns", "[", "]", "=", "'___name___'", ";", "$", "patterns", "[", "]", "=", "'___content___'", ";", "$", "patterns", "[", "]", "=", "'___time___'", ";", "$", "replacements", "[", "]", "=", "$", "cmt", "->", "avatar", ";", "$", "replacements", "[", "]", "=", "html_writer", "::", "link", "(", "$", "cmt", "->", "profileurl", ",", "$", "cmt", "->", "fullname", ")", ";", "$", "replacements", "[", "]", "=", "$", "cmt", "->", "content", ";", "$", "replacements", "[", "]", "=", "$", "cmt", "->", "time", ";", "// use html template to format a single comment.", "return", "str_replace", "(", "$", "patterns", ",", "$", "replacements", ",", "$", "this", "->", "template", ")", ";", "}" ]
Returns an array containing comments in HTML format. @global core_renderer $OUTPUT @param stdClass $cmt { id => int comment id content => string comment content format => int comment text format timecreated => int comment's timecreated profileurl => string link to user profile fullname => comment author's full name avatar => string user's avatar delete => boolean does user have permission to delete comment? } @param bool $nonjs @return array
[ "Returns", "an", "array", "containing", "comments", "in", "HTML", "format", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/comment/lib.php#L914-L941
214,432
moodle/moodle
comment/lib.php
comment.validate
protected function validate($params=array()) { foreach ($params as $key=>$value) { $this->comment_param->$key = $value; } $validation = plugin_callback($this->plugintype, $this->pluginname, 'comment', 'validate', array($this->comment_param), false); if (!$validation) { throw new comment_exception('invalidcommentparam'); } }
php
protected function validate($params=array()) { foreach ($params as $key=>$value) { $this->comment_param->$key = $value; } $validation = plugin_callback($this->plugintype, $this->pluginname, 'comment', 'validate', array($this->comment_param), false); if (!$validation) { throw new comment_exception('invalidcommentparam'); } }
[ "protected", "function", "validate", "(", "$", "params", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "comment_param", "->", "$", "key", "=", "$", "value", ";", "}", "$", "validation", "=", "plugin_callback", "(", "$", "this", "->", "plugintype", ",", "$", "this", "->", "pluginname", ",", "'comment'", ",", "'validate'", ",", "array", "(", "$", "this", "->", "comment_param", ")", ",", "false", ")", ";", "if", "(", "!", "$", "validation", ")", "{", "throw", "new", "comment_exception", "(", "'invalidcommentparam'", ")", ";", "}", "}" ]
Revoke validate callbacks @param stdClass $params addtionall parameters need to add to callbacks
[ "Revoke", "validate", "callbacks" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/comment/lib.php#L948-L956
214,433
moodle/moodle
lib/phpmailer/src/PHPMailer.php
PHPMailer.smtpSend
protected function smtpSend($header, $body) { $bad_rcpt = []; if (!$this->smtpConnect($this->SMTPOptions)) { throw new Exception($this->lang('smtp_connect_failed'), self::STOP_CRITICAL); } //Sender already validated in preSend() if ('' == $this->Sender) { $smtp_from = $this->From; } else { $smtp_from = $this->Sender; } if (!$this->smtp->mail($smtp_from)) { $this->setError($this->lang('from_failed') . $smtp_from . ' : ' . implode(',', $this->smtp->getError())); throw new Exception($this->ErrorInfo, self::STOP_CRITICAL); } $callbacks = []; // Attempt to send to all recipients foreach ([$this->to, $this->cc, $this->bcc] as $togroup) { foreach ($togroup as $to) { if (!$this->smtp->recipient($to[0])) { $error = $this->smtp->getError(); $bad_rcpt[] = ['to' => $to[0], 'error' => $error['detail']]; $isSent = false; } else { $isSent = true; } $callbacks[] = ['issent'=>$isSent, 'to'=>$to[0]]; } } // Only send the DATA command if we have viable recipients if ((count($this->all_recipients) > count($bad_rcpt)) and !$this->smtp->data($header . $body)) { throw new Exception($this->lang('data_not_accepted'), self::STOP_CRITICAL); } $smtp_transaction_id = $this->smtp->getLastTransactionID(); if ($this->SMTPKeepAlive) { $this->smtp->reset(); } else { $this->smtp->quit(); $this->smtp->close(); } foreach ($callbacks as $cb) { $this->doCallback( $cb['issent'], [$cb['to']], [], [], $this->Subject, $body, $this->From, ['smtp_transaction_id' => $smtp_transaction_id] ); } //Create error message for any bad addresses if (count($bad_rcpt) > 0) { $errstr = ''; foreach ($bad_rcpt as $bad) { $errstr .= $bad['to'] . ': ' . $bad['error']; } throw new Exception( $this->lang('recipients_failed') . $errstr, self::STOP_CONTINUE ); } return true; }
php
protected function smtpSend($header, $body) { $bad_rcpt = []; if (!$this->smtpConnect($this->SMTPOptions)) { throw new Exception($this->lang('smtp_connect_failed'), self::STOP_CRITICAL); } //Sender already validated in preSend() if ('' == $this->Sender) { $smtp_from = $this->From; } else { $smtp_from = $this->Sender; } if (!$this->smtp->mail($smtp_from)) { $this->setError($this->lang('from_failed') . $smtp_from . ' : ' . implode(',', $this->smtp->getError())); throw new Exception($this->ErrorInfo, self::STOP_CRITICAL); } $callbacks = []; // Attempt to send to all recipients foreach ([$this->to, $this->cc, $this->bcc] as $togroup) { foreach ($togroup as $to) { if (!$this->smtp->recipient($to[0])) { $error = $this->smtp->getError(); $bad_rcpt[] = ['to' => $to[0], 'error' => $error['detail']]; $isSent = false; } else { $isSent = true; } $callbacks[] = ['issent'=>$isSent, 'to'=>$to[0]]; } } // Only send the DATA command if we have viable recipients if ((count($this->all_recipients) > count($bad_rcpt)) and !$this->smtp->data($header . $body)) { throw new Exception($this->lang('data_not_accepted'), self::STOP_CRITICAL); } $smtp_transaction_id = $this->smtp->getLastTransactionID(); if ($this->SMTPKeepAlive) { $this->smtp->reset(); } else { $this->smtp->quit(); $this->smtp->close(); } foreach ($callbacks as $cb) { $this->doCallback( $cb['issent'], [$cb['to']], [], [], $this->Subject, $body, $this->From, ['smtp_transaction_id' => $smtp_transaction_id] ); } //Create error message for any bad addresses if (count($bad_rcpt) > 0) { $errstr = ''; foreach ($bad_rcpt as $bad) { $errstr .= $bad['to'] . ': ' . $bad['error']; } throw new Exception( $this->lang('recipients_failed') . $errstr, self::STOP_CONTINUE ); } return true; }
[ "protected", "function", "smtpSend", "(", "$", "header", ",", "$", "body", ")", "{", "$", "bad_rcpt", "=", "[", "]", ";", "if", "(", "!", "$", "this", "->", "smtpConnect", "(", "$", "this", "->", "SMTPOptions", ")", ")", "{", "throw", "new", "Exception", "(", "$", "this", "->", "lang", "(", "'smtp_connect_failed'", ")", ",", "self", "::", "STOP_CRITICAL", ")", ";", "}", "//Sender already validated in preSend()", "if", "(", "''", "==", "$", "this", "->", "Sender", ")", "{", "$", "smtp_from", "=", "$", "this", "->", "From", ";", "}", "else", "{", "$", "smtp_from", "=", "$", "this", "->", "Sender", ";", "}", "if", "(", "!", "$", "this", "->", "smtp", "->", "mail", "(", "$", "smtp_from", ")", ")", "{", "$", "this", "->", "setError", "(", "$", "this", "->", "lang", "(", "'from_failed'", ")", ".", "$", "smtp_from", ".", "' : '", ".", "implode", "(", "','", ",", "$", "this", "->", "smtp", "->", "getError", "(", ")", ")", ")", ";", "throw", "new", "Exception", "(", "$", "this", "->", "ErrorInfo", ",", "self", "::", "STOP_CRITICAL", ")", ";", "}", "$", "callbacks", "=", "[", "]", ";", "// Attempt to send to all recipients", "foreach", "(", "[", "$", "this", "->", "to", ",", "$", "this", "->", "cc", ",", "$", "this", "->", "bcc", "]", "as", "$", "togroup", ")", "{", "foreach", "(", "$", "togroup", "as", "$", "to", ")", "{", "if", "(", "!", "$", "this", "->", "smtp", "->", "recipient", "(", "$", "to", "[", "0", "]", ")", ")", "{", "$", "error", "=", "$", "this", "->", "smtp", "->", "getError", "(", ")", ";", "$", "bad_rcpt", "[", "]", "=", "[", "'to'", "=>", "$", "to", "[", "0", "]", ",", "'error'", "=>", "$", "error", "[", "'detail'", "]", "]", ";", "$", "isSent", "=", "false", ";", "}", "else", "{", "$", "isSent", "=", "true", ";", "}", "$", "callbacks", "[", "]", "=", "[", "'issent'", "=>", "$", "isSent", ",", "'to'", "=>", "$", "to", "[", "0", "]", "]", ";", "}", "}", "// Only send the DATA command if we have viable recipients", "if", "(", "(", "count", "(", "$", "this", "->", "all_recipients", ")", ">", "count", "(", "$", "bad_rcpt", ")", ")", "and", "!", "$", "this", "->", "smtp", "->", "data", "(", "$", "header", ".", "$", "body", ")", ")", "{", "throw", "new", "Exception", "(", "$", "this", "->", "lang", "(", "'data_not_accepted'", ")", ",", "self", "::", "STOP_CRITICAL", ")", ";", "}", "$", "smtp_transaction_id", "=", "$", "this", "->", "smtp", "->", "getLastTransactionID", "(", ")", ";", "if", "(", "$", "this", "->", "SMTPKeepAlive", ")", "{", "$", "this", "->", "smtp", "->", "reset", "(", ")", ";", "}", "else", "{", "$", "this", "->", "smtp", "->", "quit", "(", ")", ";", "$", "this", "->", "smtp", "->", "close", "(", ")", ";", "}", "foreach", "(", "$", "callbacks", "as", "$", "cb", ")", "{", "$", "this", "->", "doCallback", "(", "$", "cb", "[", "'issent'", "]", ",", "[", "$", "cb", "[", "'to'", "]", "]", ",", "[", "]", ",", "[", "]", ",", "$", "this", "->", "Subject", ",", "$", "body", ",", "$", "this", "->", "From", ",", "[", "'smtp_transaction_id'", "=>", "$", "smtp_transaction_id", "]", ")", ";", "}", "//Create error message for any bad addresses", "if", "(", "count", "(", "$", "bad_rcpt", ")", ">", "0", ")", "{", "$", "errstr", "=", "''", ";", "foreach", "(", "$", "bad_rcpt", "as", "$", "bad", ")", "{", "$", "errstr", ".=", "$", "bad", "[", "'to'", "]", ".", "': '", ".", "$", "bad", "[", "'error'", "]", ";", "}", "throw", "new", "Exception", "(", "$", "this", "->", "lang", "(", "'recipients_failed'", ")", ".", "$", "errstr", ",", "self", "::", "STOP_CONTINUE", ")", ";", "}", "return", "true", ";", "}" ]
Send mail via SMTP. Returns false if there is a bad MAIL FROM, RCPT, or DATA input. @see PHPMailer::setSMTPInstance() to use a different class. @uses \PHPMailer\PHPMailer\SMTP @param string $header The message headers @param string $body The message body @throws Exception @return bool
[ "Send", "mail", "via", "SMTP", ".", "Returns", "false", "if", "there", "is", "a", "bad", "MAIL", "FROM", "RCPT", "or", "DATA", "input", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpmailer/src/PHPMailer.php#L1706-L1779
214,434
moodle/moodle
lib/phpmailer/src/PHPMailer.php
PHPMailer.getBoundary
protected function getBoundary($boundary, $charSet, $contentType, $encoding) { $result = ''; if ('' == $charSet) { $charSet = $this->CharSet; } if ('' == $contentType) { $contentType = $this->ContentType; } if ('' == $encoding) { $encoding = $this->Encoding; } $result .= $this->textLine('--' . $boundary); $result .= sprintf('Content-Type: %s; charset=%s', $contentType, $charSet); $result .= static::$LE; // RFC1341 part 5 says 7bit is assumed if not specified if ('7bit' != $encoding) { $result .= $this->headerLine('Content-Transfer-Encoding', $encoding); } $result .= static::$LE; return $result; }
php
protected function getBoundary($boundary, $charSet, $contentType, $encoding) { $result = ''; if ('' == $charSet) { $charSet = $this->CharSet; } if ('' == $contentType) { $contentType = $this->ContentType; } if ('' == $encoding) { $encoding = $this->Encoding; } $result .= $this->textLine('--' . $boundary); $result .= sprintf('Content-Type: %s; charset=%s', $contentType, $charSet); $result .= static::$LE; // RFC1341 part 5 says 7bit is assumed if not specified if ('7bit' != $encoding) { $result .= $this->headerLine('Content-Transfer-Encoding', $encoding); } $result .= static::$LE; return $result; }
[ "protected", "function", "getBoundary", "(", "$", "boundary", ",", "$", "charSet", ",", "$", "contentType", ",", "$", "encoding", ")", "{", "$", "result", "=", "''", ";", "if", "(", "''", "==", "$", "charSet", ")", "{", "$", "charSet", "=", "$", "this", "->", "CharSet", ";", "}", "if", "(", "''", "==", "$", "contentType", ")", "{", "$", "contentType", "=", "$", "this", "->", "ContentType", ";", "}", "if", "(", "''", "==", "$", "encoding", ")", "{", "$", "encoding", "=", "$", "this", "->", "Encoding", ";", "}", "$", "result", ".=", "$", "this", "->", "textLine", "(", "'--'", ".", "$", "boundary", ")", ";", "$", "result", ".=", "sprintf", "(", "'Content-Type: %s; charset=%s'", ",", "$", "contentType", ",", "$", "charSet", ")", ";", "$", "result", ".=", "static", "::", "$", "LE", ";", "// RFC1341 part 5 says 7bit is assumed if not specified", "if", "(", "'7bit'", "!=", "$", "encoding", ")", "{", "$", "result", ".=", "$", "this", "->", "headerLine", "(", "'Content-Transfer-Encoding'", ",", "$", "encoding", ")", ";", "}", "$", "result", ".=", "static", "::", "$", "LE", ";", "return", "$", "result", ";", "}" ]
Return the start of a message boundary. @param string $boundary @param string $charSet @param string $contentType @param string $encoding @return string
[ "Return", "the", "start", "of", "a", "message", "boundary", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpmailer/src/PHPMailer.php#L2642-L2664
214,435
moodle/moodle
lib/phpmailer/src/PHPMailer.php
PHPMailer.DKIM_BodyC
public function DKIM_BodyC($body) { if (empty($body)) { return static::$LE; } // Normalize line endings $body = static::normalizeBreaks($body); //Reduce multiple trailing line breaks to a single one return rtrim($body, "\r\n") . static::$LE; }
php
public function DKIM_BodyC($body) { if (empty($body)) { return static::$LE; } // Normalize line endings $body = static::normalizeBreaks($body); //Reduce multiple trailing line breaks to a single one return rtrim($body, "\r\n") . static::$LE; }
[ "public", "function", "DKIM_BodyC", "(", "$", "body", ")", "{", "if", "(", "empty", "(", "$", "body", ")", ")", "{", "return", "static", "::", "$", "LE", ";", "}", "// Normalize line endings", "$", "body", "=", "static", "::", "normalizeBreaks", "(", "$", "body", ")", ";", "//Reduce multiple trailing line breaks to a single one", "return", "rtrim", "(", "$", "body", ",", "\"\\r\\n\"", ")", ".", "static", "::", "$", "LE", ";", "}" ]
Generate a DKIM canonicalization body. Uses the 'simple' algorithm from RFC6376 section 3.4.3. @see https://tools.ietf.org/html/rfc6376#section-3.4.3 @param string $body Message Body @return string
[ "Generate", "a", "DKIM", "canonicalization", "body", ".", "Uses", "the", "simple", "algorithm", "from", "RFC6376", "section", "3", ".", "4", ".", "3", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/phpmailer/src/PHPMailer.php#L4187-L4197
214,436
moodle/moodle
lib/classes/output/mustache_string_helper.php
mustache_string_helper.str
public function str($text, Mustache_LambdaHelper $helper) { // Split the text into an array of variables. $key = strtok($text, ","); $key = trim($key); $component = strtok(","); $component = trim($component); if (!$component) { $component = ''; } $a = new stdClass(); $next = strtok(''); $next = trim($next); if ((strpos($next, '{') === 0) && (strpos($next, '{{') !== 0)) { $rawjson = $helper->render($next); $a = json_decode($rawjson); } else { $a = $helper->render($next); } return get_string($key, $component, $a); }
php
public function str($text, Mustache_LambdaHelper $helper) { // Split the text into an array of variables. $key = strtok($text, ","); $key = trim($key); $component = strtok(","); $component = trim($component); if (!$component) { $component = ''; } $a = new stdClass(); $next = strtok(''); $next = trim($next); if ((strpos($next, '{') === 0) && (strpos($next, '{{') !== 0)) { $rawjson = $helper->render($next); $a = json_decode($rawjson); } else { $a = $helper->render($next); } return get_string($key, $component, $a); }
[ "public", "function", "str", "(", "$", "text", ",", "Mustache_LambdaHelper", "$", "helper", ")", "{", "// Split the text into an array of variables.", "$", "key", "=", "strtok", "(", "$", "text", ",", "\",\"", ")", ";", "$", "key", "=", "trim", "(", "$", "key", ")", ";", "$", "component", "=", "strtok", "(", "\",\"", ")", ";", "$", "component", "=", "trim", "(", "$", "component", ")", ";", "if", "(", "!", "$", "component", ")", "{", "$", "component", "=", "''", ";", "}", "$", "a", "=", "new", "stdClass", "(", ")", ";", "$", "next", "=", "strtok", "(", "''", ")", ";", "$", "next", "=", "trim", "(", "$", "next", ")", ";", "if", "(", "(", "strpos", "(", "$", "next", ",", "'{'", ")", "===", "0", ")", "&&", "(", "strpos", "(", "$", "next", ",", "'{{'", ")", "!==", "0", ")", ")", "{", "$", "rawjson", "=", "$", "helper", "->", "render", "(", "$", "next", ")", ";", "$", "a", "=", "json_decode", "(", "$", "rawjson", ")", ";", "}", "else", "{", "$", "a", "=", "$", "helper", "->", "render", "(", "$", "next", ")", ";", "}", "return", "get_string", "(", "$", "key", ",", "$", "component", ",", "$", "a", ")", ";", "}" ]
Read a lang string from a template and get it from get_string. Some examples for calling this from a template are: {{#str}}activity{{/str}} {{#str}}actionchoice, core, {{#str}}delete{{/str}}{{/str}} (Nested) {{#str}}addinganewto, core, {"what":"This", "to":"That"}{{/str}} (Complex $a) The args are comma separated and only the first is required. The last is a $a argument for get string. For complex data here, use JSON. @param string $text The text to parse for arguments. @param Mustache_LambdaHelper $helper Used to render nested mustache variables. @return string
[ "Read", "a", "lang", "string", "from", "a", "template", "and", "get", "it", "from", "get_string", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/output/mustache_string_helper.php#L56-L77
214,437
moodle/moodle
mod/quiz/report/statistics/classes/calculated.php
calculated.cache
public function cache($qubaids) { global $DB; $toinsert = new \stdClass(); foreach ($this->fieldsindb as $field) { $toinsert->{$field} = $this->{$field}; } $toinsert->hashcode = $qubaids->get_hash_code(); $toinsert->timemodified = time(); // Fix up some dodgy data. if (isset($toinsert->errorratio) && is_nan($toinsert->errorratio)) { $toinsert->errorratio = null; } if (isset($toinsert->standarderror) && is_nan($toinsert->standarderror)) { $toinsert->standarderror = null; } // Store the data. $DB->insert_record('quiz_statistics', $toinsert); }
php
public function cache($qubaids) { global $DB; $toinsert = new \stdClass(); foreach ($this->fieldsindb as $field) { $toinsert->{$field} = $this->{$field}; } $toinsert->hashcode = $qubaids->get_hash_code(); $toinsert->timemodified = time(); // Fix up some dodgy data. if (isset($toinsert->errorratio) && is_nan($toinsert->errorratio)) { $toinsert->errorratio = null; } if (isset($toinsert->standarderror) && is_nan($toinsert->standarderror)) { $toinsert->standarderror = null; } // Store the data. $DB->insert_record('quiz_statistics', $toinsert); }
[ "public", "function", "cache", "(", "$", "qubaids", ")", "{", "global", "$", "DB", ";", "$", "toinsert", "=", "new", "\\", "stdClass", "(", ")", ";", "foreach", "(", "$", "this", "->", "fieldsindb", "as", "$", "field", ")", "{", "$", "toinsert", "->", "{", "$", "field", "}", "=", "$", "this", "->", "{", "$", "field", "}", ";", "}", "$", "toinsert", "->", "hashcode", "=", "$", "qubaids", "->", "get_hash_code", "(", ")", ";", "$", "toinsert", "->", "timemodified", "=", "time", "(", ")", ";", "// Fix up some dodgy data.", "if", "(", "isset", "(", "$", "toinsert", "->", "errorratio", ")", "&&", "is_nan", "(", "$", "toinsert", "->", "errorratio", ")", ")", "{", "$", "toinsert", "->", "errorratio", "=", "null", ";", "}", "if", "(", "isset", "(", "$", "toinsert", "->", "standarderror", ")", "&&", "is_nan", "(", "$", "toinsert", "->", "standarderror", ")", ")", "{", "$", "toinsert", "->", "standarderror", "=", "null", ";", "}", "// Store the data.", "$", "DB", "->", "insert_record", "(", "'quiz_statistics'", ",", "$", "toinsert", ")", ";", "}" ]
Cache the stats contained in this class. @param $qubaids \qubaid_condition
[ "Cache", "the", "stats", "contained", "in", "this", "class", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/statistics/classes/calculated.php#L208-L231
214,438
moodle/moodle
question/type/multianswer/renderer.php
qtype_multianswer_subq_renderer_base.feedback_popup
protected function feedback_popup(question_graded_automatically $subq, $fraction, $feedbacktext, $rightanswer, question_display_options $options) { $feedback = array(); if ($options->correctness) { if (is_null($fraction)) { $state = question_state::$gaveup; } else { $state = question_state::graded_state_for_fraction($fraction); } $feedback[] = $state->default_string(true); } if ($options->feedback && $feedbacktext) { $feedback[] = $feedbacktext; } if ($options->rightanswer) { $feedback[] = get_string('correctansweris', 'qtype_shortanswer', $rightanswer); } $subfraction = ''; if ($options->marks >= question_display_options::MARK_AND_MAX && $subq->maxmark > 0 && (!is_null($fraction) || $feedback)) { $a = new stdClass(); $a->mark = format_float($fraction * $subq->maxmark, $options->markdp); $a->max = format_float($subq->maxmark, $options->markdp); $feedback[] = get_string('markoutofmax', 'question', $a); } if (!$feedback) { return ''; } return html_writer::tag('span', implode('<br />', $feedback), array('class' => 'feedbackspan accesshide')); }
php
protected function feedback_popup(question_graded_automatically $subq, $fraction, $feedbacktext, $rightanswer, question_display_options $options) { $feedback = array(); if ($options->correctness) { if (is_null($fraction)) { $state = question_state::$gaveup; } else { $state = question_state::graded_state_for_fraction($fraction); } $feedback[] = $state->default_string(true); } if ($options->feedback && $feedbacktext) { $feedback[] = $feedbacktext; } if ($options->rightanswer) { $feedback[] = get_string('correctansweris', 'qtype_shortanswer', $rightanswer); } $subfraction = ''; if ($options->marks >= question_display_options::MARK_AND_MAX && $subq->maxmark > 0 && (!is_null($fraction) || $feedback)) { $a = new stdClass(); $a->mark = format_float($fraction * $subq->maxmark, $options->markdp); $a->max = format_float($subq->maxmark, $options->markdp); $feedback[] = get_string('markoutofmax', 'question', $a); } if (!$feedback) { return ''; } return html_writer::tag('span', implode('<br />', $feedback), array('class' => 'feedbackspan accesshide')); }
[ "protected", "function", "feedback_popup", "(", "question_graded_automatically", "$", "subq", ",", "$", "fraction", ",", "$", "feedbacktext", ",", "$", "rightanswer", ",", "question_display_options", "$", "options", ")", "{", "$", "feedback", "=", "array", "(", ")", ";", "if", "(", "$", "options", "->", "correctness", ")", "{", "if", "(", "is_null", "(", "$", "fraction", ")", ")", "{", "$", "state", "=", "question_state", "::", "$", "gaveup", ";", "}", "else", "{", "$", "state", "=", "question_state", "::", "graded_state_for_fraction", "(", "$", "fraction", ")", ";", "}", "$", "feedback", "[", "]", "=", "$", "state", "->", "default_string", "(", "true", ")", ";", "}", "if", "(", "$", "options", "->", "feedback", "&&", "$", "feedbacktext", ")", "{", "$", "feedback", "[", "]", "=", "$", "feedbacktext", ";", "}", "if", "(", "$", "options", "->", "rightanswer", ")", "{", "$", "feedback", "[", "]", "=", "get_string", "(", "'correctansweris'", ",", "'qtype_shortanswer'", ",", "$", "rightanswer", ")", ";", "}", "$", "subfraction", "=", "''", ";", "if", "(", "$", "options", "->", "marks", ">=", "question_display_options", "::", "MARK_AND_MAX", "&&", "$", "subq", "->", "maxmark", ">", "0", "&&", "(", "!", "is_null", "(", "$", "fraction", ")", "||", "$", "feedback", ")", ")", "{", "$", "a", "=", "new", "stdClass", "(", ")", ";", "$", "a", "->", "mark", "=", "format_float", "(", "$", "fraction", "*", "$", "subq", "->", "maxmark", ",", "$", "options", "->", "markdp", ")", ";", "$", "a", "->", "max", "=", "format_float", "(", "$", "subq", "->", "maxmark", ",", "$", "options", "->", "markdp", ")", ";", "$", "feedback", "[", "]", "=", "get_string", "(", "'markoutofmax'", ",", "'question'", ",", "$", "a", ")", ";", "}", "if", "(", "!", "$", "feedback", ")", "{", "return", "''", ";", "}", "return", "html_writer", "::", "tag", "(", "'span'", ",", "implode", "(", "'<br />'", ",", "$", "feedback", ")", ",", "array", "(", "'class'", "=>", "'feedbackspan accesshide'", ")", ")", ";", "}" ]
Render the feedback pop-up contents. @param question_graded_automatically $subq the subquestion. @param float $fraction the mark the student got. null if this subq was not answered. @param string $feedbacktext the feedback text, already processed with format_text etc. @param string $rightanswer the right answer, already processed with format_text etc. @param question_display_options $options the display options. @return string the HTML for the feedback popup.
[ "Render", "the", "feedback", "pop", "-", "up", "contents", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/type/multianswer/renderer.php#L138-L174
214,439
moodle/moodle
mod/quiz/report/grading/renderer.php
quiz_grading_renderer.render_display_index_heading
public function render_display_index_heading($linktext, $listquestionurl) { $output = ''; $output .= $this->heading(get_string('questionsthatneedgrading', 'quiz_grading'), 3); $output .= html_writer::tag('p', html_writer::link($listquestionurl, $linktext), ['class' => 'toggleincludeauto']); return $output; }
php
public function render_display_index_heading($linktext, $listquestionurl) { $output = ''; $output .= $this->heading(get_string('questionsthatneedgrading', 'quiz_grading'), 3); $output .= html_writer::tag('p', html_writer::link($listquestionurl, $linktext), ['class' => 'toggleincludeauto']); return $output; }
[ "public", "function", "render_display_index_heading", "(", "$", "linktext", ",", "$", "listquestionurl", ")", "{", "$", "output", "=", "''", ";", "$", "output", ".=", "$", "this", "->", "heading", "(", "get_string", "(", "'questionsthatneedgrading'", ",", "'quiz_grading'", ")", ",", "3", ")", ";", "$", "output", ".=", "html_writer", "::", "tag", "(", "'p'", ",", "html_writer", "::", "link", "(", "$", "listquestionurl", ",", "$", "linktext", ")", ",", "[", "'class'", "=>", "'toggleincludeauto'", "]", ")", ";", "return", "$", "output", ";", "}" ]
Render index display. @param string $linktext The text of the link. @param moodle_url $listquestionurl Url of the page that list all questions. @return string The HTML for the display heading. @throws coding_exception
[ "Render", "index", "display", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/grading/renderer.php#L64-L71
214,440
moodle/moodle
mod/quiz/report/grading/renderer.php
quiz_grading_renderer.render_questions_table
public function render_questions_table($includeauto, $data, $header) { if (empty($data)) { return $this->render_quiz_no_grade_question_notification(); } $output = ''; $table = new html_table(); $table->class = 'generaltable'; $table->id = 'questionstograde'; $table->head = $header; $table->data = $data; $output .= html_writer::table($table); return $output; }
php
public function render_questions_table($includeauto, $data, $header) { if (empty($data)) { return $this->render_quiz_no_grade_question_notification(); } $output = ''; $table = new html_table(); $table->class = 'generaltable'; $table->id = 'questionstograde'; $table->head = $header; $table->data = $data; $output .= html_writer::table($table); return $output; }
[ "public", "function", "render_questions_table", "(", "$", "includeauto", ",", "$", "data", ",", "$", "header", ")", "{", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "return", "$", "this", "->", "render_quiz_no_grade_question_notification", "(", ")", ";", "}", "$", "output", "=", "''", ";", "$", "table", "=", "new", "html_table", "(", ")", ";", "$", "table", "->", "class", "=", "'generaltable'", ";", "$", "table", "->", "id", "=", "'questionstograde'", ";", "$", "table", "->", "head", "=", "$", "header", ";", "$", "table", "->", "data", "=", "$", "data", ";", "$", "output", ".=", "html_writer", "::", "table", "(", "$", "table", ")", ";", "return", "$", "output", ";", "}" ]
Render questions list table. @param bool $includeauto True to show automatically graded questions. @param array $data List of questions. @param array $header List of table headers. @return string The HTML for the question table. @throws coding_exception
[ "Render", "questions", "list", "table", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/grading/renderer.php#L82-L97
214,441
moodle/moodle
mod/quiz/report/grading/renderer.php
quiz_grading_renderer.render_grade_link
public function render_grade_link($counts, $type, $gradestring, $gradequestionurl) { $output = ''; if ($counts->$type > 0) { $output .= ' ' . html_writer::link( $gradequestionurl, get_string($gradestring, 'quiz_grading'), ['class' => 'gradetheselink']); } return $output; }
php
public function render_grade_link($counts, $type, $gradestring, $gradequestionurl) { $output = ''; if ($counts->$type > 0) { $output .= ' ' . html_writer::link( $gradequestionurl, get_string($gradestring, 'quiz_grading'), ['class' => 'gradetheselink']); } return $output; }
[ "public", "function", "render_grade_link", "(", "$", "counts", ",", "$", "type", ",", "$", "gradestring", ",", "$", "gradequestionurl", ")", "{", "$", "output", "=", "''", ";", "if", "(", "$", "counts", "->", "$", "type", ">", "0", ")", "{", "$", "output", ".=", "' '", ".", "html_writer", "::", "link", "(", "$", "gradequestionurl", ",", "get_string", "(", "$", "gradestring", ",", "'quiz_grading'", ")", ",", "[", "'class'", "=>", "'gradetheselink'", "]", ")", ";", "}", "return", "$", "output", ";", "}" ]
Render grade link for question. @param object $counts @param string $type Type of grade. @param string $gradestring Lang string. @param moodle_url $gradequestionurl Url to grade question. @return string The HTML for the question grade link. @throws coding_exception
[ "Render", "grade", "link", "for", "question", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/grading/renderer.php#L109-L118
214,442
moodle/moodle
mod/quiz/report/grading/renderer.php
quiz_grading_renderer.render_grading_interface
public function render_grading_interface($questioninfo, $listquestionsurl, $filterform, $paginginfo, $pagingbar, $formaction, $hiddeninputs, $gradequestioncontent) { $output = ''; $output .= question_engine::initialise_js(); $output .= $this->heading(get_string('gradingquestionx', 'quiz_grading', $questioninfo), 3); $output .= html_writer::tag('p', html_writer::link($listquestionsurl, get_string('backtothelistofquestions', 'quiz_grading')), ['class' => 'mdl-align']); $output .= $filterform->render(); $output .= $this->heading(get_string('gradingattemptsxtoyofz', 'quiz_grading', $paginginfo), 3); if ($pagingbar->count > $pagingbar->pagesize && $pagingbar->order != 'random') { $output .= $this->paging_bar($pagingbar->count, $pagingbar->page, $pagingbar->pagesize, $pagingbar->pagingurl); } $output .= html_writer::start_tag('form', [ 'method' => 'post', 'action' => $formaction, 'class' => 'mform', 'id' => 'manualgradingform' ]); $output .= html_writer::start_tag('div'); $output .= html_writer::input_hidden_params(new moodle_url('', $hiddeninputs)); $output .= $gradequestioncontent; $output .= html_writer::tag('div', html_writer::empty_tag('input', [ 'type' => 'submit', 'class' => 'btn btn-primary', 'value' => get_string('saveandnext', 'quiz_grading') ]), ['class' => 'mdl-align']); $output .= html_writer::end_tag('div') . html_writer::end_tag('form'); return $output; }
php
public function render_grading_interface($questioninfo, $listquestionsurl, $filterform, $paginginfo, $pagingbar, $formaction, $hiddeninputs, $gradequestioncontent) { $output = ''; $output .= question_engine::initialise_js(); $output .= $this->heading(get_string('gradingquestionx', 'quiz_grading', $questioninfo), 3); $output .= html_writer::tag('p', html_writer::link($listquestionsurl, get_string('backtothelistofquestions', 'quiz_grading')), ['class' => 'mdl-align']); $output .= $filterform->render(); $output .= $this->heading(get_string('gradingattemptsxtoyofz', 'quiz_grading', $paginginfo), 3); if ($pagingbar->count > $pagingbar->pagesize && $pagingbar->order != 'random') { $output .= $this->paging_bar($pagingbar->count, $pagingbar->page, $pagingbar->pagesize, $pagingbar->pagingurl); } $output .= html_writer::start_tag('form', [ 'method' => 'post', 'action' => $formaction, 'class' => 'mform', 'id' => 'manualgradingform' ]); $output .= html_writer::start_tag('div'); $output .= html_writer::input_hidden_params(new moodle_url('', $hiddeninputs)); $output .= $gradequestioncontent; $output .= html_writer::tag('div', html_writer::empty_tag('input', [ 'type' => 'submit', 'class' => 'btn btn-primary', 'value' => get_string('saveandnext', 'quiz_grading') ]), ['class' => 'mdl-align']); $output .= html_writer::end_tag('div') . html_writer::end_tag('form'); return $output; }
[ "public", "function", "render_grading_interface", "(", "$", "questioninfo", ",", "$", "listquestionsurl", ",", "$", "filterform", ",", "$", "paginginfo", ",", "$", "pagingbar", ",", "$", "formaction", ",", "$", "hiddeninputs", ",", "$", "gradequestioncontent", ")", "{", "$", "output", "=", "''", ";", "$", "output", ".=", "question_engine", "::", "initialise_js", "(", ")", ";", "$", "output", ".=", "$", "this", "->", "heading", "(", "get_string", "(", "'gradingquestionx'", ",", "'quiz_grading'", ",", "$", "questioninfo", ")", ",", "3", ")", ";", "$", "output", ".=", "html_writer", "::", "tag", "(", "'p'", ",", "html_writer", "::", "link", "(", "$", "listquestionsurl", ",", "get_string", "(", "'backtothelistofquestions'", ",", "'quiz_grading'", ")", ")", ",", "[", "'class'", "=>", "'mdl-align'", "]", ")", ";", "$", "output", ".=", "$", "filterform", "->", "render", "(", ")", ";", "$", "output", ".=", "$", "this", "->", "heading", "(", "get_string", "(", "'gradingattemptsxtoyofz'", ",", "'quiz_grading'", ",", "$", "paginginfo", ")", ",", "3", ")", ";", "if", "(", "$", "pagingbar", "->", "count", ">", "$", "pagingbar", "->", "pagesize", "&&", "$", "pagingbar", "->", "order", "!=", "'random'", ")", "{", "$", "output", ".=", "$", "this", "->", "paging_bar", "(", "$", "pagingbar", "->", "count", ",", "$", "pagingbar", "->", "page", ",", "$", "pagingbar", "->", "pagesize", ",", "$", "pagingbar", "->", "pagingurl", ")", ";", "}", "$", "output", ".=", "html_writer", "::", "start_tag", "(", "'form'", ",", "[", "'method'", "=>", "'post'", ",", "'action'", "=>", "$", "formaction", ",", "'class'", "=>", "'mform'", ",", "'id'", "=>", "'manualgradingform'", "]", ")", ";", "$", "output", ".=", "html_writer", "::", "start_tag", "(", "'div'", ")", ";", "$", "output", ".=", "html_writer", "::", "input_hidden_params", "(", "new", "moodle_url", "(", "''", ",", "$", "hiddeninputs", ")", ")", ";", "$", "output", ".=", "$", "gradequestioncontent", ";", "$", "output", ".=", "html_writer", "::", "tag", "(", "'div'", ",", "html_writer", "::", "empty_tag", "(", "'input'", ",", "[", "'type'", "=>", "'submit'", ",", "'class'", "=>", "'btn btn-primary'", ",", "'value'", "=>", "get_string", "(", "'saveandnext'", ",", "'quiz_grading'", ")", "]", ")", ",", "[", "'class'", "=>", "'mdl-align'", "]", ")", ";", "$", "output", ".=", "html_writer", "::", "end_tag", "(", "'div'", ")", ".", "html_writer", "::", "end_tag", "(", "'form'", ")", ";", "return", "$", "output", ";", "}" ]
Render grading page. @param object $questioninfo Information of a question. @param moodle_url $listquestionsurl Url of the page that list all questions. @param quiz_grading_settings_form $filterform Question filter form. @param object $paginginfo Pagination information. @param object $pagingbar Pagination bar information. @param moodle_url $formaction Form submit url. @param array $hiddeninputs List of hidden input fields. @param string $gradequestioncontent HTML string of question content. @return string The HTML for the grading interface. @throws coding_exception @throws moodle_exception
[ "Render", "grading", "page", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/grading/renderer.php#L135-L174
214,443
moodle/moodle
mod/quiz/report/grading/renderer.php
quiz_grading_renderer.render_grade_question
public function render_grade_question($questionusage, $slot, $displayoptions, $questionnumber, $heading) { $output = ''; if ($heading) { $output .= $this->heading($heading, 4); } $output .= $questionusage->render_question($slot, $displayoptions, $questionnumber); return $output; }
php
public function render_grade_question($questionusage, $slot, $displayoptions, $questionnumber, $heading) { $output = ''; if ($heading) { $output .= $this->heading($heading, 4); } $output .= $questionusage->render_question($slot, $displayoptions, $questionnumber); return $output; }
[ "public", "function", "render_grade_question", "(", "$", "questionusage", ",", "$", "slot", ",", "$", "displayoptions", ",", "$", "questionnumber", ",", "$", "heading", ")", "{", "$", "output", "=", "''", ";", "if", "(", "$", "heading", ")", "{", "$", "output", ".=", "$", "this", "->", "heading", "(", "$", "heading", ",", "4", ")", ";", "}", "$", "output", ".=", "$", "questionusage", "->", "render_question", "(", "$", "slot", ",", "$", "displayoptions", ",", "$", "questionnumber", ")", ";", "return", "$", "output", ";", "}" ]
Render grade question content. @param question_usage_by_activity $questionusage The question usage that need to grade. @param int $slot the number used to identify this question within this usage. @param question_display_options $displayoptions the display options to use. @param int $questionnumber the number of the question to check. @param string $heading the question heading text. @return string The HTML for the question display.
[ "Render", "grade", "question", "content", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/grading/renderer.php#L186-L196
214,444
moodle/moodle
rss/renderer.php
core_rss_renderer.user_reset_rss_token_confirmation
public function user_reset_rss_token_confirmation() { global $OUTPUT, $CFG; $managetokenurl = $CFG->wwwroot."/user/managetoken.php?sesskey=" . sesskey(); $optionsyes = array('action' => 'resetrsstoken', 'confirm' => 1, 'sesskey' => sesskey()); $optionsno = array('section' => 'webservicetokens', 'sesskey' => sesskey()); $formcontinue = new single_button(new moodle_url($managetokenurl, $optionsyes), get_string('reset')); $formcancel = new single_button(new moodle_url($managetokenurl, $optionsno), get_string('cancel'), 'get'); $html = $OUTPUT->confirm(get_string('resettokenconfirmsimple', 'webservice'), $formcontinue, $formcancel); return $html; }
php
public function user_reset_rss_token_confirmation() { global $OUTPUT, $CFG; $managetokenurl = $CFG->wwwroot."/user/managetoken.php?sesskey=" . sesskey(); $optionsyes = array('action' => 'resetrsstoken', 'confirm' => 1, 'sesskey' => sesskey()); $optionsno = array('section' => 'webservicetokens', 'sesskey' => sesskey()); $formcontinue = new single_button(new moodle_url($managetokenurl, $optionsyes), get_string('reset')); $formcancel = new single_button(new moodle_url($managetokenurl, $optionsno), get_string('cancel'), 'get'); $html = $OUTPUT->confirm(get_string('resettokenconfirmsimple', 'webservice'), $formcontinue, $formcancel); return $html; }
[ "public", "function", "user_reset_rss_token_confirmation", "(", ")", "{", "global", "$", "OUTPUT", ",", "$", "CFG", ";", "$", "managetokenurl", "=", "$", "CFG", "->", "wwwroot", ".", "\"/user/managetoken.php?sesskey=\"", ".", "sesskey", "(", ")", ";", "$", "optionsyes", "=", "array", "(", "'action'", "=>", "'resetrsstoken'", ",", "'confirm'", "=>", "1", ",", "'sesskey'", "=>", "sesskey", "(", ")", ")", ";", "$", "optionsno", "=", "array", "(", "'section'", "=>", "'webservicetokens'", ",", "'sesskey'", "=>", "sesskey", "(", ")", ")", ";", "$", "formcontinue", "=", "new", "single_button", "(", "new", "moodle_url", "(", "$", "managetokenurl", ",", "$", "optionsyes", ")", ",", "get_string", "(", "'reset'", ")", ")", ";", "$", "formcancel", "=", "new", "single_button", "(", "new", "moodle_url", "(", "$", "managetokenurl", ",", "$", "optionsno", ")", ",", "get_string", "(", "'cancel'", ")", ",", "'get'", ")", ";", "$", "html", "=", "$", "OUTPUT", "->", "confirm", "(", "get_string", "(", "'resettokenconfirmsimple'", ",", "'webservice'", ")", ",", "$", "formcontinue", ",", "$", "formcancel", ")", ";", "return", "$", "html", ";", "}" ]
Returns the html for the token reset confirmation box @return string html
[ "Returns", "the", "html", "for", "the", "token", "reset", "confirmation", "box" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/rss/renderer.php#L37-L46
214,445
moodle/moodle
rss/renderer.php
core_rss_renderer.user_rss_token_box
public function user_rss_token_box($token) { global $OUTPUT, $CFG; // Display strings. $stroperation = get_string('operation', 'webservice'); $strtoken = get_string('key', 'webservice'); $return = $OUTPUT->heading(get_string('rss', 'rss'), 3, 'main', true); $return .= $OUTPUT->box_start('generalbox webservicestokenui'); $return .= get_string('rsskeyshelp'); $table = new html_table(); $table->head = array($strtoken, $stroperation); $table->align = array('left', 'center'); $table->width = '100%'; $table->data = array(); if (!empty($token)) { $reset = "<a href=\"".$CFG->wwwroot."/user/managetoken.php?sesskey=".sesskey(). "&amp;action=resetrsstoken\">".get_string('reset')."</a>"; $table->data[] = array($token, $reset); $return .= html_writer::table($table); } else { $return .= get_string('notoken', 'webservice'); } $return .= $OUTPUT->box_end(); return $return; }
php
public function user_rss_token_box($token) { global $OUTPUT, $CFG; // Display strings. $stroperation = get_string('operation', 'webservice'); $strtoken = get_string('key', 'webservice'); $return = $OUTPUT->heading(get_string('rss', 'rss'), 3, 'main', true); $return .= $OUTPUT->box_start('generalbox webservicestokenui'); $return .= get_string('rsskeyshelp'); $table = new html_table(); $table->head = array($strtoken, $stroperation); $table->align = array('left', 'center'); $table->width = '100%'; $table->data = array(); if (!empty($token)) { $reset = "<a href=\"".$CFG->wwwroot."/user/managetoken.php?sesskey=".sesskey(). "&amp;action=resetrsstoken\">".get_string('reset')."</a>"; $table->data[] = array($token, $reset); $return .= html_writer::table($table); } else { $return .= get_string('notoken', 'webservice'); } $return .= $OUTPUT->box_end(); return $return; }
[ "public", "function", "user_rss_token_box", "(", "$", "token", ")", "{", "global", "$", "OUTPUT", ",", "$", "CFG", ";", "// Display strings.", "$", "stroperation", "=", "get_string", "(", "'operation'", ",", "'webservice'", ")", ";", "$", "strtoken", "=", "get_string", "(", "'key'", ",", "'webservice'", ")", ";", "$", "return", "=", "$", "OUTPUT", "->", "heading", "(", "get_string", "(", "'rss'", ",", "'rss'", ")", ",", "3", ",", "'main'", ",", "true", ")", ";", "$", "return", ".=", "$", "OUTPUT", "->", "box_start", "(", "'generalbox webservicestokenui'", ")", ";", "$", "return", ".=", "get_string", "(", "'rsskeyshelp'", ")", ";", "$", "table", "=", "new", "html_table", "(", ")", ";", "$", "table", "->", "head", "=", "array", "(", "$", "strtoken", ",", "$", "stroperation", ")", ";", "$", "table", "->", "align", "=", "array", "(", "'left'", ",", "'center'", ")", ";", "$", "table", "->", "width", "=", "'100%'", ";", "$", "table", "->", "data", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "token", ")", ")", "{", "$", "reset", "=", "\"<a href=\\\"\"", ".", "$", "CFG", "->", "wwwroot", ".", "\"/user/managetoken.php?sesskey=\"", ".", "sesskey", "(", ")", ".", "\"&amp;action=resetrsstoken\\\">\"", ".", "get_string", "(", "'reset'", ")", ".", "\"</a>\"", ";", "$", "table", "->", "data", "[", "]", "=", "array", "(", "$", "token", ",", "$", "reset", ")", ";", "$", "return", ".=", "html_writer", "::", "table", "(", "$", "table", ")", ";", "}", "else", "{", "$", "return", ".=", "get_string", "(", "'notoken'", ",", "'webservice'", ")", ";", "}", "$", "return", ".=", "$", "OUTPUT", "->", "box_end", "(", ")", ";", "return", "$", "return", ";", "}" ]
Display a user token with buttons to reset it @param string $token The token to be displayed @return string html code
[ "Display", "a", "user", "token", "with", "buttons", "to", "reset", "it" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/rss/renderer.php#L53-L84
214,446
moodle/moodle
lib/htmlpurifier/HTMLPurifier/DefinitionCache/Serializer.php
HTMLPurifier_DefinitionCache_Serializer.generateFilePath
public function generateFilePath($config) { $key = $this->generateKey($config); return $this->generateDirectoryPath($config) . '/' . $key . '.ser'; }
php
public function generateFilePath($config) { $key = $this->generateKey($config); return $this->generateDirectoryPath($config) . '/' . $key . '.ser'; }
[ "public", "function", "generateFilePath", "(", "$", "config", ")", "{", "$", "key", "=", "$", "this", "->", "generateKey", "(", "$", "config", ")", ";", "return", "$", "this", "->", "generateDirectoryPath", "(", "$", "config", ")", ".", "'/'", ".", "$", "key", ".", "'.ser'", ";", "}" ]
Generates the file path to the serial file corresponding to the configuration and definition name @param HTMLPurifier_Config $config @return string @todo Make protected
[ "Generates", "the", "file", "path", "to", "the", "serial", "file", "corresponding", "to", "the", "configuration", "and", "definition", "name" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/htmlpurifier/HTMLPurifier/DefinitionCache/Serializer.php#L157-L161
214,447
moodle/moodle
lib/htmlpurifier/HTMLPurifier/DefinitionCache/Serializer.php
HTMLPurifier_DefinitionCache_Serializer.generateBaseDirectoryPath
public function generateBaseDirectoryPath($config) { $base = $config->get('Cache.SerializerPath'); $base = is_null($base) ? HTMLPURIFIER_PREFIX . '/HTMLPurifier/DefinitionCache/Serializer' : $base; return $base; }
php
public function generateBaseDirectoryPath($config) { $base = $config->get('Cache.SerializerPath'); $base = is_null($base) ? HTMLPURIFIER_PREFIX . '/HTMLPurifier/DefinitionCache/Serializer' : $base; return $base; }
[ "public", "function", "generateBaseDirectoryPath", "(", "$", "config", ")", "{", "$", "base", "=", "$", "config", "->", "get", "(", "'Cache.SerializerPath'", ")", ";", "$", "base", "=", "is_null", "(", "$", "base", ")", "?", "HTMLPURIFIER_PREFIX", ".", "'/HTMLPurifier/DefinitionCache/Serializer'", ":", "$", "base", ";", "return", "$", "base", ";", "}" ]
Generates path to base directory that contains all definition type serials @param HTMLPurifier_Config $config @return mixed|string @todo Make protected
[ "Generates", "path", "to", "base", "directory", "that", "contains", "all", "definition", "type", "serials" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/htmlpurifier/HTMLPurifier/DefinitionCache/Serializer.php#L183-L188
214,448
moodle/moodle
lib/htmlpurifier/HTMLPurifier/DefinitionCache/Serializer.php
HTMLPurifier_DefinitionCache_Serializer._write
private function _write($file, $data, $config) { $result = file_put_contents($file, $data); if ($result !== false) { // set permissions of the new file (no execute) $chmod = $config->get('Cache.SerializerPermissions'); if ($chmod !== null) { chmod($file, $chmod & 0666); } } return $result; }
php
private function _write($file, $data, $config) { $result = file_put_contents($file, $data); if ($result !== false) { // set permissions of the new file (no execute) $chmod = $config->get('Cache.SerializerPermissions'); if ($chmod !== null) { chmod($file, $chmod & 0666); } } return $result; }
[ "private", "function", "_write", "(", "$", "file", ",", "$", "data", ",", "$", "config", ")", "{", "$", "result", "=", "file_put_contents", "(", "$", "file", ",", "$", "data", ")", ";", "if", "(", "$", "result", "!==", "false", ")", "{", "// set permissions of the new file (no execute)", "$", "chmod", "=", "$", "config", "->", "get", "(", "'Cache.SerializerPermissions'", ")", ";", "if", "(", "$", "chmod", "!==", "null", ")", "{", "chmod", "(", "$", "file", ",", "$", "chmod", "&", "0666", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Convenience wrapper function for file_put_contents @param string $file File name to write to @param string $data Data to write into file @param HTMLPurifier_Config $config @return int|bool Number of bytes written if success, or false if failure.
[ "Convenience", "wrapper", "function", "for", "file_put_contents" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/htmlpurifier/HTMLPurifier/DefinitionCache/Serializer.php#L197-L208
214,449
moodle/moodle
mod/assign/submission/onlinetext/locallib.php
assign_submission_onlinetext.remove
public function remove(stdClass $submission) { global $DB; $submissionid = $submission ? $submission->id : 0; if ($submissionid) { $DB->delete_records('assignsubmission_onlinetext', array('submission' => $submissionid)); } return true; }
php
public function remove(stdClass $submission) { global $DB; $submissionid = $submission ? $submission->id : 0; if ($submissionid) { $DB->delete_records('assignsubmission_onlinetext', array('submission' => $submissionid)); } return true; }
[ "public", "function", "remove", "(", "stdClass", "$", "submission", ")", "{", "global", "$", "DB", ";", "$", "submissionid", "=", "$", "submission", "?", "$", "submission", "->", "id", ":", "0", ";", "if", "(", "$", "submissionid", ")", "{", "$", "DB", "->", "delete_records", "(", "'assignsubmission_onlinetext'", ",", "array", "(", "'submission'", "=>", "$", "submissionid", ")", ")", ";", "}", "return", "true", ";", "}" ]
Remove a submission. @param stdClass $submission The submission @return boolean
[ "Remove", "a", "submission", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/submission/onlinetext/locallib.php#L67-L75
214,450
moodle/moodle
mod/assign/submission/onlinetext/locallib.php
assign_submission_onlinetext.get_settings
public function get_settings(MoodleQuickForm $mform) { global $CFG, $COURSE; $defaultwordlimit = $this->get_config('wordlimit') == 0 ? '' : $this->get_config('wordlimit'); $defaultwordlimitenabled = $this->get_config('wordlimitenabled'); $options = array('size' => '6', 'maxlength' => '6'); $name = get_string('wordlimit', 'assignsubmission_onlinetext'); // Create a text box that can be enabled/disabled for onlinetext word limit. $wordlimitgrp = array(); $wordlimitgrp[] = $mform->createElement('text', 'assignsubmission_onlinetext_wordlimit', '', $options); $wordlimitgrp[] = $mform->createElement('checkbox', 'assignsubmission_onlinetext_wordlimit_enabled', '', get_string('enable')); $mform->addGroup($wordlimitgrp, 'assignsubmission_onlinetext_wordlimit_group', $name, ' ', false); $mform->addHelpButton('assignsubmission_onlinetext_wordlimit_group', 'wordlimit', 'assignsubmission_onlinetext'); $mform->disabledIf('assignsubmission_onlinetext_wordlimit', 'assignsubmission_onlinetext_wordlimit_enabled', 'notchecked'); $mform->hideIf('assignsubmission_onlinetext_wordlimit', 'assignsubmission_onlinetext_enabled', 'notchecked'); // Add numeric rule to text field. $wordlimitgrprules = array(); $wordlimitgrprules['assignsubmission_onlinetext_wordlimit'][] = array(null, 'numeric', null, 'client'); $mform->addGroupRule('assignsubmission_onlinetext_wordlimit_group', $wordlimitgrprules); // Rest of group setup. $mform->setDefault('assignsubmission_onlinetext_wordlimit', $defaultwordlimit); $mform->setDefault('assignsubmission_onlinetext_wordlimit_enabled', $defaultwordlimitenabled); $mform->setType('assignsubmission_onlinetext_wordlimit', PARAM_INT); $mform->hideIf('assignsubmission_onlinetext_wordlimit_group', 'assignsubmission_onlinetext_enabled', 'notchecked'); }
php
public function get_settings(MoodleQuickForm $mform) { global $CFG, $COURSE; $defaultwordlimit = $this->get_config('wordlimit') == 0 ? '' : $this->get_config('wordlimit'); $defaultwordlimitenabled = $this->get_config('wordlimitenabled'); $options = array('size' => '6', 'maxlength' => '6'); $name = get_string('wordlimit', 'assignsubmission_onlinetext'); // Create a text box that can be enabled/disabled for onlinetext word limit. $wordlimitgrp = array(); $wordlimitgrp[] = $mform->createElement('text', 'assignsubmission_onlinetext_wordlimit', '', $options); $wordlimitgrp[] = $mform->createElement('checkbox', 'assignsubmission_onlinetext_wordlimit_enabled', '', get_string('enable')); $mform->addGroup($wordlimitgrp, 'assignsubmission_onlinetext_wordlimit_group', $name, ' ', false); $mform->addHelpButton('assignsubmission_onlinetext_wordlimit_group', 'wordlimit', 'assignsubmission_onlinetext'); $mform->disabledIf('assignsubmission_onlinetext_wordlimit', 'assignsubmission_onlinetext_wordlimit_enabled', 'notchecked'); $mform->hideIf('assignsubmission_onlinetext_wordlimit', 'assignsubmission_onlinetext_enabled', 'notchecked'); // Add numeric rule to text field. $wordlimitgrprules = array(); $wordlimitgrprules['assignsubmission_onlinetext_wordlimit'][] = array(null, 'numeric', null, 'client'); $mform->addGroupRule('assignsubmission_onlinetext_wordlimit_group', $wordlimitgrprules); // Rest of group setup. $mform->setDefault('assignsubmission_onlinetext_wordlimit', $defaultwordlimit); $mform->setDefault('assignsubmission_onlinetext_wordlimit_enabled', $defaultwordlimitenabled); $mform->setType('assignsubmission_onlinetext_wordlimit', PARAM_INT); $mform->hideIf('assignsubmission_onlinetext_wordlimit_group', 'assignsubmission_onlinetext_enabled', 'notchecked'); }
[ "public", "function", "get_settings", "(", "MoodleQuickForm", "$", "mform", ")", "{", "global", "$", "CFG", ",", "$", "COURSE", ";", "$", "defaultwordlimit", "=", "$", "this", "->", "get_config", "(", "'wordlimit'", ")", "==", "0", "?", "''", ":", "$", "this", "->", "get_config", "(", "'wordlimit'", ")", ";", "$", "defaultwordlimitenabled", "=", "$", "this", "->", "get_config", "(", "'wordlimitenabled'", ")", ";", "$", "options", "=", "array", "(", "'size'", "=>", "'6'", ",", "'maxlength'", "=>", "'6'", ")", ";", "$", "name", "=", "get_string", "(", "'wordlimit'", ",", "'assignsubmission_onlinetext'", ")", ";", "// Create a text box that can be enabled/disabled for onlinetext word limit.", "$", "wordlimitgrp", "=", "array", "(", ")", ";", "$", "wordlimitgrp", "[", "]", "=", "$", "mform", "->", "createElement", "(", "'text'", ",", "'assignsubmission_onlinetext_wordlimit'", ",", "''", ",", "$", "options", ")", ";", "$", "wordlimitgrp", "[", "]", "=", "$", "mform", "->", "createElement", "(", "'checkbox'", ",", "'assignsubmission_onlinetext_wordlimit_enabled'", ",", "''", ",", "get_string", "(", "'enable'", ")", ")", ";", "$", "mform", "->", "addGroup", "(", "$", "wordlimitgrp", ",", "'assignsubmission_onlinetext_wordlimit_group'", ",", "$", "name", ",", "' '", ",", "false", ")", ";", "$", "mform", "->", "addHelpButton", "(", "'assignsubmission_onlinetext_wordlimit_group'", ",", "'wordlimit'", ",", "'assignsubmission_onlinetext'", ")", ";", "$", "mform", "->", "disabledIf", "(", "'assignsubmission_onlinetext_wordlimit'", ",", "'assignsubmission_onlinetext_wordlimit_enabled'", ",", "'notchecked'", ")", ";", "$", "mform", "->", "hideIf", "(", "'assignsubmission_onlinetext_wordlimit'", ",", "'assignsubmission_onlinetext_enabled'", ",", "'notchecked'", ")", ";", "// Add numeric rule to text field.", "$", "wordlimitgrprules", "=", "array", "(", ")", ";", "$", "wordlimitgrprules", "[", "'assignsubmission_onlinetext_wordlimit'", "]", "[", "]", "=", "array", "(", "null", ",", "'numeric'", ",", "null", ",", "'client'", ")", ";", "$", "mform", "->", "addGroupRule", "(", "'assignsubmission_onlinetext_wordlimit_group'", ",", "$", "wordlimitgrprules", ")", ";", "// Rest of group setup.", "$", "mform", "->", "setDefault", "(", "'assignsubmission_onlinetext_wordlimit'", ",", "$", "defaultwordlimit", ")", ";", "$", "mform", "->", "setDefault", "(", "'assignsubmission_onlinetext_wordlimit_enabled'", ",", "$", "defaultwordlimitenabled", ")", ";", "$", "mform", "->", "setType", "(", "'assignsubmission_onlinetext_wordlimit'", ",", "PARAM_INT", ")", ";", "$", "mform", "->", "hideIf", "(", "'assignsubmission_onlinetext_wordlimit_group'", ",", "'assignsubmission_onlinetext_enabled'", ",", "'notchecked'", ")", ";", "}" ]
Get the settings for onlinetext submission plugin @param MoodleQuickForm $mform The form to add elements to @return void
[ "Get", "the", "settings", "for", "onlinetext", "submission", "plugin" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/submission/onlinetext/locallib.php#L83-L120
214,451
moodle/moodle
mod/assign/submission/onlinetext/locallib.php
assign_submission_onlinetext.save_settings
public function save_settings(stdClass $data) { if (empty($data->assignsubmission_onlinetext_wordlimit) || empty($data->assignsubmission_onlinetext_wordlimit_enabled)) { $wordlimit = 0; $wordlimitenabled = 0; } else { $wordlimit = $data->assignsubmission_onlinetext_wordlimit; $wordlimitenabled = 1; } $this->set_config('wordlimit', $wordlimit); $this->set_config('wordlimitenabled', $wordlimitenabled); return true; }
php
public function save_settings(stdClass $data) { if (empty($data->assignsubmission_onlinetext_wordlimit) || empty($data->assignsubmission_onlinetext_wordlimit_enabled)) { $wordlimit = 0; $wordlimitenabled = 0; } else { $wordlimit = $data->assignsubmission_onlinetext_wordlimit; $wordlimitenabled = 1; } $this->set_config('wordlimit', $wordlimit); $this->set_config('wordlimitenabled', $wordlimitenabled); return true; }
[ "public", "function", "save_settings", "(", "stdClass", "$", "data", ")", "{", "if", "(", "empty", "(", "$", "data", "->", "assignsubmission_onlinetext_wordlimit", ")", "||", "empty", "(", "$", "data", "->", "assignsubmission_onlinetext_wordlimit_enabled", ")", ")", "{", "$", "wordlimit", "=", "0", ";", "$", "wordlimitenabled", "=", "0", ";", "}", "else", "{", "$", "wordlimit", "=", "$", "data", "->", "assignsubmission_onlinetext_wordlimit", ";", "$", "wordlimitenabled", "=", "1", ";", "}", "$", "this", "->", "set_config", "(", "'wordlimit'", ",", "$", "wordlimit", ")", ";", "$", "this", "->", "set_config", "(", "'wordlimitenabled'", ",", "$", "wordlimitenabled", ")", ";", "return", "true", ";", "}" ]
Save the settings for onlinetext submission plugin @param stdClass $data @return bool
[ "Save", "the", "settings", "for", "onlinetext", "submission", "plugin" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/submission/onlinetext/locallib.php#L128-L141
214,452
moodle/moodle
mod/assign/submission/onlinetext/locallib.php
assign_submission_onlinetext.get_form_elements
public function get_form_elements($submission, MoodleQuickForm $mform, stdClass $data) { $elements = array(); $editoroptions = $this->get_edit_options(); $submissionid = $submission ? $submission->id : 0; if (!isset($data->onlinetext)) { $data->onlinetext = ''; } if (!isset($data->onlinetextformat)) { $data->onlinetextformat = editors_get_preferred_format(); } if ($submission) { $onlinetextsubmission = $this->get_onlinetext_submission($submission->id); if ($onlinetextsubmission) { $data->onlinetext = $onlinetextsubmission->onlinetext; $data->onlinetextformat = $onlinetextsubmission->onlineformat; } } $data = file_prepare_standard_editor($data, 'onlinetext', $editoroptions, $this->assignment->get_context(), 'assignsubmission_onlinetext', ASSIGNSUBMISSION_ONLINETEXT_FILEAREA, $submissionid); $mform->addElement('editor', 'onlinetext_editor', $this->get_name(), null, $editoroptions); return true; }
php
public function get_form_elements($submission, MoodleQuickForm $mform, stdClass $data) { $elements = array(); $editoroptions = $this->get_edit_options(); $submissionid = $submission ? $submission->id : 0; if (!isset($data->onlinetext)) { $data->onlinetext = ''; } if (!isset($data->onlinetextformat)) { $data->onlinetextformat = editors_get_preferred_format(); } if ($submission) { $onlinetextsubmission = $this->get_onlinetext_submission($submission->id); if ($onlinetextsubmission) { $data->onlinetext = $onlinetextsubmission->onlinetext; $data->onlinetextformat = $onlinetextsubmission->onlineformat; } } $data = file_prepare_standard_editor($data, 'onlinetext', $editoroptions, $this->assignment->get_context(), 'assignsubmission_onlinetext', ASSIGNSUBMISSION_ONLINETEXT_FILEAREA, $submissionid); $mform->addElement('editor', 'onlinetext_editor', $this->get_name(), null, $editoroptions); return true; }
[ "public", "function", "get_form_elements", "(", "$", "submission", ",", "MoodleQuickForm", "$", "mform", ",", "stdClass", "$", "data", ")", "{", "$", "elements", "=", "array", "(", ")", ";", "$", "editoroptions", "=", "$", "this", "->", "get_edit_options", "(", ")", ";", "$", "submissionid", "=", "$", "submission", "?", "$", "submission", "->", "id", ":", "0", ";", "if", "(", "!", "isset", "(", "$", "data", "->", "onlinetext", ")", ")", "{", "$", "data", "->", "onlinetext", "=", "''", ";", "}", "if", "(", "!", "isset", "(", "$", "data", "->", "onlinetextformat", ")", ")", "{", "$", "data", "->", "onlinetextformat", "=", "editors_get_preferred_format", "(", ")", ";", "}", "if", "(", "$", "submission", ")", "{", "$", "onlinetextsubmission", "=", "$", "this", "->", "get_onlinetext_submission", "(", "$", "submission", "->", "id", ")", ";", "if", "(", "$", "onlinetextsubmission", ")", "{", "$", "data", "->", "onlinetext", "=", "$", "onlinetextsubmission", "->", "onlinetext", ";", "$", "data", "->", "onlinetextformat", "=", "$", "onlinetextsubmission", "->", "onlineformat", ";", "}", "}", "$", "data", "=", "file_prepare_standard_editor", "(", "$", "data", ",", "'onlinetext'", ",", "$", "editoroptions", ",", "$", "this", "->", "assignment", "->", "get_context", "(", ")", ",", "'assignsubmission_onlinetext'", ",", "ASSIGNSUBMISSION_ONLINETEXT_FILEAREA", ",", "$", "submissionid", ")", ";", "$", "mform", "->", "addElement", "(", "'editor'", ",", "'onlinetext_editor'", ",", "$", "this", "->", "get_name", "(", ")", ",", "null", ",", "$", "editoroptions", ")", ";", "return", "true", ";", "}" ]
Add form elements for settings @param mixed $submission can be null @param MoodleQuickForm $mform @param stdClass $data @return true if elements were added to the form
[ "Add", "form", "elements", "for", "settings" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/submission/onlinetext/locallib.php#L151-L183
214,453
moodle/moodle
mod/assign/submission/onlinetext/locallib.php
assign_submission_onlinetext.get_edit_options
private function get_edit_options() { $editoroptions = array( 'noclean' => false, 'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $this->assignment->get_course()->maxbytes, 'context' => $this->assignment->get_context(), 'return_types' => (FILE_INTERNAL | FILE_EXTERNAL | FILE_CONTROLLED_LINK), 'removeorphaneddrafts' => true // Whether or not to remove any draft files which aren't referenced in the text. ); return $editoroptions; }
php
private function get_edit_options() { $editoroptions = array( 'noclean' => false, 'maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $this->assignment->get_course()->maxbytes, 'context' => $this->assignment->get_context(), 'return_types' => (FILE_INTERNAL | FILE_EXTERNAL | FILE_CONTROLLED_LINK), 'removeorphaneddrafts' => true // Whether or not to remove any draft files which aren't referenced in the text. ); return $editoroptions; }
[ "private", "function", "get_edit_options", "(", ")", "{", "$", "editoroptions", "=", "array", "(", "'noclean'", "=>", "false", ",", "'maxfiles'", "=>", "EDITOR_UNLIMITED_FILES", ",", "'maxbytes'", "=>", "$", "this", "->", "assignment", "->", "get_course", "(", ")", "->", "maxbytes", ",", "'context'", "=>", "$", "this", "->", "assignment", "->", "get_context", "(", ")", ",", "'return_types'", "=>", "(", "FILE_INTERNAL", "|", "FILE_EXTERNAL", "|", "FILE_CONTROLLED_LINK", ")", ",", "'removeorphaneddrafts'", "=>", "true", "// Whether or not to remove any draft files which aren't referenced in the text.", ")", ";", "return", "$", "editoroptions", ";", "}" ]
Editor format options @return array
[ "Editor", "format", "options" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/submission/onlinetext/locallib.php#L190-L200
214,454
moodle/moodle
mod/assign/submission/onlinetext/locallib.php
assign_submission_onlinetext.get_editor_text
public function get_editor_text($name, $submissionid) { if ($name == 'onlinetext') { $onlinetextsubmission = $this->get_onlinetext_submission($submissionid); if ($onlinetextsubmission) { return $onlinetextsubmission->onlinetext; } } return ''; }
php
public function get_editor_text($name, $submissionid) { if ($name == 'onlinetext') { $onlinetextsubmission = $this->get_onlinetext_submission($submissionid); if ($onlinetextsubmission) { return $onlinetextsubmission->onlinetext; } } return ''; }
[ "public", "function", "get_editor_text", "(", "$", "name", ",", "$", "submissionid", ")", "{", "if", "(", "$", "name", "==", "'onlinetext'", ")", "{", "$", "onlinetextsubmission", "=", "$", "this", "->", "get_onlinetext_submission", "(", "$", "submissionid", ")", ";", "if", "(", "$", "onlinetextsubmission", ")", "{", "return", "$", "onlinetextsubmission", "->", "onlinetext", ";", "}", "}", "return", "''", ";", "}" ]
Get the saved text content from the editor @param string $name @param int $submissionid @return string
[ "Get", "the", "saved", "text", "content", "from", "the", "editor" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/submission/onlinetext/locallib.php#L327-L336
214,455
moodle/moodle
mod/assign/submission/onlinetext/locallib.php
assign_submission_onlinetext.get_editor_format
public function get_editor_format($name, $submissionid) { if ($name == 'onlinetext') { $onlinetextsubmission = $this->get_onlinetext_submission($submissionid); if ($onlinetextsubmission) { return $onlinetextsubmission->onlineformat; } } return 0; }
php
public function get_editor_format($name, $submissionid) { if ($name == 'onlinetext') { $onlinetextsubmission = $this->get_onlinetext_submission($submissionid); if ($onlinetextsubmission) { return $onlinetextsubmission->onlineformat; } } return 0; }
[ "public", "function", "get_editor_format", "(", "$", "name", ",", "$", "submissionid", ")", "{", "if", "(", "$", "name", "==", "'onlinetext'", ")", "{", "$", "onlinetextsubmission", "=", "$", "this", "->", "get_onlinetext_submission", "(", "$", "submissionid", ")", ";", "if", "(", "$", "onlinetextsubmission", ")", "{", "return", "$", "onlinetextsubmission", "->", "onlineformat", ";", "}", "}", "return", "0", ";", "}" ]
Get the content format for the editor @param string $name @param int $submissionid @return int
[ "Get", "the", "content", "format", "for", "the", "editor" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/submission/onlinetext/locallib.php#L345-L354
214,456
moodle/moodle
mod/assign/submission/onlinetext/locallib.php
assign_submission_onlinetext.view_summary
public function view_summary(stdClass $submission, & $showviewlink) { global $CFG; $onlinetextsubmission = $this->get_onlinetext_submission($submission->id); // Always show the view link. $showviewlink = true; if ($onlinetextsubmission) { // This contains the shortened version of the text plus an optional 'Export to portfolio' button. $text = $this->assignment->render_editor_content(ASSIGNSUBMISSION_ONLINETEXT_FILEAREA, $onlinetextsubmission->submission, $this->get_type(), 'onlinetext', 'assignsubmission_onlinetext', true); // The actual submission text. $onlinetext = trim($onlinetextsubmission->onlinetext); // The shortened version of the submission text. $shorttext = shorten_text($onlinetext, 140); $plagiarismlinks = ''; if (!empty($CFG->enableplagiarism)) { require_once($CFG->libdir . '/plagiarismlib.php'); $plagiarismlinks .= plagiarism_get_links(array('userid' => $submission->userid, 'content' => $onlinetext, 'cmid' => $this->assignment->get_course_module()->id, 'course' => $this->assignment->get_course()->id, 'assignment' => $submission->assignment)); } // We compare the actual text submission and the shortened version. If they are not equal, we show the word count. if ($onlinetext != $shorttext) { $wordcount = get_string('numwords', 'assignsubmission_onlinetext', count_words($onlinetext)); return $plagiarismlinks . $wordcount . $text; } else { return $plagiarismlinks . $text; } } return ''; }
php
public function view_summary(stdClass $submission, & $showviewlink) { global $CFG; $onlinetextsubmission = $this->get_onlinetext_submission($submission->id); // Always show the view link. $showviewlink = true; if ($onlinetextsubmission) { // This contains the shortened version of the text plus an optional 'Export to portfolio' button. $text = $this->assignment->render_editor_content(ASSIGNSUBMISSION_ONLINETEXT_FILEAREA, $onlinetextsubmission->submission, $this->get_type(), 'onlinetext', 'assignsubmission_onlinetext', true); // The actual submission text. $onlinetext = trim($onlinetextsubmission->onlinetext); // The shortened version of the submission text. $shorttext = shorten_text($onlinetext, 140); $plagiarismlinks = ''; if (!empty($CFG->enableplagiarism)) { require_once($CFG->libdir . '/plagiarismlib.php'); $plagiarismlinks .= plagiarism_get_links(array('userid' => $submission->userid, 'content' => $onlinetext, 'cmid' => $this->assignment->get_course_module()->id, 'course' => $this->assignment->get_course()->id, 'assignment' => $submission->assignment)); } // We compare the actual text submission and the shortened version. If they are not equal, we show the word count. if ($onlinetext != $shorttext) { $wordcount = get_string('numwords', 'assignsubmission_onlinetext', count_words($onlinetext)); return $plagiarismlinks . $wordcount . $text; } else { return $plagiarismlinks . $text; } } return ''; }
[ "public", "function", "view_summary", "(", "stdClass", "$", "submission", ",", "&", "$", "showviewlink", ")", "{", "global", "$", "CFG", ";", "$", "onlinetextsubmission", "=", "$", "this", "->", "get_onlinetext_submission", "(", "$", "submission", "->", "id", ")", ";", "// Always show the view link.", "$", "showviewlink", "=", "true", ";", "if", "(", "$", "onlinetextsubmission", ")", "{", "// This contains the shortened version of the text plus an optional 'Export to portfolio' button.", "$", "text", "=", "$", "this", "->", "assignment", "->", "render_editor_content", "(", "ASSIGNSUBMISSION_ONLINETEXT_FILEAREA", ",", "$", "onlinetextsubmission", "->", "submission", ",", "$", "this", "->", "get_type", "(", ")", ",", "'onlinetext'", ",", "'assignsubmission_onlinetext'", ",", "true", ")", ";", "// The actual submission text.", "$", "onlinetext", "=", "trim", "(", "$", "onlinetextsubmission", "->", "onlinetext", ")", ";", "// The shortened version of the submission text.", "$", "shorttext", "=", "shorten_text", "(", "$", "onlinetext", ",", "140", ")", ";", "$", "plagiarismlinks", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "CFG", "->", "enableplagiarism", ")", ")", "{", "require_once", "(", "$", "CFG", "->", "libdir", ".", "'/plagiarismlib.php'", ")", ";", "$", "plagiarismlinks", ".=", "plagiarism_get_links", "(", "array", "(", "'userid'", "=>", "$", "submission", "->", "userid", ",", "'content'", "=>", "$", "onlinetext", ",", "'cmid'", "=>", "$", "this", "->", "assignment", "->", "get_course_module", "(", ")", "->", "id", ",", "'course'", "=>", "$", "this", "->", "assignment", "->", "get_course", "(", ")", "->", "id", ",", "'assignment'", "=>", "$", "submission", "->", "assignment", ")", ")", ";", "}", "// We compare the actual text submission and the shortened version. If they are not equal, we show the word count.", "if", "(", "$", "onlinetext", "!=", "$", "shorttext", ")", "{", "$", "wordcount", "=", "get_string", "(", "'numwords'", ",", "'assignsubmission_onlinetext'", ",", "count_words", "(", "$", "onlinetext", ")", ")", ";", "return", "$", "plagiarismlinks", ".", "$", "wordcount", ".", "$", "text", ";", "}", "else", "{", "return", "$", "plagiarismlinks", ".", "$", "text", ";", "}", "}", "return", "''", ";", "}" ]
Display onlinetext word count in the submission status table @param stdClass $submission @param bool $showviewlink - If the summary has been truncated set this to true @return string
[ "Display", "onlinetext", "word", "count", "in", "the", "submission", "status", "table" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/submission/onlinetext/locallib.php#L364-L405
214,457
moodle/moodle
mod/assign/submission/onlinetext/locallib.php
assign_submission_onlinetext.get_files
public function get_files(stdClass $submission, stdClass $user) { global $DB; $files = array(); $onlinetextsubmission = $this->get_onlinetext_submission($submission->id); // Note that this check is the same logic as the result from the is_empty function but we do // not call it directly because we already have the submission record. if ($onlinetextsubmission) { // Do not pass the text through format_text. The result may not be displayed in Moodle and // may be passed to external services such as document conversion or portfolios. $formattedtext = $this->assignment->download_rewrite_pluginfile_urls($onlinetextsubmission->onlinetext, $user, $this); $head = '<head><meta charset="UTF-8"></head>'; $submissioncontent = '<!DOCTYPE html><html>' . $head . '<body>'. $formattedtext . '</body></html>'; $filename = get_string('onlinetextfilename', 'assignsubmission_onlinetext'); $files[$filename] = array($submissioncontent); $fs = get_file_storage(); $fsfiles = $fs->get_area_files($this->assignment->get_context()->id, 'assignsubmission_onlinetext', ASSIGNSUBMISSION_ONLINETEXT_FILEAREA, $submission->id, 'timemodified', false); foreach ($fsfiles as $file) { $files[$file->get_filename()] = $file; } } return $files; }
php
public function get_files(stdClass $submission, stdClass $user) { global $DB; $files = array(); $onlinetextsubmission = $this->get_onlinetext_submission($submission->id); // Note that this check is the same logic as the result from the is_empty function but we do // not call it directly because we already have the submission record. if ($onlinetextsubmission) { // Do not pass the text through format_text. The result may not be displayed in Moodle and // may be passed to external services such as document conversion or portfolios. $formattedtext = $this->assignment->download_rewrite_pluginfile_urls($onlinetextsubmission->onlinetext, $user, $this); $head = '<head><meta charset="UTF-8"></head>'; $submissioncontent = '<!DOCTYPE html><html>' . $head . '<body>'. $formattedtext . '</body></html>'; $filename = get_string('onlinetextfilename', 'assignsubmission_onlinetext'); $files[$filename] = array($submissioncontent); $fs = get_file_storage(); $fsfiles = $fs->get_area_files($this->assignment->get_context()->id, 'assignsubmission_onlinetext', ASSIGNSUBMISSION_ONLINETEXT_FILEAREA, $submission->id, 'timemodified', false); foreach ($fsfiles as $file) { $files[$file->get_filename()] = $file; } } return $files; }
[ "public", "function", "get_files", "(", "stdClass", "$", "submission", ",", "stdClass", "$", "user", ")", "{", "global", "$", "DB", ";", "$", "files", "=", "array", "(", ")", ";", "$", "onlinetextsubmission", "=", "$", "this", "->", "get_onlinetext_submission", "(", "$", "submission", "->", "id", ")", ";", "// Note that this check is the same logic as the result from the is_empty function but we do", "// not call it directly because we already have the submission record.", "if", "(", "$", "onlinetextsubmission", ")", "{", "// Do not pass the text through format_text. The result may not be displayed in Moodle and", "// may be passed to external services such as document conversion or portfolios.", "$", "formattedtext", "=", "$", "this", "->", "assignment", "->", "download_rewrite_pluginfile_urls", "(", "$", "onlinetextsubmission", "->", "onlinetext", ",", "$", "user", ",", "$", "this", ")", ";", "$", "head", "=", "'<head><meta charset=\"UTF-8\"></head>'", ";", "$", "submissioncontent", "=", "'<!DOCTYPE html><html>'", ".", "$", "head", ".", "'<body>'", ".", "$", "formattedtext", ".", "'</body></html>'", ";", "$", "filename", "=", "get_string", "(", "'onlinetextfilename'", ",", "'assignsubmission_onlinetext'", ")", ";", "$", "files", "[", "$", "filename", "]", "=", "array", "(", "$", "submissioncontent", ")", ";", "$", "fs", "=", "get_file_storage", "(", ")", ";", "$", "fsfiles", "=", "$", "fs", "->", "get_area_files", "(", "$", "this", "->", "assignment", "->", "get_context", "(", ")", "->", "id", ",", "'assignsubmission_onlinetext'", ",", "ASSIGNSUBMISSION_ONLINETEXT_FILEAREA", ",", "$", "submission", "->", "id", ",", "'timemodified'", ",", "false", ")", ";", "foreach", "(", "$", "fsfiles", "as", "$", "file", ")", "{", "$", "files", "[", "$", "file", "->", "get_filename", "(", ")", "]", "=", "$", "file", ";", "}", "}", "return", "$", "files", ";", "}" ]
Produce a list of files suitable for export that represent this submission. @param stdClass $submission - For this is the submission data @param stdClass $user - This is the user record for this submission @return array - return an array of files indexed by filename
[ "Produce", "a", "list", "of", "files", "suitable", "for", "export", "that", "represent", "this", "submission", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/submission/onlinetext/locallib.php#L414-L447
214,458
moodle/moodle
mod/assign/submission/onlinetext/locallib.php
assign_submission_onlinetext.view
public function view(stdClass $submission) { global $CFG; $result = ''; $onlinetextsubmission = $this->get_onlinetext_submission($submission->id); if ($onlinetextsubmission) { // Render for portfolio API. $result .= $this->assignment->render_editor_content(ASSIGNSUBMISSION_ONLINETEXT_FILEAREA, $onlinetextsubmission->submission, $this->get_type(), 'onlinetext', 'assignsubmission_onlinetext'); $plagiarismlinks = ''; if (!empty($CFG->enableplagiarism)) { require_once($CFG->libdir . '/plagiarismlib.php'); $plagiarismlinks .= plagiarism_get_links(array('userid' => $submission->userid, 'content' => trim($onlinetextsubmission->onlinetext), 'cmid' => $this->assignment->get_course_module()->id, 'course' => $this->assignment->get_course()->id, 'assignment' => $submission->assignment)); } } return $plagiarismlinks . $result; }
php
public function view(stdClass $submission) { global $CFG; $result = ''; $onlinetextsubmission = $this->get_onlinetext_submission($submission->id); if ($onlinetextsubmission) { // Render for portfolio API. $result .= $this->assignment->render_editor_content(ASSIGNSUBMISSION_ONLINETEXT_FILEAREA, $onlinetextsubmission->submission, $this->get_type(), 'onlinetext', 'assignsubmission_onlinetext'); $plagiarismlinks = ''; if (!empty($CFG->enableplagiarism)) { require_once($CFG->libdir . '/plagiarismlib.php'); $plagiarismlinks .= plagiarism_get_links(array('userid' => $submission->userid, 'content' => trim($onlinetextsubmission->onlinetext), 'cmid' => $this->assignment->get_course_module()->id, 'course' => $this->assignment->get_course()->id, 'assignment' => $submission->assignment)); } } return $plagiarismlinks . $result; }
[ "public", "function", "view", "(", "stdClass", "$", "submission", ")", "{", "global", "$", "CFG", ";", "$", "result", "=", "''", ";", "$", "onlinetextsubmission", "=", "$", "this", "->", "get_onlinetext_submission", "(", "$", "submission", "->", "id", ")", ";", "if", "(", "$", "onlinetextsubmission", ")", "{", "// Render for portfolio API.", "$", "result", ".=", "$", "this", "->", "assignment", "->", "render_editor_content", "(", "ASSIGNSUBMISSION_ONLINETEXT_FILEAREA", ",", "$", "onlinetextsubmission", "->", "submission", ",", "$", "this", "->", "get_type", "(", ")", ",", "'onlinetext'", ",", "'assignsubmission_onlinetext'", ")", ";", "$", "plagiarismlinks", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "CFG", "->", "enableplagiarism", ")", ")", "{", "require_once", "(", "$", "CFG", "->", "libdir", ".", "'/plagiarismlib.php'", ")", ";", "$", "plagiarismlinks", ".=", "plagiarism_get_links", "(", "array", "(", "'userid'", "=>", "$", "submission", "->", "userid", ",", "'content'", "=>", "trim", "(", "$", "onlinetextsubmission", "->", "onlinetext", ")", ",", "'cmid'", "=>", "$", "this", "->", "assignment", "->", "get_course_module", "(", ")", "->", "id", ",", "'course'", "=>", "$", "this", "->", "assignment", "->", "get_course", "(", ")", "->", "id", ",", "'assignment'", "=>", "$", "submission", "->", "assignment", ")", ")", ";", "}", "}", "return", "$", "plagiarismlinks", ".", "$", "result", ";", "}" ]
Display the saved text content from the editor in the view table @param stdClass $submission @return string
[ "Display", "the", "saved", "text", "content", "from", "the", "editor", "in", "the", "view", "table" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/submission/onlinetext/locallib.php#L455-L484
214,459
moodle/moodle
mod/assign/submission/onlinetext/locallib.php
assign_submission_onlinetext.is_empty
public function is_empty(stdClass $submission) { $onlinetextsubmission = $this->get_onlinetext_submission($submission->id); $wordcount = 0; if (isset($onlinetextsubmission->onlinetext)) { $wordcount = count_words(trim($onlinetextsubmission->onlinetext)); } return $wordcount == 0; }
php
public function is_empty(stdClass $submission) { $onlinetextsubmission = $this->get_onlinetext_submission($submission->id); $wordcount = 0; if (isset($onlinetextsubmission->onlinetext)) { $wordcount = count_words(trim($onlinetextsubmission->onlinetext)); } return $wordcount == 0; }
[ "public", "function", "is_empty", "(", "stdClass", "$", "submission", ")", "{", "$", "onlinetextsubmission", "=", "$", "this", "->", "get_onlinetext_submission", "(", "$", "submission", "->", "id", ")", ";", "$", "wordcount", "=", "0", ";", "if", "(", "isset", "(", "$", "onlinetextsubmission", "->", "onlinetext", ")", ")", "{", "$", "wordcount", "=", "count_words", "(", "trim", "(", "$", "onlinetextsubmission", "->", "onlinetext", ")", ")", ";", "}", "return", "$", "wordcount", "==", "0", ";", "}" ]
No text is set for this plugin @param stdClass $submission @return bool
[ "No", "text", "is", "set", "for", "this", "plugin" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/submission/onlinetext/locallib.php#L599-L608
214,460
moodle/moodle
mod/assign/submission/onlinetext/locallib.php
assign_submission_onlinetext.check_word_count
public function check_word_count($submissiontext) { global $OUTPUT; $wordlimitenabled = $this->get_config('wordlimitenabled'); $wordlimit = $this->get_config('wordlimit'); if ($wordlimitenabled == 0) { return null; } // Count words and compare to limit. $wordcount = count_words($submissiontext); if ($wordcount <= $wordlimit) { return null; } else { $errormsg = get_string('wordlimitexceeded', 'assignsubmission_onlinetext', array('limit' => $wordlimit, 'count' => $wordcount)); return $OUTPUT->error_text($errormsg); } }
php
public function check_word_count($submissiontext) { global $OUTPUT; $wordlimitenabled = $this->get_config('wordlimitenabled'); $wordlimit = $this->get_config('wordlimit'); if ($wordlimitenabled == 0) { return null; } // Count words and compare to limit. $wordcount = count_words($submissiontext); if ($wordcount <= $wordlimit) { return null; } else { $errormsg = get_string('wordlimitexceeded', 'assignsubmission_onlinetext', array('limit' => $wordlimit, 'count' => $wordcount)); return $OUTPUT->error_text($errormsg); } }
[ "public", "function", "check_word_count", "(", "$", "submissiontext", ")", "{", "global", "$", "OUTPUT", ";", "$", "wordlimitenabled", "=", "$", "this", "->", "get_config", "(", "'wordlimitenabled'", ")", ";", "$", "wordlimit", "=", "$", "this", "->", "get_config", "(", "'wordlimit'", ")", ";", "if", "(", "$", "wordlimitenabled", "==", "0", ")", "{", "return", "null", ";", "}", "// Count words and compare to limit.", "$", "wordcount", "=", "count_words", "(", "$", "submissiontext", ")", ";", "if", "(", "$", "wordcount", "<=", "$", "wordlimit", ")", "{", "return", "null", ";", "}", "else", "{", "$", "errormsg", "=", "get_string", "(", "'wordlimitexceeded'", ",", "'assignsubmission_onlinetext'", ",", "array", "(", "'limit'", "=>", "$", "wordlimit", ",", "'count'", "=>", "$", "wordcount", ")", ")", ";", "return", "$", "OUTPUT", "->", "error_text", "(", "$", "errormsg", ")", ";", "}", "}" ]
Compare word count of onlinetext submission to word limit, and return result. @param string $submissiontext Onlinetext submission text from editor @return string Error message if limit is enabled and exceeded, otherwise null
[ "Compare", "word", "count", "of", "onlinetext", "submission", "to", "word", "limit", "and", "return", "result", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/submission/onlinetext/locallib.php#L688-L707
214,461
moodle/moodle
lib/dml/pdo_moodle_database.php
pdo_moodle_database.get_fieldset_sql
public function get_fieldset_sql($sql, array $params=null) { $rs = $this->get_recordset_sql($sql, $params); if (!$rs->valid()) { $rs->close(); // Not going to iterate (but exit), close rs return false; } $result = array(); foreach($rs as $value) { $result[] = reset($value); } $rs->close(); return $result; }
php
public function get_fieldset_sql($sql, array $params=null) { $rs = $this->get_recordset_sql($sql, $params); if (!$rs->valid()) { $rs->close(); // Not going to iterate (but exit), close rs return false; } $result = array(); foreach($rs as $value) { $result[] = reset($value); } $rs->close(); return $result; }
[ "public", "function", "get_fieldset_sql", "(", "$", "sql", ",", "array", "$", "params", "=", "null", ")", "{", "$", "rs", "=", "$", "this", "->", "get_recordset_sql", "(", "$", "sql", ",", "$", "params", ")", ";", "if", "(", "!", "$", "rs", "->", "valid", "(", ")", ")", "{", "$", "rs", "->", "close", "(", ")", ";", "// Not going to iterate (but exit), close rs", "return", "false", ";", "}", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "rs", "as", "$", "value", ")", "{", "$", "result", "[", "]", "=", "reset", "(", "$", "value", ")", ";", "}", "$", "rs", "->", "close", "(", ")", ";", "return", "$", "result", ";", "}" ]
Selects rows and return values of first column as array. @param string $sql The SQL query @param array $params array of sql parameters @return array of values
[ "Selects", "rows", "and", "return", "values", "of", "first", "column", "as", "array", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/dml/pdo_moodle_database.php#L295-L307
214,462
moodle/moodle
lib/dml/pdo_moodle_database.php
pdo_moodle_database.get_records_sql
public function get_records_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) { global $CFG; $rs = $this->get_recordset_sql($sql, $params, $limitfrom, $limitnum); if (!$rs->valid()) { $rs->close(); // Not going to iterate (but exit), close rs return false; } $objects = array(); foreach($rs as $value) { $key = reset($value); if ($CFG->debugdeveloper && array_key_exists($key, $objects)) { debugging("Did you remember to make the first column something unique in your call to get_records? Duplicate value '$key' found in column first column of '$sql'.", DEBUG_DEVELOPER); } $objects[$key] = (object)$value; } $rs->close(); return $objects; }
php
public function get_records_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) { global $CFG; $rs = $this->get_recordset_sql($sql, $params, $limitfrom, $limitnum); if (!$rs->valid()) { $rs->close(); // Not going to iterate (but exit), close rs return false; } $objects = array(); foreach($rs as $value) { $key = reset($value); if ($CFG->debugdeveloper && array_key_exists($key, $objects)) { debugging("Did you remember to make the first column something unique in your call to get_records? Duplicate value '$key' found in column first column of '$sql'.", DEBUG_DEVELOPER); } $objects[$key] = (object)$value; } $rs->close(); return $objects; }
[ "public", "function", "get_records_sql", "(", "$", "sql", ",", "array", "$", "params", "=", "null", ",", "$", "limitfrom", "=", "0", ",", "$", "limitnum", "=", "0", ")", "{", "global", "$", "CFG", ";", "$", "rs", "=", "$", "this", "->", "get_recordset_sql", "(", "$", "sql", ",", "$", "params", ",", "$", "limitfrom", ",", "$", "limitnum", ")", ";", "if", "(", "!", "$", "rs", "->", "valid", "(", ")", ")", "{", "$", "rs", "->", "close", "(", ")", ";", "// Not going to iterate (but exit), close rs", "return", "false", ";", "}", "$", "objects", "=", "array", "(", ")", ";", "foreach", "(", "$", "rs", "as", "$", "value", ")", "{", "$", "key", "=", "reset", "(", "$", "value", ")", ";", "if", "(", "$", "CFG", "->", "debugdeveloper", "&&", "array_key_exists", "(", "$", "key", ",", "$", "objects", ")", ")", "{", "debugging", "(", "\"Did you remember to make the first column something unique in your call to get_records? Duplicate value '$key' found in column first column of '$sql'.\"", ",", "DEBUG_DEVELOPER", ")", ";", "}", "$", "objects", "[", "$", "key", "]", "=", "(", "object", ")", "$", "value", ";", "}", "$", "rs", "->", "close", "(", ")", ";", "return", "$", "objects", ";", "}" ]
Get a number of records as an array of objects. Return value is like: @see function get_records. @param string $sql the SQL select query to execute. The first column of this SELECT statement must be a unique value (usually the 'id' field), as it will be used as the key of the returned array. @param array $params array of sql parameters @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set). @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set). @return array of objects, or empty array if no records were found, or false if an error occurred.
[ "Get", "a", "number", "of", "records", "as", "an", "array", "of", "objects", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/dml/pdo_moodle_database.php#L323-L341
214,463
moodle/moodle
lib/dml/pdo_moodle_database.php
pdo_moodle_database.set_field_select
public function set_field_select($table, $newfield, $newvalue, $select, array $params=null) { if ($select) { $select = "WHERE $select"; } if (is_null($params)) { $params = array(); } list($select, $params, $type) = $this->fix_sql_params($select, $params); if (is_bool($newvalue)) { $newvalue = (int)$newvalue; // prevent "false" problems } if (is_null($newvalue)) { $newfield = "$newfield = NULL"; } else { // make sure SET and WHERE clauses use the same type of parameters, // because we don't support different types in the same query switch($type) { case SQL_PARAMS_NAMED: $newfield = "$newfield = :newvalueforupdate"; $params['newvalueforupdate'] = $newvalue; break; case SQL_PARAMS_QM: $newfield = "$newfield = ?"; array_unshift($params, $newvalue); break; default: $this->lastError = __FILE__ . ' LINE: ' . __LINE__ . '.'; print_error(unknowparamtype, 'error', '', $this->lastError); } } $sql = "UPDATE {{$table}} SET $newfield $select"; return $this->execute($sql, $params); }
php
public function set_field_select($table, $newfield, $newvalue, $select, array $params=null) { if ($select) { $select = "WHERE $select"; } if (is_null($params)) { $params = array(); } list($select, $params, $type) = $this->fix_sql_params($select, $params); if (is_bool($newvalue)) { $newvalue = (int)$newvalue; // prevent "false" problems } if (is_null($newvalue)) { $newfield = "$newfield = NULL"; } else { // make sure SET and WHERE clauses use the same type of parameters, // because we don't support different types in the same query switch($type) { case SQL_PARAMS_NAMED: $newfield = "$newfield = :newvalueforupdate"; $params['newvalueforupdate'] = $newvalue; break; case SQL_PARAMS_QM: $newfield = "$newfield = ?"; array_unshift($params, $newvalue); break; default: $this->lastError = __FILE__ . ' LINE: ' . __LINE__ . '.'; print_error(unknowparamtype, 'error', '', $this->lastError); } } $sql = "UPDATE {{$table}} SET $newfield $select"; return $this->execute($sql, $params); }
[ "public", "function", "set_field_select", "(", "$", "table", ",", "$", "newfield", ",", "$", "newvalue", ",", "$", "select", ",", "array", "$", "params", "=", "null", ")", "{", "if", "(", "$", "select", ")", "{", "$", "select", "=", "\"WHERE $select\"", ";", "}", "if", "(", "is_null", "(", "$", "params", ")", ")", "{", "$", "params", "=", "array", "(", ")", ";", "}", "list", "(", "$", "select", ",", "$", "params", ",", "$", "type", ")", "=", "$", "this", "->", "fix_sql_params", "(", "$", "select", ",", "$", "params", ")", ";", "if", "(", "is_bool", "(", "$", "newvalue", ")", ")", "{", "$", "newvalue", "=", "(", "int", ")", "$", "newvalue", ";", "// prevent \"false\" problems", "}", "if", "(", "is_null", "(", "$", "newvalue", ")", ")", "{", "$", "newfield", "=", "\"$newfield = NULL\"", ";", "}", "else", "{", "// make sure SET and WHERE clauses use the same type of parameters,", "// because we don't support different types in the same query", "switch", "(", "$", "type", ")", "{", "case", "SQL_PARAMS_NAMED", ":", "$", "newfield", "=", "\"$newfield = :newvalueforupdate\"", ";", "$", "params", "[", "'newvalueforupdate'", "]", "=", "$", "newvalue", ";", "break", ";", "case", "SQL_PARAMS_QM", ":", "$", "newfield", "=", "\"$newfield = ?\"", ";", "array_unshift", "(", "$", "params", ",", "$", "newvalue", ")", ";", "break", ";", "default", ":", "$", "this", "->", "lastError", "=", "__FILE__", ".", "' LINE: '", ".", "__LINE__", ".", "'.'", ";", "print_error", "(", "unknowparamtype", ",", "'error'", ",", "''", ",", "$", "this", "->", "lastError", ")", ";", "}", "}", "$", "sql", "=", "\"UPDATE {{$table}} SET $newfield $select\"", ";", "return", "$", "this", "->", "execute", "(", "$", "sql", ",", "$", "params", ")", ";", "}" ]
Set a single field in every table row where the select statement evaluates to true. @param string $table The database table to be checked against. @param string $newfield the field to set. @param string $newvalue the value to set the field to. @param string $select A fragment of SQL to be used in a where clause in the SQL call. @param array $params array of sql parameters @return bool success
[ "Set", "a", "single", "field", "in", "every", "table", "row", "where", "the", "select", "statement", "evaluates", "to", "true", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/dml/pdo_moodle_database.php#L502-L535
214,464
moodle/moodle
lib/dml/pdo_moodle_database.php
pdo_moodle_database.import_record
public function import_record($table, $dataobject) { $dataobject = (object)$dataobject; $columns = $this->get_columns($table); $cleaned = array(); foreach ($dataobject as $field=>$value) { if (!isset($columns[$field])) { continue; } $cleaned[$field] = $value; } return $this->insert_record_raw($table, $cleaned, false, true, true); }
php
public function import_record($table, $dataobject) { $dataobject = (object)$dataobject; $columns = $this->get_columns($table); $cleaned = array(); foreach ($dataobject as $field=>$value) { if (!isset($columns[$field])) { continue; } $cleaned[$field] = $value; } return $this->insert_record_raw($table, $cleaned, false, true, true); }
[ "public", "function", "import_record", "(", "$", "table", ",", "$", "dataobject", ")", "{", "$", "dataobject", "=", "(", "object", ")", "$", "dataobject", ";", "$", "columns", "=", "$", "this", "->", "get_columns", "(", "$", "table", ")", ";", "$", "cleaned", "=", "array", "(", ")", ";", "foreach", "(", "$", "dataobject", "as", "$", "field", "=>", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "columns", "[", "$", "field", "]", ")", ")", "{", "continue", ";", "}", "$", "cleaned", "[", "$", "field", "]", "=", "$", "value", ";", "}", "return", "$", "this", "->", "insert_record_raw", "(", "$", "table", ",", "$", "cleaned", ",", "false", ",", "true", ",", "true", ")", ";", "}" ]
Import a record into a table, id field is required. Basic safety checks only. Lobs are supported. @param string $table name of database table to be inserted into @param mixed $dataobject object or array with fields in the record @return bool success
[ "Import", "a", "record", "into", "a", "table", "id", "field", "is", "required", ".", "Basic", "safety", "checks", "only", ".", "Lobs", "are", "supported", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/dml/pdo_moodle_database.php#L584-L597
214,465
moodle/moodle
backup/cc/cc_lib/cc_manifest.php
cc_manifest.register_namespaces_for_xpath
public function register_namespaces_for_xpath() { $scnam = $this->activemanifest->get_cc_namespaces(); foreach ($scnam as $key => $value) { $this->registerNS($key, $value); } }
php
public function register_namespaces_for_xpath() { $scnam = $this->activemanifest->get_cc_namespaces(); foreach ($scnam as $key => $value) { $this->registerNS($key, $value); } }
[ "public", "function", "register_namespaces_for_xpath", "(", ")", "{", "$", "scnam", "=", "$", "this", "->", "activemanifest", "->", "get_cc_namespaces", "(", ")", ";", "foreach", "(", "$", "scnam", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "registerNS", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}" ]
Register Namespace for use XPATH
[ "Register", "Namespace", "for", "use", "XPATH" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/cc/cc_lib/cc_manifest.php#L69-L74
214,466
moodle/moodle
backup/cc/cc_lib/cc_manifest.php
cc_manifest.add_metadata_manifest
public function add_metadata_manifest(cc_i_metadata_manifest $met) { $metanode = $this->node("//imscc:manifest[@identifier='". $this->activemanifest->manifestID(). "']/imscc:metadata"); $nmeta = $this->activemanifest->create_metadata_node($met, $this->doc, $metanode); $metanode->appendChild($nmeta); }
php
public function add_metadata_manifest(cc_i_metadata_manifest $met) { $metanode = $this->node("//imscc:manifest[@identifier='". $this->activemanifest->manifestID(). "']/imscc:metadata"); $nmeta = $this->activemanifest->create_metadata_node($met, $this->doc, $metanode); $metanode->appendChild($nmeta); }
[ "public", "function", "add_metadata_manifest", "(", "cc_i_metadata_manifest", "$", "met", ")", "{", "$", "metanode", "=", "$", "this", "->", "node", "(", "\"//imscc:manifest[@identifier='\"", ".", "$", "this", "->", "activemanifest", "->", "manifestID", "(", ")", ".", "\"']/imscc:metadata\"", ")", ";", "$", "nmeta", "=", "$", "this", "->", "activemanifest", "->", "create_metadata_node", "(", "$", "met", ",", "$", "this", "->", "doc", ",", "$", "metanode", ")", ";", "$", "metanode", "->", "appendChild", "(", "$", "nmeta", ")", ";", "}" ]
Add Metadata For Manifest @param cc_i_metadata_manifest $met
[ "Add", "Metadata", "For", "Manifest" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/cc/cc_lib/cc_manifest.php#L89-L95
214,467
moodle/moodle
backup/cc/cc_lib/cc_manifest.php
cc_manifest.add_metadata_resource
public function add_metadata_resource(cc_i_metadata_resource $met, $identifier) { $metanode = $this->node("//imscc:resource". "[@identifier='". $identifier. "']"); $metanode2 = $this->node("//imscc:resource". "[@identifier='". $identifier. "']/imscc:file"); $nspaces = $this->activemanifest->get_cc_namespaces(); $dnode = $this->append_new_element_ns($metanode2, $nspaces['imscc'], 'metadata'); $this->activemanifest->create_metadata_resource_node($met, $this->doc, $dnode); }
php
public function add_metadata_resource(cc_i_metadata_resource $met, $identifier) { $metanode = $this->node("//imscc:resource". "[@identifier='". $identifier. "']"); $metanode2 = $this->node("//imscc:resource". "[@identifier='". $identifier. "']/imscc:file"); $nspaces = $this->activemanifest->get_cc_namespaces(); $dnode = $this->append_new_element_ns($metanode2, $nspaces['imscc'], 'metadata'); $this->activemanifest->create_metadata_resource_node($met, $this->doc, $dnode); }
[ "public", "function", "add_metadata_resource", "(", "cc_i_metadata_resource", "$", "met", ",", "$", "identifier", ")", "{", "$", "metanode", "=", "$", "this", "->", "node", "(", "\"//imscc:resource\"", ".", "\"[@identifier='\"", ".", "$", "identifier", ".", "\"']\"", ")", ";", "$", "metanode2", "=", "$", "this", "->", "node", "(", "\"//imscc:resource\"", ".", "\"[@identifier='\"", ".", "$", "identifier", ".", "\"']/imscc:file\"", ")", ";", "$", "nspaces", "=", "$", "this", "->", "activemanifest", "->", "get_cc_namespaces", "(", ")", ";", "$", "dnode", "=", "$", "this", "->", "append_new_element_ns", "(", "$", "metanode2", ",", "$", "nspaces", "[", "'imscc'", "]", ",", "'metadata'", ")", ";", "$", "this", "->", "activemanifest", "->", "create_metadata_resource_node", "(", "$", "met", ",", "$", "this", "->", "doc", ",", "$", "dnode", ")", ";", "}" ]
Add Metadata For Resource @param cc_i_metadata_resource $met @param string $identifier
[ "Add", "Metadata", "For", "Resource" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/cc/cc_lib/cc_manifest.php#L104-L116
214,468
moodle/moodle
backup/cc/cc_lib/cc_manifest.php
cc_manifest.add_metadata_file
public function add_metadata_file(cc_i_metadata_file $met, $identifier, $filename) { if (empty($met) || empty($identifier) || empty($filename)) { throw new Exception('Try to add a metadata file with nulls values given!'); } $metanode = $this->node("//imscc:resource". "[@identifier='". $identifier. "']/imscc:file". "[@href='". $filename. "']"); $nspaces = $this->activemanifest->get_cc_namespaces(); $dnode = $this->doc->createElementNS($nspaces['imscc'], "metadata"); $metanode->appendChild($dnode); $this->activemanifest->create_metadata_file_node($met, $this->doc, $dnode); }
php
public function add_metadata_file(cc_i_metadata_file $met, $identifier, $filename) { if (empty($met) || empty($identifier) || empty($filename)) { throw new Exception('Try to add a metadata file with nulls values given!'); } $metanode = $this->node("//imscc:resource". "[@identifier='". $identifier. "']/imscc:file". "[@href='". $filename. "']"); $nspaces = $this->activemanifest->get_cc_namespaces(); $dnode = $this->doc->createElementNS($nspaces['imscc'], "metadata"); $metanode->appendChild($dnode); $this->activemanifest->create_metadata_file_node($met, $this->doc, $dnode); }
[ "public", "function", "add_metadata_file", "(", "cc_i_metadata_file", "$", "met", ",", "$", "identifier", ",", "$", "filename", ")", "{", "if", "(", "empty", "(", "$", "met", ")", "||", "empty", "(", "$", "identifier", ")", "||", "empty", "(", "$", "filename", ")", ")", "{", "throw", "new", "Exception", "(", "'Try to add a metadata file with nulls values given!'", ")", ";", "}", "$", "metanode", "=", "$", "this", "->", "node", "(", "\"//imscc:resource\"", ".", "\"[@identifier='\"", ".", "$", "identifier", ".", "\"']/imscc:file\"", ".", "\"[@href='\"", ".", "$", "filename", ".", "\"']\"", ")", ";", "$", "nspaces", "=", "$", "this", "->", "activemanifest", "->", "get_cc_namespaces", "(", ")", ";", "$", "dnode", "=", "$", "this", "->", "doc", "->", "createElementNS", "(", "$", "nspaces", "[", "'imscc'", "]", ",", "\"metadata\"", ")", ";", "$", "metanode", "->", "appendChild", "(", "$", "dnode", ")", ";", "$", "this", "->", "activemanifest", "->", "create_metadata_file_node", "(", "$", "met", ",", "$", "this", "->", "doc", ",", "$", "dnode", ")", ";", "}" ]
Add Metadata For File @param cc_i_metadata_file $met @param string $identifier @param string $filename
[ "Add", "Metadata", "For", "File" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/cc/cc_lib/cc_manifest.php#L126-L146
214,469
moodle/moodle
backup/cc/cc_lib/cc_manifest.php
cc_manifest.add_new_organization
public function add_new_organization(cc_i_organization &$org) { $norg = $this->activemanifest->create_organization_node($org, $this->doc); $orgnode = $this->node("//imscc:manifest[@identifier='". $this->activemanifest->manifestID(). "']/imscc:organizations"); $orgnode->appendChild($norg); }
php
public function add_new_organization(cc_i_organization &$org) { $norg = $this->activemanifest->create_organization_node($org, $this->doc); $orgnode = $this->node("//imscc:manifest[@identifier='". $this->activemanifest->manifestID(). "']/imscc:organizations"); $orgnode->appendChild($norg); }
[ "public", "function", "add_new_organization", "(", "cc_i_organization", "&", "$", "org", ")", "{", "$", "norg", "=", "$", "this", "->", "activemanifest", "->", "create_organization_node", "(", "$", "org", ",", "$", "this", "->", "doc", ")", ";", "$", "orgnode", "=", "$", "this", "->", "node", "(", "\"//imscc:manifest[@identifier='\"", ".", "$", "this", "->", "activemanifest", "->", "manifestID", "(", ")", ".", "\"']/imscc:organizations\"", ")", ";", "$", "orgnode", "->", "appendChild", "(", "$", "norg", ")", ";", "}" ]
Add a new organization @param cc_i_organization $org
[ "Add", "a", "new", "organization" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/cc/cc_lib/cc_manifest.php#L182-L188
214,470
moodle/moodle
backup/cc/cc_lib/cc_manifest.php
cc_manifest.add_resource
public function add_resource(cc_i_resource $res, $identifier = null, $type = 'webcontent') { if (!$this->ccobj->valid($type)) { throw new Exception("Type invalid..."); } if ($res == null) { throw new Exception('Invalid Resource or dont give it'); } $rst = $res; // TODO: This has to be reviewed since it does not handle multiple files properly. // Dependencies. if (is_object($identifier)) { $this->activemanifest->create_resource_node($rst, $this->doc, $identifier); } else { $nresnode = null; $rst->type = $type; if (!cc_helpers::is_html($rst->filename)) { $rst->href = null; } $this->activemanifest->create_resource_node($rst, $this->doc, $nresnode); foreach ($rst->files as $file) { $ident = $this->get_identifier_by_filename($file); if ($ident == null) { $newres = new cc_resource($rst->manifestroot, $file); if (!cc_helpers::is_html($file)) { $newres->href = null; } $newres->type = 'webcontent'; $this->activemanifest->create_resource_node($newres, $this->doc, $nresnode); } } } $tmparray = array($rst->identifier, $rst->files[0]); return $tmparray; }
php
public function add_resource(cc_i_resource $res, $identifier = null, $type = 'webcontent') { if (!$this->ccobj->valid($type)) { throw new Exception("Type invalid..."); } if ($res == null) { throw new Exception('Invalid Resource or dont give it'); } $rst = $res; // TODO: This has to be reviewed since it does not handle multiple files properly. // Dependencies. if (is_object($identifier)) { $this->activemanifest->create_resource_node($rst, $this->doc, $identifier); } else { $nresnode = null; $rst->type = $type; if (!cc_helpers::is_html($rst->filename)) { $rst->href = null; } $this->activemanifest->create_resource_node($rst, $this->doc, $nresnode); foreach ($rst->files as $file) { $ident = $this->get_identifier_by_filename($file); if ($ident == null) { $newres = new cc_resource($rst->manifestroot, $file); if (!cc_helpers::is_html($file)) { $newres->href = null; } $newres->type = 'webcontent'; $this->activemanifest->create_resource_node($newres, $this->doc, $nresnode); } } } $tmparray = array($rst->identifier, $rst->files[0]); return $tmparray; }
[ "public", "function", "add_resource", "(", "cc_i_resource", "$", "res", ",", "$", "identifier", "=", "null", ",", "$", "type", "=", "'webcontent'", ")", "{", "if", "(", "!", "$", "this", "->", "ccobj", "->", "valid", "(", "$", "type", ")", ")", "{", "throw", "new", "Exception", "(", "\"Type invalid...\"", ")", ";", "}", "if", "(", "$", "res", "==", "null", ")", "{", "throw", "new", "Exception", "(", "'Invalid Resource or dont give it'", ")", ";", "}", "$", "rst", "=", "$", "res", ";", "// TODO: This has to be reviewed since it does not handle multiple files properly.", "// Dependencies.", "if", "(", "is_object", "(", "$", "identifier", ")", ")", "{", "$", "this", "->", "activemanifest", "->", "create_resource_node", "(", "$", "rst", ",", "$", "this", "->", "doc", ",", "$", "identifier", ")", ";", "}", "else", "{", "$", "nresnode", "=", "null", ";", "$", "rst", "->", "type", "=", "$", "type", ";", "if", "(", "!", "cc_helpers", "::", "is_html", "(", "$", "rst", "->", "filename", ")", ")", "{", "$", "rst", "->", "href", "=", "null", ";", "}", "$", "this", "->", "activemanifest", "->", "create_resource_node", "(", "$", "rst", ",", "$", "this", "->", "doc", ",", "$", "nresnode", ")", ";", "foreach", "(", "$", "rst", "->", "files", "as", "$", "file", ")", "{", "$", "ident", "=", "$", "this", "->", "get_identifier_by_filename", "(", "$", "file", ")", ";", "if", "(", "$", "ident", "==", "null", ")", "{", "$", "newres", "=", "new", "cc_resource", "(", "$", "rst", "->", "manifestroot", ",", "$", "file", ")", ";", "if", "(", "!", "cc_helpers", "::", "is_html", "(", "$", "file", ")", ")", "{", "$", "newres", "->", "href", "=", "null", ";", "}", "$", "newres", "->", "type", "=", "'webcontent'", ";", "$", "this", "->", "activemanifest", "->", "create_resource_node", "(", "$", "newres", ",", "$", "this", "->", "doc", ",", "$", "nresnode", ")", ";", "}", "}", "}", "$", "tmparray", "=", "array", "(", "$", "rst", "->", "identifier", ",", "$", "rst", "->", "files", "[", "0", "]", ")", ";", "return", "$", "tmparray", ";", "}" ]
Add a resource to the manifest @param cc_i_resource $res @param string $identifier @param string $type @return array
[ "Add", "a", "resource", "to", "the", "manifest" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/cc/cc_lib/cc_manifest.php#L232-L271
214,471
moodle/moodle
backup/cc/cc_lib/cc_manifest.php
cc_manifest.put_nodes
public function put_nodes() { $resnodestr = "//imscc:manifest[@identifier='".$this->activemanifest->manifestID(). "']/imscc:resources"; $resnode = $this->node($resnodestr); foreach ($this->activemanifest->resources as $k => $v) { ($k); $depen = $this->check_if_exist_in_other($v->files[0], $v->identifier); if (!empty($depen)) { $this->replace_file_x_dependency($depen, $v->files[0]); $v->type = 'webcontent'; } } foreach ($this->activemanifest->resources as $node) { $rnode = $this->activemanifest->create_resource_node($node, $this->doc, null); $resnode->appendChild($rnode); if ($node->instructoronly) { $metafileceduc = new cc_metadata_resouce_educational(); $metafileceduc->set_value(intended_user_role::INSTRUCTOR); $metafile = new cc_metadata_resouce(); $metafile->add_metadata_resource_educational($metafileceduc); $this->activemanifest->create_metadata_educational($metafile, $this->doc, $rnode); } } return $resnode; }
php
public function put_nodes() { $resnodestr = "//imscc:manifest[@identifier='".$this->activemanifest->manifestID(). "']/imscc:resources"; $resnode = $this->node($resnodestr); foreach ($this->activemanifest->resources as $k => $v) { ($k); $depen = $this->check_if_exist_in_other($v->files[0], $v->identifier); if (!empty($depen)) { $this->replace_file_x_dependency($depen, $v->files[0]); $v->type = 'webcontent'; } } foreach ($this->activemanifest->resources as $node) { $rnode = $this->activemanifest->create_resource_node($node, $this->doc, null); $resnode->appendChild($rnode); if ($node->instructoronly) { $metafileceduc = new cc_metadata_resouce_educational(); $metafileceduc->set_value(intended_user_role::INSTRUCTOR); $metafile = new cc_metadata_resouce(); $metafile->add_metadata_resource_educational($metafileceduc); $this->activemanifest->create_metadata_educational($metafile, $this->doc, $rnode); } } return $resnode; }
[ "public", "function", "put_nodes", "(", ")", "{", "$", "resnodestr", "=", "\"//imscc:manifest[@identifier='\"", ".", "$", "this", "->", "activemanifest", "->", "manifestID", "(", ")", ".", "\"']/imscc:resources\"", ";", "$", "resnode", "=", "$", "this", "->", "node", "(", "$", "resnodestr", ")", ";", "foreach", "(", "$", "this", "->", "activemanifest", "->", "resources", "as", "$", "k", "=>", "$", "v", ")", "{", "(", "$", "k", ")", ";", "$", "depen", "=", "$", "this", "->", "check_if_exist_in_other", "(", "$", "v", "->", "files", "[", "0", "]", ",", "$", "v", "->", "identifier", ")", ";", "if", "(", "!", "empty", "(", "$", "depen", ")", ")", "{", "$", "this", "->", "replace_file_x_dependency", "(", "$", "depen", ",", "$", "v", "->", "files", "[", "0", "]", ")", ";", "$", "v", "->", "type", "=", "'webcontent'", ";", "}", "}", "foreach", "(", "$", "this", "->", "activemanifest", "->", "resources", "as", "$", "node", ")", "{", "$", "rnode", "=", "$", "this", "->", "activemanifest", "->", "create_resource_node", "(", "$", "node", ",", "$", "this", "->", "doc", ",", "null", ")", ";", "$", "resnode", "->", "appendChild", "(", "$", "rnode", ")", ";", "if", "(", "$", "node", "->", "instructoronly", ")", "{", "$", "metafileceduc", "=", "new", "cc_metadata_resouce_educational", "(", ")", ";", "$", "metafileceduc", "->", "set_value", "(", "intended_user_role", "::", "INSTRUCTOR", ")", ";", "$", "metafile", "=", "new", "cc_metadata_resouce", "(", ")", ";", "$", "metafile", "->", "add_metadata_resource_educational", "(", "$", "metafileceduc", ")", ";", "$", "this", "->", "activemanifest", "->", "create_metadata_educational", "(", "$", "metafile", ",", "$", "this", "->", "doc", ",", "$", "rnode", ")", ";", "}", "}", "return", "$", "resnode", ";", "}" ]
Append the resources nodes in the Manifest @return DOMNode
[ "Append", "the", "resources", "nodes", "in", "the", "Manifest" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/backup/cc/cc_lib/cc_manifest.php#L325-L353
214,472
moodle/moodle
lib/spout/src/Spout/Writer/Common/Helper/AbstractStyleHelper.php
AbstractStyleHelper.applyWrapTextIfCellContainsNewLine
protected function applyWrapTextIfCellContainsNewLine($style, $dataRow) { // if the "wrap text" option is already set, no-op if ($style->hasSetWrapText()) { return $style; } foreach ($dataRow as $cell) { if (is_string($cell) && strpos($cell, "\n") !== false) { $style->setShouldWrapText(); break; } } return $style; }
php
protected function applyWrapTextIfCellContainsNewLine($style, $dataRow) { // if the "wrap text" option is already set, no-op if ($style->hasSetWrapText()) { return $style; } foreach ($dataRow as $cell) { if (is_string($cell) && strpos($cell, "\n") !== false) { $style->setShouldWrapText(); break; } } return $style; }
[ "protected", "function", "applyWrapTextIfCellContainsNewLine", "(", "$", "style", ",", "$", "dataRow", ")", "{", "// if the \"wrap text\" option is already set, no-op", "if", "(", "$", "style", "->", "hasSetWrapText", "(", ")", ")", "{", "return", "$", "style", ";", "}", "foreach", "(", "$", "dataRow", "as", "$", "cell", ")", "{", "if", "(", "is_string", "(", "$", "cell", ")", "&&", "strpos", "(", "$", "cell", ",", "\"\\n\"", ")", "!==", "false", ")", "{", "$", "style", "->", "setShouldWrapText", "(", ")", ";", "break", ";", "}", "}", "return", "$", "style", ";", "}" ]
Set the "wrap text" option if a cell of the given row contains a new line. @NOTE: There is a bug on the Mac version of Excel (2011 and below) where new lines are ignored even when the "wrap text" option is set. This only occurs with inline strings (shared strings do work fine). A workaround would be to encode "\n" as "_x000D_" but it does not work on the Windows version of Excel... @param \Box\Spout\Writer\Style\Style $style The original style @param array $dataRow The row the style will be applied to @return \Box\Spout\Writer\Style\Style The eventually updated style
[ "Set", "the", "wrap", "text", "option", "if", "a", "cell", "of", "the", "given", "row", "contains", "a", "new", "line", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/spout/src/Spout/Writer/Common/Helper/AbstractStyleHelper.php#L122-L137
214,473
moodle/moodle
cache/stores/mongodb/MongoDB/Client.php
Client.listDatabases
public function listDatabases(array $options = []) { $operation = new ListDatabases($options); $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY)); return $operation->execute($server); }
php
public function listDatabases(array $options = []) { $operation = new ListDatabases($options); $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY)); return $operation->execute($server); }
[ "public", "function", "listDatabases", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "operation", "=", "new", "ListDatabases", "(", "$", "options", ")", ";", "$", "server", "=", "$", "this", "->", "manager", "->", "selectServer", "(", "new", "ReadPreference", "(", "ReadPreference", "::", "RP_PRIMARY", ")", ")", ";", "return", "$", "operation", "->", "execute", "(", "$", "server", ")", ";", "}" ]
List databases. @see ListDatabases::__construct() for supported options @return DatabaseInfoIterator @throws UnexpectedValueException if the command response was malformed @throws InvalidArgumentException for parameter/option parsing errors @throws DriverRuntimeException for other driver errors (e.g. connection errors)
[ "List", "databases", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/Client.php#L225-L231
214,474
moodle/moodle
cache/stores/mongodb/MongoDB/Client.php
Client.selectCollection
public function selectCollection($databaseName, $collectionName, array $options = []) { $options += ['typeMap' => $this->typeMap]; return new Collection($this->manager, $databaseName, $collectionName, $options); }
php
public function selectCollection($databaseName, $collectionName, array $options = []) { $options += ['typeMap' => $this->typeMap]; return new Collection($this->manager, $databaseName, $collectionName, $options); }
[ "public", "function", "selectCollection", "(", "$", "databaseName", ",", "$", "collectionName", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "+=", "[", "'typeMap'", "=>", "$", "this", "->", "typeMap", "]", ";", "return", "new", "Collection", "(", "$", "this", "->", "manager", ",", "$", "databaseName", ",", "$", "collectionName", ",", "$", "options", ")", ";", "}" ]
Select a collection. @see Collection::__construct() for supported options @param string $databaseName Name of the database containing the collection @param string $collectionName Name of the collection to select @param array $options Collection constructor options @return Collection @throws InvalidArgumentException for parameter/option parsing errors
[ "Select", "a", "collection", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/cache/stores/mongodb/MongoDB/Client.php#L243-L248
214,475
moodle/moodle
mod/lesson/locallib.php
lesson_add_page_form_base.definition
public final function definition() { global $CFG; $mform = $this->_form; $editoroptions = $this->_customdata['editoroptions']; if ($this->qtypestring != 'selectaqtype') { if ($this->_customdata['edit']) { $mform->addElement('header', 'qtypeheading', get_string('edit'. $this->qtypestring, 'lesson')); } else { $mform->addElement('header', 'qtypeheading', get_string('add'. $this->qtypestring, 'lesson')); } } if (!empty($this->_customdata['returnto'])) { $mform->addElement('hidden', 'returnto', $this->_customdata['returnto']); $mform->setType('returnto', PARAM_URL); } $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'pageid'); $mform->setType('pageid', PARAM_INT); if ($this->standard === true) { $mform->addElement('hidden', 'qtype'); $mform->setType('qtype', PARAM_INT); $mform->addElement('text', 'title', get_string('pagetitle', 'lesson'), array('size'=>70)); $mform->addRule('title', get_string('required'), 'required', null, 'client'); if (!empty($CFG->formatstringstriptags)) { $mform->setType('title', PARAM_TEXT); } else { $mform->setType('title', PARAM_CLEANHTML); } $this->editoroptions = array('noclean'=>true, 'maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$this->_customdata['maxbytes']); $mform->addElement('editor', 'contents_editor', get_string('pagecontents', 'lesson'), null, $this->editoroptions); $mform->setType('contents_editor', PARAM_RAW); $mform->addRule('contents_editor', get_string('required'), 'required', null, 'client'); } $this->custom_definition(); if ($this->_customdata['edit'] === true) { $mform->addElement('hidden', 'edit', 1); $mform->setType('edit', PARAM_BOOL); $this->add_action_buttons(get_string('cancel'), get_string('savepage', 'lesson')); } else if ($this->qtype === 'questiontype') { $this->add_action_buttons(get_string('cancel'), get_string('addaquestionpage', 'lesson')); } else { $this->add_action_buttons(get_string('cancel'), get_string('savepage', 'lesson')); } }
php
public final function definition() { global $CFG; $mform = $this->_form; $editoroptions = $this->_customdata['editoroptions']; if ($this->qtypestring != 'selectaqtype') { if ($this->_customdata['edit']) { $mform->addElement('header', 'qtypeheading', get_string('edit'. $this->qtypestring, 'lesson')); } else { $mform->addElement('header', 'qtypeheading', get_string('add'. $this->qtypestring, 'lesson')); } } if (!empty($this->_customdata['returnto'])) { $mform->addElement('hidden', 'returnto', $this->_customdata['returnto']); $mform->setType('returnto', PARAM_URL); } $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); $mform->addElement('hidden', 'pageid'); $mform->setType('pageid', PARAM_INT); if ($this->standard === true) { $mform->addElement('hidden', 'qtype'); $mform->setType('qtype', PARAM_INT); $mform->addElement('text', 'title', get_string('pagetitle', 'lesson'), array('size'=>70)); $mform->addRule('title', get_string('required'), 'required', null, 'client'); if (!empty($CFG->formatstringstriptags)) { $mform->setType('title', PARAM_TEXT); } else { $mform->setType('title', PARAM_CLEANHTML); } $this->editoroptions = array('noclean'=>true, 'maxfiles'=>EDITOR_UNLIMITED_FILES, 'maxbytes'=>$this->_customdata['maxbytes']); $mform->addElement('editor', 'contents_editor', get_string('pagecontents', 'lesson'), null, $this->editoroptions); $mform->setType('contents_editor', PARAM_RAW); $mform->addRule('contents_editor', get_string('required'), 'required', null, 'client'); } $this->custom_definition(); if ($this->_customdata['edit'] === true) { $mform->addElement('hidden', 'edit', 1); $mform->setType('edit', PARAM_BOOL); $this->add_action_buttons(get_string('cancel'), get_string('savepage', 'lesson')); } else if ($this->qtype === 'questiontype') { $this->add_action_buttons(get_string('cancel'), get_string('addaquestionpage', 'lesson')); } else { $this->add_action_buttons(get_string('cancel'), get_string('savepage', 'lesson')); } }
[ "public", "final", "function", "definition", "(", ")", "{", "global", "$", "CFG", ";", "$", "mform", "=", "$", "this", "->", "_form", ";", "$", "editoroptions", "=", "$", "this", "->", "_customdata", "[", "'editoroptions'", "]", ";", "if", "(", "$", "this", "->", "qtypestring", "!=", "'selectaqtype'", ")", "{", "if", "(", "$", "this", "->", "_customdata", "[", "'edit'", "]", ")", "{", "$", "mform", "->", "addElement", "(", "'header'", ",", "'qtypeheading'", ",", "get_string", "(", "'edit'", ".", "$", "this", "->", "qtypestring", ",", "'lesson'", ")", ")", ";", "}", "else", "{", "$", "mform", "->", "addElement", "(", "'header'", ",", "'qtypeheading'", ",", "get_string", "(", "'add'", ".", "$", "this", "->", "qtypestring", ",", "'lesson'", ")", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "_customdata", "[", "'returnto'", "]", ")", ")", "{", "$", "mform", "->", "addElement", "(", "'hidden'", ",", "'returnto'", ",", "$", "this", "->", "_customdata", "[", "'returnto'", "]", ")", ";", "$", "mform", "->", "setType", "(", "'returnto'", ",", "PARAM_URL", ")", ";", "}", "$", "mform", "->", "addElement", "(", "'hidden'", ",", "'id'", ")", ";", "$", "mform", "->", "setType", "(", "'id'", ",", "PARAM_INT", ")", ";", "$", "mform", "->", "addElement", "(", "'hidden'", ",", "'pageid'", ")", ";", "$", "mform", "->", "setType", "(", "'pageid'", ",", "PARAM_INT", ")", ";", "if", "(", "$", "this", "->", "standard", "===", "true", ")", "{", "$", "mform", "->", "addElement", "(", "'hidden'", ",", "'qtype'", ")", ";", "$", "mform", "->", "setType", "(", "'qtype'", ",", "PARAM_INT", ")", ";", "$", "mform", "->", "addElement", "(", "'text'", ",", "'title'", ",", "get_string", "(", "'pagetitle'", ",", "'lesson'", ")", ",", "array", "(", "'size'", "=>", "70", ")", ")", ";", "$", "mform", "->", "addRule", "(", "'title'", ",", "get_string", "(", "'required'", ")", ",", "'required'", ",", "null", ",", "'client'", ")", ";", "if", "(", "!", "empty", "(", "$", "CFG", "->", "formatstringstriptags", ")", ")", "{", "$", "mform", "->", "setType", "(", "'title'", ",", "PARAM_TEXT", ")", ";", "}", "else", "{", "$", "mform", "->", "setType", "(", "'title'", ",", "PARAM_CLEANHTML", ")", ";", "}", "$", "this", "->", "editoroptions", "=", "array", "(", "'noclean'", "=>", "true", ",", "'maxfiles'", "=>", "EDITOR_UNLIMITED_FILES", ",", "'maxbytes'", "=>", "$", "this", "->", "_customdata", "[", "'maxbytes'", "]", ")", ";", "$", "mform", "->", "addElement", "(", "'editor'", ",", "'contents_editor'", ",", "get_string", "(", "'pagecontents'", ",", "'lesson'", ")", ",", "null", ",", "$", "this", "->", "editoroptions", ")", ";", "$", "mform", "->", "setType", "(", "'contents_editor'", ",", "PARAM_RAW", ")", ";", "$", "mform", "->", "addRule", "(", "'contents_editor'", ",", "get_string", "(", "'required'", ")", ",", "'required'", ",", "null", ",", "'client'", ")", ";", "}", "$", "this", "->", "custom_definition", "(", ")", ";", "if", "(", "$", "this", "->", "_customdata", "[", "'edit'", "]", "===", "true", ")", "{", "$", "mform", "->", "addElement", "(", "'hidden'", ",", "'edit'", ",", "1", ")", ";", "$", "mform", "->", "setType", "(", "'edit'", ",", "PARAM_BOOL", ")", ";", "$", "this", "->", "add_action_buttons", "(", "get_string", "(", "'cancel'", ")", ",", "get_string", "(", "'savepage'", ",", "'lesson'", ")", ")", ";", "}", "else", "if", "(", "$", "this", "->", "qtype", "===", "'questiontype'", ")", "{", "$", "this", "->", "add_action_buttons", "(", "get_string", "(", "'cancel'", ")", ",", "get_string", "(", "'addaquestionpage'", ",", "'lesson'", ")", ")", ";", "}", "else", "{", "$", "this", "->", "add_action_buttons", "(", "get_string", "(", "'cancel'", ")", ",", "get_string", "(", "'savepage'", ",", "'lesson'", ")", ")", ";", "}", "}" ]
Add the required basic elements to the form. This method adds the basic elements to the form including title and contents and then calls custom_definition();
[ "Add", "the", "required", "basic", "elements", "to", "the", "form", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L1312-L1365
214,476
moodle/moodle
mod/lesson/locallib.php
lesson.load
public static function load($lessonid) { global $DB; if (!$lesson = $DB->get_record('lesson', array('id' => $lessonid))) { print_error('invalidcoursemodule'); } return new lesson($lesson); }
php
public static function load($lessonid) { global $DB; if (!$lesson = $DB->get_record('lesson', array('id' => $lessonid))) { print_error('invalidcoursemodule'); } return new lesson($lesson); }
[ "public", "static", "function", "load", "(", "$", "lessonid", ")", "{", "global", "$", "DB", ";", "if", "(", "!", "$", "lesson", "=", "$", "DB", "->", "get_record", "(", "'lesson'", ",", "array", "(", "'id'", "=>", "$", "lessonid", ")", ")", ")", "{", "print_error", "(", "'invalidcoursemodule'", ")", ";", "}", "return", "new", "lesson", "(", "$", "lesson", ")", ";", "}" ]
Generates a lesson object from the database given its id @static @param int $lessonid @return lesson
[ "Generates", "a", "lesson", "object", "from", "the", "database", "given", "its", "id" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L1626-L1633
214,477
moodle/moodle
mod/lesson/locallib.php
lesson.delete
public function delete() { global $CFG, $DB; require_once($CFG->libdir.'/gradelib.php'); require_once($CFG->dirroot.'/calendar/lib.php'); $cm = get_coursemodule_from_instance('lesson', $this->properties->id, $this->properties->course); $context = context_module::instance($cm->id); $this->delete_all_overrides(); grade_update('mod/lesson', $this->properties->course, 'mod', 'lesson', $this->properties->id, 0, null, array('deleted'=>1)); // We must delete the module record after we delete the grade item. $DB->delete_records("lesson", array("id"=>$this->properties->id)); $DB->delete_records("lesson_pages", array("lessonid"=>$this->properties->id)); $DB->delete_records("lesson_answers", array("lessonid"=>$this->properties->id)); $DB->delete_records("lesson_attempts", array("lessonid"=>$this->properties->id)); $DB->delete_records("lesson_grades", array("lessonid"=>$this->properties->id)); $DB->delete_records("lesson_timer", array("lessonid"=>$this->properties->id)); $DB->delete_records("lesson_branch", array("lessonid"=>$this->properties->id)); if ($events = $DB->get_records('event', array("modulename"=>'lesson', "instance"=>$this->properties->id))) { $coursecontext = context_course::instance($cm->course); foreach($events as $event) { $event->context = $coursecontext; $event = calendar_event::load($event); $event->delete(); } } // Delete files associated with this module. $fs = get_file_storage(); $fs->delete_area_files($context->id); return true; }
php
public function delete() { global $CFG, $DB; require_once($CFG->libdir.'/gradelib.php'); require_once($CFG->dirroot.'/calendar/lib.php'); $cm = get_coursemodule_from_instance('lesson', $this->properties->id, $this->properties->course); $context = context_module::instance($cm->id); $this->delete_all_overrides(); grade_update('mod/lesson', $this->properties->course, 'mod', 'lesson', $this->properties->id, 0, null, array('deleted'=>1)); // We must delete the module record after we delete the grade item. $DB->delete_records("lesson", array("id"=>$this->properties->id)); $DB->delete_records("lesson_pages", array("lessonid"=>$this->properties->id)); $DB->delete_records("lesson_answers", array("lessonid"=>$this->properties->id)); $DB->delete_records("lesson_attempts", array("lessonid"=>$this->properties->id)); $DB->delete_records("lesson_grades", array("lessonid"=>$this->properties->id)); $DB->delete_records("lesson_timer", array("lessonid"=>$this->properties->id)); $DB->delete_records("lesson_branch", array("lessonid"=>$this->properties->id)); if ($events = $DB->get_records('event', array("modulename"=>'lesson', "instance"=>$this->properties->id))) { $coursecontext = context_course::instance($cm->course); foreach($events as $event) { $event->context = $coursecontext; $event = calendar_event::load($event); $event->delete(); } } // Delete files associated with this module. $fs = get_file_storage(); $fs->delete_area_files($context->id); return true; }
[ "public", "function", "delete", "(", ")", "{", "global", "$", "CFG", ",", "$", "DB", ";", "require_once", "(", "$", "CFG", "->", "libdir", ".", "'/gradelib.php'", ")", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/calendar/lib.php'", ")", ";", "$", "cm", "=", "get_coursemodule_from_instance", "(", "'lesson'", ",", "$", "this", "->", "properties", "->", "id", ",", "$", "this", "->", "properties", "->", "course", ")", ";", "$", "context", "=", "context_module", "::", "instance", "(", "$", "cm", "->", "id", ")", ";", "$", "this", "->", "delete_all_overrides", "(", ")", ";", "grade_update", "(", "'mod/lesson'", ",", "$", "this", "->", "properties", "->", "course", ",", "'mod'", ",", "'lesson'", ",", "$", "this", "->", "properties", "->", "id", ",", "0", ",", "null", ",", "array", "(", "'deleted'", "=>", "1", ")", ")", ";", "// We must delete the module record after we delete the grade item.", "$", "DB", "->", "delete_records", "(", "\"lesson\"", ",", "array", "(", "\"id\"", "=>", "$", "this", "->", "properties", "->", "id", ")", ")", ";", "$", "DB", "->", "delete_records", "(", "\"lesson_pages\"", ",", "array", "(", "\"lessonid\"", "=>", "$", "this", "->", "properties", "->", "id", ")", ")", ";", "$", "DB", "->", "delete_records", "(", "\"lesson_answers\"", ",", "array", "(", "\"lessonid\"", "=>", "$", "this", "->", "properties", "->", "id", ")", ")", ";", "$", "DB", "->", "delete_records", "(", "\"lesson_attempts\"", ",", "array", "(", "\"lessonid\"", "=>", "$", "this", "->", "properties", "->", "id", ")", ")", ";", "$", "DB", "->", "delete_records", "(", "\"lesson_grades\"", ",", "array", "(", "\"lessonid\"", "=>", "$", "this", "->", "properties", "->", "id", ")", ")", ";", "$", "DB", "->", "delete_records", "(", "\"lesson_timer\"", ",", "array", "(", "\"lessonid\"", "=>", "$", "this", "->", "properties", "->", "id", ")", ")", ";", "$", "DB", "->", "delete_records", "(", "\"lesson_branch\"", ",", "array", "(", "\"lessonid\"", "=>", "$", "this", "->", "properties", "->", "id", ")", ")", ";", "if", "(", "$", "events", "=", "$", "DB", "->", "get_records", "(", "'event'", ",", "array", "(", "\"modulename\"", "=>", "'lesson'", ",", "\"instance\"", "=>", "$", "this", "->", "properties", "->", "id", ")", ")", ")", "{", "$", "coursecontext", "=", "context_course", "::", "instance", "(", "$", "cm", "->", "course", ")", ";", "foreach", "(", "$", "events", "as", "$", "event", ")", "{", "$", "event", "->", "context", "=", "$", "coursecontext", ";", "$", "event", "=", "calendar_event", "::", "load", "(", "$", "event", ")", ";", "$", "event", "->", "delete", "(", ")", ";", "}", "}", "// Delete files associated with this module.", "$", "fs", "=", "get_file_storage", "(", ")", ";", "$", "fs", "->", "delete_area_files", "(", "$", "context", "->", "id", ")", ";", "return", "true", ";", "}" ]
Deletes this lesson from the database
[ "Deletes", "this", "lesson", "from", "the", "database" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L1638-L1672
214,478
moodle/moodle
mod/lesson/locallib.php
lesson.delete_override
public function delete_override($overrideid) { global $CFG, $DB; require_once($CFG->dirroot . '/calendar/lib.php'); $cm = get_coursemodule_from_instance('lesson', $this->properties->id, $this->properties->course); $override = $DB->get_record('lesson_overrides', array('id' => $overrideid), '*', MUST_EXIST); // Delete the events. $conds = array('modulename' => 'lesson', 'instance' => $this->properties->id); if (isset($override->userid)) { $conds['userid'] = $override->userid; } else { $conds['groupid'] = $override->groupid; } $events = $DB->get_records('event', $conds); foreach ($events as $event) { $eventold = calendar_event::load($event); $eventold->delete(); } $DB->delete_records('lesson_overrides', array('id' => $overrideid)); // Set the common parameters for one of the events we will be triggering. $params = array( 'objectid' => $override->id, 'context' => context_module::instance($cm->id), 'other' => array( 'lessonid' => $override->lessonid ) ); // Determine which override deleted event to fire. if (!empty($override->userid)) { $params['relateduserid'] = $override->userid; $event = \mod_lesson\event\user_override_deleted::create($params); } else { $params['other']['groupid'] = $override->groupid; $event = \mod_lesson\event\group_override_deleted::create($params); } // Trigger the override deleted event. $event->add_record_snapshot('lesson_overrides', $override); $event->trigger(); return true; }
php
public function delete_override($overrideid) { global $CFG, $DB; require_once($CFG->dirroot . '/calendar/lib.php'); $cm = get_coursemodule_from_instance('lesson', $this->properties->id, $this->properties->course); $override = $DB->get_record('lesson_overrides', array('id' => $overrideid), '*', MUST_EXIST); // Delete the events. $conds = array('modulename' => 'lesson', 'instance' => $this->properties->id); if (isset($override->userid)) { $conds['userid'] = $override->userid; } else { $conds['groupid'] = $override->groupid; } $events = $DB->get_records('event', $conds); foreach ($events as $event) { $eventold = calendar_event::load($event); $eventold->delete(); } $DB->delete_records('lesson_overrides', array('id' => $overrideid)); // Set the common parameters for one of the events we will be triggering. $params = array( 'objectid' => $override->id, 'context' => context_module::instance($cm->id), 'other' => array( 'lessonid' => $override->lessonid ) ); // Determine which override deleted event to fire. if (!empty($override->userid)) { $params['relateduserid'] = $override->userid; $event = \mod_lesson\event\user_override_deleted::create($params); } else { $params['other']['groupid'] = $override->groupid; $event = \mod_lesson\event\group_override_deleted::create($params); } // Trigger the override deleted event. $event->add_record_snapshot('lesson_overrides', $override); $event->trigger(); return true; }
[ "public", "function", "delete_override", "(", "$", "overrideid", ")", "{", "global", "$", "CFG", ",", "$", "DB", ";", "require_once", "(", "$", "CFG", "->", "dirroot", ".", "'/calendar/lib.php'", ")", ";", "$", "cm", "=", "get_coursemodule_from_instance", "(", "'lesson'", ",", "$", "this", "->", "properties", "->", "id", ",", "$", "this", "->", "properties", "->", "course", ")", ";", "$", "override", "=", "$", "DB", "->", "get_record", "(", "'lesson_overrides'", ",", "array", "(", "'id'", "=>", "$", "overrideid", ")", ",", "'*'", ",", "MUST_EXIST", ")", ";", "// Delete the events.", "$", "conds", "=", "array", "(", "'modulename'", "=>", "'lesson'", ",", "'instance'", "=>", "$", "this", "->", "properties", "->", "id", ")", ";", "if", "(", "isset", "(", "$", "override", "->", "userid", ")", ")", "{", "$", "conds", "[", "'userid'", "]", "=", "$", "override", "->", "userid", ";", "}", "else", "{", "$", "conds", "[", "'groupid'", "]", "=", "$", "override", "->", "groupid", ";", "}", "$", "events", "=", "$", "DB", "->", "get_records", "(", "'event'", ",", "$", "conds", ")", ";", "foreach", "(", "$", "events", "as", "$", "event", ")", "{", "$", "eventold", "=", "calendar_event", "::", "load", "(", "$", "event", ")", ";", "$", "eventold", "->", "delete", "(", ")", ";", "}", "$", "DB", "->", "delete_records", "(", "'lesson_overrides'", ",", "array", "(", "'id'", "=>", "$", "overrideid", ")", ")", ";", "// Set the common parameters for one of the events we will be triggering.", "$", "params", "=", "array", "(", "'objectid'", "=>", "$", "override", "->", "id", ",", "'context'", "=>", "context_module", "::", "instance", "(", "$", "cm", "->", "id", ")", ",", "'other'", "=>", "array", "(", "'lessonid'", "=>", "$", "override", "->", "lessonid", ")", ")", ";", "// Determine which override deleted event to fire.", "if", "(", "!", "empty", "(", "$", "override", "->", "userid", ")", ")", "{", "$", "params", "[", "'relateduserid'", "]", "=", "$", "override", "->", "userid", ";", "$", "event", "=", "\\", "mod_lesson", "\\", "event", "\\", "user_override_deleted", "::", "create", "(", "$", "params", ")", ";", "}", "else", "{", "$", "params", "[", "'other'", "]", "[", "'groupid'", "]", "=", "$", "override", "->", "groupid", ";", "$", "event", "=", "\\", "mod_lesson", "\\", "event", "\\", "group_override_deleted", "::", "create", "(", "$", "params", ")", ";", "}", "// Trigger the override deleted event.", "$", "event", "->", "add_record_snapshot", "(", "'lesson_overrides'", ",", "$", "override", ")", ";", "$", "event", "->", "trigger", "(", ")", ";", "return", "true", ";", "}" ]
Deletes a lesson override from the database and clears any corresponding calendar events @param int $overrideid The id of the override being deleted @return bool true on success
[ "Deletes", "a", "lesson", "override", "from", "the", "database", "and", "clears", "any", "corresponding", "calendar", "events" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L1680-L1727
214,479
moodle/moodle
mod/lesson/locallib.php
lesson.delete_all_overrides
public function delete_all_overrides() { global $DB; $overrides = $DB->get_records('lesson_overrides', array('lessonid' => $this->properties->id), 'id'); foreach ($overrides as $override) { $this->delete_override($override->id); } }
php
public function delete_all_overrides() { global $DB; $overrides = $DB->get_records('lesson_overrides', array('lessonid' => $this->properties->id), 'id'); foreach ($overrides as $override) { $this->delete_override($override->id); } }
[ "public", "function", "delete_all_overrides", "(", ")", "{", "global", "$", "DB", ";", "$", "overrides", "=", "$", "DB", "->", "get_records", "(", "'lesson_overrides'", ",", "array", "(", "'lessonid'", "=>", "$", "this", "->", "properties", "->", "id", ")", ",", "'id'", ")", ";", "foreach", "(", "$", "overrides", "as", "$", "override", ")", "{", "$", "this", "->", "delete_override", "(", "$", "override", "->", "id", ")", ";", "}", "}" ]
Deletes all lesson overrides from the database and clears any corresponding calendar events
[ "Deletes", "all", "lesson", "overrides", "from", "the", "database", "and", "clears", "any", "corresponding", "calendar", "events" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L1732-L1739
214,480
moodle/moodle
mod/lesson/locallib.php
lesson.get_messages
protected function get_messages() { global $SESSION; $messages = array(); if (!empty($SESSION->lesson_messages) && is_array($SESSION->lesson_messages) && array_key_exists($this->properties->id, $SESSION->lesson_messages)) { $messages = $SESSION->lesson_messages[$this->properties->id]; unset($SESSION->lesson_messages[$this->properties->id]); } return $messages; }
php
protected function get_messages() { global $SESSION; $messages = array(); if (!empty($SESSION->lesson_messages) && is_array($SESSION->lesson_messages) && array_key_exists($this->properties->id, $SESSION->lesson_messages)) { $messages = $SESSION->lesson_messages[$this->properties->id]; unset($SESSION->lesson_messages[$this->properties->id]); } return $messages; }
[ "protected", "function", "get_messages", "(", ")", "{", "global", "$", "SESSION", ";", "$", "messages", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "SESSION", "->", "lesson_messages", ")", "&&", "is_array", "(", "$", "SESSION", "->", "lesson_messages", ")", "&&", "array_key_exists", "(", "$", "this", "->", "properties", "->", "id", ",", "$", "SESSION", "->", "lesson_messages", ")", ")", "{", "$", "messages", "=", "$", "SESSION", "->", "lesson_messages", "[", "$", "this", "->", "properties", "->", "id", "]", ";", "unset", "(", "$", "SESSION", "->", "lesson_messages", "[", "$", "this", "->", "properties", "->", "id", "]", ")", ";", "}", "return", "$", "messages", ";", "}" ]
Fetches messages from the session that may have been set in previous page actions. <code> // Do not call this method directly instead use $lesson->messages; </code> @return array
[ "Fetches", "messages", "from", "the", "session", "that", "may", "have", "been", "set", "in", "previous", "page", "actions", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L1902-L1912
214,481
moodle/moodle
mod/lesson/locallib.php
lesson.get_attempts
public function get_attempts($retries, $correct=false, $pageid=null, $userid=null) { global $USER, $DB; $params = array("lessonid"=>$this->properties->id, "userid"=>$userid, "retry"=>$retries); if ($correct) { $params['correct'] = 1; } if ($pageid !== null) { $params['pageid'] = $pageid; } if ($userid === null) { $params['userid'] = $USER->id; } return $DB->get_records('lesson_attempts', $params, 'timeseen ASC'); }
php
public function get_attempts($retries, $correct=false, $pageid=null, $userid=null) { global $USER, $DB; $params = array("lessonid"=>$this->properties->id, "userid"=>$userid, "retry"=>$retries); if ($correct) { $params['correct'] = 1; } if ($pageid !== null) { $params['pageid'] = $pageid; } if ($userid === null) { $params['userid'] = $USER->id; } return $DB->get_records('lesson_attempts', $params, 'timeseen ASC'); }
[ "public", "function", "get_attempts", "(", "$", "retries", ",", "$", "correct", "=", "false", ",", "$", "pageid", "=", "null", ",", "$", "userid", "=", "null", ")", "{", "global", "$", "USER", ",", "$", "DB", ";", "$", "params", "=", "array", "(", "\"lessonid\"", "=>", "$", "this", "->", "properties", "->", "id", ",", "\"userid\"", "=>", "$", "userid", ",", "\"retry\"", "=>", "$", "retries", ")", ";", "if", "(", "$", "correct", ")", "{", "$", "params", "[", "'correct'", "]", "=", "1", ";", "}", "if", "(", "$", "pageid", "!==", "null", ")", "{", "$", "params", "[", "'pageid'", "]", "=", "$", "pageid", ";", "}", "if", "(", "$", "userid", "===", "null", ")", "{", "$", "params", "[", "'userid'", "]", "=", "$", "USER", "->", "id", ";", "}", "return", "$", "DB", "->", "get_records", "(", "'lesson_attempts'", ",", "$", "params", ",", "'timeseen ASC'", ")", ";", "}" ]
Get all of the attempts for the current user. @param int $retries @param bool $correct Optional: only fetch correct attempts @param int $pageid Optional: only fetch attempts at the given page @param int $userid Optional: defaults to the current user if not set @return array|false
[ "Get", "all", "of", "the", "attempts", "for", "the", "current", "user", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L1923-L1936
214,482
moodle/moodle
mod/lesson/locallib.php
lesson.get_firstpage
protected function get_firstpage() { $pages = $this->load_all_pages(); if (count($pages) > 0) { foreach ($pages as $page) { if ((int)$page->prevpageid === 0) { return $page; } } } return false; }
php
protected function get_firstpage() { $pages = $this->load_all_pages(); if (count($pages) > 0) { foreach ($pages as $page) { if ((int)$page->prevpageid === 0) { return $page; } } } return false; }
[ "protected", "function", "get_firstpage", "(", ")", "{", "$", "pages", "=", "$", "this", "->", "load_all_pages", "(", ")", ";", "if", "(", "count", "(", "$", "pages", ")", ">", "0", ")", "{", "foreach", "(", "$", "pages", "as", "$", "page", ")", "{", "if", "(", "(", "int", ")", "$", "page", "->", "prevpageid", "===", "0", ")", "{", "return", "$", "page", ";", "}", "}", "}", "return", "false", ";", "}" ]
Returns the first page for the lesson or false if there isn't one. This method should be called via the magic method __get(); <code> $firstpage = $lesson->firstpage; </code> @return lesson_page|bool Returns the lesson_page specialised object or false
[ "Returns", "the", "first", "page", "for", "the", "lesson", "or", "false", "if", "there", "isn", "t", "one", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L1969-L1979
214,483
moodle/moodle
mod/lesson/locallib.php
lesson.get_lastpage
protected function get_lastpage() { $pages = $this->load_all_pages(); if (count($pages) > 0) { foreach ($pages as $page) { if ((int)$page->nextpageid === 0) { return $page; } } } return false; }
php
protected function get_lastpage() { $pages = $this->load_all_pages(); if (count($pages) > 0) { foreach ($pages as $page) { if ((int)$page->nextpageid === 0) { return $page; } } } return false; }
[ "protected", "function", "get_lastpage", "(", ")", "{", "$", "pages", "=", "$", "this", "->", "load_all_pages", "(", ")", ";", "if", "(", "count", "(", "$", "pages", ")", ">", "0", ")", "{", "foreach", "(", "$", "pages", "as", "$", "page", ")", "{", "if", "(", "(", "int", ")", "$", "page", "->", "nextpageid", "===", "0", ")", "{", "return", "$", "page", ";", "}", "}", "}", "return", "false", ";", "}" ]
Returns the last page for the lesson or false if there isn't one. This method should be called via the magic method __get(); <code> $lastpage = $lesson->lastpage; </code> @return lesson_page|bool Returns the lesson_page specialised object or false
[ "Returns", "the", "last", "page", "for", "the", "lesson", "or", "false", "if", "there", "isn", "t", "one", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L1991-L2001
214,484
moodle/moodle
mod/lesson/locallib.php
lesson.get_next_page
public function get_next_page($nextpageid) { global $USER, $DB; $allpages = $this->load_all_pages(); if ($this->properties->nextpagedefault) { // in Flash Card mode...first get number of retakes $nretakes = $DB->count_records("lesson_grades", array("lessonid" => $this->properties->id, "userid" => $USER->id)); shuffle($allpages); $found = false; if ($this->properties->nextpagedefault == LESSON_UNSEENPAGE) { foreach ($allpages as $nextpage) { if (!$DB->count_records("lesson_attempts", array("pageid" => $nextpage->id, "userid" => $USER->id, "retry" => $nretakes))) { $found = true; break; } } } elseif ($this->properties->nextpagedefault == LESSON_UNANSWEREDPAGE) { foreach ($allpages as $nextpage) { if (!$DB->count_records("lesson_attempts", array('pageid' => $nextpage->id, 'userid' => $USER->id, 'correct' => 1, 'retry' => $nretakes))) { $found = true; break; } } } if ($found) { if ($this->properties->maxpages) { // check number of pages viewed (in the lesson) if ($DB->count_records("lesson_attempts", array("lessonid" => $this->properties->id, "userid" => $USER->id, "retry" => $nretakes)) >= $this->properties->maxpages) { return LESSON_EOL; } } return $nextpage->id; } } // In a normal lesson mode foreach ($allpages as $nextpage) { if ((int)$nextpage->id === (int)$nextpageid) { return $nextpage->id; } } return LESSON_EOL; }
php
public function get_next_page($nextpageid) { global $USER, $DB; $allpages = $this->load_all_pages(); if ($this->properties->nextpagedefault) { // in Flash Card mode...first get number of retakes $nretakes = $DB->count_records("lesson_grades", array("lessonid" => $this->properties->id, "userid" => $USER->id)); shuffle($allpages); $found = false; if ($this->properties->nextpagedefault == LESSON_UNSEENPAGE) { foreach ($allpages as $nextpage) { if (!$DB->count_records("lesson_attempts", array("pageid" => $nextpage->id, "userid" => $USER->id, "retry" => $nretakes))) { $found = true; break; } } } elseif ($this->properties->nextpagedefault == LESSON_UNANSWEREDPAGE) { foreach ($allpages as $nextpage) { if (!$DB->count_records("lesson_attempts", array('pageid' => $nextpage->id, 'userid' => $USER->id, 'correct' => 1, 'retry' => $nretakes))) { $found = true; break; } } } if ($found) { if ($this->properties->maxpages) { // check number of pages viewed (in the lesson) if ($DB->count_records("lesson_attempts", array("lessonid" => $this->properties->id, "userid" => $USER->id, "retry" => $nretakes)) >= $this->properties->maxpages) { return LESSON_EOL; } } return $nextpage->id; } } // In a normal lesson mode foreach ($allpages as $nextpage) { if ((int)$nextpage->id === (int)$nextpageid) { return $nextpage->id; } } return LESSON_EOL; }
[ "public", "function", "get_next_page", "(", "$", "nextpageid", ")", "{", "global", "$", "USER", ",", "$", "DB", ";", "$", "allpages", "=", "$", "this", "->", "load_all_pages", "(", ")", ";", "if", "(", "$", "this", "->", "properties", "->", "nextpagedefault", ")", "{", "// in Flash Card mode...first get number of retakes", "$", "nretakes", "=", "$", "DB", "->", "count_records", "(", "\"lesson_grades\"", ",", "array", "(", "\"lessonid\"", "=>", "$", "this", "->", "properties", "->", "id", ",", "\"userid\"", "=>", "$", "USER", "->", "id", ")", ")", ";", "shuffle", "(", "$", "allpages", ")", ";", "$", "found", "=", "false", ";", "if", "(", "$", "this", "->", "properties", "->", "nextpagedefault", "==", "LESSON_UNSEENPAGE", ")", "{", "foreach", "(", "$", "allpages", "as", "$", "nextpage", ")", "{", "if", "(", "!", "$", "DB", "->", "count_records", "(", "\"lesson_attempts\"", ",", "array", "(", "\"pageid\"", "=>", "$", "nextpage", "->", "id", ",", "\"userid\"", "=>", "$", "USER", "->", "id", ",", "\"retry\"", "=>", "$", "nretakes", ")", ")", ")", "{", "$", "found", "=", "true", ";", "break", ";", "}", "}", "}", "elseif", "(", "$", "this", "->", "properties", "->", "nextpagedefault", "==", "LESSON_UNANSWEREDPAGE", ")", "{", "foreach", "(", "$", "allpages", "as", "$", "nextpage", ")", "{", "if", "(", "!", "$", "DB", "->", "count_records", "(", "\"lesson_attempts\"", ",", "array", "(", "'pageid'", "=>", "$", "nextpage", "->", "id", ",", "'userid'", "=>", "$", "USER", "->", "id", ",", "'correct'", "=>", "1", ",", "'retry'", "=>", "$", "nretakes", ")", ")", ")", "{", "$", "found", "=", "true", ";", "break", ";", "}", "}", "}", "if", "(", "$", "found", ")", "{", "if", "(", "$", "this", "->", "properties", "->", "maxpages", ")", "{", "// check number of pages viewed (in the lesson)", "if", "(", "$", "DB", "->", "count_records", "(", "\"lesson_attempts\"", ",", "array", "(", "\"lessonid\"", "=>", "$", "this", "->", "properties", "->", "id", ",", "\"userid\"", "=>", "$", "USER", "->", "id", ",", "\"retry\"", "=>", "$", "nretakes", ")", ")", ">=", "$", "this", "->", "properties", "->", "maxpages", ")", "{", "return", "LESSON_EOL", ";", "}", "}", "return", "$", "nextpage", "->", "id", ";", "}", "}", "// In a normal lesson mode", "foreach", "(", "$", "allpages", "as", "$", "nextpage", ")", "{", "if", "(", "(", "int", ")", "$", "nextpage", "->", "id", "===", "(", "int", ")", "$", "nextpageid", ")", "{", "return", "$", "nextpage", "->", "id", ";", "}", "}", "return", "LESSON_EOL", ";", "}" ]
Gets the next page id to display after the one that is provided. @param int $nextpageid @return bool
[ "Gets", "the", "next", "page", "id", "to", "display", "after", "the", "one", "that", "is", "provided", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L2051-L2091
214,485
moodle/moodle
mod/lesson/locallib.php
lesson.add_message
public function add_message($message, $class="notifyproblem", $align='center') { global $SESSION; if (empty($SESSION->lesson_messages) || !is_array($SESSION->lesson_messages)) { $SESSION->lesson_messages = array(); $SESSION->lesson_messages[$this->properties->id] = array(); } else if (!array_key_exists($this->properties->id, $SESSION->lesson_messages)) { $SESSION->lesson_messages[$this->properties->id] = array(); } $SESSION->lesson_messages[$this->properties->id][] = array($message, $class, $align); return true; }
php
public function add_message($message, $class="notifyproblem", $align='center') { global $SESSION; if (empty($SESSION->lesson_messages) || !is_array($SESSION->lesson_messages)) { $SESSION->lesson_messages = array(); $SESSION->lesson_messages[$this->properties->id] = array(); } else if (!array_key_exists($this->properties->id, $SESSION->lesson_messages)) { $SESSION->lesson_messages[$this->properties->id] = array(); } $SESSION->lesson_messages[$this->properties->id][] = array($message, $class, $align); return true; }
[ "public", "function", "add_message", "(", "$", "message", ",", "$", "class", "=", "\"notifyproblem\"", ",", "$", "align", "=", "'center'", ")", "{", "global", "$", "SESSION", ";", "if", "(", "empty", "(", "$", "SESSION", "->", "lesson_messages", ")", "||", "!", "is_array", "(", "$", "SESSION", "->", "lesson_messages", ")", ")", "{", "$", "SESSION", "->", "lesson_messages", "=", "array", "(", ")", ";", "$", "SESSION", "->", "lesson_messages", "[", "$", "this", "->", "properties", "->", "id", "]", "=", "array", "(", ")", ";", "}", "else", "if", "(", "!", "array_key_exists", "(", "$", "this", "->", "properties", "->", "id", ",", "$", "SESSION", "->", "lesson_messages", ")", ")", "{", "$", "SESSION", "->", "lesson_messages", "[", "$", "this", "->", "properties", "->", "id", "]", "=", "array", "(", ")", ";", "}", "$", "SESSION", "->", "lesson_messages", "[", "$", "this", "->", "properties", "->", "id", "]", "[", "]", "=", "array", "(", "$", "message", ",", "$", "class", ",", "$", "align", ")", ";", "return", "true", ";", "}" ]
Sets a message against the session for this lesson that will displayed next time the lesson processes messages @param string $message @param string $class @param string $align @return bool
[ "Sets", "a", "message", "against", "the", "session", "for", "this", "lesson", "that", "will", "displayed", "next", "time", "the", "lesson", "processes", "messages" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L2102-L2115
214,486
moodle/moodle
mod/lesson/locallib.php
lesson.is_accessible
public function is_accessible() { $available = $this->properties->available; $deadline = $this->properties->deadline; return (($available == 0 || time() >= $available) && ($deadline == 0 || time() < $deadline)); }
php
public function is_accessible() { $available = $this->properties->available; $deadline = $this->properties->deadline; return (($available == 0 || time() >= $available) && ($deadline == 0 || time() < $deadline)); }
[ "public", "function", "is_accessible", "(", ")", "{", "$", "available", "=", "$", "this", "->", "properties", "->", "available", ";", "$", "deadline", "=", "$", "this", "->", "properties", "->", "deadline", ";", "return", "(", "(", "$", "available", "==", "0", "||", "time", "(", ")", ">=", "$", "available", ")", "&&", "(", "$", "deadline", "==", "0", "||", "time", "(", ")", "<", "$", "deadline", ")", ")", ";", "}" ]
Check if the lesson is accessible at the present time @return bool True if the lesson is accessible, false otherwise
[ "Check", "if", "the", "lesson", "is", "accessible", "at", "the", "present", "time" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L2121-L2125
214,487
moodle/moodle
mod/lesson/locallib.php
lesson.start_timer
public function start_timer() { global $USER, $DB; $cm = get_coursemodule_from_instance('lesson', $this->properties()->id, $this->properties()->course, false, MUST_EXIST); // Trigger lesson started event. $event = \mod_lesson\event\lesson_started::create(array( 'objectid' => $this->properties()->id, 'context' => context_module::instance($cm->id), 'courseid' => $this->properties()->course )); $event->trigger(); $USER->startlesson[$this->properties->id] = true; $timenow = time(); $startlesson = new stdClass; $startlesson->lessonid = $this->properties->id; $startlesson->userid = $USER->id; $startlesson->starttime = $timenow; $startlesson->lessontime = $timenow; if (WS_SERVER) { $startlesson->timemodifiedoffline = $timenow; } $DB->insert_record('lesson_timer', $startlesson); if ($this->properties->timelimit) { $this->add_message(get_string('timelimitwarning', 'lesson', format_time($this->properties->timelimit)), 'center'); } return true; }
php
public function start_timer() { global $USER, $DB; $cm = get_coursemodule_from_instance('lesson', $this->properties()->id, $this->properties()->course, false, MUST_EXIST); // Trigger lesson started event. $event = \mod_lesson\event\lesson_started::create(array( 'objectid' => $this->properties()->id, 'context' => context_module::instance($cm->id), 'courseid' => $this->properties()->course )); $event->trigger(); $USER->startlesson[$this->properties->id] = true; $timenow = time(); $startlesson = new stdClass; $startlesson->lessonid = $this->properties->id; $startlesson->userid = $USER->id; $startlesson->starttime = $timenow; $startlesson->lessontime = $timenow; if (WS_SERVER) { $startlesson->timemodifiedoffline = $timenow; } $DB->insert_record('lesson_timer', $startlesson); if ($this->properties->timelimit) { $this->add_message(get_string('timelimitwarning', 'lesson', format_time($this->properties->timelimit)), 'center'); } return true; }
[ "public", "function", "start_timer", "(", ")", "{", "global", "$", "USER", ",", "$", "DB", ";", "$", "cm", "=", "get_coursemodule_from_instance", "(", "'lesson'", ",", "$", "this", "->", "properties", "(", ")", "->", "id", ",", "$", "this", "->", "properties", "(", ")", "->", "course", ",", "false", ",", "MUST_EXIST", ")", ";", "// Trigger lesson started event.", "$", "event", "=", "\\", "mod_lesson", "\\", "event", "\\", "lesson_started", "::", "create", "(", "array", "(", "'objectid'", "=>", "$", "this", "->", "properties", "(", ")", "->", "id", ",", "'context'", "=>", "context_module", "::", "instance", "(", "$", "cm", "->", "id", ")", ",", "'courseid'", "=>", "$", "this", "->", "properties", "(", ")", "->", "course", ")", ")", ";", "$", "event", "->", "trigger", "(", ")", ";", "$", "USER", "->", "startlesson", "[", "$", "this", "->", "properties", "->", "id", "]", "=", "true", ";", "$", "timenow", "=", "time", "(", ")", ";", "$", "startlesson", "=", "new", "stdClass", ";", "$", "startlesson", "->", "lessonid", "=", "$", "this", "->", "properties", "->", "id", ";", "$", "startlesson", "->", "userid", "=", "$", "USER", "->", "id", ";", "$", "startlesson", "->", "starttime", "=", "$", "timenow", ";", "$", "startlesson", "->", "lessontime", "=", "$", "timenow", ";", "if", "(", "WS_SERVER", ")", "{", "$", "startlesson", "->", "timemodifiedoffline", "=", "$", "timenow", ";", "}", "$", "DB", "->", "insert_record", "(", "'lesson_timer'", ",", "$", "startlesson", ")", ";", "if", "(", "$", "this", "->", "properties", "->", "timelimit", ")", "{", "$", "this", "->", "add_message", "(", "get_string", "(", "'timelimitwarning'", ",", "'lesson'", ",", "format_time", "(", "$", "this", "->", "properties", "->", "timelimit", ")", ")", ",", "'center'", ")", ";", "}", "return", "true", ";", "}" ]
Starts the lesson time for the current user @return bool Returns true
[ "Starts", "the", "lesson", "time", "for", "the", "current", "user" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L2131-L2161
214,488
moodle/moodle
mod/lesson/locallib.php
lesson.update_timer
public function update_timer($restart=false, $continue=false, $endreached =false) { global $USER, $DB; $cm = get_coursemodule_from_instance('lesson', $this->properties->id, $this->properties->course); // clock code // get time information for this user if (!$timer = $this->get_user_timers($USER->id, 'starttime DESC', '*', 0, 1)) { $this->start_timer(); $timer = $this->get_user_timers($USER->id, 'starttime DESC', '*', 0, 1); } $timer = current($timer); // This will get the latest start time record. if ($restart) { if ($continue) { // continue a previous test, need to update the clock (think this option is disabled atm) $timer->starttime = time() - ($timer->lessontime - $timer->starttime); // Trigger lesson resumed event. $event = \mod_lesson\event\lesson_resumed::create(array( 'objectid' => $this->properties->id, 'context' => context_module::instance($cm->id), 'courseid' => $this->properties->course )); $event->trigger(); } else { // starting over, so reset the clock $timer->starttime = time(); // Trigger lesson restarted event. $event = \mod_lesson\event\lesson_restarted::create(array( 'objectid' => $this->properties->id, 'context' => context_module::instance($cm->id), 'courseid' => $this->properties->course )); $event->trigger(); } } $timenow = time(); $timer->lessontime = $timenow; if (WS_SERVER) { $timer->timemodifiedoffline = $timenow; } $timer->completed = $endreached; $DB->update_record('lesson_timer', $timer); // Update completion state. $cm = get_coursemodule_from_instance('lesson', $this->properties()->id, $this->properties()->course, false, MUST_EXIST); $course = get_course($cm->course); $completion = new completion_info($course); if ($completion->is_enabled($cm) && $this->properties()->completiontimespent > 0) { $completion->update_state($cm, COMPLETION_COMPLETE); } return $timer; }
php
public function update_timer($restart=false, $continue=false, $endreached =false) { global $USER, $DB; $cm = get_coursemodule_from_instance('lesson', $this->properties->id, $this->properties->course); // clock code // get time information for this user if (!$timer = $this->get_user_timers($USER->id, 'starttime DESC', '*', 0, 1)) { $this->start_timer(); $timer = $this->get_user_timers($USER->id, 'starttime DESC', '*', 0, 1); } $timer = current($timer); // This will get the latest start time record. if ($restart) { if ($continue) { // continue a previous test, need to update the clock (think this option is disabled atm) $timer->starttime = time() - ($timer->lessontime - $timer->starttime); // Trigger lesson resumed event. $event = \mod_lesson\event\lesson_resumed::create(array( 'objectid' => $this->properties->id, 'context' => context_module::instance($cm->id), 'courseid' => $this->properties->course )); $event->trigger(); } else { // starting over, so reset the clock $timer->starttime = time(); // Trigger lesson restarted event. $event = \mod_lesson\event\lesson_restarted::create(array( 'objectid' => $this->properties->id, 'context' => context_module::instance($cm->id), 'courseid' => $this->properties->course )); $event->trigger(); } } $timenow = time(); $timer->lessontime = $timenow; if (WS_SERVER) { $timer->timemodifiedoffline = $timenow; } $timer->completed = $endreached; $DB->update_record('lesson_timer', $timer); // Update completion state. $cm = get_coursemodule_from_instance('lesson', $this->properties()->id, $this->properties()->course, false, MUST_EXIST); $course = get_course($cm->course); $completion = new completion_info($course); if ($completion->is_enabled($cm) && $this->properties()->completiontimespent > 0) { $completion->update_state($cm, COMPLETION_COMPLETE); } return $timer; }
[ "public", "function", "update_timer", "(", "$", "restart", "=", "false", ",", "$", "continue", "=", "false", ",", "$", "endreached", "=", "false", ")", "{", "global", "$", "USER", ",", "$", "DB", ";", "$", "cm", "=", "get_coursemodule_from_instance", "(", "'lesson'", ",", "$", "this", "->", "properties", "->", "id", ",", "$", "this", "->", "properties", "->", "course", ")", ";", "// clock code", "// get time information for this user", "if", "(", "!", "$", "timer", "=", "$", "this", "->", "get_user_timers", "(", "$", "USER", "->", "id", ",", "'starttime DESC'", ",", "'*'", ",", "0", ",", "1", ")", ")", "{", "$", "this", "->", "start_timer", "(", ")", ";", "$", "timer", "=", "$", "this", "->", "get_user_timers", "(", "$", "USER", "->", "id", ",", "'starttime DESC'", ",", "'*'", ",", "0", ",", "1", ")", ";", "}", "$", "timer", "=", "current", "(", "$", "timer", ")", ";", "// This will get the latest start time record.", "if", "(", "$", "restart", ")", "{", "if", "(", "$", "continue", ")", "{", "// continue a previous test, need to update the clock (think this option is disabled atm)", "$", "timer", "->", "starttime", "=", "time", "(", ")", "-", "(", "$", "timer", "->", "lessontime", "-", "$", "timer", "->", "starttime", ")", ";", "// Trigger lesson resumed event.", "$", "event", "=", "\\", "mod_lesson", "\\", "event", "\\", "lesson_resumed", "::", "create", "(", "array", "(", "'objectid'", "=>", "$", "this", "->", "properties", "->", "id", ",", "'context'", "=>", "context_module", "::", "instance", "(", "$", "cm", "->", "id", ")", ",", "'courseid'", "=>", "$", "this", "->", "properties", "->", "course", ")", ")", ";", "$", "event", "->", "trigger", "(", ")", ";", "}", "else", "{", "// starting over, so reset the clock", "$", "timer", "->", "starttime", "=", "time", "(", ")", ";", "// Trigger lesson restarted event.", "$", "event", "=", "\\", "mod_lesson", "\\", "event", "\\", "lesson_restarted", "::", "create", "(", "array", "(", "'objectid'", "=>", "$", "this", "->", "properties", "->", "id", ",", "'context'", "=>", "context_module", "::", "instance", "(", "$", "cm", "->", "id", ")", ",", "'courseid'", "=>", "$", "this", "->", "properties", "->", "course", ")", ")", ";", "$", "event", "->", "trigger", "(", ")", ";", "}", "}", "$", "timenow", "=", "time", "(", ")", ";", "$", "timer", "->", "lessontime", "=", "$", "timenow", ";", "if", "(", "WS_SERVER", ")", "{", "$", "timer", "->", "timemodifiedoffline", "=", "$", "timenow", ";", "}", "$", "timer", "->", "completed", "=", "$", "endreached", ";", "$", "DB", "->", "update_record", "(", "'lesson_timer'", ",", "$", "timer", ")", ";", "// Update completion state.", "$", "cm", "=", "get_coursemodule_from_instance", "(", "'lesson'", ",", "$", "this", "->", "properties", "(", ")", "->", "id", ",", "$", "this", "->", "properties", "(", ")", "->", "course", ",", "false", ",", "MUST_EXIST", ")", ";", "$", "course", "=", "get_course", "(", "$", "cm", "->", "course", ")", ";", "$", "completion", "=", "new", "completion_info", "(", "$", "course", ")", ";", "if", "(", "$", "completion", "->", "is_enabled", "(", "$", "cm", ")", "&&", "$", "this", "->", "properties", "(", ")", "->", "completiontimespent", ">", "0", ")", "{", "$", "completion", "->", "update_state", "(", "$", "cm", ",", "COMPLETION_COMPLETE", ")", ";", "}", "return", "$", "timer", ";", "}" ]
Updates the timer to the current time and returns the new timer object @param bool $restart If set to true the timer is restarted @param bool $continue If set to true AND $restart=true then the timer will continue from a previous attempt @return stdClass The new timer
[ "Updates", "the", "timer", "to", "the", "current", "time", "and", "returns", "the", "new", "timer", "object" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L2170-L2228
214,489
moodle/moodle
mod/lesson/locallib.php
lesson.stop_timer
public function stop_timer() { global $USER, $DB; unset($USER->startlesson[$this->properties->id]); $cm = get_coursemodule_from_instance('lesson', $this->properties()->id, $this->properties()->course, false, MUST_EXIST); // Trigger lesson ended event. $event = \mod_lesson\event\lesson_ended::create(array( 'objectid' => $this->properties()->id, 'context' => context_module::instance($cm->id), 'courseid' => $this->properties()->course )); $event->trigger(); return $this->update_timer(false, false, true); }
php
public function stop_timer() { global $USER, $DB; unset($USER->startlesson[$this->properties->id]); $cm = get_coursemodule_from_instance('lesson', $this->properties()->id, $this->properties()->course, false, MUST_EXIST); // Trigger lesson ended event. $event = \mod_lesson\event\lesson_ended::create(array( 'objectid' => $this->properties()->id, 'context' => context_module::instance($cm->id), 'courseid' => $this->properties()->course )); $event->trigger(); return $this->update_timer(false, false, true); }
[ "public", "function", "stop_timer", "(", ")", "{", "global", "$", "USER", ",", "$", "DB", ";", "unset", "(", "$", "USER", "->", "startlesson", "[", "$", "this", "->", "properties", "->", "id", "]", ")", ";", "$", "cm", "=", "get_coursemodule_from_instance", "(", "'lesson'", ",", "$", "this", "->", "properties", "(", ")", "->", "id", ",", "$", "this", "->", "properties", "(", ")", "->", "course", ",", "false", ",", "MUST_EXIST", ")", ";", "// Trigger lesson ended event.", "$", "event", "=", "\\", "mod_lesson", "\\", "event", "\\", "lesson_ended", "::", "create", "(", "array", "(", "'objectid'", "=>", "$", "this", "->", "properties", "(", ")", "->", "id", ",", "'context'", "=>", "context_module", "::", "instance", "(", "$", "cm", "->", "id", ")", ",", "'courseid'", "=>", "$", "this", "->", "properties", "(", ")", "->", "course", ")", ")", ";", "$", "event", "->", "trigger", "(", ")", ";", "return", "$", "this", "->", "update_timer", "(", "false", ",", "false", ",", "true", ")", ";", "}" ]
Updates the timer to the current time then stops it by unsetting the user var @return bool Returns true
[ "Updates", "the", "timer", "to", "the", "current", "time", "then", "stops", "it", "by", "unsetting", "the", "user", "var" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L2234-L2250
214,490
moodle/moodle
mod/lesson/locallib.php
lesson.link_for_activitylink
public function link_for_activitylink() { global $DB; $module = $DB->get_record('course_modules', array('id' => $this->properties->activitylink)); if ($module) { $modname = $DB->get_field('modules', 'name', array('id' => $module->module)); if ($modname) { $instancename = $DB->get_field($modname, 'name', array('id' => $module->instance)); if ($instancename) { return html_writer::link(new moodle_url('/mod/'.$modname.'/view.php', array('id' => $this->properties->activitylink)), get_string('activitylinkname', 'lesson', $instancename), array('class' => 'centerpadded lessonbutton standardbutton p-r-1')); } } } return ''; }
php
public function link_for_activitylink() { global $DB; $module = $DB->get_record('course_modules', array('id' => $this->properties->activitylink)); if ($module) { $modname = $DB->get_field('modules', 'name', array('id' => $module->module)); if ($modname) { $instancename = $DB->get_field($modname, 'name', array('id' => $module->instance)); if ($instancename) { return html_writer::link(new moodle_url('/mod/'.$modname.'/view.php', array('id' => $this->properties->activitylink)), get_string('activitylinkname', 'lesson', $instancename), array('class' => 'centerpadded lessonbutton standardbutton p-r-1')); } } } return ''; }
[ "public", "function", "link_for_activitylink", "(", ")", "{", "global", "$", "DB", ";", "$", "module", "=", "$", "DB", "->", "get_record", "(", "'course_modules'", ",", "array", "(", "'id'", "=>", "$", "this", "->", "properties", "->", "activitylink", ")", ")", ";", "if", "(", "$", "module", ")", "{", "$", "modname", "=", "$", "DB", "->", "get_field", "(", "'modules'", ",", "'name'", ",", "array", "(", "'id'", "=>", "$", "module", "->", "module", ")", ")", ";", "if", "(", "$", "modname", ")", "{", "$", "instancename", "=", "$", "DB", "->", "get_field", "(", "$", "modname", ",", "'name'", ",", "array", "(", "'id'", "=>", "$", "module", "->", "instance", ")", ")", ";", "if", "(", "$", "instancename", ")", "{", "return", "html_writer", "::", "link", "(", "new", "moodle_url", "(", "'/mod/'", ".", "$", "modname", ".", "'/view.php'", ",", "array", "(", "'id'", "=>", "$", "this", "->", "properties", "->", "activitylink", ")", ")", ",", "get_string", "(", "'activitylinkname'", ",", "'lesson'", ",", "$", "instancename", ")", ",", "array", "(", "'class'", "=>", "'centerpadded lessonbutton standardbutton p-r-1'", ")", ")", ";", "}", "}", "}", "return", "''", ";", "}" ]
Returns the link for the related activity @return string
[ "Returns", "the", "link", "for", "the", "related", "activity" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L2265-L2280
214,491
moodle/moodle
mod/lesson/locallib.php
lesson.load_page
public function load_page($pageid) { if (!array_key_exists($pageid, $this->pages)) { $manager = lesson_page_type_manager::get($this); $this->pages[$pageid] = $manager->load_page($pageid, $this); } return $this->pages[$pageid]; }
php
public function load_page($pageid) { if (!array_key_exists($pageid, $this->pages)) { $manager = lesson_page_type_manager::get($this); $this->pages[$pageid] = $manager->load_page($pageid, $this); } return $this->pages[$pageid]; }
[ "public", "function", "load_page", "(", "$", "pageid", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "pageid", ",", "$", "this", "->", "pages", ")", ")", "{", "$", "manager", "=", "lesson_page_type_manager", "::", "get", "(", "$", "this", ")", ";", "$", "this", "->", "pages", "[", "$", "pageid", "]", "=", "$", "manager", "->", "load_page", "(", "$", "pageid", ",", "$", "this", ")", ";", "}", "return", "$", "this", "->", "pages", "[", "$", "pageid", "]", ";", "}" ]
Loads the requested page. This function will return the requested page id as either a specialised lesson_page object OR as a generic lesson_page. If the page has been loaded previously it will be returned from the pages array, otherwise it will be loaded from the database first @param int $pageid @return lesson_page A lesson_page object or an object that extends it
[ "Loads", "the", "requested", "page", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L2293-L2299
214,492
moodle/moodle
mod/lesson/locallib.php
lesson.load_all_pages
public function load_all_pages() { if (!$this->loadedallpages) { $manager = lesson_page_type_manager::get($this); $this->pages = $manager->load_all_pages($this); $this->loadedallpages = true; } return $this->pages; }
php
public function load_all_pages() { if (!$this->loadedallpages) { $manager = lesson_page_type_manager::get($this); $this->pages = $manager->load_all_pages($this); $this->loadedallpages = true; } return $this->pages; }
[ "public", "function", "load_all_pages", "(", ")", "{", "if", "(", "!", "$", "this", "->", "loadedallpages", ")", "{", "$", "manager", "=", "lesson_page_type_manager", "::", "get", "(", "$", "this", ")", ";", "$", "this", "->", "pages", "=", "$", "manager", "->", "load_all_pages", "(", "$", "this", ")", ";", "$", "this", "->", "loadedallpages", "=", "true", ";", "}", "return", "$", "this", "->", "pages", ";", "}" ]
Loads ALL of the pages for this lesson @return array An array containing all pages from this lesson
[ "Loads", "ALL", "of", "the", "pages", "for", "this", "lesson" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L2306-L2313
214,493
moodle/moodle
mod/lesson/locallib.php
lesson.duplicate_page
public function duplicate_page($pageid) { global $PAGE; $cm = get_coursemodule_from_instance('lesson', $this->properties->id, $this->properties->course); $context = context_module::instance($cm->id); // Load the page. $page = $this->load_page($pageid); $properties = $page->properties(); // The create method checks to see if these properties are set and if not sets them to zero, hence the unsetting here. if (!$properties->qoption) { unset($properties->qoption); } if (!$properties->layout) { unset($properties->layout); } if (!$properties->display) { unset($properties->display); } $properties->pageid = $pageid; // Add text and format into the format required to create a new page. $properties->contents_editor = array( 'text' => $properties->contents, 'format' => $properties->contentsformat ); $answers = $page->get_answers(); // Answers need to be added to $properties. $i = 0; $answerids = array(); foreach ($answers as $answer) { // Needs to be rearranged to work with the create function. $properties->answer_editor[$i] = array( 'text' => $answer->answer, 'format' => $answer->answerformat ); $properties->response_editor[$i] = array( 'text' => $answer->response, 'format' => $answer->responseformat ); $answerids[] = $answer->id; $properties->jumpto[$i] = $answer->jumpto; $properties->score[$i] = $answer->score; $i++; } // Create the duplicate page. $newlessonpage = lesson_page::create($properties, $this, $context, $PAGE->course->maxbytes); $newanswers = $newlessonpage->get_answers(); // Copy over the file areas as well. $this->copy_page_files('page_contents', $pageid, $newlessonpage->id, $context->id); $j = 0; foreach ($newanswers as $answer) { if (isset($answer->answer) && strpos($answer->answer, '@@PLUGINFILE@@') !== false) { $this->copy_page_files('page_answers', $answerids[$j], $answer->id, $context->id); } if (isset($answer->response) && !is_array($answer->response) && strpos($answer->response, '@@PLUGINFILE@@') !== false) { $this->copy_page_files('page_responses', $answerids[$j], $answer->id, $context->id); } $j++; } }
php
public function duplicate_page($pageid) { global $PAGE; $cm = get_coursemodule_from_instance('lesson', $this->properties->id, $this->properties->course); $context = context_module::instance($cm->id); // Load the page. $page = $this->load_page($pageid); $properties = $page->properties(); // The create method checks to see if these properties are set and if not sets them to zero, hence the unsetting here. if (!$properties->qoption) { unset($properties->qoption); } if (!$properties->layout) { unset($properties->layout); } if (!$properties->display) { unset($properties->display); } $properties->pageid = $pageid; // Add text and format into the format required to create a new page. $properties->contents_editor = array( 'text' => $properties->contents, 'format' => $properties->contentsformat ); $answers = $page->get_answers(); // Answers need to be added to $properties. $i = 0; $answerids = array(); foreach ($answers as $answer) { // Needs to be rearranged to work with the create function. $properties->answer_editor[$i] = array( 'text' => $answer->answer, 'format' => $answer->answerformat ); $properties->response_editor[$i] = array( 'text' => $answer->response, 'format' => $answer->responseformat ); $answerids[] = $answer->id; $properties->jumpto[$i] = $answer->jumpto; $properties->score[$i] = $answer->score; $i++; } // Create the duplicate page. $newlessonpage = lesson_page::create($properties, $this, $context, $PAGE->course->maxbytes); $newanswers = $newlessonpage->get_answers(); // Copy over the file areas as well. $this->copy_page_files('page_contents', $pageid, $newlessonpage->id, $context->id); $j = 0; foreach ($newanswers as $answer) { if (isset($answer->answer) && strpos($answer->answer, '@@PLUGINFILE@@') !== false) { $this->copy_page_files('page_answers', $answerids[$j], $answer->id, $context->id); } if (isset($answer->response) && !is_array($answer->response) && strpos($answer->response, '@@PLUGINFILE@@') !== false) { $this->copy_page_files('page_responses', $answerids[$j], $answer->id, $context->id); } $j++; } }
[ "public", "function", "duplicate_page", "(", "$", "pageid", ")", "{", "global", "$", "PAGE", ";", "$", "cm", "=", "get_coursemodule_from_instance", "(", "'lesson'", ",", "$", "this", "->", "properties", "->", "id", ",", "$", "this", "->", "properties", "->", "course", ")", ";", "$", "context", "=", "context_module", "::", "instance", "(", "$", "cm", "->", "id", ")", ";", "// Load the page.", "$", "page", "=", "$", "this", "->", "load_page", "(", "$", "pageid", ")", ";", "$", "properties", "=", "$", "page", "->", "properties", "(", ")", ";", "// The create method checks to see if these properties are set and if not sets them to zero, hence the unsetting here.", "if", "(", "!", "$", "properties", "->", "qoption", ")", "{", "unset", "(", "$", "properties", "->", "qoption", ")", ";", "}", "if", "(", "!", "$", "properties", "->", "layout", ")", "{", "unset", "(", "$", "properties", "->", "layout", ")", ";", "}", "if", "(", "!", "$", "properties", "->", "display", ")", "{", "unset", "(", "$", "properties", "->", "display", ")", ";", "}", "$", "properties", "->", "pageid", "=", "$", "pageid", ";", "// Add text and format into the format required to create a new page.", "$", "properties", "->", "contents_editor", "=", "array", "(", "'text'", "=>", "$", "properties", "->", "contents", ",", "'format'", "=>", "$", "properties", "->", "contentsformat", ")", ";", "$", "answers", "=", "$", "page", "->", "get_answers", "(", ")", ";", "// Answers need to be added to $properties.", "$", "i", "=", "0", ";", "$", "answerids", "=", "array", "(", ")", ";", "foreach", "(", "$", "answers", "as", "$", "answer", ")", "{", "// Needs to be rearranged to work with the create function.", "$", "properties", "->", "answer_editor", "[", "$", "i", "]", "=", "array", "(", "'text'", "=>", "$", "answer", "->", "answer", ",", "'format'", "=>", "$", "answer", "->", "answerformat", ")", ";", "$", "properties", "->", "response_editor", "[", "$", "i", "]", "=", "array", "(", "'text'", "=>", "$", "answer", "->", "response", ",", "'format'", "=>", "$", "answer", "->", "responseformat", ")", ";", "$", "answerids", "[", "]", "=", "$", "answer", "->", "id", ";", "$", "properties", "->", "jumpto", "[", "$", "i", "]", "=", "$", "answer", "->", "jumpto", ";", "$", "properties", "->", "score", "[", "$", "i", "]", "=", "$", "answer", "->", "score", ";", "$", "i", "++", ";", "}", "// Create the duplicate page.", "$", "newlessonpage", "=", "lesson_page", "::", "create", "(", "$", "properties", ",", "$", "this", ",", "$", "context", ",", "$", "PAGE", "->", "course", "->", "maxbytes", ")", ";", "$", "newanswers", "=", "$", "newlessonpage", "->", "get_answers", "(", ")", ";", "// Copy over the file areas as well.", "$", "this", "->", "copy_page_files", "(", "'page_contents'", ",", "$", "pageid", ",", "$", "newlessonpage", "->", "id", ",", "$", "context", "->", "id", ")", ";", "$", "j", "=", "0", ";", "foreach", "(", "$", "newanswers", "as", "$", "answer", ")", "{", "if", "(", "isset", "(", "$", "answer", "->", "answer", ")", "&&", "strpos", "(", "$", "answer", "->", "answer", ",", "'@@PLUGINFILE@@'", ")", "!==", "false", ")", "{", "$", "this", "->", "copy_page_files", "(", "'page_answers'", ",", "$", "answerids", "[", "$", "j", "]", ",", "$", "answer", "->", "id", ",", "$", "context", "->", "id", ")", ";", "}", "if", "(", "isset", "(", "$", "answer", "->", "response", ")", "&&", "!", "is_array", "(", "$", "answer", "->", "response", ")", "&&", "strpos", "(", "$", "answer", "->", "response", ",", "'@@PLUGINFILE@@'", ")", "!==", "false", ")", "{", "$", "this", "->", "copy_page_files", "(", "'page_responses'", ",", "$", "answerids", "[", "$", "j", "]", ",", "$", "answer", "->", "id", ",", "$", "context", "->", "id", ")", ";", "}", "$", "j", "++", ";", "}", "}" ]
Duplicate the lesson page. @param int $pageid Page ID of the page to duplicate. @return void.
[ "Duplicate", "the", "lesson", "page", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L2321-L2382
214,494
moodle/moodle
mod/lesson/locallib.php
lesson.copy_page_files
protected function copy_page_files($filearea, $itemid, $newitemid, $contextid) { $fs = get_file_storage(); $files = $fs->get_area_files($contextid, 'mod_lesson', $filearea, $itemid); foreach ($files as $file) { $fieldupdates = array('itemid' => $newitemid); $fs->create_file_from_storedfile($fieldupdates, $file); } }
php
protected function copy_page_files($filearea, $itemid, $newitemid, $contextid) { $fs = get_file_storage(); $files = $fs->get_area_files($contextid, 'mod_lesson', $filearea, $itemid); foreach ($files as $file) { $fieldupdates = array('itemid' => $newitemid); $fs->create_file_from_storedfile($fieldupdates, $file); } }
[ "protected", "function", "copy_page_files", "(", "$", "filearea", ",", "$", "itemid", ",", "$", "newitemid", ",", "$", "contextid", ")", "{", "$", "fs", "=", "get_file_storage", "(", ")", ";", "$", "files", "=", "$", "fs", "->", "get_area_files", "(", "$", "contextid", ",", "'mod_lesson'", ",", "$", "filearea", ",", "$", "itemid", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "fieldupdates", "=", "array", "(", "'itemid'", "=>", "$", "newitemid", ")", ";", "$", "fs", "->", "create_file_from_storedfile", "(", "$", "fieldupdates", ",", "$", "file", ")", ";", "}", "}" ]
Copy the files from one page to another. @param string $filearea Area that the files are stored. @param int $itemid Item ID. @param int $newitemid The item ID for the new page. @param int $contextid Context ID for this page. @return void.
[ "Copy", "the", "files", "from", "one", "page", "to", "another", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L2393-L2400
214,495
moodle/moodle
mod/lesson/locallib.php
lesson.jumpto_is_correct
public function jumpto_is_correct($pageid, $jumpto) { global $DB; // first test the special values if (!$jumpto) { // same page return false; } elseif ($jumpto == LESSON_NEXTPAGE) { return true; } elseif ($jumpto == LESSON_UNSEENBRANCHPAGE) { return true; } elseif ($jumpto == LESSON_RANDOMPAGE) { return true; } elseif ($jumpto == LESSON_CLUSTERJUMP) { return true; } elseif ($jumpto == LESSON_EOL) { return true; } $pages = $this->load_all_pages(); $apageid = $pages[$pageid]->nextpageid; while ($apageid != 0) { if ($jumpto == $apageid) { return true; } $apageid = $pages[$apageid]->nextpageid; } return false; }
php
public function jumpto_is_correct($pageid, $jumpto) { global $DB; // first test the special values if (!$jumpto) { // same page return false; } elseif ($jumpto == LESSON_NEXTPAGE) { return true; } elseif ($jumpto == LESSON_UNSEENBRANCHPAGE) { return true; } elseif ($jumpto == LESSON_RANDOMPAGE) { return true; } elseif ($jumpto == LESSON_CLUSTERJUMP) { return true; } elseif ($jumpto == LESSON_EOL) { return true; } $pages = $this->load_all_pages(); $apageid = $pages[$pageid]->nextpageid; while ($apageid != 0) { if ($jumpto == $apageid) { return true; } $apageid = $pages[$apageid]->nextpageid; } return false; }
[ "public", "function", "jumpto_is_correct", "(", "$", "pageid", ",", "$", "jumpto", ")", "{", "global", "$", "DB", ";", "// first test the special values", "if", "(", "!", "$", "jumpto", ")", "{", "// same page", "return", "false", ";", "}", "elseif", "(", "$", "jumpto", "==", "LESSON_NEXTPAGE", ")", "{", "return", "true", ";", "}", "elseif", "(", "$", "jumpto", "==", "LESSON_UNSEENBRANCHPAGE", ")", "{", "return", "true", ";", "}", "elseif", "(", "$", "jumpto", "==", "LESSON_RANDOMPAGE", ")", "{", "return", "true", ";", "}", "elseif", "(", "$", "jumpto", "==", "LESSON_CLUSTERJUMP", ")", "{", "return", "true", ";", "}", "elseif", "(", "$", "jumpto", "==", "LESSON_EOL", ")", "{", "return", "true", ";", "}", "$", "pages", "=", "$", "this", "->", "load_all_pages", "(", ")", ";", "$", "apageid", "=", "$", "pages", "[", "$", "pageid", "]", "->", "nextpageid", ";", "while", "(", "$", "apageid", "!=", "0", ")", "{", "if", "(", "$", "jumpto", "==", "$", "apageid", ")", "{", "return", "true", ";", "}", "$", "apageid", "=", "$", "pages", "[", "$", "apageid", "]", "->", "nextpageid", ";", "}", "return", "false", ";", "}" ]
Determines if a jumpto value is correct or not. returns true if jumpto page is (logically) after the pageid page or if the jumpto value is a special value. Returns false in all other cases. @param int $pageid Id of the page from which you are jumping from. @param int $jumpto The jumpto number. @return boolean True or false after a series of tests.
[ "Determines", "if", "a", "jumpto", "value", "is", "correct", "or", "not", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L2412-L2440
214,496
moodle/moodle
mod/lesson/locallib.php
lesson.time_remaining
public function time_remaining($starttime) { $timeleft = $starttime + $this->properties->timelimit - time(); $hours = floor($timeleft/3600); $timeleft = $timeleft - ($hours * 3600); $minutes = floor($timeleft/60); $secs = $timeleft - ($minutes * 60); if ($minutes < 10) { $minutes = "0$minutes"; } if ($secs < 10) { $secs = "0$secs"; } $output = array(); $output[] = $hours; $output[] = $minutes; $output[] = $secs; $output = implode(':', $output); return $output; }
php
public function time_remaining($starttime) { $timeleft = $starttime + $this->properties->timelimit - time(); $hours = floor($timeleft/3600); $timeleft = $timeleft - ($hours * 3600); $minutes = floor($timeleft/60); $secs = $timeleft - ($minutes * 60); if ($minutes < 10) { $minutes = "0$minutes"; } if ($secs < 10) { $secs = "0$secs"; } $output = array(); $output[] = $hours; $output[] = $minutes; $output[] = $secs; $output = implode(':', $output); return $output; }
[ "public", "function", "time_remaining", "(", "$", "starttime", ")", "{", "$", "timeleft", "=", "$", "starttime", "+", "$", "this", "->", "properties", "->", "timelimit", "-", "time", "(", ")", ";", "$", "hours", "=", "floor", "(", "$", "timeleft", "/", "3600", ")", ";", "$", "timeleft", "=", "$", "timeleft", "-", "(", "$", "hours", "*", "3600", ")", ";", "$", "minutes", "=", "floor", "(", "$", "timeleft", "/", "60", ")", ";", "$", "secs", "=", "$", "timeleft", "-", "(", "$", "minutes", "*", "60", ")", ";", "if", "(", "$", "minutes", "<", "10", ")", "{", "$", "minutes", "=", "\"0$minutes\"", ";", "}", "if", "(", "$", "secs", "<", "10", ")", "{", "$", "secs", "=", "\"0$secs\"", ";", "}", "$", "output", "=", "array", "(", ")", ";", "$", "output", "[", "]", "=", "$", "hours", ";", "$", "output", "[", "]", "=", "$", "minutes", ";", "$", "output", "[", "]", "=", "$", "secs", ";", "$", "output", "=", "implode", "(", "':'", ",", "$", "output", ")", ";", "return", "$", "output", ";", "}" ]
Returns the time a user has remaining on this lesson @param int $starttime Starttime timestamp @return string
[ "Returns", "the", "time", "a", "user", "has", "remaining", "on", "this", "lesson" ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L2447-L2466
214,497
moodle/moodle
mod/lesson/locallib.php
lesson.resort_pages
public function resort_pages($pageid, $after) { global $CFG; $cm = get_coursemodule_from_instance('lesson', $this->properties->id, $this->properties->course); $context = context_module::instance($cm->id); $pages = $this->load_all_pages(); if (!array_key_exists($pageid, $pages) || ($after!=0 && !array_key_exists($after, $pages))) { print_error('cannotfindpages', 'lesson', "$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id"); } $pagetomove = clone($pages[$pageid]); unset($pages[$pageid]); $pageids = array(); if ($after === 0) { $pageids['p0'] = $pageid; } foreach ($pages as $page) { $pageids[] = $page->id; if ($page->id == $after) { $pageids[] = $pageid; } } $pageidsref = $pageids; reset($pageidsref); $prev = 0; $next = next($pageidsref); foreach ($pageids as $pid) { if ($pid === $pageid) { $page = $pagetomove; } else { $page = $pages[$pid]; } if ($page->prevpageid != $prev || $page->nextpageid != $next) { $page->move($next, $prev); if ($pid === $pageid) { // We will trigger an event. $pageupdated = array('next' => $next, 'prev' => $prev); } } $prev = $page->id; $next = next($pageidsref); if (!$next) { $next = 0; } } // Trigger an event: page moved. if (!empty($pageupdated)) { $eventparams = array( 'context' => $context, 'objectid' => $pageid, 'other' => array( 'pagetype' => $page->get_typestring(), 'prevpageid' => $pageupdated['prev'], 'nextpageid' => $pageupdated['next'] ) ); $event = \mod_lesson\event\page_moved::create($eventparams); $event->trigger(); } }
php
public function resort_pages($pageid, $after) { global $CFG; $cm = get_coursemodule_from_instance('lesson', $this->properties->id, $this->properties->course); $context = context_module::instance($cm->id); $pages = $this->load_all_pages(); if (!array_key_exists($pageid, $pages) || ($after!=0 && !array_key_exists($after, $pages))) { print_error('cannotfindpages', 'lesson', "$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id"); } $pagetomove = clone($pages[$pageid]); unset($pages[$pageid]); $pageids = array(); if ($after === 0) { $pageids['p0'] = $pageid; } foreach ($pages as $page) { $pageids[] = $page->id; if ($page->id == $after) { $pageids[] = $pageid; } } $pageidsref = $pageids; reset($pageidsref); $prev = 0; $next = next($pageidsref); foreach ($pageids as $pid) { if ($pid === $pageid) { $page = $pagetomove; } else { $page = $pages[$pid]; } if ($page->prevpageid != $prev || $page->nextpageid != $next) { $page->move($next, $prev); if ($pid === $pageid) { // We will trigger an event. $pageupdated = array('next' => $next, 'prev' => $prev); } } $prev = $page->id; $next = next($pageidsref); if (!$next) { $next = 0; } } // Trigger an event: page moved. if (!empty($pageupdated)) { $eventparams = array( 'context' => $context, 'objectid' => $pageid, 'other' => array( 'pagetype' => $page->get_typestring(), 'prevpageid' => $pageupdated['prev'], 'nextpageid' => $pageupdated['next'] ) ); $event = \mod_lesson\event\page_moved::create($eventparams); $event->trigger(); } }
[ "public", "function", "resort_pages", "(", "$", "pageid", ",", "$", "after", ")", "{", "global", "$", "CFG", ";", "$", "cm", "=", "get_coursemodule_from_instance", "(", "'lesson'", ",", "$", "this", "->", "properties", "->", "id", ",", "$", "this", "->", "properties", "->", "course", ")", ";", "$", "context", "=", "context_module", "::", "instance", "(", "$", "cm", "->", "id", ")", ";", "$", "pages", "=", "$", "this", "->", "load_all_pages", "(", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "pageid", ",", "$", "pages", ")", "||", "(", "$", "after", "!=", "0", "&&", "!", "array_key_exists", "(", "$", "after", ",", "$", "pages", ")", ")", ")", "{", "print_error", "(", "'cannotfindpages'", ",", "'lesson'", ",", "\"$CFG->wwwroot/mod/lesson/edit.php?id=$cm->id\"", ")", ";", "}", "$", "pagetomove", "=", "clone", "(", "$", "pages", "[", "$", "pageid", "]", ")", ";", "unset", "(", "$", "pages", "[", "$", "pageid", "]", ")", ";", "$", "pageids", "=", "array", "(", ")", ";", "if", "(", "$", "after", "===", "0", ")", "{", "$", "pageids", "[", "'p0'", "]", "=", "$", "pageid", ";", "}", "foreach", "(", "$", "pages", "as", "$", "page", ")", "{", "$", "pageids", "[", "]", "=", "$", "page", "->", "id", ";", "if", "(", "$", "page", "->", "id", "==", "$", "after", ")", "{", "$", "pageids", "[", "]", "=", "$", "pageid", ";", "}", "}", "$", "pageidsref", "=", "$", "pageids", ";", "reset", "(", "$", "pageidsref", ")", ";", "$", "prev", "=", "0", ";", "$", "next", "=", "next", "(", "$", "pageidsref", ")", ";", "foreach", "(", "$", "pageids", "as", "$", "pid", ")", "{", "if", "(", "$", "pid", "===", "$", "pageid", ")", "{", "$", "page", "=", "$", "pagetomove", ";", "}", "else", "{", "$", "page", "=", "$", "pages", "[", "$", "pid", "]", ";", "}", "if", "(", "$", "page", "->", "prevpageid", "!=", "$", "prev", "||", "$", "page", "->", "nextpageid", "!=", "$", "next", ")", "{", "$", "page", "->", "move", "(", "$", "next", ",", "$", "prev", ")", ";", "if", "(", "$", "pid", "===", "$", "pageid", ")", "{", "// We will trigger an event.", "$", "pageupdated", "=", "array", "(", "'next'", "=>", "$", "next", ",", "'prev'", "=>", "$", "prev", ")", ";", "}", "}", "$", "prev", "=", "$", "page", "->", "id", ";", "$", "next", "=", "next", "(", "$", "pageidsref", ")", ";", "if", "(", "!", "$", "next", ")", "{", "$", "next", "=", "0", ";", "}", "}", "// Trigger an event: page moved.", "if", "(", "!", "empty", "(", "$", "pageupdated", ")", ")", "{", "$", "eventparams", "=", "array", "(", "'context'", "=>", "$", "context", ",", "'objectid'", "=>", "$", "pageid", ",", "'other'", "=>", "array", "(", "'pagetype'", "=>", "$", "page", "->", "get_typestring", "(", ")", ",", "'prevpageid'", "=>", "$", "pageupdated", "[", "'prev'", "]", ",", "'nextpageid'", "=>", "$", "pageupdated", "[", "'next'", "]", ")", ")", ";", "$", "event", "=", "\\", "mod_lesson", "\\", "event", "\\", "page_moved", "::", "create", "(", "$", "eventparams", ")", ";", "$", "event", "->", "trigger", "(", ")", ";", "}", "}" ]
Move a page resorting all other pages. @param int $pageid @param int $after @return void
[ "Move", "a", "page", "resorting", "all", "other", "pages", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L2654-L2721
214,498
moodle/moodle
mod/lesson/locallib.php
lesson.get_context
public function get_context() { if ($this->context == null) { $this->context = context_module::instance($this->get_cm()->id); } return $this->context; }
php
public function get_context() { if ($this->context == null) { $this->context = context_module::instance($this->get_cm()->id); } return $this->context; }
[ "public", "function", "get_context", "(", ")", "{", "if", "(", "$", "this", "->", "context", "==", "null", ")", "{", "$", "this", "->", "context", "=", "context_module", "::", "instance", "(", "$", "this", "->", "get_cm", "(", ")", "->", "id", ")", ";", "}", "return", "$", "this", "->", "context", ";", "}" ]
Return the lesson context object. @return stdClass context @since Moodle 3.3
[ "Return", "the", "lesson", "context", "object", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L2729-L2734
214,499
moodle/moodle
mod/lesson/locallib.php
lesson.get_cm
public function get_cm() { if ($this->cm == null) { $this->cm = get_coursemodule_from_instance('lesson', $this->properties->id); } return $this->cm; }
php
public function get_cm() { if ($this->cm == null) { $this->cm = get_coursemodule_from_instance('lesson', $this->properties->id); } return $this->cm; }
[ "public", "function", "get_cm", "(", ")", "{", "if", "(", "$", "this", "->", "cm", "==", "null", ")", "{", "$", "this", "->", "cm", "=", "get_coursemodule_from_instance", "(", "'lesson'", ",", "$", "this", "->", "properties", "->", "id", ")", ";", "}", "return", "$", "this", "->", "cm", ";", "}" ]
Return the lesson course module object. @return stdClass course module @since Moodle 3.3
[ "Return", "the", "lesson", "course", "module", "object", "." ]
a411b499b98afc9901c24a9466c7e322946a04aa
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lesson/locallib.php#L2752-L2757