idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
34,200
private function message_has_flag ( $ messageid , $ flag ) { $ mailbox = $ this -> get_mailbox ( ) ; $ query = new \ Horde_Imap_Client_Fetch_Query ( ) ; $ query -> flags ( ) ; $ query -> structure ( ) ; $ messagedata = $ this -> client -> fetch ( $ mailbox , $ query , array ( 'ids' => $ messageid , ) ) -> first ( ) ; $...
Check whether the message has the specified flag
34,201
private function ensure_mailboxes_exist ( ) { $ requiredmailboxes = array ( self :: MAILBOX , $ this -> get_confirmation_folder ( ) , ) ; $ existingmailboxes = $ this -> client -> listMailboxes ( $ requiredmailboxes ) ; foreach ( $ requiredmailboxes as $ mailbox ) { if ( isset ( $ existingmailboxes [ $ mailbox ] ) ) { ...
Ensure that all mailboxes exist .
34,202
private function send_to_handler ( ) { try { mtrace ( " ) ; if ( $ result = $ this -> addressmanager -> handle_message ( $ this -> currentmessagedata ) ) { $ this -> inform_user_of_success ( $ this -> currentmessagedata , $ result ) ; return true ; } } catch ( \ core \ message \ inbound \ processing_failed_exception $ ...
Send the message to the appropriate handler .
34,203
private function handle_verification_failure ( \ Horde_Imap_Client_Ids $ messageids , $ recipient ) { global $ DB , $ USER ; if ( ! $ messageid = $ this -> currentmessagedata -> messageid ) { mtrace ( "- ) ; return false ; } $ this -> client -> copy ( self :: MAILBOX , $ this -> get_confirmation_folder ( ) , array ( 'c...
Handle failure of sender verification .
34,204
private function inform_user_of_error ( $ error ) { global $ USER ; $ userfrom = clone $ USER ; $ userfrom -> customheaders = array ( ) ; if ( $ messageid = $ this -> currentmessagedata -> messageid ) { $ userfrom -> customheaders [ ] = 'In-Reply-To: ' . $ messageid ; } $ messagedata = new \ stdClass ( ) ; $ messagedat...
Inform the identified sender of a processing error .
34,205
private function inform_user_of_success ( \ stdClass $ messagedata , $ handlerresult ) { global $ USER ; $ handler = $ this -> addressmanager -> get_handler ( ) ; $ message = $ handler -> get_success_message ( $ messagedata , $ handlerresult ) ; if ( ! $ message ) { mtrace ( "- ) ; return false ; } $ messageparams = ne...
Inform the identified sender that message processing was successful .
34,206
private function get_reply_subject ( $ subject ) { $ prefix = get_string ( 'replysubjectprefix' , 'tool_messageinbound' ) ; if ( ! ( substr ( $ subject , 0 , strlen ( $ prefix ) ) == $ prefix ) ) { $ subject = $ prefix . ' ' . $ subject ; } return $ subject ; }
Return a formatted subject line for replies .
34,207
protected function display_content ( $ question , $ rowclasses ) { if ( \ core_tag_tag :: is_enabled ( 'core_question' , 'question' ) && question_has_capability_on ( $ question , 'view' ) ) { $ cantag = question_has_capability_on ( $ question , 'tag' ) ; $ qbank = $ this -> qbank ; $ url = new \ moodle_url ( $ qbank ->...
Display tags column content .
34,208
protected function print_tag_icon ( $ id , \ moodle_url $ url , $ cantag , $ contextid ) { global $ OUTPUT ; $ params = [ 'data-action' => 'edittags' , 'data-cantag' => $ cantag , 'data-contextid' => $ contextid , 'data-questionid' => $ id ] ; echo \ html_writer :: link ( $ url , $ OUTPUT -> pix_icon ( 't/tags' , get_s...
Build and print the tags icon .
34,209
public function process_workshopform_rubric_config ( $ data ) { global $ DB ; $ data = ( object ) $ data ; $ data -> workshopid = $ this -> get_new_parentid ( 'workshop' ) ; $ DB -> insert_record ( 'workshopform_rubric_config' , $ data ) ; }
Processes the workshopform_rubric_map element
34,210
public function process_workshopform_rubric_dimension ( $ data ) { global $ DB ; $ data = ( object ) $ data ; $ oldid = $ data -> id ; $ data -> workshopid = $ this -> get_new_parentid ( 'workshop' ) ; $ newitemid = $ DB -> insert_record ( 'workshopform_rubric' , $ data ) ; $ this -> set_mapping ( $ this -> get_namefor...
Processes the workshopform_rubric_dimension element
34,211
public function process_workshopform_rubric_level ( $ data ) { global $ DB ; $ data = ( object ) $ data ; $ data -> dimensionid = $ this -> get_new_parentid ( $ this -> get_namefor ( 'dimension' ) ) ; $ DB -> insert_record ( 'workshopform_rubric_levels' , $ data ) ; }
Processes the workshopform_rubric_level element
34,212
public function allowedRetries ( ) { if ( isset ( $ this -> retryMap [ $ this -> code ] ) ) { return $ this -> retryMap [ $ this -> code ] ; } return 0 ; }
Gets the number of times the associated task can be retried .
34,213
public function getFixesForLevel ( $ level ) { if ( $ level == $ this -> levels [ 0 ] ) { return array ( ) ; } $ activated_levels = array ( ) ; for ( $ i = 1 , $ c = count ( $ this -> levels ) ; $ i < $ c ; $ i ++ ) { $ activated_levels [ ] = $ this -> levels [ $ i ] ; if ( $ this -> levels [ $ i ] == $ level ) { break...
Retrieves all fixes per a level returning fixes for that specific level as well as all levels below it .
34,214
public function consume ( ) { if ( isset ( $ this -> data [ $ this -> position ] ) ) { $ this -> consumed .= $ this -> data [ $ this -> position ] ; return $ this -> data [ $ this -> position ++ ] ; } else { return false ; } }
Consume the next byte
34,215
public function consume_range ( $ chars ) { if ( $ len = strspn ( $ this -> data , $ chars , $ this -> position ) ) { $ data = substr ( $ this -> data , $ this -> position , $ len ) ; $ this -> consumed .= $ data ; $ this -> position += $ len ; return $ data ; } else { return false ; } }
Consume a range of characters
34,216
public function run ( ) { $ options = $ this -> analyser -> get_options ( ) ; $ modeltimelimit = intval ( get_config ( 'analytics' , 'modeltimelimit' ) ) ; if ( $ this -> includetarget ) { $ action = 'training' ; } else { $ action = 'prediction' ; } $ analysables = $ this -> analyser -> get_analysables_iterator ( $ act...
Runs the analysis .
34,217
protected function get_processed_analysables ( ) : array { global $ DB ; $ params = array ( 'modelid' => $ this -> analyser -> get_modelid ( ) ) ; $ params [ 'action' ] = ( $ this -> includetarget ) ? 'training' : 'prediction' ; $ select = 'modelid = :modelid and action = :action' ; return $ DB -> get_records_select ( ...
Get analysables that have been already processed .
34,218
public function process_analysable ( \ core_analytics \ analysable $ analysable ) : array { $ target = call_user_func ( array ( $ this -> analyser -> get_target ( ) , 'instance' ) ) ; $ isvalidresult = $ target -> is_valid_analysable ( $ analysable , $ this -> includetarget ) ; if ( $ isvalidresult !== true ) { $ a = n...
Processes an analysable
34,219
public function calculate ( \ core_analytics \ local \ time_splitting \ base $ timesplitting , array & $ sampleids , array $ ranges , \ core_analytics \ local \ target \ base $ target ) : ? array { $ calculatedtarget = null ; if ( $ this -> includetarget ) { $ calculatedtarget = $ target -> calculate ( $ sampleids , $ ...
Calculates indicators and targets .
34,220
protected function fill_dataset ( \ core_analytics \ local \ time_splitting \ base $ timesplitting , array & $ dataset , ? array $ calculatedtarget = null ) { $ nranges = count ( $ timesplitting -> get_distinct_ranges ( ) ) ; foreach ( $ dataset as $ uniquesampleid => $ unmodified ) { list ( $ analysersampleid , $ rang...
Adds time range indicators and the target to each sample .
34,221
protected function update_analysable_analysed_time ( array $ processedanalysables , int $ analysableid ) { global $ DB ; $ now = time ( ) ; if ( ! empty ( $ processedanalysables [ $ analysableid ] ) ) { $ obj = $ processedanalysables [ $ analysableid ] ; $ obj -> id = $ obj -> primarykey ; unset ( $ obj -> primarykey )...
Updates the analysable analysis time .
34,222
public static function fill_firstanalyses_cache ( int $ modelid , ? int $ analysableid = null ) { global $ DB ; $ primarykey = $ DB -> sql_concat ( $ modelid , "'_'" , 'analysableid' ) ; $ sql = "SELECT $primarykey AS id, MIN(firstanalysis) AS firstanalysis FROM {analytics_used_analysables} aua ...
Fills a cache containing the first time each analysable in the provided model was analysed .
34,223
protected function add_context_metadata ( \ core_analytics \ local \ time_splitting \ base $ timesplitting , array & $ dataset , \ core_analytics \ local \ target \ base $ target ) { $ headers = $ this -> get_headers ( $ timesplitting , $ target ) ; array_unshift ( $ dataset , $ headers ) ; }
Adds dataset context info .
34,224
public function get_headers ( \ core_analytics \ local \ time_splitting \ base $ timesplitting , \ core_analytics \ local \ target \ base $ target ) : array { $ headers = array ( ) ; if ( ! $ this -> includetarget ) { $ headers [ ] = 'sampleid' ; } $ ranges = $ timesplitting -> get_distinct_ranges ( ) ; if ( count ( $ ...
Returns the headers for the csv file based on the indicators and the target .
34,225
protected function filter_out_train_samples ( array & $ sampleids , \ core_analytics \ local \ time_splitting \ base $ timesplitting ) { global $ DB ; $ params = array ( 'modelid' => $ this -> analyser -> get_modelid ( ) , 'analysableid' => $ timesplitting -> get_analysable ( ) -> get_id ( ) , 'timesplitting' => $ time...
Filters out samples that have already been used for training .
34,226
protected function filter_out_prediction_samples_and_ranges ( array & $ sampleids , array & $ ranges , \ core_analytics \ local \ time_splitting \ base $ timesplitting ) { if ( count ( $ ranges ) > 1 ) { throw new \ coding_exception ( '$ranges argument should only contain one range' ) ; } $ rangeindex = key ( $ ranges ...
Filters out samples that have already been used for prediction .
34,227
private function get_predict_samples_record ( \ core_analytics \ local \ time_splitting \ base $ timesplitting , int $ rangeindex ) { global $ DB ; $ params = array ( 'modelid' => $ this -> analyser -> get_modelid ( ) , 'analysableid' => $ timesplitting -> get_analysable ( ) -> get_id ( ) , 'timesplitting' => $ timespl...
Returns a predict samples record .
34,228
protected function save_train_samples ( array $ sampleids , \ core_analytics \ local \ time_splitting \ base $ timesplitting ) { global $ DB ; $ trainingsamples = new \ stdClass ( ) ; $ trainingsamples -> modelid = $ this -> analyser -> get_modelid ( ) ; $ trainingsamples -> analysableid = $ timesplitting -> get_analys...
Saves samples that have just been used for training .
34,229
protected function save_prediction_samples ( array $ sampleids , array $ ranges , \ core_analytics \ local \ time_splitting \ base $ timesplitting , ? \ stdClass $ predictsamplesrecord = null ) { global $ DB ; if ( count ( $ ranges ) > 1 ) { throw new \ coding_exception ( '$ranges argument should only contain one range...
Saves samples that have just been used for prediction .
34,230
private function init_analysable_analysis ( string $ timesplittingid , int $ analysableid ) { $ lockkey = 'modelid:' . $ this -> analyser -> get_modelid ( ) . '-analysableid:' . $ analysableid . '-timesplitting:' . self :: clean_time_splitting_id ( $ timesplittingid ) ; $ lockfactory = \ core \ lock \ lock_config :: ge...
Flags the analysable element as in - analysis and stores a lock for it .
34,231
private static function get_insert_batch_size ( ) : int { global $ DB ; $ dbconfig = $ DB -> export_dbconfig ( ) ; if ( empty ( $ dbconfig ) || empty ( $ dbconfig -> dboptions ) || empty ( $ dbconfig -> dboptions [ 'bulkinsertsize' ] ) ) { return 1000 ; } $ bulkinsert = $ dbconfig -> dboptions [ 'bulkinsertsize' ] ; if...
Returns the batch size used for insert_records .
34,232
protected function deprecated_constructor ( $ course , $ groupid = 0 , $ itemlist = '' , $ export_feedback = false , $ updatedgradesonly = false , $ displaytype = GRADE_DISPLAY_TYPE_REAL , $ decimalpoints = 2 , $ onlyactive = false , $ usercustomfields = false ) { debugging ( 'Many argument constructor for class "grade...
Old deprecated constructor .
34,233
function process_form ( $ formdata ) { global $ USER ; $ this -> columns = array ( ) ; if ( ! empty ( $ formdata -> itemids ) ) { if ( $ formdata -> itemids == '-1' ) { } else { foreach ( $ formdata -> itemids as $ itemid => $ selected ) { if ( $ selected and array_key_exists ( $ itemid , $ this -> grade_items ) ) { $ ...
Init object based using data from form
34,234
public function track_exports ( ) { global $ CFG ; if ( $ expplugins = explode ( "," , $ CFG -> gradeexport ) ) { if ( in_array ( $ this -> plugin , $ expplugins ) ) { return true ; } else { return false ; } } else { return false ; } }
Update exported field in grade_grades table
34,235
public function format_grade ( $ grade , $ gradedisplayconst = null ) { $ displaytype = $ this -> displaytype ; if ( is_array ( $ this -> displaytype ) && ! is_null ( $ gradedisplayconst ) ) { $ displaytype = $ gradedisplayconst ; } $ gradeitem = $ this -> grade_items [ $ grade -> itemid ] ; $ grademax = $ gradeitem ->...
Returns string representation of final grade
34,236
public function format_column_name ( $ grade_item , $ feedback = false , $ gradedisplayname = null ) { $ column = new stdClass ( ) ; if ( $ grade_item -> itemtype == 'mod' ) { $ column -> name = get_string ( 'modulename' , $ grade_item -> itemmodule ) . get_string ( 'labelsep' , 'langconfig' ) . $ grade_item -> get_nam...
Returns the name of column in export
34,237
public function format_feedback ( $ feedback , $ grade = null ) { $ string = $ feedback -> feedback ; if ( ! empty ( $ grade ) ) { $ string = file_rewrite_pluginfile_urls ( $ feedback -> feedback , 'pluginfile.php' , $ grade -> get_context ( ) -> id , GRADE_FILE_COMPONENT , GRADE_FEEDBACK_FILEAREA , $ grade -> id ) ; }...
Returns formatted grade feedback
34,238
public function get_export_params ( ) { $ itemids = array_keys ( $ this -> columns ) ; $ itemidsparam = implode ( ',' , $ itemids ) ; if ( empty ( $ itemidsparam ) ) { $ itemidsparam = '-1' ; } if ( ! is_array ( $ this -> displaytype ) ) { $ displaytypes = $ this -> displaytype ; } else { $ displaytypes = implode ( ','...
Returns array of parameters used by dump . php and export . php .
34,239
public function print_continue ( ) { global $ CFG , $ OUTPUT ; debugging ( 'function grade_export::print_continue is deprecated.' , DEBUG_DEVELOPER ) ; $ params = $ this -> get_export_params ( ) ; echo $ OUTPUT -> heading ( get_string ( 'export' , 'grades' ) ) ; echo $ OUTPUT -> container_start ( 'gradeexportlink' ) ; ...
Either prints a Export box which will redirect the user to the download page or prints the URL for the published data .
34,240
public static function convert_flat_displaytypes_to_array ( $ displaytypes ) { $ types = array ( ) ; if ( is_int ( $ displaytypes ) ) { $ displaytype = clean_param ( $ displaytypes , PARAM_INT ) ; $ display [ $ displaytype ] = 1 ; } else { $ display = array_flip ( explode ( ',' , $ displaytypes ) ) ; } foreach ( $ disp...
Convert the grade display types parameter into the required array to grade exporting class .
34,241
public static function convert_flat_itemids_to_array ( $ itemids ) { $ items = array ( ) ; if ( is_int ( $ itemids ) ) { $ itemid = clean_param ( $ itemids , PARAM_INT ) ; $ items [ $ itemid ] = 1 ; } else { $ items = array_flip ( explode ( ',' , $ itemids ) ) ; foreach ( $ items as $ itemid => $ value ) { $ itemid = c...
Convert the item ids parameter into the required array to grade exporting class .
34,242
public function get_grade_publishing_url ( ) { $ url = $ this -> get_export_url ( ) ; $ output = html_writer :: start_div ( ) ; $ output .= html_writer :: tag ( 'p' , get_string ( 'gradepublishinglink' , 'grades' , html_writer :: link ( $ url , $ url ) ) ) ; $ output .= html_writer :: end_div ( ) ; return $ output ; }
Create the html code of the grade publishing feature .
34,243
public static function export_bulk_export_data ( $ id , $ itemids , $ exportfeedback , $ onlyactive , $ displaytype , $ decimalpoints , $ updatedgradesonly = null , $ separator = null ) { $ formdata = new \ stdClass ( ) ; $ formdata -> id = $ id ; $ formdata -> itemids = self :: convert_flat_itemids_to_array ( $ itemid...
Create a stdClass object from URL parameters to be used by grade_export class .
34,244
public function track ( $ grade_grade ) { if ( empty ( $ grade_grade -> exported ) or empty ( $ grade_grade -> timemodified ) ) { if ( is_null ( $ grade_grade -> finalgrade ) ) { $ status = 'unknown' ; } else { $ status = 'new' ; $ this -> update_list [ ] = $ grade_grade -> id ; } } else if ( $ grade_grade -> exported ...
Track grade export status
34,245
public function getHead ( ) { $ head = $ this -> dom -> getElementsByTagName ( 'head' ) ; if ( $ head -> length ) { return $ head -> item ( 0 ) ; } $ headelt = $ this -> dom -> createElement ( 'head' ) ; $ this -> dom -> documentElement -> insertBefore ( $ headelt , $ this -> dom -> documentElement -> firstChild ) ; re...
Returns the HEAD element or creates one if it doesn t exist .
34,246
public function getBody ( ) { $ body = $ this -> dom -> getElementsByTagName ( 'body' ) ; if ( $ body -> length ) { return $ body -> item ( 0 ) ; } $ bodyelt = $ this -> dom -> createElement ( 'body' ) ; $ this -> dom -> documentElement -> appendChild ( $ bodyelt ) ; return $ bodyelt ; }
Returns the BODY element or creates one if it doesn t exist .
34,247
public function returnHtml ( array $ opts = array ( ) ) { $ curr_charset = $ this -> getCharset ( ) ; if ( strcasecmp ( $ curr_charset , 'US-ASCII' ) === 0 ) { $ curr_charset = 'UTF-8' ; } $ charset = array_key_exists ( 'charset' , $ opts ) ? ( empty ( $ opts [ 'charset' ] ) ? $ curr_charset : $ opts [ 'charset' ] ) : ...
Returns the full HTML text in the original charset .
34,248
public function returnBody ( ) { $ body = $ this -> getBody ( ) ; $ text = '' ; if ( $ body -> hasChildNodes ( ) ) { foreach ( $ body -> childNodes as $ child ) { $ text .= $ this -> dom -> saveXML ( $ child ) ; } } return Horde_String :: convertCharset ( $ text , 'UTF-8' , $ this -> _origCharset ) ; }
Returns the body text in the original charset .
34,249
public function getCharset ( ) { return $ this -> dom -> encoding ? $ this -> dom -> encoding : ( $ this -> _xmlencoding ? 'UTF-8' : $ this -> _origCharset ) ; }
Get the charset of the DOM data .
34,250
protected function _loadHTML ( $ html ) { if ( version_compare ( PHP_VERSION , '5.4' , '>=' ) ) { $ mask = defined ( 'LIBXML_PARSEHUGE' ) ? LIBXML_PARSEHUGE : 0 ; $ mask |= defined ( 'LIBXML_COMPACT' ) ? LIBXML_COMPACT : 0 ; $ this -> dom -> loadHTML ( $ html , $ mask ) ; } else { $ this -> dom -> loadHTML ( $ html ) ;...
Loads the HTML data .
34,251
public function get_emoticons ( $ selectable = false ) { global $ CFG ; $ notselectable = [ 'martin' , 'egg' ] ; if ( empty ( $ CFG -> emoticons ) ) { return array ( ) ; } $ emoticons = $ this -> decode_stored_config ( $ CFG -> emoticons ) ; if ( ! is_array ( $ emoticons ) ) { debugging ( 'Invalid format of emoticons s...
Returns the currently enabled emoticons
34,252
public function prepare_renderable_emoticon ( stdClass $ emoticon , array $ attributes = array ( ) ) { $ stringmanager = get_string_manager ( ) ; if ( $ stringmanager -> string_exists ( $ emoticon -> altidentifier , $ emoticon -> altcomponent ) ) { $ alt = get_string ( $ emoticon -> altidentifier , $ emoticon -> altcom...
Converts emoticon object into renderable pix_emoticon object
34,253
public function default_emoticons ( ) { return array ( $ this -> prepare_emoticon_object ( ":-)" , 's/smiley' , 'smiley' ) , $ this -> prepare_emoticon_object ( ":)" , 's/smiley' , 'smiley' ) , $ this -> prepare_emoticon_object ( ":-D" , 's/biggrin' , 'biggrin' ) , $ this -> prepare_emoticon_object ( ";-)" , 's/wink' ,...
Returns default set of emoticons supported by Moodle
34,254
protected function prepare_emoticon_object ( $ text , $ imagename , $ altidentifier = null , $ altcomponent = 'core_pix' , $ imagecomponent = 'core' ) { return ( object ) array ( 'text' => $ text , 'imagename' => $ imagename , 'imagecomponent' => $ imagecomponent , 'altidentifier' => $ altidentifier , 'altcomponent' =>...
Helper method preparing the stdClass with the emoticon properties
34,255
protected function get_string ( ) { global $ CFG ; if ( $ this -> string === null ) { if ( $ CFG -> debugdeveloper && clean_param ( $ this -> identifier , PARAM_STRINGID ) === '' ) { throw new coding_exception ( 'Invalid string identifier. Most probably some illegal character is part of the string identifier. Please ch...
Processes the string .
34,256
public function out ( $ lang = null ) { if ( $ lang !== null && $ lang != $ this -> lang && ( $ this -> lang == null && $ lang != current_language ( ) ) ) { if ( $ this -> forcedstring ) { debugging ( 'lang_string objects that have been used cannot be printed in another language. (' . $ this -> lang . ' used)' , DEBUG_...
Returns the string
34,257
public static function course_deleted ( \ core \ event \ course_deleted $ event ) { $ rules = rule_manager :: get_rules_by_courseid ( $ event -> courseid , 0 , 0 , false ) ; foreach ( $ rules as $ rule ) { rule_manager :: delete_rule ( $ rule -> id , $ event -> get_context ( ) ) ; } subscription_manager :: remove_all_s...
Course delete event observer . This observer monitors course delete event and when a course is deleted it deletes any rules and subscriptions associated with it so no orphan data is left behind .
34,258
public static function process_event ( \ core \ event \ base $ event ) { if ( ! get_config ( 'tool_monitor' , 'enablemonitor' ) ) { return ; } if ( empty ( self :: $ instance ) ) { self :: $ instance = new static ( ) ; \ core_shutdown_manager :: register_function ( array ( self :: $ instance , 'process_buffer' ) ) ; } ...
The observer monitoring all the events .
34,259
protected function buffer_event ( \ core \ event \ base $ event ) { if ( ! \ tool_monitor \ subscription_manager :: event_has_subscriptions ( $ event -> eventname , $ event -> courseid ) ) { return ; } $ eventdata = $ event -> get_data ( ) ; $ eventobj = new \ stdClass ( ) ; $ eventobj -> eventname = $ eventdata [ 'eve...
Api to buffer events to store to reduce db queries .
34,260
protected function flush ( ) { global $ DB ; $ events = $ this -> buffer ; $ DB -> insert_records ( 'tool_monitor_events' , $ events ) ; $ this -> buffer = array ( ) ; $ this -> count = 0 ; return $ events ; }
Protected method that flushes the buffer of events and writes them to the database .
34,261
public static function user_deleted ( \ core \ event \ user_deleted $ event ) { $ userid = $ event -> objectid ; subscription_manager :: delete_user_subscriptions ( $ userid ) ; }
Observer that monitors user deleted event and delete user subscriptions .
34,262
public static function course_module_deleted ( \ core \ event \ course_module_deleted $ event ) { $ cmid = $ event -> contextinstanceid ; subscription_manager :: delete_cm_subscriptions ( $ cmid ) ; }
Observer that monitors course module deleted event and delete user subscriptions .
34,263
public function extend_settings_navigation ( settings_navigation $ settingsnav , navigation_node $ node = null ) { $ node -> add ( get_string ( 'definemarkingguide' , 'gradingform_guide' ) , $ this -> get_editor_url ( ) , settings_navigation :: TYPE_CUSTOM , null , null , new pix_icon ( 'icon' , '' , 'gradingform_guide...
Extends the module settings navigation with the guide grading settings
34,264
public function extend_navigation ( global_navigation $ navigation , navigation_node $ node = null ) { if ( has_capability ( 'moodle/grade:managegradingforms' , $ this -> get_context ( ) ) ) { return ; } if ( $ this -> is_form_defined ( ) && ( $ options = $ this -> get_options ( ) ) && ! empty ( $ options [ 'alwaysshow...
Extends the module navigation
34,265
public function update_definition ( stdClass $ newdefinition , $ usermodified = null ) { $ this -> update_or_check_guide ( $ newdefinition , $ usermodified , true ) ; if ( isset ( $ newdefinition -> guide [ 'regrade' ] ) && $ newdefinition -> guide [ 'regrade' ] ) { $ this -> mark_for_regrade ( ) ; } }
Saves the guide definition into the database
34,266
public function mark_for_regrade ( ) { global $ DB ; if ( $ this -> has_active_instances ( ) ) { $ conditions = array ( 'definitionid' => $ this -> definition -> id , 'status' => gradingform_instance :: INSTANCE_STATUS_ACTIVE ) ; $ DB -> set_field ( 'grading_instances' , 'status' , gradingform_instance :: INSTANCE_STAT...
Marks all instances filled with this guide with the status INSTANCE_STATUS_NEEDUPDATE
34,267
protected function load_definition ( ) { global $ DB ; $ showdesc = optional_param ( 'showmarkerdesc' , null , PARAM_BOOL ) ; $ showdescstudent = optional_param ( 'showstudentdesc' , null , PARAM_BOOL ) ; if ( $ showdesc !== null ) { set_user_preference ( 'gradingform_guide-showmarkerdesc' , $ showdesc ) ; } if ( $ sho...
Loads the guide form definition if it exists
34,268
protected function delete_plugin_definition ( ) { global $ DB ; $ instances = array_keys ( $ DB -> get_records ( 'grading_instances' , array ( 'definitionid' => $ this -> definition -> id ) , '' , 'id' ) ) ; $ DB -> delete_records_list ( 'gradingform_guide_fillings' , 'instanceid' , $ instances ) ; $ DB -> delete_recor...
Deletes the guide definition and all the associated information
34,269
public function render_grade ( $ page , $ itemid , $ gradinginfo , $ defaultcontent , $ cangrade ) { return $ this -> get_renderer ( $ page ) -> display_instances ( $ this -> get_active_instances ( $ itemid ) , $ defaultcontent , $ cangrade ) ; }
Returns html code to be included in student s feedback .
34,270
public function validate_grading_element ( $ elementvalue ) { $ criteria = $ this -> get_controller ( ) -> get_definition ( ) -> guide_criteria ; if ( ! isset ( $ elementvalue [ 'criteria' ] ) || ! is_array ( $ elementvalue [ 'criteria' ] ) || count ( $ elementvalue [ 'criteria' ] ) < count ( $ criteria ) ) { return fa...
Validates that guide is fully completed and contains valid grade on each criterion
34,271
public function get_guide_filling ( $ force = false ) { global $ DB ; if ( $ this -> guide === null || $ force ) { $ records = $ DB -> get_records ( 'gradingform_guide_fillings' , array ( 'instanceid' => $ this -> get_id ( ) ) ) ; $ this -> guide = array ( 'criteria' => array ( ) ) ; foreach ( $ records as $ record ) {...
Retrieves from DB and returns the data how this guide was filled
34,272
protected static function delete_data ( int $ userid ) { global $ DB ; foreach ( static :: get_records ( $ userid ) as $ record ) { $ DB -> delete_records ( 'message_airnotifier_devices' , [ 'id' => $ record -> id ] ) ; } }
Delete data related to a userid .
34,273
public function getValue ( ) { $ value = parent :: getValue ( ) ; if ( $ value ) { $ value = unformat_float ( $ value , true ) ; } return $ value ; }
Returns the value of the form element .
34,274
public function exportValue ( & $ submitValues , $ assoc = false ) { $ value = $ this -> _findValue ( $ submitValues ) ; if ( null === $ value ) { $ value = $ this -> getValue ( ) ; } else if ( $ value ) { $ value = unformat_float ( $ value , true ) ; } return $ this -> _prepareValue ( $ value , $ assoc ) ; }
Returns a safe element s value .
34,275
private function format_float ( $ value ) { if ( is_numeric ( $ value ) ) { if ( $ value > 0 ) { $ decimals = strlen ( $ value ) - strlen ( floor ( $ value ) ) - 1 ; } else { $ decimals = strlen ( $ value ) - strlen ( ceil ( $ value ) ) - 1 ; } $ value = format_float ( $ value , $ decimals ) ; } return $ value ; }
Given a float prints it nicely . This function reserves the number of decimal places .
34,276
private function writeDefinedNameForNamedRange ( PHPExcel_Shared_XMLWriter $ objWriter = null , PHPExcel_NamedRange $ pNamedRange ) { $ objWriter -> startElement ( 'definedName' ) ; $ objWriter -> writeAttribute ( 'name' , $ pNamedRange -> getName ( ) ) ; if ( $ pNamedRange -> getLocalOnly ( ) ) { $ objWriter -> writeA...
Write Defined Name for named range
34,277
private function writeDefinedNameForAutofilter ( PHPExcel_Shared_XMLWriter $ objWriter = null , PHPExcel_Worksheet $ pSheet = null , $ pSheetId = 0 ) { $ autoFilterRange = $ pSheet -> getAutoFilter ( ) -> getRange ( ) ; if ( ! empty ( $ autoFilterRange ) ) { $ objWriter -> startElement ( 'definedName' ) ; $ objWriter -...
Write Defined Name for autoFilter
34,278
public static function get_popup_notifications_parameters ( ) { return new external_function_parameters ( array ( 'useridto' => new external_value ( PARAM_INT , 'the user id who received the message, 0 for current user' ) , 'newestfirst' => new external_value ( PARAM_BOOL , 'true for ordering by newest first, false for...
Get popup notifications parameters description .
34,279
public static function get_popup_notifications ( $ useridto , $ newestfirst , $ limit , $ offset ) { global $ USER , $ PAGE ; $ params = self :: validate_parameters ( self :: get_popup_notifications_parameters ( ) , array ( 'useridto' => $ useridto , 'newestfirst' => $ newestfirst , 'limit' => $ limit , 'offset' => $ o...
Get notifications function .
34,280
public static function get_popup_notifications_returns ( ) { return new external_single_structure ( array ( 'notifications' => new external_multiple_structure ( new external_single_structure ( array ( 'id' => new external_value ( PARAM_INT , 'Notification id (this is not guaranteed to be unique ...
Get notifications return description .
34,281
public static function get_unread_popup_notification_count ( $ useridto ) { global $ USER ; $ params = self :: validate_parameters ( self :: get_unread_popup_notification_count_parameters ( ) , array ( 'useridto' => $ useridto ) ) ; $ context = context_system :: instance ( ) ; self :: validate_context ( $ context ) ; $...
Get unread notification count function .
34,282
public static function list_templates ( $ component = '' , $ search = '' , $ themename = '' ) { global $ CFG , $ PAGE ; if ( empty ( $ themename ) ) { $ themename = $ PAGE -> theme -> name ; } $ themeconfig = \ theme_config :: load ( $ themename ) ; $ templatedirs = array ( ) ; $ results = array ( ) ; if ( $ component ...
Return a list of details about installed templates .
34,283
protected function add_collection_selector ( $ mform ) { $ tagcolls = core_tag_collection :: get_collections_menu ( false , false , get_string ( 'anycollection' , 'block_tags' ) ) ; if ( count ( $ tagcolls ) <= 1 ) { return ; } $ tagcollssearchable = core_tag_collection :: get_collections_menu ( false , true ) ; $ hasu...
Add the tag collection selector
34,284
public static function create_from_category ( $ category ) { $ event = self :: create ( array ( 'objectid' => $ category -> id , 'context' => \ context_system :: instance ( ) , 'other' => array ( 'name' => $ category -> name , ) ) ) ; $ event -> add_record_snapshot ( 'user_info_category' , $ category ) ; return $ event...
Creates an event from a profile info category .
34,285
public function add_userlist ( userlist_base $ userlist ) : userlist_collection { $ component = $ userlist -> get_component ( ) ; if ( isset ( $ this -> userlists [ $ component ] ) ) { throw new \ moodle_exception ( "A userlist has already been added for the '{$component}' component" ) ; } $ this -> userlists [ $ compo...
Add a userlist to this collection .
34,286
public function get_userlist_for_component ( string $ component ) { if ( isset ( $ this -> userlists [ $ component ] ) ) { return $ this -> userlists [ $ component ] ; } return null ; }
Get the userlist for the specified component .
34,287
public function initialise_for_subq ( $ step , $ variant = null ) { $ newsubqstat = new calculated_for_subquestion ( $ step , $ variant ) ; if ( $ variant === null ) { $ this -> subquestionstats [ $ step -> questionid ] = $ newsubqstat ; } else { $ this -> subquestionstats [ $ step -> questionid ] -> variantstats [ $ v...
Set up a calculated_for_subquestion instance ready to store a randomly selected question s stats .
34,288
public function initialise_for_slot ( $ slot , $ question , $ variant = null ) { $ newqstat = new calculated ( $ question , $ slot , $ variant ) ; if ( $ variant === null ) { $ this -> questionstats [ $ slot ] = $ newqstat ; } else { $ this -> questionstats [ $ slot ] -> variantstats [ $ variant ] = $ newqstat ; } }
Set up a calculated instance ready to store a slot question s stats .
34,289
public function for_subq ( $ questionid , $ variant = null ) { if ( $ variant === null ) { if ( ! isset ( $ this -> subquestionstats [ $ questionid ] ) ) { throw new \ coding_exception ( 'Reference to unknown question id ' . $ questionid ) ; } else { return $ this -> subquestionstats [ $ questionid ] ; } } else { if ( ...
Reference for a item stats instance for a questionid and optional variant no .
34,290
public function for_slot ( $ slot , $ variant = null ) { if ( $ variant === null ) { if ( ! isset ( $ this -> questionstats [ $ slot ] ) ) { throw new \ coding_exception ( 'Reference to unknown slot ' . $ slot ) ; } else { return $ this -> questionstats [ $ slot ] ; } } else { if ( ! isset ( $ this -> questionstats [ $...
Get position stats instance for a slot and optional variant no .
34,291
public function get_last_calculated_time ( $ qubaids ) { global $ DB ; $ timemodified = time ( ) - self :: TIME_TO_CACHE ; return $ DB -> get_field_select ( 'question_statistics' , 'timemodified' , 'hashcode = ? AND timemodified > ?' , array ( $ qubaids -> get_hash_code ( ) , $ timemodified ) , IGNORE_MULTIPLE ) ; }
Find time of non - expired statistics in the database .
34,292
public function cache ( $ qubaids ) { foreach ( $ this -> get_all_slots ( ) as $ slot ) { $ this -> for_slot ( $ slot ) -> cache ( $ qubaids ) ; } foreach ( $ this -> get_all_subq_ids ( ) as $ subqid ) { $ this -> for_subq ( $ subqid ) -> cache ( $ qubaids ) ; } }
Save stats to db .
34,293
public function any_error_messages ( ) { $ errors = array ( ) ; foreach ( $ this -> get_all_slots ( ) as $ slot ) { foreach ( $ this -> for_slot ( $ slot ) -> get_sub_question_ids ( ) as $ subqid ) { if ( $ this -> for_subq ( $ subqid ) -> differentweights ) { $ name = $ this -> for_subq ( $ subqid ) -> question -> nam...
Call after calculations to output any error messages .
34,294
protected function make_new_subq_stat_for ( $ displaynumber , $ slot , $ subqid , $ variant = null ) { $ slotstat = fullclone ( $ this -> for_subq ( $ subqid , $ variant ) ) ; $ slotstat -> question -> number = $ this -> for_slot ( $ slot ) -> question -> number ; $ slotstat -> subqdisplayorder = $ displaynumber ; retu...
We need a new object for display . Sub - question stats can appear more than once in different slots . So we create a clone of the object and then we can set properties on the object that are per slot .
34,295
protected function make_new_calculated_question_summary_stat ( $ randomquestioncalculated , $ subquestionstats ) { $ question = $ randomquestioncalculated -> question ; $ slot = $ randomquestioncalculated -> slot ; $ calculatedsummary = new calculated_question_summary ( $ question , $ slot , $ subquestionstats ) ; retu...
Create a summary calculated object for a calculated question . This is used as a placeholder to indicate that a calculated question has sub questions or variations to show rather than listing each subquestion or variation directly .
34,296
public function get_legacy_data_mapper_for_vault ( $ entity ) { switch ( $ entity ) { case 'forum' : return $ this -> get_forum_data_mapper ( ) ; case 'discussion' : return $ this -> get_discussion_data_mapper ( ) ; case 'post' : return $ this -> get_post_data_mapper ( ) ; case 'author' : return $ this -> get_author_da...
Get the corresponding entity based on the supplied value
34,297
protected function format_metadata ( $ collection , $ component , $ internaldata ) { foreach ( $ collection as $ collectioninfo ) { $ privacyfields = $ collectioninfo -> get_privacy_fields ( ) ; $ fields = '' ; if ( ! empty ( $ privacyfields ) ) { $ fields = array_map ( function ( $ key , $ field ) use ( $ component ) ...
Formats the metadata for use with a template .
34,298
protected function get_full_component_list ( ) { global $ CFG ; $ list = \ core_component :: get_component_list ( ) ; $ list [ 'core' ] [ 'core' ] = "{$CFG->dirroot}/lib" ; $ formattedlist = [ ] ; foreach ( $ list as $ plugintype => $ plugin ) { $ formattedlist [ ] = [ 'plugin_type' => $ plugintype , 'plugins' => array...
Return the full list of components .
34,299
protected function get_contrib_list ( ) { return array_map ( function ( $ plugins ) { return array_filter ( $ plugins , function ( $ plugindata ) { return ! $ plugindata -> is_standard ( ) ; } ) ; } , \ core_plugin_manager :: instance ( ) -> get_plugins ( ) ) ; }
Returns a list of contributed plugins installed on the system .