idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
31,100
public function get_step ( $ i ) { if ( $ i < 0 || $ i >= count ( $ this -> steps ) ) { throw new coding_exception ( 'Index out of bounds in question_attempt::get_step.' ) ; } return $ this -> steps [ $ i ] ; }
Get one of the steps in this attempt .
31,101
public function get_last_step_with_qt_var ( $ name ) { foreach ( $ this -> get_reverse_step_iterator ( ) as $ step ) { if ( $ step -> has_qt_var ( $ name ) ) { return $ step ; } } return new question_attempt_step_read_only ( ) ; }
Get the last step with a particular question type varialbe set .
31,102
public function get_last_step_with_behaviour_var ( $ name ) { foreach ( $ this -> get_reverse_step_iterator ( ) as $ step ) { if ( $ step -> has_behaviour_var ( $ name ) ) { return $ step ; } } return new question_attempt_step_read_only ( ) ; }
Get the last step with a particular behaviour variable set .
31,103
public function get_last_qt_var ( $ name , $ default = null ) { $ step = $ this -> get_last_step_with_qt_var ( $ name ) ; if ( $ step -> has_qt_var ( $ name ) ) { return $ step -> get_qt_var ( $ name ) ; } else { return $ default ; } }
Get the latest value of a particular question type variable . That is get the value from the latest step that has it set . Return null if it is not set in any step .
31,104
public function get_response_file_url ( stored_file $ file ) { return file_encode_url ( new moodle_url ( '/pluginfile.php' ) , '/' . implode ( '/' , array ( $ file -> get_contextid ( ) , $ file -> get_component ( ) , $ file -> get_filearea ( ) , $ this -> usageid , $ this -> slot , $ file -> get_itemid ( ) ) ) . $ file...
Get the URL of a file that belongs to a response variable of this question_attempt .
31,105
public function prepare_response_files_draft_itemid ( $ name , $ contextid ) { foreach ( $ this -> get_reverse_step_iterator ( ) as $ step ) { if ( $ step -> has_qt_var ( $ name ) ) { return $ step -> prepare_response_files_draft_itemid ( $ name , $ contextid ) ; } } $ draftid = 0 ; file_prepare_draft_area ( $ draftid ...
Prepare a draft file are for the files belonging the a response variable of this question attempt . The draft area is populated with the files from the most recent step having files .
31,106
public function get_last_behaviour_var ( $ name , $ default = null ) { foreach ( $ this -> get_reverse_step_iterator ( ) as $ step ) { if ( $ step -> has_behaviour_var ( $ name ) ) { return $ step -> get_behaviour_var ( $ name ) ; } } return $ default ; }
Get the latest value of a particular behaviour variable . That is get the value from the latest step that has it set . Return null if it is not set in any step .
31,107
public function get_current_manual_mark ( ) { $ mark = $ this -> get_submitted_var ( $ this -> get_behaviour_field_name ( 'mark' ) , PARAM_RAW_TRIMMED ) ; if ( $ mark !== null ) { return $ mark ; } $ storedmaxmark = $ this -> get_last_behaviour_var ( 'maxmark' ) ; if ( $ storedmaxmark !== null && ( $ storedmaxmark - $ ...
This is used by the manual grading code particularly in association with validation . It gets the current manual mark for a question in exactly the string form that the teacher entered it if possible . This may come from the current POST request if there is one otherwise from the database .
31,108
public function set_metadata ( $ name , $ value ) { $ firststep = $ this -> get_step ( 0 ) ; if ( ! $ firststep -> has_metadata_var ( $ name ) ) { $ this -> observer -> notify_metadata_added ( $ this , $ name ) ; } else if ( $ value !== $ firststep -> get_metadata_var ( $ name ) ) { $ this -> observer -> notify_metadat...
Set some metadata for this question attempt .
31,109
protected function add_step ( question_attempt_step $ step ) { $ this -> steps [ ] = $ step ; end ( $ this -> steps ) ; $ this -> observer -> notify_step_added ( $ step , $ this , key ( $ this -> steps ) ) ; }
Add a step to this question attempt .
31,110
protected function add_autosaved_step ( question_attempt_step $ step ) { $ this -> steps [ ] = $ step ; $ this -> autosavedstep = $ step ; end ( $ this -> steps ) ; $ this -> observer -> notify_step_added ( $ step , $ this , - key ( $ this -> steps ) ) ; }
Add an auto - saved step to this question attempt . We mark auto - saved steps by changing saving the step number with a - sign .
31,111
public function discard_autosaved_step ( ) { if ( ! $ this -> has_autosaved_step ( ) ) { return ; } $ autosaved = array_pop ( $ this -> steps ) ; $ this -> autosavedstep = null ; $ this -> observer -> notify_step_deleted ( $ autosaved , $ this ) ; }
Discard any auto - saved data belonging to this question attempt .
31,112
protected function convert_autosaved_step_to_real_step ( ) { if ( $ this -> autosavedstep === null ) { return ; } $ laststep = end ( $ this -> steps ) ; if ( $ laststep !== $ this -> autosavedstep ) { throw new coding_exception ( 'Cannot convert autosaved step to real step, since other steps have been added.' ) ; } $ t...
If there is an autosaved step convert it into a real save so that it is preserved .
31,113
public function select_variant ( question_variant_selection_strategy $ variantstrategy ) { return $ variantstrategy -> choose_variant ( $ this -> get_question ( ) -> get_num_variants ( ) , $ this -> get_question ( ) -> get_variants_selection_seed ( ) ) ; }
Use a strategy to pick a variant .
31,114
public function start ( $ preferredbehaviour , $ variant , $ submitteddata = array ( ) , $ timestamp = null , $ userid = null , $ existingstepid = null ) { if ( $ this -> get_num_steps ( ) > 0 ) { throw new coding_exception ( 'Cannot start a question that is already started.' ) ; } $ this -> variant = $ variant ; if ( ...
Start this question attempt .
31,115
public function validate_manual_mark ( $ currentmark ) { if ( $ currentmark === null || $ currentmark === '' ) { return '' ; } $ mark = question_utils :: clean_param_mark ( $ currentmark ) ; if ( $ mark === null ) { return get_string ( 'manualgradeinvalidformat' , 'question' ) ; } $ maxmark = $ this -> get_max_mark ( )...
Validate the manual mark for a question .
31,116
protected function process_response_files ( $ name , $ draftidname , $ postdata = null , $ text = null ) { if ( $ postdata ) { $ draftitemid = $ this -> get_submitted_var ( $ draftidname , PARAM_INT , $ postdata ) ; } else { $ draftitemid = file_get_submitted_draft_itemid ( $ draftidname ) ; } if ( ! $ draftitemid ) { ...
Handle a submitted variable representing uploaded files .
31,117
protected function get_expected_data ( $ expected , $ postdata , $ extraprefix ) { $ submitteddata = array ( ) ; foreach ( $ expected as $ name => $ type ) { $ value = $ this -> get_submitted_var ( $ this -> get_field_prefix ( ) . $ extraprefix . $ name , $ type , $ postdata ) ; if ( ! is_null ( $ value ) ) { $ submitt...
Get any data from the request that matches the list of expected params .
31,118
public function get_all_submitted_qt_vars ( $ postdata ) { if ( is_null ( $ postdata ) ) { $ postdata = $ _POST ; } $ pattern = '/^' . preg_quote ( $ this -> get_field_prefix ( ) , '/' ) . '[^-:]/' ; $ prefixlen = strlen ( $ this -> get_field_prefix ( ) ) ; $ submitteddata = array ( ) ; foreach ( $ postdata as $ name =...
Get all the submitted question type data for this question whithout checking that it is valid or cleaning it in any way .
31,119
public function get_submitted_data ( $ postdata = null ) { $ submitteddata = $ this -> get_expected_data ( $ this -> behaviour -> get_expected_data ( ) , $ postdata , '-' ) ; $ expected = $ this -> behaviour -> get_expected_qt_data ( ) ; $ this -> check_qt_var_name_restrictions ( $ expected ) ; if ( $ expected === self...
Get all the sumbitted data belonging to this question attempt from the current request .
31,120
protected function check_qt_var_name_restrictions ( $ expected ) { global $ CFG ; if ( $ CFG -> debugdeveloper && $ expected !== self :: USE_RAW_DATA ) { foreach ( $ expected as $ key => $ value ) { if ( strpos ( $ key , 'bf_' ) !== false ) { debugging ( 'The bf_ prefix is reserved and cannot be used by question types'...
Ensure that no reserved prefixes are being used by installed question types .
31,121
public function get_correct_response ( ) { $ response = $ this -> question -> get_correct_response ( ) ; if ( is_null ( $ response ) ) { return null ; } $ imvars = $ this -> behaviour -> get_correct_response ( ) ; foreach ( $ imvars as $ name => $ value ) { $ response [ '-' . $ name ] = $ value ; } return $ response ; ...
Get a set of response data for this question attempt that would get the best possible mark . If it is not possible to compute a correct response this method should return null .
31,122
public function process_autosave ( $ submitteddata , $ timestamp = null , $ userid = null ) { $ pendingstep = new question_attempt_pending_step ( $ submitteddata , $ timestamp , $ userid ) ; if ( $ this -> behaviour -> process_autosave ( $ pendingstep ) == self :: KEEP ) { $ this -> add_autosaved_step ( $ pendingstep )...
Process an autosave .
31,123
public function finish ( $ timestamp = null , $ userid = null ) { $ this -> convert_autosaved_step_to_real_step ( ) ; $ this -> process_action ( array ( '-finish' => 1 ) , $ timestamp , $ userid ) ; }
Perform a finish action on this question attempt . This corresponds to an external finish action for example the user pressing Submit all and finish in the quiz rather than using one of the controls that is part of the question .
31,124
public function manual_grade ( $ comment , $ mark , $ commentformat = null , $ timestamp = null , $ userid = null ) { $ submitteddata = array ( '-comment' => $ comment ) ; if ( is_null ( $ commentformat ) ) { debugging ( 'You should pass $commentformat to manual_grade.' , DEBUG_DEVELOPER ) ; $ commentformat = FORMAT_HT...
Perform a manual grading action on this attempt .
31,125
public function get_current_manual_comment ( ) { $ comment = $ this -> get_submitted_var ( $ this -> get_behaviour_field_name ( 'comment' ) , PARAM_RAW ) ; if ( is_null ( $ comment ) ) { return $ this -> get_manual_comment ( ) ; } else { $ commentformat = $ this -> get_submitted_var ( $ this -> get_behaviour_field_name...
This is used by the manual grading code particularly in association with validation . If there is a comment submitted in the request then use that otherwise use the latest comment for this question .
31,126
protected function find_steps_with_submitted_response ( ) { $ stepnos = array ( ) ; $ lastsavedstep = null ; foreach ( $ this -> qa -> get_step_iterator ( ) as $ stepno => $ step ) { if ( $ this -> qa -> get_behaviour ( ) -> step_has_a_submitted_response ( $ step ) ) { $ stepnos [ ] = $ stepno ; $ lastsavedstep = null ...
Find the step nos in which a student has submitted a response . Including any step with a response that is saved before the question attempt finishes .
31,127
public function setTopLeftPosition ( $ cell , $ xOffset = null , $ yOffset = null ) { $ this -> topLeftCellRef = $ cell ; if ( ! is_null ( $ xOffset ) ) { $ this -> setTopLeftXOffset ( $ xOffset ) ; } if ( ! is_null ( $ yOffset ) ) { $ this -> setTopLeftYOffset ( $ yOffset ) ; } return $ this ; }
Set the Top Left position for the chart
31,128
public function setTopLeftOffset ( $ xOffset = null , $ yOffset = null ) { if ( ! is_null ( $ xOffset ) ) { $ this -> setTopLeftXOffset ( $ xOffset ) ; } if ( ! is_null ( $ yOffset ) ) { $ this -> setTopLeftYOffset ( $ yOffset ) ; } return $ this ; }
Set the offset position within the Top Left cell for the chart
31,129
public function setBottomRightOffset ( $ xOffset = null , $ yOffset = null ) { if ( ! is_null ( $ xOffset ) ) { $ this -> setBottomRightXOffset ( $ xOffset ) ; } if ( ! is_null ( $ yOffset ) ) { $ this -> setBottomRightYOffset ( $ yOffset ) ; } return $ this ; }
Set the offset position within the Bottom Right cell for the chart
31,130
public function sort ( array $ opts = array ( ) ) { $ this -> _delimiter = isset ( $ opts [ 'delimiter' ] ) ? $ opts [ 'delimiter' ] : '.' ; $ this -> _sortinbox = ( ! isset ( $ opts [ 'inbox' ] ) || ! empty ( $ opts [ 'inbox' ] ) ) ; if ( empty ( $ opts [ 'noupdate' ] ) ) { $ mboxes = & $ this -> _mboxes ; } else { $ ...
Sort the list of mailboxes .
31,131
public static function get_quiz_attempt_subcontext ( \ stdClass $ attempt , \ stdClass $ user ) { $ subcontext = [ get_string ( 'attempts' , 'mod_quiz' ) , ] ; if ( $ attempt -> userid != $ user -> id ) { $ subcontext [ ] = fullname ( $ user ) ; } $ subcontext [ ] = $ attempt -> attempt ; return $ subcontext ; }
Determine the subcontext for the specified quiz attempt .
31,132
protected function create_default_options ( $ question ) { $ options = new stdClass ( ) ; $ options -> questionid = $ question -> id ; $ options -> correctfeedback = get_string ( 'correctfeedbackdefault' , 'question' ) ; $ options -> correctfeedbackformat = FORMAT_HTML ; $ options -> partiallycorrectfeedback = get_stri...
Create a default options object for the provided question .
31,133
protected function to_features ( $ calculatedvalues ) { $ nullmean = true ; foreach ( $ calculatedvalues as $ value ) { if ( ! is_null ( $ value ) ) { $ nullmean = false ; break ; } } if ( $ nullmean ) { $ mean = null ; } else { $ mean = round ( array_sum ( $ calculatedvalues ) / count ( $ calculatedvalues ) , 2 ) ; } ...
Converts the calculated values to a list of features for the dataset .
31,134
public static function instance ( ) { global $ CFG ; if ( is_null ( self :: $ singletoninstance ) ) { if ( ! empty ( $ CFG -> perfdebug ) and $ CFG -> perfdebug > 7 ) { self :: $ singletoninstance = new performance_measuring_filter_manager ( ) ; } else { self :: $ singletoninstance = new self ( ) ; } } return self :: $...
Factory method . Use this to get the filter manager .
31,135
protected function load_filters ( $ context ) { $ filters = filter_get_active_in_context ( $ context ) ; $ this -> textfilters [ $ context -> id ] = array ( ) ; $ this -> stringfilters [ $ context -> id ] = array ( ) ; foreach ( $ filters as $ filtername => $ localconfig ) { $ filter = $ this -> make_filter_object ( $ ...
Load all the filters required by this context .
31,136
protected function make_filter_object ( $ filtername , $ context , $ localconfig ) { global $ CFG ; $ path = $ CFG -> dirroot . '/filter/' . $ filtername . '/filter.php' ; if ( ! is_readable ( $ path ) ) { return null ; } include_once ( $ path ) ; $ filterclassname = 'filter_' . $ filtername ; if ( class_exists ( $ fil...
Factory method for creating a filter .
31,137
protected function apply_filter_chain ( $ text , $ filterchain , array $ options = array ( ) , array $ skipfilters = null ) { foreach ( $ filterchain as $ filtername => $ filter ) { if ( $ skipfilters !== null && in_array ( $ filtername , $ skipfilters ) ) { continue ; } $ text = $ filter -> filter ( $ text , $ options...
Apply a list of filters to some content .
31,138
protected function get_text_filters ( $ context ) { if ( ! isset ( $ this -> textfilters [ $ context -> id ] ) ) { $ this -> load_filters ( $ context ) ; } return $ this -> textfilters [ $ context -> id ] ; }
Get all the filters that apply to a given context for calls to format_text .
31,139
protected function get_string_filters ( $ context ) { if ( ! isset ( $ this -> stringfilters [ $ context -> id ] ) ) { $ this -> load_filters ( $ context ) ; } return $ this -> stringfilters [ $ context -> id ] ; }
Get all the filters that apply to a given context for calls to format_string .
31,140
public function filter_text ( $ text , $ context , array $ options = array ( ) , array $ skipfilters = null ) { $ text = $ this -> apply_filter_chain ( $ text , $ this -> get_text_filters ( $ context ) , $ options , $ skipfilters ) ; $ text = str_replace ( array ( '<nolink>' , '</nolink>' ) , '' , $ text ) ; return $ t...
Filter some text
31,141
public function setup_page_for_filters ( $ page , $ context ) { $ filters = $ this -> get_text_filters ( $ context ) ; foreach ( $ filters as $ filter ) { $ filter -> setup ( $ page , $ context ) ; } }
Setup page with filters requirements and other prepare stuff .
31,142
public function setup_page_for_globally_available_filters ( $ page ) { $ context = context_system :: instance ( ) ; $ filterdata = filter_get_globally_enabled_filters_with_config ( ) ; foreach ( $ filterdata as $ name => $ config ) { if ( isset ( $ this -> textfilters [ $ context -> id ] [ $ name ] ) ) { $ filter = $ t...
Setup the page for globally available filters .
31,143
protected function sendRequest ( ) { phpCAS :: traceBegin ( ) ; $ ch = $ this -> initAndConfigure ( ) ; $ buf = curl_exec ( $ ch ) ; if ( $ buf === false ) { phpCAS :: trace ( 'curl_exec() failed' ) ; $ this -> storeErrorMessage ( 'CURL error #' . curl_errno ( $ ch ) . ': ' . curl_error ( $ ch ) ) ; $ res = false ; } e...
Send the request and store the results .
31,144
public function initAndConfigure ( ) { $ ch = curl_init ( $ this -> url ) ; if ( version_compare ( PHP_VERSION , '5.1.3' , '>=' ) ) { curl_setopt_array ( $ ch , $ this -> _curlOptions ) ; } else { foreach ( $ this -> _curlOptions as $ key => $ value ) { curl_setopt ( $ ch , $ key , $ value ) ; } } if ( $ this -> caCert...
Internal method to initialize our cURL handle and configure the request . This method should NOT be used outside of the CurlRequest or the CurlMultiRequest .
31,145
protected function output_individual_question_data ( $ quiz , $ questionstat ) { global $ OUTPUT ; $ datumfromtable = $ this -> table -> format_row ( $ questionstat ) ; $ questioninfotable = new html_table ( ) ; $ questioninfotable -> align = array ( 'center' , 'center' ) ; $ questioninfotable -> width = '60%' ; $ ques...
Display the statistical and introductory information about a question . Only called when not downloading .
31,146
protected function render_question_text ( $ question ) { global $ OUTPUT ; $ text = question_rewrite_question_preview_urls ( $ question -> questiontext , $ question -> id , $ question -> contextid , 'question' , 'questiontext' , $ question -> id , $ this -> context -> id , 'quiz_statistics' ) ; return $ OUTPUT -> box (...
Output question text in a box with urls appropriate for a preview of the question .
31,147
protected function output_individual_question_response_analysis ( $ question , $ variantno , $ s , $ reporturl , $ qubaids , $ whichtries = question_attempt :: LAST_TRY ) { global $ OUTPUT ; if ( ! question_bank :: get_qtype ( $ question -> qtype , false ) -> can_analyse_responses ( ) ) { return ; } $ qtable = new quiz...
Display the response analysis for a question .
31,148
protected function output_quiz_structure_analysis_table ( $ questionstats ) { $ limitvariants = ! $ this -> table -> is_downloading ( ) ; foreach ( $ questionstats -> get_all_slots ( ) as $ slot ) { $ structureanalysis = $ questionstats -> structure_analysis_for_one_slot ( $ slot , $ limitvariants ) ; if ( is_null ( $ ...
Output the table that lists all the questions in the quiz with their statistics .
31,149
protected function output_quiz_info_table ( $ quizinfo ) { $ quizinfotable = new html_table ( ) ; $ quizinfotable -> align = array ( 'center' , 'center' ) ; $ quizinfotable -> width = '60%' ; $ quizinfotable -> attributes [ 'class' ] = 'generaltable titlesleft' ; $ quizinfotable -> data = array ( ) ; foreach ( $ quizin...
Return HTML for table of overall quiz statistics .
31,150
protected function download_quiz_info_table ( $ quizinfo ) { global $ OUTPUT ; if ( $ this -> table -> is_downloading ( ) == 'html' ) { echo $ OUTPUT -> heading ( get_string ( 'quizinformation' , 'quiz_statistics' ) , 3 ) ; echo $ this -> output_quiz_info_table ( $ quizinfo ) ; return ; } $ headers = array ( ) ; $ row ...
Download the table of overall quiz statistics .
31,151
protected function output_statistics_graph ( $ quizorid , $ qubaids ) { global $ DB , $ PAGE ; $ quiz = $ quizorid ; if ( ! is_object ( $ quiz ) ) { $ quiz = $ DB -> get_record ( 'quiz' , array ( 'id' => $ quizorid ) , '*' , MUST_EXIST ) ; } $ questions = quiz_report_get_significant_questions ( $ quiz ) ; $ questionsta...
Output the HTML needed to show the statistics graph .
31,152
public function get_all_stats_and_analysis ( $ quiz , $ whichattempts , $ whichtries , \ core \ dml \ sql_join $ groupstudentsjoins , $ questions , $ progress = null ) { if ( $ progress === null ) { $ progress = new \ core \ progress \ none ( ) ; } $ qubaids = quiz_statistics_qubaids_condition ( $ quiz -> id , $ groups...
Get the quiz and question statistics either by loading the cached results or by recomputing them .
31,153
protected function get_progress_trace_instance ( ) { if ( $ this -> progress === null ) { if ( ! $ this -> table -> is_downloading ( ) ) { $ this -> progress = new \ core \ progress \ display_if_slow ( get_string ( 'calculatingallstats' , 'quiz_statistics' ) ) ; $ this -> progress -> set_display_names ( ) ; } else { $ ...
Appropriate instance depending if we want html output for the user or not .
31,154
protected function analyse_responses_for_all_questions_and_subquestions ( $ questions , $ subquestions , $ qubaids , $ whichtries , $ progress = null ) { if ( $ progress === null ) { $ progress = new \ core \ progress \ none ( ) ; } $ progress -> start_progress ( '' , count ( $ questions ) + count ( $ subquestions ) ) ...
Analyse responses for all questions and sub questions in this quiz .
31,155
protected function analyse_responses_for_questions ( $ questions , $ qubaids , $ whichtries , $ progress = null , $ done = array ( ) ) { $ countquestions = count ( $ questions ) ; if ( ! $ countquestions ) { return array ( ) ; } if ( $ progress === null ) { $ progress = new \ core \ progress \ none ( ) ; } $ progress -...
Analyse responses for an array of questions or sub questions .
31,156
protected function everything_download_options ( moodle_url $ reporturl ) { global $ OUTPUT ; return $ OUTPUT -> download_dataformat_selector ( get_string ( 'downloadeverything' , 'quiz_statistics' ) , $ reporturl -> out_omit_querystring ( ) , 'download' , $ reporturl -> params ( ) + array ( 'everything' => 1 ) ) ; }
Return a little form for the user to request to download the full report including quiz stats and response analysis for all questions and sub - questions .
31,157
protected function output_caching_info ( $ lastcachetime , $ quizid , $ groupstudentsjoins , $ whichattempts , $ reporturl ) { global $ DB , $ OUTPUT ; if ( empty ( $ lastcachetime ) ) { return '' ; } list ( $ fromqa , $ whereqa , $ qaparams ) = quiz_statistics_attempts_sql ( $ quizid , $ groupstudentsjoins , $ whichat...
Return HTML for a message that says when the stats were last calculated and a recalculate now button .
31,158
protected function clear_cached_data ( $ qubaids ) { global $ DB ; $ DB -> delete_records ( 'quiz_statistics' , array ( 'hashcode' => $ qubaids -> get_hash_code ( ) ) ) ; $ DB -> delete_records ( 'question_statistics' , array ( 'hashcode' => $ qubaids -> get_hash_code ( ) ) ) ; $ DB -> delete_records ( 'question_respon...
Clear the cached data for a particular report configuration . This will trigger a re - computation the next time the report is displayed .
31,159
public function load_and_initialise_questions_for_calculations ( $ quiz ) { $ questions = quiz_report_get_significant_questions ( $ quiz ) ; $ questionids = array ( ) ; foreach ( $ questions as $ question ) { $ questionids [ ] = $ question -> id ; } $ fullquestions = question_load_questions ( $ questionids ) ; foreach ...
Load the questions in this quiz and add some properties to the objects needed in the reports .
31,160
protected function output_all_question_response_analysis ( $ qubaids , $ questions , $ questionstats , $ reporturl , $ whichtries = question_attempt :: LAST_TRY ) { foreach ( $ questions as $ slot => $ question ) { if ( question_bank :: get_qtype ( $ question -> qtype , false ) -> can_analyse_responses ( ) ) { if ( $ q...
Output all response analysis for all questions sub - questions and variants . For download in a number of formats .
31,161
protected static function export_choice_data_for_user ( array $ choicedata , \ context_module $ context , \ stdClass $ user ) { $ contextdata = helper :: get_context_data ( $ context , $ user ) ; $ contextdata = ( object ) array_merge ( ( array ) $ contextdata , $ choicedata ) ; writer :: with_context ( $ context ) -> ...
Export the supplied personal data for a single choice activity along with any generic data or area files .
31,162
public function close ( $ finalFilePointer ) { $ worksheets = $ this -> worksheets ; foreach ( $ worksheets as $ worksheet ) { $ worksheet -> close ( ) ; } $ this -> sharedStringsHelper -> close ( ) ; $ this -> fileSystemHelper -> createContentTypesFile ( $ worksheets ) -> createWorkbookFile ( $ worksheets ) -> createW...
Closes the workbook and all its associated sheets . All the necessary files are written to disk and zipped together to create the XLSX file . All the temporary files are then deleted .
31,163
protected function get_other_values ( renderer_base $ output ) { $ values = [ ] ; $ formattedbases = [ ] ; $ lawfulbases = explode ( ',' , $ this -> persistent -> get ( 'lawfulbases' ) ) ; if ( ! empty ( $ lawfulbases ) ) { foreach ( $ lawfulbases as $ basis ) { if ( empty ( trim ( $ basis ) ) ) { continue ; } $ format...
Return other properties .
31,164
public static function get_name ( $ purposeid ) { global $ PAGE ; if ( $ purposeid === false || $ purposeid == context_instance :: INHERIT ) { return get_string ( 'inherit' , 'tool_dataprivacy' ) ; } else if ( $ purposeid == context_instance :: NOTSET ) { return get_string ( 'notset' , 'tool_dataprivacy' ) ; } else { $...
Utility function that fetches a purpose name from the given ID .
31,165
public function get_addons_repository_url ( ) { global $ CFG ; if ( ! empty ( $ CFG -> config_php_settings [ 'alternativeaddonsrepositoryurl' ] ) ) { $ url = $ CFG -> config_php_settings [ 'alternativeaddonsrepositoryurl' ] ; } else { $ url = 'https://moodle.org/plugins/get.php' ; } if ( ! $ this -> should_send_site_in...
Returns URL to the repository that addons can be searched in and installed from
31,166
public function get_plugin_types_menu ( ) { global $ CFG ; $ pluginman = core_plugin_manager :: instance ( ) ; $ menu = array ( '' => get_string ( 'choosedots' ) ) ; foreach ( array_keys ( $ pluginman -> get_plugin_types ( ) ) as $ plugintype ) { $ menu [ $ plugintype ] = $ pluginman -> plugintype_name ( $ plugintype )...
Returns localised list of available plugin types
31,167
public function handle_remote_request ( tool_installaddon_renderer $ output , $ request ) { if ( is_null ( $ request ) ) { return ; } $ data = $ this -> decode_remote_request ( $ request ) ; if ( $ data === false ) { echo $ output -> remote_request_invalid_page ( $ this -> index_url ( ) ) ; exit ( ) ; } list ( $ plugin...
Hook method to handle the remote request to install an add - on
31,168
public function detect_plugin_component ( $ zipfilepath ) { $ workdir = make_request_directory ( ) ; $ versionphp = $ this -> extract_versionphp_file ( $ zipfilepath , $ workdir ) ; if ( empty ( $ versionphp ) ) { return false ; } return $ this -> detect_plugin_component_from_versionphp ( file_get_contents ( $ workdir ...
Detect the given plugin s component name
31,169
protected function decode_remote_request ( $ request ) { $ data = base64_decode ( $ request , true ) ; if ( $ data === false ) { return false ; } $ data = json_decode ( $ data ) ; if ( is_null ( $ data ) ) { return false ; } if ( ! isset ( $ data -> name ) or ! isset ( $ data -> component ) or ! isset ( $ data -> versi...
Decode the request from the Moodle Plugins directory
31,170
protected function extract_versionphp_file ( $ zipfilepath , $ targetdir ) { global $ CFG ; require_once ( $ CFG -> libdir . '/filelib.php' ) ; $ fp = get_file_packer ( 'application/zip' ) ; $ files = $ fp -> list_files ( $ zipfilepath ) ; if ( empty ( $ files ) ) { return false ; } $ rootdirname = null ; $ found = nul...
Extracts the version . php from the given plugin ZIP file into the target directory
31,171
protected function detect_plugin_component_from_versionphp ( $ code ) { $ result = preg_match_all ( '#^\s*\$plugin\->component\s*=\s*([\'"])(.+?_.+?)\1\s*;#m' , $ code , $ matches ) ; if ( $ result === 1 and ! empty ( $ matches [ 2 ] [ 0 ] ) ) { return $ matches [ 2 ] [ 0 ] ; } return false ; }
Return the plugin component declared in its version . php file
31,172
public static function get_mandatory_properties ( ) { $ properties = self :: define_properties ( ) ; $ mandatoryproperties = array_filter ( $ properties , function ( $ property ) { return empty ( $ property [ 'optional' ] ) ; } ) ; return array_keys ( $ mandatoryproperties ) ; }
The list of mandatory properties required on the question object to export .
31,173
protected function get_other_values ( \ renderer_base $ output ) { $ iconexporter = new question_icon_exporter ( $ this -> question , $ this -> related ) ; return [ 'icon' => $ iconexporter -> export ( $ output ) , ] ; }
Calculate the values for the properties defined in the define_other_properties function .
31,174
public function set_sheettitle ( $ title ) { if ( ! $ title ) { return ; } $ title = strtr ( trim ( $ title , "'" ) , '[]*/\?:' , ' ' ) ; $ title = \ core_text :: substr ( $ title , 0 , 31 ) ; $ title = trim ( $ title , "'" ) ; $ this -> sheettitle = $ title ; }
Set the title of the worksheet inside a spreadsheet
31,175
protected function compute_next_start_time ( $ numprevattempts , $ lastattempt ) { if ( $ numprevattempts == 0 ) { return 0 ; } $ lastattemptfinish = $ lastattempt -> timefinish ; if ( $ this -> quiz -> timelimit > 0 ) { $ lastattemptfinish = min ( $ lastattemptfinish , $ lastattempt -> timestart + $ this -> quiz -> ti...
Compute the next time a student would be allowed to start an attempt according to this rule .
31,176
public static function create_from_object ( category_controller $ category ) : category_created { $ eventparams = [ 'objectid' => $ category -> get ( 'id' ) , 'context' => $ category -> get_handler ( ) -> get_configuration_context ( ) , 'other' => [ 'name' => $ category -> get ( 'name' ) ] ] ; $ event = self :: create ...
Creates an instance from a category controller object
31,177
function initialise ( ) { $ this -> parser = xml_parser_create ( ) ; xml_set_object ( $ this -> parser , $ this ) ; xml_set_element_handler ( $ this -> parser , "start_element" , "end_element" ) ; xml_set_character_data_handler ( $ this -> parser , "discard_data" ) ; $ this -> tag_number = 0 ; $ this -> digest = '' ; $...
Set default element handlers and initialise properties to empty .
31,178
function parse ( $ data ) { $ p = xml_parse ( $ this -> parser , $ data ) ; if ( $ p == 0 ) { $ errcode = xml_get_error_code ( $ this -> parser ) ; $ errstring = xml_error_string ( $ errcode ) ; $ lineno = xml_get_current_line_number ( $ this -> parser ) ; if ( $ lineno !== false ) { $ error = array ( 'lineno' => $ lin...
Parse a block of XML text
31,179
function start_element ( $ parser , $ name , $ attrs ) { $ this -> tag_number ++ ; $ handler = 'discard_data' ; switch ( strtoupper ( $ name ) ) { case 'DIGESTVALUE' : $ handler = 'parse_digest' ; break ; case 'SIGNATUREVALUE' : $ handler = 'parse_signature' ; break ; case 'OBJECT' : $ handler = 'parse_object' ; break ...
Set the character - data handler to the right function for each element
31,180
function discard_data ( $ parser , $ data ) { if ( ! $ this -> errorstarted ) { return true ; } $ data = trim ( $ data ) ; if ( isset ( $ this -> errorstarted -> faultstringstarted ) && ! empty ( $ data ) ) { $ this -> remoteerror .= ', message: ' . $ data ; } else if ( isset ( $ this -> errorstarted -> faultcodestarte...
Discard the next chunk of character data
31,181
public static function course_content_deleted ( \ core \ event \ course_content_deleted $ event ) { global $ DB ; $ DB -> delete_records ( 'feedback_template' , array ( 'course' => $ event -> objectid ) ) ; }
Observer for the even course_content_deleted - delete all course templates .
31,182
protected function convert_urls_into_links ( & $ text ) { $ filterignoretagsopen = array ( '<a\s[^>]+?>' , '<span[^>]+?class="nolink"[^>]*?>' ) ; $ filterignoretagsclose = array ( '</a>' , '</span>' ) ; $ ignoretags = [ ] ; filter_save_ignore_tags ( $ text , $ filterignoretagsopen , $ filterignoretagsclose , $ ignoreta...
Given some text this function converts any URLs it finds into HTML links
31,183
public function display_instances ( $ instances , $ defaultcontent , $ cangrade ) { $ return = '' ; if ( sizeof ( $ instances ) ) { $ return .= html_writer :: start_tag ( 'div' , array ( 'class' => 'advancedgrade' ) ) ; $ idx = 0 ; foreach ( $ instances as $ instance ) { $ return .= $ this -> display_instance ( $ insta...
Displays for the student the list of instances or default content if no instances found
31,184
public function display_rubric_mapping_explained ( $ scores ) { $ html = '' ; if ( ! $ scores ) { return $ html ; } if ( $ scores [ 'minscore' ] <> 0 ) { $ html .= $ this -> output -> notification ( get_string ( 'zerolevelsabsent' , 'gradingform_rubric' ) , 'error' ) ; } $ html .= $ this -> output -> notification ( get...
Generates and returns HTML code to display information box about how rubric score is converted to the grade
31,185
public static function cancel_data_request ( $ requestid ) { global $ USER ; $ warnings = [ ] ; $ params = external_api :: validate_parameters ( self :: cancel_data_request_parameters ( ) , [ 'requestid' => $ requestid ] ) ; $ requestid = $ params [ 'requestid' ] ; $ context = context_user :: instance ( $ USER -> id ) ...
Cancel a data request .
31,186
public static function contact_dpo ( $ message ) { global $ USER ; $ warnings = [ ] ; $ params = external_api :: validate_parameters ( self :: contact_dpo_parameters ( ) , [ 'message' => $ message ] ) ; $ message = $ params [ 'message' ] ; $ userid = $ USER -> id ; $ context = context_user :: instance ( $ userid ) ; se...
Make a general enquiry to a DPO .
31,187
public static function mark_complete ( $ requestid ) { global $ USER ; $ warnings = [ ] ; $ params = external_api :: validate_parameters ( self :: mark_complete_parameters ( ) , [ 'requestid' => $ requestid , ] ) ; $ requestid = $ params [ 'requestid' ] ; $ context = context_system :: instance ( ) ; self :: validate_co...
Mark a user s general enquiry s status as complete .
31,188
public static function deny_data_request ( $ requestid ) { $ warnings = [ ] ; $ params = external_api :: validate_parameters ( self :: deny_data_request_parameters ( ) , [ 'requestid' => $ requestid ] ) ; $ requestid = $ params [ 'requestid' ] ; $ context = context_system :: instance ( ) ; self :: validate_context ( $ ...
Deny a data request .
31,189
public static function bulk_deny_data_requests ( $ requestids ) { $ warnings = [ ] ; $ result = false ; $ params = external_api :: validate_parameters ( self :: bulk_deny_data_requests_parameters ( ) , [ 'requestids' => $ requestids ] ) ; $ requestids = $ params [ 'requestids' ] ; $ context = context_system :: instance...
Bulk deny data requests .
31,190
public static function create_purpose_form ( $ jsonformdata ) { global $ PAGE ; $ warnings = [ ] ; $ params = external_api :: validate_parameters ( self :: create_purpose_form_parameters ( ) , [ 'jsonformdata' => $ jsonformdata ] ) ; self :: validate_context ( \ context_system :: instance ( ) ) ; api :: check_can_manag...
Creates a data purpose from form data .
31,191
public static function tree_extra_branches ( $ contextid , $ element ) { $ params = external_api :: validate_parameters ( self :: tree_extra_branches_parameters ( ) , [ 'contextid' => $ contextid , 'element' => $ element , ] ) ; $ context = context_helper :: instance_by_id ( $ params [ 'contextid' ] ) ; self :: validat...
Returns tree extra branches .
31,192
public static function confirm_contexts_for_deletion ( $ ids ) { $ warnings = [ ] ; $ params = external_api :: validate_parameters ( self :: confirm_contexts_for_deletion_parameters ( ) , [ 'ids' => $ ids ] ) ; $ ids = $ params [ 'ids' ] ; self :: validate_context ( \ context_system :: instance ( ) ) ; api :: check_can...
Confirm a given array of expired context record IDs
31,193
public static function get_category_options ( $ includeinherit , $ includenotset ) { $ warnings = [ ] ; $ params = self :: validate_parameters ( self :: get_category_options_parameters ( ) , [ 'includeinherit' => $ includeinherit , 'includenotset' => $ includenotset ] ) ; $ includeinherit = $ params [ 'includeinherit' ...
Fetches a list of data category options containing category IDs as keys and the category name for the value .
31,194
public static function get_purpose_options ( $ includeinherit , $ includenotset ) { $ warnings = [ ] ; $ params = self :: validate_parameters ( self :: get_category_options_parameters ( ) , [ 'includeinherit' => $ includeinherit , 'includenotset' => $ includenotset ] ) ; $ includeinherit = $ params [ 'includeinherit' ]...
Fetches a list of data storage purposes containing purpose IDs as keys and the purpose name for the value .
31,195
public static function get_activity_options ( $ nodefaults ) { $ warnings = [ ] ; $ params = self :: validate_parameters ( self :: get_activity_options_parameters ( ) , [ 'nodefaults' => $ nodefaults , ] ) ; $ nodefaults = $ params [ 'nodefaults' ] ; $ context = context_system :: instance ( ) ; self :: validate_context...
Fetches a list of activity options for setting data registry defaults .
31,196
public function close ( $ finalFilePointer ) { $ worksheets = $ this -> worksheets ; $ numWorksheets = count ( $ worksheets ) ; foreach ( $ worksheets as $ worksheet ) { $ worksheet -> close ( ) ; } $ this -> fileSystemHelper -> createContentFile ( $ worksheets , $ this -> styleHelper ) -> deleteWorksheetTempFolder ( )...
Closes the workbook and all its associated sheets . All the necessary files are written to disk and zipped together to create the ODS file . All the temporary files are then deleted .
31,197
public function to_legacy_objects ( array $ authors ) : array { return array_map ( function ( author_entity $ author ) { return ( object ) [ 'id' => $ author -> get_id ( ) , 'picture' => $ author -> get_picture_item_id ( ) , 'firstname' => $ author -> get_first_name ( ) , 'lastname' => $ author -> get_last_name ( ) , '...
Convert a list of author entities into stdClasses .
31,198
protected function prescan_keys ( ) { $ files = glob ( $ this -> glob_keys_pattern ( ) , GLOB_MARK | GLOB_NOSORT ) ; if ( is_array ( $ files ) ) { foreach ( $ files as $ filename ) { $ this -> keys [ basename ( $ filename ) ] = filemtime ( $ filename ) ; } } }
Pre - scan the cache to see which keys are present .
31,199
protected function glob_keys_pattern ( $ prefix = '' ) { if ( $ this -> singledirectory ) { return $ this -> path . '/' . $ prefix . '*.cache' ; } else { return $ this -> path . '/*/' . $ prefix . '*.cache' ; } }
Gets a pattern suitable for use with glob to find all keys in the cache .