Skip to content

Commit

Permalink
SAK-49039 - Fix error message when score scope is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
csev committed Sep 21, 2023
1 parent cb43ccb commit 93a0538
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ protected void handleTokenPost(String tool_id, HttpServletRequest request, HttpS
}
returnScopeSet.add(LTI13ConstantsUtil.SCOPE_SCORE);

sat.addScope(SakaiAccessToken.SCOPE_BASICOUTCOME);
sat.addScope(SakaiAccessToken.SCOPE_SCORE);
}

if (scope.contains(LTI13ConstantsUtil.SCOPE_RESULT_READONLY)) {
Expand All @@ -923,7 +923,7 @@ protected void handleTokenPost(String tool_id, HttpServletRequest request, HttpS
}
returnScopeSet.add(LTI13ConstantsUtil.SCOPE_RESULT_READONLY);

sat.addScope(SakaiAccessToken.SCOPE_BASICOUTCOME);
sat.addScope(SakaiAccessToken.SCOPE_RESULT_READONLY);
}

if (scope.contains(LTI13ConstantsUtil.SCOPE_NAMES_AND_ROLES)) {
Expand Down Expand Up @@ -979,9 +979,9 @@ protected void handleLineItemScore(String signed_placement, String lineItemId, H
if (sat == null) {
return; // Error already set
}
if (!sat.hasScope(SakaiAccessToken.SCOPE_BASICOUTCOME)) {
LTI13Util.return400(response, "Scope basic outcome not in access token");
log.error("Scope basic outcome not in access token");
if (!sat.hasScope(SakaiAccessToken.SCOPE_SCORE)) {
LTI13Util.return400(response, "Scope score not in access token");
log.error("Scope score not in access token");
return;
}

Expand Down Expand Up @@ -1478,7 +1478,7 @@ protected void handleNamesAndRoles(String signed_placement, HttpServletRequest r
JSONObject sakai_ext = new JSONObject();

/* SAK-47261 - Scope NRPS to Context, not Resource Link
if ( sat.hasScope(SakaiAccessToken.SCOPE_BASICOUTCOME) && assignment_name != null ) {
if ( sat.hasScope(SakaiAccessToken.SCOPE_SCORE) && assignment_name != null ) {
String placement_secret = (String) content.get(LTIService.LTI_PLACEMENTSECRET);
String placement_id = getPlacementId(signed_placement);
String result_sourcedid = SakaiBLTIUtil.getSourceDID(user, placement_id, placement_secret);
Expand Down Expand Up @@ -2147,13 +2147,12 @@ private void handleLineItemsDetail(String signed_placement, String lineItem, boo
if (sat == null) {
return;
}
/*
if (! (sat.hasScope(SakaiAccessToken.SCOPE_LINEITEMS_READONLY) || sat.hasScope(SakaiAccessToken.SCOPE_LINEITEMS) )) {
LTI13Util.return400(response, "Scope lineitems.readonly not in access token");
log.error("Scope lineitems.readonly not in access token");

if (results && ! (sat.hasScope(SakaiAccessToken.SCOPE_RESULT_READONLY)) ) {
LTI13Util.return400(response, "Scope result.readonly not in access token");
log.error("Scope result.readonly not in access token");
return;
}
*/

Site site = null;
Map<String, Object> tool = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,14 @@
public class SakaiAccessToken extends org.tsugi.lti13.objects.BaseJWT {

/**
* Allows the tool to use basic outcomes (one grade per resource)
* Allows the tool to send a score
*/
public static final String SCOPE_BASICOUTCOME = "sakai.ims.ags.basicoutcome";
public static final String SCOPE_SCORE = "sakai.ims.ags.score";

/**
* Allows the tool to send a score
*/
public static final String SCOPE_RESULT_READONLY = "sakai.ims.ags.result.readonly";

/**
* Allows the tool to list their own grade book columns (lineitems)
Expand Down

0 comments on commit 93a0538

Please sign in to comment.