Best practice forum (Archived)

Topic format course FORCE collpased display

 
? ?
Topic format course FORCE collpased display
by ? ? - Monday, 28 March 2011, 8:22 PM
 

By default the topic format displays all topics open at once, but we want it to only show 1 at a time with the "jump to.." dropdown menu at the bottom

Do you know of a way to force a topics format Totara course to display with the topics view already collapsed into just showing 1 topic?

Thanks,

Simon Coggins
Re: Topic format course FORCE collpased display
by Simon Coggins - Tuesday, 29 March 2011, 2:19 PM
Group Totara

I don't believe that there is an option to do what you want, but I had a quick look at the code and I think it's an easy fix.

Try editing the file /course/format/topics/format.php and changing this line (near the top of the file):

$topic = optional_param('topic', -1, PARAM_INT);

to:

$topic = optional_param('topic', 1, PARAM_INT);

(Change the number from -1 to 1)

That should display the first topic by default for all courses in topic format.

Simon

 

? ?
Re: Topic format course FORCE collpased display
by ? ? - Tuesday, 29 March 2011, 5:50 PM
 

that fixed it to the way we wanted big grin 

thanks for the tip

? ?
Re: Topic format course FORCE collpased display
by ? ? - Sunday, 3 April 2011, 7:39 PM
 

Ive noticed that (with this code changed) when you click to view a resource/activity (which take you to that page) and then go back to the course page, it jumps you back to the first topic again NOT the current topic you were viewing previously when you click the resource/activity link.

is there a way to keep it collapsed, but make it jump you back to the current topic you were viewing and not the first one each time?

 

 

Simon Coggins
Re: Topic format course FORCE collpased display
by Simon Coggins - Monday, 4 April 2011, 2:17 PM
Group Totara

Looks like you also need to modify this line (line 31):

if ($topic != -1) {

and change it to 1 instead of -1 too:

if ($topic != 1) {

 

Simon

 

? ?
Re: Topic format course FORCE collpased display
by ? ? - Monday, 4 April 2011, 6:48 PM
 

thanks, that worked. big grin

? ?
Re: Topic format course FORCE collpased display
by ? ? - Monday, 4 April 2011, 8:28 PM
 

found a problem with changing that last value:

now if you're viewing topic 2 onwards you can't use the jump drop-down menu to jump back to topic 1...

sad

 

? ?
Re: Topic format course FORCE collpased display
by ? ? - Sunday, 10 April 2011, 9:47 PM
 

found a problem with changing that last value:

now if you're viewing topic 2 onwards you can't use the jump drop-down menu to jump back to topic 1...

sad

Simon Coggins
Re: Topic format course FORCE collpased display
by Simon Coggins - Sunday, 10 April 2011, 10:15 PM
Group Totara

Hi Ira,

Sorry about that. I've had another look and I think I've got it this time ;-)

Undo those two changes you made and instead, change:

$displaysection = course_set_display($course->id, 0);

to:

$displaysection = course_set_display($course->id, 1);

(that's line 37 in my code)

Simon

? ?
Re: Topic format course FORCE collpased display
by ? ? - Sunday, 10 April 2011, 11:07 PM
 

i think we finally got it.

works alright so far approve

thanks again