idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
29,900 | public function new_submission_empty ( $ data ) { foreach ( $ this -> submissionplugins as $ plugin ) { if ( $ plugin -> is_enabled ( ) && $ plugin -> is_visible ( ) && $ plugin -> allow_submissions ( ) && ! $ plugin -> submission_is_empty ( $ data ) ) { return false ; } } return true ; } | Determine if a new submission is empty or not |
29,901 | protected function process_save_submission ( & $ mform , & $ notices ) { global $ CFG , $ USER ; require_once ( $ CFG -> dirroot . '/mod/assign/submission_form.php' ) ; $ userid = optional_param ( 'userid' , $ USER -> id , PARAM_INT ) ; require_sesskey ( ) ; if ( ! $ this -> submissions_open ( $ userid ) ) { $ notices ... | Save assignment submission . |
29,902 | public function grading_disabled ( $ userid , $ checkworkflow = true ) { global $ CFG ; if ( $ checkworkflow && $ this -> get_instance ( ) -> markingworkflow ) { $ grade = $ this -> get_user_grade ( $ userid , false ) ; $ validstates = $ this -> get_marking_workflow_states_for_current_user ( ) ; if ( ! empty ( $ grade ... | Determine if this users grade can be edited . |
29,903 | protected function get_grading_instance ( $ userid , $ grade , $ gradingdisabled ) { global $ CFG , $ USER ; $ grademenu = make_grades_menu ( $ this -> get_instance ( ) -> grade ) ; $ allowgradedecimals = $ this -> get_instance ( ) -> grade > 0 ; $ advancedgradingwarning = false ; $ gradingmanager = get_grading_manager... | Get an instance of a grading form if advanced grading is enabled . This is specific to the assignment marker and student . |
29,904 | protected function add_plugin_submission_elements ( $ submission , MoodleQuickForm $ mform , stdClass $ data , $ userid ) { foreach ( $ this -> submissionplugins as $ plugin ) { if ( $ plugin -> is_enabled ( ) && $ plugin -> is_visible ( ) && $ plugin -> allow_submissions ( ) ) { $ plugin -> get_form_elements_for_user ... | Add elements in submission plugin form . |
29,905 | public function is_any_feedback_plugin_enabled ( ) { if ( ! isset ( $ this -> cache [ 'any_feedback_plugin_enabled' ] ) ) { $ this -> cache [ 'any_feedback_plugin_enabled' ] = false ; foreach ( $ this -> feedbackplugins as $ plugin ) { if ( $ plugin -> is_enabled ( ) && $ plugin -> is_visible ( ) ) { $ this -> cache [ ... | Check if feedback plugins installed are enabled . |
29,906 | public function is_any_submission_plugin_enabled ( ) { if ( ! isset ( $ this -> cache [ 'any_submission_plugin_enabled' ] ) ) { $ this -> cache [ 'any_submission_plugin_enabled' ] = false ; foreach ( $ this -> submissionplugins as $ plugin ) { if ( $ plugin -> is_enabled ( ) && $ plugin -> is_visible ( ) && $ plugin ->... | Check if submission plugins installed are enabled . |
29,907 | public function add_submission_form_elements ( MoodleQuickForm $ mform , stdClass $ data ) { global $ USER ; $ userid = $ data -> userid ; if ( $ this -> get_instance ( ) -> teamsubmission ) { $ submission = $ this -> get_group_submission ( $ userid , 0 , false ) ; } else { $ submission = $ this -> get_user_submission ... | Add elements to submission form . |
29,908 | public function remove_submission ( $ userid ) { global $ USER ; if ( ! $ this -> can_edit_submission ( $ userid , $ USER -> id ) ) { print_error ( 'nopermission' ) ; } if ( $ this -> get_instance ( ) -> teamsubmission ) { $ submission = $ this -> get_group_submission ( $ userid , 0 , false ) ; } else { $ submission = ... | Remove any data from the current submission . |
29,909 | public function revert_to_draft ( $ userid ) { global $ DB , $ USER ; require_capability ( 'mod/assign:grade' , $ this -> context ) ; if ( $ this -> get_instance ( ) -> teamsubmission ) { $ submission = $ this -> get_group_submission ( $ userid , 0 , false ) ; } else { $ submission = $ this -> get_user_submission ( $ u... | Revert to draft . |
29,910 | protected function process_remove_submission ( $ userid = 0 ) { require_sesskey ( ) ; if ( ! $ userid ) { $ userid = required_param ( 'userid' , PARAM_INT ) ; } return $ this -> remove_submission ( $ userid ) ; } | Remove the current submission . |
29,911 | protected function process_revert_to_draft ( $ userid = 0 ) { require_sesskey ( ) ; if ( ! $ userid ) { $ userid = required_param ( 'userid' , PARAM_INT ) ; } return $ this -> revert_to_draft ( $ userid ) ; } | Revert to draft . Uses url parameter userid if userid not supplied as a parameter . |
29,912 | public function lock_submission ( $ userid ) { global $ USER , $ DB ; require_capability ( 'mod/assign:grade' , $ this -> context ) ; $ plugins = $ this -> get_submission_plugins ( ) ; $ submission = $ this -> get_user_submission ( $ userid , false ) ; $ flags = $ this -> get_user_flags ( $ userid , true ) ; $ flags ->... | Prevent student updates to this submission |
29,913 | protected function process_set_batch_marking_workflow_state ( ) { global $ CFG , $ DB ; require_once ( $ CFG -> dirroot . '/mod/assign/batchsetmarkingworkflowstateform.php' ) ; $ formparams = array ( 'userscount' => 0 , 'usershtml' => '' , 'markingworkflowstates' => $ this -> get_marking_workflow_states_for_current_use... | Set the workflow state for multiple users |
29,914 | protected function process_set_batch_marking_allocation ( ) { global $ CFG , $ DB ; require_once ( $ CFG -> dirroot . '/mod/assign/batchsetallocatedmarkerform.php' ) ; $ formparams = array ( 'userscount' => 0 , 'usershtml' => '' ) ; list ( $ sort , $ params ) = users_order_by_sql ( 'u' ) ; $ markers = get_enrolled_user... | Set the marking allocation for multiple users |
29,915 | protected function process_lock_submission ( $ userid = 0 ) { require_sesskey ( ) ; if ( ! $ userid ) { $ userid = required_param ( 'userid' , PARAM_INT ) ; } return $ this -> lock_submission ( $ userid ) ; } | Prevent student updates to this submission . Uses url parameter userid . |
29,916 | protected function process_unlock_submission ( $ userid = 0 ) { require_sesskey ( ) ; if ( ! $ userid ) { $ userid = required_param ( 'userid' , PARAM_INT ) ; } return $ this -> unlock_submission ( $ userid ) ; } | Unlock the student submission . Uses url parameter userid . |
29,917 | protected function process_outcomes ( $ userid , $ formdata , $ sourceuserid = null ) { global $ CFG , $ USER ; if ( empty ( $ CFG -> enableoutcomes ) ) { return ; } if ( $ this -> grading_disabled ( $ userid ) ) { return ; } require_once ( $ CFG -> libdir . '/gradelib.php' ) ; $ data = array ( ) ; $ gradinginfo = grad... | Save outcomes submitted from grading form . |
29,918 | protected function reopen_submission_if_required ( $ userid , $ submission , $ addattempt ) { $ instance = $ this -> get_instance ( ) ; $ maxattemptsreached = ! empty ( $ submission ) && $ submission -> attemptnumber >= ( $ instance -> maxattempts - 1 ) && $ instance -> maxattempts != ASSIGN_UNLIMITED_ATTEMPTS ; $ shou... | If the requirements are met - reopen the submission for another attempt . Only call this function when grading the latest attempt . |
29,919 | public function save_grade ( $ userid , $ data ) { require_capability ( 'mod/assign:grade' , $ this -> context ) ; $ instance = $ this -> get_instance ( ) ; $ submission = null ; if ( $ instance -> teamsubmission ) { $ mostrecentsubmission = $ this -> get_group_submission ( $ userid , 0 , false , - 1 ) ; $ this -> set_... | Save grade update . |
29,920 | protected function process_save_grade ( & $ mform ) { global $ CFG , $ SESSION ; require_once ( $ CFG -> dirroot . '/mod/assign/gradeform.php' ) ; require_sesskey ( ) ; $ instance = $ this -> get_instance ( ) ; $ rownum = required_param ( 'rownum' , PARAM_INT ) ; $ attemptnumber = optional_param ( 'attemptnumber' , - 1... | Save grade . |
29,921 | public static function can_upgrade_assignment ( $ type , $ version ) { $ assignment = new assign ( null , null , null ) ; return $ assignment -> can_upgrade ( $ type , $ version ) ; } | This function is a static wrapper around can_upgrade . |
29,922 | public function can_upgrade ( $ type , $ version ) { if ( $ type == 'offline' && $ version >= 2011112900 ) { return true ; } foreach ( $ this -> submissionplugins as $ plugin ) { if ( $ plugin -> can_upgrade ( $ type , $ version ) ) { return true ; } } foreach ( $ this -> feedbackplugins as $ plugin ) { if ( $ plugin -... | This function returns true if it can upgrade an assignment from the 2 . 2 module . |
29,923 | public function copy_area_files_for_upgrade ( $ oldcontextid , $ oldcomponent , $ oldfilearea , $ olditemid , $ newcontextid , $ newcomponent , $ newfilearea , $ newitemid ) { $ count = 0 ; $ fs = get_file_storage ( ) ; $ oldfiles = $ fs -> get_area_files ( $ oldcontextid , $ oldcomponent , $ oldfilearea , $ olditemid ... | Copy all the files from the old assignment files area to the new one . This is used by the plugin upgrade code . |
29,924 | protected function process_add_attempt_group ( $ useridlist ) { $ groupsprocessed = array ( ) ; $ result = true ; foreach ( $ useridlist as $ userid ) { $ groupid = 0 ; $ group = $ this -> get_submission_group ( $ userid ) ; if ( $ group ) { $ groupid = $ group -> id ; } if ( empty ( $ groupsprocessed [ $ groupid ] ) )... | Add a new attempt for each user in the list - but reopen each group assignment at most 1 time . |
29,925 | protected function add_attempt ( $ userid ) { require_capability ( 'mod/assign:grade' , $ this -> context ) ; if ( $ this -> get_instance ( ) -> attemptreopenmethod == ASSIGN_ATTEMPT_REOPEN_METHOD_NONE ) { return false ; } if ( $ this -> get_instance ( ) -> teamsubmission ) { $ oldsubmission = $ this -> get_group_submi... | Add a new attempt for a user . |
29,926 | public function get_user_grades_for_gradebook ( $ userid ) { global $ DB , $ CFG ; $ grades = array ( ) ; $ assignmentid = $ this -> get_instance ( ) -> id ; $ adminconfig = $ this -> get_admin_config ( ) ; $ gradebookpluginname = $ adminconfig -> feedback_plugin_for_gradebook ; $ gradebookplugin = null ; foreach ( $ t... | Get an upto date list of user grades and feedback for the gradebook . |
29,927 | public static function allocate_unique_ids ( $ assignid ) { global $ DB ; $ cm = get_coursemodule_from_instance ( 'assign' , $ assignid , 0 , false , MUST_EXIST ) ; $ context = context_module :: instance ( $ cm -> id ) ; $ currentgroup = groups_get_activity_group ( $ cm , true ) ; $ users = get_enrolled_users ( $ conte... | Foreach participant in the course - assign them a random id . |
29,928 | public static function get_uniqueid_for_user_static ( $ assignid , $ userid ) { global $ DB ; $ params = array ( 'assignment' => $ assignid , 'userid' => $ userid ) ; if ( $ record = $ DB -> get_record ( 'assign_user_mapping' , $ params , 'id' ) ) { return $ record -> id ; } self :: allocate_unique_ids ( $ assignid ) ;... | Lookup this user id and return the unique id for this assignment . |
29,929 | public static function get_user_id_for_uniqueid_static ( $ assignid , $ uniqueid ) { global $ DB ; if ( $ record = $ DB -> get_record ( 'assign_user_mapping' , array ( 'assignment' => $ assignid , 'id' => $ uniqueid ) , 'userid' , IGNORE_MISSING ) ) { return $ record -> userid ; } return false ; } | Lookup this unique id and return the user id for this assignment . |
29,930 | public function get_marking_workflow_states_for_current_user ( ) { if ( ! empty ( $ this -> markingworkflowstates ) ) { return $ this -> markingworkflowstates ; } $ states = array ( ) ; if ( has_capability ( 'mod/assign:grade' , $ this -> context ) ) { $ states [ ASSIGN_MARKING_WORKFLOW_STATE_INMARKING ] = get_string (... | Get the list of marking_workflow states the current user has permission to transition a grade to . |
29,931 | public function show_only_active_users ( ) { global $ CFG ; if ( is_null ( $ this -> showonlyactiveenrol ) ) { $ defaultgradeshowactiveenrol = ! empty ( $ CFG -> grade_report_showonlyactiveenrol ) ; $ this -> showonlyactiveenrol = get_user_preferences ( 'grade_report_showonlyactiveenrol' , $ defaultgradeshowactiveenrol... | Check is only active users in course should be shown . |
29,932 | public function is_gradebook_feedback_enabled ( ) { $ adminconfig = $ this -> get_admin_config ( ) ; $ gradebookplugin = $ adminconfig -> feedback_plugin_for_gradebook ; $ gradebookplugin = str_replace ( 'assignfeedback_' , '' , $ gradebookplugin ) ; $ gradebookfeedbackplugin = $ this -> get_feedback_plugin_by_type ( $... | Returns true if gradebook feedback plugin is enabled |
29,933 | public function get_grading_status ( $ userid ) { if ( $ this -> get_instance ( ) -> markingworkflow ) { $ flags = $ this -> get_user_flags ( $ userid , false ) ; if ( ! empty ( $ flags -> workflowstate ) ) { return $ flags -> workflowstate ; } return ASSIGN_MARKING_WORKFLOW_STATE_NOTMARKED ; } else { $ attemptnumber =... | Returns the grading status . |
29,934 | public function get_useridlist_key ( $ id = null ) { if ( $ id === null ) { $ id = $ this -> get_useridlist_key_id ( ) ; } return $ this -> get_course_module ( ) -> id . '_' . $ id ; } | Generates the key that should be used for an entry in the useridlist cache . |
29,935 | protected function update_activity_completion_records ( $ teamsubmission , $ requireallteammemberssubmit , $ submission , $ userid , $ complete , $ completion ) { if ( ( $ teamsubmission && $ submission -> groupid > 0 && ! $ requireallteammemberssubmit ) || ( $ teamsubmission && $ submission -> groupid > 0 && $ require... | Updates and creates the completion records in mdl_course_modules_completion . |
29,936 | protected function add_grade_notices ( ) { if ( has_capability ( 'mod/assign:grade' , $ this -> get_context ( ) ) && get_config ( 'assign' , 'has_rescaled_null_grades_' . $ this -> get_instance ( ) -> id ) ) { $ link = new \ moodle_url ( '/mod/assign/view.php' , array ( 'id' => $ this -> get_course_module ( ) -> id , '... | Checks for any grade notices and adds notifications . Will display on assignment main page and grading table . |
29,937 | public function get_marking_allocation_filters ( $ export = false ) { $ markingallocation = $ this -> get_instance ( ) -> markingworkflow && $ this -> get_instance ( ) -> markingallocation && has_capability ( 'mod/assign:manageallocations' , $ this -> context ) ; $ markingallocationoptions = array ( ) ; if ( $ markinga... | Return array of valid grading allocation filters for the grading interface . |
29,938 | public function get_marking_workflow_filters ( $ export = false ) { $ markingworkflow = $ this -> get_instance ( ) -> markingworkflow ; $ markingworkflowoptions = array ( ) ; if ( $ markingworkflow ) { $ notmarked = get_string ( 'markingworkflowstatenotmarked' , 'assign' ) ; $ markingworkflowoptions [ '' ] = get_string... | Return array of valid grading workflow filters for the grading interface . |
29,939 | public function get_filters ( ) { $ filterkeys = [ ASSIGN_FILTER_SUBMITTED , ASSIGN_FILTER_NOT_SUBMITTED , ASSIGN_FILTER_REQUIRE_GRADING , ASSIGN_FILTER_GRANTED_EXTENSION ] ; $ current = get_user_preferences ( 'assign_filter' , '' ) ; $ filters = [ ] ; array_push ( $ filters , [ 'key' => 'none' , 'name' => get_string (... | Return array of valid search filters for the grading interface . |
29,940 | protected function get_submissionstatement ( $ adminconfig , $ instance , $ context ) { $ submissionstatement = '' ; if ( ! ( $ context instanceof context ) ) { return $ submissionstatement ; } if ( ! $ instance -> teamsubmission ) { if ( ! empty ( $ adminconfig -> submissionstatement ) ) { $ options = array ( 'context... | Get the correct submission statement depending on single submisison team submission or team submission where all team memebers must submit . |
29,941 | public function load_data ( ) { global $ DB ; $ context = context_module :: instance ( $ this -> cmid ) ; if ( empty ( $ this -> fileid ) ) { if ( empty ( $ this -> sid ) || empty ( $ this -> area ) ) { throw new portfolio_caller_exception ( 'invalidfileandsubmissionid' , 'mod_assign' ) ; } $ submission = $ DB -> get_r... | Load data needed for the portfolio export . |
29,942 | protected function get_submission_plugin ( ) { global $ CFG ; if ( ! $ this -> plugin || ! $ this -> cmid ) { return null ; } require_once ( $ CFG -> dirroot . '/mod/assign/locallib.php' ) ; $ context = context_module :: instance ( $ this -> cmid ) ; $ assignment = new assign ( $ context , null , null ) ; return $ assi... | Fetch the plugin by its type . |
29,943 | public function get_sha1 ( ) { if ( $ this -> plugin && $ this -> editor ) { $ plugin = $ this -> get_submission_plugin ( ) ; $ options = portfolio_format_text_options ( ) ; $ options -> context = context_module :: instance ( $ this -> cmid ) ; $ text = format_text ( $ plugin -> get_editor_text ( $ this -> editor , $ t... | Calculate a sha1 has of either a single file or a list of files based on the data set by load_data . |
29,944 | public function setLevel ( $ level ) { if ( ! array_key_exists ( $ level , self :: $ levels ) ) { throw new Mustache_Exception_InvalidArgumentException ( sprintf ( 'Unexpected logging level: %s' , $ level ) ) ; } $ this -> level = $ level ; } | Set the minimum logging level . |
29,945 | protected function writeLog ( $ level , $ message , array $ context = array ( ) ) { if ( ! is_resource ( $ this -> stream ) ) { if ( ! isset ( $ this -> url ) ) { throw new Mustache_Exception_LogicException ( 'Missing stream url, the stream can not be opened. This may be caused by a premature call to close().' ) ; } $ ... | Write a record to the log . |
29,946 | protected static function formatLine ( $ level , $ message , array $ context = array ( ) ) { return sprintf ( "%s: %s\n" , self :: getLevelName ( $ level ) , self :: interpolateMessage ( $ message , $ context ) ) ; } | Format a log line for output . |
29,947 | public function render ( $ string ) { return $ this -> mustache -> loadLambda ( ( string ) $ string , $ this -> delims ) -> renderInternal ( $ this -> context ) ; } | Render a string as a Mustache template with the current rendering context . |
29,948 | public function init ( ) { if ( $ this -> csvreader == null ) { $ this -> csvreader = new csv_import_reader ( $ this -> importid , 'assignfeedback_offline' ) ; } $ this -> csvreader -> init ( ) ; $ columns = $ this -> csvreader -> get_columns ( ) ; $ strgrade = get_string ( 'grade' ) ; $ strid = get_string ( 'recordid'... | Initialise the import reader and locate the column indexes . |
29,949 | public function count_response ( $ subpart , $ try = 0 ) { $ responseanalysisforclass = $ this -> get_response_class ( $ subpart -> responseclassid ) ; $ responseanalysisforclass -> count_response ( $ subpart -> response , $ subpart -> fraction , $ try ) ; } | Count a part of a response . |
29,950 | public function cache ( $ qubaids , $ whichtries , $ questionid , $ variantno , $ subpartid ) { foreach ( $ this -> get_response_class_ids ( ) as $ responseclassid ) { $ analysisforclass = $ this -> get_response_class ( $ responseclassid ) ; $ analysisforclass -> cache ( $ qubaids , $ whichtries , $ questionid , $ vari... | Cache analysis for sub part . |
29,951 | public function has_actual_responses ( ) { foreach ( $ this -> get_response_class_ids ( ) as $ responseclassid ) { if ( $ this -> get_response_class ( $ responseclassid ) -> has_actual_responses ( ) ) { return true ; } } return false ; } | Has actual responses different to the model response for this class? |
29,952 | public function get_maximum_tries ( ) { $ max = 1 ; foreach ( $ this -> get_response_class_ids ( ) as $ responseclassid ) { $ max = max ( $ max , $ this -> get_response_class ( $ responseclassid ) -> get_maximum_tries ( ) ) ; } return $ max ; } | What is the highest try number for this sub part? |
29,953 | protected function process_actions ( $ quiz , $ cm , $ currentgroup , \ core \ dml \ sql_join $ groupstudentsjoins , \ core \ dml \ sql_join $ allowedjoins , $ redirecturl ) { parent :: process_actions ( $ quiz , $ cm , $ currentgroup , $ groupstudentsjoins , $ allowedjoins , $ redirecturl ) ; if ( empty ( $ currentgro... | Extends parent function processing any submitted actions . |
29,954 | protected function start_regrade ( $ quiz , $ cm ) { require_capability ( 'mod/quiz:regrade' , $ this -> context ) ; $ this -> print_header_and_tabs ( $ cm , $ this -> course , $ quiz , $ this -> mode ) ; } | Check necessary capabilities and start the display of the regrade progress page . |
29,955 | protected function finish_regrade ( $ nexturl ) { global $ OUTPUT ; \ core \ notification :: success ( get_string ( 'regradecomplete' , 'quiz_overview' ) ) ; echo $ OUTPUT -> continue_button ( $ nexturl ) ; echo $ OUTPUT -> footer ( ) ; die ( ) ; } | Finish displaying the regrade progress page . |
29,956 | protected function regrade_attempts ( $ quiz , $ dryrun = false , \ core \ dml \ sql_join $ groupstudentsjoins = null , $ attemptids = array ( ) ) { global $ DB ; $ this -> unlock_session ( ) ; $ sql = "SELECT quiza.* FROM {quiz_attempts} quiza" ; $ where = "quiz = :qid AND preview = 0" ; $ params = ar... | Regrade attempts for this quiz exactly which attempts are regraded is controlled by the parameters . |
29,957 | protected function regrade_attempts_needing_it ( $ quiz , \ core \ dml \ sql_join $ groupstudentsjoins ) { global $ DB ; $ this -> unlock_session ( ) ; $ join = '{quiz_overview_regrades} qqr ON qqr.questionusageid = quiza.uniqueid' ; $ where = "quiza.quiz = :qid AND quiza.preview = 0 AND qqr.regraded = 0" ; $ params = ... | Regrade those questions in those attempts that are marked as needing regrading in the quiz_overview_regrades table . |
29,958 | protected function count_question_attempts_needing_regrade ( $ quiz , \ core \ dml \ sql_join $ groupstudentsjoins ) { global $ DB ; $ userjoin = '' ; $ usertest = '' ; $ params = array ( ) ; if ( $ this -> hasgroupstudents ) { $ userjoin = "JOIN {user} u ON u.id = quiza.userid {$groupstudentsjoins->... | Count the number of attempts in need of a regrade . |
29,959 | public static function get_bands_count_and_width ( $ quiz ) { $ bands = $ quiz -> grade ; while ( $ bands > 20 || $ bands <= 10 ) { if ( $ bands > 50 ) { $ bands /= 5 ; } else if ( $ bands > 20 ) { $ bands /= 2 ; } if ( $ bands < 4 ) { $ bands *= 5 ; } else if ( $ bands <= 10 ) { $ bands *= 2 ; } } $ bands = ( int ) ce... | Get the bands configuration for the quiz . |
29,960 | public static function get_bands_labels ( $ bands , $ bandwidth , $ quiz ) { $ bandlabels = [ ] ; for ( $ i = 1 ; $ i <= $ bands ; $ i ++ ) { $ bandlabels [ ] = quiz_format_grade ( $ quiz , ( $ i - 1 ) * $ bandwidth ) . ' - ' . quiz_format_grade ( $ quiz , $ i * $ bandwidth ) ; } return $ bandlabels ; } | Get the bands labels . |
29,961 | protected static function get_chart ( $ labels , $ data ) { $ chart = new \ core \ chart_bar ( ) ; $ chart -> set_labels ( $ labels ) ; $ chart -> get_xaxis ( 0 , true ) -> set_label ( get_string ( 'grade' ) ) ; $ yaxis = $ chart -> get_yaxis ( 0 , true ) ; $ yaxis -> set_label ( get_string ( 'participants' ) ) ; $ yax... | Get a chart . |
29,962 | public static function file_exists ( $ pFilename ) { if ( strtolower ( substr ( $ pFilename , 0 , 3 ) ) == 'zip' ) { $ zipFile = substr ( $ pFilename , 6 , strpos ( $ pFilename , '#' ) - 6 ) ; $ archiveFile = substr ( $ pFilename , strpos ( $ pFilename , '#' ) + 1 ) ; $ zip = new ZipArchive ( ) ; if ( $ zip -> open ( $... | Verify if a file exists |
29,963 | public static function delete_data_for_userlist ( \ core_privacy \ local \ request \ approved_userlist $ userlist ) { list ( $ db , $ table ) = static :: get_database_and_table ( ) ; if ( ! $ db || ! $ table ) { return ; } list ( $ insql , $ inparams ) = $ db -> get_in_or_equal ( $ userlist -> get_userids ( ) , SQL_PAR... | Delete all user data for the specified users in the specified context . |
29,964 | function get_plugin_type ( $ dirpath ) { global $ CFG ; $ dirpath = $ CFG -> dirroot . $ dirpath ; $ plugintypes = array_reverse ( core_component :: get_plugin_types ( ) ) ; foreach ( $ plugintypes as $ plugintype => $ pluginbasedir ) { if ( substr ( $ dirpath , 0 , strlen ( $ pluginbasedir ) ) == $ pluginbasedir ) { r... | From a given path work out what type of plugin this belongs to |
29,965 | public function dispose ( ) { if ( $ this -> generator ) { $ this -> generator -> dispose ( ) ; $ this -> generator = null ; } $ this -> mdb = null ; } | Releases all resources |
29,966 | public function find_index_name ( xmldb_table $ xmldb_table , xmldb_index $ xmldb_index , $ returnall = false ) { $ tablename = $ xmldb_table -> getName ( ) ; if ( ! $ this -> table_exists ( $ xmldb_table ) ) { throw new ddl_table_missing_exception ( $ tablename ) ; } $ indcolumns = $ xmldb_index -> getFields ( ) ; $ i... | Given one xmldb_index the function returns the name of the index in DB of false if it doesn t exist |
29,967 | public function delete_tables_from_xmldb_file ( $ file ) { $ xmldb_file = new xmldb_file ( $ file ) ; if ( ! $ xmldb_file -> fileExists ( ) ) { throw new ddl_exception ( 'ddlxmlfileerror' , null , 'File does not exist' ) ; } $ loaded = $ xmldb_file -> loadXMLStructure ( ) ; $ structure = $ xmldb_file -> getStructure ( ... | This function will delete all tables found in XMLDB file from db |
29,968 | private function load_xmldb_file ( $ file ) { $ xmldb_file = new xmldb_file ( $ file ) ; if ( ! $ xmldb_file -> fileExists ( ) ) { throw new ddl_exception ( 'ddlxmlfileerror' , null , 'File does not exist' ) ; } $ loaded = $ xmldb_file -> loadXMLStructure ( ) ; if ( ! $ loaded || ! $ xmldb_file -> isLoaded ( ) ) { if (... | Load an install . xml file checking that it exists and that the structure is OK . |
29,969 | public function install_from_xmldb_structure ( $ xmldb_structure ) { if ( ! $ sqlarr = $ this -> generator -> getCreateStructureSQL ( $ xmldb_structure ) ) { return ; } $ tablenames = array ( ) ; foreach ( $ xmldb_structure as $ xmldb_table ) { if ( $ xmldb_table instanceof xmldb_table ) { $ tablenames [ ] = $ xmldb_ta... | This function will generate all the needed SQL statements specific for each RDBMS type and finally it will execute all those statements against the DB . |
29,970 | public function rename_table ( xmldb_table $ xmldb_table , $ newname ) { if ( ! $ newname ) { throw new ddl_exception ( 'ddlunknownerror' , null , 'newname can not be empty' ) ; } $ check = new xmldb_table ( $ newname ) ; if ( ! $ this -> table_exists ( $ xmldb_table ) ) { if ( $ this -> table_exists ( $ check ) ) { th... | This function will rename the table passed as argument Before renaming the index the function will check it exists |
29,971 | public function add_field ( xmldb_table $ xmldb_table , xmldb_field $ xmldb_field ) { if ( $ this -> field_exists ( $ xmldb_table , $ xmldb_field ) ) { throw new ddl_exception ( 'ddlfieldalreadyexists' , $ xmldb_field -> getName ( ) ) ; } if ( $ xmldb_field -> getNotNull ( ) && $ this -> generator -> getDefaultValue ( ... | This function will add the field to the table passed as arguments |
29,972 | public function drop_field ( xmldb_table $ xmldb_table , xmldb_field $ xmldb_field ) { if ( ! $ this -> table_exists ( $ xmldb_table ) ) { throw new ddl_table_missing_exception ( $ xmldb_table -> getName ( ) ) ; } if ( ! $ this -> field_exists ( $ xmldb_table , $ xmldb_field ) ) { throw new ddl_field_missing_exception ... | This function will drop the field from the table passed as arguments |
29,973 | public function change_field_type ( xmldb_table $ xmldb_table , xmldb_field $ xmldb_field ) { if ( ! $ this -> table_exists ( $ xmldb_table ) ) { throw new ddl_table_missing_exception ( $ xmldb_table -> getName ( ) ) ; } if ( ! $ this -> field_exists ( $ xmldb_table , $ xmldb_field ) ) { throw new ddl_field_missing_exc... | This function will change the type of the field in the table passed as arguments |
29,974 | public function change_field_default ( xmldb_table $ xmldb_table , xmldb_field $ xmldb_field ) { if ( ! $ this -> table_exists ( $ xmldb_table ) ) { throw new ddl_table_missing_exception ( $ xmldb_table -> getName ( ) ) ; } if ( ! $ this -> field_exists ( $ xmldb_table , $ xmldb_field ) ) { throw new ddl_field_missing_... | This function will change the default of the field in the table passed as arguments One null value in the default field means delete the default |
29,975 | public function rename_field ( xmldb_table $ xmldb_table , xmldb_field $ xmldb_field , $ newname ) { if ( empty ( $ newname ) ) { throw new ddl_exception ( 'ddlunknownerror' , null , 'newname can not be empty' ) ; } if ( ! $ this -> table_exists ( $ xmldb_table ) ) { throw new ddl_table_missing_exception ( $ xmldb_tabl... | This function will rename the field in the table passed as arguments Before renaming the field the function will check it exists |
29,976 | private function check_field_dependencies ( xmldb_table $ xmldb_table , xmldb_field $ xmldb_field ) { if ( ! $ this -> table_exists ( $ xmldb_table ) ) { throw new ddl_table_missing_exception ( $ xmldb_table -> getName ( ) ) ; } if ( ! $ this -> field_exists ( $ xmldb_table , $ xmldb_field ) ) { throw new ddl_field_mis... | This function will check for the given table and field if there there is any dependency preventing the field to be modified . It s used by all the public methods that perform any DDL change on fields throwing one ddl_dependency_exception if dependencies are found . |
29,977 | public function add_key ( xmldb_table $ xmldb_table , xmldb_key $ xmldb_key ) { if ( $ xmldb_key -> getType ( ) == XMLDB_KEY_PRIMARY ) { throw new ddl_exception ( 'ddlunknownerror' , null , 'Primary Keys can be added at table create time only' ) ; } if ( ! $ sqlarr = $ this -> generator -> getAddKeySQL ( $ xmldb_table ... | This function will create the key in the table passed as arguments |
29,978 | public function drop_key ( xmldb_table $ xmldb_table , xmldb_key $ xmldb_key ) { if ( $ xmldb_key -> getType ( ) == XMLDB_KEY_PRIMARY ) { throw new ddl_exception ( 'ddlunknownerror' , null , 'Primary Keys can be deleted at table drop time only' ) ; } if ( ! $ sqlarr = $ this -> generator -> getDropKeySQL ( $ xmldb_tabl... | This function will drop the key in the table passed as arguments |
29,979 | public function add_index ( $ xmldb_table , $ xmldb_intex ) { if ( ! $ this -> table_exists ( $ xmldb_table ) ) { throw new ddl_table_missing_exception ( $ xmldb_table -> getName ( ) ) ; } if ( $ this -> index_exists ( $ xmldb_table , $ xmldb_intex ) ) { throw new ddl_exception ( 'ddlunknownerror' , null , 'Index ' . $... | This function will create the index in the table passed as arguments Before creating the index the function will check it doesn t exists |
29,980 | public function drop_index ( $ xmldb_table , $ xmldb_intex ) { if ( ! $ this -> table_exists ( $ xmldb_table ) ) { throw new ddl_table_missing_exception ( $ xmldb_table -> getName ( ) ) ; } if ( ! $ this -> index_exists ( $ xmldb_table , $ xmldb_intex ) ) { throw new ddl_exception ( 'ddlunknownerror' , null , 'Index ' ... | This function will drop the index in the table passed as arguments Before dropping the index the function will check it exists |
29,981 | public function rename_index ( $ xmldb_table , $ xmldb_intex , $ newname ) { debugging ( 'rename_index() is one experimental feature. You must not use it in production!' , DEBUG_DEVELOPER ) ; if ( ! $ newname ) { throw new ddl_exception ( 'ddlunknownerror' , null , 'newname can not be empty' ) ; } if ( ! $ this -> inde... | This function will rename the index in the table passed as arguments Before renaming the index the function will check it exists Experimental . Shouldn t be used at all! |
29,982 | public function get_install_xml_files ( ) : array { global $ CFG ; require_once ( $ CFG -> libdir . '/adminlib.php' ) ; $ files = [ ] ; $ dbdirs = get_db_directories ( ) ; foreach ( $ dbdirs as $ dbdir ) { $ filename = "{$dbdir}/install.xml" ; if ( file_exists ( $ filename ) ) { $ files [ ] = $ filename ; } } return $ ... | Get the list of install . xml files . |
29,983 | public function get_install_xml_schema ( ) { global $ CFG ; require_once ( $ CFG -> libdir . '/adminlib.php' ) ; $ schema = new xmldb_structure ( 'export' ) ; $ schema -> setVersion ( $ CFG -> version ) ; foreach ( $ this -> get_install_xml_files ( ) as $ filename ) { $ xmldb_file = new xmldb_file ( $ filename ) ; if (... | Reads the install . xml files for Moodle core and modules and returns an array of xmldb_structure object with xmldb_table from these files . |
29,984 | public function get_first_discussion_in_forum ( forum_entity $ forum ) : ? discussion_entity { $ records = $ this -> get_db ( ) -> get_records ( self :: TABLE , [ 'forum' => $ forum -> get_id ( ) , ] , 'timemodified ASC' , '*' , 0 , 1 ) ; $ records = $ this -> transform_db_records_to_entities ( $ records ) ; return cou... | Get the first discussion in the specified forum . |
29,985 | public function get_count_discussions_in_forum ( forum_entity $ forum ) : ? int { return $ this -> get_db ( ) -> count_records ( self :: TABLE , [ 'forum' => $ forum -> get_id ( ) ] ) ; } | Get the count of the discussions in the specified forum . |
29,986 | public function update_discussion ( discussion_entity $ discussion ) : ? discussion_entity { $ discussionrecord = $ this -> get_legacy_factory ( ) -> to_legacy_object ( $ discussion ) ; if ( $ this -> get_db ( ) -> update_record ( 'forum_discussions' , $ discussionrecord ) ) { $ records = $ this -> transform_db_records... | Update the discussion |
29,987 | public function edit_field_add ( $ mform ) { $ calendartype = \ core_calendar \ type_factory :: get_calendar_instance ( ) ; if ( $ this -> field -> required ) { $ optional = false ; } else { $ optional = true ; } $ startdate = $ calendartype -> convert_from_gregorian ( $ this -> field -> param1 , 1 , 1 ) ; $ stopdate =... | Handles editing datetime fields . |
29,988 | public function edit_save_data_preprocess ( $ datetime , $ datarecord ) { if ( ! $ datetime ) { return 0 ; } if ( is_numeric ( $ datetime ) ) { $ gregoriancalendar = \ core_calendar \ type_factory :: get_calendar_instance ( 'gregorian' ) ; $ datetime = $ gregoriancalendar -> timestamp_to_date_string ( $ datetime , '%Y-... | If timestamp is in YYYY - MM - DD or YYYY - MM - DD - HH - MM - SS format then convert it to timestamp . |
29,989 | public function display_data ( ) { if ( ! empty ( $ this -> field -> param3 ) ) { $ format = get_string ( 'strftimedaydatetime' , 'langconfig' ) ; } else { $ format = get_string ( 'strftimedate' , 'langconfig' ) ; } if ( empty ( $ this -> data ) ) { return get_string ( 'notset' , 'profilefield_datetime' ) ; } else { re... | Display the data for this field . |
29,990 | public function isEOF ( ) { if ( $ this -> chunkOffset === $ this -> numChunks - 1 ) { return $ this -> bufferOffset >= $ this -> expectedLastChunkSize ; } return $ this -> chunkOffset >= $ this -> numChunks ; } | Return whether the current read position is at the end of the stream . |
29,991 | public function seek ( $ offset ) { if ( $ offset < 0 || $ offset > $ this -> file -> length ) { throw new InvalidArgumentException ( sprintf ( '$offset must be >= 0 and <= %d; given: %d' , $ this -> file -> length , $ offset ) ) ; } $ lastChunkOffset = $ this -> chunkOffset ; $ this -> chunkOffset = ( integer ) floor ... | Seeks the chunk and buffer offsets for the next read operation . |
29,992 | private function initBufferFromCurrentChunk ( ) { if ( $ this -> chunkOffset === 0 && $ this -> numChunks === 0 ) { return false ; } if ( ! $ this -> chunksIterator -> valid ( ) ) { throw CorruptFileException :: missingChunk ( $ this -> chunkOffset ) ; } $ currentChunk = $ this -> chunksIterator -> current ( ) ; if ( $... | Initialize the buffer to the current chunk s data . |
29,993 | private function initBufferFromNextChunk ( ) { if ( $ this -> chunkOffset === $ this -> numChunks - 1 ) { return false ; } $ this -> bufferOffset = 0 ; $ this -> chunkOffset ++ ; $ this -> chunksIterator -> next ( ) ; return $ this -> initBufferFromCurrentChunk ( ) ; } | Advance to the next chunk and initialize the buffer to its data . |
29,994 | private function initChunksIterator ( ) { $ cursor = $ this -> collectionWrapper -> findChunksByFileId ( $ this -> file -> _id , $ this -> chunkOffset ) ; $ this -> chunksIterator = new IteratorIterator ( $ cursor ) ; $ this -> chunksIterator -> rewind ( ) ; } | Initializes the chunk iterator starting from the current offset . |
29,995 | function add_field_php ( $ structure , $ table , $ field ) { $ result = '' ; if ( ! $ table = $ structure -> getTable ( $ table ) ) { return false ; } if ( ! $ field = $ table -> getField ( $ field ) ) { return false ; } if ( $ table -> getAllErrors ( ) ) { return false ; } $ result .= XMLDB_PHP_HEADER ; $ result .= XM... | This function will generate all the PHP code needed to create one field using XMLDB objects and functions |
29,996 | function drop_field_php ( $ structure , $ table , $ field ) { $ result = '' ; if ( ! $ table = $ structure -> getTable ( $ table ) ) { return false ; } if ( ! $ field = $ table -> getField ( $ field ) ) { return false ; } if ( $ table -> getAllErrors ( ) ) { return false ; } $ result .= XMLDB_PHP_HEADER ; $ result .= X... | This function will generate all the PHP code needed to drop one field using XMLDB objects and functions |
29,997 | function change_field_precision_php ( $ structure , $ table , $ field ) { $ result = '' ; if ( ! $ table = $ structure -> getTable ( $ table ) ) { return false ; } if ( ! $ field = $ table -> getField ( $ field ) ) { return false ; } if ( $ table -> getAllErrors ( ) ) { return false ; } $ precision = '(' . $ field -> g... | This function will generate all the PHP code needed to change the precision of one field using XMLDB objects and functions |
29,998 | function drop_key_php ( $ structure , $ table , $ key ) { $ result = '' ; if ( ! $ table = $ structure -> getTable ( $ table ) ) { return false ; } if ( ! $ key = $ table -> getKey ( $ key ) ) { return false ; } if ( $ table -> getAllErrors ( ) ) { return false ; } $ result .= XMLDB_PHP_HEADER ; $ result .= XMLDB_LINEF... | This function will generate all the PHP code needed to drop one key using XMLDB objects and functions |
29,999 | function add_index_php ( $ structure , $ table , $ index ) { $ result = '' ; if ( ! $ table = $ structure -> getTable ( $ table ) ) { return false ; } if ( ! $ index = $ table -> getIndex ( $ index ) ) { return false ; } if ( $ table -> getAllErrors ( ) ) { return false ; } $ result .= XMLDB_PHP_HEADER ; $ result .= XM... | This function will generate all the PHP code needed to create one index using XMLDB objects and functions |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.