idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
26,700
public function get_parent_directory ( ) { if ( $ this -> file_record -> filepath === '/' and $ this -> file_record -> filename === '.' ) { return null ; } if ( $ this -> file_record -> filename !== '.' ) { return $ this -> fs -> create_directory ( $ this -> file_record -> contextid , $ this -> file_record -> component...
Returns parent directory creates missing parents if needed .
26,701
public function set_sortorder ( $ sortorder ) { $ oldorder = $ this -> file_record -> sortorder ; $ filerecord = new stdClass ; $ filerecord -> sortorder = $ sortorder ; $ this -> update ( $ filerecord ) ; if ( ! $ this -> is_directory ( ) ) { if ( $ pluginsfunction = get_plugins_with_function ( 'after_file_sorted' ) )...
Set file sort order
26,702
public function set_synchronized ( $ contenthash , $ filesize , $ status = 0 , $ timemodified = null ) { if ( ! $ this -> is_external_file ( ) ) { return ; } $ now = time ( ) ; if ( $ contenthash === null ) { $ contenthash = $ this -> file_record -> contenthash ; } if ( $ contenthash != $ this -> file_record -> content...
Called after reference - file has been synchronized with the repository
26,703
public function send_file ( $ lifetime , $ filter , $ forcedownload , $ options ) { $ this -> repository -> send_file ( $ this , $ lifetime , $ filter , $ forcedownload , $ options ) ; }
Send file references
26,704
public function generate_image_thumbnail ( $ width , $ height ) { global $ CFG ; require_once ( $ CFG -> libdir . '/gdlib.php' ) ; if ( empty ( $ width ) or empty ( $ height ) ) { return false ; } $ content = $ this -> get_content ( ) ; $ imageinfo = @ getimagesizefromstring ( $ content ) ; if ( empty ( $ imageinfo ) )...
Generates a thumbnail for this stored_file .
26,705
public function resize_image ( $ width , $ height ) { global $ CFG ; require_once ( $ CFG -> libdir . '/gdlib.php' ) ; $ content = $ this -> get_content ( ) ; $ imageinfo = @ getimagesizefromstring ( $ content ) ; if ( empty ( $ imageinfo ) ) { return false ; } $ original = @ imagecreatefromstring ( $ content ) ; retur...
Generate a resized image for this stored_file .
26,706
public function get_title ( ) { global $ DB ; $ role = $ DB -> get_record ( 'role' , array ( 'id' => $ this -> role ) ) ; if ( ! $ role ) { return '[' . get_string ( 'roleidnotfound' , 'completion' , $ this -> role ) . ']' ; } return role_get_name ( $ role , context_course :: instance ( $ this -> course ) ) ; }
Return criteria title for display in reports
26,707
private function createDeleteOptions ( ) { $ deleteOptions = [ 'limit' => $ this -> limit ] ; if ( isset ( $ this -> options [ 'collation' ] ) ) { $ deleteOptions [ 'collation' ] = ( object ) $ this -> options [ 'collation' ] ; } return $ deleteOptions ; }
Create options for the delete command .
26,708
private function createExecuteOptions ( ) { $ options = [ ] ; if ( isset ( $ this -> options [ 'session' ] ) ) { $ options [ 'session' ] = $ this -> options [ 'session' ] ; } if ( isset ( $ this -> options [ 'writeConcern' ] ) ) { $ options [ 'writeConcern' ] = $ this -> options [ 'writeConcern' ] ; } return $ options ...
Create options for executing the bulk write .
26,709
public static function get_missing_plans ( $ templateid , $ cohortid , $ unlinkedaremissing = false ) { global $ DB ; $ skipsql = '' ; $ skipparams = array ( ) ; if ( ! $ unlinkedaremissing ) { $ skipsql = 'OR p.origtemplateid = :origtemplateid' ; $ skipparams = array ( 'origtemplateid' => $ templateid ) ; } $ sql = "S...
Return an array of user IDs for which the plans are missing .
26,710
public static function get_relations_by_templateid ( $ templateid ) { global $ DB ; $ params = array ( 'templateid' => $ templateid ) ; $ relations = array ( ) ; $ records = $ DB -> get_records ( self :: TABLE , $ params ) ; foreach ( $ records as $ record ) { $ relations [ ] = new template_cohort ( 0 , $ record ) ; } ...
Get a relations by templateid .
26,711
public static function get_all_missing_plans ( $ lastruntime = 0 , $ unlinkedaremissing = false ) { global $ DB ; $ planwhereclause = " WHERE (p.id is NULL AND (cm.timeadded >= :lastruntime1 OR tc.timecreated >= :lastruntime3 OR...
Return an array of templates persistent with their missing userids .
26,712
public static function get_overrides_for_purpose ( purpose $ purpose ) : array { $ cache = \ cache :: make ( 'tool_dataprivacy' , 'purpose_overrides' ) ; $ overrides = [ ] ; $ alldata = $ cache -> get ( $ purpose -> get ( 'id' ) ) ; if ( false === $ alldata ) { $ tocache = [ ] ; foreach ( self :: get_records ( [ 'purpo...
Get all role overrides for the purpose .
26,713
private function setData ( $ data ) { if ( $ data !== false ) { $ this -> cache -> set ( $ this -> name . '_mtime' , time ( ) , ( int ) $ this -> options [ 'extras' ] [ 'timeout' ] ) ; return $ this -> cache -> set ( $ this -> name , $ data , ( int ) $ this -> options [ 'extras' ] [ 'timeout' ] ) ; } return false ; }
Set the last modified time and data to Memcached
26,714
function send_message ( $ eventdata ) { global $ CFG ; if ( $ eventdata -> userto -> auth === 'nologin' or $ eventdata -> userto -> suspended or $ eventdata -> userto -> deleted ) { return true ; } if ( ! empty ( $ CFG -> noemailever ) ) { debugging ( '$CFG->noemailever is active, no jabber message sent.' , DEBUG_MINIM...
Processes the message and sends a notification via jabber
26,715
function is_system_configured ( ) { global $ CFG ; return ( ! empty ( $ CFG -> jabberhost ) && ! empty ( $ CFG -> jabberport ) && ! empty ( $ CFG -> jabberusername ) && ! empty ( $ CFG -> jabberpassword ) ) ; }
Tests whether the Jabber settings have been configured
26,716
function is_user_configured ( $ user = null ) { global $ USER ; if ( is_null ( $ user ) ) { $ user = $ USER ; } return ( bool ) get_user_preferences ( 'message_processor_jabber_jabberid' , null , $ user -> id ) ; }
Tests whether the Jabber settings have been configured on user level
26,717
protected function after_definition ( ) { parent :: after_definition ( ) ; $ mform = $ this -> _form ; $ class = static :: $ persistentclass ; $ properties = $ class :: properties_definition ( ) ; foreach ( $ mform -> _elements as $ element ) { $ name = $ element -> getName ( ) ; if ( isset ( $ mform -> _types [ $ name...
After definition hook .
26,718
public function get_data ( ) { $ data = parent :: get_data ( ) ; if ( is_object ( $ data ) ) { foreach ( static :: $ fieldstoremove as $ field ) { unset ( $ data -> { $ field } ) ; } $ data = static :: convert_fields ( $ data ) ; $ data -> id = $ this -> persistent -> get ( 'id' ) ; } return $ data ; }
Get form data .
26,719
public function get_submitted_data ( ) { $ data = parent :: get_submitted_data ( ) ; if ( is_object ( $ data ) ) { foreach ( static :: $ fieldstoremove as $ field ) { unset ( $ data -> { $ field } ) ; } $ data = static :: convert_fields ( $ data ) ; } return $ data ; }
Get the submitted form data .
26,720
public static function create_relation ( $ userid , $ competencyid , $ planid ) { $ relation = new user_competency_plan ( 0 , ( object ) array ( 'userid' => $ userid , 'competencyid' => $ competencyid , 'planid' => $ planid ) ) ; return $ relation ; }
Create a new user_competency_plan object .
26,721
public static function list_competencies ( $ planid , $ userid ) { global $ DB ; $ sql = 'SELECT c.* FROM {' . competency :: TABLE . '} c JOIN {' . self :: TABLE . '} ucp ON ucp.competencyid = c.id AND ucp.userid = :userid WHERE ucp....
List the competencies in this plan .
26,722
public static function get_competency_by_planid ( $ planid , $ competencyid ) { global $ DB ; $ sql = "SELECT c.* FROM {" . self :: TABLE . "} ucp JOIN {" . competency :: TABLE . "} c ON c.id = ucp.competencyid WHERE ucp.planid = ? A...
Fetch a competency by plan ID .
26,723
public static function has_records_for_competencies ( $ competencyids ) { global $ DB ; list ( $ insql , $ params ) = $ DB -> get_in_or_equal ( $ competencyids , SQL_PARAMS_NAMED ) ; return self :: record_exists_select ( "competencyid $insql" , $ params ) ; }
Check if user competency plan has records for competencies .
26,724
public static function count_records_for_template ( $ templateid , $ proficiency = null ) { global $ DB ; $ params = array ( 'templateid' => $ templateid ) ; $ sql = 'SELECT ' . " COUNT('x') " . 'FROM {' . self :: TABLE . '} ucp JOIN {' . plan :: TABLE . '} p ON ucp.planid = p.id ...
Count the number of records matching a specific template optionally filtered by proficient values .
26,725
public function getOPT ( $ property ) { if ( isset ( $ this -> OPT [ $ property ] ) ) { return $ this -> OPT [ $ property ] ; } return null ; }
Get an option for the Shape Group Container
26,726
public function getNestingLevel ( ) { $ nestingLevel = 0 ; $ parent = $ this -> getParent ( ) ; while ( $ parent instanceof PHPExcel_Shared_Escher_DgContainer_SpgrContainer ) { ++ $ nestingLevel ; $ parent = $ parent -> getParent ( ) ; } return $ nestingLevel ; }
Get the nesting level of this spContainer . This is the number of spgrContainers between this spContainer and the dgContainer . A value of 1 = immediately within first spgrContainer Higher nesting level occurs if and only if spContainer is part of a shape group
26,727
function AddColumnSQL ( $ tabname , $ flds ) { $ tabname = $ this -> TableName ( $ tabname ) ; $ sql = array ( ) ; $ not_null = false ; list ( $ lines , $ pkey ) = $ this -> _GenFields ( $ flds ) ; $ alter = 'ALTER TABLE ' . $ tabname . $ this -> addCol . ' ' ; foreach ( $ lines as $ v ) { if ( ( $ not_null = preg_matc...
Adding a new Column
26,728
function _recreate_copy_table ( $ tabname , $ dropflds , $ tableflds , $ tableoptions = '' ) { if ( $ dropflds && ! is_array ( $ dropflds ) ) $ dropflds = explode ( ',' , $ dropflds ) ; $ copyflds = array ( ) ; foreach ( $ this -> MetaColumns ( $ tabname ) as $ fld ) { if ( ! $ dropflds || ! in_array ( $ fld -> name , ...
Save the content into a temp . table drop and recreate the original table and copy the content back in
26,729
function _DropAutoIncrement ( $ tabname ) { $ tabname = $ this -> connection -> quote ( '%' . $ tabname . '%' ) ; $ seq = $ this -> connection -> GetOne ( "SELECT relname FROM pg_class WHERE NOT relname ~ 'pg_.*' AND relname LIKE $tabname AND relkind='S'" ) ; if ( ! $ seq || $ this -> connection -> GetOne ( "SELECT rel...
this is still necessary if postgres < 7 . 3 or the SERIAL was created on an earlier version!!!
26,730
private function get_message ( post_entity $ post ) : string { global $ CFG ; $ message = $ post -> get_message ( ) ; if ( ! empty ( $ CFG -> enableplagiarism ) ) { require_once ( $ CFG -> libdir . '/plagiarismlib.php' ) ; $ forum = $ this -> related [ 'forum' ] ; $ message .= plagiarism_get_links ( [ 'userid' => $ pos...
Get the message text from a post .
26,731
private function export_attachments ( array $ attachments , post_entity $ post , renderer_base $ output , bool $ canexport ) : array { global $ CFG ; $ urlfactory = $ this -> related [ 'urlfactory' ] ; $ enableplagiarism = $ CFG -> enableplagiarism ; $ forum = $ this -> related [ 'forum' ] ; $ context = $ this -> relat...
Get the exported attachments for a post .
26,732
private function export_tags ( array $ tags ) : array { $ user = $ this -> related [ 'user' ] ; $ context = $ this -> related [ 'context' ] ; $ capabilitymanager = $ this -> related [ 'capabilitymanager' ] ; $ canmanagetags = $ capabilitymanager -> can_manage_tags ( $ user ) ; return array_values ( array_map ( function...
Export the list of tags .
26,733
private function get_author_subheading_html ( stdClass $ exportedauthor , int $ timecreated ) : string { $ fullname = $ exportedauthor -> fullname ; $ profileurl = $ exportedauthor -> urls [ 'profile' ] ?? null ; $ formatteddate = userdate ( $ timecreated , get_string ( 'strftimedaydatetime' , 'core_langconfig' ) ) ; $...
Get the HTML to display as a subheading in a post .
26,734
protected function render_workshop_message ( workshop_message $ message ) { $ text = $ message -> get_message ( ) ; $ url = $ message -> get_action_url ( ) ; $ label = $ message -> get_action_label ( ) ; if ( empty ( $ text ) and empty ( $ label ) ) { return '' ; } switch ( $ message -> get_type ( ) ) { case workshop_m...
Renders workshop message
26,735
protected function render_workshop_submission_summary ( workshop_submission_summary $ summary ) { $ o = '' ; $ anonymous = $ summary -> is_anonymous ( ) ; $ classes = 'submission-summary' ; if ( $ anonymous ) { $ classes .= ' anonymous' ; } $ gradestatus = '' ; if ( $ summary -> status == 'notgraded' ) { $ classes .= '...
Renders short summary of the submission
26,736
protected function render_workshop_example_submission ( workshop_example_submission $ example ) { $ o = '' ; $ classes = 'submission-full example' ; $ o .= $ this -> output -> container_start ( $ classes ) ; $ o .= $ this -> output -> container_start ( 'header' ) ; $ o .= $ this -> output -> container ( format_string (...
Renders full workshop example submission
26,737
protected function render_workshop_example_submission_summary ( workshop_example_submission_summary $ summary ) { $ o = '' ; $ o .= $ this -> output -> box_start ( 'generalbox example-summary ' . $ summary -> status ) ; $ o .= $ this -> output -> container_start ( 'example-title' ) ; $ o .= html_writer :: link ( $ summ...
Renders short summary of the example submission
26,738
protected function render_workshop_user_plan ( workshop_user_plan $ plan ) { $ o = '' ; $ numberofphases = count ( $ plan -> phases ) ; $ o .= html_writer :: start_tag ( 'div' , array ( 'class' => 'userplan' , 'aria-labelledby' => 'mod_workshop-userplanheading' , 'aria-describedby' => 'mod_workshop-userplanaccessibilit...
Renders the user plannner tool
26,739
protected function render_workshop_allocation_result ( workshop_allocation_result $ result ) { global $ CFG ; $ status = $ result -> get_status ( ) ; if ( is_null ( $ status ) or $ status == workshop_allocation_result :: STATUS_VOID ) { debugging ( 'Attempt to render workshop_allocation_result with empty status' , DEBU...
Renders the result of the submissions allocation process
26,740
private function helper_render_feedback ( $ feedback ) { $ o = '' ; $ o .= $ this -> output -> container_start ( 'feedback feedbackforauthor' ) ; $ o .= $ this -> output -> container_start ( 'header' ) ; $ o .= $ this -> output -> heading ( get_string ( 'feedbackby' , 'workshop' , s ( fullname ( $ feedback -> get_provi...
Helper method to rendering feedback
26,741
protected function overall_feedback ( workshop_assessment $ assessment ) { $ content = $ assessment -> get_overall_feedback_content ( ) ; if ( $ content === false ) { return '' ; } $ o = '' ; if ( ! is_null ( $ content ) ) { $ o .= $ this -> output -> container ( $ content , 'content' ) ; } $ attachments = $ assessment...
Renders the overall feedback for the author of the submission
26,742
public function perpage_selector ( $ current = 10 ) { $ options = array ( ) ; foreach ( array ( 10 , 20 , 30 , 40 , 50 , 60 , 70 , 80 , 90 , 100 , 200 , 300 , 400 , 500 , 1000 ) as $ option ) { if ( $ option != $ current ) { $ options [ $ option ] = $ option ; } } $ select = new single_select ( $ this -> page -> url , ...
Renders a perpage selector for workshop listings
26,743
protected function render_workshop_final_grades ( workshop_final_grades $ grades ) { $ out = html_writer :: start_tag ( 'div' , array ( 'class' => 'finalgrades' ) ) ; if ( ! empty ( $ grades -> submissiongrade ) ) { $ cssclass = 'grade submissiongrade' ; if ( $ grades -> submissiongrade -> hidden ) { $ cssclass .= ' hi...
Renders the user s final grades
26,744
protected function helper_user_plan_tasks ( array $ tasks ) { $ out = '' ; foreach ( $ tasks as $ taskcode => $ task ) { $ classes = '' ; $ accessibilitytext = '' ; $ icon = null ; if ( $ task -> completed === true ) { $ classes .= ' completed' ; $ accessibilitytext .= get_string ( 'taskdone' , 'workshop' ) . ' ' ; } e...
Renders the tasks for the single phase in the user plan
26,745
protected function helper_grading_report_grade ( $ grade , $ over = null ) { $ a = new stdclass ( ) ; $ a -> grade = is_null ( $ grade ) ? get_string ( 'nullgrade' , 'workshop' ) : $ grade ; if ( is_null ( $ over ) ) { $ text = get_string ( 'formataggregatedgrade' , 'workshop' , $ a ) ; } else { $ a -> over = is_null (...
Formats the aggreagated grades
26,746
protected static function moodleform ( moodleform $ mform ) { ob_start ( ) ; $ mform -> display ( ) ; $ o = ob_get_contents ( ) ; ob_end_clean ( ) ; return $ o ; }
Helper method dealing with the fact we can not just fetch the output of moodleforms
26,747
protected static function array_nth ( array $ a , $ n ) { $ keys = array_keys ( $ a ) ; if ( $ n < 0 or $ n > count ( $ keys ) - 1 ) { return null ; } $ key = $ keys [ $ n ] ; return $ a [ $ key ] ; }
Helper function returning the n - th item of the array
26,748
public static function get_time_from_fields ( $ year , $ month , $ day , $ hour , $ minute ) { $ calendartype = \ core_calendar \ type_factory :: get_calendar_instance ( ) ; $ gregoriandate = $ calendartype -> convert_to_gregorian ( $ year , $ month , $ day , $ hour , $ minute ) ; return make_timestamp ( $ gregoriandat...
Given field values obtains the corresponding timestamp .
26,749
public static function get_fields_from_time ( $ time ) { $ calendartype = \ core_calendar \ type_factory :: get_calendar_instance ( ) ; $ wrongfields = $ calendartype -> timestamp_to_date_array ( $ time ) ; return array ( 'day' => $ wrongfields [ 'mday' ] , 'month' => $ wrongfields [ 'mon' ] , 'year' => $ wrongfields [...
Given a timestamp obtains corresponding field values .
26,750
public function execute_plan ( ) { core_php_time_limit :: raise ( 1 * 60 * 60 ) ; raise_memory_limit ( MEMORY_EXTRA ) ; if ( $ this -> get_type ( ) !== backup :: TYPE_1COURSE && $ this -> get_type ( ) !== backup :: TYPE_1ACTIVITY ) { $ this -> log ( 'notifying plan about excluded activities by type' , backup :: LOG_DEB...
Executes the backup
26,751
protected function set_include_files ( ) { $ includefiles = true ; if ( $ this -> get_mode ( ) === backup :: MODE_IMPORT ) { $ includefiles = false ; } if ( $ this -> get_mode ( ) === backup :: MODE_SAMESITE ) { $ includefiles = false ; } $ this -> includefiles = ( int ) $ includefiles ; $ this -> log ( "setting file i...
Set the initial value for the include_files setting .
26,752
public function get_authors_for_posts ( array $ posts ) : array { $ authorids = array_reduce ( $ posts , function ( $ carry , $ post ) { $ carry [ $ post -> get_author_id ( ) ] = true ; return $ carry ; } , [ ] ) ; $ authorids = array_keys ( $ authorids ) ; return $ this -> get_from_ids ( $ authorids ) ; }
Get the authors for the given posts .
26,753
public function get_context_ids_for_author_ids ( array $ authorids ) : array { $ db = $ this -> get_db ( ) ; [ $ insql , $ params ] = $ db -> get_in_or_equal ( $ authorids ) ; $ sql = "SELECT instanceid, id FROM {context} WHERE contextlevel = ? AND instanceid {$insql}" ; $ records = $ db -> get_records_sql ( $ sql , ar...
Get the context ids for a set of author ids . The results are indexed by the author id .
26,754
public static final function create_from_cm ( $ cm , $ modcontext = null ) { if ( empty ( $ modcontext ) ) { $ modcontext = \ context_module :: instance ( $ cm -> id ) ; } $ event = static :: create ( array ( 'context' => $ modcontext , 'objectid' => $ cm -> id , 'other' => array ( 'modulename' => $ cm -> modname , 'in...
Set data to create new event from course module .
26,755
public function addAttribute ( $ element_name , $ attr_name , $ def ) { $ module = $ this -> getAnonymousModule ( ) ; if ( ! isset ( $ module -> info [ $ element_name ] ) ) { $ element = $ module -> addBlankElement ( $ element_name ) ; } else { $ element = $ module -> info [ $ element_name ] ; } $ element -> attr [ $ a...
Adds a custom attribute to a pre - existing element
26,756
public function addElement ( $ element_name , $ type , $ contents , $ attr_collections , $ attributes = array ( ) ) { $ module = $ this -> getAnonymousModule ( ) ; $ element = $ module -> addElement ( $ element_name , $ type , $ contents , $ attr_collections , $ attributes ) ; return $ element ; }
Adds a custom element to your HTML definition
26,757
public function addBlankElement ( $ element_name ) { $ module = $ this -> getAnonymousModule ( ) ; $ element = $ module -> addBlankElement ( $ element_name ) ; return $ element ; }
Adds a blank element to your HTML definition for overriding existing behavior
26,758
public function getAnonymousModule ( ) { if ( ! $ this -> _anonModule ) { $ this -> _anonModule = new HTMLPurifier_HTMLModule ( ) ; $ this -> _anonModule -> name = 'Anonymous' ; } return $ this -> _anonModule ; }
Retrieves a reference to the anonymous module so you can bust out advanced features without having to make your own module .
26,759
private function setup_sortitemid ( ) { global $ SESSION ; if ( ! isset ( $ SESSION -> gradeuserreport ) ) { $ SESSION -> gradeuserreport = new stdClass ( ) ; } if ( $ this -> sortitemid ) { if ( ! isset ( $ SESSION -> gradeuserreport -> sort ) ) { if ( $ this -> sortitemid == 'firstname' || $ this -> sortitemid == 'la...
Setting the sort order this depends on last state all this should be in the new table class that we might need to use for displaying grades .
26,760
protected function get_allgradeitems ( ) { if ( ! empty ( $ this -> allgradeitems ) ) { return $ this -> allgradeitems ; } $ allgradeitems = grade_item :: fetch_all ( array ( 'courseid' => $ this -> courseid ) ) ; $ this -> allgradeitems = array_filter ( $ allgradeitems , function ( $ item ) { return $ item -> gradetyp...
Load all grade items .
26,761
public function get_left_icons_row ( $ rows = array ( ) , $ colspan = 1 ) { global $ USER ; if ( $ USER -> gradeediting [ $ this -> courseid ] ) { $ controlsrow = new html_table_row ( ) ; $ controlsrow -> attributes [ 'class' ] = 'controls' ; $ controlscell = new html_table_cell ( ) ; $ controlscell -> attributes [ 'cl...
Builds and return the row of icons for the left side of the report . It only has one cell that says Controls
26,762
public function get_left_range_row ( $ rows = array ( ) , $ colspan = 1 ) { global $ CFG , $ USER ; if ( $ this -> get_pref ( 'showranges' ) ) { $ rangerow = new html_table_row ( ) ; $ rangerow -> attributes [ 'class' ] = 'range r' . $ this -> rowcount ++ ; $ rangecell = new html_table_cell ( ) ; $ rangecell -> attribu...
Builds and return the header for the row of ranges for the left part of the grader report .
26,763
public function get_left_avg_row ( $ rows = array ( ) , $ colspan = 1 , $ groupavg = false ) { if ( ! $ this -> canviewhidden ) { return $ rows ; } $ showaverages = $ this -> get_pref ( 'showaverages' ) ; $ showaveragesgroup = $ this -> currentgroup && $ showaverages ; $ straveragegroup = get_string ( 'groupavg' , 'gra...
Builds and return the headers for the rows of averages for the left part of the grader report .
26,764
public function get_right_icons_row ( $ rows = array ( ) ) { global $ USER ; if ( $ USER -> gradeediting [ $ this -> courseid ] ) { $ iconsrow = new html_table_row ( ) ; $ iconsrow -> attributes [ 'class' ] = 'controls' ; foreach ( $ this -> gtree -> items as $ itemid => $ unused ) { $ item = $ this -> gtree -> get_ite...
Builds and return the row of icons when editing is on for the right part of the grader report .
26,765
public function get_right_range_row ( $ rows = array ( ) ) { global $ OUTPUT ; if ( $ this -> get_pref ( 'showranges' ) ) { $ rangesdisplaytype = $ this -> get_pref ( 'rangesdisplaytype' ) ; $ rangesdecimalpoints = $ this -> get_pref ( 'rangesdecimalpoints' ) ; $ rangerow = new html_table_row ( ) ; $ rangerow -> attrib...
Builds and return the row of ranges for the right part of the grader report .
26,766
protected function get_course_header ( $ element ) { global $ OUTPUT ; $ icon = '' ; if ( $ element [ 'type' ] == 'category' ) { $ strswitchminus = $ this -> get_lang_string ( 'aggregatesonly' , 'grades' ) ; $ strswitchplus = $ this -> get_lang_string ( 'gradesonly' , 'grades' ) ; $ strswitchwhole = $ this -> get_lang_...
Given element category create a collapsible icon and course header .
26,767
protected function get_icons ( $ element ) { global $ CFG , $ USER , $ OUTPUT ; if ( ! $ USER -> gradeediting [ $ this -> courseid ] ) { return '<div class="grade_icons" />' ; } $ editicon = '' ; $ editable = true ; if ( $ element [ 'type' ] == 'grade' ) { $ item = $ element [ 'object' ] -> grade_item ; if ( $ item -> ...
Given a grade_category grade_item or grade_grade this function figures out the state of the object and builds then returns a div with the icons needed for the grader report .
26,768
protected static function filter_collapsed_categories ( $ courseid , $ collapsed ) { global $ DB ; if ( empty ( $ collapsed ) ) { $ collapsed = array ( 'aggregatesonly' => array ( ) , 'gradesonly' => array ( ) ) ; } if ( empty ( $ collapsed [ 'aggregatesonly' ] ) && empty ( $ collapsed [ 'gradesonly' ] ) ) { return $ c...
From the list of categories that this user prefers to collapse choose ones that belong to the current course .
26,769
protected static function get_collapsed_preferences ( $ courseid ) { if ( $ collapsed = get_user_preferences ( 'grade_report_grader_collapsed_categories' . $ courseid ) ) { return json_decode ( $ collapsed , true ) ; } if ( ( $ oldcollapsedpref = get_user_preferences ( 'grade_report_grader_collapsed_categories' ) ) !==...
Returns the list of categories that this user wants to collapse or display aggregatesonly
26,770
protected static function set_collapsed_preferences ( $ courseid , $ collapsed ) { global $ DB ; if ( strlen ( json_encode ( $ collapsed ) ) >= 1333 ) { $ collapsed = static :: filter_collapsed_categories ( $ courseid , $ collapsed ) ; } while ( strlen ( json_encode ( $ collapsed ) ) >= 1333 ) { if ( count ( $ collapse...
Sets the list of categories that user wants to see collapsed in user preferences
26,771
public function get_sort_arrows ( array $ extrafields = array ( ) ) { global $ OUTPUT , $ CFG ; $ arrows = array ( ) ; $ strsortasc = $ this -> get_lang_string ( 'sortasc' , 'grades' ) ; $ strsortdesc = $ this -> get_lang_string ( 'sortdesc' , 'grades' ) ; $ iconasc = $ OUTPUT -> pix_icon ( 't/sort_asc' , $ strsortasc ...
Refactored function for generating HTML of sorting links with matching arrows . Returns an array with studentname and idnumber as keys with HTML ready to inject into a table header cell .
26,772
public static function create_from_question_instance ( $ question , $ context = null , $ other = null ) { $ params = [ 'objectid' => $ question -> id , 'other' => [ 'categoryid' => $ question -> category ] ] ; if ( ! empty ( $ question -> contextid ) ) { $ params [ 'contextid' ] = $ question -> contextid ; } $ params [...
Create a event from question object
26,773
protected function get_folder_list ( ) { if ( empty ( $ this -> folders ) ) { $ folders = array ( ) ; $ result = $ this -> boxclient -> get_folder_items ( ) ; foreach ( $ result -> entries as $ item ) { if ( $ item -> type != 'folder' ) { continue ; } $ folders [ $ item -> id ] = $ item -> name ; if ( ! empty ( $ item ...
Get the folder list .
26,774
public static function pixelsToCellDimension ( $ pValue = 0 , PHPExcel_Style_Font $ pDefaultFont ) { $ name = $ pDefaultFont -> getName ( ) ; $ size = $ pDefaultFont -> getSize ( ) ; if ( isset ( PHPExcel_Shared_Font :: $ defaultColumnWidths [ $ name ] [ $ size ] ) ) { $ colWidth = $ pValue * PHPExcel_Shared_Font :: $ ...
Convert pixels to column width . Exact algorithm not known . By inspection of a real Excel file using Calibri 11 one finds 1000px ~ 142 . 85546875 This gives a conversion factor of 7 . Also we assume that pixels and font size are proportional .
26,775
public static function factory ( $ params ) { global $ CFG , $ COMPLETION_CRITERIA_TYPES ; if ( ! isset ( $ params [ 'criteriatype' ] ) || ! isset ( $ COMPLETION_CRITERIA_TYPES [ $ params [ 'criteriatype' ] ] ) ) { print_error ( 'invalidcriteriatype' , 'completion' ) ; } $ class = 'completion_criteria_' . $ COMPLETION_...
Factory method for creating correct class object
26,776
public function get_icon ( $ alt , array $ attributes = null ) { global $ COMPLETION_CRITERIA_TYPES ; $ criteriatype = $ COMPLETION_CRITERIA_TYPES [ $ this -> criteriatype ] ; return new pix_icon ( 'i/' . $ criteriatype , $ alt , 'moodle' , $ attributes ) ; }
Return pix_icon for display in reports .
26,777
public static function get_metadata ( collection $ collection ) : collection { $ collection -> add_user_preference ( 'block_timeline_user_sort_preference' , 'privacy:metadata:timelinesortpreference' ) ; $ collection -> add_user_preference ( 'block_timeline_user_filter_preference' , 'privacy:metadata:timelinefilterprefe...
Returns meta - data information about the myoverview block .
26,778
public function parse ( $ date ) { foreach ( $ this -> user as $ method ) { if ( ( $ returned = call_user_func ( $ method , $ date ) ) !== false ) { return $ returned ; } } foreach ( $ this -> built_in as $ method ) { if ( ( $ returned = call_user_func ( array ( $ this , $ method ) , $ date ) ) !== false ) { return $ r...
Parse a date
26,779
public function date_rfc2822 ( $ date ) { static $ pcre ; if ( ! $ pcre ) { $ wsp = '[\x09\x20]' ; $ fws = '(?:' . $ wsp . '+|' . $ wsp . '*(?:\x0D\x0A' . $ wsp . '+)+)' ; $ optional_fws = $ fws . '?' ; $ day_name = $ this -> day_pcre ; $ month = $ this -> month_pcre ; $ day = '([0-9]{1,2})' ; $ hour = $ minute = $ sec...
Parse RFC2822 s date format
26,780
public function date_rfc850 ( $ date ) { static $ pcre ; if ( ! $ pcre ) { $ space = '[\x09\x20]+' ; $ day_name = $ this -> day_pcre ; $ month = $ this -> month_pcre ; $ day = '([0-9]{1,2})' ; $ year = $ hour = $ minute = $ second = '([0-9]{2})' ; $ zone = '([A-Z]{1,5})' ; $ pcre = '/^' . $ day_name . ',' . $ space . $...
Parse RFC850 s date format
26,781
public function data_preprocessing ( & $ defaultvalues ) { parent :: data_preprocessing ( $ defaultvalues ) ; $ defaultvalues [ 'completionentriesenabled' ] = ! empty ( $ defaultvalues [ 'completionentries' ] ) ? 1 : 0 ; if ( empty ( $ defaultvalues [ 'completionentries' ] ) ) { $ defaultvalues [ 'completionentries' ] ...
Set up the completion checkbox which is not part of standard data .
26,782
protected function execute_on ( $ tmpdir ) { global $ CFG ; $ time = time ( ) - ( $ CFG -> tempdatafoldercleanup * 3600 ) ; $ dir = new \ RecursiveDirectoryIterator ( $ tmpdir ) ; $ iter = new \ RecursiveIteratorIterator ( $ dir , \ RecursiveIteratorIterator :: CHILD_FIRST ) ; $ modifieddateobject = array ( ) ; for ( $...
Do the job given the target directory .
26,783
protected function fetch_dropbox_data ( $ endpoint , $ data = [ ] ) { $ url = $ this -> get_api_endpoint ( $ endpoint ) ; $ this -> cleanopt ( ) ; $ this -> resetHeader ( ) ; if ( $ data === null ) { $ options [ 'CURLOPT_POSTFIELDS' ] = 'null' ; } else { $ options [ 'CURLOPT_POSTFIELDS' ] = json_encode ( $ data ) ; } $...
Make an API call against the specified endpoint with supplied data .
26,784
protected function fetch_dropbox_content ( $ endpoint , $ data = [ ] ) { $ url = $ this -> get_content_endpoint ( $ endpoint ) ; $ this -> cleanopt ( ) ; $ this -> resetHeader ( ) ; $ options [ 'CURLOPT_POST' ] = 1 ; $ this -> setHeader ( 'Content-Type: ' ) ; $ this -> setHeader ( 'Dropbox-API-Arg: ' . json_encode ( $ ...
Fetch content from the specified endpoint with the supplied data .
26,785
protected function check_and_handle_api_errors ( $ data ) { if ( $ this -> info [ 'http_code' ] == 200 ) { return ; } switch ( $ this -> info [ 'http_code' ] ) { case 400 : throw new \ coding_exception ( 'Invalid input parameter passed to DropBox API.' ) ; break ; case 401 : throw new authentication_exception ( 'Authen...
Check for an attempt to handle API errors .
26,786
public function get_file_share_info ( $ id ) { $ data = $ this -> fetch_dropbox_data ( 'sharing/list_shared_links' , [ 'path' => $ id , ] ) ; if ( isset ( $ data -> links ) ) { $ link = reset ( $ data -> links ) ; if ( isset ( $ link -> { ".tag" } ) && $ link -> { ".tag" } === "file" ) { return $ this -> normalize_file...
Fetch a valid public share link for the specified file .
26,787
public function allDrawings ( PHPExcel $ pPHPExcel = null ) { $ aDrawings = array ( ) ; $ sheetCount = $ pPHPExcel -> getSheetCount ( ) ; for ( $ i = 0 ; $ i < $ sheetCount ; ++ $ i ) { $ iterator = $ pPHPExcel -> getSheet ( $ i ) -> getDrawingCollection ( ) -> getIterator ( ) ; while ( $ iterator -> valid ( ) ) { $ aD...
Get an array of all drawings
26,788
public function get_exported_posts_builder ( ) : exported_posts_builder { return new exported_posts_builder ( $ this -> rendererbase , $ this -> legacydatamapperfactory , $ this -> exporterfactory , $ this -> vaultfactory , $ this -> managerfactory -> get_rating_manager ( ) ) ; }
Get an instance of the exported posts builder .
26,789
public function get_exported_discussion_summaries_builder ( ) : exported_discussion_summaries_builder { return new exported_discussion_summaries_builder ( $ this -> rendererbase , $ this -> legacydatamapperfactory , $ this -> exporterfactory , $ this -> vaultfactory , $ this -> managerfactory ) ; }
Get an instance of the exported discussion summaries builder .
26,790
public function get_exported_discussion_builder ( ) : exported_discussion_builder { return new exported_discussion_builder ( $ this -> rendererbase , $ this -> legacydatamapperfactory , $ this -> exporterfactory , $ this -> vaultfactory , $ this -> managerfactory -> get_rating_manager ( ) ) ; }
Get an instance of the exported discussion builder .
26,791
public function setup ( $ file = false ) { if ( ! $ file ) { $ file = HTMLPURIFIER_PREFIX . '/HTMLPurifier/EntityLookup/entities.ser' ; } $ this -> table = unserialize ( file_get_contents ( $ file ) ) ; }
Sets up the entity lookup table from the serialized file contents .
26,792
public static function get_target_type ( step $ step ) { if ( ! isset ( self :: $ mapping [ $ step -> get_targettype ( ) ] ) ) { throw new \ moodle_exception ( 'Unknown Target type' ) ; } $ targettype = self :: $ mapping [ $ step -> get_targettype ( ) ] ; return "\\tool_usertours\\local\\target\\{$targettype}" ; }
Return the instance of the class for this target .
26,793
public function render_rules_link ( $ ruleurl ) { echo \ html_writer :: start_div ( ) ; $ a = \ html_writer :: link ( $ ruleurl , get_string ( 'managerules' , 'tool_monitor' ) ) ; $ link = \ html_writer :: tag ( 'span' , get_string ( 'manageruleslink' , 'tool_monitor' , $ a ) ) ; echo $ link ; echo \ html_writer :: end...
Html to add a link to go to the rule manager page .
26,794
protected static function validate_contextlist_contexts ( approved_contextlist $ contextlist ) { return array_reduce ( $ contextlist -> get_contexts ( ) , function ( $ carry , $ context ) { if ( $ context -> contextlevel == CONTEXT_COURSE ) { $ carry [ ] = $ context ; } return $ carry ; } , [ ] ) ; }
Simple sanity check on the contextlist contexts making sure they re of CONTEXT_COURSE contextlevel .
26,795
public function get_doc_url ( \ core_search \ document $ doc ) { $ entry = $ this -> get_entry ( $ doc -> get ( 'itemid' ) ) ; return new \ moodle_url ( '/mod/data/view.php' , array ( 'd' => $ entry -> dataid , 'rid' => $ entry -> id ) ) ; }
Link to database entry .
26,796
public function get_context_url ( \ core_search \ document $ doc ) { $ entry = $ this -> get_entry ( $ doc -> get ( 'itemid' ) ) ; return new \ moodle_url ( '/mod/data/view.php' , array ( 'd' => $ entry -> dataid ) ) ; }
Link to the database activity .
26,797
public function attach_files ( $ doc ) { global $ DB ; $ entryid = $ doc -> get ( 'itemid' ) ; try { $ entry = $ this -> get_entry ( $ entryid ) ; } catch ( \ dml_missing_record_exception $ e ) { debugging ( 'Could not get record to attach files to ' . $ doc -> get ( 'id' ) , DEBUG_DEVELOPER ) ; return ; } $ cm = $ thi...
Add the database entries attachments .
26,798
protected function get_entry ( $ entryid ) { global $ DB ; if ( empty ( $ this -> entriesdata [ $ entryid ] ) ) { $ this -> entriesdata [ $ entryid ] = $ DB -> get_record ( 'data_records' , array ( 'id' => $ entryid ) , '*' , MUST_EXIST ) ; } return $ this -> entriesdata [ $ entryid ] ; }
Get database entry data
26,799
protected function get_field_class_name ( $ fieldtype ) { global $ CFG ; $ fieldtype = trim ( $ fieldtype ) ; require_once ( $ CFG -> dirroot . '/mod/data/field/' . $ fieldtype . '/field.class.php' ) ; return 'data_field_' . $ fieldtype ; }
Returns the class name for that field type and includes it .