idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
34,900
public static function move_category ( int $ id , int $ beforeid ) { $ params = self :: validate_parameters ( self :: move_category_parameters ( ) , [ 'id' => $ id , 'beforeid' => $ beforeid ] ) ; $ category = core_customfield \ category_controller :: create ( $ id ) ; $ handler = $ category -> get_handler ( ) ; self :...
Reorder categories . Move category to the new position
34,901
public function update_definition ( stdClass $ newdefinition , $ usermodified = null ) { $ this -> update_or_check_rubric ( $ newdefinition , $ usermodified , true ) ; if ( isset ( $ newdefinition -> rubric [ 'regrade' ] ) && $ newdefinition -> rubric [ 'regrade' ] ) { $ this -> mark_for_regrade ( ) ; } }
Saves the rubric definition into the database
34,902
protected function load_definition ( ) { global $ DB ; $ sql = "SELECT gd.*, rc.id AS rcid, rc.sortorder AS rcsortorder, rc.description AS rcdescription, rc.descriptionformat AS rcdescriptionformat, rl.id AS rlid, rl.score AS rlscore, rl.definition AS rldefinition, rl.definit...
Loads the rubric form definition if it exists
34,903
public function get_options ( ) { $ options = self :: get_default_options ( ) ; if ( ! empty ( $ this -> definition -> options ) ) { $ thisoptions = json_decode ( $ this -> definition -> options ) ; foreach ( $ thisoptions as $ option => $ value ) { $ options [ $ option ] = $ value ; } if ( ! array_key_exists ( 'lockze...
Gets the options of this rubric definition fills the missing options with default values
34,904
public function clear_attempt ( $ data ) { global $ DB ; foreach ( $ data [ 'criteria' ] as $ criterionid => $ record ) { $ DB -> delete_records ( 'gradingform_rubric_fillings' , array ( 'criterionid' => $ criterionid , 'instanceid' => $ this -> get_id ( ) ) ) ; } }
Removes the attempt from the gradingform_guide_fillings table
34,905
public function validate_grading_element ( $ elementvalue ) { $ criteria = $ this -> get_controller ( ) -> get_definition ( ) -> rubric_criteria ; if ( ! isset ( $ elementvalue [ 'criteria' ] ) || ! is_array ( $ elementvalue [ 'criteria' ] ) || sizeof ( $ elementvalue [ 'criteria' ] ) < sizeof ( $ criteria ) ) { return...
Validates that rubric is fully completed and contains valid grade on each criterion
34,906
public function get_rubric_filling ( $ force = false ) { global $ DB ; if ( $ this -> rubric === null || $ force ) { $ records = $ DB -> get_records ( 'gradingform_rubric_fillings' , array ( 'instanceid' => $ this -> get_id ( ) ) ) ; $ this -> rubric = array ( 'criteria' => array ( ) ) ; foreach ( $ records as $ record...
Retrieves from DB and returns the data how this rubric was filled
34,907
private function get_completion_detail ( $ mod ) { global $ OUTPUT ; $ strings = [ ] ; switch ( $ mod -> completion ) { case COMPLETION_TRACKING_NONE : $ strings [ 'string' ] = get_string ( 'none' ) ; break ; case COMPLETION_TRACKING_MANUAL : $ strings [ 'string' ] = get_string ( 'manual' , 'completion' ) ; $ strings [...
Get completion information on the selected module or module type
34,908
protected function get_completion_active_rule_descriptions ( $ moduledata ) { $ activeruledescriptions = [ ] ; if ( $ moduledata -> completion == COMPLETION_TRACKING_AUTOMATIC ) { if ( ! empty ( $ moduledata -> completionview ) ) { $ activeruledescriptions [ ] = get_string ( 'completionview_desc' , 'completion' ) ; } i...
Get the descriptions for all active conditional completion rules for the current module .
34,909
public function get_activities_and_resources ( ) { global $ DB , $ OUTPUT , $ CFG ; require_once ( $ CFG -> dirroot . '/course/lib.php' ) ; $ modules = $ DB -> get_records ( 'modules' , [ 'visible' => 1 ] , 'name ASC' ) ; $ data = new stdClass ( ) ; $ data -> courseid = $ this -> courseid ; $ data -> sesskey = sesskey ...
Gets the course modules for the current course .
34,910
public static function can_edit_bulk_completion ( $ courseorid , $ cm = null ) { if ( $ cm ) { return $ cm -> uservisible && has_capability ( 'moodle/course:manageactivities' , $ cm -> context ) ; } $ coursecontext = context_course :: instance ( is_object ( $ courseorid ) ? $ courseorid -> id : $ courseorid ) ; if ( ha...
Checks if current user can edit activity completion
34,911
public static function get_available_completion_tabs ( $ courseorid ) { $ tabs = [ ] ; $ courseid = is_object ( $ courseorid ) ? $ courseorid -> id : $ courseorid ; $ coursecontext = context_course :: instance ( $ courseid ) ; if ( has_capability ( 'moodle/course:update' , $ coursecontext ) ) { $ tabs [ ] = new tabobje...
Gets the available completion tabs for the current course and user .
34,912
public function apply_completion ( $ data , $ updateinstances ) { $ updated = false ; $ needreset = [ ] ; $ modinfo = get_fast_modinfo ( $ this -> courseid ) ; $ cmids = $ data -> cmid ; $ data = ( array ) $ data ; unset ( $ data [ 'id' ] ) ; unset ( $ data [ 'cmid' ] ) ; unset ( $ data [ 'submitbutton' ] ) ; foreach (...
Applies completion from the bulk edit form to all selected modules
34,913
protected function apply_completion_cm ( \ cm_info $ cm , $ data , $ updateinstance ) { global $ DB ; $ defaults = [ 'completion' => COMPLETION_DISABLED , 'completionview' => COMPLETION_VIEW_NOT_REQUIRED , 'completionexpected' => 0 , 'completiongradeitemnumber' => null ] ; $ data += [ 'completion' => $ cm -> completion...
Applies new completion rules to one course module
34,914
public function apply_default_completion ( $ data , $ updatecustomrules ) { global $ DB ; $ courseid = $ data -> id ; $ coursecontext = context_course :: instance ( $ courseid ) ; if ( ! $ modids = $ data -> modids ) { return ; } $ defaults = [ 'completion' => COMPLETION_DISABLED , 'completionview' => COMPLETION_VIEW_N...
Saves default completion from edit form to all selected module types
34,915
public static function get_default_completion ( $ course , $ module , $ flatten = true ) { global $ DB , $ CFG ; if ( $ data = $ DB -> get_record ( 'course_completion_defaults' , [ 'course' => $ course -> id , 'module' => $ module -> id ] , 'completion, completionview, completionexpected, completionusegrade, customrule...
Returns default completion rules for given module type in the given course
34,916
public function process_assignfeedback_comments_grade ( $ data ) { global $ DB ; $ data = ( object ) $ data ; $ data -> assignment = $ this -> get_new_parentid ( 'assign' ) ; $ oldgradeid = $ data -> grade ; $ data -> grade = $ this -> get_mappingid ( 'grade' , $ data -> grade ) ; $ DB -> insert_record ( 'assignfeedbac...
Processes one feedback_comments element .
34,917
public function setUrl ( $ url ) { if ( $ this -> hasBeenSent ( ) ) { throw new CAS_OutOfSequenceException ( 'Cannot set the URL, request already sent.' ) ; } if ( ! is_string ( $ url ) ) { throw new CAS_InvalidArgumentException ( '$url must be a string.' ) ; } $ this -> _url = $ url ; }
Set the URL of the Request
34,918
protected function makeRequest ( $ url ) { $ this -> _numRequests ++ ; if ( $ this -> _numRequests > 4 ) { $ message = 'Exceeded the maximum number of redirects (3) in proxied service request.' ; phpCAS :: trace ( $ message ) ; throw new CAS_ProxiedService_Exception ( $ message ) ; } $ request = clone $ this -> request...
Build and perform a request following redirects
34,919
protected function getRedirectUrl ( array $ responseHeaders ) { foreach ( $ responseHeaders as $ header ) { if ( preg_match ( '/^(Location:|URI:)\s*([^\s]+.*)$/' , $ header , $ matches ) ) { return trim ( array_pop ( $ matches ) ) ; } } return null ; }
Answer a redirect URL if a redirect header is found otherwise null .
34,920
protected function magic_get_blockmanipulations ( ) { if ( ! right_to_left ( ) ) { return false ; } if ( is_null ( $ this -> _theme ) ) { $ this -> initialise_theme_and_output ( ) ; } return $ this -> _theme -> blockrtlmanipulations ; }
Returns an array of minipulations or false if there are none to make .
34,921
protected function magic_get_navigation ( ) { if ( $ this -> _navigation === null ) { $ this -> _navigation = new global_navigation ( $ this ) ; } return $ this -> _navigation ; }
Return the navigation object
34,922
protected function magic_get_navbar ( ) { if ( $ this -> _navbar === null ) { $ this -> _navbar = new navbar ( $ this ) ; } return $ this -> _navbar ; }
Return a navbar object
34,923
protected function magic_get_settingsnav ( ) { if ( $ this -> _settingsnav === null ) { $ this -> _settingsnav = new settings_navigation ( $ this ) ; $ this -> _settingsnav -> initialise ( ) ; } return $ this -> _settingsnav ; }
Returns the settings navigation object
34,924
protected function magic_get_flatnav ( ) { if ( $ this -> _flatnav === null ) { $ this -> _flatnav = new flat_navigation ( $ this ) ; $ this -> _flatnav -> initialise ( ) ; } return $ this -> _flatnav ; }
Returns the flat navigation object
34,925
public function get_renderer ( $ component , $ subtype = null , $ target = null ) { if ( $ this -> pagelayout === 'maintenance' ) { $ target = RENDERER_TARGET_MAINTENANCE ; } return $ this -> magic_get_theme ( ) -> get_renderer ( $ this , $ component , $ subtype , $ target ) ; }
Returns instance of page renderer
34,926
public function has_navbar ( ) { if ( $ this -> _navbar === null ) { $ this -> _navbar = new navbar ( $ this ) ; } return $ this -> _navbar -> has_items ( ) ; }
Checks to see if there are any items on the navbar object
34,927
public function end_collecting_javascript_requirements ( ) { if ( $ this -> savedrequires === null ) { throw new coding_exception ( 'JavaScript collection has not been started.' ) ; } $ this -> _requires = $ this -> savedrequires ; $ this -> savedrequires = null ; }
Switches back from collecting fragment JS requirement to the original requirement manager
34,928
public function debug_summary ( ) { $ summary = '' ; $ summary .= 'General type: ' . $ this -> pagelayout . '. ' ; if ( ! during_initial_install ( ) ) { $ summary .= 'Context ' . $ this -> context -> get_context_name ( ) . ' (context id ' . $ this -> _context -> id . '). ' ; } $ summary .= 'Page type ' . $ this -> page...
Get a description of this page . Normally displayed in the footer in developer debug mode .
34,929
public function set_state ( $ state ) { if ( $ state != $ this -> _state + 1 || $ state > self :: STATE_DONE ) { throw new coding_exception ( 'Invalid state passed to moodle_page::set_state. We are in state ' . $ this -> _state . ' and state ' . $ state . ' was requested.' ) ; } if ( $ state == self :: STATE_PRINTING_H...
Set the state .
34,930
public function set_context ( $ context ) { if ( $ context === null ) { if ( ! $ this -> _context ) { $ this -> _context = context_system :: instance ( ) ; } return ; } if ( isset ( $ this -> _context ) && $ context -> id !== $ this -> _context -> id ) { $ current = $ this -> _context -> contextlevel ; if ( $ current =...
Set the main context to which this page belongs .
34,931
public function set_pagelayout ( $ pagelayout ) { global $ SESSION ; if ( ! empty ( $ SESSION -> forcepagelayout ) ) { $ this -> _pagelayout = $ SESSION -> forcepagelayout ; } else { $ this -> _pagelayout = $ pagelayout ; } }
Sets the layout to use for this page .
34,932
public function set_title ( $ title ) { $ title = format_string ( $ title ) ; $ title = strip_tags ( $ title ) ; $ title = str_replace ( '"' , '&quot;' , $ title ) ; $ this -> _title = $ title ; }
Sets the title for the page . This is normally used within the title tag in the head of the page .
34,933
public function set_category_by_id ( $ categoryid ) { global $ SITE ; if ( ! is_null ( $ this -> _course ) ) { throw new coding_exception ( 'Course has already been set. You cannot change the category now.' ) ; } if ( is_array ( $ this -> _categories ) ) { throw new coding_exception ( 'Course category has already been ...
Set the course category this page belongs to manually .
34,934
public function set_url ( $ url , array $ params = null ) { global $ CFG ; if ( is_string ( $ url ) && strpos ( $ url , 'http' ) !== 0 ) { if ( strpos ( $ url , '/' ) === 0 ) { $ url = $ CFG -> wwwroot . $ url ; } else { throw new coding_exception ( 'Invalid parameter $url, has to be full url or in shortened form start...
You should call this method from every page to set the URL that should be used to return to this page .
34,935
public function add_alternate_version ( $ title , $ url , $ mimetype ) { if ( $ this -> _state > self :: STATE_BEFORE_HEADER ) { throw new coding_exception ( 'Cannot call moodle_page::add_alternate_version after output has been started.' ) ; } $ alt = new stdClass ; $ alt -> title = $ title ; $ alt -> url = $ url ; $ t...
Sets an alternative version of this page .
34,936
public function set_other_editing_capability ( $ capability ) { if ( is_array ( $ capability ) ) { $ this -> _othereditingcaps = array_unique ( $ this -> _othereditingcaps + $ capability ) ; } else { $ this -> _othereditingcaps [ ] = $ capability ; } }
Some pages let you turn editing on for reasons other than editing blocks . If that is the case you can pass other capabilities that let the user edit this page here .
34,937
public function set_periodic_refresh_delay ( $ delay = null ) { if ( $ this -> _state > self :: STATE_BEFORE_HEADER ) { throw new coding_exception ( 'You cannot set a periodic refresh delay after the header has been printed' ) ; } if ( $ delay === null ) { $ this -> _periodicrefreshdelay = null ; } else if ( is_int ( $...
Sets the page to periodically refresh
34,938
public function reload_theme ( ) { if ( ! is_null ( $ this -> _theme ) ) { $ this -> _theme = theme_config :: load ( $ this -> _theme -> name ) ; } }
Reload theme settings .
34,939
protected function starting_output ( ) { global $ CFG ; if ( ! during_initial_install ( ) ) { $ this -> blocks -> load_blocks ( ) ; if ( empty ( $ this -> _block_actions_done ) ) { $ this -> _block_actions_done = true ; if ( $ this -> blocks -> process_url_actions ( $ this ) ) { redirect ( $ this -> url -> out ( false ...
This method is called when the page first moves out of the STATE_BEFORE_HEADER state . This is our last change to initialise things .
34,940
public function initialise_theme_and_output ( ) { global $ OUTPUT , $ PAGE , $ SITE , $ CFG ; if ( ! empty ( $ this -> _wherethemewasinitialised ) ) { return ; } if ( ! during_initial_install ( ) ) { $ this -> magic_get_context ( ) ; } if ( ! $ this -> _course && ! during_initial_install ( ) ) { $ this -> set_course ( ...
Method for use by Moodle core to set up the theme . Do not use this in your own code .
34,941
protected function resolve_theme ( ) { global $ CFG , $ USER , $ SESSION ; if ( empty ( $ CFG -> themeorder ) ) { $ themeorder = array ( 'course' , 'category' , 'session' , 'user' , 'cohort' , 'site' ) ; } else { $ themeorder = $ CFG -> themeorder ; $ themeorder [ ] = 'site' ; } $ mnetpeertheme = '' ; if ( isloggedin (...
Work out the theme this page should use .
34,942
protected function load_activity_record ( ) { global $ DB ; if ( is_null ( $ this -> _cm ) ) { return ; } $ this -> _module = $ DB -> get_record ( $ this -> _cm -> modname , array ( 'id' => $ this -> _cm -> instance ) ) ; }
Loads the activity record for the current CM object associated with this page .
34,943
protected function ensure_category_loaded ( ) { if ( is_array ( $ this -> _categories ) ) { return ; } if ( is_null ( $ this -> _course ) ) { throw new coding_exception ( 'Attempt to get the course category for this page before the course was set.' ) ; } if ( $ this -> _course -> category == 0 ) { $ this -> _categories...
This function ensures that the category of the current course has been loaded and if not the function loads it now .
34,944
protected function load_category ( $ categoryid ) { global $ DB ; $ category = $ DB -> get_record ( 'course_categories' , array ( 'id' => $ categoryid ) ) ; if ( ! $ category ) { throw new moodle_exception ( 'unknowncategory' ) ; } $ this -> _categories [ $ category -> id ] = $ category ; $ parentcategoryids = explode ...
Loads the requested category into the pages categories array .
34,945
protected function ensure_categories_loaded ( ) { global $ DB ; $ this -> ensure_category_loaded ( ) ; if ( ! is_null ( end ( $ this -> _categories ) ) ) { return ; } $ idstoload = array_keys ( $ this -> _categories ) ; array_shift ( $ idstoload ) ; $ categories = $ DB -> get_records_list ( 'course_categories' , 'id' ,...
Ensures that the category the current course is within as well as all of its parent categories have been loaded .
34,946
protected function url_to_class_name ( $ url ) { $ bits = parse_url ( $ url ) ; $ class = str_replace ( '.' , '-' , $ bits [ 'host' ] ) ; if ( ! empty ( $ bits [ 'port' ] ) ) { $ class .= '--' . $ bits [ 'port' ] ; } if ( ! empty ( $ bits [ 'path' ] ) ) { $ path = trim ( $ bits [ 'path' ] , '/' ) ; if ( $ path ) { $ cl...
Converts the provided URL into a CSS class that be used within the page . This is primarily used to add the wwwroot to the body tag as a CSS class .
34,947
public function apply_theme_region_manipulations ( $ region ) { if ( $ this -> blockmanipulations && isset ( $ this -> blockmanipulations [ $ region ] ) ) { $ regionwas = $ region ; $ regionnow = $ this -> blockmanipulations [ $ region ] ; if ( $ this -> blocks -> is_known_region ( $ regionwas ) && $ this -> blocks -> ...
Returns the block region having made any required theme manipulations .
34,948
public function add_report_nodes ( $ userid , $ nodeinfo ) { global $ USER ; $ newusernode = $ this -> navigation -> find ( 'user' . $ userid , null ) ; $ reportnode = null ; $ navigationnodeerror = 'Could not find the navigation node requested. Please check that the node you are looking for exists.' ; if ( $ userid !=...
Add a report node and a specific report to the navigation .
34,949
public function setPartials ( array $ partials = array ( ) ) { if ( ! isset ( $ this -> partialsLoader ) ) { $ this -> partialsLoader = new Mustache_Loader_ArrayLoader ( ) ; } if ( ! $ this -> partialsLoader instanceof Mustache_Loader_MutableLoader ) { throw new Mustache_Exception_RuntimeException ( 'Unable to set part...
Set partials for the current partials Loader instance .
34,950
public function setHelpers ( $ helpers ) { if ( ! is_array ( $ helpers ) && ! $ helpers instanceof Traversable ) { throw new Mustache_Exception_InvalidArgumentException ( 'setHelpers expects an array of helpers' ) ; } $ this -> getHelpers ( ) -> clear ( ) ; foreach ( $ helpers as $ name => $ helper ) { $ this -> addHel...
Set an array of Mustache helpers .
34,951
public function setLogger ( $ logger = null ) { if ( $ logger !== null && ! ( $ logger instanceof Mustache_Logger || is_a ( $ logger , 'Psr\\Log\\LoggerInterface' ) ) ) { throw new Mustache_Exception_InvalidArgumentException ( 'Expected an instance of Mustache_Logger or Psr\\Log\\LoggerInterface.' ) ; } if ( $ this -> ...
Set the Mustache Logger instance .
34,952
public function setCache ( Mustache_Cache $ cache ) { if ( isset ( $ this -> logger ) && $ cache -> getLogger ( ) === null ) { $ cache -> setLogger ( $ this -> getLogger ( ) ) ; } $ this -> cache = $ cache ; }
Set the Mustache Cache instance .
34,953
protected function getLambdaCache ( ) { if ( $ this -> cacheLambdaTemplates ) { return $ this -> getCache ( ) ; } if ( ! isset ( $ this -> lambdaCache ) ) { $ this -> lambdaCache = new Mustache_Cache_NoopCache ( ) ; } return $ this -> lambdaCache ; }
Get the current Lambda Cache instance .
34,954
public function getTemplateClassName ( $ source ) { $ chunks = array ( 'charset' => $ this -> charset , 'delimiters' => $ this -> delimiters ? $ this -> delimiters : '{{ }}' , 'entityFlags' => $ this -> entityFlags , 'escape' => isset ( $ this -> escape ) ? 'custom' : 'default' , 'key' => ( $ source instanceof Mustache...
Helper method to generate a Mustache template class .
34,955
public function loadPartial ( $ name ) { try { if ( isset ( $ this -> partialsLoader ) ) { $ loader = $ this -> partialsLoader ; } elseif ( isset ( $ this -> loader ) && ! $ this -> loader instanceof Mustache_Loader_StringLoader ) { $ loader = $ this -> loader ; } else { throw new Mustache_Exception_UnknownTemplateExce...
Load a Mustache partial Template by name .
34,956
public function loadLambda ( $ source , $ delims = null ) { if ( $ delims !== null ) { $ source = $ delims . "\n" . $ source ; } return $ this -> loadSource ( $ source , $ this -> getLambdaCache ( ) ) ; }
Load a Mustache lambda Template by source .
34,957
private function loadSource ( $ source , Mustache_Cache $ cache = null ) { $ className = $ this -> getTemplateClassName ( $ source ) ; if ( ! isset ( $ this -> templates [ $ className ] ) ) { if ( $ cache === null ) { $ cache = $ this -> getCache ( ) ; } if ( ! class_exists ( $ className , false ) ) { if ( ! $ cache ->...
Instantiate and return a Mustache Template instance by source .
34,958
private function parse ( $ source ) { $ parser = $ this -> getParser ( ) ; $ parser -> setPragmas ( $ this -> getPragmas ( ) ) ; return $ parser -> parse ( $ this -> tokenize ( $ source ) ) ; }
Helper method to parse a Mustache template .
34,959
private function compile ( $ source ) { $ name = $ this -> getTemplateClassName ( $ source ) ; $ this -> log ( Mustache_Logger :: INFO , 'Compiling template to "{className}" class' , array ( 'className' => $ name ) ) ; if ( $ source instanceof Mustache_Source ) { $ source = $ source -> getSource ( ) ; } $ tree = $ this...
Helper method to compile a Mustache template .
34,960
private function log ( $ level , $ message , array $ context = array ( ) ) { if ( isset ( $ this -> logger ) ) { $ this -> logger -> log ( $ level , $ message , $ context ) ; } }
Add a log record if logging is enabled .
34,961
protected function get_course ( $ data ) { $ importoptions = array ( 'candelete' => $ this -> allowdeletes , 'canrename' => $ this -> allowrenames , 'canreset' => $ this -> allowresets , 'reset' => $ this -> reset , 'restoredir' => $ this -> get_restore_content_dir ( ) , 'shortnametemplate' => $ this -> shortnametempla...
Return a course import object .
34,962
protected function log_error ( $ errors ) { if ( empty ( $ errors ) ) { return ; } foreach ( $ errors as $ code => $ langstring ) { if ( ! isset ( $ this -> errors [ $ this -> linenb ] ) ) { $ this -> errors [ $ this -> linenb ] = array ( ) ; } $ this -> errors [ $ this -> linenb ] [ $ code ] = $ langstring ; } }
Log errors on the current line .
34,963
public function preview ( $ rows = 10 , $ tracker = null ) { if ( $ this -> processstarted ) { throw new coding_exception ( 'Process has already been started' ) ; } $ this -> processstarted = true ; if ( empty ( $ tracker ) ) { $ tracker = new tool_uploadcourse_tracker ( tool_uploadcourse_tracker :: NO_OUTPUT ) ; } $ t...
Return a preview of the import .
34,964
public function reset ( ) { $ this -> processstarted = false ; $ this -> linenb = 0 ; $ this -> cir -> init ( ) ; $ this -> errors = array ( ) ; }
Reset the current process .
34,965
public static function get_areas ( $ tagcollid = null , $ enabledonly = false ) { global $ DB ; $ cache = cache :: make ( 'core' , 'tags' ) ; if ( ( $ itemtypes = $ cache -> get ( 'tag_area' ) ) === false ) { $ colls = core_tag_collection :: get_collections ( ) ; $ defaultcoll = reset ( $ colls ) ; $ itemtypes = array ...
Returns the list of areas indexed by itemtype and component
34,966
public static function get_by_id ( $ tagareaid ) { $ tagareas = self :: get_areas ( ) ; foreach ( $ tagareas as $ itemtype => $ it ) { foreach ( $ it as $ component => $ v ) { if ( $ v -> id == $ tagareaid ) { return $ v ; } } } return null ; }
Retrieves info about one tag area
34,967
public static function display_name ( $ component , $ itemtype ) { $ identifier = 'tagarea_' . clean_param ( $ itemtype , PARAM_STRINGID ) ; if ( $ component === 'core' ) { $ component = 'tag' ; } return new lang_string ( $ identifier , $ component ) ; }
Returns the display name for this area
34,968
public static function is_enabled ( $ component , $ itemtype ) { global $ CFG ; if ( empty ( $ CFG -> usetags ) ) { return false ; } $ itemtypes = self :: get_areas ( ) ; if ( isset ( $ itemtypes [ $ itemtype ] [ $ component ] ) ) { return $ itemtypes [ $ itemtype ] [ $ component ] -> enabled ? true : false ; } return ...
Returns whether the tag area is enabled
34,969
public static function allows_tagging_in_multiple_contexts ( $ component , $ itemtype ) { $ itemtypes = self :: get_areas ( ) ; if ( isset ( $ itemtypes [ $ itemtype ] [ $ component ] ) ) { $ config = $ itemtypes [ $ itemtype ] [ $ component ] ; return isset ( $ config -> multiplecontexts ) ? $ config -> multiplecontex...
Checks if the tag area allows items to be tagged in multiple different contexts .
34,970
public static function get_collection ( $ component , $ itemtype ) { $ itemtypes = self :: get_areas ( ) ; if ( array_key_exists ( $ itemtype , $ itemtypes ) ) { if ( ! array_key_exists ( $ component , $ itemtypes [ $ itemtype ] ) ) { $ component = key ( $ itemtypes [ $ itemtype ] ) ; } return $ itemtypes [ $ itemtype ...
Returns the id of the tag collection that should be used for storing tags of this itemtype
34,971
public static function get_showstandard ( $ component , $ itemtype ) { $ itemtypes = self :: get_areas ( ) ; if ( array_key_exists ( $ itemtype , $ itemtypes ) ) { if ( ! array_key_exists ( $ component , $ itemtypes [ $ itemtype ] ) ) { $ component = key ( $ itemtypes [ $ itemtype ] ) ; } return $ itemtypes [ $ itemtyp...
Returns wether this tag area should display or not standard tags when user edits it .
34,972
protected static function get_definitions_for_component ( $ componentname ) { global $ DB ; list ( $ a , $ b ) = core_component :: normalize_component ( $ componentname ) ; $ component = $ b ? ( $ a . '_' . $ b ) : $ a ; $ sql = 'component = :component' ; $ params = array ( 'component' => $ component ) ; if ( $ compone...
Returns all tag areas and collections that are currently cached in DB for this component
34,973
protected static function delete ( $ record ) { global $ DB ; core_tag_tag :: delete_instances ( $ record -> component , $ record -> itemtype ) ; $ DB -> delete_records ( 'tag_area' , array ( 'itemtype' => $ record -> itemtype , 'component' => $ record -> component ) ) ; cache :: make ( 'core' , 'tags' ) -> delete ( 't...
Completely delete a tag area and all instances inside it
34,974
protected static function create ( $ record ) { global $ DB ; if ( empty ( $ record -> tagcollid ) ) { $ record -> tagcollid = core_tag_collection :: get_default ( ) ; } $ DB -> insert_record ( 'tag_area' , array ( 'component' => $ record -> component , 'itemtype' => $ record -> itemtype , 'tagcollid' => $ record -> ta...
Create a new tag area
34,975
public static function update ( $ existing , $ data ) { global $ DB ; $ data = array_intersect_key ( ( array ) $ data , array ( 'enabled' => 1 , 'tagcollid' => 1 , 'callback' => 1 , 'callbackfile' => 1 , 'showstandard' => 1 , 'multiplecontexts' => 1 ) ) ; foreach ( $ data as $ key => $ value ) { if ( $ existing -> $ ke...
Update the tag area
34,976
public static function uninstall ( $ pluginname ) { global $ DB ; list ( $ a , $ b ) = core_component :: normalize_component ( $ pluginname ) ; if ( empty ( $ b ) || $ a === 'core' ) { throw new coding_exception ( 'Core component can not be uninstalled' ) ; } $ component = $ a . '_' . $ b ; core_tag_tag :: delete_insta...
Deletes all tag areas collections and instances associated with the plugin .
34,977
public static function change_encoding ( $ data , $ input , $ output ) { $ input = SimplePie_Misc :: encoding ( $ input ) ; $ output = SimplePie_Misc :: encoding ( $ output ) ; if ( $ input === 'US-ASCII' ) { static $ non_ascii_octects = '' ; if ( ! $ non_ascii_octects ) { for ( $ i = 0x80 ; $ i <= 0xFF ; $ i ++ ) { $ ...
Change a string from one encoding to another
34,978
public static function strip_comments ( $ data ) { $ output = '' ; while ( ( $ start = strpos ( $ data , '<!--' ) ) !== false ) { $ output .= substr ( $ data , 0 , $ start ) ; if ( ( $ end = strpos ( $ data , ' , $ start ) ) !== false ) { $ data = substr_replace ( $ data , '' , 0 , $ end + 3 ) ; } else { $ data = '' ; ...
Strip HTML comments
34,979
public static function uncomment_rfc822 ( $ string ) { $ string = ( string ) $ string ; $ position = 0 ; $ length = strlen ( $ string ) ; $ depth = 0 ; $ output = '' ; while ( $ position < $ length && ( $ pos = strpos ( $ string , '(' , $ position ) ) !== false ) { $ output .= substr ( $ string , $ position , $ pos - $...
Remove RFC822 comments
34,980
public static function codepoint_to_utf8 ( $ codepoint ) { $ codepoint = ( int ) $ codepoint ; if ( $ codepoint < 0 ) { return false ; } else if ( $ codepoint <= 0x7f ) { return chr ( $ codepoint ) ; } else if ( $ codepoint <= 0x7ff ) { return chr ( 0xc0 | ( $ codepoint >> 6 ) ) . chr ( 0x80 | ( $ codepoint & 0x3f ) ) ...
Converts a unicode codepoint to a UTF - 8 character
34,981
public static function debug ( & $ sp ) { $ info = 'SimplePie ' . SIMPLEPIE_VERSION . ' Build ' . SIMPLEPIE_BUILD . "\n" ; $ info .= 'PHP ' . PHP_VERSION . "\n" ; if ( $ sp -> error ( ) !== null ) { $ info .= 'Error occurred: ' . $ sp -> error ( ) . "\n" ; } else { $ info .= "No error found.\n" ; } $ info .= "Extension...
Format debugging information
34,982
public function get_owning_activity ( ) { global $ DB ; $ result = new stdClass ( ) ; $ result -> id = 0 ; if ( empty ( $ this -> instance -> parentcontextid ) ) { return $ result ; } $ parentcontext = context :: instance_by_id ( $ this -> instance -> parentcontextid ) ; if ( $ parentcontext -> contextlevel != CONTEXT_...
If this block belongs to a activity context then return that activity s id . Otherwise return 0 .
34,983
public function instance_config_save ( $ data , $ nolongerused = false ) { global $ DB ; if ( empty ( $ data -> activitygradeitemid ) ) { $ info = $ this -> get_owning_activity ( ) ; $ data -> activitygradeitemid = $ info -> id ; if ( $ info -> id < 1 ) { $ info -> itemmodule = '' ; $ info -> iteminstance = '' ; } else...
Used to save the form config data
34,984
private function activity_format_grade ( $ grade ) { if ( is_null ( $ grade ) ) { return get_string ( 'notyetgraded' , 'block_activity_results' ) ; } return format_float ( $ grade , $ this -> config -> decimalpoints ) ; }
Formats the grade to the specified decimal points
34,985
private function activity_link ( $ activity , $ cm ) { $ o = html_writer :: start_tag ( 'h3' ) ; $ o .= html_writer :: link ( new moodle_url ( '/mod/' . $ activity -> itemmodule . '/view.php' , array ( 'id' => $ cm -> id ) ) , format_string ( ( $ activity -> itemname ) , true , [ 'context' => context_module :: instance...
Generates the Link to the activity module when displaed outside of the module
34,986
private function get_scale ( $ scaleid ) { global $ DB ; $ scaletext = $ DB -> get_field ( 'scale' , 'scale' , array ( 'id' => $ scaleid ) , IGNORE_MISSING ) ; $ scale = explode ( ',' , $ scaletext ) ; return $ scale ; }
Generates a numeric array of scale entries
34,987
public function doSettingService ( $ action , $ value = null ) { $ response = false ; $ this -> extResponse = null ; switch ( $ action ) { case self :: EXT_READ : $ do = 'basic-lti-loadsetting' ; break ; case self :: EXT_WRITE : $ do = 'basic-lti-savesetting' ; break ; case self :: EXT_DELETE : $ do = 'basic-lti-delete...
Perform a Setting service request .
34,988
public function hasMembershipService ( ) { $ has = ! empty ( $ this -> contextId ) ; if ( $ has ) { $ has = ! empty ( $ this -> getContext ( ) -> getSetting ( 'custom_context_memberships_url' ) ) ; } return $ has ; }
Check if the Membership service is supported .
34,989
public static function fromContext ( $ context , $ ltiResourceLinkId , $ tempId = null ) { $ resourceLink = new ResourceLink ( ) ; $ resourceLink -> setContextId ( $ context -> getRecordId ( ) ) ; $ resourceLink -> context = $ context ; $ resourceLink -> dataConnector = $ context -> getDataConnector ( ) ; $ resourceLin...
Class constructor from context .
34,990
public function get_start ( ) { if ( ! empty ( $ this -> start ) ) { return $ this -> start ; } $ admins = get_admins ( ) ; $ this -> start = 9999999999 ; foreach ( $ admins as $ admin ) { if ( $ admin -> firstaccess < $ this -> start ) { $ this -> start = $ admin -> firstaccess ; } } return $ this -> start ; }
Analysable start timestamp .
34,991
public function get_end ( ) { if ( ! empty ( $ this -> end ) ) { return $ this -> end ; } $ this -> end = time ( ) ; return $ this -> end ; }
Analysable end timestamp .
34,992
function _FetchField ( $ fieldOffset = - 1 ) { $ fld = new ADOFieldObject ; $ fieldOffset += 1 ; $ fld -> name = OCIcolumnname ( $ this -> _queryID , $ fieldOffset ) ; if ( ADODB_ASSOC_CASE == ADODB_ASSOC_CASE_LOWER ) { $ fld -> name = strtolower ( $ fld -> name ) ; } $ fld -> type = OCIcolumntype ( $ this -> _queryID ...
lowercase field names ...
34,993
public function get_visible_name ( $ lazyload = false ) { $ component = $ this -> componentname ; if ( $ this -> componenttype === 'core' ) { $ component = 'search' ; } return get_string ( 'search:' . $ this -> areaname , $ component , null , $ lazyload ) ; }
Returns the area visible name .
34,994
public function get_config_var_name ( ) { if ( $ this -> componenttype === 'core' ) { $ parts = \ core_search \ manager :: extract_areaid_parts ( $ this -> areaid ) ; return array ( 'core_search' , $ parts [ 0 ] . '_' . $ parts [ 1 ] ) ; } return array ( $ this -> componentname , 'search_' . $ this -> areaname ) ; }
Returns the config var name .
34,995
public function get_config ( ) { list ( $ componentname , $ varname ) = $ this -> get_config_var_name ( ) ; $ config = [ ] ; $ settingnames = self :: get_settingnames ( ) ; foreach ( $ settingnames as $ name ) { $ config [ $ varname . $ name ] = get_config ( $ componentname , $ varname . $ name ) ; } if ( $ config [ $ ...
Returns all the search area configuration .
34,996
public function is_enabled ( ) { list ( $ componentname , $ varname ) = $ this -> get_config_var_name ( ) ; $ value = get_config ( $ componentname , $ varname . '_enabled' ) ; if ( $ value === false ) { $ value = 1 ; } return ( bool ) $ value ; }
Is the search component enabled by the system administrator?
34,997
public function get_recordset_by_timestamp ( $ modifiedfrom = 0 ) { $ result = $ this -> get_document_recordset ( $ modifiedfrom ) ; if ( $ result === false ) { throw new \ coding_exception ( 'Search area must implement get_document_recordset or get_recordset_by_timestamp' ) ; } return $ result ; }
Returns a recordset ordered by modification date ASC .
34,998
protected function get_course_level_context_restriction_sql ( \ context $ context = null , $ coursetable , $ paramtype = SQL_PARAMS_QM ) { global $ DB ; if ( ! $ context ) { return [ '' , [ ] ] ; } switch ( $ paramtype ) { case SQL_PARAMS_QM : $ param1 = '?' ; $ param2 = '?' ; $ key1 = 0 ; $ key2 = 1 ; break ; case SQL...
Helper function that gets SQL useful for restricting a search query given a passed - in context for data stored at course level .
34,999
public static function export_question_usage ( int $ userid , \ context $ context , array $ usagecontext , int $ usage , \ question_display_options $ options , bool $ isowner ) { $ quba = \ question_engine :: load_questions_usage_by_activity ( $ usage ) ; $ basepath = $ usagecontext ; $ questionscontext = array_merge (...
Export the data for all question attempts on this question usage .