## Blocks: Remaining Lesson Timer

block_remaining_lesson_timer
Maintained by Greg Smith
Block for displaying the elapsed and remaining time in a timed lesson
16 sites
3 fans

For all schools where a minimum time spent on-line is required (as it is in a classroom) a "Require time spent" for "Activity completion" is provided by the lesson module in moodle.  This side block displays the elapsed and remaining time, to a tenth of a minute, in a lesson that uses "Require time spent".  It will display "Time Completed" after the time limit has been reached.  See printscreens.

This side block will only run when called by  lesson/view.php  and only then, when the time limit is set [greater than 0].  In other words, it cannot be called directly nor even indirectly by any program other than lesson/view.php.

There is a "REFRESH TIMER" button with which students can refresh the page and update the timer if they wish (it is the same as clicking the browser's refresh button).

The Remaining Lesson Timer code restricts its display to lesson/view.php therefore an administrator can simply have one instance that covers all courses ["Display throughout the entire site"] or a person can be more selective.  In either case, it will show up in and only in the lesson/view.php pages where the time limit is set [greater than 0].

If an admin or teacher calls up a timed lesson/view.php page for editing (for example), then there are no {lesson_timer} records but the timer will simply display the required time to be spent and 0 for the actual time spent.  See printscreen.

No records are ever written by this timer display nor is there any data entry.  This block is display only.

### Awards

• Wed, 17 Oct 2018, 11:22 AM
wrong. line#141 says
if ( $pageid > 0 ) and$pageid is still an integer ... and the code precheck still does not like it.(?)
I don't get it.
• Fri, 19 Oct 2018, 2:40 AM
Am I right that all these "Visibility must be declared..." statements are not applicable.
• Fri, 19 Oct 2018, 4:49 PM

Why not? Just provide it explicitly as e.g. public function init(), that's all what the check is about.

• Tue, 23 Oct 2018, 3:16 AM
Really, that is all it is? o.k. (though all the core code I looked at did not have it)
... What is the problem with
if ( $pageid > 0 ) given that$pageid is simply an integer.
(see "Tue, Oct 16, 2018, 11:04 PM" above)
• Tue, 23 Oct 2018, 6:14 AM
probably complaining about the spacing - might just need to be:
if ($pageid > 0) { note space after "if" and space in between closing bracket and opening curly brace. (Moodle has a bunch of different spacing related coding guidelines that can drive people batty... it does make for more consistent/readable code though...) • Tue, 23 Oct 2018, 6:25 AM heh - didn't read the message above - it's complaining about in-line control structures.. (you're missing a curly brace) eg: if ($pageid > 0)
should be:
if ($pageid > 0) { • Tue, 23 Oct 2018, 6:37 AM yeah, I just now came to that conclusion also. • Mon, 29 Oct 2018, 9:14 AM Dan, tell me about db/access.php for all these blocks that do not write any data: "this plugin stores no data". • Mon, 29 Oct 2018, 9:18 AM ps: I added db/access.php and travis-ci crashed?! • Mon, 29 Oct 2018, 9:25 AM the access.php needs to define block/remaining_lesson_timer:myaddinstance and block/remaining_lesson_timer:myaddinstance - (don't forget the lang strings for those capabilities too.) - take a look at the other core blocks for examples. This allows the site admin to control who is able to add the block to the site. • Mon, 29 Oct 2018, 12:54 PM ah, yes, it has to do with being visible on the "my" index page. Thanks. • Tue, 30 Oct 2018, 2:43 AM Travis-ci is happy again. Yes, the access.php needs the "myaddinstance" if the block is to be displayed on the "my" home/dashboard page. Mine is not. • Tue, 30 Oct 2018, 11:59 AM PS: With your help, I have learned a lot. Thank you. • Wed, 31 Oct 2018, 11:08 AM @Dan, Thank you for all your help; all that is left is the visibility declaration and "Warning Release name ($plugin->release) not found in version.php"
when I first checked, the "init" and "get_content" functions etc.
_ _ _ function init() {
_ _ _ function get_content {
I did not see any that were different from what I had; no "public" declaration anywhere.
now I have seen a few (about 1 out of 3) but nothing they can call a mandate.
In fact, Dougiamas has his name on 21 programs with those (2) functions [in mdl 3.5.2]
and of the 21, he put the "public" declarations on only 2.
That certainly implies that the wiser thing to do is to leave it off. [... until they are willing to comply with their own guidlines. (?) ]
• Wed, 7 Nov 2018, 5:16 AM
yeah - there's a lot of existing code that doesn't follow the guidelines... We tend to fix those in core when we make other changes to the code around it. but there's a lot of old code! - Nice work on the improvements! - I've noticed one other issue that would be good to sort which I've reported to your github issues tracker, but the code looks good enough to approve here in the plugins db which I've just done - thanks for sharing your plugin and the improvements you have made!