thepurpleblob/moodle-block_course_overview

Courses marked as Favourites and unmarked courses switch place when changing course sort order

Closed this issue · 6 comments

cdipe commented

We have discovered a serious problem: The courses marked as Favourites and the courses not marked as favourites switch place when customising the course sort order.

Steps to replicate

  1. Set Favourites as default tab and have Keep favourites in course list unchecked.at admin/settings.php?section=blocksettingcourse_overview
  2. Have courses not marked as Favourites plus one or more courses marked as Favourites
  3. Select Customise this page
  4. Select the Courses tab
  5. Change order on a few courses
  6. Select Stop customising this page
  7. Verify that all your favourites have been unmarked as favourites, and that you previously unmarked courses have become favourites.

Using Moodle 3.4.4 and Course overview (Legacy) 3.5.4

cdipe commented
Video showing this problem and issue #31 
[https://play.lnu.se/media/t/0_klqjt72x] (https://play.lnu.se/media/t/0_klqjt72x)

This plugin is in the middle of quite a comprehensive rewrite. I'll make sure this is addressed/tested.

As usual, this is taking way longer than I expected :(

cdipe commented

OK. Appreciate it as soon as it can be done, we would really like to use this block instead of the half ready native course overview moodle 3.4 has.

Hello,
I made many change (nearly deleted all the differences between editmode and normalmode, add icons (for visibility,parameters,deletecourse), and javascript to not reload the page on favorite and visibility change) and putted it in a fork and i think i corrected this problem :-)
The problem is... my commits are bad because they include many change -_-

For this specific problem, if I remember well, the problem is on the "active" tab.
You actually put active on the "favorite link" (a) but when we click on tabs, it's the "list" (li) that become active, so the "active" always stay on the "favorite link", then when you call save on a drag and drop from the "course list", the activetab from edit.js always send "favorite" instead of "course", and then you update the favorite list with all the course of the course list, and all courses becomes favorite.

To correct it, we need to put "active" on the "li" instead of the "a"
in main.mustache :

<li class="nav-item">
            <a class="nav-link {{^ viewingfavourites }}active{{/ viewingfavourites }}" href="#courses" role="tab" data-toggle="tab" data-tabname="courses">

Should be :

 <li class="nav-item {{^ viewingfavourites }}active{{/ viewingfavourites }}" data-tabname="courses">
            <a class="nav-link" href="#courses" role="tab" data-toggle="tab">

And in edit.js (i don't remember if it's was for necessity or just to be more comprehensible for me) :
var activetab = $(".block_course_overview .nav-tabs .active").data("tabname");
Should be :
var activetab = $(".block_course_overview .nav-tabs li.active").data("tabname");

If I remember well (and if I'm not wrong on the source of the problem), it should be enough to correct this bug

Hello, I have created a pull request to fix this issue (Send correct tab name when editing course order #37). Note that this is theme related and is not an issue in some themes. Thanks!

I've been unable to reproduce this, so I'm relying on @bel-omahoney to have sorted it.