idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
33,800 | public function add_question_in_place_of_other ( $ slot , question_definition $ question , $ maxmark = null ) { $ newslot = $ this -> next_slot_number ( ) ; $ oldqa = $ this -> get_question_attempt ( $ slot ) ; $ oldqa -> set_slot ( $ newslot ) ; $ this -> questionattempts [ $ newslot ] = $ oldqa ; if ( $ maxmark === n... | Add another question to this usage in the place of an existing slot . The question_attempt that was in that slot is moved to the end at a new slot number which is returned . |
33,801 | public function get_total_mark ( ) { $ mark = 0 ; foreach ( $ this -> questionattempts as $ qa ) { if ( $ qa -> get_max_mark ( ) > 0 && $ qa -> get_state ( ) == question_state :: $ needsgrading ) { return null ; } $ mark += $ qa -> get_mark ( ) ; } return $ mark ; } | Get the total mark for all questions in this usage . |
33,802 | public function get_summary_information ( question_display_options $ options ) { return question_engine :: get_behaviour_type ( $ this -> preferredbehaviour ) -> summarise_usage ( $ this , $ options ) ; } | Get summary information about this usage . |
33,803 | public function set_question_attempt_metadata ( $ slot , $ name , $ value ) { $ this -> get_question_attempt ( $ slot ) -> set_metadata ( $ name , $ value ) ; } | Set some metadata for a particular question attempt in this usage . |
33,804 | public function replace_loaded_question_attempt_info ( $ slot , $ qa ) { $ this -> check_slot ( $ slot ) ; $ this -> questionattempts [ $ slot ] = $ qa ; } | Replace a particular question_attempt with a different one . |
33,805 | public function start_question ( $ slot , $ variant = null , $ timenow = null ) { if ( is_null ( $ variant ) ) { $ variant = rand ( 1 , $ this -> get_num_variants ( $ slot ) ) ; } $ qa = $ this -> get_question_attempt ( $ slot ) ; $ qa -> start ( $ this -> preferredbehaviour , $ variant , array ( ) , $ timenow ) ; $ th... | Start the attempt at a question that has been added to this usage . |
33,806 | public function start_all_questions ( question_variant_selection_strategy $ variantstrategy = null , $ timestamp = null , $ userid = null ) { if ( is_null ( $ variantstrategy ) ) { $ variantstrategy = new question_variant_random_strategy ( ) ; } foreach ( $ this -> questionattempts as $ qa ) { $ qa -> start ( $ this ->... | Start the attempt at all questions that has been added to this usage . |
33,807 | public function process_all_actions ( $ timestamp = null , $ postdata = null ) { foreach ( $ this -> get_slots_in_request ( $ postdata ) as $ slot ) { if ( ! $ this -> validate_sequence_number ( $ slot , $ postdata ) ) { continue ; } $ submitteddata = $ this -> extract_responses ( $ slot , $ postdata ) ; $ this -> proc... | Process all the question actions in the current request . |
33,808 | public function process_all_autosaves ( $ timestamp = null , $ postdata = null ) { foreach ( $ this -> get_slots_in_request ( $ postdata ) as $ slot ) { if ( ! $ this -> is_autosave_required ( $ slot , $ postdata ) ) { continue ; } $ submitteddata = $ this -> extract_responses ( $ slot , $ postdata ) ; $ this -> proces... | Process all the question autosave data in the current request . |
33,809 | protected function get_slots_in_request ( $ postdata = null ) { if ( is_null ( $ postdata ) ) { $ slots = optional_param ( 'slots' , null , PARAM_SEQUENCE ) ; } else if ( array_key_exists ( 'slots' , $ postdata ) ) { $ slots = clean_param ( $ postdata [ 'slots' ] , PARAM_SEQUENCE ) ; } else { $ slots = null ; } if ( is... | Get the list of slot numbers that should be processed as part of processing the current request . |
33,810 | public function prepare_simulated_post_data ( $ simulatedresponses ) { $ simulatedpostdata = array ( ) ; $ simulatedpostdata [ 'slots' ] = implode ( ',' , array_keys ( $ simulatedresponses ) ) ; foreach ( $ simulatedresponses as $ slot => $ responsedata ) { $ slotresponse = array ( ) ; $ behaviourvars = $ this -> get_q... | Transform an array of response data for slots to an array of post data as you would get from quiz attempt form . |
33,811 | public function process_action ( $ slot , $ submitteddata , $ timestamp = null ) { $ qa = $ this -> get_question_attempt ( $ slot ) ; $ qa -> process_action ( $ submitteddata , $ timestamp ) ; $ this -> observer -> notify_attempt_modified ( $ qa ) ; } | Process a specific action on a specific question . |
33,812 | public function validate_sequence_number ( $ slot , $ postdata = null ) { $ qa = $ this -> get_question_attempt ( $ slot ) ; $ sequencecheck = $ qa -> get_submitted_var ( $ qa -> get_control_field_name ( 'sequencecheck' ) , PARAM_INT , $ postdata ) ; if ( is_null ( $ sequencecheck ) ) { return false ; } else if ( $ seq... | Check that the sequence number that detects weird things like the student clicking back is OK . If the sequence check variable is not present returns false . If the check variable is present and correct returns true . If the variable is present and wrong throws an exception . |
33,813 | public function is_autosave_required ( $ slot , $ postdata = null ) { $ qa = $ this -> get_question_attempt ( $ slot ) ; $ sequencecheck = $ qa -> get_submitted_var ( $ qa -> get_control_field_name ( 'sequencecheck' ) , PARAM_INT , $ postdata ) ; if ( is_null ( $ sequencecheck ) ) { return false ; } else if ( $ sequenc... | Check based on the sequence number whether this auto - save is still required . |
33,814 | public function finish_question ( $ slot , $ timestamp = null ) { $ qa = $ this -> get_question_attempt ( $ slot ) ; $ qa -> finish ( $ timestamp ) ; $ this -> observer -> notify_attempt_modified ( $ qa ) ; } | Finish the active phase of an attempt at a question . |
33,815 | public function manual_grade ( $ slot , $ comment , $ mark , $ commentformat = null ) { $ qa = $ this -> get_question_attempt ( $ slot ) ; $ qa -> manual_grade ( $ comment , $ mark , $ commentformat ) ; $ this -> observer -> notify_attempt_modified ( $ qa ) ; } | Perform a manual grading action on a question attempt . |
33,816 | public function regrade_question ( $ slot , $ finished = false , $ newmaxmark = null ) { $ oldqa = $ this -> get_question_attempt ( $ slot ) ; if ( is_null ( $ newmaxmark ) ) { $ newmaxmark = $ oldqa -> get_max_mark ( ) ; } $ newqa = new question_attempt ( $ oldqa -> get_question ( ) , $ oldqa -> get_usage_id ( ) , $ t... | Regrade a question in this usage . This replays the sequence of submitted actions to recompute the outcomes . |
33,817 | public static function load_from_records ( $ records , $ qubaid ) { $ record = $ records -> current ( ) ; while ( $ record -> qubaid != $ qubaid ) { $ records -> next ( ) ; if ( ! $ records -> valid ( ) ) { throw new coding_exception ( "Question usage {$qubaid} not found in the database." ) ; } $ record = $ records -> ... | Create a question_usage_by_activity from records loaded from the database . |
33,818 | public static function generate_shortname ( $ data , $ templateshortname ) { if ( empty ( $ templateshortname ) && ! is_numeric ( $ templateshortname ) ) { return null ; } if ( strpos ( $ templateshortname , '%' ) === false ) { return $ templateshortname ; } $ course = ( object ) $ data ; $ fullname = isset ( $ course ... | Generate a shortname based on a template . |
33,819 | public static function generate_shortname_callback ( $ fullname , $ idnumber , $ block ) { switch ( $ block [ 3 ] ) { case 'f' : $ repl = $ fullname ; break ; case 'i' : $ repl = $ idnumber ; break ; default : return $ block [ 0 ] ; } switch ( $ block [ 1 ] ) { case '+' : $ repl = core_text :: strtoupper ( $ repl ) ; b... | Callback used when generating a shortname based on a template . |
33,820 | public static function get_enrolment_data ( $ data ) { $ enrolmethods = array ( ) ; $ enroloptions = array ( ) ; foreach ( $ data as $ field => $ value ) { $ matches = array ( ) ; if ( preg_match ( '/^enrolment_(\d+)(_(.+))?$/' , $ field , $ matches ) ) { $ key = $ matches [ 1 ] ; if ( ! isset ( $ enroloptions [ $ key ... | Extract enrolment data from passed data . |
33,821 | public static function get_enrolment_plugins ( ) { $ cache = cache :: make ( 'tool_uploadcourse' , 'helper' ) ; if ( ( $ enrol = $ cache -> get ( 'enrol' ) ) === false ) { $ enrol = enrol_get_plugins ( false ) ; $ cache -> set ( 'enrol' , $ enrol ) ; } return $ enrol ; } | Return the enrolment plugins . |
33,822 | public static function get_restore_content_dir ( $ backupfile = null , $ shortname = null , & $ errors = array ( ) ) { global $ CFG , $ DB , $ USER ; $ cachekey = null ; if ( ! empty ( $ backupfile ) ) { $ backupfile = realpath ( $ backupfile ) ; if ( empty ( $ backupfile ) || ! is_readable ( $ backupfile ) ) { $ error... | Get the restore content tempdir . |
33,823 | public static function get_role_ids ( ) { $ cache = cache :: make ( 'tool_uploadcourse' , 'helper' ) ; if ( ( $ roles = $ cache -> get ( 'roles' ) ) === false ) { $ roles = array ( ) ; $ rolesraw = get_all_roles ( ) ; foreach ( $ rolesraw as $ role ) { $ roles [ $ role -> shortname ] = $ role -> id ; } $ cache -> set (... | Return the role IDs . |
33,824 | public static function get_role_names ( $ data , & $ errors = array ( ) ) { $ rolenames = array ( ) ; $ rolesids = self :: get_role_ids ( ) ; $ invalidroles = array ( ) ; foreach ( $ data as $ field => $ value ) { $ matches = array ( ) ; if ( preg_match ( '/^role_(.+)?$/' , $ field , $ matches ) ) { if ( ! isset ( $ ro... | Get the role renaming data from the passed data . |
33,825 | public static function increment_idnumber ( $ idnumber ) { global $ DB ; while ( $ DB -> record_exists ( 'course' , array ( 'idnumber' => $ idnumber ) ) ) { $ matches = array ( ) ; if ( ! preg_match ( '/(.*?)([0-9]+)$/' , $ idnumber , $ matches ) ) { $ newidnumber = $ idnumber . '_2' ; } else { $ newidnumber = $ matche... | Helper to increment an ID number . |
33,826 | public static function increment_shortname ( $ shortname ) { global $ DB ; do { $ matches = array ( ) ; if ( ! preg_match ( '/(.*?)([0-9]+)$/' , $ shortname , $ matches ) ) { $ newshortname = $ shortname . '_2' ; } else { $ newshortname = $ matches [ 1 ] . ( $ matches [ 2 ] + 1 ) ; } $ shortname = $ newshortname ; } wh... | Helper to increment a shortname . |
33,827 | public static function resolve_category ( $ data , & $ errors = array ( ) ) { $ catid = null ; if ( ! empty ( $ data [ 'category' ] ) ) { $ category = core_course_category :: get ( ( int ) $ data [ 'category' ] , IGNORE_MISSING ) ; if ( ! empty ( $ category ) && ! empty ( $ category -> id ) ) { $ catid = $ category -> ... | Resolve a category based on the data passed . |
33,828 | public static function resolve_category_by_idnumber ( $ idnumber ) { global $ DB ; $ cache = cache :: make ( 'tool_uploadcourse' , 'helper' ) ; $ cachekey = 'cat_idn_' . $ idnumber ; if ( ( $ id = $ cache -> get ( $ cachekey ) ) === false ) { $ params = array ( 'idnumber' => $ idnumber ) ; $ id = $ DB -> get_field_sele... | Resolve a category by ID number . |
33,829 | public static function resolve_category_by_path ( array $ path ) { global $ DB ; $ cache = cache :: make ( 'tool_uploadcourse' , 'helper' ) ; $ cachekey = 'cat_path_' . serialize ( $ path ) ; if ( ( $ id = $ cache -> get ( $ cachekey ) ) === false ) { $ parent = 0 ; $ sql = 'name = :name AND parent = :parent' ; while (... | Resolve a category by path . |
33,830 | private function do_query ( $ sql , $ params , $ sql_query_type , $ free_result = true , $ scrollable = false ) { list ( $ sql , $ params , $ type ) = $ this -> fix_sql_params ( $ sql , $ params ) ; $ sql = $ this -> emulate_bound_params ( $ sql , $ params ) ; $ this -> query_start ( $ sql , $ params , $ sql_query_type... | Prepare the query binding and do the actual query . |
33,831 | private function sqlsrvtype2moodletype ( $ sqlsrv_type ) { $ type = null ; switch ( strtoupper ( $ sqlsrv_type ) ) { case 'BIT' : $ type = 'L' ; break ; case 'INT' : case 'SMALLINT' : case 'INTEGER' : case 'BIGINT' : $ type = 'I' ; break ; case 'DECIMAL' : case 'REAL' : case 'FLOAT' : $ type = 'N' ; break ; case 'VARCH... | Provides mapping between sqlsrv native data types and moodle_database - database_column_info - ones ) |
33,832 | protected function add_no_lock_to_temp_tables ( $ sql ) { return preg_replace_callback ( '/(\{([a-z][a-z0-9_]*)\})(\s+(\w+))?/' , function ( $ matches ) { $ table = $ matches [ 1 ] ; $ name = $ matches [ 2 ] ; $ tail = isset ( $ matches [ 3 ] ) ? $ matches [ 3 ] : '' ; $ replacement = $ matches [ 0 ] ; if ( $ this -> t... | Use NOLOCK on any temp tables . Since it s a temp table and uncommitted reads are low risk anyway . |
33,833 | protected function create_recordset ( $ result ) { $ rs = new sqlsrv_native_moodle_recordset ( $ result , $ this ) ; $ this -> recordsets [ ] = $ rs ; return $ rs ; } | Create a record set and initialize with first row |
33,834 | public function recordset_closed ( sqlsrv_native_moodle_recordset $ rs ) { if ( $ key = array_search ( $ rs , $ this -> recordsets , true ) ) { unset ( $ this -> recordsets [ $ key ] ) ; } } | Do not use outside of recordset class . |
33,835 | private function sqlsrv_fetch_id ( ) { $ query_id = sqlsrv_query ( $ this -> sqlsrv , 'SELECT SCOPE_IDENTITY()' ) ; if ( $ query_id === false ) { $ dberr = $ this -> get_last_error ( ) ; return false ; } $ row = $ this -> sqlsrv_fetchrow ( $ query_id ) ; return ( int ) $ row [ 0 ] ; } | Get the ID of the current action |
33,836 | private function sqlsrv_fetchrow ( $ query_id ) { $ row = sqlsrv_fetch_array ( $ query_id , SQLSRV_FETCH_NUMERIC ) ; if ( $ row === false ) { $ dberr = $ this -> get_last_error ( ) ; return false ; } foreach ( $ row as $ key => $ value ) { $ row [ $ key ] = ( $ value === ' ' || $ value === NULL ) ? '' : $ value ; } ret... | Fetch a single row into an numbered array |
33,837 | public function is_fulltext_search_supported ( ) { global $ CFG ; $ sql = "SELECT FULLTEXTSERVICEPROPERTY('IsFullTextInstalled')" ; $ this -> query_start ( $ sql , null , SQL_QUERY_AUX ) ; $ result = sqlsrv_query ( $ this -> sqlsrv , $ sql ) ; $ this -> query_end ( $ result ) ; if ( $ result ) { if ( $ row = sqlsrv_fet... | Is fulltext search enabled? . |
33,838 | public static function get_backup_status_array ( ) { global $ DB ; $ result = array ( self :: BACKUP_STATUS_ERROR => 0 , self :: BACKUP_STATUS_OK => 0 , self :: BACKUP_STATUS_UNFINISHED => 0 , self :: BACKUP_STATUS_SKIPPED => 0 , self :: BACKUP_STATUS_WARNING => 0 , self :: BACKUP_STATUS_NOTYETRUN => 0 ) ; $ statuses =... | Gets the results from the last automated backup that was run based upon the statuses of the courses that were looked at . |
33,839 | public static function calculate_next_automated_backup ( $ ignoredtimezone , $ now ) { $ config = get_config ( 'backup' ) ; $ backuptime = new DateTime ( '@' . $ now ) ; $ backuptime -> setTimezone ( core_date :: get_server_timezone_object ( ) ) ; $ backuptime -> setTime ( $ config -> backup_auto_hour , $ config -> bac... | Works out the next time the automated backup should be run . |
33,840 | public static function outcome_from_results ( $ results ) { $ outcome = self :: BACKUP_STATUS_OK ; foreach ( $ results as $ code => $ value ) { switch ( $ code ) { case 'missing_files_in_pool' : $ outcome = self :: BACKUP_STATUS_WARNING ; break ; } if ( $ outcome == self :: BACKUP_STATUS_ERROR ) { break ; } } return $ ... | Returns the backup outcome by analysing its results . |
33,841 | public static function remove_deleted_courses_from_schedule ( ) { global $ DB ; $ skipped = 0 ; $ sql = "SELECT bc.courseid FROM {backup_courses} bc WHERE bc.courseid NOT IN (SELECT c.id FROM {course} c)" ; $ rs = $ DB -> get_recordset_sql ( $ sql ) ; foreach ( $ rs as $ deletedcourse ) { $ DB -> delete_records ( 'back... | Removes deleted courses fromn the backup_courses table so that we don t waste time backing them up . |
33,842 | public static function get_automated_backup_state ( $ rundirective = self :: RUN_ON_SCHEDULE ) { global $ DB ; $ config = get_config ( 'backup' ) ; $ active = ( int ) $ config -> backup_auto_active ; $ weekdays = ( string ) $ config -> backup_auto_weekdays ; if ( $ active === self :: AUTO_BACKUP_DISABLED || ( $ rundire... | Gets the state of the automated backup system . |
33,843 | public static function set_state_running ( $ running = true ) { if ( $ running === true ) { if ( self :: get_automated_backup_state ( ) === self :: STATE_RUNNING ) { throw new backup_helper_exception ( 'backup_automated_already_running' ) ; } set_config ( 'backup_auto_running' , '1' , 'backup' ) ; } else { unset_config... | Sets the state of the automated backup system . |
33,844 | public static function remove_excess_backups ( $ course , $ now = null ) { $ config = get_config ( 'backup' ) ; $ maxkept = ( int ) $ config -> backup_auto_max_kept ; $ storage = $ config -> backup_auto_storage ; $ deletedays = ( int ) $ config -> backup_auto_delete_days ; if ( $ maxkept == 0 && $ deletedays == 0 ) { r... | Removes excess backups from a specified course . |
33,845 | protected static function remove_excess_backups_from_course ( $ course , $ now ) { $ fs = get_file_storage ( ) ; $ context = context_course :: instance ( $ course -> id ) ; $ component = 'backup' ; $ filearea = 'automated' ; $ itemid = 0 ; $ backupfiles = array ( ) ; $ backupfilesarea = $ fs -> get_area_files ( $ conte... | Removes excess backups in the course backup filearea from a specified course . |
33,846 | protected static function remove_excess_backups_from_directory ( $ course , $ now ) { $ config = get_config ( 'backup' ) ; $ dir = $ config -> backup_auto_destination ; $ isnotvaliddir = ! file_exists ( $ dir ) || ! is_dir ( $ dir ) || ! is_writable ( $ dir ) ; if ( $ isnotvaliddir ) { mtrace ( 'Error: ' . $ dir . ' do... | Removes excess backups in the specified external directory from a specified course . |
33,847 | protected static function get_backups_to_delete ( $ backupfiles , $ now ) { $ config = get_config ( 'backup' ) ; $ maxkept = ( int ) $ config -> backup_auto_max_kept ; $ deletedays = ( int ) $ config -> backup_auto_delete_days ; $ minkept = ( int ) $ config -> backup_auto_min_kept ; krsort ( $ backupfiles ) ; $ tokeep ... | Get the list of backup files to delete depending on the automated backup settings . |
33,848 | protected static function is_course_modified ( $ courseid , $ since ) { $ logmang = get_log_manager ( ) ; $ readers = $ logmang -> get_readers ( 'core\log\sql_reader' ) ; $ params = array ( 'courseid' => $ courseid , 'since' => $ since ) ; foreach ( $ readers as $ readerpluginname => $ reader ) { $ where = "courseid = ... | Check logs to find out if a course was modified since the given time . |
33,849 | public function get_type ( ) { if ( isset ( $ this -> file -> headers [ 'content-type' ] ) ) { if ( ! isset ( $ this -> file -> headers [ 'content-encoding' ] ) && ( $ this -> file -> headers [ 'content-type' ] === 'text/plain' || $ this -> file -> headers [ 'content-type' ] === 'text/plain; charset=ISO-8859-1' || $ th... | Get the Content - Type of the specified file |
33,850 | public function text_or_binary ( ) { if ( substr ( $ this -> file -> body , 0 , 2 ) === "\xFE\xFF" || substr ( $ this -> file -> body , 0 , 2 ) === "\xFF\xFE" || substr ( $ this -> file -> body , 0 , 4 ) === "\x00\x00\xFE\xFF" || substr ( $ this -> file -> body , 0 , 3 ) === "\xEF\xBB\xBF" ) { return 'text/plain' ; } e... | Sniff text or binary |
33,851 | protected function get_cm ( $ modulename , $ instanceid , $ courseid ) { $ modinfo = get_fast_modinfo ( $ courseid ) ; $ instances = $ modinfo -> get_instances_of ( $ modulename ) ; foreach ( $ instances as $ cminfo ) { if ( $ cminfo -> instance == $ instanceid ) { return $ cminfo ; } } throw new \ dml_missing_record_e... | Gets the course module for the required instanceid + modulename . |
33,852 | public function get_contexts_to_reindex ( ) { global $ DB ; list ( $ extrajoins , $ dborder ) = $ this -> get_contexts_to_reindex_extra_sql ( ) ; $ contexts = [ ] ; $ selectcolumns = \ context_helper :: get_preload_record_columns_sql ( 'x' ) ; $ groupbycolumns = '' ; foreach ( \ context_helper :: get_preload_record_col... | Gets a list of all contexts to reindex when reindexing this search area . |
33,853 | protected function _normalizeEOL ( $ data ) { return strtr ( $ data , array ( "\r\n" => $ this -> sep , "\r" => $ this -> sep , "\n" => $ this -> sep ) ) ; } | Normalizes EOLs in string data . |
33,854 | protected function _getFrom ( $ from , $ headers ) { foreach ( array_keys ( $ headers ) as $ hdr ) { if ( strcasecmp ( $ hdr , 'Return-Path' ) === 0 ) { $ from = $ headers [ $ hdr ] ; break ; } } if ( ! strlen ( $ from ) ) { throw new Horde_Mail_Exception ( 'No from address provided.' ) ; } $ from = new Horde_Mail_Rfc8... | Get the from address . |
33,855 | public function definition ( ) { $ mform = $ this -> _form ; $ mform -> addElement ( 'hidden' , 'returnurl' , $ this -> _customdata [ 'returnurl' ] ) ; $ mform -> setType ( 'returnurl' , PARAM_LOCALURL ) ; $ mform -> addElement ( 'submit' , 'all' , get_string ( 'purgecaches' , 'admin' ) ) ; $ mform -> addElement ( 'hea... | Define a Purge all caches button and a fieldset with checkboxes for selectively purging separate caches . |
33,856 | public function validation ( $ data , $ files ) { $ errors = [ ] ; if ( isset ( $ data [ 'purgeselectedcaches' ] ) && empty ( array_filter ( $ data [ 'purgeselectedoptions' ] ) ) ) { $ errors [ 'purgeselectedoptions' ] = get_string ( 'purgecachesnoneselected' , 'admin' ) ; } return $ errors ; } | If the Purge selected caches button was pressed ensure at least one cache was selected . |
33,857 | public function after_restore ( ) { global $ DB ; $ blockid = $ this -> get_blockid ( ) ; $ configdata = $ DB -> get_field ( 'block_instances' , 'configdata' , array ( 'id' => $ blockid ) ) ; $ newconfigdata = '' ; if ( ! empty ( $ configdata ) ) { $ config = unserialize ( base64_decode ( $ configdata ) ) ; $ config ->... | This function executed after all the tasks in the plan have been executed will perform the recode of the target quiz for the block . This must be done here and not in normal execution steps because the quiz can be restored after the block . |
33,858 | public function render_blog_entry_attachment ( blog_entry_attachment $ attachment ) { $ syscontext = context_system :: instance ( ) ; if ( file_mimetype_in_typegroup ( $ attachment -> file -> get_mimetype ( ) , 'web_image' ) ) { $ attrs = array ( 'src' => $ attachment -> url , 'alt' => '' ) ; $ o = html_writer :: empty... | Renders an entry attachment |
33,859 | private function get_grade ( $ completion ) { $ grade = grade_get_course_grade ( $ completion -> userid , $ this -> course ) ; return $ grade -> grade ; } | Get user s course grade in this course |
33,860 | public function add_from_sql ( $ sql , $ params ) { global $ DB ; $ userids = $ DB -> get_records_sql ( $ sql , $ params ) ; if ( ! empty ( $ userids ) ) { $ this -> userids = array_merge ( $ this -> userids , $ userids ) ; } } | Add sql and params to return user IDs . |
33,861 | public function get_lineitem ( $ courseid , $ itemid , $ typeid ) { global $ DB , $ CFG ; require_once ( $ CFG -> libdir . '/gradelib.php' ) ; $ lineitem = \ grade_item :: fetch ( array ( 'id' => $ itemid ) ) ; if ( $ lineitem ) { $ gbs = $ this -> find_ltiservice_gradebookservice_for_lineitem ( $ itemid ) ; if ( ! $ g... | Fetch a lineitem instance . |
33,862 | public static function save_score ( $ gradeitem , $ score , $ userid ) { global $ DB , $ CFG ; $ source = 'mod' . self :: SERVICE_NAME ; if ( $ DB -> get_record ( 'user' , array ( 'id' => $ userid ) ) === false ) { throw new \ Exception ( null , 400 ) ; } require_once ( $ CFG -> libdir . '/gradelib.php' ) ; $ finalgrad... | Set a grade item . |
33,863 | public static function item_for_json ( $ item , $ endpoint , $ typeid ) { $ lineitem = new \ stdClass ( ) ; if ( is_null ( $ typeid ) ) { $ typeidstring = "" ; } else { $ typeidstring = "?type_id={$typeid}" ; } $ lineitem -> id = "{$endpoint}/{$item->id}/lineitem" . $ typeidstring ; $ lineitem -> label = $ item -> item... | Get the json object representation of the grade item |
33,864 | public static function result_for_json ( $ grade , $ endpoint , $ typeid ) { if ( is_null ( $ typeid ) ) { $ id = "{$endpoint}/results?user_id={$grade->userid}" ; } else { $ id = "{$endpoint}/results?type_id={$typeid}&user_id={$grade->userid}" ; } $ result = new \ stdClass ( ) ; $ result -> id = $ id ; $ result -> user... | Get the object matching the JSON representation of the result . |
33,865 | public static function check_lti_id ( $ linkid , $ course , $ toolproxy ) { global $ DB ; $ sqlparams1 = array ( ) ; $ sqlparams1 [ 'linkid' ] = $ linkid ; $ sqlparams1 [ 'course' ] = $ course ; $ ltiactivity = $ DB -> get_record ( 'lti' , array ( 'id' => $ linkid , 'course' => $ course ) ) ; if ( $ ltiactivity -> type... | Check if an LTI id is valid . |
33,866 | public static function check_lti_1x_id ( $ linkid , $ course , $ typeid ) { global $ DB ; $ sqlparams1 = array ( ) ; $ sqlparams1 [ 'linkid' ] = $ linkid ; $ sqlparams1 [ 'course' ] = $ course ; $ ltiactivity = $ DB -> get_record ( 'lti' , array ( 'id' => $ linkid , 'course' => $ course ) ) ; if ( $ ltiactivity ) { if ... | Check if an LTI id is valid when we are in a LTI 1 . x case |
33,867 | public static function is_user_gradable_in_course ( $ courseid , $ userid ) { global $ CFG ; $ gradableuser = false ; $ coursecontext = \ context_course :: instance ( $ courseid ) ; if ( is_enrolled ( $ coursecontext , $ userid , '' , false ) ) { $ roles = get_user_roles ( $ coursecontext , $ userid ) ; $ gradebookrole... | Check if a user can be graded in a course |
33,868 | public static function find_ltiservice_gradebookservice_for_lineitem ( $ lineitemid ) { global $ DB ; if ( ! $ lineitemid ) { return false ; } $ gradeitem = $ DB -> get_record ( 'grade_items' , array ( 'id' => $ lineitemid ) ) ; if ( $ gradeitem ) { $ gbs = $ DB -> get_record ( 'ltiservice_gradebookservices' , array ( ... | Find the right element in the ltiservice_gradebookservice table for a lineitem |
33,869 | protected function define_settings ( ) { $ settingprefix = $ this -> info -> modulename . '_' . $ this -> info -> moduleid . '_' ; $ settingname = $ settingprefix . 'included' ; $ activity_included = new restore_activity_generic_setting ( $ settingname , base_setting :: IS_BOOLEAN , true ) ; $ activity_included -> get_... | Define the common setting that any restore activity will have |
33,870 | protected function get_parser ( ) { $ parser = xml_parser_create ( ) ; xml_set_object ( $ parser , $ this ) ; xml_set_element_handler ( $ parser , 'tag_open' , 'tag_close' ) ; xml_set_character_data_handler ( $ parser , 'cdata' ) ; xml_parser_set_option ( $ parser , XML_OPTION_CASE_FOLDING , false ) ; return $ parser ;... | Creates and setups a SAX parser . Subclasses should use this method to create the XML parser . |
33,871 | protected function tag_open ( $ parser , $ tag , $ attributes ) { switch ( $ tag ) { case 'moodle_database' : if ( empty ( $ attributes [ 'version' ] ) || empty ( $ attributes [ 'timestamp' ] ) ) { throw new dbtransfer_exception ( 'malformedxmlexception' ) ; } $ this -> begin_database_import ( $ attributes [ 'version' ... | Callback function . Called by the XML parser for opening tags processing . |
33,872 | protected function tag_close ( $ parser , $ tag ) { switch ( $ tag ) { case 'moodle_database' : $ this -> finish_database_import ( ) ; break ; case 'table' : $ this -> finish_table_import ( $ this -> current_table ) ; $ this -> current_table = null ; break ; case 'record' : $ this -> import_table_data ( $ this -> curre... | Callback function . Called by the XML parser for closing tags processing . |
33,873 | protected function after_create ( ) { $ cache = \ cache :: make ( 'tool_dataprivacy' , 'purpose' ) ; $ cache -> set ( $ this -> get ( 'id' ) , $ this -> to_record ( ) ) ; } | Adds the new record to the cache . |
33,874 | protected function after_update ( $ result ) { $ cache = \ cache :: make ( 'tool_dataprivacy' , 'purpose' ) ; $ cache -> set ( $ this -> get ( 'id' ) , $ this -> to_record ( ) ) ; } | Updates the cache record . |
33,875 | public function on_elements_end ( ) { foreach ( $ this -> mappings as $ mapping ) { $ this -> write_xml ( 'workshopform_numerrors_map' , $ mapping , array ( '/workshopform_numerrors_map/id' ) ) ; } foreach ( $ this -> dimensions as $ dimension ) { $ this -> write_xml ( 'workshopform_numerrors_dimension' , $ dimension ,... | Writes gathered mappings and dimensions |
33,876 | public function get ( $ name ) { if ( ! $ this -> has ( $ name ) ) { throw new Mustache_Exception_UnknownHelperException ( $ name ) ; } return $ this -> helpers [ $ name ] ; } | Get a helper by name . |
33,877 | public function remove ( $ name ) { if ( ! $ this -> has ( $ name ) ) { throw new Mustache_Exception_UnknownHelperException ( $ name ) ; } unset ( $ this -> helpers [ $ name ] ) ; } | Check whether a given helper is present in the collection . |
33,878 | protected function _sortString ( & $ sorted ) { if ( empty ( $ this -> _collator ) ) { asort ( $ sorted , SORT_LOCALE_STRING ) ; } else { $ this -> _collator -> asort ( $ sorted , Collator :: SORT_STRING ) ; } } | Sort an array of strings based on current locale . |
33,879 | public function findDot ( $ id ) { $ chunks = explode ( '.' , $ id ) ; $ first = array_shift ( $ chunks ) ; $ value = $ this -> findVariableInStack ( $ first , $ this -> stack ) ; foreach ( $ chunks as $ chunk ) { if ( $ value === '' ) { return $ value ; } $ value = $ this -> findVariableInStack ( $ chunk , array ( $ v... | Find a dot notation variable in the Context stack . |
33,880 | public function findAnchoredDot ( $ id ) { $ chunks = explode ( '.' , $ id ) ; $ first = array_shift ( $ chunks ) ; if ( $ first !== '' ) { throw new Mustache_Exception_InvalidArgumentException ( sprintf ( 'Unexpected id for findAnchoredDot: %s' , $ id ) ) ; } $ value = $ this -> last ( ) ; foreach ( $ chunks as $ chun... | Find an anchored dot notation variable in the Context stack . |
33,881 | public function findInBlock ( $ id ) { foreach ( $ this -> blockStack as $ context ) { if ( array_key_exists ( $ id , $ context ) ) { return $ context [ $ id ] ; } } return '' ; } | Find an argument in the block context stack . |
33,882 | private function findVariableInStack ( $ id , array $ stack ) { for ( $ i = count ( $ stack ) - 1 ; $ i >= 0 ; $ i -- ) { $ frame = & $ stack [ $ i ] ; switch ( gettype ( $ frame ) ) { case 'object' : if ( ! ( $ frame instanceof Closure ) ) { if ( method_exists ( $ frame , $ id ) ) { return $ frame -> $ id ( ) ; } if (... | Helper function to find a variable in the Context stack . |
33,883 | function _initrs ( ) { global $ ADODB_COUNTRECS ; $ this -> _numOfRows = ( $ ADODB_COUNTRECS ) ? @ pg_num_rows ( $ this -> _queryID ) : - 1 ; $ this -> _numOfFields = @ pg_num_fields ( $ this -> _queryID ) ; } | _initrs modified to disable blob handling |
33,884 | public function write ( PHPExcel $ pPHPExcel = null ) { if ( ! $ pPHPExcel ) { $ pPHPExcel = $ this -> getParentWriter ( ) -> getPHPExcel ( ) ; } $ objWriter = null ; if ( $ this -> getParentWriter ( ) -> getUseDiskCaching ( ) ) { $ objWriter = new PHPExcel_Shared_XMLWriter ( PHPExcel_Shared_XMLWriter :: STORAGE_DISK ,... | Write settings . xml to XML format |
33,885 | protected function get_trace ( ) { if ( null === $ this -> trace ) { $ this -> trace = new \ text_progress_trace ( ) ; $ this -> tracestats = new \ stdClass ( ) ; } return $ this -> trace ; } | Get the progress_trace . |
33,886 | protected function log_start ( $ message , $ depth = 0 ) { $ this -> log ( $ message , $ depth ) ; if ( defined ( 'MDL_PERFTOLOG' ) && MDL_PERFTOLOG ) { $ this -> tracestats -> $ depth = [ 'mem' => memory_get_usage ( ) , 'time' => microtime ( ) , ] ; } } | Log a start message to the progress tracer . |
33,887 | protected function log_finish ( $ message , $ depth = 0 ) { $ this -> log ( $ message , $ depth ) ; if ( isset ( $ this -> tracestats -> $ depth ) ) { $ startstats = $ this -> tracestats -> $ depth ; $ this -> log ( sprintf ( "Time taken %s, memory total: %s, Memory growth: %s, Memory peak: %s" , microtime_diff ( $ sta... | Log an end message to the progress tracer . |
33,888 | private function get_mod_instance ( $ cmid ) { global $ DB ; $ rec = $ DB -> get_record_sql ( "SELECT md.name FROM {course_modules} cm, {modules} md WHERE cm.id = ? AND md.id = cm.module" ,... | Gets the module instance from the database and returns it . If no module instance exists this function returns false . |
33,889 | public function get_details ( $ short = '' ) { global $ DB , $ OUTPUT ; $ output = array ( ) ; foreach ( $ this -> params as $ p ) { $ mod = self :: get_mod_instance ( $ p [ 'module' ] ) ; if ( ! $ mod ) { $ str = $ OUTPUT -> error_text ( get_string ( 'error:nosuchmod' , 'badges' ) ) ; } else { $ str = html_writer :: t... | Get criteria description for displaying to users |
33,890 | public static function list_models ( ) { cli_heading ( "List of models" ) ; echo str_pad ( get_string ( 'modelid' , 'tool_analytics' ) , 15 , ' ' ) . ' ' . str_pad ( get_string ( 'name' ) , 50 , ' ' ) . ' ' . str_pad ( get_string ( 'status' ) , 15 , ' ' ) . "\n" ; $ models = \ core_analytics \ manager :: get_all_models... | List all models in the system . To be used from cli scripts . |
33,891 | public static function get_courses_with_competency_and_user ( $ competencyid , $ userid ) { global $ CFG , $ DB ; if ( ! $ plugins = explode ( ',' , $ CFG -> enrol_plugins_enabled ) ) { return array ( ) ; } $ ctxfields = \ context_helper :: get_preload_record_columns_sql ( 'ctx' ) ; list ( $ plugins , $ params ) = $ DB... | Return the courses where both competency and user are . |
33,892 | public static function get_ruleoutcome_list ( ) { static $ list = null ; if ( $ list === null ) { $ list = array ( self :: OUTCOME_NONE => self :: get_ruleoutcome_name ( self :: OUTCOME_NONE ) , self :: OUTCOME_EVIDENCE => self :: get_ruleoutcome_name ( self :: OUTCOME_EVIDENCE ) , self :: OUTCOME_RECOMMEND => self :: ... | Return a list of rules . |
33,893 | public static function list_courses_min ( $ competencyid ) { global $ DB ; $ results = $ DB -> get_records_sql ( 'SELECT course.id as id, course.visible as visible FROM {' . self :: TABLE . '} coursecomp JOIN {course} course ... | Return the course IDs and visible flags that include this competency . |
33,894 | public static function list_courses ( $ competencyid ) { global $ DB ; $ results = $ DB -> get_records_sql ( 'SELECT course.id, course.visible, course.shortname, course.idnumber, course.fullname, course.summary, course.summaryformat, course.startdate, ... | Return partial course records foreach course that contains this competency . |
33,895 | public static function count_competencies ( $ courseid ) { global $ DB ; $ sql = 'SELECT COUNT(comp.id) FROM {' . self :: TABLE . '} coursecomp JOIN {' . competency :: TABLE . '} comp ON coursecomp.competencyid = comp.id WHERE coursecomp.courseid = ? ... | Count the competencies in this course . |
33,896 | public static function list_competencies ( $ courseid ) { global $ DB ; $ sql = 'SELECT comp.* FROM {' . competency :: TABLE . '} comp JOIN {' . self :: TABLE . '} coursecomp ON coursecomp.competencyid = comp.id WHERE coursecomp.courseid = ?' ; $ para... | List the competencies in this course . |
33,897 | public static function get_course_competency ( $ courseid , $ competencyid ) { global $ DB ; $ sql = 'SELECT crscomp.* FROM {' . self :: TABLE . '} crscomp WHERE crscomp.courseid = ? AND crscomp.competencyid = ?' ; $ params = array ( $ courseid , $ competencyid ) ; $ result = $ DB -> ge... | Get the specified course_competency in this course . |
33,898 | public static function list_course_competencies ( $ courseid ) { global $ DB ; $ sql = 'SELECT coursecomp.* FROM {' . self :: TABLE . '} coursecomp JOIN {' . competency :: TABLE . '} comp ON coursecomp.competencyid = comp.id WHERE coursecomp.courseid ... | List the course_competencies in this course . |
33,899 | protected function add_plugin_structure ( $ plugintype , $ element , $ multiple ) { global $ CFG ; if ( ! array_key_exists ( $ plugintype , core_component :: get_plugin_types ( $ plugintype ) ) ) { throw new backup_step_exception ( 'incorrect_plugin_type' , $ plugintype ) ; } $ optigroupname = $ plugintype . '_' . $ el... | Add plugin structure to any element in the structure backup tree |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.