Skip to content

Commit

Permalink
Update profile
Browse files Browse the repository at this point in the history
Add missing capabilities
  • Loading branch information
spvickers committed May 20, 2018
1 parent 55e5c1d commit 9b342e8
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 17 deletions.
26 changes: 19 additions & 7 deletions src/java/org/oscelot/blackboard/lti/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,13 @@ public static String parseParameter(B2Context b2Context, Properties props, User

if (value.contains("$User.")) {
if (tool.getDoSendUserId()) {
value = value.replaceAll("\\$User.id", user.getId().toExternalString());
value = value.replaceAll("\\$User.id", props.getProperty("user_id"));
value = value.replaceAll("\\$User.username", user.getUserName());
if (value.contains("$User.org")) {
value = value.replaceAll("\\$User.org", getOrg(user.getId(), false));
}
}
if (tool.getDoSendAvatar()) {
try {
if (value.contains("$User.image") && MyPlacesUtil.avatarsEnabled() && displayAvatar(user.getId()) && tool.getDoSendAvatar()) {
String image = MyPlacesUtil.getAvatarImage(user.getId());
Expand All @@ -596,9 +601,6 @@ public static String parseParameter(B2Context b2Context, Properties props, User
}
} catch (Exception e) {
}
if (value.contains("$User.org")) {
value = value.replaceAll("\\$User.org", getOrg(user.getId(), false));
}
}
}
if (value.contains("$Person.")) {
Expand Down Expand Up @@ -634,6 +636,11 @@ public static String parseParameter(B2Context b2Context, Properties props, User
value = value.replaceAll("\\$Person.email.personal", user.getEmailAddress());
}
}
if (value.contains("$Membership.")) {
if (tool.getDoSendRoles()) {
value = value.replaceAll("\\$Membership.role", props.getProperty("roles"));
}
}
String oldContextId = null;
if ((course != null) && value.contains("$Context.")) {
if (tool.getDoSendContextId()) {
Expand All @@ -654,7 +661,7 @@ public static String parseParameter(B2Context b2Context, Properties props, User
value = value.replaceAll("\\$Context.dataSource", course.getDataSourceId().toExternalString());
value = value.replaceAll("\\$Context.sourceSectionId", course.getCourseId());
}
value = value.replaceAll("\\$Context.label", "");
// value = value.replaceAll("\\$Context.label", "");
value = value.replaceAll("\\$Context.title", course.getTitle());
value = value.replaceAll("\\$Context.shortDescription", course.getDescription());
value = value.replaceAll("\\$Context.longDescription", course.getDescription());
Expand Down Expand Up @@ -706,13 +713,18 @@ public static String parseParameter(B2Context b2Context, Properties props, User
value = value.replaceAll("\\$ResourceLink.timeFrame.end", formatCalendar(content.getEndDate(), Constants.ISO_DATE_FORMAT));
}
}
if ((course != null) && value.contains("$CourseSection.")) {
if ((course != null) && value.contains("$CourseSection.") && props.getProperty("context_type").equals("CourseSection")) {
if (tool.getDoSendContextId()) {
if (props.containsKey("context_id")) {
value = value.replaceAll("\\$CourseSection.id", props.getProperty("context_id"));
}
}
if (tool.getDoSendContextSourcedid()) {
value = value.replaceAll("\\$CourseSection.sourcedId", course.getBatchUid());
value = value.replaceAll("\\$CourseSection.dataSource", course.getDataSourceId().toExternalString());
value = value.replaceAll("\\$CourseSection.sourceSectionId", course.getCourseId());
}
value = value.replaceAll("\\$CourseSection.label", "");
// value = value.replaceAll("\\$CourseSection.label", "");
value = value.replaceAll("\\$CourseSection.title", course.getTitle());
value = value.replaceAll("\\$CourseSection.shortDescription", course.getDescription());
value = value.replaceAll("\\$CourseSection.longDescription", course.getDescription());
Expand Down
41 changes: 31 additions & 10 deletions src/java/org/oscelot/blackboard/lti/resources/Profile.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,30 +157,51 @@ public void execute(B2Context b2Context, Response response) {
profile.append(" },\n");
profile.append(" \"capability_offered\":[\n");
profile.append(" \"basic-lti-launch-request\"");
if (tool.getContentItem().equals(Constants.DATA_TRUE)) {
profile.append(", \"ContentItemSelectionRequest\"");
}
if (tool.getConfig().equals(Constants.DATA_TRUE)) {
profile.append(", \"ConfigureLaunchRequest\"");
}
if (tool.getDashboard().equals(Constants.DATA_TRUE)) {
profile.append(", \"DashboardRequest\"");
}
profile.append(",\n \"ResourceLink.id\", \"ResourceLink.id.history\", \"ResourceLink.title\", \"ResourceLink.description\"");
profile.append(",\n \"ResourceLink.timeFrame.begin\", \"ResourceLink.timeFrame.end\"");
profile.append(",\n \"CourseSection.id\", \"CourseSection.title\", \"CourseSection.shortDescription\", \"CourseSection.longDescription\", \"CourseSection.dept\"");
profile.append(",\n \"Context.id\", \"Context.title\" ,\"Context.shortDescription\", \"Context.longDescription\", \"Context.dept\"");
if (tool.getDoSendContextSourcedid()) {
profile.append(",\n \"CourseSection.sourcedId\",\"CourseSection.dataSource\",\"CourseSection.sourceSectionId\"");
profile.append(",\n \"CourseSection.sourcedId\", \"CourseSection.dataSource\", \"CourseSection.sourceSectionId\"");
profile.append(",\n \"Context.sourcedId\", \"Context.dataSource\", \"Context.sourceSectionId\"");
}
profile.append(",\n \"CourseSection.timeFrame.begin\", \"CourseSection.timeFrame.end\"");
profile.append(",\n \"Context.timeFrame.begin\", \"Context.timeFrame.end\"");
if (tool.getDoSendExtCopyOf()) {
profile.append(",\n \"Context.id.history\"");
}
profile.append(",\n \"CourseSection.title\",\"CourseSection.shortDescription\",\"CourseSection.longDescription\"");
profile.append(",\n \"CourseSection.timeframe.begin\",\"CourseSection.timeframe.end\"");
if (tool.getDoSendUserId()) {
profile.append(",\n \"User.id\",\"User.username\",\"Person.studentId\"");
profile.append(",\n \"User.id\", \"User.username\", \"User.org\"");
}
if (tool.getDoSendAvatar()) {
profile.append(", \"User.image\"");
}
profile.append(", \"Person.studentId\"");
if (tool.getDoSendUserSourcedid()) {
profile.append(",\n \"Person.sourcedId\"");
profile.append(", \"Person.sourcedId\"");
}
if (tool.getDoSendUsername()) {
profile.append(",\n \"Person.name.prefix\",\"Person.name.given\",\"Person.name.middle\",\"Person.name.family\",\"Person.name.full\"");
profile.append(",\n \"Person.address.street1\",\"Person.address.street2\",\"Person.address.locality\",\"Person.address.statepr\",\"Person.address.country\",\"Person.address.postcode\",\"Person.address.timezone\"");
profile.append(",\n \"Person.phone.mobile\",\"Person.phone.primary\",\"Person.phone.home\",\"Person.phone.work\",\"Person.phone.webaddress\"");
profile.append(",\n \"Person.name.prefix\", \"Person.name.given\", \"Person.name.middle\", \"Person.name.family\", \"Person.name.full\"");
profile.append(",\n \"Person.address.street1\", \"Person.address.street2\", \"Person.address.locality\", \"Person.address.statepr\", \"Person.address.country\", \"Person.address.postcode\", \"Person.address.timezone\"");
profile.append(",\n \"Person.phone.mobile\", \"Person.phone.primary\", \"Person.phone.home\", \"Person.phone.work\", \"Person.webaddress\"");
}
if (tool.getDoSendEmail()) {
profile.append(",\n \"Person.email.primary\",\"Person.email.personal\"");
profile.append(",\n \"Person.email.primary\", \"Person.email.personal\"");
}
if (tool.getDoSendRoles()) {
profile.append(",\n \"Membership.role\"");
}
if (tool.getDoSendOutcomesService()) {
profile.append(",\n \"Result.autocreate\",\"Result.sourcedId\"");
profile.append(",\n \"Result.autocreate\", \"Result.sourcedId\", \"Result.pointsPossible\"");
}
StringBuilder service = new StringBuilder();
service.append(" \"service_offered\":[");
Expand Down

0 comments on commit 9b342e8

Please sign in to comment.