Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dbupdates/patch20131130.sql
===================================================================
diff -u
--- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dbupdates/patch20131130.sql (revision 0)
+++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/dbupdates/patch20131130.sql (revision 7ca2ecb923f530394e8f5a4109216cbc0dd975dd)
@@ -0,0 +1,15 @@
+-- Turn off autocommit, so nothing is committed if there is an error
+SET AUTOCOMMIT = 0;
+SET FOREIGN_KEY_CHECKS=0;
+----------------------Put all sql statements below here-------------------------
+
+-- LKC-40 prevent Massive load of DB when accessing tool with 20+ users
+ALTER TABLE tl_lascrt11_user ADD INDEX userIdIndex (user_id);
+ALTER TABLE tl_lascrt11_session ADD INDEX sessionIdIndex (session_id);
+
+----------------------Put all sql statements above here-------------------------
+
+-- If there were no errors, commit and restore autocommit to on
+COMMIT;
+SET AUTOCOMMIT = 1;
+SET FOREIGN_KEY_CHECKS=1;
\ No newline at end of file
Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieSession.java
===================================================================
diff -u -rc7569597546126af159f169353e68e91241b7f10 -r7ca2ecb923f530394e8f5a4109216cbc0dd975dd
--- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieSession.java (.../ScratchieSession.java) (revision c7569597546126af159f169353e68e91241b7f10)
+++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/model/ScratchieSession.java (.../ScratchieSession.java) (revision 7ca2ecb923f530394e8f5a4109216cbc0dd975dd)
@@ -173,5 +173,11 @@
public void setGroupLeader(ScratchieUser groupLeader) {
this.groupLeader = groupLeader;
}
+
+ public boolean isUserGroupLeader(ScratchieUser user) {
+ boolean isUserLeader = (this.groupLeader != null) && user.getUid().equals(this.groupLeader.getUid());
+ return isUserLeader;
+ }
+
}
Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/scratchieApplicationContext.xml
===================================================================
diff -u -raab18261022d7746e10b3651bd3c864356c58a8b -r7ca2ecb923f530394e8f5a4109216cbc0dd975dd
--- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/scratchieApplicationContext.xml (.../scratchieApplicationContext.xml) (revision aab18261022d7746e10b3651bd3c864356c58a8b)
+++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/scratchieApplicationContext.xml (.../scratchieApplicationContext.xml) (revision 7ca2ecb923f530394e8f5a4109216cbc0dd975dd)
@@ -119,7 +119,8 @@
- PROPAGATION_REQUIRED,readOnly
+ PROPAGATION_SUPPORTS,readOnly
+ PROPAGATION_SUPPORTS,readOnly
PROPAGATION_REQUIRED,-java.lang.Exception
PROPAGATION_REQUIRED,-java.lang.Exception
PROPAGATION_REQUIRED,-java.lang.Exception
@@ -141,6 +142,7 @@
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 -r8a54fe0a58501da756e245edb3529d69275623ad -r7ca2ecb923f530394e8f5a4109216cbc0dd975dd
--- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/IScratchieService.java (.../IScratchieService.java) (revision 8a54fe0a58501da756e245edb3529d69275623ad)
+++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/IScratchieService.java (.../IScratchieService.java) (revision 7ca2ecb923f530394e8f5a4109216cbc0dd975dd)
@@ -59,21 +59,14 @@
Scratchie getScratchieByContentId(Long contentId);
/**
- * @param user
- * @param toolSessionId
- * @return
- */
- boolean isUserGroupLeader(ScratchieUser user, ScratchieSession session);
-
- /**
* Set specified user as a leader. Also the previous leader (if any) is marked as non-leader.
*
* @param userId
* @param toolSessionId
*/
ScratchieUser checkLeaderSelectToolForSessionLeader(ScratchieUser user, Long toolSessionId);
- ScratchieAnswer getScratchieAnswerById (Long answerUid);
+ ScratchieAnswer getScratchieAnswerByUid (Long answerUid);
/**
* Check user has the same scrathes logs as group leader. If not - creates missing ones.
@@ -207,7 +200,7 @@
* @param items
* @param user
*/
- void retrieveScratchesOrder(Collection items, ScratchieUser user);
+ void getScratchesOrder(Collection items, ScratchieUser user);
/**
* Fill in scratchieItems with information about whether they were unraveled; and answers with information on their scratched.
@@ -261,19 +254,6 @@
LinkedHashMap exportExcel(Long contentId);
/**
- * Get scratchie item Summary
list according to sessionId and skipHide flag.
- *
- * @param sessionId
- * @param skipHide
- * true, don't get scratchie item if its isHide
flag is true. Otherwise, get all
- * scratchie item
- * @return
- */
- List exportBySessionId(Long sessionId);
-
- List> exportByContentId(Long contentId);
-
- /**
* Create refection entry into notebook tool.
*
* @param sessionId
Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java
===================================================================
diff -u -r89d5ef09ed75d306b9a21956735533e442bb4045 -r7ca2ecb923f530394e8f5a4109216cbc0dd975dd
--- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java (.../ScratchieServiceImpl.java) (revision 89d5ef09ed75d306b9a21956735533e442bb4045)
+++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/service/ScratchieServiceImpl.java (.../ScratchieServiceImpl.java) (revision 7ca2ecb923f530394e8f5a4109216cbc0dd975dd)
@@ -290,14 +290,6 @@
}
@Override
- public boolean isUserGroupLeader(ScratchieUser user, ScratchieSession session) {
-
- ScratchieUser groupLeader = session.getGroupLeader();
- boolean isUserLeader = (groupLeader != null) && user.getUid().equals(groupLeader.getUid());
- return isUserLeader;
- }
-
- @Override
public ScratchieUser checkLeaderSelectToolForSessionLeader(ScratchieUser user, Long toolSessionId) {
if (user == null || toolSessionId == null) {
return null;
@@ -443,76 +435,6 @@
}
@Override
- public List exportBySessionId(Long sessionId) {
- ScratchieSession session = scratchieSessionDao.getSessionBySessionId(sessionId);
- if (session == null) {
- ScratchieServiceImpl.log.error("Failed get ScratchieSession by ID [" + sessionId + "]");
- return null;
- }
- // initial scratchie items list
- List itemList = new ArrayList();
- Set resList = session.getScratchie().getScratchieItems();
- for (ScratchieItem item : resList) {
- // if item is create by author
- if (item.isCreateByAuthor()) {
- Summary sum = new Summary(session.getSessionId(), session.getSessionName(), item, false);
- itemList.add(sum);
- }
- }
-
- // get this session's all scratchie items
- Set sessList = session.getScratchieItems();
- for (ScratchieItem item : sessList) {
-
- // to skip all item create by author
- if (!item.isCreateByAuthor()) {
- Summary sum = new Summary(session.getSessionId(), session.getSessionName(), item, false);
- itemList.add(sum);
- }
- }
-
- return itemList;
- }
-
- @Override
- public List> exportByContentId(Long contentId) {
- Scratchie scratchie = scratchieDao.getByContentId(contentId);
- List> groupList = new ArrayList();
-
- // create init scratchie items list
- List initList = new ArrayList();
- groupList.add(initList);
- Set resList = scratchie.getScratchieItems();
- for (ScratchieItem item : resList) {
- if (item.isCreateByAuthor()) {
- Summary sum = new Summary(null, null, item, true);
- initList.add(sum);
- }
- }
-
- // session by session
- List sessionList = scratchieSessionDao.getByContentId(contentId);
- for (ScratchieSession session : sessionList) {
- List group = new ArrayList();
- // get this session's all scratchie items
- Set sessList = session.getScratchieItems();
- for (ScratchieItem item : sessList) {
- // to skip all item create by author
- if (!item.isCreateByAuthor()) {
- Summary sum = new Summary(session.getSessionId(), session.getSessionName(), item, false);
- group.add(sum);
- }
- }
- if (group.size() == 0) {
- group.add(new Summary(session.getSessionId(), session.getSessionName(), null, false));
- }
- groupList.add(group);
- }
-
- return groupList;
- }
-
- @Override
public Scratchie getScratchieBySessionId(Long sessionId) {
ScratchieSession session = scratchieSessionDao.getSessionBySessionId(sessionId);
// to skip CGLib problem
@@ -534,10 +456,10 @@
@Override
public void logAnswerAccess(ScratchieUser leader, Long answerUid) {
- ScratchieAnswer answer = getScratchieAnswerById(answerUid);
+ ScratchieAnswer answer = this.getScratchieAnswerByUid(answerUid);
Long sessionId = leader.getSession().getSessionId();
- List users = getUsersBySession(sessionId);
+ List users = this.getUsersBySession(sessionId);
for (ScratchieUser user : users) {
ScratchieAnswerVisitLog log = scratchieAnswerVisitDao.getLog(answerUid, user.getUserId());
if (log == null) {
@@ -550,7 +472,7 @@
}
}
- recalculateMarkForSession(leader, false);
+ this.recalculateMarkForSession(leader, false);
}
@@ -590,7 +512,7 @@
}
@Override
- public ScratchieAnswer getScratchieAnswerById(Long answerUid) {
+ public ScratchieAnswer getScratchieAnswerByUid(Long answerUid) {
return (ScratchieAnswer) userManagementService.findById(ScratchieAnswer.class, answerUid);
}
@@ -665,7 +587,7 @@
List usersToShow = new LinkedList();
for (ScratchieUser user : sessionUsers) {
- boolean isUserGroupLeader = isUserGroupLeader(user, session);
+ boolean isUserGroupLeader = session.isUserGroupLeader(user);
//include only leaders in case isUserGroupLeader is ON, include all otherwise
if (isIncludeOnlyLeaders && isUserGroupLeader || !isIncludeOnlyLeaders) {
int totalAttempts = scratchieAnswerVisitDao.getLogCountTotal(sessionId, user.getUserId());
@@ -683,7 +605,7 @@
}
@Override
- public void retrieveScratchesOrder(Collection items, ScratchieUser user) {
+ public void getScratchesOrder(Collection items, ScratchieUser user) {
for (ScratchieItem item : items) {
List itemLogs = scratchieAnswerVisitDao.getLogsByScratchieUserAndItem(
@@ -736,7 +658,7 @@
}
}
- boolean isItemUnraveled = isItemUnraveled(item, userLogs);
+ boolean isItemUnraveled = this.isItemUnraveled(item, userLogs);
item.setUnraveled(isItemUnraveled);
}
@@ -908,14 +830,17 @@
NotebookEntry notebookEntry = getEntry(session.getSessionId(), CoreNotebookConstants.NOTEBOOK_TOOL,
ScratchieConstants.TOOL_SIGNATURE, leader.getUserId().intValue());
if ((notebookEntry != null) && StringUtils.isNotBlank(notebookEntry.getEntry())) {
- ReflectDTO reflectDTO = new ReflectDTO(notebookEntry.getUser());
+ User user = new User();
+ user.setLastName(leader.getLastName());
+ user.setFirstName(leader.getFirstName());
+ ReflectDTO reflectDTO = new ReflectDTO(user);
reflectDTO.setGroupName(session.getSessionName());
String reflection = notebookEntry.getEntry();
if (isEscapeText) {
reflection = StringEscapeUtils.escapeJavaScript(reflection);
}
reflectDTO.setReflection(reflection);
- reflectDTO.setIsGroupLeader(this.isUserGroupLeader(leader, session));
+ reflectDTO.setIsGroupLeader(session.isUserGroupLeader(leader));
reflections.add(reflectDTO);
}
Index: lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java
===================================================================
diff -u -r98d6135d78b975d3d7487470795b4a9e5bbf2bc6 -r7ca2ecb923f530394e8f5a4109216cbc0dd975dd
--- lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java (.../LearningAction.java) (revision 98d6135d78b975d3d7487470795b4a9e5bbf2bc6)
+++ lams_tool_scratchie/src/java/org/lamsfoundation/lams/tool/scratchie/web/action/LearningAction.java (.../LearningAction.java) (revision 7ca2ecb923f530394e8f5a4109216cbc0dd975dd)
@@ -185,7 +185,7 @@
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, toolSession);
+ boolean isUserLeader = toolSession.isUserGroupLeader(user);
sessionMap.put(ScratchieConstants.ATTR_IS_USER_LEADER, isUserLeader);
boolean isUserFinished = user != null && user.isSessionFinished();
sessionMap.put(ScratchieConstants.ATTR_USER_FINISHED, isUserFinished);
@@ -239,7 +239,7 @@
// for teacher in monitoring display the number of attempt.
if (mode.isTeacher()) {
- service.retrieveScratchesOrder(items, user);
+ service.getScratchesOrder(items, user);
}
//calculate max score
@@ -281,7 +281,7 @@
request.setAttribute(ScratchieConstants.ATTR_SESSION_MAP_ID, sessionMapID);
Long toolSessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);
- ScratchieUser user = getCurrentUser(toolSessionId);
+ ScratchieUser user = this.getCurrentUser(toolSessionId);
// set scratched flag for display purpose
Set items = service.getItemsWithIndicatedScratches(toolSessionId, user);
@@ -316,14 +316,14 @@
Long toolSessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);
ScratchieSession toolSession = service.getScratchieSessionBySessionId(toolSessionId);
- ScratchieUser leader = getCurrentUser(toolSessionId);
+ ScratchieUser leader = this.getCurrentUser(toolSessionId);
// only leaders are allowed to scratch answers
- if (!service.isUserGroupLeader(leader, toolSession)) {
+ if (!toolSession.isUserGroupLeader(leader)) {
return null;
}
Long answerUid = NumberUtils.createLong(request.getParameter(ScratchieConstants.PARAM_ANSWER_UID));
- ScratchieAnswer answer = service.getScratchieAnswerById(answerUid);
+ ScratchieAnswer answer = service.getScratchieAnswerByUid(answerUid);
if (answer == null) {
return mapping.findForward(ScratchieConstants.ERROR);
}
@@ -362,7 +362,7 @@
ScratchieUser user = (ScratchieUser) sessionMap.get(ScratchieConstants.ATTR_USER);
// in case of the leader we should let all other learners see Next Activity button
- if (service.isUserGroupLeader(user, toolSession)) {
+ if (toolSession.isUserGroupLeader(user)) {
service.setScratchingFinished(toolSessionId);
}
@@ -517,7 +517,7 @@
HttpSession ss = SessionManager.getSession();
// get back login user DTO
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
- ScratchieUser scratchieUser = service.getUserByIDAndSession(new Long(user.getUserID().intValue()), sessionId);
+ ScratchieUser scratchieUser = service.getUserByIDAndSession(user.getUserID().longValue(), sessionId);
if (scratchieUser == null) {
ScratchieSession session = service.getScratchieSessionBySessionId(sessionId);
@@ -528,7 +528,7 @@
}
private ScratchieUser getSpecifiedUser(Long sessionId, Integer userId) {
- ScratchieUser scratchieUser = service.getUserByIDAndSession(new Long(userId.intValue()), sessionId);
+ ScratchieUser scratchieUser = service.getUserByIDAndSession(userId.longValue(), sessionId);
if (scratchieUser == null) {
log.error("Unable to find specified user for scratchie activity. Screens are likely to fail. SessionId="
+ sessionId + " UserId=" + userId);