idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
35,200
public function col_type ( $ row ) : string { if ( \ core \ task \ database_logger :: TYPE_SCHEDULED == $ row -> type ) { return get_string ( 'task_type:scheduled' , 'admin' ) ; } else { return get_string ( 'task_type:adhoc' , 'admin' ) ; } }
Format the type cell .
35,201
public function col_duration ( $ row ) : string { $ duration = round ( $ row -> timeend - $ row -> timestart , 2 ) ; if ( empty ( $ duration ) ) { return '0 ' . get_string ( 'secs' , 'moodle' ) ; } return format_time ( $ duration ) ; }
Format the duration cell .
35,202
public function col_db ( $ row ) : string { $ output = '' ; $ output .= \ html_writer :: div ( get_string ( 'task_stats:dbreads' , 'admin' , $ row -> dbreads ) ) ; $ output .= \ html_writer :: div ( get_string ( 'task_stats:dbwrites' , 'admin' , $ row -> dbwrites ) ) ; return $ output ; }
Format the DB details cell .
35,203
public function col_actions ( $ row ) : string { global $ OUTPUT ; $ actions = [ ] ; $ url = new \ moodle_url ( '/admin/tasklogs.php' , [ 'logid' => $ row -> id ] ) ; $ actions [ ] = $ OUTPUT -> action_icon ( $ url , new \ pix_icon ( 'e/search' , get_string ( 'view' ) ) , new \ popup_action ( 'click' , $ url ) ) ; $ ac...
Format the actions cell .
35,204
public function col_userid ( $ row ) : string { if ( empty ( $ row -> userid ) ) { return '' ; } $ user = ( object ) [ ] ; username_load_fields_from_object ( $ user , $ row , 'user' ) ; return fullname ( $ user ) ; }
Format the user cell .
35,205
protected function definition_drop_zones ( $ mform , $ imagerepeats ) { $ mform -> addElement ( 'header' , 'dropzoneheader' , get_string ( 'dropzoneheader' , 'qtype_' . $ this -> qtype ( ) ) ) ; $ countdropzones = 0 ; if ( isset ( $ this -> question -> id ) ) { foreach ( $ this -> question -> options -> drops as $ drop...
Make and add drop zones to the form .
35,206
protected function get_drag_item_repeats ( ) { $ countimages = 0 ; if ( isset ( $ this -> question -> id ) ) { foreach ( $ this -> question -> options -> drags as $ drag ) { $ countimages = max ( $ countimages , $ drag -> no ) ; } } if ( ! $ countimages ) { $ countimages = self :: START_NUM_ITEMS ; } $ itemrepeatsatsta...
Returns an array of starting number of repeats and the total number of repeats .
35,207
public static function file_uploaded ( $ draftitemid ) { $ draftareafiles = file_get_drafarea_files ( $ draftitemid ) ; do { $ draftareafile = array_shift ( $ draftareafiles -> list ) ; } while ( $ draftareafile !== null && $ draftareafile -> filename == '.' ) ; if ( $ draftareafile === null ) { return false ; } return...
Checks to see if a file has been uploaded .
35,208
public static function export_context_data ( \ core_privacy \ local \ request \ contextlist_collection $ contextlistcollection ) { global $ DB ; $ coursecontextids = $ DB -> get_records_menu ( 'context' , [ 'contextlevel' => CONTEXT_COURSE ] , '' , 'id, instanceid' ) ; $ courseids = [ ] ; foreach ( $ contextlistcollect...
Give the component a chance to include any contextual information deemed relevant to any child contexts which are exporting personal data .
35,209
public function define_form ( & $ form ) { $ form -> addElement ( 'header' , '_commonsettings' , get_string ( 'profilecommonsettings' , 'admin' ) ) ; $ this -> define_form_common ( $ form ) ; $ form -> addElement ( 'header' , '_specificsettings' , get_string ( 'profilespecificsettings' , 'admin' ) ) ; $ this -> define_...
Prints out the form snippet for creating or editing a profile field
35,210
public function define_form_common ( & $ form ) { $ strrequired = get_string ( 'required' ) ; $ form -> addElement ( 'text' , 'shortname' , get_string ( 'profileshortname' , 'admin' ) , 'maxlength="100" size="25"' ) ; $ form -> addRule ( 'shortname' , $ strrequired , 'required' , null , 'client' ) ; $ form -> setType (...
Prints out the form snippet for the part of creating or editing a profile field common to all data types .
35,211
public function define_save ( $ data ) { global $ DB ; $ data = $ this -> define_save_preprocess ( $ data ) ; $ old = false ; if ( ! empty ( $ data -> id ) ) { $ old = $ DB -> get_record ( 'user_info_field' , array ( 'id' => ( int ) $ data -> id ) ) ; } if ( ! $ old or $ old -> categoryid != $ data -> categoryid ) { $ ...
Add a new profile field or save changes to current field
35,212
public static function create_from_tag ( $ tag ) { $ event = self :: create ( array ( 'objectid' => $ tag -> id , 'relateduserid' => $ tag -> userid , 'context' => \ context_system :: instance ( ) , 'other' => array ( 'name' => $ tag -> name , 'rawname' => $ tag -> rawname ) ) ) ; return $ event ; }
Creates an event from tag object
35,213
public static final function create_from_record ( $ enrol ) { $ event = static :: create ( array ( 'context' => \ context_course :: instance ( $ enrol -> courseid ) , 'objectid' => $ enrol -> id , 'other' => array ( 'enrol' => $ enrol -> enrol ) ) ) ; $ event -> add_record_snapshot ( 'enrol' , $ enrol ) ; return $ even...
Api to Create new event from enrol object .
35,214
public function is_configured ( ) { if ( $ this -> get_config ( 'runningmethod' ) === 'commandline' ) { return ( bool ) $ this -> get_config ( 'pathtoclam' ) ; } else if ( $ this -> get_config ( 'runningmethod' ) === 'unixsocket' ) { return ( bool ) $ this -> get_config ( 'pathtounixsocket' ) ; } return false ; }
Are the necessary antivirus settings configured?
35,215
public function scan_file ( $ file , $ filename ) { if ( ! is_readable ( $ file ) ) { debugging ( 'File is not readable.' ) ; return self :: SCAN_RESULT_ERROR ; } $ method = 'scan_file_execute_' . $ this -> get_config ( 'runningmethod' ) ; if ( ! method_exists ( $ this , $ method ) ) { throw new \ coding_exception ( 'A...
Scan file .
35,216
private function get_clam_error_code ( $ returncode ) { $ returncodes = array ( ) ; $ returncodes [ 0 ] = 'No virus found.' ; $ returncodes [ 1 ] = 'Virus(es) found.' ; $ returncodes [ 2 ] = ' An error occured' ; $ returncodes [ 40 ] = 'Unknown option passed.' ; $ returncodes [ 50 ] = 'Database initialization error.' ;...
Returns the string equivalent of a numeric clam error code
35,217
public function scan_file_execute_commandline ( $ file ) { $ pathtoclam = trim ( $ this -> get_config ( 'pathtoclam' ) ) ; if ( ! file_exists ( $ pathtoclam ) or ! is_executable ( $ pathtoclam ) ) { $ notice = get_string ( 'invalidpathtoclam' , 'antivirus_clamav' , $ pathtoclam ) ; $ this -> set_scanning_notice ( $ not...
Scan file using command line utility .
35,218
public function scan_file_execute_unixsocket ( $ file ) { $ socket = stream_socket_client ( 'unix://' . $ this -> get_config ( 'pathtounixsocket' ) , $ errno , $ errstr , ANTIVIRUS_CLAMAV_SOCKET_TIMEOUT ) ; if ( ! $ socket ) { $ notice = get_string ( 'errorcantopensocket' , 'antivirus_clamav' , "$errstr ($errno)" ) ; $...
Scan file using Unix domain sockets .
35,219
public function scan_data_execute_unixsocket ( $ data ) { $ socket = stream_socket_client ( 'unix://' . $ this -> get_config ( 'pathtounixsocket' ) , $ errno , $ errstr , ANTIVIRUS_CLAMAV_SOCKET_TIMEOUT ) ; if ( ! $ socket ) { $ notice = get_string ( 'errorcantopensocket' , 'antivirus_clamav' , "$errstr ($errno)" ) ; $...
Scan data using unix socket .
35,220
private function parse_unixsocket_response ( $ output ) { $ splitoutput = explode ( ': ' , $ output ) ; $ message = trim ( $ splitoutput [ 1 ] ) ; if ( $ message === 'OK' ) { return self :: SCAN_RESULT_OK ; } else { $ parts = explode ( ' ' , $ message ) ; $ status = array_pop ( $ parts ) ; if ( $ status === 'FOUND' ) {...
Parse unix socket command response .
35,221
final protected function verify_protected_methods ( ) { $ properties = static :: properties_definition ( ) ; foreach ( $ properties as $ property => $ definition ) { $ method = 'get_' . $ property ; if ( method_exists ( $ this , $ method ) ) { $ reflection = new ReflectionMethod ( $ this , $ method ) ; if ( ! $ reflect...
This function is used to verify that custom getters and setters are declared as protected .
35,222
final public function get ( $ property ) { if ( ! static :: has_property ( $ property ) ) { throw new coding_exception ( 'Unexpected property \'' . s ( $ property ) . '\' requested.' ) ; } $ methodname = 'get_' . $ property ; if ( method_exists ( $ this , $ methodname ) ) { return $ this -> $ methodname ( ) ; } return ...
Data getter .
35,223
final protected function raw_get ( $ property ) { if ( ! static :: has_property ( $ property ) ) { throw new coding_exception ( 'Unexpected property \'' . s ( $ property ) . '\' requested.' ) ; } if ( ! array_key_exists ( $ property , $ this -> data ) && ! static :: is_property_required ( $ property ) ) { $ this -> raw...
Internal Data getter .
35,224
final public static function properties_definition ( ) { global $ CFG ; static $ def = null ; if ( $ def !== null ) { return $ def ; } $ def = static :: define_properties ( ) ; $ def [ 'id' ] = array ( 'default' => 0 , 'type' => PARAM_INT , ) ; $ def [ 'timecreated' ] = array ( 'default' => 0 , 'type' => PARAM_INT , ) ...
Get the properties definition of this model ..
35,225
final public static function get_formatted_properties ( ) { $ properties = static :: properties_definition ( ) ; $ formatted = array ( ) ; foreach ( $ properties as $ property => $ definition ) { $ propertyformat = $ property . 'format' ; if ( ( $ definition [ 'type' ] == PARAM_RAW || $ definition [ 'type' ] == PARAM_C...
Gets all the formatted properties .
35,226
final protected static function get_property_default_value ( $ property ) { $ properties = static :: properties_definition ( ) ; if ( ! isset ( $ properties [ $ property ] [ 'default' ] ) ) { return null ; } $ value = $ properties [ $ property ] [ 'default' ] ; if ( $ value instanceof \ Closure ) { return $ value ( ) ;...
Gets the default value for a property .
35,227
final protected static function get_property_error_message ( $ property ) { $ properties = static :: properties_definition ( ) ; if ( ! isset ( $ properties [ $ property ] [ 'message' ] ) ) { return new lang_string ( 'invaliddata' , 'error' ) ; } return $ properties [ $ property ] [ 'message' ] ; }
Gets the error message for a property .
35,228
final public function from_record ( stdClass $ record ) { $ record = ( array ) $ record ; foreach ( $ record as $ property => $ value ) { $ this -> raw_set ( $ property , $ value ) ; } return $ this ; }
Populate this class with data from a DB record .
35,229
final public function to_record ( ) { $ data = new stdClass ( ) ; $ properties = static :: properties_definition ( ) ; foreach ( $ properties as $ property => $ definition ) { $ data -> $ property = $ this -> raw_get ( $ property ) ; } return $ data ; }
Create a DB record from this class .
35,230
final public function read ( ) { global $ DB ; if ( $ this -> get ( 'id' ) <= 0 ) { throw new coding_exception ( 'id is required to load' ) ; } $ record = $ DB -> get_record ( static :: TABLE , array ( 'id' => $ this -> get ( 'id' ) ) , '*' , MUST_EXIST ) ; $ this -> from_record ( $ record ) ; $ this -> validated = tru...
Load the data from the DB .
35,231
final public function create ( ) { global $ DB , $ USER ; if ( $ this -> raw_get ( 'id' ) ) { throw new coding_exception ( 'Cannot create an object that has an ID defined.' ) ; } if ( ! $ this -> is_valid ( ) ) { throw new invalid_persistent_exception ( $ this -> get_errors ( ) ) ; } $ this -> before_create ( ) ; $ now...
Insert a record in the DB .
35,232
final public function update ( ) { global $ DB , $ USER ; if ( $ this -> raw_get ( 'id' ) <= 0 ) { throw new coding_exception ( 'id is required to update' ) ; } else if ( ! $ this -> is_valid ( ) ) { throw new invalid_persistent_exception ( $ this -> get_errors ( ) ) ; } $ this -> before_update ( ) ; $ this -> raw_set ...
Update the existing record in the DB .
35,233
final public function delete ( ) { global $ DB ; if ( $ this -> raw_get ( 'id' ) <= 0 ) { throw new coding_exception ( 'id is required to delete' ) ; } $ this -> before_delete ( ) ; $ result = $ DB -> delete_records ( static :: TABLE , array ( 'id' => $ this -> raw_get ( 'id' ) ) ) ; $ this -> after_delete ( $ result )...
Delete an entry from the database .
35,234
final public function validate ( ) { global $ CFG ; $ this -> before_validate ( ) ; if ( $ this -> validated !== true ) { $ errors = array ( ) ; $ properties = static :: properties_definition ( ) ; foreach ( $ properties as $ property => $ definition ) { $ value = $ this -> raw_get ( $ property ) ; if ( $ value === nul...
Validates the data .
35,235
public static function extract_record ( $ row , $ prefix = null ) { if ( $ prefix === null ) { $ prefix = str_replace ( '_' , '' , static :: TABLE ) . '_' ; } $ prefixlength = strlen ( $ prefix ) ; $ data = new stdClass ( ) ; foreach ( $ row as $ property => $ value ) { if ( strpos ( $ property , $ prefix ) === 0 ) { $...
Extract a record from a row of data .
35,236
public static function get_records ( $ filters = array ( ) , $ sort = '' , $ order = 'ASC' , $ skip = 0 , $ limit = 0 ) { global $ DB ; $ orderby = '' ; if ( ! empty ( $ sort ) ) { $ orderby = $ sort . ' ' . $ order ; } $ records = $ DB -> get_records ( static :: TABLE , $ filters , $ orderby , '*' , $ skip , $ limit )...
Load a list of records .
35,237
public static function get_record ( $ filters = array ( ) ) { global $ DB ; $ record = $ DB -> get_record ( static :: TABLE , $ filters ) ; return $ record ? new static ( 0 , $ record ) : false ; }
Load a single record .
35,238
public static function get_records_select ( $ select , $ params = null , $ sort = '' , $ fields = '*' , $ limitfrom = 0 , $ limitnum = 0 ) { global $ DB ; $ records = $ DB -> get_records_select ( static :: TABLE , $ select , $ params , $ sort , $ fields , $ limitfrom , $ limitnum ) ; $ instances = array ( ) ; foreach (...
Load a list of records based on a select query .
35,239
public static function get_sql_fields ( $ alias , $ prefix = null ) { global $ CFG ; $ fields = array ( ) ; if ( $ prefix === null ) { $ prefix = str_replace ( '_' , '' , static :: TABLE ) . '_' ; } $ properties = static :: properties_definition ( ) ; $ id = $ properties [ 'id' ] ; unset ( $ properties [ 'id' ] ) ; $ p...
Return the list of fields for use in a SELECT clause .
35,240
public static function count_records_select ( $ select , $ params = null ) { global $ DB ; $ count = $ DB -> count_records_select ( static :: TABLE , $ select , $ params ) ; return $ count ; }
Count a list of records .
35,241
public static function record_exists_select ( $ select , array $ params = null ) { global $ DB ; return $ DB -> record_exists_select ( static :: TABLE , $ select , $ params ) ; }
Check if a records exists .
35,242
public function extract ( tgz_extractor_handler $ handler , file_progress $ progress = null ) { $ this -> mode = self :: MODE_EXTRACT ; $ this -> extract_or_list ( $ handler , $ progress ) ; $ results = $ this -> results ; unset ( $ this -> results ) ; return $ results ; }
Extracts the archive .
35,243
protected function process_header ( $ block , $ handler ) { if ( $ block === str_pad ( '' , tgz_packer :: TAR_BLOCK_SIZE , "\0" ) ) { return ; } $ name = rtrim ( substr ( $ block , 0 , 100 ) , "\0" ) ; $ filesize = octdec ( substr ( $ block , 124 , 11 ) ) ; $ mtime = octdec ( substr ( $ block , 136 , 11 ) ) ; $ typefla...
Process 512 - byte header block .
35,244
protected function process_file_block ( $ block , tgz_extractor_handler $ handler = null ) { $ blocksize = tgz_packer :: TAR_BLOCK_SIZE ; if ( $ this -> currentfileprocessed + tgz_packer :: TAR_BLOCK_SIZE > $ this -> currentfilesize ) { $ blocksize = $ this -> currentfilesize - $ this -> currentfileprocessed ; $ this -...
Processes one 512 - byte block of an existing file .
35,245
protected function start_current_file ( $ archivepath , $ filesize , $ mtime , tgz_extractor_handler $ handler = null ) { global $ CFG ; $ this -> currentarchivepath = $ archivepath ; $ this -> currentmtime = $ mtime ; $ this -> currentfilesize = $ filesize ; $ this -> currentfileprocessed = 0 ; if ( $ archivepath === ...
Starts processing a file from archive .
35,246
protected function close_current_file ( $ handler ) { if ( $ this -> currentfp !== null ) { if ( ! fclose ( $ this -> currentfp ) ) { throw new moodle_exception ( 'errorprocessingarchive' , '' , '' , null , 'Failed to close output file: ' . $ this -> currentfile ) ; } } if ( $ this -> currentarchivepath === tgz_packer ...
Closes the current file calls handler and sets up data .
35,247
public function get_file_info ( $ context = NULL , $ component = NULL , $ filearea = NULL , $ itemid = NULL , $ filepath = NULL , $ filename = NULL ) { if ( ! $ context ) { $ context = context_system :: instance ( ) ; } switch ( $ context -> contextlevel ) { case CONTEXT_SYSTEM : return $ this -> get_file_info_context_...
Looks up file_info instance
35,248
private function get_file_info_context_user ( $ context , $ component , $ filearea , $ itemid , $ filepath , $ filename ) { global $ DB , $ USER ; if ( $ context -> instanceid == $ USER -> id ) { $ user = $ USER ; } else { $ user = $ DB -> get_record ( 'user' , array ( 'id' => $ context -> instanceid ) ) ; } if ( isgue...
Returns info about the files at User context
35,249
public function is_enrolled ( $ courseid ) { if ( $ this -> enrolledcourses === null || PHPUNIT_TEST ) { $ this -> enrolledcourses = enrol_get_my_courses ( [ 'id' ] ) ; } return array_key_exists ( $ courseid , $ this -> enrolledcourses ) ; }
Check if user is enrolled into the course
35,250
public function insert ( $ oItem , $ oSibling ) { $ iIndex = array_search ( $ oSibling , $ this -> aContents ) ; if ( $ iIndex === false ) { return $ this -> append ( $ oItem ) ; } array_splice ( $ this -> aContents , $ iIndex , 0 , array ( $ oItem ) ) ; }
Insert an item before its sibling .
35,251
public function remove ( $ oItemToRemove ) { $ iKey = array_search ( $ oItemToRemove , $ this -> aContents , true ) ; if ( $ iKey !== false ) { unset ( $ this -> aContents [ $ iKey ] ) ; return true ; } return false ; }
Removes an item from the CSS list .
35,252
public function setContents ( array $ aContents ) { $ this -> aContents = array ( ) ; foreach ( $ aContents as $ content ) { $ this -> append ( $ content ) ; } }
Set the contents .
35,253
public function removeDeclarationBlockBySelector ( $ mSelector , $ bRemoveAll = false ) { if ( $ mSelector instanceof DeclarationBlock ) { $ mSelector = $ mSelector -> getSelectors ( ) ; } if ( ! is_array ( $ mSelector ) ) { $ mSelector = explode ( ',' , $ mSelector ) ; } foreach ( $ mSelector as $ iKey => & $ mSel ) {...
Removes a declaration block from the CSS list if it matches all given selectors .
35,254
protected function render_report_loglive ( report_loglive_renderable $ reportloglive ) { if ( empty ( $ reportloglive -> selectedlogreader ) ) { return null ; } $ table = $ reportloglive -> get_table ( true ) ; return $ table -> out ( $ reportloglive -> perpage , false ) ; }
Render logs for ajax .
35,255
public function Reset ( $ options = null ) { $ this -> rules = array ( ) ; self :: $ imports = array ( ) ; self :: $ has_extends = false ; self :: $ imports = array ( ) ; self :: $ contentsMap = array ( ) ; $ this -> env = new Less_Environment ( $ options ) ; $ this -> env -> Init ( ) ; if ( is_array ( $ options ) ) { ...
Reset the parser state completely
35,256
public function SetOption ( $ option , $ value ) { switch ( $ option ) { case 'import_dirs' : $ this -> SetImportDirs ( $ value ) ; return ; case 'cache_dir' : if ( is_string ( $ value ) ) { Less_Cache :: SetCacheDir ( $ value ) ; Less_Cache :: CheckCacheDir ( ) ; } return ; } Less_Parser :: $ options [ $ option ] = $ ...
Set one compiler option
35,257
public function unregisterFunction ( $ name ) { if ( isset ( $ this -> env -> functions [ $ name ] ) ) unset ( $ this -> env -> functions [ $ name ] ) ; }
Removed an already registered function
35,258
public function getCss ( ) { $ precision = ini_get ( 'precision' ) ; @ ini_set ( 'precision' , 16 ) ; $ locale = setlocale ( LC_NUMERIC , 0 ) ; setlocale ( LC_NUMERIC , "C" ) ; try { $ root = new Less_Tree_Ruleset ( array ( ) , $ this -> rules ) ; $ root -> root = true ; $ root -> firstRoot = true ; $ this -> PreVisito...
Get the current css buffer
35,259
private function PreVisitors ( $ root ) { if ( Less_Parser :: $ options [ 'plugins' ] ) { foreach ( Less_Parser :: $ options [ 'plugins' ] as $ plugin ) { if ( ! empty ( $ plugin -> isPreEvalVisitor ) ) { $ plugin -> run ( $ root ) ; } } } }
Run pre - compile visitors
35,260
private function PostVisitors ( $ evaldRoot ) { $ visitors = array ( ) ; $ visitors [ ] = new Less_Visitor_joinSelector ( ) ; if ( self :: $ has_extends ) { $ visitors [ ] = new Less_Visitor_processExtends ( ) ; } $ visitors [ ] = new Less_Visitor_toCSS ( ) ; if ( Less_Parser :: $ options [ 'plugins' ] ) { foreach ( Le...
Run post - compile visitors
35,261
public function parse ( $ str , $ file_uri = null ) { if ( ! $ file_uri ) { $ uri_root = '' ; $ filename = 'anonymous-file-' . Less_Parser :: $ next_id ++ . '.less' ; } else { $ file_uri = self :: WinPath ( $ file_uri ) ; $ filename = $ file_uri ; $ uri_root = dirname ( $ file_uri ) ; } $ previousFileInfo = $ this -> e...
Parse a Less string into css
35,262
public function ModifyVars ( $ vars ) { $ this -> input = Less_Parser :: serializeVars ( $ vars ) ; $ this -> _parse ( ) ; return $ this ; }
Allows a user to set variables values
35,263
public function SetImportDirs ( $ dirs ) { Less_Parser :: $ options [ 'import_dirs' ] = array ( ) ; foreach ( $ dirs as $ path => $ uri_root ) { $ path = self :: WinPath ( $ path ) ; if ( ! empty ( $ path ) ) { $ path = rtrim ( $ path , '/' ) . '/' ; } if ( ! is_callable ( $ uri_root ) ) { $ uri_root = self :: WinPath ...
Set a list of directories or callbacks the parser should use for determining import paths
35,264
public function SetInput ( $ file_path ) { if ( $ file_path ) { $ this -> input = file_get_contents ( $ file_path ) ; } $ this -> pos = $ this -> furthest = 0 ; $ this -> input = preg_replace ( '/\\G\xEF\xBB\xBF/' , '' , $ this -> input ) ; $ this -> input_len = strlen ( $ this -> input ) ; if ( Less_Parser :: $ option...
Set up the input buffer
35,265
public function UnsetInput ( ) { unset ( $ this -> input , $ this -> pos , $ this -> input_len , $ this -> furthest ) ; $ this -> saveStack = array ( ) ; }
Free up some memory
35,266
private function match ( $ toks ) { foreach ( $ toks as $ tok ) { $ char = $ tok [ 0 ] ; if ( $ char === '/' ) { $ match = $ this -> MatchReg ( $ tok ) ; if ( $ match ) { return count ( $ match ) === 1 ? $ match [ 0 ] : $ match ; } } elseif ( $ char === '#' ) { $ match = $ this -> MatchChar ( $ tok [ 1 ] ) ; } else { $...
Parse from a token regexp or string and move forward if match
35,267
private function MatchChar ( $ tok ) { if ( ( $ this -> pos < $ this -> input_len ) && ( $ this -> input [ $ this -> pos ] === $ tok ) ) { $ this -> skipWhitespace ( 1 ) ; return $ tok ; } }
Match a single character in the input
35,268
private function MatchReg ( $ tok ) { if ( preg_match ( $ tok , $ this -> input , $ match , 0 , $ this -> pos ) ) { $ this -> skipWhitespace ( strlen ( $ match [ 0 ] ) ) ; return $ match ; } }
Match a regexp from the current start point
35,269
private function parseComment ( ) { if ( $ this -> input [ $ this -> pos ] !== '/' ) { return ; } if ( $ this -> input [ $ this -> pos + 1 ] === '/' ) { $ match = $ this -> MatchReg ( '/\\G\/\/.*/' ) ; return $ this -> NewObj4 ( 'Less_Tree_Comment' , array ( $ match [ 0 ] , true , $ this -> pos , $ this -> env -> curre...
over them .
35,270
private function parseEntitiesArguments ( ) { $ args = array ( ) ; while ( true ) { $ arg = $ this -> MatchFuncs ( array ( 'parseEntitiesAssignment' , 'parseExpression' ) ) ; if ( ! $ arg ) { break ; } $ args [ ] = $ arg ; if ( ! $ this -> MatchChar ( ',' ) ) { break ; } } return $ args ; }
Parse a list of arguments
35,271
function parseMultiplication ( ) { $ return = $ m = $ this -> parseOperand ( ) ; if ( $ return ) { while ( true ) { $ isSpaced = $ this -> isWhitespace ( - 1 ) ; if ( $ this -> PeekReg ( '/\\G\/[*\/]/' ) ) { break ; } $ op = $ this -> MatchChar ( '/' ) ; if ( ! $ op ) { $ op = $ this -> MatchChar ( '*' ) ; if ( ! $ op ...
Parses multiplication operation
35,272
private function parseAddition ( ) { $ return = $ m = $ this -> parseMultiplication ( ) ; if ( $ return ) { while ( true ) { $ isSpaced = $ this -> isWhitespace ( - 1 ) ; $ op = $ this -> MatchReg ( '/\\G[-+]\s+/' ) ; if ( $ op ) { $ op = $ op [ 0 ] ; } else { if ( ! $ isSpaced ) { $ op = $ this -> match ( array ( '#+'...
Parses an addition operation
35,273
private function parseConditions ( ) { $ index = $ this -> pos ; $ return = $ a = $ this -> parseCondition ( ) ; if ( $ a ) { while ( true ) { if ( ! $ this -> PeekReg ( '/\\G,\s*(not\s*)?\(/' ) || ! $ this -> MatchChar ( ',' ) ) { break ; } $ b = $ this -> parseCondition ( ) ; if ( ! $ b ) { break ; } $ return = $ thi...
Parses the conditions
35,274
private function parseOperand ( ) { $ negate = false ; $ offset = $ this -> pos + 1 ; if ( $ offset >= $ this -> input_len ) { return ; } $ char = $ this -> input [ $ offset ] ; if ( $ char === '@' || $ char === '(' ) { $ negate = $ this -> MatchChar ( '-' ) ; } $ o = $ this -> MatchFuncs ( array ( 'parseSub' , 'parseE...
An operand is anything that can be part of an operation such as a Color or a Variable
35,275
private function parseExpression ( ) { $ entities = array ( ) ; do { $ e = $ this -> MatchFuncs ( array ( 'parseAddition' , 'parseEntity' ) ) ; if ( $ e ) { $ entities [ ] = $ e ; if ( ! $ this -> PeekReg ( '/\\G\/[\/*]/' ) ) { $ delim = $ this -> MatchChar ( '/' ) ; if ( $ delim ) { $ entities [ ] = $ this -> NewObj1 ...
Expressions either represent mathematical operations or white - space delimited Entities .
35,276
public static function ArgString ( $ arg ) { $ type = gettype ( $ arg ) ; if ( $ type === 'object' ) { $ string = $ arg -> cache_string ; unset ( $ arg -> cache_string ) ; return $ string ; } elseif ( $ type === 'array' ) { $ string = ' Array(' ; foreach ( $ arg as $ k => $ a ) { $ string .= var_export ( $ k , true ) ....
Convert an argument to a string for use in the parser cache
35,277
protected static function typo3 ( $ reset = false ) { static $ typo3cs = null ; if ( $ reset ) { $ typo3cs = null ; return null ; } if ( isset ( $ typo3cs ) ) { return $ typo3cs ; } global $ CFG ; require_once ( $ CFG -> libdir . '/typo3/class.t3lib_cs.php' ) ; require_once ( $ CFG -> libdir . '/typo3/class.t3lib_div.p...
Return t3lib helper class which is used for conversion between charsets
35,278
public static function parse_charset ( $ charset ) { $ charset = strtolower ( $ charset ) ; if ( $ charset === 'utf8' or $ charset === 'utf-8' ) { return 'utf-8' ; } if ( preg_match ( '/^(cp|win|windows)-?(12[0-9]{2})$/' , $ charset , $ matches ) ) { return 'windows-' . $ matches [ 2 ] ; } if ( preg_match ( '/^iso-8859...
Standardise charset name
35,279
public static function str_max_bytes ( $ string , $ bytes ) { if ( function_exists ( 'mb_strcut' ) ) { return mb_strcut ( $ string , 0 , $ bytes , 'UTF-8' ) ; } $ oldlevel = error_reporting ( E_PARSE ) ; $ result = self :: typo3 ( ) -> strtrunc ( 'utf-8' , $ string , $ bytes ) ; error_reporting ( $ oldlevel ) ; return ...
Truncates a string to no more than a certain number of bytes in a multi - byte safe manner . UTF - 8 only!
35,280
public static function specialtoascii ( $ text , $ charset = 'utf-8' ) { $ charset = self :: parse_charset ( $ charset ) ; $ oldlevel = error_reporting ( E_PARSE ) ; $ result = self :: typo3 ( ) -> specCharsToASCII ( $ charset , ( string ) $ text ) ; error_reporting ( $ oldlevel ) ; return $ result ; }
Try to convert upper unicode characters to plain ascii the returned string may contain unconverted unicode characters .
35,281
protected static function get_entities_table ( ) { static $ trans_tbl = null ; if ( ! isset ( $ trans_tbl ) ) { if ( version_compare ( phpversion ( ) , '5.3.4' ) < 0 ) { $ trans_tbl = array ( ) ; foreach ( get_html_translation_table ( HTML_ENTITIES ) as $ val => $ key ) { $ trans_tbl [ $ key ] = self :: convert ( $ val...
Returns HTML entity transliteration table .
35,282
public static function get_encodings ( ) { $ encodings = array ( ) ; $ encodings [ 'UTF-8' ] = 'UTF-8' ; $ winenc = strtoupper ( get_string ( 'localewincharset' , 'langconfig' ) ) ; if ( $ winenc != '' ) { $ encodings [ $ winenc ] = $ winenc ; } $ nixenc = strtoupper ( get_string ( 'oldcharset' , 'langconfig' ) ) ; $ e...
Returns encoding options for select boxes utf - 8 and platform encoding first
35,283
public static function utf8ord ( $ utf8char ) { if ( $ utf8char == '' ) { return 0 ; } $ ord0 = ord ( $ utf8char { 0 } ) ; if ( $ ord0 >= 0 && $ ord0 <= 127 ) { return $ ord0 ; } $ ord1 = ord ( $ utf8char { 1 } ) ; if ( $ ord0 >= 192 && $ ord0 <= 223 ) { return ( $ ord0 - 192 ) * 64 + ( $ ord1 - 128 ) ; } $ ord2 = ord ...
Returns the code of the given UTF - 8 character
35,284
public static function strtotitle ( $ text ) { if ( empty ( $ text ) ) { return $ text ; } if ( function_exists ( 'mb_convert_case' ) ) { return mb_convert_case ( $ text , MB_CASE_TITLE , 'UTF-8' ) ; } $ text = self :: strtolower ( $ text ) ; $ words = explode ( ' ' , $ text ) ; foreach ( $ words as $ i => $ word ) { $...
Makes first letter of each word capital - words must be separated by spaces . Use with care this function does not work properly in many locales!!!
35,285
public function qualifies_for_regrading ( ) { if ( empty ( $ this -> id ) ) { return false ; } $ db_item = new grade_item ( array ( 'id' => $ this -> id ) ) ; $ calculationdiff = $ db_item -> calculation != $ this -> calculation ; $ categorydiff = $ db_item -> categoryid != $ this -> categoryid ; $ gradetypediff = $ db...
Compares the values held by this object with those of the matching record in DB and returns whether or not these differences are sufficient to justify an update of all parent objects . This assumes that this object has an id number and a matching record in DB . If not it will return false .
35,286
public function delete_all_grades ( $ source = null ) { if ( ! $ this -> is_course_item ( ) ) { $ this -> force_regrading ( ) ; } if ( $ grades = grade_grade :: fetch_all ( array ( 'itemid' => $ this -> id ) ) ) { foreach ( $ grades as $ grade ) { $ grade -> delete ( $ source ) ; } } if ( $ this -> is_external_item ( )...
Delete all grades
35,287
public function add_idnumber ( $ idnumber ) { global $ DB ; if ( ! empty ( $ this -> idnumber ) ) { return false ; } if ( $ this -> itemtype == 'mod' and ! $ this -> is_outcome_item ( ) ) { if ( $ this -> itemnumber == 0 ) { if ( ! $ cm = get_coursemodule_from_instance ( $ this -> itemmodule , $ this -> iteminstance , ...
Set idnumber of grade item updates also course_modules table
35,288
public function set_hidden ( $ hidden , $ cascade = false ) { parent :: set_hidden ( $ hidden , $ cascade ) ; if ( $ cascade ) { if ( $ grades = grade_grade :: fetch_all ( array ( 'itemid' => $ this -> id ) ) ) { foreach ( $ grades as $ grade ) { $ grade -> grade_item = & $ this ; $ grade -> set_hidden ( $ hidden , $ c...
Set the hidden status of grade_item and all grades .
35,289
public function has_hidden_grades ( $ groupsql = "" , array $ params = null , $ groupwheresql = "" ) { global $ DB ; $ params = ( array ) $ params ; $ params [ 'itemid' ] = $ this -> id ; return $ DB -> get_field_sql ( "SELECT COUNT(*) FROM {grade_grades} g LEFT JOIN " . "{user} u ON g.userid = u.id $groupsql WHERE ite...
Returns the number of grades that are hidden
35,290
public function regrade_final_grades ( $ userid = null ) { global $ CFG , $ DB ; if ( $ this -> is_locked ( ) ) { return true ; } if ( $ this -> is_calculated ( ) ) { if ( $ this -> compute ( $ userid ) ) { return true ; } else { return "Could not calculate grades for grade item" ; } } else if ( $ this -> is_outcome_it...
Performs the necessary calculations on the grades_final referenced by this grade_item . Also resets the needsupdate flag once successfully performed .
35,291
public function adjust_raw_grade ( $ rawgrade , $ rawmin , $ rawmax ) { if ( is_null ( $ rawgrade ) ) { return null ; } if ( $ this -> gradetype == GRADE_TYPE_VALUE ) { if ( $ this -> grademax < $ this -> grademin ) { return null ; } if ( $ this -> grademax == $ this -> grademin ) { return $ this -> grademax ; } $ manu...
Given a float grade value or integer grade scale applies a number of adjustment based on grade_item variables and returns the result .
35,292
public function rescale_grades_keep_percentage ( $ oldgrademin , $ oldgrademax , $ newgrademin , $ newgrademax , $ source = null ) { global $ DB ; if ( empty ( $ this -> id ) ) { return false ; } if ( $ oldgrademax <= $ oldgrademin ) { return false ; } $ scale = ( $ newgrademax - $ newgrademin ) / ( $ oldgrademax - $ o...
Update the rawgrademax and rawgrademin for all grade_grades records for this item . Scale every rawgrade to maintain the percentage . This function should be called after the gradeitem has been updated to the new min and max values .
35,293
public function force_regrading ( ) { global $ DB ; $ this -> needsupdate = 1 ; $ wheresql = "(itemtype='course' OR id=?) AND courseid=?" ; $ params = array ( $ this -> id , $ this -> courseid ) ; $ DB -> set_field_select ( 'grade_items' , 'needsupdate' , 1 , $ wheresql , $ params ) ; }
Sets this grade_item s needsupdate to true . Also marks the course item as needing update .
35,294
public function load_scale ( ) { if ( $ this -> gradetype != GRADE_TYPE_SCALE ) { $ this -> scaleid = null ; } if ( ! empty ( $ this -> scaleid ) ) { if ( empty ( $ this -> scale -> id ) or $ this -> scale -> id != $ this -> scaleid ) { $ this -> scale = grade_scale :: fetch ( array ( 'id' => $ this -> scaleid ) ) ; if...
Instantiates a grade_scale object from the DB if this item s scaleid variable is set
35,295
public function load_outcome ( ) { if ( ! empty ( $ this -> outcomeid ) ) { $ this -> outcome = grade_outcome :: fetch ( array ( 'id' => $ this -> outcomeid ) ) ; } return $ this -> outcome ; }
Instantiates a grade_outcome object from the DB if this item s outcomeid variable is set
35,296
public function get_item_category ( ) { if ( ! $ this -> is_course_item ( ) and ! $ this -> is_category_item ( ) ) { return false ; } return grade_category :: fetch ( array ( 'id' => $ this -> iteminstance ) ) ; }
Returns the grade_category for a grade category grade item
35,297
public function is_overridable_item ( ) { if ( $ this -> is_course_item ( ) or $ this -> is_category_item ( ) ) { $ overridable = ( bool ) get_config ( 'moodle' , 'grade_overridecat' ) ; } else { $ overridable = false ; } return ! $ this -> is_outcome_item ( ) and ( $ this -> is_external_item ( ) or $ this -> is_calcul...
Is the grade item overridable
35,298
public static function fetch_course_item ( $ courseid ) { if ( $ course_item = grade_item :: fetch ( array ( 'courseid' => $ courseid , 'itemtype' => 'course' ) ) ) { return $ course_item ; } $ course_category = grade_category :: fetch_course_category ( $ courseid ) ; return $ course_category -> get_grade_item ( ) ; }
Returns the grade item associated with the course
35,299
public function is_calculated ( ) { if ( empty ( $ this -> calculation ) ) { return false ; } if ( ! $ this -> calculation_normalized and strpos ( $ this -> calculation , '[[' ) !== false ) { $ this -> set_calculation ( $ this -> calculation ) ; } return ! empty ( $ this -> calculation ) ; }
Checks if grade calculated . Returns this object s calculation .