Index: lams_central/src/java/org/lamsfoundation/lams/web/outcome/OutcomeController.java =================================================================== diff -u -ra9f95a26e562a58b55c99f2c18e253c151ef457a -r95a88e5e56253d7007ebf634b6969cb353d7cf1e --- lams_central/src/java/org/lamsfoundation/lams/web/outcome/OutcomeController.java (.../OutcomeController.java) (revision a9f95a26e562a58b55c99f2c18e253c151ef457a) +++ lams_central/src/java/org/lamsfoundation/lams/web/outcome/OutcomeController.java (.../OutcomeController.java) (revision 95a88e5e56253d7007ebf634b6969cb353d7cf1e) @@ -55,6 +55,7 @@ import org.lamsfoundation.lams.util.MessageService; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.util.excel.ExcelCell; +import org.lamsfoundation.lams.util.excel.ExcelSheet; import org.lamsfoundation.lams.util.excel.ExcelUtil; import org.lamsfoundation.lams.web.session.SessionManager; import org.lamsfoundation.lams.web.util.AttributeNames; @@ -403,7 +404,7 @@ UserDTO user = getUserDTO(); securityService.isSysadmin(user.getUserID(), "export outcomes", true); - LinkedHashMap dataToExport = outcomeService.exportOutcomes(); + List sheets = outcomeService.exportOutcomes(); String fileName = "lams_outcomes.xls"; fileName = FileUtil.encodeFilenameForDownload(request, fileName); @@ -419,7 +420,7 @@ // Code to generate file and write file contents to response ServletOutputStream out = response.getOutputStream(); - ExcelUtil.createExcelXLS(out, dataToExport, messageService.getMessage("outcome.export.date"), true); + ExcelUtil.createExcel(out, sheets, messageService.getMessage("outcome.export.date"), true, false); } @RequestMapping("/outcomeImport") @@ -576,7 +577,7 @@ UserDTO user = getUserDTO(); securityService.isSysadmin(user.getUserID(), "export outcome scales", true); - LinkedHashMap dataToExport = outcomeService.exportScales(); + List sheets = outcomeService.exportScales(); String fileName = "lams_outcome_scales.xls"; fileName = FileUtil.encodeFilenameForDownload(request, fileName); @@ -592,7 +593,7 @@ // Code to generate file and write file contents to response ServletOutputStream out = response.getOutputStream(); - ExcelUtil.createExcelXLS(out, dataToExport, messageService.getMessage("outcome.export.date"), true); + ExcelUtil.createExcel(out, sheets, messageService.getMessage("outcome.export.date"), true, false); } @RequestMapping("/scaleImport") Index: lams_common/src/java/org/lamsfoundation/lams/outcome/service/IOutcomeService.java =================================================================== diff -u -ra9f95a26e562a58b55c99f2c18e253c151ef457a -r95a88e5e56253d7007ebf634b6969cb353d7cf1e --- lams_common/src/java/org/lamsfoundation/lams/outcome/service/IOutcomeService.java (.../IOutcomeService.java) (revision a9f95a26e562a58b55c99f2c18e253c151ef457a) +++ lams_common/src/java/org/lamsfoundation/lams/outcome/service/IOutcomeService.java (.../IOutcomeService.java) (revision 95a88e5e56253d7007ebf634b6969cb353d7cf1e) @@ -1,14 +1,13 @@ package org.lamsfoundation.lams.outcome.service; import java.io.IOException; -import java.util.LinkedHashMap; import java.util.List; import org.lamsfoundation.lams.outcome.Outcome; import org.lamsfoundation.lams.outcome.OutcomeMapping; import org.lamsfoundation.lams.outcome.OutcomeResult; import org.lamsfoundation.lams.outcome.OutcomeScale; -import org.lamsfoundation.lams.util.excel.ExcelCell; +import org.lamsfoundation.lams.util.excel.ExcelSheet; import org.springframework.web.multipart.MultipartFile; public interface IOutcomeService { @@ -41,9 +40,9 @@ Integer sourceQbQuestionId, Long targetLessonId, Long targetToolContentId, Long targetItemId, Integer targetQbQuestionId); - LinkedHashMap exportScales(); + List exportScales(); - LinkedHashMap exportOutcomes(); + List exportOutcomes(); int importScales(MultipartFile fileItem) throws IOException; Index: lams_common/src/java/org/lamsfoundation/lams/outcome/service/OutcomeService.java =================================================================== diff -u -ra9f95a26e562a58b55c99f2c18e253c151ef457a -r95a88e5e56253d7007ebf634b6969cb353d7cf1e --- lams_common/src/java/org/lamsfoundation/lams/outcome/service/OutcomeService.java (.../OutcomeService.java) (revision a9f95a26e562a58b55c99f2c18e253c151ef457a) +++ lams_common/src/java/org/lamsfoundation/lams/outcome/service/OutcomeService.java (.../OutcomeService.java) (revision 95a88e5e56253d7007ebf634b6969cb353d7cf1e) @@ -1,337 +1,332 @@ -package org.lamsfoundation.lams.outcome.service; - -import java.io.IOException; -import java.util.Collections; -import java.util.Comparator; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import javax.servlet.http.HttpSession; - -import org.apache.log4j.Logger; -import org.apache.poi.hssf.usermodel.HSSFCell; -import org.apache.poi.hssf.usermodel.HSSFRow; -import org.apache.poi.hssf.usermodel.HSSFSheet; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.poifs.filesystem.POIFSFileSystem; -import org.lamsfoundation.lams.outcome.Outcome; -import org.lamsfoundation.lams.outcome.OutcomeMapping; -import org.lamsfoundation.lams.outcome.OutcomeResult; -import org.lamsfoundation.lams.outcome.OutcomeScale; -import org.lamsfoundation.lams.outcome.OutcomeScaleItem; -import org.lamsfoundation.lams.outcome.dao.IOutcomeDAO; -import org.lamsfoundation.lams.usermanagement.User; -import org.lamsfoundation.lams.usermanagement.dto.UserDTO; -import org.lamsfoundation.lams.util.MessageService; -import org.lamsfoundation.lams.util.excel.ExcelCell; -import org.lamsfoundation.lams.web.session.SessionManager; -import org.lamsfoundation.lams.web.util.AttributeNames; -import org.springframework.web.multipart.MultipartFile; - -public class OutcomeService implements IOutcomeService { - private IOutcomeDAO outcomeDAO; - private MessageService messageService; - - private static Logger log = Logger.getLogger(OutcomeService.class); - - @Override - public List getOutcomes() { - return outcomeDAO.getOutcomesSortedByName(); +package org.lamsfoundation.lams.outcome.service; + +import java.io.IOException; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import javax.servlet.http.HttpSession; + +import org.apache.log4j.Logger; +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.poifs.filesystem.POIFSFileSystem; +import org.lamsfoundation.lams.outcome.Outcome; +import org.lamsfoundation.lams.outcome.OutcomeMapping; +import org.lamsfoundation.lams.outcome.OutcomeResult; +import org.lamsfoundation.lams.outcome.OutcomeScale; +import org.lamsfoundation.lams.outcome.OutcomeScaleItem; +import org.lamsfoundation.lams.outcome.dao.IOutcomeDAO; +import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.util.MessageService; +import org.lamsfoundation.lams.util.excel.ExcelCell; +import org.lamsfoundation.lams.util.excel.ExcelRow; +import org.lamsfoundation.lams.util.excel.ExcelSheet; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.web.multipart.MultipartFile; + +public class OutcomeService implements IOutcomeService { + private IOutcomeDAO outcomeDAO; + private MessageService messageService; + + private static Logger log = Logger.getLogger(OutcomeService.class); + + @Override + public List getOutcomes() { + return outcomeDAO.getOutcomesSortedByName(); + } + + @Override + public List getScales() { + return outcomeDAO.getScalesSortedByName(); + } + + @Override + public List getOutcomes(String search) { + return outcomeDAO.getOutcomesSortedByName(search); + } + + @Override + public List getOutcomeMappings(Long lessonId, Long toolContentId, Long itemId, + Integer qbQuestionId) { + return outcomeDAO.getOutcomeMappings(lessonId, toolContentId, itemId, qbQuestionId); + } + + @Override + public long countOutcomeMappings(Long outcomeId) { + Map properties = new HashMap<>(); + properties.put("outcome.outcomeId", outcomeId); + return outcomeDAO.countByProperties(OutcomeMapping.class, properties); + } + + @Override + public long countScaleUse(Long scaleId) { + Map properties = new HashMap<>(); + properties.put("scale.scaleId", scaleId); + return outcomeDAO.countByProperties(Outcome.class, properties); + } + + @Override + public List getOutcomeResults(Integer userId, Long lessonId, Long toolContentId, Long itemId) { + return outcomeDAO.getOutcomeResults(userId, lessonId, toolContentId, itemId); + } + + @Override + public OutcomeResult getOutcomeResult(Integer userId, Long mappingId) { + return outcomeDAO.getOutcomeResult(userId, mappingId); + } + + @Override + public OutcomeScale getDefaultScale() { + return outcomeDAO.find(OutcomeScale.class, DEFAULT_SCALE_ID); + } + + @Override + public boolean isDefaultScale(Long scaleId) { + return scaleId != null && DEFAULT_SCALE_ID == scaleId; + } + + @Override + public void copyOutcomeMappings(Long sourceLessonId, Long sourceToolContentId, Long sourceItemId, + Integer sourceQbQuestionId, Long targetLessonId, Long targetToolContentId, Long targetItemId, + Integer targetQbQuestionId) { + List sourceMappings = getOutcomeMappings(sourceLessonId, sourceToolContentId, sourceItemId, + sourceQbQuestionId); + for (OutcomeMapping sourceMapping : sourceMappings) { + OutcomeMapping targetMapping = new OutcomeMapping(); + targetMapping.setOutcome(sourceMapping.getOutcome()); + targetMapping.setLessonId(targetLessonId); + targetMapping.setToolContentId(targetToolContentId); + targetMapping.setItemId(targetItemId); + targetMapping.setQbQuestionId(targetQbQuestionId); + outcomeDAO.insert(targetMapping); + } + } + + @Override + public List exportScales() { + List sheets = new LinkedList(); + ExcelSheet scalesSheet = new ExcelSheet(messageService.getMessage("scale.title")); + sheets.add(scalesSheet); + + ExcelRow headerRow = scalesSheet.initRow(); + headerRow.addCell(messageService.getMessage("outcome.manage.add.name"), true); + headerRow.addCell(messageService.getMessage("outcome.manage.add.code"), true); + headerRow.addCell(messageService.getMessage("outcome.manage.add.description"), true); + headerRow.addCell(messageService.getMessage("scale.manage.add.value"), true); + + List scales = getScales(); + for (OutcomeScale scale : scales) { + ExcelRow scaleRow = scalesSheet.initRow(); + scaleRow.addCell(scale.getName()); + scaleRow.addCell(scale.getCode()); + scaleRow.addCell(scale.getDescription()); + scaleRow.addCell(scale.getItemString()); + } + return sheets; + } + + + @Override + public List exportOutcomes() { + List sheets = new LinkedList(); + ExcelSheet outcomeSheet = new ExcelSheet(messageService.getMessage("index.outcome.manage")); + sheets.add(outcomeSheet); + + // The entire data list + ExcelRow headerRow = outcomeSheet.initRow(); + headerRow.addCell(messageService.getMessage("outcome.manage.add.name"), true); + headerRow.addCell(messageService.getMessage("outcome.manage.add.code"), true); + headerRow.addCell(messageService.getMessage("outcome.manage.add.description"), true); + headerRow.addCell(messageService.getMessage("outcome.manage.add.scale"), true); + + List outcomes = getOutcomes(); + for (Outcome outcome : outcomes) { + ExcelRow outcomeRow = outcomeSheet.initRow(); + outcomeRow.addCell(outcome.getName()); + outcomeRow.addCell(outcome.getCode()); + outcomeRow.addCell(outcome.getDescription()); + outcomeRow.addCell(outcome.getScale().getCode()); + } + + return sheets; + } + + @Override + public int importScales(MultipartFile fileItem) throws IOException { + int counter = 0; + POIFSFileSystem fs = new POIFSFileSystem(fileItem.getInputStream()); + try (HSSFWorkbook wb = new HSSFWorkbook(fs)) { + HSSFSheet sheet = wb.getSheetAt(0); + int startRow = sheet.getFirstRowNum(); + int endRow = sheet.getLastRowNum(); + User user = null; + + // make import work with files with header ("exported on") or without (pure data) + HSSFRow row = sheet.getRow(startRow); + HSSFCell cell = row.getCell(0); + String header = cell.getStringCellValue(); + startRow += "name".equalsIgnoreCase(header) ? 1 : 5; + + for (int i = startRow; i < (endRow + 1); i++) { + row = sheet.getRow(i); + cell = row.getCell(0); + String name = cell.getStringCellValue(); + cell = row.getCell(1); + String code = cell.getStringCellValue(); + List foundScales = outcomeDAO.findByProperty(OutcomeScale.class, "name", name); + foundScales.addAll(outcomeDAO.findByProperty(OutcomeScale.class, "code", code)); + if (!foundScales.isEmpty()) { + if (log.isDebugEnabled()) { + log.debug("Skipping an outcome scale with existing name \"" + name + "\" or code \"" + code + + "\""); + } + continue; + } + + cell = row.getCell(2); + String description = cell == null ? null : cell.getStringCellValue(); + cell = row.getCell(3); + String itemsString = cell.getStringCellValue(); + + OutcomeScale scale = new OutcomeScale(); + scale.setName(name); + scale.setCode(code); + scale.setDescription(description); + if (user == null) { + UserDTO userDTO = OutcomeService.getUserDTO(); + user = outcomeDAO.find(User.class, userDTO.getUserID()); + } + scale.setCreateBy(user); + scale.setCreateDateTime(new Date()); + outcomeDAO.insert(scale); + + List items = OutcomeScale.parseItems(itemsString); + int value = 0; + for (String itemString : items) { + OutcomeScaleItem item = new OutcomeScaleItem(); + item.setName(itemString); + item.setValue(value++); + item.setScale(scale); + outcomeDAO.insert(item); + } + + counter++; + } + } + return counter; + } + + @Override + public int importOutcomes(MultipartFile fileItem) throws IOException { + int counter = 0; + POIFSFileSystem fs = new POIFSFileSystem(fileItem.getInputStream()); + try (HSSFWorkbook wb = new HSSFWorkbook(fs)) { + HSSFSheet sheet = wb.getSheetAt(0); + int startRow = sheet.getFirstRowNum(); + int endRow = sheet.getLastRowNum(); + User user = null; + + // make import work with files with header ("exported on") or without (pure data) + HSSFRow row = sheet.getRow(startRow); + HSSFCell cell = row.getCell(0); + String header = cell.getStringCellValue(); + startRow += "name".equalsIgnoreCase(header) ? 1 : 5; + + for (int i = startRow; i < (endRow + 1); i++) { + row = sheet.getRow(i); + cell = row.getCell(0); + String name = cell.getStringCellValue(); + cell = row.getCell(1); + String code = cell.getStringCellValue(); + List foundOutcomes = outcomeDAO.findByProperty(Outcome.class, "name", name); + foundOutcomes.addAll(outcomeDAO.findByProperty(Outcome.class, "code", code)); + if (!foundOutcomes.isEmpty()) { + if (log.isDebugEnabled()) { + log.debug("Skipping an outcome with existing name \"" + name + "\" or code \"" + code + "\""); + } + continue; + } + cell = row.getCell(3); + String scaleName = cell.getStringCellValue(); + List foundScales = outcomeDAO.findByProperty(OutcomeScale.class, "name", scaleName); + OutcomeScale scale = foundScales.isEmpty() ? null : foundScales.get(0); + if (scale == null) { + if (log.isDebugEnabled()) { + log.debug("Skipping an outcome with missing scale with name: " + scaleName); + } + continue; + } + + cell = row.getCell(2); + String description = cell == null ? null : cell.getStringCellValue(); + + Outcome outcome = new Outcome(); + outcome.setName(name); + outcome.setCode(code); + outcome.setDescription(description); + outcome.setScale(scale); + if (user == null) { + UserDTO userDTO = OutcomeService.getUserDTO(); + user = outcomeDAO.find(User.class, userDTO.getUserID()); + } + outcome.setCreateBy(user); + outcome.setCreateDateTime(new Date()); + outcomeDAO.insert(outcome); + + counter++; + } + } + return counter; + } + + /** + * There can be duplicates in mappings, if one comes from activity and the other comes from a QB question that the + * activity imported. + * We need to get rid of duplicates and sort the remaining mappings. + */ + public static void filterQuestionMappings(List mappings) { + Iterator iterator = mappings.iterator(); + while (iterator.hasNext()) { + OutcomeMapping mapping = iterator.next(); + boolean duplicateFound = false; + for (OutcomeMapping otherMapping : mappings) { + if (!mapping.getMappingId().equals(otherMapping.getMappingId()) + && mapping.getOutcome().getOutcomeId().equals(otherMapping.getOutcome().getOutcomeId())) { + duplicateFound = true; + break; + } + } + // remove the one coming from activity, not one coming from question + if (duplicateFound && mapping.getQbQuestionId() == null) { + iterator.remove(); + } + } + + Collections.sort(mappings, + Comparator.comparing(OutcomeMapping::getOutcome, Comparator.comparing(Outcome::getName))); + } + + private static UserDTO getUserDTO() { + HttpSession ss = SessionManager.getSession(); + return (UserDTO) ss.getAttribute(AttributeNames.USER); + } + + public void setOutcomeDAO(IOutcomeDAO outcomeDAO) { + this.outcomeDAO = outcomeDAO; + } + + public void setMessageService(MessageService messageService) { + this.messageService = messageService; } - - @Override - public List getScales() { - return outcomeDAO.getScalesSortedByName(); - } - - @Override - public List getOutcomes(String search) { - return outcomeDAO.getOutcomesSortedByName(search); - } - - @Override - public List getOutcomeMappings(Long lessonId, Long toolContentId, Long itemId, - Integer qbQuestionId) { - return outcomeDAO.getOutcomeMappings(lessonId, toolContentId, itemId, qbQuestionId); - } - - @Override - public long countOutcomeMappings(Long outcomeId) { - Map properties = new HashMap<>(); - properties.put("outcome.outcomeId", outcomeId); - return outcomeDAO.countByProperties(OutcomeMapping.class, properties); - } - - @Override - public long countScaleUse(Long scaleId) { - Map properties = new HashMap<>(); - properties.put("scale.scaleId", scaleId); - return outcomeDAO.countByProperties(Outcome.class, properties); - } - - @Override - public List getOutcomeResults(Integer userId, Long lessonId, Long toolContentId, Long itemId) { - return outcomeDAO.getOutcomeResults(userId, lessonId, toolContentId, itemId); - } - - @Override - public OutcomeResult getOutcomeResult(Integer userId, Long mappingId) { - return outcomeDAO.getOutcomeResult(userId, mappingId); - } - - @Override - public OutcomeScale getDefaultScale() { - return outcomeDAO.find(OutcomeScale.class, DEFAULT_SCALE_ID); - } - - @Override - public boolean isDefaultScale(Long scaleId) { - return scaleId != null && DEFAULT_SCALE_ID == scaleId; - } - - @Override - public void copyOutcomeMappings(Long sourceLessonId, Long sourceToolContentId, Long sourceItemId, - Integer sourceQbQuestionId, Long targetLessonId, Long targetToolContentId, Long targetItemId, - Integer targetQbQuestionId) { - List sourceMappings = getOutcomeMappings(sourceLessonId, sourceToolContentId, sourceItemId, - sourceQbQuestionId); - for (OutcomeMapping sourceMapping : sourceMappings) { - OutcomeMapping targetMapping = new OutcomeMapping(); - targetMapping.setOutcome(sourceMapping.getOutcome()); - targetMapping.setLessonId(targetLessonId); - targetMapping.setToolContentId(targetToolContentId); - targetMapping.setItemId(targetItemId); - targetMapping.setQbQuestionId(targetQbQuestionId); - outcomeDAO.insert(targetMapping); - } - } - - @Override - public LinkedHashMap exportScales() { - LinkedHashMap dataToExport = new LinkedHashMap<>(); - - // The entire data list - List rowList = new LinkedList<>(); - ExcelCell[] row = new ExcelCell[4]; - row[0] = new ExcelCell(messageService.getMessage("outcome.manage.add.name"), true); - row[1] = new ExcelCell(messageService.getMessage("outcome.manage.add.code"), true); - row[2] = new ExcelCell(messageService.getMessage("outcome.manage.add.description"), true); - row[3] = new ExcelCell(messageService.getMessage("scale.manage.add.value"), true); - rowList.add(row); - - List scales = getScales(); - for (OutcomeScale scale : scales) { - row = new ExcelCell[4]; - row[0] = new ExcelCell(scale.getName(), false); - row[1] = new ExcelCell(scale.getCode(), false); - row[2] = new ExcelCell(scale.getDescription(), false); - row[3] = new ExcelCell(scale.getItemString(), false); - rowList.add(row); - } - - ExcelCell[][] data = rowList.toArray(new ExcelCell[][] {}); - dataToExport.put(messageService.getMessage("scale.title"), data); - return dataToExport; - } - - @Override - public LinkedHashMap exportOutcomes() { - LinkedHashMap dataToExport = new LinkedHashMap<>(); - - // The entire data list - List rowList = new LinkedList<>(); - ExcelCell[] row = new ExcelCell[4]; - row[0] = new ExcelCell(messageService.getMessage("outcome.manage.add.name"), true); - row[1] = new ExcelCell(messageService.getMessage("outcome.manage.add.code"), true); - row[2] = new ExcelCell(messageService.getMessage("outcome.manage.add.description"), true); - row[3] = new ExcelCell(messageService.getMessage("outcome.manage.add.scale"), true); - rowList.add(row); - - List outcomes = getOutcomes(); - for (Outcome outcome : outcomes) { - row = new ExcelCell[4]; - row[0] = new ExcelCell(outcome.getName(), false); - row[1] = new ExcelCell(outcome.getCode(), false); - row[2] = new ExcelCell(outcome.getDescription(), false); - row[3] = new ExcelCell(outcome.getScale().getName(), false); - rowList.add(row); - } - - ExcelCell[][] data = rowList.toArray(new ExcelCell[][] {}); - dataToExport.put(messageService.getMessage("index.outcome.manage"), data); - return dataToExport; - } - - @Override - public int importScales(MultipartFile fileItem) throws IOException { - int counter = 0; - POIFSFileSystem fs = new POIFSFileSystem(fileItem.getInputStream()); - try (HSSFWorkbook wb = new HSSFWorkbook(fs)) { - HSSFSheet sheet = wb.getSheetAt(0); - int startRow = sheet.getFirstRowNum(); - int endRow = sheet.getLastRowNum(); - User user = null; - - // make import work with files with header ("exported on") or without (pure data) - HSSFRow row = sheet.getRow(startRow); - HSSFCell cell = row.getCell(0); - String header = cell.getStringCellValue(); - startRow += "name".equalsIgnoreCase(header) ? 1 : 5; - - for (int i = startRow; i < (endRow + 1); i++) { - row = sheet.getRow(i); - cell = row.getCell(0); - String name = cell.getStringCellValue(); - cell = row.getCell(1); - String code = cell.getStringCellValue(); - List foundScales = outcomeDAO.findByProperty(OutcomeScale.class, "name", name); - foundScales.addAll(outcomeDAO.findByProperty(OutcomeScale.class, "code", code)); - if (!foundScales.isEmpty()) { - if (log.isDebugEnabled()) { - log.debug("Skipping an outcome scale with existing name \"" + name + "\" or code \"" + code - + "\""); - } - continue; - } - - cell = row.getCell(2); - String description = cell == null ? null : cell.getStringCellValue(); - cell = row.getCell(3); - String itemsString = cell.getStringCellValue(); - - OutcomeScale scale = new OutcomeScale(); - scale.setName(name); - scale.setCode(code); - scale.setDescription(description); - if (user == null) { - UserDTO userDTO = OutcomeService.getUserDTO(); - user = outcomeDAO.find(User.class, userDTO.getUserID()); - } - scale.setCreateBy(user); - scale.setCreateDateTime(new Date()); - outcomeDAO.insert(scale); - - List items = OutcomeScale.parseItems(itemsString); - int value = 0; - for (String itemString : items) { - OutcomeScaleItem item = new OutcomeScaleItem(); - item.setName(itemString); - item.setValue(value++); - item.setScale(scale); - outcomeDAO.insert(item); - } - - counter++; - } - } - return counter; - } - - @Override - public int importOutcomes(MultipartFile fileItem) throws IOException { - int counter = 0; - POIFSFileSystem fs = new POIFSFileSystem(fileItem.getInputStream()); - try (HSSFWorkbook wb = new HSSFWorkbook(fs)) { - HSSFSheet sheet = wb.getSheetAt(0); - int startRow = sheet.getFirstRowNum(); - int endRow = sheet.getLastRowNum(); - User user = null; - - // make import work with files with header ("exported on") or without (pure data) - HSSFRow row = sheet.getRow(startRow); - HSSFCell cell = row.getCell(0); - String header = cell.getStringCellValue(); - startRow += "name".equalsIgnoreCase(header) ? 1 : 5; - - for (int i = startRow; i < (endRow + 1); i++) { - row = sheet.getRow(i); - cell = row.getCell(0); - String name = cell.getStringCellValue(); - cell = row.getCell(1); - String code = cell.getStringCellValue(); - List foundOutcomes = outcomeDAO.findByProperty(Outcome.class, "name", name); - foundOutcomes.addAll(outcomeDAO.findByProperty(Outcome.class, "code", code)); - if (!foundOutcomes.isEmpty()) { - if (log.isDebugEnabled()) { - log.debug("Skipping an outcome with existing name \"" + name + "\" or code \"" + code + "\""); - } - continue; - } - cell = row.getCell(3); - String scaleName = cell.getStringCellValue(); - List foundScales = outcomeDAO.findByProperty(OutcomeScale.class, "name", scaleName); - OutcomeScale scale = foundScales.isEmpty() ? null : foundScales.get(0); - if (scale == null) { - if (log.isDebugEnabled()) { - log.debug("Skipping an outcome with missing scale with name: " + scaleName); - } - continue; - } - - cell = row.getCell(2); - String description = cell == null ? null : cell.getStringCellValue(); - - Outcome outcome = new Outcome(); - outcome.setName(name); - outcome.setCode(code); - outcome.setDescription(description); - outcome.setScale(scale); - if (user == null) { - UserDTO userDTO = OutcomeService.getUserDTO(); - user = outcomeDAO.find(User.class, userDTO.getUserID()); - } - outcome.setCreateBy(user); - outcome.setCreateDateTime(new Date()); - outcomeDAO.insert(outcome); - - counter++; - } - } - return counter; - } - - /** - * There can be duplicates in mappings, if one comes from activity and the other comes from a QB question that the - * activity imported. - * We need to get rid of duplicates and sort the remaining mappings. - */ - public static void filterQuestionMappings(List mappings) { - Iterator iterator = mappings.iterator(); - while (iterator.hasNext()) { - OutcomeMapping mapping = iterator.next(); - boolean duplicateFound = false; - for (OutcomeMapping otherMapping : mappings) { - if (!mapping.getMappingId().equals(otherMapping.getMappingId()) - && mapping.getOutcome().getOutcomeId().equals(otherMapping.getOutcome().getOutcomeId())) { - duplicateFound = true; - break; - } - } - // remove the one coming from activity, not one coming from question - if (duplicateFound && mapping.getQbQuestionId() == null) { - iterator.remove(); - } - } - - Collections.sort(mappings, - Comparator.comparing(OutcomeMapping::getOutcome, Comparator.comparing(Outcome::getName))); - } - - private static UserDTO getUserDTO() { - HttpSession ss = SessionManager.getSession(); - return (UserDTO) ss.getAttribute(AttributeNames.USER); - } - - public void setOutcomeDAO(IOutcomeDAO outcomeDAO) { - this.outcomeDAO = outcomeDAO; - } - - public void setMessageService(MessageService messageService) { - this.messageService = messageService; - } } \ No newline at end of file Index: lams_tool_lamc/web/learning/ViewAnswers.jsp =================================================================== diff -u -r1d029587ac6d31024eb5c5536b0f0eb502e8e15c -r95a88e5e56253d7007ebf634b6969cb353d7cf1e --- lams_tool_lamc/web/learning/ViewAnswers.jsp (.../ViewAnswers.jsp) (revision 1d029587ac6d31024eb5c5536b0f0eb502e8e15c) +++ lams_tool_lamc/web/learning/ViewAnswers.jsp (.../ViewAnswers.jsp) (revision 95a88e5e56253d7007ebf634b6969cb353d7cf1e) @@ -197,7 +197,7 @@ -
+
questions; - protected List userResponses; - protected String initialScreen; protected String lockWhenFinished; @@ -104,30 +95,13 @@ protected String userUid; - protected String usernameVisible; - protected String allowRichEditor; protected String useSelectLeaderToolOuput; protected boolean allowRateAnswers; /** - * @return Returns the usernameVisible. - */ - public String getUsernameVisible() { - return usernameVisible; - } - - /** - * @param usernameVisible - * The usernameVisible to set. - */ - public void setUsernameVisible(String usernameVisible) { - this.usernameVisible = usernameVisible; - } - - /** * @return Returns the currentAnswer. */ public String getCurrentAnswer() { @@ -245,22 +219,6 @@ } } - @Override - public String toString() { - return new ToStringBuilder(this).append("remainingQuestionCount: ", remainingQuestionCount) - .append("totalQuestionCount : ", totalQuestionCount) - .append("activityInstructions: ", activityInstructions).append("teacherViewOnly: ", teacherViewOnly) - .append("lockWhenFinished: ", lockWhenFinished).append("activityTitle: ", activityTitle) - .append("countSessionComplete: ", countSessionComplete).append("toolSessionID: ", toolSessionID) - .append("currentQuestionIndex: ", currentQuestionIndex) - .append("questionListingMode: ", questionListingMode) - .append("userNameVisible: ", userNameVisible).append("requestLearningReport: ", requestLearningReport) - .append("requestLearningReportProgress: ", requestLearningReportProgress) - .append("requestLearningReportViewOnly: ", requestLearningReportViewOnly) - .append("mapAnswers: ", mapAnswers).append("mapQuestions: ", mapQuestions) - .append("mapQuestionContentLearner: ", mapQuestionContentLearner).toString(); - } - /** * @param currentQuestionIndex * The currentQuestionIndex to set. @@ -324,15 +282,11 @@ /** * @return Returns the userNameVisible. */ - public String getUserNameVisible() { + public boolean getUserNameVisible() { return userNameVisible; } - /** - * @param userNameVisible - * The userNameVisible to set. - */ - public void setUserNameVisible(String userNameVisible) { + public void setUserNameVisible(boolean userNameVisible) { this.userNameVisible = userNameVisible; } @@ -381,69 +335,17 @@ this.sessionMapID = sessionMapID; } - /** - * @return Returns the requestLearningReport. - */ - public String getRequestLearningReport() { - return requestLearningReport; + public boolean getIsLearnerFinished() { + return isLearnerFinished; } - /** - * @param requestLearningReport - * The requestLearningReport to set. - */ - public void setRequestLearningReport(String requestLearningReport) { - this.requestLearningReport = requestLearningReport; + public void setIsLearnerFinished(boolean isLearnerFinished) { + this.isLearnerFinished = isLearnerFinished; } /** - * @return Returns the requestLearningReportProgress. - */ - public String getRequestLearningReportProgress() { - return requestLearningReportProgress; - } - - /** - * @param requestLearningReportProgress - * The requestLearningReportProgress to set. - */ - public void setRequestLearningReportProgress(String requestLearningReportProgress) { - this.requestLearningReportProgress = requestLearningReportProgress; - } - - /** - * @return Returns the requestLearningReportViewOnly. - */ - public String getRequestLearningReportViewOnly() { - return requestLearningReportViewOnly; - } - - /** - * @param requestLearningReportViewOnly - * The requestLearningReportViewOnly to set. - */ - public void setRequestLearningReportViewOnly(String requestLearningReportViewOnly) { - this.requestLearningReportViewOnly = requestLearningReportViewOnly; - } - - /** * @return Returns the questions. */ - public List getUserResponses() { - return userResponses; - } - - /** - * @param questions - * The questions to set. - */ - public void setUserResponses(List userResponses) { - this.userResponses = userResponses; - } - - /** - * @return Returns the questions. - */ public Set getQuestions() { return questions; } @@ -547,21 +449,6 @@ } /** - * @return Returns the teacherViewOnly. - */ - public String getTeacherViewOnly() { - return teacherViewOnly; - } - - /** - * @param teacherViewOnly - * The teacherViewOnly to set. - */ - public void setTeacherViewOnly(String teacherViewOnly) { - this.teacherViewOnly = teacherViewOnly; - } - - /** * @return Returns the remainingQuestionCount. */ public String getRemainingQuestionCount() { Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/model/QaQueContent.java =================================================================== diff -u -r8a5ba0f4e4ced295600d75bca2fef2ef727d7eb0 -r95a88e5e56253d7007ebf634b6969cb353d7cf1e --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/model/QaQueContent.java (.../QaQueContent.java) (revision 8a5ba0f4e4ced295600d75bca2fef2ef727d7eb0) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/model/QaQueContent.java (.../QaQueContent.java) (revision 95a88e5e56253d7007ebf634b6969cb353d7cf1e) @@ -31,6 +31,7 @@ import javax.persistence.ManyToOne; import javax.persistence.PrimaryKeyJoinColumn; import javax.persistence.Table; +import javax.persistence.Transient; import org.apache.commons.lang.builder.ToStringBuilder; import org.lamsfoundation.lams.qb.model.QbQuestion; @@ -52,6 +53,10 @@ @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "qa_content_id") private QaContent qaContent; + + // *************** NON Persist Fields used in learning ******************** + @Transient + private QaUsrResp userResponse; public QaQueContent() { } @@ -83,4 +88,14 @@ this.qaContent = qaContent; this.toolContentId = qaContent == null ? null : qaContent.getQaContentId(); } -} \ No newline at end of file + + // *************** NON Persist Fields used in monitoring ******************** + + public QaUsrResp getUserResponse() { + return userResponse; + } + + public void setUserResponse(QaUsrResp userResponse) { + this.userResponse = userResponse; + } +} Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/LearningUtil.java =================================================================== diff -u -r86c25c80d92701a94c3161575c76c363891402ad -r95a88e5e56253d7007ebf634b6969cb353d7cf1e --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/LearningUtil.java (.../LearningUtil.java) (revision 86c25c80d92701a94c3161575c76c363891402ad) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/util/LearningUtil.java (.../LearningUtil.java) (revision 95a88e5e56253d7007ebf634b6969cb353d7cf1e) @@ -71,7 +71,7 @@ generalLearnerFlowDTO.setQuestionListingMode(QUESTION_LISTING_MODE_COMBINED); } - generalLearnerFlowDTO.setUserNameVisible(new Boolean(qaContent.isUsernameVisible()).toString()); + generalLearnerFlowDTO.setUserNameVisible(qaContent.isUsernameVisible()); generalLearnerFlowDTO.setShowOtherAnswers(qaContent.isShowOtherAnswers()); generalLearnerFlowDTO.setAllowRichEditor(new Boolean(qaContent.isAllowRichEditor()).toString()); generalLearnerFlowDTO Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/controller/QaLearningController.java =================================================================== diff -u -r02ce40b60524aa33d326fbda824dcd43f566ab94 -r95a88e5e56253d7007ebf634b6969cb353d7cf1e --- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/controller/QaLearningController.java (.../QaLearningController.java) (revision 02ce40b60524aa33d326fbda824dcd43f566ab94) +++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/controller/QaLearningController.java (.../QaLearningController.java) (revision 95a88e5e56253d7007ebf634b6969cb353d7cf1e) @@ -39,7 +39,6 @@ import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; -import org.apache.log4j.Logger; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.rating.dto.ItemRatingCriteriaDTO; @@ -79,7 +78,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.context.WebApplicationContext; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; @@ -91,47 +89,28 @@ @Controller @RequestMapping("/learning") public class QaLearningController implements QaAppConstants { - private static Logger logger = Logger.getLogger(QaLearningController.class.getName()); - @Autowired private IQaService qaService; @Autowired @Qualifier("qaMessageService") private MessageService messageService; - - @Autowired - private WebApplicationContext applicationContext; - + @RequestMapping("/") public String unspecified() throws IOException, ServletException, ToolException { - QaLearningController.logger.warn("dispatching unspecified..."); return null; } @RequestMapping("/learning") public String execute(@ModelAttribute("qaLearningForm") QaLearningForm qaLearningForm, HttpServletRequest request) throws IOException, ServletException { - /* validate learning mode parameters */ - validateParameters(request, qaLearningForm); - String mode = qaLearningForm.getMode(); - String toolSessionID = qaLearningForm.getToolSessionID(); + String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); + qaLearningForm.setToolSessionID(toolSessionID); + String mode = request.getParameter(MODE); + qaLearningForm.setMode(mode); - /* - * By now, the passed tool session id MUST exist in the db by calling: - * public void createToolSession(Long toolSessionId, Long toolContentId) by the core. - * - * make sure this session exists in tool's session table by now. - */ QaSession qaSession = qaService.getSessionById(new Long(toolSessionID).longValue()); - if (qaSession == null) { - throw new ServletException("No session found"); - } - QaContent qaContent = qaSession.getQaContent(); - if (qaContent == null) { - throw new ServletException("No QA content found"); - } QaQueUsr user = null; if ((mode != null) && mode.equals(ToolAccessMode.TEACHER.toString())) { @@ -175,7 +154,7 @@ } /* holds the question contents for a given tool session and relevant content */ - Map mapQuestionStrings = new TreeMap(new QaComparator()); + Map mapQuestionStrings = new TreeMap<>(new QaComparator()); Map mapQuestions = new TreeMap<>(); String sessionMapID = qaLearningForm.getSessionMapID(); @@ -234,9 +213,9 @@ /* * fetch question content from content */ - Iterator contentIterator = qaContent.getQaQueContents().iterator(); + Iterator contentIterator = qaContent.getQaQueContents().iterator(); while (contentIterator.hasNext()) { - QaQueContent qaQuestion = (QaQueContent) contentIterator.next(); + QaQueContent qaQuestion = contentIterator.next(); if (qaQuestion != null) { int displayOrder = qaQuestion.getDisplayOrder(); @@ -247,15 +226,14 @@ QaQuestionDTO questionDTO = new QaQuestionDTO(qaQuestion); mapQuestions.put(displayOrder, questionDTO); - mapQuestionStrings.put(new Integer(displayOrder).toString(), qaQuestion.getQbQuestion().getName()); - + mapQuestionStrings.put(String.valueOf(displayOrder), qaQuestion.getQbQuestion().getName()); } } } generalLearnerFlowDTO.setMapQuestions(mapQuestionStrings); generalLearnerFlowDTO.setMapQuestionContentLearner(mapQuestions); - generalLearnerFlowDTO.setTotalQuestionCount(new Integer(mapQuestions.size())); - qaLearningForm.setTotalQuestionCount(new Integer(mapQuestions.size()).toString()); + generalLearnerFlowDTO.setTotalQuestionCount(mapQuestions.size()); + qaLearningForm.setTotalQuestionCount(String.valueOf(mapQuestions.size())); String feedBackType = ""; if (qaContent.isQuestionsSequenced()) { @@ -267,25 +245,18 @@ generalLearnerFlowDTO.setUserFeedback(userFeedback); generalLearnerFlowDTO.setRemainingQuestionCount(generalLearnerFlowDTO.getTotalQuestionCount().toString()); - generalLearnerFlowDTO.setInitialScreen(new Boolean(true).toString()); + generalLearnerFlowDTO.setInitialScreen(Boolean.TRUE.toString()); request.setAttribute(GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); /* - * by now, we know that the mode is either teacher or learner - * check if the mode is teacher and request is for Learner Progress + * check if the mode is teacher */ if (mode.equals("teacher")) { - //start generating learner progress report for toolSessionID - /* * the report should have the all entries for the users in this tool session, * and display under the "my answers" section the answers for the user id in the url */ -// Long learnerProgressUserId = WebUtil.readLongParam(request, AttributeNames.PARAM_USER_ID, false); - generalLearnerFlowDTO.setRequestLearningReport(new Boolean(true).toString()); - generalLearnerFlowDTO.setRequestLearningReportProgress(new Boolean(true).toString()); - generalLearnerFlowDTO.setTeacherViewOnly(new Boolean(true).toString()); QaLearningController.refreshSummaryData(request, qaContent, qaSession, qaService, sessionMapId, user, generalLearnerFlowDTO); @@ -319,20 +290,14 @@ * the report should have all the users' entries OR the report should have only the current * session's entries */ - generalLearnerFlowDTO.setRequestLearningReport(new Boolean(true).toString()); - + QaLearningController.refreshSummaryData(request, qaContent, qaSession, qaService, sessionMapId, user, generalLearnerFlowDTO); - if (user.isLearnerFinished()) { - generalLearnerFlowDTO.setRequestLearningReportViewOnly(new Boolean(true).toString()); - return "learning/RevisitedLearnerRep"; - } else { - generalLearnerFlowDTO.setRequestLearningReportViewOnly(new Boolean(false).toString()); - return "learning/LearnerRep"; - } + generalLearnerFlowDTO.setIsLearnerFinished(user.isLearnerFinished()); + return "learning/learnerRep"; - // show submissionDeadline page otherwise + // show submissionDeadline page otherwise } else { return "learning/submissionDeadline"; } @@ -351,7 +316,6 @@ * if the 'All Responses' has been clicked no more user entry is accepted, and isResponseFinalized() returns * true */ - Long currentToolSessionID = new Long(qaLearningForm.getToolSessionID()); //if Response is Finalized if (user.isResponseFinalized()) { @@ -360,28 +324,22 @@ if (checkSession != null) { Long checkQaSessionId = checkSession.getQaSessionId(); - if (checkQaSessionId.toString().equals(currentToolSessionID.toString())) { + if (checkQaSessionId.toString().equals(toolSessionID)) { // the learner is in the same session and has already responsed to this content - generalLearnerFlowDTO.setLockWhenFinished(new Boolean(qaContent.isLockWhenFinished()).toString()); + generalLearnerFlowDTO.setLockWhenFinished(String.valueOf(qaContent.isLockWhenFinished())); generalLearnerFlowDTO.setNoReeditAllowed(qaContent.isNoReeditAllowed()); /* * the report should have all the users' entries OR the report should have only the current * session's entries */ - generalLearnerFlowDTO.setRequestLearningReport(new Boolean(true).toString()); QaLearningController.refreshSummaryData(request, qaContent, qaSession, qaService, sessionMapId, user, generalLearnerFlowDTO); - if (user.isLearnerFinished()) { - generalLearnerFlowDTO.setRequestLearningReportViewOnly(new Boolean(true).toString()); - return "learning/RevisitedLearnerRep"; - } else { - generalLearnerFlowDTO.setRequestLearningReportViewOnly(new Boolean(false).toString()); - return "learning/LearnerRep"; - } + generalLearnerFlowDTO.setIsLearnerFinished(user.isLearnerFinished()); + return "learning/LearnerRep"; } } } @@ -392,45 +350,6 @@ return "learning/AnswersContent"; } - /** - * validates the learning mode parameters - */ - protected void validateParameters(HttpServletRequest request, - @ModelAttribute("qaLearningForm") QaLearningForm qaLearningForm) { - /* - * process incoming tool session id and later derive toolContentId from it. - */ - String strToolSessionId = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); - long toolSessionId = 0; - if ((strToolSessionId == null) || (strToolSessionId.length() == 0)) { - MultiValueMap errorMap = new LinkedMultiValueMap<>(); - errorMap.add("GLOBAL", messageService.getMessage("error.toolSessionId.required")); - logger.error("error.toolSessionId.required"); - request.setAttribute("errorMap", errorMap); - return; - } else { - try { - toolSessionId = new Long(strToolSessionId).longValue(); - qaLearningForm.setToolSessionID(new Long(toolSessionId).toString()); - } catch (NumberFormatException e) { - logger.error("add error.sessionId.numberFormatException to ActionMessages."); - return; - } - } - - /* mode can be learner, teacher or author */ - String mode = request.getParameter(MODE); - if ((mode == null) || (mode.length() == 0)) { - logger.error("Mode is empty"); - return; - } - if ((!mode.equals("learner")) && (!mode.equals("teacher")) && (!mode.equals("author"))) { - logger.error("Wrong mode"); - return; - } - qaLearningForm.setMode(mode); - } - private QaQueUsr getSpecifiedUser(String toolSessionId, Integer userId) { QaQueUsr qaUser = qaService.getUserByIdAndSession(userId.longValue(), new Long(toolSessionId)); if (qaUser == null) { @@ -552,7 +471,6 @@ @RequestMapping(value = "/checkLeaderProgress") @ResponseBody public String checkLeaderProgress(HttpServletRequest request, HttpServletResponse response) throws IOException { - Long toolSessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID); QaSession session = qaService.getSessionById(toolSessionId); @@ -567,7 +485,7 @@ } /** - * auto saves responses + * Auto saves responses. */ @RequestMapping("/autoSaveAnswers") @ResponseStatus(HttpStatus.OK) @@ -586,7 +504,6 @@ int intTotalQuestionCount = qaContent.getQaQueContents().size(); if (!qaContent.isQuestionsSequenced()) { - for (int questionIndex = QaAppConstants.INITIAL_QUESTION_COUNT .intValue(); questionIndex <= intTotalQuestionCount; questionIndex++) { String newAnswer = request.getParameter("answer" + questionIndex); @@ -613,7 +530,6 @@ @RequestMapping("/redoQuestions") public String redoQuestions(@ModelAttribute("qaLearningForm") QaLearningForm qaLearningForm, HttpServletRequest request) throws IOException, ServletException { - LearningUtil.saveFormRequestData(request, qaLearningForm); String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); @@ -662,7 +578,6 @@ @RequestMapping("/storeAllResults") public String storeAllResults(@ModelAttribute("qaLearningForm") QaLearningForm qaLearningForm, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { - LearningUtil.saveFormRequestData(request, qaLearningForm); String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID); @@ -682,8 +597,6 @@ QaLearningController.refreshSummaryData(request, qaContent, qaSession, qaService, sessionMapID, user, generalLearnerFlowDTO); - generalLearnerFlowDTO.setRequestLearningReport(new Boolean(true).toString()); - generalLearnerFlowDTO.setRequestLearningReportProgress(new Boolean(false).toString()); generalLearnerFlowDTO.setReflection(new Boolean(qaContent.isReflect()).toString()); boolean lockWhenFinished = qaContent.isLockWhenFinished(); @@ -698,7 +611,7 @@ generalLearnerFlowDTO.setUserUid(user.getQueUsrId().toString()); boolean usernameVisible = qaContent.isUsernameVisible(); - generalLearnerFlowDTO.setUserNameVisible(new Boolean(usernameVisible).toString()); + generalLearnerFlowDTO.setUserNameVisible(usernameVisible); NotebookEntry notebookEntry = qaService.getEntry(new Long(toolSessionID), CoreNotebookConstants.NOTEBOOK_TOOL, QaAppConstants.MY_SIGNATURE, new Integer(userID)); @@ -756,11 +669,8 @@ QaLearningController.refreshSummaryData(request, qaContent, qaSession, qaService, sessionMapID, user, generalLearnerFlowDTO); - generalLearnerFlowDTO.setRequestLearningReport(new Boolean(true).toString()); - generalLearnerFlowDTO.setRequestLearningReportProgress(new Boolean(false).toString()); - generalLearnerFlowDTO.setReflection(new Boolean(qaContent.isReflect()).toString()); - // generalLearnerFlowDTO.setNotebookEntriesVisible(new Boolean(false).toString()); + // generalLearnerFlowDTO.setNotebookEntriesVisible(Boolean.FALSE.toString()); boolean lockWhenFinished; boolean noReeditAllowed; @@ -784,7 +694,7 @@ generalLearnerFlowDTO.setUserUid(qaQueUsr.getQueUsrId().toString()); boolean usernameVisible = qaContent.isUsernameVisible(); - generalLearnerFlowDTO.setUserNameVisible(new Boolean(usernameVisible).toString()); + generalLearnerFlowDTO.setUserNameVisible(usernameVisible); request.setAttribute(QaAppConstants.GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); @@ -826,7 +736,6 @@ } GeneralLearnerFlowDTO generalLearnerFlowDTO = LearningUtil.buildGeneralLearnerFlowDTO(qaService, qaContent); - storeSequentialAnswer(qaLearningForm, request, generalLearnerFlowDTO, true); request.setAttribute("learningForm", qaLearningForm); @@ -1102,7 +1011,6 @@ } request.setAttribute(QaAppConstants.GENERAL_LEARNER_FLOW_DTO, generalLearnerFlowDTO); - return "learning/Notebook"; } @@ -1114,13 +1022,10 @@ */ public static void refreshSummaryData(HttpServletRequest request, QaContent qaContent, QaSession qaSession, IQaService qaService, String sessionMapID, QaQueUsr user, GeneralLearnerFlowDTO generalLearnerFlowDTO) { - SessionMap sessionMap = (SessionMap) request.getSession() .getAttribute(sessionMapID); Long userId = user.getQueUsrId(); - Set questions = qaContent.getQaQueContents(); - generalLearnerFlowDTO.setQuestions(questions); - generalLearnerFlowDTO.setUserNameVisible(new Boolean(qaContent.isUsernameVisible()).toString()); + generalLearnerFlowDTO.setUserNameVisible(qaContent.isUsernameVisible()); // potentially empty list if the user starts the lesson after the time restriction has expired. List userResponses = qaService.getResponsesByUserUid(user.getUid()); @@ -1175,15 +1080,23 @@ countRatedQuestions = qaService.getCountItemsRatedByUser(qaContent.getQaContentId(), userId.intValue()); } } + + Set questions = qaContent.getQaQueContents(); + generalLearnerFlowDTO.setQuestions(questions); + //find according QaQueContent, if any + for (QaQueContent question : questions) { + for (QaUsrResp userResponse : userResponses) { + if (question.getUid().equals(userResponse.getQaQuestion().getUid())) { + question.setUserResponse(userResponse); + break; + } + } + } request.setAttribute(TOOL_SESSION_ID, qaSession.getQaSessionId()); - sessionMap.put("commentsMinWordsLimit", commentsMinWordsLimit); sessionMap.put("isCommentsEnabled", isCommentsEnabled); sessionMap.put(AttributeNames.ATTR_COUNT_RATED_ITEMS, countRatedQuestions); - - generalLearnerFlowDTO.setUserResponses(userResponses); - generalLearnerFlowDTO.setRequestLearningReportProgress(new Boolean(true).toString()); } /** Index: lams_tool_laqa/web/learning/LearnerRep.jsp =================================================================== diff -u -rf0997a08e6b5eeae233351103cfe619432f88016 -r95a88e5e56253d7007ebf634b6969cb353d7cf1e --- lams_tool_laqa/web/learning/LearnerRep.jsp (.../LearnerRep.jsp) (revision f0997a08e6b5eeae233351103cfe619432f88016) +++ lams_tool_laqa/web/learning/LearnerRep.jsp (.../LearnerRep.jsp) (revision 95a88e5e56253d7007ebf634b6969cb353d7cf1e) @@ -20,8 +20,33 @@ - + + - @@ -98,7 +122,7 @@ rows += ''; rows += ''; - if (${generalLearnerFlowDTO.userNameVisible == 'true'}) { + if (${generalLearnerFlowDTO.userNameVisible}) { rows += definePortraitMiniHeader(userData["portraitId"], userData["userID"], '${lams}', userData["userName"], '', false, "sbox-heading bg-warning") @@ -202,7 +226,7 @@ //show comments textarea and a submit button } else if (! (IS_DISABLED || usesRatings && MAX_RATES>0 && countRatedItems >= MAX_RATES && !hasStartedRating)) { rows += '
'; - rows += ''; + rows += ''; rows += '
'; rows += '
'; @@ -256,11 +280,16 @@ - + + + + + + - + @@ -303,178 +332,187 @@ - -

- -

- - -
+ +
- ${status.count}.  + ${status.count}.  +
- +
- +
-
- - - - - -
-
-
-
- -
+ <%--User own responses---------------------------------------%> + + +
+ + + + + +
+
+
+
+ +
+
+
+ +
-
- -
- + +
+

+ +

+ +
+
- <%--Rating area---------------------------------------%> - -
-

- -

- -
+
+ + + + + + + : ${sessionMap.commentsMinWordsLimit} + + -
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+
+
+
+ +
+
+
+ +
+
+ +
+ + + + +
+
+
+
+
- - - -

- -

- - -

- ${status.count}.  -

- - - - - : ${sessionMap.commentsMinWordsLimit} - - + + +
+ + + + + + - - + + - - - - - - - - - - - + + + + +
- - - - - - - - - - -
- - - - - - - - - - - - - -
-
-
- - - - Index: lams_tool_laqa/web/monitoring/MonitoringMaincontent.jsp =================================================================== diff -u -r86c25c80d92701a94c3161575c76c363891402ad -r95a88e5e56253d7007ebf634b6969cb353d7cf1e --- lams_tool_laqa/web/monitoring/MonitoringMaincontent.jsp (.../MonitoringMaincontent.jsp) (revision 86c25c80d92701a94c3161575c76c363891402ad) +++ lams_tool_laqa/web/monitoring/MonitoringMaincontent.jsp (.../MonitoringMaincontent.jsp) (revision 95a88e5e56253d7007ebf634b6969cb353d7cf1e) @@ -1,16 +1,11 @@ - <%@ include file="/common/taglibs.jsp"%> <%@ page import="org.lamsfoundation.lams.tool.qa.QaAppConstants"%> - - - - - - + + @@ -40,6 +35,9 @@ a.image-link { border-bottom: none !important; } + .tablesorter.table>tbody>tr>td { + vertical-align:top; + }