Index: lams_build/lib/lams/lams.jar =================================================================== diff -u -rdc7b67e7677c8cd2289130c67094a62b39177d05 -rcc5ac6445941cdeeb5fd2440621630496e9f81e1 Binary files differ Index: lams_common/src/java/org/lamsfoundation/lams/util/ExcelCell.java =================================================================== diff -u -r83a30f7dc5023b6e9402166abcfd293a650edf08 -rcc5ac6445941cdeeb5fd2440621630496e9f81e1 --- lams_common/src/java/org/lamsfoundation/lams/util/ExcelCell.java (.../ExcelCell.java) (revision 83a30f7dc5023b6e9402166abcfd293a650edf08) +++ lams_common/src/java/org/lamsfoundation/lams/util/ExcelCell.java (.../ExcelCell.java) (revision cc5ac6445941cdeeb5fd2440621630496e9f81e1) @@ -23,13 +23,16 @@ /* $Id$ */ package org.lamsfoundation.lams.util; +import org.apache.poi.ss.usermodel.IndexedColors; + /** * Bean object holding necessary data for excel export. */ public class ExcelCell { private Object cellValue; private Boolean isBold; + private IndexedColors color; public ExcelCell() { } @@ -38,6 +41,18 @@ this.cellValue = cellValue; this.isBold = isBold; } + + public ExcelCell(Object cellValue, IndexedColors color) { + this.cellValue = cellValue; + this.isBold = false; + this.color = color; + } + + public ExcelCell(Object cellValue, Boolean isBold, IndexedColors color) { + this.cellValue = cellValue; + this.isBold = isBold; + this.color = color; + } public Object getCellValue() { return cellValue; @@ -47,11 +62,19 @@ this.cellValue = cellValue; } - public Boolean getIsBold() { + public Boolean isBold() { return isBold; } public void setIsBold(Boolean isBold) { this.isBold = isBold; } + + public IndexedColors getColor() { + return color; + } + + public void setColor(IndexedColors color) { + this.color = color; + } } Index: lams_common/src/java/org/lamsfoundation/lams/util/ExcelUtil.java =================================================================== diff -u -r83a30f7dc5023b6e9402166abcfd293a650edf08 -rcc5ac6445941cdeeb5fd2440621630496e9f81e1 --- lams_common/src/java/org/lamsfoundation/lams/util/ExcelUtil.java (.../ExcelUtil.java) (revision 83a30f7dc5023b6e9402166abcfd293a650edf08) +++ lams_common/src/java/org/lamsfoundation/lams/util/ExcelUtil.java (.../ExcelUtil.java) (revision cc5ac6445941cdeeb5fd2440621630496e9f81e1) @@ -33,6 +33,7 @@ import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.Font; +import org.apache.poi.ss.usermodel.IndexedColors; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; @@ -44,6 +45,11 @@ public class ExcelUtil { private static CellStyle boldStyle; + + private static CellStyle greenColor; + private static CellStyle blueColor; + private static CellStyle redColor; + private static CellStyle yellowColor; /** * Create .xlsx file out of provided data and then write out it to an OutputStream. @@ -64,11 +70,26 @@ String dateHeader, boolean displaySheetTitle) throws IOException { Workbook workbook = new SXSSFWorkbook(100); // keep 100 rows in memory, exceeding rows will be flushed to disk + //create bold style boldStyle = workbook.createCellStyle(); Font font = workbook.createFont(); font.setBoldweight(Font.BOLDWEIGHT_BOLD); boldStyle.setFont(font); - + + //create color style + blueColor = workbook.createCellStyle(); + blueColor.setFillForegroundColor(IndexedColors.LIGHT_CORNFLOWER_BLUE.getIndex()); + blueColor.setFillPattern(CellStyle.SOLID_FOREGROUND); + redColor = workbook.createCellStyle(); + redColor.setFillForegroundColor(IndexedColors.RED.getIndex()); + redColor.setFillPattern(CellStyle.SOLID_FOREGROUND); + greenColor = workbook.createCellStyle(); + greenColor.setFillForegroundColor(IndexedColors.LIME.getIndex()); + greenColor.setFillPattern(CellStyle.SOLID_FOREGROUND); + yellowColor = workbook.createCellStyle(); + yellowColor.setFillForegroundColor(IndexedColors.GOLD.getIndex()); + yellowColor.setFillPattern(CellStyle.SOLID_FOREGROUND); + int i = 0; for (String sheetName : dataToExport.keySet()) { if (dataToExport.get(sheetName) != null) { @@ -129,13 +150,34 @@ cell.setCellValue((Double) excelCell.getCellValue()); } else if (excelCell.getCellValue() != null && excelCell.getCellValue() instanceof java.lang.Long) { cell.setCellValue(((Long) excelCell.getCellValue()).doubleValue()); + } else if (excelCell.getCellValue() != null && excelCell.getCellValue() instanceof java.lang.Integer) { + cell.setCellValue(((Integer) excelCell.getCellValue()).doubleValue()); } else if (excelCell.getCellValue() != null) { cell.setCellValue(excelCell.getCellValue().toString()); } - if (excelCell.getIsBold()) { + if (excelCell.isBold()) { cell.setCellStyle(boldStyle); } + + if (excelCell.getColor() != null) { + switch (excelCell.getColor()) { + case BLUE: + cell.setCellStyle(blueColor); + break; + case GREEN: + cell.setCellStyle(greenColor); + break; + case RED: + cell.setCellStyle(redColor); + break; + case YELLOW: + cell.setCellStyle(yellowColor); + break; + default: + break; + } + } } } Index: lams_tool_scratchie/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -re06bc8308908f6437459add365b322ffb4244aed -rcc5ac6445941cdeeb5fd2440621630496e9f81e1 --- lams_tool_scratchie/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision e06bc8308908f6437459add365b322ffb4244aed) +++ lams_tool_scratchie/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision cc5ac6445941cdeeb5fd2440621630496e9f81e1) @@ -170,3 +170,10 @@ label.authoring.advanced.show.results.page =Use leader selection tool results. label.waiting.for.leader =Please, wait while somebody will become a group leader. label.users.from.group =Other users participating in current group: +label.total =Total +label.report.by.team.tra =Report by Team TRA +label.table.below.shows.which.answer.teams.selected.first.try =The table below shows which answer the teams selected on the first try +label.denotes.correct.answer =*- Denotes the correct answer +label.legend =Legend +label.median =Median +label.avg.mean =Ave. Mean Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/ScratchieAnswerVisitDAO.java =================================================================== diff -u -rced85c0d8b00a9c225ba5eabd8dd1cf3e01e0fa3 -rcc5ac6445941cdeeb5fd2440621630496e9f81e1 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/ScratchieAnswerVisitDAO.java (.../ScratchieAnswerVisitDAO.java) (revision ced85c0d8b00a9c225ba5eabd8dd1cf3e01e0fa3) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/ScratchieAnswerVisitDAO.java (.../ScratchieAnswerVisitDAO.java) (revision cc5ac6445941cdeeb5fd2440621630496e9f81e1) @@ -25,6 +25,7 @@ import java.util.List; +import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAnswer; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAnswerVisitLog; public interface ScratchieAnswerVisitDAO extends DAO { @@ -38,5 +39,7 @@ List getLogsByScratchieUserAndItem(Long userUid, Long itemUid); List getLogsByScratchieUser(Long userUid); + + ScratchieAnswer getFirstScratchedAnswerByUserAndItem(Long userUid, Long itemUid); } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieAnswerVisitDAOHibernate.java =================================================================== diff -u -rced85c0d8b00a9c225ba5eabd8dd1cf3e01e0fa3 -rcc5ac6445941cdeeb5fd2440621630496e9f81e1 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieAnswerVisitDAOHibernate.java (.../ScratchieAnswerVisitDAOHibernate.java) (revision ced85c0d8b00a9c225ba5eabd8dd1cf3e01e0fa3) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieAnswerVisitDAOHibernate.java (.../ScratchieAnswerVisitDAOHibernate.java) (revision cc5ac6445941cdeeb5fd2440621630496e9f81e1) @@ -26,17 +26,21 @@ import java.util.List; import org.lamsfoundation.lams.tool.scratchie.dao.ScratchieAnswerVisitDAO; +import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAnswer; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAnswerVisitLog; public class ScratchieAnswerVisitDAOHibernate extends BaseDAOHibernate implements ScratchieAnswerVisitDAO { private static final String FIND_BY_ANSWER_AND_USER = "from " + ScratchieAnswerVisitLog.class.getName() + " as r where r.user.userId = ? and r.scratchieAnswer.uid=?"; - private static final String FIND_BY_SCRATCHIE_USER_AND_ITEM = "from " + ScratchieAnswerVisitLog.class.getName() + private static final String FIND_BY_USER_AND_ITEM = "from " + ScratchieAnswerVisitLog.class.getName() + " as r where r.user.uid=? and r.scratchieAnswer.scratchieItem.uid = ? order by r.accessDate asc"; - private static final String FIND_BY_SCRATCHIE_USER = "from " + ScratchieAnswerVisitLog.class.getName() + private static final String FIND_FIRST_SCRATCHED_ANSWER_BY_USER_AND_ITEM = "SELECT r.scratchieAnswer from " + ScratchieAnswerVisitLog.class.getName() + + " as r where r.user.uid=? and r.scratchieAnswer.scratchieItem.uid = ? order by r.accessDate asc LIMIT 1;"; + + private static final String FIND_BY_USER = "from " + ScratchieAnswerVisitLog.class.getName() + " as r where r.user.uid=? order by r.accessDate asc"; private static final String FIND_VIEW_COUNT_BY_USER = "select count(*) from " @@ -71,12 +75,20 @@ @Override public List getLogsByScratchieUserAndItem(Long userUid, Long itemUid) { - return getHibernateTemplate().find(FIND_BY_SCRATCHIE_USER_AND_ITEM, new Object[] { userUid, itemUid }); + return getHibernateTemplate().find(FIND_BY_USER_AND_ITEM, new Object[] { userUid, itemUid }); } @Override public List getLogsByScratchieUser(Long userUid) { - return getHibernateTemplate().find(FIND_BY_SCRATCHIE_USER, new Object[] { userUid }); + return getHibernateTemplate().find(FIND_BY_USER, new Object[] { userUid }); } + + @Override + public ScratchieAnswer getFirstScratchedAnswerByUserAndItem(Long userUid, Long itemUid) { + List list = getHibernateTemplate().find(FIND_FIRST_SCRATCHED_ANSWER_BY_USER_AND_ITEM, new Object[] { userUid, itemUid }); + if (list == null || list.size() == 0) + return null; + return (ScratchieAnswer) list.get(0); + } } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieItem.java =================================================================== diff -u -r9465560dcbea622e2f3a01e334400f2005ce2ed3 -rcc5ac6445941cdeeb5fd2440621630496e9f81e1 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieItem.java (.../ScratchieItem.java) (revision 9465560dcbea622e2f3a01e334400f2005ce2ed3) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieItem.java (.../ScratchieItem.java) (revision cc5ac6445941cdeeb5fd2440621630496e9f81e1) @@ -64,6 +64,7 @@ private String correctAnswer; private int userMark; private int userAttempts; + private String firstChoiceAnswerLetter; /** * Default contruction method. @@ -241,4 +242,12 @@ public void setUserAttempts(int userAttempts) { this.userAttempts = userAttempts; } + + public String getFirstChoiceAnswerLetter() { + return firstChoiceAnswerLetter; + } + + public void setFirstChoiceAnswerLetter(String firstChoiceAnswerLetter) { + this.firstChoiceAnswerLetter = firstChoiceAnswerLetter; + } } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java =================================================================== diff -u -rced85c0d8b00a9c225ba5eabd8dd1cf3e01e0fa3 -rcc5ac6445941cdeeb5fd2440621630496e9f81e1 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java (.../ScratchieServiceImpl.java) (revision ced85c0d8b00a9c225ba5eabd8dd1cf3e01e0fa3) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java (.../ScratchieServiceImpl.java) (revision cc5ac6445941cdeeb5fd2440621630496e9f81e1) @@ -28,6 +28,7 @@ import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Date; import java.util.HashMap; @@ -43,6 +44,7 @@ import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; +import org.apache.poi.ss.usermodel.IndexedColors; import org.apache.struts.upload.FormFile; import org.lamsfoundation.lams.contentrepository.AccessDeniedException; import org.lamsfoundation.lams.contentrepository.ICredentials; @@ -876,17 +878,191 @@ Scratchie scratchie = scratchieDao.getByContentId(contentId); Collection items = new TreeSet(new ScratchieItemComparator()); items.addAll(scratchie.getScratchieItems()); + int numberOfItems = items.size(); LinkedHashMap dataToExport = new LinkedHashMap(); + + // ======================================================= For Immediate Analysis page + // ======================================= + List rowList = new LinkedList(); + + ExcelCell[] row = new ExcelCell[1]; + row[0] = new ExcelCell(getMessage("label.quick.analysis"), true); + rowList.add(row); + row = new ExcelCell[2]; + row[1] = new ExcelCell(getMessage("label.in.table.below.we.show"), false); + rowList.add(row); + rowList.add(EMPTY_ROW); + + row = new ExcelCell[3]; + row[2] = new ExcelCell(getMessage("label.questions"), false); + rowList.add(row); + + row = new ExcelCell[numberOfItems + 4]; + int columnCount = 1; + row[columnCount++] = new ExcelCell(getMessage("label.teams"), true); + for (int itemCount = 0; itemCount < numberOfItems; itemCount++) { + row[columnCount++] = new ExcelCell("Q" + (itemCount + 1), true); + } + row[columnCount++] = new ExcelCell(getMessage("label.total"), true); + row[columnCount++] = new ExcelCell(getMessage("label.total") + " %", true); + rowList.add(row); + + int groupCount = 1; + List summaryByTeam = getSummaryByTeam(scratchie, items); + for (GroupSummary summary : summaryByTeam) { + + row = new ExcelCell[numberOfItems + 4]; + columnCount = 1; + row[columnCount++] = new ExcelCell("T" + groupCount++, true); + + int numberOfFirstChoiceEvents = 0; + for (ScratchieItem item : summary.getItems()) { + int attempts = item.getUserAttempts(); + + String isFirstChoice; + IndexedColors color; + if (item.getCorrectAnswer().equals(Boolean.TRUE.toString())) { + isFirstChoice = getMessage("label.correct"); + color = IndexedColors.GREEN; + numberOfFirstChoiceEvents++; + } else if (attempts == 0) { + isFirstChoice = null; + color = null; + } else { + isFirstChoice = getMessage("label.incorrect"); + color = IndexedColors.RED; + } + row[columnCount++] = new ExcelCell(isFirstChoice, color); + } + row[columnCount++] = new ExcelCell(new Integer(numberOfFirstChoiceEvents), false); + int percentage = (numberOfItems == 0) ? 0 : 100*numberOfFirstChoiceEvents/numberOfItems; + row[columnCount++] = new ExcelCell(percentage + "%", false); + rowList.add(row); + } + + ExcelCell[][] firstPageData = rowList.toArray(new ExcelCell[][] {}); + dataToExport.put(getMessage("label.for.immediate.analysis"), firstPageData); + + + // ======================================================= For Report by Team TRA page + // ======================================= + + rowList = new LinkedList(); + + row = new ExcelCell[1]; + row[0] = new ExcelCell(getMessage("label.quick.analysis"), true); + rowList.add(row); + row = new ExcelCell[2]; + row[1] = new ExcelCell(getMessage("label.table.below.shows.which.answer.teams.selected.first.try"), false); + rowList.add(row); + rowList.add(EMPTY_ROW); + + row = new ExcelCell[numberOfItems + 3]; + columnCount = 1; + for (int itemCount = 0; itemCount < numberOfItems; itemCount++) { + row[columnCount++] = new ExcelCell(getMessage("label.authoring.basic.instruction") + " " + (itemCount + 1), false); + } + row[columnCount++] = new ExcelCell(getMessage("label.total"), false); + row[columnCount++] = new ExcelCell(getMessage("label.total") + " %", false); + rowList.add(row); + + row = new ExcelCell[numberOfItems + 1]; + columnCount = 0; + row[columnCount++] = new ExcelCell(getMessage("label.correct.answer"), false); + for (ScratchieItem item : items) { + + // find out the correct answer's sequential letter - A,B,C... + String correctAnswerLetter = ""; + int answerCount = 1; + for (ScratchieAnswer answer : (Set)item.getAnswers()) { + if (answer.isCorrect()) { + correctAnswerLetter = String.valueOf((char)(answerCount + 'A' - 1)); + break; + } + answerCount++; + } + row[columnCount++] = new ExcelCell(correctAnswerLetter, false); + } + rowList.add(row); + + row = new ExcelCell[1]; + row[0] = new ExcelCell(getMessage("monitoring.label.group"), false); + rowList.add(row); + + groupCount = 1; + int[] percentages = new int[summaryByTeam.size()]; + for (GroupSummary summary : summaryByTeam) { + + row = new ExcelCell[numberOfItems + 3]; + columnCount = 0; + row[columnCount++] = new ExcelCell(groupCount, false); + + int numberOfFirstChoiceEvents = 0; + for (ScratchieItem item : summary.getItems()) { + + IndexedColors color = null; + if (item.getCorrectAnswer().equals(Boolean.TRUE.toString())) { + color = IndexedColors.GREEN; + numberOfFirstChoiceEvents++; + } + row[columnCount++] = new ExcelCell(item.getFirstChoiceAnswerLetter(), color); + } + row[columnCount++] = new ExcelCell(new Integer(numberOfFirstChoiceEvents), false); + int percentage = (numberOfItems == 0) ? 0 : 100*numberOfFirstChoiceEvents/numberOfItems; + row[columnCount++] = new ExcelCell(percentage + "%", false); + rowList.add(row); + percentages[groupCount-1] = percentage; + groupCount++; + } + + Arrays.sort(percentages); + + //avg mean + int sum = 0; + for (int i = 0; i < percentages.length; i++) { + sum += percentages[i]; + } + int avgMean = sum / percentages.length; + row = new ExcelCell[numberOfItems + 3]; + row[0] = new ExcelCell(getMessage("label.avg.mean"), false); + row[numberOfItems + 2] = new ExcelCell(avgMean + "%", false); + rowList.add(row); + + // median + int median; + int middle = percentages.length / 2; + if (percentages.length % 2 == 1) { + median = percentages[middle]; + } else { + median = (int) ((percentages[middle - 1] + percentages[middle]) / 2.0); + } + row = new ExcelCell[numberOfItems + 3]; + row[0] = new ExcelCell(getMessage("label.median"), false); + row[numberOfItems + 2] = new ExcelCell(median, false); + rowList.add(row); + + row = new ExcelCell[1]; + row[0] = new ExcelCell(getMessage("label.legend"), false); + rowList.add(row); + + row = new ExcelCell[1]; + row[0] = new ExcelCell(getMessage("label.denotes.correct.answer"), IndexedColors.GREEN); + rowList.add(row); + + ExcelCell[][] secondPageData = rowList.toArray(new ExcelCell[][] {}); + dataToExport.put(getMessage("label.report.by.team.tra"), secondPageData); + + // ======================================================= Research and Analysis page // ======================================= // all rows - List rowList = new LinkedList(); + rowList = new LinkedList(); // Caption - ExcelCell[] row = new ExcelCell[2]; + row = new ExcelCell[2]; row[0] = new ExcelCell(getMessage("label.scratchie.report"), true); rowList.add(row); rowList.add(EMPTY_ROW); @@ -897,26 +1073,25 @@ row[0] = new ExcelCell(getMessage("label.overall.summary.by.team"), true); rowList.add(row); - row = new ExcelCell[items.size() * 3 + 1]; - int columnCount = 1; - for (int itemCount = 0; itemCount < items.size(); itemCount++) { + row = new ExcelCell[numberOfItems * 3 + 1]; + columnCount = 1; + for (int itemCount = 0; itemCount < numberOfItems; itemCount++) { row[columnCount] = new ExcelCell(getMessage("label.for.question", new Object[] { itemCount + 1 }), false); columnCount += 3; } rowList.add(row); - row = new ExcelCell[items.size() * 3 + 1]; + row = new ExcelCell[numberOfItems * 3 + 1]; columnCount = 1; - for (int itemCount = 0; itemCount < items.size(); itemCount++) { - row[columnCount++] = new ExcelCell(getMessage("label.first.choice"), false); - row[columnCount++] = new ExcelCell(getMessage("label.attempts"), false); - row[columnCount++] = new ExcelCell(getMessage("label.mark"), false); + for (int itemCount = 0; itemCount < numberOfItems; itemCount++) { + row[columnCount++] = new ExcelCell(getMessage("label.first.choice"), IndexedColors.BLUE); + row[columnCount++] = new ExcelCell(getMessage("label.attempts"), IndexedColors.BLUE); + row[columnCount++] = new ExcelCell(getMessage("label.mark"), IndexedColors.BLUE); } rowList.add(row); - List summaryByTeam = getSummaryByTeam(scratchie, items); for (GroupSummary summary : summaryByTeam) { - row = new ExcelCell[items.size() * 3 + 1]; + row = new ExcelCell[numberOfItems * 3 + 1]; columnCount = 0; row[columnCount++] = new ExcelCell(summary.getSessionName(), false); @@ -925,15 +1100,19 @@ int attempts = item.getUserAttempts(); String isFirstChoice; + IndexedColors color; if (item.getCorrectAnswer().equals(Boolean.TRUE.toString())) { isFirstChoice = getMessage("label.correct"); + color = IndexedColors.GREEN; } else if (attempts == 0) { isFirstChoice = null; + color = null; } else { isFirstChoice = getMessage("label.incorrect"); + color = IndexedColors.RED; } - row[columnCount++] = new ExcelCell(isFirstChoice, false); - row[columnCount++] = new ExcelCell(new Long(attempts), false); + row[columnCount++] = new ExcelCell(isFirstChoice, color); + row[columnCount++] = new ExcelCell(new Long(attempts), color); Long mark = (item.getUserMark() == -1) ? null : new Long(item.getUserMark()); row[columnCount++] = new ExcelCell(mark, false); } @@ -1002,18 +1181,20 @@ row = new ExcelCell[1 + answers.size()]; for (int i = 0; i < answers.size(); i++) { - row[i + 1] = new ExcelCell((long) i + 1, false); + row[i + 1] = new ExcelCell((long) i + 1, IndexedColors.YELLOW); } rowList.add(row); for (ScratchieAnswer answer : answers) { row = new ExcelCell[1 + answers.size()]; String answerTitle = removeHtmlMarkup(answer.getDescription()); + IndexedColors color = null; if (answer.isCorrect()) { answerTitle += "(" + getMessage("label.monitoring.item.summary.correct") + ")"; + color = IndexedColors.GREEN; } columnCount = 0; - row[columnCount++] = new ExcelCell(answerTitle, false); + row[columnCount++] = new ExcelCell(answerTitle, color); for (int numberAttempts : answer.getAttempts()) { row[columnCount++] = new ExcelCell(new Long(numberAttempts), false); @@ -1117,60 +1298,10 @@ } } - ExcelCell[][] firstPageData = rowList.toArray(new ExcelCell[][] {}); - dataToExport.put(getMessage("label.research.analysis"), firstPageData); + ExcelCell[][] thirdPageData = rowList.toArray(new ExcelCell[][] {}); + dataToExport.put(getMessage("label.research.analysis"), thirdPageData); - // ======================================================= For Immediate Analysis page - // ======================================= - rowList = new LinkedList(); - - row = new ExcelCell[1]; - row[0] = new ExcelCell(getMessage("label.quick.analysis"), true); - rowList.add(row); - row = new ExcelCell[2]; - row[1] = new ExcelCell(getMessage("label.in.table.below.we.show"), false); - rowList.add(row); - rowList.add(EMPTY_ROW); - - row = new ExcelCell[3]; - row[2] = new ExcelCell(getMessage("label.questions"), false); - rowList.add(row); - - row = new ExcelCell[items.size() + 2]; - columnCount = 1; - row[columnCount++] = new ExcelCell(getMessage("label.teams"), true); - for (int itemCount = 0; itemCount < items.size(); itemCount++) { - row[columnCount++] = new ExcelCell("Q" + (itemCount + 1), true); - } - rowList.add(row); - - int groupCount = 1; - for (GroupSummary summary : summaryByTeam) { - - row = new ExcelCell[items.size() + 2]; - columnCount = 1; - row[columnCount++] = new ExcelCell("T" + groupCount++, true); - - for (ScratchieItem item : summary.getItems()) { - int attempts = item.getUserAttempts(); - - String isFirstChoice; - if (item.getCorrectAnswer().equals(Boolean.TRUE.toString())) { - isFirstChoice = getMessage("label.correct"); - } else if (attempts == 0) { - isFirstChoice = null; - } else { - isFirstChoice = getMessage("label.incorrect"); - } - row[columnCount++] = new ExcelCell(isFirstChoice, false); - } - rowList.add(row); - } - - ExcelCell[][] activityData = rowList.toArray(new ExcelCell[][] {}); - dataToExport.put(getMessage("label.for.immediate.analysis"), activityData); - // ======================================================= For_XLS_export(SPSS analysis) page // ======================================= @@ -1298,8 +1429,8 @@ } - ExcelCell[][] userData = rowList.toArray(new ExcelCell[][] {}); - dataToExport.put(getMessage("label.spss.analysis"), userData); + ExcelCell[][] fourthPageData = rowList.toArray(new ExcelCell[][] {}); + dataToExport.put(getMessage("label.spss.analysis"), fourthPageData); return dataToExport; } @@ -1332,28 +1463,46 @@ for (ScratchieItem item : sortedItems) { ScratchieItem newItem = new ScratchieItem(); - int attempts = 0; + int numberOfAttempts = 0; int mark = -1; boolean isFirstChoice = false; + String firstChoiceAnswerLetter = ""; // if there is no group leader don't calculate numbers - they aren't any if (groupLeader != null) { - attempts = scratchieAnswerVisitDao.getLogCountPerItem(sessionId, groupLeader.getUserId(), + numberOfAttempts = scratchieAnswerVisitDao.getLogCountPerItem(sessionId, groupLeader.getUserId(), item.getUid()); // for displaying purposes if there is no attemps we assign -1 which will be shown as "-" - mark = (attempts == 0) ? -1 : getUserMarkPerItem(scratchie, item, sessionId, + mark = (numberOfAttempts == 0) ? -1 : getUserMarkPerItem(scratchie, item, sessionId, groupLeader.getUserId()); - isFirstChoice = (attempts == 1) && isItemUnraveled(item, groupLeader.getUserId(), null); + isFirstChoice = (numberOfAttempts == 1) && isItemUnraveled(item, groupLeader.getUserId(), null); + + if (numberOfAttempts > 0) { + ScratchieAnswer firstChoiceAnswer = scratchieAnswerVisitDao + .getFirstScratchedAnswerByUserAndItem(groupLeader.getUid(), item.getUid()); + + // find out the correct answer's sequential letter - A,B,C... + int answerCount = 1; + for (ScratchieAnswer answer : (Set) item.getAnswers()) { + if (answer.getUid().equals(firstChoiceAnswer.getUid())) { + firstChoiceAnswerLetter = String.valueOf((char) (answerCount + 'A' - 1)); + break; + } + answerCount++; + } + } + } newItem.setUid(item.getUid()); newItem.setTitle(item.getTitle()); newItem.setAnswers(item.getAnswers()); - newItem.setUserAttempts(attempts); + newItem.setUserAttempts(numberOfAttempts); newItem.setUserMark(mark); newItem.setCorrectAnswer("" + isFirstChoice); + newItem.setFirstChoiceAnswerLetter(firstChoiceAnswerLetter); items.add(newItem); } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/AuthoringAction.java =================================================================== diff -u -r1b4e9de10adddb2caa877e7f16bdb6fa620c555a -rcc5ac6445941cdeeb5fd2440621630496e9f81e1 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/AuthoringAction.java (.../AuthoringAction.java) (revision 1b4e9de10adddb2caa877e7f16bdb6fa620c555a) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/AuthoringAction.java (.../AuthoringAction.java) (revision cc5ac6445941cdeeb5fd2440621630496e9f81e1) @@ -896,7 +896,7 @@ int answerIndex = NumberUtils.stringToInt(request.getParameter(ScratchieConstants.PARAM_ANSWER_INDEX), -1); if (answerIndex != -1) { List rList = new ArrayList(answerList); - ScratchieAnswer answer = rList.remove(answerIndex); + rList.remove(answerIndex); answerList.clear(); answerList.addAll(rList); }