idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
26,800 | protected function generate_message ( $ subscriptionid , \ stdClass $ eventobj ) { try { $ subscription = subscription_manager :: get_subscription ( $ subscriptionid ) ; } catch ( \ dml_exception $ e ) { return false ; } $ user = \ core_user :: get_user ( $ subscription -> userid ) ; if ( empty ( $ user ) ) { return fa... | Generates the message object for a give subscription and event . |
26,801 | protected function replace_placeholders ( $ template , subscription $ subscription , $ eventobj , $ context ) { $ template = str_replace ( '{link}' , $ eventobj -> link , $ template ) ; if ( $ eventobj -> contextlevel == CONTEXT_MODULE && ! empty ( $ eventobj -> contextinstanceid ) && ( strpos ( $ template , '{moduleli... | Replace place holders in the template with respective content . |
26,802 | public function is_disabled ( ) { $ lockedgrade = $ lockedgradeitem = 0 ; if ( ! empty ( $ this -> grade -> locked ) ) { $ lockedgrade = 1 ; } if ( ! empty ( $ this -> grade -> grade_item -> locked ) ) { $ lockedgradeitem = 1 ; } return ( $ lockedgrade || $ lockedgradeitem ) ; } | Is this input disabled |
26,803 | public function get_label ( ) { if ( ! isset ( $ this -> grade -> label ) ) { $ this -> grade -> label = '' ; } return $ this -> grade -> label ; } | Get the label for this form element . |
26,804 | public function determine_format ( ) { if ( ! $ this -> grade -> grade_item -> is_overridable_item ( ) ) { return new empty_element ( ) ; } return new checkbox_attribute ( $ this -> get_name ( ) , $ this -> get_label ( ) , $ this -> is_checked ( ) , $ this -> is_disabled ( ) ) ; } | Generate the element for this form input . |
26,805 | public function set ( $ value ) { if ( empty ( $ this -> grade -> id ) ) { return false ; } $ state = $ value == 0 ? false : true ; $ this -> grade -> set_overridden ( $ state ) ; $ this -> grade -> grade_item -> force_regrading ( ) ; return false ; } | Save the modified value of this form element . |
26,806 | public function is_editing_the_frontpage ( ) { $ ctxconditions = $ this -> page -> context -> contextlevel == CONTEXT_COURSE && $ this -> page -> context -> instanceid == get_site ( ) -> id ; $ issiteindex = ( strpos ( $ this -> page -> pagetype , 'site-index' ) === 0 ) ; return ( $ ctxconditions && $ issiteindex ) ; } | Returns true if the user is editing a frontpage . |
26,807 | public function allow_unenrol_user ( stdClass $ instance , stdClass $ ue ) { if ( $ ue -> status == ENROL_USER_SUSPENDED ) { return true ; } return false ; } | Does this plugin allow manual unenrolment of a specific user? Yes but only if user suspended ... |
26,808 | protected function db_init ( ) { global $ CFG ; require_once ( $ CFG -> libdir . '/adodb/adodb.inc.php' ) ; $ extdb = ADONewConnection ( $ this -> get_config ( 'dbtype' ) ) ; if ( $ this -> get_config ( 'debugdb' ) ) { $ extdb -> debug = true ; ob_start ( ) ; } if ( ! $ extdb -> IsConnected ( ) ) { $ result = $ extdb -... | Tries to make connection to the external database . |
26,809 | public function add_entry ( portfolio_format_leap2a_entry $ entry ) { if ( array_key_exists ( $ entry -> id , $ this -> entries ) ) { if ( ! ( $ entry instanceof portfolio_format_leap2a_file ) ) { throw new portfolio_format_leap2a_exception ( 'leap2a_entryalreadyexists' , 'portfolio' , '' , $ entry -> id ) ; } } $ this... | Adds a entry to the feed ready to be exported |
26,810 | public function make_selection ( $ selectionentry , $ ids , $ selectiontype ) { $ selectionid = null ; if ( $ selectionentry instanceof portfolio_format_leap2a_entry ) { $ selectionid = $ selectionentry -> id ; } else if ( is_string ( $ selectionentry ) ) { $ selectionid = $ selectionentry ; } if ( ! array_key_exists (... | Select an entry that has previously been added into the feed |
26,811 | public function link_files ( $ entry , $ files ) { foreach ( $ files as $ file ) { $ fileentry = new portfolio_format_leap2a_file ( $ file -> get_filename ( ) , $ file ) ; $ this -> add_entry ( $ fileentry ) ; $ entry -> add_link ( $ fileentry , 'related' ) ; $ fileentry -> add_link ( $ entry , 'related' ) ; } } | Helper function to link some stored_files into the feed and link them to a particular entry |
26,812 | private function validate ( ) { foreach ( $ this -> entries as $ entry ) { $ entry -> validate ( ) ; foreach ( $ entry -> links as $ linkedid => $ rel ) { if ( ! array_key_exists ( $ linkedid , $ this -> entries ) ) { $ a = ( object ) array ( 'rel' => $ rel -> type , 'to' => $ linkedid , 'from' => $ entry -> id ) ; thr... | Validate the feed and all entries |
26,813 | public function to_xml ( ) { $ this -> validate ( ) ; foreach ( $ this -> entries as $ entry ) { $ entry -> id = 'portfolio:' . $ entry -> id ; $ this -> feed -> appendChild ( $ entry -> to_dom ( $ this -> dom , $ this -> user ) ) ; } return $ this -> dom -> saveXML ( ) ; } | Return the entire feed as a string . Then it calls for validation |
26,814 | public function validate ( ) { foreach ( $ this -> requiredfields as $ key ) { if ( empty ( $ this -> { $ key } ) ) { throw new portfolio_format_leap2a_exception ( 'leap2a_missingfield' , 'portfolio' , '' , $ key ) ; } } if ( $ this -> type == 'selection' ) { if ( count ( $ this -> links ) == 0 ) { throw new portfolio_... | Validate this entry . At the moment this just makes sure required fields exist but it could also check things against a list for example |
26,815 | protected function add_extra_links ( $ dom , $ entry ) { $ link = $ dom -> createElement ( 'link' ) ; $ link -> setAttribute ( 'rel' , 'enclosure' ) ; $ link -> setAttribute ( 'href' , portfolio_format_leap2a :: get_file_directory ( ) . $ this -> referencedfile -> get_filename ( ) ) ; $ link -> setAttribute ( 'length' ... | Implement the hook to add extra links to attach the file in an enclosure |
26,816 | public function get_maximum_tries ( ) { $ max = 1 ; foreach ( $ this -> get_variant_nos ( ) as $ variantno ) { foreach ( $ this -> get_subpart_ids ( $ variantno ) as $ subpartid ) { $ max = max ( $ max , $ this -> get_analysis_for_subpart ( $ variantno , $ subpartid ) -> get_maximum_tries ( ) ) ; } } return $ max ; } | What is the highest number of tries at this question? |
26,817 | public static function get_pages_by_courses ( $ courseids = array ( ) ) { $ warnings = array ( ) ; $ returnedpages = array ( ) ; $ params = array ( 'courseids' => $ courseids , ) ; $ params = self :: validate_parameters ( self :: get_pages_by_courses_parameters ( ) , $ params ) ; $ mycourses = array ( ) ; if ( empty ( ... | Returns a list of pages in a provided list of courses . If no list is provided all pages that the user can view will be returned . |
26,818 | public function execute ( ) { global $ DB ; $ lifetime = get_config ( 'tool_recyclebin' , 'categorybinexpiry' ) ; if ( ! \ tool_recyclebin \ category_bin :: is_enabled ( ) || $ lifetime <= 0 ) { return true ; } $ items = $ DB -> get_recordset_select ( 'tool_recyclebin_category' , 'timecreated <= :timecreated' , array (... | Delete all expired items . |
26,819 | public function throwParseError ( $ msg = 'parse error' ) { list ( $ line , ) = $ this -> getSourcePosition ( $ this -> count ) ; $ loc = empty ( $ this -> sourceName ) ? "line: $line" : "$this->sourceName on line $line" ; if ( $ this -> peek ( "(.*?)(\n|$)" , $ m , $ this -> count ) ) { throw new ParserException ( "$m... | Throw parser error |
26,820 | public function parseValue ( $ buffer , & $ out ) { $ this -> count = 0 ; $ this -> env = null ; $ this -> inParens = false ; $ this -> eatWhiteDefault = true ; $ this -> buffer = ( string ) $ buffer ; $ this -> saveEncoding ( ) ; $ list = $ this -> valueList ( $ out ) ; $ this -> restoreEncoding ( ) ; return $ list ; ... | Parse a value or value list |
26,821 | public function parseSelector ( $ buffer , & $ out ) { $ this -> count = 0 ; $ this -> env = null ; $ this -> inParens = false ; $ this -> eatWhiteDefault = true ; $ this -> buffer = ( string ) $ buffer ; $ this -> saveEncoding ( ) ; $ selector = $ this -> selectors ( $ out ) ; $ this -> restoreEncoding ( ) ; return $ ... | Parse a selector or selector list |
26,822 | protected function peek ( $ regex , & $ out , $ from = null ) { if ( ! isset ( $ from ) ) { $ from = $ this -> count ; } $ r = '/' . $ regex . '/' . $ this -> patternModifiers ; $ result = preg_match ( $ r , $ this -> buffer , $ out , null , $ from ) ; return $ result ; } | Peek input stream |
26,823 | protected function matchString ( & $ m , $ delim ) { $ token = null ; $ end = strlen ( $ this -> buffer ) ; foreach ( [ '#{' , '\\' , $ delim ] as $ lookahead ) { $ pos = strpos ( $ this -> buffer , $ lookahead , $ this -> count ) ; if ( $ pos !== false && $ pos < $ end ) { $ end = $ pos ; $ token = $ lookahead ; } } i... | Match string looking for either ending delim escape or string interpolation |
26,824 | protected function literal ( $ what , $ eatWhitespace = null ) { if ( ! isset ( $ eatWhitespace ) ) { $ eatWhitespace = $ this -> eatWhiteDefault ; } $ len = strlen ( $ what ) ; if ( strcasecmp ( substr ( $ this -> buffer , $ this -> count , $ len ) , $ what ) === 0 ) { $ this -> count += $ len ; if ( $ eatWhitespace )... | Match literal string |
26,825 | protected function whitespace ( ) { $ gotWhite = false ; while ( preg_match ( static :: $ whitePattern , $ this -> buffer , $ m , null , $ this -> count ) ) { if ( isset ( $ m [ 1 ] ) && empty ( $ this -> commentsSeen [ $ this -> count ] ) ) { $ this -> appendComment ( [ Type :: T_COMMENT , $ m [ 1 ] ] ) ; $ this -> co... | Match some whitespace |
26,826 | protected function appendComment ( $ comment ) { $ comment [ 1 ] = substr ( preg_replace ( [ '/^\s+/m' , '/^(.)/m' ] , [ '' , ' \1' ] , $ comment [ 1 ] ) , 1 ) ; $ this -> env -> comments [ ] = $ comment ; } | Append comment to current block |
26,827 | protected function append ( $ statement , $ pos = null ) { if ( $ pos !== null ) { list ( $ line , $ column ) = $ this -> getSourcePosition ( $ pos ) ; $ statement [ static :: SOURCE_LINE ] = $ line ; $ statement [ static :: SOURCE_COLUMN ] = $ column ; $ statement [ static :: SOURCE_INDEX ] = $ this -> sourceIndex ; }... | Append statement to current block |
26,828 | protected function last ( ) { $ i = count ( $ this -> env -> children ) - 1 ; if ( isset ( $ this -> env -> children [ $ i ] ) ) { return $ this -> env -> children [ $ i ] ; } } | Returns last child was appended |
26,829 | protected function expHelper ( $ lhs , $ minP ) { $ operators = static :: $ operatorPattern ; $ ss = $ this -> seek ( ) ; $ whiteBefore = isset ( $ this -> buffer [ $ this -> count - 1 ] ) && ctype_space ( $ this -> buffer [ $ this -> count - 1 ] ) ; while ( $ this -> match ( $ operators , $ m , false ) && static :: $ ... | Parse left - hand side of subexpression |
26,830 | protected function parenValue ( & $ out ) { $ s = $ this -> seek ( ) ; $ inParens = $ this -> inParens ; if ( $ this -> literal ( '(' ) ) { if ( $ this -> literal ( ')' ) ) { $ out = [ Type :: T_LIST , '' , [ ] ] ; return true ; } $ this -> inParens = true ; if ( $ this -> expression ( $ exp ) && $ this -> literal ( ')... | Parse parenthesized value |
26,831 | protected function selectors ( & $ out ) { $ s = $ this -> seek ( ) ; $ selectors = [ ] ; while ( $ this -> selector ( $ sel ) ) { $ selectors [ ] = $ sel ; if ( ! $ this -> literal ( ',' ) ) { break ; } while ( $ this -> literal ( ',' ) ) { ; } } if ( count ( $ selectors ) === 0 ) { $ this -> seek ( $ s ) ; return fal... | Parse comma separated selector list |
26,832 | protected function selector ( & $ out ) { $ selector = [ ] ; for ( ; ; ) { if ( $ this -> match ( '[>+~]+' , $ m ) ) { $ selector [ ] = [ $ m [ 0 ] ] ; continue ; } if ( $ this -> selectorSingle ( $ part ) ) { $ selector [ ] = $ part ; $ this -> match ( '\s+' , $ m ) ; continue ; } if ( $ this -> match ( '\/[^\/]+\/' ,... | Parse whitespace separated selector list |
26,833 | protected function placeholder ( & $ placeholder ) { if ( $ this -> match ( $ this -> utf8 ? '([\pL\w\-_]+|#[{][$][\pL\w\-_]+[}])' : '([\w\-_]+|#[{][$][\w\-_]+[}])' , $ m ) ) { $ placeholder = $ m [ 1 ] ; return true ; } return false ; } | Parse a placeholder |
26,834 | protected function url ( & $ out ) { if ( $ this -> match ( '(url\(\s*(["\']?)([^)]+)\2\s*\))' , $ m ) ) { $ out = [ Type :: T_STRING , '' , [ 'url(' . $ m [ 2 ] . $ m [ 3 ] . $ m [ 2 ] . ')' ] ] ; return true ; } return false ; } | Parse a url |
26,835 | protected function stripAssignmentFlags ( & $ value ) { $ flags = [ ] ; for ( $ token = & $ value ; $ token [ 0 ] === Type :: T_LIST && ( $ s = count ( $ token [ 2 ] ) ) ; $ token = & $ lastNode ) { $ lastNode = & $ token [ 2 ] [ $ s - 1 ] ; while ( $ lastNode [ 0 ] === Type :: T_KEYWORD && in_array ( $ lastNode [ 1 ] ... | Strip assignment flag from the list |
26,836 | protected function stripOptionalFlag ( & $ selectors ) { $ optional = false ; $ selector = end ( $ selectors ) ; $ part = end ( $ selector ) ; if ( $ part === [ '!optional' ] ) { array_pop ( $ selectors [ count ( $ selectors ) - 1 ] ) ; $ optional = true ; } return $ optional ; } | Strip optional flag from selector list |
26,837 | protected function flattenList ( $ value ) { if ( $ value [ 0 ] === Type :: T_LIST && count ( $ value [ 2 ] ) === 1 ) { return $ this -> flattenList ( $ value [ 2 ] [ 0 ] ) ; } return $ value ; } | Turn list of length 1 into value type |
26,838 | private function extractLineNumbers ( $ buffer ) { $ this -> sourcePositions = [ 0 => 0 ] ; $ prev = 0 ; while ( ( $ pos = strpos ( $ buffer , "\n" , $ prev ) ) !== false ) { $ this -> sourcePositions [ ] = $ pos ; $ prev = $ pos + 1 ; } $ this -> sourcePositions [ ] = strlen ( $ buffer ) ; if ( substr ( $ buffer , - 1... | Extract line numbers from buffer |
26,839 | private function saveEncoding ( ) { if ( version_compare ( PHP_VERSION , '7.2.0' ) >= 0 ) { return ; } $ iniDirective = 'mbstring' . '.func_overload' ; if ( ini_get ( $ iniDirective ) & 2 ) { $ this -> encoding = mb_internal_encoding ( ) ; mb_internal_encoding ( 'iso-8859-1' ) ; } } | Save internal encoding |
26,840 | public static function get ( $ course , $ hiddenparams , array $ allowedqtypes = null ) { $ realqtypes = array ( ) ; $ fakeqtypes = array ( ) ; foreach ( question_bank :: get_creatable_qtypes ( ) as $ qtypename => $ qtype ) { if ( $ allowedqtypes && ! in_array ( $ qtypename , $ allowedqtypes ) ) { continue ; } if ( $ q... | Get an instance of the question bank chooser . |
26,841 | public static function get_instance_fields_data ( array $ fields , int $ instanceid , bool $ adddefaults = true ) : array { return self :: get_instances_fields_data ( $ fields , [ $ instanceid ] , $ adddefaults ) [ $ instanceid ] ; } | For the given instance and list of fields fields retrieves data associated with them |
26,842 | public static function get_instances_fields_data ( array $ fields , array $ instanceids , bool $ adddefaults = true ) : array { global $ DB ; $ result = array_fill_keys ( $ instanceids , array_fill_keys ( array_keys ( $ fields ) , null ) ) ; if ( empty ( $ instanceids ) || empty ( $ fields ) ) { return $ result ; } lis... | For given list of instances and fields retrieves data associated with them |
26,843 | public static function get_available_field_types ( ) { $ fieldtypes = array ( ) ; $ plugins = \ core \ plugininfo \ customfield :: get_enabled_plugins ( ) ; foreach ( $ plugins as $ type => $ unused ) { $ fieldtypes [ $ type ] = get_string ( 'pluginname' , 'customfield_' . $ type ) ; } asort ( $ fieldtypes ) ; return $... | Retrieve a list of all available custom field types |
26,844 | public static function save_field_configuration ( field_controller $ field , \ stdClass $ formdata ) { foreach ( $ formdata as $ key => $ value ) { if ( $ key === 'configdata' && is_array ( $ formdata -> configdata ) ) { $ field -> set ( $ key , json_encode ( $ value ) ) ; } else if ( $ key === 'id' || ( $ key === 'typ... | Updates or creates a field with data that came from a form |
26,845 | public static function delete_field_configuration ( field_controller $ field ) : bool { $ event = field_deleted :: create_from_object ( $ field ) ; get_file_storage ( ) -> delete_area_files ( $ field -> get_handler ( ) -> get_configuration_context ( ) -> id , 'core_customfield' , 'description' , $ field -> get ( 'id' )... | Delete a field |
26,846 | public static function get_category_inplace_editable ( category_controller $ category , bool $ editable = true ) : inplace_editable { return new inplace_editable ( 'core_customfield' , 'category' , $ category -> get ( 'id' ) , $ editable , $ category -> get_formatted_name ( ) , $ category -> get ( 'name' ) , get_string... | Returns an object for inplace editable |
26,847 | public static function move_category ( category_controller $ category , int $ beforeid = 0 ) { global $ DB ; $ records = $ DB -> get_records ( category :: TABLE , [ 'component' => $ category -> get ( 'component' ) , 'area' => $ category -> get ( 'area' ) , 'itemid' => $ category -> get ( 'itemid' ) ] , 'sortorder, id' ... | Reorder categories move given category before another category |
26,848 | public static function save_category ( category_controller $ category ) { $ isnewcategory = empty ( $ category -> get ( 'id' ) ) ; $ category -> save ( ) ; if ( $ isnewcategory ) { self :: move_category ( $ category ) ; category_created :: create_from_object ( $ category ) -> trigger ( ) ; } else { category_updated :: ... | Insert or update custom field category |
26,849 | public static function delete_category ( category_controller $ category ) : bool { $ event = category_deleted :: create_from_object ( $ category ) ; foreach ( $ category -> get_fields ( ) as $ field ) { self :: delete_field_configuration ( $ field ) ; } $ result = $ category -> delete ( ) ; $ event -> trigger ( ) ; ret... | Delete a custom field category |
26,850 | public static function get_categories_with_fields ( string $ component , string $ area , int $ itemid ) : array { global $ DB ; $ categories = [ ] ; $ options = [ 'component' => $ component , 'area' => $ area , 'itemid' => $ itemid ] ; $ plugins = \ core \ plugininfo \ customfield :: get_enabled_plugins ( ) ; list ( $ ... | Returns a list of categories with their related fields . |
26,851 | public function build ( $ interchange , $ hash ) { if ( ! $ hash instanceof HTMLPurifier_StringHash ) { $ hash = new HTMLPurifier_StringHash ( $ hash ) ; } if ( ! isset ( $ hash [ 'ID' ] ) ) { throw new HTMLPurifier_ConfigSchema_Exception ( 'Hash does not have any ID' ) ; } if ( strpos ( $ hash [ 'ID' ] , '.' ) === fal... | Builds an interchange object based on a hash . |
26,852 | protected function _findUnused ( $ hash ) { $ accessed = $ hash -> getAccessed ( ) ; foreach ( $ hash as $ k => $ v ) { if ( ! isset ( $ accessed [ $ k ] ) ) { trigger_error ( "String hash key '$k' not used by builder" , E_USER_NOTICE ) ; } } } | Triggers errors for any unused keys passed in the hash ; such keys may indicate typos missing values etc . |
26,853 | protected function get_all_groupings ( $ courseid ) { global $ DB ; if ( $ courseid != $ this -> allgroupingscourseid ) { $ this -> allgroupings = $ DB -> get_records ( 'groupings' , array ( 'courseid' => $ courseid ) , 'id, name' ) ; $ this -> allgroupingscourseid = $ courseid ; } return $ this -> allgroupings ; } | Gets all the groupings on the course . |
26,854 | protected function extra_validation ( $ data , $ files , array & $ errors ) { $ newerrors = array ( ) ; if ( isset ( $ errors [ 'scaleconfiguration' ] ) && ! isset ( $ errors [ 'scaleid' ] ) ) { $ newerrors [ 'scaleid' ] = $ errors [ 'scaleconfiguration' ] ; unset ( $ errors [ 'scaleconfiguration' ] ) ; } return $ newe... | Extra validation . |
26,855 | public static function is_tgz_file ( $ archivefile ) { if ( is_a ( $ archivefile , 'stored_file' ) ) { $ fp = $ archivefile -> get_content_file_handle ( ) ; } else { $ fp = fopen ( $ archivefile , 'rb' ) ; } $ firstbytes = fread ( $ fp , 2 ) ; fclose ( $ fp ) ; return ( $ firstbytes [ 0 ] == "\x1f" && $ firstbytes [ 1 ... | Checks whether a file appears to be a . tar . gz file . |
26,856 | public static function localize ( $ formula ) { $ formula = str_replace ( '.' , '$' , $ formula ) ; $ formula = str_replace ( ',' , get_string ( 'listsep' , 'langconfig' ) , $ formula ) ; $ formula = str_replace ( '$' , get_string ( 'decsep' , 'langconfig' ) , $ formula ) ; return $ formula ; } | Similar to format_float formats the numbers and list separators according to locale specifics . |
26,857 | public static function unlocalize ( $ formula ) { $ formula = str_replace ( get_string ( 'decsep' , 'langconfig' ) , '$' , $ formula ) ; $ formula = str_replace ( get_string ( 'listsep' , 'langconfig' ) , ',' , $ formula ) ; $ formula = str_replace ( '$' , '.' , $ formula ) ; return $ formula ; } | Similar to unformat_float converts floats and lists to PHP standards . |
26,858 | static private function encode_links_helper ( $ content , $ name , $ path ) { global $ CFG ; $ root = $ CFG -> wwwroot ; $ httpsroot = str_replace ( 'http://' , 'https://' , $ root ) ; $ httproot = str_replace ( 'https://' , 'http://' , $ root ) ; $ httpsbase = preg_quote ( $ httpsroot . $ path , '/' ) ; $ httpbase = p... | Helper method used by encode_content_links . |
26,859 | protected static function has_marked_assignment_submissions ( $ assignmentid , $ userid ) { global $ DB ; $ params = [ 'assignment' => $ assignmentid , 'teacher' => $ userid ] ; $ sql = "SELECT count(s.id) as nomarked FROM {assignment_submissions} s WHERE s.assignment = :assignment ... | Helper function to check if a user has marked assignment submissions for a given assignment . |
26,860 | protected static function get_assignment_by_context ( $ context ) { global $ DB ; $ params = [ 'modulename' => 'assignment' , 'contextmodule' => CONTEXT_MODULE , 'contextid' => $ context -> id ] ; $ sql = "SELECT a.id, a.name, a.intro, a.assignmenttype, ... | Helper function to return assignment for a context module . |
26,861 | protected static function get_assignment_output ( $ assignmentdata ) { $ assignment = ( object ) [ 'name' => $ assignmentdata -> name , 'intro' => $ assignmentdata -> intro , 'assignmenttype' => $ assignmentdata -> assignmenttype , 'grade' => $ assignmentdata -> grade , 'timemodified' => transform :: datetime ( $ assig... | Helper function generate assignment output object for exporting . |
26,862 | protected static function get_assignment_submission_output ( $ submissiondata ) { $ submission = ( object ) [ 'assignment' => $ submissiondata -> assignment , 'numfiles' => $ submissiondata -> numfiles , 'data1' => $ submissiondata -> data1 , 'data2' => $ submissiondata -> data2 , 'grade' => $ submissiondata -> grade ,... | Helper function generate assignment submission output object for exporting . |
26,863 | public static function get_policy_version ( $ versionid , $ behalfid = null ) { global $ PAGE ; $ result = [ ] ; $ warnings = [ ] ; $ params = external_api :: validate_parameters ( self :: get_policy_version_parameters ( ) , [ 'versionid' => $ versionid , 'behalfid' => $ behalfid ] ) ; $ versionid = $ params [ 'version... | Fetch the details of a policy version . |
26,864 | public static function submit_accept_on_behalf ( $ jsonformdata ) { $ params = self :: validate_parameters ( self :: submit_accept_on_behalf_parameters ( ) , [ 'jsonformdata' => $ jsonformdata ] ) ; self :: validate_context ( context_system :: instance ( ) ) ; $ serialiseddata = json_decode ( $ params [ 'jsonformdata' ... | Submit the create group form . |
26,865 | public function parseFile ( $ file ) { if ( ! file_exists ( $ file ) ) { return false ; } $ fh = fopen ( $ file , 'r' ) ; if ( ! $ fh ) { return false ; } $ ret = $ this -> parseHandle ( $ fh ) ; fclose ( $ fh ) ; return $ ret ; } | Parses a file that contains a single string - hash . |
26,866 | protected function parseHandle ( $ fh ) { $ state = false ; $ single = false ; $ ret = array ( ) ; do { $ line = fgets ( $ fh ) ; if ( $ line === false ) { break ; } $ line = rtrim ( $ line , "\n\r" ) ; if ( ! $ state && $ line === '' ) { continue ; } if ( $ line === '----' ) { break ; } if ( strncmp ( '--#' , $ line ,... | Internal parser that acepts a file handle . |
26,867 | protected function prepareContextStack ( $ context = null ) { $ stack = new Mustache_Context ( ) ; $ helpers = $ this -> mustache -> getHelpers ( ) ; if ( ! $ helpers -> isEmpty ( ) ) { $ stack -> push ( $ helpers ) ; } if ( ! empty ( $ context ) ) { $ stack -> push ( $ context ) ; } return $ stack ; } | Helper method to prepare the Context stack . |
26,868 | protected function resolveValue ( $ value , Mustache_Context $ context ) { if ( ( $ this -> strictCallables ? is_object ( $ value ) : ! is_string ( $ value ) ) && is_callable ( $ value ) ) { return $ this -> mustache -> loadLambda ( ( string ) call_user_func ( $ value ) ) -> renderInternal ( $ context ) ; } return $ va... | Resolve a context value . |
26,869 | public function validation ( $ data , $ files ) { global $ CFG , $ DB ; $ errors = parent :: validation ( $ data , $ files ) ; $ data = ( object ) $ data ; $ duplicate = $ DB -> get_field ( 'user_info_category' , 'id' , array ( 'name' => $ data -> name ) ) ; if ( ! empty ( $ data -> id ) ) { $ olddata = $ DB -> get_rec... | Perform some moodle validation . |
26,870 | public static function sort ( array $ records , array $ fields ) { $ records = new coursecat_sortable_records ( $ records ) ; $ records -> sortfields = $ fields ; $ records -> uasort ( array ( $ records , 'sort_by_many_fields' ) ) ; return $ records -> getArrayCopy ( ) ; } | Sorts this array using the given fields . |
26,871 | public function sort_by_many_fields ( $ a , $ b ) { foreach ( $ this -> sortfields as $ field => $ mult ) { if ( is_null ( $ a -> $ field ) && ! is_null ( $ b -> $ field ) ) { return - $ mult ; } if ( is_null ( $ b -> $ field ) && ! is_null ( $ a -> $ field ) ) { return $ mult ; } if ( is_string ( $ a -> $ field ) || i... | Sorts the two records based upon many fields . |
26,872 | protected function encode_request ( $ functionname , $ params ) { $ outputoptions = array ( 'encoding' => 'utf-8' , 'escaping' => 'markup' , ) ; $ params = array_values ( $ params ) ; return xmlrpc_encode_request ( $ functionname , $ params , $ outputoptions ) ; } | Generates XML for a method request . |
26,873 | protected function decode_response ( $ response ) { $ method = null ; $ encoding = null ; if ( preg_match ( '/^<\?xml version="1.0" encoding="([^"]*)"\?>/' , $ response , $ matches ) ) { $ encoding = $ matches [ 1 ] ; } $ r = xmlrpc_decode_request ( $ response , $ method , $ encoding ) ; return $ r ; } | Parses and decodes the response XML |
26,874 | protected static function is_minimum_version_met ( ) { global $ CFG ; $ currentversion = 0 ; $ supportedversion = 0.7 ; $ unoconvbin = \ escapeshellarg ( $ CFG -> pathtounoconv ) ; $ command = "$unoconvbin --version" ; exec ( $ command , $ output ) ; if ( $ output ) { foreach ( $ output as $ response ) { if ( preg_matc... | Whether the minimum version of unoconv has been met . |
26,875 | protected static function is_format_supported ( $ format ) { $ formats = self :: fetch_supported_formats ( ) ; $ format = trim ( \ core_text :: strtolower ( $ format ) ) ; return in_array ( $ format , $ formats ) ; } | Whether the specified file format is supported . |
26,876 | protected static function fetch_supported_formats ( ) { global $ CFG ; if ( ! isset ( self :: $ formats ) ) { $ cmd = escapeshellcmd ( trim ( $ CFG -> pathtounoconv ) ) . ' --show' ; $ pipes = array ( ) ; $ pipesspec = array ( 2 => array ( 'pipe' , 'w' ) ) ; $ proc = proc_open ( $ cmd , $ pipesspec , $ pipes ) ; $ prog... | Fetch the list of supported file formats . |
26,877 | public function handler_close ( ) { try { foreach ( $ this -> locks as $ id => $ expirytime ) { if ( $ expirytime > $ this -> time ( ) ) { $ this -> unlock_session ( $ id ) ; } unset ( $ this -> locks [ $ id ] ) ; } } catch ( RedisException $ e ) { error_log ( 'Failed talking to redis: ' . $ e -> getMessage ( ) ) ; ret... | Close the session completely . We also remove all locks we may have obtained that aren t expired . |
26,878 | public function handler_read ( $ id ) { try { $ this -> lock_session ( $ id ) ; $ sessiondata = $ this -> connection -> get ( $ id ) ; if ( $ sessiondata === false ) { $ this -> unlock_session ( $ id ) ; return '' ; } $ this -> connection -> expire ( $ id , $ this -> timeout ) ; } catch ( RedisException $ e ) { error_l... | Read the session data from storage |
26,879 | public function handler_write ( $ id , $ data ) { if ( is_null ( $ this -> connection ) ) { error_log ( 'Tried to write session: ' . $ id . ' before open or after close.' ) ; return false ; } try { $ this -> connection -> setex ( $ id , $ this -> timeout , $ data ) ; } catch ( RedisException $ e ) { error_log ( 'Failed... | Write the serialized session data to our session store . |
26,880 | public function handler_destroy ( $ id ) { try { $ this -> connection -> del ( $ id ) ; $ this -> unlock_session ( $ id ) ; } catch ( RedisException $ e ) { error_log ( 'Failed talking to redis: ' . $ e -> getMessage ( ) ) ; return false ; } return true ; } | Handle destroying a session . |
26,881 | protected function unlock_session ( $ id ) { if ( isset ( $ this -> locks [ $ id ] ) ) { $ this -> connection -> del ( $ id . ".lock" ) ; unset ( $ this -> locks [ $ id ] ) ; } } | Unlock a session . |
26,882 | protected function lock_session ( $ id ) { $ lockkey = $ id . ".lock" ; $ haslock = isset ( $ this -> locks [ $ id ] ) && $ this -> time ( ) < $ this -> locks [ $ id ] ; $ startlocktime = $ this -> time ( ) ; while ( ! $ haslock ) { $ haslock = $ this -> connection -> setnx ( $ lockkey , '1' ) ; if ( ! $ haslock ) { us... | Obtain a session lock so we are the only one using it at the moent . |
26,883 | public function process ( ) { if ( $ this -> progress >= self :: PROGRESS_PROCESSED ) { throw new backup_ui_exception ( 'backupuialreadyprocessed' ) ; } $ this -> progress = self :: PROGRESS_PROCESSED ; if ( optional_param ( 'previous' , false , PARAM_BOOL ) && $ this -> stage -> get_stage ( ) > $ this -> get_first_sta... | This processes the current stage of the backup |
26,884 | public function save_controller ( ) { if ( $ this -> progress >= self :: PROGRESS_SAVED ) { throw new base_ui_exception ( 'backupuialreadysaved' ) ; } $ this -> progress = self :: PROGRESS_SAVED ; $ this -> enforce_dependencies ( ) ; $ this -> controller -> process_ui_event ( ) ; $ this -> controller -> save_controller... | Saves the backup controller . |
26,885 | public function display ( core_backup_renderer $ renderer ) { if ( $ this -> progress < self :: PROGRESS_SAVED ) { throw new base_ui_exception ( 'backupsavebeforedisplay' ) ; } return $ this -> stage -> display ( $ renderer ) ; } | Displays the UI for the backup! |
26,886 | protected function enforce_dependencies ( ) { $ plan = $ this -> controller -> get_plan ( ) ; $ tasks = $ plan -> get_tasks ( ) ; $ changes = 0 ; foreach ( $ tasks as & $ task ) { $ settings = $ task -> get_settings ( ) ; foreach ( $ settings as & $ setting ) { $ dependencies = $ setting -> get_dependencies ( ) ; forea... | Enforces dependencies on all settings . Call before save |
26,887 | public function get_setting ( $ name , $ default = false ) { try { return $ this -> controller -> get_plan ( ) -> get_setting ( $ name ) ; } catch ( Exception $ e ) { debugging ( 'Failed to find the setting: ' . $ name , DEBUG_DEVELOPER ) ; return $ default ; } } | Gets the requested setting |
26,888 | protected function processDeclaration ( $ node ) { $ selectors = $ node instanceof \ Sabberworm \ CSS \ RuleSet \ DeclarationBlock ? $ node -> getSelectors ( ) : [ ] ; foreach ( $ selectors as $ selector ) { if ( strpos ( $ selector -> getSelector ( ) , '.dir-rtl' ) !== false ) { return ; } } return parent :: processDe... | Process a block declaration . |
26,889 | protected function is_user_setup ( $ user ) { if ( ! isset ( $ this -> userssetupcache [ $ user -> id ] ) ) { $ this -> userssetupcache [ $ user -> id ] = ! user_not_fully_set_up ( $ user , true ) ; } return $ this -> userssetupcache [ $ user -> id ] ; } | Determines whether a user is fully set up using cached results where possible . |
26,890 | protected function user_can_access_course ( $ user , $ course , $ capability ) { if ( ! isset ( $ this -> courseaccesscache [ $ course -> id ] [ $ user -> id ] [ $ capability ] ) ) { $ this -> courseaccesscache [ $ course -> id ] [ $ user -> id ] [ $ capability ] = can_access_course ( $ course , $ user , $ capability ,... | Determines a user s access to a course with a given capability using cached results where possible . |
26,891 | protected function get_subscription_from_rowdata ( $ rowdata ) { $ sub = new \ stdClass ( ) ; $ sub -> id = $ rowdata -> subid ; $ sub -> userid = $ rowdata -> subuserid ; $ sub -> courseid = $ rowdata -> subcourseid ; $ sub -> cmid = $ rowdata -> subcmid ; $ sub -> inactivedate = $ rowdata -> subinactivedate ; return ... | Returns a partial subscription record created from properties of the supplied recordset row object . Intended to return a minimal record for specific use within this class and in subsequent access control calls only . |
26,892 | protected function get_course_from_rowdata ( $ rowdata ) { $ course = new \ stdClass ( ) ; $ course -> id = $ rowdata -> subcourseid ; $ course -> visible = $ rowdata -> coursevisible ; $ course -> cacherev = $ rowdata -> coursecacherev ; return $ course ; } | Returns a partial course record created from properties of the supplied recordset row object . Intended to return a minimal record for specific use within this class and in subsequent access control calls only . |
26,893 | protected function get_user_from_rowdata ( $ rowdata ) { $ user = new \ stdClass ( ) ; $ user -> id = $ rowdata -> userid ; $ user -> firstname = $ rowdata -> userfirstname ; $ user -> lastname = $ rowdata -> userlastname ; $ user -> email = $ rowdata -> useremail ; $ user -> suspended = $ rowdata -> usersuspended ; re... | Returns a partial user record created from properties of the supplied recordset row object . Intended to return a minimal record for specific use within this class and in subsequent access control calls only . |
26,894 | public function execute ( ) { global $ CFG ; require_once ( $ CFG -> dirroot . '/mod/assign/locallib.php' ) ; \ assign :: cron ( ) ; $ plugins = \ core_component :: get_plugin_list ( 'assignsubmission' ) ; foreach ( $ plugins as $ name => $ plugin ) { $ disabled = get_config ( 'assignsubmission_' . $ name , 'disabled' ... | Run assignment cron . |
26,895 | public static function detect_format ( $ tempdir ) { global $ CFG ; $ tempdirpath = make_backup_temp_directory ( $ tempdir , false ) ; $ filepath = $ tempdirpath . '/moodle.xml' ; if ( file_exists ( $ filepath ) ) { $ handle = fopen ( $ filepath , 'r' ) ; $ first_chars = fread ( $ handle , 200 ) ; fclose ( $ handle ) ;... | Detects the Moodle 1 . 9 format of the backup directory |
26,896 | protected function init ( ) { parent :: init ( ) ; $ this -> log ( 'initializing ' . $ this -> get_name ( ) . ' converter' , backup :: LOG_INFO ) ; $ this -> log ( 'setting xml parser' , backup :: LOG_DEBUG , null , 1 ) ; $ this -> xmlparser = new progressive_parser ( ) ; $ this -> xmlparser -> set_file ( $ this -> get... | Initialize the instance if needed called by the constructor |
26,897 | protected function execute ( ) { $ this -> log ( 'creating the stash storage' , backup :: LOG_DEBUG ) ; $ this -> create_stash_storage ( ) ; $ this -> log ( 'parsing moodle.xml starts' , backup :: LOG_DEBUG ) ; $ this -> xmlparser -> process ( ) ; $ this -> log ( 'parsing moodle.xml done' , backup :: LOG_DEBUG ) ; $ th... | Converts the contents of the tempdir into the target format in the workdir |
26,898 | protected function register_handler ( moodle1_handler $ handler , array $ elements ) { $ names = array ( ) ; $ paths = array ( ) ; foreach ( $ elements as $ element ) { if ( ! $ element instanceof convert_path ) { throw new convert_exception ( 'path_element_wrong_class' , get_class ( $ element ) ) ; } if ( array_key_ex... | Register a handler for the given path elements |
26,899 | public function process_chunk ( $ data ) { $ path = $ data [ 'path' ] ; if ( $ path === '/MOODLE_BACKUP/COURSE/MODULES/MOD' ) { $ this -> currentmod = strtoupper ( $ data [ 'tags' ] [ 'MODTYPE' ] ) ; $ path = '/MOODLE_BACKUP/COURSE/MODULES/MOD/' . $ this -> currentmod ; } else if ( strpos ( $ path , '/MOODLE_BACKUP/COU... | Process the data obtained from the XML parser processor |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.