idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
32,200
public function precheck_notices ( $ results ) { $ output = html_writer :: start_tag ( 'div' , array ( 'class' => 'restore-precheck-notices' ) ) ; if ( array_key_exists ( 'errors' , $ results ) ) { foreach ( $ results [ 'errors' ] as $ error ) { $ output .= $ this -> output -> notification ( $ error ) ; } } if ( array_...
Displays precheck notices
32,201
public function substage_buttons ( $ haserrors ) { $ output = html_writer :: start_tag ( 'div' , array ( 'continuebutton' ) ) ; if ( ! $ haserrors ) { $ attrs = array ( 'type' => 'submit' , 'value' => get_string ( 'continue' ) , 'class' => 'btn btn-primary' ) ; $ output .= html_writer :: empty_tag ( 'input' , $ attrs )...
Displays substage buttons
32,202
public function role_mappings ( $ rolemappings , $ roles ) { $ roles [ 0 ] = get_string ( 'none' ) ; $ output = html_writer :: start_tag ( 'div' , array ( 'class' => 'restore-rolemappings' ) ) ; $ output .= $ this -> output -> heading ( get_string ( 'restorerolemappings' , 'backup' ) , 2 ) ; foreach ( $ rolemappings as...
Displays a role mapping interface
32,203
public function continue_button ( $ url , $ method = 'post' ) { if ( ! ( $ url instanceof moodle_url ) ) { $ url = new moodle_url ( $ url ) ; } if ( $ method != 'post' ) { $ method = 'get' ; } $ url -> param ( 'sesskey' , sesskey ( ) ) ; $ button = new single_button ( $ url , get_string ( 'continue' ) , $ method , true...
Displays a continue button
32,204
public function get_status_display ( $ statuscode , $ backupid ) { if ( $ statuscode == backup :: STATUS_AWAITING || $ statuscode == backup :: STATUS_EXECUTING ) { $ progresssetup = array ( 'backupid' => $ backupid , 'width' => '100' ) ; $ status = $ this -> render_from_template ( 'core/async_backup_progress' , $ progr...
Generate the status indicator markup for display in the backup restore file area UI .
32,205
public function restore_progress_viewer ( $ userid , $ context ) { $ tablehead = array ( get_string ( 'course' ) , get_string ( 'time' ) , get_string ( 'status' , 'backup' ) ) ; $ table = new html_table ( ) ; $ table -> attributes [ 'class' ] = 'backup-files-table generaltable' ; $ table -> head = $ tablehead ; $ table...
Get markup to render table for all of a users async in progress restores .
32,206
public static function get_collections ( $ onlysearchable = false ) { global $ DB ; $ cache = cache :: make ( 'core' , 'tags' ) ; if ( ( $ tagcolls = $ cache -> get ( 'tag_coll' ) ) === false ) { $ tagcolls = $ DB -> get_records ( 'tag_coll' , null , 'isdefault DESC, sortorder, id' ) ; if ( empty ( $ tagcolls ) ) { $ D...
Returns the list of tag collections defined in the system .
32,207
public static function get_by_id ( $ tagcollid ) { $ tagcolls = self :: get_collections ( ) ; if ( array_key_exists ( $ tagcollid , $ tagcolls ) ) { return $ tagcolls [ $ tagcollid ] ; } return null ; }
Returns the tag collection object
32,208
public static function get_collections_menu ( $ unlockedonly = false , $ onlysearchable = false , $ selectalllabel = null ) { $ tagcolls = self :: get_collections ( $ onlysearchable ) ; $ options = array ( ) ; foreach ( $ tagcolls as $ id => $ tagcoll ) { if ( ! $ unlockedonly || empty ( $ tagcoll -> component ) ) { $ ...
Returns the list of existing tag collections as id = > name
32,209
public static function display_name ( $ record ) { $ syscontext = context_system :: instance ( ) ; if ( ! empty ( $ record -> component ) ) { $ identifier = 'tagcollection_' . clean_param ( $ record -> name , PARAM_STRINGID ) ; $ component = $ record -> component ; if ( $ component === 'core' ) { $ component = 'tag' ; ...
Returns formatted name of the tag collection
32,210
public static function get_areas ( $ tagcollid ) { $ allitemtypes = core_tag_area :: get_areas ( $ tagcollid , true ) ; $ itemtypes = array ( ) ; foreach ( $ allitemtypes as $ itemtype => $ it ) { foreach ( $ it as $ component => $ v ) { $ itemtypes [ $ v -> id ] = $ v ; } } return $ itemtypes ; }
Returns all tag areas in the given tag collection
32,211
public static function create ( $ data ) { global $ DB ; $ data = ( object ) $ data ; $ tagcolls = self :: get_collections ( ) ; $ tagcoll = ( object ) array ( 'name' => $ data -> name , 'isdefault' => 0 , 'component' => ! empty ( $ data -> component ) ? $ data -> component : null , 'sortorder' => count ( $ tagcolls ) ...
Creates a new tag collection
32,212
public static function update ( $ tagcoll , $ data ) { global $ DB ; $ defaulttagcollid = self :: get_default ( ) ; $ allowedfields = array ( 'name' , 'searchable' , 'customurl' ) ; if ( $ tagcoll -> id == $ defaulttagcollid ) { $ allowedfields = array ( 'name' ) ; } $ updatedata = array ( ) ; $ data = ( array ) $ data...
Updates the tag collection information
32,213
public static function delete ( $ tagcoll ) { global $ DB , $ CFG ; $ defaulttagcollid = self :: get_default ( ) ; if ( $ tagcoll -> id == $ defaulttagcollid ) { return false ; } $ allitemtypes = core_tag_area :: get_areas ( $ tagcoll -> id ) ; foreach ( $ allitemtypes as $ it ) { foreach ( $ it as $ v ) { core_tag_are...
Deletes a custom tag collection
32,214
public static function change_sortorder ( $ tagcoll , $ direction ) { global $ DB ; if ( $ direction != - 1 && $ direction != 1 ) { throw new coding_exception ( 'Second argument in tag_coll_change_sortorder() can be only 1 or -1' ) ; } $ tagcolls = self :: get_collections ( ) ; $ keys = array_keys ( $ tagcolls ) ; $ id...
Moves the tag collection in the list one position up or down
32,215
public static function cleanup_unused_tags ( $ collections = null ) { global $ DB , $ CFG ; $ params = array ( ) ; $ sql = "SELECT tg.id FROM {tag} tg LEFT OUTER JOIN {tag_instance} ti ON ti.tagid = tg.id WHERE ti.id IS NULL AND tg.isstandard = 0" ; if ( $ collections ) { list ( $ sqlcoll , $ params ) = ...
Permanently deletes all non - standard tags that no longer have any instances pointing to them
32,216
public static function get_tag_cloud ( $ tagcollid , $ isstandard = false , $ limit = 150 , $ sort = 'name' , $ search = '' , $ fromctx = 0 , $ ctx = 0 , $ rec = 1 ) { global $ DB ; $ fromclause = 'FROM {tag_instance} ti JOIN {tag} tg ON tg.id = ti.tagid' ; $ whereclause = 'WHERE ti.itemtype <> \'tag\'' ; list ( $ sql ...
Returns the list of tags with number of items tagged
32,217
public static function cloud_sort ( $ a , $ b ) { $ tagsort = self :: $ cloudsortfield ? : 'name' ; if ( is_numeric ( $ a -> $ tagsort ) ) { return ( $ a -> $ tagsort == $ b -> $ tagsort ) ? 0 : ( $ a -> $ tagsort > $ b -> $ tagsort ) ? 1 : - 1 ; } else if ( is_string ( $ a -> $ tagsort ) ) { return strcmp ( $ a -> $ t...
This function is used to sort the tags in the cloud .
32,218
public static function export_data_for_null_provider ( approved_contextlist $ contextlist ) { $ user = $ contextlist -> get_user ( ) ; foreach ( $ contextlist as $ context ) { $ data = static :: get_context_data ( $ context , $ user ) ; static :: export_context_files ( $ context , $ user ) ; writer :: with_context ( $ ...
Handle export of standard data for a plugin which implements the null provider and does not normally store data of its own .
32,219
public static function get_context_data ( \ context $ context , \ stdClass $ user ) : \ stdClass { global $ DB ; $ basedata = ( object ) [ ] ; if ( $ context instanceof \ context_module ) { return static :: get_context_module_data ( $ context , $ user ) ; } if ( $ context instanceof \ context_block ) { return static ::...
Get all general data for this context .
32,220
public static function export_context_files ( \ context $ context , \ stdClass $ user ) { if ( $ context instanceof \ context_module ) { return static :: export_context_module_files ( $ context , $ user ) ; } }
Export all files for this context .
32,221
protected static function get_context_block_data ( \ context_block $ context , \ stdClass $ user ) : \ stdClass { global $ DB ; $ block = $ DB -> get_record ( 'block_instances' , [ 'id' => $ context -> instanceid ] ) ; $ basedata = ( object ) [ 'blocktype' => get_string ( 'pluginname' , 'block_' . $ block -> blockname ...
Get all general data for the block at this context .
32,222
public static function delete_data_for_all_users_in_context_course_module ( string $ component , \ context $ context ) { global $ DB ; if ( $ context instanceof \ context_module ) { \ core_completion \ privacy \ provider :: delete_completion ( null , null , $ context -> instanceid ) ; } }
Handle removal of standard data for course modules .
32,223
protected static function delete_data_for_user_in_course_module ( approved_contextlist $ contextlist ) { global $ DB ; foreach ( $ contextlist as $ context ) { if ( $ context instanceof \ context_module ) { \ core_completion \ privacy \ provider :: delete_completion ( $ contextlist -> get_user ( ) , null , $ context ->...
Delete all standard user data for the specified user in course modules .
32,224
protected function get_url_params ( ) { $ params = array ( 'id' => $ this -> cm -> id , 'mode' => $ this -> mode , 'attempts' => $ this -> attempts , 'onlygraded' => $ this -> onlygraded , ) ; if ( $ this -> states ) { $ params [ 'states' ] = implode ( '-' , $ this -> states ) ; } if ( groups_get_activity_groupmode ( $...
Get the URL parameters required to show the report with these options .
32,225
public function get_initial_form_data ( ) { $ toform = new stdClass ( ) ; $ toform -> attempts = $ this -> attempts ; $ toform -> onlygraded = $ this -> onlygraded ; $ toform -> pagesize = $ this -> pagesize ; if ( $ this -> states ) { foreach ( self :: $ statefields as $ field => $ state ) { $ toform -> $ field = in_a...
Get the current value of the settings to pass to the settings form .
32,226
public function setup_from_form_data ( $ fromform ) { $ this -> attempts = $ fromform -> attempts ; $ this -> group = groups_get_activity_group ( $ this -> cm , true ) ; $ this -> onlygraded = ! empty ( $ fromform -> onlygraded ) ; $ this -> pagesize = $ fromform -> pagesize ; $ this -> states = array ( ) ; foreach ( s...
Set the fields of this object from the form data .
32,227
public function setup_from_params ( ) { $ this -> attempts = optional_param ( 'attempts' , $ this -> attempts , PARAM_ALPHAEXT ) ; $ this -> group = groups_get_activity_group ( $ this -> cm , true ) ; $ this -> onlygraded = optional_param ( 'onlygraded' , $ this -> onlygraded , PARAM_BOOL ) ; $ this -> pagesize = optio...
Set the fields of this object from the URL parameters .
32,228
public function resolve_dependencies ( ) { if ( $ this -> group ) { if ( $ this -> attempts === null || $ this -> attempts == quiz_attempts_report :: ALL_WITH ) { $ this -> attempts = quiz_attempts_report :: ENROLLED_WITH ; } } else if ( ! $ this -> group && $ this -> course -> id == SITEID ) { $ this -> attempts = qui...
Check the settings and remove any impossible combinations .
32,229
public function edit_field_add ( $ mform ) { $ mform -> addElement ( 'editor' , $ this -> inputname , format_string ( $ this -> field -> name ) , null , null ) ; $ mform -> setType ( $ this -> inputname , PARAM_RAW ) ; }
Adds elements for this field type to the edit form .
32,230
public function edit_save_data_preprocess ( $ data , $ datarecord ) { if ( is_array ( $ data ) ) { $ datarecord -> dataformat = $ data [ 'format' ] ; $ data = $ data [ 'text' ] ; } return $ data ; }
Process incoming data for the field .
32,231
public function edit_load_user_data ( $ user ) { if ( $ this -> data !== null ) { $ this -> data = clean_text ( $ this -> data , $ this -> dataformat ) ; $ user -> { $ this -> inputname } = array ( 'text' => $ this -> data , 'format' => $ this -> dataformat ) ; } }
Load user data for this profile field ready for editing .
32,232
protected function _add ( Matrix $ other , $ sign = 1 ) { $ a1 = $ this -> toArray ( ) ; $ a2 = $ other -> toArray ( ) ; $ newMatrix = [ ] ; for ( $ i = 0 ; $ i < $ this -> rows ; ++ $ i ) { for ( $ k = 0 ; $ k < $ this -> columns ; ++ $ k ) { $ newMatrix [ $ i ] [ $ k ] = $ a1 [ $ i ] [ $ k ] + $ sign * $ a2 [ $ i ] [...
Element - wise addition or substraction depending on the given sign parameter
32,233
protected static function delete_user_data ( $ userid ) { global $ DB ; $ DB -> delete_records_select ( 'messageinbound_messagelist' , 'userid = :userid' , [ 'userid' => $ userid ] ) ; \ core_userkey \ privacy \ provider :: delete_userkeys ( 'messageinbound_handler' , $ userid ) ; }
Delete a user s data .
32,234
protected static function approved_contextlist_contains_my_context ( approved_contextlist $ contextlist ) { $ userid = $ contextlist -> get_user ( ) -> id ; foreach ( $ contextlist -> get_contexts ( ) as $ context ) { if ( $ context -> contextlevel == CONTEXT_USER && $ context -> instanceid == $ userid ) { return true ...
Return whether the contextlist contains our own context .
32,235
public function can_create ( ) { return in_array ( $ this -> mode , array ( tool_uploadcourse_processor :: MODE_CREATE_ALL , tool_uploadcourse_processor :: MODE_CREATE_NEW , tool_uploadcourse_processor :: MODE_CREATE_OR_UPDATE ) ) ; }
Does the mode allow for course creation?
32,236
public function can_update ( ) { return in_array ( $ this -> mode , array ( tool_uploadcourse_processor :: MODE_UPDATE_ONLY , tool_uploadcourse_processor :: MODE_CREATE_OR_UPDATE ) ) && $ this -> updatemode != tool_uploadcourse_processor :: UPDATE_NOTHING ; }
Does the mode allow for course update?
32,237
protected function delete ( ) { global $ DB ; $ this -> id = $ DB -> get_field_select ( 'course' , 'id' , 'shortname = :shortname' , array ( 'shortname' => $ this -> shortname ) , MUST_EXIST ) ; return delete_course ( $ this -> id , false ) ; }
Delete the current course .
32,238
protected function exists ( $ shortname = null ) { global $ DB ; if ( is_null ( $ shortname ) ) { $ shortname = $ this -> shortname ; } if ( ! empty ( $ shortname ) || is_numeric ( $ shortname ) ) { return $ DB -> record_exists ( 'course' , array ( 'shortname' => $ shortname ) ) ; } return false ; }
Return whether the course exists or not .
32,239
public function proceed ( ) { global $ CFG , $ USER ; if ( ! $ this -> prepared ) { throw new coding_exception ( 'The course has not been prepared.' ) ; } else if ( $ this -> has_errors ( ) ) { throw new moodle_exception ( 'Cannot proceed, errors were detected.' ) ; } else if ( $ this -> processstarted ) { throw new co...
Proceed with the import of the course .
32,240
protected function reset ( $ course ) { global $ DB ; $ resetdata = new stdClass ( ) ; $ resetdata -> id = $ course -> id ; $ resetdata -> reset_start_date = time ( ) ; $ resetdata -> reset_events = true ; $ resetdata -> reset_notes = true ; $ resetdata -> delete_blog_associations = true ; $ resetdata -> reset_completi...
Reset the current course .
32,241
protected function status ( $ code , lang_string $ message ) { if ( array_key_exists ( $ code , $ this -> statuses ) ) { throw new coding_exception ( 'Status code already defined' ) ; } $ this -> statuses [ $ code ] = $ message ; }
Log a status
32,242
public function summarise ( ) { if ( trim ( $ this -> text ) != '' ) { $ summariseplace = get_string ( 'summariseplace' , 'qtype_ddimageortext' , $ this ) ; } else { $ summariseplace = get_string ( 'summariseplaceno' , 'qtype_ddimageortext' , $ this -> no ) ; } return $ summariseplace ; }
Creates summary text of for the drop zone
32,243
protected function render_mod_scorm_attempt_bar ( mod_scorm_attempt_bar $ attemptbar ) { $ output = '' ; $ attemptbar = clone ( $ attemptbar ) ; $ attemptbar -> prepare ( $ this , $ this -> page , $ this -> target ) ; if ( count ( $ attemptbar -> attemptids ) > 1 ) { $ output .= get_string ( 'attempt' , 'scorm' ) . ':'...
scorm attempt bar renderer
32,244
public function prepare ( renderer_base $ output , moodle_page $ page , $ target ) { if ( empty ( $ this -> attemptids ) ) { throw new coding_exception ( 'mod_scorm_attempt_bar requires a attemptids value.' ) ; } if ( ! isset ( $ this -> attempt ) || is_null ( $ this -> attempt ) ) { throw new coding_exception ( 'mod_s...
Prepares the scorm attempt bar for output .
32,245
public function before_path ( $ path ) { if ( $ this -> path_is_grouped ( $ path ) and ! isset ( $ this -> currentdata [ $ path ] ) ) { $ this -> currentdata [ $ path ] = array ( 'path' => $ path , 'level' => substr_count ( $ path , '/' ) + 1 , 'tags' => array ( ) , ) ; } if ( ! $ this -> grouped_parent_exists ( $ path...
The parser fires this each time one path is going to be parsed
32,246
protected function grouped_parent_exists ( $ path ) { $ patharray = explode ( '/' , $ this -> get_parent_path ( $ path ) ) ; $ groupedpath = '' ; $ currentpos = & $ this -> groupedparentprefixtree ; foreach ( $ patharray as $ item ) { if ( ! isset ( $ currentpos [ $ item ] ) ) { return false ; } if ( $ item != '' ) { $...
Function that will look for any grouped parent for the given path returning it if found false if not
32,247
protected function get_parent_path ( $ path ) { if ( ! isset ( $ this -> parentcache [ $ path ] ) ) { $ this -> parentcache [ $ path ] = progressive_parser :: dirname ( $ path ) ; $ this -> parentcacheavailablesize -- ; if ( $ this -> parentcacheavailablesize < 0 ) { $ this -> parentcache = array_slice ( $ this -> pare...
Get the parent path using a local cache for performance .
32,248
protected function grouped_child_exists ( $ path ) { $ childpath = $ path . '/' ; foreach ( $ this -> groupedpaths as $ groupedpath => $ set ) { if ( strpos ( $ groupedpath , $ childpath ) === 0 ) { return $ groupedpath ; } } return false ; }
Function that will look for any grouped child for the given path returning it if found false if not
32,249
protected function build_currentdata ( $ grouped , $ data ) { if ( ! is_array ( $ this -> currentdata ) or ! array_key_exists ( $ grouped , $ this -> currentdata ) ) { $ a = new stdclass ( ) ; $ a -> grouped = $ grouped ; $ a -> child = $ data [ 'path' ] ; throw new progressive_parser_exception ( 'xml_cannot_add_to_gro...
This function will accumulate the chunk into the specified grouped element for later dispatching once it is complete
32,250
protected function add_missing_sub ( $ grouped , $ path , $ tags ) { $ processedtag = basename ( $ path ) ; $ info = & $ this -> currentdata [ $ grouped ] [ 'tags' ] ; $ hierarchyarr = explode ( '/' , str_replace ( $ grouped . '/' , '' , $ path ) ) ; $ previouselement = '' ; $ currentpath = '' ; foreach ( $ hierarchyar...
Add non - existing subarray elements
32,251
public static function get_databases_by_courses ( $ courseids = array ( ) ) { global $ PAGE ; $ params = self :: validate_parameters ( self :: get_databases_by_courses_parameters ( ) , array ( 'courseids' => $ courseids ) ) ; $ warnings = array ( ) ; $ mycourses = array ( ) ; if ( empty ( $ params [ 'courseids' ] ) ) {...
Returns a list of databases in a provided list of courses if no list is provided all databases that the user can view will be returned .
32,252
protected static function validate_database ( $ databaseid ) { global $ DB ; $ database = $ DB -> get_record ( 'data' , array ( 'id' => $ databaseid ) , '*' , MUST_EXIST ) ; list ( $ course , $ cm ) = get_course_and_cm_from_instance ( $ database , 'data' ) ; $ context = context_module :: instance ( $ cm -> id ) ; self ...
Utility function for validating a database .
32,253
public static function get_data_access_information ( $ databaseid , $ groupid = 0 ) { $ params = array ( 'databaseid' => $ databaseid , 'groupid' => $ groupid ) ; $ params = self :: validate_parameters ( self :: get_data_access_information_parameters ( ) , $ params ) ; $ warnings = array ( ) ; list ( $ database , $ cou...
Return access information for a given database .
32,254
public static function get_entry ( $ entryid , $ returncontents = false ) { global $ PAGE , $ DB ; $ params = array ( 'entryid' => $ entryid , 'returncontents' => $ returncontents ) ; $ params = self :: validate_parameters ( self :: get_entry_parameters ( ) , $ params ) ; $ warnings = array ( ) ; $ record = $ DB -> get...
Return one entry record from the database including contents optionally .
32,255
public static function get_fields ( $ databaseid ) { global $ PAGE ; $ params = array ( 'databaseid' => $ databaseid ) ; $ params = self :: validate_parameters ( self :: get_fields_parameters ( ) , $ params ) ; $ fields = $ warnings = array ( ) ; list ( $ database , $ course , $ cm , $ context ) = self :: validate_data...
Return the list of configured fields for the given database .
32,256
public static function approve_entry ( $ entryid , $ approve = true ) { global $ PAGE , $ DB ; $ params = array ( 'entryid' => $ entryid , 'approve' => $ approve ) ; $ params = self :: validate_parameters ( self :: approve_entry_parameters ( ) , $ params ) ; $ warnings = array ( ) ; $ record = $ DB -> get_record ( 'dat...
Approves or unapproves an entry .
32,257
public static function delete_entry ( $ entryid ) { global $ PAGE , $ DB ; $ params = array ( 'entryid' => $ entryid ) ; $ params = self :: validate_parameters ( self :: delete_entry_parameters ( ) , $ params ) ; $ warnings = array ( ) ; $ record = $ DB -> get_record ( 'data_records' , array ( 'id' => $ params [ 'entry...
Deletes an entry .
32,258
public static function add_entry ( $ databaseid , $ groupid , $ data ) { global $ DB ; $ params = array ( 'databaseid' => $ databaseid , 'groupid' => $ groupid , 'data' => $ data ) ; $ params = self :: validate_parameters ( self :: add_entry_parameters ( ) , $ params ) ; $ warnings = array ( ) ; $ fieldnotifications = ...
Adds a new entry to a database
32,259
public static function update_entry ( $ entryid , $ data ) { global $ DB ; $ params = array ( 'entryid' => $ entryid , 'data' => $ data ) ; $ params = self :: validate_parameters ( self :: update_entry_parameters ( ) , $ params ) ; $ warnings = array ( ) ; $ fieldnotifications = array ( ) ; $ updated = false ; $ record...
Updates an existing entry .
32,260
protected function process_ltitype ( $ data ) { global $ DB , $ USER ; $ data = ( object ) $ data ; $ oldid = $ data -> id ; if ( ! empty ( $ data -> createdby ) ) { $ data -> createdby = $ this -> get_mappingid ( 'user' , $ data -> createdby ) ? : $ USER -> id ; } $ courseid = $ this -> get_courseid ( ) ; $ data -> co...
Process an lti type restore
32,261
protected function find_existing_lti_type ( $ data ) { global $ DB ; if ( $ ltitypeid = $ this -> get_mappingid ( 'ltitype' , $ data -> id ) ) { return $ ltitypeid ; } $ ltitype = null ; $ params = ( array ) $ data ; if ( $ this -> task -> is_samesite ( ) ) { $ sql = 'id = :id AND course = :course' ; $ sql .= ( $ data ...
Attempts to find existing record in lti_type
32,262
protected function _replaceTenPrefixes ( $ string ) { foreach ( $ this -> TEN_PREFIXES as $ tp => $ tp_replacement ) { $ string = preg_replace_callback ( "/(?:$tp)( *\d(?=[^\d]|\$))*/i" , function ( $ m ) use ( $ tp_replacement ) { return $ tp_replacement + ( isset ( $ m [ 1 ] ) ? ( int ) $ m [ 1 ] : 0 ) ; } , $ string...
ten twenty etc .
32,263
protected function _replaceBigPrefixes ( $ string ) { foreach ( $ this -> BIG_PREFIXES as $ bp => $ bp_replacement ) { $ string = preg_replace_callback ( '/(\d*) *' . $ bp . '(\d?)/i' , function ( $ m ) use ( $ bp_replacement ) { $ factor = ( int ) $ m [ 1 ] ; if ( ! $ factor ) { $ factor = 1 ; } return ( $ bp_replacem...
hundreds thousands millions etc .
32,264
public function display_header ( ) { echo '<th class="header ' . $ this -> get_classes ( ) . '" scope="col">' ; $ sortable = $ this -> is_sortable ( ) ; $ name = get_class ( $ this ) ; $ title = $ this -> get_title ( ) ; $ tip = $ this -> get_title_tip ( ) ; if ( is_array ( $ sortable ) ) { if ( $ title ) { echo '<div ...
Output the column header cell .
32,265
protected function make_sort_link ( $ sort , $ title , $ tip , $ defaultreverse = false ) { $ currentsort = $ this -> qbank -> get_primary_sort_order ( $ sort ) ; $ newsortreverse = $ defaultreverse ; if ( $ currentsort ) { $ newsortreverse = $ currentsort > 0 ; } if ( ! $ tip ) { $ tip = $ title ; } if ( $ newsortreve...
Get a link that changes the sort order and indicates the current sort state .
32,266
protected function get_sort_icon ( $ reverse ) { global $ OUTPUT ; if ( $ reverse ) { return $ OUTPUT -> pix_icon ( 't/sort_desc' , get_string ( 'desc' ) , '' , array ( 'class' => 'iconsort' ) ) ; } else { return $ OUTPUT -> pix_icon ( 't/sort_asc' , get_string ( 'asc' ) , '' , array ( 'class' => 'iconsort' ) ) ; } }
Get an icon representing the corrent sort state .
32,267
public function display ( $ question , $ rowclasses ) { $ this -> display_start ( $ question , $ rowclasses ) ; $ this -> display_content ( $ question , $ rowclasses ) ; $ this -> display_end ( $ question , $ rowclasses ) ; }
Output this column .
32,268
protected function display_end ( $ question , $ rowclasses ) { $ tag = 'td' ; if ( $ this -> isheading ) { $ tag = 'th' ; } echo \ html_writer :: end_tag ( $ tag ) ; }
Output the closing column tag
32,269
public function get_users ( $ userlimit = 0 ) { global $ DB ; $ users = $ DB -> get_records_sql ( $ this -> sql , $ this -> params , 0 , $ userlimit ) ; return $ users ; }
Get a list of the most recent online users
32,270
protected function write_single_page_xml ( $ page , $ prevpageid = 0 , $ nextpageid = 0 ) { $ page -> data [ 'nextpageid' ] = $ nextpageid ; $ page -> data [ 'prevpageid' ] = $ prevpageid ; $ this -> xmlwriter -> begin_tag ( 'page' , array ( 'id' => $ page -> id ) ) ; foreach ( $ page -> data as $ field => $ value ) { ...
writes out the given page into the open xml handle
32,271
protected function renderDoctype ( ) { $ doctype = $ this -> def -> doctype ; $ ret = '' ; $ ret .= $ this -> start ( 'table' ) ; $ ret .= $ this -> element ( 'caption' , 'Doctype' ) ; $ ret .= $ this -> row ( 'Name' , $ doctype -> name ) ; $ ret .= $ this -> row ( 'XML' , $ doctype -> xml ? 'Yes' : 'No' ) ; $ ret .= $...
Renders the Doctype table
32,272
protected function renderEnvironment ( ) { $ def = $ this -> def ; $ ret = '' ; $ ret .= $ this -> start ( 'table' ) ; $ ret .= $ this -> element ( 'caption' , 'Environment' ) ; $ ret .= $ this -> row ( 'Parent of fragment' , $ def -> info_parent ) ; $ ret .= $ this -> renderChildren ( $ def -> info_parent_def -> child...
Renders environment table which is miscellaneous info
32,273
protected function renderContentSets ( ) { $ ret = '' ; $ ret .= $ this -> start ( 'table' ) ; $ ret .= $ this -> element ( 'caption' , 'Content Sets' ) ; foreach ( $ this -> def -> info_content_sets as $ name => $ lookup ) { $ ret .= $ this -> heavyHeader ( $ name ) ; $ ret .= $ this -> start ( 'tr' ) ; $ ret .= $ thi...
Renders the Content Sets table
32,274
protected function listifyObjectList ( $ array ) { ksort ( $ array ) ; $ list = array ( ) ; foreach ( $ array as $ obj ) { $ list [ ] = $ this -> getClass ( $ obj , 'AttrTransform_' ) ; } return $ this -> listify ( $ list ) ; }
Listifies a list of objects by retrieving class names and internal state
32,275
protected function heavyHeader ( $ text , $ num = 1 ) { $ ret = '' ; $ ret .= $ this -> start ( 'tr' ) ; $ ret .= $ this -> element ( 'th' , $ text , array ( 'colspan' => $ num , 'class' => 'heavy' ) ) ; $ ret .= $ this -> end ( 'tr' ) ; return $ ret ; }
Creates a heavy header row
32,276
function validate ( $ value , $ options = null ) { $ length = core_text :: strlen ( $ value ) ; switch ( $ this -> name ) { case 'minlength' : return ( $ length >= $ options ) ; case 'maxlength' : return ( $ length <= $ options ) ; default : return ( $ length >= $ options [ 0 ] && $ length <= $ options [ 1 ] ) ; } }
Validates a value using a range comparison
32,277
function getValidationScript ( $ options = null ) { switch ( $ this -> name ) { case 'minlength' : $ test = '{jsVar}.length < ' . $ options ; break ; case 'maxlength' : $ test = '{jsVar}.length > ' . $ options ; break ; default : $ test = '({jsVar}.length < ' . $ options [ 0 ] . ' || {jsVar}.length > ' . $ options [ 1 ...
end func validate
32,278
public function send_intent ( ) { global $ CFG , $ DB ; require_once ( $ CFG -> dirroot . '/mnet/xmlrpc/client.php' ) ; $ client = new mnet_xmlrpc_client ( ) ; $ client -> set_method ( 'portfolio/mahara/lib.php/send_content_intent' ) ; $ client -> add_param ( $ this -> get ( 'user' ) -> username ) ; $ this -> ensure_mn...
sends the content_intent ping to mahara if all goes well this will set the token and sendtype member variables .
32,279
public function set_areas ( array $ areas ) { foreach ( $ areas as $ area ) { if ( $ area instanceof base && ! key_exists ( $ area -> get_area_id ( ) , $ this -> areas ) ) { $ this -> areas [ $ area -> get_area_id ( ) ] = $ area ; } } }
Set list of search areas for this category
32,280
public function process ( $ processor ) { if ( ! $ processor instanceof base_processor ) { throw new base_element_struct_exception ( 'incorrect_processor' ) ; } $ iterator = $ this -> get_iterator ( $ processor ) ; foreach ( $ iterator as $ key => $ values ) { $ this -> fill_values ( $ values ) ; $ processor -> pre_pro...
Process the nested element
32,281
protected function add_log ( $ message , $ level , $ a = null , $ depth = null , $ display = false ) { if ( $ this -> get_parent ( ) ) { $ parent = $ this -> get_grandparent ( ) ; $ parent -> add_log ( $ message , $ level , $ a , $ depth , $ display ) ; } else { $ log = new stdClass ( ) ; $ log -> message = $ message ;...
Saves a log message to an array
32,282
protected function add_result ( $ result ) { if ( is_array ( $ result ) ) { if ( $ this -> get_parent ( ) ) { $ parent = $ this -> get_grandparent ( ) ; $ parent -> add_result ( $ result ) ; } else { $ this -> results = array_merge ( $ this -> results , $ result ) ; } } }
Saves the results to an array
32,283
public static function get_users ( $ context , $ search = '' , $ page = 0 , $ perpage = 25 ) { global $ DB ; list ( $ sql , $ params ) = self :: get_users_sql_and_params ( $ context , $ search ) ; $ limitfrom = $ page * $ perpage ; $ limitto = $ limitfrom + $ perpage ; $ users = $ DB -> get_records_sql ( $ sql , $ para...
Retrieve a list of users .
32,284
public static function get_users_count ( $ context , $ search = '' ) { global $ DB ; list ( $ sql , $ params ) = self :: get_users_sql_and_params ( $ context , $ search , true ) ; return $ DB -> count_records_sql ( $ sql , $ params ) ; }
Get total number of users present for the given search criteria .
32,285
protected static function get_users_sql_and_params ( $ context , $ search = '' , $ count = false ) { $ extrafields = get_extra_user_fields ( $ context ) ; $ params = array ( ) ; if ( ! empty ( $ search ) ) { list ( $ filtersql , $ params ) = users_search_sql ( $ search , 'u' , true , $ extrafields ) ; $ filtersql .= ' ...
Get sql and params to use to get list of users .
32,286
public static function get_graders ( $ courseid ) { global $ DB ; $ ufields = get_all_user_name_fields ( true , 'u' ) ; $ sql = "SELECT u.id, $ufields FROM {user} u JOIN {grade_grades_history} ggh ON ggh.usermodified = u.id JOIN {grade_items} gi ON gi.id = ggh.itemid ...
Get a list of graders .
32,287
protected function define_definition_plugin_structure ( ) { $ plugin = $ this -> get_plugin_element ( null , '../../method' , 'rubric' ) ; $ pluginwrapper = new backup_nested_element ( $ this -> get_recommended_name ( ) ) ; $ plugin -> add_child ( $ pluginwrapper ) ; $ criteria = new backup_nested_element ( 'criteria' ...
Declares rubric structures to append to the grading form definition
32,288
public function definition ( ) { global $ CFG ; $ mform = $ this -> _form ; $ mform -> setDisableShortforms ( true ) ; $ mform -> addElement ( 'header' , 'setpassword' , get_string ( 'setpassword' ) , '' ) ; $ mform -> addElement ( 'text' , 'username' , '' , 'style="display: none;"' ) ; $ mform -> setType ( 'username' ...
Define the set password form .
32,289
public function validation ( $ data , $ files ) { $ user = $ this -> _customdata ; $ errors = parent :: validation ( $ data , $ files ) ; if ( $ data [ 'password' ] !== $ data [ 'password2' ] ) { $ errors [ 'password' ] = get_string ( 'passwordsdiffer' ) ; $ errors [ 'password2' ] = get_string ( 'passwordsdiffer' ) ; r...
Perform extra password change validation .
32,290
public function is_valid_sample ( $ sampleid , \ core_analytics \ analysable $ analysable , $ fortraining = true ) { $ course = $ this -> retrieve ( 'course' , $ sampleid ) ; $ now = time ( ) ; if ( ! $ course -> startdate || ( ! empty ( $ course -> enddate ) && $ course -> enddate < $ now ) || $ course -> startdate - ...
Only process samples which start date is getting close .
32,291
public function add ( $ data ) { $ args = array ( $ data ) + func_get_args ( ) ; foreach ( $ args as $ data ) { if ( is_array ( $ data ) ) { call_user_func_array ( array ( $ this , 'add' ) , $ data ) ; continue ; } $ data = ( string ) $ data ; $ value = $ this -> load ( $ data ) ; $ key = ( $ data != $ value ) ? $ data...
Add a file or straight - up code to be minified .
32,292
public function cache ( CacheItemInterface $ item ) { $ content = $ this -> execute ( ) ; $ item -> set ( $ content ) ; return $ item ; }
Minify the data & write it to a CacheItemInterface object .
32,293
protected function save ( $ content , $ path ) { $ handler = $ this -> openFileForWriting ( $ path ) ; $ this -> writeToFile ( $ handler , $ content ) ; @ fclose ( $ handler ) ; }
Save to file .
32,294
protected function extractStrings ( $ chars = '\'"' , $ placeholderPrefix = '' ) { $ minifier = $ this ; $ callback = function ( $ match ) use ( $ minifier , $ placeholderPrefix ) { if ( $ match [ 2 ] === '' ) { return $ match [ 0 ] ; } $ count = count ( $ minifier -> extracted ) ; $ placeholder = $ match [ 1 ] . $ pla...
Strings are a pattern we need to match in order to ignore potential code - like content inside them but we just want all of the string content to remain untouched .
32,295
public static function login_user ( $ chatid , $ groupid = 0 ) { global $ DB ; $ params = self :: validate_parameters ( self :: login_user_parameters ( ) , array ( 'chatid' => $ chatid , 'groupid' => $ groupid ) ) ; $ warnings = array ( ) ; $ chat = $ DB -> get_record ( 'chat' , array ( 'id' => $ params [ 'chatid' ] ) ...
Log the current user into a chat room in the given chat .
32,296
public static function get_chat_users ( $ chatsid ) { global $ DB , $ PAGE ; $ params = self :: validate_parameters ( self :: get_chat_users_parameters ( ) , array ( 'chatsid' => $ chatsid ) ) ; $ warnings = array ( ) ; if ( ! $ chatuser = $ DB -> get_record ( 'chat_users' , array ( 'sid' => $ params [ 'chatsid' ] ) ) ...
Get the list of users in the given chat session .
32,297
public static function send_chat_message ( $ chatsid , $ messagetext , $ beepid = '' ) { global $ DB ; $ params = self :: validate_parameters ( self :: send_chat_message_parameters ( ) , array ( 'chatsid' => $ chatsid , 'messagetext' => $ messagetext , 'beepid' => $ beepid ) ) ; $ warnings = array ( ) ; if ( ! $ chatus...
Send a message on the given chat session .
32,298
public static function get_chats_by_courses ( $ courseids = array ( ) ) { global $ CFG ; $ returnedchats = array ( ) ; $ warnings = array ( ) ; $ params = self :: validate_parameters ( self :: get_chats_by_courses_parameters ( ) , array ( 'courseids' => $ courseids ) ) ; $ courses = array ( ) ; if ( empty ( $ params [ ...
Returns a list of chats in a provided list of courses if no list is provided all chats that the user can view will be returned .
32,299
public static function get_chats_by_courses_returns ( ) { return new external_single_structure ( array ( 'chats' => new external_multiple_structure ( new external_single_structure ( array ( 'id' => new external_value ( PARAM_INT , 'Chat id' ) , 'coursemodule' => new external_value ( PARAM_INT , 'Course module id' ) , '...
Describes the get_chats_by_courses return value .