mTargetUser = ISISession.get().getTargetUserModel();
teacher = mUser.getObject().getRole().equals(Role.TEACHER);
ISIXmlSection currentPage = mCurrentPage != null ? (ISIXmlSection) mCurrentPage.getObject() : null;
ISIXmlSection currentSection = ((ISIXmlSection) mSection.getObject()); // May be itself
SectionStatus currentSectionStatus = sectionService.getSectionStatus(mTargetUser.getObject(), currentSection);
// Page Number Repeater
RepeatingView pageRepeater = new RepeatingView("pageRepeater");
int pageNumDisplay = ISIApplication.get().getStudentContent().getLabelIndex(ISIXmlSection.SectionType.PAGE, currentSection.firstPage());
for(ISIXmlSection page = currentSection.firstPage(); page != null; page = page.getNext(), pageNumDisplay++) {
WebMarkupContainer pageLinkContainer = new WebMarkupContainer(pageRepeater.newChildId());
pageRepeater.add(pageLinkContainer);
BookmarkablePageLink<ISIStandardPage> link = new SectionLinkFactory().linkToPage("pageLink", page);
pageLinkContainer.add(link);
link.setVisible(ISIApplication.get().isPageNumbersOn());
link.add(new Label("pageNum", String.valueOf(pageNumDisplay)).setRenderBodyOnly(true));
feedbackRequired = false;
Icon envelopImage;
if (page.equals(currentPage)) {
envelopImage = new EnvelopImageWithStatusUpdate("icon", new Model<ISIXmlSection>(page));
link.setEnabled(false);
link.add(new ClassAttributeModifier("current"));
} else {
envelopImage = new EnvelopeImage("icon", new Model<ISIXmlSection>(page));
}
// for teachers add any of the status icons, for students, just add the envelope if appropriate
if (teacher && (currentSectionStatus != null)) {
// if the page has feedback (red envelope) then display the envelope
// otherwise, display the needs review icon or no icon at all
if ((currentSectionStatus.getCompleted() == true) &&
(currentSectionStatus.getReviewed() == false) &&
(!feedbackRequired)) {
Icon icon = new Icon("icon", "img/icons/status_ready.png", "Ready for review");
link.add(icon);
// don't display the status icon if there's no response group on this page
icon.setVisible(page.hasResponseGroup());