idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
31,400
protected function set_rules ( $ record ) { $ comp = $ record -> createdcomp ; if ( $ record -> ruletype ) { $ class = $ record -> ruletype ; if ( class_exists ( $ class ) ) { $ oldruleconfig = $ record -> ruleconfig ; if ( $ oldruleconfig == "null" ) { $ oldruleconfig = null ; } $ newruleconfig = $ class :: migrate_co...
Create any completion rule attached to this competency .
31,401
public function view_user_selector ( $ userid , $ userview ) { global $ PAGE , $ USER ; $ url = $ PAGE -> url ; if ( $ userid != $ USER -> id ) { $ url -> param ( 'userid' , $ userid ) ; } $ options = array ( GRADE_REPORT_USER_VIEW_USER => get_string ( 'otheruser' , 'gradereport_user' ) , GRADE_REPORT_USER_VIEW_SELF =>...
Creates and renders the single select box for the user view .
31,402
public static function get_course_listitem_actions ( \ core_course_category $ category , \ core_course_list_element $ course ) { $ baseurl = new \ moodle_url ( '/course/management.php' , array ( 'courseid' => $ course -> id , 'categoryid' => $ course -> category , 'sesskey' => \ sesskey ( ) ) ) ; $ actions = array ( ) ...
Returns an array of actions for a course listitem .
31,403
public static function get_course_detail_actions ( \ core_course_list_element $ course ) { $ params = array ( 'courseid' => $ course -> id , 'categoryid' => $ course -> category , 'sesskey' => \ sesskey ( ) ) ; $ baseurl = new \ moodle_url ( '/course/management.php' , $ params ) ; $ actions = array ( ) ; $ actions [ 'v...
Returns an array of actions that can be performed on the course being displayed .
31,404
public static function action_course_change_sortorder_after_course ( $ courserecordorid , $ moveaftercourseid ) { $ course = \ get_course ( $ courserecordorid ) ; $ category = \ core_course_category :: get ( $ course -> category ) ; if ( ! $ category -> can_resort_courses ( ) ) { $ url = '/course/management.php?categor...
Changes the sort order so that the first course appears after the second course .
31,405
public static function action_course_show ( \ core_course_list_element $ course ) { if ( ! $ course -> can_change_visibility ( ) ) { throw new \ moodle_exception ( 'permissiondenied' , 'error' , '' , null , 'core_course_list_element::can_change_visbility' ) ; } return course_change_visibility ( $ course -> id , true ) ...
Makes a course visible given a \ core_course_list_element object .
31,406
public static function action_course_hide ( \ core_course_list_element $ course ) { if ( ! $ course -> can_change_visibility ( ) ) { throw new \ moodle_exception ( 'permissiondenied' , 'error' , '' , null , 'core_course_list_element::can_change_visbility' ) ; } return course_change_visibility ( $ course -> id , false )...
Makes a course hidden given a \ core_course_list_element object .
31,407
public static function action_course_show_by_record ( $ courserecordorid ) { if ( is_int ( $ courserecordorid ) ) { $ courserecordorid = get_course ( $ courserecordorid ) ; } $ course = new \ core_course_list_element ( $ courserecordorid ) ; return self :: action_course_show ( $ course ) ; }
Makes a course visible given a course id or a database record .
31,408
public static function action_course_hide_by_record ( $ courserecordorid ) { if ( is_int ( $ courserecordorid ) ) { $ courserecordorid = get_course ( $ courserecordorid ) ; } $ course = new \ core_course_list_element ( $ courserecordorid ) ; return self :: action_course_hide ( $ course ) ; }
Makes a course hidden given a course id or a database record .
31,409
public static function action_category_change_sortorder_up_one ( \ core_course_category $ category ) { if ( ! $ category -> can_change_sortorder ( ) ) { throw new \ moodle_exception ( 'permissiondenied' , 'error' , '' , null , 'core_course_category::can_change_sortorder' ) ; } return $ category -> change_sortorder_by_o...
Resort a categories subcategories shifting the given category up one .
31,410
public static function action_category_change_sortorder_down_one ( \ core_course_category $ category ) { if ( ! $ category -> can_change_sortorder ( ) ) { throw new \ moodle_exception ( 'permissiondenied' , 'error' , '' , null , 'core_course_category::can_change_sortorder' ) ; } return $ category -> change_sortorder_by...
Resort a categories subcategories shifting the given category down one .
31,411
public static function action_category_hide ( \ core_course_category $ category ) { if ( ! $ category -> can_change_visibility ( ) ) { throw new \ moodle_exception ( 'permissiondenied' , 'error' , '' , null , 'core_course_category::can_change_visbility' ) ; } $ category -> hide ( ) ; return true ; }
Makes a category hidden given a core_course_category object .
31,412
public static function action_category_show ( \ core_course_category $ category ) { if ( ! $ category -> can_change_visibility ( ) ) { throw new \ moodle_exception ( 'permissiondenied' , 'error' , '' , null , 'core_course_category::can_change_visbility' ) ; } $ category -> show ( ) ; return true ; }
Makes a category visible given a core_course_category object .
31,413
public static function action_category_resort_subcategories ( \ core_course_category $ category , $ sort , $ cleanup = true ) { if ( ! $ category -> can_resort_subcategories ( ) ) { throw new \ moodle_exception ( 'permissiondenied' , 'error' , '' , null , 'core_course_category::can_resort' ) ; } return $ category -> re...
Resorts the sub categories of the given category .
31,414
public static function action_category_resort_courses ( \ core_course_category $ category , $ sort , $ cleanup = true ) { if ( ! $ category -> can_resort_courses ( ) ) { throw new \ moodle_exception ( 'permissiondenied' , 'error' , '' , null , 'core_course_category::can_resort' ) ; } return $ category -> resort_courses...
Resorts the courses within the given category .
31,415
public static function action_category_move_courses_into ( \ core_course_category $ oldcategory , \ core_course_category $ newcategory , array $ courseids ) { global $ DB ; list ( $ where , $ params ) = $ DB -> get_in_or_equal ( $ courseids , SQL_PARAMS_NAMED ) ; $ params [ 'categoryid' ] = $ oldcategory -> id ; $ sql ...
Moves courses out of one category and into a new category .
31,416
public static function search_courses ( $ search , $ blocklist , $ modulelist , $ page = 0 , $ perpage = null ) { global $ CFG ; if ( $ perpage === null ) { $ perpage = $ CFG -> coursesperpage ; } $ searchcriteria = array ( ) ; if ( ! empty ( $ search ) ) { $ searchcriteria = array ( 'search' => $ search ) ; } else if ...
Search for courses with matching params .
31,417
public static function move_courses_into_category ( $ categoryorid , $ courseids = array ( ) ) { global $ DB ; if ( ! is_array ( $ courseids ) ) { $ courseids = array ( $ courseids ) ; } if ( count ( $ courseids ) === 0 ) { return false ; } if ( $ categoryorid instanceof \ core_course_category ) { $ moveto = $ category...
Moves one or more courses out of the category they are currently in and into a new category .
31,418
public static function get_category_courses_visibility ( $ categoryid ) { global $ DB ; $ sql = "SELECT c.id, c.visible FROM {course} c WHERE c.category = :category" ; $ params = array ( 'category' => ( int ) $ categoryid ) ; return $ DB -> get_records_sql ( $ sql , $ params ) ; }
Returns an array of courseids and visiblity for all courses within the given category .
31,419
public static function get_category_children_visibility ( $ categoryid ) { global $ DB ; $ category = \ core_course_category :: get ( $ categoryid ) ; $ select = $ DB -> sql_like ( 'path' , ':path' ) ; $ path = $ category -> path . '/%' ; $ sql = "SELECT c.id, c.visible FROM {course_categories} c ...
Returns an array of all categoryids that have the given category as a parent and their visible value .
31,420
public static function record_expanded_category ( \ core_course_category $ coursecat , $ expanded = true ) { self :: $ expandedcategories = null ; $ categoryid = $ coursecat -> id ; $ path = $ coursecat -> get_parents ( ) ; $ cache = \ cache :: make ( 'core' , 'userselections' ) ; $ categories = $ cache -> get ( 'categ...
Records when a category is expanded or collapsed so that when the user
31,421
public static function get_expanded_categories ( $ withpath = null ) { if ( self :: $ expandedcategories === null ) { $ cache = \ cache :: make ( 'core' , 'userselections' ) ; self :: $ expandedcategories = $ cache -> get ( 'categorymanagementexpanded' ) ; if ( self :: $ expandedcategories === false ) { self :: $ expan...
Returns the categories that should be expanded when displaying the interface .
31,422
public static function loadHandler ( $ handlerClass ) { if ( ! static :: $ _domain ) { throw new Horde_Translation_Exception ( 'The domain property must be set by the class that extends Horde_Translation_Autodetect.' ) ; } $ directory = static :: _searchLocaleDirectory ( ) ; if ( ! $ directory ) { throw new Horde_Trans...
Auto detects the locale directory location .
31,423
protected static function _getSearchDirectories ( ) { $ className = get_called_class ( ) ; $ class = new ReflectionClass ( $ className ) ; $ basedir = dirname ( $ class -> getFilename ( ) ) ; $ depth = substr_count ( $ className , '\\' ) ? : substr_count ( $ className , '_' ) ; return array ( $ basedir . str_repeat ( '...
Get potential locations for the locale directory .
31,424
public function get_heading ( $ adding = false ) { if ( $ adding ) { $ string = 'pluginnameadding' ; } else { $ string = 'pluginnameediting' ; } return get_string ( $ string , $ this -> plugin_name ( ) ) ; }
Method called by display_question_editing_page and by question . php to get heading for breadcrumbs .
31,425
public function save_question_options ( $ question ) { global $ DB ; $ extraquestionfields = $ this -> extra_question_fields ( ) ; if ( is_array ( $ extraquestionfields ) ) { $ question_extension_table = array_shift ( $ extraquestionfields ) ; $ function = 'update_record' ; $ questionidcolname = $ this -> questionid_co...
Saves question - type specific options
31,426
protected function count_hints_on_form ( $ formdata , $ withparts ) { if ( ! empty ( $ formdata -> hint ) ) { $ numhints = max ( array_keys ( $ formdata -> hint ) ) + 1 ; } else { $ numhints = 0 ; } if ( $ withparts ) { if ( ! empty ( $ formdata -> hintclearwrong ) ) { $ numclears = max ( array_keys ( $ formdata -> hin...
Count number of hints on the form . Overload if you use custom hint controls .
31,427
protected function is_hint_empty_in_form_data ( $ formdata , $ number , $ withparts ) { if ( $ withparts ) { return empty ( $ formdata -> hint [ $ number ] [ 'text' ] ) && empty ( $ formdata -> hintclearwrong [ $ number ] ) && empty ( $ formdata -> hintshownumcorrect [ $ number ] ) ; } else { return empty ( $ formdata ...
Determine if the hint with specified number is not empty and should be saved . Overload if you use custom hint controls .
31,428
public function make_question ( $ questiondata ) { $ question = $ this -> make_question_instance ( $ questiondata ) ; $ this -> initialise_question_instance ( $ question , $ questiondata ) ; return $ question ; }
Create an appropriate question_definition for the question of this type using data loaded from the database .
31,429
protected function initialise_question_instance ( question_definition $ question , $ questiondata ) { $ question -> id = $ questiondata -> id ; $ question -> category = $ questiondata -> category ; $ question -> contextid = $ questiondata -> contextid ; $ question -> parent = $ questiondata -> parent ; $ question -> qt...
Initialise the common question_definition fields .
31,430
protected function initialise_combined_feedback ( question_definition $ question , $ questiondata , $ withparts = false ) { $ question -> correctfeedback = $ questiondata -> options -> correctfeedback ; $ question -> correctfeedbackformat = $ questiondata -> options -> correctfeedbackformat ; $ question -> partiallycor...
Initialise the combined feedback fields .
31,431
protected function make_answer ( $ answer ) { return new question_answer ( $ answer -> id , $ answer -> answer , $ answer -> fraction , $ answer -> feedback , $ answer -> feedbackformat ) ; }
Create a question_answer or an appropriate subclass for this question from a row loaded from the database .
31,432
public function delete_question ( $ questionid , $ contextid ) { global $ DB ; $ this -> delete_files ( $ questionid , $ contextid ) ; $ extraquestionfields = $ this -> extra_question_fields ( ) ; if ( is_array ( $ extraquestionfields ) ) { $ question_extension_table = array_shift ( $ extraquestionfields ) ; $ DB -> de...
Deletes the question - type specific data when a question is deleted .
31,433
protected function get_context_by_category_id ( $ category ) { global $ DB ; $ contextid = $ DB -> get_field ( 'question_categories' , 'contextid' , array ( 'id' => $ category ) ) ; $ context = context :: instance_by_id ( $ contextid , IGNORE_MISSING ) ; return $ context ; }
Get question context by category id
31,434
protected function import_or_save_files ( $ field , $ context , $ component , $ filearea , $ itemid ) { if ( ! empty ( $ field [ 'itemid' ] ) ) { return file_save_draft_area_files ( $ field [ 'itemid' ] , $ context -> id , $ component , $ filearea , $ itemid , $ this -> fileoptions , trim ( $ field [ 'text' ] ) ) ; } e...
Save the file belonging to one text field .
31,435
public function move_files ( $ questionid , $ oldcontextid , $ newcontextid ) { $ fs = get_file_storage ( ) ; $ fs -> move_area_files_to_new_context ( $ oldcontextid , $ newcontextid , 'question' , 'questiontext' , $ questionid ) ; $ fs -> move_area_files_to_new_context ( $ oldcontextid , $ newcontextid , 'question' , ...
Move all the files belonging to this question from one context to another .
31,436
protected function move_files_in_hints ( $ questionid , $ oldcontextid , $ newcontextid ) { global $ DB ; $ fs = get_file_storage ( ) ; $ hintids = $ DB -> get_records_menu ( 'question_hints' , array ( 'questionid' => $ questionid ) , 'id' , 'id,1' ) ; foreach ( $ hintids as $ hintid => $ notused ) { $ fs -> move_area_...
Move all the files belonging to this question s hints when the question is moved from one context to another .
31,437
protected function delete_files_in_hints ( $ questionid , $ contextid ) { global $ DB ; $ fs = get_file_storage ( ) ; $ hintids = $ DB -> get_records_menu ( 'question_hints' , array ( 'questionid' => $ questionid ) , 'id' , 'id,1' ) ; foreach ( $ hintids as $ hintid => $ notused ) { $ fs -> delete_area_files ( $ contex...
Delete all the files belonging to this question s hints .
31,438
protected static function get_context_parameters ( ) { $ id = new external_value ( PARAM_INT , 'Context ID. Either use this value, or level and instanceid.' , VALUE_DEFAULT , 0 ) ; $ level = new external_value ( PARAM_ALPHA , 'Context level. To be used with instanceid.' , VALUE_DEFAULT , '' ) ; $ instanceid = new exter...
Returns a prepared structure to use a context parameters .
31,439
public static function data_for_competency_frameworks_manage_page ( $ pagecontext ) { global $ PAGE ; $ params = self :: validate_parameters ( self :: data_for_competency_frameworks_manage_page_parameters ( ) , array ( 'pagecontext' => $ pagecontext ) ) ; $ context = self :: get_context_from_params ( $ params [ 'pageco...
Loads the data required to render the competency_frameworks_manage_page template .
31,440
public static function data_for_competencies_manage_page ( $ competencyframeworkid , $ search ) { global $ PAGE ; $ params = self :: validate_parameters ( self :: data_for_competencies_manage_page_parameters ( ) , array ( 'competencyframeworkid' => $ competencyframeworkid , 'search' => $ search ) ) ; $ framework = api ...
Loads the data required to render the competencies_manage_page template .
31,441
public static function data_for_competency_summary ( $ competencyid , $ includerelated = false , $ includecourses = false ) { global $ PAGE ; $ params = self :: validate_parameters ( self :: data_for_competency_summary_parameters ( ) , array ( 'competencyid' => $ competencyid , 'includerelated' => $ includerelated , 'i...
Loads the data required to render the competency_page template .
31,442
public static function data_for_course_competencies_page ( $ courseid ) { global $ PAGE ; $ params = self :: validate_parameters ( self :: data_for_course_competencies_page_parameters ( ) , array ( 'courseid' => $ courseid , ) ) ; self :: validate_context ( context_course :: instance ( $ params [ 'courseid' ] ) ) ; $ r...
Loads the data required to render the course_competencies_page template .
31,443
public static function data_for_templates_manage_page ( $ pagecontext ) { global $ PAGE ; $ params = self :: validate_parameters ( self :: data_for_templates_manage_page_parameters ( ) , array ( 'pagecontext' => $ pagecontext ) ) ; $ context = self :: get_context_from_params ( $ params [ 'pagecontext' ] ) ; self :: val...
Loads the data required to render the templates_manage_page template .
31,444
public static function data_for_template_competencies_page ( $ templateid , $ pagecontext ) { global $ PAGE ; $ params = self :: validate_parameters ( self :: data_for_template_competencies_page_parameters ( ) , array ( 'templateid' => $ templateid , 'pagecontext' => $ pagecontext ) ) ; $ context = self :: get_context_...
Loads the data required to render the template_competencies_page template .
31,445
public static function data_for_plan_page ( $ planid ) { global $ PAGE ; $ params = self :: validate_parameters ( self :: data_for_plan_page_parameters ( ) , array ( 'planid' => $ planid ) ) ; $ plan = api :: read_plan ( $ params [ 'planid' ] ) ; self :: validate_context ( $ plan -> get_context ( ) ) ; $ renderable = n...
Loads the data required to render the plan_page template .
31,446
public static function data_for_plans_page ( $ userid ) { global $ PAGE ; $ params = self :: validate_parameters ( self :: data_for_plans_page_parameters ( ) , array ( 'userid' => $ userid , ) ) ; $ context = context_user :: instance ( $ params [ 'userid' ] ) ; self :: validate_context ( $ context ) ; $ output = $ PAGE...
Loads the data required to render the plans_page template .
31,447
public static function data_for_user_evidence_list_page ( $ userid ) { global $ PAGE ; $ params = self :: validate_parameters ( self :: data_for_user_evidence_list_page_parameters ( ) , array ( 'userid' => $ userid ) ) ; $ context = context_user :: instance ( $ params [ 'userid' ] ) ; self :: validate_context ( $ conte...
Loads the data required to render the user_evidence_list_page template .
31,448
public static function data_for_user_evidence_page ( $ id ) { global $ PAGE ; $ params = self :: validate_parameters ( self :: data_for_user_evidence_page_parameters ( ) , array ( 'id' => $ id ) ) ; $ userevidence = api :: read_user_evidence ( $ id ) ; self :: validate_context ( $ userevidence -> get_context ( ) ) ; $ ...
Loads the data required to render the user_evidence_page template .
31,449
public static function data_for_related_competencies_section ( $ competencyid ) { global $ PAGE ; $ params = self :: validate_parameters ( self :: data_for_related_competencies_section_parameters ( ) , array ( 'competencyid' => $ competencyid , ) ) ; $ competency = api :: read_competency ( $ params [ 'competencyid' ] )...
Data to render in the related competencies section .
31,450
public static function data_for_user_competency_summary_parameters ( ) { $ userid = new external_value ( PARAM_INT , 'Data base record id for the user' , VALUE_REQUIRED ) ; $ competencyid = new external_value ( PARAM_INT , 'Data base record id for the competency' , VALUE_REQUIRED ) ; $ params = array ( 'userid' => $ us...
Returns description of external function .
31,451
public static function data_for_user_competency_summary ( $ userid , $ competencyid ) { global $ PAGE ; $ params = self :: validate_parameters ( self :: data_for_user_competency_summary_parameters ( ) , array ( 'userid' => $ userid , 'competencyid' => $ competencyid , ) ) ; $ uc = api :: get_user_competency ( $ params ...
Data for user competency summary .
31,452
public static function dispatch ( \ core \ event \ base $ event ) { if ( during_initial_install ( ) ) { return ; } if ( ! $ event -> is_triggered ( ) or $ event -> is_dispatched ( ) ) { throw new \ coding_exception ( 'Illegal event dispatching attempted.' ) ; } self :: $ buffer [ ] = $ event ; if ( self :: $ dispatchin...
Trigger new event .
31,453
public static function database_transaction_commited ( ) { if ( self :: $ dispatching or empty ( self :: $ extbuffer ) ) { return ; } self :: $ dispatching = true ; self :: process_buffers ( ) ; self :: $ dispatching = false ; }
Notification from DML layer .
31,454
protected static function get_observing_classes ( \ core \ event \ base $ event ) { $ classname = get_class ( $ event ) ; $ observers = array ( '\\' . $ classname ) ; while ( $ classname = get_parent_class ( $ classname ) ) { $ observers [ ] = '\\' . $ classname ; } $ observers = array_reverse ( $ observers , false ) ;...
Returns list of classes related to this event .
31,455
protected static function init_all_observers ( ) { global $ CFG ; if ( is_array ( self :: $ allobservers ) ) { return ; } if ( ! PHPUNIT_TEST and ! during_initial_install ( ) ) { $ cache = \ cache :: make ( 'core' , 'observers' ) ; $ cached = $ cache -> get ( 'all' ) ; $ dirroot = $ cache -> get ( 'dirroot' ) ; if ( $ ...
Initialise the list of observers .
31,456
protected static function add_observers ( array $ observers , $ file , $ plugintype = null , $ plugin = null ) { global $ CFG ; foreach ( $ observers as $ observer ) { if ( empty ( $ observer [ 'eventname' ] ) or ! is_string ( $ observer [ 'eventname' ] ) ) { debugging ( "Invalid 'eventname' detected in $file observer ...
Add observers .
31,457
protected static function order_all_observers ( ) { foreach ( self :: $ allobservers as $ classname => $ observers ) { \ core_collator :: asort_objects_by_property ( $ observers , 'priority' , \ core_collator :: SORT_NUMERIC ) ; self :: $ allobservers [ $ classname ] = array_reverse ( $ observers ) ; } }
Reorder observers to allow quick lookup of observer for each event .
31,458
protected function build_breadcrumb ( $ fullpath ) { $ breadcrumb = array ( array ( 'name' => get_string ( 'pluginname' , 'repository_boxnet' ) , 'path' => '' ) ) ; $ breadcrumbpath = '' ; $ crumbs = explode ( '/' , $ fullpath ) ; foreach ( $ crumbs as $ crumb ) { if ( empty ( $ crumb ) ) { continue ; } list ( $ unused...
Construct a breadcrumb from a path .
31,459
protected function build_part ( $ type , $ value , $ name = '' ) { $ return = $ type . ':' . urlencode ( $ value ) ; if ( $ name !== '' ) { $ return .= '|' . urlencode ( $ name ) ; } return $ return ; }
Build a part of the path .
31,460
protected function split_part ( $ part ) { list ( $ type , $ tosplit ) = explode ( ':' , $ part ) ; $ name = '' ; if ( strpos ( $ tosplit , '|' ) !== false ) { list ( $ value , $ name ) = explode ( '|' , $ tosplit , 2 ) ; } else { $ value = $ tosplit ; } return array ( $ type , urldecode ( $ value ) , urldecode ( $ nam...
Extract information from a part of path .
31,461
public function print_login ( ) { $ url = $ this -> boxnetclient -> get_login_url ( ) ; if ( $ this -> options [ 'ajax' ] ) { $ ret = array ( ) ; $ popup_btn = new stdClass ( ) ; $ popup_btn -> type = 'popup' ; $ popup_btn -> url = $ url -> out ( false ) ; $ ret [ 'login' ] = array ( $ popup_btn ) ; return $ ret ; } el...
Return login form
31,462
public function get_link ( $ reference ) { $ reference = unserialize ( self :: convert_to_valid_reference ( $ reference ) ) ; $ shareinfo = $ this -> boxnetclient -> share_file ( $ reference -> fileid , false ) ; return $ shareinfo -> url ; }
Get a link to the file .
31,463
public function sync_reference ( stored_file $ file ) { global $ CFG ; if ( $ file -> get_referencelastsync ( ) + DAYSECS > time ( ) ) { return false ; } $ c = new curl ( ) ; $ reference = unserialize ( self :: convert_to_valid_reference ( $ file -> get_reference ( ) ) ) ; $ url = $ reference -> downloadurl ; if ( file...
Synchronize the references .
31,464
public function get_file_source_info ( $ source ) { global $ USER ; list ( $ type , $ fileid , $ filename ) = $ this -> split_part ( $ source ) ; return 'Box (' . fullname ( $ USER ) . '): ' . $ filename ; }
Return the source information .
31,465
public function is_available ( ) { $ target = $ this -> get_target ( ) ; if ( ! $ target ) { return false ; } $ classname = $ target -> get_analyser_class ( ) ; if ( ! class_exists ( $ classname ) ) { return false ; } return true ; }
Quick safety check to discard site models which required components are not available anymore .
31,466
public function get_target ( ) { if ( $ this -> target !== null ) { return $ this -> target ; } $ instance = \ core_analytics \ manager :: get_target ( $ this -> model -> target ) ; $ this -> target = $ instance ; return $ this -> target ; }
Returns the model target .
31,467
public function get_indicators ( ) { if ( $ this -> indicators !== null ) { return $ this -> indicators ; } $ fullclassnames = json_decode ( $ this -> model -> indicators ) ; if ( ! is_array ( $ fullclassnames ) ) { throw new \ coding_exception ( 'Model ' . $ this -> model -> id . ' indicators can not be read' ) ; } $ ...
Returns the model indicators .
31,468
public function get_potential_indicators ( ) { $ indicators = \ core_analytics \ manager :: get_all_indicators ( ) ; if ( empty ( $ this -> analyser ) ) { $ this -> init_analyser ( array ( 'evaluation' => true ) ) ; } foreach ( $ indicators as $ classname => $ indicator ) { if ( $ this -> analyser -> check_indicator_re...
Returns the list of indicators that could potentially be used by the model target .
31,469
protected function init_analyser ( $ options = array ( ) ) { $ target = $ this -> get_target ( ) ; $ indicators = $ this -> get_indicators ( ) ; if ( empty ( $ target ) ) { throw new \ moodle_exception ( 'errornotarget' , 'analytics' ) ; } $ timesplittings = array ( ) ; if ( empty ( $ options [ 'notimesplitting' ] ) ) ...
Initialises the model analyser .
31,470
public function get_time_splitting ( ) { if ( empty ( $ this -> model -> timesplitting ) ) { return false ; } return \ core_analytics \ manager :: get_time_splitting ( $ this -> model -> timesplitting ) ; }
Returns the model time splitting method .
31,471
public static function exists ( \ core_analytics \ local \ target \ base $ target , $ indicators = false ) { global $ DB ; $ existingmodels = $ DB -> get_records ( 'analytics_models' , array ( 'target' => $ target -> get_id ( ) ) ) ; if ( ! $ existingmodels ) { return false ; } if ( ! $ indicators && $ existingmodels )...
Does this model exist?
31,472
public function delete ( ) { global $ DB ; \ core_analytics \ manager :: check_can_manage_models ( ) ; $ this -> clear ( ) ; $ predictor = $ this -> get_predictions_processor ( false ) ; if ( $ predictor -> is_ready ( ) !== true ) { $ predictorname = \ core_analytics \ manager :: get_predictions_processor_name ( $ pred...
Removes the model .
31,473
public function train ( ) { \ core_analytics \ manager :: check_can_manage_models ( ) ; if ( $ this -> is_static ( ) ) { $ this -> get_analyser ( ) -> add_log ( get_string ( 'notrainingbasedassumptions' , 'analytics' ) ) ; $ result = new \ stdClass ( ) ; $ result -> status = self :: OK ; return $ result ; } if ( ! $ th...
Trains the model using the site contents .
31,474
private function format_predictor_predictions ( $ predictorresult ) { $ predictions = array ( ) ; if ( ! empty ( $ predictorresult -> predictions ) ) { foreach ( $ predictorresult -> predictions as $ sampleinfo ) { switch ( count ( $ sampleinfo ) ) { case 1 : debugging ( $ this -> model -> id . ' model predictions proc...
Formats the predictor results .
31,475
protected function execute_prediction_callbacks ( & $ predictions , $ indicatorcalculations ) { $ samplecontexts = array ( ) ; $ records = array ( ) ; foreach ( $ predictions as $ uniquesampleid => $ prediction ) { list ( $ sampleid , $ rangeindex ) = $ this -> get_time_splitting ( ) -> infer_sample_info ( $ uniquesamp...
Execute the prediction callbacks defined by the target .
31,476
protected function trigger_insights ( $ samplecontexts , $ predictionrecords ) { if ( $ this -> get_analyser ( ) :: one_sample_per_analysable ( ) ) { $ predictionrecords = $ this -> add_prediction_ids ( $ predictionrecords ) ; $ predictions = array_map ( function ( $ predictionobj ) { $ prediction = new \ core_analytic...
Generates insights and updates the cache .
31,477
protected function prepare_prediction_record ( $ sampleid , $ rangeindex , $ prediction , $ predictionscore , $ calculations ) { $ context = $ this -> get_analyser ( ) -> sample_access_context ( $ sampleid ) ; $ record = new \ stdClass ( ) ; $ record -> modelid = $ this -> model -> id ; $ record -> contextid = $ contex...
Stores the prediction in the database .
31,478
public function enable ( $ timesplittingid = false ) { global $ DB , $ USER ; $ now = time ( ) ; if ( $ timesplittingid && $ timesplittingid !== $ this -> model -> timesplitting ) { if ( ! \ core_analytics \ manager :: is_valid ( $ timesplittingid , '\core_analytics\local\time_splitting\base' ) ) { throw new \ moodle_e...
Enabled the model using the provided time splitting method .
31,479
public function mark_as_trained ( ) { global $ DB ; \ core_analytics \ manager :: check_can_manage_models ( ) ; $ this -> model -> trained = 1 ; $ DB -> update_record ( 'analytics_models' , $ this -> model ) ; }
Marks the model as trained
31,480
public function get_predictions_contexts ( $ skiphidden = true ) { global $ DB , $ USER ; $ sql = "SELECT DISTINCT ap.contextid FROM {analytics_predictions} ap JOIN {context} ctx ON ctx.id = ap.contextid WHERE ap.modelid = :modelid" ; $ params = array ( 'modelid' => $ this -> model -> i...
Get the contexts with predictions .
31,481
public function any_prediction_obtained ( ) { global $ DB ; return $ DB -> record_exists ( 'analytics_predict_samples' , array ( 'modelid' => $ this -> model -> id , 'timesplitting' => $ this -> model -> timesplitting ) ) ; }
Has this model generated predictions?
31,482
public function predictions_exist ( \ context $ context ) { global $ DB ; $ select = "modelid = :modelid AND contextid = :contextid" ; $ params = array ( 'modelid' => $ this -> model -> id , 'contextid' => $ context -> id ) ; return $ DB -> record_exists_select ( 'analytics_predictions' , $ select , $ params ) ; }
Whether predictions exist for this context .
31,483
public function get_predictions ( \ context $ context , $ skiphidden = true , $ page = false , $ perpage = 100 ) { global $ DB , $ USER ; \ core_analytics \ manager :: check_can_list_insights ( $ context ) ; $ sql = "SELECT ap.* FROM {analytics_predictions} ap JOIN ( ...
Gets the predictions for this context .
31,484
public function prediction_sample_data ( $ predictionobj ) { list ( $ unused , $ samplesdata ) = $ this -> get_analyser ( ) -> get_samples ( array ( $ predictionobj -> sampleid ) ) ; if ( empty ( $ samplesdata [ $ predictionobj -> sampleid ] ) ) { throw new \ moodle_exception ( 'errorsamplenotavailable' , 'analytics' )...
Returns the sample data of a prediction .
31,485
public function prediction_sample_description ( \ core_analytics \ prediction $ prediction ) { return $ this -> get_analyser ( ) -> sample_description ( $ prediction -> get_prediction_data ( ) -> sampleid , $ prediction -> get_prediction_data ( ) -> contextid , $ prediction -> get_sample_data ( ) ) ; }
Returns the description of a sample
31,486
public function get_output_dir ( $ subdirs = array ( ) , $ onlymodelid = false ) { global $ CFG ; $ subdirstr = '' ; foreach ( $ subdirs as $ subdir ) { $ subdirstr .= DIRECTORY_SEPARATOR . $ subdir ; } $ outputdir = get_config ( 'analytics' , 'modeloutputdir' ) ; if ( empty ( $ outputdir ) ) { $ outputdir = rtrim ( $ ...
Returns the output directory for prediction processors .
31,487
public function get_unique_id ( ) { global $ CFG ; if ( ! is_null ( $ this -> uniqueid ) ) { return $ this -> uniqueid ; } $ ids = array ( $ CFG -> wwwroot , $ CFG -> prefix , $ this -> model -> id , $ this -> model -> version ) ; $ this -> uniqueid = sha1 ( implode ( '$$' , $ ids ) ) ; return $ this -> uniqueid ; }
Returns a unique id for this model .
31,488
public function export ( \ renderer_base $ output ) { \ core_analytics \ manager :: check_can_manage_models ( ) ; $ data = clone $ this -> model ; $ data -> name = $ this -> inplace_editable_name ( ) -> export_for_template ( $ output ) ; $ data -> target = $ this -> get_target ( ) -> get_name ( ) ; $ data -> targetclas...
Exports the model data for displaying it in a template .
31,489
public function export_model ( string $ zipfilename , bool $ includeweights = true ) : string { \ core_analytics \ manager :: check_can_manage_models ( ) ; $ modelconfig = new model_config ( $ this ) ; return $ modelconfig -> export ( $ zipfilename , $ includeweights ) ; }
Exports the model data to a zip file .
31,490
public static function import_model ( string $ zipfilepath ) : \ core_analytics \ model { \ core_analytics \ manager :: check_can_manage_models ( ) ; $ modelconfig = new \ core_analytics \ model_config ( ) ; return $ modelconfig -> import ( $ zipfilepath ) ; }
Imports the provided model .
31,491
public function can_export_configuration ( ) : bool { if ( empty ( $ this -> model -> timesplitting ) ) { return false ; } if ( ! $ this -> get_indicators ( ) ) { return false ; } if ( $ this -> is_static ( ) ) { return false ; } return true ; }
Can this model be exported?
31,492
public function get_logs ( $ limitfrom = 0 , $ limitnum = 0 ) { global $ DB ; \ core_analytics \ manager :: check_can_manage_models ( ) ; return $ DB -> get_records ( 'analytics_models_log' , array ( 'modelid' => $ this -> get_id ( ) ) , 'timecreated DESC' , '*' , $ limitfrom , $ limitnum ) ; }
Returns the model logs data .
31,493
public function get_training_data ( ) { \ core_analytics \ manager :: check_can_manage_models ( ) ; $ timesplittingid = $ this -> get_time_splitting ( ) -> get_id ( ) ; return \ core_analytics \ dataset_manager :: export_training_data ( $ this -> get_id ( ) , $ timesplittingid ) ; }
Merges all training data files into one and returns it .
31,494
public function trained_locally ( ) : bool { global $ DB ; if ( ! $ this -> is_trained ( ) || $ this -> is_static ( ) ) { return false ; } if ( $ DB -> record_exists ( 'analytics_train_samples' , [ 'modelid' => $ this -> model -> id ] ) ) { return true ; } return false ; }
Has the model been trained using data from this site?
31,495
protected function flag_file_as_used ( \ stored_file $ file , $ action ) { global $ DB ; $ usedfile = new \ stdClass ( ) ; $ usedfile -> modelid = $ this -> model -> id ; $ usedfile -> fileid = $ file -> get_id ( ) ; $ usedfile -> action = $ action ; $ usedfile -> time = time ( ) ; $ DB -> insert_record ( 'analytics_us...
Flag the provided file as used for training or prediction .
31,496
protected function log_result ( $ timesplittingid , $ score , $ dir = false , $ info = false , $ evaluationmode = 'configuration' ) { global $ DB , $ USER ; $ log = new \ stdClass ( ) ; $ log -> modelid = $ this -> get_id ( ) ; $ log -> version = $ this -> model -> version ; $ log -> evaluationmode = $ evaluationmode ;...
Log the evaluation results in the database .
31,497
private static function indicator_classes ( $ indicators ) { $ indicatorclasses = array ( ) ; foreach ( $ indicators as $ indicator ) { if ( ! \ core_analytics \ manager :: is_valid ( $ indicator , '\core_analytics\local\indicator\base' ) ) { if ( ! is_object ( $ indicator ) && ! is_scalar ( $ indicator ) ) { $ indicat...
Utility method to return indicator class names from a list of indicator objects
31,498
public function clear ( ) { global $ DB , $ USER ; \ core_analytics \ manager :: check_can_manage_models ( ) ; $ predictor = $ this -> get_predictions_processor ( false ) ; if ( $ predictor -> is_ready ( ) !== true ) { $ predictorname = \ core_analytics \ manager :: get_predictions_processor_name ( $ predictor ) ; debu...
Clears the model training and prediction data .
31,499
public function get_name ( ) { if ( trim ( $ this -> model -> name ) === '' ) { return $ this -> get_target ( ) -> get_name ( ) ; } else { return $ this -> model -> name ; } }
Returns the name of the model .