tags.
*/
private String removeHtmlMarkup(String string) {
return string.replaceAll("[<](/)?div[^>]*[>]", "");
}
-
+
/**
* Serves merely for excel export purposes. Produces data for "Summary By Team" section.
*/
@@ -1240,41 +1299,43 @@
GroupSummary groupSummary = new GroupSummary(sessionId, session.getSessionName());
ArrayList
items = new ArrayList();
- ScratchieUser groupLeader = getGroupLeader(sessionId);
-
+ ScratchieUser groupLeader = session.getGroupLeader();
+
for (ScratchieItem item : sortedItems) {
ScratchieItem newItem = new ScratchieItem();
int attempts = 0;
int mark = -1;
boolean isFirstChoice = false;
-
+
// if there is no group leader don't calculate numbers - they aren't any
if (groupLeader != null) {
- attempts = scratchieAnswerVisitDao.getLogCountPerItem(sessionId, groupLeader.getUserId(), item.getUid());
+ attempts = scratchieAnswerVisitDao.getLogCountPerItem(sessionId, groupLeader.getUserId(),
+ item.getUid());
// for displaying purposes if there is no attemps we assign -1 which will be shown as "-"
- mark = (attempts == 0) ? -1 : getUserMarkPerItem(scratchie, item, sessionId, groupLeader.getUserId());
-
+ mark = (attempts == 0) ? -1 : getUserMarkPerItem(scratchie, item, sessionId,
+ groupLeader.getUserId());
+
isFirstChoice = (attempts == 1) && isItemUnraveled(item, groupLeader.getUserId());
}
-
+
newItem.setUid(item.getUid());
newItem.setTitle(item.getTitle());
newItem.setAnswers(item.getAnswers());
newItem.setUserAttempts(attempts);
newItem.setUserMark(mark);
newItem.setCorrectAnswer("" + isFirstChoice);
-
+
items.add(newItem);
}
-
+
groupSummary.setItems(items);
groupSummaries.add(groupSummary);
}
return groupSummaries;
}
-
+
private Scratchie getDefaultScratchie() throws ScratchieApplicationException {
Long defaultScratchieId = getToolDefaultContentIdBySignature(ScratchieConstants.TOOL_SIGNATURE);
Scratchie defaultScratchie = getScratchieByContentId(defaultScratchieId);
@@ -1658,7 +1719,7 @@
public void setEventNotificationService(IEventNotificationService eventNotificationService) {
this.eventNotificationService = eventNotificationService;
}
-
+
@Override
public String getMessage(String key) {
return messageService.getMessage(key);
@@ -1670,26 +1731,15 @@
public String getMessage(String key, Object[] args) {
return messageService.getMessage(key, args);
}
-
- public ILessonService getLessonService() {
- return lessonService;
+
+ public void setActivityDAO(IActivityDAO activityDAO) {
+ this.activityDAO = activityDAO;
}
- public void setLessonService(ILessonService lessonService) {
- this.lessonService = lessonService;
+ public void setLamsCoreToolService(ILamsCoreToolService lamsCoreToolService) {
+ this.lamsCoreToolService = lamsCoreToolService;
}
- /**
- * Finds out which lesson the given tool content belongs to and returns its monitoring users.
- *
- * @param sessionId
- * tool session ID
- * @return list of teachers that monitor the lesson which contains the tool with given session ID
- */
- public List getMonitorsByToolSessionId(Long sessionId) {
- return getLessonService().getMonitorsByToolSessionId(sessionId);
- }
-
public Class[] getSupportedToolOutputDefinitionClasses(int definitionType) {
return getScratchieOutputFactory().getSupportedDefinitionClasses(definitionType);
}
Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java
===================================================================
diff -u -r00c7a1f28f5ef0e4f890aabd0ff5b97701d4b1bb -rc7569597546126af159f169353e68e91241b7f10
--- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java (.../LearningAction.java) (revision 00c7a1f28f5ef0e4f890aabd0ff5b97701d4b1bb)
+++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java (.../LearningAction.java) (revision c7569597546126af159f169353e68e91241b7f10)
@@ -87,9 +87,6 @@
if (param.equals("refreshQuestionList")) {
return refreshQuestionList(mapping, form, request, response);
}
- if (param.equals("becomeLeader")) {
- return becomeLeader(mapping, form, request, response);
- }
if (param.equals("scratchItem")) {
return scratchItem(mapping, form, request, response);
}
@@ -128,7 +125,7 @@
// get back the scratchie and item list and display them on page
IScratchieService service = getScratchieService();
Scratchie scratchie = service.getScratchieBySessionId(toolSessionId);
-
+
ScratchieUser user = null;
if (mode != null && mode.isTeacher()) {
// monitoring mode - user is specified in URL
@@ -138,38 +135,38 @@
} else {
user = getCurrentUser(service, toolSessionId);
}
-
- ScratchieUser groupLeader = service.getGroupLeader(toolSessionId);
- //forwards to the leaderSelection page
- if ((groupLeader == null) && !mode.isTeacher()) {
+
+ ScratchieUser groupLeader = service.checkLeaderSelectToolForSessionLeader(user, toolSessionId);
+
+ // forwards to the leaderSelection page
+ if (groupLeader == null && !mode.isTeacher()) {
+
List groupUsers = service.getUsersBySession(toolSessionId);
request.setAttribute(ScratchieConstants.ATTR_GROUP_USERS, groupUsers);
request.setAttribute(ScratchieConstants.PARAM_TOOL_SESSION_ID, toolSessionId);
request.setAttribute(ScratchieConstants.ATTR_SCRATCHIE, scratchie);
-
- //checks whether to display dialog prompting to become a leader
- boolean nodialog = WebUtil.readBooleanParam(request, "nodialog", false);
- request.setAttribute("nodialog", nodialog);
- return mapping.findForward("leaderSelection");
+
+ return mapping.findForward("waitforleader");
}
-
- //in case user joins the lesson after leader has scratched some answers already - we need to make sure he has the same scratches as leader
- if (!mode.isTeacher()) {
+
+ if (groupLeader != null && !mode.isTeacher()) {
+ // in case user joins the lesson after leader has scratched some answers already - we need to make sure
+ // he has the same scratches as leader
service.copyScratchesFromLeader(user, groupLeader);
-
- //if user joins a lesson after leader has already finished an activity set his scratchingFinished parameter to true
+
+ // if user joins a lesson after leader has already finished an activity set his scratchingFinished
+ // parameter to true
if (groupLeader.isScratchingFinished()) {
user.setScratchingFinished(true);
service.saveUser(user);
}
}
-
+
// initial Session Map
SessionMap sessionMap = new SessionMap();
request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap);
request.setAttribute(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID());
-
// get notebook entry
String entryText = new String();
if (groupLeader != null) {
@@ -186,6 +183,8 @@
sessionMap.put(ScratchieConstants.ATTR_USER_ID, user.getUserId());
sessionMap.put(ScratchieConstants.ATTR_USER, user);
sessionMap.put(ScratchieConstants.ATTR_GROUP_LEADER, groupLeader);
+ boolean isUserLeader = service.isUserGroupLeader(user, toolSessionId);
+ sessionMap.put(ScratchieConstants.ATTR_IS_USER_LEADER, isUserLeader);
boolean isUserFinished = user != null && user.isSessionFinished();
sessionMap.put(ScratchieConstants.ATTR_USER_FINISHED, isUserFinished);
sessionMap.put(ScratchieConstants.ATTR_IS_SHOW_RESULTS_PAGE, scratchie.isShowResultsPage());
@@ -206,10 +205,10 @@
scratchie.setDefineLater(false);
service.saveOrUpdateScratchie(scratchie);
- ActivityPositionDTO activityPosition = LearningWebUtil.putActivityPositionInRequestByToolSessionId(toolSessionId, request, getServlet()
- .getServletContext());
+ ActivityPositionDTO activityPosition = LearningWebUtil.putActivityPositionInRequestByToolSessionId(
+ toolSessionId, request, getServlet().getServletContext());
sessionMap.put(AttributeNames.ATTR_ACTIVITY_POSITION, activityPosition);
-
+
// add run offline support
if (scratchie.getRunOffline()) {
sessionMap.put(ScratchieConstants.PARAM_RUN_OFFLINE, true);
@@ -219,13 +218,14 @@
}
Set initialItems = scratchie.getScratchieItems();
- // becuase in webpage will use this login name. Here is just initialize it to avoid session close error in proxy object.
+ // becuase in webpage will use this login name. Here is just initialize it to avoid session close error in proxy
+ // object.
for (ScratchieItem item : initialItems) {
if (item.getCreateBy() != null) {
item.getCreateBy().getLoginName();
}
}
-
+
// for teacher in monitoring display the number of attempt.
if (mode.isTeacher()) {
service.retrieveScratchesOrder(initialItems, user);
@@ -235,15 +235,15 @@
if (user != null) {
service.retrieveScratched(initialItems, user);
}
-
+
Collection items = new TreeSet(new ScratchieItemComparator());
items.addAll(initialItems);
sessionMap.put(ScratchieConstants.ATTR_ITEM_LIST, items);
sessionMap.put(ScratchieConstants.ATTR_SCRATCHIE, scratchie);
boolean isScratchingFinished = user != null && user.isScratchingFinished();
sessionMap.put(ScratchieConstants.ATTR_IS_SCRATCHING_FINISHED, isScratchingFinished);
-
- //decide whether to show results page or learning one
+
+ // decide whether to show results page or learning one
if (scratchie.isShowResultsPage() && isScratchingFinished && !mode.isTeacher()) {
ActionRedirect redirect = new ActionRedirect(mapping.findForwardConfig("showResults"));
redirect.addParameter(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID());
@@ -252,95 +252,68 @@
} else {
return mapping.findForward(ScratchieConstants.SUCCESS);
}
-
+
}
-
+
/**
* Refresh
- *
*/
private ActionForward refreshQuestionList(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
-
+
String sessionMapID = request.getParameter(ScratchieConstants.ATTR_SESSION_MAP_ID);
SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
request.setAttribute(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMapID);
IScratchieService service = getScratchieService();
Long toolSessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);
ScratchieUser user = getCurrentUser(service, toolSessionId);
-
+
// get back the scratchie and item list and display them on page
Scratchie scratchie = service.getScratchieBySessionId(toolSessionId);
Collection items = new TreeSet(new ScratchieItemComparator());
items.addAll(scratchie.getScratchieItems());
-
+
// set scratched flag for display purpose
if (user != null) {
service.retrieveScratched(items, user);
}
-
+
sessionMap.put(ScratchieConstants.ATTR_ITEM_LIST, items);
- //refresh leadership status
+ // refresh leadership status
sessionMap.put(ScratchieConstants.ATTR_USER, user);
- //refresh ScratchingFinished status
+ // refresh ScratchingFinished status
boolean isScratchingFinished = user != null && user.isScratchingFinished();
sessionMap.put(ScratchieConstants.ATTR_IS_SCRATCHING_FINISHED, isScratchingFinished);
-
+
return mapping.findForward(ScratchieConstants.SUCCESS);
-
+
}
-
+
/**
- * Sets current user as a leader of a group.
- *
- * @param mapping
- * @param form
- * @param request
- * @param response
- * @return
- * @throws JSONException
- * @throws IOException
- */
- private ActionForward becomeLeader(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws JSONException, IOException {
- IScratchieService service = getScratchieService();
- Long toolSessionId = new Long(request.getParameter(ScratchieConstants.PARAM_TOOL_SESSION_ID));
-
- ScratchieUser groupLeader = service.getGroupLeader(toolSessionId);
- //check there is no leader yet. Just in case somebody has pressed "Yes" button faster
- if (groupLeader == null) {
- ScratchieUser user = getCurrentUser(service, toolSessionId);
- service.setGroupLeader(user.getUserId(), toolSessionId);
- }
-
- return null;
- }
-
- /**
* Scratch specified answer.
*
* @param mapping
* @param form
* @param request
* @param response
* @return
- * @throws JSONException
- * @throws IOException
+ * @throws JSONException
+ * @throws IOException
*/
private ActionForward scratchItem(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws JSONException, IOException {
-
+
IScratchieService service = getScratchieService();
String sessionMapID = WebUtil.readStrParam(request, ScratchieConstants.ATTR_SESSION_MAP_ID);
SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
Long toolSessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);
-
+
ScratchieUser user = getCurrentUser(service, toolSessionId);
- //only leaders are allowed to scratch answers
- if (!user.isLeader()) {
+ // only leaders are allowed to scratch answers
+ if (!service.isUserGroupLeader(user, toolSessionId)) {
return null;
}
@@ -352,14 +325,14 @@
service.setAnswerAccess(answer.getUid(), toolSessionId);
- JSONObject JSONObject = new JSONObject();
+ JSONObject JSONObject = new JSONObject();
JSONObject.put(ScratchieConstants.ATTR_ANSWER_CORRECT, answer.isCorrect());
response.setContentType("application/x-json;charset=utf-8");
response.getWriter().print(JSONObject);
return null;
}
-
+
/**
* Leader presses button show results. All the users set scratchingFinished to true.
*
@@ -380,8 +353,8 @@
IScratchieService service = getScratchieService();
Long userId = (Long) sessionMap.get(ScratchieConstants.ATTR_USER_ID);
-
- //only leaders should get to here to finalize scratching
+
+ // only leaders should get to here to finalize scratching
service.setScratchingFinished(toolSessionId);
Set items = service.populateItemsResults(toolSessionId, userId);
@@ -408,12 +381,12 @@
Long toolSessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);
ScratchieUser user = (ScratchieUser) sessionMap.get(AttributeNames.USER);
IScratchieService service = getScratchieService();
-
- //in case of the leader we should let all other learners see Next Activity button
- if (user.isLeader()) {
+
+ // in case of the leader we should let all other learners see Next Activity button
+ if (service.isUserGroupLeader(user, toolSessionId)) {
service.setScratchingFinished(toolSessionId);
}
-
+
String nextActivityUrl = null;
try {
nextActivityUrl = service.finishToolSession(toolSessionId, user.getUserId());
@@ -503,7 +476,7 @@
// *************************************************************************************
// Private method
// *************************************************************************************
-
+
private IScratchieService getScratchieService() {
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet()
.getServletContext());
Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/MonitoringAction.java
===================================================================
diff -u -r5a5f3640c4d5fdf0c302347e7d6b502a972fd9cc -rc7569597546126af159f169353e68e91241b7f10
--- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/MonitoringAction.java (.../MonitoringAction.java) (revision 5a5f3640c4d5fdf0c302347e7d6b502a972fd9cc)
+++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/MonitoringAction.java (.../MonitoringAction.java) (revision c7569597546126af159f169353e68e91241b7f10)
@@ -74,12 +74,6 @@
if (param.equals("itemSummary")) {
return itemSummary(mapping, form, request, response);
}
- if (param.equals("manageLeaders")) {
- return manageLeaders(mapping, form, request, response);
- }
- if (param.equals("saveLeaders")) {
- return saveLeaders(mapping, form, request, response);
- }
if (param.equals("exportExcel")) {
return exportExcel(mapping, form, request, response);
}
@@ -145,62 +139,6 @@
}
/**
- * Show leaders manage page
- */
- private ActionForward manageLeaders(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) {
- String sessionMapID = request.getParameter(ScratchieConstants.ATTR_SESSION_MAP_ID);
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
- request.setAttribute(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID());
- return mapping.findForward(ScratchieConstants.SUCCESS);
- }
-
- /**
- * Save selected users as a leaders
- */
- private ActionForward saveLeaders(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) {
- String sessionMapID = request.getParameter(ScratchieConstants.ATTR_SESSION_MAP_ID);
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
- request.setAttribute(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID());
- IScratchieService service = getScratchieService();
-
- List summaryList = (List) sessionMap.get(ScratchieConstants.ATTR_SUMMARY_LIST);
- for (GroupSummary summary : summaryList) {
- Long toolSessionId = summary.getSessionId();
- Long leaderUserId = WebUtil.readLongParam(request, "sessionId" + toolSessionId, true);
-
- // save selected users as a leaders
- if (leaderUserId != null) {
- service.setGroupLeader(leaderUserId, toolSessionId);
- }
- }
-
- // refresh users leadership status in summaryList
- Long contentId = (Long) sessionMap.get(ScratchieConstants.ATTR_TOOL_CONTENT_ID);
- summaryList = service.getMonitoringSummary(contentId);
- sessionMap.put(ScratchieConstants.ATTR_SUMMARY_LIST, summaryList);
-
- return null;
- }
-
- private ActionForward viewReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) {
-
- Long uid = WebUtil.readLongParam(request, ScratchieConstants.ATTR_USER_UID);
- Long sessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID);
-
- IScratchieService service = getScratchieService();
- ScratchieUser user = service.getUser(uid);
- NotebookEntry notebookEntry = service.getEntry(sessionID, CoreNotebookConstants.NOTEBOOK_TOOL,
- ScratchieConstants.TOOL_SIGNATURE, user.getUserId().intValue());
-
- ScratchieSession session = service.getScratchieSessionBySessionId(sessionID);
-
- return mapping.findForward("success");
- }
-
- /**
* Exports tool results into excel.
* @throws IOException
*/
Fisheye: Tag c7569597546126af159f169353e68e91241b7f10 refers to a dead (removed) revision in file `lams_tool_scratchie/web/pages/learning/leaderselection.jsp'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_scratchie/web/pages/learning/learning.jsp
===================================================================
diff -u -r9e864ab873d7cfd46f81b0347b272e7813daab39 -rc7569597546126af159f169353e68e91241b7f10
--- lams_tool_scratchie/web/pages/learning/learning.jsp (.../learning.jsp) (revision 9e864ab873d7cfd46f81b0347b272e7813daab39)
+++ lams_tool_scratchie/web/pages/learning/learning.jsp (.../learning.jsp) (revision c7569597546126af159f169353e68e91241b7f10)
@@ -10,7 +10,7 @@
-
+
Index: lams_tool_scratchie/web/pages/learning/questionlist.jsp
===================================================================
diff -u -r00c7a1f28f5ef0e4f890aabd0ff5b97701d4b1bb -rc7569597546126af159f169353e68e91241b7f10
--- lams_tool_scratchie/web/pages/learning/questionlist.jsp (.../questionlist.jsp) (revision 00c7a1f28f5ef0e4f890aabd0ff5b97701d4b1bb)
+++ lams_tool_scratchie/web/pages/learning/questionlist.jsp (.../questionlist.jsp) (revision c7569597546126af159f169353e68e91241b7f10)
@@ -9,7 +9,7 @@
-
+
Index: lams_tool_scratchie/web/pages/learning/results.jsp
===================================================================
diff -u -r00c7a1f28f5ef0e4f890aabd0ff5b97701d4b1bb -rc7569597546126af159f169353e68e91241b7f10
--- lams_tool_scratchie/web/pages/learning/results.jsp (.../results.jsp) (revision 00c7a1f28f5ef0e4f890aabd0ff5b97701d4b1bb)
+++ lams_tool_scratchie/web/pages/learning/results.jsp (.../results.jsp) (revision c7569597546126af159f169353e68e91241b7f10)
@@ -10,7 +10,7 @@
-
+
Index: lams_tool_scratchie/web/pages/learning/waitforleader.jsp
===================================================================
diff -u
--- lams_tool_scratchie/web/pages/learning/waitforleader.jsp (revision 0)
+++ lams_tool_scratchie/web/pages/learning/waitforleader.jsp (revision c7569597546126af159f169353e68e91241b7f10)
@@ -0,0 +1,54 @@
+
+
+<%@ include file="/common/taglibs.jsp"%>
+
+
+
+
+ <%@ include file="/common/header.jsp"%>
+
+
+
+
+
+
+
+ ${scratchie.title}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ${user.firstName} ${user.lastName}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Fisheye: Tag c7569597546126af159f169353e68e91241b7f10 refers to a dead (removed) revision in file `lams_tool_scratchie/web/pages/monitoring/manageLeaders.jsp'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_scratchie/web/pages/monitoring/summary.jsp
===================================================================
diff -u -r6b651e7c25c7baa6a942ea7348f59701bbb4e603 -rc7569597546126af159f169353e68e91241b7f10
--- lams_tool_scratchie/web/pages/monitoring/summary.jsp (.../summary.jsp) (revision 6b651e7c25c7baa6a942ea7348f59701bbb4e603)
+++ lams_tool_scratchie/web/pages/monitoring/summary.jsp (.../summary.jsp) (revision c7569597546126af159f169353e68e91241b7f10)
@@ -197,9 +197,6 @@
- >
-
-