idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
28,800
public function on_resource_end ( array $ data ) { if ( $ successor = $ this -> get_successor ( $ data [ 'type' ] , $ data [ 'reference' ] ) ) { $ successor -> on_legacy_resource_end ( $ data ) ; } }
Give succesors a chance to finish their job
28,801
protected function get_successor ( $ type , $ reference ) { switch ( $ type ) { case 'text' : case 'html' : $ name = 'page' ; break ; case 'directory' : $ name = 'folder' ; break ; case 'ims' : $ name = 'imscp' ; break ; case 'file' : if ( strpos ( $ reference , '$@FILEPHP@$' ) === 0 ) { $ name = null ; break ; } if ( ...
Returns the handler of the new 2 . 0 mod type according the given type of the legacy 1 . 9 resource
28,802
public function user_list ( $ userlist , $ exclusivemode ) { $ tagfeed = new core_tag \ output \ tagfeed ( ) ; foreach ( $ userlist as $ user ) { $ userpicture = $ this -> output -> user_picture ( $ user , array ( 'size' => $ exclusivemode ? 100 : 35 ) ) ; $ fullname = fullname ( $ user ) ; if ( user_can_view_profile (...
Displays the list of tagged users
28,803
protected function format_filter_option ( $ filtertype , $ criteria , $ value , $ label ) { $ optionlabel = get_string ( 'filteroption' , 'moodle' , ( object ) [ 'criteria' => $ criteria , 'value' => $ label ] ) ; $ optionvalue = "$filtertype:$value" ; return [ $ optionvalue => $ optionlabel ] ; }
Returns a formatted filter option .
28,804
private function handle_missing_applied_filters ( $ filtersapplied , $ filteroptions ) { global $ DB ; foreach ( $ filtersapplied as $ filter ) { if ( ! array_key_exists ( $ filter , $ filteroptions ) ) { $ filtervalue = explode ( ':' , $ filter ) ; if ( count ( $ filtervalue ) !== 2 ) { continue ; } $ key = $ filterva...
Handles cases when after reloading the applied filters are missing in the filter options .
28,805
protected static final function get_format_or_default ( $ format ) { global $ CFG ; require_once ( $ CFG -> dirroot . '/course/lib.php' ) ; if ( array_key_exists ( $ format , self :: $ classesforformat ) ) { return self :: $ classesforformat [ $ format ] ; } $ plugins = get_sorted_course_formats ( ) ; foreach ( $ plugi...
Validates that course format exists and enabled and returns either itself or default format
28,806
protected static final function get_class_name ( $ format ) { global $ CFG ; static $ classnames = array ( 'site' => 'format_site' ) ; if ( ! isset ( $ classnames [ $ format ] ) ) { $ plugins = core_component :: get_plugin_list ( 'format' ) ; $ usedformat = self :: get_format_or_default ( $ format ) ; if ( isset ( $ pl...
Get class name for the format
28,807
public static final function instance ( $ courseorid ) { global $ DB ; if ( ! is_object ( $ courseorid ) ) { $ courseid = ( int ) $ courseorid ; if ( $ courseid && isset ( self :: $ instances [ $ courseid ] ) && count ( self :: $ instances [ $ courseid ] ) == 1 ) { $ formats = array_keys ( self :: $ instances [ $ cours...
Returns an instance of the class
28,808
public function get_course ( ) { global $ DB ; if ( ! $ this -> courseid ) { return null ; } if ( $ this -> course === false ) { $ this -> course = get_course ( $ this -> courseid ) ; $ options = $ this -> get_format_options ( ) ; $ dbcoursecolumns = null ; foreach ( $ options as $ optionname => $ optionvalue ) { if ( ...
Returns a record from course database table plus additional fields that course format defines
28,809
public function get_last_section_number ( ) { $ course = $ this -> get_course ( ) ; if ( isset ( $ course -> numsections ) ) { return $ course -> numsections ; } $ modinfo = get_fast_modinfo ( $ course ) ; $ sections = $ modinfo -> get_section_info_all ( ) ; return ( int ) max ( array_keys ( $ sections ) ) ; }
Method used in the rendered and during backup instead of legacy numsections
28,810
public final function get_section ( $ section , $ strictness = IGNORE_MISSING ) { if ( is_object ( $ section ) ) { $ sectionnum = $ section -> section ; } else { $ sectionnum = $ section ; } $ sections = $ this -> get_sections ( ) ; if ( array_key_exists ( $ sectionnum , $ sections ) ) { return $ sections [ $ sectionnu...
Returns information about section used in course
28,811
public function get_format_options ( $ section = null ) { global $ DB ; if ( $ section === null ) { $ options = $ this -> course_format_options ( ) ; } else { $ options = $ this -> section_format_options ( ) ; } if ( empty ( $ options ) ) { return array ( ) ; } if ( $ section === null ) { $ sectionid = 0 ; } else if ( ...
Returns the format options stored for this course or course section
28,812
protected function validate_format_options ( array $ rawdata , int $ sectionid = null ) : array { if ( ! $ sectionid ) { $ allformatoptions = $ this -> course_format_options ( true ) ; } else { $ allformatoptions = $ this -> section_format_options ( true ) ; } $ data = array_intersect_key ( $ rawdata , $ allformatoptio...
Prepares values of course or section format options before storing them in DB
28,813
protected function update_format_options ( $ data , $ sectionid = null ) { global $ DB ; $ data = $ this -> validate_format_options ( ( array ) $ data , $ sectionid ) ; if ( ! $ sectionid ) { $ allformatoptions = $ this -> course_format_options ( ) ; $ sectionid = 0 ; } else { $ allformatoptions = $ this -> section_for...
Updates format options for a course or section
28,814
public function editsection_form ( $ action , $ customdata = array ( ) ) { global $ CFG ; require_once ( $ CFG -> dirroot . '/course/editsection_form.php' ) ; $ context = context_course :: instance ( $ this -> courseid ) ; if ( ! array_key_exists ( 'course' , $ customdata ) ) { $ customdata [ 'course' ] = $ this -> get...
Return an instance of moodleform to edit a specified section
28,815
public function is_section_current ( $ section ) { if ( is_object ( $ section ) ) { $ sectionnum = $ section -> section ; } else { $ sectionnum = $ section ; } return ( $ sectionnum && ( $ course = $ this -> get_course ( ) ) && $ course -> marker == $ sectionnum ) ; }
Returns true if the specified section is current
28,816
public function delete_section ( $ section , $ forcedeleteifnotempty = false ) { global $ DB ; if ( ! $ this -> uses_sections ( ) ) { return false ; } if ( ! is_object ( $ section ) ) { $ section = $ DB -> get_record ( 'course_sections' , array ( 'course' => $ this -> get_courseid ( ) , 'section' => $ section ) , 'id,s...
Deletes a section
28,817
public function inplace_editable_update_section_name ( $ section , $ itemtype , $ newvalue ) { if ( $ itemtype === 'sectionname' || $ itemtype === 'sectionnamenl' ) { $ context = context_course :: instance ( $ section -> course ) ; external_api :: validate_context ( $ context ) ; require_capability ( 'moodle/course:upd...
Updates the value in the database and modifies this object respectively .
28,818
public function get_default_course_enddate ( $ mform , $ fieldnames = array ( ) ) { if ( empty ( $ fieldnames ) ) { $ fieldnames = array ( 'startdate' => 'startdate' ) ; } $ startdate = $ this -> get_form_start_date ( $ mform , $ fieldnames ) ; $ courseduration = intval ( get_config ( 'moodlecourse' , 'courseduration' ...
Returns the default end date value based on the start date .
28,819
public function supports_news ( ) { $ defaultblocks = $ this -> get_default_blocks ( ) ; foreach ( $ defaultblocks as $ blocks ) { if ( in_array ( 'news_items' , $ blocks ) ) { return true ; } } return false ; }
Indicates whether the course format supports the creation of the Announcements forum .
28,820
protected function get_form_start_date ( $ mform , $ fieldnames ) { $ startdate = $ mform -> getElementValue ( $ fieldnames [ 'startdate' ] ) ; return $ mform -> getElement ( $ fieldnames [ 'startdate' ] ) -> exportValue ( $ startdate ) ; }
Get the start date value from the course settings page form .
28,821
public function course_format_options ( $ foreditform = false ) { static $ courseformatoptions = false ; if ( $ courseformatoptions === false ) { $ courseformatoptions = array ( 'numsections' => array ( 'default' => 1 , 'type' => PARAM_INT , ) , ) ; } return $ courseformatoptions ; }
Definitions of the additional options that site uses
28,822
protected function init_qtype_lists ( ) { if ( ! is_null ( $ this -> excludedqtypes ) ) { return ; } $ excludedqtypes = array ( ) ; $ manualqtypes = array ( ) ; foreach ( question_bank :: get_all_qtypes ( ) as $ qtype ) { $ quotedname = "'" . $ qtype -> name ( ) . "'" ; if ( ! $ qtype -> is_usable_by_random ( ) ) { $ e...
This method needs to be called before the - > excludedqtypes and - > manualqtypes fields can be used .
28,823
public function get_available_questions_from_category ( $ categoryid , $ subcategories ) { if ( isset ( $ this -> availablequestionsbycategory [ $ categoryid ] [ $ subcategories ] ) ) { return $ this -> availablequestionsbycategory [ $ categoryid ] [ $ subcategories ] ; } $ this -> init_qtype_lists ( ) ; if ( $ subcate...
Get all the usable questions from a particular question category .
28,824
public function choose_other_question ( $ questiondata , $ excludedquestions , $ allowshuffle = true , $ forcequestionid = null ) { $ available = $ this -> get_available_questions_from_category ( $ questiondata -> category , ! empty ( $ questiondata -> questiontext ) ) ; shuffle ( $ available ) ; if ( $ forcequestionid...
Load the definition of another question picked randomly by this question .
28,825
function moveUploadedFile ( $ dest , $ fileName = '' ) { if ( $ dest != '' && substr ( $ dest , - 1 ) != '/' ) { $ dest .= '/' ; } $ fileName = ( $ fileName != '' ) ? $ fileName : basename ( $ this -> _value [ 'name' ] ) ; if ( move_uploaded_file ( $ this -> _value [ 'tmp_name' ] , $ dest . $ fileName ) ) { return true...
Moves an uploaded file into the destination
28,826
function _ruleIsUploadedFile ( $ elementValue ) { if ( ( isset ( $ elementValue [ 'error' ] ) && $ elementValue [ 'error' ] == 0 ) || ( ! empty ( $ elementValue [ 'tmp_name' ] ) && $ elementValue [ 'tmp_name' ] != 'none' ) ) { return is_uploaded_file ( $ elementValue [ 'tmp_name' ] ) ; } else { return false ; } }
Checks if the given element contains an uploaded file
28,827
function _ruleCheckMaxFileSize ( $ elementValue , $ maxSize ) { if ( ! empty ( $ elementValue [ 'error' ] ) && ( UPLOAD_ERR_FORM_SIZE == $ elementValue [ 'error' ] || UPLOAD_ERR_INI_SIZE == $ elementValue [ 'error' ] ) ) { return false ; } if ( ! HTML_QuickForm_file :: _ruleIsUploadedFile ( $ elementValue ) ) { return ...
Checks that the file does not exceed the max file size
28,828
function _ruleCheckMimeType ( $ elementValue , $ mimeType ) { if ( ! HTML_QuickForm_file :: _ruleIsUploadedFile ( $ elementValue ) ) { return true ; } if ( is_array ( $ mimeType ) ) { return in_array ( $ elementValue [ 'type' ] , $ mimeType ) ; } return $ elementValue [ 'type' ] == $ mimeType ; }
Checks if the given element contains an uploaded file of the right mime type
28,829
function _ruleCheckFileName ( $ elementValue , $ regex ) { if ( ! HTML_QuickForm_file :: _ruleIsUploadedFile ( $ elementValue ) ) { return true ; } return preg_match ( $ regex , $ elementValue [ 'name' ] ) ; }
Checks if the given element contains an uploaded file of the filename regex
28,830
public function can_add_instance ( $ courseid ) { global $ CFG , $ DB ; require_once ( $ CFG -> dirroot . '/mnet/service/enrol/locallib.php' ) ; $ service = mnetservice_enrol :: get_instance ( ) ; if ( ! $ service -> is_available ( ) ) { return false ; } $ coursecontext = context_course :: instance ( $ courseid ) ; if ...
Returns true if a new instance can be added to this course .
28,831
protected function get_valid_hosts_options ( ) { global $ CFG ; require_once ( $ CFG -> dirroot . '/mnet/service/enrol/locallib.php' ) ; $ service = mnetservice_enrol :: get_instance ( ) ; $ subscribers = $ service -> get_remote_subscribers ( ) ; $ hosts = array ( 0 => get_string ( 'remotesubscribersall' , 'enrol_mnet'...
Return an array of valid options for the hosts property .
28,832
public function instance_copy ( $ fromid ) { $ fromcontext = context_block :: instance ( $ fromid ) ; $ fs = get_file_storage ( ) ; if ( ! $ fs -> is_area_empty ( $ fromcontext -> id , 'block_html' , 'content' , 0 , false ) ) { $ draftitemid = 0 ; file_prepare_draft_area ( $ draftitemid , $ fromcontext -> id , 'block_h...
Copy any block - specific data when copying to a new block instance .
28,833
protected function from_db_records ( array $ results ) { $ entityfactory = $ this -> get_entity_factory ( ) ; $ records = array_map ( function ( $ result ) { return $ result [ 'record' ] ; } , $ results ) ; return $ entityfactory -> get_post_read_receipt_collection_from_stdclasses ( $ records ) ; }
Convert the DB records into post_read_receipt_collection entities .
28,834
protected function add_userids ( array $ userids ) : userlist_base { $ this -> set_userids ( array_merge ( $ this -> get_userids ( ) , $ userids ) ) ; return $ this ; }
Add a set of additional userids .
28,835
public function get_users ( ) : array { $ users = [ ] ; foreach ( $ this -> userids as $ userid ) { if ( $ user = \ core_user :: get_user ( $ userid ) ) { $ users [ ] = $ user ; } } return $ users ; }
Get the complete list of user objects that relate to this request .
28,836
public function current ( ) { $ user = \ core_user :: get_user ( $ this -> userids [ $ this -> iteratorposition ] ) ; if ( false === $ user ) { unset ( $ this -> userids [ $ this -> iteratorposition ] ) ; if ( $ this -> count ( ) ) { $ this -> next ( ) ; $ user = $ this -> current ( ) ; } else { return ; } } return $ u...
Return the current user .
28,837
protected function format_text ( $ text ) { $ out = s ( $ text ) ; $ startcount = 0 ; $ endcount = 0 ; $ regex = '|' . engine :: HIGHLIGHT_END . '([ .,-]{0,3})' . engine :: HIGHLIGHT_START . '|' ; $ out = preg_replace ( $ regex , '$1' , $ out ) ; $ out = str_replace ( engine :: HIGHLIGHT_START , '<span class="highlight...
Formats a text string coming from the search engine .
28,838
protected function apply_defaults ( ) { parent :: apply_defaults ( ) ; if ( ! isset ( $ this -> data [ 'solr_filegroupingid' ] ) ) { $ this -> data [ 'solr_filegroupingid' ] = $ this -> data [ 'id' ] ; } }
Apply any defaults to unset fields before export . Called after document building but before export .
28,839
public function export_file_for_engine ( $ file ) { $ data = $ this -> export_for_engine ( ) ; unset ( $ data [ 'content' ] ) ; unset ( $ data [ 'description1' ] ) ; unset ( $ data [ 'description2' ] ) ; $ data [ 'id' ] = $ data [ 'id' ] . '-solrfile' . $ file -> get_id ( ) ; $ data [ 'type' ] = \ core_search \ manager...
Export the data for the given file in relation to this document .
28,840
public static function t ( $ message ) { if ( ! isset ( static :: $ _handlers [ static :: $ _domain ] ) ) { static :: loadHandler ( 'Horde_Translation_Handler_Gettext' ) ; } return static :: $ _handlers [ static :: $ _domain ] -> t ( $ message ) ; }
Returns the translation of a message .
28,841
public function add ( $ alert , $ type = null ) { $ this -> _alert = new stdClass ; $ this -> _alert -> alert = $ alert ; if ( ! is_null ( $ type ) ) { $ this -> _alert -> type = $ type ; } $ this -> notify ( ) ; }
Add an alert .
28,842
public function add_completion_rules ( ) { $ mform = & $ this -> _form ; $ group = array ( ) ; $ group [ ] = & $ mform -> createElement ( 'checkbox' , 'completionpostsenabled' , '' , get_string ( 'completionposts' , 'forum' ) ) ; $ group [ ] = & $ mform -> createElement ( 'text' , 'completionposts' , '' , array ( 'size...
Add custom completion rules .
28,843
public static function export_user_preferences ( int $ userid ) { $ preferences = get_user_preferences ( null , null , $ userid ) ; foreach ( $ preferences as $ name => $ value ) { if ( ( substr ( $ name , 0 , 16 ) == 'message_provider' ) || ( $ name == 'message_blocknoncontacts' ) || ( $ name == 'message_entertosend' ...
Store all user preferences for core message .
28,844
public static function export_conversations ( int $ userid , string $ component , string $ itemtype , \ context $ context , array $ subcontext = [ ] , int $ itemid = 0 ) { global $ DB ; $ sql = "SELECT DISTINCT mc.* FROM {message_conversations} mc JOIN {message_conversation_members} mc...
Store all conversations which match the specified component itemtype and itemid .
28,845
protected static function delete_user_data ( int $ userid ) { global $ DB ; self :: delete_user_data_conversations ( $ userid , [ ] , '' , '' ) ; $ DB -> delete_records_select ( 'message_contacts' , 'userid = ? OR contactid = ?' , [ $ userid , $ userid ] ) ; $ DB -> delete_records_select ( 'message_contact_requests' , ...
Delete all user data for the specified user .
28,846
protected static function export_user_data_contacts ( int $ userid ) { global $ DB ; $ context = \ context_user :: instance ( $ userid ) ; if ( $ contacts = $ DB -> get_records_select ( 'message_contacts' , 'userid = ? OR contactid = ?' , [ $ userid , $ userid ] , 'id ASC' ) ) { $ contactdata = [ ] ; foreach ( $ contac...
Export the messaging contact data .
28,847
protected static function export_user_data_contact_requests ( int $ userid ) { global $ DB ; $ context = \ context_user :: instance ( $ userid ) ; if ( $ contactrequests = $ DB -> get_records_select ( 'message_contact_requests' , 'userid = ? OR requesteduserid = ?' , [ $ userid , $ userid ] , 'id ASC' ) ) { $ contactre...
Export the messaging contact requests data .
28,848
protected static function export_user_data_blocked_users ( int $ userid ) { global $ DB ; $ context = \ context_user :: instance ( $ userid ) ; if ( $ blockedusers = $ DB -> get_records ( 'message_users_blocked' , [ 'userid' => $ userid ] , 'id ASC' ) ) { $ blockedusersdata = [ ] ; foreach ( $ blockedusers as $ blocked...
Export the messaging blocked users data .
28,849
protected static function export_user_data_notifications ( int $ userid ) { global $ DB ; $ context = \ context_user :: instance ( $ userid ) ; $ notificationdata = [ ] ; $ select = "useridfrom = ? OR useridto = ?" ; $ notifications = $ DB -> get_recordset_select ( 'notifications' , $ select , [ $ userid , $ userid ] ,...
Export the notification data .
28,850
public function to_css ( ) { $ content = implode ( ';' , $ this -> scssprepend ) ; if ( ! empty ( $ this -> scssfile ) ) { $ content .= file_get_contents ( $ this -> scssfile ) ; } $ content .= implode ( ';' , $ this -> scsscontent ) ; return $ this -> compile ( $ content ) ; }
Compiles to CSS .
28,851
public function compile ( $ code , $ path = null ) { global $ CFG ; $ pathtosassc = trim ( $ CFG -> pathtosassc ?? '' ) ; if ( ! empty ( $ pathtosassc ) && is_executable ( $ pathtosassc ) && ! is_dir ( $ pathtosassc ) ) { $ process = proc_open ( $ pathtosassc . ' -I' . implode ( ':' , $ this -> importPaths ) . ' -s' , ...
Compile scss .
28,852
protected function is_valid_file ( $ path ) { global $ CFG ; $ realpath = realpath ( $ path ) ; $ addthemedirectory = core_component :: get_plugin_types ( ) [ 'theme' ] ; $ addrealroot = realpath ( $ addthemedirectory ) ; $ themedirectory = $ CFG -> dirroot . "/theme" ; $ realroot = realpath ( $ themedirectory ) ; $ pa...
Is the given file valid for import ?
28,853
protected static function get_browse_modes_from_display_format ( $ format ) { global $ DB ; $ formats = array ( ) ; $ dp = $ DB -> get_record ( 'glossary_formats' , array ( 'name' => $ format ) , '*' , IGNORE_MISSING ) ; if ( $ dp ) { $ formats = glossary_get_visible_tabs ( $ dp ) ; } $ modes = array ( 'letter' ) ; if ...
Get the browse modes from the display format .
28,854
protected static function get_entry_return_structure ( $ includecat = false ) { $ params = array ( 'id' => new external_value ( PARAM_INT , 'The entry ID' ) , 'glossaryid' => new external_value ( PARAM_INT , 'The glossary ID' ) , 'userid' => new external_value ( PARAM_INT , 'Author ID' ) , 'userfullname' => new externa...
Get the return value of an entry .
28,855
protected static function fill_entry_details ( $ entry , $ context ) { global $ PAGE ; $ canviewfullnames = has_capability ( 'moodle/site:viewfullnames' , $ context ) ; $ entry -> concept = external_format_string ( $ entry -> concept , $ context -> id ) ; list ( $ entry -> definition , $ entry -> definitionformat ) = e...
Fill in an entry object .
28,856
protected static function validate_glossary ( $ id ) { global $ DB ; $ glossary = $ DB -> get_record ( 'glossary' , array ( 'id' => $ id ) , '*' , MUST_EXIST ) ; list ( $ course , $ cm ) = get_course_and_cm_from_instance ( $ glossary , 'glossary' ) ; $ context = context_module :: instance ( $ cm -> id ) ; self :: valid...
Validate a glossary via ID .
28,857
public static function get_glossaries_by_courses ( $ courseids = array ( ) ) { $ params = self :: validate_parameters ( self :: get_glossaries_by_courses_parameters ( ) , array ( 'courseids' => $ courseids ) ) ; $ warnings = array ( ) ; $ courses = array ( ) ; $ courseids = $ params [ 'courseids' ] ; if ( empty ( $ cou...
Returns a list of glossaries in a provided list of courses .
28,858
public static function view_glossary ( $ id , $ mode ) { $ params = self :: validate_parameters ( self :: view_glossary_parameters ( ) , array ( 'id' => $ id , 'mode' => $ mode ) ) ; $ id = $ params [ 'id' ] ; $ mode = $ params [ 'mode' ] ; $ warnings = array ( ) ; list ( $ glossary , $ context , $ course , $ cm ) = se...
Notify that the course module was viewed .
28,859
public static function view_entry ( $ id ) { global $ DB , $ USER ; $ params = self :: validate_parameters ( self :: view_entry_parameters ( ) , array ( 'id' => $ id ) ) ; $ id = $ params [ 'id' ] ; $ warnings = array ( ) ; $ entry = $ DB -> get_record ( 'glossary_entries' , array ( 'id' => $ id ) , '*' , MUST_EXIST ) ...
Notify that the entry was viewed .
28,860
public static function get_entries_by_letter ( $ id , $ letter , $ from , $ limit , $ options ) { $ params = self :: validate_parameters ( self :: get_entries_by_letter_parameters ( ) , array ( 'id' => $ id , 'letter' => $ letter , 'from' => $ from , 'limit' => $ limit , 'options' => $ options , ) ) ; $ id = $ params [...
Browse a glossary entries by letter .
28,861
public static function get_categories ( $ id , $ from , $ limit ) { $ params = self :: validate_parameters ( self :: get_categories_parameters ( ) , array ( 'id' => $ id , 'from' => $ from , 'limit' => $ limit ) ) ; $ id = $ params [ 'id' ] ; $ from = $ params [ 'from' ] ; $ limit = $ params [ 'limit' ] ; $ warnings = ...
Get the categories of a glossary .
28,862
public static function get_entries_by_category ( $ id , $ categoryid , $ from , $ limit , $ options ) { global $ DB ; $ params = self :: validate_parameters ( self :: get_entries_by_category_parameters ( ) , array ( 'id' => $ id , 'categoryid' => $ categoryid , 'from' => $ from , 'limit' => $ limit , 'options' => $ opt...
Browse a glossary entries by category .
28,863
public static function get_authors ( $ id , $ from , $ limit , $ options ) { global $ PAGE ; $ params = self :: validate_parameters ( self :: get_authors_parameters ( ) , array ( 'id' => $ id , 'from' => $ from , 'limit' => $ limit , 'options' => $ options , ) ) ; $ id = $ params [ 'id' ] ; $ from = $ params [ 'from' ]...
Get the authors of a glossary .
28,864
public static function get_entries_by_search ( $ id , $ query , $ fullsearch , $ order , $ sort , $ from , $ limit , $ options ) { $ params = self :: validate_parameters ( self :: get_entries_by_search_parameters ( ) , array ( 'id' => $ id , 'query' => $ query , 'fullsearch' => $ fullsearch , 'order' => core_text :: st...
Browse a glossary entries using the search .
28,865
public static function get_entry_by_id ( $ id ) { global $ DB , $ USER ; $ params = self :: validate_parameters ( self :: get_entry_by_id_parameters ( ) , array ( 'id' => $ id ) ) ; $ id = $ params [ 'id' ] ; $ warnings = array ( ) ; $ entry = $ DB -> get_record ( 'glossary_entries' , array ( 'id' => $ id ) , '*' , MUS...
Get an entry .
28,866
public static function add_entry ( $ glossaryid , $ concept , $ definition , $ definitionformat , $ options = array ( ) ) { global $ CFG ; $ params = self :: validate_parameters ( self :: add_entry_parameters ( ) , array ( 'glossaryid' => $ glossaryid , 'concept' => $ concept , 'definition' => $ definition , 'definitio...
Add a new entry to a given glossary .
28,867
protected static function sync_course_instances ( $ courseid , $ userid ) { global $ DB ; static $ preventrecursion = false ; if ( ! $ enrols = $ DB -> get_records ( 'enrol' , array ( 'customint1' => $ courseid , 'enrol' => 'meta' ) , 'id ASC' ) ) { return ; } if ( $ preventrecursion ) { return ; } $ preventrecursion =...
Synchronise meta enrolments of this user in this course
28,868
protected static function user_not_supposed_to_be_here ( $ instance , $ ue , context_course $ context , $ plugin ) { if ( ! $ ue ) { return ; } $ userid = $ ue -> userid ; $ unenrolaction = $ plugin -> get_config ( 'unenrolaction' , ENROL_EXT_REMOVED_SUSPENDNOROLES ) ; if ( $ unenrolaction == ENROL_EXT_REMOVED_UNENROL ...
Deal with users that are not supposed to be enrolled via this instance
28,869
public function load_csv_content ( $ text , $ encoding , $ separator , $ previewrows ) { $ this -> raise_limits ( ) ; $ this -> iid = csv_import_reader :: get_new_iid ( 'grade' ) ; $ csvimport = new csv_import_reader ( $ this -> iid , 'grade' ) ; $ csvimport -> load_csv_content ( $ text , $ encoding , $ separator ) ; $...
Load CSV content for previewing .
28,870
public static function fetch_grade_items ( $ courseid ) { $ gradeitems = null ; if ( $ allgradeitems = grade_item :: fetch_all ( array ( 'courseid' => $ courseid ) ) ) { foreach ( $ allgradeitems as $ gradeitem ) { if ( $ gradeitem -> itemtype == 'course' || $ gradeitem -> itemtype == 'category' ) { continue ; } $ disp...
Gets all of the grade items in this course .
28,871
protected function trim_headers ( ) { foreach ( $ this -> headers as $ i => $ h ) { $ h = trim ( $ h ) ; $ h = clean_param ( $ h , PARAM_RAW ) ; $ this -> headers [ $ i ] = $ h ; } }
Cleans the column headers from the CSV file .
28,872
protected function insert_grade_record ( $ record , $ studentid ) { global $ DB , $ USER , $ CFG ; $ record -> importcode = $ this -> importcode ; $ record -> userid = $ studentid ; $ record -> importer = $ USER -> id ; $ gradepointmaximum = 100 ; if ( $ CFG -> unlimitedgrades ) { $ gradepointmaximum = $ CFG -> gradepo...
Inserts a record into the grade_import_values table . This also adds common record information .
28,873
protected function import_new_grade_item ( $ header , $ key , $ value ) { global $ DB , $ USER ; if ( empty ( $ this -> newgradeitems [ $ key ] ) ) { $ newgradeitem = new stdClass ( ) ; $ newgradeitem -> itemname = $ header [ $ key ] ; $ newgradeitem -> importcode = $ this -> importcode ; $ newgradeitem -> importer = $...
Insert the new grade into the grade item buffer table .
28,874
protected function check_user_exists ( $ value , $ userfields ) { global $ DB ; $ user = null ; $ errorkey = false ; try { $ field = $ userfields [ 'field' ] ; $ caseinsensitivefields = [ 'email' , 'username' , ] ; if ( in_array ( $ field , $ caseinsensitivefields ) ) { $ select = $ DB -> sql_equal ( $ field , ':' . $ ...
Check that the user is in the system .
28,875
protected function create_feedback ( $ courseid , $ itemid , $ value ) { if ( ! new grade_item ( array ( 'id' => $ itemid , 'courseid' => $ courseid ) ) ) { $ this -> cleanup_import ( get_string ( 'importfailed' , 'grades' ) ) ; return null ; } $ feedback = new stdClass ( ) ; $ feedback -> itemid = $ itemid ; $ feedbac...
Check to see if the feedback matches a grade item .
28,876
protected function update_grade_item ( $ courseid , $ map , $ key , $ verbosescales , $ value ) { if ( ! $ gradeitem = new grade_item ( array ( 'id' => $ map [ $ key ] , 'courseid' => $ courseid ) ) ) { $ this -> cleanup_import ( get_string ( 'importfailed' , 'grades' ) ) ; return null ; } if ( $ gradeitem -> is_locked...
This updates existing grade items .
28,877
protected function cleanup_import ( $ notification ) { $ this -> status = false ; import_cleanup ( $ this -> importcode ) ; $ this -> gradebookerrors [ ] = $ notification ; }
Clean up failed CSV grade import . Clears the temp table for inserting grades .
28,878
protected function map_user_data_with_value ( $ mappingidentifier , $ value , $ header , $ map , $ key , $ courseid , $ feedbackgradeid , $ verbosescales ) { $ userfields = array ( 'userid' => array ( 'field' => 'id' , 'label' => 'id' , ) , 'useridnumber' => array ( 'field' => 'idnumber' , 'label' => 'idnumber' , ) , '...
Check user mapping .
28,879
public function start ( ) { $ ci = 0 ; echo '<table id="uuresults" class="generaltable boxaligncenter flexible-wrap" summary="' . get_string ( 'uploadusersresult' , 'tool_uploaduser' ) . '">' ; echo '<tr class="heading r0">' ; echo '<th class="header c' . $ ci ++ . '" scope="col">' . get_string ( 'status' ) . '</th>' ;...
Print table header .
28,880
public function flush ( ) { if ( empty ( $ this -> _row ) or empty ( $ this -> _row [ 'line' ] [ 'normal' ] ) ) { $ this -> _row = array ( ) ; foreach ( $ this -> columns as $ col ) { $ this -> _row [ $ col ] = array ( 'normal' => '' , 'info' => '' , 'warning' => '' , 'error' => '' ) ; } return ; } $ ci = 0 ; $ ri = 1 ...
Flush previous line and start a new one .
28,881
public function track ( $ col , $ msg , $ level = 'normal' , $ merge = true ) { if ( empty ( $ this -> _row ) ) { $ this -> flush ( ) ; } if ( ! in_array ( $ col , $ this -> columns ) ) { debugging ( 'Incorrect column:' . $ col ) ; return ; } if ( $ merge ) { if ( $ this -> _row [ $ col ] [ $ level ] != '' ) { $ this -...
Add tracking info
28,882
public function get_filecontent ( $ path ) { $ fullpath = $ this -> tempdir . '/' . $ path ; if ( is_file ( $ fullpath ) && is_readable ( $ fullpath ) ) { return file_get_contents ( $ fullpath ) ; } return false ; }
Return the content of a file given by its path in the tempdir directory .
28,883
public static function parse_URL ( $ url ) { $ params = parse_url ( $ url ) ; $ params [ 'extras' ] = array ( ) ; if ( isset ( $ params [ 'query' ] ) ) { parse_str ( $ params [ 'query' ] , $ params [ 'extras' ] ) ; } return $ params ; }
Parse a URL into an array
28,884
public function export_for_template ( \ renderer_base $ output ) { $ result = ( object ) [ 'name' => $ this -> tour -> get_tour_key ( ) , 'steps' => [ ] , ] ; foreach ( $ this -> tour -> get_steps ( ) as $ step ) { $ result -> steps [ ] = ( new step ( $ step ) ) -> export_for_template ( $ output ) ; } return $ result ;...
Prepare the data for export .
28,885
public static function getStream ( & $ string ) { if ( ! self :: $ _id ) { stream_wrapper_register ( self :: WRAPPER_NAME , __CLASS__ ) ; } $ ob = new stdClass ; $ ob -> string = & $ string ; return fopen ( self :: WRAPPER_NAME . '://' . ++ self :: $ _id , 'wb' , false , stream_context_create ( array ( self :: WRAPPER_...
Create a stream from a PHP string .
28,886
public static function doExecute ( Google_Client $ client , Google_Http_Request $ req ) { $ httpRequest = $ client -> getIo ( ) -> makeRequest ( $ req ) ; $ httpRequest -> setExpectedClass ( $ req -> getExpectedClass ( ) ) ; return self :: decodeHttpResponse ( $ httpRequest , $ client ) ; }
Executes a Google_Http_Request
28,887
public static function create_from_user_competency_viewed_in_course ( user_competency_course $ usercompetencycourse ) { if ( ! $ usercompetencycourse -> get ( 'id' ) ) { throw new \ coding_exception ( 'The user competency course ID must be set.' ) ; } $ params = array ( 'objectid' => $ usercompetencycourse -> get ( 'id...
Convenience method to instantiate the event in course .
28,888
public function load_optional_fields ( ) { global $ DB ; foreach ( $ this -> optional_fields as $ field => $ default ) { if ( property_exists ( $ this , $ field ) ) { continue ; } if ( empty ( $ this -> id ) ) { $ this -> $ field = $ default ; } else { $ this -> $ field = $ DB -> get_field ( $ this -> table , $ field ,...
Makes sure all the optional fields are loaded .
28,889
protected static function fetch_helper ( $ table , $ classname , $ params ) { if ( $ instances = self :: fetch_all_helper ( $ table , $ classname , $ params ) ) { if ( count ( $ instances ) > 1 ) { print_error ( 'morethanonerecordinfetch' , 'debug' ) ; } return reset ( $ instances ) ; } else { return false ; } }
Factory method - uses the parameters to retrieve matching instance from the DB .
28,890
public static function fetch_all_helper ( $ table , $ classname , $ params ) { $ instance = new $ classname ( ) ; $ classvars = ( array ) $ instance ; $ params = ( array ) $ params ; $ wheresql = array ( ) ; $ dbparams = array ( ) ; foreach ( $ params as $ var => $ value ) { if ( ! in_array ( $ var , $ instance -> requ...
Factory method - uses the parameters to retrieve all matching instances from the DB .
28,891
public function get_record_data ( ) { $ data = new stdClass ( ) ; foreach ( $ this as $ var => $ value ) { if ( in_array ( $ var , $ this -> required_fields ) or array_key_exists ( $ var , $ this -> optional_fields ) ) { if ( is_object ( $ value ) or is_array ( $ value ) ) { debugging ( "Incorrect property '$var' found...
Returns object with fields and values that are defined in database
28,892
protected static function get_plugin_handlers ( $ type , moodle1_converter $ converter ) { global $ CFG ; $ handlers = array ( ) ; $ plugins = core_component :: get_plugin_list ( $ type ) ; foreach ( $ plugins as $ name => $ dir ) { $ handlerfile = $ dir . '/backup/moodle1/lib.php' ; $ handlerclass = "moodle1_{$type}_{...
Runs through all plugins of a specific type and instantiates their handlers
28,893
protected function close_xml_writer ( ) { if ( $ this -> xmlwriter instanceof xml_writer ) { $ this -> xmlwriter -> stop ( ) ; } unset ( $ this -> xmlwriter ) ; $ this -> xmlwriter = null ; $ this -> xmlfilename = null ; }
Close the XML writer
28,894
protected function write_xml ( $ element , array $ data , array $ attribs = array ( ) , $ parent = '/' ) { if ( ! $ this -> has_xml_writer ( ) ) { throw new moodle1_convert_exception ( 'write_xml_without_writer' ) ; } $ mypath = $ parent . $ element ; $ myattribs = array ( ) ; foreach ( $ data as $ name => $ value ) { ...
Writes the given XML tree data into the currently opened file
28,895
protected function make_sure_xml_exists ( $ filename , $ rootelement = false , $ content = array ( ) ) { $ existed = file_exists ( $ this -> converter -> get_workdir_path ( ) . '/' . $ filename ) ; if ( $ existed ) { return true ; } if ( $ rootelement !== false ) { $ this -> open_xml_writer ( $ filename ) ; $ this -> w...
Makes sure that a new XML file exists or creates it itself
28,896
protected function migrate_course_files ( ) { $ ids = array ( ) ; $ fileman = $ this -> converter -> get_file_manager ( $ this -> converter -> get_contextid ( CONTEXT_COURSE ) , 'course' , 'legacy' ) ; $ this -> converter -> set_stash ( 'course_files_ids' , array ( ) ) ; if ( file_exists ( $ this -> converter -> get_te...
Migrates course_files in the converter workdir
28,897
public function on_course_modules_end ( ) { foreach ( $ this -> converter -> get_stash ( 'modnameslist' ) as $ modname ) { $ modinfo = $ this -> converter -> get_stash ( 'modinfo_' . $ modname ) ; foreach ( $ modinfo [ 'instances' ] as $ modinstanceid => $ modinstance ) { $ cminfo = $ this -> converter -> get_stash ( '...
Writes the information collected by mod handlers
28,898
public function process_roles_role ( $ data ) { if ( ! $ this -> has_xml_writer ( ) ) { $ this -> open_xml_writer ( 'roles.xml' ) ; $ this -> xmlwriter -> begin_tag ( 'roles_definition' ) ; } if ( ! isset ( $ data [ 'nameincourse' ] ) ) { $ data [ 'nameincourse' ] = null ; } $ this -> write_xml ( 'role' , $ data , arra...
If there are any roles defined in moodle . xml convert them to roles . xml
28,899
public function on_roles_end ( ) { if ( ! $ this -> has_xml_writer ( ) ) { $ this -> open_xml_writer ( 'roles.xml' ) ; $ this -> write_xml ( 'roles_definition' , array ( ) ) ; } else { $ this -> xmlwriter -> end_tag ( 'roles_definition' ) ; } $ this -> close_xml_writer ( ) ; }
Finishes writing roles . xml