Possible bug in assign courses (array from GetMyCourses)

  • Paolo
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
13 years 9 months ago - 13 years 9 months ago #1 by Paolo
Hi guys,
I have a problem with the assigncourses page. Basically, when I assign a course to a new child, the child[ courses ] array get more values.. exactly it appends after my 0=>mycourse,...1=>2, 2=>3, 3=>2)
Then if I assign him another course (not the 2 and 3 because the checkboxes are disabled) the first wrong value is overwritten, so I get 0=>mycourse, 1=>mycourse, 2=>3, 3=>2). The enrol is working right it's just that array that got messed up and obviously some checkboxes are disabled where they wouldn't.
The function getChildren looks good to me, so I guess the issue is in the function GetMyCourses but I don't understand how it works with moodle..
I tried to change courses ids from 1, 2, 3 to 101, 102, 103 but it doesn't change, I get 0=>mycourse, 1=>mycourse, 2=>103 3=>102
I assume if I had more than 4 courses I would get a longer false array.
To see the array I put a var_export($child[ courses ]) into childrenCheckboxes function in parents.php

Paolo
Last edit: 13 years 9 months ago by Paolo.

Please Log in or Create an account to join the conversation.

  • Paolo
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
13 years 9 months ago - 13 years 9 months ago #2 by Paolo
I noticed, if you have for example 4 new users with empty array and you assign courses just to one user,all the other users are fine with empty array, but if one of other users has the array initialized, its array is updated every time you assign a course to someone else..
Last edit: 13 years 9 months ago by Paolo.

Please Log in or Create an account to join the conversation.

  • Paolo
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
13 years 9 months ago #3 by Paolo
I guess I found the bug!

In the getChildren function in parents.php just add

if ((is_array ($courses)) && (count ($courses)))
{
$user_courses = array ();
...
...

Please Log in or Create an account to join the conversation.

More
13 years 9 months ago #4 by Chris
Thanks Paolo.

Antonio is on holidays at the moment, so will have him took at this once he returns.

Please Log in or Create an account to join the conversation.