Index: lams_tool_scratchie/conf/xdoclet/struts-actions.xml =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scratchie/conf/xdoclet/struts-actions.xml,v diff -u -r1.20.2.2 -r1.20.2.3 --- lams_tool_scratchie/conf/xdoclet/struts-actions.xml 3 Jul 2015 15:42:12 -0000 1.20.2.2 +++ lams_tool_scratchie/conf/xdoclet/struts-actions.xml 5 Apr 2016 17:24:33 -0000 1.20.2.3 @@ -212,6 +212,14 @@ + + + + + + + + + @@ -75,6 +80,9 @@ + + + Fisheye: Tag 1.1.2.1 refers to a dead (removed) revision in file `lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/BurningQuestionLikeDAO.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/ScratchieBurningQuestionDAO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/ScratchieBurningQuestionDAO.java,v diff -u -r1.2.2.3 -r1.2.2.4 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/ScratchieBurningQuestionDAO.java 3 Jul 2015 20:24:51 -0000 1.2.2.3 +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/ScratchieBurningQuestionDAO.java 5 Apr 2016 17:24:33 -0000 1.2.2.4 @@ -25,11 +25,12 @@ import java.util.List; +import org.lamsfoundation.lams.tool.scratchie.dto.BurningQuestionDTO; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieBurningQuestion; public interface ScratchieBurningQuestionDAO extends DAO { - List getBurningQuestionsByItemUid(Long itemUid); + List getBurningQuestionsByContentId(Long scratchieUid, Long sessionId); ScratchieBurningQuestion getBurningQuestionBySessionAndItem(Long sessionId, Long itemUid); Fisheye: Tag 1.1.2.1 refers to a dead (removed) revision in file `lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/BurningQuestionLikeDAOHibernate.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieBurningQuestionDAOHibernate.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieBurningQuestionDAOHibernate.java,v diff -u -r1.2.2.3 -r1.2.2.4 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieBurningQuestionDAOHibernate.java 3 Jul 2015 20:24:52 -0000 1.2.2.3 +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieBurningQuestionDAOHibernate.java 5 Apr 2016 17:24:33 -0000 1.2.2.4 @@ -23,10 +23,17 @@ /* $Id$ */ package org.lamsfoundation.lams.tool.scratchie.dao.hibernate; +import java.util.ArrayList; import java.util.List; +import org.hibernate.Hibernate; +import org.hibernate.SQLQuery; +import org.hibernate.type.IntegerType; +import org.hibernate.type.LongType; +import org.hibernate.type.StringType; import org.lamsfoundation.lams.dao.hibernate.LAMSBaseDAO; import org.lamsfoundation.lams.tool.scratchie.dao.ScratchieBurningQuestionDAO; +import org.lamsfoundation.lams.tool.scratchie.dto.BurningQuestionDTO; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieBurningQuestion; public class ScratchieBurningQuestionDAOHibernate extends LAMSBaseDAO implements ScratchieBurningQuestionDAO { @@ -49,8 +56,57 @@ // } @Override - public List getBurningQuestionsByItemUid(Long itemUid) { - return (List) this.doFind(FIND_BY_ITEM_UID, new Object[] { itemUid}); + @SuppressWarnings("unchecked") + public List getBurningQuestionsByContentId(Long scratchieUid, Long sessionId) { + + /* Thread based lookups - Returns a complex structure so that the likes information can be passed + * back with it. */ + String GET_BURNING_QUESTIONS_WITH_LIKES = + "SELECT bq.*, ANY_VALUE(session.session_name) sessionName, count(like1.uid) total_likes "; + //in case sessionId is provided - we need to also return which burning questions leader has liked + if (sessionId != null) { + GET_BURNING_QUESTIONS_WITH_LIKES += + ", EXISTS(select * from tl_lascrt11_burning_que_like like2 where bq.uid = like2.burning_question_uid AND like2.session_id=:sessionId) user_liked"; + } + GET_BURNING_QUESTIONS_WITH_LIKES += + " FROM tl_lascrt11_burning_question bq " + + " JOIN tl_lascrt11_session session" + + " ON session.scratchie_uid = :scratchieUid AND bq.session_id = session.session_id " + + " LEFT JOIN tl_lascrt11_burning_que_like like1 ON bq.uid = like1.burning_question_uid " + + " WHERE bq.question IS NOT NULL AND bq.question != ''" + + " GROUP BY bq.uid"; + + SQLQuery query = getSession().createSQLQuery(GET_BURNING_QUESTIONS_WITH_LIKES); + query.addEntity("bq", ScratchieBurningQuestion.class) + .addScalar("sessionName", StringType.INSTANCE) + .addScalar("total_likes", IntegerType.INSTANCE) + .setLong("scratchieUid", scratchieUid); + if (sessionId != null) { + query.addScalar("user_liked", IntegerType.INSTANCE) + .setLong("sessionId", sessionId); + } + List rawObjects = query.list(); + +// Comparator comparator = ICommentService.SORT_BY_LIKE.equals(sortBy) ? new TopicComparatorLike() : new TopicComparator(); +// SortedSet results = new TreeSet(comparator); + List results = new ArrayList(); + for ( Object[] rawObject : rawObjects ) { + + ScratchieBurningQuestion burningQuestion = (ScratchieBurningQuestion) rawObject[0]; + String sessionName = (String) rawObject[1]; + Integer likeCount = (Integer) rawObject[2]; + + BurningQuestionDTO burningQuestionDTO = new BurningQuestionDTO(); + burningQuestionDTO.setBurningQuestion(burningQuestion); + burningQuestionDTO.setLikeCount(likeCount != null ? likeCount : 0); + if (sessionId != null) { + boolean userLiked = (Integer) rawObject[3] == 1; + burningQuestionDTO.setUserLiked(userLiked); + } + burningQuestionDTO.setSessionName(sessionName); + results.add(burningQuestionDTO); + } + return results; } @Override Fisheye: Tag 1.1.2.1 refers to a dead (removed) revision in file `lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dbupdates/patch20160329.sql'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dto/BurningQuestionDTO.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dto/BurningQuestionDTO.java,v diff -u -r1.1.2.3 -r1.1.2.4 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dto/BurningQuestionDTO.java 3 Jul 2015 20:24:52 -0000 1.1.2.3 +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dto/BurningQuestionDTO.java 5 Apr 2016 17:24:33 -0000 1.1.2.4 @@ -23,29 +23,53 @@ /* $Id$ */ package org.lamsfoundation.lams.tool.scratchie.dto; -import java.util.Map; - import org.lamsfoundation.lams.tool.scratchie.model.ScratchieBurningQuestion; -import org.lamsfoundation.lams.tool.scratchie.model.ScratchieItem; public class BurningQuestionDTO { - private ScratchieItem item; + private ScratchieBurningQuestion burningQuestion; + private String escapedBurningQuestion; + private String sessionName; - private Map groupNameToBurningQuestion; + private Integer likeCount; + private boolean userLiked; - public ScratchieItem getItem() { - return item; + public ScratchieBurningQuestion getBurningQuestion() { + return burningQuestion; } - public void setItem(ScratchieItem item) { - this.item = item; + public void setBurningQuestion(ScratchieBurningQuestion burningQuestion) { + this.burningQuestion = burningQuestion; } + + public String getEscapedBurningQuestion() { + return escapedBurningQuestion; + } - public Map getGroupNameToBurningQuestion() { - return groupNameToBurningQuestion; + public void setEscapedBurningQuestion(String escapedBurningQuestion) { + this.escapedBurningQuestion = escapedBurningQuestion; } + + public String getSessionName() { + return sessionName; + } - public void setGroupNameToBurningQuestion(Map leaderNameToBurningQuestion) { - this.groupNameToBurningQuestion = leaderNameToBurningQuestion; + public void setSessionName(String sessionName) { + this.sessionName = sessionName; } + + public Integer getLikeCount() { + return likeCount; + } + + public void setLikeCount(Integer likeCount) { + this.likeCount = likeCount; + } + + public boolean isUserLiked() { + return userLiked; + } + + public void setUserLiked(boolean userLiked) { + this.userLiked = userLiked; + } } Fisheye: Tag 1.1.2.1 refers to a dead (removed) revision in file `lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dto/BurningQuestionItemDTO.java'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 1.1.2.1 refers to a dead (removed) revision in file `lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/BurningQuestionLike.java'. Fisheye: No comparison available. Pass `N' to diff? Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/IScratchieService.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/IScratchieService.java,v diff -u -r1.29.2.2 -r1.29.2.3 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/IScratchieService.java 3 Jul 2015 20:24:52 -0000 1.29.2.2 +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/IScratchieService.java 5 Apr 2016 17:24:33 -0000 1.29.2.3 @@ -31,6 +31,7 @@ import org.lamsfoundation.lams.events.IEventNotificationService; import org.lamsfoundation.lams.notebook.model.NotebookEntry; 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.ReflectDTO; import org.lamsfoundation.lams.tool.scratchie.model.Scratchie; @@ -224,13 +225,18 @@ List getQuestionSummary(Long contentId, Long itemUid); /** - * Get BurningQuestionDtos used for summary tab + * In order to group BurningQuestions by items, organise them as a list of BurningQuestionItemDTOs. * * @param scratchie + * @param sessionId optional parameter, if it's specified, BurningQuestionDTOs will also contain information what leader of this group has liked * @return */ - List getBurningQuestionDtos(Scratchie scratchie); + List getBurningQuestionDtos(Scratchie scratchie, Long sessionId); + boolean addLike(Long burningQuestionUid, Long sessionId); + + void removeLike(Long burningQuestionUid, Long sessionId); + /** * Export excel spreadheet * Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java,v diff -u -r1.51.2.16 -r1.51.2.17 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java 18 Feb 2016 15:44:46 -0000 1.51.2.16 +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java 5 Apr 2016 17:24:33 -0000 1.51.2.17 @@ -66,6 +66,7 @@ import org.lamsfoundation.lams.tool.exception.DataMissingException; import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.scratchie.ScratchieConstants; +import org.lamsfoundation.lams.tool.scratchie.dao.BurningQuestionLikeDAO; import org.lamsfoundation.lams.tool.scratchie.dao.ScratchieAnswerVisitDAO; import org.lamsfoundation.lams.tool.scratchie.dao.ScratchieBurningQuestionDAO; import org.lamsfoundation.lams.tool.scratchie.dao.ScratchieConfigItemDAO; @@ -74,6 +75,7 @@ import org.lamsfoundation.lams.tool.scratchie.dao.ScratchieSessionDAO; import org.lamsfoundation.lams.tool.scratchie.dao.ScratchieUserDAO; 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.ReflectDTO; import org.lamsfoundation.lams.tool.scratchie.model.Scratchie; @@ -117,6 +119,8 @@ private ScratchieBurningQuestionDAO scratchieBurningQuestionDao; + private BurningQuestionLikeDAO burningQuestionLikeDao; + private ScratchieConfigItemDAO scratchieConfigItemDao; // tool service @@ -775,68 +779,77 @@ } @Override - public List getBurningQuestionDtos(Scratchie scratchie) { + public List getBurningQuestionDtos(Scratchie scratchie, Long sessionId) { Set items = new TreeSet(new ScratchieItemComparator()); items.addAll(scratchie.getScratchieItems()); - // get all available leaders associated with this content as only leaders have reflections - List sessionList = scratchieSessionDao.getByContentId(scratchie.getContentId()); - - List burningQuestionDtos = new LinkedList(); + List burningQuestionDtos = scratchieBurningQuestionDao + .getBurningQuestionsByContentId(scratchie.getUid(), sessionId); + + //in order to group BurningQuestions by items, organise them as a list of BurningQuestionItemDTOs + List burningQuestionItemDtos = new ArrayList(); for (ScratchieItem item : items) { - BurningQuestionDTO burningQuestionDTO = new BurningQuestionDTO(); - burningQuestionDTO.setItem(item); - List burningQuestions = scratchieBurningQuestionDao - .getBurningQuestionsByItemUid(item.getUid()); + List burningQuestionDtosOfSpecifiedItem = new ArrayList(); - Map groupNameToBurningQuestion = new LinkedHashMap(); - for (ScratchieBurningQuestion burningQuestion : burningQuestions) { - - // find corresponding session - ScratchieSession session = null; - for (ScratchieSession sessionIter : sessionList) { - if (burningQuestion.getSessionId().equals(sessionIter.getSessionId())) { - session = sessionIter; - break; - } + for (BurningQuestionDTO burningQuestionDto : burningQuestionDtos) { + ScratchieBurningQuestion burningQuestion = burningQuestionDto.getBurningQuestion(); + + //general burning question is handled further down + if (!burningQuestion.isGeneralQuestion() && item.getUid().equals(burningQuestion.getScratchieItem().getUid())) { + burningQuestionDtosOfSpecifiedItem.add(burningQuestionDto); } - - String groupName = StringEscapeUtils.escapeJavaScript(session.getSessionName()); - String burningQuestionText = StringEscapeUtils.escapeJavaScript(burningQuestion.getQuestion()); - groupNameToBurningQuestion.put(groupName, burningQuestionText); } - burningQuestionDTO.setGroupNameToBurningQuestion(groupNameToBurningQuestion); - - burningQuestionDtos.add(burningQuestionDTO); + + BurningQuestionItemDTO burningQuestionItemDto = new BurningQuestionItemDTO(); + burningQuestionItemDto.setScratchieItem(item); + burningQuestionItemDto.setBurningQuestionDtos(burningQuestionDtosOfSpecifiedItem); + burningQuestionItemDtos.add(burningQuestionItemDto); } - // general burning question - BurningQuestionDTO generalBurningQuestionDTO = new BurningQuestionDTO(); + // handle general burning question + BurningQuestionItemDTO generalBurningQuestionItemDto = new BurningQuestionItemDTO(); ScratchieItem generalDummyItem = new ScratchieItem(); generalDummyItem.setUid(0L); final String generalQuestionMessage = messageService.getMessage("label.general.burning.question"); generalDummyItem.setTitle(generalQuestionMessage); - generalBurningQuestionDTO.setItem(generalDummyItem); - Map groupNameToBurningQuestion = new LinkedHashMap(); - generalBurningQuestionDTO.setGroupNameToBurningQuestion(groupNameToBurningQuestion); - for (ScratchieSession session : sessionList) { - - ScratchieBurningQuestion burningQuestion = scratchieBurningQuestionDao - .getGeneralBurningQuestionBySession(session.getSessionId()); - if (burningQuestion == null) { - continue; + generalBurningQuestionItemDto.setScratchieItem(generalDummyItem); + List burningQuestionDtosOfSpecifiedItem = new ArrayList(); + for (BurningQuestionDTO burningQuestionDto : burningQuestionDtos) { + ScratchieBurningQuestion burningQuestion = burningQuestionDto.getBurningQuestion(); + + if (burningQuestion.isGeneralQuestion()) { + burningQuestionDtosOfSpecifiedItem.add(burningQuestionDto); } + } + generalBurningQuestionItemDto.setBurningQuestionDtos(burningQuestionDtosOfSpecifiedItem); + burningQuestionItemDtos.add(generalBurningQuestionItemDto); + + //escape for Javascript + for (BurningQuestionItemDTO burningQuestionItemDto : burningQuestionItemDtos) { + for (BurningQuestionDTO burningQuestionDto : burningQuestionItemDto.getBurningQuestionDtos()) { + String escapedSessionName = StringEscapeUtils.escapeJavaScript(burningQuestionDto.getSessionName()); + burningQuestionDto.setSessionName(escapedSessionName); - String groupName = StringEscapeUtils.escapeJavaScript(session.getSessionName()); - String burningQuestionText = StringEscapeUtils.escapeJavaScript(burningQuestion.getQuestion()); - groupNameToBurningQuestion.put(groupName, burningQuestionText); + String escapedBurningQuestion = StringEscapeUtils + .escapeJavaScript(burningQuestionDto.getBurningQuestion().getQuestion()); + burningQuestionDto.setEscapedBurningQuestion(escapedBurningQuestion); + } } - burningQuestionDtos.add(generalBurningQuestionDTO); - return burningQuestionDtos; + return burningQuestionItemDtos; } + + @Override + public boolean addLike(Long burningQuestionUid, Long sessionId) { + return burningQuestionLikeDao.addLike(burningQuestionUid, sessionId); + } + + @Override + public void removeLike(Long burningQuestionUid, Long sessionId) { + burningQuestionLikeDao.removeLike(burningQuestionUid, sessionId); + } @Override public List getReflectionList(Long contentId) { @@ -1046,7 +1059,8 @@ for (int i = 0; i < percentages.length; i++) { sum += percentages[i]; } - int avgMean = sum / percentages.length; + int percentagesLength = percentages.length == 0 ? 1 : percentages.length; + int avgMean = sum / percentagesLength; row = new ExcelCell[numberOfItems + 3]; row[0] = new ExcelCell(getMessage("label.avg.mean"), false); row[numberOfItems + 2] = new ExcelCell(avgMean + "%", false); @@ -1453,31 +1467,38 @@ ExcelCell[][] fourthPageData = rowList.toArray(new ExcelCell[][] {}); dataToExport.put(getMessage("label.spss.analysis"), fourthPageData); - + // ======================================================= Burning questions page // ======================================= - + if (scratchie.isBurningQuestionsEnabled()) { rowList = new LinkedList(); row = new ExcelCell[1]; row[0] = new ExcelCell(getMessage("label.burning.questions"), true); rowList.add(row); rowList.add(ScratchieServiceImpl.EMPTY_ROW); + + row = new ExcelCell[3]; + row[0] = new ExcelCell(getMessage("label.monitoring.summary.user.name"), IndexedColors.BLUE); + row[1] = new ExcelCell(getMessage("label.burning.questions"), IndexedColors.BLUE); + row[2] = new ExcelCell(getMessage("label.count"), IndexedColors.BLUE); + rowList.add(row); - List burningQuestionDtos = getBurningQuestionDtos(scratchie); - for (BurningQuestionDTO burningQuestionDto : burningQuestionDtos) { - ScratchieItem item = burningQuestionDto.getItem(); + List burningQuestionItemDtos = getBurningQuestionDtos(scratchie, null); + for (BurningQuestionItemDTO burningQuestionItemDto : burningQuestionItemDtos) { + ScratchieItem item = burningQuestionItemDto.getScratchieItem(); row = new ExcelCell[1]; row[0] = new ExcelCell(item.getTitle(), false); rowList.add(row); - - Map groupNameToBurningQuestion = burningQuestionDto.getGroupNameToBurningQuestion(); - for (String groupName : groupNameToBurningQuestion.keySet()) { - String burningQuestion = groupNameToBurningQuestion.get(groupName); - row = new ExcelCell[2]; - row[0] = new ExcelCell(groupName, false); + + List burningQuestionDtos = burningQuestionItemDto.getBurningQuestionDtos(); + for (BurningQuestionDTO burningQuestionDto : burningQuestionDtos) { + String burningQuestion = burningQuestionDto.getBurningQuestion().getQuestion(); + row = new ExcelCell[3]; + row[0] = new ExcelCell(burningQuestionDto.getSessionName(), false); row[1] = new ExcelCell(burningQuestion, false); + row[2] = new ExcelCell(burningQuestionDto.getLikeCount(), false); rowList.add(row); } rowList.add(ScratchieServiceImpl.EMPTY_ROW); @@ -1643,6 +1664,10 @@ this.scratchieBurningQuestionDao = scratchieBurningQuestionDao; } + public void setBurningQuestionLikeDao(BurningQuestionLikeDAO burningQuestionLikeDao) { + this.burningQuestionLikeDao = burningQuestionLikeDao; + } + public void setScratchieConfigItemDao(ScratchieConfigItemDAO scratchieConfigItemDao) { this.scratchieConfigItemDao = scratchieConfigItemDao; } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java,v diff -u -r1.44.2.8 -r1.44.2.9 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java 13 Aug 2015 10:01:29 -0000 1.44.2.8 +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java 5 Apr 2016 17:24:33 -0000 1.44.2.9 @@ -55,7 +55,7 @@ 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.BurningQuestionDTO; +import org.lamsfoundation.lams.tool.scratchie.dto.BurningQuestionItemDTO; import org.lamsfoundation.lams.tool.scratchie.dto.ReflectDTO; import org.lamsfoundation.lams.tool.scratchie.model.Scratchie; import org.lamsfoundation.lams.tool.scratchie.model.ScratchieAnswer; @@ -116,6 +116,12 @@ if (param.equals("showResults")) { return showResults(mapping, form, request, response); } + if (param.equals("like")) { + return like(mapping, form, request, response); + } + if (param.equals("removeLike")) { + return removeLike(mapping, form, request, response); + } // ================ Reflection ======================= if (param.equals("newReflection")) { @@ -503,8 +509,8 @@ // display other groups' BurningQuestions if (isBurningQuestionsEnabled) { Scratchie scratchie = toolSession.getScratchie(); - List burningQuestionDtos = LearningAction.service.getBurningQuestionDtos(scratchie); - request.setAttribute(ScratchieConstants.ATTR_BURNING_QUESTIONS_DTOS, burningQuestionDtos); + List burningQuestionItemDtos = LearningAction.service.getBurningQuestionDtos(scratchie, toolSessionId); + request.setAttribute(ScratchieConstants.ATTR_BURNING_QUESTION_ITEM_DTOS, burningQuestionItemDtos); } // display other groups' notebooks @@ -533,8 +539,66 @@ return mapping.findForward(ScratchieConstants.SUCCESS); } + + /** + * @throws ServletException + * @throws ScratchieApplicationException + */ + private synchronized ActionForward like(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws JSONException, IOException, ServletException, ScratchieApplicationException { + initializeScratchieService(); + + String sessionMapID = WebUtil.readStrParam(request, ScratchieConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession() + .getAttribute(sessionMapID); + final Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + ScratchieSession toolSession = LearningAction.service.getScratchieSessionBySessionId(sessionId); + Long burningQuestionUid = WebUtil.readLongParam(request, ScratchieConstants.PARAM_BURNING_QUESTION_UID); + + ScratchieUser leader = this.getCurrentUser(sessionId); + // only leader is allowed to scratch answers + if (!toolSession.isUserGroupLeader(leader.getUid())) { + return null; + } + + boolean added = service.addLike(burningQuestionUid, sessionId); + + JSONObject JSONObject = new JSONObject(); + JSONObject.put("added", added); + response.setContentType("application/json;charset=utf-8"); + response.getWriter().print(JSONObject); + return null; + } + /** + * @throws ServletException + * @throws ScratchieApplicationException + */ + private synchronized ActionForward removeLike(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) throws JSONException, IOException, ServletException, ScratchieApplicationException { + initializeScratchieService(); + + String sessionMapID = WebUtil.readStrParam(request, ScratchieConstants.ATTR_SESSION_MAP_ID); + SessionMap sessionMap = (SessionMap) request.getSession() + .getAttribute(sessionMapID); + final Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID); + ScratchieSession toolSession = LearningAction.service.getScratchieSessionBySessionId(sessionId); + + Long burningQuestionUid = WebUtil.readLongParam(request, ScratchieConstants.PARAM_BURNING_QUESTION_UID); + + ScratchieUser leader = this.getCurrentUser(sessionId); + // only leader is allowed to scratch answers + if (!toolSession.isUserGroupLeader(leader.getUid())) { + return null; + } + + service.removeLike(burningQuestionUid, sessionId); + + return null; + } + + /** * Finish learning session. * * @param mapping Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/MonitoringAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/MonitoringAction.java,v diff -u -r1.21.2.1 -r1.21.2.2 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/MonitoringAction.java 13 Feb 2015 23:51:06 -0000 1.21.2.1 +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/MonitoringAction.java 5 Apr 2016 17:24:33 -0000 1.21.2.2 @@ -46,6 +46,7 @@ import org.apache.struts.action.ActionMapping; import org.lamsfoundation.lams.tool.scratchie.ScratchieConstants; 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.ReflectDTO; import org.lamsfoundation.lams.tool.scratchie.model.Scratchie; @@ -134,8 +135,8 @@ // Create BurningQuestionsDtos if BurningQuestions is enabled. if (scratchie.isBurningQuestionsEnabled()) { - List burningQuestionDtos = service.getBurningQuestionDtos(scratchie); - sessionMap.put(ScratchieConstants.ATTR_BURNING_QUESTIONS_DTOS, burningQuestionDtos); + List burningQuestionItemDtos = service.getBurningQuestionDtos(scratchie, null); + sessionMap.put(ScratchieConstants.ATTR_BURNING_QUESTION_ITEM_DTOS, burningQuestionItemDtos); } // Create reflectList if reflection is enabled. Index: lams_tool_scratchie/web/pages/learning/results.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scratchie/web/pages/learning/results.jsp,v diff -u -r1.13.2.6 -r1.13.2.7 --- lams_tool_scratchie/web/pages/learning/results.jsp 7 Mar 2016 23:22:53 -0000 1.13.2.6 +++ lams_tool_scratchie/web/pages/learning/results.jsp 5 Apr 2016 17:24:32 -0000 1.13.2.7 @@ -18,62 +18,131 @@ <fmt:message key="label.learning.title" /> <%@ include file="/common/header.jsp"%> - + + -.burning-question-dto { - padding-bottom: 5px; -} - -.ui-jqgrid tr.jqgrow td { - white-space: normal !important; - height: auto; - vertical-align: text-top; - padding-top: 2px; -} - - - ${scratchie.title} / + ${scratchie.title} / - @@ -155,26 +227,27 @@ ${score}% + +
+ + + +
- +
- +
-
+
- -
-
-
- Index: lams_tool_scratchie/web/pages/monitoring/summary.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_scratchie/web/pages/monitoring/summary.jsp,v diff -u -r1.14.2.4 -r1.14.2.5 --- lams_tool_scratchie/web/pages/monitoring/summary.jsp 15 Oct 2015 10:01:14 -0000 1.14.2.4 +++ lams_tool_scratchie/web/pages/monitoring/summary.jsp 5 Apr 2016 17:24:32 -0000 1.14.2.5 @@ -93,37 +93,40 @@
- - - jQuery("#burningQuestions${burningQuestionDto.item.uid}").jqGrid({ + + + + + jQuery("#burningQuestions${scratchieItem.uid}").jqGrid({ datatype: "local", rowNum: 10000, height: 'auto', autowidth: true, shrinkToFit: false, colNames:['#', "", - "" + "", + "" ], colModel:[ {name:'id', index:'id', width:0, sorttype:"int", hidden: true}, {name:'groupName', index:'groupName', width:200}, - {name:'feedback', index:'feedback', width:570} + {name:'feedback', index:'feedback', width:530}, + {name:'count', index:'count', width:40} ], - caption: "${burningQuestionDto.item.title}" + caption: "${scratchieItem.title}" }); - - - - - jQuery("#burningQuestions${burningQuestionDto.item.uid}").addRowData(${i.index + 1}, { + + + jQuery("#burningQuestions${scratchieItem.uid}").addRowData(${i.index + 1}, { id:"${i.index + 1}", - groupName:"${groupName}", - feedback:"" + groupName:"${burningQuestionDto.sessionName}", + feedback:"", + count:"${burningQuestionDto.likeCount}" }); - jQuery("#burningQuestions${burningQuestionDto.item.uid}").jqGrid('sortGrid','groupName', false, 'asc'); + jQuery("#burningQuestions${scratchieItem.uid}").jqGrid('sortGrid','groupName', false, 'asc'); @@ -305,7 +308,7 @@
- +
@@ -314,16 +317,11 @@
- +
-
+
- - -
-
-