Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SAK-49493 Gradebook add support for gradebooks by group #12843

Closed

Conversation

bgarciaentornos
Copy link
Contributor

Following up the work done last year in the S2U-26 jira under the Unidigital project, this PR overpasses #12338 , which can be closed.
As previously mentioned, this feature provides the option to generate different gradebook instances for selected groups of a site and all this is achieved with no database changes, no gradebook ui modifications and can be disabled via property. The development is based upon lots of methods being overridden with a new parameter to separate the siteId=gradebookUid simplification that was in the previous situation.
In the near future there are some parts that will probably have to be adapted with other announced changes that are coming into the gradebook integration with tools like LTI and assignments. But with such a big piece of work it's necessary to have a first version we can include before the 25 freeze date while we keep working on updating, improving the feature and building upon it.
And also, as @ern mentioned, once everything is settled, a big round of QA can be done to test this and other features modifying the same bits of code.
I also want to thank to all the people of the EDF team who have worked on this development, the S2U group for making it happen, plus the biggest gratitude to @jesusmmp for all the help and his university (Murcia) for sponsoring the second phase.

@bgarciaentornos bgarciaentornos changed the title S2U-26 Gradebook: support for group instances SAK-49493 Gradebook: support for group instances Sep 3, 2024
Comment on lines +3814 to +3820
// get all assignments in Gradebook
List gradebookAssignments = gradingService.getAssignments(contextString, contextString, SortType.SORT_BY_NONE);

context.put("gradebookAssignmentsSelectedDisabled", gradebookAssignmentsSelectedDisabled);
context.put("gradebookAssignmentsLabel", gradebookAssignmentsLabel);
// filtering out those from Samigo
for (Iterator i = gradebookAssignments.iterator(); i.hasNext(); ) {
org.sakaiproject.grading.api.Assignment gAssignment = (org.sakaiproject.grading.api.Assignment) i.next();
if (!gAssignment.getExternallyMaintained() || gAssignment.getExternallyMaintained() && gAssignment.getExternalAppName().equals(assignmentService.getToolId())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably should simply ask the gardingService for only assignments with a specifc tool id vs getting all assignments and then attempting to filter them, this should be something the gradingService is responsible for

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is actually the existing "site instance" code, we just left it as it is (and I think that's what should be done). It appears as modified because it's now inside an if block that checks if the feature is enabled, so we added some tabs.

Comment on lines 8425 to 8431
// What this part does is search in one gradebook or several (if isGradebookGroupEnabled is active)
// for the category that contains the assignment. When it finds it, it retrieves the points for the
// category (category.getPointsForCategory()) and stores them in a HashMap that keeps track
// of the gradebook + category score. In the end, instead of using the old Double,
// we will iterate through the HashMap, using the Double from each entry, and perform
// the same check as before.
private void buildGradebookPointsMap(String gbUid, String siteId, String assignmentRef,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should likely be something the gradingService should do, remember this feature is about enabling group gradebooks and then ensuring tools integrate with that.

Any time your having to get data from the GradingService and then filter or manipulate it in a tool then you should likely should consider moving the method to the GradingService and have it do that. Remember the tools are users of the GradingService.

@ern ern changed the title SAK-49493 Gradebook: support for group instances SAK-49493 Gradebook add support for gradebooks by group Sep 23, 2024
@@ -140,6 +140,9 @@ public class Assignment implements Serializable, Comparable<Assignment> {
@Getter
@Setter
private String gradebookId;
@Getter
@Setter
private String gradebookUid;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the gradebookId is the same as the site which is by default a UUID, how does gradebookUid differ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, gradebookId is a existing database sequence. It's used some times for direct access, this is just a setter/getter that was missing for some specific use but we're just setting a different value, not adding anything.


import java.text.MessageFormat;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

import org.sakaiproject.util.ResourceLoader;
//import org.sakaiproject.util.ResourceLoader;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

}

/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove code vs commenting

@SpringBean(name = "org.sakaiproject.user.api.UserDirectoryService")
protected UserDirectoryService userDirectoryService;

public static final String GB_PREF_KEY = "GBNG-";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public static final String GB_PREF_KEY = "GBNG-";
public static final String GB_PREF_KEY = "GB-";

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See next comment

Comment on lines +389 to +408
PreferencesEdit prefsEdit = null;
try {
prefsEdit = preferencesService.edit(currentUserId);
}
catch (IdUnusedException e) {
try {
prefsEdit = preferencesService.add(currentUserId);
} catch (PermissionException e1) {
log.warn("setUserGbPreference PermissionException attempting to add prefs for user {}, prefName={}", currentUserId, prefName);
} catch (IdUsedException e1) {
log.warn("setUserGbPreference IdUsedException attempting to add prefs for user {}, prefName={}", currentUserId, prefName);
}
} catch (PermissionException e) {
log.warn("setUserGbPreference PermissionException attempting to edit prefs for user {}, prefName={}", currentUserId, prefName);
} catch (InUseException e) {
log.warn("setUserGbPreference InUseException attempting to edit prefs for user {}, prefName={}", currentUserId, prefName);
}
ResourcePropertiesEdit props = prefsEdit.getPropertiesEdit(GB_PREF_KEY + siteId);
props.addProperty(prefName, prefValue);
preferencesService.commit(prefsEdit);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check elsewhere in sakai for a better way to make edits to a users preferences

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was moved from the GradebookNgBusinessService class, as we tried to avoid to get current context or user on that class. But we didn't add or modify that part.

Comment on lines +15 to +16
<!-- Allow multiple instances of this tool within one site -->
<configuration name="allowMultipleInstances" value="true" />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to contrast with the sakai property?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting false the property will override this.

@bgarciaentornos
Copy link
Contributor Author

Thanks a lot for the review @ern , all the comments have been applied or answered

@ern ern added the 25 Blocker label Oct 1, 2024
@@ -129,12 +136,12 @@ public String archive(final String siteId, final Document doc, final Stack<Eleme
// <GradebookConfig>
Element gradebookConfigEl = doc.createElement("GradebookConfig");

Gradebook gradebook = this.gradingService.getGradebook(siteId);
Gradebook gradebook = this.gradingService.getGradebook(siteId, siteId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is strange to me

		Gradebook gradebook =  this.gradingService.getGradebook(siteId, siteId);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just for retrocompatibility and an exception case. It is called when archiving the tool and that functionality won't be covered for groups. I guess we could add a one parameter method just for that case but it feels redundant and we preferred it like this.

@bgarciaentornos
Copy link
Contributor Author

bgarciaentornos commented Oct 2, 2024

We're reviewing the cypress tests

EDIT: @ottenhoff first look and it doesn't really look related to this, rubrics and resubmission stuff but we don't touch that. Just saw this, what previous assignments change is that modification related to?

image

@ottenhoff
Copy link
Contributor

EDIT: @ottenhoff first look and it doesn't really look related to this, rubrics and resubmission stuff but we don't touch that. Just saw this, what previous assignments change is that modification related to?

I think it was just getting the tests working again. Maybe you just need to rebase from upstream/master

@bgarciaentornos
Copy link
Contributor Author

I

EDIT: @ottenhoff first look and it doesn't really look related to this, rubrics and resubmission stuff but we don't touch that. Just saw this, what previous assignments change is that modification related to?

I think it was just getting the tests working again. Maybe you just need to rebase from upstream/master

I rebased it and it seems they're still failing, not sure. We'll take a look but if you find out anything please let us know, thanks

Co-authored-by: jumarub <[email protected]>
Co-authored-by: JuanDavid102 <[email protected]>
@ern
Copy link
Contributor

ern commented Nov 5, 2024

closing as there is a new PR #13005

@ern ern closed this Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants