Countdown Block

Countdown Block

by Mat Cannings -
Number of replies: 40
I found a great Flash script at http://www.brandspankingnew.net/archive/2005/06/flashactionscri.html and have turned it into a block.

The block has optional text above and below, can countdown to the users system clock or the server time, can countdown to a specific second and has colour options.

The block is fully functional but has no date validation (i.e. 30th of Feb is allowed) and will show zeroes once the date has been reached.
An example can be found at my temporary test site (server is usually slow! sad)
Average of ratings:Useful (1)
In reply to Mat Cannings

Re: Countdown Block

by Genner Cerna -
can the found style and size be change?
In reply to Genner Cerna

Re: Countdown Block

by Mat Cannings -

The width and height of the Flash Component is currently hardcoded in block_countdown.php so could be edited within the file. The current dimensions are those that the SWF was created at, although it will stretch to fill the space allocated in the <embed> tags.

I will add this to the next version of the block, although I think this would be best as a swf size set by the admin rather than a per block setting.

The next version will hopefully have a mechanism to show a new message once the countdown reaches 0. Also if I can work out the required flash code I will try to make the words for day, min, hr and sec into parameters that can be passed into the swf file from the moodle lang folder and also a colour option for this text.

I don't think it is possible to customize the font without generating a new swf file but I will also look at maybe having a choice of countdown styles.

I have added this to the Module and Plugins Database - http://moodle.org/mod/data/view.php?d=13&rid=718

In reply to Mat Cannings

Re: Countdown Block

by Mat Cannings -
I have now added a block setting for the admin to specify the width and height for the swf file within the block for the whole site, and also added an option for repeating annual events (where instead of stopping at 0 the count resets to 365 days).

This is now all the features covered that the original swf file supported, I will look at modifying the swf over the weekend to try and add new features such as text parameters and maybe creating a few different styles.

The updated version is available from the Module and Plugins Database - http://moodle.org/mod/data/view.php?d=13&rid=718.

In reply to Mat Cannings

Re: Countdown Block

by David Cooper -

Hi Matthew. I posted this in Installation:

I've been trying to add a countdown block from here:

http://moodle.b-r-u-m.co.uk/course/view.php?id=6

I've unzipped the file into a directory called countdown inside the blocks directory. If I have unstood this correctly, I then go to my site, log in as admin, go to Modules, Blocks and my new block should magically appear in the list? Or do I need to do something to install it. At the moment, I can't see the new block amongst the others and nuffin's happening!

Any help, please?

Thanks

In reply to Mat Cannings

Re: Countdown Block

by Frank Liauw -
Hi Mat, great block you have here. I was in the midst of doing something similar when I chanced upon yours on moodle's module and plugins database (too bad i didnt take a good hard look through all the available blocks prior to starting, almost reinvented the wheel).

I've added in an additional feature into your current block with just a couple of lines. You can now hide the title of the block without leaving it blank (the expand/contract button still appeared on mine even though the block was supposed to hide itself when there is no text in the title before the hack).

In block_countdown.php, on line 26, add:
function hide_header() {
if ($this->config->showheader == 0) {
return true;
}
}

In config_instance.html, on line 9, add:
<tr>
<td align="right"><?php print_string('configshowheader', 'block_countdown'); ?>: </td>
<td colspan="3">
<input type="hidden" name="showheader" value="0" />
<input type="checkbox" name="showheader" value="1" <?php if(!empty($this->config->showheader)) echo 'checked="checked "'; ?>/>
</td>
</tr>

and remove on line 7:
(<?php print_string('leaveblanktohide', 'block_html'); ?>)

In block_countdown.php, on line 4, add:
$string['configshowheader'] = 'Show header';


That should do the trick. You'll be presented with a checkbox immediately after your Title in the instance configuration page to choose if you want the header to appear.

I'll probably do something about the display of zeros when the countdown date have been reached.
In reply to Frank Liauw

Re: Countdown Block

by Frank Liauw -
I've done another hack and bug fix (there were quite a bit of changes, thus i've uploaded the complete block with this post to facilitate users in their updating).
The block will automatically hide itself when the countdown date and time have been reached. This is achieved by calculating the difference in days, hours, minutes and seconds (set to 00) using the date difference class on phpclasses and checking if any of them are negative. A negative value will denote that the date have been reached.

If the result is negative, the block will set the configuration to hide the title and set the content as a blank string. This will effectively 'hide' the block from user view and will only be visible under the Editing mode.

A bug have also been fixed in the instance configuration template. Prior to the fix, all dropdowns for selection of date, month, year, hour and minute were "selected" in the HTML code. This causes the user to not have their previous saved configuration selected by default when they launch the instance configuration to amend, lets say the title only.

Mat also raised another problem of not being able to perform validation of the selected dates. I'm rather new to Moodle programming and I'll like to ask if there is a function to insert custom javascript and css spreadsheets in the configuration page from the block. This is because a simple javascript calendar and clock time selector can be used instead of drop-down selection to prevent input of illegal dates, but addition of additional scripts to the head of the HTML will be required.
In reply to Frank Liauw

Re: Countdown Block

by Dan Jeffries -
Hi

Does this countdown block work in 1.9?

Thanks
In reply to Dan Jeffries

Re: Countdown Block

by Mat Cannings -
I have finally got around to updating the Countdown block and it should work for versions of Moodle from 1.6 upto 2.0dev. I started to upgrade a long while back and have managed to merge most of Frank Liauw's modifications into this update

Main Changes
  • Flash files completely rewritten by Charlotte Owen and source fla files made available
  • Using the flash sources, modified versions of the countdown can be created. Config will allow choice of all flash files in the clocks folder
  • Text for hrs, mins, days and secs passed to flash from lang files
  • Block can be hidden after countdown complete (thanks to Frank Liauw)
+ many more minor tweaks and fixes

Available via the Moodle Modules and Plugins Database @ http://moodle.org/mod/data/view.php?d=13&rid=718

Some examples of usage at http://www.matc-online.co.uk/
In reply to Dan Jeffries

Re: Countdown Block

by William Lu -
I tested it today on my moodle1.9 (PHP4.4.7, MySQL4.0).

After I clicked on the ‘countdown’ from the add block dropdown menu, the ‘Blocks’ block disappeared. Whatever I ‘Turn editing off” or on, the ‘Blocks’ didn’t show any more. To recover my blocks, I’ve to delete this ‘countdown block’ from manage blocks > delete countdown files > re-layout my course blocks.


Help please.

In reply to William Lu

Re: Countdown Block

by Mat Cannings -
Hi William, I have just spotted your post, thanks for the information you have provided. The error you describe sounds like a PHP error has occured within the block (the new block should appear just above the 'Blocks' block, the error is causing everything after to not display). I have had a quick check and have been unable to recreate the problem, I am assuming the error is caused by some code that I have that requires PHP5. I will try and find the problem and rectify it in the next version if possible.
In reply to Mat Cannings

Re: Countdown Block

by William Lu -
Dear Mat,
Yes, It works beautifully on my Moodle1.9 with PHP4 and MySql4.
Thank you sooooooooooo much for fix it for me so quickly!!!!!!!!!!!
Have a nice day!
In reply to William Lu

Re: Countdown Block

by Mat Cannings -
I have added the changes made to make this compatible with PHP4.
There are also a couple of other minor changes made to make the produced html code W3C valid and to fix the Flash so that CSS floated areas appear correctly when above a countdown. (I had a problem with a CSS dropdown menu)

Latest version is now 2.1 and is available from the Module and Plugins Database - http://moodle.org/mod/data/view.php?d=13&rid=718
In reply to Mat Cannings

Re: Countdown Block

by Shaun Daubney -
Just to say, although I haven't personally used it yet, my colleague Rachel, who maintains the learner resource area of our Moodle, loves this block. I don't think she has it set for anything in particular, it's just set to something so she can sit there quite happily watching it tick over. Maybe it's set to the end of term.. 41 days, gosh, not long now...... SUMMER HOLIDAYS!

Heck, it looks so good even I'm using it on the frontpage. Thanks for this cool block.
In reply to Shaun Daubney

Re: Countdown Block

by Peter de Groot -
Outstanding block.. very nice....

Just one query ... is is possible to have it just show the days .. and not the hours. We have ours set to show the countdown to the exams ... and the days alone scare them smile


In reply to Peter de Groot

Re: Countdown Block

by Mat Cannings -
This block is really in two parts
  1. PHP script that generates values and parameters for the count
  2. Flash file that receives parameters and displays the countdown
The settings in the Moodle allow you to change the countdown date and the colours that are passed to the Flash component as well as the text above and/or below the count. Any other changes need to be made by editing the Flash files themselves.

Charlotte Owen has released the Flash source files (.fla) which are contained in the download. By loading these into Flash and editing the graphics you can change the fonts, the layout, anything really.

Once you have edited the Flash you export it as a .swf file then drop it into the yourmoodle/blocks/countdown/clocks folder. Next time you edit a countdown block the new option will be available.

I have attached a swf file that just displays "xxx days". When using it remember to set the countdown to 24 hours after the target time(or 23.59 on the target day) as it will display 0 days for the last 24hours ie.0 Days 23 Hours and xx Minutes


In reply to Mat Cannings

Re: Countdown Block

by Peter de Groot -
Tx .. downloaded and tried ... Unfortunately when I have a look.. all I get is a blank block... screenshot attached
Attachment untitled.JPG
In reply to Peter de Groot

Re: Countdown Block

by Lael ... -
hmmm - old postings.

OK - trying version 2-1 downloaded from the modules and plugins database. It all works fine in Internet Explorer, but in firefox none of the flash clocks show up on the editing form, or on the main page.

Any help appreciated.

Lael
In reply to Lael ...

Odp: Re: Countdown Block

by Sławomir Gajewski -
Hi Mat
I installed the Countdown Block on Moodle 1.9.5+ and it works properly Uśmiech.
Thanks for this great block!
Hm, here is the Polish language version.
This may be useful to someone in Poland Mieszane uczucia
SG
In reply to Sławomir Gajewski

Re: Odp: Re: Countdown Block

by Heather P -
What version of php are you using?

I'm using Moodle 1.9.5+ with php 5.2.6 and I can't get the block to install. Did you have to do anything special to make it install?
In reply to Heather P

Re: Odp: Re: Countdown Block

by Mat Cannings -
Hi Heather,
I think there have been a couple of changes in the most recent versions of Moodle that may have caused this to break on new installs. I will be looking to repair this block in the next few days (possibly over the weekend) as there is also an issue with another block with the same name within the Moodle database.

I will update here when the new version is ready.

Matthew Cannings
In reply to Mat Cannings

Re: Odp: Re: Countdown Block

by Tony Parke -

Hi Mat,

Did you get anywhere with updating this block so it installs OK on 1.9.5? I am having the same problem as Heather whereby it refuses to complete the instal using the Notifications link and therefore the block does not appear. I would really like to use this block so could you please attach the repaired version to this thread.

Cheers,
Tony

In reply to Tony Parke

Re: Odp: Re: Countdown Block

by Mat Cannings -

I have had a look at this and can not find any problems,

Have you followed the instructions that are in the README.txt file.

This block is slightly different from most others because the zip file that you download contains the block itself and extra source files to help with creating your own custom flash counters.

To install you only need to put one folder called countdown on the server in /moodle/blocks/ all the other files/folders contained in the zip do not need to be placed on the server.

There is a known conflict with the Covcell Deadline Countdown block that I am still trying to work out the best way of resolving. At the moment you can not run this block and the Covcell Deadline Countdown block on the same install.

In reply to Mat Cannings

Re: Odp: Re: Countdown Block

by L Robinson -

DOwnload link on plugins database seems to be broken- I'd love this block if anyone has it. or if the link can be restored.

Thanks,

Leslie

In reply to L Robinson

Re: Odp: Re: Countdown Block

by Mat Cannings -
Hi Leslie,
I upgraded my server and unfortunately changed my website url to have www. at the start. The link should now work.

Hi All,
I am going to start work on an upgraded version of this block in the next few weeks so if people have any suggestions or feedback to help improve this then please send me a private message by clicking on my name above this post.
In reply to Mat Cannings

Re: Odp: Re: Countdown Block

by a m -

The download link seems to be broken - is there any way of getting this block? Would love to have it on our school site.

Thanks

Alison

In reply to a m

Re: Odp: Re: Countdown Block

by Joachim Vogelgesang -
Download link from http://www.matc-online.co.uk/mod/resource/view.php?id=20 is working well (Click countdown2_1a.zip link to view the file.) zwinkernd
In reply to Joachim Vogelgesang

Re: Odp: Re: Countdown Block

by a m -

Hi

I have just tried again but keep getting the same problem.

 Please see attachment of screenshot. I get the same message despite using different computers at different locations.

Any ideas????

Attachment countdown_block_printscreen.JPG
In reply to a m

Re: Odp: Re: Countdown Block

by Joachim Vogelgesang -
Try by using a different browser. With Firefox 3.6.7 I´m able to download right now.
In reply to Joachim Vogelgesang

Re: Odp: Re: Countdown Block

by Mat Cannings -
This does seem to be a problem just with IE and Moodle 2.0, I have changed a setting within Moodle to cause it to download differently which seems to have resolved this problem. I will investigate this further to see if this is a possible bug with Moodle 2.0 (or just another IE problem tongueout).

I am currently converting this block to work with Moodle 2.0 and it looks like this is not going to be able to upgrade properly as I did not use mforms (it was not part of Moodle) when I originally created this block. The main problem is with the way the date/time was selected and stored before.

Would this be a major problem to anyone using this block? I could probably get it to upgrade without the date/time being set, but you would need to edit each block instance to set a new time?



In reply to Mat Cannings

Re: Odp: Re: Countdown Block

by Katerina Nemcova -

Hi,

Is there a working version available for Moodle 2.0.6 please as the 'Latest version' I have downloaded does not seem to work and I get this message:

Plugin "block/countdown" is defective or outdated, can not continue, sorry

Thanks

Katerina

In reply to Katerina Nemcova

Re: Odp: Re: Countdown Block

by Alan Taylor -

I miss not having this block with 2.x.  It was a great little block I used to keep students knowing how much time they had left as we were working on projects.

Please bring it back!

Alan

In reply to Mat Cannings

Re: Countdown Block

by Vlad Kuzba -

Hi, does anybody happen to know if the block can be downloaded from anywhere else? The link from this page http://moodle.org/mod/data/view.php?d=13&rid=718 gives me nothing but a broken ZIP file which I seem to be unable to unpack. Our GCSE is approaching and I want to show the students how little time they have left. Thnaks in advance.

In reply to Vlad Kuzba

Re: Countdown Block

by Luke Wells -

Does anybody know how to make the block display 2011 or 2012 in the date section. i currently only go upto 2010

In reply to Luke Wells

Re: Countdown Block

by Ralf Brauckhoff -

in the "config_instance.html" find in line 98

if(!isset($CFG->block_countdown_startyear)){$CFG->block_countdown_startyear="2008";}
if(!isset($CFG->block_countdown_endyear)){$CFG->block_countdown_endyear="2015";}

 

idoetz

In reply to Ralf Brauckhoff

Re: Countdown Block

by juice masters -

Is there any way this block can be used to match the timer for an activity lock?  Basically I want the block to start counting down when a user enrolls in a course and depending on the activity lock timer, this block would count down with the activity lock timer.  If the lock was 60 minutes, the timer would start with 60 minutes, if the lock was 120 minutes, the timer would start with 120 minutes. Any help would be appreciated.  Thanks