New course format displaying weeks in reverse order ...

New course format displaying weeks in reverse order ...

by Baptiste Lhoste -
Number of replies: 7

Hi everybody,

I'm trying to create a new course format to display weeks in reversed order since the plugin format_weeksrev is not maintained.

I have some issues when using the drag-and-drop functionality.

I can not found which javascript method is called when the user release the mouse, and how to override it.

Can someone help me on this ?

Thanks,


Batistou

Average of ratings: -
In reply to Baptiste Lhoste

Re: New course format displaying weeks in reverse order ...

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

Hi Batistou,

All of the Drag and Drop callback JS code is handled in the format.js file: https://github.com/brum1975/moodle-course_format_weeksrev/blob/master/format.js for when sections are moved up and down.

Cheers,

Gareth

In reply to Gareth J Barnard

Re: New course format displaying weeks in reverse order ...

by Baptiste Lhoste -

Hi Gareth,

First of all, thanks for your response.

I must miss something, because in the format.js, I only have a function (process_sections) which seems to be called after the ajax response.

To ensure coherent behavior, I need to change the rest.php call prior this function. How can I do that ?

Thanks,

Batistou

In reply to Baptiste Lhoste

Re: New course format displaying weeks in reverse order ...

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

Hi Batistou,

Off the top of my head, I don't know how to call the rest.php file prior.  But what I'm confused about is the need to alter things in the first place.  There is another function 'M.course.format.swap_sections' that orchestrates the swap.

So in reality, the real question is 'What is the problem and why do you think you need to change things?'.

In all my formats I've not needed that solution, I've just adapted format.js.

Cheers,

Gareth

In reply to Gareth J Barnard

Re: New course format displaying weeks in reverse order ...

by Baptiste Lhoste -

Thanks Gareth to take time to answer me.

I will try to explain my problem.

Lets assume we have a course composed by 8 sections.

Since I want to display weeks in reverse order, the display is like this :

General section then section 8 then section 7 ... section 2 finally section 1

When I use the drag and drop functionality to move the section 7 up in place of section 8, I expect to have :

General section then section 7 then section 8 ... section 2 finally section 1

Instead I have : General section then section 8 then section 6 ... section 2 then section 1 finally section 7.

Because the AJAX call ask to move the section 7 to 1 instead of asking a move to 8.

If it is not clear that is normal. :D

Batistou


In reply to Baptiste Lhoste

Re: New course format displaying weeks in reverse order ...

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

Hi Batistou,

Very clear thank you.  Please give me a little time to think about this.  Ages since I messed with this area of course formats and looked at the network traffic involved.

In the mean time, look in the '\course\yui\src\dragdrop\js' folder for information on this.

Cheers,

Gareth

In reply to Baptiste Lhoste

Re: New course format displaying weeks in reverse order ...

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Why not just switch to topic format and then change the name of each section to whatever you want? That way you can have sections labeled Section 8, Section 7 or Feb 30, Feb 23 etc...

In reply to Emma Richardson

Re: New course format displaying weeks in reverse order ...

by Baptiste Lhoste -

Hi Emma,

Thanks for your proposition, but my end-users will not appreciate to do that for each course in weekly format.

I can not automate this behavior because there is also some courses in topic format and we do not want them to display weeks information.

Batistou