Skip to content

Commit

Permalink
SAK-44626 Lessons Add Dates to Assignment Links (sakaiproject#8799)
Browse files Browse the repository at this point in the history
  • Loading branch information
MRutea authored Nov 11, 2020
1 parent e91848d commit 90f4999
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public class ShowPageProducer implements ViewComponentProducer, DefaultView, Nav
private ToolManager toolManager;
public TextInputEvolver richTextEvolver;
private static LessonBuilderAccessService lessonBuilderAccessService;
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.DEFAULT, DateFormat.DEFAULT, new ResourceLoader().getLocale());;

private List<Long> printedSubpages;

Expand Down Expand Up @@ -4008,15 +4009,7 @@ protected boolean makeLink(UIContainer container, String ID, SimplePageItem i, S
ID = ID + "-fake";
String linkText = i.getName();
if (i.getType() == SimplePageItem.ASSIGNMENT) {
SecurityAdvisor yesMan = (String arg0, String arg1, String agr2) -> SecurityAdvisor.SecurityAdvice.ALLOWED;
securityService.pushAdvisor(yesMan);
try {
AssignmentEntity assignment = (AssignmentEntity) assignmentEntity.getEntity(i.getSakaiId(), simplePageBean);
linkText += " " + messageLocator.getMessage("simplepage.assignment.open_date", new Object[] {assignment.getOpenDate()});
} catch (Exception ex) {}
finally {
securityService.popAdvisor(yesMan);
}
linkText = getLinkText(linkText, i.getSakaiId());
}
UIOutput link = UIOutput.make(container, ID, linkText);
link.decorate(new UIFreeAttributeDecorator("lessonbuilderitem", itemString));
Expand Down Expand Up @@ -4045,7 +4038,11 @@ protected boolean makeLink(UIContainer container, String ID, SimplePageItem i, S
link.decorate(new UITooltipDecorator(messageLocator.getMessage("simplepage.complete_required")));
}
} else {
UIOutput.make(container, ID + "-text", i.getName());
String linkText = i.getName();
if (i.getType() == SimplePageItem.ASSIGNMENT) {
linkText = getLinkText(linkText, i.getSakaiId());
}
UIOutput.make(container, ID + "-text", linkText);
}

if (note != null) {
Expand All @@ -4055,6 +4052,22 @@ protected boolean makeLink(UIContainer container, String ID, SimplePageItem i, S
return available;
}


private String getLinkText(String linkText, String sakaiId ) {
//Create a link with open and due dates for assignments links in Lessons
SecurityAdvisor yesMan = (String arg0, String arg1, String agr2) -> SecurityAdvisor.SecurityAdvice.ALLOWED;
securityService.pushAdvisor(yesMan);
try {
AssignmentEntity assignment = (AssignmentEntity) assignmentEntity.getEntity(sakaiId, simplePageBean);
linkText += " " + messageLocator.getMessage("simplepage.assignment.open_close_date",
new Object[] {df.format(assignment.getOpenDate()), df.format(assignment.getDueDate())});
} catch (Exception ex) {}
finally {
securityService.popAdvisor(yesMan);
}
return linkText;
}

private static String getUserDisplayName(String owner) {
String userDisplayName = StringUtils.EMPTY;
try {
Expand Down
2 changes: 1 addition & 1 deletion lessonbuilder/tool/src/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ simplepage.error=Error
simplepage.error_colon=Error:
simplepage.complete_required=Please complete all of the above required items before viewing this item.
simplepage.not_usable=Item is not yet available
simplepage.assignment.open_date=[Open on: {0}]
simplepage.assignment.open_close_date=[Open on: {0}] [Close on: {1}]
simplepage.prerequisites_tag=Has prerequisites

simplepage.editpermissions=Set permissions for
Expand Down

0 comments on commit 90f4999

Please sign in to comment.