chamilo-lms icon indicating copy to clipboard operation
chamilo-lms copied to clipboard

Announcements: rows per page wrong

Open jderriks opened this issue 9 years ago • 11 comments

Current behavior / Resultado actual / Résultat actuel

When announcements are sent to many groups at once, the number of announcements shown is lower than the numRow (page size) specifies.

Expected behavior / Resultado esperado / Résultat attendu

If you select 20, 50 or 100 rows in the announcement tool, that should be the number to show.

Steps to reproduce / Pasos para reproducir / Étapes pour reproduire

Create many announcements to many groups and look at the pages. Numbers are totally wrong. (See picture where 20 is the page size but only 4 rows are shown)

Chamilo Version / Versión de Chamilo / Version de Chamilo

1.11.x latest git checkout 2017-04-22

Caused by changes in function getAnnouncements in main/inc/lib/AnnouncementManager class.

afbeelding

afbeelding

jderriks avatar Apr 22 '17 21:04 jderriks

See my Announcements page https://pageshot.net/1cQZlcgZRfPZwfxI/chamilo111x.dev https://pageshot.net/oAuElNlr5DZJ8rbk/chamilo111x.dev

Try replicate this in 1.11.chamilo.org

AngelFQC avatar May 15 '17 22:05 AngelFQC

Will be left open 3 more days for feedback.

ywarnier avatar May 17 '17 06:05 ywarnier

Here you go:

afbeelding afbeelding

Make sure you have some announcements that are sent to many groups at once and to some users. The code to add the "group" label causes the count of the number of announcements to go wrong.

jderriks avatar May 17 '17 12:05 jderriks

Another way to reproduce it with only 2 announcements: afbeelding

Steps:

  1. use fill data to create some users and courses
  2. create 80 groups with 2 users (use random filler)
  3. sent 1 announcement to 40 groups.
  4. sent another one to all 40 groups

These are 2 announcements but the count will be 80 and the list will show one per page even if the page size is set to 20. That is because the single announcement-to-40-groups is counted as 40 announcements.

All because of a change in a SQL select query to add the "group" label to the list...

jderriks avatar May 17 '17 12:05 jderriks

Announcement bad dead code example: test on 0: afbeelding

jderriks avatar May 17 '17 19:05 jderriks

Even on the chamilo campus the issue appears: https://campus.chamilo.org/main/announcements/announcements.php?cidReq=TEST9&id_session=0&gidReq=0&gradebook=0&origin= (you have to login to see announcements)

The root cause of the issue is the SELECT part in AnnouncementManager:getAnnouncements (a terrible piece of code) where multiple rows with the same ID pop up. The "fix" in the while loop where is checked if the announcement has already been displayed is a complex not-working fix because it conflicts with the LIMIT in the SQL statements, causing fewer than the page-size number of items to be displayed. When testing the fix, also keep in mind that the insert-date of similar announcements can be 1 second different from each other. A DISTINCT does not fix this.

jderriks avatar May 17 '17 21:05 jderriks

campus.chamilo.org is version 1.10, so it shouldn't be used as an example. I'm not sure we're going to be able to fix this one in time for 1.11.4. We'll see, but otherwise we'll move it to 1.11.6.

ywarnier avatar May 23 '17 04:05 ywarnier

@jderriks try with the last 1.11.x changes

AngelFQC avatar May 25 '17 22:05 AngelFQC

Considered fixed. Please don't hesitate to report back (we'll reopen it and reschedule for 1.11.6) if it wasn't fixed for you in 1.11.4 (to be released today).

ywarnier avatar May 31 '17 15:05 ywarnier

If only this bug was that easy to fix :-)

https://1.11.chamilo.org/main/announcements/announcements.php?cidReq=TESTHVA&gidReq=0&id_session=0

jderriks avatar May 31 '17 20:05 jderriks

This was already fixed:

https://11.chamilo.org/main/announcements/announcements.php?cidReq=TESTHVA&gidReq=0&id_session=0

jmontoyaa avatar Oct 11 '17 08:10 jmontoyaa