Skip to content

Commit

Permalink
SAK-50773 LTI Improve support of presentationDocumentTarget (#13116)
Browse files Browse the repository at this point in the history
  • Loading branch information
csev authored Dec 18, 2024
1 parent 47d46b7 commit 06b9af7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -506,16 +506,16 @@
<input type="hidden" id="returnContentId" name="$name_ContentId" value="$value_ContentId">
<script>
window.returnContentItem = function (contentItem) {
console.log("returnContentItem", contentItem);
console.debug("returnContentItem", contentItem);
if ( ! Array.isArray(contentItem) ) return;
if ( contentItem.length != 1 ) return;
var item = contentItem[0];
console.log("item", item);
console.debug("item", item);
// Strangely, https://www.sakailms.org/spec/lti-ags/v2p0/releaseToStudent does not have an analog in Assignments
// Content Item Variant
if ( item && item.lineItem && item.lineItem.scoreConstraints ) {
var scoreConstraints = item.lineItem.scoreConstraints;
console.log("item.lineItem.scoreConstraints", scoreConstraints);
console.debug("item.lineItem.scoreConstraints", scoreConstraints);
if ( scoreConstraints.normalMaximum ) {
$("#new_assignment_grade_points").val(scoreConstraints.normalMaximum);
}
Expand Down Expand Up @@ -562,6 +562,7 @@
if ( item ) {
if( item.tool_newpage == 2 ) {
$("#content-launch-new-window-checkbox").show();
$( "#$name_ContentLaunchNewWindow" ).prop( "checked", ( item.content_newpage == 1 ) );
} else {
$("#content-launch-new-window-checkbox").hide();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2427,6 +2427,7 @@ public void doMultipleContentItemResponse(RunData data, Context context) {
}

item.put("content_key", contentKey);
item.put("content_newpage", reqProps.getProperty(LTIService.LTI_NEWPAGE));
item.put("tool_key", toolKey);
item.put("tool_title", (String) tool.get(LTIService.LTI_TITLE));
item.put("tool_newpage", foorm.getLong(tool.get(LTIService.LTI_NEWPAGE)));
Expand Down Expand Up @@ -2526,6 +2527,7 @@ public void doMultipleContentItemResponse(RunData data, Context context) {
}

item.put("content_key", contentKey);
item.put("content_newpage", reqProps.getProperty(LTIService.LTI_NEWPAGE));
item.put("tool_key", toolKey);
item.put("tool_title", (String) tool.get(LTIService.LTI_TITLE));
item.put("tool_newpage", foorm.getLong(tool.get(LTIService.LTI_NEWPAGE)));
Expand Down Expand Up @@ -2623,6 +2625,9 @@ public Properties extractLTIContentItem(JSONObject item, Map<String, Object> too
JSONObject iconObject = getObject(item, ContentItem.ICON);
String icon = getString(iconObject, "fa_icon");

JSONObject placementAdvice = getObject(item, ContentItem.PLACEMENTADVICE);
String presentationDocumentTarget = getString(placementAdvice, ContentItem.PRESENTATION_DOCUMENT_TARGET);

// Prepare data for the next phase
Properties reqProps = new Properties();
reqProps.setProperty(LTIService.LTI_CONTENTITEM, item.toString());
Expand All @@ -2648,6 +2653,7 @@ public Properties extractLTIContentItem(JSONObject item, Map<String, Object> too
if (custom_str.length() > 0) {
reqProps.setProperty(LTIService.LTI_CUSTOM, custom_str);
}
reqProps.setProperty(LTIService.LTI_NEWPAGE, ContentItem.PRESENTATION_DOCUMENT_TARGET_IFRAME.equals(presentationDocumentTarget) ? "0" : "1");

return reqProps;
}
Expand Down Expand Up @@ -2758,6 +2764,8 @@ public Properties extractLTIDeepLink(JSONObject item, Map<String, Object> tool,
if (custom_str.length() > 0) {
reqProps.setProperty(LTIService.LTI_CUSTOM, custom_str);
}
// The tool does not express a target preference one way or the other in DeepLink
reqProps.setProperty(LTIService.LTI_NEWPAGE, "1");

return reqProps;
}
Expand Down
4 changes: 4 additions & 0 deletions lti/tsugi-util/src/java/org/tsugi/lti/ContentItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ public class ContentItem {
public static final String TEXT = "text";
public static final String URL = "url";
public static final String LINEITEM = "lineItem";
public static final String PLACEMENTADVICE = "placementAdvice";
public static final String PRESENTATION_DOCUMENT_TARGET = "presentationDocumentTarget";
public static final String PRESENTATION_DOCUMENT_TARGET_IFRAME = "iframe";
public static final String PRESENTATION_DOCUMENT_TARGET_WINDOW = "window";
public static final String SCORE_CONSTRAINTS = "scoreConstraints";
public static final String SCORE_CONSTRAINTS_NORMAL_MAXIMUM = "normalMaximum";
public static final String SCORE_CONSTRAINTS_EXTRA_CREDIT_MAXIMUM = "extraCreditMaximum";
Expand Down

0 comments on commit 06b9af7

Please sign in to comment.