Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieBurningQuestionDAOHibernate.java =================================================================== diff -u -r42e6c9c7220f8baf3b245d73b57aca9be08191ea -re2f4b14e2d8f0ef1feef10abdc21f3d446fca2a5 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieBurningQuestionDAOHibernate.java (.../ScratchieBurningQuestionDAOHibernate.java) (revision 42e6c9c7220f8baf3b245d73b57aca9be08191ea) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dao/hibernate/ScratchieBurningQuestionDAOHibernate.java (.../ScratchieBurningQuestionDAOHibernate.java) (revision e2f4b14e2d8f0ef1feef10abdc21f3d446fca2a5) @@ -45,9 +45,6 @@ private static final String FIND_BY_SESSION = "from " + ScratchieBurningQuestion.class.getName() + " as r where r.sessionId=?"; - private static final String FIND_BY_ITEM_UID = "from " + ScratchieBurningQuestion.class.getName() - + " as r where r.scratchieItem.uid=? order by r.sessionId asc"; - @Override @SuppressWarnings("unchecked") public List getBurningQuestionsByContentId(Long scratchieUid, Long sessionId) { @@ -90,6 +87,9 @@ if (sessionId != null) { boolean userLiked = (Integer) rawObject[3] == 1; burningQuestionDTO.setUserLiked(userLiked); + + //sets whether the leader of specified group created this burningQuestion + burningQuestionDTO.setUserAuthor(sessionId.equals(burningQuestion.getSessionId())); } burningQuestionDTO.setSessionName(sessionName); results.add(burningQuestionDTO); Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dto/BurningQuestionDTO.java =================================================================== diff -u -r2f725f8ef2aa09a2663b2335bf67213074426d11 -re2f4b14e2d8f0ef1feef10abdc21f3d446fca2a5 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dto/BurningQuestionDTO.java (.../BurningQuestionDTO.java) (revision 2f725f8ef2aa09a2663b2335bf67213074426d11) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dto/BurningQuestionDTO.java (.../BurningQuestionDTO.java) (revision e2f4b14e2d8f0ef1feef10abdc21f3d446fca2a5) @@ -31,7 +31,10 @@ private String sessionName; private Integer likeCount; + //whether the leader of specified group liked this burningQuestion private boolean userLiked; + //whether the leader of specified group created this burningQuestion + private boolean userAuthor; public ScratchieBurningQuestion getBurningQuestion() { return burningQuestion; @@ -72,4 +75,15 @@ public void setUserLiked(boolean userLiked) { this.userLiked = userLiked; } + + /** + * @return whether the leader of specified group created this burningQuestion + */ + public boolean isUserAuthor() { + return userAuthor; + } + + public void setUserAuthor(boolean userAuthor) { + this.userAuthor = userAuthor; + } } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java =================================================================== diff -u -r3d40a7e98de7bcd2cb744cdb8dc13c0022fb7bdb -re2f4b14e2d8f0ef1feef10abdc21f3d446fca2a5 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java (.../ScratchieServiceImpl.java) (revision 3d40a7e98de7bcd2cb744cdb8dc13c0022fb7bdb) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java (.../ScratchieServiceImpl.java) (revision e2f4b14e2d8f0ef1feef10abdc21f3d446fca2a5) @@ -944,7 +944,7 @@ } } generalBurningQuestionItemDto.setBurningQuestionDtos(burningQuestionDtosOfSpecifiedItem); - //don't display general burning question if it's empty and such rule is enforced + //skip empty item if required if (!burningQuestionDtosOfSpecifiedItem.isEmpty() || includeEmptyItems) { burningQuestionItemDtos.add(generalBurningQuestionItemDto); } @@ -956,7 +956,7 @@ burningQuestionDto.setSessionName(escapedSessionName); String escapedBurningQuestion = StringEscapeUtils.escapeJavaScript( - burningQuestionDto.getBurningQuestion().getQuestion().replaceAll("\\n", "
")); + burningQuestionDto.getBurningQuestion().getQuestion()); burningQuestionDto.setEscapedBurningQuestion(escapedBurningQuestion); } } Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java =================================================================== diff -u -r3d40a7e98de7bcd2cb744cdb8dc13c0022fb7bdb -re2f4b14e2d8f0ef1feef10abdc21f3d446fca2a5 --- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java (.../LearningAction.java) (revision 3d40a7e98de7bcd2cb744cdb8dc13c0022fb7bdb) +++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java (.../LearningAction.java) (revision e2f4b14e2d8f0ef1feef10abdc21f3d446fca2a5) @@ -40,6 +40,7 @@ import javax.servlet.http.HttpSession; import org.apache.commons.lang.StringEscapeUtils; +import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.math.NumberUtils; import org.apache.log4j.Logger; import org.apache.struts.action.Action; @@ -111,6 +112,9 @@ if (param.equals("showResults")) { return showResults(mapping, form, request, response); } + if (param.equals("editBurningQuestion")) { + return editBurningQuestion(mapping, form, request, response); + } if (param.equals("like")) { return like(mapping, form, request, response); } @@ -513,7 +517,27 @@ return mapping.findForward(ScratchieConstants.SUCCESS); } + + /** + * Saves newly entered burning question. Used by jqGrid cellediting feature. + */ + private ActionForward editBurningQuestion(ActionMapping mapping, ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + if (!StringUtils.isEmpty(request.getParameter(ScratchieConstants.ATTR_ITEM_UID)) + && !StringUtils.isEmpty(request.getParameter(ScratchieConstants.PARAM_SESSION_ID))) { + initializeScratchieService(); + + Long itemUid = WebUtil.readLongParam(request, ScratchieConstants.ATTR_ITEM_UID) == 0 ? null + : WebUtil.readLongParam(request, ScratchieConstants.ATTR_ITEM_UID); + Long sessionId = WebUtil.readLongParam(request, ScratchieConstants.PARAM_SESSION_ID); + String question = request.getParameter(ScratchieConstants.ATTR_BURNING_QUESTION_PREFIX); + service.saveBurningQuestion(sessionId, itemUid, question); + } + + return null; + } + private ActionForward like(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws JSONException, IOException, ServletException, ScratchieApplicationException { Index: lams_tool_scratchie/web/WEB-INF/struts-config.xml =================================================================== diff -u -r868cbadb5ccd51c7172a97cfd02b31edbaa9d97a -re2f4b14e2d8f0ef1feef10abdc21f3d446fca2a5 --- lams_tool_scratchie/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 868cbadb5ccd51c7172a97cfd02b31edbaa9d97a) +++ lams_tool_scratchie/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision e2f4b14e2d8f0ef1feef10abdc21f3d446fca2a5) @@ -224,6 +224,10 @@ parameter="showResults" > + + <fmt:message key="label.learning.title" /> <%@ include file="/common/header.jsp"%> - - - + + - - - +