idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
29,600
public static function build ( $ params ) { global $ CFG ; require_once ( $ CFG -> libdir . '/badgeslib.php' ) ; $ types = badges_list_criteria ( false ) ; if ( ! isset ( $ params [ 'criteriatype' ] ) || ! isset ( $ types [ $ params [ 'criteriatype' ] ] ) ) { print_error ( 'error:invalidcriteriatype' , 'badges' ) ; } $...
Factory method for creating criteria class object
29,601
public function config_form_criteria ( $ data ) { global $ OUTPUT ; $ agg = $ data -> get_aggregation_methods ( ) ; $ editurl = new moodle_url ( '/badges/criteria_settings.php' , array ( 'badgeid' => $ this -> badgeid , 'edit' => true , 'type' => $ this -> criteriatype , 'crit' => $ this -> id ) ) ; $ deleteurl = new m...
Add appropriate criteria elements
29,602
public function mark_complete ( $ userid ) { global $ DB ; $ obj = array ( ) ; $ obj [ 'critid' ] = $ this -> id ; $ obj [ 'userid' ] = $ userid ; $ obj [ 'datemet' ] = time ( ) ; if ( ! $ DB -> record_exists ( 'badge_criteria_met' , array ( 'critid' => $ this -> id , 'userid' => $ userid ) ) ) { $ DB -> insert_record ...
Mark this criteria as complete for a user
29,603
public function get_params ( $ cid ) { global $ DB ; $ params = array ( ) ; $ records = $ DB -> get_records ( 'badge_criteria_param' , array ( 'critid' => $ cid ) ) ; foreach ( $ records as $ rec ) { $ arr = explode ( '_' , $ rec -> name ) ; $ params [ $ arr [ 1 ] ] [ $ arr [ 0 ] ] = $ rec -> value ; } return $ params ...
Return criteria parameters
29,604
public function delete ( ) { global $ DB , $ PAGE ; $ DB -> delete_records ( 'badge_criteria_met' , array ( 'critid' => $ this -> id ) ) ; $ DB -> delete_records ( 'badge_criteria_param' , array ( 'critid' => $ this -> id ) ) ; $ DB -> delete_records ( 'badge_criteria' , array ( 'id' => $ this -> id ) ) ; $ eventparams...
Delete this criterion
29,605
public static function create ( $ quizid , $ userid = null ) { global $ DB ; $ quiz = quiz_access_manager :: load_quiz_and_settings ( $ quizid ) ; $ course = $ DB -> get_record ( 'course' , array ( 'id' => $ quiz -> course ) , '*' , MUST_EXIST ) ; $ cm = get_coursemodule_from_instance ( 'quiz' , $ quiz -> id , $ course...
Static function to create a new quiz object for a specific user .
29,606
public function get_sections ( ) { global $ DB ; if ( $ this -> sections === null ) { $ this -> sections = array_values ( $ DB -> get_records ( 'quiz_sections' , array ( 'quizid' => $ this -> get_quizid ( ) ) , 'firstslot' ) ) ; } return $ this -> sections ; }
Get all the sections in this quiz .
29,607
public function get_access_manager ( $ timenow ) { if ( is_null ( $ this -> accessmanager ) ) { $ this -> accessmanager = new quiz_access_manager ( $ this , $ timenow , has_capability ( 'mod/quiz:ignoretimelimits' , $ this -> context , null , false ) ) ; } return $ this -> accessmanager ; }
Return quiz_access_manager and instance of the quiz_access_manager class for this quiz at this time .
29,608
protected function ensure_question_loaded ( $ id ) { if ( isset ( $ this -> questions [ $ id ] -> _partiallyloaded ) ) { throw new moodle_quiz_exception ( $ this , 'questionnotloaded' , $ id ) ; } }
Check that the definition of a particular question is loaded and if not throw an exception .
29,609
public function get_all_question_types_used ( $ includepotential = false ) { $ questiontypes = array ( ) ; $ qcategories = array ( ) ; foreach ( $ this -> get_questions ( ) as $ questiondata ) { if ( $ questiondata -> qtype == 'random' and $ includepotential ) { $ includesubcategories = ( bool ) $ questiondata -> quest...
Return all the question types used in this quiz .
29,610
protected function link_sections_and_slots ( ) { foreach ( $ this -> sections as $ i => $ section ) { if ( isset ( $ this -> sections [ $ i + 1 ] ) ) { $ section -> lastslot = $ this -> sections [ $ i + 1 ] -> firstslot - 1 ; } else { $ section -> lastslot = count ( $ this -> slots ) ; } for ( $ slot = $ section -> fir...
Let each slot know which section it is part of .
29,611
protected function determine_layout ( ) { $ this -> pagelayout = array ( ) ; $ pagelayouts = explode ( ',0' , $ this -> attempt -> layout ) ; if ( end ( $ pagelayouts ) == '' ) { array_pop ( $ pagelayouts ) ; } $ unseensections = $ this -> sections ; $ this -> pagelayout = array ( ) ; foreach ( $ pagelayouts as $ page ...
Parse attempt - > layout to populate the other arrays the represent the layout .
29,612
public function has_response_to_at_least_one_graded_question ( ) { foreach ( $ this -> quba -> get_attempt_iterator ( ) as $ qa ) { if ( $ qa -> get_max_mark ( ) == 0 ) { continue ; } if ( $ qa -> get_num_steps ( ) > 1 ) { return true ; } } return false ; }
Has the student in this attempt engaged with the quiz in a non - trivial way? That is is there any question worth a non - zero number of marks where the student has made some response that we have saved?
29,613
public function check_review_capability ( ) { if ( $ this -> get_attempt_state ( ) == mod_quiz_display_options :: IMMEDIATELY_AFTER ) { $ capability = 'mod/quiz:attempt' ; } else { $ capability = 'mod/quiz:reviewmyattempts' ; } if ( $ this -> has_capability ( $ capability ) ) { return ; } if ( $ this -> has_capability ...
Check the appropriate capability to see whether this user may review their own attempt . If not prints an error .
29,614
public function all_question_attempts_originally_in_slot ( $ slot ) { $ qas = array ( ) ; foreach ( $ this -> quba -> get_attempt_iterator ( ) as $ qa ) { if ( $ qa -> get_metadata ( 'originalslot' ) == $ slot ) { $ qas [ ] = $ qa ; } } $ qas [ ] = $ this -> quba -> get_question_attempt ( $ slot ) ; return $ qas ; }
Get the question_attempt object for a particular question in this attempt .
29,615
public function is_blocked_by_previous_question ( $ slot ) { return $ slot > 1 && isset ( $ this -> slots [ $ slot ] ) && $ this -> slots [ $ slot ] -> requireprevious && ! $ this -> slots [ $ slot ] -> section -> shufflequestions && ! $ this -> slots [ $ slot - 1 ] -> section -> shufflequestions && $ this -> get_navig...
Checks whether the question in this slot requires the previous question to have been completed .
29,616
public function can_question_be_redone_now ( $ slot ) { return $ this -> get_quiz ( ) -> canredoquestions && ! $ this -> is_finished ( ) && $ this -> get_question_state ( $ slot ) -> is_finished ( ) ; }
Is it possible for this question to be re - started within this attempt?
29,617
public function get_original_slot ( $ slot ) { $ originalslot = $ this -> quba -> get_question_attempt_metadata ( $ slot , 'originalslot' ) ; if ( $ originalslot ) { return $ originalslot ; } else { return $ slot ; } }
Given a slot in this attempt which may or not be a redone question return the original slot .
29,618
public function get_heading_before_slot ( $ slot ) { if ( $ this -> slots [ $ slot ] -> firstinsection ) { return $ this -> slots [ $ slot ] -> section -> heading ; } else { return null ; } }
If the section heading if any that should come just before this slot .
29,619
public function get_time_left_display ( $ timenow ) { if ( $ this -> attempt -> state != self :: IN_PROGRESS ) { return false ; } return $ this -> get_access_manager ( $ timenow ) -> get_time_left_display ( $ this -> attempt , $ timenow ) ; }
Get the time remaining for an in - progress attempt if the time is short enought that it would be worth showing a timer .
29,620
public function get_due_date ( ) { $ deadlines = array ( ) ; if ( $ this -> quizobj -> get_quiz ( ) -> timelimit ) { $ deadlines [ ] = $ this -> attempt -> timestart + $ this -> quizobj -> get_quiz ( ) -> timelimit ; } if ( $ this -> quizobj -> get_quiz ( ) -> timeclose ) { $ deadlines [ ] = $ this -> quizobj -> get_qu...
If the attempt is in an applicable state work out the time by which the student should next do something .
29,621
public function get_html_head_contributions ( $ page = 'all' , $ showall = false ) { if ( $ showall ) { $ page = 'all' ; } $ result = '' ; foreach ( $ this -> get_slots ( $ page ) as $ slot ) { $ result .= $ this -> quba -> render_question_head_html ( $ slot ) ; } $ result .= question_engine :: initialise_js ( ) ; retu...
Initialise the JS etc . required all the questions on a page .
29,622
public function restart_preview_button ( ) { global $ OUTPUT ; if ( $ this -> is_preview ( ) && $ this -> is_preview_user ( ) ) { return $ OUTPUT -> single_button ( new moodle_url ( $ this -> start_attempt_url ( ) , array ( 'forcenew' => true ) ) , get_string ( 'startnewpreview' , 'quiz' ) ) ; } else { return '' ; } }
Print the HTML for the start new preview button if the current user is allowed to see one .
29,623
public function render_question ( $ slot , $ reviewing , mod_quiz_renderer $ renderer , $ thispageurl = null ) { if ( $ this -> is_blocked_by_previous_question ( $ slot ) ) { $ placeholderqa = $ this -> make_blocked_question_placeholder ( $ slot ) ; $ displayoptions = $ this -> get_display_options ( $ reviewing ) ; $ d...
Generate the HTML that displayes the question in its current state with the appropriate display options .
29,624
protected function make_blocked_question_placeholder ( $ slot ) { $ replacedquestion = $ this -> get_question_attempt ( $ slot ) -> get_question ( ) ; question_bank :: load_question_definition_classes ( 'description' ) ; $ question = new qtype_description_question ( ) ; $ question -> id = $ replacedquestion -> id ; $ q...
Create a fake question to be displayed in place of a question that is blocked until the previous question has been answered .
29,625
public function check_file_access ( $ slot , $ reviewing , $ contextid , $ component , $ filearea , $ args , $ forcedownload ) { $ options = $ this -> get_display_options ( $ reviewing ) ; if ( $ reviewing && $ this -> is_own_attempt ( ) && ! $ options -> attempt ) { return false ; } if ( $ reviewing && ! $ this -> is_...
Check wheter access should be allowed to a particular file .
29,626
public function get_navigation_panel ( mod_quiz_renderer $ output , $ panelclass , $ page , $ showall = false ) { $ panel = new $ panelclass ( $ this , $ this -> get_display_options ( true ) , $ page , $ showall ) ; $ bc = new block_contents ( ) ; $ bc -> attributes [ 'id' ] = 'mod_quiz_navblock' ; $ bc -> attributes [...
Get the navigation panel object for this attempt .
29,627
public function links_to_other_attempts ( moodle_url $ url ) { $ attempts = quiz_get_user_attempts ( $ this -> get_quiz ( ) -> id , $ this -> attempt -> userid , 'all' ) ; if ( count ( $ attempts ) <= 1 ) { return false ; } $ links = new mod_quiz_links_to_other_attempts ( ) ; foreach ( $ attempts as $ at ) { if ( $ at ...
Return an array of variant URLs to other attempts at this quiz .
29,628
public function links_to_other_redos ( $ slot , moodle_url $ baseurl ) { $ originalslot = $ this -> get_original_slot ( $ slot ) ; $ qas = $ this -> all_question_attempts_originally_in_slot ( $ originalslot ) ; if ( count ( $ qas ) <= 1 ) { return null ; } $ links = new mod_quiz_links_to_other_attempts ( ) ; $ index = ...
Return an array of variant URLs to other redos of the question in a particular slot .
29,629
public function handle_if_time_expired ( $ timestamp , $ studentisonline ) { global $ DB ; $ timeclose = $ this -> get_access_manager ( $ timestamp ) -> get_end_time ( $ this -> attempt ) ; if ( $ timeclose === false || $ this -> is_preview ( ) ) { $ this -> update_timecheckstate ( null ) ; return ; } if ( $ timestamp ...
Check this attempt to see if there are any state transitions that should happen automatically . This function will update the attempt checkstatetime .
29,630
public function process_submitted_actions ( $ timestamp , $ becomingoverdue = false , $ simulatedresponses = null ) { global $ DB ; $ transaction = $ DB -> start_delegated_transaction ( ) ; if ( $ simulatedresponses !== null ) { if ( is_int ( key ( $ simulatedresponses ) ) ) { $ simulatedpostdata = $ this -> quba -> pr...
Process all the actions that were submitted as part of the current request .
29,631
public function process_redo_question ( $ slot , $ timestamp ) { global $ DB ; if ( ! $ this -> can_question_be_redone_now ( $ slot ) ) { throw new coding_exception ( 'Attempt to restart the question in slot ' . $ slot . ' when it is not in a state to be restarted.' ) ; } $ qubaids = new \ mod_quiz \ question \ qubaids...
Replace a question in an attempt with a new attempt at the same qestion .
29,632
public function process_auto_save ( $ timestamp ) { global $ DB ; $ transaction = $ DB -> start_delegated_transaction ( ) ; $ this -> quba -> process_all_autosaves ( $ timestamp ) ; question_engine :: save_questions_usage_by_activity ( $ this -> quba ) ; $ transaction -> allow_commit ( ) ; }
Process all the autosaved data that was part of the current request .
29,633
public function update_timecheckstate ( $ time ) { global $ DB ; if ( $ this -> attempt -> timecheckstate !== $ time ) { $ this -> attempt -> timecheckstate = $ time ; $ DB -> set_field ( 'quiz_attempts' , 'timecheckstate' , $ time , array ( 'id' => $ this -> attempt -> id ) ) ; } }
Update this attempt timecheckstate if necessary .
29,634
public function process_going_overdue ( $ timestamp , $ studentisonline ) { global $ DB ; $ transaction = $ DB -> start_delegated_transaction ( ) ; $ this -> attempt -> timemodified = $ timestamp ; $ this -> attempt -> state = self :: OVERDUE ; $ this -> attempt -> timecheckstate = $ timestamp ; $ DB -> update_record (...
Mark this attempt as now overdue .
29,635
public function process_abandon ( $ timestamp , $ studentisonline ) { global $ DB ; $ transaction = $ DB -> start_delegated_transaction ( ) ; $ this -> attempt -> timemodified = $ timestamp ; $ this -> attempt -> state = self :: ABANDONED ; $ this -> attempt -> timecheckstate = null ; $ DB -> update_record ( 'quiz_atte...
Mark this attempt as abandoned .
29,636
protected function fire_state_transition_event ( $ eventclass , $ timestamp ) { global $ USER ; $ quizrecord = $ this -> get_quiz ( ) ; $ params = array ( 'context' => $ this -> get_quizobj ( ) -> get_context ( ) , 'courseid' => $ this -> get_courseid ( ) , 'objectid' => $ this -> attempt -> id , 'relateduserid' => $ t...
Fire a state transition event . the same event information .
29,637
public function check_page_access ( $ page ) { global $ DB ; if ( $ this -> get_currentpage ( ) != $ page ) { if ( $ this -> get_navigation_method ( ) == QUIZ_NAVMETHOD_SEQ && $ this -> get_currentpage ( ) > $ page ) { return false ; } } return true ; }
Check a page access to see if is an out of sequence access .
29,638
public function set_currentpage ( $ page ) { global $ DB ; if ( $ this -> check_page_access ( $ page ) ) { $ DB -> set_field ( 'quiz_attempts' , 'currentpage' , $ page , array ( 'id' => $ this -> get_attemptid ( ) ) ) ; return true ; } return false ; }
Update attempt page .
29,639
public function fire_attempt_viewed_event ( ) { $ params = array ( 'objectid' => $ this -> get_attemptid ( ) , 'relateduserid' => $ this -> get_userid ( ) , 'courseid' => $ this -> get_courseid ( ) , 'context' => context_module :: instance ( $ this -> get_cmid ( ) ) , 'other' => array ( 'quizid' => $ this -> get_quizid...
Trigger the attempt_viewed event .
29,640
public function fire_attempt_summary_viewed_event ( ) { $ params = array ( 'objectid' => $ this -> get_attemptid ( ) , 'relateduserid' => $ this -> get_userid ( ) , 'courseid' => $ this -> get_courseid ( ) , 'context' => context_module :: instance ( $ this -> get_cmid ( ) ) , 'other' => array ( 'quizid' => $ this -> ge...
Trigger the attempt_summary_viewed event .
29,641
public function fire_attempt_reviewed_event ( ) { $ params = array ( 'objectid' => $ this -> get_attemptid ( ) , 'relateduserid' => $ this -> get_userid ( ) , 'courseid' => $ this -> get_courseid ( ) , 'context' => context_module :: instance ( $ this -> get_cmid ( ) ) , 'other' => array ( 'quizid' => $ this -> get_quiz...
Trigger the attempt_reviewed event .
29,642
public function set_offline_modified_time ( $ time ) { global $ DB ; if ( WS_SERVER ) { $ this -> attempt -> timemodifiedoffline = $ time ; return true ; } return false ; }
Update the timemodifiedoffline attempt field . This function should be used only when web services are being used .
29,643
public function get_question_buttons ( ) { $ buttons = array ( ) ; foreach ( $ this -> attemptobj -> get_slots ( ) as $ slot ) { if ( $ heading = $ this -> attemptobj -> get_heading_before_slot ( $ slot ) ) { $ buttons [ ] = new quiz_nav_section_heading ( format_string ( $ heading ) ) ; } $ qa = $ this -> attemptobj ->...
Get the buttons and section headings to go in the quiz navigation block .
29,644
public function col_indicators ( $ log ) { $ indicatorclasses = json_decode ( $ log -> indicators ) ; $ indicators = array ( ) ; foreach ( $ indicatorclasses as $ indicatorclass ) { $ indicator = \ core_analytics \ manager :: get_indicator ( $ indicatorclass ) ; if ( $ indicator ) { $ indicators [ ] = $ indicator -> ge...
Generate the indicators column .
29,645
public function col_info ( $ log ) { global $ PAGE ; if ( empty ( $ log -> info ) && empty ( $ log -> dir ) ) { return '' ; } $ info = array ( ) ; if ( ! empty ( $ log -> info ) ) { $ info = json_decode ( $ log -> info ) ; } if ( ! empty ( $ log -> dir ) ) { $ info [ ] = get_string ( 'predictorresultsin' , 'tool_analyt...
Generate the info column .
29,646
public function query_db ( $ pagesize , $ useinitialsbar = true ) { $ total = count ( $ this -> model -> get_logs ( ) ) ; $ this -> pagesize ( $ pagesize , $ total ) ; $ this -> rawdata = $ this -> model -> get_logs ( $ this -> get_page_start ( ) , $ this -> get_page_size ( ) ) ; if ( $ useinitialsbar ) { $ this -> ini...
Query the logs table . Store results in the object for use by build_table .
29,647
public static function encode ( $ text , $ eol = "\n" , $ wrap = 76 ) { $ fp = fopen ( 'php://temp' , 'r+' ) ; stream_filter_append ( $ fp , 'convert.quoted-printable-encode' , STREAM_FILTER_WRITE , array ( 'line-break-chars' => $ eol , 'line-length' => $ wrap ) ) ; fwrite ( $ fp , $ text ) ; rewind ( $ fp ) ; $ out = ...
Encodes text via quoted - printable encoding .
29,648
protected static function get ( $ resource , $ args ) { global $ CFG ; if ( ! isset ( static :: $ resolver ) ) { $ klass = ! empty ( $ CFG -> core_competency_url_resolver ) ? $ CFG -> core_competency_url_resolver : 'tool_lp\\url_resolver' ; static :: $ resolver = new $ klass ( ) ; } if ( ! method_exists ( static :: $ r...
Defer to the resolver .
29,649
protected static function calculate_permission_tree ( array $ pathroleperms ) { $ pathallows = [ ] ; $ mindepth = 1000 ; $ maxdepth = 0 ; foreach ( $ pathroleperms as $ path => $ roles ) { $ evaluatedroleperms = [ ] ; $ innerpath = $ path ; while ( $ innerpath !== '' ) { $ roles = $ pathroleperms [ $ innerpath ] ; fore...
Calculates a permission tree based on an array of information about role permissions .
29,650
protected static function remove_duplicate_nodes ( $ parent ) { $ length = count ( $ parent -> children ) ; $ index = 0 ; while ( $ index < $ length ) { $ child = $ parent -> children [ $ index ] ; if ( $ child -> allow === $ parent -> allow ) { array_splice ( $ parent -> children , $ index , 1 ) ; $ length -- ; $ inde...
Removes duplicate nodes of a tree - where a child node has the same permission as its parent .
29,651
protected static function get_tree ( $ userid , $ capability ) { $ pathroleperms = self :: get_capability_info_at_each_context ( $ userid , $ capability ) ; $ root = self :: calculate_permission_tree ( $ pathroleperms ) ; unset ( $ pathroleperms ) ; $ root = self :: remove_negative_subtrees ( $ root ) ; self :: remove_...
Gets a permission tree for the given user and capability representing the value of that capability at different contexts across the system . The tree will be simplified as far as possible .
29,652
protected static function create_sql ( $ parent ) { global $ DB ; $ sql = '' ; $ params = [ ] ; if ( $ parent -> path !== null ) { $ sql = ' (x.path = ? OR ' . $ DB -> sql_like ( 'x.path' , '?' ) . ')' ; $ params [ ] = $ parent -> path ; $ params [ ] = $ parent -> path . '/%' ; if ( $ parent -> children ) { $ sql .= ' ...
Creates SQL suitable for restricting by contexts listed in the given permission tree .
29,653
public static function get_sql ( $ userid , $ capability ) { $ root = self :: get_tree ( $ userid , $ capability ) ; if ( ! $ root -> children ) { return [ false , false ] ; } return self :: create_sql ( $ root ) ; }
Gets SQL to restrict a query to contexts in which the user has a capability .
29,654
protected function readquestions ( $ text ) { try { $ xml = xmlize ( $ text , 0 , 'UTF-8' , true ) ; } catch ( xml_format_exception $ e ) { $ this -> error ( $ e -> getMessage ( ) , '' ) ; return false ; } $ questions = array ( ) ; $ this -> process_category ( $ xml , $ questions ) ; $ this -> process_tf ( $ xml , $ qu...
Parse the xml document into an array of questions
29,655
public function process_common ( $ questiondata ) { $ question = $ this -> defaultquestion ( ) ; $ this -> ishtml = $ this -> getpath ( $ questiondata , array ( '#' , 'BODY' , 0 , '#' , 'FLAGS' , 0 , '#' , 'ISHTML' , 0 , '@' , 'value' ) , false , false ) ; $ text = $ this -> getpath ( $ questiondata , array ( '#' , 'BO...
Do question import processing common to every qtype .
29,656
public function process_essay ( $ xml , & $ questions ) { if ( $ this -> getpath ( $ xml , array ( 'POOL' , '#' , 'QUESTION_ESSAY' ) , false , false ) ) { $ essayquestions = $ this -> getpath ( $ xml , array ( 'POOL' , '#' , 'QUESTION_ESSAY' ) , false , false ) ; } else { return ; } foreach ( $ essayquestions as $ this...
Process Essay Questions
29,657
public function process_mc ( $ xml , & $ questions ) { if ( $ this -> getpath ( $ xml , array ( 'POOL' , '#' , 'QUESTION_MULTIPLECHOICE' ) , false , false ) ) { $ mcquestions = $ this -> getpath ( $ xml , array ( 'POOL' , '#' , 'QUESTION_MULTIPLECHOICE' ) , false , false ) ; } else { return ; } foreach ( $ mcquestions ...
Process Multiple Choice Questions with single answer
29,658
public function process_ma ( $ xml , & $ questions ) { if ( $ this -> getpath ( $ xml , array ( 'POOL' , '#' , 'QUESTION_MULTIPLEANSWER' ) , false , false ) ) { $ maquestions = $ this -> getpath ( $ xml , array ( 'POOL' , '#' , 'QUESTION_MULTIPLEANSWER' ) , false , false ) ; } else { return ; } foreach ( $ maquestions ...
Process Multiple Choice Questions With Multiple Answers
29,659
public function process_fib ( $ xml , & $ questions ) { if ( $ this -> getpath ( $ xml , array ( 'POOL' , '#' , 'QUESTION_FILLINBLANK' ) , false , false ) ) { $ fibquestions = $ this -> getpath ( $ xml , array ( 'POOL' , '#' , 'QUESTION_FILLINBLANK' ) , false , false ) ; } else { return ; } foreach ( $ fibquestions as ...
Process Fill in the Blank Questions
29,660
public function generateCSS ( ) { $ output = new Less_Output_Mapped ( $ this -> contentsMap , $ this ) ; $ this -> root -> genCSS ( $ output ) ; $ sourceMapUrl = $ this -> getOption ( 'sourceMapURL' ) ; $ sourceMapFilename = $ this -> getOption ( 'sourceMapFilename' ) ; $ sourceMapContent = $ this -> generateJson ( ) ;...
Generates the CSS
29,661
public function fixWindowsPath ( $ path , $ addEndSlash = false ) { $ slash = ( $ addEndSlash ) ? '/' : '' ; if ( ! empty ( $ path ) ) { $ path = str_replace ( '\\' , '/' , $ path ) ; $ path = rtrim ( $ path , '/' ) . $ slash ; } return $ path ; }
fix windows paths
29,662
public function extend ( $ maxlifetime = 86400 ) { if ( $ this -> factory ) { return $ this -> factory -> extend_lock ( $ this , $ maxlifetime ) ; } return false ; }
Extend the lifetime of this lock . Not supported by all factories .
29,663
public function release ( ) { $ this -> released = true ; if ( empty ( $ this -> factory ) ) { return false ; } $ result = $ this -> factory -> release_lock ( $ this ) ; unset ( $ this -> factory ) ; $ this -> factory = null ; $ this -> key = '' ; return $ result ; }
Release this lock
29,664
private function backOff ( ) { $ delay = $ this -> getDelay ( ) ; $ this -> client -> getLogger ( ) -> debug ( 'Retrying task with backoff' , array ( 'request' => $ this -> name , 'retry' => $ this -> attempts , 'backoff_seconds' => $ delay ) ) ; usleep ( $ delay * 1000000 ) ; }
Sleeps in accordance to the backoff configurations .
29,665
public static function confirm_user ( $ username , $ secret ) { global $ PAGE ; $ warnings = array ( ) ; $ params = self :: validate_parameters ( self :: confirm_user_parameters ( ) , array ( 'username' => $ username , 'secret' => $ secret , ) ) ; $ context = context_system :: instance ( ) ; $ PAGE -> set_context ( $ c...
Confirm a user account .
29,666
public static function request_password_reset_parameters ( ) { return new external_function_parameters ( array ( 'username' => new external_value ( core_user :: get_property_type ( 'username' ) , 'User name' , VALUE_DEFAULT , '' ) , 'email' => new external_value ( core_user :: get_property_type ( 'email' ) , 'User emai...
Describes the parameters for request_password_reset .
29,667
public static function request_password_reset ( $ username = '' , $ email = '' ) { global $ CFG , $ PAGE ; require_once ( $ CFG -> dirroot . '/login/lib.php' ) ; $ warnings = array ( ) ; $ params = self :: validate_parameters ( self :: request_password_reset_parameters ( ) , array ( 'username' => $ username , 'email' =...
Requests a password reset .
29,668
public static function is_minor ( $ age , $ country ) { global $ CFG , $ PAGE ; require_once ( $ CFG -> dirroot . '/login/lib.php' ) ; $ params = self :: validate_parameters ( self :: is_minor_parameters ( ) , array ( 'age' => $ age , 'country' => $ country , ) ) ; if ( ! array_key_exists ( $ params [ 'country' ] , get...
Requests a check if a user is digital minor .
29,669
public static function is_age_digital_consent_verification_enabled ( ) { global $ PAGE ; $ context = context_system :: instance ( ) ; $ PAGE -> set_context ( $ context ) ; $ status = false ; if ( \ core_auth \ digital_consent :: is_age_digital_consent_verification_enabled ( ) ) { $ status = true ; } return array ( 'sta...
Checks if age digital consent verification is enabled .
29,670
public static function resend_confirmation_email_parameters ( ) { return new external_function_parameters ( array ( 'username' => new external_value ( core_user :: get_property_type ( 'username' ) , 'Username.' ) , 'password' => new external_value ( core_user :: get_property_type ( 'password' ) , 'Plain text password.'...
Describes the parameters for resend_confirmation_email .
29,671
public static function resend_confirmation_email ( $ username , $ password , $ redirect = '' ) { global $ PAGE ; $ warnings = array ( ) ; $ params = self :: validate_parameters ( self :: resend_confirmation_email_parameters ( ) , array ( 'username' => $ username , 'password' => $ password , 'redirect' => $ redirect , )...
Requests resend the confirmation email .
29,672
protected function col_cohortname ( $ data ) { global $ OUTPUT ; $ record = ( object ) array ( 'id' => $ data -> cohortid , 'idnumber' => $ data -> cohortidnumber , 'description' => $ data -> cohortdescription , 'visible' => $ data -> cohortvisible , 'name' => $ data -> cohortname , 'theme' => $ data -> cohorttheme ) ;...
Cohort name column .
29,673
protected function col_actions ( $ data ) { global $ OUTPUT ; $ action = new \ confirm_action ( get_string ( 'removecohortroleassignmentconfirm' , 'tool_cohortroles' ) ) ; $ url = new moodle_url ( $ this -> baseurl ) ; $ url -> params ( array ( 'removecohortroleassignment' => $ data -> id , 'sesskey' => sesskey ( ) ) )...
Actions column .
29,674
public static function get_converter ( $ name , $ tempdir , $ logger = null ) { global $ CFG ; $ name = clean_param ( $ name , PARAM_SAFEDIR ) ; $ classfile = "$CFG->dirroot/backup/converter/$name/lib.php" ; $ classname = "{$name}_converter" ; if ( ! file_exists ( $ classfile ) ) { throw new coding_exception ( "Convert...
Instantinates the given converter operating on a given directory
29,675
public function manual_comment ( question_attempt $ qa , question_display_options $ options ) { if ( $ options -> manualcomment == question_display_options :: EDITABLE ) { return $ this -> manual_comment_fields ( $ qa , $ options ) ; } else if ( $ options -> manualcomment == question_display_options :: VISIBLE ) { retu...
Display the manual comment and a link to edit it if appropriate .
29,676
protected function submit_button ( question_attempt $ qa , question_display_options $ options ) { if ( ! $ qa -> get_state ( ) -> is_active ( ) ) { return '' ; } $ attributes = array ( 'type' => 'submit' , 'id' => $ qa -> get_behaviour_field_name ( 'submit' ) , 'name' => $ qa -> get_behaviour_field_name ( 'submit' ) , ...
Several behaviours need a submit button so put the common code here . The button is disabled if the question is displayed read - only .
29,677
public function user_signup_with_confirmation ( $ user , $ notify = true , $ confirmationurl = null ) { global $ CFG , $ DB , $ SESSION ; require_once ( $ CFG -> dirroot . '/user/profile/lib.php' ) ; require_once ( $ CFG -> dirroot . '/user/lib.php' ) ; $ plainpassword = $ user -> password ; $ user -> password = hash_i...
Sign up a new user ready for confirmation .
29,678
public function delete_favourite ( string $ component , string $ itemtype , int $ itemid , \ context $ context ) { if ( ! in_array ( $ component , \ core_component :: get_component_names ( ) ) ) { throw new \ moodle_exception ( "Invalid component name '$component'" ) ; } try { $ favourite = $ this -> repo -> find_favou...
Delete a favourite item from an area and from within a context .
29,679
public function favourite_exists ( string $ component , string $ itemtype , int $ itemid , \ context $ context ) : bool { return $ this -> repo -> exists_by ( [ 'userid' => $ this -> userid , 'component' => $ component , 'itemtype' => $ itemtype , 'itemid' => $ itemid , 'contextid' => $ context -> id ] ) ; }
Check whether an item has been marked as a favourite in the respective area .
29,680
public function get_favourite ( string $ component , string $ itemtype , int $ itemid , \ context $ context ) { try { return $ this -> repo -> find_favourite ( $ this -> userid , $ component , $ itemtype , $ itemid , $ context -> id ) ; } catch ( \ dml_missing_record_exception $ e ) { return null ; } }
Get the favourite .
29,681
public function count_favourites_by_type ( string $ component , string $ itemtype , \ context $ context = null ) { $ criteria = [ 'userid' => $ this -> userid , 'component' => $ component , 'itemtype' => $ itemtype ] ; if ( $ context ) { $ criteria [ 'contextid' ] = $ context -> id ; } return $ this -> repo -> count_by...
Count the favourite by item type .
29,682
function getPGTIouFilename ( $ pgt_iou ) { phpCAS :: traceBegin ( ) ; $ filename = $ this -> getPath ( ) . "phpcas-" . hash ( "sha256" , $ pgt_iou ) ; phpCAS :: trace ( "Sha256 filename:" . $ filename ) ; phpCAS :: traceEnd ( ) ; return $ filename ; }
This method returns the filename corresponding to a PGT Iou .
29,683
function write ( $ pgt , $ pgt_iou ) { phpCAS :: traceBegin ( ) ; $ fname = $ this -> getPGTIouFilename ( $ pgt_iou ) ; if ( ! file_exists ( $ fname ) ) { touch ( $ fname ) ; @ chmod ( $ fname , 0600 ) ; if ( $ f = fopen ( $ fname , "w" ) ) { if ( fputs ( $ f , $ pgt ) === false ) { phpCAS :: error ( 'could not write P...
This method stores a PGT and its corresponding PGT Iou into a file . Echoes a warning on error .
29,684
function read ( $ pgt_iou ) { phpCAS :: traceBegin ( ) ; $ pgt = false ; $ fname = $ this -> getPGTIouFilename ( $ pgt_iou ) ; if ( file_exists ( $ fname ) ) { if ( ! ( $ f = fopen ( $ fname , "r" ) ) ) { phpCAS :: error ( 'could not open `' . $ fname . '\'' ) ; } else { if ( ( $ pgt = fgets ( $ f ) ) === false ) { php...
This method reads a PGT corresponding to a PGT Iou and deletes the corresponding file .
29,685
public function generateJson ( ) { $ sourceMap = array ( ) ; $ mappings = $ this -> generateMappings ( ) ; $ sourceMap [ 'version' ] = self :: VERSION ; $ file = $ this -> options [ 'sourceMapFilename' ] ; if ( $ file ) { $ sourceMap [ 'file' ] = $ file ; } $ root = $ this -> options [ 'sourceRoot' ] ; if ( $ root ) { ...
Generates the JSON source map
29,686
protected function getSourcesContent ( ) { if ( empty ( $ this -> sources ) ) { return null ; } $ content = array ( ) ; foreach ( $ this -> sources as $ sourceFile ) { $ content [ ] = file_get_contents ( $ sourceFile ) ; } return $ content ; }
Returns the sources contents
29,687
public function set_type ( $ type ) { if ( ! in_array ( $ type , [ self :: TYPE_DEFAULT , self :: TYPE_LINE ] ) ) { throw new coding_exception ( 'Invalid serie type.' ) ; } $ this -> type = $ type ; }
Set the type of the series .
29,688
public function determine_format ( ) { return new checkbox_attribute ( $ this -> get_name ( ) , $ this -> get_label ( ) , $ this -> is_checked ( ) , $ this -> is_disabled ( ) ) ; }
Generate the element used to render the UI
29,689
public function set ( $ value ) { if ( empty ( $ this -> grade -> id ) ) { if ( empty ( $ value ) ) { return false ; } $ gradeitem = $ this -> grade -> grade_item ; $ gradeitem -> update_final_grade ( $ this -> grade -> userid , null , 'singleview' , null , FORMAT_MOODLE ) ; $ gradeparams = array ( 'userid' => $ this -...
Set the value that was changed in the form .
29,690
private function EvalMixinCalls ( $ ruleset , $ env , & $ rsRuleCnt ) { for ( $ i = 0 ; $ i < $ rsRuleCnt ; $ i ++ ) { $ rule = $ ruleset -> rules [ $ i ] ; if ( $ rule instanceof Less_Tree_Mixin_Call ) { $ rule = $ rule -> compile ( $ env ) ; $ temp = array ( ) ; foreach ( $ rule as $ r ) { if ( ( $ r instanceof Less_...
Compile Less_Tree_Mixin_Call objects
29,691
public function matchCondition ( $ args , $ env ) { $ lastSelector = end ( $ this -> selectors ) ; if ( ! $ lastSelector -> evaldCondition ) { return false ; } if ( $ lastSelector -> condition && ! $ lastSelector -> condition -> compile ( $ env -> copyEvalEnv ( $ env -> frames ) ) ) { return false ; } return true ; }
lets you call a css selector with a guard
29,692
protected function prepare_form_fields ( array $ dims , array $ maps ) { $ formdata = new stdclass ( ) ; $ key = 0 ; foreach ( $ dims as $ dimension ) { $ formdata -> { 'dimensionid__idx_' . $ key } = $ dimension -> id ; $ formdata -> { 'description__idx_' . $ key } = $ dimension -> description ; $ formdata -> { 'descr...
Prepares the database data to be used by the mform
29,693
protected function errors_to_grade ( $ numerrors ) { $ grade = 100.00000 ; for ( $ i = 1 ; $ i <= $ numerrors ; $ i ++ ) { if ( isset ( $ this -> mappings [ $ i ] ) ) { $ grade = $ this -> mappings [ $ i ] -> grade ; } } if ( $ grade > 100.00000 ) { $ grade = 100.00000 ; } if ( $ grade < 0.00000 ) { $ grade = 0.00000 ;...
Returns a grade 0 . 00000 to 100 . 00000 for the given number of errors
29,694
protected function full_tag_found_in_cache ( $ tagname , $ latestline ) { if ( strpos ( strtolower ( $ latestline ) , '</' . strtolower ( $ tagname ) . '>' ) === false ) { return false ; } else if ( preg_match ( '{(<' . $ tagname . '\b.*?>.*?</' . $ tagname . '>)}is' , $ this -> xmlcache , $ matches ) ) { return $ matc...
Check if a complete tag is found in the cached data which usually happens when the end of the tag has only just been loaded into the cache .
29,695
private function get_category_from_group ( $ categories ) { global $ DB ; if ( empty ( $ categories ) ) { $ catid = $ this -> get_default_category_id ( ) ; } else { $ createnewcategories = $ this -> get_config ( 'createnewcategories' ) ; $ categoryseparator = trim ( $ this -> get_config ( 'categoryseparator' ) ) ; $ ne...
Find the category using idnumber or name .
29,696
public function skip_whitespace ( ) { $ whitespace = strspn ( $ this -> data , "\x09\x0A\x0D\x20" , $ this -> position ) ; $ this -> position += $ whitespace ; return $ whitespace ; }
Advance past any whitespace
29,697
protected function validation_inner ( $ data , $ files ) { $ errors = array ( ) ; for ( $ i = 0 ; isset ( $ data [ 'dimensionid__idx_' . $ i ] ) ; $ i ++ ) { $ dimgrades = array ( ) ; if ( 0 == strlen ( trim ( $ data [ 'description__idx_' . $ i . '_editor' ] [ 'text' ] ) ) ) { continue ; } $ atleastonelevel = false ; f...
Provide validation rules for the rubric editor form .
29,698
public function set_qt_var ( $ name , $ value ) { if ( $ name [ 0 ] != '_' ) { throw new coding_exception ( 'Cannot set question type data ' . $ name . ' on an attempt step. You can only set variables with names begining with _.' ) ; } $ this -> data [ $ name ] = $ value ; }
Set a cached question type variable .
29,699
public function prepare_response_files_draft_itemid ( $ name , $ contextid ) { list ( $ draftid , $ notused ) = $ this -> prepare_response_files_draft_itemid_with_text ( $ name , $ contextid , null ) ; return $ draftid ; }
Prepare a draft file are for the files belonging the a response variable of this step .