Inverting the topics or weeks.

Inverting the topics or weeks.

by Jeff Hague -
Number of replies: 4

I have been looking for a way to invert the layout of the topics or weeks. I am using 1.5.4 and found a post from May 04 where Bernard Boucher had it working with the weeks format for version 1.3 - thanks Bernard if your still out there!. I downloaded his format.php and copied the useful code into my 1.5.4 format.php and it does invert them - yay! The problem is that it still numbers them from 1 at the top to X at the bottom (actually 0 at the top but I figured out how to make it start at 1) - it doesnt invert the numbers, just the display of the start and end date of the weeks.

I would really like to invert the topics format instead but I could deal with the weeks format. In any case, does anyone know how to do this or feel like figuring it out? I am no programmer and looking at php for more than 30 minutes makes my eyes cross... I have attached the format.php that I am working with (from 1.5.4 with Bernard's 1.3 invert code spliced in) if anyone wants to take a look. The code Bernard figured out is lines 114 through 153...

Thanks!

Jeff

Average of ratings: -
In reply to Jeff Hague

Re: Inverting the topics or weeks.

by Bernard Boucher -
Hi Jeff,
you are near the solution I think!

I don't have a working version 1.5.3 at hand but in your attached file I think you forgot to replace to lines :
$section++
in
$section--
as it was done in my original file.


Also your line 118
$section = $course->numsections - $course->numsections + 1;

should be like the original:
$section = $course->numsections;


Let me know if it works.

I hope it may help,

Bernard

In reply to Bernard Boucher

Re: Inverting the topics or weeks.

by Jeff Hague -

Well hello Bernard! How is Quebec?

That was it! the $section++ shows up in three places and I had only set it to $section-- within the lines I copied from your 1.3 script. I think I fiddled with nearly every line in there trying to either flip the section numbers or hide them entirely but I didnt notice that until you pointed it out.

Line 118 is how I got it to number from 1 to X instead of 0 to X-1 but is not needed with the $section-- mods. Once I fixed the $section thing it really went haywire until I set that back to $section = $course->numsections;
Everything looks good now.

I normally use the topics format and I like to hide the sections until the class period they relate to comes around. I also dont like to hide previous sections because students will refer back to things from time to time. Once you get past 5 or 6 sections, the students have to start scrolling a lot. It hasnt been a big issue because the courses I have been teaching only have 10 sections (Technical college) but I am preparing to teach a course in the Spring at a 4 year college and that class meets 26 times! I am hoping that by flipping it upside down, the sections will simply move down screen as I unhide them. I will probably try to see if I can figure out how to invert the topics format too but this will likely work every bit as well. Ill let you know how it works!

I have not yet looked at any changes that need to be made in Lang\en\moodle.php - any tips for what I may need to look for?

Thanks again!

Jeff

In reply to Jeff Hague

Re: Inverting the topics or weeks.

by Bernard Boucher -
Excellent work Jeff,
here in Québec it is colder than in Virginia Beach but I just arriving from Acapulcocool to compensate.

This partly explain the Mexican delay wink on my side that give you time to auto answer yourself thoughtful


Have a good hack,

Bernard

In reply to Jeff Hague

Re: Inverting the topics or weeks.

by Jeff Hague -

I figured it out! Thanks to the help from Bernard Boucher and his inverted weeks format, I was able to figure out how to modify the Topics format so that it also displays inverted.

Obligatory disclaimer - I am no programmer by any measure of the term! I litterally just compared Bernard's format.php with the "normal" one to try to figure out what he had done to invert the weeks format. I then just started cutting, copying, pasting and editing the format.php for the topics format until I got it to work. This is for 1.5.4 and, so far, I havent seen any side effects but Im sure that there are plenty of things that I havent tried yet. I am also quite sure that my "code" is probably not the best way to handle this but Ill leave the clean up to folks who actually know what they are doing...

It really only took about 30 tries and I got to see some interesting things like a course with 3600+ topics sessions numbered from +9 to -35xx! That one took a while to load...

Anyway, the reason I wanted this is because I generally hide upcoming topics until the day of class that covers that topic, but I dont want to hide past topics because students will refer back to them. With the topics numbered from the top down, as the course progresses, students have to keep scrolling down to get to the current topic. Even with only a few sections, the screen tends to get pretty cluttered. By inverting them, as I unhide a current topic, the past topics move down the page so they are still accessible but not in the way.

Attached is theinverted topics format.php - I have commented all of the lines that I added and hacked with my initials - //jmh so they should be fairly easy to spot. Also, the Lang\en\moodle.php file needs a couple of lines of code added so they display properly (if you want to add this format as opposed to replacing the existing one). That one is pretty easy to figure out but let me know if you need to know what needs to be added.

If anyone finds an issue (and a fix), please let me know.

Thanks!

Jeff