I searched why is it like that and I found the reason:

function gradebookapi_get_students populates all students from all hook_gradebookapi_students as expected (in my case from gradebook, og_gradebook and gradebook_roster)

I don't know why but "gradebook" and "gradebook_roster" modules populate all student users and they override the array of list of group member students via og_gradebook module.

if you add $modules = array('og_gradebook'); to line 1213 of gradebookapi.module it works fine.

CommentFileSizeAuthor
#7 Untitled.png31.4 KBtutumlum
#7 Untitled2.png7.09 KBtutumlum
#7 Untitled3.png40.93 KBtutumlum

Comments

jzornig’s picture

I also ran into this problem. As far as I can figure it, the list of students is calculated as the SUM of all the students from each module that implements hook_gradebookapi_students. Therefore it is not possible for a module like og_gradebook to make the list of students smaller.

jzornig’s picture

This seems to work as a patch to OG Gradebook. The one line added is commented below.


/**
 * Implementation of hook_gradebookapi_students().
 *
 * @param $gradebook
 *   The gradebook object
 * @return array
 *   An array with keys 'uid', containing a list of student ids and 'name', containing a list of student names
 *   This was changed for gradebookapi 6.x.2.x
 */

function og_gradebook_gradebookapi_students($gradebook, $students = array('uid' => array(), 'name' => array())) {

  if ($group_id = og_gradebook_get_group($gradebook->tid)) {
    foreach ($students as $key => $value) unset($students[$key]);  // Add this line to clear other modules student lists
    $sql = "SELECT u.uid, u.name FROM {og_uid} ou INNER JOIN {users} u ON ou.uid = u.uid WHERE ou.nid = %d AND u.status <> 0 AND ou.is_active <> 0 AND ou.is_admin = 0";
    $result = db_query($sql, $group_id);
    while ($user = db_fetch_object($result)) {
      $students['uid'][$user->uid] = $user->uid;
      $students['name'][$user->uid] = $user->name;
    }
  }
  return $students;
}
AntiNSA’s picture

so what is the proper way? The first way mentioned in this thread, or the way in #2? or both?

AntiNSA’s picture

Priority: Normal » Critical

this is a critical issue.

MGN’s picture

Thanks for the suggested fixes to this issue. Unfortunately, I still have not been able to make this happen on properly configured test sites or live sites...

It would help if someone could writeup a step by step guide that I could follow to force this problem happen.

Any chance you have selected student and/or teacher roles in the sitewide gradebook settings (at admin/gradebook/gradebook/settings) ? You shouldn't if you are using og gradebook. The directions on that page state:

Any student and teacher roles selected here will apply to ALL gradebooks. If you are using the OG_Gradebook module, do not select any names here and gradebooks will be formed by group membership. Otherwise, any roles selected here will appear in the gradebook for each group.

This sounds like it could be the source of the problem.

If this isn't it, can you let me know...

Do you only see the problem when you are using the gradebook_roster submodule?

I don't know why but "gradebook" and "gradebook_roster" modules populate all student users and they override the array of list of group member students via og_gradebook module.

gradebook_roster is supposed to override the roster of students and teachers produced by other modules. It can add or subtract from the initial list created by og_gradebook (by design).

Sorry for the delay in getting to this issue...its been a very busy year!

[Note: I marked #925922: Students from wrong group mixed into grade input form as a duplicate of this issue]

jzornig’s picture

Thanks MGN, I think that was the cause of my issue. I should have RTFM a bit more carefully. I'll reconfigure my site without the global student/teacher roles selected.

tutumlum’s picture

StatusFileSize
new40.93 KB
new7.09 KB
new31.4 KB

@MGN
It was too old issue for me, I changed my mind to about using gradebook and I decided to write my own code with Drupal7, but just to follow up the issue I found my gradebook test case from my backups and I checked what you said. No global role is selected and problem persists. Please refer to attachments.

AntiNSA’s picture

I have also found that I did not follow directions.. You are right. I removed pathes, corrected ssettings and itworks. Iam seeing if this aaffects my student/monitor response problems.

AntiNSA’s picture

Argghh... Itake that back.. after removing the mods I could see some groups were correct and soem were still including all students, even after corecting the settings..... any ideas ?

MGN’s picture

Category: bug » support
Priority: Critical » Normal

@tutumlum and AntiNSA,

You may need to check and reconfigure your roster (if you are using gradebook_roster - I think you both are) after you make the change. The roster was probably built with the previous settings, so students that aren't in the group are being added in by your roster. If this is the case, just delete the students that shouldn't be in the class from the roster...

AntiNSA’s picture

would it be possible to rebuild the roster by disabling it/uninstaling it and reinstaling without loosing assignments?

MGN’s picture

Yes. The roster won't affect anything but the list of users displayed in the gradebook. I should probably add a button to delete/reinitialize the roster.

tutumlum’s picture

I uninstalled and installed gradebook roster and it works as MGN suggested. It was about gradebook roster. a button to reinitialize the roster is a good idea in this case.

MGN’s picture

Status: Active » Fixed

Thanks for the feedback. I've added a rebuild button on the gradebook roster form to delete and reinitialize the roster. Just committed the feature to gradebook 6.x-2.x-dev.

I am going to mark this issue as fixed based on the feedback. Feel free to reopen if there are more questions related to this issue.

jzornig’s picture

If I don't define the teacher role in the sitewide settings, where does it get defined for each gradebook?

MGN’s picture

For og_gradebook, the group administrators are teachers (by default) so you don't need to designate a role (for the gradebook anyway- you may still want to have a teacher role for other aspects of your site). This can also be modified by using gradebook_roster to designate another group member as the teacher.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.