idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
30,900 | protected function load_function_info ( ) { global $ DB , $ USER , $ CFG ; if ( empty ( $ this -> functionname ) ) { throw new invalid_parameter_exception ( 'Missing function name' ) ; } $ function = external_api :: external_function_info ( $ this -> functionname ) ; if ( $ this -> restricted_serviceid ) { $ params = a... | Fetches the function description from database verifies user is allowed to use this function and loads all paremeters and return descriptions . |
30,901 | protected function execute ( ) { $ params = call_user_func ( array ( $ this -> function -> classname , 'validate_parameters' ) , $ this -> function -> parameters_desc , $ this -> parameters ) ; $ params = array_values ( $ params ) ; $ callbacks = get_plugins_with_function ( 'override_webservice_execution' ) ; foreach (... | Execute previously loaded function using parameters parsed from the request data . |
30,902 | protected function init_service_class ( ) { global $ USER , $ DB ; $ this -> servicemethods = array ( ) ; $ this -> servicestructs = array ( ) ; $ params = array ( ) ; $ wscond1 = '' ; $ wscond2 = '' ; if ( $ this -> restricted_serviceid ) { $ params = array ( 'sid1' => $ this -> restricted_serviceid , 'sid2' => $ this... | Load the virtual class needed for the web service . |
30,903 | protected function generate_simple_struct_class ( external_single_structure $ structdesc ) { global $ USER ; $ propeties = array ( ) ; $ fields = array ( ) ; foreach ( $ structdesc -> keys as $ name => $ fieldsdesc ) { $ type = $ this -> get_phpdoc_type ( $ fieldsdesc ) ; $ propertytype = array ( 'type' => $ type ) ; i... | Generates a struct class . |
30,904 | protected function get_phpdoc_type ( $ keydesc ) { $ type = null ; if ( $ keydesc instanceof external_value ) { switch ( $ keydesc -> type ) { case PARAM_BOOL : case PARAM_INT : $ type = 'int' ; break ; case PARAM_FLOAT ; $ type = 'double' ; break ; default : $ type = 'string' ; } } else if ( $ keydesc instanceof exter... | Get the phpdoc type for an external_description object . external_value = > int double or string external_single_structure = > object|struct on - fly generated stdClass name . external_multiple_structure = > array |
30,905 | protected function service_class_method_body ( $ function , $ params ) { $ castingcode = '' ; $ paramsstr = '' ; if ( ! empty ( $ params ) ) { foreach ( $ params as $ paramtocast ) { $ paramtocast = trim ( $ paramtocast ) ; $ castingcode .= " $paramtocast = json_decode(json_encode($paramtocast), true);\n" ; } $ para... | Generates the method body of the virtual external function . |
30,906 | public function question_preview_link ( $ questionid , context $ context , $ showlabel ) { if ( $ showlabel ) { $ alt = '' ; $ label = get_string ( 'preview' ) ; $ attributes = array ( ) ; } else { $ alt = get_string ( 'preview' ) ; $ label = '' ; $ attributes = array ( 'title' => $ alt ) ; } $ image = $ this -> pix_ic... | Render an icon optionally with the word Preview beside it to preview a given question . |
30,907 | protected function info ( question_attempt $ qa , qbehaviour_renderer $ behaviouroutput , qtype_renderer $ qtoutput , question_display_options $ options , $ number ) { $ output = '' ; $ output .= $ this -> number ( $ number ) ; $ output .= $ this -> status ( $ qa , $ behaviouroutput , $ options ) ; $ output .= $ this -... | Generate the information bit of the question display that contains the metadata like the question number current state and mark . |
30,908 | protected function number ( $ number ) { if ( trim ( $ number ) === '' ) { return '' ; } $ numbertext = '' ; if ( trim ( $ number ) === 'i' ) { $ numbertext = get_string ( 'information' , 'question' ) ; } else { $ numbertext = get_string ( 'questionx' , 'question' , html_writer :: tag ( 'span' , $ number , array ( 'cla... | Generate the display of the question number . |
30,909 | protected function add_part_heading ( $ heading , $ content ) { if ( $ content ) { $ content = html_writer :: tag ( 'h4' , $ heading , array ( 'class' => 'accesshide' ) ) . $ content ; } return $ content ; } | Add an invisible heading like question text feebdack at the top of a section s contents but only if the section has some content . |
30,910 | protected function status ( question_attempt $ qa , qbehaviour_renderer $ behaviouroutput , question_display_options $ options ) { return html_writer :: tag ( 'div' , $ qa -> get_state_string ( $ options -> correctness ) , array ( 'class' => 'state' ) ) ; } | Generate the display of the status line that gives the current state of the question . |
30,911 | protected function get_flag_html ( $ flagged , $ id = '' ) { if ( $ flagged ) { $ icon = 'i/flagged' ; $ alt = get_string ( 'flagged' , 'question' ) ; } else { $ icon = 'i/unflagged' ; $ alt = get_string ( 'notflagged' , 'question' ) ; } $ attributes = array ( 'src' => $ this -> image_url ( $ icon ) , 'alt' => $ alt , ... | Work out the actual img tag needed for the flag |
30,912 | protected function formulation ( question_attempt $ qa , qbehaviour_renderer $ behaviouroutput , qtype_renderer $ qtoutput , question_display_options $ options ) { $ output = '' ; $ output .= html_writer :: empty_tag ( 'input' , array ( 'type' => 'hidden' , 'name' => $ qa -> get_control_field_name ( 'sequencecheck' ) ,... | Generate the display of the formulation part of the question . This is the area that contains the quetsion text and the controls for students to input their answers . Some question types also embed feedback for example ticks and crosses in this area . |
30,913 | protected function outcome ( question_attempt $ qa , qbehaviour_renderer $ behaviouroutput , qtype_renderer $ qtoutput , question_display_options $ options ) { $ output = '' ; $ output .= html_writer :: nonempty_tag ( 'div' , $ qtoutput -> feedback ( $ qa , $ options ) , array ( 'class' => 'feedback' ) ) ; $ output .= ... | Generate the display of the outcome part of the question . This is the area that contains the various forms of feedback . |
30,914 | protected function response_history ( question_attempt $ qa , qbehaviour_renderer $ behaviouroutput , qtype_renderer $ qtoutput , question_display_options $ options ) { if ( ! $ options -> history ) { return '' ; } $ table = new html_table ( ) ; $ table -> head = array ( get_string ( 'step' , 'question' ) , get_string ... | Generate the display of the response history part of the question . This is the table showing all the steps the question has been through . |
30,915 | public function add_complex_type ( $ classname , $ properties ) { $ typeschema = $ this -> nodetypes -> children ( ) ; $ complextype = $ typeschema -> addChild ( 'x:xsd:complexType' ) ; $ complextype -> addAttribute ( 'name' , $ classname ) ; $ child = $ complextype -> addChild ( 'x:xsd:all' ) ; foreach ( $ properties ... | Adds a complex type to the WSDL . |
30,916 | public function register ( $ functionname , $ inputparams = array ( ) , $ outputparams = array ( ) , $ documentation = '' ) { $ porttypeoperation = $ this -> nodeporttype -> addChild ( 'operation' ) ; $ porttypeoperation -> addAttribute ( 'name' , $ functionname ) ; $ porttypeoperation -> addChild ( 'documentation' , $... | Registers the external service method to the WSDL . |
30,917 | public function render_results ( $ results , $ page , $ totalcount , $ url , $ cat = null ) { $ content = '' ; if ( \ core_search \ manager :: is_search_area_categories_enabled ( ) && ! empty ( $ cat ) ) { $ toprow = [ ] ; foreach ( \ core_search \ manager :: get_search_area_categories ( ) as $ category ) { $ taburl = ... | Renders search results . |
30,918 | public function render_result ( \ core_search \ document $ doc ) { $ docdata = $ doc -> export_for_template ( $ this ) ; $ docdata [ 'title' ] = shorten_text ( $ docdata [ 'title' ] , static :: SEARCH_RESULT_STRING_SIZE , true ) ; $ docdata [ 'content' ] = $ docdata [ 'content' ] ? shorten_text ( $ docdata [ 'content' ... | Displaying search results . |
30,919 | public function render_search_disabled ( ) { $ content = $ this -> output -> box_start ( ) ; $ content .= $ this -> output -> notification ( get_string ( 'globalsearchdisabled' , 'search' ) , 'notifymessage' ) ; $ content .= $ this -> output -> box_end ( ) ; return $ content ; } | Returns a box with a search disabled lang string . |
30,920 | protected function after_update ( $ result ) { global $ DB ; if ( ! $ result ) { $ this -> beforeupdate = null ; return ; } if ( $ this -> beforeupdate -> get ( 'parentid' ) != $ this -> get ( 'parentid' ) ) { $ beforepath = $ this -> beforeupdate -> get ( 'path' ) . $ this -> get ( 'id' ) . '/' ; $ like = $ DB -> sql_... | Hook to execute after an update . |
30,921 | protected function after_delete ( $ result ) { global $ DB ; if ( ! $ result ) { return ; } $ table = '{' . self :: TABLE . '}' ; $ sql = "UPDATE $table SET sortorder = sortorder -1 WHERE competencyframeworkid = ? AND parentid = ? AND sortorder > ?" ; $ DB -> execute ( $ sql , array ( $ this -> get ( 'competencyframe... | Hook to execute after a delete . |
30,922 | public function get_default_grade ( ) { $ scaleid = $ this -> get ( 'scaleid' ) ; $ scaleconfig = $ this -> get ( 'scaleconfiguration' ) ; if ( $ scaleid === null ) { $ scaleconfig = $ this -> get_framework ( ) -> get ( 'scaleconfiguration' ) ; } return competency_framework :: get_default_grade_from_scale_configuration... | Extracts the default grade from the scale configuration . |
30,923 | public function get_proficiency_of_grade ( $ grade ) { $ scaleid = $ this -> get ( 'scaleid' ) ; $ scaleconfig = $ this -> get ( 'scaleconfiguration' ) ; if ( $ scaleid === null ) { $ scaleconfig = $ this -> get_framework ( ) -> get ( 'scaleconfiguration' ) ; } return competency_framework :: get_proficiency_of_grade_fr... | Extracts the proficiency of a grade from the scale configuration . |
30,924 | public function get_rule_object ( ) { $ rule = $ this -> get ( 'ruletype' ) ; if ( ! $ rule || ! is_subclass_of ( $ rule , 'core_competency\\competency_rule' ) ) { return null ; } return new $ rule ( $ this ) ; } | Get the rule object . |
30,925 | public function get_scale ( ) { $ scaleid = $ this -> get ( 'scaleid' ) ; if ( $ scaleid === null ) { return $ this -> get_framework ( ) -> get_scale ( ) ; } $ scale = \ grade_scale :: fetch ( array ( 'id' => $ scaleid ) ) ; $ scale -> load_items ( ) ; return $ scale ; } | Return the scale . |
30,926 | public function is_parent_of ( array $ ids ) { global $ DB ; list ( $ insql , $ params ) = $ DB -> get_in_or_equal ( $ ids , SQL_PARAMS_NAMED ) ; $ params [ 'parentid' ] = $ this -> get ( 'id' ) ; return $ DB -> count_records_select ( self :: TABLE , "id $insql AND parentid = :parentid" , $ params ) == count ( $ ids ) ... | Check if the competency is the parent of passed competencies . |
30,927 | public function reset_rule ( ) { $ this -> raw_set ( 'ruleoutcome' , static :: OUTCOME_NONE ) ; $ this -> raw_set ( 'ruletype' , null ) ; $ this -> raw_set ( 'ruleconfig' , null ) ; } | Reset the rule . |
30,928 | protected function set_new_path ( competency $ parent = null ) { $ path = '/0/' ; if ( $ this -> get ( 'parentid' ) ) { $ parent = $ parent !== null ? $ parent : $ this -> get_parent ( ) ; $ path = $ parent -> get ( 'path' ) . $ this -> get ( 'parentid' ) . '/' ; } $ this -> raw_set ( 'path' , $ path ) ; } | Helper method to set the path . |
30,929 | protected function set_new_sortorder ( ) { $ search = array ( 'parentid' => $ this -> get ( 'parentid' ) , 'competencyframeworkid' => $ this -> get ( 'competencyframeworkid' ) ) ; $ this -> raw_set ( 'sortorder' , $ this -> count_records ( $ search ) ) ; } | Helper method to set the sortorder . |
30,930 | public static function search ( $ searchtext , $ competencyframeworkid ) { global $ DB ; $ like1 = $ DB -> sql_like ( 'shortname' , ':like1' , false ) ; $ like2 = $ DB -> sql_like ( 'idnumber' , ':like2' , false ) ; $ like3 = $ DB -> sql_like ( 'description' , ':like3' , false ) ; $ params = array ( 'like1' => '%' . $ ... | This does a specialised search that finds all nodes in the tree with matching text on any text like field and returns this node and all its parents in a displayable sort order . |
30,931 | protected function validate_competencyframeworkid ( $ value ) { if ( $ this -> get ( 'id' ) ) { if ( $ this -> beforeupdate -> get ( 'competencyframeworkid' ) != $ value ) { return new lang_string ( 'invaliddata' , 'error' ) ; } } else { if ( ! competency_framework :: record_exists ( $ value ) ) { return new lang_strin... | Validate the competency framework ID . |
30,932 | protected function validate_idnumber ( $ value ) { global $ DB ; $ sql = 'idnumber = :idnumber AND competencyframeworkid = :competencyframeworkid AND id <> :id' ; $ params = array ( 'id' => $ this -> get ( 'id' ) , 'idnumber' => $ value , 'competencyframeworkid' => $ this -> get ( 'competencyframeworkid' ) ) ; if ( $ D... | Validate the ID number . |
30,933 | protected function validate_path ( $ value ) { $ id = $ this -> get ( 'parentid' ) ; if ( substr ( $ value , - ( strlen ( $ id ) + 2 ) ) != '/' . $ id . '/' ) { return new lang_string ( 'invaliddata' , 'error' ) ; } else if ( ! preg_match ( '@/([0-9]+/)+@' , $ value ) ) { return new lang_string ( 'invaliddata' , 'error... | Validate the path . |
30,934 | protected function validate_parentid ( $ value ) { if ( ! empty ( $ value ) && ! $ this -> newparent && ! self :: record_exists ( $ value ) ) { return new lang_string ( 'invaliddata' , 'error' ) ; } if ( $ this -> get ( 'id' ) ) { if ( $ this -> beforeupdate -> get ( 'parentid' ) != $ value && $ this -> newparent ) { i... | Validate the parent ID . |
30,935 | protected function validate_ruletype ( $ value ) { if ( $ value === null ) { return true ; } if ( ! class_exists ( $ value ) || ! is_subclass_of ( $ value , 'core_competency\\competency_rule' ) ) { return new lang_string ( 'invaliddata' , 'error' ) ; } return true ; } | Validate the rule . |
30,936 | public static function share_same_framework ( array $ ids ) { global $ DB ; list ( $ insql , $ params ) = $ DB -> get_in_or_equal ( $ ids ) ; $ sql = "SELECT COUNT('x') FROM (SELECT DISTINCT(competencyframeworkid) FROM {" . self :: TABLE . "} WHERE id {$insql}) f" ; return $ DB -> count_records_sql ( $ sql , $ params )... | Return whether or not the competency IDs share the same framework . |
30,937 | public static function get_framework_depth ( $ frameworkid ) { global $ DB ; $ totallength = $ DB -> sql_length ( 'path' ) ; $ trimmedlength = $ DB -> sql_length ( "REPLACE(path, '/', '')" ) ; $ sql = "SELECT ($totallength - $trimmedlength - 1) AS depth FROM {" . self :: TABLE . "} WHER... | Return the current depth of a competency framework . |
30,938 | protected static function build_tree ( $ all , $ parentid ) { $ tree = array ( ) ; foreach ( $ all as $ one ) { if ( $ one -> get ( 'parentid' ) == $ parentid ) { $ node = new stdClass ( ) ; $ node -> competency = $ one ; $ node -> children = self :: build_tree ( $ all , $ one -> get ( 'id' ) ) ; $ tree [ ] = $ node ; ... | Recursively build up the tree of nodes . |
30,939 | public static function can_all_be_deleted ( $ ids ) { global $ CFG ; if ( empty ( $ ids ) ) { return true ; } if ( template_competency :: has_records_for_competencies ( $ ids ) ) { return false ; } if ( plan_competency :: has_records_for_competencies ( $ ids ) ) { return false ; } if ( course_competency :: has_records_... | Check if we can delete competencies safely . |
30,940 | public static function delete_multiple ( $ ids ) { global $ DB ; list ( $ insql , $ params ) = $ DB -> get_in_or_equal ( $ ids , SQL_PARAMS_NAMED ) ; return $ DB -> delete_records_select ( self :: TABLE , "id $insql" , $ params ) ; } | Delete the competencies . |
30,941 | public static function get_descendants_ids ( $ competency ) { global $ DB ; $ path = $ DB -> sql_like_escape ( $ competency -> get ( 'path' ) . $ competency -> get ( 'id' ) . '/' ) . '%' ; $ like = $ DB -> sql_like ( 'path' , ':likepath' ) ; return $ DB -> get_fieldset_select ( self :: TABLE , 'id' , $ like , array ( '... | Get descendant ids . |
30,942 | public function get_ancestors ( ) { global $ DB ; $ ancestors = array ( ) ; $ ancestorsids = explode ( '/' , trim ( $ this -> get ( 'path' ) , '/' ) ) ; array_shift ( $ ancestorsids ) ; if ( ! empty ( $ ancestorsids ) ) { list ( $ insql , $ params ) = $ DB -> get_in_or_equal ( $ ancestorsids , SQL_PARAMS_NAMED ) ; $ an... | Get competency ancestors . |
30,943 | public function zeroFill ( $ a , $ b ) { return ( $ a >= 0 ) ? ( $ a >> $ b ) : ( $ a >> $ b ) & ( PHP_INT_MAX >> ( $ b - 1 ) ) ; } | Right shift with zero fill . |
30,944 | public function base64Encode ( $ number ) { if ( $ number < 0 || $ number > 63 ) { throw new \ Exception ( sprintf ( 'Invalid number "%s" given. Must be between 0 and 63.' , $ number ) ) ; } return $ this -> intToCharMap [ $ number ] ; } | Encode single 6 - bit digit as base64 . |
30,945 | public function arrays_same_at_key_integer ( array $ array1 , array $ array2 , $ key ) { if ( array_key_exists ( $ key , $ array1 ) ) { $ value1 = $ array1 [ $ key ] ; } else { $ value1 = '' ; } if ( array_key_exists ( $ key , $ array2 ) ) { $ value2 = $ array2 [ $ key ] ; } else { $ value2 = '' ; } $ coords1 = explode... | Tests to see whether two arrays have the same set of coords at a particular key . Coords can be in any order . |
30,946 | protected function choose_hits ( array $ response ) { $ allhits = $ this -> get_all_hits ( $ response ) ; $ chosenhits = array ( ) ; foreach ( $ allhits as $ placeno => $ hits ) { foreach ( $ hits as $ itemno => $ hit ) { $ choice = $ this -> get_right_choice_for ( $ placeno ) ; $ choiceitem = "$choice $itemno" ; if ( ... | Choose hits to maximize grade where drop targets may have more than one hit and drop targets can overlap . |
30,947 | protected function get_all_hits ( array $ response ) { $ hits = array ( ) ; foreach ( $ this -> places as $ placeno => $ place ) { $ rightchoice = $ this -> get_right_choice_for ( $ placeno ) ; $ rightchoicekey = $ this -> choice ( $ rightchoice ) ; if ( ! array_key_exists ( $ rightchoicekey , $ response ) ) { continue... | Get s an array of all hits on drop targets . Needs further processing to find which hits to select in the general case that drop targets may have more than one hit and drop targets can overlap . |
30,948 | public function encodeHeader ( $ str , $ position = 'text' ) { $ encoded = core_text :: encode_mimeheader ( $ str , $ this -> CharSet ) ; if ( $ encoded !== false ) { if ( $ position === 'phrase' ) { $ chunks = preg_split ( "/\\n/" , $ encoded ) ; $ chunks = array_map ( function ( $ chunk ) { return addcslashes ( $ chu... | Use internal moodles own core_text to encode mimeheaders . Fall back to phpmailers inbuilt functions if not |
30,949 | public function postSend ( ) { if ( PHPUNIT_TEST ) { if ( ! phpunit_util :: is_redirecting_phpmailer ( ) ) { debugging ( 'Unit tests must not send real emails! Use $this->redirectEmails()' ) ; return true ; } $ mail = new stdClass ( ) ; $ mail -> header = $ this -> MIMEHeader ; $ mail -> body = $ this -> MIMEBody ; $ m... | Sends this mail . |
30,950 | public function get_sql_where ( ) { list ( $ where , $ params ) = parent :: get_sql_where ( ) ; $ where = preg_replace ( '/firstname/' , 'u.firstname' , $ where ) ; $ where = preg_replace ( '/lastname/' , 'u.lastname' , $ where ) ; return [ $ where , $ params ] ; } | Get sql to add to where statement . |
30,951 | protected function build_sql_for_roles_filter ( ) { foreach ( $ this -> acceptancesfilter -> get_role_filters ( ) as $ roleid ) { $ this -> sql -> where .= ' AND ' . $ this -> sql_has_role ( [ $ roleid => $ roleid ] ) ; } } | If there is a filter by user roles add it to the SQL query . |
30,952 | public function col_fullname ( $ row ) { global $ OUTPUT ; $ userpic = $ this -> is_downloading ( ) ? '' : $ OUTPUT -> user_picture ( $ row -> user ) ; return $ userpic . $ this -> username ( $ row -> user , true ) ; } | Get the column fullname value . |
30,953 | protected function username ( $ user , $ profilelink = true ) { $ canviewfullnames = has_capability ( 'moodle/site:viewfullnames' , \ context_system :: instance ( ) ) || has_capability ( 'moodle/site:viewfullnames' , \ context_user :: instance ( $ user -> id ) ) ; $ name = fullname ( $ user , $ canviewfullnames ) ; if ... | User name with a link to profile |
30,954 | protected function status ( $ versionid , $ row ) { $ onbehalf = false ; $ versions = $ versionid ? [ $ versionid => $ this -> versionids [ $ versionid ] ] : $ this -> versionids ; $ accepted = [ ] ; $ declined = [ ] ; foreach ( $ versions as $ v => $ name ) { if ( $ row -> { 'status' . $ v } !== null ) { if ( empty ( ... | Return agreement status |
30,955 | public function col_timemodified ( $ row ) { if ( $ row -> timemodified ) { if ( $ this -> is_downloading ( ) ) { return date_format_string ( $ row -> timemodified , '%Y-%m-%d %H:%M:%S %Z' ) ; } else { return userdate ( $ row -> timemodified , get_string ( 'strftimedatetime' ) ) ; } } else { return null ; } } | Get the column timemodified value . |
30,956 | public function col_note ( $ row ) { if ( $ this -> is_downloading ( ) ) { return $ row -> note ; } else { return format_text ( $ row -> note , FORMAT_MOODLE ) ; } } | Get the column note value . |
30,957 | public function other_cols ( $ column , $ row ) { if ( preg_match ( '/^status([\d]+)$/' , $ column , $ matches ) ) { $ versionid = $ matches [ 1 ] ; return $ this -> status ( $ versionid , $ row ) ; } if ( preg_match ( '/^usermodified([\d]+)$/' , $ column , $ matches ) ) { if ( $ row -> $ column && $ row -> $ column !=... | You can override this method in a child class . See the description of build_table which calls this method . |
30,958 | public function definition ( ) { $ mform = $ this -> _form ; $ this -> definition_inner ( $ mform ) ; $ mform -> addElement ( 'hidden' , 'contextid' ) ; $ mform -> setType ( 'contextid' , PARAM_INT ) ; $ mform -> setDefault ( 'contextid' , $ this -> context -> id ) ; $ mform -> addElement ( 'hidden' , 'filter' ) ; $ mf... | Build the form definition . Rather than overriding this method you should probably override definition_inner instead . |
30,959 | public function save_changes ( $ data ) { $ data = ( array ) $ data ; unset ( $ data [ 'filter' ] ) ; unset ( $ data [ 'contextid' ] ) ; foreach ( $ data as $ name => $ value ) { if ( $ value !== '' ) { filter_set_local_config ( $ this -> filter , $ this -> context -> id , $ name , $ value ) ; } else { filter_unset_loc... | Override this method to save the settings to the database . The default implementation will probably be sufficient for most simple cases . |
30,960 | static function format_number ( $ number ) { $ formatted = rtrim ( format_float ( $ number , 4 ) , '0' ) ; if ( substr ( $ formatted , - 1 ) == get_string ( 'decsep' , 'langconfig' ) ) { $ formatted .= '0' ; } return $ formatted ; } | Grader report has its own decimal place settings so they are handled elsewhere . |
30,961 | public function write ( $ data , $ debug = true ) { if ( fwrite ( $ this -> _stream , $ data . "\r\n" ) === false ) { throw new Horde_Imap_Client_Exception ( Horde_Imap_Client_Translation :: r ( "Server write error." ) , Horde_Imap_Client_Exception :: SERVER_WRITEERROR ) ; } if ( $ debug ) { $ this -> _params [ 'debug'... | Writes data to the POP3 output stream . |
30,962 | public function read ( $ size = null ) { if ( feof ( $ this -> _stream ) ) { $ this -> close ( ) ; $ this -> _params [ 'debug' ] -> info ( 'ERROR: Server closed the connection.' ) ; throw new Horde_Imap_Client_Exception ( Horde_Imap_Client_Translation :: r ( "Server closed the connection unexpectedly." ) , Horde_Imap_C... | Read data from incoming POP3 stream . |
30,963 | protected function _baseSql ( $ mailbox , $ join = null ) { $ sql = sprintf ( 'FROM %s d' , self :: BASE_TABLE ) ; if ( ! is_null ( $ join ) ) { $ sql .= sprintf ( ' INNER JOIN %s t ON d.messageid = t.messageid' , $ join ) ; } return array ( $ sql . ' WHERE d.hostspec = ? AND d.port = ? AND d.username = ? AND d.mailbox... | Prepare the base SQL query . |
30,964 | public function execute_query ( $ filters , $ accessinfo , $ limit = 0 ) { global $ USER ; if ( empty ( $ limit ) ) { $ limit = \ core_search \ manager :: MAX_RESULTS ; } $ client = $ this -> get_search_client ( ) ; $ query = $ this -> create_user_query ( $ filters , $ accessinfo ) ; if ( ! $ query ) { return [ ] ; } $... | Prepares a Solr query applies filters and executes it returning its results . |
30,965 | protected function get_query_response ( $ query ) { try { return $ this -> get_search_client ( ) -> query ( $ query ) -> getResponse ( ) ; } catch ( \ SolrClientException $ ex ) { debugging ( 'Error executing the provided query: ' . $ ex -> getMessage ( ) , DEBUG_DEVELOPER ) ; $ this -> queryerror = $ ex -> getMessage ... | Takes a query and returns the response in SolrObject format . |
30,966 | protected function get_response_counts ( $ response ) { $ found = 0 ; $ included = 0 ; if ( isset ( $ response -> grouped -> solr_filegroupingid -> ngroups ) ) { $ found = $ response -> grouped -> solr_filegroupingid -> ngroups ; $ included = count ( $ response -> grouped -> solr_filegroupingid -> groups ) ; } else if ... | Returns count information for a provided response . Will return 0 0 for invalid or empty responses . |
30,967 | protected function set_query ( $ query , $ q ) { $ query -> setHighlight ( true ) ; foreach ( $ this -> highlightfields as $ field ) { $ query -> addHighlightField ( $ field ) ; } $ query -> setHighlightFragsize ( static :: FRAG_SIZE ) ; $ query -> setHighlightSimplePre ( self :: HIGHLIGHT_START ) ; $ query -> setHighl... | Prepares a new query by setting the query start offset and rows to return . |
30,968 | public function add_fields ( $ query ) { $ documentclass = $ this -> get_document_classname ( ) ; $ fields = $ documentclass :: get_default_fields_definition ( ) ; $ dismax = false ; if ( $ query instanceof \ SolrDisMaxQuery ) { $ dismax = true ; } foreach ( $ fields as $ key => $ field ) { $ query -> addField ( $ key ... | Sets fields to be returned in the result . |
30,969 | public function add_highlight_content ( $ response ) { if ( ! isset ( $ response -> highlighting ) ) { return ; } $ highlightedobject = $ response -> highlighting ; foreach ( $ response -> response -> docs as $ doc ) { $ x = $ doc -> id ; $ highlighteddoc = $ highlightedobject -> $ x ; $ this -> merge_highlight_field_v... | Finds the key common to both highlighing and docs array returned from response . |
30,970 | public function merge_highlight_field_values ( $ doc , $ highlighteddoc ) { foreach ( $ this -> highlightfields as $ field ) { if ( ! empty ( $ doc -> $ field ) ) { if ( is_array ( $ doc -> { $ field } ) ) { throw new \ core_search \ engine_exception ( 'multivaluedfield' , 'search_solr' , '' , $ field ) ; } if ( ! empt... | Adds the highlighting array values to docs array values . |
30,971 | protected function process_response ( $ response , $ limit = 0 , $ skipaccesscheck = false ) { global $ USER ; if ( empty ( $ response ) ) { return array ( ) ; } if ( isset ( $ response -> grouped ) ) { return $ this -> grouped_files_process_response ( $ response , $ limit ) ; } $ userid = $ USER -> id ; $ noownerid = ... | Filters the response on Moodle side . |
30,972 | protected function grouped_files_process_response ( $ response , $ limit = 0 ) { if ( ! isset ( $ response -> grouped -> solr_filegroupingid ) || empty ( $ response -> grouped -> solr_filegroupingid -> matches ) ) { return array ( ) ; } $ numgranted = 0 ; $ orderedids = array ( ) ; $ completedocs = array ( ) ; $ incomp... | Processes grouped file results into documents with attached matching files . |
30,973 | protected function get_missing_docs ( $ missingdocs ) { if ( empty ( $ missingdocs ) ) { return array ( ) ; } $ docids = array_keys ( $ missingdocs ) ; $ query = new \ SolrQuery ( ) ; $ this -> set_query ( $ query , '*' ) ; $ this -> add_fields ( $ query ) ; $ query -> setRows ( count ( $ docids ) ) ; $ query -> addFil... | Retreive any missing main documents and attach provided files . |
30,974 | public function standarize_solr_obj ( \ SolrObject $ obj ) { $ properties = $ obj -> getPropertyNames ( ) ; $ docdata = array ( ) ; foreach ( $ properties as $ name ) { $ name = trim ( $ name ) ; $ docdata [ $ name ] = $ obj -> offsetGet ( $ name ) ; } return $ docdata ; } | Returns a standard php array from a \ SolrObject instance . |
30,975 | protected function add_solr_document ( $ doc ) { $ solrdoc = new \ SolrInputDocument ( ) ; foreach ( $ doc as $ field => $ value ) { $ solrdoc -> addField ( $ field , $ value ) ; } try { $ result = $ this -> get_search_client ( ) -> addDocument ( $ solrdoc , true , static :: AUTOCOMMIT_WITHIN ) ; return true ; } catch ... | Adds a text document to the search engine . |
30,976 | protected function process_document_files ( $ document ) { if ( ! $ this -> file_indexing_enabled ( ) ) { return ; } $ rows = 500 ; $ files = $ document -> get_files ( ) ; if ( ! $ document -> get_is_new ( ) ) { list ( $ numfound , $ indexedfiles ) = $ this -> get_indexed_files ( $ document , 0 , $ rows ) ; $ count = 0... | Index files attached to the docuemnt ensuring the index matches the current document files . |
30,977 | protected function get_indexed_files ( $ document , $ start = 0 , $ rows = 500 ) { $ query = new \ SolrQuery ( ) ; $ query -> setQuery ( '*' ) ; $ query -> setRows ( $ rows ) ; $ query -> setStart ( $ start ) ; $ query -> addSortField ( 'id' ) ; $ query -> addField ( 'id' ) ; $ query -> addField ( 'modified' ) ; $ quer... | Get the currently indexed files for a particular document returns the total count and a subset of files . |
30,978 | protected function convert_file_results ( $ responsedoc ) { if ( ! $ docs = $ responsedoc -> response -> docs ) { return array ( ) ; } $ out = array ( ) ; foreach ( $ docs as $ doc ) { $ result = new \ stdClass ( ) ; $ result -> id = $ doc -> id ; $ result -> modified = document :: import_time_from_engine ( $ doc -> mo... | A very lightweight handler for getting information about already indexed files from a Solr response . |
30,979 | protected function file_is_indexable ( $ file ) { if ( ! empty ( $ this -> config -> maxindexfilekb ) && ( $ file -> get_filesize ( ) > ( $ this -> config -> maxindexfilekb * 1024 ) ) ) { return false ; } $ mime = $ file -> get_mimetype ( ) ; if ( $ mime == 'application/vnd.moodle.backup' ) { return false ; } return tr... | Checks to see if a passed file is indexable . |
30,980 | public function is_server_ready ( ) { $ configured = $ this -> is_server_configured ( ) ; if ( $ configured !== true ) { return $ configured ; } if ( $ this -> should_skip_schema_check ( ) ) { return true ; } $ schemalatest = $ this -> check_latest_schema ( ) ; if ( $ schemalatest !== true ) { return $ schemalatest ; }... | Pings the Solr server using search_solr config |
30,981 | public function is_server_configured ( ) { if ( empty ( $ this -> config -> server_hostname ) || empty ( $ this -> config -> indexname ) ) { return 'No solr configuration found' ; } if ( ! $ client = $ this -> get_search_client ( false ) ) { return get_string ( 'engineserverstatus' , 'search' ) ; } try { if ( $ this ->... | Is the solr server properly configured? . |
30,982 | public function get_solr_major_version ( ) { if ( $ this -> solrmajorversion !== null ) { return $ this -> solrmajorversion ; } $ systemdata = @ $ this -> get_search_client ( ) -> system ( ) ; $ solrversion = $ systemdata -> getResponse ( ) -> offsetGet ( 'lucene' ) -> offsetGet ( 'solr-spec-version' ) ; $ this -> solr... | Returns the solr server major version . |
30,983 | protected function get_search_client ( $ triggerexception = true ) { global $ CFG ; if ( $ this -> client !== null ) { return $ this -> client ; } $ options = array ( 'hostname' => $ this -> config -> server_hostname , 'path' => '/solr/' . $ this -> config -> indexname , 'login' => ! empty ( $ this -> config -> server_... | Returns the solr client instance . |
30,984 | public function get_curl_object ( ) { if ( ! is_null ( $ this -> curl ) ) { return $ this -> curl ; } $ this -> curl = new \ curl ( [ 'ignoresecurity' => true ] ) ; $ options = array ( ) ; if ( ! empty ( $ this -> config -> secure ) ) { if ( ! empty ( $ this -> config -> ssl_cert ) ) { $ options [ 'CURLOPT_SSLCERT' ] =... | Returns a curl object for conntecting to solr . |
30,985 | public function get_connection_url ( $ path ) { $ protocol = ! empty ( $ this -> config -> secure ) ? 'https' : 'http' ; $ url = $ protocol . '://' . rtrim ( $ this -> config -> server_hostname , '/' ) ; if ( ! empty ( $ this -> config -> server_port ) ) { $ url .= ':' . $ this -> config -> server_port ; } $ url .= '/s... | Return a Moodle url object for the server connection . |
30,986 | public function get_supported_orders ( \ context $ context ) { $ orders = parent :: get_supported_orders ( $ context ) ; $ coursecontext = $ context -> get_course_context ( false ) ; if ( $ coursecontext ) { $ orders [ 'location' ] = get_string ( 'order_location' , 'search' , $ context -> get_context_name ( ) ) ; } ret... | Solr supports sort by location within course contexts or below . |
30,987 | public static function has_records_for_competencies ( $ competencyids ) { global $ DB ; list ( $ insql , $ params ) = $ DB -> get_in_or_equal ( $ competencyids , SQL_PARAMS_NAMED ) ; $ sql = "SELECT DISTINCT bc.badgeid FROM {badge_criteria} bc JOIN {badge_criteria_param} bcp ON bc.... | Check if any badge has records for competencies . |
30,988 | protected function prepare_sql_courses ( ) { global $ DB ; if ( ! preg_match ( '/\\%COURSEFILTER\\%/' , $ this -> sql ) ) { return ; } $ this -> init_course_access ( ) ; $ unaccessiblecourses = array_filter ( $ this -> courseaccess , function ( $ item ) { return ! $ item ; } ) ; $ idx = 0 ; while ( preg_match ( '/^([^\... | Substitute %COURSEFILTER% with an expression filtering out courses where current user does not have access |
30,989 | protected function prepare_sql_items ( ) { global $ DB ; if ( ! preg_match ( '/\\%ITEMFILTER\\%/' , $ this -> sql ) ) { return ; } $ this -> init_items_access ( ) ; $ unaccessibleitems = array_filter ( $ this -> accessibleitems , function ( $ item ) { return ! $ item ; } ) ; $ idx = 0 ; while ( preg_match ( '/^([^\\0]*... | Substitute %ITEMFILTER% with an expression filtering out items where current user does not have access |
30,990 | public function get_items ( ) { global $ DB , $ CFG ; if ( is_siteadmin ( ) ) { $ this -> sql = preg_replace ( '/\\%COURSEFILTER\\%/' , '<>0' , $ this -> sql ) ; $ this -> sql = preg_replace ( '/\\%ITEMFILTER\\%/' , '<>0' , $ this -> sql ) ; return $ DB -> get_records_sql ( $ this -> sql , $ this -> params , $ this -> ... | Returns the filtered records from SQL query result . |
30,991 | public function has_item_that_needs_access_check ( ) { if ( is_siteadmin ( ) ) { return null ; } $ this -> retrieve_items ( ) ; $ counter = 0 ; foreach ( $ this -> itemkeys as $ id ) { if ( ! array_key_exists ( $ id , $ this -> accessibleitems ) ) { return ( object ) ( array ) $ this -> items [ $ id ] ; } $ counter += ... | Returns the first row from the SQL result that we don t know whether it is accessible by user or not . |
30,992 | protected function init_items_access ( ) { if ( $ this -> accessibleitems === null ) { $ this -> accessibleitems = cache :: make ( 'core' , 'tagindexbuilder' ) -> get ( $ this -> component . '__' . $ this -> itemtype ) ? : [ ] ; } } | Ensures that we read the items access from the cache . |
30,993 | public function can_access_course ( $ courseid ) { $ this -> init_course_access ( ) ; if ( ! array_key_exists ( $ courseid , $ this -> courseaccess ) ) { $ this -> courseaccess [ $ courseid ] = can_access_course ( $ this -> get_course ( $ courseid ) ) ? 1 : 0 ; $ this -> cachechangedcourse = true ; } return $ this -> c... | Checks if current user has access to the course |
30,994 | protected function get_simple_query ( $ q ) { global $ DB ; $ sql = '(' . $ DB -> sql_like ( 'title' , '?' , false , false ) . ' OR ' . $ DB -> sql_like ( 'content' , '?' , false , false ) . ' OR ' . $ DB -> sql_like ( 'description1' , '?' , false , false ) . ' OR ' . $ DB -> sql_like ( 'description2' , '?' , false , f... | Returns the default query for db engines . |
30,995 | protected function annotate_plugin_config_files ( backup_nested_element $ assign , $ subtype ) { $ dummyassign = new assign ( null , null , null ) ; $ plugins = $ dummyassign -> load_plugins ( $ subtype ) ; foreach ( $ plugins as $ plugin ) { $ component = $ plugin -> get_subtype ( ) . '_' . $ plugin -> get_type ( ) ; ... | Annotate files from plugin configuration |
30,996 | public function generate ( array $ opts = array ( ) ) { $ this -> _guid = date ( 'YmdHis' ) . '.' . ( isset ( $ opts [ 'prefix' ] ) ? $ opts [ 'prefix' ] . '.' : '' ) . strval ( new Horde_Support_Randomid ( ) ) . '@' . ( isset ( $ opts [ 'server' ] ) ? $ opts [ 'server' ] : ( isset ( $ _SERVER [ 'SERVER_NAME' ] ) ? $ _... | Generates a GUID . |
30,997 | public static function initialize ( ) { $ instance = t3lib_div :: makeInstance ( 't3lib_l10n_Locales' ) ; $ instance -> isoMapping = array_flip ( $ instance -> isoReverseMapping ) ; if ( isset ( $ GLOBALS [ 'TYPO3_CONF_VARS' ] [ 'SYS' ] [ 'localization' ] [ 'locales' ] [ 'user' ] ) && is_array ( $ GLOBALS [ 'TYPO3_CONF... | Initializes the languages . |
30,998 | public function getLocaleDependencies ( $ locale ) { $ dependencies = array ( ) ; if ( isset ( $ this -> localeDependencies [ $ locale ] ) ) { $ dependencies = $ this -> localeDependencies [ $ locale ] ; $ localeDependencies = $ dependencies ; foreach ( $ localeDependencies as $ dependency ) { if ( isset ( $ this -> lo... | Returns the dependencies of a given locale if any . |
30,999 | public function getTerLocaleDependencies ( $ locale ) { $ terLocale = isset ( $ this -> isoMapping [ $ locale ] ) ? $ this -> isoMapping [ $ locale ] : $ locale ; return $ this -> convertToTerLocales ( $ this -> getLocaleDependencies ( $ terLocale ) ) ; } | Returns the dependencies of a given locale using TER compatible locale codes . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.