idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
33,200 | protected function runTraining ( array $ samples , array $ targets ) { $ callback = function ( $ weights , $ sample , $ target ) { $ this -> weights = $ weights ; $ prediction = $ this -> outputClass ( $ sample ) ; $ gradient = $ prediction - $ target ; $ error = $ gradient ** 2 ; return [ $ error , $ gradient ] ; } ; ... | Trains the perceptron model with Stochastic Gradient Descent optimization to get the correct set of weights |
33,201 | protected function runGradientDescent ( array $ samples , array $ targets , \ Closure $ gradientFunc , bool $ isBatch = false ) { $ class = $ isBatch ? GD :: class : StochasticGD :: class ; if ( empty ( $ this -> optimizer ) ) { $ this -> optimizer = ( new $ class ( $ this -> featureCount ) ) -> setLearningRate ( $ thi... | Executes a Gradient Descent algorithm for the given cost function |
33,202 | protected function checkNormalizedSample ( array $ sample ) { if ( $ this -> normalizer ) { $ samples = [ $ sample ] ; $ this -> normalizer -> transform ( $ samples ) ; $ sample = $ samples [ 0 ] ; } return $ sample ; } | Checks if the sample should be normalized and if so returns the normalized sample |
33,203 | public static function make_from_quiz ( $ quiz , $ when ) { $ options = new self ( ) ; $ options -> attempt = self :: extract ( $ quiz -> reviewattempt , $ when , true , false ) ; $ options -> correctness = self :: extract ( $ quiz -> reviewcorrectness , $ when ) ; $ options -> marks = self :: extract ( $ quiz -> revie... | Set up the various options from the quiz settings and a time constant . |
33,204 | public function get_course ( event_interface $ event ) { if ( is_null ( $ this -> courses ) ) { $ this -> load_courses ( ) ; } if ( $ course = $ event -> get_course ( ) ) { $ courseid = $ course -> get ( 'id' ) ; return isset ( $ this -> courses [ $ courseid ] ) ? $ this -> courses [ $ courseid ] : null ; } else { retu... | Get the related course object for a given event . |
33,205 | public function get_context ( event_interface $ event ) { global $ USER ; $ courseid = $ event -> get_course ( ) ? $ event -> get_course ( ) -> get ( 'id' ) : null ; $ groupid = $ event -> get_group ( ) ? $ event -> get_group ( ) -> get ( 'id' ) : null ; $ userid = $ event -> get_user ( ) ? $ event -> get_user ( ) -> g... | Get the related context for a given event . |
33,206 | public function get_group ( event_interface $ event ) { if ( is_null ( $ this -> groups ) ) { $ this -> load_groups ( ) ; } if ( $ group = $ event -> get_group ( ) ) { $ groupid = $ group -> get ( 'id' ) ; return isset ( $ this -> groups [ $ groupid ] ) ? $ this -> groups [ $ groupid ] : null ; } else { return null ; }... | Get the related group object for a given event . |
33,207 | public function get_course_module ( event_interface $ event ) { if ( ! $ event -> get_course_module ( ) ) { return null ; } $ id = $ event -> get_course_module ( ) -> get ( 'id' ) ; $ name = $ event -> get_course_module ( ) -> get ( 'modname' ) ; $ key = $ name . '_' . $ id ; if ( ! isset ( $ this -> coursemodules [ $ ... | Get the related course module for a given event . |
33,208 | public function get_module_instance ( event_interface $ event ) { if ( ! $ event -> get_course_module ( ) ) { return null ; } if ( is_null ( $ this -> moduleinstances ) ) { $ this -> load_module_instances ( ) ; } $ id = $ event -> get_course_module ( ) -> get ( 'instance' ) ; $ name = $ event -> get_course_module ( ) -... | Get the related module instance for a given event . |
33,209 | protected function load_courses ( ) { global $ DB ; $ courseids = [ ] ; foreach ( $ this -> events as $ event ) { if ( $ course = $ event -> get_course ( ) ) { $ id = $ course -> get ( 'id' ) ; $ courseids [ $ id ] = true ; } } if ( empty ( $ courseids ) ) { $ this -> courses = [ ] ; return ; } list ( $ idsql , $ param... | Load the list of all of the distinct courses required for the list of provided events and save the result in memory . |
33,210 | protected function load_groups ( ) { global $ DB ; $ groupids = [ ] ; foreach ( $ this -> events as $ event ) { if ( $ group = $ event -> get_group ( ) ) { $ id = $ group -> get ( 'id' ) ; $ groupids [ $ id ] = true ; } } if ( empty ( $ groupids ) ) { $ this -> groups = [ ] ; return ; } list ( $ idsql , $ params ) = $ ... | Load the list of all of the distinct groups required for the list of provided events and save the result in memory . |
33,211 | protected function load_module_instances ( ) { global $ DB ; $ this -> moduleinstances = [ ] ; $ modulestoload = [ ] ; foreach ( $ this -> events as $ event ) { if ( $ module = $ event -> get_course_module ( ) ) { $ id = $ module -> get ( 'instance' ) ; $ name = $ module -> get ( 'modname' ) ; $ ids = isset ( $ modules... | Load the list of all of the distinct module instances required for the list of provided events and save the result in memory . |
33,212 | public function train_classification ( $ uniqueid , \ stored_file $ dataset , $ outputdir ) { $ modelfilepath = $ this -> get_model_filepath ( $ outputdir ) ; $ modelmanager = new ModelManager ( ) ; if ( file_exists ( $ modelfilepath ) ) { $ classifier = $ modelmanager -> restoreFromFile ( $ modelfilepath ) ; } else { ... | Train this processor classification model using the provided supervised learning dataset . |
33,213 | protected function get_evaluation_result_object ( \ stored_file $ dataset , $ phis , $ maxdeviation ) { if ( count ( $ phis ) === 1 ) { $ avgphi = reset ( $ phis ) ; } else { $ avgphi = \ Phpml \ Math \ Statistic \ Mean :: arithmetic ( $ phis ) ; } if ( count ( $ phis ) === 1 ) { $ modeldev = 0 ; } else { $ modeldev = ... | Returns the results objects from all evaluations . |
33,214 | protected function load_classifier ( $ outputdir ) { $ modelfilepath = $ this -> get_model_filepath ( $ outputdir ) ; if ( ! file_exists ( $ modelfilepath ) ) { throw new \ moodle_exception ( 'errorcantloadmodel' , 'mlbackend_php' , '' , $ modelfilepath ) ; } $ modelmanager = new ModelManager ( ) ; return $ modelmanage... | Loads the pre - trained classifier . |
33,215 | protected function get_phi ( $ testlabels , $ predictedlabels ) { $ matrix = \ Phpml \ Metric \ ConfusionMatrix :: compute ( $ testlabels , $ predictedlabels , array ( 0 , 1 ) ) ; $ tptn = $ matrix [ 0 ] [ 0 ] * $ matrix [ 1 ] [ 1 ] ; $ fpfn = $ matrix [ 1 ] [ 0 ] * $ matrix [ 0 ] [ 1 ] ; $ tpfp = $ matrix [ 0 ] [ 0 ] ... | Returns the Phi correlation coefficient . |
33,216 | public function loadXMLStructure ( ) { if ( $ this -> fileExists ( ) ) { if ( ! $ this -> validateXMLStructure ( ) ) { return false ; } $ contents = file_get_contents ( $ this -> path ) ; if ( strpos ( $ contents , '<STATEMENTS>' ) ) { $ contents = preg_replace ( '|<STATEMENTS>.*</STATEMENTS>|s' , '' , $ contents ) ; d... | Load and the XMLDB structure from file |
33,217 | public function arr2xmldb_structure ( $ xmlarr ) { $ structure = new xmldb_structure ( $ this -> path ) ; $ structure -> arr2xmldb_structure ( $ xmlarr ) ; return $ structure ; } | This function takes an xmlized array and put it into one xmldb_structure |
33,218 | public function saveXMLFile ( ) { $ structure = $ this -> getStructure ( ) ; $ result = file_put_contents ( $ this -> path , $ structure -> xmlOutput ( ) ) ; return $ result ; } | This function saves the whole xmldb_structure to its file |
33,219 | protected function update_init_params ( array & $ params , context $ context , array $ options = null ) { global $ USER ; if ( ! isloggedin ( ) or isguestuser ( ) ) { return ; } if ( ! isset ( $ options [ 'maxfiles' ] ) or $ options [ 'maxfiles' ] == 0 ) { return ; } $ params [ 'managefiles' ] = array ( 'usercontext' =... | Adjusts TinyMCE init parameters for tinymce_managefiles |
33,220 | public static function wiki_parser_link_callback ( $ link , $ options ) { $ l = urlencode ( $ link ) ; if ( ! empty ( $ options [ 'anchor' ] ) ) { $ l .= "#" . urlencode ( $ options [ 'anchor' ] ) ; } return array ( 'content' => $ link , 'url' => "http://" . $ l ) ; } | Default link generator |
33,221 | public static function wiki_parser_table_callback ( $ table ) { $ html = "" ; $ headers = $ table [ 0 ] ; $ columncount = count ( $ headers ) ; $ headerhtml = "" ; foreach ( $ headers as $ h ) { $ text = trim ( $ h [ 1 ] ) ; if ( $ h [ 0 ] == 'header' ) { $ headerhtml .= "\n" . parser_utils :: h ( 'th' , $ text ) . "\n... | Default table generator |
33,222 | protected function get_post_author ( $ userid , $ course , $ forum , $ cm , $ context ) { if ( ! isset ( $ this -> users [ $ userid ] ) ) { return false ; } $ user = $ this -> users [ $ userid ] ; if ( ! isset ( $ user -> groups ) ) { $ user -> groups = [ ] ; } if ( ! isset ( $ user -> groups [ $ forum -> id ] ) ) { $ ... | Fetch and initialise the post author . |
33,223 | protected function get_message_headers ( $ course , $ forum , $ discussion , $ post , $ a , $ message ) { $ cleanforumname = str_replace ( '"' , "'" , strip_tags ( format_string ( $ forum -> name ) ) ) ; $ viewurl = new \ moodle_url ( '/mod/forum/view.php' , [ 'f' => $ forum -> id ] ) ; $ headers = [ 'List-Id: "' . $ c... | Get the list of message headers . |
33,224 | protected function get_reply_address ( $ course , $ forum , $ discussion , $ post , $ cm , $ context ) { if ( $ this -> can_post ( $ course , $ forum , $ discussion , $ post , $ cm , $ context ) ) { $ this -> inboundmanager -> set_data ( $ post -> id ) ; return $ this -> inboundmanager -> generate ( $ this -> recipient... | Get a no - reply address for this user to reply to the current post . |
33,225 | protected function can_post ( $ course , $ forum , $ discussion , $ post , $ cm , $ context ) { if ( ! isset ( $ this -> canpostto [ $ discussion -> id ] ) ) { $ this -> canpostto [ $ discussion -> id ] = forum_user_can_post ( $ forum , $ discussion , $ this -> recipient , $ cm , $ course , $ context ) ; } return $ thi... | Check whether the user can post . |
33,226 | protected function can_view_fullnames ( $ course , $ forum , $ discussion , $ post , $ cm , $ context ) { if ( ! isset ( $ this -> viewfullnames [ $ forum -> id ] ) ) { $ this -> viewfullnames [ $ forum -> id ] = has_capability ( 'moodle/site:viewfullnames' , $ context , $ this -> recipient -> id ) ; } return $ this ->... | Check whether the user can view full names of other users . |
33,227 | protected function minimise_user_record ( \ stdClass $ user ) { unset ( $ user -> institution ) ; unset ( $ user -> department ) ; unset ( $ user -> address ) ; unset ( $ user -> city ) ; unset ( $ user -> url ) ; unset ( $ user -> currentlogin ) ; unset ( $ user -> description ) ; unset ( $ user -> descriptionformat )... | Removes properties from user record that are not necessary for sending post notifications . |
33,228 | public static function signup_form ( $ mform ) { if ( $ url = static :: get_embed_url ( ) ) { $ mform -> addElement ( 'header' , 'policyagreement' , get_string ( 'policyagreement' ) , '' ) ; $ mform -> setExpanded ( 'policyagreement' ) ; $ mform -> addElement ( 'static' , 'policylink' , '' , '<a href="' . $ url . '" on... | Adds Agree to site policy checkbox to the signup form . |
33,229 | public function data_preprocessing ( & $ data ) { if ( $ this -> current -> instance ) { $ draftitemid = file_get_submitted_draft_itemid ( 'instructauthors' ) ; $ data [ 'instructauthorseditor' ] [ 'text' ] = file_prepare_draft_area ( $ draftitemid , $ this -> context -> id , 'mod_workshop' , 'instructauthors' , 0 , wo... | Prepares the form before data are set |
33,230 | public function data_postprocessing ( $ data ) { parent :: data_postprocessing ( $ data ) ; foreach ( [ 'text' , 'file' ] as $ type ) { $ field = 'submissiontype' . $ type ; $ available = $ field . 'available' ; $ required = $ field . 'required' ; if ( $ data -> $ required ) { $ data -> $ field = WORKSHOP_SUBMISSION_TY... | Combine submission type checkboxes into integer values for the database . |
33,231 | public function definition_after_data ( ) { $ mform = & $ this -> _form ; if ( $ id = $ mform -> getElementValue ( 'update' ) ) { $ instance = $ mform -> getElementValue ( 'instance' ) ; $ gradeitems = grade_item :: fetch_all ( array ( 'itemtype' => 'mod' , 'itemmodule' => 'workshop' , 'iteminstance' => $ instance , 'c... | Set the grade item categories when editing an instance |
33,232 | public function validation ( $ data , $ files ) { $ errors = parent :: validation ( $ data , $ files ) ; if ( $ data [ 'submissionstart' ] > 0 and $ data [ 'submissionend' ] > 0 and $ data [ 'submissionstart' ] >= $ data [ 'submissionend' ] ) { $ errors [ 'submissionend' ] = get_string ( 'submissionendbeforestart' , 'm... | Validates the form input |
33,233 | private function get_forum_record ( ) : stdClass { $ forumdbdatamapper = $ this -> related [ 'legacydatamapperfactory' ] -> get_forum_data_mapper ( ) ; return $ forumdbdatamapper -> to_legacy_object ( $ this -> forum ) ; } | Get the legacy forum record for this forum . |
33,234 | protected static function export_policy_agreements_for_context ( \ context_user $ context ) { global $ DB ; $ sysctx = \ context_system :: instance ( ) ; $ fs = get_file_storage ( ) ; $ agreementsql = " SELECT a.id AS agreementid, a.userid, a.timemodified, a.note, a.status, a.po... | Export all policy agreements relating to the specified user context . |
33,235 | protected static function export_authored_policies ( \ stdClass $ user ) { global $ DB ; $ context = \ context_system :: instance ( ) ; $ basecontext = [ get_string ( 'policydocuments' , 'tool_policy' ) , ] ; $ sql = "SELECT v.id, v.name, v.revision, v.s... | Export all policy agreements that the user authored . |
33,236 | protected function definition ( ) { global $ CFG ; $ mform = $ this -> _form ; $ mform -> addElement ( 'header' , 'database' , get_string ( 'targetdatabase' , 'tool_dbtransfer' ) ) ; $ drivers = tool_dbtransfer_get_drivers ( ) ; $ drivers = array_reverse ( $ drivers , true ) ; $ drivers [ '' ] = get_string ( 'choosedot... | Define transfer form . |
33,237 | protected function expandCSSEscape ( $ string ) { $ ret = '' ; for ( $ i = 0 , $ c = strlen ( $ string ) ; $ i < $ c ; $ i ++ ) { if ( $ string [ $ i ] === '\\' ) { $ i ++ ; if ( $ i >= $ c ) { $ ret .= '\\' ; break ; } if ( ctype_xdigit ( $ string [ $ i ] ) ) { $ code = $ string [ $ i ] ; for ( $ a = 1 , $ i ++ ; $ i ... | Parses a possibly escaped CSS string and returns the pure version of it . |
33,238 | function ServerInfo ( ) { if ( ! empty ( $ this -> host ) && ADODB_PHPVER >= 0x4300 ) { $ stmt = $ this -> Prepare ( 'EXECUTE PROCEDURE sp_mgGetInstallInfo()' ) ; $ res = $ this -> Execute ( $ stmt ) ; if ( ! $ res ) print $ this -> ErrorMsg ( ) ; else { $ ret [ "version" ] = $ res -> fields [ 3 ] ; $ ret [ "descriptio... | returns the Server version and Description |
33,239 | function GenID ( $ seqname = 'adodbseq' , $ start = 1 ) { $ go = $ this -> Execute ( "select * from $seqname" ) ; if ( ! $ go ) { $ res = $ this -> Execute ( "CREATE TABLE $seqname ( ID autoinc( 1 ) ) IN DATABASE" ) ; if ( ! res ) { print $ this -> ErrorMsg ( ) ; return false ; } } $ res = $ this -> Execute ( "INSERT I... | and gets the ID number of the last inserted record . |
33,240 | function & MetaTables ( $ ttype = false , $ showSchema = false , $ mask = false ) { $ recordSet1 = $ this -> Execute ( "select * from system.tables" ) ; if ( ! $ recordSet1 ) { print $ this -> ErrorMsg ( ) ; return false ; } $ recordSet2 = $ this -> Execute ( "select * from system.views" ) ; if ( ! $ recordSet2 ) { pri... | tables by default on succesfull execustion . |
33,241 | function & MetaColumnNames ( $ table , $ numIndexes = false , $ useattnum = false ) { $ recordSet = $ this -> Execute ( "select name from system.columns where parent='$table'" ) ; if ( ! $ recordSet ) { print $ this -> ErrorMsg ( ) ; return false ; } else { $ i = 0 ; while ( ! $ recordSet -> EOF ) { $ arr [ "FIELD$i" ]... | Returns an array of columns names for a given table |
33,242 | public static function nonInputVar ( $ varname , $ default = null ) { return ( isset ( $ _GET [ $ varname ] ) || isset ( $ _POST [ $ varname ] ) || isset ( $ _COOKIE [ $ varname ] ) ) ? $ default : ( isset ( $ GLOBALS [ $ varname ] ) ? $ GLOBALS [ $ varname ] : $ default ) ; } | Checks to see if a value has been set by the script and not by GET POST or cookie input . The value being checked MUST be in the global scope . |
33,243 | public static function formInput ( $ append_session = 0 ) { return ( ( $ append_session == 1 ) || ! isset ( $ _COOKIE [ session_name ( ) ] ) ) ? '<input type="hidden" name="' . htmlspecialchars ( session_name ( ) ) . '" value="' . htmlspecialchars ( session_id ( ) ) . "\" />\n" : '' ; } | Returns a hidden form input containing the session name and id . |
33,244 | public static function createTempDir ( $ delete = true , $ temp_dir = null ) { if ( is_null ( $ temp_dir ) ) { $ temp_dir = sys_get_temp_dir ( ) ; } if ( empty ( $ temp_dir ) ) { return false ; } do { $ new_dir = $ temp_dir . '/' . substr ( base_convert ( uniqid ( mt_rand ( ) ) , 10 , 36 ) , 0 , 8 ) ; } while ( file_ex... | Creates a temporary directory in the system s temporary directory . |
33,245 | public static function deleteAtShutdown ( $ filename , $ register = true , $ secure = false ) { if ( ! self :: $ _shutdownreg ) { register_shutdown_function ( array ( __CLASS__ , 'shutdown' ) ) ; self :: $ _shutdownreg = true ; } $ ptr = & self :: $ _shutdowndata ; if ( $ register ) { $ ptr [ 'paths' ] [ $ filename ] =... | Removes given elements at request shutdown . |
33,246 | public static function shutdown ( ) { $ ptr = & self :: $ _shutdowndata ; foreach ( array_keys ( $ ptr [ 'paths' ] ) as $ val ) { if ( @ is_file ( $ val ) ) { self :: _secureDelete ( $ val ) ; continue ; } try { $ it = new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ val ) , RecursiveIteratorIterator ... | Deletes registered files at request shutdown . |
33,247 | protected static function _secureDelete ( $ file ) { if ( isset ( $ ptr [ 'secure' ] [ $ file ] ) ) { $ filesize = filesize ( $ file ) ; $ fp = fopen ( $ file , 'r+' ) ; foreach ( self :: $ patterns as $ pattern ) { $ pattern = substr ( str_repeat ( $ pattern , floor ( $ filesize / strlen ( $ pattern ) ) + 1 ) , 0 , $ ... | Securely delete the file by overwriting the data with a random string . |
33,248 | public static function loadExtension ( $ ext ) { if ( self :: extensionExists ( $ ext ) ) { return true ; } if ( ( ini_get ( 'enable_dl' ) != 1 ) || ( ini_get ( 'safe_mode' ) == 1 ) || ! function_exists ( 'dl' ) ) { return false ; } if ( ! strncasecmp ( PHP_OS , 'WIN' , 3 ) ) { $ suffix = 'dll' ; } else { switch ( PHP_... | Tries to load a PHP extension behaving correctly for all operating systems . |
33,249 | public static function getPathInfo ( ) { if ( isset ( $ _SERVER [ 'PATH_INFO' ] ) && ( strpos ( $ _SERVER [ 'SERVER_SOFTWARE' ] , 'lighttpd' ) === false ) ) { return $ _SERVER [ 'PATH_INFO' ] ; } elseif ( isset ( $ _SERVER [ 'REQUEST_URI' ] ) && isset ( $ _SERVER [ 'SCRIPT_NAME' ] ) ) { $ search = Horde_String :: commo... | Utility function to obtain PATH_INFO information . |
33,250 | public function process_workshopeval_best_setting ( $ data ) { global $ DB ; $ data = ( object ) $ data ; $ data -> workshopid = $ this -> get_new_parentid ( 'workshop' ) ; $ DB -> insert_record ( 'workshopeval_best_settings' , $ data ) ; } | Processes one workshopeval_best_settings element |
33,251 | public function find_right_answer ( $ wrappedquestion ) { while ( $ answer = array_shift ( $ wrappedquestion -> answers ) ) { if ( ! question_state :: graded_state_for_fraction ( $ answer -> fraction ) -> is_incorrect ( ) ) { $ key = array_search ( $ answer -> answer , $ this -> choices ) ; if ( $ key === false ) { $ k... | Find the corresponding choice id of the first correct answer of a shortanswer question . choice is added to the randomsamatch question if it doesn t already exist . |
33,252 | public function load_questions ( ) { if ( $ this -> choose > count ( $ this -> availablequestions ) ) { throw new coding_exception ( 'notenoughtshortanswerquestions' ) ; } $ questionids = draw_rand_array ( $ this -> availablequestions , $ this -> choose ) ; $ questions = array ( ) ; foreach ( $ questionids as $ questio... | Choose and load the desired number of questions . |
33,253 | public static function initialize ( ) { if ( self :: $ registered ) { debugging ( 'Shutdown manager is already initialised!' ) ; } self :: $ registered = true ; register_shutdown_function ( array ( 'core_shutdown_manager' , 'shutdown_handler' ) ) ; if ( CLI_SCRIPT && extension_loaded ( 'pcntl' ) && function_exists ( 'p... | Register self as main shutdown handler . |
33,254 | public static function signal_handler ( $ signo ) { switch ( $ signo ) { case SIGTERM : echo "Terminated: {$signo}\n" ; $ exitcode = 143 ; break ; case SIGINT : echo "\n" ; $ exitcode = 130 ; break ; default : echo "Warning: \core_shutdown_manager::signal_handler() was called with an unexpected signal ({$signo}).\n" ; ... | Signal handler for SIGINT and SIGTERM . |
33,255 | protected static function request_shutdown ( ) { global $ CFG ; $ apachereleasemem = false ; if ( function_exists ( 'apache_child_terminate' ) && function_exists ( 'memory_get_usage' ) && ini_get_bool ( 'child_terminate' ) ) { $ limit = ( empty ( $ CFG -> apachemaxmem ) ? 64 * 1024 * 1024 : $ CFG -> apachemaxmem ) ; if... | Standard shutdown sequence . |
33,256 | public function _createElements ( ) { if ( ! $ this -> has_customize_switch ( ) ) { $ element = $ this -> createFormElement ( 'hidden' , 'customize' , 1 ) ; } else { $ element = $ this -> createFormElement ( 'advcheckbox' , 'customize' , '' , $ this -> _options [ 'customlabel' ] ) ; } $ this -> _elements [ ] = $ elemen... | This will create all elements in the group |
33,257 | public 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 ( empty ( $ val... | Output a value . Give it the name of the group . In case of default return false . |
33,258 | public function is_feedback_modified ( stdClass $ grade , stdClass $ data ) { global $ USER ; $ filekey = null ; $ draftareainfo = null ; foreach ( $ data as $ key => $ value ) { if ( strpos ( $ key , 'files_' ) === 0 && strpos ( $ key , '_filemanager' ) ) { $ filekey = $ key ; } } if ( isset ( $ filekey ) ) { $ drafta... | Has the feedback file been modified? |
33,259 | private function copy_area_files ( file_storage $ fs , $ fromcontextid , $ fromcomponent , $ fromfilearea , $ fromitemid , $ tocontextid , $ tocomponent , $ tofilearea , $ toitemid ) { $ newfilerecord = new stdClass ( ) ; $ newfilerecord -> contextid = $ tocontextid ; $ newfilerecord -> component = $ tocomponent ; $ ne... | Copy all the files from one file area to another . |
33,260 | public function get_form_elements_for_user ( $ grade , MoodleQuickForm $ mform , stdClass $ data , $ userid ) { $ fileoptions = $ this -> get_file_options ( ) ; $ gradeid = $ grade ? $ grade -> id : 0 ; $ elementname = 'files_' . $ userid ; $ data = file_prepare_standard_filemanager ( $ data , $ elementname , $ fileopt... | Get form elements for grading form . |
33,261 | public function update_file_count ( $ grade ) { global $ DB ; $ filefeedback = $ this -> get_file_feedback ( $ grade -> id ) ; if ( $ filefeedback ) { $ filefeedback -> numfiles = $ this -> count_files ( $ grade -> id , ASSIGNFEEDBACK_FILE_FILEAREA ) ; return $ DB -> update_record ( 'assignfeedback_file' , $ filefeedba... | Update the number of files in the file area . |
33,262 | public function save ( stdClass $ grade , stdClass $ data ) { $ fileoptions = $ this -> get_file_options ( ) ; foreach ( $ data as $ key => $ value ) { if ( strpos ( $ key , 'files_' ) === 0 && strpos ( $ key , '_filemanager' ) ) { $ elementname = substr ( $ key , 0 , strpos ( $ key , '_filemanager' ) ) ; } } $ data = ... | Save the feedback files . |
33,263 | public function upgrade ( context $ oldcontext , stdClass $ oldassignment , stdClass $ oldsubmission , stdClass $ grade , & $ log ) { global $ DB ; $ this -> assignment -> copy_area_files_for_upgrade ( $ oldcontext -> id , 'mod_assignment' , 'response' , $ oldsubmission -> id , $ this -> assignment -> get_context ( ) -... | Upgrade the feedback from the old assignment to the new one . |
33,264 | public function view_page ( $ action ) { if ( $ action == 'uploadfiles' ) { $ users = required_param ( 'selectedusers' , PARAM_SEQUENCE ) ; return $ this -> view_batch_upload_files ( explode ( ',' , $ users ) ) ; } if ( $ action == 'uploadzip' ) { return $ this -> view_upload_zip ( ) ; } return '' ; } | Called by the assignment module when someone chooses something from the grading navigation or batch operations list . |
33,265 | public function get_config ( $ property ) { if ( property_exists ( $ this -> config , $ property ) ) { return $ this -> config -> $ property ; } throw new \ coding_exception ( 'Config property "' . $ property . '" doesn\'t exist' ) ; } | Config get method . |
33,266 | public function message_admins ( $ notice ) { $ site = get_site ( ) ; $ subject = get_string ( 'emailsubject' , 'antivirus' , format_string ( $ site -> fullname ) ) ; $ admins = get_admins ( ) ; foreach ( $ admins as $ admin ) { $ eventdata = new \ core \ message \ message ( ) ; $ eventdata -> courseid = SITEID ; $ eve... | Email admins about antivirus scan outcomes . |
33,267 | public static function get_class_for_mode ( $ mode ) { switch ( $ mode ) { case cache_store :: MODE_APPLICATION : return 'cache_application' ; case cache_store :: MODE_REQUEST : return 'cache_request' ; case cache_store :: MODE_SESSION : return 'cache_session' ; } throw new coding_exception ( 'Unknown cache mode passed... | Returns the class for use as a cache loader for the given mode . |
33,268 | public static function get_cache_stores ( cache_definition $ definition ) { $ instance = cache_config :: instance ( ) ; $ stores = $ instance -> get_stores_for_definition ( $ definition ) ; $ stores = self :: initialise_cachestore_instances ( $ stores , $ definition ) ; return $ stores ; } | Returns the cache stores to be used with the given definition . |
33,269 | protected static function initialise_cachestore_instances ( array $ stores , cache_definition $ definition ) { $ return = array ( ) ; $ factory = cache_factory :: instance ( ) ; foreach ( $ stores as $ name => $ details ) { $ store = $ factory -> create_store_from_config ( $ name , $ details , $ definition ) ; if ( $ s... | Internal function for initialising an array of stores against a given cache definition . |
33,270 | public static function get_cachelock_for_store ( cache_store $ store ) { $ instance = cache_config :: instance ( ) ; $ lockconf = $ instance -> get_lock_for_store ( $ store -> my_name ( ) ) ; $ factory = cache_factory :: instance ( ) ; return $ factory -> create_lock_instance ( $ lockconf ) ; } | Returns a cache_lock instance suitable for use with the store . |
33,271 | public static function early_get_cache_plugins ( ) { global $ CFG ; $ result = array ( ) ; $ ignored = array ( 'CVS' , '_vti_cnf' , 'simpletest' , 'db' , 'yui' , 'tests' ) ; $ fulldir = $ CFG -> dirroot . '/cache/stores' ; $ items = new DirectoryIterator ( $ fulldir ) ; foreach ( $ items as $ item ) { if ( $ item -> is... | Returns an array of plugins without using core methods . |
33,272 | public static function invalidate_by_definition ( $ component , $ area , array $ identifiers = array ( ) , $ keys = array ( ) ) { $ cache = cache :: make ( $ component , $ area , $ identifiers ) ; if ( is_array ( $ keys ) ) { $ cache -> delete_many ( $ keys ) ; } else if ( is_scalar ( $ keys ) ) { $ cache -> delete ( $... | Invalidates a given set of keys from a given definition . |
33,273 | public static function invalidate_by_event ( $ event , array $ keys ) { $ instance = cache_config :: instance ( ) ; $ invalidationeventset = false ; $ factory = cache_factory :: instance ( ) ; $ inuse = $ factory -> get_caches_in_use ( ) ; $ purgetoken = null ; foreach ( $ instance -> get_definitions ( ) as $ name => $... | Invalidates a given set of keys by means of an event . |
33,274 | public static function purge_by_definition ( $ component , $ area , array $ identifiers = array ( ) ) { $ cache = cache :: make ( $ component , $ area , $ identifiers ) ; if ( $ cache instanceof cache_store ) { $ factory = cache_factory :: instance ( ) ; $ definition = $ factory -> create_definition ( $ component , $ a... | Purges the cache for a specific definition . |
33,275 | protected static function ensure_ready_for_stats ( $ store , $ definition , $ mode = cache_store :: MODE_APPLICATION ) { if ( isset ( self :: $ stats [ $ definition ] [ 'stores' ] [ $ store ] ) ) { return ; } if ( ! array_key_exists ( $ definition , self :: $ stats ) ) { self :: $ stats [ $ definition ] = array ( 'mode... | Ensure that the stats array is ready to collect information for the given store and definition . |
33,276 | protected static function get_definition_stat_id_and_mode ( $ definition ) { if ( ! ( $ definition instanceof cache_definition ) ) { debugging ( 'Please update you cache stat calls to pass the definition rather than just its ID.' , DEBUG_DEVELOPER ) ; return array ( ( string ) $ definition , cache_store :: MODE_APPLICA... | Returns a string to describe the definition . |
33,277 | public static function record_cache_hit ( $ store , $ definition , $ hits = 1 ) { list ( $ definitionstr , $ mode ) = self :: get_definition_stat_id_and_mode ( $ definition ) ; self :: ensure_ready_for_stats ( $ store , $ definitionstr , $ mode ) ; self :: $ stats [ $ definitionstr ] [ 'stores' ] [ $ store ] [ 'hits' ]... | Record a cache hit in the stats for the given store and definition . |
33,278 | public static function record_cache_miss ( $ store , $ definition , $ misses = 1 ) { list ( $ definitionstr , $ mode ) = self :: get_definition_stat_id_and_mode ( $ definition ) ; self :: ensure_ready_for_stats ( $ store , $ definitionstr , $ mode ) ; self :: $ stats [ $ definitionstr ] [ 'stores' ] [ $ store ] [ 'miss... | Record a cache miss in the stats for the given store and definition . |
33,279 | public static function record_cache_set ( $ store , $ definition , $ sets = 1 ) { list ( $ definitionstr , $ mode ) = self :: get_definition_stat_id_and_mode ( $ definition ) ; self :: ensure_ready_for_stats ( $ store , $ definitionstr , $ mode ) ; self :: $ stats [ $ definitionstr ] [ 'stores' ] [ $ store ] [ 'sets' ]... | Record a cache set in the stats for the given store and definition . |
33,280 | public static function purge_all ( $ usewriter = false ) { $ factory = cache_factory :: instance ( ) ; $ config = $ factory -> create_config_instance ( $ usewriter ) ; foreach ( $ config -> get_all_stores ( ) as $ store ) { self :: purge_store ( $ store [ 'name' ] , $ config ) ; } foreach ( $ factory -> get_adhoc_cache... | Purge all of the cache stores of all of their data . |
33,281 | public static function purge_store ( $ storename , cache_config $ config = null ) { if ( $ config === null ) { $ config = cache_config :: instance ( ) ; } $ stores = $ config -> get_all_stores ( ) ; if ( ! array_key_exists ( $ storename , $ stores ) ) { return false ; } $ store = $ stores [ $ storename ] ; $ class = $ ... | Purges a store given its name . |
33,282 | public static function purge_stores_used_by_definition ( $ component , $ area ) { $ factory = cache_factory :: instance ( ) ; $ config = $ factory -> create_config_instance ( ) ; $ definition = $ factory -> create_definition ( $ component , $ area ) ; $ stores = $ config -> get_stores_for_definition ( $ definition ) ; ... | Purges all of the stores used by a definition . |
33,283 | public static function get_definition_name ( $ definition ) { if ( $ definition instanceof cache_definition ) { return $ definition -> get_name ( ) ; } $ identifier = 'cachedef_' . clean_param ( $ definition [ 'area' ] , PARAM_STRINGID ) ; $ component = $ definition [ 'component' ] ; if ( $ component === 'core' ) { $ c... | Returns the translated name of the definition . |
33,284 | public static function hash_key ( $ key , cache_definition $ definition ) { if ( $ definition -> uses_simple_keys ( ) ) { if ( debugging ( ) && preg_match ( '#[^a-zA-Z0-9_]#' , $ key ) ) { throw new coding_exception ( 'Cache definition ' . $ definition -> get_id ( ) . ' requires simple keys. Invalid key provided.' , $ ... | Hashes a descriptive key to make it shorter and still unique . |
33,285 | public static function update_definitions ( $ coreonly = false ) { global $ CFG ; require_once ( $ CFG -> dirroot . '/cache/locallib.php' ) ; cache_config_writer :: update_definitions ( $ coreonly ) ; cache_factory :: reset ( ) ; } | Finds all definitions and updates them within the cache config file . |
33,286 | public static function get_site_identifier ( ) { global $ CFG ; if ( ! is_null ( self :: $ siteidentifier ) ) { return self :: $ siteidentifier ; } $ factory = cache_factory :: instance ( ) ; if ( ! $ factory -> is_initialising ( ) ) { $ config = $ factory -> create_config_instance ( ) ; self :: $ siteidentifier = $ co... | Returns the site identifier . |
33,287 | public static function clean_old_session_data ( $ output = false ) { global $ CFG ; if ( $ output ) { mtrace ( 'Cleaning up stale session data from cache stores.' ) ; } $ factory = cache_factory :: instance ( ) ; $ config = $ factory -> create_config_instance ( ) ; $ definitions = $ config -> get_definitions ( ) ; $ pu... | Cleans old session data from cache stores used for session based definitions . |
33,288 | public static function get_stores_suitable_for_mode_default ( ) { $ factory = cache_factory :: instance ( ) ; $ config = $ factory -> create_config_instance ( ) ; $ requirements = 0 ; foreach ( $ config -> get_definitions ( ) as $ definition ) { $ definition = cache_definition :: load ( $ definition [ 'component' ] . '... | Returns an array of stores that would meet the requirements for every definition . |
33,289 | public static function get_stores_suitable_for_definition ( cache_definition $ definition ) { $ factory = cache_factory :: instance ( ) ; $ stores = array ( ) ; if ( $ factory -> is_initialising ( ) || $ factory -> stores_disabled ( ) ) { return $ stores ; } else { $ stores = self :: get_cache_stores ( $ definition ) ;... | Returns stores suitable for use with a given definition . |
33,290 | public static function warnings ( array $ stores = null ) { global $ CFG ; if ( $ stores === null ) { require_once ( $ CFG -> dirroot . '/cache/locallib.php' ) ; $ stores = cache_administration_helper :: get_store_instance_summaries ( ) ; } $ warnings = array ( ) ; foreach ( $ stores as $ store ) { if ( ! empty ( $ sto... | Returns an array of warnings from the cache API . |
33,291 | public function deleteToolConsumer ( $ consumer ) { global $ DB ; $ consumerpk = $ consumer -> getRecordId ( ) ; $ deletecondition = [ 'consumerid' => $ consumerpk ] ; $ DB -> delete_records ( $ this -> noncetable , $ deletecondition ) ; $ where = "resourcelinkid IN ( SELECT rl.id ... | Delete tool consumer object and related records . |
33,292 | public function getToolConsumers ( ) { global $ DB ; $ consumers = [ ] ; $ rsconsumers = $ DB -> get_recordset ( $ this -> consumertable , null , 'name' ) ; foreach ( $ rsconsumers as $ row ) { $ consumer = new ToolProvider \ ToolConsumer ( $ row -> consumerkey , $ this ) ; $ this -> build_tool_consumer_object ( $ row ... | Load all tool consumers from the database . |
33,293 | public function get_contexts_from_consumer ( ToolConsumer $ consumer ) { global $ DB ; $ contexts = [ ] ; $ contextrecords = $ DB -> get_records ( $ this -> contexttable , [ 'consumerid' => $ consumer -> getRecordId ( ) ] , '' , 'lticontextkey' ) ; foreach ( $ contextrecords as $ record ) { $ context = Context :: fromC... | Fetches the list of Context objects that are linked to a ToolConsumer . |
33,294 | public function get_resourcelink_from_consumer ( ToolConsumer $ consumer ) { global $ DB ; $ resourcelink = null ; if ( $ resourcelinkrecord = $ DB -> get_record ( $ this -> resourcelinktable , [ 'consumerid' => $ consumer -> getRecordId ( ) ] , 'ltiresourcelinkkey' ) ) { $ resourcelink = ResourceLink :: fromConsumer (... | Fetches a resource link record that is associated with a ToolConsumer . |
33,295 | public function get_resourcelink_from_context ( Context $ context ) { global $ DB ; $ resourcelink = null ; if ( $ resourcelinkrecord = $ DB -> get_record ( $ this -> resourcelinktable , [ 'contextid' => $ context -> getRecordId ( ) ] , 'ltiresourcelinkkey' ) ) { $ resourcelink = ResourceLink :: fromContext ( $ context... | Fetches a resource link record that is associated with a Context object . |
33,296 | public function get_consumers_mapped_to_tool ( $ toolid ) { global $ DB ; $ consumers = [ ] ; $ consumerrecords = $ DB -> get_records ( 'enrol_lti_tool_consumer_map' , [ 'toolid' => $ toolid ] , '' , 'consumerid' ) ; foreach ( $ consumerrecords as $ record ) { $ consumers [ ] = ToolConsumer :: fromRecordId ( $ record -... | Fetches the list of ToolConsumer objects that are linked to a tool . |
33,297 | protected function build_tool_consumer_object ( $ record , ToolConsumer $ consumer ) { $ consumer -> setRecordId ( $ record -> id ) ; $ consumer -> name = $ record -> name ; $ key = empty ( $ record -> consumerkey ) ? $ record -> consumerkey256 : $ record -> consumerkey ; $ consumer -> setKey ( $ key ) ; $ consumer -> ... | Builds a ToolConsumer object from a record object from the DB . |
33,298 | public function isLocal ( $ config , $ context ) { if ( $ this -> host === null ) { return true ; } $ uri_def = $ config -> getDefinition ( 'URI' ) ; if ( $ uri_def -> host === $ this -> host ) { return true ; } return false ; } | Returns true if this URL might be considered a local URL given the current context . This is true when the host is null or when it matches the host supplied to the configuration . |
33,299 | public function other_cols ( $ column , $ row ) { if ( preg_match ( '/^val(\d+)$/' , $ column , $ matches ) ) { $ items = $ this -> feedbackstructure -> get_items ( ) ; $ itemobj = feedback_get_item_class ( $ items [ $ matches [ 1 ] ] -> typ ) ; return trim ( $ itemobj -> get_printval ( $ items [ $ matches [ 1 ] ] , ( ... | Allows to set the display column value for all columns without col_xxxxx method . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.