Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/ScratchieConstants.java =================================================================== diff -u -r62aaf160878735888d077bf28fac3c1989bb8fbd -r23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/ScratchieConstants.java (.../ScratchieConstants.java) (revision 62aaf160878735888d077bf28fac3c1989bb8fbd) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/ScratchieConstants.java (.../ScratchieConstants.java) (revision 23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75) @@ -30,7 +30,7 @@ public static final int COMPLETED = 1; - public static final int INITIAL_ANSWERS_NUMBER = 4; + public static final int INITIAL_OPTIONS_NUMBER = 4; // for action forward name public static final String SUCCESS = "success"; @@ -54,9 +54,9 @@ public static final String PARAM_ITEM_UID = "itemUid"; - public static final String PARAM_ANSWER_UID = "answerUid"; + public static final String PARAM_OPTION_UID = "optionUid"; - public static final String PARAM_ANSWER_INDEX = "answerIndex"; + public static final String PARAM_OPTION_INDEX = "optionIndex"; public static final String PARAM_NOT_A_NUMBER = "nan"; @@ -83,25 +83,25 @@ public static final String ATTR_ITEM_DESCRIPTION_PREFIX = "itemDescription"; - public static final String ATTR_ANSWER_CORRECT = "answerCorrect"; + public static final String ATTR_OPTION_CORRECT = "optionCorrect"; public static final String ATTR_ITEM_COUNT = "itemCount"; public static final String ATTR_GROUP_USERS = "groupUsers"; - public static final String ATTR_ANSWER_LIST = "answerList"; + public static final String ATTR_OPTION_LIST = "optionList"; - public static final String ATTR_ANSWER_COUNT = "answerCount"; + public static final String ATTR_OPTION_COUNT = "optionCount"; - public static final String ATTR_ANSWER_DESCRIPTION_PREFIX = "answerDescription"; + public static final String ATTR_OPTION_DESCRIPTION_PREFIX = "optionDescription"; - public static final String ATTR_ANSWER_ORDER_ID_PREFIX = "answerOrderId"; + public static final String ATTR_OPTION_ORDER_ID_PREFIX = "optionOrderId"; - public static final String ATTR_ANSWER_UID_PREFIX = "answerUid"; + public static final String ATTR_OPTION_UID_PREFIX = "optionUid"; public static final String ATTR_DELETED_ITEM_LIST = "deleteItemList"; - public static final String ATTR_DELETED_ANSWER_LIST = "deleteAnswerList"; + public static final String ATTR_DELETED_OPTION_LIST = "deleteOptionList"; public static final String ATTR_SCRATCHIE = "scratchie"; @@ -181,7 +181,7 @@ public static final String ATTR_SUBMISSION_DEADLINE_DATESTRING = "submissionDateString"; public static final String ATTR_IS_SUBMISSION_DEADLINE_PASSED = "isSubmissionDeadlinePassed"; - public static final String ATTR_ANSWER_UIDS = "answerUids"; + public static final String ATTR_OPTION_UIDS = "optionUids"; public static final String ATTR_CONFIDENCE_LEVELS_ACTIVITIES = "confidenceLevelsActivities"; Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/ScratchieAnswerVisitDAO.java =================================================================== diff -u -rfba7287887f6dd83d3098100af6320cccf1f3e36 -r23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/ScratchieAnswerVisitDAO.java (.../ScratchieAnswerVisitDAO.java) (revision fba7287887f6dd83d3098100af6320cccf1f3e36) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/ScratchieAnswerVisitDAO.java (.../ScratchieAnswerVisitDAO.java) (revision 23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75) @@ -29,7 +29,7 @@ public interface ScratchieAnswerVisitDAO extends DAO { - ScratchieAnswerVisitLog getLog(Long answerUid, Long itemUid, Long sessionId); + ScratchieAnswerVisitLog getLog(Long optionUid, Long itemUid, Long sessionId); int getLogCountTotal(Long sessionId); Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieAnswerVisitDAOHibernate.java =================================================================== diff -u -reb5312af3f0d7ca64ca3b41988129079c7509427 -r23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieAnswerVisitDAOHibernate.java (.../ScratchieAnswerVisitDAOHibernate.java) (revision eb5312af3f0d7ca64ca3b41988129079c7509427) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieAnswerVisitDAOHibernate.java (.../ScratchieAnswerVisitDAOHibernate.java) (revision 23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75) @@ -33,7 +33,7 @@ @Repository public class ScratchieAnswerVisitDAOHibernate extends LAMSBaseDAO implements ScratchieAnswerVisitDAO { - private static final String FIND_BY_SESSION_AND_ANSWER = "from " + ScratchieAnswerVisitLog.class.getName() + private static final String FIND_BY_SESSION_AND_OPTION = "from " + ScratchieAnswerVisitLog.class.getName() + " as r where r.sessionId = ? and r.qbOption.uid=? and r.qbToolQuestion.uid = ?"; private static final String FIND_BY_SESSION_AND_ITEM = "from " + ScratchieAnswerVisitLog.class.getName() @@ -46,8 +46,8 @@ + ScratchieAnswerVisitLog.class.getName() + " as r where r.sessionId=?"; @Override - public ScratchieAnswerVisitLog getLog(Long answerUid, Long itemUid, Long sessionId) { - List list = doFind(FIND_BY_SESSION_AND_ANSWER, new Object[] { sessionId, itemUid, answerUid }); + public ScratchieAnswerVisitLog getLog(Long optionUid, Long itemUid, Long sessionId) { + List list = doFind(FIND_BY_SESSION_AND_OPTION, new Object[] { sessionId, itemUid, optionUid }); if (list == null || list.size() == 0) { return null; } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dto/GroupSummary.java =================================================================== diff -u -r62aaf160878735888d077bf28fac3c1989bb8fbd -r23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dto/GroupSummary.java (.../GroupSummary.java) (revision 62aaf160878735888d077bf28fac3c1989bb8fbd) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dto/GroupSummary.java (.../GroupSummary.java) (revision 23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75) @@ -25,7 +25,6 @@ import java.util.Collection; -import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAnswer; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieSession; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieUser; @@ -39,7 +38,7 @@ private Collection users; private Collection itemDtos; - private Collection answers; + private Collection optionDtos; public GroupSummary() { } @@ -115,11 +114,11 @@ this.users = users; } - public Collection getAnswers() { - return answers; + public Collection getOptionDtos() { + return optionDtos; } - public void setAnswers(Collection answers) { - this.answers = answers; + public void setOptionDtos(Collection optionDtos) { + this.optionDtos = optionDtos; } } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dto/QbOptionDTO.java =================================================================== diff -u --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dto/QbOptionDTO.java (revision 0) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dto/QbOptionDTO.java (revision 23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75) @@ -0,0 +1,93 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +package org.lamsfoundation.lams.tool.scratchie.dto; + +import java.util.List; + +import org.lamsfoundation.lams.confidencelevel.ConfidenceLevelDTO; +import org.lamsfoundation.lams.qb.model.QbOption; + +/** + * Tool may contain several questions. Which in turn contain options. + * + * @author Andrey Balan + */ +public class QbOptionDTO implements Comparable { + private QbOption qbOption; + + private boolean scratched; + private int attemptOrder; + private int[] attempts; + private List confidenceLevelDtos; + + @Override + public int compareTo(QbOptionDTO o) { + return this.qbOption.compareTo(o.qbOption); + } + + public QbOption getQbOption() { + return qbOption; + } + + public void setQbOption(QbOption qbOption) { + this.qbOption = qbOption; + } + + public void setScratched(boolean complete) { + this.scratched = complete; + } + + public boolean isScratched() { + return scratched; + } + + /** + * @return in which order the student selected it + */ + public int getAttemptOrder() { + return attemptOrder; + } + + public void setAttemptOrder(int attemptOrder) { + this.attemptOrder = attemptOrder; + } + + /** + * Used for item summary page in monitor + */ + public int[] getAttempts() { + return attempts; + } + + public void setAttempts(int[] attempts) { + this.attempts = attempts; + } + + public List getConfidenceLevelDtos() { + return confidenceLevelDtos; + } + + public void setConfidenceLevelDtos(List confidenceLevelDtos) { + this.confidenceLevelDtos = confidenceLevelDtos; + } +} \ No newline at end of file Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dto/ScratchieItemDTO.java =================================================================== diff -u -rfba7287887f6dd83d3098100af6320cccf1f3e36 -r23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dto/ScratchieItemDTO.java (.../ScratchieItemDTO.java) (revision fba7287887f6dd83d3098100af6320cccf1f3e36) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dto/ScratchieItemDTO.java (.../ScratchieItemDTO.java) (revision 23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75) @@ -3,8 +3,6 @@ import java.util.LinkedList; import java.util.List; -import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAnswer; - /** * ScratchieItem's DTO. * @@ -14,18 +12,18 @@ private Long uid; private String title; - private List answers; + private List optionDtos; private boolean unraveledOnFirstAttempt; private int userMark; private int userAttempts; - //sequence of answers selected by user in the form of "X, Y, Z" - private String answersSequence; + //sequence of optionDtos selected by user in the form of "X, Y, Z" + private String optionsSequence; /** * Default contruction method. */ public ScratchieItemDTO() { - answers = new LinkedList<>(); + optionDtos = new LinkedList<>(); } // ********************************************************** @@ -47,12 +45,12 @@ this.title = title; } - public List getAnswers() { - return answers; + public List getOptionDtos() { + return optionDtos; } - public void setAnswers(List answers) { - this.answers = answers; + public void setOptionDtos(List optionDtos) { + this.optionDtos = optionDtos; } public boolean isUnraveledOnFirstAttempt() { @@ -80,17 +78,17 @@ } /** - * @return sequence of answers selected by user in the form of "X, Y, Z" + * @return sequence of optionDtos selected by user in the form of "X, Y, Z" */ - public String getAnswersSequence() { - return answersSequence; + public String getOptionsSequence() { + return optionsSequence; } /** - * @param answersSequence - * sequence of answers selected by user in the form of "X, Y, Z" + * @param optionsSequence + * sequence of optionDtos selected by user in the form of "X, Y, Z" */ - public void setAnswersSequence(String answersSequence) { - this.answersSequence = answersSequence; + public void setOptionsSequence(String optionsSequence) { + this.optionsSequence = optionsSequence; } } Fisheye: Tag 23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75 refers to a dead (removed) revision in file `lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieAnswer.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieItem.java =================================================================== diff -u -r6de3d240b76c900f96a93ab784838f2153fbe7c5 -r23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieItem.java (.../ScratchieItem.java) (revision 6de3d240b76c900f96a93ab784838f2153fbe7c5) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieItem.java (.../ScratchieItem.java) (revision 23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75) @@ -36,9 +36,10 @@ import org.lamsfoundation.lams.qb.model.QbOption; import org.lamsfoundation.lams.qb.model.QbToolQuestion; import org.lamsfoundation.lams.qb.service.IQbService; +import org.lamsfoundation.lams.tool.scratchie.dto.QbOptionDTO; /** - * Tool may contain several questions. Which in turn contain answers. + * Tool may contain several questions. Which in turn contain optionDtos. * * @author Andrey Balan */ @@ -57,7 +58,7 @@ @Transient private String burningQuestion; @Transient - private List answers = null; + private List optionDtos = null; @Transient private int qbQuestionModified = IQbService.QUESTION_MODIFIED_NONE; @@ -77,20 +78,20 @@ return item; } - public List getAnswers() { - if (answers == null) { - answers = new LinkedList<>(); + public List getOptionDtos() { + if (optionDtos == null) { + optionDtos = new LinkedList<>(); for (QbOption option : qbQuestion.getQbOptions()) { - ScratchieAnswer answer = new ScratchieAnswer(); + QbOptionDTO answer = new QbOptionDTO(); answer.setQbOption(option); - answers.add(answer); + optionDtos.add(answer); } } - return answers; + return optionDtos; } - public void setAnswers(List answers) { - this.answers = answers; + public void setOptionDtos(List optionDtos) { + this.optionDtos = optionDtos; } public boolean isUnraveled() { Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/IScratchieService.java =================================================================== diff -u -rfba7287887f6dd83d3098100af6320cccf1f3e36 -r23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/IScratchieService.java (.../IScratchieService.java) (revision fba7287887f6dd83d3098100af6320cccf1f3e36) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/IScratchieService.java (.../IScratchieService.java) (revision 23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75) @@ -220,15 +220,15 @@ void saveOrUpdateScratchieSession(ScratchieSession resSession); /** - * Fills in which order the student selects answers + * Fills in which order the student selects options * * @param items * @param user */ void getScratchesOrder(Collection items, Long toolSessionId); /** - * Fill in scratchieItems with information about whether they were unraveled; and answers with information on their + * Fill in scratchieItems with information about whether they were unraveled; and options with information on their * scratched. * * @param scratchieItemList @@ -254,6 +254,12 @@ */ void recordItemScratched(Long toolSessionId, Long itemUid, Long scratchieItemUid); + /** + * Recalculate mark for leader and sets it to all members of a group + * + * @param sessionId + * @param isPropagateToGradebook + */ void recalculateMarkForSession(Long sessionId, boolean isPropagateToGradebook); /** Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieImportContentVersionFilter.java =================================================================== diff -u -r62aaf160878735888d077bf28fac3c1989bb8fbd -r23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieImportContentVersionFilter.java (.../ScratchieImportContentVersionFilter.java) (revision 62aaf160878735888d077bf28fac3c1989bb8fbd) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieImportContentVersionFilter.java (.../ScratchieImportContentVersionFilter.java) (revision 23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75) @@ -24,8 +24,8 @@ package org.lamsfoundation.lams.tool.scratchie.service; import org.lamsfoundation.lams.learningdesign.service.ToolContentVersionFilter; +import org.lamsfoundation.lams.tool.scratchie.dto.QbOptionDTO; import org.lamsfoundation.lams.tool.scratchie.model.Scratchie; -import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAnswer; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieItem; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieSession; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieUser; @@ -46,7 +46,7 @@ this.removeField(Scratchie.class, "createdBy"); - this.removeField(ScratchieAnswer.class, "scratchieItem"); + this.removeField(QbOptionDTO.class, "scratchieItem"); this.addField(ScratchieSession.class, "mark", "0"); this.addField(ScratchieSession.class, "scratchingFinished", "0"); Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java =================================================================== diff -u -rb1ee7c7d55795c2b920bef41137748a8a95873b6 -r23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java (.../ScratchieServiceImpl.java) (revision b1ee7c7d55795c2b920bef41137748a8a95873b6) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java (.../ScratchieServiceImpl.java) (revision 23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75) @@ -84,10 +84,10 @@ import org.lamsfoundation.lams.tool.scratchie.dto.BurningQuestionItemDTO; import org.lamsfoundation.lams.tool.scratchie.dto.GroupSummary; import org.lamsfoundation.lams.tool.scratchie.dto.LeaderResultsDTO; +import org.lamsfoundation.lams.tool.scratchie.dto.QbOptionDTO; import org.lamsfoundation.lams.tool.scratchie.dto.ReflectDTO; import org.lamsfoundation.lams.tool.scratchie.dto.ScratchieItemDTO; import org.lamsfoundation.lams.tool.scratchie.model.Scratchie; -import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAnswer; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAnswerVisitLog; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieBurningQuestion; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieConfigItem; @@ -287,10 +287,10 @@ //populate Scratchie items with confidence levels for (ScratchieItem item : items) { - //init answers' confidenceLevelDtos list - for (ScratchieAnswer answer : item.getAnswers()) { + //init options' confidenceLevelDtos list + for (QbOptionDTO optionDto : item.getOptionDtos()) { LinkedList confidenceLevelDtosTemp = new LinkedList<>(); - answer.setConfidenceLevelDtos(confidenceLevelDtosTemp); + optionDto.setConfidenceLevelDtos(confidenceLevelDtosTemp); } //Assessment (similar with Scratchie) adds '\n' at the end of question, MCQ - '\r\n' @@ -301,11 +301,11 @@ for (ConfidenceLevelDTO confidenceLevelDto : confidenceLevelDtos) { if (question.equals(confidenceLevelDto.getQuestion().replaceAll("(\\r|\\n)", ""))) { - //find according answer - for (ScratchieAnswer answer : item.getAnswers()) { - String answerText = answer.getQbOption().getName().replaceAll("(\\r|\\n)", ""); - if (answerText.equals(confidenceLevelDto.getAnswer().replaceAll("(\\r|\\n)", ""))) { - answer.getConfidenceLevelDtos().add(confidenceLevelDto); + //find according option + for (QbOptionDTO option : item.getOptionDtos()) { + String optionText = option.getQbOption().getName().replaceAll("(\\r|\\n)", ""); + if (optionText.equals(confidenceLevelDto.getAnswer().replaceAll("(\\r|\\n)", ""))) { + option.getConfidenceLevelDtos().add(confidenceLevelDto); } } @@ -437,16 +437,16 @@ } @Override - public void recordItemScratched(Long sessionId, Long itemUid, Long answerUid) { - QbOption answer = this.getQbOptionByUid(answerUid); - if (answer == null) { + public void recordItemScratched(Long sessionId, Long itemUid, Long optionUid) { + QbOption option = this.getQbOptionByUid(optionUid); + if (option == null) { return; } - ScratchieAnswerVisitLog log = scratchieAnswerVisitDao.getLog(answerUid, itemUid, sessionId); + ScratchieAnswerVisitLog log = scratchieAnswerVisitDao.getLog(optionUid, itemUid, sessionId); if (log == null) { log = new ScratchieAnswerVisitLog(); - log.setQbOption(answer); + log.setQbOption(option); log.setSessionId(sessionId); QbToolQuestion qbToolQuestion = (QbToolQuestion) scratchieDao.find(QbToolQuestion.class, itemUid); log.setQbToolQuestion(qbToolQuestion); @@ -457,12 +457,6 @@ this.recalculateMarkForSession(sessionId, false); } - /** - * Recalculate mark for leader and sets it to all members of a group - * - * @param leader - * @param answerUid - */ @Override public void recalculateMarkForSession(Long sessionId, boolean isPropagateToGradebook) { List userLogs = scratchieAnswerVisitDao.getLogsBySession(sessionId); @@ -512,14 +506,14 @@ } // options are different - List oldAnswers = oldItem.getQbQuestion().getQbOptions(); - List newAnswers = newItem.getQbQuestion().getQbOptions(); - for (QbOption oldAnswer : oldAnswers) { - for (QbOption newAnswer : newAnswers) { - if (oldAnswer.getUid().equals(newAnswer.getUid())) { + List oldOptions = oldItem.getQbQuestion().getQbOptions(); + List newOptions = newItem.getQbQuestion().getQbOptions(); + for (QbOption oldOption : oldOptions) { + for (QbOption newOption : newOptions) { + if (oldOption.getUid().equals(newOption.getUid())) { - if (!StringUtils.equals(oldAnswer.getName(), newAnswer.getName()) - || (oldAnswer.isCorrect() != newAnswer.isCorrect())) { + if (!StringUtils.equals(oldOption.getName(), newOption.getName()) + || (oldOption.isCorrect() != newOption.isCorrect())) { isItemModified = true; } } @@ -712,10 +706,10 @@ List itemLogs = scratchieAnswerVisitDao.getLogsBySessionAndItem(sessionId, item.getUid()); - for (ScratchieAnswer answer : item.getAnswers()) { + for (QbOptionDTO optionDto : item.getOptionDtos()) { int attemptNumber; - ScratchieAnswerVisitLog log = scratchieAnswerVisitDao.getLog(answer.getQbOption().getUid(), + ScratchieAnswerVisitLog log = scratchieAnswerVisitDao.getLog(optionDto.getQbOption().getUid(), item.getUid(), sessionId); if (log == null) { // -1 if there is no log @@ -725,7 +719,7 @@ attemptNumber = itemLogs.indexOf(log) + 1; } - answer.setAttemptOrder(attemptNumber); + optionDto.setAttemptOrder(attemptNumber); } } } @@ -747,21 +741,21 @@ for (ScratchieItem item : items) { - for (ScratchieAnswer answer : item.getAnswers()) { + for (QbOptionDTO optionDto : item.getOptionDtos()) { // find according log if it exists ScratchieAnswerVisitLog log = null; for (ScratchieAnswerVisitLog userLog : userLogs) { - if (userLog.getQbOption().getUid().equals(answer.getQbOption().getUid()) + if (userLog.getQbOption().getUid().equals(optionDto.getQbOption().getUid()) && userLog.getQbToolQuestion().getUid().equals(item.getUid())) { log = userLog; break; } } if (log == null) { - answer.setScratched(false); + optionDto.setScratched(false); } else { - answer.setScratched(true); + optionDto.setScratched(true); } } @@ -784,18 +778,18 @@ private boolean isItemUnraveled(ScratchieItem item, List userLogs) { boolean isItemUnraveled = false; - for (QbOption answer : item.getQbQuestion().getQbOptions()) { + for (QbOption option : item.getQbQuestion().getQbOptions()) { ScratchieAnswerVisitLog log = null; for (ScratchieAnswerVisitLog userLog : userLogs) { - if (userLog.getQbOption().getUid().equals(answer.getUid())) { + if (userLog.getQbOption().getUid().equals(option.getUid())) { log = userLog; break; } } if (log != null) { - isItemUnraveled |= answer.isCorrect(); + isItemUnraveled |= option.isCorrect(); } } @@ -854,23 +848,23 @@ List groupSummaryList = new ArrayList<>(); ScratchieItem item = scratchieItemDao.getByUid(itemUid); - List answers = item.getQbQuestion().getQbOptions(); + List options = item.getQbQuestion().getQbOptions(); List sessionList = scratchieSessionDao.getByContentId(contentId); for (ScratchieSession session : sessionList) { Long sessionId = session.getSessionId(); // one new summary for one session. GroupSummary groupSummary = new GroupSummary(session); - Map answerMap = new HashMap<>(); - for (QbOption dbAnswer : answers) { + Map optionMap = new HashMap<>(); + for (QbOption dbOption : options) { // clone it so it doesn't interfere with values from other sessions - ScratchieAnswer answer = new ScratchieAnswer(); - answer.setQbOption(dbAnswer); - int[] attempts = new int[answers.size()]; - answer.setAttempts(attempts); - answerMap.put(dbAnswer.getUid(), answer); + QbOptionDTO optionDto = new QbOptionDTO(); + optionDto.setQbOption(dbOption); + int[] attempts = new int[options.size()]; + optionDto.setAttempts(attempts); + optionMap.put(dbOption.getUid(), optionDto); } List sessionAttempts = scratchieAnswerVisitDao.getLogsBySessionAndItem(sessionId, itemUid); @@ -882,16 +876,16 @@ int attemptNumber = 0; for (ScratchieAnswerVisitLog attempt : sessionAttempts) { - ScratchieAnswer answer = answerMap.get(attempt.getQbOption().getUid()); - int[] attempts = answer.getAttempts(); + QbOptionDTO optionDto = optionMap.get(attempt.getQbOption().getUid()); + int[] attempts = optionDto.getAttempts(); // +1 for corresponding choice attempts[attemptNumber++]++; } } - Collection sortedAnswers = new LinkedList<>(); - sortedAnswers.addAll(answerMap.values()); - groupSummary.setAnswers(sortedAnswers); + Collection sortedOptions = new LinkedList<>(); + sortedOptions.addAll(optionMap.values()); + groupSummary.setOptionDtos(sortedOptions); groupSummaryList.add(groupSummary); } @@ -902,33 +896,33 @@ groupSummaryTotal.setSessionName("Summary"); groupSummaryTotal.setMark(0); - Map answerMapTotal = new HashMap<>(); - for (QbOption dbAnswer : answers) { + Map optionMapTotal = new HashMap<>(); + for (QbOption dbOption : options) { // clone it so it doesn't interfere with values from other sessions - ScratchieAnswer answer = new ScratchieAnswer(); - answer.setQbOption(dbAnswer); - int[] attempts = new int[answers.size()]; - answer.setAttempts(attempts); - answerMapTotal.put(dbAnswer.getUid(), answer); + QbOptionDTO optionDto = new QbOptionDTO(); + optionDto.setQbOption(dbOption); + int[] attempts = new int[options.size()]; + optionDto.setAttempts(attempts); + optionMapTotal.put(dbOption.getUid(), optionDto); } for (GroupSummary groupSummary : groupSummaryList) { - Collection sortedAnswers = groupSummary.getAnswers(); - for (ScratchieAnswer sortedAnswer : sortedAnswers) { - int[] attempts = sortedAnswer.getAttempts(); + Collection sortedOptionDtos = groupSummary.getOptionDtos(); + for (QbOptionDTO sortedOptionDto : sortedOptionDtos) { + int[] attempts = sortedOptionDto.getAttempts(); - ScratchieAnswer answerTotal = answerMapTotal.get(sortedAnswer.getQbOption().getUid()); - int[] attemptsTotal = answerTotal.getAttempts(); + QbOptionDTO optionTotal = optionMapTotal.get(sortedOptionDto.getQbOption().getUid()); + int[] attemptsTotal = optionTotal.getAttempts(); for (int i = 0; i < attempts.length; i++) { attemptsTotal[i] += attempts[i]; } } } - Collection sortedAnswers = new TreeSet<>(); - sortedAnswers.addAll(answerMapTotal.values()); - groupSummaryTotal.setAnswers(sortedAnswers); + Collection sortedOptions = new TreeSet<>(); + sortedOptions.addAll(optionMapTotal.values()); + groupSummaryTotal.setOptionDtos(sortedOptions); groupSummaryList.add(0, groupSummaryTotal); } @@ -1177,16 +1171,16 @@ for (ScratchieItem item : items) { // find out the correct answer's sequential letter - A,B,C... - String correctAnswerLetter = ""; - int answerCount = 1; - for (ScratchieAnswer answer : item.getAnswers()) { - if (answer.getQbOption().isCorrect()) { - correctAnswerLetter = String.valueOf((char) ((answerCount + 'A') - 1)); + String correctOptionLetter = ""; + int optionCount = 1; + for (QbOptionDTO optionDto : item.getOptionDtos()) { + if (optionDto.getQbOption().isCorrect()) { + correctOptionLetter = String.valueOf((char) ((optionCount + 'A') - 1)); break; } - answerCount++; + optionCount++; } - row[columnCount++] = new ExcelCell(correctAnswerLetter, false); + row[columnCount++] = new ExcelCell(correctOptionLetter, false); } rowList.add(row); @@ -1210,7 +1204,7 @@ color = IndexedColors.GREEN; numberOfFirstChoiceEvents++; } - row[columnCount++] = new ExcelCell(itemDto.getAnswersSequence(), color); + row[columnCount++] = new ExcelCell(itemDto.getOptionsSequence(), color); } row[columnCount++] = new ExcelCell(new Integer(numberOfFirstChoiceEvents), false); int percentage = (numberOfItems == 0) ? 0 : (100 * numberOfFirstChoiceEvents) / numberOfItems; @@ -1381,26 +1375,26 @@ rowList.add(row); GroupSummary allTeamSummary = itemSummary.get(0); - Collection answers = allTeamSummary.getAnswers(); + Collection optionDtos = allTeamSummary.getOptionDtos(); - row = new ExcelCell[1 + answers.size()]; - for (int i = 0; i < answers.size(); i++) { + row = new ExcelCell[1 + optionDtos.size()]; + for (int i = 0; i < optionDtos.size(); i++) { 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.getQbOption().getName()); + for (QbOptionDTO optionDto : optionDtos) { + row = new ExcelCell[1 + optionDtos.size()]; + String optionTitle = removeHtmlMarkup(optionDto.getQbOption().getName()); IndexedColors color = null; - if (answer.getQbOption().isCorrect()) { - answerTitle += "(" + getMessage("label.monitoring.item.summary.correct") + ")"; + if (optionDto.getQbOption().isCorrect()) { + optionTitle += "(" + getMessage("label.monitoring.item.summary.correct") + ")"; color = IndexedColors.GREEN; } columnCount = 0; - row[columnCount++] = new ExcelCell(answerTitle, color); + row[columnCount++] = new ExcelCell(optionTitle, color); - for (int numberAttempts : answer.getAttempts()) { + for (int numberAttempts : optionDto.getAttempts()) { row[columnCount++] = new ExcelCell(new Long(numberAttempts), false); } rowList.add(row); @@ -1417,28 +1411,28 @@ continue; } - Collection answers = groupSummary.getAnswers(); + Collection optionDtos = groupSummary.getOptionDtos(); row = new ExcelCell[1]; row[0] = new ExcelCell(groupSummary.getSessionName(), true); rowList.add(row); - row = new ExcelCell[1 + answers.size()]; - for (int i = 0; i < answers.size(); i++) { + row = new ExcelCell[1 + optionDtos.size()]; + for (int i = 0; i < optionDtos.size(); i++) { row[i + 1] = new ExcelCell(new Long(i + 1), false); } rowList.add(row); - for (ScratchieAnswer answer : answers) { - row = new ExcelCell[1 + answers.size()]; - String answerTitle = removeHtmlMarkup(answer.getQbOption().getName()); - if (answer.getQbOption().isCorrect()) { - answerTitle += "(" + getMessage("label.monitoring.item.summary.correct") + ")"; + for (QbOptionDTO optionDto : optionDtos) { + row = new ExcelCell[1 + optionDtos.size()]; + String optionTitle = removeHtmlMarkup(optionDto.getQbOption().getName()); + if (optionDto.getQbOption().isCorrect()) { + optionTitle += "(" + getMessage("label.monitoring.item.summary.correct") + ")"; } columnCount = 0; - row[columnCount++] = new ExcelCell(answerTitle, false); + row[columnCount++] = new ExcelCell(optionTitle, false); - for (int numberAttempts : answer.getAttempts()) { + for (int numberAttempts : optionDto.getAttempts()) { row[columnCount++] = new ExcelCell(new Long(numberAttempts), false); } rowList.add(row); @@ -1491,8 +1485,8 @@ for (ScratchieAnswerVisitLog log : logs) { row = new ExcelCell[4]; row[0] = new ExcelCell(new Long(i++), false); - String answerDescr = removeHtmlMarkup(log.getQbOption().getName()); - row[1] = new ExcelCell(answerDescr, false); + String optionDescr = removeHtmlMarkup(log.getQbOption().getName()); + row[1] = new ExcelCell(optionDescr, false); row[3] = new ExcelCell(fullDateFormat.format(log.getAccessDate()), false); rowList.add(row); } @@ -1512,14 +1506,14 @@ // Table header------------------------------------ - int maxAnswers = 0; + int maxOptions = 0; for (ScratchieItem item : items) { - if (item.getAnswers().size() > maxAnswers) { - maxAnswers = item.getAnswers().size(); + if (item.getOptionDtos().size() > maxOptions) { + maxOptions = item.getOptionDtos().size(); } } - row = new ExcelCell[10 + (maxAnswers * 2)]; + row = new ExcelCell[10 + (maxOptions * 2)]; columnCount = 0; row[columnCount++] = new ExcelCell(getMessage("label.student.name"), true); row[columnCount++] = new ExcelCell(getMessage("label.student.username"), true); @@ -1530,11 +1524,11 @@ row[columnCount++] = new ExcelCell(getMessage("label.first.choice.accuracy"), true); row[columnCount++] = new ExcelCell(getMessage("label.number.of.attempts"), true); row[columnCount++] = new ExcelCell(getMessage("label.mark.awarded"), true); - for (int i = 0; i < maxAnswers; i++) { + for (int i = 0; i < maxOptions; i++) { row[columnCount++] = new ExcelCell(getMessage("label." + (i + 1) + ".answer.selected"), true); } row[columnCount++] = new ExcelCell(getMessage("label.date"), true); - for (int i = 0; i < maxAnswers; i++) { + for (int i = 0; i < maxOptions; i++) { row[columnCount++] = new ExcelCell(getMessage("label.time.of.selection." + (i + 1)), true); } rowList.add(row); @@ -1550,7 +1544,7 @@ int questionCount = 1; for (ScratchieItemDTO itemDto : summary.getItemDtos()) { - row = new ExcelCell[10 + (maxAnswers * 2)]; + row = new ExcelCell[10 + (maxOptions * 2)]; columnCount = 0; // learner name row[columnCount++] = new ExcelCell(user.getFirstName() + " " + user.getLastName(), false); @@ -1563,15 +1557,15 @@ // question title row[columnCount++] = new ExcelCell(itemDto.getTitle(), false); - // correct answer - String correctAnswer = ""; - List answers = itemDto.getAnswers(); - for (ScratchieAnswer answer : answers) { - if (answer.getQbOption().isCorrect()) { - correctAnswer = removeHtmlMarkup(answer.getQbOption().getName()); + // correct option + String correctOption = ""; + List options = itemDto.getOptionDtos(); + for (QbOptionDTO option : options) { + if (option.getQbOption().isCorrect()) { + correctOption = removeHtmlMarkup(option.getQbOption().getName()); } } - row[columnCount++] = new ExcelCell(correctAnswer, false); + row[columnCount++] = new ExcelCell(correctOption, false); // isFirstChoice int attempts = itemDto.getUserAttempts(); @@ -1590,21 +1584,21 @@ Object mark = (itemDto.getUserMark() == -1) ? "" : new Long(itemDto.getUserMark()); row[columnCount++] = new ExcelCell(mark, false); - // Answers selected + // options selected List logs = scratchieAnswerVisitDao.getLogsBySessionAndItem(sessionId, itemDto.getUid()); if (logs == null) { logs = new ArrayList<>(); } for (ScratchieAnswerVisitLog log : logs) { - String answer = removeHtmlMarkup(log.getQbOption().getName()); - row[columnCount++] = new ExcelCell(answer, false); + String optionText = removeHtmlMarkup(log.getQbOption().getName()); + row[columnCount++] = new ExcelCell(optionText, false); } - for (int i = logs.size(); i < itemDto.getAnswers().size(); i++) { + for (int i = logs.size(); i < itemDto.getOptionDtos().size(); i++) { row[columnCount++] = new ExcelCell(getMessage("label.none"), false); } - for (int i = answers.size(); i < maxAnswers; i++) { + for (int i = options.size(); i < maxOptions; i++) { row[columnCount++] = new ExcelCell("", false); } @@ -1624,7 +1618,7 @@ String timeStr = timeFormat.format(accessDate); row[columnCount++] = new ExcelCell(timeStr, false); } - for (int i = logs.size(); i < maxAnswers; i++) { + for (int i = logs.size(); i < maxOptions; i++) { row[columnCount++] = new ExcelCell("", false); } @@ -1743,48 +1737,48 @@ ScratchieUser groupLeader = session.getGroupLeader(); - List answerLogs = scratchieAnswerVisitDao.getLogsBySession(sessionId); + List logs = scratchieAnswerVisitDao.getLogsBySession(sessionId); for (ScratchieItem item : sortedItems) { ScratchieItemDTO itemDto = new ScratchieItemDTO(); int numberOfAttempts = 0; int mark = -1; boolean isUnraveledOnFirstAttempt = false; - String answersSequence = ""; + String optionsSequence = ""; // if there is no group leader don't calculate numbers - there aren't any if (groupLeader != null) { //create a list of attempts user done for the current item - List itemAttempts = new ArrayList<>(); - for (ScratchieAnswerVisitLog answerLog : answerLogs) { - if (answerLog.getQbToolQuestion().getUid().equals(item.getUid())) { - itemAttempts.add(answerLog); + List itemLogs = new ArrayList<>(); + for (ScratchieAnswerVisitLog log : logs) { + if (log.getQbToolQuestion().getUid().equals(item.getUid())) { + itemLogs.add(log); } } - numberOfAttempts = itemAttempts.size(); + numberOfAttempts = itemLogs.size(); // for displaying purposes if there is no attemps we assign -1 which will be shown as "-" - mark = (numberOfAttempts == 0) ? -1 : getUserMarkPerItem(scratchie, item, answerLogs, presetMarks); + mark = (numberOfAttempts == 0) ? -1 : getUserMarkPerItem(scratchie, item, logs, presetMarks); - isUnraveledOnFirstAttempt = (numberOfAttempts == 1) && isItemUnraveled(item, answerLogs); + isUnraveledOnFirstAttempt = (numberOfAttempts == 1) && isItemUnraveled(item, logs); - // find out answers' sequential letters - A,B,C... - for (ScratchieAnswerVisitLog itemAttempt : itemAttempts) { + // find out options' sequential letters - A,B,C... + for (ScratchieAnswerVisitLog itemAttempt : itemLogs) { String sequencialLetter = ScratchieServiceImpl.getSequencialLetter(item, itemAttempt.getQbOption()); - answersSequence += answersSequence.isEmpty() ? sequencialLetter : ", " + sequencialLetter; + optionsSequence += optionsSequence.isEmpty() ? sequencialLetter : ", " + sequencialLetter; } } itemDto.setUid(item.getUid()); itemDto.setTitle(item.getQbQuestion().getName()); - itemDto.setAnswers(item.getAnswers()); + itemDto.setOptionDtos(item.getOptionDtos()); itemDto.setUserAttempts(numberOfAttempts); itemDto.setUserMark(mark); itemDto.setUnraveledOnFirstAttempt(isUnraveledOnFirstAttempt); - itemDto.setAnswersSequence(answersSequence); + itemDto.setOptionsSequence(optionsSequence); itemDtos.add(itemDto); } @@ -1797,18 +1791,18 @@ } /** - * Return specified answer's sequential letter (e.g. A,B,C) among other possible answers + * Return specified option's sequential letter (e.g. A,B,C) among other possible options */ private static String getSequencialLetter(ScratchieItem item, QbOption asnwer) { String sequencialLetter = ""; - int answerCount = 1; - for (ScratchieAnswer answer : item.getAnswers()) { - if (answer.getQbOption().getUid().equals(asnwer.getUid())) { - sequencialLetter = String.valueOf((char) ((answerCount + 'A') - 1)); + int optionCount = 1; + for (QbOptionDTO option : item.getOptionDtos()) { + if (option.getQbOption().getUid().equals(asnwer.getUid())) { + sequencialLetter = String.valueOf((char) ((optionCount + 'A') - 1)); break; } - answerCount++; + optionCount++; } return sequencialLetter; @@ -1920,13 +1914,13 @@ // set ScratchieToolContentHandler as null to avoid copy file node in repository again. toolContentObj = Scratchie.newInstance(toolContentObj, toolContentId); - // wipe out the links from ScratchieAnswer back to ScratchieItem, or it will try to + // wipe out the links from QbOptionDTO back to ScratchieItem, or it will try to // include the hibernate object version of the ScratchieItem within the XML Set items = toolContentObj.getScratchieItems(); for (ScratchieItem item : items) { - Collection answers = item.getQbQuestion().getQbOptions(); - for (QbOption answer : answers) { - answer.setQbQuestion(null); + Collection options = item.getQbQuestion().getQbOptions(); + for (QbOption option : options) { + option.setQbQuestion(null); } } @@ -2174,7 +2168,6 @@ if ((session == null) || (session.getScratchie() == null)) { return; } - Scratchie scratchie = session.getScratchie(); // as long as leader aware feature is always ON - copy answers from leader to non-leader user @@ -2311,23 +2304,23 @@ newItems.add(item); // set options - List newAnswers = new LinkedList<>(); + List newOptions = new LinkedList<>(); ArrayNode answersData = JsonUtil.optArray(questionData, RestTags.ANSWERS); for (int j = 0; j < answersData.size(); j++) { ObjectNode answerData = (ObjectNode) answersData.get(j); - QbOption answer = new QbOption(); + QbOption option = new QbOption(); // Removes redundant new line characters from options left by CKEditor (otherwise it will break // Javascript in monitor). Copied from AuthoringAction. - String answerDescription = JsonUtil.optString(answerData, RestTags.ANSWER_TEXT); - answer.setName(answerDescription != null ? answerDescription.replaceAll("[\n\r\f]", "") : ""); - answer.setCorrect(JsonUtil.optBoolean(answerData, RestTags.CORRECT)); - answer.setDisplayOrder(JsonUtil.optInt(answerData, RestTags.DISPLAY_ORDER)); - answer.setQbQuestion(item.getQbQuestion()); - newAnswers.add(answer); + String optionDescription = JsonUtil.optString(answerData, RestTags.ANSWER_TEXT); + option.setName(optionDescription != null ? optionDescription.replaceAll("[\n\r\f]", "") : ""); + option.setCorrect(JsonUtil.optBoolean(answerData, RestTags.CORRECT)); + option.setDisplayOrder(JsonUtil.optInt(answerData, RestTags.DISPLAY_ORDER)); + option.setQbQuestion(item.getQbQuestion()); + newOptions.add(option); } - item.getQbQuestion().setQbOptions(newAnswers); + item.getQbQuestion().setQbOptions(newOptions); } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/AuthoringController.java =================================================================== diff -u -r801c7bf1be518b27b381568351fe8c1c1ff98482 -r23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/AuthoringController.java (.../AuthoringController.java) (revision 801c7bf1be518b27b381568351fe8c1c1ff98482) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/AuthoringController.java (.../AuthoringController.java) (revision 23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75) @@ -358,13 +358,13 @@ scratchieItemForm.setSessionMapID(sessionMapID); scratchieItemForm.setContentFolderID(contentFolderID); - List answerList = new ArrayList<>(); - for (int i = 0; i < ScratchieConstants.INITIAL_ANSWERS_NUMBER; i++) { - QbOption answer = new QbOption(); - answer.setDisplayOrder(i + 1); - answerList.add(answer); + List optionList = new ArrayList<>(); + for (int i = 0; i < ScratchieConstants.INITIAL_OPTIONS_NUMBER; i++) { + QbOption option = new QbOption(); + option.setDisplayOrder(i + 1); + optionList.add(option); } - request.setAttribute(ScratchieConstants.ATTR_ANSWER_LIST, answerList); + request.setAttribute(ScratchieConstants.ATTR_OPTION_LIST, optionList); request.setAttribute(AttributeNames.PARAM_CONTENT_FOLDER_ID, contentFolderID); return "pages/authoring/parts/additem"; @@ -396,8 +396,8 @@ scratchieItemForm.setItemIndex(new Integer(itemIdx).toString()); } - List answerList = item.getQbQuestion().getQbOptions(); - request.setAttribute(ScratchieConstants.ATTR_ANSWER_LIST, answerList); + List optionList = item.getQbQuestion().getQbOptions(); + request.setAttribute(ScratchieConstants.ATTR_OPTION_LIST, optionList); scratchieItemForm.setContentFolderID(contentFolderID); } @@ -490,14 +490,14 @@ item.getQbQuestion().setDescription(scratchieItemForm.getDescription()); // set options - Set answerList = getAnswersFromRequest(request, true); - List answers = new ArrayList<>(); + Set optionList = getOptionsFromRequest(request, true); + List options = new ArrayList<>(); int orderId = 0; - for (QbOption answer : answerList) { - answer.setDisplayOrder(orderId++); - answers.add(answer); + for (QbOption option : optionList) { + option.setDisplayOrder(orderId++); + options.add(option); } - item.getQbQuestion().setQbOptions(answers); + item.getQbQuestion().setQbOptions(options); item.setQbQuestionModified(scratchieService.isQbQuestionModified(baseLine, item.getQbQuestion())); request.setAttribute("qbQuestionModified", item.getQbQuestionModified()); @@ -536,44 +536,44 @@ qbQuestion.setDescription(QuestionParser.processHTMLField(question.getText(), false, contentFolderID, question.getResourcesFolderPath())); - TreeSet answerList = new TreeSet<>(); - String correctAnswer = null; + TreeSet optionList = new TreeSet<>(); + String correctOption = null; int orderId = 1; if (question.getAnswers() != null) { for (Answer answer : question.getAnswers()) { String answerText = QuestionParser.processHTMLField(answer.getText(), false, contentFolderID, question.getResourcesFolderPath()); - if (correctAnswer != null && correctAnswer.equals(answerText)) { + if (correctOption != null && correctOption.equals(answerText)) { log.warn("Skipping an answer with same text as the correct answer: " + answerText); continue; } - QbOption scratchieAnswer = new QbOption(); - scratchieAnswer.setName(answerText); - scratchieAnswer.setDisplayOrder(orderId++); + QbOption option = new QbOption(); + option.setName(answerText); + option.setDisplayOrder(orderId++); if ((answer.getScore() != null) && (answer.getScore() > 0)) { - if (correctAnswer == null) { - scratchieAnswer.setCorrect(true); - correctAnswer = answerText; + if (correctOption == null) { + option.setCorrect(true); + correctOption = answerText; } else { log.warn( - "Choosing only first correct answer, despite another one was found: " + answerText); - scratchieAnswer.setCorrect(false); + "Choosing only the first correct option, despite another one was found: " + answerText); + option.setCorrect(false); } } else { - scratchieAnswer.setCorrect(false); + option.setCorrect(false); } - answerList.add(scratchieAnswer); + optionList.add(option); } } - if (correctAnswer == null) { - log.warn("No correct answer found for question: " + question.getText()); + if (correctOption == null) { + log.warn("No correct option found for question: " + question.getText()); continue; } - qbQuestion.setQbOptions(new ArrayList<>(answerList)); + qbQuestion.setQbOptions(new ArrayList<>(optionList)); itemList.add(item); if (log.isDebugEnabled()) { log.debug("Added question: " + question.getText()); @@ -606,10 +606,10 @@ question.setText(qbQuestion.getDescription()); List answers = new ArrayList<>(); - Set scratchieAnswers = new TreeSet<>(); - scratchieAnswers.addAll(qbQuestion.getQbOptions()); + Set scratchieOptions = new TreeSet<>(); + scratchieOptions.addAll(qbQuestion.getQbOptions()); - for (QbOption itemAnswer : scratchieAnswers) { + for (QbOption itemAnswer : scratchieOptions) { Answer answer = new Answer(); answer.setText(itemAnswer.getName()); // there is no LAMS interface to adjust, so use the default 1 point @@ -724,7 +724,7 @@ return "pages/authoring/parts/itemlist"; } - // ----------------------- Answers functions --------------- + // ----------------------- Options functions --------------- /** * Ajax call, will add one more input line for new resource item instruction. @@ -738,25 +738,25 @@ @RequestMapping("/addAnswer") private String addAnswer(HttpServletRequest request) { - SortedSet answerList = getAnswersFromRequest(request, false); + SortedSet optionList = getOptionsFromRequest(request, false); - QbOption answer = new QbOption(); + QbOption option = new QbOption(); int maxSeq = 1; - if (answerList != null && answerList.size() > 0) { - QbOption last = answerList.last(); + if (optionList != null && optionList.size() > 0) { + QbOption last = optionList.last(); maxSeq = last.getDisplayOrder() + 1; } - answer.setDisplayOrder(maxSeq); - answerList.add(answer); + option.setDisplayOrder(maxSeq); + optionList.add(option); - request.setAttribute(ScratchieConstants.ATTR_ANSWER_LIST, answerList); + request.setAttribute(ScratchieConstants.ATTR_OPTION_LIST, optionList); request.setAttribute(AttributeNames.PARAM_CONTENT_FOLDER_ID, WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID)); - return "pages/authoring/parts/answerlist"; + return "pages/authoring/parts/optionlist"; } /** - * Ajax call, remove the given answer. + * Ajax call, remove the given option. * * @param mapping * @param form @@ -767,24 +767,24 @@ @RequestMapping("/removeAnswer") private String removeAnswer(HttpServletRequest request) { - SortedSet answerList = getAnswersFromRequest(request, false); + SortedSet optionList = getOptionsFromRequest(request, false); - int answerIndex = NumberUtils.toInt(request.getParameter(ScratchieConstants.PARAM_ANSWER_INDEX), -1); - if (answerIndex != -1) { - List rList = new ArrayList<>(answerList); - rList.remove(answerIndex); - answerList.clear(); - answerList.addAll(rList); + int optionIndex = NumberUtils.toInt(request.getParameter(ScratchieConstants.PARAM_OPTION_INDEX), -1); + if (optionIndex != -1) { + List rList = new ArrayList<>(optionList); + rList.remove(optionIndex); + optionList.clear(); + optionList.addAll(rList); } - request.setAttribute(ScratchieConstants.ATTR_ANSWER_LIST, answerList); + request.setAttribute(ScratchieConstants.ATTR_OPTION_LIST, optionList); request.setAttribute(AttributeNames.PARAM_CONTENT_FOLDER_ID, WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID)); - return "pages/authoring/parts/answerlist"; + return "pages/authoring/parts/optionlist"; } /** - * Move up current answer. + * Move up current option. * * @param mapping * @param form @@ -794,11 +794,11 @@ */ @RequestMapping("/upAnswer") private String upAnswer(HttpServletRequest request) { - return switchAnswer(request, true); + return switchOption(request, true); } /** - * Move down current answer. + * Move down current option. * * @param mapping * @param form @@ -808,36 +808,36 @@ */ @RequestMapping("/downAnswer") private String downAnswer(HttpServletRequest request) { - return switchAnswer(request, false); + return switchOption(request, false); } - private String switchAnswer(HttpServletRequest request, boolean up) { - SortedSet answerList = getAnswersFromRequest(request, false); + private String switchOption(HttpServletRequest request, boolean up) { + SortedSet optionList = getOptionsFromRequest(request, false); - int answerIndex = NumberUtils.toInt(request.getParameter(ScratchieConstants.PARAM_ANSWER_INDEX), -1); - if (answerIndex != -1) { - List rList = new ArrayList<>(answerList); + int optionIndex = NumberUtils.toInt(request.getParameter(ScratchieConstants.PARAM_OPTION_INDEX), -1); + if (optionIndex != -1) { + List rList = new ArrayList<>(optionList); // get current and the target item, and switch their sequnece - QbOption answer = rList.get(answerIndex); - QbOption repAnswer; + QbOption option = rList.get(optionIndex); + QbOption repOption; if (up) { - repAnswer = rList.get(--answerIndex); + repOption = rList.get(--optionIndex); } else { - repAnswer = rList.get(++answerIndex); + repOption = rList.get(++optionIndex); } - int upSeqId = repAnswer.getDisplayOrder(); - repAnswer.setDisplayOrder(answer.getDisplayOrder()); - answer.setDisplayOrder(upSeqId); + int upSeqId = repOption.getDisplayOrder(); + repOption.setDisplayOrder(option.getDisplayOrder()); + option.setDisplayOrder(upSeqId); // put back list, it will be sorted again - answerList.clear(); - answerList.addAll(rList); + optionList.clear(); + optionList.addAll(rList); } - request.setAttribute(ScratchieConstants.ATTR_ANSWER_LIST, answerList); - return "pages/authoring/parts/answerlist"; + request.setAttribute(ScratchieConstants.ATTR_OPTION_LIST, optionList); + return "pages/authoring/parts/optionlist"; } // ----------------------- PedagogicalPlannerForm --------------- @@ -914,49 +914,49 @@ } /** - * Get answer options from HttpRequest + * Get options from HttpRequest * * @param request * @param isForSaving * whether the blank options will be preserved or not * */ - private TreeSet getAnswersFromRequest(HttpServletRequest request, boolean isForSaving) { - Map paramMap = splitRequestParameter(request, ScratchieConstants.ATTR_ANSWER_LIST); - Integer correctAnswerIndex = (paramMap.get(ScratchieConstants.ATTR_ANSWER_CORRECT) == null) ? null - : NumberUtils.toInt(paramMap.get(ScratchieConstants.ATTR_ANSWER_CORRECT)); + private TreeSet getOptionsFromRequest(HttpServletRequest request, boolean isForSaving) { + Map paramMap = splitRequestParameter(request, ScratchieConstants.ATTR_OPTION_LIST); + Integer correctOptionIndex = (paramMap.get(ScratchieConstants.ATTR_OPTION_CORRECT) == null) ? null + : NumberUtils.toInt(paramMap.get(ScratchieConstants.ATTR_OPTION_CORRECT)); - int count = NumberUtils.toInt(paramMap.get(ScratchieConstants.ATTR_ANSWER_COUNT)); - TreeSet answerList = new TreeSet<>(); + int count = NumberUtils.toInt(paramMap.get(ScratchieConstants.ATTR_OPTION_COUNT)); + TreeSet optionList = new TreeSet<>(); for (int i = 0; i < count; i++) { - String answerDescription = paramMap.get(ScratchieConstants.ATTR_ANSWER_DESCRIPTION_PREFIX + i); - if ((answerDescription == null) && isForSaving) { + String optionDescription = paramMap.get(ScratchieConstants.ATTR_OPTION_DESCRIPTION_PREFIX + i); + if ((optionDescription == null) && isForSaving) { continue; } - QbOption answer = null; - String uidStr = paramMap.get(ScratchieConstants.ATTR_ANSWER_UID_PREFIX + i); + QbOption option = null; + String uidStr = paramMap.get(ScratchieConstants.ATTR_OPTION_UID_PREFIX + i); if (uidStr != null) { Long uid = NumberUtils.toLong(uidStr); - answer = scratchieService.getQbOptionByUid(uid); - scratchieService.releaseFromCache(answer.getQbQuestion()); + option = scratchieService.getQbOptionByUid(uid); + scratchieService.releaseFromCache(option.getQbQuestion()); } else { - answer = new QbOption(); + option = new QbOption(); } - String orderIdStr = paramMap.get(ScratchieConstants.ATTR_ANSWER_ORDER_ID_PREFIX + i); + String orderIdStr = paramMap.get(ScratchieConstants.ATTR_OPTION_ORDER_ID_PREFIX + i); Integer orderId = NumberUtils.toInt(orderIdStr); - answer.setDisplayOrder(orderId); - answer.setName(answerDescription); - if ((correctAnswerIndex != null) && correctAnswerIndex.equals(orderId)) { - answer.setCorrect(true); + option.setDisplayOrder(orderId); + option.setName(optionDescription); + if ((correctOptionIndex != null) && correctOptionIndex.equals(orderId)) { + option.setCorrect(true); } - answerList.add(answer); + optionList.add(option); } - return answerList; + return optionList; } /** @@ -994,13 +994,13 @@ * monitor) */ private void removeNewLineCharacters(ScratchieItem item) { - Collection answers = item.getQbQuestion().getQbOptions(); - if (answers != null) { - for (QbOption answer : answers) { - String answerDescription = answer.getName(); - if (answerDescription != null) { - answerDescription = answerDescription.replaceAll("[\n\r\f]", ""); - answer.setName(answerDescription); + Collection options = item.getQbQuestion().getQbOptions(); + if (options != null) { + for (QbOption option : options) { + String optionDescription = option.getName(); + if (optionDescription != null) { + optionDescription = optionDescription.replaceAll("[\n\r\f]", ""); + option.setName(optionDescription); } } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/LearningController.java =================================================================== diff -u -r07be5ed62c56a16247f3d934413770f7774e5920 -r23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/LearningController.java (.../LearningController.java) (revision 07be5ed62c56a16247f3d934413770f7774e5920) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/LearningController.java (.../LearningController.java) (revision 23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75) @@ -164,15 +164,15 @@ sessionMap.put(ScratchieConstants.ATTR_REFLECTION_ON, isReflectOnActivity); sessionMap.put(ScratchieConstants.ATTR_REFLECTION_INSTRUCTION, scratchie.getReflectInstructions()); sessionMap.put(ScratchieConstants.ATTR_REFLECTION_ENTRY, entryText); - // add all answer uids to one set + // add all option uids to one set if (isUserLeader) { - Set answerUids = new HashSet<>(); + Set optionUids = new HashSet<>(); for (ScratchieItem item : scratchie.getScratchieItems()) { - for (QbOption answer : item.getQbQuestion().getQbOptions()) { - answerUids.add(answer.getUid()); + for (QbOption option : item.getQbQuestion().getQbOptions()) { + optionUids.add(option.getUid()); } } - sessionMap.put(ScratchieConstants.ATTR_ANSWER_UIDS, answerUids); + sessionMap.put(ScratchieConstants.ATTR_OPTION_UIDS, optionUids); } // add define later support @@ -283,7 +283,7 @@ } /** - * Stores into session map all data needed to display scratchies and answers + * Stores into session map all data needed to display scratchies and options */ private void storeItemsToSessionMap(Long toolSessionId, Scratchie scratchie, SessionMap sessionMap, boolean showOrder) { @@ -345,7 +345,7 @@ } /** - * Record in DB that leader has scratched specified answer. And return whether scratchie answer is correct or not. + * Record in DB that leader has scratched specified option. And return whether scratchie option is correct or not. */ @RequestMapping("/recordItemScratched") private String recordItemScratched(HttpServletRequest request, HttpServletResponse response) @@ -354,31 +354,31 @@ SessionMap sessionMap = (SessionMap) request.getSession() .getAttribute(sessionMapID); final Long toolSessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); - final Long answerUid = NumberUtils.createLong(request.getParameter(ScratchieConstants.PARAM_ANSWER_UID)); + final Long optionUid = NumberUtils.createLong(request.getParameter(ScratchieConstants.PARAM_OPTION_UID)); final Long itemUid = NumberUtils.createLong(request.getParameter(ScratchieConstants.PARAM_ITEM_UID)); ScratchieSession toolSession = scratchieService.getScratchieSessionBySessionId(toolSessionId); ScratchieUser leader = getCurrentUser(toolSessionId); - // only leader is allowed to scratch answers + // only leader is allowed to scratch options if (!toolSession.isUserGroupLeader(leader.getUid())) { return null; } - // check answer is belong to current session - Set answerUids = (Set) sessionMap.get(ScratchieConstants.ATTR_ANSWER_UIDS); - if (!answerUids.contains(answerUid)) { + // check option is belong to current session + Set optionUids = (Set) sessionMap.get(ScratchieConstants.ATTR_OPTION_UIDS); + if (!optionUids.contains(optionUid)) { return null; } - // Return whether scratchie answer is correct or not - QbOption answer = scratchieService.getQbOptionByUid(answerUid); - if (answer == null) { + // Return whether option is correct or not + QbOption option = scratchieService.getQbOptionByUid(optionUid); + if (option == null) { return null; } ObjectNode ObjectNode = JsonNodeFactory.instance.objectNode(); - ObjectNode.put(ScratchieConstants.ATTR_ANSWER_CORRECT, answer.isCorrect()); + ObjectNode.put(ScratchieConstants.ATTR_OPTION_CORRECT, option.isCorrect()); response.setContentType("application/json;charset=utf-8"); response.getWriter().print(ObjectNode); @@ -387,7 +387,7 @@ Thread recordItemScratchedThread = new Thread(new Runnable() { @Override public void run() { - scratchieService.recordItemScratched(toolSessionId, itemUid, answerUid); + scratchieService.recordItemScratched(toolSessionId, itemUid, optionUid); } }, "LAMS_recordItemScratched_thread"); recordItemScratchedThread.start(); @@ -524,7 +524,7 @@ Long burningQuestionUid = WebUtil.readLongParam(request, ScratchieConstants.PARAM_BURNING_QUESTION_UID); ScratchieUser leader = this.getCurrentUser(sessionId); - // only leader is allowed to scratch answers + // only leader is allowed to scratch options if (!toolSession.isUserGroupLeader(leader.getUid())) { return null; } @@ -551,7 +551,7 @@ Long burningQuestionUid = WebUtil.readLongParam(request, ScratchieConstants.PARAM_BURNING_QUESTION_UID); ScratchieUser leader = this.getCurrentUser(sessionId); - // only leader is allowed to scratch answers + // only leader is allowed to scratch options if (!toolSession.isUserGroupLeader(leader.getUid())) { return null; } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/LearningWebsocketServer.java =================================================================== diff -u -rfba7287887f6dd83d3098100af6320cccf1f3e36 -r23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/LearningWebsocketServer.java (.../LearningWebsocketServer.java) (revision fba7287887f6dd83d3098100af6320cccf1f3e36) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/LearningWebsocketServer.java (.../LearningWebsocketServer.java) (revision 23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75) @@ -21,7 +21,7 @@ import org.apache.log4j.Logger; import org.lamsfoundation.lams.tool.scratchie.ScratchieConstants; -import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAnswer; +import org.lamsfoundation.lams.tool.scratchie.dto.QbOptionDTO; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieItem; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieSession; import org.lamsfoundation.lams.tool.scratchie.service.IScratchieService; @@ -138,7 +138,7 @@ } /** - * Feeds websockets with scratched answers. + * Feeds websockets with scratched options. */ @SuppressWarnings("unchecked") private static void send(Long toolSessionId) throws IOException { @@ -152,7 +152,7 @@ // do not init variables below until it's really needed Map itemCache = null; ObjectNode itemJSON = null; - for (ScratchieAnswer answer : (Set) item.getAnswers()) { + for (QbOptionDTO answer : (Set) item.getOptionDtos()) { if (answer.isScratched()) { // answer is scratched, check if it is present in cache if (itemCache == null) { @@ -163,17 +163,17 @@ } } - Long answerUid = answer.getQbOption().getUid(); + Long optionUid = answer.getQbOption().getUid(); Boolean answerStoredIsCorrect = answer.getQbOption().isCorrect(); - Boolean answerCache = itemCache.get(answerUid); + Boolean answerCache = itemCache.get(optionUid); // check if the correct answer is stored in cache if ((answerCache == null) || !answerCache.equals(answerStoredIsCorrect)) { // send only updates, nothing Learners are already aware of - itemCache.put(answerUid, answerStoredIsCorrect); + itemCache.put(optionUid, answerStoredIsCorrect); if (itemJSON == null) { itemJSON = JsonNodeFactory.instance.objectNode(); } - itemJSON.put(answerUid.toString(), answerStoredIsCorrect); + itemJSON.put(optionUid.toString(), answerStoredIsCorrect); } } } @@ -200,7 +200,7 @@ private static IScratchieService scratchieService; private static final SendWorker sendWorker = new SendWorker(); - // maps toolSessionId -> itemUid -> answerUid -> isCorrect + // maps toolSessionId -> itemUid -> optionUid -> isCorrect private static final Map>> cache = new ConcurrentHashMap<>(); private static final Map> websockets = new ConcurrentHashMap<>(); Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/MonitoringController.java =================================================================== diff -u -rfba7287887f6dd83d3098100af6320cccf1f3e36 -r23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/MonitoringController.java (.../MonitoringController.java) (revision fba7287887f6dd83d3098100af6320cccf1f3e36) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/MonitoringController.java (.../MonitoringController.java) (revision 23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75) @@ -44,9 +44,9 @@ import org.lamsfoundation.lams.tool.scratchie.dto.BurningQuestionItemDTO; import org.lamsfoundation.lams.tool.scratchie.dto.GroupSummary; import org.lamsfoundation.lams.tool.scratchie.dto.LeaderResultsDTO; +import org.lamsfoundation.lams.tool.scratchie.dto.QbOptionDTO; import org.lamsfoundation.lams.tool.scratchie.dto.ReflectDTO; import org.lamsfoundation.lams.tool.scratchie.model.Scratchie; -import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAnswer; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieItem; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieUser; import org.lamsfoundation.lams.tool.scratchie.service.IScratchieService; @@ -146,12 +146,12 @@ Long contentId = (Long) sessionMap.get(ScratchieConstants.ATTR_TOOL_CONTENT_ID); List summaryList = scratchieService.getQuestionSummary(contentId, itemUid); - // escape JS sensitive characters in answer descriptions + // escape JS sensitive characters in option descriptions for (GroupSummary summary : summaryList) { - for (ScratchieAnswer answer : summary.getAnswers()) { - String description = (answer.getQbOption().getName() == null) ? "" - : StringEscapeUtils.escapeJavaScript(answer.getQbOption().getName()); - answer.getQbOption().setName(description); + for (QbOptionDTO optionDto : summary.getOptionDtos()) { + String description = (optionDto.getQbOption().getName() == null) ? "" + : StringEscapeUtils.escapeJavaScript(optionDto.getQbOption().getName()); + optionDto.getQbOption().setName(description); } } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/TblMonitorController.java =================================================================== diff -u -rb1ee7c7d55795c2b920bef41137748a8a95873b6 -r23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/TblMonitorController.java (.../TblMonitorController.java) (revision b1ee7c7d55795c2b920bef41137748a8a95873b6) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/controller/TblMonitorController.java (.../TblMonitorController.java) (revision 23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75) @@ -46,9 +46,9 @@ import org.lamsfoundation.lams.tool.scratchie.dto.BurningQuestionDTO; import org.lamsfoundation.lams.tool.scratchie.dto.BurningQuestionItemDTO; import org.lamsfoundation.lams.tool.scratchie.dto.GroupSummary; +import org.lamsfoundation.lams.tool.scratchie.dto.QbOptionDTO; import org.lamsfoundation.lams.tool.scratchie.dto.ScratchieItemDTO; import org.lamsfoundation.lams.tool.scratchie.model.Scratchie; -import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAnswer; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieItem; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieUser; import org.lamsfoundation.lams.tool.scratchie.service.IScratchieService; @@ -133,7 +133,7 @@ LinkedHashMap excelDoc = scratchieService.exportExcel(toolContentId); ExcelCell[][] secondPageData = null; for (ExcelCell[][] excelPage : excelDoc.values()) { - //check last row string starts with "*" (i.e. the string "*- Denotes the correct answer") + //check last row string starts with "*" (i.e. the string "*- Denotes the correct option") if (excelPage.length > 0) { ExcelCell lastRow = excelPage[excelPage.length - 1][0]; if (lastRow != null && ((String) lastRow.getCellValue()).startsWith("*")) { @@ -143,11 +143,11 @@ } } - //correct answers - ExcelCell[] correctAnswersRow = secondPageData[4]; - request.setAttribute("correctAnswers", correctAnswersRow); + //correct options + ExcelCell[] correctOptionsRow = secondPageData[4]; + request.setAttribute("correctOptions", correctOptionsRow); - //prepare data for displaying user answers table + //prepare data for displaying user option table int groupsSize = scratchieService.countSessionsByContentId(toolContentId); ArrayList sessionDtos = new ArrayList<>(); for (int groupCount = 0; groupCount < groupsSize; groupCount++) { @@ -160,24 +160,24 @@ Collection itemDtos = new ArrayList<>(); for (int i = 1; i <= items.size(); i++) { ScratchieItemDTO itemDto = new ScratchieItemDTO(); - String answersSequence = groupRow[i].getCellValue().toString(); - String[] answerLetters = answersSequence.split(", "); + String optionsSequence = groupRow[i].getCellValue().toString(); + String[] optionLetters = optionsSequence.split(", "); - List answers = new LinkedList<>(); - for (int j = 0; j < answerLetters.length; j++) { - String answerLetter = answerLetters[j]; - String correctAnswerLetter = correctAnswersRow[i].getCellValue().toString(); + List optionDtos = new LinkedList<>(); + for (int j = 0; j < optionLetters.length; j++) { + String optionLetter = optionLetters[j]; + String correctOptionLetter = correctOptionsRow[i].getCellValue().toString(); - ScratchieAnswer answer = new ScratchieAnswer(); + QbOptionDTO optionDto = new QbOptionDTO(); QbOption qbOption = new QbOption(); - answer.setQbOption(qbOption); - qbOption.setName(answerLetter); - qbOption.setCorrect(correctAnswerLetter.equals(answerLetter)); + optionDto.setQbOption(qbOption); + qbOption.setName(optionLetter); + qbOption.setCorrect(correctOptionLetter.equals(optionLetter)); - answers.add(answer); + optionDtos.add(optionDto); } - itemDto.setAnswers(answers); + itemDto.setOptionDtos(optionDtos); itemDtos.add(itemDto); } groupSummary.setItemDtos(itemDtos); Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/form/ScratchieItemForm.java =================================================================== diff -u -r085d47fc4191f2cb614a5a7c8fe3ff6c5abcef0f -r23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/form/ScratchieItemForm.java (.../ScratchieItemForm.java) (revision 085d47fc4191f2cb614a5a7c8fe3ff6c5abcef0f) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/form/ScratchieItemForm.java (.../ScratchieItemForm.java) (revision 23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75) @@ -24,7 +24,7 @@ import java.util.List; -import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAnswer; +import org.lamsfoundation.lams.tool.scratchie.dto.QbOptionDTO; /** * Index: lams_tool_scratchie/web/pages/authoring/parts/additem.jsp =================================================================== diff -u -ref60ff3e102503af3adb40d0569e45d3adc06991 -r23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75 --- lams_tool_scratchie/web/pages/authoring/parts/additem.jsp (.../additem.jsp) (revision ef60ff3e102503af3adb40d0569e45d3adc06991) +++ lams_tool_scratchie/web/pages/authoring/parts/additem.jsp (.../additem.jsp) (revision 23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75) @@ -24,8 +24,8 @@ var answerTargetDiv = "#answerArea"; function addAnswer(){ - //check maximum number of answers - var numberOfAnswers = $("textarea[name^=answerDescription]").length; + //check maximum number of options + var numberOfAnswers = $("textarea[name^=optionDescription]").length; if (numberOfAnswers >= 10) { alert(""); return; @@ -40,13 +40,13 @@ var url= addAnswerUrl; var contentFolderID= $("#contentFolderID").val(); prepareAnswerEditorsForAjaxSubmit(); - var answerList = $("#answerForm").serialize(true); + var optionList = $("#answerForm").serialize(true); $.ajaxSetup({ cache: true }); $(answerTargetDiv).load( url, { contentFolderID: contentFolderID, - answerList: answerList + optionList: optionList }, function(){ reinitializeAnswerEditors(oldAnswerIds); @@ -57,13 +57,13 @@ var url= removeAnswerUrl; var contentFolderID= $("#contentFolderID").val(); prepareAnswerEditorsForAjaxSubmit(); - var answerList = $("#answerForm").serialize(true); + var optionList = $("#answerForm").serialize(true); $(answerTargetDiv).load( url, { contentFolderID: contentFolderID, - answerIndex: idx, - answerList: answerList + optionIndex: idx, + optionList: optionList }, function(){ reinitializeAnswerEditors(null); @@ -74,13 +74,13 @@ var url= upAnswerUrl; var contentFolderID= $("#contentFolderID").val(); prepareAnswerEditorsForAjaxSubmit(); - var answerList = $("#answerForm").serialize(true); + var optionList = $("#answerForm").serialize(true); $(answerTargetDiv).load( url, { contentFolderID: contentFolderID, - answerIndex: idx, - answerList: answerList + optionIndex: idx, + optionList: optionList }, function(){ reinitializeAnswerEditors(null); @@ -91,21 +91,21 @@ var url= downAnswerUrl; var contentFolderID= $("#contentFolderID").val(); prepareAnswerEditorsForAjaxSubmit(); - var answerList = $("#answerForm").serialize(true); + var optionList = $("#answerForm").serialize(true); $(answerTargetDiv).load( url, { contentFolderID: contentFolderID, - answerIndex: idx, - answerList: answerList + optionIndex: idx, + optionList: optionList }, function(){ reinitializeAnswerEditors(null); } ); } - //reinitialize all CKEditors responsible for answers after Ajax call has done + //reinitialize all CKEditors responsible for options after Ajax call has done function reinitializeAnswerEditors(answerIds){ return; if (answerIds == null) { @@ -130,7 +130,7 @@ //in order to be able to use answer's value, copy it from CKEditor to textarea function prepareAnswerEditorsForAjaxSubmit(){ - $("textarea[name^=answerDescription]").each(function() { + $("textarea[name^=optionDescription]").each(function() { var ckeditorData = CKEDITOR.instances[this.name].getData(); //skip out empty values this.value = ((ckeditorData == null) || (ckeditorData.replace(/ | |
|\s|

|<\/p>|\xa0/g, "").length == 0)) ? "" : ckeditorData; @@ -146,7 +146,7 @@ required: function(element) { //check there should be at least one answer filled prepareAnswerEditorsForAjaxSubmit(); - return $("textarea[name^=answerDescription]:filled").length < 1; + return $("textarea[name^=optionDescription]:filled").length < 1; } }, hasFilledCorrectAnswer: { @@ -155,10 +155,10 @@ prepareAnswerEditorsForAjaxSubmit(); var hasFilledCorrectAnswer = false; - $("input[name^=answerCorrect]:checked").each(function() { + $("input[name^=optionCorrect]:checked").each(function() { var statusIndex = this.alt; - var answerDescription = $("textarea[name=answerDescription" + statusIndex + "]"); - hasFilledCorrectAnswer = answerDescription.val() != ""; + var optionDescription = $("textarea[name=optionDescription" + statusIndex + "]"); + hasFilledCorrectAnswer = optionDescription.val() != ""; }); return !hasFilledCorrectAnswer; @@ -186,18 +186,18 @@ debug: false, submitHandler: function(form) { prepareAnswerEditorsForAjaxSubmit(); - $("#answerList").val($("#answerForm").serialize(true)); + $("#optionList").val($("#answerForm").serialize(true)); $("#description").val(CKEDITOR.instances.description.getData()); - var answers = { + var items = { target: parent.jQuery('#itemArea'), success: function (responseText, statusText) { self.parent.refreshThickbox() self.parent.tb_remove(); } }; - $('#scratchieItemForm').ajaxSubmit(answers); + $('#scratchieItemForm').ajaxSubmit(items); } }); }); @@ -223,7 +223,7 @@ - + @@ -246,9 +246,9 @@ - +

- <%@ include file="answerlist.jsp"%> + <%@ include file="optionlist.jsp"%>   Fisheye: Tag 23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75 refers to a dead (removed) revision in file `lams_tool_scratchie/web/pages/authoring/parts/answerlist.jsp'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_scratchie/web/pages/authoring/parts/optionlist.jsp =================================================================== diff -u --- lams_tool_scratchie/web/pages/authoring/parts/optionlist.jsp (revision 0) +++ lams_tool_scratchie/web/pages/authoring/parts/optionlist.jsp (revision 23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75) @@ -0,0 +1,37 @@ +<%@ include file="/common/taglibs.jsp"%> + +
+ + + + + + + + + + + + + +
+ + + &#${status.index + 65};) + + + + checked="checked" > + + + + + + + + + + +
+
\ No newline at end of file Index: lams_tool_scratchie/web/pages/learning/learning.jsp =================================================================== diff -u -rfba7287887f6dd83d3098100af6320cccf1f3e36 -r23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75 --- lams_tool_scratchie/web/pages/learning/learning.jsp (.../learning.jsp) (revision fba7287887f6dd83d3098100af6320cccf1f3e36) +++ lams_tool_scratchie/web/pages/learning/learning.jsp (.../learning.jsp) (revision 23980a8cbd4e0d8d4e0b7ac4ad02e510d5653b75) @@ -63,10 +63,10 @@