idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
29,300 | protected function get_component_select_sql ( $ alias = '' ) { $ component = $ this -> get_component ( ) ; if ( $ alias ) { $ alias = $ alias . '.' ; } if ( empty ( $ component ) ) { $ componentwhere = "{$alias}component IS NULL" ; $ component = null ; } else { $ componentwhere = "({$alias}component IS NULL OR {$alias}... | Returns an SQL fragment and param for selecting on component . |
29,301 | public function count ( ) { global $ DB ; if ( $ this -> totalcommentcount === null ) { list ( $ where , $ component ) = $ this -> get_component_select_sql ( ) ; $ where .= ' AND itemid = :itemid AND commentarea = :commentarea AND contextid = :contextid' ; $ params = array ( 'itemid' => $ this -> itemid , 'commentarea'... | Returns the number of comments associated with the details of this object |
29,302 | public function get_pagination ( $ page = 0 ) { global $ CFG , $ OUTPUT ; $ count = $ this -> count ( ) ; $ perpage = ( ! empty ( $ CFG -> commentsperpage ) ) ? $ CFG -> commentsperpage : 15 ; $ pages = ( int ) ceil ( $ count / $ perpage ) ; if ( $ pages == 1 || $ pages == 0 ) { return html_writer :: tag ( 'div' , '' ,... | Returns HTML to display a pagination bar |
29,303 | public static function delete_comments ( $ param ) { global $ DB ; $ param = ( array ) $ param ; if ( empty ( $ param [ 'contextid' ] ) ) { return false ; } $ DB -> delete_records ( 'comments' , $ param ) ; return true ; } | delete by context commentarea and itemid |
29,304 | public static function reset_course_page_comments ( $ context ) { global $ DB ; $ contexts = array ( ) ; $ contexts [ ] = $ context -> id ; $ children = $ context -> get_child_contexts ( ) ; foreach ( $ children as $ c ) { $ contexts [ ] = $ c -> id ; } list ( $ ids , $ params ) = $ DB -> get_in_or_equal ( $ contexts )... | Delete page_comments in whole course used by course reset |
29,305 | public function print_comment ( $ cmt , $ nonjs = true ) { global $ OUTPUT ; $ patterns = array ( ) ; $ replacements = array ( ) ; if ( ! empty ( $ cmt -> delete ) && empty ( $ nonjs ) ) { $ strdelete = get_string ( 'deletecommentbyon' , 'moodle' , ( object ) [ 'user' => $ cmt -> fullname , 'time' => $ cmt -> time ] ) ... | Returns an array containing comments in HTML format . |
29,306 | protected function validate ( $ params = array ( ) ) { foreach ( $ params as $ key => $ value ) { $ this -> comment_param -> $ key = $ value ; } $ validation = plugin_callback ( $ this -> plugintype , $ this -> pluginname , 'comment' , 'validate' , array ( $ this -> comment_param ) , false ) ; if ( ! $ validation ) { t... | Revoke validate callbacks |
29,307 | protected function smtpSend ( $ header , $ body ) { $ bad_rcpt = [ ] ; if ( ! $ this -> smtpConnect ( $ this -> SMTPOptions ) ) { throw new Exception ( $ this -> lang ( 'smtp_connect_failed' ) , self :: STOP_CRITICAL ) ; } if ( '' == $ this -> Sender ) { $ smtp_from = $ this -> From ; } else { $ smtp_from = $ this -> S... | Send mail via SMTP . Returns false if there is a bad MAIL FROM RCPT or DATA input . |
29,308 | protected function getBoundary ( $ boundary , $ charSet , $ contentType , $ encoding ) { $ result = '' ; if ( '' == $ charSet ) { $ charSet = $ this -> CharSet ; } if ( '' == $ contentType ) { $ contentType = $ this -> ContentType ; } if ( '' == $ encoding ) { $ encoding = $ this -> Encoding ; } $ result .= $ this -> t... | Return the start of a message boundary . |
29,309 | public function DKIM_BodyC ( $ body ) { if ( empty ( $ body ) ) { return static :: $ LE ; } $ body = static :: normalizeBreaks ( $ body ) ; return rtrim ( $ body , "\r\n" ) . static :: $ LE ; } | Generate a DKIM canonicalization body . Uses the simple algorithm from RFC6376 section 3 . 4 . 3 . |
29,310 | public function str ( $ text , Mustache_LambdaHelper $ helper ) { $ key = strtok ( $ text , "," ) ; $ key = trim ( $ key ) ; $ component = strtok ( "," ) ; $ component = trim ( $ component ) ; if ( ! $ component ) { $ component = '' ; } $ a = new stdClass ( ) ; $ next = strtok ( '' ) ; $ next = trim ( $ next ) ; if ( (... | Read a lang string from a template and get it from get_string . |
29,311 | public function cache ( $ qubaids ) { global $ DB ; $ toinsert = new \ stdClass ( ) ; foreach ( $ this -> fieldsindb as $ field ) { $ toinsert -> { $ field } = $ this -> { $ field } ; } $ toinsert -> hashcode = $ qubaids -> get_hash_code ( ) ; $ toinsert -> timemodified = time ( ) ; if ( isset ( $ toinsert -> errorrati... | Cache the stats contained in this class . |
29,312 | protected function feedback_popup ( question_graded_automatically $ subq , $ fraction , $ feedbacktext , $ rightanswer , question_display_options $ options ) { $ feedback = array ( ) ; if ( $ options -> correctness ) { if ( is_null ( $ fraction ) ) { $ state = question_state :: $ gaveup ; } else { $ state = question_st... | Render the feedback pop - up contents . |
29,313 | public function render_display_index_heading ( $ linktext , $ listquestionurl ) { $ output = '' ; $ output .= $ this -> heading ( get_string ( 'questionsthatneedgrading' , 'quiz_grading' ) , 3 ) ; $ output .= html_writer :: tag ( 'p' , html_writer :: link ( $ listquestionurl , $ linktext ) , [ 'class' => 'toggleinclude... | Render index display . |
29,314 | public function render_questions_table ( $ includeauto , $ data , $ header ) { if ( empty ( $ data ) ) { return $ this -> render_quiz_no_grade_question_notification ( ) ; } $ output = '' ; $ table = new html_table ( ) ; $ table -> class = 'generaltable' ; $ table -> id = 'questionstograde' ; $ table -> head = $ header ... | Render questions list table . |
29,315 | public function render_grade_link ( $ counts , $ type , $ gradestring , $ gradequestionurl ) { $ output = '' ; if ( $ counts -> $ type > 0 ) { $ output .= ' ' . html_writer :: link ( $ gradequestionurl , get_string ( $ gradestring , 'quiz_grading' ) , [ 'class' => 'gradetheselink' ] ) ; } return $ output ; } | Render grade link for question . |
29,316 | public function render_grading_interface ( $ questioninfo , $ listquestionsurl , $ filterform , $ paginginfo , $ pagingbar , $ formaction , $ hiddeninputs , $ gradequestioncontent ) { $ output = '' ; $ output .= question_engine :: initialise_js ( ) ; $ output .= $ this -> heading ( get_string ( 'gradingquestionx' , 'qu... | Render grading page . |
29,317 | public function render_grade_question ( $ questionusage , $ slot , $ displayoptions , $ questionnumber , $ heading ) { $ output = '' ; if ( $ heading ) { $ output .= $ this -> heading ( $ heading , 4 ) ; } $ output .= $ questionusage -> render_question ( $ slot , $ displayoptions , $ questionnumber ) ; return $ output ... | Render grade question content . |
29,318 | public function user_reset_rss_token_confirmation ( ) { global $ OUTPUT , $ CFG ; $ managetokenurl = $ CFG -> wwwroot . "/user/managetoken.php?sesskey=" . sesskey ( ) ; $ optionsyes = array ( 'action' => 'resetrsstoken' , 'confirm' => 1 , 'sesskey' => sesskey ( ) ) ; $ optionsno = array ( 'section' => 'webservicetokens... | Returns the html for the token reset confirmation box |
29,319 | public function user_rss_token_box ( $ token ) { global $ OUTPUT , $ CFG ; $ stroperation = get_string ( 'operation' , 'webservice' ) ; $ strtoken = get_string ( 'key' , 'webservice' ) ; $ return = $ OUTPUT -> heading ( get_string ( 'rss' , 'rss' ) , 3 , 'main' , true ) ; $ return .= $ OUTPUT -> box_start ( 'generalbox... | Display a user token with buttons to reset it |
29,320 | public function generateFilePath ( $ config ) { $ key = $ this -> generateKey ( $ config ) ; return $ this -> generateDirectoryPath ( $ config ) . '/' . $ key . '.ser' ; } | Generates the file path to the serial file corresponding to the configuration and definition name |
29,321 | public function generateBaseDirectoryPath ( $ config ) { $ base = $ config -> get ( 'Cache.SerializerPath' ) ; $ base = is_null ( $ base ) ? HTMLPURIFIER_PREFIX . '/HTMLPurifier/DefinitionCache/Serializer' : $ base ; return $ base ; } | Generates path to base directory that contains all definition type serials |
29,322 | private function _write ( $ file , $ data , $ config ) { $ result = file_put_contents ( $ file , $ data ) ; if ( $ result !== false ) { $ chmod = $ config -> get ( 'Cache.SerializerPermissions' ) ; if ( $ chmod !== null ) { chmod ( $ file , $ chmod & 0666 ) ; } } return $ result ; } | Convenience wrapper function for file_put_contents |
29,323 | public function remove ( stdClass $ submission ) { global $ DB ; $ submissionid = $ submission ? $ submission -> id : 0 ; if ( $ submissionid ) { $ DB -> delete_records ( 'assignsubmission_onlinetext' , array ( 'submission' => $ submissionid ) ) ; } return true ; } | Remove a submission . |
29,324 | public function get_settings ( MoodleQuickForm $ mform ) { global $ CFG , $ COURSE ; $ defaultwordlimit = $ this -> get_config ( 'wordlimit' ) == 0 ? '' : $ this -> get_config ( 'wordlimit' ) ; $ defaultwordlimitenabled = $ this -> get_config ( 'wordlimitenabled' ) ; $ options = array ( 'size' => '6' , 'maxlength' => '... | Get the settings for onlinetext submission plugin |
29,325 | public function save_settings ( stdClass $ data ) { if ( empty ( $ data -> assignsubmission_onlinetext_wordlimit ) || empty ( $ data -> assignsubmission_onlinetext_wordlimit_enabled ) ) { $ wordlimit = 0 ; $ wordlimitenabled = 0 ; } else { $ wordlimit = $ data -> assignsubmission_onlinetext_wordlimit ; $ wordlimitenabl... | Save the settings for onlinetext submission plugin |
29,326 | public function get_form_elements ( $ submission , MoodleQuickForm $ mform , stdClass $ data ) { $ elements = array ( ) ; $ editoroptions = $ this -> get_edit_options ( ) ; $ submissionid = $ submission ? $ submission -> id : 0 ; if ( ! isset ( $ data -> onlinetext ) ) { $ data -> onlinetext = '' ; } if ( ! isset ( $ d... | Add form elements for settings |
29,327 | private function get_edit_options ( ) { $ editoroptions = array ( 'noclean' => false , 'maxfiles' => EDITOR_UNLIMITED_FILES , 'maxbytes' => $ this -> assignment -> get_course ( ) -> maxbytes , 'context' => $ this -> assignment -> get_context ( ) , 'return_types' => ( FILE_INTERNAL | FILE_EXTERNAL | FILE_CONTROLLED_LINK... | Editor format options |
29,328 | public function get_editor_text ( $ name , $ submissionid ) { if ( $ name == 'onlinetext' ) { $ onlinetextsubmission = $ this -> get_onlinetext_submission ( $ submissionid ) ; if ( $ onlinetextsubmission ) { return $ onlinetextsubmission -> onlinetext ; } } return '' ; } | Get the saved text content from the editor |
29,329 | public function get_editor_format ( $ name , $ submissionid ) { if ( $ name == 'onlinetext' ) { $ onlinetextsubmission = $ this -> get_onlinetext_submission ( $ submissionid ) ; if ( $ onlinetextsubmission ) { return $ onlinetextsubmission -> onlineformat ; } } return 0 ; } | Get the content format for the editor |
29,330 | public function view_summary ( stdClass $ submission , & $ showviewlink ) { global $ CFG ; $ onlinetextsubmission = $ this -> get_onlinetext_submission ( $ submission -> id ) ; $ showviewlink = true ; if ( $ onlinetextsubmission ) { $ text = $ this -> assignment -> render_editor_content ( ASSIGNSUBMISSION_ONLINETEXT_FI... | Display onlinetext word count in the submission status table |
29,331 | public function get_files ( stdClass $ submission , stdClass $ user ) { global $ DB ; $ files = array ( ) ; $ onlinetextsubmission = $ this -> get_onlinetext_submission ( $ submission -> id ) ; if ( $ onlinetextsubmission ) { $ formattedtext = $ this -> assignment -> download_rewrite_pluginfile_urls ( $ onlinetextsubmi... | Produce a list of files suitable for export that represent this submission . |
29,332 | public function view ( stdClass $ submission ) { global $ CFG ; $ result = '' ; $ onlinetextsubmission = $ this -> get_onlinetext_submission ( $ submission -> id ) ; if ( $ onlinetextsubmission ) { $ result .= $ this -> assignment -> render_editor_content ( ASSIGNSUBMISSION_ONLINETEXT_FILEAREA , $ onlinetextsubmission ... | Display the saved text content from the editor in the view table |
29,333 | public function is_empty ( stdClass $ submission ) { $ onlinetextsubmission = $ this -> get_onlinetext_submission ( $ submission -> id ) ; $ wordcount = 0 ; if ( isset ( $ onlinetextsubmission -> onlinetext ) ) { $ wordcount = count_words ( trim ( $ onlinetextsubmission -> onlinetext ) ) ; } return $ wordcount == 0 ; } | No text is set for this plugin |
29,334 | public function check_word_count ( $ submissiontext ) { global $ OUTPUT ; $ wordlimitenabled = $ this -> get_config ( 'wordlimitenabled' ) ; $ wordlimit = $ this -> get_config ( 'wordlimit' ) ; if ( $ wordlimitenabled == 0 ) { return null ; } $ wordcount = count_words ( $ submissiontext ) ; if ( $ wordcount <= $ wordli... | Compare word count of onlinetext submission to word limit and return result . |
29,335 | public function get_fieldset_sql ( $ sql , array $ params = null ) { $ rs = $ this -> get_recordset_sql ( $ sql , $ params ) ; if ( ! $ rs -> valid ( ) ) { $ rs -> close ( ) ; return false ; } $ result = array ( ) ; foreach ( $ rs as $ value ) { $ result [ ] = reset ( $ value ) ; } $ rs -> close ( ) ; return $ result ;... | Selects rows and return values of first column as array . |
29,336 | public function get_records_sql ( $ sql , array $ params = null , $ limitfrom = 0 , $ limitnum = 0 ) { global $ CFG ; $ rs = $ this -> get_recordset_sql ( $ sql , $ params , $ limitfrom , $ limitnum ) ; if ( ! $ rs -> valid ( ) ) { $ rs -> close ( ) ; return false ; } $ objects = array ( ) ; foreach ( $ rs as $ value )... | Get a number of records as an array of objects . |
29,337 | public function set_field_select ( $ table , $ newfield , $ newvalue , $ select , array $ params = null ) { if ( $ select ) { $ select = "WHERE $select" ; } if ( is_null ( $ params ) ) { $ params = array ( ) ; } list ( $ select , $ params , $ type ) = $ this -> fix_sql_params ( $ select , $ params ) ; if ( is_bool ( $ ... | Set a single field in every table row where the select statement evaluates to true . |
29,338 | public function import_record ( $ table , $ dataobject ) { $ dataobject = ( object ) $ dataobject ; $ columns = $ this -> get_columns ( $ table ) ; $ cleaned = array ( ) ; foreach ( $ dataobject as $ field => $ value ) { if ( ! isset ( $ columns [ $ field ] ) ) { continue ; } $ cleaned [ $ field ] = $ value ; } return ... | Import a record into a table id field is required . Basic safety checks only . Lobs are supported . |
29,339 | public function register_namespaces_for_xpath ( ) { $ scnam = $ this -> activemanifest -> get_cc_namespaces ( ) ; foreach ( $ scnam as $ key => $ value ) { $ this -> registerNS ( $ key , $ value ) ; } } | Register Namespace for use XPATH |
29,340 | public function add_metadata_manifest ( cc_i_metadata_manifest $ met ) { $ metanode = $ this -> node ( "//imscc:manifest[@identifier='" . $ this -> activemanifest -> manifestID ( ) . "']/imscc:metadata" ) ; $ nmeta = $ this -> activemanifest -> create_metadata_node ( $ met , $ this -> doc , $ metanode ) ; $ metanode ->... | Add Metadata For Manifest |
29,341 | public function add_metadata_resource ( cc_i_metadata_resource $ met , $ identifier ) { $ metanode = $ this -> node ( "//imscc:resource" . "[@identifier='" . $ identifier . "']" ) ; $ metanode2 = $ this -> node ( "//imscc:resource" . "[@identifier='" . $ identifier . "']/imscc:file" ) ; $ nspaces = $ this -> activemani... | Add Metadata For Resource |
29,342 | public function add_metadata_file ( cc_i_metadata_file $ met , $ identifier , $ filename ) { if ( empty ( $ met ) || empty ( $ identifier ) || empty ( $ filename ) ) { throw new Exception ( 'Try to add a metadata file with nulls values given!' ) ; } $ metanode = $ this -> node ( "//imscc:resource" . "[@identifier='" . ... | Add Metadata For File |
29,343 | public function add_new_organization ( cc_i_organization & $ org ) { $ norg = $ this -> activemanifest -> create_organization_node ( $ org , $ this -> doc ) ; $ orgnode = $ this -> node ( "//imscc:manifest[@identifier='" . $ this -> activemanifest -> manifestID ( ) . "']/imscc:organizations" ) ; $ orgnode -> appendChil... | Add a new organization |
29,344 | public function add_resource ( cc_i_resource $ res , $ identifier = null , $ type = 'webcontent' ) { if ( ! $ this -> ccobj -> valid ( $ type ) ) { throw new Exception ( "Type invalid..." ) ; } if ( $ res == null ) { throw new Exception ( 'Invalid Resource or dont give it' ) ; } $ rst = $ res ; if ( is_object ( $ ident... | Add a resource to the manifest |
29,345 | public function put_nodes ( ) { $ resnodestr = "//imscc:manifest[@identifier='" . $ this -> activemanifest -> manifestID ( ) . "']/imscc:resources" ; $ resnode = $ this -> node ( $ resnodestr ) ; foreach ( $ this -> activemanifest -> resources as $ k => $ v ) { ( $ k ) ; $ depen = $ this -> check_if_exist_in_other ( $ ... | Append the resources nodes in the Manifest |
29,346 | protected function applyWrapTextIfCellContainsNewLine ( $ style , $ dataRow ) { if ( $ style -> hasSetWrapText ( ) ) { return $ style ; } foreach ( $ dataRow as $ cell ) { if ( is_string ( $ cell ) && strpos ( $ cell , "\n" ) !== false ) { $ style -> setShouldWrapText ( ) ; break ; } } return $ style ; } | Set the wrap text option if a cell of the given row contains a new line . |
29,347 | public function listDatabases ( array $ options = [ ] ) { $ operation = new ListDatabases ( $ options ) ; $ server = $ this -> manager -> selectServer ( new ReadPreference ( ReadPreference :: RP_PRIMARY ) ) ; return $ operation -> execute ( $ server ) ; } | List databases . |
29,348 | public function selectCollection ( $ databaseName , $ collectionName , array $ options = [ ] ) { $ options += [ 'typeMap' => $ this -> typeMap ] ; return new Collection ( $ this -> manager , $ databaseName , $ collectionName , $ options ) ; } | Select a collection . |
29,349 | public final function definition ( ) { global $ CFG ; $ mform = $ this -> _form ; $ editoroptions = $ this -> _customdata [ 'editoroptions' ] ; if ( $ this -> qtypestring != 'selectaqtype' ) { if ( $ this -> _customdata [ 'edit' ] ) { $ mform -> addElement ( 'header' , 'qtypeheading' , get_string ( 'edit' . $ this -> q... | Add the required basic elements to the form . |
29,350 | public static function load ( $ lessonid ) { global $ DB ; if ( ! $ lesson = $ DB -> get_record ( 'lesson' , array ( 'id' => $ lessonid ) ) ) { print_error ( 'invalidcoursemodule' ) ; } return new lesson ( $ lesson ) ; } | Generates a lesson object from the database given its id |
29,351 | public function delete ( ) { global $ CFG , $ DB ; require_once ( $ CFG -> libdir . '/gradelib.php' ) ; require_once ( $ CFG -> dirroot . '/calendar/lib.php' ) ; $ cm = get_coursemodule_from_instance ( 'lesson' , $ this -> properties -> id , $ this -> properties -> course ) ; $ context = context_module :: instance ( $ ... | Deletes this lesson from the database |
29,352 | public function delete_override ( $ overrideid ) { global $ CFG , $ DB ; require_once ( $ CFG -> dirroot . '/calendar/lib.php' ) ; $ cm = get_coursemodule_from_instance ( 'lesson' , $ this -> properties -> id , $ this -> properties -> course ) ; $ override = $ DB -> get_record ( 'lesson_overrides' , array ( 'id' => $ o... | Deletes a lesson override from the database and clears any corresponding calendar events |
29,353 | public function delete_all_overrides ( ) { global $ DB ; $ overrides = $ DB -> get_records ( 'lesson_overrides' , array ( 'lessonid' => $ this -> properties -> id ) , 'id' ) ; foreach ( $ overrides as $ override ) { $ this -> delete_override ( $ override -> id ) ; } } | Deletes all lesson overrides from the database and clears any corresponding calendar events |
29,354 | protected function get_messages ( ) { global $ SESSION ; $ messages = array ( ) ; if ( ! empty ( $ SESSION -> lesson_messages ) && is_array ( $ SESSION -> lesson_messages ) && array_key_exists ( $ this -> properties -> id , $ SESSION -> lesson_messages ) ) { $ messages = $ SESSION -> lesson_messages [ $ this -> propert... | Fetches messages from the session that may have been set in previous page actions . |
29,355 | public function get_attempts ( $ retries , $ correct = false , $ pageid = null , $ userid = null ) { global $ USER , $ DB ; $ params = array ( "lessonid" => $ this -> properties -> id , "userid" => $ userid , "retry" => $ retries ) ; if ( $ correct ) { $ params [ 'correct' ] = 1 ; } if ( $ pageid !== null ) { $ params ... | Get all of the attempts for the current user . |
29,356 | protected function get_firstpage ( ) { $ pages = $ this -> load_all_pages ( ) ; if ( count ( $ pages ) > 0 ) { foreach ( $ pages as $ page ) { if ( ( int ) $ page -> prevpageid === 0 ) { return $ page ; } } } return false ; } | Returns the first page for the lesson or false if there isn t one . |
29,357 | protected function get_lastpage ( ) { $ pages = $ this -> load_all_pages ( ) ; if ( count ( $ pages ) > 0 ) { foreach ( $ pages as $ page ) { if ( ( int ) $ page -> nextpageid === 0 ) { return $ page ; } } } return false ; } | Returns the last page for the lesson or false if there isn t one . |
29,358 | public function get_next_page ( $ nextpageid ) { global $ USER , $ DB ; $ allpages = $ this -> load_all_pages ( ) ; if ( $ this -> properties -> nextpagedefault ) { $ nretakes = $ DB -> count_records ( "lesson_grades" , array ( "lessonid" => $ this -> properties -> id , "userid" => $ USER -> id ) ) ; shuffle ( $ allpag... | Gets the next page id to display after the one that is provided . |
29,359 | public function add_message ( $ message , $ class = "notifyproblem" , $ align = 'center' ) { global $ SESSION ; if ( empty ( $ SESSION -> lesson_messages ) || ! is_array ( $ SESSION -> lesson_messages ) ) { $ SESSION -> lesson_messages = array ( ) ; $ SESSION -> lesson_messages [ $ this -> properties -> id ] = array ( ... | Sets a message against the session for this lesson that will displayed next time the lesson processes messages |
29,360 | public function is_accessible ( ) { $ available = $ this -> properties -> available ; $ deadline = $ this -> properties -> deadline ; return ( ( $ available == 0 || time ( ) >= $ available ) && ( $ deadline == 0 || time ( ) < $ deadline ) ) ; } | Check if the lesson is accessible at the present time |
29,361 | public function start_timer ( ) { global $ USER , $ DB ; $ cm = get_coursemodule_from_instance ( 'lesson' , $ this -> properties ( ) -> id , $ this -> properties ( ) -> course , false , MUST_EXIST ) ; $ event = \ mod_lesson \ event \ lesson_started :: create ( array ( 'objectid' => $ this -> properties ( ) -> id , 'con... | Starts the lesson time for the current user |
29,362 | public function update_timer ( $ restart = false , $ continue = false , $ endreached = false ) { global $ USER , $ DB ; $ cm = get_coursemodule_from_instance ( 'lesson' , $ this -> properties -> id , $ this -> properties -> course ) ; if ( ! $ timer = $ this -> get_user_timers ( $ USER -> id , 'starttime DESC' , '*' , ... | Updates the timer to the current time and returns the new timer object |
29,363 | public function stop_timer ( ) { global $ USER , $ DB ; unset ( $ USER -> startlesson [ $ this -> properties -> id ] ) ; $ cm = get_coursemodule_from_instance ( 'lesson' , $ this -> properties ( ) -> id , $ this -> properties ( ) -> course , false , MUST_EXIST ) ; $ event = \ mod_lesson \ event \ lesson_ended :: create... | Updates the timer to the current time then stops it by unsetting the user var |
29,364 | public function link_for_activitylink ( ) { global $ DB ; $ module = $ DB -> get_record ( 'course_modules' , array ( 'id' => $ this -> properties -> activitylink ) ) ; if ( $ module ) { $ modname = $ DB -> get_field ( 'modules' , 'name' , array ( 'id' => $ module -> module ) ) ; if ( $ modname ) { $ instancename = $ DB... | Returns the link for the related activity |
29,365 | public function load_page ( $ pageid ) { if ( ! array_key_exists ( $ pageid , $ this -> pages ) ) { $ manager = lesson_page_type_manager :: get ( $ this ) ; $ this -> pages [ $ pageid ] = $ manager -> load_page ( $ pageid , $ this ) ; } return $ this -> pages [ $ pageid ] ; } | Loads the requested page . |
29,366 | public function load_all_pages ( ) { if ( ! $ this -> loadedallpages ) { $ manager = lesson_page_type_manager :: get ( $ this ) ; $ this -> pages = $ manager -> load_all_pages ( $ this ) ; $ this -> loadedallpages = true ; } return $ this -> pages ; } | Loads ALL of the pages for this lesson |
29,367 | public function duplicate_page ( $ pageid ) { global $ PAGE ; $ cm = get_coursemodule_from_instance ( 'lesson' , $ this -> properties -> id , $ this -> properties -> course ) ; $ context = context_module :: instance ( $ cm -> id ) ; $ page = $ this -> load_page ( $ pageid ) ; $ properties = $ page -> properties ( ) ; i... | Duplicate the lesson page . |
29,368 | protected function copy_page_files ( $ filearea , $ itemid , $ newitemid , $ contextid ) { $ fs = get_file_storage ( ) ; $ files = $ fs -> get_area_files ( $ contextid , 'mod_lesson' , $ filearea , $ itemid ) ; foreach ( $ files as $ file ) { $ fieldupdates = array ( 'itemid' => $ newitemid ) ; $ fs -> create_file_from... | Copy the files from one page to another . |
29,369 | public function jumpto_is_correct ( $ pageid , $ jumpto ) { global $ DB ; if ( ! $ jumpto ) { return false ; } elseif ( $ jumpto == LESSON_NEXTPAGE ) { return true ; } elseif ( $ jumpto == LESSON_UNSEENBRANCHPAGE ) { return true ; } elseif ( $ jumpto == LESSON_RANDOMPAGE ) { return true ; } elseif ( $ jumpto == LESSON_... | Determines if a jumpto value is correct or not . |
29,370 | public function time_remaining ( $ starttime ) { $ timeleft = $ starttime + $ this -> properties -> timelimit - time ( ) ; $ hours = floor ( $ timeleft / 3600 ) ; $ timeleft = $ timeleft - ( $ hours * 3600 ) ; $ minutes = floor ( $ timeleft / 60 ) ; $ secs = $ timeleft - ( $ minutes * 60 ) ; if ( $ minutes < 10 ) { $ m... | Returns the time a user has remaining on this lesson |
29,371 | public function resort_pages ( $ pageid , $ after ) { global $ CFG ; $ cm = get_coursemodule_from_instance ( 'lesson' , $ this -> properties -> id , $ this -> properties -> course ) ; $ context = context_module :: instance ( $ cm -> id ) ; $ pages = $ this -> load_all_pages ( ) ; if ( ! array_key_exists ( $ pageid , $ ... | Move a page resorting all other pages . |
29,372 | public function get_context ( ) { if ( $ this -> context == null ) { $ this -> context = context_module :: instance ( $ this -> get_cm ( ) -> id ) ; } return $ this -> context ; } | Return the lesson context object . |
29,373 | public function get_cm ( ) { if ( $ this -> cm == null ) { $ this -> cm = get_coursemodule_from_instance ( 'lesson' , $ this -> properties -> id ) ; } return $ this -> cm ; } | Return the lesson course module object . |
29,374 | public function get_courserecord ( ) { global $ DB ; if ( $ this -> courserecord == null ) { $ this -> courserecord = $ DB -> get_record ( 'course' , array ( 'id' => $ this -> properties -> course ) ) ; } return $ this -> courserecord ; } | Return the lesson course object . |
29,375 | public function get_time_restriction_status ( ) { if ( $ this -> can_manage ( ) ) { return false ; } if ( ! $ this -> is_accessible ( ) ) { if ( $ this -> properties -> deadline != 0 && time ( ) > $ this -> properties -> deadline ) { $ status = [ 'reason' => 'lessonclosed' , 'time' => $ this -> properties -> deadline ]... | Check if time restriction is applied . |
29,376 | public function get_password_restriction_status ( $ userpassword ) { global $ USER ; if ( $ this -> can_manage ( ) ) { return false ; } if ( $ this -> properties -> usepassword && empty ( $ USER -> lessonloggedin [ $ this -> id ] ) ) { $ correctpass = false ; if ( ! empty ( $ userpassword ) && ( ( $ this -> properties ... | Check if password restriction is applied . |
29,377 | public function get_dependencies_restriction_status ( ) { global $ DB , $ USER ; if ( $ this -> can_manage ( ) ) { return false ; } if ( $ dependentlesson = $ DB -> get_record ( 'lesson' , array ( 'id' => $ this -> properties -> dependency ) ) ) { $ conditions = unserialize ( $ this -> properties -> conditions ) ; $ er... | Check if dependencies restrictions are applied . |
29,378 | public function get_last_page_seen ( $ retriescount ) { global $ DB , $ USER ; $ lastpageseen = false ; $ allattempts = $ this -> get_attempts ( $ retriescount ) ; if ( ! empty ( $ allattempts ) ) { $ attempt = end ( $ allattempts ) ; $ attemptpage = $ this -> load_page ( $ attempt -> pageid ) ; $ jumpto = $ DB -> get_... | Return the last page the current user saw . |
29,379 | public function left_during_timed_session ( $ retriescount ) { global $ DB , $ USER ; $ conditions = array ( 'lessonid' => $ this -> properties -> id , 'userid' => $ USER -> id , 'retry' => $ retriescount ) ; return $ DB -> count_records ( 'lesson_attempts' , $ conditions ) > 0 || $ DB -> count_records ( 'lesson_branch... | Check if a user left a timed session . |
29,380 | public function check_time ( $ timer ) { if ( $ this -> properties -> timelimit ) { $ timeleft = $ timer -> starttime + $ this -> properties -> timelimit - time ( ) ; if ( $ timeleft <= 0 ) { $ this -> add_message ( get_string ( 'eolstudentoutoftime' , 'lesson' ) ) ; return false ; } else if ( $ timeleft < 60 ) { $ thi... | Check if the user is out of time in a timed lesson . |
29,381 | public function calculate_progress ( ) { global $ USER , $ DB ; if ( isset ( $ USER -> modattempts [ $ this -> properties -> id ] ) ) { return 100 ; } $ pages = $ this -> load_all_pages ( ) ; foreach ( $ pages as $ page ) { if ( $ page -> prevpageid == 0 ) { $ pageid = $ page -> id ; break ; } } if ( ! $ ntries = $ DB ... | Calculate the progress of the current user in the lesson . |
29,382 | public function process_page_responses ( lesson_page $ page ) { $ context = $ this -> get_context ( ) ; if ( count ( $ page -> answers ) > 0 ) { $ result = $ page -> record_attempt ( $ context ) ; } else { $ result = new stdClass ; $ result -> newpageid = optional_param ( 'newpageid' , $ page -> nextpageid , PARAM_INT ... | Process page responses . |
29,383 | final public static function load ( $ id , lesson $ lesson ) { global $ DB ; if ( is_object ( $ id ) && ! empty ( $ id -> qtype ) ) { $ page = $ id ; } else { $ page = $ DB -> get_record ( "lesson_pages" , array ( "id" => $ id ) ) ; if ( ! $ page ) { print_error ( 'cannotfindpages' , 'lesson' ) ; } } $ manager = lesson... | This method loads a page object from the database and returns it as a specialised object that extends lesson_page |
29,384 | final public function move ( $ nextpageid = null , $ prevpageid = null ) { global $ DB ; if ( $ nextpageid === null ) { $ nextpageid = $ this -> properties -> nextpageid ; } if ( $ prevpageid === null ) { $ prevpageid = $ this -> properties -> prevpageid ; } $ obj = new stdClass ; $ obj -> id = $ this -> properties -> ... | Moves a page by updating its nextpageid and prevpageid values within the database |
29,385 | final public function get_answers ( ) { global $ DB ; if ( $ this -> answers === null ) { $ this -> answers = array ( ) ; $ answers = $ DB -> get_records ( 'lesson_answers' , array ( 'pageid' => $ this -> properties -> id , 'lessonid' => $ this -> lesson -> id ) , 'id' ) ; if ( ! $ answers ) { return array ( ) ; } fore... | Returns the answers that are associated with this page in the database |
29,386 | public function format_answer ( $ answer , $ context , $ answerformat , $ options = [ ] ) { if ( is_object ( $ options ) ) { $ options = ( array ) $ options ; } if ( empty ( $ options [ 'context' ] ) ) { $ options [ 'context' ] = $ context ; } if ( empty ( $ options [ 'para' ] ) ) { $ options [ 'para' ] = true ; } retu... | Formats the answer . Override for custom formatting . |
29,387 | private function format_response ( $ response , $ context , $ responseformat , $ answerid , $ options ) { $ convertstudentresponse = file_rewrite_pluginfile_urls ( $ response , 'pluginfile.php' , $ context -> id , 'mod_lesson' , 'page_responses' , $ answerid ) ; return format_text ( $ convertstudentresponse , $ respons... | Formats the response |
29,388 | final protected function get_jump_name ( $ jumpto ) { global $ DB ; static $ jumpnames = array ( ) ; if ( ! array_key_exists ( $ jumpto , $ jumpnames ) ) { if ( $ jumpto == LESSON_THISPAGE ) { $ jumptitle = get_string ( 'thispage' , 'lesson' ) ; } elseif ( $ jumpto == LESSON_NEXTPAGE ) { $ jumptitle = get_string ( 'nex... | Returns the string for a jump name |
29,389 | public function save_answers_files ( $ context , $ maxbytes , & $ answer , $ answereditor = '' , $ responseeditor = '' ) { global $ DB ; if ( isset ( $ answereditor [ 'itemid' ] ) ) { $ answer -> answer = file_save_draft_area_files ( $ answereditor [ 'itemid' ] , $ context -> id , 'mod_lesson' , 'page_answers' , $ answ... | save editor answers files and update answer record |
29,390 | public static function rewrite_answers_urls ( $ answer , $ rewriteanswer = true ) { global $ PAGE ; $ context = context_module :: instance ( $ PAGE -> cm -> id ) ; if ( $ rewriteanswer ) { $ answer -> answer = file_rewrite_pluginfile_urls ( $ answer -> answer , 'pluginfile.php' , $ context -> id , 'mod_lesson' , 'page_... | Rewrite urls in response and optionality answer of a question answer |
29,391 | public function is_unseen ( $ param ) { global $ USER , $ DB ; if ( is_array ( $ param ) ) { $ seenpages = $ param ; return ( ! array_key_exists ( $ this -> properties -> id , $ seenpages ) ) ; } else { $ nretakes = $ param ; if ( ! $ DB -> count_records ( "lesson_attempts" , array ( "pageid" => $ this -> properties ->... | Returns true if a page has been viewed before |
29,392 | public function is_unanswered ( $ nretakes ) { global $ DB , $ USER ; if ( ! $ DB -> count_records ( "lesson_attempts" , array ( 'pageid' => $ this -> properties -> id , 'userid' => $ USER -> id , 'correct' => 1 , 'retry' => $ nretakes ) ) ) { return true ; } return false ; } | Checks to see if a page has been answered previously |
29,393 | public function check_answer ( ) { $ result = new stdClass ; $ result -> answerid = 0 ; $ result -> noanswer = false ; $ result -> correctanswer = false ; $ result -> isessayquestion = false ; $ result -> response = '' ; $ result -> newpageid = 0 ; $ result -> studentanswer = '' ; $ result -> studentanswerformat = FORM... | This method MUST be overridden by all question page types or page types that wish to score a page . |
29,394 | public function properties ( ) { $ properties = clone ( $ this -> properties ) ; if ( $ this -> answers === null ) { $ this -> get_answers ( ) ; } if ( count ( $ this -> answers ) > 0 ) { $ count = 0 ; $ qtype = $ properties -> qtype ; foreach ( $ this -> answers as $ answer ) { $ properties -> { 'answer_editor[' . $ c... | Returns the properties of this lesson page as an object |
29,395 | public function get_contents ( ) { global $ PAGE ; if ( ! empty ( $ this -> properties -> contents ) ) { if ( ! isset ( $ this -> properties -> contentsformat ) ) { $ this -> properties -> contentsformat = FORMAT_HTML ; } $ context = context_module :: instance ( $ PAGE -> cm -> id ) ; $ contents = file_rewrite_pluginfi... | Returns the contents field for the page properly formatted and with plugin file url s converted |
29,396 | public function display_answers ( html_table $ table ) { $ answers = $ this -> get_answers ( ) ; $ i = 1 ; foreach ( $ answers as $ answer ) { $ cells = array ( ) ; $ cells [ ] = '<label>' . get_string ( 'jump' , 'lesson' ) . ' ' . $ i . '</label>:' ; $ cells [ ] = $ this -> get_jump_name ( $ answer -> jumpto ) ; $ tab... | Updates a table with the answers for this page |
29,397 | public function report_answers ( $ answerpage , $ answerdata , $ useranswer , $ pagestats , & $ i , & $ n ) { $ answers = $ this -> get_answers ( ) ; $ formattextdefoptions = new stdClass ; $ formattextdefoptions -> para = false ; foreach ( $ answers as $ answer ) { $ data = get_string ( 'jumpsto' , 'lesson' , $ this -... | Formats the answers of this page for a report |
29,398 | public function valid_page_and_view ( & $ validpages , & $ pageviews ) { $ validpages [ $ this -> properties -> id ] = 1 ; return $ this -> properties -> nextpageid ; } | This method is used to determine if this page is a valid page |
29,399 | public function get_files ( $ includedirs = true , $ updatedsince = 0 ) { $ fs = get_file_storage ( ) ; return $ fs -> get_area_files ( $ this -> lesson -> context -> id , 'mod_lesson' , 'page_contents' , $ this -> properties -> id , 'itemid, filepath, filename' , $ includedirs , $ updatedsince ) ; } | Get files from the page area file . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.