Modifying the Social course format

Modifying the Social course format

by Stephen Hutchison -
Number of replies: 8

Hi,

I'm working on setting up a Moodle site where we'll be making use of the Social course format. However, I'd like the course home page to display Recent Activity for the course instead than the default social forum. 

Rather than modify the code for the Social Course Format, I've made a new course format by copying social one as per https://moodle.org/mod/forum/discuss.php?d=169976. So far so good.

Now I just need to modify the format.php file so that it does what recent.php does. I tried just copying the code from the recent.php file into the format.php file but it just gave me the error:

Coding error detected, it must be fixed by a programmer: The theme has already been set up for this page ready for output. Therefore, you can no longer change the theme, or anything that might affect what the current theme is, for example, the course.

Any help would great.

Thanks
Stephen

Stephen Hutchison
Web Development Officer
Queensland Council of Social Service
AUSTRALIA

Average of ratings: -
In reply to Stephen Hutchison

Re: Modifying the Social course format

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Dear Stephen,

I understand that it's a coding fault possibly with attempting to modify the contents of the page header after it's been output.  But to help you further I need to see the stack trace and have a copy of the code.

Cheers,

Gareth

In reply to Gareth J Barnard

Re: Modifying the Social course format

by Stephen Hutchison -

Hi Gareth,

I found a way to do it by replacing the code in the format.php with the line...

echo '<META HTTP-EQUIV="Refresh" Content="0; URL=recent.php?id=' . $id . '">';

...which just does a simple redirect to the recent activity page.

Is it ok to do it this way? or is there a better way?

thanks

Stephen

 

In reply to Stephen Hutchison

Re: Modifying the Social course format

by Marina Glancy -
Picture of Core developers Picture of Moodle HQ Picture of Moodle Workplace team Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

Hi Stephen, which moodle version are you using?

in 2.4 you can make redirection quite elegant:

http://docs.moodle.org/dev/Course_formats#Executing_code_before_output

In reply to Marina Glancy

Re: Modifying the Social course format

by Stephen Hutchison -

Thanks Marina,

I'm running 2.4. What do i have to do to implement a redirection?

In reply to Stephen Hutchison

Re: Modifying the Social course format

by Marina Glancy -
Picture of Core developers Picture of Moodle HQ Picture of Moodle Workplace team Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

read documentation... or copy from core format scorm

In reply to Marina Glancy

Re: Modifying the Social course format

by Stephen Hutchison -

ah ok... the doco's a bit cryptic for a newbie like me. 

I think I'll stick with what I've done. It seems to work pretty well.

In reply to Stephen Hutchison

Re: Modifying the Social course format

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Dear Stephen,

Even though the redirect works, what would be really great is a format working with it.  So, would you be willing to post the code so that it can be fixed?

Cheers,

Gareth

In reply to Gareth J Barnard

Re: Modifying the Social course format

by Stephen Hutchison -

a redirect to the recent.php is really what i need. if i can figure out what to do with page_set_cm() / page_set_course() I'll do that. Otherwise I'll perservere with my http redirect.