Index: lams_tool_scratchie/conf/language/lams/ApplicationResources_en_AU.properties =================================================================== diff -u -r6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18 -r0ef117e7eca05b962210cb3b18eab1e39a6c57d1 --- lams_tool_scratchie/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18) +++ lams_tool_scratchie/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 0ef117e7eca05b962210cb3b18eab1e39a6c57d1) @@ -91,5 +91,15 @@ label.monitoring.summary.choose =Choose... label.monitoring.item.summary.group =Group: output.desc.learner.number.of.attempts =Number of attempts made by user +warning.msg.authoring.do.you.want.to.delete =Do you really want to delete this question? +warning.msg.are.you.sure.you.want.to.finish =Are you sure you want to finish? +label.authoring.add.blank.answer =Add Blank Answer +label.authoring.title.required =Title is required. +label.authoring.numerical.error.answer =You should provide at least one possible answer. +error.form.validation.error =You have 1 error in a form. It has been highlighted +error.form.validation.errors =You have {0} errors in a form. They have been highlighted +label.edit.question =Add/Edit Question +label.authoring.basic.question.name =Question title +label.authoring.basic.question.text =Question description #======= End labels: Exported 176 labels for en AU ===== Index: lams_tool_scratchie/conf/xdoclet/struts-actions.xml =================================================================== diff -u -r6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18 -r0ef117e7eca05b962210cb3b18eab1e39a6c57d1 --- lams_tool_scratchie/conf/xdoclet/struts-actions.xml (.../struts-actions.xml) (revision 6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18) +++ lams_tool_scratchie/conf/xdoclet/struts-actions.xml (.../struts-actions.xml) (revision 0ef117e7eca05b962210cb3b18eab1e39a6c57d1) @@ -72,9 +72,28 @@ + + + + + + + + @@ -99,6 +118,36 @@ + + + + + + + + + + + + + + + + getSummary(Long contentId); + + public List getLogsBySessionAndUser(Long sessionId, Long userId); + +} Fisheye: Tag 0ef117e7eca05b962210cb3b18eab1e39a6c57d1 refers to a dead (removed) revision in file `lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/ScratchieItemVisitDAO.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieAnswerVisitDAOHibernate.java =================================================================== diff -u --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieAnswerVisitDAOHibernate.java (revision 0) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieAnswerVisitDAOHibernate.java (revision 0ef117e7eca05b962210cb3b18eab1e39a6c57d1) @@ -0,0 +1,83 @@ +/**************************************************************** + * 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 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 + * **************************************************************** + */ +/* $$Id$$ */ +package org.lamsfoundation.lams.tool.scratchie.dao.hibernate; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.lamsfoundation.lams.tool.scratchie.dao.ScratchieAnswerVisitDAO; +import org.lamsfoundation.lams.tool.scratchie.model.Scratchie; +import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAnswerVisitLog; +import org.lamsfoundation.lams.tool.scratchie.model.ScratchieSession; + +public class ScratchieAnswerVisitDAOHibernate extends BaseDAOHibernate implements ScratchieAnswerVisitDAO { + + private static final String FIND_BY_ITEM_AND_USER = "from " + ScratchieAnswerVisitLog.class.getName() + + " as r where r.user.userId = ? and r.scratchieAnswer.uid=?"; + + private static final String FIND_BY_SESSION_AND_USER = "from " + ScratchieAnswerVisitLog.class.getName() + + " as r where r.sessionId = ? and r.user.userId=? order by r.accessDate asc"; + + private static final String FIND_VIEW_COUNT_BY_USER = "select count(*) from " + + ScratchieAnswerVisitLog.class.getName() + " as r where r.sessionId=? and r.user.userId =?"; + + private static final String FIND_SUMMARY = "select v.scratchieAnswer.uid, count(v.scratchieAnswer) from " + + ScratchieAnswerVisitLog.class.getName() + " as v , " + ScratchieSession.class.getName() + " as s, " + + Scratchie.class.getName() + " as r " + " where v.sessionId = s.sessionId " + + " and s.scratchie.uid = r.uid " + " and r.contentId =? " + " group by v.sessionId, v.scratchieAnswer.uid "; + + public ScratchieAnswerVisitLog getScratchieAnswerLog(Long answerUid, Long userId) { + List list = getHibernateTemplate().find(FIND_BY_ITEM_AND_USER, new Object[] { userId, answerUid }); + if (list == null || list.size() == 0) + return null; + return (ScratchieAnswerVisitLog) list.get(0); + } + + public int getUserViewLogCount(Long toolSessionId, Long userId) { + List list = getHibernateTemplate().find(FIND_VIEW_COUNT_BY_USER, new Object[] { toolSessionId, userId }); + if (list == null || list.size() == 0) + return 0; + return ((Number) list.get(0)).intValue(); + } + + public Map getSummary(Long contentId) { + + // Note: Hibernate 3.1 query.uniqueResult() returns Integer, Hibernate 3.2 query.uniqueResult() returns Long + List result = getHibernateTemplate().find(FIND_SUMMARY, contentId); + Map summaryList = new HashMap(result.size()); + for (Object[] list : result) { + if (list[1] != null) { + summaryList.put((Long) list[0], new Integer(((Number) list[1]).intValue())); + } + } + return summaryList; + + } + + public List getLogsBySessionAndUser(Long sessionId, Long userId) { + return getHibernateTemplate().find(FIND_BY_SESSION_AND_USER, new Object[] { sessionId, userId }); + } + +} Fisheye: Tag 0ef117e7eca05b962210cb3b18eab1e39a6c57d1 refers to a dead (removed) revision in file `lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieItemVisitDAOHibernate.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dto/GroupSummary.java =================================================================== diff -u --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dto/GroupSummary.java (revision 0) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dto/GroupSummary.java (revision 0ef117e7eca05b962210cb3b18eab1e39a6c57d1) @@ -0,0 +1,75 @@ +/**************************************************************** + * 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 + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.tool.scratchie.dto; + +import java.util.Collection; + +import org.lamsfoundation.lams.tool.scratchie.model.ScratchieUser; + +public class GroupSummary { + + private Long sessionId; + private String sessionName; + + private Collection users; + + /** + * Contruction method for monitoring summary function. + * + * Don't not set isInitGroup and viewNumber fields + * + * @param sessionName + * @param item + * @param isInitGroup + */ + public GroupSummary(Long sessionId, String sessionName) { + this.sessionId = sessionId; + this.sessionName = sessionName; + } + + public Long getSessionId() { + return sessionId; + } + + public void setSessionId(Long sessionId) { + this.sessionId = sessionId; + } + + public String getSessionName() { + return sessionName; + } + + public void setSessionName(String sessionName) { + this.sessionName = sessionName; + } + + public Collection getUsers() { + return users; + } + + public void setUsers(Collection users) { + this.users = users; + } + +} Fisheye: Tag 0ef117e7eca05b962210cb3b18eab1e39a6c57d1 refers to a dead (removed) revision in file `lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/GroupSummary.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieAnswer.java =================================================================== diff -u --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieAnswer.java (revision 0) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieAnswer.java (revision 0ef117e7eca05b962210cb3b18eab1e39a6c57d1) @@ -0,0 +1,137 @@ +/**************************************************************** + * 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 + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.tool.scratchie.model; + +import java.util.Date; + +import org.apache.log4j.Logger; + +/** + * Tool may contain several questions. Which in turn contain answers. + * + * @author Andrey Balan + * + * @hibernate.class table="tl_lascrt11_scratchie_answer" + * + */ +public class ScratchieAnswer implements Cloneable { + private static final Logger log = Logger.getLogger(ScratchieAnswer.class); + + private Long uid; + + private String description; + + private boolean correct; + + private Integer orderId; + + // *********************************************** + // DTO fields: + private boolean scratched; + private Date scratchedDate; + + // ********************************************************** + // Get/Set methods + // ********************************************************** + /** + * @hibernate.id generator-class="native" type="java.lang.Long" column="uid" + * @return Returns the uid. + */ + public Long getUid() { + return uid; + } + + /** + * @param uid + * The uid to set. + */ + public void setUid(Long userID) { + this.uid = userID; + } + + /** + * @hibernate.property column="description" type="text" + * @return + */ + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + /** + * @hibernate.property column="correct" + * @return + */ + public boolean isCorrect() { + return correct; + } + + public void setCorrect(boolean correctScratchie) { + this.correct = correctScratchie; + } + + /** + * @hibernate.property column="order_id" + * @return + */ + public Integer getOrderId() { + return orderId; + } + + public void setOrderId(Integer orderId) { + this.orderId = orderId; + } + + public void setScratched(boolean complete) { + this.scratched = complete; + } + + public boolean isScratched() { + return scratched; + } + + public Date getScratchedDate() { + return scratchedDate; + } + + public void setScratchedDate(Date scratchedDate) { + this.scratchedDate = scratchedDate; + } + + @Override + public Object clone() { + ScratchieAnswer obj = null; + try { + obj = (ScratchieAnswer) super.clone(); + obj.setUid(null); + } catch (CloneNotSupportedException e) { + ScratchieAnswer.log.error("When clone " + ScratchieAnswer.class + " failed"); + } + + return obj; + } +} Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieAnswerVisitLog.java =================================================================== diff -u --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieAnswerVisitLog.java (revision 0) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieAnswerVisitLog.java (revision 0ef117e7eca05b962210cb3b18eab1e39a6c57d1) @@ -0,0 +1,105 @@ +/**************************************************************** + * 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 + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.tool.scratchie.model; + +import java.util.Date; + +/** + * Scratchie + * + * @author Andrey Balan + * + * @hibernate.class table="tl_lascrt11_answer_log" + * + */ +public class ScratchieAnswerVisitLog { + + private Long uid; + private ScratchieUser user; + private ScratchieAnswer scratchieAnswer; + private Date accessDate; + private Long sessionId; + + /** + * @hibernate.property column="access_date" + * @return + */ + public Date getAccessDate() { + return accessDate; + } + + public void setAccessDate(Date accessDate) { + this.accessDate = accessDate; + } + + /** + * @hibernate.many-to-one column="scratchie_answer_uid" cascade="none" + * @return + */ + public ScratchieAnswer getScratchieAnswer() { + return scratchieAnswer; + } + + public void setScratchieAnswer(ScratchieAnswer item) { + this.scratchieAnswer = item; + } + + /** + * @hibernate.id generator-class="native" type="java.lang.Long" column="uid" + * @return Returns the log Uid. + */ + public Long getUid() { + return uid; + } + + public void setUid(Long uid) { + this.uid = uid; + } + + /** + * @hibernate.many-to-one column="user_uid" cascade="none" + * @return + */ + public ScratchieUser getUser() { + return user; + } + + public void setUser(ScratchieUser user) { + this.user = user; + } + + /** + * @hibernate.property column="session_id" + * @return + */ + public Long getSessionId() { + return sessionId; + } + + public void setSessionId(Long sessionId) { + this.sessionId = sessionId; + } + +} Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieItem.java =================================================================== diff -u -r6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18 -r0ef117e7eca05b962210cb3b18eab1e39a6c57d1 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieItem.java (.../ScratchieItem.java) (revision 6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieItem.java (.../ScratchieItem.java) (revision 0ef117e7eca05b962210cb3b18eab1e39a6c57d1) @@ -24,11 +24,14 @@ package org.lamsfoundation.lams.tool.scratchie.model; import java.util.Date; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; import org.apache.log4j.Logger; /** - * Scratchie + * Tool may contain several questions. Which in turn contain answers. * * @author Andrey Balan * @@ -39,38 +42,57 @@ private static final Logger log = Logger.getLogger(ScratchieItem.class); private Long uid; + + private String title; private String description; - private boolean correct; - private Integer orderId; private boolean isCreateByAuthor; private Date createDate; private ScratchieUser createBy; + + // scratchie Items + private Set answers; + + /** + * Default contruction method. + * + */ + public ScratchieItem() { + answers = new HashSet(); + } - // *********************************************** - // DTO fields: - private boolean scratched; - private Date scratchedDate; - public Object clone() { - ScratchieItem obj = null; + ScratchieItem item = null; try { - obj = (ScratchieItem) super.clone(); + item = (ScratchieItem) super.clone(); - ((ScratchieItem) obj).setUid(null); + ((ScratchieItem) item).setUid(null); + + if (answers != null) { + Iterator iter = answers.iterator(); + Set set = new HashSet(); + while (iter.hasNext()) { + ScratchieAnswer answer = (ScratchieAnswer) iter.next(); + ScratchieAnswer newAnswer = (ScratchieAnswer) answer.clone(); + // just clone old file without duplicate it in repository + set.add(newAnswer); + } + item.answers = set; + } + // clone ReourceUser as well if (this.createBy != null) - ((ScratchieItem) obj).setCreateBy((ScratchieUser) this.createBy.clone()); + ((ScratchieItem) item).setCreateBy((ScratchieUser) this.createBy.clone()); } catch (CloneNotSupportedException e) { log.error("When clone " + ScratchieItem.class + " failed"); } - return obj; + return item; } // ********************************************************** @@ -91,9 +113,21 @@ public void setUid(Long userID) { this.uid = userID; } + + /** + * @hibernate.property column="title" + * @return + */ + public String getTitle() { + return title; + } + public void setTitle(String title) { + this.title = title; + } + /** - * @hibernate.property column="description" + * @hibernate.property column="description" type="text" * @return */ public String getDescription() { @@ -140,18 +174,6 @@ public void setCreateByAuthor(boolean isCreateByAuthor) { this.isCreateByAuthor = isCreateByAuthor; } - - /** - * @hibernate.property column="correct" - * @return - */ - public boolean isCorrect() { - return correct; - } - - public void setCorrect(boolean correctScratchie) { - this.correct = correctScratchie; - } /** * @hibernate.property column="order_id" @@ -164,20 +186,19 @@ public void setOrderId(Integer orderId) { this.orderId = orderId; } - - public void setScratched(boolean complete) { - this.scratched = complete; - } - - public boolean isScratched() { - return scratched; - } - public Date getScratchedDate() { - return scratchedDate; + /** + * @hibernate.set inverse="false" cascade="all" order-by="order_id desc" + * @hibernate.collection-key column="scratchie_item_uid" + * @hibernate.collection-one-to-many class="org.lamsfoundation.lams.tool.scratchie.model.ScratchieAnswer" + * + * @return + */ + public Set getAnswers() { + return answers; } - public void setScratchedDate(Date scratchedDate) { - this.scratchedDate = scratchedDate; + public void setAnswers(Set answers) { + this.answers = answers; } } Fisheye: Tag 0ef117e7eca05b962210cb3b18eab1e39a6c57d1 refers to a dead (removed) revision in file `lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieItemVisitLog.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/scratchieApplicationContext.xml =================================================================== diff -u -r6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18 -r0ef117e7eca05b962210cb3b18eab1e39a6c57d1 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/scratchieApplicationContext.xml (.../scratchieApplicationContext.xml) (revision 6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/scratchieApplicationContext.xml (.../scratchieApplicationContext.xml) (revision 0ef117e7eca05b962210cb3b18eab1e39a6c57d1) @@ -22,7 +22,7 @@ - + @@ -63,8 +63,8 @@ - - + + @@ -125,7 +125,7 @@ PROPAGATION_REQUIRED,-java.lang.Exception PROPAGATION_REQUIRED,-java.lang.Exception PROPAGATION_REQUIRED,-java.lang.Exception - PROPAGATION_REQUIRED,-java.lang.Exception + PROPAGATION_REQUIRED,-java.lang.Exception PROPAGATION_REQUIRED,-java.lang.Exception PROPAGATION_REQUIRED,-java.lang.Exception PROPAGATION_REQUIRED,-java.lang.Exception Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/IScratchieService.java =================================================================== diff -u -r6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18 -r0ef117e7eca05b962210cb3b18eab1e39a6c57d1 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/IScratchieService.java (.../IScratchieService.java) (revision 6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/IScratchieService.java (.../IScratchieService.java) (revision 0ef117e7eca05b962210cb3b18eab1e39a6c57d1) @@ -31,13 +31,14 @@ import org.apache.struts.upload.FormFile; import org.lamsfoundation.lams.events.IEventNotificationService; import org.lamsfoundation.lams.notebook.model.NotebookEntry; +import org.lamsfoundation.lams.tool.scratchie.dto.GroupSummary; import org.lamsfoundation.lams.tool.scratchie.dto.ReflectDTO; import org.lamsfoundation.lams.tool.scratchie.dto.Summary; -import org.lamsfoundation.lams.tool.scratchie.model.GroupSummary; import org.lamsfoundation.lams.tool.scratchie.model.Scratchie; -import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAttachment; +import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAnswer; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieItem; -import org.lamsfoundation.lams.tool.scratchie.model.ScratchieItemVisitLog; +import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAnswerVisitLog; +import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAttachment; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieSession; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieUser; import org.lamsfoundation.lams.usermanagement.User; @@ -56,6 +57,8 @@ * @return */ Scratchie getScratchieByContentId(Long contentId); + + ScratchieAnswer getScratchieAnswerById (Long answerUid); /** * Get a cloned copy of tool default tool content (Scratchie) and assign the toolContentId of that copy as the given @@ -161,7 +164,7 @@ void retrieveScratched(Collection scratchieItemList, ScratchieUser user); - void setItemAccess(Long scratchieItemUid, Long userId, Long sessionId); + void setAnswerAccess(Long scratchieItemUid, Long userId, Long sessionId); int getNumberAttempts(Long userId, Long sessionId); @@ -178,7 +181,7 @@ List getMonitoringSummary(Long contentId); - List getUserMasterDetail(Long sessionId, Long userId); + List getUserMasterDetail(Long sessionId, Long userId); List getQuestionSummary(Long contentId, Long itemUid); Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java =================================================================== diff -u -r6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18 -r0ef117e7eca05b962210cb3b18eab1e39a6c57d1 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java (.../ScratchieServiceImpl.java) (revision 6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java (.../ScratchieServiceImpl.java) (revision 0ef117e7eca05b962210cb3b18eab1e39a6c57d1) @@ -73,19 +73,20 @@ import org.lamsfoundation.lams.tool.exception.SessionDataExistsException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.scratchie.ScratchieConstants; +import org.lamsfoundation.lams.tool.scratchie.dao.ScratchieItemDAO; +import org.lamsfoundation.lams.tool.scratchie.dao.ScratchieAnswerVisitDAO; import org.lamsfoundation.lams.tool.scratchie.dao.ScratchieAttachmentDAO; import org.lamsfoundation.lams.tool.scratchie.dao.ScratchieDAO; -import org.lamsfoundation.lams.tool.scratchie.dao.ScratchieItemDAO; -import org.lamsfoundation.lams.tool.scratchie.dao.ScratchieItemVisitDAO; import org.lamsfoundation.lams.tool.scratchie.dao.ScratchieSessionDAO; import org.lamsfoundation.lams.tool.scratchie.dao.ScratchieUserDAO; +import org.lamsfoundation.lams.tool.scratchie.dto.GroupSummary; import org.lamsfoundation.lams.tool.scratchie.dto.ReflectDTO; import org.lamsfoundation.lams.tool.scratchie.dto.Summary; -import org.lamsfoundation.lams.tool.scratchie.model.GroupSummary; import org.lamsfoundation.lams.tool.scratchie.model.Scratchie; -import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAttachment; +import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAnswer; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieItem; -import org.lamsfoundation.lams.tool.scratchie.model.ScratchieItemVisitLog; +import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAnswerVisitLog; +import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAttachment; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieSession; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieUser; import org.lamsfoundation.lams.tool.scratchie.util.ReflectDTOComparator; @@ -102,7 +103,7 @@ /** * - * @author Dapeng.Ni + * @author Andrey Balan */ public class ScratchieServiceImpl implements IScratchieService, ToolContentManager, ToolSessionManager, ToolContentImport102Manager { @@ -118,7 +119,7 @@ private ScratchieSessionDAO scratchieSessionDao; - private ScratchieItemVisitDAO scratchieItemVisitDao; + private ScratchieAnswerVisitDAO scratchieAnswerVisitDao; // tool service private ScratchieToolContentHandler scratchieToolContentHandler; @@ -389,32 +390,39 @@ public void retrieveScratched(Collection items, ScratchieUser user) { for (ScratchieItem item : items) { - ScratchieItemVisitLog log = scratchieItemVisitDao.getScratchieItemLog(item.getUid(), user.getUserId()); - if (log == null) { - item.setScratched(false); - } else { - item.setScratched(true); - item.setScratchedDate(log.getAccessDate()); + for (ScratchieAnswer answer : (Set)item.getAnswers()) { + ScratchieAnswerVisitLog log = scratchieAnswerVisitDao.getScratchieAnswerLog(answer.getUid(), + user.getUserId()); + if (log == null) { + answer.setScratched(false); + } else { + answer.setScratched(true); + answer.setScratchedDate(log.getAccessDate()); + } } } } - public void setItemAccess(Long scratchieItemUid, Long userId, Long sessionId) { - ScratchieItemVisitLog log = scratchieItemVisitDao.getScratchieItemLog(scratchieItemUid, userId); + public void setAnswerAccess(Long answerUid, Long userId, Long sessionId) { + ScratchieAnswerVisitLog log = scratchieAnswerVisitDao.getScratchieAnswerLog(answerUid, userId); if (log == null) { - log = new ScratchieItemVisitLog(); - ScratchieItem item = scratchieItemDao.getByUid(scratchieItemUid); - log.setScratchieItem(item); + log = new ScratchieAnswerVisitLog(); + ScratchieAnswer answer = getScratchieAnswerById(answerUid); + log.setScratchieAnswer(answer); ScratchieUser user = scratchieUserDao.getUserByUserIDAndSessionID(userId, sessionId); log.setUser(user); log.setSessionId(sessionId); log.setAccessDate(new Timestamp(new Date().getTime())); - scratchieItemVisitDao.saveObject(log); + scratchieAnswerVisitDao.saveObject(log); } } + public ScratchieAnswer getScratchieAnswerById (Long answerUid) { + return (ScratchieAnswer) userManagementService.findById(ScratchieAnswer.class, answerUid); + } + public int getNumberAttempts(Long userId, Long sessionId) { - return scratchieItemVisitDao.getUserViewLogCount(sessionId, userId); + return scratchieAnswerVisitDao.getUserViewLogCount(sessionId, userId); } public String finishToolSession(Long toolSessionId, Long userId) throws ScratchieApplicationException { @@ -454,7 +462,7 @@ List users = scratchieUserDao.getBySessionID(sessionId); for (ScratchieUser user : users) { - int attempts = scratchieItemVisitDao.getUserViewLogCount(sessionId, user.getUserId()); + int attempts = scratchieAnswerVisitDao.getUserViewLogCount(sessionId, user.getUserId()); int mark = (attempts == 0) ? -1 : scratchie.getScratchieItems().size() - attempts + 1; user.setTotalAttempts(attempts); @@ -468,8 +476,8 @@ return groupSummaryList; } - public List getUserMasterDetail(Long sessionId, Long userId) { - List logs = scratchieItemVisitDao.getLogsBySessionAndUser(sessionId, userId); + public List getUserMasterDetail(Long sessionId, Long userId) { + List logs = scratchieAnswerVisitDao.getLogsBySessionAndUser(sessionId, userId); return logs; } @@ -490,12 +498,12 @@ for (ScratchieUser user : users) { int attemptNumber; - ScratchieItemVisitLog log = scratchieItemVisitDao.getScratchieItemLog(itemUid, user.getUserId()); + ScratchieAnswerVisitLog log = scratchieAnswerVisitDao.getScratchieAnswerLog(itemUid, user.getUserId()); if (log == null) { //-1 if there is no log attemptNumber = -1; } else { - List allAttempts = scratchieItemVisitDao.getLogsBySessionAndUser(sessionId, user.getUserId()); + List allAttempts = scratchieAnswerVisitDao.getLogsBySessionAndUser(sessionId, user.getUserId()); attemptNumber = allAttempts.indexOf(log); } @@ -663,8 +671,8 @@ this.scratchieDao = scratchieDao; } - public void setScratchieItemDao(ScratchieItemDAO scratchieItemDao) { - this.scratchieItemDao = scratchieItemDao; + public void setScratchieItemDao(ScratchieItemDAO scratchieAnswerDao) { + this.scratchieItemDao = scratchieAnswerDao; } public void setScratchieSessionDao(ScratchieSessionDAO scratchieSessionDao) { @@ -683,12 +691,12 @@ this.toolService = toolService; } - public ScratchieItemVisitDAO getScratchieItemVisitDao() { - return scratchieItemVisitDao; + public ScratchieAnswerVisitDAO getScratchieAnswerVisitDao() { + return scratchieAnswerVisitDao; } - public void setScratchieItemVisitDao(ScratchieItemVisitDAO scratchieItemVisitDao) { - this.scratchieItemVisitDao = scratchieItemVisitDao; + public void setScratchieAnswerVisitDao(ScratchieAnswerVisitDAO scratchieItemVisitDao) { + this.scratchieAnswerVisitDao = scratchieItemVisitDao; } // ******************************************************************************* @@ -973,8 +981,6 @@ item.setCreateBy(ruser); item.setCreateByAuthor(true); - item.setCorrect(false); - items.put(itemOrder, item); } } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/util/ScratchieAnswerComparator.java =================================================================== diff -u --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/util/ScratchieAnswerComparator.java (revision 0) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/util/ScratchieAnswerComparator.java (revision 0ef117e7eca05b962210cb3b18eab1e39a6c57d1) @@ -0,0 +1,45 @@ +/**************************************************************** + * 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 + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.tool.scratchie.util; + +import java.util.Comparator; + +import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAnswer; + +public class ScratchieAnswerComparator implements Comparator { + + public int compare(ScratchieAnswer o1, ScratchieAnswer o2) { + + if (o1 != null && o2 != null & o1.getOrderId() != null && o2.getOrderId() != null) { + if (o1.getOrderId() > o2.getOrderId()) { + return 1; + } else { + return -1; + } + } else if (o1 != null) + return 1; + else + return -1; + } +} Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/AuthoringAction.java =================================================================== diff -u -r6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18 -r0ef117e7eca05b962210cb3b18eab1e39a6c57d1 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/AuthoringAction.java (.../AuthoringAction.java) (revision 6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/AuthoringAction.java (.../AuthoringAction.java) (revision 0ef117e7eca05b962210cb3b18eab1e39a6c57d1) @@ -59,13 +59,16 @@ import org.lamsfoundation.lams.tool.ToolAccessMode; import org.lamsfoundation.lams.tool.scratchie.ScratchieConstants; import org.lamsfoundation.lams.tool.scratchie.model.Scratchie; +import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAnswer; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAttachment; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieItem; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieUser; import org.lamsfoundation.lams.tool.scratchie.service.IScratchieService; import org.lamsfoundation.lams.tool.scratchie.service.UploadScratchieFileException; +import org.lamsfoundation.lams.tool.scratchie.util.ScratchieAnswerComparator; import org.lamsfoundation.lams.tool.scratchie.util.ScratchieItemComparator; import org.lamsfoundation.lams.tool.scratchie.web.form.ScratchieForm; +import org.lamsfoundation.lams.tool.scratchie.web.form.ScratchieItemForm; import org.lamsfoundation.lams.tool.scratchie.web.form.ScratchiePedagogicalPlannerForm; import org.lamsfoundation.lams.usermanagement.dto.UserDTO; import org.lamsfoundation.lams.util.FileValidatorUtil; @@ -87,7 +90,7 @@ public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { - // -----------------------Scratchie Author functions + // -----------------------Scratchie Author functions ----------- String param = mapping.getParameter(); if (param.equals("start")) { ToolAccessMode mode = getAccessMode(request); @@ -130,10 +133,16 @@ if (param.equals("deleteOfflineFile")) { return deleteOfflineFile(mapping, form, request, response); } - // ----------------------- Add scratchie item functions + // ----------------------- Scratchie item functions --------- if (param.equals("addItem")) { return addItem(mapping, form, request, response); } + if (param.equals("editItem")) { + return editItem(mapping, form, request, response); + } + if (param.equals("saveItem")) { + return saveItem(mapping, form, request, response); + } if (param.equals("removeItem")) { return removeItem(mapping, form, request, response); } @@ -143,7 +152,20 @@ if (param.equals("downItem")) { return downItem(mapping, form, request, response); } - // -----------------------PedagogicalPlanner functions + // ----------------------- Answers functions --------------- + if (param.equals("addAnswer")) { + return addAnswer(mapping, form, request, response); + } + if (param.equals("removeAnswer")) { + return removeAnswer(mapping, form, request, response); + } + if (param.equals("upAnswer")) { + return upAnswer(mapping, form, request, response); + } + if (param.equals("downAnswer")) { + return downAnswer(mapping, form, request, response); + } + // -----------------------PedagogicalPlanner functions --------- if (param.equals("initPedagogicalPlannerForm")) { return initPedagogicalPlannerForm(mapping, form, request, response); } @@ -219,7 +241,7 @@ ScratchieUser scratchieUser = null; // handle system default question: createBy is null, now set it to // current user - for (ScratchieItem item : items) { + for (ScratchieItem item : items) {item.getAnswers(); if (item.getCreateBy() == null) { if (scratchieUser == null) { // get back login user DTO @@ -251,13 +273,6 @@ /** * Display same entire authoring page content from HttpSession variable. - * - * @param mapping - * @param form - * @param request - * @param response - * @return - * @throws ServletException */ private ActionForward initPage(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws ServletException { @@ -282,13 +297,6 @@ /** * This method will persist all inforamtion in this authoring page, include all scratchie item, information etc. - * - * @param mapping - * @param form - * @param request - * @param response - * @return - * @throws ServletException */ private ActionForward updateContent(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { @@ -384,7 +392,7 @@ // ************************* Handle scratchie items ******************* // Handle scratchie items Set itemList = new LinkedHashSet(); - SortedSet topics = getItemsFromRequest(request, true); + SortedSet topics = getItemList(sessionMap); iter = topics.iterator(); while (iter.hasNext()) { ScratchieItem item = (ScratchieItem) iter.next(); @@ -426,13 +434,6 @@ /** * Handle upload online instruction files request. - * - * @param mapping - * @param form - * @param request - * @param response - * @return - * @throws UploadScratchieFileException */ public ActionForward uploadOnline(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws UploadScratchieFileException { @@ -441,13 +442,6 @@ /** * Handle upload offline instruction files request. - * - * @param mapping - * @param form - * @param request - * @param response - * @return - * @throws UploadScratchieFileException */ public ActionForward uploadOffline(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws UploadScratchieFileException { @@ -456,23 +450,16 @@ /** * Common method to upload online or offline instruction files request. - * - * @param mapping - * @param form - * @param type - * @param request - * @return - * @throws UploadScratchieFileException */ private ActionForward uploadFile(ActionMapping mapping, ActionForm form, String type, HttpServletRequest request) throws UploadScratchieFileException { - - SortedSet itemList = getItemsFromRequest(request, false); - request.setAttribute(ScratchieConstants.ATTR_ITEM_LIST, itemList); ScratchieForm scratchieForm = (ScratchieForm) form; // get back sessionMAP SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(scratchieForm.getSessionMapID()); + + SortedSet itemList = getItemList(sessionMap); + request.setAttribute(ScratchieConstants.ATTR_ITEM_LIST, itemList); FormFile file; if (StringUtils.equals(IToolContentHandler.TYPE_OFFLINE, type)) { @@ -522,12 +509,6 @@ /** * Delete offline instruction file from current Scratchie authoring page. - * - * @param mapping - * @param form - * @param request - * @param response - * @return */ public ActionForward deleteOfflineFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { @@ -536,12 +517,6 @@ /** * Delete online instruction file from current Scratchie authoring page. - * - * @param mapping - * @param form - * @param request - * @param response - * @return */ public ActionForward deleteOnlineFile(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { @@ -550,26 +525,20 @@ /** * General method to delete file (online or offline) - * - * @param mapping - * @param request - * @param response - * @param form - * @param type - * @return */ private ActionForward deleteFile(ActionMapping mapping, HttpServletRequest request, HttpServletResponse response, ActionForm form, String type) { - SortedSet itemList = getItemsFromRequest(request, false); + + // get back sessionMAP + String sessionMapID = WebUtil.readStrParam(request, ScratchieConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + + SortedSet itemList = getItemList(sessionMap); request.setAttribute(ScratchieConstants.ATTR_ITEM_LIST, itemList); Long versionID = new Long(WebUtil.readLongParam(request, ScratchieConstants.PARAM_FILE_VERSION_ID)); Long uuID = new Long(WebUtil.readLongParam(request, ScratchieConstants.PARAM_FILE_UUID)); - // get back sessionMAP - String sessionMapID = WebUtil.readStrParam(request, ScratchieConstants.ATTR_SESSION_MAP_ID); - SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); - // handle session value List attachmentList = getAttachmentList(sessionMap); List deleteAttachmentList = getDeletedAttachmentList(sessionMap); @@ -594,32 +563,112 @@ /** * Ajax call, will add one more input line for new resource item instruction. - * - * @param mapping - * @param form - * @param request - * @param response - * @return */ private ActionForward addItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { String sessionMapID = WebUtil.readStrParam(request, ScratchieConstants.ATTR_SESSION_MAP_ID); - request.setAttribute(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMapID); - SortedSet itemList = getItemsFromRequest(request, false); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + String contentFolderID = (String) sessionMap.get(AttributeNames.PARAM_CONTENT_FOLDER_ID); + ScratchieItemForm itemForm = (ScratchieItemForm) form; + itemForm.setSessionMapID(sessionMapID); + itemForm.setContentFolderID(contentFolderID); - ScratchieItem item = new ScratchieItem(); - int maxSeq = 1; - if (itemList != null && itemList.size() > 0) { - ScratchieItem last = itemList.last(); - maxSeq = last.getOrderId() + 1; + List answerList = new ArrayList(); + for (int i = 0; i < ScratchieConstants.INITIAL_ANSWERS_NUMBER; i++) { + ScratchieAnswer answer = new ScratchieAnswer(); + answer.setOrderId(i+1); + answerList.add(answer); } - item.setOrderId(maxSeq); - itemList.add(item); + request.setAttribute(ScratchieConstants.ATTR_ANSWER_LIST, answerList); - request.setAttribute(ScratchieConstants.ATTR_ITEM_LIST, itemList); + request.setAttribute(AttributeNames.PARAM_CONTENT_FOLDER_ID, contentFolderID); return mapping.findForward(ScratchieConstants.SUCCESS); } + + /** + * Display edit page for existed scratchie item. + */ + private ActionForward editItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + // get back sessionMAP + String sessionMapID = WebUtil.readStrParam(request, ScratchieConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + String contentFolderID = (String) sessionMap.get(AttributeNames.PARAM_CONTENT_FOLDER_ID); + + int itemIdx = NumberUtils.stringToInt(request.getParameter(ScratchieConstants.PARAM_ITEM_INDEX), -1); + ScratchieItem item = null; + if (itemIdx != -1) { + SortedSet itemList = getItemList(sessionMap); + List rList = new ArrayList(itemList); + item = rList.get(itemIdx); + if (item != null) { + ScratchieItemForm itemForm = (ScratchieItemForm) form; + itemForm.setTitle(item.getTitle()); + itemForm.setDescription(item.getDescription()); + if (itemIdx >= 0) { + itemForm.setItemIndex(new Integer(itemIdx).toString()); + } + + Set answerList = item.getAnswers(); + request.setAttribute(ScratchieConstants.ATTR_ANSWER_LIST, answerList); + + itemForm.setContentFolderID(contentFolderID); + } + } + request.setAttribute(AttributeNames.PARAM_CONTENT_FOLDER_ID, contentFolderID); + return mapping.findForward(ScratchieConstants.SUCCESS); + } + + /** + * This method will get necessary information from assessment question form and save or update into + * HttpSession AssessmentQuestionList. Notice, this save is not persist them into database, just save + * HttpSession temporarily. Only they will be persist when the entire authoring page is being + * persisted. + */ + private ActionForward saveItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + ScratchieItemForm itemForm = (ScratchieItemForm) form; + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(itemForm.getSessionMapID()); + // check whether it is "edit(old Question)" or "add(new Question)" + SortedSet itemList = getItemList(sessionMap); + int itemIdx = NumberUtils.stringToInt(itemForm.getItemIndex(), -1); + ScratchieItem item = null; + + if (itemIdx == -1) { // add + item = new ScratchieItem(); + item.setCreateDate(new Timestamp(new Date().getTime())); + int maxSeq = 1; + if (itemList != null && itemList.size() > 0) { + ScratchieItem last = itemList.last(); + maxSeq = last.getOrderId() + 1; + } + item.setOrderId(maxSeq); + itemList.add(item); + } else { // edit + List rList = new ArrayList(itemList); + item = rList.get(itemIdx); + } + + item.setTitle(itemForm.getTitle()); + item.setDescription(itemForm.getDescription()); + + // set options + Set answerList = getAnswersFromRequest(request, true); + Set answers = new LinkedHashSet(); + int orderId = 0; + for (ScratchieAnswer answer : answerList) { + answer.setOrderId(orderId++); + answers.add(answer); + } + item.setAnswers(answers); + + // set session map ID so that itemlist.jsp can get sessionMAP + request.setAttribute(ScratchieConstants.ATTR_SESSION_MAP_ID, itemForm.getSessionMapID()); + return mapping.findForward(ScratchieConstants.SUCCESS); + } /** * Ajax call, remove the given line of instruction of resource item. @@ -636,7 +685,7 @@ String sessionMapID = WebUtil.readStrParam(request, ScratchieConstants.ATTR_SESSION_MAP_ID); request.setAttribute(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMapID); SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); - SortedSet itemList = getItemsFromRequest(request, false); + SortedSet itemList = getItemList(sessionMap); int itemIndex = NumberUtils.stringToInt(request.getParameter(ScratchieConstants.PARAM_ITEM_INDEX), -1); if (itemIndex != -1) { @@ -655,7 +704,7 @@ } /** - * Move up current option. + * Move up current item. * * @param mapping * @param form @@ -665,11 +714,11 @@ */ private ActionForward upItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - return switchOption(mapping, request, true); + return switchItem(mapping, request, true); } /** - * Move down current option. + * Move down current item. * * @param mapping * @param form @@ -679,13 +728,14 @@ */ private ActionForward downItem(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { - return switchOption(mapping, request, false); + return switchItem(mapping, request, false); } - private ActionForward switchOption(ActionMapping mapping, HttpServletRequest request, boolean up) { + private ActionForward switchItem(ActionMapping mapping, HttpServletRequest request, boolean up) { String sessionMapID = WebUtil.readStrParam(request, ScratchieConstants.ATTR_SESSION_MAP_ID); request.setAttribute(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMapID); - SortedSet itemList = getItemsFromRequest(request, false); + SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); + SortedSet itemList = getItemList(sessionMap); int itemIndex = NumberUtils.stringToInt(request.getParameter(ScratchieConstants.PARAM_ITEM_INDEX), -1); if (itemIndex != -1) { @@ -714,6 +764,124 @@ return mapping.findForward(ScratchieConstants.SUCCESS); } + // ----------------------- Answers functions --------------- + + /** + * Ajax call, will add one more input line for new resource item instruction. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + private ActionForward addAnswer(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + SortedSet answerList = getAnswersFromRequest(request, false); + + ScratchieAnswer answer = new ScratchieAnswer(); + int maxSeq = 1; + if (answerList != null && answerList.size() > 0) { + ScratchieAnswer last = answerList.last(); + maxSeq = last.getOrderId() + 1; + } + answer.setOrderId(maxSeq); + answerList.add(answer); + + request.setAttribute(ScratchieConstants.ATTR_ANSWER_LIST, answerList); + request.setAttribute(AttributeNames.PARAM_CONTENT_FOLDER_ID, WebUtil.readStrParam(request, + AttributeNames.PARAM_CONTENT_FOLDER_ID)); + return mapping.findForward(ScratchieConstants.SUCCESS); + } + + /** + * Ajax call, remove the given answer. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + private ActionForward removeAnswer(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + SortedSet answerList = getAnswersFromRequest(request, false); + + int answerIndex = NumberUtils.stringToInt(request.getParameter(ScratchieConstants.PARAM_ANSWER_INDEX), -1); + if (answerIndex != -1) { + List rList = new ArrayList(answerList); + ScratchieAnswer answer = rList.remove(answerIndex); + answerList.clear(); + answerList.addAll(rList); + } + + request.setAttribute(ScratchieConstants.ATTR_ANSWER_LIST, answerList); + request.setAttribute(AttributeNames.PARAM_CONTENT_FOLDER_ID, WebUtil.readStrParam(request, + AttributeNames.PARAM_CONTENT_FOLDER_ID)); + return mapping.findForward(ScratchieConstants.SUCCESS); + } + + /** + * Move up current answer. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + private ActionForward upAnswer(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + return switchAnswer(mapping, request, true); + } + + /** + * Move down current answer. + * + * @param mapping + * @param form + * @param request + * @param response + * @return + */ + private ActionForward downAnswer(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + return switchAnswer(mapping, request, false); + } + + private ActionForward switchAnswer(ActionMapping mapping, HttpServletRequest request, boolean up) { + SortedSet answerList = getAnswersFromRequest(request, false); + + int itemIndex = NumberUtils.stringToInt(request.getParameter(ScratchieConstants.PARAM_ITEM_INDEX), -1); + if (itemIndex != -1) { + List rList = new ArrayList(answerList); + + // get current and the target item, and switch their sequnece + ScratchieAnswer item = rList.get(itemIndex); + ScratchieAnswer repOption; + if (up) { + repOption = rList.get(--itemIndex); + } else { + repOption = rList.get(++itemIndex); + } + + int upSeqId = repOption.getOrderId(); + repOption.setOrderId(item.getOrderId()); + item.setOrderId(upSeqId); + + // put back list, it will be sorted again + answerList.clear(); + answerList.addAll(rList); + } + + request.setAttribute(ScratchieConstants.ATTR_ANSWER_LIST, answerList); + return mapping.findForward(ScratchieConstants.SUCCESS); + } + + // ----------------------- PedagogicalPlannerForm --------------- + public ActionForward initPedagogicalPlannerForm(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) { ScratchiePedagogicalPlannerForm plannerForm = (ScratchiePedagogicalPlannerForm) form; @@ -816,32 +984,32 @@ * @param isForSaving whether the blank options will be preserved or not * */ - private TreeSet getItemsFromRequest(HttpServletRequest request, boolean isForSaving) { - Map paramMap = splitRequestParameter(request, ScratchieConstants.ATTR_ITEM_LIST); - Integer correctItemIndex = (paramMap.get(ScratchieConstants.ATTR_ITEM_CORRECT) == null) ? null - : NumberUtils.stringToInt(paramMap.get(ScratchieConstants.ATTR_ITEM_CORRECT)); + 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.stringToInt(paramMap.get(ScratchieConstants.ATTR_ANSWER_CORRECT)); - int count = NumberUtils.stringToInt(paramMap.get(ScratchieConstants.ATTR_ITEM_COUNT)); - TreeSet itemList = new TreeSet(new ScratchieItemComparator()); + int count = NumberUtils.stringToInt(paramMap.get(ScratchieConstants.ATTR_ANSWER_COUNT)); + TreeSet answerList = new TreeSet(new ScratchieAnswerComparator()); for (int i = 0; i < count; i++) { - String itemDescription = paramMap.get(ScratchieConstants.ATTR_ITEM_DESCRIPTION_PREFIX + i); - if ((itemDescription == null) && isForSaving) { + String answerDescription = paramMap.get(ScratchieConstants.ATTR_ANSWER_DESCRIPTION_PREFIX + i); + if ((answerDescription == null) && isForSaving) { continue; } - ScratchieItem item = new ScratchieItem(); - String orderIdStr = paramMap.get(ScratchieConstants.ATTR_ITEM_ORDER_ID_PREFIX + i); + ScratchieAnswer answer = new ScratchieAnswer(); + String orderIdStr = paramMap.get(ScratchieConstants.ATTR_ANSWER_ORDER_ID_PREFIX + i); Integer orderId = NumberUtils.stringToInt(orderIdStr); - item.setOrderId(orderId); - item.setDescription(itemDescription); - if ((correctItemIndex!=null) && correctItemIndex.equals(orderId)) { - item.setCorrect(true); + answer.setOrderId(orderId); + answer.setDescription(answerDescription); + if ((correctAnswerIndex!=null) && correctAnswerIndex.equals(orderId)) { + answer.setCorrect(true); } - itemList.add(item); + answerList.add(answer); } - return itemList; + return answerList; } /** Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java =================================================================== diff -u -r6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18 -r0ef117e7eca05b962210cb3b18eab1e39a6c57d1 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java (.../LearningAction.java) (revision 6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java (.../LearningAction.java) (revision 0ef117e7eca05b962210cb3b18eab1e39a6c57d1) @@ -50,6 +50,7 @@ import org.lamsfoundation.lams.tool.ToolAccessMode; import org.lamsfoundation.lams.tool.scratchie.ScratchieConstants; 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; @@ -197,11 +198,12 @@ sessionMap.put(ScratchieConstants.ATTR_ITEM_LIST, items); boolean scratchingLock = isUserFinished; - for (ScratchieItem item : items) { - if (item.isScratched() && item.isCorrect()) { - scratchingLock = true; - } - } + //TODO!!!! +// for (ScratchieItem item : items) { +// if (item.isScratched() && item.isCorrect()) { +// scratchingLock = true; +// } +// } sessionMap.put(ScratchieConstants.ATTR_SCRATCHING_LOCK, scratchingLock); @@ -228,9 +230,9 @@ String sessionMapID = WebUtil.readStrParam(request, ScratchieConstants.ATTR_SESSION_MAP_ID); SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID); - Long itemUid = NumberUtils.createLong(request.getParameter(ScratchieConstants.PARAM_ITEM_UID)); + Long answerUid = NumberUtils.createLong(request.getParameter(ScratchieConstants.PARAM_ANSWER_UID)); // get back the resource and item list and display them on page - ScratchieItem item = getScratchieService().getScratchieItemByUid(itemUid); + ScratchieAnswer answer = getScratchieService().getScratchieAnswerById(answerUid); String toolSessionIdStr = request.getParameter(ScratchieConstants.ATTR_TOOL_SESSION_ID); Long toolSessionId = NumberUtils.createLong(toolSessionIdStr); @@ -239,15 +241,15 @@ HttpSession ss = SessionManager.getSession(); // get back login user DTO UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER); - getScratchieService().setItemAccess(item.getUid(), new Long(user.getUserID().intValue()), toolSessionId); + getScratchieService().setAnswerAccess(answer.getUid(), new Long(user.getUserID().intValue()), toolSessionId); } - if (item == null) { + if (answer == null) { return mapping.findForward(ScratchieConstants.ERROR); } JSONObject JSONObject = new JSONObject(); - JSONObject.put(ScratchieConstants.ATTR_ITEM_CORRECT, item.isCorrect()); + JSONObject.put(ScratchieConstants.ATTR_ANSWER_CORRECT, answer.isCorrect()); response.setContentType("application/x-json"); response.getWriter().print(JSONObject); return null; Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/MonitoringAction.java =================================================================== diff -u -r6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18 -r0ef117e7eca05b962210cb3b18eab1e39a6c57d1 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/MonitoringAction.java (.../MonitoringAction.java) (revision 6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/MonitoringAction.java (.../MonitoringAction.java) (revision 0ef117e7eca05b962210cb3b18eab1e39a6c57d1) @@ -39,11 +39,11 @@ import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.tool.scratchie.ScratchieConstants; +import org.lamsfoundation.lams.tool.scratchie.dto.GroupSummary; import org.lamsfoundation.lams.tool.scratchie.dto.ReflectDTO; -import org.lamsfoundation.lams.tool.scratchie.model.GroupSummary; import org.lamsfoundation.lams.tool.scratchie.model.Scratchie; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieItem; -import org.lamsfoundation.lams.tool.scratchie.model.ScratchieItemVisitLog; +import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAnswerVisitLog; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieSession; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieUser; import org.lamsfoundation.lams.tool.scratchie.service.IScratchieService; @@ -110,7 +110,7 @@ HttpServletResponse response) { Long userId = WebUtil.readLongParam(request, AttributeNames.PARAM_USER_ID); Long sessionId = WebUtil.readLongParam(request, ScratchieConstants.PARAM_SESSION_ID); - List logs = getScratchieService().getUserMasterDetail(sessionId, userId); + List logs = getScratchieService().getUserMasterDetail(sessionId, userId); request.setAttribute(ScratchieConstants.ATTR_USER_SESSION_ID, sessionId); request.setAttribute(ScratchieConstants.ATTR_VISIT_LOGS, logs); Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/form/ScratchieItemForm.java =================================================================== diff -u --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/form/ScratchieItemForm.java (revision 0) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/form/ScratchieItemForm.java (revision 0ef117e7eca05b962210cb3b18eab1e39a6c57d1) @@ -0,0 +1,102 @@ +/**************************************************************** + * 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 + * **************************************************************** + */ + +/* $Id$ */ +package org.lamsfoundation.lams.tool.scratchie.web.form; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.apache.struts.action.ActionForm; +import org.apache.struts.action.ActionMapping; +import org.apache.struts.upload.FormFile; +import org.lamsfoundation.lams.tool.scratchie.model.Scratchie; + +/** + * + * Scratchie Item Form. + * + * @struts.form name="scratchieItemForm" + */ +public class ScratchieItemForm extends ActionForm { + private static final long serialVersionUID = 3599879328307492312L; + + private String itemIndex; + private String sessionMapID; + private String contentFolderID; + + // tool access mode; + private String mode; + + private String title; + private String description; + + public String getItemIndex() { + return itemIndex; + } + + public void setItemIndex(String itemIndex) { + this.itemIndex = itemIndex; + } + + public String getSessionMapID() { + return sessionMapID; + } + + public void setSessionMapID(String sessionMapID) { + this.sessionMapID = sessionMapID; + } + + public String getContentFolderID() { + return contentFolderID; + } + + public void setContentFolderID(String contentFolderID) { + this.contentFolderID = contentFolderID; + } + + public String getMode() { + return mode; + } + + public void setMode(String mode) { + this.mode = mode; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + +} Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/servlet/ExportServlet.java =================================================================== diff -u -r6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18 -r0ef117e7eca05b962210cb3b18eab1e39a6c57d1 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/servlet/ExportServlet.java (.../ExportServlet.java) (revision 6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/servlet/ExportServlet.java (.../ExportServlet.java) (revision 0ef117e7eca05b962210cb3b18eab1e39a6c57d1) @@ -43,8 +43,8 @@ import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants; import org.lamsfoundation.lams.tool.ToolAccessMode; import org.lamsfoundation.lams.tool.scratchie.ScratchieConstants; +import org.lamsfoundation.lams.tool.scratchie.dto.GroupSummary; import org.lamsfoundation.lams.tool.scratchie.dto.ReflectDTO; -import org.lamsfoundation.lams.tool.scratchie.model.GroupSummary; import org.lamsfoundation.lams.tool.scratchie.model.Scratchie; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieItem; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieSession; Index: lams_tool_scratchie/web/WEB-INF/tags/AuthoringButton.tag =================================================================== diff -u -r6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18 -r0ef117e7eca05b962210cb3b18eab1e39a6c57d1 --- lams_tool_scratchie/web/WEB-INF/tags/AuthoringButton.tag (.../AuthoringButton.tag) (revision 6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18) +++ lams_tool_scratchie/web/WEB-INF/tags/AuthoringButton.tag (.../AuthoringButton.tag) (revision 0ef117e7eca05b962210cb3b18eab1e39a6c57d1) @@ -83,15 +83,6 @@ } } function doSubmit_Form_Only() { - //check one answer should be selected as correct - var numberOfAnswers = $("input[name^=itemCorrect]:checked").length; - if (numberOfAnswers == 0) { - alert(""); - return; - } - - prepareItemEditorsForAjaxSubmit(); - $("#itemList").val($("#authoringForm").serialize(true)); document.getElementById("${formID}").submit(); } function doCancel() { Index: lams_tool_scratchie/web/includes/images/req.gif =================================================================== diff -u Binary files differ Index: lams_tool_scratchie/web/includes/images/warning.gif =================================================================== diff -u Binary files differ Index: lams_tool_scratchie/web/pages/authoring/authoring.jsp =================================================================== diff -u -r6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18 -r0ef117e7eca05b962210cb3b18eab1e39a6c57d1 --- lams_tool_scratchie/web/pages/authoring/authoring.jsp (.../authoring.jsp) (revision 6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18) +++ lams_tool_scratchie/web/pages/authoring/authoring.jsp (.../authoring.jsp) (revision 0ef117e7eca05b962210cb3b18eab1e39a6c57d1) @@ -10,8 +10,14 @@ <fmt:message key="label.author.title" /> <%@ include file="/common/tabbedheader.jsp"%> + + + + @@ -109,8 +115,11 @@
- - - + + ?sessionMapID=${sessionMapID}&KeepThis=true&TB_iframe=true&height=540&width=850&modal=true + + + +
Index: lams_tool_scratchie/web/pages/authoring/parts/additem.jsp =================================================================== diff -u --- lams_tool_scratchie/web/pages/authoring/parts/additem.jsp (revision 0) +++ lams_tool_scratchie/web/pages/authoring/parts/additem.jsp (revision 0ef117e7eca05b962210cb3b18eab1e39a6c57d1) @@ -0,0 +1,261 @@ + + +<%@ include file="/common/taglibs.jsp"%> + + + <%@ include file="/common/header.jsp"%> + + + + + + + + + + + + +
+ <%@ include file="/common/messages.jsp"%> + + + + + + + + + +

+ +

+ +
+ + Required field +
+ + +
+ +
+ + +
+ + +
+ <%@ include file="answerlist.jsp"%> + + + +
+

+ + + + + + + + + + +
+ + + + + + +
Index: lams_tool_scratchie/web/pages/authoring/parts/answerlist.jsp =================================================================== diff -u --- lams_tool_scratchie/web/pages/authoring/parts/answerlist.jsp (revision 0) +++ lams_tool_scratchie/web/pages/authoring/parts/answerlist.jsp (revision 0ef117e7eca05b962210cb3b18eab1e39a6c57d1) @@ -0,0 +1,70 @@ +<%@ include file="/common/taglibs.jsp"%> + +
+ + + + + + + + + + + + +
+ + + + + + + + + + +
+ + + &#${status.index + 65};) + +
+ +
+ checked="checked" > + + + + +
+ +
+ + " + onclick="upAnswer(${status.index})"> + + "> + + + + + + "> + + + " + onclick="downAnswer(${status.index})"> + + + " + onclick="removeAnswer(${status.index})" /> +
+
\ No newline at end of file Index: lams_tool_scratchie/web/pages/authoring/parts/itemlist.jsp =================================================================== diff -u -r6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18 -r0ef117e7eca05b962210cb3b18eab1e39a6c57d1 --- lams_tool_scratchie/web/pages/authoring/parts/itemlist.jsp (.../itemlist.jsp) (revision 6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18) +++ lams_tool_scratchie/web/pages/authoring/parts/itemlist.jsp (.../itemlist.jsp) (revision 0ef117e7eca05b962210cb3b18eab1e39a6c57d1) @@ -2,37 +2,13 @@ - + - + + + Index: lams_tool_scratchie/web/pages/learning/learning.jsp =================================================================== diff -u -r6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18 -r0ef117e7eca05b962210cb3b18eab1e39a6c57d1 --- lams_tool_scratchie/web/pages/learning/learning.jsp (.../learning.jsp) (revision 6aaee4b2fe2caa08b0c63a0de11f05042d5a3e18) +++ lams_tool_scratchie/web/pages/learning/learning.jsp (.../learning.jsp) (revision 0ef117e7eca05b962210cb3b18eab1e39a6c57d1) @@ -30,42 +30,46 @@ //hide finish button if user haven't guessed correct answer nor used all attempts - $("#finishButton").hide(); + //$("#finishButton").hide(); }); - function scratchItem(itemUid){ + function scratchItem(answerUid){ $.ajax({ async: false, url: '', - data: 'sessionMapID=${sessionMapID}&mode=${mode}&toolSessionID=${toolSessionID}&itemUid=' + itemUid, + data: 'sessionMapID=${sessionMapID}&mode=${mode}&toolSessionID=${toolSessionID}&answerUid=' + answerUid, dataType: 'json', type: 'post', success: function (json) { - if (json.itemCorrect) { + if (json.answerCorrect) { //show animation - $('#image' + itemUid).attr("src", "?reqID=" + (new Date()).getTime()); + $('#image' + answerUid).attr("src", "?reqID=" + (new Date()).getTime()); disableScratching(); } else { //show animation, disable onclick, move to the bottom this item - $('#image' + itemUid).attr("src", "?reqID=" + (new Date()).getTime()); - $('#imageLink' + itemUid).removeAttr('onclick'); + $('#image' + answerUid).attr("src", "?reqID=" + (new Date()).getTime()); + $('#imageLink' + answerUid).removeAttr('onclick'); } } }); } function disableScratching() { - $("[id^=imageLink]").removeAttr('onclick'); - $("img", $("#scratches")).not("img[src*='scratchie-correct-animation.gif']").not("img[src*='scratchie-correct.gif']").fadeTo(1300, 0.3); - $("#finishButton").show(); + //$("[id^=imageLink]").removeAttr('onclick'); + //$("img", $("#scratches")).not("img[src*='scratchie-correct-animation.gif']").not("img[src*='scratchie-correct.gif']").fadeTo(1300, 0.3); + //$("#finishButton").show(); } function finishSession(){ - document.getElementById("finishButton").disabled = true; - document.location.href =''; - return false; + //var finishConfirmed = confirm(""); + + //if (finishConfirmed) { + document.getElementById("finishButton").disabled = true; + document.location.href =''; + return false; + //} } function continueReflect(){ document.location.href=''; @@ -86,34 +90,40 @@ <%@ include file="/common/messages.jsp"%> + +

${item.title}

+

${item.description}

+
- - - - - - - - - - -
- - - &#${status.index + 65};) - -
- -
- checked="checked" > - - - - -
- + ${item.title}
@@ -59,10 +35,20 @@ onclick="downItem(${status.index})"> + + ?sessionMapID=${sessionMapID}&itemIndex=${status.index}&KeepThis=true&TB_iframe=true&height=540&width=850&modal=true + + + " style="border-style: none;"/> + + " + title="" onclick="removeItem(${status.index})" />
- - + +
- + - + - - + + - ${item.description} + ${answer.description}
+ +