idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
34,500 | public function get_start ( ) { if ( $ this -> starttime !== null ) { return $ this -> starttime ; } if ( ! empty ( $ this -> get_course_data ( ) -> startdate ) ) { $ this -> starttime = ( int ) $ this -> get_course_data ( ) -> startdate ; } else { $ this -> starttime = 0 ; } return $ this -> starttime ; } | Get the course start timestamp . |
34,501 | public function guess_start ( ) { global $ DB ; if ( ! $ this -> get_total_logs ( ) ) { return 0 ; } if ( ! $ logstore = \ core_analytics \ manager :: get_analytics_logstore ( ) ) { return 0 ; } $ firstlogs = array ( ) ; foreach ( $ this -> get_students ( ) as $ studentid ) { $ select = "userid = :userid AND contextlev... | Guesses the start of the course based on students activity and enrolment start dates . |
34,502 | public function was_started ( ) { if ( $ this -> started === null ) { if ( $ this -> get_start ( ) === 0 || $ this -> now < $ this -> get_start ( ) ) { $ this -> started = false ; } else { $ this -> started = true ; } } return $ this -> started ; } | Has the course started? |
34,503 | public function is_finished ( ) { if ( $ this -> finished === null ) { $ endtime = $ this -> get_end ( ) ; if ( $ endtime === 0 || $ this -> now < $ endtime ) { $ this -> finished = false ; } else { $ this -> finished = true ; } } return $ this -> finished ; } | Has the course finished? |
34,504 | public function get_user_ids ( $ roleids ) { $ records = get_role_users ( $ roleids , $ this -> get_context ( ) , true , 'ra.id, u.id AS userid, r.id AS roleid' , 'ra.id ASC' ) ; $ callable = array ( $ this , 'filter_user_id' ) ; $ userids = array_values ( array_map ( $ callable , $ records ) ) ; return array_combine (... | Returns a list of user ids matching the specified roles in this course . |
34,505 | public function get_total_logs ( ) { global $ DB ; if ( empty ( $ this -> get_students ( ) ) ) { return 0 ; } if ( $ this -> ntotallogs === null ) { list ( $ filterselect , $ filterparams ) = $ this -> course_students_query_filter ( ) ; if ( ! $ logstore = \ core_analytics \ manager :: get_analytics_logstore ( ) ) { $ ... | Returns the total number of student logs in the course |
34,506 | public function get_all_activities ( $ activitytype ) { if ( ! isset ( $ this -> courseactivities [ $ activitytype ] ) ) { $ modinfo = get_fast_modinfo ( $ this -> get_course_data ( ) , - 1 ) ; $ instances = $ modinfo -> get_instances_of ( $ activitytype ) ; if ( $ instances ) { $ this -> courseactivities [ $ activityt... | Returns all the activities of the provided type the course has . |
34,507 | public function get_student_grades ( $ courseactivities ) { if ( empty ( $ courseactivities ) ) { return array ( ) ; } $ grades = array ( ) ; foreach ( $ courseactivities as $ contextid => $ instance ) { $ gradesinfo = grade_get_grades ( $ this -> course -> id , 'mod' , $ instance -> modname , $ instance -> instance , ... | Returns the course students grades . |
34,508 | protected function update_loop_times ( $ start , $ end ) { $ avg = intval ( ( $ start + $ end ) / 2 ) ; return array ( $ start , $ avg , $ end ) ; } | Returns the average time between 2 timestamps . |
34,509 | protected function course_students_query_filter ( $ prefix = false ) { global $ DB ; if ( $ prefix ) { $ prefix = $ prefix . '.' ; } list ( $ studentssql , $ studentsparams ) = $ DB -> get_in_or_equal ( $ this -> get_students ( ) , SQL_PARAMS_NAMED ) ; $ filterselect = $ prefix . 'courseid = :courseid AND ' . $ prefix ... | Returns the query and params used to filter the logstore by this course students . |
34,510 | public function getTable ( $ tablename ) { $ i = $ this -> findTableInArray ( $ tablename ) ; if ( $ i !== null ) { return $ this -> tables [ $ i ] ; } return null ; } | Returns one xmldb_table |
34,511 | public function findTableInArray ( $ tablename ) { foreach ( $ this -> tables as $ i => $ table ) { if ( $ tablename == $ table -> getName ( ) ) { return $ i ; } } return null ; } | Returns the position of one table in the array . |
34,512 | public function orderTables ( ) { $ result = $ this -> orderElements ( $ this -> tables ) ; if ( $ result ) { $ this -> setTables ( $ result ) ; return true ; } else { return false ; } } | This function will reorder the array of tables |
34,513 | public function addTable ( $ table , $ after = null ) { $ prevtable = null ; $ nexttable = null ; if ( ! $ after ) { if ( $ this -> tables ) { end ( $ this -> tables ) ; $ prevtable = $ this -> tables [ key ( $ this -> tables ) ] ; } } else { $ prevtable = $ this -> getTable ( $ after ) ; } if ( $ prevtable && $ prevta... | Add one table to the structure allowing to specify the desired order If it s not specified then the table is added at the end . |
34,514 | public function deleteTable ( $ tablename ) { $ table = $ this -> getTable ( $ tablename ) ; if ( $ table ) { $ i = $ this -> findTableInArray ( $ tablename ) ; $ prevtable = $ this -> getTable ( $ table -> getPrevious ( ) ) ; $ nexttable = $ this -> getTable ( $ table -> getNext ( ) ) ; if ( $ prevtable ) { $ prevtabl... | Delete one table from the Structure |
34,515 | public function calculateHash ( $ recursive = false ) { if ( ! $ this -> loaded ) { $ this -> hash = null ; } else { $ key = $ this -> name . $ this -> path . $ this -> comment ; if ( $ this -> tables ) { foreach ( $ this -> tables as $ tbl ) { $ table = $ this -> getTable ( $ tbl -> getName ( ) ) ; if ( $ recursive ) ... | This function calculate and set the hash of one xmldb_structure |
34,516 | public function xmlOutput ( ) { $ o = '<?xml version="1.0" encoding="UTF-8" ?>' . "\n" ; $ o .= '<XMLDB PATH="' . $ this -> path . '"' ; $ o .= ' VERSION="' . $ this -> version . '"' ; if ( $ this -> comment ) { $ o .= ' COMMENT="' . htmlspecialchars ( $ this -> comment ) . '"' . "\n" ; } $ rel = array_fill ( 0 , count... | This function will output the XML text for one structure |
34,517 | public function getTableUses ( $ tablename ) { $ uses = array ( ) ; if ( $ this -> tables ) { foreach ( $ this -> tables as $ table ) { $ keys = $ table -> getKeys ( ) ; if ( $ keys ) { foreach ( $ keys as $ key ) { if ( $ key -> getType ( ) == XMLDB_KEY_FOREIGN ) { if ( $ tablename == $ key -> getRefTable ( ) ) { $ us... | This function returns the number of uses of one table inside a whole XMLDStructure . Useful to detect if the table must be locked . Return false if no uses are found . |
34,518 | public function getFieldUses ( $ tablename , $ fieldname ) { $ uses = array ( ) ; $ table = $ this -> getTable ( $ tablename ) ; if ( $ keys = $ table -> getKeys ( ) ) { foreach ( $ keys as $ key ) { if ( in_array ( $ fieldname , $ key -> getFields ( ) ) || in_array ( $ fieldname , $ key -> getRefFields ( ) ) ) { $ use... | This function returns the number of uses of one field inside a whole xmldb_structure . Useful to detect if the field must be locked . Return false if no uses are found . |
34,519 | public function getKeyUses ( $ tablename , $ keyname ) { $ uses = array ( ) ; $ mytable = $ this -> getTable ( $ tablename ) ; $ mykey = $ mytable -> getKey ( $ keyname ) ; if ( $ this -> tables && $ mykey ) { foreach ( $ this -> tables as $ table ) { $ allkeys = $ table -> getKeys ( ) ; if ( $ allkeys ) { foreach ( $ ... | This function returns the number of uses of one key inside a whole xmldb_structure . Useful to detect if the key must be locked . Return false if no uses are found . |
34,520 | public function getAllErrors ( ) { $ errors = array ( ) ; if ( $ this -> getError ( ) ) { $ errors [ ] = $ this -> getError ( ) ; } if ( $ this -> tables ) { foreach ( $ this -> tables as $ table ) { if ( $ tableerrors = $ table -> getAllErrors ( ) ) { } } if ( $ tableerrors ) { $ errors = array_merge ( $ errors , $ ta... | This function will return all the errors found in one structure looking recursively inside each table . Returns an array of errors or false |
34,521 | public static function prepare ( $ data = null ) { if ( $ data === null ) { $ data = new stdClass ; } $ data = file_prepare_standard_editor ( $ data , 'summary' , self :: summary_editor_options ( ) ) ; return $ data ; } | Static function to prepare the summary editor for working with a course request . |
34,522 | public static function create ( $ data ) { global $ USER , $ DB , $ CFG ; $ data -> requester = $ USER -> id ; if ( empty ( $ data -> category ) || empty ( $ CFG -> requestcategoryselection ) ) { $ data -> category = $ CFG -> defaultrequestcategory ; } $ data -> summary = $ data -> summary_editor [ 'text' ] ; $ data ->... | Static function to create a new course request when passed an array of properties for it . |
34,523 | public function get_requester ( ) { global $ DB ; static $ requesters = array ( ) ; if ( ! array_key_exists ( $ this -> properties -> requester , $ requesters ) ) { $ requesters [ $ this -> properties -> requester ] = $ DB -> get_record ( 'user' , array ( 'id' => $ this -> properties -> requester ) ) ; } return $ reque... | Returns the user who requested this course |
34,524 | public function check_shortname_collision ( $ shortnamemark = '[*]' ) { global $ DB ; if ( $ this -> properties -> collision !== null ) { return $ this -> properties -> collision ; } if ( empty ( $ this -> properties -> shortname ) ) { debugging ( 'Attempting to check a course request shortname before it has been set' ... | Checks that the shortname used by the course does not conflict with any other courses that exist |
34,525 | public function get_category ( ) { global $ CFG ; if ( empty ( $ this -> properties -> category ) || ! has_capability ( 'moodle/course:changecategory' , context_system :: instance ( ) ) || ( ! $ category = core_course_category :: get ( $ this -> properties -> category , IGNORE_MISSING , true ) ) ) { $ category = core_c... | Returns the category where this course request should be created |
34,526 | public function reject ( $ notice ) { global $ USER , $ DB ; $ user = $ DB -> get_record ( 'user' , array ( 'id' => $ this -> properties -> requester ) , '*' , MUST_EXIST ) ; $ this -> notify ( $ user , $ USER , 'courserequestrejected' , get_string ( 'courserejectsubject' ) , get_string ( 'courserejectemail' , 'moodle'... | Reject a course request |
34,527 | protected function notify ( $ touser , $ fromuser , $ name = 'courserequested' , $ subject , $ message , $ courseid = null ) { $ eventdata = new \ core \ message \ message ( ) ; $ eventdata -> courseid = empty ( $ courseid ) ? SITEID : $ courseid ; $ eventdata -> component = 'moodle' ; $ eventdata -> name = $ name ; $ ... | Send a message from one user to another using events_trigger |
34,528 | protected function getObjective ( ) { $ sum = 0.0 ; $ distance = new Euclidean ( ) ; for ( $ i = 0 ; $ i < $ this -> clustersNumber ; ++ $ i ) { $ clust = $ this -> clusters [ $ i ] -> getCoordinates ( ) ; for ( $ k = 0 ; $ k < $ this -> sampleCount ; ++ $ k ) { $ point = $ this -> samples [ $ k ] ; $ sum += $ distance... | The objective is to minimize the distance between all data points and all cluster centers . This method returns the summation of all these distances |
34,529 | public function get_doc_url ( \ core_search \ document $ doc ) { global $ USER ; $ entry = $ this -> get_entry ( $ doc -> get ( 'itemid' ) ) ; $ contextmodule = \ context :: instance_by_id ( $ doc -> get ( 'contextid' ) ) ; if ( $ entry -> approved == false && $ entry -> userid != $ USER -> id ) { $ docparams = array (... | Link to glossary entry . |
34,530 | protected function get_entry ( $ entryid ) { global $ DB ; if ( empty ( $ this -> entriesdata [ $ entryid ] ) ) { $ this -> entriesdata [ $ entryid ] = $ DB -> get_record_sql ( "SELECT ge.*, g.course, g.defaultapproval FROM {glossary_entries} ge JOIN {glo... | Returns the specified glossary entry checking the internal cache . |
34,531 | protected static function export_data_content ( $ context , $ recordobj , $ fieldobj , $ contentobj ) { $ value = ( object ) [ 'field' => [ 'name' => $ fieldobj -> name , 'description' => $ fieldobj -> description , 'type' => $ fieldobj -> type , 'required' => transform :: yesno ( $ fieldobj -> required ) , ] , 'conten... | Export one field answer in a record in database activity module |
34,532 | protected static function export_data ( $ context , $ user ) { if ( ! $ context ) { return ; } $ contextdata = helper :: get_context_data ( $ context , $ user ) ; helper :: export_context_files ( $ context , $ user ) ; writer :: with_context ( $ context ) -> export_data ( [ ] , $ contextdata ) ; } | Export basic info about database activity module |
34,533 | protected static function delete_data_records ( $ context , $ recordstobedeleted ) { global $ DB ; if ( empty ( $ recordstobedeleted ) ) { return ; } list ( $ sql , $ params ) = $ DB -> get_in_or_equal ( $ recordstobedeleted , SQL_PARAMS_NAMED ) ; get_file_storage ( ) -> delete_area_files_select ( $ context -> id , 'mo... | Deletes records marked for deletion and all associated data |
34,534 | public static function make ( $ component , $ area , array $ identifiers = array ( ) , $ unused = null ) { $ factory = cache_factory :: instance ( ) ; return $ factory -> create_cache_from_definition ( $ component , $ area , $ identifiers ) ; } | Creates a new cache instance for a pre - defined definition . |
34,535 | public static function make_from_params ( $ mode , $ component , $ area , array $ identifiers = array ( ) , array $ options = array ( ) ) { $ factory = cache_factory :: instance ( ) ; return $ factory -> create_cache_from_params ( $ mode , $ component , $ area , $ identifiers , $ options ) ; } | Creates a new cache instance based upon the given params . |
34,536 | protected function set_is_sub_loader ( $ setting = true ) { if ( $ setting ) { $ this -> subloader = true ; $ this -> staticacceleration = false ; $ this -> staticaccelerationsize = false ; } else { $ this -> subloader = true ; $ this -> staticacceleration = $ this -> definition -> use_static_acceleration ( ) ; if ( $ ... | Used to inform the loader of its state as a sub loader or as the top of the chain . |
34,537 | public function set_identifiers ( array $ identifiers ) { if ( $ this -> definition -> set_identifiers ( $ identifiers ) ) { $ this -> staticaccelerationarray = array ( ) ; if ( $ this -> staticaccelerationsize !== false ) { $ this -> staticaccelerationkeys = array ( ) ; $ this -> staticaccelerationcount = 0 ; } } } | Alters the identifiers that have been provided to the definition . |
34,538 | protected function handle_invalidation_events ( ) { if ( ! $ this -> definition -> has_invalidation_events ( ) ) { return ; } $ lastinvalidation = $ this -> get ( 'lastinvalidation' ) ; if ( $ lastinvalidation === false ) { $ this -> set ( 'lastinvalidation' , self :: get_purge_token ( ) ) ; return ; } else if ( $ last... | Process any outstanding invalidation events for the cache we are registering |
34,539 | protected function unref ( $ data ) { if ( $ this -> definition -> uses_simple_data ( ) ) { return $ data ; } if ( $ this -> requires_serialisation ( $ data ) ) { $ data = serialize ( $ data ) ; $ data = unserialize ( $ data ) ; } else if ( ! is_scalar ( $ data ) ) { $ data = $ this -> deep_clone ( $ data ) ; } return ... | Removes references where required . |
34,540 | protected function requires_serialisation ( $ value , $ depth = 1 ) { if ( is_scalar ( $ value ) ) { return false ; } else if ( is_array ( $ value ) || $ value instanceof stdClass || $ value instanceof Traversable ) { if ( $ depth > 5 ) { return true ; } foreach ( $ value as $ key => $ subvalue ) { if ( $ this -> requi... | Checks to see if a var requires serialisation . |
34,541 | protected function deep_clone ( $ value ) { if ( is_object ( $ value ) ) { $ value = clone $ value ; } if ( is_array ( $ value ) || is_object ( $ value ) ) { foreach ( $ value as $ key => $ subvalue ) { $ value [ $ key ] = $ this -> deep_clone ( $ subvalue ) ; } } return $ value ; } | Creates a reference free clone of the given value . |
34,542 | protected function store_supports_native_ttl ( ) { if ( $ this -> supportsnativettl === null ) { $ this -> supportsnativettl = ( $ this -> store -> supports_native_ttl ( ) ) ; } return $ this -> supportsnativettl ; } | Returns true if the cache store supports native ttl . |
34,543 | protected function store_supports_key_awareness ( ) { if ( $ this -> supportskeyawareness === null ) { $ this -> supportskeyawareness = ( $ this -> store instanceof cache_is_key_aware ) ; } return $ this -> supportskeyawareness ; } | Returns true if the store supports key awareness . |
34,544 | protected function store_supports_native_locking ( ) { if ( $ this -> nativelocking === null ) { $ this -> nativelocking = ( $ this -> store instanceof cache_is_lockable ) ; } return $ this -> nativelocking ; } | Returns true if the store natively supports locking . |
34,545 | protected function static_acceleration_has ( $ key ) { if ( ! $ this -> staticacceleration || ! isset ( $ this -> staticaccelerationarray [ $ key ] ) ) { return false ; } return true ; } | Returns true if the requested key exists within the static acceleration array . |
34,546 | protected function static_acceleration_get ( $ key ) { if ( ! $ this -> staticacceleration || ! isset ( $ this -> staticaccelerationarray [ $ key ] ) ) { $ result = false ; } else { $ data = $ this -> staticaccelerationarray [ $ key ] [ 'data' ] ; if ( $ data instanceof cache_cached_object ) { $ result = $ data -> rest... | Returns the item from the static acceleration array if it exists there . |
34,547 | protected function static_acceleration_set ( $ key , $ data ) { if ( $ this -> staticaccelerationsize !== false && isset ( $ this -> staticaccelerationkeys [ $ key ] ) ) { $ this -> staticaccelerationcount -- ; unset ( $ this -> staticaccelerationkeys [ $ key ] ) ; } if ( is_scalar ( $ data ) || $ this -> definition ->... | Sets a key value pair into the static acceleration array . |
34,548 | protected function static_acceleration_delete ( $ key ) { unset ( $ this -> staticaccelerationarray [ $ key ] ) ; if ( $ this -> staticaccelerationsize !== false && isset ( $ this -> staticaccelerationkeys [ $ key ] ) ) { unset ( $ this -> staticaccelerationkeys [ $ key ] ) ; $ this -> staticaccelerationcount -- ; } re... | Deletes an item from the static acceleration array . |
34,549 | protected function static_acceleration_purge ( ) { $ this -> staticaccelerationarray = array ( ) ; if ( $ this -> staticaccelerationsize !== false ) { $ this -> staticaccelerationkeys = array ( ) ; $ this -> staticaccelerationcount = 0 ; } } | Purge the static acceleration cache . |
34,550 | public static function now ( $ float = false ) { if ( self :: $ now === null ) { self :: $ now = microtime ( true ) ; } if ( $ float ) { return self :: $ now ; } else { return ( int ) self :: $ now ; } } | Returns the timestamp from the first request for the time from the cache API . |
34,551 | public static function get_purge_token ( $ reset = false ) { if ( self :: $ purgetoken === null || $ reset ) { self :: $ now = null ; self :: $ purgetoken = self :: now ( true ) . '-' . uniqid ( '' , true ) ; } return self :: $ purgetoken ; } | Get a purge token used for cache invalidation handling . |
34,552 | public static function compare_purge_tokens ( $ tokena , $ tokenb ) { if ( $ tokena === $ tokenb ) { return 0 ; } list ( $ atime ) = explode ( '-' , "{$tokena}-" , 2 ) ; list ( $ btime ) = explode ( '-' , "{$tokenb}-" , 2 ) ; if ( $ atime >= $ btime ) { return 1 ; } else { return - 1 ; } } | Compare a pair of purge tokens . |
34,553 | public function get_identifier ( ) { static $ instances = 0 ; if ( $ this -> lockidentifier === null ) { $ this -> lockidentifier = md5 ( $ this -> get_definition ( ) -> generate_definition_hash ( ) . sesskey ( ) . $ instances ++ . 'cache_application' ) ; } return $ this -> lockidentifier ; } | Returns the identifier to use |
34,554 | public function acquire_lock ( $ key ) { $ key = $ this -> parse_key ( $ key ) ; if ( $ this -> nativelocking ) { return $ this -> get_store ( ) -> acquire_lock ( $ key , $ this -> get_identifier ( ) ) ; } else { $ this -> ensure_cachelock_available ( ) ; return $ this -> cachelockinstance -> lock ( $ key , $ this -> g... | Acquires a lock on the given key . |
34,555 | public function check_lock_state ( $ key ) { $ key = $ this -> parse_key ( $ key ) ; if ( $ this -> nativelocking ) { return $ this -> get_store ( ) -> check_lock_state ( $ key , $ this -> get_identifier ( ) ) ; } else { $ this -> ensure_cachelock_available ( ) ; return $ this -> cachelockinstance -> check_state ( $ ke... | Checks if this cache has a lock on the given key . |
34,556 | public function release_lock ( $ key ) { $ key = $ this -> parse_key ( $ key ) ; if ( $ this -> nativelocking ) { return $ this -> get_store ( ) -> release_lock ( $ key , $ this -> get_identifier ( ) ) ; } else { $ this -> ensure_cachelock_available ( ) ; return $ this -> cachelockinstance -> unlock ( $ key , $ this ->... | Releases the lock this cache has on the given key |
34,557 | protected function ensure_cachelock_available ( ) { if ( $ this -> cachelockinstance === null ) { $ this -> cachelockinstance = cache_helper :: get_cachelock_for_store ( $ this -> get_store ( ) ) ; } } | Ensure that the dedicated lock store is ready to go . |
34,558 | protected function check_tracked_user ( ) { if ( isset ( $ _SESSION [ 'USER' ] -> id ) && $ _SESSION [ 'USER' ] -> id !== null ) { $ new = $ _SESSION [ 'USER' ] -> id ; } else { $ new = 0 ; } if ( $ new !== self :: $ loadeduserid ) { if ( ! is_null ( self :: $ loadeduserid ) ) { $ this -> purge ( ) ; } self :: $ loaded... | Check that this cache instance is tracking the current user . |
34,559 | public function purge_current_user ( ) { $ keys = $ this -> get_store ( ) -> find_by_prefix ( $ this -> get_key_prefix ( ) ) ; $ this -> get_store ( ) -> delete_many ( $ keys ) ; } | Purges the session cache of all data belonging to the current user . |
34,560 | public function has_all ( array $ keys ) { $ this -> check_tracked_user ( ) ; if ( ( $ this -> has_a_ttl ( ) && ! $ this -> store_supports_native_ttl ( ) ) || ! $ this -> store_supports_key_awareness ( ) ) { foreach ( $ keys as $ key ) { if ( ! $ this -> has ( $ key ) ) { return false ; } } return true ; } $ store = $ ... | Test is a cache has all of the given keys . |
34,561 | public static function get ( $ mbox , $ utf7imap = false ) { return ( $ mbox instanceof Horde_Imap_Client_Mailbox ) ? $ mbox : new Horde_Imap_Client_Mailbox ( $ mbox , $ utf7imap ) ; } | Shortcut to obtaining mailbox object . |
34,562 | public function process_cdata ( $ cdata ) { global $ CFG ; if ( $ cdata === '$@NULL@$' ) { return null ; } else if ( $ cdata === '' ) { return '' ; } else if ( is_numeric ( $ cdata ) ) { return $ cdata ; } else if ( strlen ( $ cdata ) < 32 ) { return $ cdata ; } else if ( strpos ( $ cdata , '$@FILEPHP@$' ) === false ) ... | Provide NULL and legacy file . php uses decoding |
34,563 | protected function postprocess_chunk ( $ data ) { foreach ( $ data [ 'tags' ] as $ key => $ value ) { if ( trim ( $ value ) !== '' || strpos ( $ key , 'subplugin_' ) !== 0 ) { parent :: postprocess_chunk ( $ data ) ; return ; } } $ this -> chunks -- ; debugging ( 'Missing support on restore for ' . clean_param ( $ data... | Override this method so we ll be able to skip dispatching some well - known chunks like the ones being 100% part of subplugins stuff . Useful for allowing development without having all the possible restore subplugins defined |
34,564 | public function format_stem_text ( $ qa , $ stemid ) { $ question = $ qa -> get_question ( ) ; return $ question -> format_text ( $ question -> stems [ $ stemid ] , $ question -> stemformat [ $ stemid ] , $ qa , 'qtype_match' , 'subquestion' , $ stemid ) ; } | Format each question stem . Overwritten by randomsamatch renderer . |
34,565 | function create_table_php ( $ structure , $ table ) { $ result = '' ; if ( ! $ table = $ structure -> getTable ( $ table ) ) { return false ; } if ( $ table -> getAllErrors ( ) ) { return false ; } $ result .= XMLDB_PHP_HEADER ; $ result .= XMLDB_LINEFEED ; $ result .= ' // Define table ' . $ table -> getName ( ... | This function will generate all the PHP code needed to create one table using XMLDB objects and functions |
34,566 | function drop_table_php ( $ structure , $ table ) { $ result = '' ; if ( ! $ table = $ structure -> getTable ( $ table ) ) { return false ; } if ( $ table -> getAllErrors ( ) ) { return false ; } $ result .= XMLDB_PHP_HEADER ; $ result .= XMLDB_LINEFEED ; $ result .= ' // Define table ' . $ table -> getName ( ) ... | This function will generate all the PHP code needed to drop one table using XMLDB objects and functions |
34,567 | public function after_restore ( ) { global $ DB ; $ blockid = $ this -> get_blockid ( ) ; if ( $ configdata = $ DB -> get_field ( 'block_instances' , 'configdata' , array ( 'id' => $ blockid ) ) ) { $ config = unserialize ( base64_decode ( $ configdata ) ) ; $ changed = false ; if ( ! empty ( $ config -> tagcoll ) && $... | This function executed after all the tasks in the plan have been executed will remove tag collection reference in case block was restored into another site . Also get mapping of contextid . |
34,568 | public function jsonSerialize ( ) { $ data = parent :: jsonSerialize ( ) ; $ data [ 'horizontal' ] = $ this -> get_horizontal ( ) ; $ data [ 'stacked' ] = $ this -> get_stacked ( ) ; return $ data ; } | Add the horizontal to the parent and return the serialized data . |
34,569 | public static function is_extension_invalid ( $ extension , $ oldextension = '' ) { $ extension = trim ( $ extension ) ; if ( $ extension === '' || $ extension [ 0 ] === '.' ) { return true ; } $ mimeinfo = get_mimetypes_array ( ) ; if ( $ oldextension !== '' ) { unset ( $ mimeinfo [ $ oldextension ] ) ; } return array... | Checks if the given file type extension is invalid . The added file type extension must be unique and must not begin with a dot . |
34,570 | public static function is_defaulticon_allowed ( $ mimetype , $ oldextension = '' ) { $ mimeinfo = get_mimetypes_array ( ) ; if ( $ oldextension !== '' ) { unset ( $ mimeinfo [ $ oldextension ] ) ; } foreach ( $ mimeinfo as $ extension => $ values ) { if ( $ values [ 'type' ] !== $ mimetype ) { continue ; } if ( ! empty... | Checks if we are allowed to turn on the default icon option . You can only have one of these for a given MIME type . |
34,571 | public static function get_icons_from_path ( $ path ) { $ icons = array ( ) ; if ( $ handle = @ opendir ( $ path ) ) { while ( ( $ file = readdir ( $ handle ) ) !== false ) { $ matches = array ( ) ; if ( preg_match ( '~(.+?)(?:-24|-32|-48|-64|-72|-80|-96|-128|-256)?\.(?:svg|gif|png)$~' , $ file , $ matches ) ) { $ key ... | Gets all unique file type icons from a specific path not including sub - directories . |
34,572 | public function zip_plugin_folder ( $ folderpath , $ targetzip ) { if ( file_exists ( $ targetzip ) ) { throw new coding_exception ( 'Attempting to create already existing ZIP file' , $ targetzip ) ; } if ( ! is_writable ( dirname ( $ targetzip ) ) ) { throw new coding_exception ( 'Target ZIP location not writable' , d... | Make an archive backup of the existing plugin folder . |
34,573 | public function archive_plugin_version ( $ folderpath , $ component , $ version , $ overwrite = false ) { if ( $ component !== clean_param ( $ component , PARAM_SAFEDIR ) ) { throw new moodle_exception ( 'unexpected_plugin_component_format' , 'core_plugin' , '' , null , $ component ) ; } if ( ( string ) $ version !== c... | Archive the current plugin on - disk version . |
34,574 | public function get_archived_plugin_version ( $ component , $ version ) { if ( empty ( $ component ) or empty ( $ version ) ) { return false ; } $ archzip = $ this -> temproot . '/archive/' . $ component . '/' . $ version . '.zip' ; if ( file_exists ( $ archzip ) ) { return $ archzip ; } return false ; } | Return the path to the ZIP file with the archive of the given plugin version . |
34,575 | public function list_plugin_folder_files ( $ folderpath ) { $ folder = new RecursiveDirectoryIterator ( $ folderpath ) ; $ iterator = new RecursiveIteratorIterator ( $ folder ) ; $ folderpathinfo = new SplFileInfo ( $ folderpath ) ; $ strip = strlen ( $ folderpathinfo -> getPathInfo ( ) -> getRealPath ( ) ) + 1 ; $ fil... | Returns list of all files in the given directory . |
34,576 | public function get_plugin_zip_root_dir ( $ zipfilepath ) { $ fp = get_file_packer ( 'application/zip' ) ; $ files = $ fp -> list_files ( $ zipfilepath ) ; if ( empty ( $ files ) ) { return false ; } $ rootdirname = null ; foreach ( $ files as $ file ) { $ pathnameitems = explode ( '/' , $ file -> pathname ) ; if ( emp... | Detects the plugin s name from its ZIP file . |
34,577 | protected function download_plugin_zip_file ( $ url , $ tofile ) { if ( file_exists ( $ tofile ) ) { $ this -> debug ( 'Error fetching plugin ZIP: target location exists.' ) ; return false ; } $ status = $ this -> download_file_content ( $ url , $ tofile ) ; if ( ! $ status ) { $ this -> debug ( 'Error fetching plugin ... | Download the ZIP file with the plugin package from the given location |
34,578 | protected function rename_extracted_rootdir ( $ dirname , $ rootdir , array $ files ) { if ( ! is_dir ( $ dirname ) ) { $ this -> debug ( 'Unable to rename rootdir of non-existing content' ) ; return $ files ; } if ( file_exists ( $ dirname . '/' . $ rootdir ) ) { return $ files ; } $ found = null ; foreach ( scandir (... | Renames the root directory of the extracted ZIP package . |
34,579 | protected function set_plugin_files_permissions ( $ targetdir , array $ files ) { $ dirpermissions = fileperms ( $ targetdir ) ; $ filepermissions = ( $ dirpermissions & 0666 ) ; foreach ( $ files as $ subpath => $ notusedhere ) { $ path = $ targetdir . '/' . $ subpath ; if ( is_dir ( $ path ) ) { @ chmod ( $ path , $ ... | Sets the permissions of extracted subdirs and files |
34,580 | protected function move_extracted_plugin_files ( $ sourcedir , $ targetdir , array $ files ) { global $ CFG ; foreach ( $ files as $ file => $ status ) { if ( $ status !== true ) { throw new moodle_exception ( 'corrupted_archive_structure' , 'core_plugin' , '' , $ file , $ status ) ; } $ source = $ sourcedir . '/' . $ ... | Moves the extracted contents of the plugin ZIP into the target location . |
34,581 | function SelectLimit ( $ sql , $ nrows = - 1 , $ offset = - 1 , $ inputarr = false , $ secs2cache = 0 ) { $ offsetStr = ( $ offset >= 0 ) ? " OFFSET " . ( ( integer ) $ offset ) : '' ; $ limitStr = ( $ nrows >= 0 ) ? " LIMIT " . ( ( integer ) $ nrows ) : '' ; if ( $ secs2cache ) $ rs = $ this -> CacheExecute ( $ secs2c... | which makes obsolete the LIMIT limit offset syntax |
34,582 | protected function _generateMetaColumnsSQL ( $ table , $ schema ) { if ( $ schema ) { return sprintf ( $ this -> metaColumnsSQL1 , $ table , $ table , $ table , $ schema ) ; } else { return sprintf ( $ this -> metaColumnsSQL , $ table , $ table , $ schema ) ; } } | Generate the SQL to retrieve MetaColumns data |
34,583 | function _old_MetaForeignKeys ( $ table , $ owner = false , $ upper = false ) { $ sql = 'SELECT t.tgargs as args FROM pg_trigger t,pg_class c,pg_proc p WHERE t.tgenabled AND t.tgrelid = c.oid AND t.tgfoid = p.oid AND p.proname = \'RI_FKey_check_ins\' AND c.relname = \'' . strtolower ( $ table ) . '\' ORDER BY ... | from Edward Jaramilla improved version - works on pg 7 . 4 |
34,584 | function GetCharSet ( ) { $ this -> charSet = @ pg_client_encoding ( $ this -> _connectionID ) ; if ( ! $ this -> charSet ) { return false ; } else { return $ this -> charSet ; } } | it will return SQL_ANSI always |
34,585 | function SetCharSet ( $ charset_name ) { $ this -> GetCharSet ( ) ; if ( $ this -> charSet !== $ charset_name ) { $ if = pg_set_client_encoding ( $ this -> _connectionID , $ charset_name ) ; if ( $ if == "0" & $ this -> GetCharSet ( ) == $ charset_name ) { return true ; } else return false ; } else return true ; } | SetCharSet - switch the client encoding |
34,586 | public function recode_legacy_state_answer ( $ state ) { $ answer = $ state -> answer ; $ resultarr = array ( ) ; foreach ( explode ( ',' , $ answer ) as $ pair ) { $ pairarr = explode ( '-' , $ pair ) ; $ id = $ pairarr [ 0 ] ; $ code = $ pairarr [ 1 ] ; $ newid = $ this -> get_mappingid ( 'qtype_match_subquestions' ,... | Given one question_states record return the answer recoded pointing to all the restored stuff for match questions . |
34,587 | public function get_document_recordset ( $ modifiedfrom = 0 , \ context $ context = null ) { global $ DB ; list ( $ contextjoin , $ contextparams ) = $ this -> get_course_level_context_restriction_sql ( $ context , 'c' ) ; if ( $ contextjoin === null ) { return null ; } $ comparetext = $ DB -> sql_compare_text ( 'cs.su... | Returns recordset containing required data for indexing course sections . |
34,588 | public function check_access ( $ id ) { global $ DB ; $ sectionrec = $ DB -> get_record ( 'course_sections' , [ 'id' => $ id ] , '*' , IGNORE_MISSING ) ; if ( ! $ sectionrec ) { return \ core_search \ manager :: ACCESS_DELETED ; } try { $ modinfo = get_fast_modinfo ( $ sectionrec -> course ) ; } catch ( \ moodle_except... | Whether the user can access the section or not . |
34,589 | public function get_doc_url ( \ core_search \ document $ doc ) { global $ DB ; $ section = $ DB -> get_field ( 'course_sections' , 'section' , [ 'id' => $ doc -> get ( 'itemid' ) ] , MUST_EXIST ) ; $ format = course_get_format ( $ doc -> get ( 'courseid' ) ) ; return $ format -> get_view_url ( $ section ) ; } | Gets a link to the section . |
34,590 | protected function get_num_competencies_in_course ( $ courseid ) { if ( ! isset ( $ this -> coursecompetencies [ $ courseid ] ) ) { $ ccs = \ core_competency \ api :: count_competencies_in_course ( $ courseid ) ; $ this -> coursecompetencies [ $ courseid ] = $ ccs ; } else { $ ccs = $ this -> coursecompetencies [ $ cou... | Count the competencies in a course . |
34,591 | protected function calculate_sample ( $ sampleid , \ core_analytics \ analysable $ course , $ starttime = false , $ endtime = false ) { $ userenrol = $ this -> retrieve ( 'user_enrolments' , $ sampleid ) ; $ key = $ course -> get_id ( ) ; $ ccs = $ this -> get_num_competencies_in_course ( $ key ) ; $ ucs = \ core_compe... | To have the proficiency or not in each of the competencies assigned to the course sets the target value . |
34,592 | public function update ( $ ids ) { if ( empty ( $ ids ) ) { return false ; } elseif ( empty ( $ this -> _ids ) ) { $ this -> _ids = $ ids ; $ change = true ; } else { $ change = false ; foreach ( $ ids as $ k => $ v ) { if ( ! isset ( $ this -> _ids [ $ k ] ) || ( $ this -> _ids [ $ k ] != $ v ) ) { $ this -> _ids [ $ ... | Updates the mapping . |
34,593 | public function remove ( Horde_Imap_Client_Ids $ ids ) { if ( $ ids -> sequence ) { $ remove = $ ids -> ids ; } else { $ ids -> sort ( ) ; $ remove = array_reverse ( array_keys ( $ this -> lookup ( $ ids ) ) ) ; } if ( empty ( $ remove ) ) { return ; } $ this -> sort ( ) ; if ( count ( $ remove ) == count ( $ this -> _... | Removes messages from the ID mapping . |
34,594 | public function sort ( ) { if ( ! $ this -> _sorted ) { ksort ( $ this -> _ids , SORT_NUMERIC ) ; $ this -> _sorted = true ; } } | Sort the map . |
34,595 | public function get_file_info ( $ fileid ) { $ this -> reset_state ( ) ; $ result = $ this -> request ( $ this -> make_url ( "/files/$fileid" ) ) ; return json_decode ( $ result ) ; } | Get info of a file . |
34,596 | public function get_folder_items ( $ folderid = 0 ) { $ this -> reset_state ( ) ; $ result = $ this -> request ( $ this -> make_url ( "/folders/$folderid/items" , array ( 'fields' => 'id,name,type,modified_at,size,owned_by' ) ) ) ; return json_decode ( $ result ) ; } | Get a folder content . |
34,597 | public function log_out ( ) { if ( $ accesstoken = $ this -> get_accesstoken ( ) ) { $ params = array ( 'client_id' => $ this -> get_clientid ( ) , 'client_secret' => $ this -> get_clientsecret ( ) , 'token' => $ accesstoken -> token ) ; $ this -> reset_state ( ) ; $ this -> post ( $ this -> revoke_url ( ) , $ params )... | Log out . |
34,598 | protected function make_url ( $ uri , $ params = array ( ) , $ uploadapi = false ) { $ api = $ uploadapi ? self :: UPLOAD_API : self :: API ; $ url = new moodle_url ( $ api . '/' . ltrim ( $ uri , '/' ) , $ params ) ; return $ url -> out ( false ) ; } | Build a request URL . |
34,599 | public function share_file ( $ fileid , $ businesscheck = true ) { $ data = array ( 'shared_link' => array ( 'access' => 'open' , 'permissions' => array ( 'can_download' => true , 'can_preview' => true ) ) ) ; $ options = array ( 'CURLOPT_CUSTOMREQUEST' => 'PUT' , 'CURLOPT_POSTFIELDS' => json_encode ( $ data ) ) ; $ th... | Share a file and return the link to it . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.