Best practice forum (Archived)

End of lesson congratulations editing

 
? ?
Re: End of lesson congratulations editing
על ידי ? ? בתאריך 12/06/2012, 21:41
 

Hi Haydn, 

I have worked out a way to get the effect we are wanting but probably not the best way. 

What ive done is edit the lesson.php language file with the following changes.

Congratulations - end of lesson reached
congratulations

======================================================

<img id="normal" src="http://skills4work.ac.nz/file.php/2/Congratulations_image.png">
<img id="last" src="http://skills4work.ac.nz/file.php/2/End_Congratulations_image.png" style="display:none; text-align:center">

======================================================

Return to $a

returnto

======================================================

Return to $a

<div id="lastwording" style="text-align:center; padding:5px; display:none" class="lessonbutton standardbutton"><a href="http://skills4work.ac.nz/course/view.php?id=2">Finish</a></div>

======================================================

Added the following into the header.

function func1(){

if(location.href == 'http://skills4work.ac.nz/mod/lesson/view.php?id=5&pageid=-9')
{
document.getElementById('normal').style.display = "none";
document.getElementById('last').style.display = "";
document.getElementById('wording').innerHTML = '<a href="http://skills4work.ac.nz/course/view.php?id=2"> Finish </a>';
}
}

And then edited the file /mod/lesson/view.php

echo "<div style=\"text-align:center; padding:5px;\" id=\"wording\" class=\"lessonbutton standardbutton\"><a href=\"$CFG->wwwroot/course/view.php?id=$course->id\">".get_string('returnto', 'lesson', format_string($course->fullname, true))."</a></div>\n";

When the user visits that page URL, which is the last page in the last module, the image is changed to the "Course finished" image, rather than "Module complete" image. The button that usually says "Return to $a" changes to Finish. This is all done in the javascript by using the ID and swapping them out. However, this is quite slow and can sometimes be seen by the image flashing and button moving around resizing.

The main reason I had to make the change to the view.php code (which will now stop upgrades from being simple, i guess?) is because i couldnt just replace the wording "Return to $a" as it left a <a href> tag there and a half box was drawn. 

Forgive me if this seems to be the worst way around getting the desired effect but thats all I could think of to make it work at the time. 

So, how could this be done, without making core code changes? And if what you just mentioned above will do the same thing but using the language files, how is that done, im still a little confused of where and how i use a multi-language filter.

Thanks again, 

Matt.