idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
32,000
public function setup_blocks ( $ pagelayout , $ blockmanager ) { $ layoutinfo = $ this -> layout_info_for_page ( $ pagelayout ) ; if ( ! empty ( $ layoutinfo [ 'regions' ] ) ) { $ blockmanager -> add_regions ( $ layoutinfo [ 'regions' ] , false ) ; $ blockmanager -> set_default_region ( $ layoutinfo [ 'defaultregion' ]...
Inform a block_manager about the block regions this theme wants on this page layout .
32,001
protected function get_region_name ( $ region , $ theme ) { $ regionstring = get_string ( 'region-' . $ region , 'theme_' . $ theme ) ; if ( substr ( $ regionstring , 0 , 1 ) != '[' ) { return $ regionstring ; } foreach ( $ this -> parents as $ parentthemename ) { $ regionstring = get_string ( 'region-' . $ region , 't...
Gets the visible name for the requested block region .
32,002
public function get_all_block_regions ( ) { $ regions = array ( ) ; foreach ( $ this -> layouts as $ layoutinfo ) { foreach ( $ layoutinfo [ 'regions' ] as $ region ) { $ regions [ $ region ] = $ this -> get_region_name ( $ region , $ this -> name ) ; } } return $ regions ; }
Get the list of all block regions known to this theme in all templates .
32,003
public function get_block_render_method ( ) { if ( $ this -> blockrendermethod ) { return $ this -> blockrendermethod ; } foreach ( $ this -> parent_configs as $ config ) { if ( isset ( $ config -> blockrendermethod ) ) { return $ config -> blockrendermethod ; } } return 'blocks' ; }
Returns the block render method .
32,004
public function get_css_tree_post_processor ( ) { $ configs = [ $ this ] + $ this -> parent_configs ; foreach ( $ configs as $ config ) { if ( ! empty ( $ config -> csstreepostprocessor ) && is_callable ( $ config -> csstreepostprocessor ) ) { return $ config -> csstreepostprocessor ; } } return null ; }
Get the callable for CSS tree post processing .
32,005
public function push ( $ type , $ closehtml ) { $ container = new stdClass ; $ container -> type = $ type ; $ container -> closehtml = $ closehtml ; if ( $ this -> isdebugging ) { $ this -> log ( 'Open' , $ type ) ; } array_push ( $ this -> opencontainers , $ container ) ; }
Push the close HTML for a recently opened container onto the stack .
32,006
public static function available_converters ( $ restore = true ) { global $ CFG ; $ converters = array ( ) ; $ plugins = get_list_of_plugins ( 'backup/converter' ) ; foreach ( $ plugins as $ name ) { $ filename = $ restore ? 'lib.php' : 'backuplib.php' ; $ classuf = $ restore ? '_converter' : '_export_converter' ; $ cl...
Returns the list of all available converters and loads their classes
32,007
public static function detect_moodle2_format ( $ tempdir ) { $ dirpath = make_backup_temp_directory ( $ tempdir , false ) ; if ( ! is_dir ( $ dirpath ) ) { throw new convert_helper_exception ( 'tmp_backup_directory_not_found' , $ dirpath ) ; } $ filepath = $ dirpath . '/moodle_backup.xml' ; if ( ! file_exists ( $ filep...
Detects if the given folder contains an unpacked moodle2 backup
32,008
public static function to_moodle2_format ( $ tempdir , $ format = null , $ logger = null ) { if ( is_null ( $ format ) ) { $ format = backup_general_helper :: detect_backup_format ( $ tempdir ) ; } $ converters = self :: available_converters ( ) ; $ descriptions = array ( ) ; foreach ( $ converters as $ name ) { $ clas...
Converts the given directory with the backup into moodle2 format
32,009
public function write_general_feedback ( $ question , $ indent = "\t" ) { $ generalfeedback = $ this -> write_questiontext ( $ question -> generalfeedback , $ question -> generalfeedbackformat , $ question -> questiontextformat ) ; if ( $ generalfeedback ) { $ generalfeedback = '####' . $ generalfeedback ; if ( $ inden...
Outputs the general feedback for the question if any . This needs to be the last thing before the } .
32,010
public static function get_comments ( $ contextlevel , $ instanceid , $ component , $ itemid , $ area = '' , $ page = 0 ) { $ warnings = array ( ) ; $ arrayparams = array ( 'contextlevel' => $ contextlevel , 'instanceid' => $ instanceid , 'component' => $ component , 'itemid' => $ itemid , 'area' => $ area , 'page' => ...
Return a list of comments
32,011
public function view_summary ( stdClass $ submission , & $ showviewlink ) { $ showviewlink = false ; comment :: init ( ) ; $ options = new stdClass ( ) ; $ options -> area = 'submission_comments' ; $ options -> course = $ this -> assignment -> get_course ( ) ; $ options -> context = $ this -> assignment -> get_context ...
Display AJAX based comment in the submission status table
32,012
public function adjust_display_options ( question_display_options $ options ) { if ( ! $ this -> qa -> has_marks ( ) ) { $ options -> correctness = false ; $ options -> numpartscorrect = false ; } if ( $ this -> qa -> get_state ( ) -> is_finished ( ) ) { $ options -> readonly = true ; $ options -> numpartscorrect = $ o...
Make any changes to the display options before a question is rendered so that it can be displayed in a way that is appropriate for the statue it is currently in . For example by default if the question is finished we ensure that it is only ever displayed read - only .
32,013
public function get_expected_data ( ) { if ( ! $ this -> qa -> get_state ( ) -> is_finished ( ) ) { return array ( ) ; } $ vars = array ( 'comment' => question_attempt :: PARAM_RAW_FILES , 'commentformat' => PARAM_INT ) ; if ( $ this -> qa -> get_max_mark ( ) ) { $ vars [ 'mark' ] = PARAM_RAW_TRIMMED ; $ vars [ 'maxmar...
Return an array of the behaviour variables that could be submitted as part of a question of this type with their types so they can be properly cleaned .
32,014
public function process_save ( question_attempt_pending_step $ pendingstep ) { if ( $ this -> qa -> get_state ( ) -> is_finished ( ) ) { return question_attempt :: DISCARD ; } else if ( ! $ this -> qa -> get_state ( ) -> is_active ( ) ) { throw new coding_exception ( 'Question is not active, cannot process_actions.' ) ...
Implementation of processing a save action that should be suitable for most subclasses .
32,015
public static function adjust_fraction ( $ fraction , $ certainty ) { if ( $ certainty == - 1 ) { return 0 ; } if ( $ fraction <= 0.00000005 ) { return self :: $ wrongscore [ $ certainty ] ; } else { return self :: $ rightscore [ $ certainty ] * $ fraction ; } }
Given a fraction and a certainty compute the adjusted fraction .
32,016
public static function summary_with_certainty ( $ summary , $ certainty ) { if ( is_null ( $ certainty ) ) { return $ summary ; } return $ summary . ' [' . self :: get_short_string ( $ certainty ) . ']' ; }
Add information about certainty to a response summary .
32,017
public function get_file_info ( $ component , $ filearea , $ itemid , $ filepath , $ filename ) { if ( empty ( $ component ) ) { return $ this ; } $ methodname = "get_area_{$component}_{$filearea}" ; if ( method_exists ( $ this , $ methodname ) ) { return $ this -> $ methodname ( $ itemid , $ filepath , $ filename ) ; ...
Return information about this specific part of context level
32,018
public static function fetch ( $ params ) { $ cache = cache :: make ( 'core' , 'coursecompletion' ) ; $ key = $ params [ 'userid' ] . '_' . $ params [ 'course' ] ; if ( $ hit = $ cache -> get ( $ key ) ) { return $ hit [ 'value' ] ; } $ tocache = self :: fetch_helper ( 'course_completions' , __CLASS__ , $ params ) ; $ ...
Finds and returns a data_object instance based on params .
32,019
public function mark_inprogress ( $ timestarted = null ) { $ timenow = time ( ) ; $ this -> reaggregate = $ timenow ; if ( ! $ this -> timestarted ) { if ( ! $ timestarted ) { $ timestarted = $ timenow ; } $ this -> timestarted = $ timestarted ; } return $ this -> _save ( ) ; }
Mark this user as inprogress in this course
32,020
public function mark_complete ( $ timecomplete = null ) { global $ USER ; if ( $ this -> timecompleted ) { return ; } if ( ! $ timecomplete ) { $ timecomplete = time ( ) ; } $ this -> timecompleted = $ timecomplete ; if ( $ result = $ this -> _save ( ) ) { $ data = $ this -> get_record_data ( ) ; \ core \ event \ cours...
Mark this user complete in this course
32,021
private function _save ( ) { if ( $ this -> timeenrolled === null ) { $ this -> timeenrolled = 0 ; } $ result = false ; if ( $ this -> id ) { $ result = $ this -> update ( ) ; } else { if ( ! $ this -> reaggregate ) { $ this -> reaggregate = 0 ; } if ( ! $ this -> timestarted ) { $ this -> timestarted = 0 ; } $ result ...
Save course completion status
32,022
public function remove_success ( moodle_url $ url ) { $ html = $ this -> output -> notification ( get_string ( 'communityremoved' , 'hub' ) , 'notifysuccess' ) ; $ continuebutton = new single_button ( $ url , get_string ( 'continue' , 'block_community' ) ) ; $ html .= html_writer :: tag ( 'div' , $ this -> output -> re...
Display remove community success message and a button to be redirected to te referer page
32,023
public function moodlenet_info ( ) { if ( ! $ info = \ core \ hub \ registration :: get_moodlenet_info ( ) ) { return '' ; } $ image = html_writer :: div ( html_writer :: img ( $ info [ 'imgurl' ] , $ info [ 'name' ] ) , 'hubimage' ) ; $ namelink = html_writer :: link ( $ info [ 'url' ] , html_writer :: tag ( 'h2' , $ ...
Displays information about moodle . net above course search form
32,024
public function get_name ( ) { $ context = $ this -> context -> get_course_context ( false ) ; if ( $ context ) { return get_string ( 'courselegacyfilesofcourse' , 'moodle' , $ context -> get_context_name ( false , true ) ) ; } else { return get_string ( 'courselegacyfiles' ) ; } }
Return the repository name .
32,025
protected function find_language ( ) { global $ CFG ; $ this -> language = current_language ( ) ; $ basedir = $ CFG -> dirroot . '/media/player/videojs/videojs/lang/' ; $ langfiles = get_directory_list ( $ basedir ) ; $ candidates = [ ] ; foreach ( $ langfiles as $ langfile ) { if ( strtolower ( pathinfo ( $ langfile ,...
Tries to match the current language to existing language files
32,026
public function setup ( $ page ) { $ path = new moodle_url ( '/media/player/videojs/videojs/video-js.swf' ) ; $ contents = 'videojs.options.flash.swf = "' . $ path . '";' . "\n" ; $ contents .= $ this -> find_language ( current_language ( ) ) ; $ page -> requires -> js_amd_inline ( <<<EOTrequire(["media_videojs/loader"...
Setup page requirements .
32,027
protected function get_social_indicator ( $ modname ) { $ indicators = \ core_analytics \ manager :: get_all_indicators ( ) ; foreach ( $ indicators as $ indicator ) { if ( $ indicator instanceof community_of_inquiry_activity && $ indicator -> get_indicator_type ( ) === community_of_inquiry_activity :: INDICATOR_SOCIAL...
Returns the social breadth class of this indicator .
32,028
protected function from_db_records ( array $ results ) { $ entityfactory = $ this -> get_entity_factory ( ) ; return array_map ( function ( array $ result ) use ( $ entityfactory ) { [ 'record' => $ record ] = $ result ; return $ entityfactory -> get_post_from_stdclass ( $ record ) ; } , $ results ) ; }
Convert the DB records into post entities .
32,029
public function get_from_discussion_id ( stdClass $ user , int $ discussionid , bool $ canseeprivatereplies , string $ orderby = 'created ASC' ) : array { $ alias = $ this -> get_table_alias ( ) ; [ 'where' => $ privatewhere , 'params' => $ privateparams , ] = $ this -> get_private_reply_sql ( $ user , $ canseeprivater...
Get the post ids for the given discussion .
32,030
public function get_from_discussion_ids ( stdClass $ user , array $ discussionids , bool $ canseeprivatereplies ) : array { if ( empty ( $ discussionids ) ) { return [ ] ; } $ alias = $ this -> get_table_alias ( ) ; list ( $ insql , $ params ) = $ this -> get_db ( ) -> get_in_or_equal ( $ discussionids , SQL_PARAMS_NAM...
Get the list of posts for the given discussions .
32,031
public function get_replies_to_post ( stdClass $ user , post_entity $ post , bool $ canseeprivatereplies , string $ orderby = 'created ASC' ) : array { $ alias = $ this -> get_table_alias ( ) ; [ 'where' => $ privatewhere , 'params' => $ privateparams , ] = $ this -> get_private_reply_sql ( $ user , $ canseeprivaterepl...
Load a list of replies to the given post . This will load all descendants of the post . That is all direct replies and replies to those replies etc .
32,032
public function get_reply_count_for_post_id_in_discussion_id ( stdClass $ user , int $ postid , int $ discussionid , bool $ canseeprivatereplies ) : int { [ 'where' => $ privatewhere , 'params' => $ privateparams , ] = $ this -> get_private_reply_sql ( $ user , $ canseeprivatereplies ) ; $ alias = $ this -> get_table_a...
Get a mapping of replies to the specified discussions .
32,033
private function count_children_from_parent_recursively ( array $ postparents , int $ postid ) : int { if ( ! isset ( $ postparents [ $ postid ] ) ) { return 0 ; } $ count = 0 ; foreach ( $ postparents as $ pid => $ parentid ) { if ( $ postid == $ parentid ) { $ count += $ this -> count_children_from_parent_recursively...
Count the children whose parent matches the current record recursively .
32,034
public function get_unread_count_for_discussion_ids ( stdClass $ user , array $ discussionids , bool $ canseeprivatereplies ) : array { global $ CFG ; if ( empty ( $ discussionids ) ) { return [ ] ; } [ 'where' => $ privatewhere , 'params' => $ privateparams , ] = $ this -> get_private_reply_sql ( $ user , $ canseepriv...
Get a mapping of unread post counts for the specified discussions .
32,035
private function get_private_reply_sql ( stdClass $ user , bool $ canseeprivatereplies ) { $ params = [ ] ; $ privatewhere = '' ; if ( ! $ canseeprivatereplies ) { $ privatewhere = ' AND (p.privatereplyto = :privatereplyto OR p.userid = :privatereplyfrom OR p.privatereplyto = 0)' ; $ params [ 'privatereplyto' ] = $ use...
Get the SQL where and additional parameters to use to restrict posts to private reply posts .
32,036
public function get_first_post_for_discussion_ids ( array $ discussionids ) : array { if ( empty ( $ discussionids ) ) { return [ ] ; } list ( $ insql , $ params ) = $ this -> get_db ( ) -> get_in_or_equal ( $ discussionids , SQL_PARAMS_NAMED ) ; $ sql = " SELECT p.* FROM {" . self :: TABLE . "}...
Get a mapping of the first post in each discussion based on post creation time .
32,037
public function getAllValues ( $ mElement = null , $ bSearchInFunctionArguments = false ) { $ sSearchString = null ; if ( $ mElement === null ) { $ mElement = $ this ; } else if ( is_string ( $ mElement ) ) { $ sSearchString = $ mElement ; $ mElement = $ this ; } $ aResult = array ( ) ; $ this -> allValues ( $ mElement...
Returns all Value objects found recursively in the tree .
32,038
public function select_text ( ) { if ( ! $ this -> running_javascript ( ) ) { throw new coding_exception ( 'Selecting text requires javascript.' ) ; } $ editorid = $ this -> field -> getAttribute ( 'id' ) ; $ js = ' (function() { var e = document.getElementById("' . $ editorid . 'editable"), r = rangy.createR...
Select all the text in the form field .
32,039
public function has_user_read_post ( stdClass $ user , post_entity $ post ) : bool { global $ CFG ; $ isoldpost = ( $ post -> get_time_modified ( ) < ( time ( ) - ( $ CFG -> forum_oldpostdays * 24 * 3600 ) ) ) ; if ( $ isoldpost ) { return true ; } $ receipts = isset ( $ this -> receiptsbypostid [ $ post -> get_id ( ) ...
Check whether a user has read a post .
32,040
protected static function define_related ( ) { $ related = parent :: define_related ( ) ; $ related [ 'daylink' ] = \ moodle_url :: class ; $ related [ 'type' ] = '\core_calendar\type_base' ; $ related [ 'today' ] = 'int' ; $ related [ 'moduleinstance' ] = 'stdClass?' ; return $ related ; }
Returns a list of objects that are related .
32,041
protected function get_timestamp_min_limit ( \ DateTimeInterface $ starttime , $ min ) { $ values = [ ] ; $ timestamp = $ min [ 0 ] ; $ errorstring = $ min [ 1 ] ; $ mindate = ( new \ DateTimeImmutable ( ) ) -> setTimestamp ( $ timestamp ) ; $ minstart = $ mindate -> setTime ( $ starttime -> format ( 'H' ) , $ starttim...
Get the correct minimum midnight day limit based on the event start time and the minimum timestamp limit of what the event belongs to .
32,042
protected function get_timestamp_max_limit ( \ DateTimeInterface $ starttime , $ max ) { $ values = [ ] ; $ timestamp = $ max [ 0 ] ; $ errorstring = $ max [ 1 ] ; $ maxdate = ( new \ DateTimeImmutable ( ) ) -> setTimestamp ( $ timestamp ) ; $ maxstart = $ maxdate -> setTime ( $ starttime -> format ( 'H' ) , $ starttim...
Get the correct maximum midnight day limit based on the event start time and the maximum timestamp limit of what the event belongs to .
32,043
protected function get_module_timestamp_min_limit ( \ DateTimeInterface $ starttime , $ min ) { debugging ( 'get_module_timestamp_min_limit() has been deprecated. Please call get_timestamp_min_limit() instead.' , DEBUG_DEVELOPER ) ; return $ this -> get_timestamp_min_limit ( $ starttime , $ min ) ; }
Get the correct minimum midnight day limit based on the event start time and the module s minimum timestamp limit .
32,044
protected function get_module_timestamp_max_limit ( \ DateTimeInterface $ starttime , $ max ) { debugging ( 'get_module_timestamp_max_limit() has been deprecated. Please call get_timestamp_max_limit() instead.' , DEBUG_DEVELOPER ) ; return $ this -> get_timestamp_max_limit ( $ starttime , $ max ) ; }
Get the correct maximum midnight day limit based on the event start time and the module s maximum timestamp limit .
32,045
public function convert ( ) { try { $ this -> log ( 'creating the target directory' , backup :: LOG_DEBUG ) ; $ this -> create_workdir ( ) ; $ this -> log ( 'executing the conversion' , backup :: LOG_DEBUG ) ; $ this -> execute ( ) ; $ this -> log ( 'replacing the source directory with the converted version' , backup :...
Converts the backup directory
32,046
protected function replace_tempdir ( ) { global $ CFG ; $ tempdir = $ this -> get_tempdir_path ( ) ; if ( empty ( $ CFG -> keeptempdirectoriesonbackup ) ) { fulldelete ( $ tempdir ) ; } else { if ( ! rename ( $ tempdir , $ tempdir . '_' . $ this -> get_name ( ) . '_' . $ this -> id . '_source' ) ) { throw new convert_e...
Replaces the source backup directory with the converted version
32,047
public static function create_for_quiz ( $ quizobj ) { $ structure = self :: create ( ) ; $ structure -> quizobj = $ quizobj ; $ structure -> populate_structure ( $ quizobj -> get_quiz ( ) ) ; return $ structure ; }
Create an instance of this class representing the structure of a given quiz .
32,048
public function can_finish_during_the_attempt ( $ slotnumber ) { if ( $ this -> quizobj -> get_navigation_method ( ) == QUIZ_NAVMETHOD_SEQ ) { return false ; } if ( $ this -> slotsinorder [ $ slotnumber ] -> section -> shufflequestions ) { return false ; } if ( in_array ( $ this -> get_question_type_for_slot ( $ slotnu...
Whether it is possible for another question to depend on this one finishing . Note that the answer is not exact because of random questions and sometimes questions cannot be depended upon because of quiz options .
32,049
public function can_be_edited ( ) { if ( $ this -> canbeedited === null ) { $ this -> canbeedited = ! quiz_has_attempts ( $ this -> quizobj -> get_quizid ( ) ) ; } return $ this -> canbeedited ; }
Quizzes can only be edited if they have not been attempted .
32,050
public function check_can_be_edited ( ) { if ( ! $ this -> can_be_edited ( ) ) { $ reportlink = quiz_attempt_summary_link_to_reports ( $ this -> get_quiz ( ) , $ this -> quizobj -> get_cm ( ) , $ this -> quizobj -> get_context ( ) ) ; throw new \ moodle_exception ( 'cannoteditafterattempts' , 'quiz' , new \ moodle_url ...
This quiz can only be edited if they have not been attempted . Throw an exception if this is not the case .
32,051
public function is_first_slot_on_page ( $ slotnumber ) { if ( $ slotnumber == 1 ) { return true ; } return $ this -> slotsinorder [ $ slotnumber ] -> page != $ this -> slotsinorder [ $ slotnumber - 1 ] -> page ; }
Is this slot the first one on its page?
32,052
public function is_last_slot_on_page ( $ slotnumber ) { if ( ! isset ( $ this -> slotsinorder [ $ slotnumber + 1 ] ) ) { return true ; } return $ this -> slotsinorder [ $ slotnumber ] -> page != $ this -> slotsinorder [ $ slotnumber + 1 ] -> page ; }
Is this slot the last one on its page?
32,053
public function is_only_slot_in_section ( $ slotnumber ) { return $ this -> slotsinorder [ $ slotnumber ] -> section -> firstslot == $ this -> slotsinorder [ $ slotnumber ] -> section -> lastslot ; }
Is this slot the only one in its section?
32,054
public function get_slot_by_id ( $ slotid ) { if ( ! array_key_exists ( $ slotid , $ this -> slots ) ) { throw new \ coding_exception ( 'The \'slotid\' could not be found.' ) ; } return $ this -> slots [ $ slotid ] ; }
Get a slot by it s id . Throws an exception if it is missing .
32,055
public function get_slot_by_number ( $ slotnumber ) { foreach ( $ this -> slots as $ slot ) { if ( $ slot -> slot == $ slotnumber ) { return $ slot ; } } throw new \ coding_exception ( 'The \'slotnumber\' could not be found.' ) ; }
Get a slot by it s slot number . Throws an exception if it is missing .
32,056
public function can_add_section_heading ( $ pagenumber ) { if ( $ pagenumber == 1 ) { return false ; } $ firstslots = array ( ) ; foreach ( $ this -> sections as $ section ) { $ firstslots [ ] = $ section -> firstslot ; } foreach ( $ this -> slotsinorder as $ slot ) { if ( $ slot -> page == $ pagenumber ) { if ( in_arr...
Check whether adding a section heading is possible
32,057
public function get_slots_in_section ( $ sectionid ) { $ slots = array ( ) ; foreach ( $ this -> slotsinorder as $ slot ) { if ( $ slot -> section -> id == $ sectionid ) { $ slots [ ] = $ slot -> slot ; } } return $ slots ; }
Get all the slots in a section of the quiz .
32,058
public function get_edit_page_warnings ( ) { $ warnings = array ( ) ; if ( quiz_has_attempts ( $ this -> quizobj -> get_quizid ( ) ) ) { $ reviewlink = quiz_attempt_summary_link_to_reports ( $ this -> quizobj -> get_quiz ( ) , $ this -> quizobj -> get_cm ( ) , $ this -> quizobj -> get_context ( ) ) ; $ warnings [ ] = g...
Get any warnings to show at the top of the edit page .
32,059
public function get_dates_summary ( ) { $ timenow = time ( ) ; $ quiz = $ this -> quizobj -> get_quiz ( ) ; $ dates = array ( ) ; if ( $ quiz -> timeopen > 0 ) { if ( $ timenow > $ quiz -> timeopen ) { $ dates [ ] = get_string ( 'quizopenedon' , 'quiz' , userdate ( $ quiz -> timeopen ) ) ; } else { $ dates [ ] = get_st...
Get the date information about the current state of the quiz .
32,060
public function populate_structure ( $ quiz ) { global $ DB ; $ slots = $ DB -> get_records_sql ( " SELECT slot.id AS slotid, slot.slot, slot.questionid, slot.page, slot.maxmark, slot.requireprevious, q.*, qc.contextid FROM {quiz_slots} slot LEFT J...
Set up this class with the structure for a given quiz .
32,061
protected function populate_missing_questions ( $ slots ) { foreach ( $ slots as $ slot ) { if ( $ slot -> qtype === null ) { $ slot -> id = $ slot -> questionid ; $ slot -> category = 0 ; $ slot -> qtype = 'missingtype' ; $ slot -> name = get_string ( 'missingquestion' , 'quiz' ) ; $ slot -> slot = $ slot -> slot ; $ ...
Used by populate . Make up fake data for any missing questions .
32,062
public function populate_slots_with_sections ( ) { $ sections = array_values ( $ this -> sections ) ; foreach ( $ sections as $ i => $ section ) { if ( isset ( $ sections [ $ i + 1 ] ) ) { $ section -> lastslot = $ sections [ $ i + 1 ] -> firstslot - 1 ; } else { $ section -> lastslot = count ( $ this -> slotsinorder )...
Fill in the section ids for each slot .
32,063
protected function populate_question_numbers ( ) { $ number = 1 ; foreach ( $ this -> slots as $ slot ) { if ( $ this -> questions [ $ slot -> questionid ] -> length == 0 ) { $ slot -> displayednumber = get_string ( 'infoshort' , 'quiz' ) ; } else { $ slot -> displayednumber = $ number ; $ number += 1 ; } } }
Number the questions .
32,064
public function refresh_page_numbers ( $ slots = array ( ) ) { global $ DB ; if ( ! count ( $ slots ) ) { $ slots = $ DB -> get_records ( 'quiz_slots' , array ( 'quizid' => $ this -> get_quizid ( ) ) , 'slot, page' ) ; } $ pagenumbers = array ( 'new' => 0 , 'old' => 0 ) ; foreach ( $ slots as $ slot ) { if ( $ slot -> ...
Refresh page numbering of quiz slots .
32,065
public function refresh_page_numbers_and_update_db ( ) { global $ DB ; $ this -> check_can_be_edited ( ) ; $ slots = $ this -> refresh_page_numbers ( ) ; foreach ( $ slots as $ slot ) { $ DB -> set_field ( 'quiz_slots' , 'page' , $ slot -> page , array ( 'id' => $ slot -> id ) ) ; } return $ slots ; }
Refresh page numbering of quiz slots and save to the database .
32,066
public function remove_slot ( $ slotnumber ) { global $ DB ; $ this -> check_can_be_edited ( ) ; if ( $ this -> is_only_slot_in_section ( $ slotnumber ) && $ this -> get_section_count ( ) > 1 ) { throw new \ coding_exception ( 'You cannot remove the last slot in a section.' ) ; } $ slot = $ DB -> get_record ( 'quiz_slo...
Remove a slot from a quiz
32,067
public function update_slot_maxmark ( $ slot , $ maxmark ) { global $ DB ; if ( abs ( $ maxmark - $ slot -> maxmark ) < 1e-7 ) { return false ; } $ trans = $ DB -> start_delegated_transaction ( ) ; $ slot -> maxmark = $ maxmark ; $ DB -> update_record ( 'quiz_slots' , $ slot ) ; \ question_engine :: set_max_mark_in_att...
Change the max mark for a slot .
32,068
public function add_section_heading ( $ pagenumber , $ heading = null ) { global $ DB ; $ section = new \ stdClass ( ) ; if ( $ heading !== null ) { $ section -> heading = $ heading ; } else { $ section -> heading = get_string ( 'newsectionheading' , 'quiz' ) ; } $ section -> quizid = $ this -> get_quizid ( ) ; $ slots...
Add a section heading on a given page and return the sectionid
32,069
public function set_section_heading ( $ id , $ newheading ) { global $ DB ; $ section = $ DB -> get_record ( 'quiz_sections' , array ( 'id' => $ id ) , '*' , MUST_EXIST ) ; $ section -> heading = $ newheading ; $ DB -> update_record ( 'quiz_sections' , $ section ) ; }
Change the heading for a section .
32,070
public function set_section_shuffle ( $ id , $ shuffle ) { global $ DB ; $ section = $ DB -> get_record ( 'quiz_sections' , array ( 'id' => $ id ) , '*' , MUST_EXIST ) ; $ section -> shufflequestions = $ shuffle ; $ DB -> update_record ( 'quiz_sections' , $ section ) ; }
Change the shuffle setting for a section .
32,071
public function remove_section_heading ( $ sectionid ) { global $ DB ; $ section = $ DB -> get_record ( 'quiz_sections' , array ( 'id' => $ sectionid ) , '*' , MUST_EXIST ) ; if ( $ section -> firstslot == 1 ) { throw new \ coding_exception ( 'Cannot remove the first section in a quiz.' ) ; } $ DB -> delete_records ( '...
Remove the section heading with the given id
32,072
public function get_slot_tags_for_slot_id ( $ slotid ) { if ( ! $ this -> hasloadedtags ) { $ this -> populate_slot_tags ( ) ; $ this -> hasloadedtags = true ; } return isset ( $ this -> slottags [ $ slotid ] ) ? $ this -> slottags [ $ slotid ] : [ ] ; }
Retrieve the list of slot tags for the given slot id .
32,073
public static function instance ( $ page = null ) { if ( ! $ page ) { global $ PAGE ; $ page = $ PAGE ; } if ( self :: $ instance === null || ( $ page && self :: $ instance -> page !== $ page ) ) { self :: $ instance = new self ( $ page ) ; } return self :: $ instance ; }
Returns a singleton instance of a manager
32,074
private function get_players ( ) { if ( ! $ this -> players ) { $ sortorder = \ core \ plugininfo \ media :: get_enabled_plugins ( ) ; $ this -> players = [ ] ; foreach ( $ sortorder as $ name ) { $ classname = "media_" . $ name . "_plugin" ; if ( class_exists ( $ classname ) ) { $ this -> players [ ] = new $ classname...
Obtains the list of core_media_player objects currently in use to render items .
32,075
private function fallback_to_link ( $ urls , $ name , $ options ) { if ( ! empty ( $ options [ self :: OPTION_NO_LINK ] ) ) { return '' ; } $ output = '' ; foreach ( $ urls as $ url ) { if ( strval ( $ name ) !== '' && $ output === '' ) { $ title = $ name ; } else { $ title = $ this -> get_filename ( $ url ) ; } $ prin...
Returns links to the specified URLs unless OPTION_NO_LINK is passed .
32,076
public function can_embed_urls ( array $ urls , $ options = array ( ) ) { foreach ( $ this -> get_players ( ) as $ player ) { if ( $ player -> list_supported_urls ( $ urls , $ options ) ) { return true ; } } return false ; }
Checks whether a file can be embedded . If this returns true you will get an embedded player ; if this returns false you will just get a download link .
32,077
public function get_embeddable_markers ( ) { if ( empty ( $ this -> embeddablemarkers ) ) { $ markers = '' ; foreach ( $ this -> get_players ( ) as $ player ) { foreach ( $ player -> get_embeddable_markers ( ) as $ marker ) { if ( $ markers !== '' ) { $ markers .= '|' ; } $ markers .= preg_quote ( $ marker ) ; } } $ th...
Obtains a list of markers that can be used in a regular expression when searching for URLs that can be embedded by any player type .
32,078
public function get_extension ( moodle_url $ url ) { $ filename = self :: get_filename ( $ url ) ; $ dot = strrpos ( $ filename , '.' ) ; if ( $ dot === false ) { return '' ; } else { return strtolower ( substr ( $ filename , $ dot + 1 ) ) ; } }
Returns the file extension for a URL .
32,079
public function get_filename ( moodle_url $ url ) { $ path = $ url -> get_param ( 'file' ) ; if ( ! $ path ) { $ path = $ url -> get_path ( ) ; } $ slash = strrpos ( $ path , '/' ) ; if ( $ slash !== false ) { $ path = substr ( $ path , $ slash + 1 ) ; } return $ path ; }
Obtains the filename from the moodle_url .
32,080
public static function is_scale_used_anywhere ( $ scaleid ) { global $ DB ; $ sql = "SELECT s.id FROM {scale} s LEFT JOIN {" . competency_framework :: TABLE . "} f ON f.scaleid = :scaleid1 LEFT JOIN {" . competency :: TABLE . "} c ON c.scale...
Checks whether a scale is used anywhere in the plugin .
32,081
protected static function validate_course_module ( $ cmmixed , $ throwexception = true ) { $ cm = $ cmmixed ; if ( ! is_object ( $ cm ) ) { $ cmrecord = get_coursemodule_from_id ( null , $ cmmixed ) ; $ modinfo = get_fast_modinfo ( $ cmrecord -> course ) ; $ cm = $ modinfo -> get_cm ( $ cmmixed ) ; } else if ( ! $ cm i...
Validate if current user have acces to the course_module if hidden .
32,082
protected static function validate_course ( $ courseorid , $ throwexception = true ) { $ course = $ courseorid ; if ( ! is_object ( $ course ) ) { $ course = get_course ( $ course ) ; } $ coursecontext = context_course :: instance ( $ course -> id ) ; if ( ! $ course -> visible and ! has_capability ( 'moodle/course:vie...
Validate if current user have acces to the course if hidden .
32,083
public static function create_competency ( stdClass $ record ) { static :: require_enabled ( ) ; $ competency = new competency ( 0 , $ record ) ; require_capability ( 'moodle/competency:competencymanage' , $ competency -> get_context ( ) ) ; $ competency -> set ( 'sortorder' , 0 ) ; $ competency -> create ( ) ; \ core ...
Create a competency from a record containing all the data for the class .
32,084
public static function delete_competency ( $ id ) { global $ DB ; static :: require_enabled ( ) ; $ competency = new competency ( $ id ) ; require_capability ( 'moodle/competency:competencymanage' , $ competency -> get_context ( ) ) ; $ events = array ( ) ; $ competencyids = array ( intval ( $ competency -> get ( 'id' ...
Delete a competency by id .
32,085
public static function move_up_competency ( $ id ) { static :: require_enabled ( ) ; $ current = new competency ( $ id ) ; require_capability ( 'moodle/competency:competencymanage' , $ current -> get_context ( ) ) ; $ sortorder = $ current -> get ( 'sortorder' ) ; if ( $ sortorder == 0 ) { return false ; } $ sortorder ...
Reorder this competency .
32,086
public static function set_parent_competency ( $ id , $ newparentid ) { global $ DB ; static :: require_enabled ( ) ; $ current = new competency ( $ id ) ; require_capability ( 'moodle/competency:competencymanage' , $ current -> get_context ( ) ) ; if ( $ id == $ newparentid ) { throw new coding_exception ( 'Can not se...
Move this competency so it sits in a new parent .
32,087
public static function update_competency ( $ record ) { static :: require_enabled ( ) ; $ competency = new competency ( $ record -> id ) ; require_capability ( 'moodle/competency:competencymanage' , $ competency -> get_context ( ) ) ; $ record -> sortorder = $ competency -> get ( 'sortorder' ) ; $ record -> parentid = ...
Update the details for a competency .
32,088
public static function read_competency ( $ id , $ includerelated = false ) { static :: require_enabled ( ) ; $ competency = new competency ( $ id ) ; $ context = $ competency -> get_context ( ) ; if ( ! has_any_capability ( array ( 'moodle/competency:competencyview' , 'moodle/competency:competencymanage' ) , $ context ...
Read a the details for a single competency and return a record .
32,089
public static function search_competencies ( $ textsearch , $ competencyframeworkid ) { static :: require_enabled ( ) ; $ framework = new competency_framework ( $ competencyframeworkid ) ; $ context = $ framework -> get_context ( ) ; if ( ! has_any_capability ( array ( 'moodle/competency:competencyview' , 'moodle/compe...
Perform a text search based and return all results and their parents .
32,090
public static function create_framework ( stdClass $ record ) { static :: require_enabled ( ) ; $ framework = new competency_framework ( 0 , $ record ) ; require_capability ( 'moodle/competency:competencymanage' , $ framework -> get_context ( ) ) ; if ( isset ( $ record -> taxonomies ) ) { $ framework -> set ( 'taxonom...
Create a competency framework from a record containing all the data for the class .
32,091
public static function duplicate_framework ( $ id ) { global $ DB ; static :: require_enabled ( ) ; $ framework = new competency_framework ( $ id ) ; require_capability ( 'moodle/competency:competencymanage' , $ framework -> get_context ( ) ) ; $ transaction = $ DB -> start_delegated_transaction ( ) ; try { $ idnumber ...
Duplicate a competency framework by id .
32,092
public static function delete_framework ( $ id ) { global $ DB ; static :: require_enabled ( ) ; $ framework = new competency_framework ( $ id ) ; require_capability ( 'moodle/competency:competencymanage' , $ framework -> get_context ( ) ) ; $ events = array ( ) ; $ competenciesid = competency :: get_ids_by_frameworkid...
Delete a competency framework by id .
32,093
public static function update_framework ( $ record ) { static :: require_enabled ( ) ; $ framework = new competency_framework ( $ record -> id ) ; require_capability ( 'moodle/competency:competencymanage' , $ framework -> get_context ( ) ) ; $ framework -> from_record ( $ record ) ; if ( isset ( $ record -> taxonomies ...
Update the details for a competency framework .
32,094
public static function read_framework ( $ id ) { static :: require_enabled ( ) ; $ framework = new competency_framework ( $ id ) ; if ( ! has_any_capability ( array ( 'moodle/competency:competencyview' , 'moodle/competency:competencymanage' ) , $ framework -> get_context ( ) ) ) { throw new required_capability_exceptio...
Read a the details for a single competency framework and return a record .
32,095
public static function competency_framework_viewed ( $ frameworkorid ) { static :: require_enabled ( ) ; $ framework = $ frameworkorid ; if ( ! is_object ( $ framework ) ) { $ framework = new competency_framework ( $ framework ) ; } if ( ! has_any_capability ( array ( 'moodle/competency:competencyview' , 'moodle/compet...
Logg the competency framework viewed event .
32,096
public static function competency_viewed ( $ competencyorid ) { static :: require_enabled ( ) ; $ competency = $ competencyorid ; if ( ! is_object ( $ competency ) ) { $ competency = new competency ( $ competency ) ; } if ( ! has_any_capability ( array ( 'moodle/competency:competencyview' , 'moodle/competency:competenc...
Logg the competency viewed event .
32,097
public static function get_related_contexts ( $ context , $ includes , array $ hasanycapability = null ) { global $ DB ; static :: require_enabled ( ) ; if ( ! in_array ( $ includes , array ( 'children' , 'parents' , 'self' ) ) ) { throw new coding_exception ( 'Invalid parameter value for \'includes\'.' ) ; } if ( $ co...
Fetches all the relevant contexts .
32,098
public static function count_courses_using_competency ( $ competencyid ) { static :: require_enabled ( ) ; $ courses = course_competency :: list_courses_min ( $ competencyid ) ; $ count = 0 ; foreach ( $ courses as $ course ) { if ( ! self :: validate_course ( $ course , false ) ) { continue ; } $ context = context_cou...
Count all the courses using a competency .
32,099
public static function list_course_modules_using_competency ( $ competencyid , $ courseid ) { static :: require_enabled ( ) ; $ result = array ( ) ; self :: validate_course ( $ courseid ) ; $ coursecontext = context_course :: instance ( $ courseid ) ; $ capabilities = array ( 'moodle/competency:coursecompetencyview' , ...
List all the courses modules using a competency in a course .