Index: lams_tool_lamc/conf/hibernate/mappings/org/lamsfoundation/lams/tool/mc/McUsrAttempt.hbm.xml
===================================================================
diff -u -rf931ace3d9f38ea25225bd0cd55adfdcb3dfc376 -r71d4ba0de556ac5712891e102bf8935fa4a01810
--- lams_tool_lamc/conf/hibernate/mappings/org/lamsfoundation/lams/tool/mc/McUsrAttempt.hbm.xml (.../McUsrAttempt.hbm.xml) (revision f931ace3d9f38ea25225bd0cd55adfdcb3dfc376)
+++ lams_tool_lamc/conf/hibernate/mappings/org/lamsfoundation/lams/tool/mc/McUsrAttempt.hbm.xml (.../McUsrAttempt.hbm.xml) (revision 71d4ba0de556ac5712891e102bf8935fa4a01810)
@@ -42,12 +42,15 @@
column="mark"
/>
-
+
+
+
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
Index: lams_tool_lamc/db/sql/create_lams_tool_mc.sql
===================================================================
diff -u -rf931ace3d9f38ea25225bd0cd55adfdcb3dfc376 -r71d4ba0de556ac5712891e102bf8935fa4a01810
--- lams_tool_lamc/db/sql/create_lams_tool_mc.sql (.../create_lams_tool_mc.sql) (revision f931ace3d9f38ea25225bd0cd55adfdcb3dfc376)
+++ lams_tool_lamc/db/sql/create_lams_tool_mc.sql (.../create_lams_tool_mc.sql) (revision 71d4ba0de556ac5712891e102bf8935fa4a01810)
@@ -89,7 +89,7 @@
, mark VARCHAR(255)
, passed TINYINT(1) NOT NULL DEFAULT 0
, attemptOrder INTEGER NOT NULL DEFAULT 1
- , totalWeight INTEGER DEFAULT 0
+ , finished TINYINT(1) DEFAULT 0
, PRIMARY KEY (uid)
, INDEX (mc_que_content_id)
, CONSTRAINT FK_tl_lamc11_usr_attempt_2 FOREIGN KEY (mc_que_content_id)
@@ -114,6 +114,7 @@
REFERENCES tl_lamc11_content (uid)
)TYPE=InnoDB;
+
INSERT INTO tl_lamc11_content(uid, content_id , title , instructions , creation_date , questions_sequenced , username_visible , created_by , monitoring_report_title , report_title , run_offline , define_later, synch_in_monitor, offline_instructions, online_instructions, end_learning_message, content_in_use, retries, show_feedback, show_report, pass_mark) VALUES (1, ${default_content_id} ,'MCQ Title','MCQ Instructions', NOW(), 0, 0,1,'Monitoring Report','Report', 0, 0, 0,'offline instructions','online instructions','Finished Activity...', 0, 0, 0, 0, 50);
INSERT INTO tl_lamc11_que_content (uid,question, weight, disabled, display_order, mc_content_id, feedbackIncorrect, feedbackCorrect) VALUES (1, 'A Sample question?', 100, 0, 1,1, 'Your answer is incorrect', 'Correct');
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUsrAttemptDAO.java
===================================================================
diff -u -rf931ace3d9f38ea25225bd0cd55adfdcb3dfc376 -r71d4ba0de556ac5712891e102bf8935fa4a01810
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUsrAttemptDAO.java (.../IMcUsrAttemptDAO.java) (revision f931ace3d9f38ea25225bd0cd55adfdcb3dfc376)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUsrAttemptDAO.java (.../IMcUsrAttemptDAO.java) (revision 71d4ba0de556ac5712891e102bf8935fa4a01810)
@@ -132,6 +132,16 @@
public List getUserAttemptsForQuestionContentAndSessionUid(final Long queUsrUid, final Long mcQueContentId, final Long mcSessionUid);
+ public McUsrAttempt getAttemptWithLastAttemptOrderForUserInSession(Long queUsrUid, final Long mcSessionUid);
+
+ public List getAttemptsForUserInSession(final Long queUsrUid, final Long mcSessionUid);
+
+ public List getAttemptsForUserOnHighestAttemptOrderInSession(final Long queUsrUid, final Long mcSessionUid, final Integer attemptOrder);
+
+ public List getAttemptsOnHighestAttemptOrder(final Long queUsrUid, final Long mcQueContentId, final Long mcSessionUid, final Integer attemptOrder);
+
+ public boolean getUserAttemptCorrectForQuestionContentAndSessionUid(final Long queUsrUid, final Long mcQueContentId, final Long mcSessionUid, final Integer attemptOrder);
+
public List getMarks();
}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUsrAttemptDAO.java
===================================================================
diff -u -rf931ace3d9f38ea25225bd0cd55adfdcb3dfc376 -r71d4ba0de556ac5712891e102bf8935fa4a01810
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUsrAttemptDAO.java (.../McUsrAttemptDAO.java) (revision f931ace3d9f38ea25225bd0cd55adfdcb3dfc376)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUsrAttemptDAO.java (.../McUsrAttemptDAO.java) (revision 71d4ba0de556ac5712891e102bf8935fa4a01810)
@@ -56,6 +56,8 @@
private static final String LOAD_MARK = "from mcUsrAttempt in class McUsrAttempt";
+ private static final String LOAD_ATTEMPTS_ON_HIGHEST_ATTEMPT_ORDER = "from mcUsrAttempt in class McUsrAttempt where mcUsrAttempt.attemptOrder=:attemptOrder";
+
private static final String LOAD_HIGHEST_MARK = "from mcUsrAttempt in class McUsrAttempt";
public McUsrAttempt getMcUserAttemptByUID(Long uid)
@@ -121,7 +123,7 @@
public List getUserAttemptsForQuestionContentAndSessionUid(final Long queUsrUid, final Long mcQueContentId, final Long mcSessionUid)
{
- logger.debug("doing getUserAttemptsForQuestionContentAndSessionUid:");
+ logger.debug("starting getUserAttemptsForQuestionContentAndSessionUid:");
logger.debug("queUsrUid:" + queUsrUid);
logger.debug("mcQueContentId:" + mcQueContentId);
logger.debug("mcSessionUid:" + mcSessionUid);
@@ -154,9 +156,216 @@
logger.debug("userEntries:" + userEntries);
return userEntries;
}
+
+ public List getAttemptsOnHighestAttemptOrder(final Long queUsrUid, final Long mcQueContentId, final Long mcSessionUid, final Integer attemptOrder)
+ {
+ logger.debug("starting getUserAttemptsForQuestionContentAndSessionUid:");
+ logger.debug("queUsrUid:" + queUsrUid);
+ logger.debug("mcQueContentId:" + mcQueContentId);
+ logger.debug("mcSessionUid:" + mcSessionUid);
+ logger.debug("attemptOrder:" + attemptOrder);
+
+ HibernateTemplate templ = this.getHibernateTemplate();
+ List list = getSession().createQuery(LOAD_ATTEMPT_FOR_QUESTION_CONTENT)
+ .setLong("mcQueContentId", mcQueContentId.longValue())
+ .list();
+
+ List userEntries= new ArrayList();
+ if(list != null && list.size() > 0){
+ Iterator listIterator=list.iterator();
+ while (listIterator.hasNext())
+ {
+ McUsrAttempt attempt=(McUsrAttempt)listIterator.next();
+ logger.debug("attempt:" + attempt);
+
+ if (attempt.getMcQueUsr().getUid().toString().equals(queUsrUid.toString()))
+ {
+ logger.debug("queUsrUid equal:" + queUsrUid);
+ if (attempt.getMcQueUsr().getMcSession().getUid().toString().equals(mcSessionUid.toString()))
+ {
+ logger.debug("user belong to this session:" + mcSessionUid);
+
+ if (attempt.getAttemptOrder().intValue() == attemptOrder.intValue())
+ userEntries.add(attempt);
+ }
+
+ }
+ }
+ }
+ logger.debug("userEntries:" + userEntries);
+ return userEntries;
+ }
+
+ public List getAttemptsForUserInSession(final Long queUsrUid, final Long mcSessionUid)
+ {
+ logger.debug("starting getAttemptsForUserInSession:");
+ logger.debug("queUsrUid:" + queUsrUid);
+ logger.debug("mcSessionUid:" + mcSessionUid);
+
+ HibernateTemplate templ = this.getHibernateTemplate();
+ List list = getSession().createQuery(LOAD_MARK)
+ .list();
+
+ List userEntries= new ArrayList();
+ if(list != null && list.size() > 0){
+ Iterator listIterator=list.iterator();
+ while (listIterator.hasNext())
+ {
+ McUsrAttempt attempt=(McUsrAttempt)listIterator.next();
+ logger.debug("attempt:" + attempt);
+
+ if (attempt.getMcQueUsr().getUid().toString().equals(queUsrUid.toString()))
+ {
+ logger.debug("queUsrUid equal:" + queUsrUid);
+ if (attempt.getMcQueUsr().getMcSession().getUid().toString().equals(mcSessionUid.toString()))
+ {
+ logger.debug("user belong to this session:" + mcSessionUid);
+ userEntries.add(attempt);
+ }
+
+ }
+ }
+ }
+ logger.debug("userEntries:" + userEntries);
+ return userEntries;
+ }
+
+ public List getAttemptsForUserOnHighestAttemptOrderInSession(final Long queUsrUid, final Long mcSessionUid, final Integer attemptOrder)
+ {
+ logger.debug("starting getAttemptsForUserOnHighestAttemptOrderInSession:");
+ logger.debug("queUsrUid:" + queUsrUid);
+ logger.debug("mcSessionUid:" + mcSessionUid);
+
+ HibernateTemplate templ = this.getHibernateTemplate();
+ List list = getSession().createQuery(LOAD_ATTEMPTS_ON_HIGHEST_ATTEMPT_ORDER)
+ .setInteger("attemptOrder", attemptOrder.intValue())
+ .list();
+
+ List userEntries= new ArrayList();
+ if(list != null && list.size() > 0){
+ Iterator listIterator=list.iterator();
+ while (listIterator.hasNext())
+ {
+ McUsrAttempt attempt=(McUsrAttempt)listIterator.next();
+ logger.debug("attempt:" + attempt);
+
+ if (attempt.getMcQueUsr().getUid().toString().equals(queUsrUid.toString()))
+ {
+ logger.debug("queUsrUid equal:" + queUsrUid);
+ if (attempt.getMcQueUsr().getMcSession().getUid().toString().equals(mcSessionUid.toString()))
+ {
+ logger.debug("user belong to this session:" + mcSessionUid);
+ userEntries.add(attempt);
+ }
+
+ }
+ }
+ }
+ logger.debug("userEntries:" + userEntries);
+ return userEntries;
+ }
+
+
+ public boolean getUserAttemptCorrectForQuestionContentAndSessionUid(final Long queUsrUid, final Long mcQueContentId, final Long mcSessionUid, final Integer attemptOrder)
+ {
+ logger.debug("starting getUserAttemptsForQuestionContentAndSessionUid:");
+ logger.debug("queUsrUid:" + queUsrUid);
+ logger.debug("mcQueContentId:" + mcQueContentId);
+ logger.debug("mcSessionUid:" + mcSessionUid);
+ logger.debug("attemptOrder:" + attemptOrder);
+
+ HibernateTemplate templ = this.getHibernateTemplate();
+ List list = getSession().createQuery(LOAD_ATTEMPT_FOR_QUESTION_CONTENT)
+ .setLong("mcQueContentId", mcQueContentId.longValue())
+ .list();
+
+ if(list != null && list.size() > 0){
+ Iterator listIterator=list.iterator();
+ while (listIterator.hasNext())
+ {
+ McUsrAttempt attempt=(McUsrAttempt)listIterator.next();
+ logger.debug("attempt:" + attempt);
+
+ if (attempt.getMcQueUsr().getUid().toString().equals(queUsrUid.toString()))
+ {
+ logger.debug("queUsrUid equal:" + queUsrUid);
+ if (attempt.getMcQueUsr().getMcSession().getUid().toString().equals(mcSessionUid.toString()))
+ {
+ logger.debug("user belong to this session:" + mcSessionUid);
+ logger.debug("isAttemptCorrect:" + attempt.isAttemptCorrect());
+ if (attempt.getAttemptOrder().intValue() == attemptOrder.intValue())
+ return attempt.isAttemptCorrect();
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+
+ public McUsrAttempt getAttemptWithLastAttemptOrderForUserInSession(Long queUsrUid, final Long mcSessionUid)
+ {
+ logger.debug("starting getLastAttemptOrderForUserInSession:");
+ logger.debug("queUsrUid:" + queUsrUid);
+ logger.debug("mcSessionUid:" + mcSessionUid);
+
+ HibernateTemplate templ = this.getHibernateTemplate();
+ List list = getSession().createQuery(LOAD_MARK)
+ .list();
+
+ logger.debug("list:" + list);
+
+ List userEntries= new ArrayList();
+ if(list != null && list.size() > 0){
+ Iterator listIterator=list.iterator();
+ while (listIterator.hasNext())
+ {
+ McUsrAttempt attempt=(McUsrAttempt)listIterator.next();
+ logger.debug("attempt:" + attempt);
+
+ if (attempt.getMcQueUsr().getUid().toString().equals(queUsrUid.toString()))
+ {
+ logger.debug("queUsrUid equal:" + queUsrUid);
+ if (attempt.getMcQueUsr().getMcSession().getUid().toString().equals(mcSessionUid.toString()))
+ {
+ logger.debug("user belong to this session:" + mcSessionUid);
+ userEntries.add(attempt);
+ }
+
+ }
+ }
+ }
+ logger.debug("userEntries:" + userEntries);
+
+ Iterator itAttempts=userEntries.iterator();
+ int highestOrder=0;
+ McUsrAttempt mcHighestUsrAttempt=null;
+
+ while (itAttempts.hasNext())
+ {
+ McUsrAttempt mcUsrAttempt=(McUsrAttempt)itAttempts.next();
+ logger.debug("mcUsrAttempt: " + mcUsrAttempt);
+ int currentOrder=mcUsrAttempt.getAttemptOrder().intValue();
+ logger.debug("currentOrder: " + currentOrder);
+
+ if (currentOrder > highestOrder)
+ {
+ mcHighestUsrAttempt=mcUsrAttempt;
+ highestOrder=currentOrder;
+ logger.debug("highestOrder is updated to: " + highestOrder);
+ }
+ }
+
+ logger.debug("returning mcHighestUsrAttempt: " + mcHighestUsrAttempt);
+ logger.debug("highestOrder has become: " + highestOrder);
+ logger.debug("returning mcHighestUsrAttempt: " + mcHighestUsrAttempt);
+ return mcHighestUsrAttempt;
+ }
+
+
public List getAttemptForQueContent(final Long queUsrId, final Long mcQueContentId)
{
HibernateTemplate templ = this.getHibernateTemplate();
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/pojos/McUsrAttempt.java
===================================================================
diff -u -rf931ace3d9f38ea25225bd0cd55adfdcb3dfc376 -r71d4ba0de556ac5712891e102bf8935fa4a01810
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/pojos/McUsrAttempt.java (.../McUsrAttempt.java) (revision f931ace3d9f38ea25225bd0cd55adfdcb3dfc376)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/pojos/McUsrAttempt.java (.../McUsrAttempt.java) (revision 71d4ba0de556ac5712891e102bf8935fa4a01810)
@@ -52,7 +52,7 @@
private Integer mark;
- private Integer totalWeight;
+ private boolean finished;
private boolean attemptCorrect;
@@ -278,17 +278,17 @@
this.attemptCorrect = attemptCorrect;
}
+
/**
- * @return Returns the totalWeight.
+ * @return Returns the finished.
*/
- public Integer getTotalWeight() {
- return totalWeight;
+ public boolean isFinished() {
+ return finished;
}
/**
- * @param totalWeight The totalWeight to set.
+ * @param finished The finished to set.
*/
- public void setTotalWeight(Integer totalWeight) {
- this.totalWeight = totalWeight;
+ public void setFinished(boolean finished) {
+ this.finished = finished;
}
-
}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java
===================================================================
diff -u -rf931ace3d9f38ea25225bd0cd55adfdcb3dfc376 -r71d4ba0de556ac5712891e102bf8935fa4a01810
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java (.../IMcService.java) (revision f931ace3d9f38ea25225bd0cd55adfdcb3dfc376)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java (.../IMcService.java) (revision 71d4ba0de556ac5712891e102bf8935fa4a01810)
@@ -161,6 +161,16 @@
public List getUserAttemptsForQuestionContentAndSessionUid(final Long queUsrUid, final Long mcQueContentId, final Long mcSessionUid) throws McApplicationException;
+ public boolean getUserAttemptCorrectForQuestionContentAndSessionUid(final Long queUsrUid, final Long mcQueContentId, final Long mcSessionUid, final Integer attemptOrder) throws McApplicationException;
+
+ public List getAttemptsForUserInSession(final Long queUsrUid, final Long mcSessionUid) throws McApplicationException;
+
+ public List getAttemptsForUserOnHighestAttemptOrderInSession(final Long queUsrUid, final Long mcSessionUid, final Integer attemptOrder) throws McApplicationException;
+
+ public List getAttemptsOnHighestAttemptOrder(final Long queUsrUid, final Long mcQueContentId, final Long mcSessionUid, final Integer attemptOrder) throws McApplicationException;
+
+ public McUsrAttempt getAttemptWithLastAttemptOrderForUserInSession(Long queUsrUid, final Long mcSessionUid) throws McApplicationException;
+
public int countIncompleteSession(McContent mc) throws McApplicationException;
public boolean studentActivityOccurred(McContent mc) throws McApplicationException;
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java
===================================================================
diff -u -rf931ace3d9f38ea25225bd0cd55adfdcb3dfc376 -r71d4ba0de556ac5712891e102bf8935fa4a01810
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java (.../McServicePOJO.java) (revision f931ace3d9f38ea25225bd0cd55adfdcb3dfc376)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java (.../McServicePOJO.java) (revision 71d4ba0de556ac5712891e102bf8935fa4a01810)
@@ -861,6 +861,21 @@
}
}
+
+ public McUsrAttempt getAttemptWithLastAttemptOrderForUserInSession(Long queUsrUid, final Long mcSessionUid) throws McApplicationException
+ {
+ try
+ {
+ return mcUsrAttemptDAO.getAttemptWithLastAttemptOrderForUserInSession(queUsrUid, mcSessionUid);
+ }
+ catch(DataAccessException e)
+ {
+ throw new McApplicationException("Exception occured when lams is getting last attempt order for user in session"
+ + e.getMessage(),e);
+ }
+ }
+
+
public List getUserAttemptsForQuestionContentAndSessionUid(final Long queUsrUid, final Long mcQueContentId, final Long mcSessionUid)
{
try
@@ -874,6 +889,60 @@
}
}
+
+ public List getAttemptsForUserOnHighestAttemptOrderInSession(final Long queUsrUid, final Long mcSessionUid, final Integer attemptOrder) throws McApplicationException
+ {
+ try
+ {
+ return mcUsrAttemptDAO.getAttemptsForUserOnHighestAttemptOrderInSession(queUsrUid, mcSessionUid, attemptOrder);
+ }
+ catch(DataAccessException e)
+ {
+ throw new McApplicationException("Exception occured when lams is finding whether attempt is correct based on userid, sessionid"
+ + e.getMessage(),e);
+ }
+ }
+
+ public List getAttemptsOnHighestAttemptOrder(final Long queUsrUid, final Long mcQueContentId, final Long mcSessionUid, final Integer attemptOrder) throws McApplicationException
+ {
+ try
+ {
+ return mcUsrAttemptDAO.getAttemptsOnHighestAttemptOrder(queUsrUid, mcQueContentId, mcSessionUid, attemptOrder);
+ }
+ catch(DataAccessException e)
+ {
+ throw new McApplicationException("Exception occured when lams is getting attempts on hightest attempt order"
+ + e.getMessage(),e);
+ }
+ }
+
+ public List getAttemptsForUserInSession(final Long queUsrUid, final Long mcSessionUid) throws McApplicationException
+ {
+ try
+ {
+ return mcUsrAttemptDAO.getAttemptsForUserInSession(queUsrUid, mcSessionUid);
+ }
+ catch(DataAccessException e)
+ {
+ throw new McApplicationException("Exception occured when lams is finding whether attempt is correct based on userid, sessionid"
+ + e.getMessage(),e);
+ }
+ }
+
+
+ public boolean getUserAttemptCorrectForQuestionContentAndSessionUid(final Long queUsrUid, final Long mcQueContentId, final Long mcSessionUid, final Integer attemptOrder) throws McApplicationException
+ {
+ try
+ {
+ return mcUsrAttemptDAO.getUserAttemptCorrectForQuestionContentAndSessionUid(queUsrUid, mcQueContentId, mcSessionUid, attemptOrder);
+ }
+ catch(DataAccessException e)
+ {
+ throw new McApplicationException("Exception occured when lams is finding whether attempt is correct based on userid, sessionid and que content id "
+ + e.getMessage(),e);
+ }
+ }
+
public void deleteMcQueUsr(McQueUsr mcQueUsr) throws McApplicationException
{
try
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java
===================================================================
diff -u -rf931ace3d9f38ea25225bd0cd55adfdcb3dfc376 -r71d4ba0de556ac5712891e102bf8935fa4a01810
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java (.../LearningUtil.java) (revision f931ace3d9f38ea25225bd0cd55adfdcb3dfc376)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java (.../LearningUtil.java) (revision 71d4ba0de556ac5712891e102bf8935fa4a01810)
@@ -700,6 +700,7 @@
logger.debug("createIndividualOptions-> isAttemptCorrect: " + isAttemptCorrect);
logger.debug("mcQueContent: " + mcQueContent);
logger.debug("mapCheckedOptions: " + mapCheckedOptions);
+ logger.debug("highestAttemptOrder used : " + highestAttemptOrder);
if (mcQueContent != null)
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java
===================================================================
diff -u -rf931ace3d9f38ea25225bd0cd55adfdcb3dfc376 -r71d4ba0de556ac5712891e102bf8935fa4a01810
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java (.../McLearningAction.java) (revision f931ace3d9f38ea25225bd0cd55adfdcb3dfc376)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java (.../McLearningAction.java) (revision 71d4ba0de556ac5712891e102bf8935fa4a01810)
@@ -328,6 +328,35 @@
logger.debug("success getting nextUrl: "+ nextUrl);
mcLearningForm.resetCommands();
+ McSession mcSession=mcService.retrieveMcSession(toolSessionId);
+ logger.debug("retrieving mcSession: " + mcSession);
+
+ McQueUsr mcQueUsr=mcService.getMcUserBySession(new Long(userID), mcSession.getUid());
+ logger.debug("mcQueUsr:" + mcQueUsr);
+
+ McUsrAttempt mcUsrAttempt = mcService.getAttemptWithLastAttemptOrderForUserInSession(mcQueUsr.getUid(), mcSession.getUid());
+ logger.debug("mcUsrAttempt with highest attempt order: " + mcUsrAttempt);
+ String highestAttemptOrder="";
+ if (mcUsrAttempt != null)
+ {
+ highestAttemptOrder=mcUsrAttempt.getAttemptOrder().toString();
+ }
+ logger.debug("highestAttemptOrder: " + highestAttemptOrder);
+
+
+ List userAttempts=mcService.getAttemptsForUserOnHighestAttemptOrderInSession(mcQueUsr.getUid(), mcSession.getUid(), new Integer(highestAttemptOrder));
+ logger.debug("userAttempts:" + userAttempts);
+
+ Iterator itAttempts=userAttempts.iterator();
+ while (itAttempts.hasNext())
+ {
+ mcUsrAttempt=(McUsrAttempt)itAttempts.next();
+ logger.debug("mcUsrAttempt: " + mcUsrAttempt);
+ mcUsrAttempt.setFinished(true);
+ mcService.updateMcUsrAttempt(mcUsrAttempt);
+ }
+ logger.debug("updated user records to finished");
+
/* pay attention here*/
logger.debug("redirecting to the nextUrl: "+ nextUrl);
response.sendRedirect(nextUrl);
@@ -471,22 +500,37 @@
mcQueUsr=existingMcQueUsr;
logger.debug("assign");
}
-
+
logger.debug("final mcQueUsr: " + mcQueUsr);
- String highestAttemptOrder=(String)request.getSession().getAttribute(LEARNER_LAST_ATTEMPT_ORDER);
- logger.debug("current highestAttemptOrder:" + highestAttemptOrder);
+ //String highestAttemptOrder=(String)request.getSession().getAttribute(LEARNER_LAST_ATTEMPT_ORDER);
+ //logger.debug("current highestAttemptOrder:" + highestAttemptOrder);
+
+ String highestAttemptOrder="0";
+ McUsrAttempt mcUsrAttempt = mcService.getAttemptWithLastAttemptOrderForUserInSession(mcQueUsr.getUid(), toolSessionUid);
+ logger.debug("mcUsrAttempt with highest attempt order: " + mcUsrAttempt);
+ if (mcUsrAttempt != null)
+ {
+ highestAttemptOrder=mcUsrAttempt.getAttemptOrder().toString();
+ }
+ logger.debug("highestAttemptOrder: " + highestAttemptOrder);
+
+ int intHighestAttemptOrder=0;
+ intHighestAttemptOrder=new Integer(highestAttemptOrder).intValue();
+ logger.debug("intHighestAttemptOrder: " + intHighestAttemptOrder);
+ logger.debug("new intHighestAttemptOrder: " + ++intHighestAttemptOrder);
+
+ highestAttemptOrder = new Integer(intHighestAttemptOrder).toString();
+ logger.debug("new highestAttemptOrder: " + highestAttemptOrder);
+
- if (highestAttemptOrder == null)
- highestAttemptOrder="0";
-
logger.debug("passed: " + passed);
LearningUtil.createAttempt(request, mcQueUsr, mapGeneralCheckedOptionsContent, mark, passed, new Integer(highestAttemptOrder).intValue(), mapLearnerAssessmentResults);
logger.debug("created user attempt in the db");
- int intHighestAttemptOrder=new Integer(highestAttemptOrder).intValue()+ 1 ;
- logger.debug("updated highestAttemptOrder:" + intHighestAttemptOrder);
- request.getSession().setAttribute(LEARNER_LAST_ATTEMPT_ORDER, new Integer(intHighestAttemptOrder).toString());
+ //int intHighestAttemptOrder=new Integer(highestAttemptOrder).intValue()+ 1 ;
+ //logger.debug("updated highestAttemptOrder:" + intHighestAttemptOrder);
+ //request.getSession().setAttribute(LEARNER_LAST_ATTEMPT_ORDER, new Integer(intHighestAttemptOrder).toString());
logger.debug("before getLearnerMarkAtLeast: passMark" + passMark);
logger.debug("before getLearnerMarkAtLeast: mapQuestionWeights" + mapQuestionWeights);
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/MonitoringUtil.java
===================================================================
diff -u -rf931ace3d9f38ea25225bd0cd55adfdcb3dfc376 -r71d4ba0de556ac5712891e102bf8935fa4a01810
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision f931ace3d9f38ea25225bd0cd55adfdcb3dfc376)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision 71d4ba0de556ac5712891e102bf8935fa4a01810)
@@ -214,9 +214,7 @@
List listMcUsers=mcService.getMcUserBySessionOnly(mcSession);
logger.debug("listMcUsers for session id:" + mcSession.getMcSessionId() + " = " + listMcUsers);
Map sessionUsersAttempts=populateSessionUsersAttempts(request,mcSession.getMcSessionId(), listMcUsers, questionUid, null, mcService);
- Map sessionUsersMarks=populateSessionUsersMarks(request,mcSession.getMcSessionId(), listMcUsers, questionUid, null, mcService);
-
listMonitoredAttemptsContainerDTO.add(sessionUsersAttempts);
}
}
@@ -282,7 +280,8 @@
*/
public static Map populateSessionUsersAttempts(HttpServletRequest request,Long sessionId, List listMcUsers, String questionUid, Long userID, IMcService mcService)
{
- logger.debug("will be populating users attempt history for session id: " + sessionId);
+ logger.debug("starting populateSessionUsersAttempts");
+ logger.debug("will be populating users marks for session id: " + sessionId);
McSession mcSession=mcService.retrieveMcSession(sessionId);
logger.debug("retrieving mcSession: " + mcSession);
@@ -303,7 +302,17 @@
if (mcQueUsr != null)
{
logger.debug("getting listUserAttempts for user id: " + mcQueUsr.getUid() + " and que content id: " + questionUid);
- List listUserAttempts=mcService.getUserAttemptsForQuestionContentAndSessionUid(mcQueUsr.getUid(), new Long(questionUid), mcSession.getUid());
+
+ McUsrAttempt mcUsrAttempt = mcService.getAttemptWithLastAttemptOrderForUserInSession(mcQueUsr.getUid(), mcSession.getUid());
+ logger.debug("mcUsrAttempt with highest attempt order: " + mcUsrAttempt);
+ String highestAttemptOrder="";
+ if (mcUsrAttempt != null)
+ {
+ highestAttemptOrder=mcUsrAttempt.getAttemptOrder().toString();
+ }
+ logger.debug("highestAttemptOrder: " + highestAttemptOrder);
+
+ List listUserAttempts=mcService.getAttemptsOnHighestAttemptOrder(mcQueUsr.getUid(), new Long(questionUid), mcSession.getUid(), new Integer(highestAttemptOrder));
logger.debug("listUserAttempts: " + listUserAttempts);
Iterator itAttempts=listUserAttempts.iterator();
@@ -316,7 +325,7 @@
while (itAttempts.hasNext())
{
- McUsrAttempt mcUsrAttempt=(McUsrAttempt)itAttempts.next();
+ mcUsrAttempt=(McUsrAttempt)itAttempts.next();
logger.debug("mcUsrAttempt: " + mcUsrAttempt);
mcUsrAttemptUser=mcUsrAttempt;
@@ -330,33 +339,6 @@
}
logger.debug("final attemptCorrect: " + attemptCorrect);
McMonitoredUserDTO mcMonitoredUserDTO = new McMonitoredUserDTO();
- int extraWeight=0;
- if (attemptCorrect)
- {
- mcMonitoredUserDTO.setMark(mcUsrAttemptUser.getMcQueContent().getWeight().toString());
- extraWeight=mcUsrAttemptUser.getMcQueContent().getWeight().intValue();
- }
- else
- {
- mcMonitoredUserDTO.setMark("0");
- extraWeight=0;
- }
-
- /*
- logger.debug("start updating user's weight records with extraWeight: " + extraWeight);
- Iterator itAttemptsLocal=listUserAttempts.iterator();
- while (itAttemptsLocal.hasNext())
- {
- McUsrAttempt mcUsrAttempt=(McUsrAttempt)itAttemptsLocal.next();
- logger.debug("mcUsrAttempt: " + mcUsrAttempt);
-
- int currentTotalWeight =mcUsrAttempt.getTotalWeight().intValue();
- mcUsrAttempt.setTotalWeight(new Integer(currentTotalWeight + extraWeight));
- logger.debug("updated total user weight to: " + mcUsrAttempt.getTotalWeight());
- mcService.updateMcUsrAttempt(mcUsrAttempt);
- }
- */
-
mcMonitoredUserDTO.setUid(mcUsrAttemptUser.getUid().toString());
mcMonitoredUserDTO.setUserName(mcQueUsr.getFullname());
mcMonitoredUserDTO.setSessionId(sessionId.toString());
@@ -368,171 +350,98 @@
else
{
logger.debug("retries is ON. User had to PASS. Print the final attempt's data");
- McUsrAttempt mcUsrAttempt=getAttemptWithHighestOrder(listUserAttempts);
- logger.debug("attempt with highest attempt order, mcUsrAttempt: " + mcUsrAttempt);
-
McMonitoredUserDTO mcMonitoredUserDTO = new McMonitoredUserDTO();
- mcMonitoredUserDTO.setMark(mcUsrAttempt.getMcQueContent().getWeight().toString());
+ boolean isAttemptCorrect=false;
+ McUsrAttempt mcUsrAttemptGeneral=null;
+ while (itAttempts.hasNext())
+ {
+ mcUsrAttempt=(McUsrAttempt)itAttempts.next();
+ logger.debug("mcUsrAttempt: " + mcUsrAttempt);
+ mcUsrAttemptGeneral=mcUsrAttempt;
+
+ if (mcUsrAttempt != null)
+ {
+ if (mcUsrAttempt.isFinished() && mcUsrAttempt.isPassed())
+ {
+ logger.debug("this is a individual question attempt that is finished and passed: " + mcUsrAttempt);
+ isAttemptCorrect=mcService.getUserAttemptCorrectForQuestionContentAndSessionUid(mcQueUsr.getUid(), new Long(questionUid), mcSession.getUid(), new Integer(highestAttemptOrder));
+ logger.debug("isAttemptCorrect: " + isAttemptCorrect);
+ break;
+ }
+ }
+ }
+
+ logger.debug("final isAttemptCorrect: " + isAttemptCorrect);
+ if (isAttemptCorrect)
+ {
+ mcMonitoredUserDTO.setMark(mcUsrAttemptGeneral.getMcQueContent().getWeight().toString());
+ }
+ else
+ {
+ mcMonitoredUserDTO.setMark("0");
+ }
+
mcMonitoredUserDTO.setUserName(mcQueUsr.getFullname());
+ mcMonitoredUserDTO.setSessionId(sessionId.toString());
+ mcMonitoredUserDTO.setQuestionUid(questionUid);
logger.debug("final constructed mcMonitoredUserDTO: " + mcMonitoredUserDTO);
listMonitoredUserContainerDTO.add(mcMonitoredUserDTO);
- }
- }
- }
- logger.debug("final listMonitoredUserContainerDTO: " + listMonitoredUserContainerDTO);
- mapMonitoredUserContainerDTO=convertToMcMonitoredUserDTOMap(listMonitoredUserContainerDTO);
- logger.debug("final mapMonitoredUserContainerDTO:..." + mapMonitoredUserContainerDTO);
- return mapMonitoredUserContainerDTO;
- }
- else
- {
- logger.debug("request is for learner export portfolio: " + userID);
- Iterator itUsers=listMcUsers.iterator();
- while (itUsers.hasNext())
- {
- McQueUsr mcQueUsr=(McQueUsr)itUsers.next();
- logger.debug("mcQueUsr: " + mcQueUsr);
- logger.debug("local mcQueUsr userID: " + mcQueUsr.getQueUsrId());
- logger.debug("mcQueUsr.getQueUsrId().toString versus userID.toString(): " + mcQueUsr.getQueUsrId().toString() + " versus " + userID.toString());
- if ((mcQueUsr != null) && (mcQueUsr.getQueUsrId().toString().equals(userID.toString())))
- {
- logger.debug("the user in question is found: " + mcQueUsr.getQueUsrId());
- logger.debug("getting listUserAttempts for user id: " + mcQueUsr.getUid() + " and que content id: " + questionUid);
- //List listUserAttempts=mcService.getAttemptsForUserAndQuestionContent(mcQueUsr.getUid(), new Long(questionUid));
- List listUserAttempts=mcService.getUserAttemptsForQuestionContentAndSessionUid(mcQueUsr.getUid(), new Long(questionUid), mcSession.getUid());
- logger.debug("listUserAttempts: " + listUserAttempts);
- Iterator itAttempts=listUserAttempts.iterator();
- while (itAttempts.hasNext())
- {
- McUsrAttempt mcUsrAttempt=(McUsrAttempt)itAttempts.next();
- logger.debug("mcUsrAttempt: " + mcUsrAttempt);
-
- if (mcUsrAttempt != null)
- {
- McMonitoredUserDTO mcMonitoredUserDTO = new McMonitoredUserDTO();
- mcMonitoredUserDTO.setAttemptTime(mcUsrAttempt.getAttemptTime().toString());
- mcMonitoredUserDTO.setIsCorrect(new Boolean(mcUsrAttempt.isAttemptCorrect()).toString());
- mcMonitoredUserDTO.setResponse(mcUsrAttempt.getMcOptionsContent().getMcQueOptionText().toString());
- mcMonitoredUserDTO.setTimeZone(mcUsrAttempt.getTimeZone());
- mcMonitoredUserDTO.setUid(mcUsrAttempt.getUid().toString());
- mcMonitoredUserDTO.setUserName(mcQueUsr.getFullname());
- mcMonitoredUserDTO.setQueUsrId(mcQueUsr.getUid().toString());
- mcMonitoredUserDTO.setSessionId(sessionId.toString());
- mcMonitoredUserDTO.setQuestionUid(questionUid);
- listMonitoredUserContainerDTO.add(mcMonitoredUserDTO);
- }
- }
- }
- }
- logger.debug("final listMonitoredUserContainerDTO: " + listMonitoredUserContainerDTO);
- mapMonitoredUserContainerDTO=convertToMcMonitoredUserDTOMap(listMonitoredUserContainerDTO);
- logger.debug("final mapMonitoredUserContainerDTO:..." + mapMonitoredUserContainerDTO);
- return mapMonitoredUserContainerDTO;
-
- }
-
- }
-
-
- public static Map populateSessionUsersMarks(HttpServletRequest request,Long sessionId, List listMcUsers, String questionUid, Long userID, IMcService mcService)
- {
- logger.debug("will be populating users marks for session id: " + sessionId);
-
- McSession mcSession=mcService.retrieveMcSession(sessionId);
- logger.debug("retrieving mcSession: " + mcSession);
-
- logger.debug("userID: " + userID);
- Map mapMonitoredUserContainerDTO= new TreeMap(new McStringComparator());
- List listMonitoredUserContainerDTO= new LinkedList();
-
- if (userID == null)
- {
- logger.debug("generating standard summary page");
- Iterator itUsers=listMcUsers.iterator();
- while (itUsers.hasNext())
- {
- McQueUsr mcQueUsr=(McQueUsr)itUsers.next();
- logger.debug("mcQueUsr: " + mcQueUsr);
-
- if (mcQueUsr != null)
- {
- logger.debug("getting listUserAttempts for user id: " + mcQueUsr.getUid() + " and que content id: " + questionUid);
- List listUserAttempts=mcService.getUserAttemptsForQuestionContentAndSessionUid(mcQueUsr.getUid(), new Long(questionUid), mcSession.getUid());
- logger.debug("listUserAttempts: " + listUserAttempts);
-
- Iterator itAttempts=listUserAttempts.iterator();
-
- if (!mcSession.getMcContent().isRetries())
- {
- logger.debug("retries is OFF.");
- boolean attemptCorrect=false;
- McUsrAttempt mcUsrAttemptUser=null;
- while (itAttempts.hasNext())
- {
- McUsrAttempt mcUsrAttempt=(McUsrAttempt)itAttempts.next();
- logger.debug("mcUsrAttempt: " + mcUsrAttempt);
- mcUsrAttemptUser=mcUsrAttempt;
-
- if (mcUsrAttempt != null)
- {
- if (mcUsrAttempt.isAttemptCorrect())
- {
- attemptCorrect=true;
- }
- }
- }
- logger.debug("final attemptCorrect: " + attemptCorrect);
- McMonitoredUserDTO mcMonitoredUserDTO = new McMonitoredUserDTO();
- int extraWeight=0;
- if (attemptCorrect)
- {
- mcMonitoredUserDTO.setMark(mcUsrAttemptUser.getMcQueContent().getWeight().toString());
- extraWeight=mcUsrAttemptUser.getMcQueContent().getWeight().intValue();
- }
- else
- {
- mcMonitoredUserDTO.setMark("0");
- extraWeight=0;
- }
-
/*
- logger.debug("start updating user's weight records with extraWeight: " + extraWeight);
- Iterator itAttemptsLocal=listUserAttempts.iterator();
- while (itAttemptsLocal.hasNext())
- {
- McUsrAttempt mcUsrAttempt=(McUsrAttempt)itAttemptsLocal.next();
- logger.debug("mcUsrAttempt: " + mcUsrAttempt);
-
- int currentTotalWeight =mcUsrAttempt.getTotalWeight().intValue();
- mcUsrAttempt.setTotalWeight(new Integer(currentTotalWeight + extraWeight));
- logger.debug("updated total user weight to: " + mcUsrAttempt.getTotalWeight());
- mcService.updateMcUsrAttempt(mcUsrAttempt);
- }
- */
-
- mcMonitoredUserDTO.setUid(mcUsrAttemptUser.getUid().toString());
- mcMonitoredUserDTO.setUserName(mcQueUsr.getFullname());
- mcMonitoredUserDTO.setSessionId(sessionId.toString());
- mcMonitoredUserDTO.setQuestionUid(questionUid);
-
- logger.debug("final constructed mcMonitoredUserDTO: " + mcMonitoredUserDTO);
- listMonitoredUserContainerDTO.add(mcMonitoredUserDTO);
- }
- else
- {
- logger.debug("retries is ON. User had to PASS. Print the final attempt's data");
McUsrAttempt mcUsrAttempt=getAttemptWithHighestOrder(listUserAttempts);
logger.debug("attempt with highest attempt order, mcUsrAttempt: " + mcUsrAttempt);
-
- McMonitoredUserDTO mcMonitoredUserDTO = new McMonitoredUserDTO();
- mcMonitoredUserDTO.setMark(mcUsrAttempt.getMcQueContent().getWeight().toString());
- mcMonitoredUserDTO.setUserName(mcQueUsr.getFullname());
-
- logger.debug("final constructed mcMonitoredUserDTO: " + mcMonitoredUserDTO);
- listMonitoredUserContainerDTO.add(mcMonitoredUserDTO);
+ if (mcUsrAttempt != null)
+ {
+ Integer IntegerPassmark=mcUsrAttempt.getMcOptionsContent().getMcQueContent().getMcContent().getPassMark();
+ logger.debug("IntegerPassmark: " + IntegerPassmark);
+ if ((IntegerPassmark != null) && (IntegerPassmark.intValue() >= 0))
+ {
+ logger.debug("pasmark is defined: ");
+ if (mcUsrAttempt.isPassed())
+ {
+ logger.debug("user has passed the activity");
+ McMonitoredUserDTO mcMonitoredUserDTO = new McMonitoredUserDTO();
+ mcMonitoredUserDTO.setMark(mcUsrAttempt.getMcQueContent().getWeight().toString());
+ mcMonitoredUserDTO.setUserName(mcQueUsr.getFullname());
+ mcMonitoredUserDTO.setUid(mcUsrAttempt.getUid().toString());
+ mcMonitoredUserDTO.setSessionId(sessionId.toString());
+ mcMonitoredUserDTO.setQuestionUid(questionUid);
+
+ logger.debug("final constructed mcMonitoredUserDTO: " + mcMonitoredUserDTO);
+ listMonitoredUserContainerDTO.add(mcMonitoredUserDTO);
+ }
+ else
+ {
+ logger.debug("user did not finish the the activity yet");
+ McMonitoredUserDTO mcMonitoredUserDTO = new McMonitoredUserDTO();
+ mcMonitoredUserDTO.setMark("Learner still responding...");
+ mcMonitoredUserDTO.setUserName(mcQueUsr.getFullname());
+ mcMonitoredUserDTO.setUid(mcUsrAttempt.getUid().toString());
+ mcMonitoredUserDTO.setSessionId(sessionId.toString());
+ mcMonitoredUserDTO.setQuestionUid(questionUid);
+
+ logger.debug("final constructed mcMonitoredUserDTO: " + mcMonitoredUserDTO);
+ listMonitoredUserContainerDTO.add(mcMonitoredUserDTO);
+ }
+ }
+ else
+ {
+ logger.debug("pasmark is Undefined: ");
+ logger.debug("pupulate user marks as if user has passed");
+ McMonitoredUserDTO mcMonitoredUserDTO = new McMonitoredUserDTO();
+ mcMonitoredUserDTO.setMark(mcUsrAttempt.getMcQueContent().getWeight().toString());
+ mcMonitoredUserDTO.setUserName(mcQueUsr.getFullname());
+ mcMonitoredUserDTO.setUid(mcUsrAttempt.getUid().toString());
+ mcMonitoredUserDTO.setSessionId(sessionId.toString());
+ mcMonitoredUserDTO.setQuestionUid(questionUid);
+
+ logger.debug("final constructed mcMonitoredUserDTO: " + mcMonitoredUserDTO);
+ listMonitoredUserContainerDTO.add(mcMonitoredUserDTO);
+ }
+ }
+ */
}
}
}
@@ -588,10 +497,9 @@
return mapMonitoredUserContainerDTO;
}
-
}
-
+
public static McUsrAttempt getAttemptWithHighestOrder(List listUserAttempts)
{
logger.debug("starting getAttemptWithHighestOrder: " + listUserAttempts);
@@ -604,14 +512,18 @@
McUsrAttempt mcUsrAttempt=(McUsrAttempt)itAttempts.next();
logger.debug("mcUsrAttempt: " + mcUsrAttempt);
int currentOrder=mcUsrAttempt.getAttemptOrder().intValue();
+ logger.debug("currentOrder: " + currentOrder);
if (currentOrder > highestOrder)
{
mcHighestUsrAttempt=mcUsrAttempt;
+ highestOrder=currentOrder;
+ logger.debug("highestOrder is updated to: " + highestOrder);
}
}
logger.debug("returning mcHighestUsrAttempt: " + mcHighestUsrAttempt);
+ logger.debug("highestOrder has become: " + highestOrder);
return mcHighestUsrAttempt;
}