Fisheye: Tag 9465560dcbea622e2f3a01e334400f2005ce2ed3 refers to a dead (removed) revision in file `lams_tool_scratchie/conf/hibernate/mappings/.cvsignore'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_scratchie/conf/language/lams/ApplicationResources_en_AU.properties
===================================================================
diff -u -r7f8e34f36196eb71f16ec1984091704d36682166 -r9465560dcbea622e2f3a01e334400f2005ce2ed3
--- lams_tool_scratchie/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 7f8e34f36196eb71f16ec1984091704d36682166)
+++ lams_tool_scratchie/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 9465560dcbea622e2f3a01e334400f2005ce2ed3)
@@ -54,6 +54,7 @@
label.view =View
label.edit =Edit
label.finished =Next Activity
+label.submit =Submit
label.finish =Finished
message.monitoring.summary.no.session =No Session Available
define.later.message =Please wait for the instructor to complete the contents of this activity.
@@ -105,5 +106,9 @@
label.authoring.advanced.give.extra.point =Give an extra point to all questions if student gets it right in the first attempt
label.authoring.scratchie.answers =Scratchie answers
label.one.or.more.questions.not.completed =One or more questions have not being completed. If you are to continue, you won't be able to answer these questions at a later stage and you'll get zero point for this questions. Are you sure you want to continue?
+label.authoring.advanced.show.results.page =When the student finish the scratchies, we've got to show a results page before they continue to the next activity
+label.correct.answer =Correct answer
+label.mark =Mark
+label.attempts =Attempts
#======= End labels: Exported 176 labels for en AU =====
Index: lams_tool_scratchie/conf/xdoclet/struts-actions.xml
===================================================================
diff -u -r0ef117e7eca05b962210cb3b18eab1e39a6c57d1 -r9465560dcbea622e2f3a01e334400f2005ce2ed3
--- lams_tool_scratchie/conf/xdoclet/struts-actions.xml (.../struts-actions.xml) (revision 0ef117e7eca05b962210cb3b18eab1e39a6c57d1)
+++ lams_tool_scratchie/conf/xdoclet/struts-actions.xml (.../struts-actions.xml) (revision 9465560dcbea622e2f3a01e334400f2005ce2ed3)
@@ -188,6 +188,11 @@
type="org.lamsfoundation.lams.tool.scratchie.web.action.LearningAction"
parameter="scratchItem" >
+
+
+
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 -r7f8e34f36196eb71f16ec1984091704d36682166 -r9465560dcbea622e2f3a01e334400f2005ce2ed3
--- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/IScratchieService.java (.../IScratchieService.java) (revision 7f8e34f36196eb71f16ec1984091704d36682166)
+++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/IScratchieService.java (.../IScratchieService.java) (revision 9465560dcbea622e2f3a01e334400f2005ce2ed3)
@@ -173,6 +173,14 @@
void setAnswerAccess(Long scratchieItemUid, Long userId, Long sessionId);
int getUserMark(Long sessionId, Long userId);
+
+ /**
+ * Mark user session as finished so that user can't continue scratching after this.
+ *
+ * @param toolSessionId
+ * @param userId
+ */
+ void setUserFinished(Long toolSessionId, Long userId);
/**
* If success return next activity's url, otherwise return null.
@@ -277,4 +285,13 @@
* @return
*/
boolean isGroupedActivity(long toolContentID);
+
+ /**
+ * Populates items with results, i.e. correctAnswer, userMark, userAttempts. Used for displaying this data on learner results page.
+ *
+ * @param sessionId
+ * @param userId
+ * @return
+ */
+ Set populateItemsResults(Long sessionId, Long userId);
}
Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java
===================================================================
diff -u -r7f8e34f36196eb71f16ec1984091704d36682166 -r9465560dcbea622e2f3a01e334400f2005ce2ed3
--- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java (.../ScratchieServiceImpl.java) (revision 7f8e34f36196eb71f16ec1984091704d36682166)
+++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java (.../ScratchieServiceImpl.java) (revision 9465560dcbea622e2f3a01e334400f2005ce2ed3)
@@ -388,27 +388,6 @@
scratchieSessionDao.saveObject(resSession);
}
- public void retrieveScratched(Collection items, ScratchieUser user) {
-
- for (ScratchieItem item : items) {
- boolean isItemUnraveled = false;
-
- 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());
- isItemUnraveled |= answer.isCorrect();
- }
- }
- item.setUnraveled(isItemUnraveled);
- }
-
- }
-
public void setAnswerAccess(Long answerUid, Long userId, Long sessionId) {
ScratchieAnswerVisitLog log = scratchieAnswerVisitDao.getScratchieAnswerLog(answerUid, userId);
if (log == null) {
@@ -426,12 +405,14 @@
public ScratchieAnswer getScratchieAnswerById (Long answerUid) {
return (ScratchieAnswer) userManagementService.findById(ScratchieAnswer.class, answerUid);
}
-
- public String finishToolSession(Long toolSessionId, Long userId) throws ScratchieApplicationException {
+
+ public void setUserFinished(Long toolSessionId, Long userId) {
ScratchieUser user = scratchieUserDao.getUserByUserIDAndSessionID(userId, toolSessionId);
user.setSessionFinished(true);
scratchieUserDao.saveObject(user);
+ }
+ public String finishToolSession(Long toolSessionId, Long userId) throws ScratchieApplicationException {
String nextUrl = null;
try {
nextUrl = this.leaveToolSession(toolSessionId, userId);
@@ -461,7 +442,7 @@
List users = scratchieUserDao.getBySessionID(sessionId);
for (ScratchieUser user : users) {
- int totalAttempts = scratchieAnswerVisitDao.getUserViewLogCount(sessionId, user.getUserId());
+ int totalAttempts = scratchieAnswerVisitDao.getLogCountTotal(sessionId, user.getUserId());
user.setTotalAttempts(totalAttempts);
//for displaying purposes if there is no attemps we assign -1 which will be shown as "-"
@@ -476,30 +457,102 @@
return groupSummaryList;
}
+ public void retrieveScratched(Collection items, ScratchieUser user) {
+
+ for (ScratchieItem item : items) {
+
+ 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());
+ }
+ }
+
+ item.setUnraveled(isItemUnraveled(item, user.getUserId()));
+ }
+ }
+
+ private boolean isItemUnraveled(ScratchieItem item, Long userId) {
+ boolean isItemUnraveled = false;
+
+ for (ScratchieAnswer answer : (Set) item.getAnswers()) {
+ ScratchieAnswerVisitLog log = scratchieAnswerVisitDao.getScratchieAnswerLog(answer.getUid(), userId);
+ if (log != null) {
+ isItemUnraveled |= answer.isCorrect();
+ }
+ }
+
+ return isItemUnraveled;
+ }
+
public int getUserMark(Long sessionId, Long userId) {
ScratchieUser user = getUserByIDAndSession(userId, sessionId);
ScratchieSession session = scratchieSessionDao.getSessionBySessionId(sessionId);
Scratchie scratchie = session.getScratchie();
Set items = scratchie.getScratchieItems();
- retrieveScratched(items, user);
int mark = 0;
for (ScratchieItem item : items) {
- // add mark only if an item was unraveled
- if (item.isUnraveled()) {
- int attempts = scratchieAnswerVisitDao.getUserViewLogCount(sessionId, userId, item.getUid());
- mark += item.getAnswers().size() - attempts;
+ mark += getUserMarkPerItem(scratchie, item, sessionId, userId);
+ }
+
+ return mark;
+ }
+
+ /**
+ *
+ *
+ * @param sessionId
+ * @param userId
+ * @param item
+ * @return
+ */
+ private int getUserMarkPerItem(Scratchie scratchie, ScratchieItem item, Long sessionId, Long userId) {
+
+ int mark = 0;
+ // add mark only if an item was unraveled
+ if (isItemUnraveled(item, userId)) {
+ int attempts = scratchieAnswerVisitDao.getLogCountPerItem(sessionId, userId, item.getUid());
+ mark += item.getAnswers().size() - attempts;
- // add extra point if needed
- if (scratchie.isExtraPoint() && (attempts == 1)) {
- mark++;
- }
+ // add extra point if needed
+ if (scratchie.isExtraPoint() && (attempts == 1)) {
+ mark++;
}
}
return mark;
}
+ public Set populateItemsResults(Long sessionId, Long userId) {
+ ScratchieUser user = getUserByIDAndSession(userId, sessionId);
+ ScratchieSession session = scratchieSessionDao.getSessionBySessionId(sessionId);
+ Scratchie scratchie = session.getScratchie();
+ Set items = scratchie.getScratchieItems();
+
+ for (ScratchieItem item : items) {
+ int mark = getUserMarkPerItem(scratchie, item, sessionId, userId);
+ item.setUserMark(mark);
+
+ int attempts = scratchieAnswerVisitDao.getLogCountPerItem(sessionId, userId, item.getUid());
+ item.setUserAttempts(attempts);
+
+ String correctAnswer = "";
+ for (ScratchieAnswer answer : (Set)item.getAnswers()) {
+ if (answer.isCorrect()) {
+ correctAnswer = answer.getDescription();
+ }
+ }
+ item.setCorrectAnswer(correctAnswer);
+ }
+
+ return items;
+ }
+
public List getUserMasterDetail(Long sessionId, Long userId) {
List logs = scratchieAnswerVisitDao.getLogsBySessionAndUser(sessionId, userId);
@@ -970,6 +1023,7 @@
toolContentObj.setUpdated(now);
toolContentObj.setReflectOnActivity(Boolean.FALSE);
toolContentObj.setExtraPoint(Boolean.FALSE);
+ toolContentObj.setShowResultsPage(Boolean.TRUE);
toolContentObj.setReflectInstructions(null);
// leave as empty, no need to set them to anything.
Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/AuthoringAction.java
===================================================================
diff -u -r6ade8791af29bde5c1e1b1aad674a9d23b69fb36 -r9465560dcbea622e2f3a01e334400f2005ce2ed3
--- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/AuthoringAction.java (.../AuthoringAction.java) (revision 6ade8791af29bde5c1e1b1aad674a9d23b69fb36)
+++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/AuthoringAction.java (.../AuthoringAction.java) (revision 9465560dcbea622e2f3a01e334400f2005ce2ed3)
@@ -241,7 +241,13 @@
ScratchieUser scratchieUser = null;
// handle system default question: createBy is null, now set it to
// current user
- for (ScratchieItem item : items) {item.getAnswers();
+ for (ScratchieItem item : items) {
+
+ //sort answers by order id. it's needed only for the default answers. rest could be skipped
+ TreeSet answerList = new TreeSet(new ScratchieAnswerComparator());
+ answerList.addAll(item.getAnswers());
+ item.setAnswers(answerList);
+
if (item.getCreateBy() == null) {
if (scratchieUser == null) {
// get back login user DTO
Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java
===================================================================
diff -u -rded32af47a9de99cb3319fdd7461906323f7e293 -r9465560dcbea622e2f3a01e334400f2005ce2ed3
--- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java (.../LearningAction.java) (revision ded32af47a9de99cb3319fdd7461906323f7e293)
+++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java (.../LearningAction.java) (revision 9465560dcbea622e2f3a01e334400f2005ce2ed3)
@@ -88,6 +88,9 @@
if (param.equals("finish")) {
return finish(mapping, form, request, response);
}
+ if (param.equals("showResults")) {
+ return showResults(mapping, form, request, response);
+ }
// ================ Reflection =======================
if (param.equals("newReflection")) {
@@ -113,16 +116,12 @@
// initial Session Map
SessionMap sessionMap = new SessionMap();
request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap);
+ request.setAttribute(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID());
// save toolContentID into HTTPSession
ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE, true);
-
Long toolSessionId = new Long(request.getParameter(ScratchieConstants.PARAM_TOOL_SESSION_ID));
- request.setAttribute(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID());
- request.setAttribute(AttributeNames.ATTR_MODE, mode);
- request.setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, toolSessionId);
-
// get back the scratchie and item list and display them on page
IScratchieService service = getScratchieService();
ScratchieUser scratchieUser = null;
@@ -153,8 +152,7 @@
sessionMap.put(ScratchieConstants.ATTR_RESOURCE_INSTRUCTION, scratchie.getInstructions());
boolean isUserFinished = scratchieUser != null && scratchieUser.isSessionFinished();
sessionMap.put(ScratchieConstants.ATTR_USER_FINISHED, isUserFinished);
-
-
+ sessionMap.put(ScratchieConstants.ATTR_IS_SHOW_RESULTS_PAGE, scratchie.isShowResultsPage());
sessionMap.put(AttributeNames.PARAM_TOOL_SESSION_ID, toolSessionId);
sessionMap.put(AttributeNames.ATTR_MODE, mode);
// reflection information
@@ -214,22 +212,22 @@
*/
private ActionForward scratchItem(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws JSONException, IOException {
- String mode = request.getParameter(AttributeNames.ATTR_MODE);
String sessionMapID = WebUtil.readStrParam(request, ScratchieConstants.ATTR_SESSION_MAP_ID);
SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
+
+ ToolAccessMode mode = (ToolAccessMode) sessionMap.get(AttributeNames.ATTR_MODE);
Long answerUid = NumberUtils.createLong(request.getParameter(ScratchieConstants.PARAM_ANSWER_UID));
// get back the resource and item list and display them on page
ScratchieAnswer answer = getScratchieService().getScratchieAnswerById(answerUid);
-
- String toolSessionIdStr = request.getParameter(ScratchieConstants.ATTR_TOOL_SESSION_ID);
- Long toolSessionId = NumberUtils.createLong(toolSessionIdStr);
+
// mark this item access flag if it is learner
- if (ToolAccessMode.LEARNER.toString().equals(mode)) {
+ if (mode.isLearner()) {
HttpSession ss = SessionManager.getSession();
// get back login user DTO
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ Long toolSessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);
getScratchieService().setAnswerAccess(answer.getUid(), new Long(user.getUserID().intValue()), toolSessionId);
}
@@ -245,38 +243,36 @@
}
+ /**
+ * Finish learning session.
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ */
+ private ActionForward showResults(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) {
+ // get back SessionMap
+ String sessionMapID = request.getParameter(ScratchieConstants.ATTR_SESSION_MAP_ID);
+ SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
+ request.setAttribute(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMapID);
+ Long toolSessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);
-// /**
-// * Set complete flag for given scratchie item.
-// *
-// * @param request
-// * @param sessionId
-// */
-// private void doComplete(HttpServletRequest request) {
-// // get back sessionMap
-// String sessionMapID = request.getParameter(ScratchieConstants.ATTR_SESSION_MAP_ID);
-// SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
-//
-// Long scratchieItemUid = new Long(request.getParameter(ScratchieConstants.PARAM_ITEM_UID));
-// IScratchieService service = getScratchieService();
-// HttpSession ss = SessionManager.getSession();
-// // get back login user DTO
-// UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
-//
-// Long sessionId = (Long) sessionMap.get(ScratchieConstants.ATTR_TOOL_SESSION_ID);
-// service.setItemComplete(scratchieItemUid, new Long(user.getUserID().intValue()), sessionId);
-//
-// // set scratchie item complete tag
-// SortedSet scratchieItemList = getScratchieItemList(sessionMap);
-// for (ScratchieItem item : scratchieItemList) {
-// if (item.getUid().equals(scratchieItemUid)) {
-// item.setScratched(true);
-// break;
-// }
-// }
-// }
+ IScratchieService service = getScratchieService();
+ HttpSession ss = SessionManager.getSession();
+ UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ Long userId = new Long(user.getUserID().longValue());
+ service.setUserFinished(toolSessionId, userId);
+ Set items = service.populateItemsResults(toolSessionId, userId);
+ request.setAttribute(ScratchieConstants.ATTR_ITEM_LIST, items);
+
+ return mapping.findForward(ScratchieConstants.SUCCESS);
+ }
+
/**
* Finish learning session.
*
@@ -292,7 +288,7 @@
// get back SessionMap
String sessionMapID = request.getParameter(ScratchieConstants.ATTR_SESSION_MAP_ID);
SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
- Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);
+ Long toolSessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);
IScratchieService service = getScratchieService();
// get sessionId from HttpServletRequest
@@ -302,7 +298,8 @@
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
Long userID = new Long(user.getUserID().longValue());
- nextActivityUrl = service.finishToolSession(sessionId, userID);
+ service.setUserFinished(toolSessionId, userID);
+ nextActivityUrl = service.finishToolSession(toolSessionId, userID);
request.setAttribute(ScratchieConstants.ATTR_NEXT_ACTIVITY_URL, nextActivityUrl);
} catch (ScratchieApplicationException e) {
LearningAction.log.error("Failed get next activity url:" + e.getMessage());
Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/form/ScratchieForm.java
===================================================================
diff -u -r6ade8791af29bde5c1e1b1aad674a9d23b69fb36 -r9465560dcbea622e2f3a01e334400f2005ce2ed3
--- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/form/ScratchieForm.java (.../ScratchieForm.java) (revision 6ade8791af29bde5c1e1b1aad674a9d23b69fb36)
+++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/form/ScratchieForm.java (.../ScratchieForm.java) (revision 9465560dcbea622e2f3a01e334400f2005ce2ed3)
@@ -76,6 +76,7 @@
scratchie.setRunOffline(false);
scratchie.setReflectOnActivity(false);
scratchie.setExtraPoint(false);
+ scratchie.setShowResultsPage(false);
}
}
Index: lams_tool_scratchie/web/pages/authoring/advance.jsp
===================================================================
diff -u -r6ade8791af29bde5c1e1b1aad674a9d23b69fb36 -r9465560dcbea622e2f3a01e334400f2005ce2ed3
--- lams_tool_scratchie/web/pages/authoring/advance.jsp (.../advance.jsp) (revision 6ade8791af29bde5c1e1b1aad674a9d23b69fb36)
+++ lams_tool_scratchie/web/pages/authoring/advance.jsp (.../advance.jsp) (revision 9465560dcbea622e2f3a01e334400f2005ce2ed3)
@@ -11,6 +11,13 @@
+
+
+
+
+