Index: lams_tool_vote/conf/language/ApplicationResources.properties
===================================================================
diff -u -rc5172424555b18ee103dd5609fd36e2d886d035a -rafd9f8463f033997ae0deaa55116a875d9da776f
--- lams_tool_vote/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision c5172424555b18ee103dd5609fd36e2d886d035a)
+++ lams_tool_vote/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision afd9f8463f033997ae0deaa55116a875d9da776f)
@@ -177,7 +177,7 @@
error.selectedIndex.empty =Can not continue. Please select the correct answer and click "Done".
error.content.locked =The content has been locked since it is being used by one mor more learners.
The modification of the content is not allowed.
error.content.doesNotExist =Tool Activity Error! Can't continue. Tool content is not ready in the tool's database yet.
-error.content.inUse =The modification of the content is not allowed since one or more students has attempted the activity.
+error.content.inUse =The modification of the content is not allowed since it is being used.
error.content.beingModified =The content can not be presented since it is being modified. Please check back later.
error.content.unstableState =The content is in an unstable state since it has been left editable while monitored.
Please use this screen to redefine the content.
error.defaultContent.notAvailable =Tool Activity Error! Can't continue
The the default content for the Tool Activity has not been set up.
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAppConstants.java
===================================================================
diff -u -ra135b38b088c2fe771f10b3d87705efc5b877412 -rafd9f8463f033997ae0deaa55116a875d9da776f
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAppConstants.java (.../VoteAppConstants.java) (revision a135b38b088c2fe771f10b3d87705efc5b877412)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/VoteAppConstants.java (.../VoteAppConstants.java) (revision afd9f8463f033997ae0deaa55116a875d9da776f)
@@ -38,6 +38,7 @@
*/
public static final String LOAD ="load";
public static final String LOAD_QUESTIONS ="load";
+ public static final String LOAD_MONITORING ="refreshMonitoring";
public static final String LOAD_STARTER ="starter";
public static final String AUTHORING_STARTER ="starter";
public static final String LEARNING_STARTER ="learningStarter";
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/IVoteUserDAO.java
===================================================================
diff -u -r6cfdabe63a1d792f3135529031f9a969768a6b10 -rafd9f8463f033997ae0deaa55116a875d9da776f
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/IVoteUserDAO.java (.../IVoteUserDAO.java) (revision 6cfdabe63a1d792f3135529031f9a969768a6b10)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/IVoteUserDAO.java (.../IVoteUserDAO.java) (revision afd9f8463f033997ae0deaa55116a875d9da776f)
@@ -41,9 +41,13 @@
public VoteQueUsr getVoteUserBySession(final Long queUsrId, final Long voteSessionId);
+ public VoteQueUsr getVoteQueUsrById(long voteQueUsrId);
+
public void saveVoteUser(VoteQueUsr voteUser);
public void updateVoteUser(VoteQueUsr voteUser);
+
+ public List getUserBySessionOnly(final VoteSession voteSession);
public void removeVoteUserById(Long userId);
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteSessionDAO.java
===================================================================
diff -u -r6cfdabe63a1d792f3135529031f9a969768a6b10 -rafd9f8463f033997ae0deaa55116a875d9da776f
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteSessionDAO.java (.../VoteSessionDAO.java) (revision 6cfdabe63a1d792f3135529031f9a969768a6b10)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteSessionDAO.java (.../VoteSessionDAO.java) (revision afd9f8463f033997ae0deaa55116a875d9da776f)
@@ -47,11 +47,11 @@
private static final String LOAD_VOTESESSION_BY_USER = "select votes from VoteSession votes left join fetch "
+ "votes.voteQueUsers user where user.queUsrId=:userId";
- private static final String GET_SESSIONS_FROM_CONTENT = "select votes.voteSessionId from VoteSession vote where vote.voteContent=:voteContent";
+ private static final String GET_SESSIONS_FROM_CONTENT = "select votes.voteSessionId from VoteSession votes where votes.voteContent=:voteContent";
- private static final String COUNT_SESSION_COMPLETE = "from voteSession in class where voteSession.sessionStatus='COMPLETE'";
+ private static final String COUNT_SESSION_COMPLETE = "from voteSession in class VoteSession where voteSession.sessionStatus='COMPLETE'";
- private static final String COUNT_SESSION_INCOMPLETE = "from voteSession in class where voteSession.sessionStatus='INCOMPLETE'";
+ private static final String COUNT_SESSION_INCOMPLETE = "from voteSession in class VoteSession where voteSession.sessionStatus='INCOMPLETE'";
private static final String GET_SESSIONNAMES_FROM_CONTENT = "select votes.session_name from VoteSession votes where votes.voteContent=:voteContent order by votes.voteSessionId";
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteUserDAO.java
===================================================================
diff -u -r6cfdabe63a1d792f3135529031f9a969768a6b10 -rafd9f8463f033997ae0deaa55116a875d9da776f
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteUserDAO.java (.../VoteUserDAO.java) (revision 6cfdabe63a1d792f3135529031f9a969768a6b10)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/dao/hibernate/VoteUserDAO.java (.../VoteUserDAO.java) (revision afd9f8463f033997ae0deaa55116a875d9da776f)
@@ -44,8 +44,8 @@
private static final String COUNT_USERS = "select voteu.queUsrId from VoteQueUsr";
private static final String LOAD_USER_FOR_SESSION = "from voteQueUsr in class VoteQueUsr where voteQueUsr.voteSessionId= :voteSessionId";
-
-
+
+
public VoteQueUsr getVoteUserByUID(Long uid)
{
return (VoteQueUsr) this.getHibernateTemplate()
@@ -97,6 +97,24 @@
}
+ public VoteQueUsr getVoteQueUsrById(long voteQueUsrId)
+ {
+ String query = "from VoteQueUsr user where user.queUsrId=?";
+
+ HibernateTemplate templ = this.getHibernateTemplate();
+ List list = getSession().createQuery(query)
+ .setLong(0,voteQueUsrId)
+ .list();
+
+ if(list != null && list.size() > 0){
+ VoteQueUsr qu = (VoteQueUsr) list.get(0);
+ return qu;
+ }
+ return null;
+ }
+
+
+
public void saveVoteUser(VoteQueUsr voteUser)
{
this.getHibernateTemplate().save(voteUser);
@@ -127,7 +145,17 @@
}
+ public List getUserBySessionOnly(final VoteSession voteSession)
+ {
+ HibernateTemplate templ = this.getHibernateTemplate();
+ List list = getSession().createQuery(LOAD_USER_FOR_SESSION)
+ .setLong("voteSessionId", voteSession.getUid().longValue())
+ .list();
+ return list;
+ }
+
+
public void removeVoteUser(VoteQueUsr voteUser)
{
this.getSession().setFlushMode(FlushMode.AUTO);
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java
===================================================================
diff -u -r6cfdabe63a1d792f3135529031f9a969768a6b10 -rafd9f8463f033997ae0deaa55116a875d9da776f
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java (.../IVoteService.java) (revision 6cfdabe63a1d792f3135529031f9a969768a6b10)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/IVoteService.java (.../IVoteService.java) (revision afd9f8463f033997ae0deaa55116a875d9da776f)
@@ -71,6 +71,8 @@
public void updateVoteUsrAttempt(VoteUsrAttempt mcUsrAttempt) throws VoteApplicationException;
+ public List getUserBySessionOnly(final VoteSession voteSession) throws VoteApplicationException;
+
public void updateVoteQueContent(VoteQueContent voteQueContent) throws VoteApplicationException;
public List getAttemptsForUserAndQuestionContent(final Long queUsrId, final Long mcQueContentId) throws VoteApplicationException;
@@ -103,6 +105,8 @@
public List getAllQuestionEntries(final Long mcContentId) throws VoteApplicationException;
+ public VoteQueUsr getVoteQueUsrById(long voteQueUsrId) throws VoteApplicationException;
+
public VoteSession retrieveVoteSession(Long mcSessionId) throws VoteApplicationException;
public VoteContent retrieveVoteBySessionId(Long mcSessionId) throws VoteApplicationException;
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java
===================================================================
diff -u -r6cfdabe63a1d792f3135529031f9a969768a6b10 -rafd9f8463f033997ae0deaa55116a875d9da776f
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java (.../VoteServicePOJO.java) (revision 6cfdabe63a1d792f3135529031f9a969768a6b10)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/service/VoteServicePOJO.java (.../VoteServicePOJO.java) (revision afd9f8463f033997ae0deaa55116a875d9da776f)
@@ -174,11 +174,26 @@
}
}
- public List retrieveVoteQueContentsByToolContentId(long qaContentId) throws VoteApplicationException
+ public VoteQueUsr getVoteQueUsrById(long voteQueUsrId) throws VoteApplicationException
{
+ try
+ {
+ VoteQueUsr voteQueUsr=voteUserDAO.getVoteQueUsrById(voteQueUsrId);
+ return voteQueUsr;
+ }
+ catch (DataAccessException e)
+ {
+ throw new VoteApplicationException("Exception occured when lams is getting vote QueUsr: "
+ + e.getMessage(),
+ e);
+ }
+ }
+
+ public List retrieveVoteQueContentsByToolContentId(long voteContentId) throws VoteApplicationException
+ {
try
{
- return voteQueContentDAO.getVoteQueContentsByContentId(qaContentId);
+ return voteQueContentDAO.getVoteQueContentsByContentId(voteContentId);
}
catch (DataAccessException e)
{
@@ -232,6 +247,21 @@
}
+ public List getUserBySessionOnly(final VoteSession voteSession) throws VoteApplicationException
+ {
+ try
+ {
+ return voteUserDAO.getUserBySessionOnly(voteSession);
+ }
+ catch (DataAccessException e)
+ {
+ throw new VoteApplicationException("Exception occured when lams is getting vote QueUsr by vote session "
+ + e.getMessage(),
+ e);
+ }
+ }
+
+
public void removeQuestionContentByVoteUid(final Long voteContentUid) throws VoteApplicationException
{
try
@@ -1793,12 +1823,12 @@
/*
!!! COMPLETE THIS !!!
- public IQaUploadedFileDAO getQaUploadedFileDAO() {
- return qaUploadedFileDAO;
+ public IVoteUploadedFileDAO getVoteUploadedFileDAO() {
+ return voteUploadedFileDAO;
}
- public void setQaUploadedFileDAO(IQaUploadedFileDAO qaUploadedFileDAO) {
- this.qaUploadedFileDAO = qaUploadedFileDAO;
+ public void setQaUploadedFileDAO(IVoteUploadedFileDAO voteUploadedFileDAO) {
+ this.voteUploadedFileDAO = voteUploadedFileDAO;
}
*/
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/MonitoringUtil.java
===================================================================
diff -u -r6cfdabe63a1d792f3135529031f9a969768a6b10 -rafd9f8463f033997ae0deaa55116a875d9da776f
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision 6cfdabe63a1d792f3135529031f9a969768a6b10)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision afd9f8463f033997ae0deaa55116a875d9da776f)
@@ -22,8 +22,27 @@
package org.lamsfoundation.lams.tool.vote.web;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeMap;
+
+import javax.servlet.http.HttpServletRequest;
+
import org.apache.log4j.Logger;
import org.lamsfoundation.lams.tool.vote.VoteAppConstants;
+import org.lamsfoundation.lams.tool.vote.VoteComparator;
+import org.lamsfoundation.lams.tool.vote.VoteMonitoredAnswersDTO;
+import org.lamsfoundation.lams.tool.vote.VoteMonitoredUserDTO;
+import org.lamsfoundation.lams.tool.vote.VoteStringComparator;
+import org.lamsfoundation.lams.tool.vote.VoteUtils;
+import org.lamsfoundation.lams.tool.vote.pojos.VoteContent;
+import org.lamsfoundation.lams.tool.vote.pojos.VoteQueContent;
+import org.lamsfoundation.lams.tool.vote.pojos.VoteQueUsr;
+import org.lamsfoundation.lams.tool.vote.pojos.VoteSession;
+import org.lamsfoundation.lams.tool.vote.pojos.VoteUsrAttempt;
+import org.lamsfoundation.lams.tool.vote.service.IVoteService;
/**
*
@@ -33,5 +52,422 @@
*/
public class MonitoringUtil implements VoteAppConstants{
static Logger logger = Logger.getLogger(MonitoringUtil.class.getName());
+
+ public static Map populateToolSessions(HttpServletRequest request, VoteContent voteContent, IVoteService voteService)
+ {
+ List sessionsList=voteService.getSessionNamesFromContent(voteContent);
+ logger.debug("sessionsList size is:..." + sessionsList.size());
+
+ Map sessionsMap=VoteUtils.convertToStringMap(sessionsList, "String");
+ logger.debug("generated sessionsMap:..." + sessionsMap);
+ logger.debug("sessionsMap size:..." + sessionsMap.size());
+
+ if (sessionsMap.isEmpty())
+ {
+ logger.debug("sessionsMap size is 0:");
+ sessionsMap.put(new Long(1).toString() , "None");
+ }
+ else
+ {
+ logger.debug("sessionsMap has some entries: " + sessionsMap.size());
+ sessionsMap.put(new Long(sessionsMap.size()+ 1).toString() , "All");
+ }
+
+ logger.debug("final sessionsMap:" + sessionsMap);
+ return sessionsMap;
+ }
+
+ public static List buildGroupsQuestionData(HttpServletRequest request, VoteContent voteContent,
+ boolean isUserNamesVisible, boolean isLearnerRequest, String currentSessionId, String userId)
+ {
+ logger.debug("isUserNamesVisible: " + isUserNamesVisible);
+ logger.debug("isLearnerRequest: " + isLearnerRequest);
+ logger.debug("userId: " + userId);
+
+ IVoteService voteService = (IVoteService)request.getSession().getAttribute(TOOL_SERVICE);
+ logger.debug("voteService: " + voteService);
+
+ logger.debug("will be building groups question data for content:..." + voteContent);
+ List listQuestions=voteService.getAllQuestionEntries(voteContent.getUid());
+ logger.debug("listQuestions:..." + listQuestions);
+
+ List listMonitoredAnswersContainerDTO= new LinkedList();
+
+ Iterator itListQuestions = listQuestions.iterator();
+ while (itListQuestions.hasNext())
+ {
+ VoteQueContent voteQueContent =(VoteQueContent)itListQuestions.next();
+ logger.debug("voteQueContent:..." + voteQueContent);
+ if (voteQueContent != null)
+ {
+ VoteMonitoredAnswersDTO voteMonitoredAnswersDTO= new VoteMonitoredAnswersDTO();
+ voteMonitoredAnswersDTO.setQuestionUid(voteQueContent.getUid().toString());
+ voteMonitoredAnswersDTO.setQuestion(voteQueContent.getQuestion());
+
+ logger.debug("using allUsersData to retrieve users data: " + isUserNamesVisible);
+ Map questionAttemptData= buildGroupsAttemptData(request, voteContent, voteQueContent, voteQueContent.getUid().toString(),
+ isUserNamesVisible,isLearnerRequest, currentSessionId, userId);
+ logger.debug("questionAttemptData:..." + questionAttemptData);
+ voteMonitoredAnswersDTO.setQuestionAttempts(questionAttemptData);
+ listMonitoredAnswersContainerDTO.add(voteMonitoredAnswersDTO);
+
+ }
+ }
+ logger.debug("final listMonitoredAnswersContainerDTO:..." + listMonitoredAnswersContainerDTO);
+ return listMonitoredAnswersContainerDTO;
+ }
+
+
+ public static Map buildGroupsAttemptData(HttpServletRequest request, VoteContent voteContent, VoteQueContent voteQueContent, String questionUid,
+ boolean isUserNamesVisible, boolean isLearnerRequest, String currentSessionId, String userId)
+ {
+ logger.debug("isUserNamesVisible: " + isUserNamesVisible);
+ logger.debug("isLearnerRequest: " + isLearnerRequest);
+ logger.debug("currentSessionId: " + currentSessionId);
+ logger.debug("userId: " + userId);
+
+ logger.debug("doing buildGroupsAttemptData...");
+ IVoteService voteService = (IVoteService)request.getSession().getAttribute(TOOL_SERVICE);
+ logger.debug("voteService: " + voteService);
+
+ Map mapMonitoredAttemptsContainerDTO= new TreeMap(new VoteComparator());
+ List listMonitoredAttemptsContainerDTO= new LinkedList();
+
+ Map summaryToolSessions=populateToolSessionsId(request, voteContent, voteService);
+ logger.debug("summaryToolSessions: " + summaryToolSessions);
+
+ Iterator itMap = summaryToolSessions.entrySet().iterator();
+
+
+ /*request is for monitoring summary */
+ if (!isLearnerRequest)
+ {
+ while (itMap.hasNext())
+ {
+ Map.Entry pairs = (Map.Entry)itMap.next();
+ logger.debug("using the summary tool sessions pair: " + pairs.getKey() + " = " + pairs.getValue());
+
+ if (!(pairs.getValue().toString().equals("None")) && !(pairs.getValue().toString().equals("All")))
+ {
+ logger.debug("using the numerical summary tool sessions pair: " + " = " + pairs.getValue());
+ VoteSession voteSession= voteService.retrieveVoteSession(new Long(pairs.getValue().toString()));
+ logger.debug("voteSession: " + " = " + voteSession);
+ if (voteSession != null)
+ {
+ List listUsers=voteService.getUserBySessionOnly(voteSession);
+ logger.debug("listMcUsers for session id:" + voteSession.getVoteSessionId() + " = " + listUsers);
+ Map sessionUsersAttempts=populateSessionUsersAttempts(request,voteSession.getVoteSessionId(), listUsers, questionUid,
+ isUserNamesVisible, isLearnerRequest, userId);
+ listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts);
+ }
+ }
+ }
+ }
+ else
+ {
+ /*request is for learner report, use only the passed tool session in the report*/
+ logger.debug("using currentSessionId for the learner report:" + currentSessionId);
+ while (itMap.hasNext())
+ {
+ Map.Entry pairs = (Map.Entry)itMap.next();
+ logger.debug("using the summary tool sessions pair: " + pairs.getKey() + " = " + pairs.getValue());
+
+ if (!(pairs.getValue().toString().equals("None")) && !(pairs.getValue().toString().equals("All")))
+ {
+ logger.debug("using the numerical summary tool sessions pair: " + " = " + pairs.getValue());
+
+ if (currentSessionId.equals(pairs.getValue()))
+ {
+ logger.debug("only using this tool session for the learner report: " + " = " + pairs.getValue());
+ VoteSession voteSession= voteService.retrieveVoteSession(new Long(pairs.getValue().toString()));
+ logger.debug("voteSession: " + " = " + voteSession);
+ if (voteSession != null)
+ {
+ List listUsers=voteService.getUserBySessionOnly(voteSession);
+ logger.debug("listMcUsers for session id:" + voteSession.getVoteSessionId() + " = " + listUsers);
+ Map sessionUsersAttempts=populateSessionUsersAttempts(request,voteSession.getVoteSessionId(), listUsers, questionUid,
+ isUserNamesVisible, isLearnerRequest, userId);
+ listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts);
+ }
+ }
+ }
+ }
+ }
+
+ logger.debug("final listMonitoredAttemptsContainerDTO:..." + listMonitoredAttemptsContainerDTO);
+ mapMonitoredAttemptsContainerDTO=convertToMap(listMonitoredAttemptsContainerDTO);
+ logger.debug("final mapMonitoredAttemptsContainerDTO:..." + mapMonitoredAttemptsContainerDTO);
+ return mapMonitoredAttemptsContainerDTO;
+ }
+
+
+ public static Map populateSessionUsersAttempts(HttpServletRequest request,Long sessionId, List listUsers, String questionUid,
+ boolean isUserNamesVisible, boolean isLearnerRequest, String userId)
+ {
+ logger.debug("isUserNamesVisible: " + isUserNamesVisible);
+ logger.debug("isLearnerRequest: " + isLearnerRequest);
+ logger.debug("userId: " + userId);
+
+ logger.debug("doing populateSessionUsersAttempts...");
+ IVoteService voteService = (IVoteService)request.getSession().getAttribute(TOOL_SERVICE);
+ logger.debug("voteService: " + voteService);
+
+ Map mapMonitoredUserContainerDTO= new TreeMap(new VoteStringComparator());
+ List listMonitoredUserContainerDTO= new LinkedList();
+ Iterator itUsers=listUsers.iterator();
+
+
+ if (userId == null)
+ {
+ logger.debug("request is not for learner progress report");
+ if ((isUserNamesVisible) && (!isLearnerRequest))
+ {
+ logger.debug("isUserNamesVisible true, isLearnerRequest false" );
+ logger.debug("getting alll the user' data");
+ while (itUsers.hasNext())
+ {
+ VoteQueUsr voteQueUsr=(VoteQueUsr)itUsers.next();
+ logger.debug("voteQueUsr: " + voteQueUsr);
+
+ if (voteQueUsr != null)
+ {
+ logger.debug("getting listUserAttempts for user id: " + voteQueUsr.getUid() + " and que content id: " + questionUid);
+ List listUserAttempts=voteService.getAttemptsForUserAndQuestionContent(voteQueUsr.getUid(), new Long(questionUid));
+ logger.debug("listUserAttempts: " + listUserAttempts);
+
+ Iterator itAttempts=listUserAttempts.iterator();
+ while (itAttempts.hasNext())
+ {
+ VoteUsrAttempt voteUsrResp=(VoteUsrAttempt)itAttempts.next();
+ logger.debug("voteUsrResp: " + voteUsrResp);
+
+ if (voteUsrResp != null)
+ {
+ VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO();
+ voteMonitoredUserDTO.setAttemptTime(voteUsrResp.getAttemptTime().toString());
+ voteMonitoredUserDTO.setTimeZone(voteUsrResp.getTimeZone());
+ //voteMonitoredUserDTO.setUid(voteUsrResp.getResponseId().toString());
+ voteMonitoredUserDTO.setUserName(voteQueUsr.getUsername());
+ voteMonitoredUserDTO.setQueUsrId(voteQueUsr.getUid().toString());
+ voteMonitoredUserDTO.setSessionId(sessionId.toString());
+ voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry());
+ voteMonitoredUserDTO.setQuestionUid(questionUid);
+ listMonitoredUserContainerDTO.add(voteMonitoredUserDTO);
+ }
+ }
+ }
+ }
+ }
+ else if ((isUserNamesVisible) && (isLearnerRequest))
+ {
+ logger.debug("just populating data normally just like monitoring summary, except that the data is ony for a specific session" );
+ logger.debug("isUserNamesVisible true, isLearnerRequest true" );
+ String userID= (String)request.getSession().getAttribute(USER_ID);
+ logger.debug("userID: " + userID);
+ VoteQueUsr voteQueUsr=voteService.getVoteQueUsrById(new Long(userID).longValue());
+ logger.debug("the current user voteQueUsr " + voteQueUsr + " and username: " + voteQueUsr.getUsername());
+
+ while (itUsers.hasNext())
+ {
+ voteQueUsr=(VoteQueUsr)itUsers.next();
+ logger.debug("voteQueUsr: " + voteQueUsr);
+
+ if (voteQueUsr != null)
+ {
+ logger.debug("getting listUserAttempts for user id: " + voteQueUsr.getUid() + " and que content id: " + questionUid);
+ List listUserAttempts=voteService.getAttemptsForUserAndQuestionContent(voteQueUsr.getUid(), new Long(questionUid));
+ logger.debug("listUserAttempts: " + listUserAttempts);
+
+ Iterator itAttempts=listUserAttempts.iterator();
+ while (itAttempts.hasNext())
+ {
+ VoteUsrAttempt voteUsrResp=(VoteUsrAttempt)itAttempts.next();
+ logger.debug("voteUsrResp: " + voteUsrResp);
+
+ if (voteUsrResp != null)
+ {
+ VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO();
+ voteMonitoredUserDTO.setAttemptTime(voteUsrResp.getAttemptTime().toString());
+ voteMonitoredUserDTO.setTimeZone(voteUsrResp.getTimeZone());
+ voteMonitoredUserDTO.setUid(voteUsrResp.getUid().toString());
+ voteMonitoredUserDTO.setUserName(voteQueUsr.getUsername());
+ voteMonitoredUserDTO.setQueUsrId(voteQueUsr.getUid().toString());
+ voteMonitoredUserDTO.setSessionId(sessionId.toString());
+ voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry());
+ voteMonitoredUserDTO.setQuestionUid(questionUid);
+ listMonitoredUserContainerDTO.add(voteMonitoredUserDTO);
+ }
+ }
+ }
+ }
+ }
+ else if ((!isUserNamesVisible) && (isLearnerRequest))
+ {
+ logger.debug("populating data normally exception are for a specific session and other user names are not visible.");
+ logger.debug("isUserNamesVisible false, isLearnerRequest true" );
+ logger.debug("getting only current user's data" );
+ String userID= (String)request.getSession().getAttribute(USER_ID);
+ logger.debug("userID: " + userID);
+
+ while (itUsers.hasNext())
+ {
+ VoteQueUsr voteQueUsr=(VoteQueUsr)itUsers.next();
+ logger.debug("voteQueUsr: " + voteQueUsr);
+
+ if (voteQueUsr != null)
+ {
+ logger.debug("getting listUserAttempts for user id: " + voteQueUsr.getUid() + " and que content id: " + questionUid);
+ List listUserAttempts=voteService.getAttemptsForUserAndQuestionContent(voteQueUsr.getUid(), new Long(questionUid));
+ logger.debug("listUserAttempts: " + listUserAttempts);
+
+ Iterator itAttempts=listUserAttempts.iterator();
+ while (itAttempts.hasNext())
+ {
+ VoteUsrAttempt voteUsrResp=(VoteUsrAttempt)itAttempts.next();
+ logger.debug("voteUsrResp: " + voteUsrResp);
+
+ if (voteUsrResp != null)
+ {
+ VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO();
+ voteMonitoredUserDTO.setAttemptTime(voteUsrResp.getAttemptTime().toString());
+ voteMonitoredUserDTO.setTimeZone(voteUsrResp.getTimeZone());
+ voteMonitoredUserDTO.setUid(voteUsrResp.getUid().toString());
+
+ logger.debug("userID versus queUsrId: " + userID + "-" + voteQueUsr.getQueUsrId());
+ if (userID.equals(voteQueUsr.getQueUsrId().toString()))
+ {
+ logger.debug("this is current user, put his name normally.");
+ voteMonitoredUserDTO.setUserName(voteQueUsr.getUsername());
+ }
+ else
+ {
+ logger.debug("this is not current user, put his name as blank.");
+ voteMonitoredUserDTO.setUserName("[ ]");
+ }
+
+ voteMonitoredUserDTO.setQueUsrId(voteQueUsr.getUid().toString());
+ voteMonitoredUserDTO.setSessionId(sessionId.toString());
+ voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry());
+ voteMonitoredUserDTO.setQuestionUid(questionUid);
+ listMonitoredUserContainerDTO.add(voteMonitoredUserDTO);
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ logger.debug("request is for learner progress report: " + userId);
+ while (itUsers.hasNext())
+ {
+ VoteQueUsr voteQueUsr=(VoteQueUsr)itUsers.next();
+ logger.debug("voteQueUsr: " + voteQueUsr);
+
+ if (voteQueUsr != null)
+ {
+ logger.debug("getting listUserAttempts for user id: " + voteQueUsr.getUid() + " and que content id: " + questionUid);
+ List listUserAttempts=voteService.getAttemptsForUserAndQuestionContent(voteQueUsr.getUid(), new Long(questionUid));
+ logger.debug("listUserAttempts: " + listUserAttempts);
+
+ Iterator itAttempts=listUserAttempts.iterator();
+ while (itAttempts.hasNext())
+ {
+ VoteUsrAttempt voteUsrResp=(VoteUsrAttempt)itAttempts.next();
+ logger.debug("voteUsrResp: " + voteUsrResp);
+
+ if (voteUsrResp != null)
+ {
+ logger.debug("userID versus queUsrId: " + userId + "-" + voteQueUsr.getQueUsrId());
+ if (userId.equals(voteQueUsr.getQueUsrId().toString()))
+ {
+ logger.debug("this is the user requested , include his name for learner progress.");
+ VoteMonitoredUserDTO voteMonitoredUserDTO = new VoteMonitoredUserDTO();
+ voteMonitoredUserDTO.setAttemptTime(voteUsrResp.getAttemptTime().toString());
+ voteMonitoredUserDTO.setTimeZone(voteUsrResp.getTimeZone());
+ voteMonitoredUserDTO.setUid(voteUsrResp.getUid().toString());
+ voteMonitoredUserDTO.setUserName(voteQueUsr.getUsername());
+ voteMonitoredUserDTO.setQueUsrId(voteQueUsr.getUid().toString());
+ voteMonitoredUserDTO.setSessionId(sessionId.toString());
+ voteMonitoredUserDTO.setResponse(voteUsrResp.getUserEntry());
+ voteMonitoredUserDTO.setQuestionUid(questionUid);
+ listMonitoredUserContainerDTO.add(voteMonitoredUserDTO);
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+
+ logger.debug("final listMonitoredUserContainerDTO: " + listMonitoredUserContainerDTO);
+ mapMonitoredUserContainerDTO=convertToVoteMonitoredUserDTOMap(listMonitoredUserContainerDTO);
+ logger.debug("final mapMonitoredUserContainerDTO:..." + mapMonitoredUserContainerDTO);
+ return mapMonitoredUserContainerDTO;
+ }
+
+
+
+ public static Map populateToolSessionsId(HttpServletRequest request, VoteContent voteContent, IVoteService voteService)
+ {
+ logger.debug("attempt populateToolSessionsId for: " + voteContent);
+ List sessionsList=voteService.getSessionsFromContent(voteContent);
+ logger.debug("sessionsList size is:..." + sessionsList.size());
+
+ Map sessionsMap=VoteUtils.convertToStringMap(sessionsList, "Long");
+ logger.debug("generated sessionsMap:..." + sessionsMap);
+ logger.debug("sessionsMap size:..." + sessionsMap.size());
+
+ if (sessionsMap.isEmpty())
+ {
+ logger.debug("sessionsMap size is 0:");
+ sessionsMap.put(new Long(1).toString() , "None");
+ }
+ else
+ {
+ logger.debug("sessionsMap has some entries: " + sessionsMap.size());
+ sessionsMap.put(new Long(sessionsMap.size()+ 1).toString() , "All");
+ }
+
+ logger.debug("final sessionsMap:" + sessionsMap);
+ return sessionsMap;
+ }
+
+ public static Map convertToVoteMonitoredUserDTOMap(List list)
+ {
+ logger.debug("using convertToVoteMonitoredUserDTOMap: " + list);
+ Map map= new TreeMap(new VoteComparator());
+
+ Iterator listIterator=list.iterator();
+ Long mapIndex=new Long(1);
+
+ while (listIterator.hasNext())
+ {
+ VoteMonitoredUserDTO data=(VoteMonitoredUserDTO)listIterator.next();
+ map.put(mapIndex.toString(), data);
+ mapIndex=new Long(mapIndex.longValue()+1);
+ }
+ return map;
+ }
+
+
+ public static Map convertToMap(List list)
+ {
+ logger.debug("using convertToMap: " + list);
+ Map map= new TreeMap(new VoteComparator());
+
+ Iterator listIterator=list.iterator();
+ Long mapIndex=new Long(1);
+
+ while (listIterator.hasNext())
+ {
+ Map data=(Map)listIterator.next();
+ map.put(mapIndex.toString(), data);
+ mapIndex=new Long(mapIndex.longValue()+1);
+ }
+ return map;
+ }
+
}
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningForm.java
===================================================================
diff -u -r6cfdabe63a1d792f3135529031f9a969768a6b10 -rafd9f8463f033997ae0deaa55116a875d9da776f
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningForm.java (.../VoteLearningForm.java) (revision 6cfdabe63a1d792f3135529031f9a969768a6b10)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteLearningForm.java (.../VoteLearningForm.java) (revision afd9f8463f033997ae0deaa55116a875d9da776f)
@@ -48,9 +48,125 @@
protected String donePreview;
protected String doneLearnerProgress;
+ protected String method;
+ protected String answer;
+ protected String currentQuestionIndex;
+ protected String submitAnswersContent;
+ protected String getNextQuestion;
+ protected String getPreviousQuestion;
+ protected String endLearning;
+ protected void resetUserActions()
+ {
+ this.getNextQuestion=null;
+ this.getPreviousQuestion=null;
+ this.endLearning=null;
+ }
+
+ /**
+ * @return Returns the answer.
+ */
+ public String getAnswer() {
+ return answer;
+ }
+ /**
+ * @param answer The answer to set.
+ */
+ public void setAnswer(String answer) {
+ this.answer = answer;
+ }
+ /**
+ * @return Returns the currentQuestionIndex.
+ */
+ public String getCurrentQuestionIndex() {
+ return currentQuestionIndex;
+ }
+ /**
+ * @param currentQuestionIndex The currentQuestionIndex to set.
+ */
+ public void setCurrentQuestionIndex(String currentQuestionIndex) {
+ this.currentQuestionIndex = currentQuestionIndex;
+ }
+ /**
+ * @return Returns the endLearning.
+ */
+ public String getEndLearning() {
+ return endLearning;
+ }
+ /**
+ * @param endLearning The endLearning to set.
+ */
+ public void setEndLearning(String endLearning) {
+ this.endLearning = endLearning;
+ }
+ /**
+ * @return Returns the getNextQuestion.
+ */
+ public String getGetNextQuestion() {
+ return getNextQuestion;
+ }
+ /**
+ * @param getNextQuestion The getNextQuestion to set.
+ */
+ public void setGetNextQuestion(String getNextQuestion) {
+ this.getNextQuestion = getNextQuestion;
+ }
+ /**
+ * @return Returns the getPreviousQuestion.
+ */
+ public String getGetPreviousQuestion() {
+ return getPreviousQuestion;
+ }
+ /**
+ * @param getPreviousQuestion The getPreviousQuestion to set.
+ */
+ public void setGetPreviousQuestion(String getPreviousQuestion) {
+ this.getPreviousQuestion = getPreviousQuestion;
+ }
+ /**
+ * @return Returns the method.
+ */
+ public String getMethod() {
+ return method;
+ }
+ /**
+ * @param method The method to set.
+ */
+ public void setMethod(String method) {
+ this.method = method;
+ }
+ /**
+ * @return Returns the responseId.
+ */
+ public String getResponseId() {
+ return responseId;
+ }
+ /**
+ * @param responseId The responseId to set.
+ */
+ public void setResponseId(String responseId) {
+ this.responseId = responseId;
+ }
+ /**
+ * @return Returns the submitAnswersContent.
+ */
+ public String getSubmitAnswersContent() {
+ return submitAnswersContent;
+ }
+ /**
+ * @param submitAnswersContent The submitAnswersContent to set.
+ */
+ public void setSubmitAnswersContent(String submitAnswersContent) {
+ this.submitAnswersContent = submitAnswersContent;
+ }
+ protected String responseId;
+
+
+
+
+
public void resetCommands()
{
this.setContinueOptions(null);
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringAction.java
===================================================================
diff -u -r6cfdabe63a1d792f3135529031f9a969768a6b10 -rafd9f8463f033997ae0deaa55116a875d9da776f
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringAction.java (.../VoteMonitoringAction.java) (revision 6cfdabe63a1d792f3135529031f9a969768a6b10)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringAction.java (.../VoteMonitoringAction.java) (revision afd9f8463f033997ae0deaa55116a875d9da776f)
@@ -23,6 +23,8 @@
package org.lamsfoundation.lams.tool.vote.web;
import java.io.IOException;
+import java.util.List;
+import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -38,6 +40,9 @@
import org.lamsfoundation.lams.tool.vote.VoteAppConstants;
import org.lamsfoundation.lams.tool.vote.VoteApplicationException;
import org.lamsfoundation.lams.tool.vote.VoteUtils;
+import org.lamsfoundation.lams.tool.vote.pojos.VoteContent;
+import org.lamsfoundation.lams.tool.vote.service.IVoteService;
+import org.lamsfoundation.lams.tool.vote.service.VoteServiceProxy;
import org.lamsfoundation.lams.web.action.LamsDispatchAction;
/**
@@ -102,8 +107,237 @@
return null;
}
+ public void refreshSummaryData(HttpServletRequest request, VoteContent voteContent, IVoteService voteService,
+ boolean isUserNamesVisible, boolean isLearnerRequest, String currentSessionId, String userId)
+ {
+ if (voteService == null)
+ {
+ logger.debug("will retrieve voteService");
+ voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
+ logger.debug("retrieving voteService from session: " + voteService);
+ }
+ if (voteService == null)
+ {
+ voteService = (IVoteService)request.getSession().getAttribute(TOOL_SERVICE);
+ logger.debug("voteService: " + voteService);
+ }
+
+
+ logger.debug("isUserNamesVisible: " + isUserNamesVisible);
+ logger.debug("isLearnerRequest: " + isLearnerRequest);
+
+ /* this section is related to summary tab. Starts here. */
+ Map summaryToolSessions=MonitoringUtil.populateToolSessions(request, voteContent, voteService);
+ logger.debug("summaryToolSessions: " + summaryToolSessions);
+ request.getSession().setAttribute(SUMMARY_TOOL_SESSIONS, summaryToolSessions);
+
+
+ if (voteService.studentActivityOccurredGlobal(voteContent))
+ {
+ request.getSession().setAttribute(USER_EXCEPTION_NO_TOOL_SESSIONS, new Boolean(false).toString());
+ logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false");
+ }
+ else
+ {
+ request.getSession().setAttribute(USER_EXCEPTION_NO_TOOL_SESSIONS, new Boolean(true).toString());
+ logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true");
+ logger.debug("error.noLearnerActivity must be displayed");
+ }
+
+
+ Map summaryToolSessionsId=MonitoringUtil.populateToolSessionsId(request, voteContent, voteService);
+ logger.debug("summaryToolSessionsId: " + summaryToolSessionsId);
+ request.getSession().setAttribute(SUMMARY_TOOL_SESSIONS_ID, summaryToolSessionsId);
+
+ /* SELECTION_CASE == 2 indicates start up */
+ request.getSession().setAttribute(SELECTION_CASE, new Long(2));
+ logger.debug("SELECTION_CASE: " + request.getSession().getAttribute(SELECTION_CASE));
+
+ /* Default to All for tool Sessions so that all tool sessions' summary information gets displayed when the module starts up */
+ request.getSession().setAttribute(CURRENT_MONITORED_TOOL_SESSION, "All");
+ logger.debug("CURRENT_MONITORED_TOOL_SESSION: " + request.getSession().getAttribute(CURRENT_MONITORED_TOOL_SESSION));
+
+
+ logger.debug("using allUsersData to retrieve data: " + isUserNamesVisible);
+ List listMonitoredAnswersContainerDTO=MonitoringUtil.buildGroupsQuestionData(request, voteContent,
+ isUserNamesVisible, isLearnerRequest, currentSessionId, userId);
+ request.getSession().setAttribute(LIST_MONITORED_ANSWERS_CONTAINER_DTO, listMonitoredAnswersContainerDTO);
+ logger.debug("LIST_MONITORED_ANSWERS_CONTAINER_DTO: " + request.getSession().getAttribute(LIST_MONITORED_ANSWERS_CONTAINER_DTO));
+ /* ends here. */
+ }
+
+
+ public void initSummaryContent(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ {
+ logger.debug("start initSummaryContent...");
+
+ logger.debug("dispatching getSummary..." + request);
+
+ IVoteService voteService = (IVoteService)request.getSession().getAttribute(TOOL_SERVICE);
+ logger.debug("voteService: " + voteService);
+ if (voteService == null)
+ {
+ logger.debug("will retrieve voteService");
+ voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
+ logger.debug("retrieving voteService from session: " + voteService);
+ }
+
+ Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID);
+ logger.debug("toolContentId: " + toolContentId);
+
+ VoteContent voteContent=voteService.retrieveVote(toolContentId);
+ logger.debug("existing voteContent:" + voteContent);
+
+ /* this section is related to summary tab. Starts here. */
+ Map summaryToolSessions=MonitoringUtil.populateToolSessions(request, voteContent, voteService);
+ logger.debug("summaryToolSessions: " + summaryToolSessions);
+ request.getSession().setAttribute(SUMMARY_TOOL_SESSIONS, summaryToolSessions);
+ logger.debug("SUMMARY_TOOL_SESSIONS: " + request.getSession().getAttribute(SUMMARY_TOOL_SESSIONS));
+ /* ends here. */
+
+ /*true means there is at least 1 response*/
+ if (voteService.studentActivityOccurredGlobal(voteContent))
+ {
+ request.getSession().setAttribute(USER_EXCEPTION_NO_TOOL_SESSIONS, new Boolean(false).toString());
+ logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false");
+ }
+ else
+ {
+ request.getSession().setAttribute(USER_EXCEPTION_NO_TOOL_SESSIONS, new Boolean(true).toString());
+ logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true");
+ }
+
+ request.getSession().setAttribute(CURRENT_MONITORING_TAB, "summary");
+ logger.debug("end initSummaryContent...");
+ }
+
+ public void initInstructionsContent(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ {
+ logger.debug("starting initInstructionsContent...");
+ logger.debug("dispatching getInstructions..." + request);
+
+ IVoteService voteService = (IVoteService)request.getSession().getAttribute(TOOL_SERVICE);
+ logger.debug("voteService: " + voteService);
+ if (voteService == null)
+ {
+ logger.debug("will retrieve voteService");
+ voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
+ logger.debug("retrieving voteService from session: " + voteService);
+ }
+
+ Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID);
+ logger.debug("toolContentId: " + toolContentId);
+
+ VoteContent voteContent=voteService.retrieveVote(toolContentId);
+ logger.debug("existing voteContent:" + voteContent);
+
+ if (voteService.studentActivityOccurredGlobal(voteContent))
+ {
+ request.getSession().setAttribute(USER_EXCEPTION_NO_TOOL_SESSIONS, new Boolean(false).toString());
+ logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false");
+ }
+ else
+ {
+ request.getSession().setAttribute(USER_EXCEPTION_NO_TOOL_SESSIONS, new Boolean(true).toString());
+ logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true");
+ }
+
+ refreshInstructionsData(request, voteContent);
+
+ request.getSession().setAttribute(CURRENT_MONITORING_TAB, "instructions");
+ logger.debug("ending initInstructionsContent...");
+ }
+
+ public void refreshInstructionsData(HttpServletRequest request, VoteContent voteContent)
+ {
+ request.getSession().setAttribute(RICHTEXT_ONLINEINSTRUCTIONS,voteContent.getOnlineInstructions());
+ request.getSession().setAttribute(RICHTEXT_OFFLINEINSTRUCTIONS,voteContent.getOfflineInstructions());
+ }
+
+
+ public void initStatsContent(ActionMapping mapping,
+ ActionForm form,
+ HttpServletRequest request,
+ HttpServletResponse response) throws IOException,
+ ServletException
+ {
+ logger.debug("starting initStatsContent...");
+ logger.debug("dispatching getStats..." + request);
+
+ IVoteService voteService = (IVoteService)request.getSession().getAttribute(TOOL_SERVICE);
+ logger.debug("voteService: " + voteService);
+ if (voteService == null)
+ {
+ logger.debug("will retrieve voteService");
+ voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
+ logger.debug("retrieving voteService from session: " + voteService);
+ }
+
+ Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID);
+ logger.debug("toolContentId: " + toolContentId);
+
+ VoteContent voteContent=voteService.retrieveVote(toolContentId);
+ logger.debug("existing voteContent:" + voteContent);
+
+
+ if (voteService.studentActivityOccurredGlobal(voteContent))
+ {
+ request.getSession().setAttribute(USER_EXCEPTION_NO_TOOL_SESSIONS, new Boolean(false).toString());
+ logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false");
+ }
+ else
+ {
+ request.getSession().setAttribute(USER_EXCEPTION_NO_TOOL_SESSIONS, new Boolean(true).toString());
+ logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true");
+ }
+
+ refreshStatsData(request);
+
+ request.getSession().setAttribute(CURRENT_MONITORING_TAB, "stats");
+ logger.debug("ending initStatsContent...");
+ }
+
+ public void refreshStatsData(HttpServletRequest request)
+ {
+ /* it is possible that no users has ever logged in for the activity yet*/
+ IVoteService voteService = (IVoteService)request.getSession().getAttribute(TOOL_SERVICE);
+ logger.debug("voteService: " + voteService);
+ if (voteService == null)
+ {
+ logger.debug("will retrieve voteService");
+ voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
+ logger.debug("retrieving voteService from session: " + voteService);
+ }
+
+
+ int countAllUsers=voteService.getTotalNumberOfUsers();
+ logger.debug("countAllUsers: " + countAllUsers);
+
+ if (countAllUsers == 0)
+ {
+ logger.debug("error: countAllUsers is 0");
+ request.getSession().setAttribute(USER_EXCEPTION_NO_STUDENT_ACTIVITY, new Boolean(true));
+ }
+
+ request.getSession().setAttribute(COUNT_ALL_USERS, new Integer(countAllUsers).toString());
+
+ int countSessionComplete=voteService.countSessionComplete();
+ logger.debug("countSessionComplete: " + countSessionComplete);
+ request.getSession().setAttribute(COUNT_SESSION_COMPLETE, new Integer(countSessionComplete).toString());
+ }
+
+
+
/**
* persists error messages to request scope
* @param request
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringForm.java
===================================================================
diff -u -r6cfdabe63a1d792f3135529031f9a969768a6b10 -rafd9f8463f033997ae0deaa55116a875d9da776f
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringForm.java (.../VoteMonitoringForm.java) (revision 6cfdabe63a1d792f3135529031f9a969768a6b10)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringForm.java (.../VoteMonitoringForm.java) (revision afd9f8463f033997ae0deaa55116a875d9da776f)
@@ -37,6 +37,7 @@
protected String isToolSessionChanged;
+
/**
* @return Returns the isToolSessionChanged.
*/
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringStarterAction.java
===================================================================
diff -u -r6cfdabe63a1d792f3135529031f9a969768a6b10 -rafd9f8463f033997ae0deaa55116a875d9da776f
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringStarterAction.java (.../VoteMonitoringStarterAction.java) (revision 6cfdabe63a1d792f3135529031f9a969768a6b10)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteMonitoringStarterAction.java (.../VoteMonitoringStarterAction.java) (revision afd9f8463f033997ae0deaa55116a875d9da776f)
@@ -23,6 +23,9 @@
package org.lamsfoundation.lams.tool.vote.web;
import java.io.IOException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -38,6 +41,13 @@
import org.apache.struts.action.ActionMessages;
import org.lamsfoundation.lams.tool.vote.VoteAppConstants;
import org.lamsfoundation.lams.tool.vote.VoteApplicationException;
+import org.lamsfoundation.lams.tool.vote.VoteComparator;
+import org.lamsfoundation.lams.tool.vote.VoteUtils;
+import org.lamsfoundation.lams.tool.vote.pojos.VoteContent;
+import org.lamsfoundation.lams.tool.vote.pojos.VoteQueContent;
+import org.lamsfoundation.lams.tool.vote.service.IVoteService;
+import org.lamsfoundation.lams.tool.vote.service.VoteServiceProxy;
+import org.lamsfoundation.lams.web.util.AttributeNames;
/**
@@ -52,12 +62,209 @@
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException, VoteApplicationException
{
+ logger.debug("init VoteMonitoringStarterAction...");
+ VoteUtils.cleanUpSessionAbsolute(request);
+
+ ActionForward validateParameters=validateParameters(request, mapping);
+ logger.debug("validateParamaters: " + validateParameters);
+ if (validateParameters != null)
+ {
+ return validateParameters;
+ }
+
+ boolean initData=initialiseMonitoringData(mapping, form, request, response);
+ logger.debug("initData: " + initData);
+ if (initData == false)
+ return (mapping.findForward(ERROR_LIST));
+
+ VoteMonitoringForm voteMonitoringForm = (VoteMonitoringForm) form;
+ logger.debug("voteMonitoringForm: " + voteMonitoringForm);
+ voteMonitoringForm.setCurrentTab("1");
+ logger.debug("setting current tab to 1: ");
+
+
+ request.getSession().setAttribute(USER_EXCEPTION_NO_TOOL_SESSIONS, new Boolean(true).toString());
+
+ VoteMonitoringAction voteMonitoringAction= new VoteMonitoringAction();
+ logger.debug("calling initSummaryContent.");
+ voteMonitoringAction.initSummaryContent(mapping, form, request, response);
+ logger.debug("calling initInstructionsContent.");
+ voteMonitoringAction.initInstructionsContent(mapping, form, request, response);
+ logger.debug("calling initStatsContent.");
+ voteMonitoringAction.initStatsContent(mapping, form, request, response);
+
+
+ IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
+
+ /* we have made sure TOOL_CONTENT_ID is passed */
+ Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID);
+ logger.debug("toolContentId: " + toolContentId);
+ VoteContent voteContent=voteService.retrieveVote(toolContentId);
+
+ logger.debug("existing voteContent:" + voteContent);
+ Map mapQuestionContent= new TreeMap(new VoteComparator());
+ logger.debug("mapQuestionContent: " + mapQuestionContent);
+ /*
+ * get the existing question content
+ */
+ logger.debug("setting existing content data from the db");
+ mapQuestionContent.clear();
+ Iterator queIterator=voteContent.getVoteQueContents().iterator();
+ Long mapIndex=new Long(1);
+ logger.debug("mapQuestionContent: " + mapQuestionContent);
+ while (queIterator.hasNext())
+ {
+ VoteQueContent voteQueContent=(VoteQueContent) queIterator.next();
+ if (voteQueContent != null)
+ {
+ logger.debug("question: " + voteQueContent.getQuestion());
+ mapQuestionContent.put(mapIndex.toString(),voteQueContent.getQuestion());
+ /**
+ * make the first entry the default(first) one for jsp
+ */
+ if (mapIndex.longValue() == 1)
+ request.getSession().setAttribute(DEFAULT_QUESTION_CONTENT, voteQueContent.getQuestion());
+ mapIndex=new Long(mapIndex.longValue()+1);
+ }
+ }
+ logger.debug("Map initialized with existing contentid to: " + mapQuestionContent);
+ logger.debug("callling presentInitialUserInterface for the existing content.");
+
+ request.getSession().setAttribute(MAP_QUESTION_CONTENT, mapQuestionContent);
+ logger.debug("execute initialized the Comparable Map: " + request.getSession().getAttribute("mapQuestionContent") );
+
+ /*true means there is at least 1 response*/
+ if (voteService.studentActivityOccurredGlobal(voteContent))
+ {
+ request.getSession().setAttribute(USER_EXCEPTION_NO_TOOL_SESSIONS, new Boolean(false).toString());
+ logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to false");
+ }
+ else
+ {
+ request.getSession().setAttribute(USER_EXCEPTION_NO_TOOL_SESSIONS, new Boolean(true).toString());
+ logger.debug("USER_EXCEPTION_NO_TOOL_SESSIONS is set to true");
+ }
+
+
+ request.getSession().setAttribute(ACTIVE_MODULE, MONITORING);
+ return (mapping.findForward(LOAD_MONITORING));
+ }
+
+
+ public boolean initialiseMonitoringData(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
+ {
+ logger.debug("start initializing monitoring data...");
+ IVoteService voteService = VoteServiceProxy.getVoteService(getServlet().getServletContext());
+ request.getSession().setAttribute(TOOL_SERVICE, voteService);
+
+ request.getSession().setAttribute(CURRENT_MONITORING_TAB, "summary");
+
+ request.getSession().setAttribute(USER_EXCEPTION_NO_TOOL_SESSIONS, new Boolean(true).toString());
+ /*
+ * persist time zone information to session scope.
+ */
+ VoteUtils.persistTimeZone(request);
+
+ /* we have made sure TOOL_CONTENT_ID is passed */
+ Long toolContentId =(Long) request.getSession().getAttribute(TOOL_CONTENT_ID);
+ logger.debug("toolContentId: " + toolContentId);
+
+ VoteContent voteContent=voteService.retrieveVote(toolContentId);
+ logger.debug("existing voteContent:" + voteContent);
+
+ if (voteContent == null)
+ {
+ VoteUtils.cleanUpSessionAbsolute(request);
+ request.getSession().setAttribute(USER_EXCEPTION_CONTENT_DOESNOTEXIST, new Boolean(true).toString());
+ persistError(request, "error.content.doesNotExist");
+ return false;
+ }
+
+
+ boolean isContentInUse=VoteUtils.isContentInUse(voteContent);
+ logger.debug("isContentInUse:" + isContentInUse);
+
+
+ request.getSession().setAttribute(IS_MONITORED_CONTENT_IN_USE, new Boolean(false).toString());
+ if (isContentInUse == true)
+ {
+ logger.debug("monitoring url does not allow editActivity since the content is in use.");
+ persistError(request,"error.content.inUse");
+ request.getSession().setAttribute(IS_MONITORED_CONTENT_IN_USE, new Boolean(true).toString());
+ }
+
+
+ if (voteContent.getTitle() == null)
+ {
+ request.getSession().setAttribute(ACTIVITY_TITLE, "Voting Title");
+ request.getSession().setAttribute(ACTIVITY_INSTRUCTIONS, "Voting Instructions");
+ }
+ else
+ {
+ request.getSession().setAttribute(ACTIVITY_TITLE, voteContent.getTitle());
+ request.getSession().setAttribute(ACTIVITY_INSTRUCTIONS, voteContent.getInstructions());
+ }
+
+
+ if (voteService.studentActivityOccurredGlobal(voteContent))
+ {
+ VoteUtils.cleanUpSessionAbsolute(request);
+ logger.debug("student activity occurred on this content:" + voteContent);
+ request.getSession().setAttribute(USER_EXCEPTION_CONTENT_IN_USE, new Boolean(true).toString());
+ }
+
+ VoteMonitoringAction voteMonitoringAction= new VoteMonitoringAction();
+ logger.debug("refreshing summary data...");
+ voteMonitoringAction.refreshSummaryData(request, voteContent, voteService, true, false, null, null);
+
+ logger.debug("refreshing stats data...");
+ voteMonitoringAction.refreshStatsData(request);
+
+ logger.debug("refreshing instructions data...");
+ voteMonitoringAction.refreshInstructionsData(request, voteContent);
+
+ /* this section is related to instructions tab. Starts here. */
+ /* ends here. */
+
+ logger.debug("end initializing monitoring data...");
+ return true;
+ }
+
+
+ protected ActionForward validateParameters(HttpServletRequest request, ActionMapping mapping)
+ {
+ logger.debug("start validating monitoring parameters...");
+
+ String strToolContentId=request.getParameter(AttributeNames.PARAM_TOOL_CONTENT_ID);
+ logger.debug("strToolContentId: " + strToolContentId);
+
+ if ((strToolContentId == null) || (strToolContentId.length() == 0))
+ {
+ persistError(request, "error.contentId.required");
+ VoteUtils.cleanUpSessionAbsolute(request);
+ return (mapping.findForward(ERROR_LIST));
+ }
+ else
+ {
+ try
+ {
+ long toolContentId=new Long(strToolContentId).longValue();
+ logger.debug("passed TOOL_CONTENT_ID : " + new Long(toolContentId));
+ request.getSession().setAttribute(TOOL_CONTENT_ID,new Long(toolContentId));
+ }
+ catch(NumberFormatException e)
+ {
+ persistError(request, "error.contentId.numberFormatException");
+ logger.debug("add error.contentId.numberFormatException to ActionMessages.");
+ VoteUtils.cleanUpSessionAbsolute(request);
+ return (mapping.findForward(ERROR_LIST));
+ }
+ }
return null;
}
-
/**
* persists error messages to request scope
* @param request
Index: lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteStarterAction.java
===================================================================
diff -u -rf9e3bb1e954f24078531d9a9114952f84cad4bb2 -rafd9f8463f033997ae0deaa55116a875d9da776f
--- lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteStarterAction.java (.../VoteStarterAction.java) (revision f9e3bb1e954f24078531d9a9114952f84cad4bb2)
+++ lams_tool_vote/src/java/org/lamsfoundation/lams/tool/vote/web/VoteStarterAction.java (.../VoteStarterAction.java) (revision afd9f8463f033997ae0deaa55116a875d9da776f)
@@ -348,6 +348,20 @@
logger.debug("add error.content.inUse to ActionMessages.");
return (mapping.findForward(ERROR_LIST));
}
+
+ boolean isDefineLater=VoteUtils.isDefineLater(voteContent);
+ logger.debug("isDefineLater:" + isDefineLater);
+ if (isDefineLater == true)
+ {
+ VoteUtils.cleanUpSessionAbsolute(request);
+ logger.debug("student activity occurred on this content:" + voteContent);
+ request.getSession().setAttribute(USER_EXCEPTION_CONTENT_IN_USE, new Boolean(true).toString());
+ persistError(request, "error.content.inUse");
+ logger.debug("add error.content.inUse to ActionMessages.");
+ return (mapping.findForward(ERROR_LIST));
+
+ }
+
logger.debug("will get content for strToolContentId:" + strToolContentId);
retrieveContent(request, mapping, voteAuthoringForm, mapOptionsContent, new Long(strToolContentId).longValue());
}
Index: lams_tool_vote/web/WEB-INF/struts-config.xml
===================================================================
diff -u -rf9e3bb1e954f24078531d9a9114952f84cad4bb2 -rafd9f8463f033997ae0deaa55116a875d9da776f
--- lams_tool_vote/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision f9e3bb1e954f24078531d9a9114952f84cad4bb2)
+++ lams_tool_vote/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision afd9f8463f033997ae0deaa55116a875d9da776f)
@@ -278,7 +278,20 @@
handler="org.lamsfoundation.lams.tool.vote.web.CustomStrutsExceptionHandler"
path="/VoteErrorBox.jsp"
scope="request"
- />
+ />
+
+
+
+
+
+
+
+
+
+