add(chapterRepeater);
for (XmlDocument doc : ISIApplication.get().getStudentContent()) { // For each XML Document
for (XmlSection rs : doc.getTocSection().getChildren()) { // For each chapter in the document; tends to be only one.
final ISIXmlSection rootSection = (ISIXmlSection) rs;
WebMarkupContainer rootSectionContainer = new WebMarkupContainer(chapterRepeater.newChildId());
chapterRepeater.add(rootSectionContainer);
rootSectionContainer.add(new Label("title", rs.getTitle()));
rootSectionContainer.add(new Label("subtitle", rootSection.getSubTitle()));
if (rootSection.equals(currentRootSection))
rootSectionContainer.add(new ClassAttributeModifier("open"));
WebMarkupContainer table = new WebMarkupContainer("periodTable");
rootSectionContainer.add(table);
table.add(new Label("periodName", new PropertyModel<String>(ISISession.get().getCurrentPeriodModel(), "name")));
// Add non-section children as Super Section Labels
// TODO: Lame hack for differences between IQWST/FS
// TODO: Have TeacherToc create a custom repeater that can be extended by subclasses?
RepeatingView superSectionRepeater = new RepeatingView("superSectionRepeater");
for (XmlSection rc : rootSection.getChildren()) {
ISIXmlSection rootChild = (ISIXmlSection) rc;
WebMarkupContainer superSectionContainer = new WebMarkupContainer(superSectionRepeater.newChildId());
superSectionRepeater.add(superSectionContainer);
if (rootChild.isSuperSection()) {
superSectionContainer.add(new Label("superSectionTitle", rootChild.getTitle()));
if (rootChild.getChildren().size() > 1) {
superSectionContainer.add(new SimpleAttributeModifier("colspan", String.valueOf(rootChild.getChildren().size())));
}
} else {
superSectionContainer.add(new EmptyPanel("superSectionTitle"));
}
}
table.add(superSectionRepeater);
// List Sections across the top of the table.
table.add(new ListView<ISIXmlSection>("sectionList", rootSection.getSectionChildren()) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<ISIXmlSection> item) {
ISIXmlSection sec = item.getModelObject();
BookmarkablePageLink<ISIStandardPage> link = new SectionLinkFactory().linkToPage("sectionLink", sec);
item.add(link);
link.add(ISIApplication.get().iconFor(sec));
}
});
// List students and their appropriate status messages
// get the list of students in this period
UserCriteriaBuilder c = new UserCriteriaBuilder();
c.setRole(Role.STUDENT);
c.setPeriod(ISISession.get().getCurrentPeriodModel());
// add the students to the table
table.add(new ListView<User>("student", new UserListModel(c)) {
private static final long serialVersionUID = 1L;
// for each student add the following fields
@Override
protected void populateItem(ListItem<User> userItem) {
final User student = userItem.getModelObject();
userItem.add(new StudentFlagPanel("flagPanel", student, mFlagMap.getObject()));
userItem.add(new Label("studentName", student.getSortName()));
// The cells in the table are status indications
userItem.add(new ListView<ISIXmlSection>("statusCell", rootSection.getSectionChildren()) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<ISIXmlSection> sectionItem) {
final ISIXmlSection sec = sectionItem.getModelObject();
Link<ISIXmlSection> link = new Link<ISIXmlSection>("link") {
private static final long serialVersionUID = 1L;
@Override
public void onClick() {
SectionStatus stat = getUserSectionStatus(student, sec);
ISIXmlSection targetSection = new SectionLinkFactory().sectionLinkDest(sec);
Class<? extends ISIStandardPage> pageType = ISIApplication.get().getReadingPageClass();
ISISession.get().setStudentModel(new HibernateObjectModel<User>(student));
PageParameters param = new PageParameters();
// TODO: This first statement is a hack. For some reason, getUnreadStudentMessages()
// is able to be out of sync with FeedbackMessage.isUnread() flag and is displaying
// the wrong icon on the page. See ISIApplication.statusIconFor() as well.
String s = null;
if (stat != null && stat.getUnreadStudentMessages() > 0 && (s = responseService.locationOfFirstUnreadMessage(student, sec)) != null) {
param.put("loc", s);
} else if (stat != null && stat.getCompleted() && !stat.getReviewed()){
ISIXmlSection section = targetSection.getSectionAncestor().firstPageWithResponseGroup();
if (section != null)
param.put("loc", (new ContentLoc(section).getLocation()));
else
throw new IllegalStateException("Section without response areas marked Ready For Review - should automatically be reviewed.");
} else {