public void setQuestionSizeAndTotalScore() { this.questionSize = 0; this.totalScore = 0; int randomPartCount = 0; AuthorBean author = (AuthorBean) ContextUtil.lookupBean("author"); for (int i = 0; i < this.sections.size(); i++) { SectionContentsBean sectionBean = (SectionContentsBean) sections.get(i); ArrayList items = sectionBean.getItemContents(); int itemsInThisSection = 0; if (sectionBean.getSectionAuthorType().equals(SectionDataIfc.RANDOM_DRAW_FROM_QUESTIONPOOL)) { // for random draw parts, add randomPartCount++; itemsInThisSection = sectionBean.getNumberToBeDrawn().intValue(); } else { itemsInThisSection = items.size(); } this.questionSize += itemsInThisSection; for (int j = 0; j < itemsInThisSection; j++) { ItemContentsBean item = (ItemContentsBean) items.get(j); if (item.getItemData().getScore() != null) { this.totalScore += item.getItemData().getScore().doubleValue(); } } } if (randomPartCount > 0) { setHasRandomDrawPart(true); } else { setHasRandomDrawPart(false); } }
private void buildItemContentsMap(DeliveryBean dbean) { HashMap itemContentsMap = new HashMap(); ArrayList partsContents = dbean.getPageContents().getPartsContents(); if (partsContents != null) { Iterator iter = partsContents.iterator(); while (iter.hasNext()) { SectionContentsBean sectionContentsBean = (SectionContentsBean) iter.next(); if (sectionContentsBean != null) { ArrayList itemContents = sectionContentsBean.getItemContents(); Iterator iter2 = itemContents.iterator(); while (iter2.hasNext()) { ItemContentsBean itemContentsBean = (ItemContentsBean) iter2.next(); if (itemContentsBean != null) { List<ItemGradingData> itemGradingDataArray = itemContentsBean.getItemGradingDataArray(); Iterator<ItemGradingData> iter3 = itemGradingDataArray.iterator(); while (iter3.hasNext()) { ItemGradingData itemGradingData = iter3.next(); itemContentsMap.put(itemGradingData.getItemGradingId(), itemContentsBean); } } } } } } dbean.setItemContentsMap(itemContentsMap); }
public ArrayList getSectionSelectList() { ArrayList list = new ArrayList(); ResourceLoader rb = new ResourceLoader("org.sakaiproject.tool.assessment.bundle.AuthorMessages"); AssessmentBean assessbean = (AssessmentBean) ContextUtil.lookupBean("assessmentBean"); List<SectionContentsBean> sectionSet = assessbean.getSections(); Iterator<SectionContentsBean> iter = sectionSet.iterator(); int i = 0; while (iter.hasNext()) { i = i + 1; SectionContentsBean part = iter.next(); SelectItem selection = new SelectItem(); // need to filter out all the random draw parts if (part.getSectionAuthorType().equals(SectionDataIfc.RANDOM_DRAW_FROM_QUESTIONPOOL)) { // skip random draw parts, cannot add items to this part manually } else { if ("".equals(part.getTitle())) { selection.setLabel(rb.getString("p") + " " + i); } else { selection.setLabel( rb.getString("p") + " " + i + " - " + FormattedText.convertFormattedTextToPlaintext(part.getTitle())); } selection.setValue(part.getSectionId()); list.add(selection); } } Collections.reverse(list); // create a new part if there are no non-randomDraw parts available if (list.size() < 1) { i = i + 1; SelectItem temppart = new SelectItem(); temppart.setLabel(rb.getString("p") + " " + i); temppart.setValue( "-1"); // use -1 to indicate this is a temporary part. if the user decides to cancel the // operation, this part will not be created list.add(temppart); } return list; }
public int updateRandomPoolQuestions(String sectionId) { for (int i = 0; i < this.sections.size(); i++) { SectionContentsBean sectionBean = (SectionContentsBean) sections.get(i); if (sectionBean.getSectionId().equals(sectionId)) { AssessmentService assessmentService = new AssessmentService(); int success = assessmentService.updateRandomPoolQuestions(assessmentService.getSection(sectionId)); if (success == AssessmentService.UPDATE_SUCCESS) { // need to update section since it has changed sections.set( i, new SectionContentsBean(assessmentService.getSection(sectionBean.getSectionId()))); } else { return success; } } } return AssessmentService.UPDATE_SUCCESS; }
/** * Returns a generic Map of section options (for use by helpers that won't be in the same class * loader and would thus get class cast issues from using SelectItem) */ public Map getSectionList() { Map items = new Hashtable(); ResourceLoader rb = new ResourceLoader("org.sakaiproject.tool.assessment.bundle.AuthorMessages"); AssessmentBean assessbean = (AssessmentBean) ContextUtil.lookupBean("assessmentBean"); List<SectionContentsBean> sectionSet = assessbean.getSections(); Iterator<SectionContentsBean> iter = sectionSet.iterator(); int i = 0; while (iter.hasNext()) { i = i + 1; SectionContentsBean part = iter.next(); // need to filter out all the random draw parts if (part.getSectionAuthorType().equals(SectionDataIfc.RANDOM_DRAW_FROM_QUESTIONPOOL)) { // skip random draw parts, cannot add items to this part // manually } else { if ("".equals(part.getTitle())) { items.put(rb.getString("p") + " " + i, part.getSectionId()); } else { items.put(rb.getString("p") + " " + i + " - " + part.getTitle(), part.getSectionId()); } } } // create a new part if there are no non-randomDraw parts available if (items.size() < 1) { i = i + 1; items.put(rb.getString("p") + " " + i, "-1"); // use -1 to // indicate this is // a temporary part. // if the user // decides to cancel // the operation, // this part will // not be created } return items; }