idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
29,400
public function get_files ( $ includedirs = true , $ updatedsince = 0 ) { $ lesson = lesson :: load ( $ this -> properties -> lessonid ) ; $ fs = get_file_storage ( ) ; $ answerfiles = $ fs -> get_area_files ( $ lesson -> context -> id , 'mod_lesson' , 'page_answers' , $ this -> properties -> id , 'itemid, filepath, fi...
Get files from the answer area file .
29,401
public static function get ( lesson $ lesson ) { static $ pagetypemanager ; if ( ! ( $ pagetypemanager instanceof lesson_page_type_manager ) ) { $ pagetypemanager = new lesson_page_type_manager ( ) ; $ pagetypemanager -> load_lesson_types ( $ lesson ) ; } return $ pagetypemanager ; }
Retrieves the lesson page type manager object
29,402
public function get_page_type_strings ( $ type = null , $ special = true ) { $ types = array ( ) ; foreach ( $ this -> types as $ pagetype ) { if ( ( $ type === null || $ pagetype -> type === $ type ) && ( $ special === true || $ pagetype -> is_standard ( ) ) ) { $ types [ $ pagetype -> typeid ] = $ pagetype -> typestr...
Returns an array of strings to describe the loaded page types
29,403
public function get_page_type_idstring ( $ id ) { foreach ( $ this -> types as $ pagetype ) { if ( ( int ) $ pagetype -> typeid === ( int ) $ id ) { return $ pagetype -> idstring ; } } return 'unknown' ; }
Returns the basic string used to identify a page type provided with an id
29,404
public function load_page ( $ pageid , lesson $ lesson ) { global $ DB ; if ( ! ( $ page = $ DB -> get_record ( 'lesson_pages' , array ( 'id' => $ pageid , 'lessonid' => $ lesson -> id ) ) ) ) { print_error ( 'cannotfindpages' , 'lesson' ) ; } $ pagetype = get_class ( $ this -> types [ $ page -> qtype ] ) ; $ page = ne...
Loads a page for the provided lesson given it s id
29,405
protected function check_page_order ( $ page1 , $ page2 ) { global $ DB ; if ( empty ( $ page1 ) ) { if ( $ page2 -> prevpageid != 0 ) { debugging ( "***prevpageid of page " . $ page2 -> id . " set to 0***" ) ; $ page2 -> prevpageid = 0 ; $ DB -> set_field ( "lesson_pages" , "prevpageid" , 0 , array ( "id" => $ page2 -...
This function detects errors in the ordering between 2 pages and updates the page records .
29,406
public function load_all_pages ( lesson $ lesson ) { global $ DB ; if ( ! ( $ pages = $ DB -> get_records ( 'lesson_pages' , array ( 'lessonid' => $ lesson -> id ) ) ) ) { return array ( ) ; } foreach ( $ pages as $ key => $ page ) { $ pagetype = get_class ( $ this -> types [ $ page -> qtype ] ) ; $ pages [ $ key ] = n...
This function loads ALL pages that belong to the lesson .
29,407
public function get_add_page_type_links ( $ previd ) { global $ OUTPUT ; $ links = array ( ) ; foreach ( $ this -> types as $ key => $ type ) { if ( $ link = $ type -> add_page_link ( $ previd ) ) { $ links [ $ key ] = $ link ; } } return $ links ; }
Returns an array of links to use as add page links
29,408
public static function normalize ( $ arr ) { if ( ! is_array ( $ arr ) ) { return array ( ) ; } $ normalized = array ( ) ; foreach ( $ arr as $ key => $ val ) { $ normalized [ strtolower ( $ key ) ] = $ val ; } return $ normalized ; }
Normalize all keys in an array to lower - case .
29,409
public static function create ( int $ id , \ stdClass $ record = null , category_controller $ category = null ) : field_controller { global $ DB ; if ( $ id && $ record ) { debugging ( 'Too many parameters, either id need to be specified or a record, but not both.' , DEBUG_DEVELOPER ) ; } if ( $ id ) { if ( ! $ record ...
Creates an instance of field_controller
29,410
public function delete ( ) : bool { global $ DB ; $ DB -> delete_records ( 'customfield_data' , [ 'fieldid' => $ this -> get ( 'id' ) ] ) ; return $ this -> field -> delete ( ) ; }
Delete a field and all associated data
29,411
public function get_configdata_property ( string $ property ) { $ configdata = $ this -> field -> get ( 'configdata' ) ; if ( ! isset ( $ configdata [ $ property ] ) ) { return null ; } return $ configdata [ $ property ] ; }
Get configdata property .
29,412
public function get_formatted_name ( ) : string { $ context = $ this -> get_handler ( ) -> get_configuration_context ( ) ; return format_string ( $ this -> get ( 'name' ) , true , [ 'context' => $ context ] ) ; }
Returns the field name formatted according to configuration context .
29,413
public static function export_item_tags ( int $ userid , \ context $ context , array $ subcontext , string $ component , string $ itemtype , int $ itemid , bool $ onlyuser = false ) { global $ DB ; $ sql = "SELECT t.rawname FROM {tag} t INNER JOIN {tag_instance} ti ON ti.t...
Store all tags which match the specified component itemtype and itemid .
29,414
public static function delete_item_tags ( \ context $ context , $ component , $ itemtype , $ itemid = null , $ userid = null ) { global $ DB ; $ params = [ 'contextid' => $ context -> id , 'component' => $ component , 'itemtype' => $ itemtype ] ; if ( $ itemid ) { $ params [ 'itemid' ] = $ itemid ; } if ( $ userid ) { ...
Deletes all tag instances for given context component itemtype itemid
29,415
protected function get_fragments_glue_placeholders ( $ fragments ) { $ fragmentscount = count ( $ fragments ) ; if ( $ fragmentscount <= 1 ) { return [ ] ; } $ prefix = '[[$' ; $ postfix = ']]' ; $ text = join ( '' , $ fragments ) ; while ( preg_match ( '/' . preg_quote ( $ prefix , '/' ) . '\\d+' . preg_quote ( $ post...
Find strings that we can use to glue the fragments with
29,416
public static function create_from_object ( $ choiceanswer , $ choice , $ cm , $ course ) { global $ USER ; $ eventdata = array ( ) ; $ eventdata [ 'objectid' ] = $ choiceanswer -> id ; $ eventdata [ 'context' ] = \ context_module :: instance ( $ cm -> id ) ; $ eventdata [ 'userid' ] = $ USER -> id ; $ eventdata [ 'cou...
Creates an instance of the event from the records
29,417
protected function define_definition_plugin_structure ( ) { $ paths = array ( ) ; $ paths [ ] = new restore_path_element ( 'gradingform_guide_criterion' , $ this -> get_pathfor ( '/guidecriteria/guidecriterion' ) ) ; $ paths [ ] = new restore_path_element ( 'gradingform_guide_comment' , $ this -> get_pathfor ( '/guidec...
Declares the marking guide XML paths attached to the form definition element
29,418
public function process_gradingform_guide_criterion ( $ data ) { global $ DB ; $ data = ( object ) $ data ; $ oldid = $ data -> id ; $ data -> definitionid = $ this -> get_new_parentid ( 'grading_definition' ) ; $ newid = $ DB -> insert_record ( 'gradingform_guide_criteria' , $ data ) ; $ this -> set_mapping ( 'grading...
Processes criterion element data
29,419
public static function is_manual_grade_in_range ( $ qubaid , $ slot ) { $ prefix = 'q' . $ qubaid . ':' . $ slot . '_' ; $ mark = question_utils :: optional_param_mark ( $ prefix . '-mark' ) ; $ maxmark = optional_param ( $ prefix . '-maxmark' , null , PARAM_FLOAT ) ; $ minfraction = optional_param ( $ prefix . ':minfr...
Validate that the manual grade submitted for a particular question is in range .
29,420
public static function get_dp_options ( ) { $ options = array ( ) ; for ( $ i = 0 ; $ i <= self :: MAX_DP ; $ i += 1 ) { $ options [ $ i ] = $ i ; } return $ options ; }
Returns the valid choices for the number of decimal places for showing question marks . For use in the user interface .
29,421
protected static function get_toggle_checksum ( $ qubaid , $ questionid , $ qaid , $ slot , $ user = null ) { if ( is_null ( $ user ) ) { global $ USER ; $ user = $ USER ; } return md5 ( $ qubaid . "_" . $ user -> secret . "_" . $ questionid . "_" . $ qaid . "_" . $ slot ) ; }
Get the checksum that validates that a toggle request is valid .
29,422
public static function update_flag ( $ qubaid , $ questionid , $ qaid , $ slot , $ checksum , $ newstate ) { if ( $ checksum != self :: get_toggle_checksum ( $ qubaid , $ questionid , $ qaid , $ slot ) ) { throw new moodle_exception ( 'errorsavingflags' , 'question' ) ; } $ dm = new question_engine_data_mapper ( ) ; $ ...
If the request seems valid update the flag state of a question attempt . Throws exceptions if this is not a valid update request .
29,423
public static function int_to_roman ( $ number ) { if ( ! is_integer ( $ number ) || $ number < 1 || $ number > 3999 ) { throw new coding_exception ( 'Only integers between 0 and 3999 can be ' . 'converted to roman numerals.' , $ number ) ; } return self :: $ thousands [ $ number / 1000 % 10 ] . self :: $ hundreds [ $ ...
Convert an integer to roman numerals .
29,424
public static function int_to_letter ( $ number ) { $ alphabet = [ '1' => 'A' , '2' => 'B' , '3' => 'C' , '4' => 'D' , '5' => 'E' , '6' => 'F' , '7' => 'G' , '8' => 'H' , '9' => 'I' , '10' => 'J' , '11' => 'K' , '12' => 'L' , '13' => 'M' , '14' => 'N' , '15' => 'O' , '16' => 'P' , '17' => 'Q' , '18' => 'R' , '19' => 'S...
Convert an integer to a letter of alphabet .
29,425
public static function to_plain_text ( $ text , $ format , $ options = array ( 'noclean' => 'true' ) ) { $ text = str_replace ( '@@PLUGINFILE@@/' , 'http://example.com/' , $ text ) ; return html_to_text ( format_text ( $ text , $ format , $ options ) , 0 , false ) ; }
Convert part of some question content to plain text .
29,426
public static function get_filepicker_options ( $ context , $ draftitemid ) { return [ 'image' => self :: specific_filepicker_options ( [ 'image' ] , $ draftitemid , $ context ) , 'media' => self :: specific_filepicker_options ( [ 'video' , 'audio' ] , $ draftitemid , $ context ) , 'link' => self :: specific_filepicker...
Get filepicker options for question related text areas .
29,427
public static function get_editor_options ( $ context ) { global $ CFG ; $ editoroptions = [ 'subdirs' => 0 , 'context' => $ context , 'maxfiles' => EDITOR_UNLIMITED_FILES , 'maxbytes' => $ CFG -> maxbytes , 'noclean' => 0 , 'trusttext' => 0 , 'autosave' => false ] ; return $ editoroptions ; }
Get editor options for question related text areas .
29,428
public function parse ( $ strinputxml ) { $ this -> resparser = xml_parser_create ( 'UTF-8' ) ; xml_set_object ( $ this -> resparser , $ this ) ; xml_set_element_handler ( $ this -> resparser , "tagopen" , "tagclosed" ) ; xml_set_character_data_handler ( $ this -> resparser , "tagdata" ) ; $ this -> strxmldata = xml_pa...
Parse an XML text string and create an array tree that rapresent the XML structure
29,429
protected function get_area_user_private ( $ itemid , $ filepath , $ filename ) { global $ USER , $ CFG ; if ( $ this -> user -> id != $ USER -> id ) { return null ; } if ( is_null ( $ itemid ) ) { return $ this ; } $ fs = get_file_storage ( ) ; $ filepath = is_null ( $ filepath ) ? '/' : $ filepath ; $ filename = is_n...
Get a file from user private area
29,430
static protected function build_activity_plan ( $ controller , $ activityid ) { $ plan = $ controller -> get_plan ( ) ; $ info = $ controller -> get_info ( ) ; $ infoactivity = $ info -> activities [ $ activityid ] ; if ( $ task = restore_factory :: get_restore_activity_task ( $ infoactivity ) ) { $ plan -> add_task ( ...
Restore one 1 - activity backup
29,431
static protected function build_section_plan ( $ controller , $ sectionid ) { $ plan = $ controller -> get_plan ( ) ; $ info = $ controller -> get_info ( ) ; $ infosection = $ info -> sections [ $ sectionid ] ; $ plan -> add_task ( restore_factory :: get_restore_section_task ( $ infosection ) ) ; $ controller -> get_pr...
Restore one 1 - section backup
29,432
static protected function build_course_plan ( $ controller , $ courseid ) { $ plan = $ controller -> get_plan ( ) ; $ info = $ controller -> get_info ( ) ; $ task = restore_factory :: get_restore_course_task ( $ info -> course , $ courseid ) ; $ plan -> add_task ( $ task ) ; $ controller -> get_progress ( ) -> progress...
Restore one 1 - course backup
29,433
public function store ( $ data ) { $ fs = get_file_storage ( ) ; $ filerecord = [ 'component' => 'analytics' , 'filearea' => $ this -> filearea , 'itemid' => $ this -> modelid , 'contextid' => \ context_system :: instance ( ) -> id , 'filepath' => '/analysable/' . $ this -> analysableid . '/' . \ core_analytics \ analy...
Store the dataset in the internal file system .
29,434
public static function get_previous_evaluation_file ( $ modelid , $ timesplittingid ) { $ fs = get_file_storage ( ) ; $ filepath = '/timesplitting/' . \ core_analytics \ analysis :: clean_time_splitting_id ( $ timesplittingid ) . '/' ; return $ fs -> get_file ( \ context_system :: instance ( ) -> id , 'analytics' , sel...
Returns the previous evaluation file .
29,435
public static function get_pending_files ( $ modelid , $ includetarget , $ timesplittingids ) { global $ DB ; $ fs = get_file_storage ( ) ; if ( $ includetarget ) { $ filearea = self :: LABELLED_FILEAREA ; $ usedfileaction = 'trained' ; } else { $ filearea = self :: UNLABELLED_FILEAREA ; $ usedfileaction = 'predicted' ...
Gets the list of files that couldn t be previously used for training and prediction .
29,436
public static function delete_previous_evaluation_file ( $ modelid , $ timesplittingid ) { if ( $ file = self :: get_previous_evaluation_file ( $ modelid , $ timesplittingid ) ) { $ file -> delete ( ) ; return true ; } return false ; }
Deletes previous evaluation files of this model .
29,437
public static function merge_datasets ( array $ files , $ modelid , $ timesplittingid , $ filearea , $ evaluation = false ) { $ tmpfilepath = make_request_directory ( ) . DIRECTORY_SEPARATOR . 'tmpfile.csv' ; $ varnames = '' ; $ analysablesvalues = array ( ) ; foreach ( $ files as $ file ) { $ rh = $ file -> get_conten...
Merge multiple files into one .
29,438
public static function export_training_data ( $ modelid , $ timesplittingid ) { $ fs = get_file_storage ( ) ; $ contextid = \ context_system :: instance ( ) -> id ; $ filepath = '/timesplitting/' . \ core_analytics \ analysis :: clean_time_splitting_id ( $ timesplittingid ) . '/' ; $ files = $ fs -> get_directory_files...
Exports the model training data .
29,439
public static function get_structured_data ( \ stored_file $ dataset ) { if ( $ dataset -> get_filearea ( ) !== 'unlabelled' ) { throw new \ coding_exception ( 'Sorry, only support for unlabelled data' ) ; } $ rh = $ dataset -> get_content_file_handle ( ) ; fgets ( $ rh ) ; fgets ( $ rh ) ; $ calculations = array ( ) ;...
Returns the dataset file data structured by sampleids using the indicators and target column names .
29,440
public static function clear_model_files ( $ modelid ) { $ fs = get_file_storage ( ) ; return $ fs -> delete_area_files ( \ context_system :: instance ( ) -> id , 'analytics' , false , $ modelid ) ; }
Delete all files of a model .
29,441
protected static function get_filename ( $ evaluation ) { if ( $ evaluation === true ) { $ filename = self :: EVALUATION_FILENAME ; } else { $ filename = microtime ( true ) . '.csv' ; } return $ filename ; }
Returns the file name to be used .
29,442
public function get_preferences_as_booleans ( ) { $ preferences = [ ] ; $ preferences [ $ this -> view ] = true ; $ preferences [ $ this -> sort ] = true ; $ preferences [ $ this -> grouping ] = true ; return $ preferences ; }
Get the user preferences as an array to figure out what has been selected
29,443
public function get_matching_answer ( $ value , $ multiplier ) { if ( is_null ( $ value ) || $ value === '' ) { return null ; } if ( ! is_null ( $ multiplier ) ) { $ scaledvalue = $ value * $ multiplier ; } else { $ scaledvalue = $ value ; } foreach ( $ this -> answers as $ answer ) { if ( $ answer -> within_tolerance ...
Get an answer that contains the feedback and fraction that should be awarded for this response .
29,444
public function apply_unit_penalty ( $ fraction , $ unitisright ) { if ( $ unitisright ) { return $ fraction ; } if ( $ this -> unitgradingtype == qtype_numerical :: UNITGRADEDOUTOFMARK ) { $ fraction -= $ this -> unitpenalty * $ fraction ; } else if ( $ this -> unitgradingtype == qtype_numerical :: UNITGRADEDOUTOFMAX ...
Adjust the fraction based on whether the unit was correct .
29,445
protected function validate ( ) { if ( $ this -> n === '+0' || $ this -> n === '-0' ) { $ this -> n = '0' ; } if ( $ this -> n === '0' && $ this -> unit === false ) { return true ; } if ( ! ctype_lower ( $ this -> unit ) ) { $ this -> unit = strtolower ( $ this -> unit ) ; } if ( ! isset ( HTMLPurifier_Length :: $ allo...
Validates the number and unit .
29,446
public static function uncompress ( $ ip ) { $ c1 = - 1 ; $ c2 = - 1 ; if ( substr_count ( $ ip , '::' ) === 1 ) { list ( $ ip1 , $ ip2 ) = explode ( '::' , $ ip ) ; if ( $ ip1 === '' ) { $ c1 = - 1 ; } else { $ c1 = substr_count ( $ ip1 , ':' ) ; } if ( $ ip2 === '' ) { $ c2 = - 1 ; } else { $ c2 = substr_count ( $ ip...
Uncompresses an IPv6 address
29,447
private static function split_v6_v4 ( $ ip ) { if ( strpos ( $ ip , '.' ) !== false ) { $ pos = strrpos ( $ ip , ':' ) ; $ ipv6_part = substr ( $ ip , 0 , $ pos ) ; $ ipv4_part = substr ( $ ip , $ pos + 1 ) ; return array ( $ ipv6_part , $ ipv4_part ) ; } else { return array ( $ ip , '' ) ; } }
Splits an IPv6 address into the IPv6 and IPv4 representation parts
29,448
public static function check_ipv6 ( $ ip ) { $ ip = self :: uncompress ( $ ip ) ; list ( $ ipv6 , $ ipv4 ) = self :: split_v6_v4 ( $ ip ) ; $ ipv6 = explode ( ':' , $ ipv6 ) ; $ ipv4 = explode ( '.' , $ ipv4 ) ; if ( count ( $ ipv6 ) === 8 && count ( $ ipv4 ) === 1 || count ( $ ipv6 ) === 6 && count ( $ ipv4 ) === 4 ) ...
Checks an IPv6 address
29,449
protected function define_enrol_plugin_structure ( ) { $ paths = array ( ) ; $ paths [ ] = new restore_path_element ( 'enrol_lti_tool' , $ this -> connectionpoint -> get_path ( ) . '/tool' ) ; $ paths [ ] = new restore_path_element ( 'enrol_lti_users' , $ this -> connectionpoint -> get_path ( ) . '/tool/users/user' ) ;...
Declares the enrol LTI XML paths attached to the enrol element
29,450
public function process_enrol_lti_tool ( $ data ) { global $ DB ; $ data = ( object ) $ data ; $ oldid = $ data -> id ; $ data -> timecreated = time ( ) ; $ data -> timemodified = $ data -> timecreated ; $ data -> id = $ DB -> insert_record ( 'enrol_lti_tools' , $ data ) ; $ this -> tools [ $ data -> id ] = $ data ; $ ...
Processes LTI tools element data
29,451
public function process_enrol_lti_users ( $ data ) { global $ DB ; $ data = ( object ) $ data ; $ data -> userid = $ this -> get_mappingid ( 'user' , $ data -> userid ) ; $ data -> toolid = $ this -> get_mappingid ( 'enrol_lti_tool' , $ data -> toolid ) ; $ data -> timecreated = time ( ) ; $ DB -> insert_record ( 'enro...
Processes LTI users element data
29,452
public function after_restore_enrol ( ) { global $ DB ; foreach ( $ this -> tools as $ tool ) { $ updatetool = new stdClass ( ) ; $ updatetool -> id = $ tool -> id ; $ updatetool -> enrolid = $ this -> get_mappingid ( 'enrol' , $ tool -> enrolid ) ; $ updatetool -> contextid = $ this -> get_mappingid ( 'context' , $ to...
This function is executed after all the tasks in the plan have been finished . This must be done here because the activities have not been restored yet .
29,453
private function mapBorderStyle ( $ borderStyle ) { switch ( $ borderStyle ) { case PHPExcel_Style_Border :: BORDER_NONE : return 'none' ; case PHPExcel_Style_Border :: BORDER_DASHDOT : return '1px dashed' ; case PHPExcel_Style_Border :: BORDER_DASHDOTDOT : return '1px dotted' ; case PHPExcel_Style_Border :: BORDER_DAS...
Map border style
29,454
public function generateHTMLHeader ( $ pIncludeStyles = false ) { if ( is_null ( $ this -> phpExcel ) ) { throw new PHPExcel_Writer_Exception ( 'Internal PHPExcel object not set to an instance of an object.' ) ; } $ properties = $ this -> phpExcel -> getProperties ( ) ; $ html = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML...
Generate HTML header
29,455
private function writeChartInCell ( PHPExcel_Worksheet $ pSheet , $ coordinates ) { $ html = '' ; foreach ( $ pSheet -> getChartCollection ( ) as $ chart ) { if ( $ chart instanceof PHPExcel_Chart ) { $ chartCoordinates = $ chart -> getTopLeftPosition ( ) ; if ( $ chartCoordinates [ 'cell' ] == $ coordinates ) { $ char...
Generate chart tag in cell
29,456
public static function get_list_of_calendar_types ( ) { $ calendars = array ( ) ; $ calendardirs = \ core_component :: get_plugin_list ( 'calendartype' ) ; foreach ( $ calendardirs as $ name => $ location ) { $ calendars [ $ name ] = get_string ( 'name' , "calendartype_{$name}" ) ; } return $ calendars ; }
Returns a list of calendar typess available for use .
29,457
public static function get_calendar_type ( ) { global $ CFG , $ USER , $ SESSION , $ COURSE ; if ( ! empty ( $ COURSE -> id ) and $ COURSE -> id != SITEID and ! empty ( $ COURSE -> calendartype ) ) { $ return = $ COURSE -> calendartype ; } else if ( ! empty ( $ SESSION -> calendartype ) ) { $ return = $ SESSION -> cale...
Returns the current calendar type in use .
29,458
public function toHtml ( ) { global $ PAGE ; $ html = $ this -> _getTabs ( ) ; $ renderer = $ PAGE -> get_renderer ( 'gradingform_rubric' ) ; $ data = $ this -> prepare_data ( null , $ this -> wasvalidated ) ; if ( ! $ this -> _flagFrozen ) { $ mode = gradingform_rubric_controller :: DISPLAY_EDIT_FULL ; $ module = arra...
Returns html string to display this element
29,459
public function validate ( $ value ) { if ( ! $ this -> wasvalidated ) { $ this -> prepare_data ( $ value , true ) ; } return $ this -> validationerrors ; }
Validates that rubric has at least one criterion at least two levels within one criterion each level has a valid score all levels have filled definitions and all criteria have filled descriptions
29,460
public function get_context ( ) { if ( $ this -> type == BADGE_TYPE_SITE ) { return context_system :: instance ( ) ; } else if ( $ this -> type == BADGE_TYPE_COURSE ) { return context_course :: instance ( $ this -> courseid ) ; } else { debugging ( 'Something is wrong...' ) ; } }
Use to get context instance of a badge .
29,461
public function get_accepted_criteria ( ) { global $ CFG ; $ criteriatypes = array ( ) ; if ( $ this -> type == BADGE_TYPE_COURSE ) { $ criteriatypes = array ( BADGE_CRITERIA_TYPE_OVERALL , BADGE_CRITERIA_TYPE_MANUAL , BADGE_CRITERIA_TYPE_COURSE , BADGE_CRITERIA_TYPE_BADGE , BADGE_CRITERIA_TYPE_ACTIVITY , BADGE_CRITERI...
Return array of accepted criteria types for this badge
29,462
public function make_clone ( ) { global $ DB , $ USER , $ PAGE ; $ fordb = new stdClass ( ) ; foreach ( get_object_vars ( $ this ) as $ k => $ v ) { $ fordb -> { $ k } = $ v ; } $ fordb -> name = get_string ( 'copyof' , 'badges' , $ this -> name ) ; $ fordb -> status = BADGE_STATUS_INACTIVE ; $ fordb -> usercreated = $...
Creates and saves a clone of badge with all its properties . Clone is not active by default and has Copy of attached to its name .
29,463
public function issue ( $ userid , $ nobake = false ) { global $ DB , $ CFG ; $ now = time ( ) ; $ issued = new stdClass ( ) ; $ issued -> badgeid = $ this -> id ; $ issued -> userid = $ userid ; $ issued -> uniquehash = sha1 ( rand ( ) . $ userid . $ this -> id . $ now ) ; $ issued -> dateissued = $ now ; if ( $ this ...
Issue a badge to user .
29,464
public function review_all_criteria ( ) { global $ DB , $ CFG ; $ awards = 0 ; core_php_time_limit :: raise ( ) ; raise_memory_limit ( MEMORY_HUGE ) ; foreach ( $ this -> criteria as $ crit ) { if ( $ crit -> criteriatype == BADGE_CRITERIA_TYPE_OVERALL ) { continue ; } list ( $ extrajoin , $ extrawhere , $ extraparams ...
Reviews all badge criteria and checks if badge can be instantly awarded .
29,465
public function get_criteria_completions ( $ userid ) { global $ DB ; $ completions = array ( ) ; $ sql = "SELECT bcm.id, bcm.critid FROM {badge_criteria_met} bcm INNER JOIN {badge_criteria} bc ON bcm.critid = bc.id WHERE bc.badgeid = :badgeid AND bcm.userid = :userid " ...
Gets an array of completed criteria from badge_criteria_met table .
29,466
public function get_criteria ( ) { global $ DB ; $ criteria = array ( ) ; if ( $ records = ( array ) $ DB -> get_records ( 'badge_criteria' , array ( 'badgeid' => $ this -> id ) ) ) { foreach ( $ records as $ record ) { $ criteria [ $ record -> criteriatype ] = award_criteria :: build ( ( array ) $ record ) ; } } retur...
Returns badge award criteria
29,467
public function get_aggregation_method ( $ criteriatype = 0 ) { global $ DB ; $ params = array ( 'badgeid' => $ this -> id , 'criteriatype' => $ criteriatype ) ; $ aggregation = $ DB -> get_field ( 'badge_criteria' , 'method' , $ params , IGNORE_MULTIPLE ) ; if ( ! $ aggregation ) { return BADGE_CRITERIA_AGGREGATION_AL...
Get aggregation method for badge criteria
29,468
public function calculate_expiry ( $ timestamp ) { $ expiry = null ; if ( isset ( $ this -> expiredate ) ) { $ expiry = $ this -> expiredate ; } else if ( isset ( $ this -> expireperiod ) ) { $ expiry = $ timestamp + $ this -> expireperiod ; } return $ expiry ; }
Calculates badge expiry date based on either expirydate or expiryperiod .
29,469
public function has_manual_award_criteria ( ) { foreach ( $ this -> criteria as $ criterion ) { if ( $ criterion -> criteriatype == BADGE_CRITERIA_TYPE_MANUAL ) { return true ; } } return false ; }
Checks if badge has manual award criteria set .
29,470
public function delete ( $ archive = true ) { global $ DB ; if ( $ archive ) { $ this -> status = BADGE_STATUS_ARCHIVED ; $ this -> save ( ) ; $ eventparams = array ( 'objectid' => $ this -> id , 'context' => $ this -> get_context ( ) ) ; $ event = \ core \ event \ badge_archived :: create ( $ eventparams ) ; $ event -...
Fully deletes the badge or marks it as archived .
29,471
public function add_related_badges ( $ relatedids ) { global $ DB ; $ relatedbadges = array ( ) ; foreach ( $ relatedids as $ relatedid ) { $ relatedbadge = new stdClass ( ) ; $ relatedbadge -> badgeid = $ this -> id ; $ relatedbadge -> relatedbadgeid = $ relatedid ; $ relatedbadges [ ] = $ relatedbadge ; } $ DB -> ins...
Add multiple related badges .
29,472
public function delete_related_badge ( $ relatedid ) { global $ DB ; $ sql = "(badgeid = :badgeid AND relatedbadgeid = :relatedid) OR " . "(badgeid = :relatedid2 AND relatedbadgeid = :badgeid2)" ; $ params = [ 'badgeid' => $ this -> id , 'badgeid2' => $ this -> id , 'relatedid' => $ relatedid , 'relatedid2' => $ relate...
Delete an related badge .
29,473
public function has_related ( ) { global $ DB ; $ sql = "SELECT DISTINCT b.id FROM {badge_related} br JOIN {badge} b ON (br.relatedbadgeid = b.id OR br.badgeid = b.id) WHERE (br.badgeid = :badgeid OR br.relatedbadgeid = :badgeid2) AND b.id != :badgeid3" ; return $...
Checks if badge has related badges .
29,474
public function get_related_badges ( bool $ activeonly = false ) { global $ DB ; $ params = array ( 'badgeid' => $ this -> id , 'badgeid2' => $ this -> id , 'badgeid3' => $ this -> id ) ; $ query = "SELECT DISTINCT b.id, b.name, b.version, b.language, b.type FROM {badge_related} br ...
Get related badges of badge .
29,475
public function markdown_badge_criteria ( ) { $ agg = $ this -> get_aggregation_methods ( ) ; if ( empty ( $ this -> criteria ) ) { return get_string ( 'nocriteria' , 'badges' ) ; } $ overalldescr = '' ; $ overall = $ this -> criteria [ BADGE_CRITERIA_TYPE_OVERALL ] ; if ( ! empty ( $ overall -> description ) ) { $ ove...
Markdown language support for criteria .
29,476
public function get_badge_issuer ( ) { $ issuer = array ( ) ; $ issuerurl = new moodle_url ( '/badges/badge_json.php' , array ( 'id' => $ this -> id , 'action' => 0 ) ) ; $ issuer [ 'name' ] = $ this -> issuername ; $ issuer [ 'url' ] = $ this -> issuerurl ; $ issuer [ 'email' ] = $ this -> issuercontact ; $ issuer [ '...
Define issuer information by format Open Badges specification version 2 .
29,477
function print_header ( ) { global $ OUTPUT , $ PAGE , $ CFG , $ USER , $ SESSION ; $ PAGE -> set_heading ( $ PAGE -> course -> fullname ) ; $ this -> set_url ( ) ; if ( isset ( $ SESSION -> wikipreviousurl ) && is_array ( $ SESSION -> wikipreviousurl ) ) { $ this -> process_session_url ( ) ; } $ this -> set_session_ur...
This method prints the top of the page .
29,478
protected function setup_tabs ( $ options = array ( ) ) { global $ CFG , $ PAGE ; $ groupmode = groups_get_activity_groupmode ( $ this -> cm ) ; if ( empty ( $ CFG -> usecomments ) || ! has_capability ( 'mod/wiki:viewcomment' , $ PAGE -> context ) ) { unset ( $ this -> tabs [ 'comments' ] ) ; } if ( ! has_capability ( ...
Setup page tabs if options is empty will set up active tab automatically
29,479
function set_page ( $ page ) { global $ PAGE ; $ this -> page = $ page ; $ this -> title = $ page -> title ; $ PAGE -> set_title ( $ this -> title ) ; }
Method to set the current page
29,480
function set_title ( $ title ) { global $ PAGE ; $ this -> page = null ; $ this -> title = $ title ; $ PAGE -> set_title ( $ this -> title ) ; }
Method to set the current page title . This method must be called when the current page is not created yet .
29,481
protected function create_navbar ( ) { global $ PAGE , $ CFG ; $ PAGE -> navbar -> add ( format_string ( $ this -> title ) , $ CFG -> wwwroot . '/mod/wiki/view.php?pageid=' . $ this -> page -> id ) ; }
Protected method to create the common items of the navbar in every page type .
29,482
private function print_diff_content ( ) { global $ CFG , $ OUTPUT , $ PAGE ; $ pageid = $ this -> page -> id ; $ total = wiki_count_wiki_page_versions ( $ pageid ) - 1 ; $ oldversion = wiki_get_wiki_page_version ( $ pageid , $ this -> compare ) ; $ newversion = wiki_get_wiki_page_version ( $ pageid , $ this -> comparew...
Given two versions of a page prints a page displaying the differences between them .
29,483
private function choose_from_radio ( $ options , $ name , $ onclick = '' , $ checked = '' , $ return = false ) { static $ idcounter = 0 ; if ( ! $ name ) { $ name = 'unnamed' ; } $ output = '<span class="radiogroup ' . $ name . "\">\n" ; if ( ! empty ( $ options ) ) { $ currentradio = 0 ; foreach ( $ options as $ value...
Given an array of values creates a group of radio buttons to be part of a form
29,484
private function print_contributions_content ( ) { global $ CFG , $ OUTPUT , $ USER ; $ page = $ this -> page ; if ( $ page -> timerendered + WIKI_REFRESH_CACHE_TIME < time ( ) ) { $ fresh = wiki_refresh_cachedcontent ( $ page ) ; $ page = $ fresh [ 'page' ] ; } $ swid = $ this -> subwiki -> id ; $ table = new html_tab...
Prints the contributions tab content
29,485
private function print_navigation_content ( ) { global $ OUTPUT ; $ page = $ this -> page ; if ( $ page -> timerendered + WIKI_REFRESH_CACHE_TIME < time ( ) ) { $ fresh = wiki_refresh_cachedcontent ( $ page ) ; $ page = $ fresh [ 'page' ] ; } $ tolinks = wiki_get_linked_to_pages ( $ page -> id ) ; $ fromlinks = wiki_ge...
Prints the navigation tab content
29,486
private function print_index_content ( ) { global $ OUTPUT ; $ page = $ this -> page ; if ( $ page -> timerendered + WIKI_REFRESH_CACHE_TIME < time ( ) ) { $ fresh = wiki_refresh_cachedcontent ( $ page ) ; $ page = $ fresh [ 'page' ] ; } $ node = new navigation_node ( $ page -> title ) ; $ keys = array ( ) ; $ tree = a...
Prints the index page tab content
29,487
private function print_page_list_content ( ) { global $ OUTPUT ; $ page = $ this -> page ; if ( $ page -> timerendered + WIKI_REFRESH_CACHE_TIME < time ( ) ) { $ fresh = wiki_refresh_cachedcontent ( $ page ) ; $ page = $ fresh [ 'page' ] ; } $ pages = wiki_get_page_list ( $ this -> subwiki -> id ) ; $ stdaux = new stdC...
Prints the page list tab content
29,488
private function print_orphaned_content ( ) { global $ OUTPUT ; $ page = $ this -> page ; if ( $ page -> timerendered + WIKI_REFRESH_CACHE_TIME < time ( ) ) { $ fresh = wiki_refresh_cachedcontent ( $ page ) ; $ page = $ fresh [ 'page' ] ; } $ swid = $ this -> subwiki -> id ; $ table = new html_table ( ) ; $ table -> he...
Prints the orphaned tab content
29,489
private function print_updated_content ( ) { global $ COURSE , $ OUTPUT ; $ page = $ this -> page ; if ( $ page -> timerendered + WIKI_REFRESH_CACHE_TIME < time ( ) ) { $ fresh = wiki_refresh_cachedcontent ( $ page ) ; $ page = $ fresh [ 'page' ] ; } $ swid = $ this -> subwiki -> id ; $ table = new html_table ( ) ; $ t...
Prints the updated tab content
29,490
private function print_restoreversion ( ) { global $ OUTPUT ; $ version = wiki_get_version ( $ this -> version -> id ) ; $ optionsyes = array ( 'confirm' => 1 , 'pageid' => $ this -> page -> id , 'versionid' => $ version -> id , 'sesskey' => sesskey ( ) ) ; $ restoreurl = new moodle_url ( '/mod/wiki/restoreversion.php'...
Prints the restore version content
29,491
private function printconfirmdelete ( ) { global $ OUTPUT ; $ strdeletecheck = get_string ( 'deletecommentcheck' , 'wiki' ) ; $ strdeletecheckfull = get_string ( 'deletecommentcheckfull' , 'wiki' ) ; $ optionsyes = array ( 'confirm' => 1 , 'pageid' => $ this -> page -> id , 'action' => 'delete' , 'commentid' => $ this ...
Prints the comment deletion confirmation form
29,492
private function print_version_view ( ) { global $ CFG , $ OUTPUT , $ PAGE ; $ pageversion = wiki_get_version ( $ this -> version -> id ) ; if ( $ pageversion ) { $ restorelink = new moodle_url ( '/mod/wiki/restoreversion.php' , array ( 'pageid' => $ this -> page -> id , 'versionid' => $ this -> version -> id ) ) ; ech...
Given an old page version output the version content
29,493
function print_content ( ) { require_capability ( 'mod/wiki:managewiki' , $ this -> modcontext , NULL , true , 'noviewpagepermission' , 'wiki' ) ; $ page = $ this -> page ; if ( $ page -> timerendered + WIKI_REFRESH_CACHE_TIME < time ( ) ) { $ fresh = wiki_refresh_cachedcontent ( $ page ) ; $ page = $ fresh [ 'page' ] ...
This function will display administration view to users with managewiki capability
29,494
public function set_view ( $ view , $ listorphan = true ) { $ this -> view = $ view ; $ this -> listorphan = $ listorphan ; }
Sets admin view option
29,495
protected function print_delete_content ( $ showorphan = true ) { $ contents = array ( ) ; $ table = new html_table ( ) ; $ table -> head = array ( '' , get_string ( 'pagename' , 'wiki' ) ) ; $ table -> attributes [ 'class' ] = 'table generaltable' ; $ swid = $ this -> subwiki -> id ; if ( $ showorphan ) { if ( $ orpha...
Show wiki page delete options
29,496
protected function add_page_delete_options ( $ pages , $ swid , & $ table ) { global $ OUTPUT ; foreach ( $ pages as $ page ) { $ link = wiki_parser_link ( $ page -> title , array ( 'swid' => $ swid ) ) ; $ class = ( $ link [ 'new' ] ) ? 'class="wiki_newentry"' : '' ; $ pagelink = '<a href="' . $ link [ 'url' ] . '"' ....
helper function for print_delete_content . This will add data to the table .
29,497
public static function update_activity_completion_status_manually ( $ cmid , $ completed ) { $ params = self :: validate_parameters ( self :: update_activity_completion_status_manually_parameters ( ) , array ( 'cmid' => $ cmid , 'completed' => $ completed ) ) ; $ cmid = $ params [ 'cmid' ] ; $ completed = $ params [ 'c...
Update completion status for the current user in an activity only for activities with manual tracking .
29,498
public static function override_activity_completion_status ( $ userid , $ cmid , $ newstate ) { $ params = self :: validate_parameters ( self :: override_activity_completion_status_parameters ( ) , array ( 'userid' => $ userid , 'cmid' => $ cmid , 'newstate' => $ newstate ) ) ; $ userid = $ params [ 'userid' ] ; $ cmid...
Update completion status for a user in an activity .
29,499
public static function override_activity_completion_status_returns ( ) { return new external_single_structure ( array ( 'cmid' => new external_value ( PARAM_INT , 'The course module id' ) , 'userid' => new external_value ( PARAM_INT , 'The user id to which the completion info belongs' ) , 'state' => new external_value ...
Describes the override_activity_completion_status return value .