idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
27,200 | function utf8_to_entities ( $ str ) { $ strLen = strlen ( $ str ) ; $ outStr = '' ; $ buf = '' ; for ( $ a = 0 ; $ a < $ strLen ; $ a ++ ) { $ chr = substr ( $ str , $ a , 1 ) ; $ ord = ord ( $ chr ) ; if ( $ ord > 127 ) { if ( $ ord & 64 ) { $ buf = $ chr ; for ( $ b = 0 ; $ b < 8 ; $ b ++ ) { $ ord = $ ord << 1 ; if ... | Converts all chars > 127 to numeric entities . |
27,201 | function utf8_to_numberarray ( $ str , $ convEntities = 0 , $ retChar = 0 ) { if ( $ convEntities ) { $ str = $ this -> entities_to_utf8 ( $ str , 1 ) ; } $ strLen = strlen ( $ str ) ; $ outArr = array ( ) ; $ buf = '' ; for ( $ a = 0 ; $ a < $ strLen ; $ a ++ ) { $ chr = substr ( $ str , $ a , 1 ) ; $ ord = ord ( $ ch... | Converts all chars in the input UTF - 8 string into integer numbers returned in an array |
27,202 | function utf8CharToUnumber ( $ str , $ hex = 0 ) { $ ord = ord ( substr ( $ str , 0 , 1 ) ) ; if ( ( $ ord & 192 ) == 192 ) { $ binBuf = '' ; for ( $ b = 0 ; $ b < 8 ; $ b ++ ) { $ ord = $ ord << 1 ; if ( $ ord & 128 ) { $ binBuf .= substr ( '00000000' . decbin ( ord ( substr ( $ str , $ b + 1 , 1 ) ) ) , - 6 ) ; } els... | Converts a UTF - 8 Multibyte character to a UNICODE number Unit - tested by Kasper |
27,203 | function initCaseFolding ( $ charset ) { if ( is_array ( $ this -> caseFolding [ $ charset ] ) ) { return 1 ; } $ cacheFile = t3lib_div :: getFileAbsFileName ( 'typo3temp/cs/cscase_' . $ charset . '.tbl' ) ; if ( $ cacheFile && @ is_file ( $ cacheFile ) ) { $ this -> caseFolding [ $ charset ] = unserialize ( t3lib_div ... | This function initializes the folding table for a charset other than UTF - 8 . This function is automatically called by the case folding functions . |
27,204 | function initToASCII ( $ charset ) { if ( is_array ( $ this -> toASCII [ $ charset ] ) ) { return 1 ; } $ cacheFile = t3lib_div :: getFileAbsFileName ( 'typo3temp/cs/csascii_' . $ charset . '.tbl' ) ; if ( $ cacheFile && @ is_file ( $ cacheFile ) ) { $ this -> toASCII [ $ charset ] = unserialize ( t3lib_div :: getUrl (... | This function initializes the to - ASCII conversion table for a charset other than UTF - 8 . This function is automatically called by the ASCII transliteration functions . |
27,205 | protected function cropMbstring ( $ charset , $ string , $ len , $ crop = '' ) { if ( intval ( $ len ) === 0 || mb_strlen ( $ string , $ charset ) <= abs ( $ len ) ) { return $ string ; } if ( $ len > 0 ) { $ string = mb_substr ( $ string , 0 , $ len , $ charset ) . $ crop ; } else { $ string = $ crop . mb_substr ( $ s... | Method to crop strings using the mb_substr function . |
27,206 | function strtrunc ( $ charset , $ string , $ len ) { if ( $ len <= 0 ) { return '' ; } if ( $ GLOBALS [ 'TYPO3_CONF_VARS' ] [ 'SYS' ] [ 't3lib_cs_utils' ] == 'mbstring' ) { return mb_strcut ( $ string , 0 , $ len , $ charset ) ; } elseif ( $ charset == 'utf-8' ) { return $ this -> utf8_strtrunc ( $ string , $ len ) ; }... | Cuts a string short at a given byte length . |
27,207 | function sb_char_mapping ( $ str , $ charset , $ mode , $ opt = '' ) { switch ( $ mode ) { case 'case' : if ( ! $ this -> initCaseFolding ( $ charset ) ) { return $ str ; } $ map = & $ this -> caseFolding [ $ charset ] [ $ opt ] ; break ; case 'ascii' : if ( ! $ this -> initToASCII ( $ charset ) ) { return $ str ; } $ ... | Maps all characters of a string in a single byte charset . |
27,208 | function utf8_strtrunc ( $ str , $ len ) { $ i = $ len - 1 ; if ( ord ( $ str { $ i } ) & 0x80 ) { for ( ; $ i > 0 && ! ( ord ( $ str { $ i } ) & 0x40 ) ; $ i -- ) { ; } if ( $ i <= 0 ) { return '' ; } for ( $ bc = 0 , $ mbs = ord ( $ str { $ i } ) ; $ mbs & 0x80 ; $ mbs = $ mbs << 1 ) { $ bc ++ ; } if ( $ bc + $ i > $... | Truncates a string in UTF - 8 short at a given byte length . |
27,209 | function utf8_strpos ( $ haystack , $ needle , $ offset = 0 ) { if ( $ GLOBALS [ 'TYPO3_CONF_VARS' ] [ 'SYS' ] [ 't3lib_cs_utils' ] == 'mbstring' ) { return mb_strpos ( $ haystack , $ needle , $ offset , 'utf-8' ) ; } elseif ( $ GLOBALS [ 'TYPO3_CONF_VARS' ] [ 'SYS' ] [ 't3lib_cs_utils' ] == 'iconv' ) { return iconv_st... | Find position of first occurrence of a string both arguments are in UTF - 8 . |
27,210 | function utf8_strrpos ( $ haystack , $ needle ) { if ( $ GLOBALS [ 'TYPO3_CONF_VARS' ] [ 'SYS' ] [ 't3lib_cs_utils' ] == 'mbstring' ) { return mb_strrpos ( $ haystack , $ needle , 'utf-8' ) ; } elseif ( $ GLOBALS [ 'TYPO3_CONF_VARS' ] [ 'SYS' ] [ 't3lib_cs_utils' ] == 'iconv' ) { return iconv_strrpos ( $ haystack , $ n... | Find position of last occurrence of a char in a string both arguments are in UTF - 8 . |
27,211 | function utf8_char2byte_pos ( $ str , $ pos ) { $ n = 0 ; $ p = abs ( $ pos ) ; if ( $ pos >= 0 ) { $ i = 0 ; $ d = 1 ; } else { $ i = strlen ( $ str ) - 1 ; $ d = - 1 ; } for ( ; strlen ( $ str { $ i } ) && $ n < $ p ; $ i += $ d ) { $ c = ( int ) ord ( $ str { $ i } ) ; if ( ! ( $ c & 0x80 ) ) { $ n ++ ; } elseif ( (... | Translates a character position into an absolute byte position . Unit tested by Kasper . |
27,212 | function utf8_byte2char_pos ( $ str , $ pos ) { $ n = 0 ; for ( $ i = $ pos ; $ i > 0 ; $ i -- ) { $ c = ( int ) ord ( $ str { $ i } ) ; if ( ! ( $ c & 0x80 ) ) { $ n ++ ; } elseif ( ( $ c & 0xC0 ) == 0xC0 ) { $ n ++ ; } } if ( ! strlen ( $ str { $ i } ) ) { return FALSE ; } return $ n ; } | Translates an absolute byte position into a character position . Unit tested by Kasper . |
27,213 | function utf8_char_mapping ( $ str , $ mode , $ opt = '' ) { if ( ! $ this -> initUnicodeData ( $ mode ) ) { return $ str ; } $ out = '' ; switch ( $ mode ) { case 'case' : $ map = & $ this -> caseFolding [ 'utf-8' ] [ $ opt ] ; break ; case 'ascii' : $ map = & $ this -> toASCII [ 'utf-8' ] ; break ; default : return $... | Maps all characters of an UTF - 8 string . |
27,214 | function euc_strtrunc ( $ str , $ len , $ charset ) { $ sjis = ( $ charset == 'shift_jis' ) ; for ( $ i = 0 ; strlen ( $ str { $ i } ) && $ i < $ len ; $ i ++ ) { $ c = ord ( $ str { $ i } ) ; if ( $ sjis ) { if ( ( $ c >= 0x80 && $ c < 0xA0 ) || ( $ c >= 0xE0 ) ) { $ i ++ ; } } else { if ( $ c >= 0x80 ) { $ i ++ ; } }... | Cuts a string in the EUC charset family short at a given byte length . |
27,215 | function euc_substr ( $ str , $ start , $ charset , $ len = NULL ) { $ byte_start = $ this -> euc_char2byte_pos ( $ str , $ start , $ charset ) ; if ( $ byte_start === FALSE ) { return FALSE ; } $ str = substr ( $ str , $ byte_start ) ; if ( $ len != NULL ) { $ byte_end = $ this -> euc_char2byte_pos ( $ str , $ len , $... | Returns a part of a string in the EUC charset family . |
27,216 | function euc_strlen ( $ str , $ charset ) { $ sjis = ( $ charset == 'shift_jis' ) ; $ n = 0 ; for ( $ i = 0 ; strlen ( $ str { $ i } ) ; $ i ++ ) { $ c = ord ( $ str { $ i } ) ; if ( $ sjis ) { if ( ( $ c >= 0x80 && $ c < 0xA0 ) || ( $ c >= 0xE0 ) ) { $ i ++ ; } } else { if ( $ c >= 0x80 ) { $ i ++ ; } } $ n ++ ; } ret... | Counts the number of characters of a string in the EUC charset family . |
27,217 | function euc_char2byte_pos ( $ str , $ pos , $ charset ) { $ sjis = ( $ charset == 'shift_jis' ) ; $ n = 0 ; $ p = abs ( $ pos ) ; if ( $ pos >= 0 ) { $ i = 0 ; $ d = 1 ; } else { $ i = strlen ( $ str ) - 1 ; $ d = - 1 ; } for ( ; strlen ( $ str { $ i } ) && $ n < $ p ; $ i += $ d ) { $ c = ord ( $ str { $ i } ) ; if (... | Translates a character position into an absolute byte position . |
27,218 | function euc_char_mapping ( $ str , $ charset , $ mode , $ opt = '' ) { switch ( $ mode ) { case 'case' : if ( ! $ this -> initCaseFolding ( $ charset ) ) { return $ str ; } $ map = & $ this -> caseFolding [ $ charset ] [ $ opt ] ; break ; case 'ascii' : if ( ! $ this -> initToASCII ( $ charset ) ) { return $ str ; } $... | Maps all characters of a string in the EUC charset family . |
27,219 | public function setFontColor ( $ fontColor ) { $ this -> fontColor = $ fontColor ; $ this -> hasSetFontColor = true ; $ this -> shouldApplyFont = true ; return $ this ; } | Sets the font color . |
27,220 | public function serialize ( ) { $ currentId = $ this -> id ; $ this -> setId ( 0 ) ; $ serializedStyle = serialize ( $ this ) ; $ this -> setId ( $ currentId ) ; return $ serializedStyle ; } | Serializes the style for future comparison with other styles . The ID is excluded from the comparison as we only care about actual style properties . |
27,221 | protected function from_db_records ( array $ results ) : array { $ entityfactory = $ this -> get_entity_factory ( ) ; return array_map ( function ( array $ result ) use ( $ entityfactory ) { [ 'forum' => $ forumrecord , 'course_module' => $ coursemodule , 'course' => $ course , 'context' => $ context , ] = $ result ; r... | Convert the DB records into forum entities . |
27,222 | public function get_from_course_module_id ( int $ id ) : ? forum_entity { $ records = $ this -> get_from_course_module_ids ( [ $ id ] ) ; return count ( $ records ) ? array_shift ( $ records ) : null ; } | Get the forum for the given course module id . |
27,223 | public function get_from_post_id ( int $ id ) : ? forum_entity { $ alias = $ this -> get_table_alias ( ) ; $ thistable = new dml_table ( self :: TABLE , $ alias , $ alias ) ; $ coursemoduletable = new dml_table ( 'course_modules' , 'cm' , 'cm_' ) ; $ coursetable = new dml_table ( 'course' , 'c' , 'c_' ) ; $ tablefields... | Get the forum entity for the given post id . |
27,224 | public function getU ( ) { return new Matrix ( $ this -> U , $ this -> m , min ( $ this -> m + 1 , $ this -> n ) ) ; } | Return the left singular vectors |
27,225 | public function getS ( ) { for ( $ i = 0 ; $ i < $ this -> n ; ++ $ i ) { for ( $ j = 0 ; $ j < $ this -> n ; ++ $ j ) { $ S [ $ i ] [ $ j ] = 0.0 ; } $ S [ $ i ] [ $ i ] = $ this -> s [ $ i ] ; } return new Matrix ( $ S ) ; } | Return the diagonal matrix of singular values |
27,226 | public function cond ( ) { return $ this -> s [ 0 ] / $ this -> s [ min ( $ this -> m , $ this -> n ) - 1 ] ; } | Two norm condition number |
27,227 | public function rank ( ) { $ eps = pow ( 2.0 , - 52.0 ) ; $ tol = max ( $ this -> m , $ this -> n ) * $ this -> s [ 0 ] * $ eps ; $ r = 0 ; for ( $ i = 0 ; $ i < count ( $ this -> s ) ; ++ $ i ) { if ( $ this -> s [ $ i ] > $ tol ) { ++ $ r ; } } return $ r ; } | Effective numerical matrix rank |
27,228 | public function get_js_options ( ) { $ jsoptions = '' ; foreach ( $ this -> params as $ var => $ val ) { if ( is_string ( $ val ) || is_int ( $ val ) ) { $ jsoptions .= "$var=$val," ; } elseif ( is_bool ( $ val ) ) { $ jsoptions .= ( $ val ) ? "$var," : "$var=0," ; } } $ jsoptions = substr ( $ jsoptions , 0 , strlen ( ... | Returns a string of concatenated option - > value pairs used by JS to call the popup window based on this object s variables |
27,229 | private function createCommand ( ) { $ cmd = [ 'dropIndexes' => $ this -> collectionName , 'index' => $ this -> indexName , ] ; if ( isset ( $ this -> options [ 'maxTimeMS' ] ) ) { $ cmd [ 'maxTimeMS' ] = $ this -> options [ 'maxTimeMS' ] ; } return new Command ( $ cmd ) ; } | Create the dropIndexes command . |
27,230 | public function add_database_table ( $ name , array $ privacyfields , $ summary = '' ) { $ this -> add_type ( new types \ database_table ( $ name , $ privacyfields , $ summary ) ) ; return $ this ; } | Function to add a database table which contains user data to this collection . |
27,231 | public function add_subsystem_link ( $ name , array $ privacyfields = [ ] , $ summary = '' ) { $ this -> add_type ( new types \ subsystem_link ( $ name , $ privacyfields , $ summary ) ) ; return $ this ; } | Function to link a subsystem to the component . |
27,232 | public function link_subsystem ( $ name , $ summary = '' ) { $ this -> add_type ( new types \ subsystem_link ( $ name , [ ] , $ summary ) ) ; return $ this ; } | Old function to link a subsystem to the component . |
27,233 | public function add_plugintype_link ( $ name , array $ privacyfields = [ ] , $ summary = '' ) { $ this -> add_type ( new types \ plugintype_link ( $ name , $ privacyfields , $ summary ) ) ; return $ this ; } | Function to link a plugin to the component . |
27,234 | public function link_plugintype ( $ name , $ summary = '' ) { $ this -> add_type ( new types \ plugintype_link ( $ name , [ ] , $ summary ) ) ; return $ this ; } | Old function to link a plugin to the component . |
27,235 | public function add_external_location_link ( $ name , array $ privacyfields , $ summary = '' ) { $ this -> add_type ( new types \ external_location ( $ name , $ privacyfields , $ summary ) ) ; return $ this ; } | Function to indicate that data may be exported to an external location . |
27,236 | public function link_external_location ( $ name , array $ privacyfields , $ summary = '' ) { $ this -> add_type ( new types \ external_location ( $ name , $ privacyfields , $ summary ) ) ; return $ this ; } | Old function to indicate that data may be exported to an external location . |
27,237 | public function add_user_preference ( $ name , $ summary = '' ) { $ this -> add_type ( new types \ user_preference ( $ name , $ summary ) ) ; return $ this ; } | Add a type of user preference to the collection . |
27,238 | public function process_question ( array $ data , array $ raw ) { if ( isset ( $ data [ 'randomsamatch' ] ) ) { $ randomsamatch = $ data [ 'randomsamatch' ] [ 0 ] ; } else { $ randomsamatch = array ( 'choose' => 4 ) ; } $ randomsamatch [ 'id' ] = $ this -> converter -> get_nextid ( ) ; $ randomsamatch [ 'subcats' ] = 1... | Appends the randomsamatch specific information to the question . |
27,239 | public static function get_blockids_from_moduleid ( $ moduleid ) { global $ DB ; $ contextid = context_module :: instance ( $ moduleid ) -> id ; $ blockids = array ( ) ; $ instances = $ DB -> get_records ( 'block_instances' , array ( 'parentcontextid' => $ contextid ) , '' , 'id' ) ; foreach ( $ instances as $ instance... | Given one course module id return one array with all the block intances that belong to it |
27,240 | public static function get_blockids_from_courseid ( $ courseid ) { global $ DB ; $ contextid = context_course :: instance ( $ courseid ) -> id ; $ blockids = array ( ) ; $ instances = $ DB -> get_records ( 'block_instances' , array ( 'parentcontextid' => $ contextid ) , '' , 'id' ) ; foreach ( $ instances as $ instance... | Given one course id return one array with all the block intances that belong to it |
27,241 | public static function get_modules_from_sectionid ( $ sectionid ) { global $ DB ; $ secrec = $ DB -> get_record ( 'course_sections' , array ( 'id' => $ sectionid ) , 'course, sequence' ) ; $ courseid = $ secrec -> course ; $ sequence = $ secrec -> sequence ; $ modulesarr = array ( ) ; $ modules = $ DB -> get_records_sq... | Given one section id return one array with all the course modules that belong to it |
27,242 | public static function get_sections_from_courseid ( $ courseid ) { global $ DB ; $ sectionsarr = array ( ) ; $ sections = $ DB -> get_records ( 'course_sections' , array ( 'course' => $ courseid ) , 'section' ) ; foreach ( $ sections as $ section ) { $ sectionsarr [ ] = $ section -> id ; } return $ sectionsarr ; } | Given one course id return one array with all the course_sections belonging to it |
27,243 | public static function get_default_backup_filename ( $ format , $ type , $ id , $ users , $ anonymised , $ useidonly = false ) { global $ DB ; $ backupword = str_replace ( ' ' , '_' , core_text :: strtolower ( get_string ( 'backupfilename' ) ) ) ; $ backupword = trim ( clean_filename ( $ backupword ) , '_' ) ; $ shortn... | Returns the default backup filename based in passed params . |
27,244 | public static function require_gradebook_backup ( $ courseid , $ backupid ) { global $ DB ; $ sql = "SELECT count(id) FROM {grade_items} WHERE courseid=:courseid AND itemtype = 'mod' AND id NOT IN ( SELECT bi.itemid ... | Returns a flag indicating the need to backup gradebook elements like calculated grade items and category visibility If all activity related grade items are being backed up we can also backup calculated grade items and categories |
27,245 | public function initialise ( cache_definition $ definition ) { if ( $ definition -> get_mode ( ) !== self :: MODE_APPLICATION ) { $ this -> persist = true ; } else { $ this -> persist = ! $ definition -> use_static_acceleration ( ) ; } } | Initialises the store instance for a definition . |
27,246 | public function get ( $ key ) { if ( $ this -> persist && array_key_exists ( $ key , $ this -> store ) ) { return $ this -> store [ $ key ] ; } return false ; } | Returns the data for the given key |
27,247 | public function get_many ( $ keys ) { $ return = array ( ) ; foreach ( $ keys as $ key ) { if ( $ this -> persist && array_key_exists ( $ key , $ this -> store ) ) { $ return [ $ key ] = $ this -> store [ $ key ] ; } else { $ return [ $ key ] = false ; } } return $ return ; } | Gets the values for many keys |
27,248 | public function set ( $ key , $ data ) { if ( $ this -> persist ) { $ this -> store [ $ key ] = $ data ; } return true ; } | Sets an item in the cache |
27,249 | public function set_many ( array $ keyvaluearray ) { if ( $ this -> persist ) { foreach ( $ keyvaluearray as $ pair ) { $ this -> store [ $ pair [ 'key' ] ] = $ pair [ 'value' ] ; } } return count ( $ keyvaluearray ) ; } | Sets many items in the cache |
27,250 | public function delete_many ( array $ keys ) { if ( $ this -> persist ) { foreach ( $ keys as $ key ) { unset ( $ this -> store [ $ key ] ) ; } } return count ( $ keys ) ; } | Deletes many items from the cache |
27,251 | function exportValue ( & $ submitValues , $ assoc = false ) { $ valuearray = array ( ) ; foreach ( $ this -> _elements as $ element ) { $ thisexport = $ element -> exportValue ( $ submitValues [ $ this -> getName ( ) ] , true ) ; if ( $ thisexport != null ) { $ valuearray += $ thisexport ; } } if ( count ( $ valuearray... | Output a timestamp . Give it the name of the group . |
27,252 | public function begin_database_export ( $ version , $ release , $ timestamp , $ description ) { $ this -> output ( '<?xml version="1.0" encoding="utf-8"?>' ) ; $ this -> output ( '<moodle_database version="' . $ version . '" release="' . $ release . '" timestamp="' . $ timestamp . '"' . ( empty ( $ description ) ? '' :... | Callback function . Outputs open XML PI and moodle_database opening tag . |
27,253 | public function export_table_data ( xmldb_table $ table , $ data ) { $ this -> output ( '<record>' ) ; foreach ( $ data as $ key => $ value ) { if ( is_null ( $ value ) ) { $ this -> output ( '<field name="' . $ key . '" value="null" />' ) ; } else { $ this -> output ( '<field name="' . $ key . '">' . htmlspecialchars ... | Callback function . Outputs record tag with field subtags and data . |
27,254 | protected static function _getBackend ( ) { if ( ! isset ( self :: $ _backend ) ) { if ( extension_loaded ( 'intl' ) ) { self :: $ _backend = defined ( 'INTL_IDNA_VARIANT_UTS46' ) ? 'INTL_UTS46' : 'INTL' ; } else { self :: $ _backend = new Horde_Idna_Punycode ( ) ; } } return self :: $ _backend ; } | Return the IDNA backend . |
27,255 | protected function escape_url ( $ url ) { $ url = str_replace ( '"' , '%22' , $ url ) ; $ url = str_replace ( '\'' , '%27' , $ url ) ; $ url = str_replace ( ' ' , '%20' , $ url ) ; $ url = str_replace ( '<' , '%3C' , $ url ) ; $ url = str_replace ( '>' , '%3E' , $ url ) ; return $ url ; } | Escapes a url by replacing spaces with %20 . |
27,256 | public static function get_wikis_by_courses ( $ courseids = array ( ) ) { $ returnedwikis = array ( ) ; $ warnings = array ( ) ; $ params = self :: validate_parameters ( self :: get_wikis_by_courses_parameters ( ) , array ( 'courseids' => $ courseids ) ) ; $ mycourses = array ( ) ; if ( empty ( $ params [ 'courseids' ]... | Returns a list of wikis in a provided list of courses if no list is provided all wikis that the user can view will be returned . |
27,257 | public static function get_wikis_by_courses_returns ( ) { return new external_single_structure ( array ( 'wikis' => new external_multiple_structure ( new external_single_structure ( array ( 'id' => new external_value ( PARAM_INT , 'Wiki ID.' ) , 'coursemodule' => new external_value ( PARAM_INT , 'Course module ID.' ) ,... | Describes the get_wikis_by_courses return value . |
27,258 | public static function view_page ( $ pageid ) { $ params = self :: validate_parameters ( self :: view_page_parameters ( ) , array ( 'pageid' => $ pageid ) ) ; $ warnings = array ( ) ; if ( ! $ page = wiki_get_page ( $ params [ 'pageid' ] ) ) { throw new moodle_exception ( 'incorrectpageid' , 'wiki' ) ; } if ( ! $ wiki ... | Trigger the page viewed event and update the module completion status . |
27,259 | public static function get_subwikis ( $ wikiid ) { global $ USER ; $ warnings = array ( ) ; $ params = self :: validate_parameters ( self :: get_subwikis_parameters ( ) , array ( 'wikiid' => $ wikiid ) ) ; if ( ! $ wiki = wiki_get_wiki ( $ params [ 'wikiid' ] ) ) { throw new moodle_exception ( 'incorrectwikiid' , 'wiki... | Returns the list of subwikis the user can see in a specific wiki . |
27,260 | public static function get_subwikis_returns ( ) { return new external_single_structure ( array ( 'subwikis' => new external_multiple_structure ( new external_single_structure ( array ( 'id' => new external_value ( PARAM_INT , 'Subwiki ID.' ) , 'wikiid' => new external_value ( PARAM_INT , 'Wiki ID.' ) , 'groupid' => new... | Describes the get_subwikis return value . |
27,261 | public static function get_subwiki_pages_parameters ( ) { return new external_function_parameters ( array ( 'wikiid' => new external_value ( PARAM_INT , 'Wiki instance ID.' ) , 'groupid' => new external_value ( PARAM_INT , 'Subwiki\'s group ID, -1 means current group. It will be ignored' . ' if the wiki doesn\'t use gr... | Describes the parameters for get_subwiki_pages . |
27,262 | public static function get_subwiki_pages_returns ( ) { return new external_single_structure ( array ( 'pages' => new external_multiple_structure ( new external_single_structure ( array ( 'id' => new external_value ( PARAM_INT , 'Page ID.' ) , 'subwikiid' => new external_value ( PARAM_INT , 'Page\'s subwiki ID.' ) , 'ti... | Describes the get_subwiki_pages return value . |
27,263 | public static function get_page_contents ( $ pageid ) { $ params = self :: validate_parameters ( self :: get_page_contents_parameters ( ) , array ( 'pageid' => $ pageid ) ) ; $ warnings = array ( ) ; if ( ! $ page = wiki_get_page ( $ params [ 'pageid' ] ) ) { throw new moodle_exception ( 'incorrectpageid' , 'wiki' ) ; ... | Get a page contents . |
27,264 | public static function get_subwiki_files_parameters ( ) { return new external_function_parameters ( array ( 'wikiid' => new external_value ( PARAM_INT , 'Wiki instance ID.' ) , 'groupid' => new external_value ( PARAM_INT , 'Subwiki\'s group ID, -1 means current group. It will be ignored' . ' if the wiki doesn\'t use gr... | Describes the parameters for get_subwiki_files . |
27,265 | public static function get_subwiki_files ( $ wikiid , $ groupid = - 1 , $ userid = 0 ) { $ returnedfiles = array ( ) ; $ warnings = array ( ) ; $ params = self :: validate_parameters ( self :: get_subwiki_files_parameters ( ) , array ( 'wikiid' => $ wikiid , 'groupid' => $ groupid , 'userid' => $ userid ) ) ; if ( ! $ ... | Returns the list of files from a specific subwiki . |
27,266 | protected static function determine_group_and_user ( $ cm , $ wiki , $ groupid = - 1 , $ userid = 0 ) { global $ USER ; $ currentgroup = groups_get_activity_group ( $ cm ) ; if ( $ currentgroup === false ) { $ groupid = 0 ; } else if ( $ groupid == - 1 ) { $ groupid = ! empty ( $ currentgroup ) ? $ currentgroup : 0 ; }... | Utility function for determining the groupid and userid to use . |
27,267 | public static function get_page_for_editing_parameters ( ) { return new external_function_parameters ( array ( 'pageid' => new external_value ( PARAM_INT , 'Page ID to edit.' ) , 'section' => new external_value ( PARAM_RAW , 'Section page title.' , VALUE_DEFAULT , null ) , 'lockonly' => new external_value ( PARAM_BOOL ... | Describes the parameters for get_page_for_editing . |
27,268 | public static function get_page_for_editing ( $ pageid , $ section = null , $ lockonly = false ) { global $ USER ; $ params = self :: validate_parameters ( self :: get_page_for_editing_parameters ( ) , array ( 'pageid' => $ pageid , 'section' => $ section , 'lockonly' => $ lockonly ) ) ; $ warnings = array ( ) ; if ( !... | Locks and retrieves info of page - section to be edited . |
27,269 | public static function get_page_for_editing_returns ( ) { return new external_single_structure ( array ( 'pagesection' => new external_single_structure ( array ( 'content' => new external_value ( PARAM_RAW , 'The contents of the page-section to be edited.' , VALUE_OPTIONAL ) , 'contentformat' => new external_value ( PA... | Describes the get_page_for_editing return value . |
27,270 | public static function new_page_parameters ( ) { return new external_function_parameters ( array ( 'title' => new external_value ( PARAM_TEXT , 'New page title.' ) , 'content' => new external_value ( PARAM_RAW , 'Page contents.' ) , 'contentformat' => new external_value ( PARAM_TEXT , 'Page contents format. If an inval... | Describes the parameters for new_page . |
27,271 | public static function edit_page_parameters ( ) { return new external_function_parameters ( array ( 'pageid' => new external_value ( PARAM_INT , 'Page ID.' ) , 'content' => new external_value ( PARAM_RAW , 'Page contents.' ) , 'section' => new external_value ( PARAM_RAW , 'Section page title.' , VALUE_DEFAULT , null ) ... | Describes the parameters for edit_page . |
27,272 | public static function edit_page ( $ pageid , $ content , $ section = null ) { global $ USER ; $ params = self :: validate_parameters ( self :: edit_page_parameters ( ) , array ( 'pageid' => $ pageid , 'content' => $ content , 'section' => $ section ) ) ; $ warnings = array ( ) ; if ( ! $ page = wiki_get_page ( $ param... | Edit a page contents . |
27,273 | public function setKey ( $ key , $ iv = null ) { if ( ! is_string ( $ key ) ) { throw new Horde_Crypt_Blowfish_Exception ( 'Encryption key must be a string.' ) ; } $ len = strlen ( $ key ) ; if ( ( $ len > self :: MAXKEYSIZE ) || ( $ len == 0 ) ) { throw new Horde_Crypt_Blowfish_Exception ( sprintf ( 'Encryption key mu... | Sets the secret key . |
27,274 | public static function scale_used ( $ scaleid , $ workshopid = null ) { global $ DB ; $ conditions [ 'grade' ] = - $ scaleid ; if ( ! is_null ( $ workshopid ) ) { $ conditions [ 'workshopid' ] = $ workshopid ; } return $ DB -> record_exists ( 'workshopform_accumulative' , $ conditions ) ; } | Is a given scale used by the instance of workshop? |
27,275 | protected function update_peer_grade ( stdclass $ assessment ) { $ grades = $ this -> get_current_assessment_data ( $ assessment ) ; $ suggested = $ this -> calculate_peer_grade ( $ grades ) ; if ( ! is_null ( $ suggested ) ) { $ this -> workshop -> set_peer_grade ( $ assessment -> id , $ suggested ) ; } return $ sugge... | Aggregates the assessment form data and sets the grade for the submission given by the peer |
27,276 | protected function scale_to_grade ( $ scaleid , $ item ) { global $ DB ; static $ numofscaleitems = array ( ) ; if ( ! isset ( $ numofscaleitems [ $ scaleid ] ) ) { $ scale = $ DB -> get_field ( 'scale' , 'scale' , array ( 'id' => $ scaleid ) , MUST_EXIST ) ; $ items = explode ( ',' , $ scale ) ; $ numofscaleitems [ $ ... | Convert scale grade to numerical grades |
27,277 | public function execute ( ) { global $ DB , $ CFG ; require_once ( $ CFG -> dirroot . '/auth/mnet/auth.php' ) ; $ mnetplugin = new \ auth_plugin_mnet ( ) ; $ mnetplugin -> keepalive_client ( ) ; $ random100 = rand ( 0 , 100 ) ; if ( $ random100 < 10 ) { $ longtime = time ( ) - DAYSECS ; $ DB -> delete_records_select ( ... | Run auth mnet cron . |
27,278 | public function endpoints_table ( $ endpoints , $ issuerid ) { global $ CFG ; $ table = new html_table ( ) ; $ table -> head = [ get_string ( 'name' ) , get_string ( 'url' ) , get_string ( 'edit' ) , ] ; $ table -> attributes [ 'class' ] = 'admintable generaltable' ; $ data = [ ] ; $ index = 0 ; foreach ( $ endpoints a... | This function will render one beautiful table with all the endpoints . |
27,279 | public function user_field_mappings_table ( $ userfieldmappings , $ issuerid ) { global $ CFG ; $ table = new html_table ( ) ; $ table -> head = [ get_string ( 'userfieldexternalfield' , 'tool_oauth2' ) , get_string ( 'userfieldinternalfield' , 'tool_oauth2' ) , get_string ( 'edit' ) , ] ; $ table -> attributes [ 'clas... | This function will render one beautiful table with all the user_field_mappings . |
27,280 | public function is_own_form ( $ userid = null ) { global $ USER ; if ( ! $ this -> is_form_defined ( ) ) { return null ; } if ( is_null ( $ userid ) ) { $ userid = $ USER -> id ; } return ( $ this -> definition -> usercreated == $ userid ) ; } | Is the grading form owned by the given user? |
27,281 | public function get_editor_url ( moodle_url $ returnurl = null ) { $ params = array ( 'areaid' => $ this -> areaid ) ; if ( ! is_null ( $ returnurl ) ) { $ params [ 'returnurl' ] = $ returnurl -> out ( false ) ; } return new moodle_url ( '/grade/grading/form/' . $ this -> get_method_name ( ) . '/edit.php' , $ params ) ... | Returns URL of a page where the grading form can be defined and edited . |
27,282 | public function get_definition ( $ force = false ) { if ( $ this -> definition === false || $ force ) { $ this -> load_definition ( ) ; } return $ this -> definition ; } | Returns the grading form definition structure |
27,283 | public function update_definition ( stdClass $ definition , $ usermodified = null ) { global $ DB , $ USER ; if ( is_null ( $ usermodified ) ) { $ usermodified = $ USER -> id ; } if ( ! empty ( $ this -> definition -> id ) ) { $ record = new stdClass ( ) ; foreach ( $ definition as $ prop => $ val ) { if ( is_array ( $... | Saves the defintion data into the database |
27,284 | public function has_active_instances ( ) { global $ DB ; if ( empty ( $ this -> definition -> id ) ) { return false ; } if ( $ this -> hasactiveinstances === null ) { $ conditions = array ( 'definitionid' => $ this -> definition -> id , 'status' => gradingform_instance :: INSTANCE_STATUS_ACTIVE ) ; $ this -> hasactivei... | Returns true if there are already people who has been graded on this definition . In this case plugins may restrict changes of the grading definition |
27,285 | public function get_or_create_instance ( $ instanceid , $ raterid , $ itemid ) { global $ DB ; if ( $ instanceid && $ instance = $ DB -> get_record ( 'grading_instances' , array ( 'id' => $ instanceid , 'raterid' => $ raterid , 'itemid' => $ itemid ) , '*' , IGNORE_MISSING ) ) { return $ this -> get_instance ( $ instan... | If instanceid is specified and grading instance exists and it is created by this rater for this item this instance is returned . Otherwise new instance is created for the specified rater and itemid |
27,286 | public function delete_definition ( ) { global $ DB ; if ( ! $ this -> is_form_defined ( ) ) { return ; } $ this -> delete_plugin_definition ( ) ; $ DB -> delete_records ( 'grading_instances' , array ( 'definitionid' => $ this -> definition -> id ) ) ; $ DB -> delete_records ( 'grading_definitions' , array ( 'id' => $ ... | Deletes the form definition and all the associated data |
27,287 | protected function load_definition ( ) { global $ DB ; $ this -> definition = $ DB -> get_record ( 'grading_definitions' , array ( 'areaid' => $ this -> areaid , 'method' => $ this -> get_method_name ( ) ) , '*' , IGNORE_MISSING ) ; } | Loads the form definition if it exists |
27,288 | public final function set_grade_range ( array $ graderange , $ allowgradedecimals = false ) { $ this -> graderange = $ graderange ; $ this -> allowgradedecimals = $ allowgradedecimals ; } | Sets the range of grades used in this area . This is usually either range like 0 - 100 or the scale where keys start from 1 . |
27,289 | public static function create_new ( $ definitionid , $ raterid , $ itemid ) { global $ DB ; $ instance = new stdClass ( ) ; $ instance -> definitionid = $ definitionid ; $ instance -> raterid = $ raterid ; $ instance -> itemid = $ itemid ; $ instance -> status = self :: INSTANCE_STATUS_INCOMPLETE ; $ instance -> timemo... | Creates a new empty instance in DB and mark its status as INCOMPLETE |
27,290 | public function can_setup_server ( ) { $ status = $ this -> engine -> is_server_configured ( ) ; if ( $ status !== true ) { return $ status ; } if ( $ this -> engine -> get_solr_major_version ( ) < 5 ) { return get_string ( 'schemasetupfromsolr5' , 'search_solr' ) ; } return true ; } | Can setup be executed against the configured server . |
27,291 | public function setup ( $ checkexisting = true ) { $ fields = \ search_solr \ document :: get_default_fields_definition ( ) ; unset ( $ fields [ 'id' ] ) ; $ this -> check_index ( ) ; $ return = $ this -> add_fields ( $ fields , $ checkexisting ) ; $ this -> engine -> record_applied_schema_version ( document :: SCHEMA_... | Setup solr stuff required by moodle . |
27,292 | public function validate_setup ( ) { $ fields = \ search_solr \ document :: get_default_fields_definition ( ) ; unset ( $ fields [ 'id' ] ) ; $ this -> check_index ( ) ; $ this -> validate_fields ( $ fields , true ) ; } | Checks the schema is properly set up . |
27,293 | protected function check_index ( ) { $ url = $ this -> engine -> get_connection_url ( '/select?wt=json' ) ; $ result = $ this -> curl -> get ( $ url ) ; if ( $ this -> curl -> error ) { throw new \ moodle_exception ( 'connectionerror' , 'search_solr' ) ; } if ( $ this -> curl -> info [ 'http_code' ] === 404 ) { throw n... | Checks if the index is ready triggers an exception otherwise . |
27,294 | protected function add_fields ( $ fields , $ checkexisting = true ) { if ( $ checkexisting ) { $ this -> validate_fields ( $ fields , false ) ; } $ url = $ this -> engine -> get_connection_url ( '/schema' ) ; foreach ( $ fields as $ fieldname => $ data ) { if ( ! isset ( $ data [ 'type' ] ) || ! isset ( $ data [ 'store... | Adds the provided fields to Solr schema . |
27,295 | protected function validate_fields ( & $ fields , $ requireexisting = false ) { global $ CFG ; foreach ( $ fields as $ fieldname => $ data ) { $ url = $ this -> engine -> get_connection_url ( '/schema/fields/' . $ fieldname ) ; $ results = $ this -> curl -> get ( $ url ) ; if ( $ this -> curl -> error ) { throw new \ m... | Checks if the schema existing fields are properly set triggers an exception otherwise . |
27,296 | protected function validate_add_field_result ( $ result ) { if ( ! $ result ) { throw new \ moodle_exception ( 'errorcreatingschema' , 'search_solr' , '' , get_string ( 'nodatafromserver' , 'search_solr' ) ) ; } $ results = json_decode ( $ result ) ; if ( ! $ results ) { if ( is_scalar ( $ result ) ) { $ errormsg = $ r... | Checks that the field results do not contain errors . |
27,297 | private function doc_field_to_solr_field ( $ datatype ) { $ type = $ datatype ; $ solrversion = $ this -> engine -> get_solr_major_version ( ) ; switch ( $ datatype ) { case 'text' : $ type = 'text_general' ; break ; case 'int' : if ( $ solrversion >= 7 ) { $ type = 'pint' ; } break ; case 'tdate' : if ( $ solrversion ... | Returns the solr field type from the document field type string . |
27,298 | public function coerce ( $ units ) { if ( $ this -> unitless ( ) ) { return new Number ( $ this -> dimension , $ units ) ; } $ dimension = $ this -> dimension ; foreach ( static :: $ unitTable [ 'in' ] as $ unit => $ conv ) { $ from = isset ( $ this -> units [ $ unit ] ) ? $ this -> units [ $ unit ] : 0 ; $ to = isset ... | Coerce number to target units |
27,299 | public function count_response ( $ actualresponse , $ fraction , $ try ) { if ( ! isset ( $ this -> actualresponses [ $ actualresponse ] ) ) { if ( $ fraction === null ) { $ fraction = $ this -> fraction ; } $ this -> add_response ( $ actualresponse , $ fraction ) ; } $ this -> get_response ( $ actualresponse ) -> incr... | Keep a count of a response to this question sub part that falls within this class . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.