@@ -42,10 +43,10 @@
protected Integer mark;
- protected Map candidateAnswers;
+ protected McOptsContent answerOption;
+
+ protected List options;
- protected Map candidateAnswerUids;
-
protected String attemptCorrect;
protected String feedbackIncorrect;
@@ -55,21 +56,36 @@
protected String feedback;
/**
- * @return Returns the candidateAnswers.
+ * @return Returns the answerOption.
*/
- public Map getCandidateAnswers() {
- return candidateAnswers;
+ public McOptsContent getAnswerOption() {
+ return answerOption;
}
/**
- * @param candidateAnswers
- * The candidateAnswers to set.
+ * @param answerOption
+ * The answerOption to set.
*/
- public void setCandidateAnswers(Map candidateAnswers) {
- this.candidateAnswers = candidateAnswers;
+ public void setAnswerOption(McOptsContent answerOption) {
+ this.answerOption = answerOption;
}
+
+ /**
+ * @return Returns the options.
+ */
+ public List getOptions() {
+ return options;
+ }
/**
+ * @param options
+ * The options to set.
+ */
+ public void setOptions(List options) {
+ this.options = options;
+ }
+
+ /**
* @return Returns the question.
*/
public String getQuestion() {
@@ -86,7 +102,7 @@
public String toString() {
return new ToStringBuilder(this).append("question: ", getQuestion())
- .append("displayOrder: ", getDisplayOrder()).append("candidateAnswers: ", getCandidateAnswers())
+ .append("displayOrder: ", getDisplayOrder()).append("answerOption: ", getAnswerOption())
.toString();
}
@@ -130,21 +146,6 @@
}
/**
- * @return Returns the candidateAnswerUids.
- */
- public Map getCandidateAnswerUids() {
- return candidateAnswerUids;
- }
-
- /**
- * @param candidateAnswerUids
- * The candidateAnswerUids to set.
- */
- public void setCandidateAnswerUids(Map candidateAnswerUids) {
- this.candidateAnswerUids = candidateAnswerUids;
- }
-
- /**
* @return Returns the feedbackCorrect.
*/
public String getFeedbackCorrect() {
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McMonitoredUserDTO.java
===================================================================
diff -u -r8ddb4345fdfc8904e5a7ff156cc63053e63741ca -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McMonitoredUserDTO.java (.../McMonitoredUserDTO.java) (revision 8ddb4345fdfc8904e5a7ff156cc63053e63741ca)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McMonitoredUserDTO.java (.../McMonitoredUserDTO.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -22,8 +22,6 @@
/* $$Id$$ */
package org.lamsfoundation.lams.tool.mc;
-import java.util.Map;
-
import org.apache.commons.lang.builder.ToStringBuilder;
/**
@@ -54,7 +52,7 @@
private String questionUid;
- private Map usersAttempts;
+ private String userAnswer;
/**
* @return Returns the queUsrId.
@@ -74,26 +72,19 @@
public String toString() {
return new ToStringBuilder(this).append("queUsrId", queUsrId).append("username", userName)
.append("isCorrect", isCorrect).append("mark", mark).append("sessionId", sessionId)
- .append("questionUid", questionUid).append("usersAttempts", usersAttempts).toString();
+ .append("questionUid", questionUid).append("userAnswer", userAnswer).toString();
}
- /**
- * UserAttempts is a map, where the key is the attemptOrder and the value is String array with the text of the
- * attempt. At present, the string array will be of length one, but if we ever support more than one answer to a
- * question then this will need to be changed to a list of strings.
- *
- * @return Returns the usersAttempts.
- */
- public Map getUsersAttempts() {
- return usersAttempts;
+ public String getUserAnswer() {
+ return userAnswer;
}
/**
- * @param usersAttempts
- * The usersAttempts to set.
+ * @param userAnswer
+ * The userAnswer to set.
*/
- public void setUsersAttempts(Map usersAttempts) {
- this.usersAttempts = usersAttempts;
+ public void setUserAnswer(String userAnswer) {
+ this.userAnswer = userAnswer;
}
public int compareTo(Object o) {
Fisheye: Tag c369c0326857e08851d03a29d39d4337091f5253 refers to a dead (removed) revision in file `lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McRandomizedListsDTO.java'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java
===================================================================
diff -u -r8ddb4345fdfc8904e5a7ff156cc63053e63741ca -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java (.../McUtils.java) (revision 8ddb4345fdfc8904e5a7ff156cc63053e63741ca)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McUtils.java (.../McUtils.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -267,9 +267,6 @@
request.getSession().removeAttribute(MAP_LEARNER_FEEDBACK_INCORRECT);
request.getSession().removeAttribute(MAP_LEARNER_FEEDBACK_CORRECT);
request.getSession().removeAttribute(MAP_QUESTION_WEIGHTS);
- request.getSession().removeAttribute(MAP_QUE_ATTEMPTS);
- request.getSession().removeAttribute(MAP_QUE_CORRECT_ATTEMPTS);
- request.getSession().removeAttribute(MAP_QUE_INCORRECT_ATTEMPTS);
request.getSession().removeAttribute(MAP_WEIGHTS);
request.getSession().removeAttribute(MAP_CHECKBOX_STATES);
request.getSession().removeAttribute(MAP_SELECTED_OPTIONS);
@@ -289,7 +286,6 @@
request.getSession().removeAttribute(RICHTEXT_FEEDBACK_INCORRECT);
request.getSession().removeAttribute(RICHTEXT_OFFLINEINSTRUCTIONS);
request.getSession().removeAttribute(PASSMARK);
- request.getSession().removeAttribute(VIEW_ANSWERS);
request.getSession().removeAttribute(SHOW_AUTHORING_TABS);
request.getSession().removeAttribute(RICHTEXT_ONLINEINSTRUCTIONS);
request.getSession().removeAttribute(RICHTEXT_REPORT_TITLE);
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcOptionsContentDAO.java
===================================================================
diff -u -r8ddb4345fdfc8904e5a7ff156cc63053e63741ca -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcOptionsContentDAO.java (.../IMcOptionsContentDAO.java) (revision 8ddb4345fdfc8904e5a7ff156cc63053e63741ca)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcOptionsContentDAO.java (.../IMcOptionsContentDAO.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -46,8 +46,6 @@
*/
public McOptsContent getMcOptionsContentByUID(Long uid);
- public List findMcOptionUidsByQueId(Long mcQueContentId);
-
/**
*
* Return a list of a McOptsContents with the given identifier mcQueContentId, returns null if not
@@ -71,23 +69,10 @@
*/
public McOptsContent getOptionContentByOptionText(final String option, final Long mcQueContentUid);
- /**
- *
- * Return a list of a persisted McOptsContents with the given identifier mcQueContentId, returns null
- * if not found.
- *
- *
- * @param mcQueContentId
- * @return List
- */
- public List getPersistedSelectedOptions(Long mcQueContentId);
-
public List findMcOptionCorrectByQueId(Long mcQueContentId);
public List populateCandidateAnswersDTO(Long mcQueContentId);
- public List getCorrectOption(Long mcQueContentId);
-
/**
*
* saves McOptsContent
@@ -132,6 +117,4 @@
* @param mcOptionsContent
*/
public void removeMcOptionsContent(McOptsContent mcOptsContent);
-
- public List findMcOptionNamesByQueId(Long mcQueContentId);
}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcSessionDAO.java
===================================================================
diff -u -r8ddb4345fdfc8904e5a7ff156cc63053e63741ca -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcSessionDAO.java (.../IMcSessionDAO.java) (revision 8ddb4345fdfc8904e5a7ff156cc63053e63741ca)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcSessionDAO.java (.../IMcSessionDAO.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -56,7 +56,7 @@
* The tool session id
* @return the persistent instance of a McSession or null if not found.
*/
- public McSession findMcSessionById(Long mcSessionId);
+ public McSession getMcSessionById(Long mcSessionId);
/**
*
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUserDAO.java
===================================================================
diff -u -r8ddb4345fdfc8904e5a7ff156cc63053e63741ca -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUserDAO.java (.../IMcUserDAO.java) (revision 8ddb4345fdfc8904e5a7ff156cc63053e63741ca)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUserDAO.java (.../IMcUserDAO.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -56,7 +56,7 @@
*/
public McQueUsr findMcUserById(Long userId);
- public McQueUsr getMcUserBySession(Long userId, Long sessionId);
+ public McQueUsr getMcUserBySession(Long userId, Long sessionUid);
public void saveMcUser(McQueUsr mcUser);
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUsrAttemptDAO.java
===================================================================
diff -u -r9a2c06691bf5157039ae82f36ec2f84c32eda8cb -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUsrAttemptDAO.java (.../IMcUsrAttemptDAO.java) (revision 9a2c06691bf5157039ae82f36ec2f84c32eda8cb)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcUsrAttemptDAO.java (.../IMcUsrAttemptDAO.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -67,31 +67,19 @@
* @param mcUsrAttempt
* @return
*/
- public void removeMcUsrAttempt(McUsrAttempt mcUsrAttempt);
+ public void removeAllUserAttempts(Long queUserUid);
/**
* Get the most recent attempts (for all questions) for one user in one tool session
*
* @param queUserUid
* @return
*/
- public List getLatestAttemptsForAUser(Long queUserUid);
+ public List getUserAttempts(Long queUserUid);
/**
- *
- * gets all the attempts for one questions for one user in one tool session queUsrId, ordered by the
- * attempt id. If there is more than one option selected for a question, the attempts are "batched".
- *
- *
- * @param queUsrId
- * @return
- */
- public List getAllAttemptsForAUserForOneQuestionContentOrderByAttempt(Long queUsrUid,
- Long mcQueContentId);
-
- /**
* Get the highest attempt order for a user for a particular question
*/
- public List getLatestAttemptsForAUserForOneQuestionContent(Long queUsrUid, Long mcQueContentId);
+ public McUsrAttempt getUserAttemptByQuestion(Long queUsrUid, Long mcQueContentId);
}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McOptionsContentDAO.java
===================================================================
diff -u -r9a2c06691bf5157039ae82f36ec2f84c32eda8cb -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McOptionsContentDAO.java (.../McOptionsContentDAO.java) (revision 9a2c06691bf5157039ae82f36ec2f84c32eda8cb)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McOptionsContentDAO.java (.../McOptionsContentDAO.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -46,15 +46,11 @@
private static final String FIND_MC_OPTIONS_CONTENT = "from mcOptsContent in class McOptsContent where mcOptsContent.mcQueContentId=:mcQueContentUid order by mcOptsContent.displayOrder";
private static final String LOAD_OPTION_CONTENT_BY_OPTION_TEXT = "from mcOptsContent in class McOptsContent where mcOptsContent.mcQueOptionText=:option and mcOptsContent.mcQueContentId=:mcQueContentUid";
- private static final String LOAD_PERSISTED_SELECTED_OPTIONS = "from mcOptsContent in class McOptsContent where mcOptsContent.mcQueContentId=:mcQueContentUid and mcOptsContent.correctOption = 1";
-
- private static final String LOAD_CORRECT_OPTION = "from mcOptsContent in class McOptsContent where mcOptsContent.mcQueContentId=:mcQueContentUid and mcOptsContent.correctOption = 1";
-
public McOptsContent getMcOptionsContentByUID(Long uid) {
return (McOptsContent) this.getHibernateTemplate().get(McOptsContent.class, uid);
}
- public List findMcOptionsContentByQueId(Long mcQueContentId) {
+ public List findMcOptionsContentByQueId(Long mcQueContentId) {
HibernateTemplate templ = this.getHibernateTemplate();
if (mcQueContentId != null) {
List list = getSession().createQuery(FIND_MC_OPTIONS_CONTENT)
@@ -64,46 +60,6 @@
return null;
}
- public List findMcOptionUidsByQueId(Long mcQueContentId) {
-
- List listOptionUids = new LinkedList();
-
- HibernateTemplate templ = this.getHibernateTemplate();
- if (mcQueContentId != null) {
- List list = getSession().createQuery(FIND_MC_OPTIONS_CONTENT)
- .setLong("mcQueContentUid", mcQueContentId.longValue()).list();
-
- if (list != null && list.size() > 0) {
- Iterator listIterator = list.iterator();
- while (listIterator.hasNext()) {
- McOptsContent mcOptsContent = (McOptsContent) listIterator.next();
- listOptionUids.add(mcOptsContent.getUid().toString());
- }
- }
- }
- return listOptionUids;
- }
-
- public List findMcOptionNamesByQueId(Long mcQueContentId) {
-
- List listOptionNames = new LinkedList();
-
- HibernateTemplate templ = this.getHibernateTemplate();
- if (mcQueContentId != null) {
- List list = getSession().createQuery(FIND_MC_OPTIONS_CONTENT)
- .setLong("mcQueContentUid", mcQueContentId.longValue()).list();
-
- if (list != null && list.size() > 0) {
- Iterator listIterator = list.iterator();
- while (listIterator.hasNext()) {
- McOptsContent mcOptsContent = (McOptsContent) listIterator.next();
- listOptionNames.add(mcOptsContent.getMcQueOptionText());
- }
- }
- }
- return listOptionNames;
- }
-
public List populateCandidateAnswersDTO(Long mcQueContentId) {
List listCandidateAnswersData = new LinkedList();
@@ -130,7 +86,6 @@
List listOptionCorrect = new LinkedList();
- HibernateTemplate templ = this.getHibernateTemplate();
if (mcQueContentId != null) {
List list = getSession().createQuery(FIND_MC_OPTIONS_CONTENT)
.setLong("mcQueContentUid", mcQueContentId.longValue()).list();
@@ -147,7 +102,6 @@
}
public McOptsContent getOptionContentByOptionText(final String option, final Long mcQueContentUid) {
- HibernateTemplate templ = this.getHibernateTemplate();
List list = getSession().createQuery(LOAD_OPTION_CONTENT_BY_OPTION_TEXT).setString("option", option)
.setLong("mcQueContentUid", mcQueContentUid.longValue()).list();
@@ -158,22 +112,6 @@
return null;
}
- public List getPersistedSelectedOptions(Long mcQueContentId) {
- HibernateTemplate templ = this.getHibernateTemplate();
- List list = getSession().createQuery(LOAD_PERSISTED_SELECTED_OPTIONS)
- .setLong("mcQueContentUid", mcQueContentId.longValue()).list();
-
- return list;
- }
-
- public List getCorrectOption(Long mcQueContentId) {
- HibernateTemplate templ = this.getHibernateTemplate();
- List list = getSession().createQuery(LOAD_CORRECT_OPTION)
- .setLong("mcQueContentUid", mcQueContentId.longValue()).list();
-
- return list;
- }
-
public void saveMcOptionsContent(McOptsContent mcOptsContent) {
this.getHibernateTemplate().save(mcOptsContent);
}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McSessionDAO.java
===================================================================
diff -u -r8ddb4345fdfc8904e5a7ff156cc63053e63741ca -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McSessionDAO.java (.../McSessionDAO.java) (revision 8ddb4345fdfc8904e5a7ff156cc63053e63741ca)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McSessionDAO.java (.../McSessionDAO.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -50,7 +50,7 @@
return (McSession) this.getHibernateTemplate().get(McSession.class, uid);
}
- public McSession findMcSessionById(Long mcSessionId) {
+ public McSession getMcSessionById(Long mcSessionId) {
List list = getSession().createQuery(LOAD_MCSESSION_BY_MCSESSIONID).setLong(0, mcSessionId.longValue()).list();
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUserDAO.java
===================================================================
diff -u -r8ddb4345fdfc8904e5a7ff156cc63053e63741ca -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUserDAO.java (.../McUserDAO.java) (revision 8ddb4345fdfc8904e5a7ff156cc63053e63741ca)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUserDAO.java (.../McUserDAO.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -40,7 +40,7 @@
private static final String CALC_MARK_STATS_FOR_SESSION = "select max(mu.lastAttemptTotalMark), min(mu.lastAttemptTotalMark), avg(mu.lastAttemptTotalMark)"
+ " from McQueUsr mu where mu.mcSessionId = :mcSessionUid";
- private static final String GET_USER_BY_USER_ID_SESSION = "from mcQueUsr in class McQueUsr where mcQueUsr.queUsrId=:queUsrId and mcQueUsr.mcSessionId=:mcSessionId";
+ private static final String GET_USER_BY_USER_ID_SESSION = "from mcQueUsr in class McQueUsr where mcQueUsr.queUsrId=:queUsrId and mcQueUsr.mcSessionId=:mcSessionUid";
private static final String GET_USER_BY_USER_ID = "from McQueUsr user where user.queUsrId=?";
@@ -58,10 +58,10 @@
return null;
}
- public McQueUsr getMcUserBySession(final Long queUsrId, final Long mcSessionId) {
+ public McQueUsr getMcUserBySession(final Long queUsrId, final Long mcSessionUid) {
List list = getSession().createQuery(GET_USER_BY_USER_ID_SESSION).setLong("queUsrId", queUsrId.longValue())
- .setLong("mcSessionId", mcSessionId.longValue()).list();
+ .setLong("mcSessionUid", mcSessionUid.longValue()).list();
if (list != null && list.size() > 0) {
McQueUsr usr = (McQueUsr) list.get(0);
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUsrAttemptDAO.java
===================================================================
diff -u -r9a2c06691bf5157039ae82f36ec2f84c32eda8cb -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUsrAttemptDAO.java (.../McUsrAttemptDAO.java) (revision 9a2c06691bf5157039ae82f36ec2f84c32eda8cb)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McUsrAttemptDAO.java (.../McUsrAttemptDAO.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -44,51 +44,49 @@
*/
public class McUsrAttemptDAO extends HibernateDaoSupport implements IMcUsrAttemptDAO {
- private static final String LOAD_LAST_ATTEMPT_BY_ATTEMPT_ORDER = "from mcUsrAttempt in class McUsrAttempt where mcUsrAttempt.mcQueUsr.uid=:queUsrUid"
- + " and mcUsrAttempt.mcQueContentId=:mcQueContentId and mcUsrAttempt.attemptOrder=mcUsrAttempt.mcQueUsr.lastAttemptOrder"
+ private static final String LOAD_PARTICULAR_QUESTION_ATTEMPT = "from mcUsrAttempt in class McUsrAttempt where mcUsrAttempt.mcQueUsr.uid=:queUsrUid"
+ + " and mcUsrAttempt.mcQueContentId=:mcQueContentId"
+ " order by mcUsrAttempt.mcOptionsContent.uid";
- private static final String LOAD_ATTEMPT_FOR_QUESTION_CONTENT = "from mcUsrAttempt in class McUsrAttempt "
- + " where mcUsrAttempt.mcQueContentId=:mcQueContentId and mcUsrAttempt.queUsrId=:queUsrUid"
- + " order by mcUsrAttempt.attemptOrder";
-
- private static final String LOAD_LAST_ATTEMPTS = "from mcUsrAttempt in class McUsrAttempt where mcUsrAttempt.mcQueUsr.uid=:queUsrUid"
- + " and mcUsrAttempt.attemptOrder=mcUsrAttempt.mcQueUsr.lastAttemptOrder"
+ private static final String LOAD_ALL_QUESTION_ATTEMPTS = "from mcUsrAttempt in class McUsrAttempt where mcUsrAttempt.mcQueUsr.uid=:queUsrUid"
+ " order by mcUsrAttempt.mcQueContentId, mcUsrAttempt.mcOptionsContent.uid";
-
- public void saveMcUsrAttempt(McUsrAttempt mcUsrAttempt) {
+
+ public void saveMcUsrAttempt(McUsrAttempt mcUsrAttempt) {
this.getHibernateTemplate().save(mcUsrAttempt);
}
- public List getLatestAttemptsForAUser(final Long queUserUid) {
- return (List) getSession().createQuery(LOAD_LAST_ATTEMPTS).setLong("queUsrUid", queUserUid.longValue()).list();
+ public List getUserAttempts(final Long queUserUid) {
+ return (List) getSession().createQuery(LOAD_ALL_QUESTION_ATTEMPTS)
+ .setLong("queUsrUid", queUserUid.longValue()).list();
}
- // should be able to get rid of this one by rewriting export portfolio
@SuppressWarnings("unchecked")
- public List getLatestAttemptsForAUserForOneQuestionContent(final Long queUsrUid,
- final Long mcQueContentId) {
- return (List) getSession().createQuery(LOAD_LAST_ATTEMPT_BY_ATTEMPT_ORDER)
- .setLong("queUsrUid", queUsrUid.longValue()).setLong("mcQueContentId", mcQueContentId.longValue())
- .list();
- }
+ public McUsrAttempt getUserAttemptByQuestion(final Long queUsrUid, final Long mcQueContentId) {
+ List userAttemptList = (List) getSession()
+ .createQuery(LOAD_PARTICULAR_QUESTION_ATTEMPT).setLong("queUsrUid", queUsrUid.longValue())
+ .setLong("mcQueContentId", mcQueContentId.longValue()).list();
+ if (userAttemptList.size() > 1) {
+ throw new RuntimeException("There are more than 1 latest question attempt");
+ }
- @SuppressWarnings("unchecked")
- public List getAllAttemptsForAUserForOneQuestionContentOrderByAttempt(final Long queUsrUid,
- final Long mcQueContentId) {
- return (List) getSession().createQuery(LOAD_ATTEMPT_FOR_QUESTION_CONTENT)
- .setLong("mcQueContentId", mcQueContentId.longValue()).setLong("queUsrUid", queUsrUid.longValue())
- .list();
+ McUsrAttempt userAttempt = (userAttemptList.size() == 0) ? null : userAttemptList.get(0);
+ return userAttempt;
}
public void updateMcUsrAttempt(McUsrAttempt mcUsrAttempt) {
this.getSession().setFlushMode(FlushMode.AUTO);
this.getHibernateTemplate().update(mcUsrAttempt);
}
- public void removeMcUsrAttempt(McUsrAttempt mcUsrAttempt) {
+ public void removeAllUserAttempts(Long queUserUid) {
this.getSession().setFlushMode(FlushMode.AUTO);
- this.getHibernateTemplate().delete(mcUsrAttempt);
+
+ List userAttempts = (List) getSession().createQuery(LOAD_ALL_QUESTION_ATTEMPTS)
+ .setLong("queUsrUid", queUserUid.longValue()).list();
+
+ for (McUsrAttempt userAttempt : userAttempts) {
+ this.getHibernateTemplate().delete(userAttempt);
+ }
}
}
\ No newline at end of file
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dbupdates/patch20130812.sql
===================================================================
diff -u
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dbupdates/patch20130812.sql (revision 0)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dbupdates/patch20130812.sql (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -0,0 +1,25 @@
+-- Turn off autocommit, so nothing is committed if there is an error
+SET AUTOCOMMIT = 0;
+
+----------------------Put all sql statements below here-------------------------
+
+--LDEV-3085 Autosave feature for MCQ
+DELETE FROM tl_lamc11_usr_attempt WHERE uid NOT IN ( --remove all attempts except the last one
+ SELECT uid
+ FROM (
+ SELECT uid
+ FROM tl_lamc11_usr_attempt
+ ORDER BY attemptOrder DESC
+ LIMIT 1
+ ) foo
+);
+ALTER TABLE tl_lamc11_usr_attempt DROP COLUMN attemptOrder;
+
+ALTER TABLE tl_lamc11_que_usr DROP COLUMN last_attempt_order;
+ALTER TABLE tl_lamc11_que_usr ADD COLUMN number_attempts INTEGER DEFAULT 0;
+
+----------------------Put all sql statements above here-------------------------
+
+-- If there were no errors, commit and restore autocommit to on
+COMMIT;
+SET AUTOCOMMIT = 1;
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/pojos/McOptsContent.java
===================================================================
diff -u -r9a2c06691bf5157039ae82f36ec2f84c32eda8cb -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/pojos/McOptsContent.java (.../McOptsContent.java) (revision 9a2c06691bf5157039ae82f36ec2f84c32eda8cb)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/pojos/McOptsContent.java (.../McOptsContent.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -23,9 +23,6 @@
package org.lamsfoundation.lams.tool.mc.pojos;
import java.io.Serializable;
-import java.util.HashSet;
-import java.util.Set;
-import java.util.TreeSet;
import org.apache.commons.lang.builder.ToStringBuilder;
@@ -57,6 +54,9 @@
/** persistent field */
private org.lamsfoundation.lams.tool.mc.pojos.McQueContent mcQueContent;
+
+ //DTO field
+ private boolean selected;
public McOptsContent(Integer displayOrder, boolean correctOption, String mcQueOptionText,
org.lamsfoundation.lams.tool.mc.pojos.McQueContent mcQueContent) {
@@ -167,4 +167,12 @@
public void setDisplayOrder(Integer displayOrder) {
this.displayOrder = displayOrder;
}
+
+ public boolean isSelected() {
+ return this.selected;
+ }
+
+ public void setSelected(boolean selected) {
+ this.selected = selected;
+ }
}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/pojos/McQueUsr.java
===================================================================
diff -u -r8ddb4345fdfc8904e5a7ff156cc63053e63741ca -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/pojos/McQueUsr.java (.../McQueUsr.java) (revision 8ddb4345fdfc8904e5a7ff156cc63053e63741ca)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/pojos/McQueUsr.java (.../McQueUsr.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -23,7 +23,6 @@
package org.lamsfoundation.lams.tool.mc.pojos;
import java.io.Serializable;
-import java.util.HashSet;
import java.util.Set;
import org.apache.commons.lang.builder.ToStringBuilder;
@@ -52,26 +51,28 @@
private boolean responseFinalised;
+ //please pay attention this is *sessionUid* and not sessionId (this is due to Ozgur gave wrongly name to this field)
private Long mcSessionId;
/** nullable persistent field */
- private org.lamsfoundation.lams.tool.mc.pojos.McSession mcSession;
+ private McSession mcSession;
- /** persistent field */
- private Set mcUsrAttempts;
+ private Integer numberOfAttempts;
- private Integer lastAttemptOrder;
-
private Integer lastAttemptTotalMark;
+
+ /** default constructor */
+ public McQueUsr() {
+ }
/** full constructor */
public McQueUsr(Long queUsrId, String username, String fullname,
- org.lamsfoundation.lams.tool.mc.pojos.McSession mcSession, Set mcUsrAttempts) {
+ McSession mcSession, Set mcUsrAttempts) {
this.queUsrId = queUsrId;
this.username = username;
this.fullname = fullname;
this.mcSession = mcSession;
- this.mcUsrAttempts = mcUsrAttempts;
+ this.numberOfAttempts = 0;
}
/**
@@ -89,16 +90,6 @@
this.responseFinalised = responseFinalised;
}
- /** default constructor */
- public McQueUsr() {
- }
-
- /** minimal constructor */
- public McQueUsr(Long queUsrId, Set mcUsrAttempts) {
- this.queUsrId = queUsrId;
- this.mcUsrAttempts = mcUsrAttempts;
- }
-
public Long getUid() {
return this.uid;
}
@@ -131,33 +122,25 @@
this.fullname = fullname;
}
- public org.lamsfoundation.lams.tool.mc.pojos.McSession getMcSession() {
+ public McSession getMcSession() {
return this.mcSession;
}
- public void setMcSession(org.lamsfoundation.lams.tool.mc.pojos.McSession mcSession) {
+ public void setMcSession(McSession mcSession) {
this.mcSession = mcSession;
}
- public Set getMcUsrAttempts() {
- if (this.mcUsrAttempts == null)
- setMcUsrAttempts(new HashSet());
- return this.mcUsrAttempts;
- }
-
- public void setMcUsrAttempts(Set mcUsrAttempts) {
- this.mcUsrAttempts = mcUsrAttempts;
- }
-
public String toString() {
return new ToStringBuilder(this).append("uid", getUid()).append("queUsrId", getQueUsrId())
.append("username", getUsername()).append("fullname", getFullname())
.append("responseFinalised", isResponseFinalised()).append("mcSessionId", getMcSessionId())
- .append("lastAttemptOrder", getLastAttemptOrder())
+ .append("numberOfAttempts", getNumberOfAttempts())
.append("lastAttemptTotalMark", getLastAttemptTotalMark()).toString();
}
/**
+ * Please pay attention this is *sessionUid* and not sessionId (this is due to Ozgur gave wrongly name to this field)
+ *
* @return Returns the mcSessionId.
*/
public Long getMcSessionId() {
@@ -172,12 +155,12 @@
this.mcSessionId = mcSessionId;
}
- public Integer getLastAttemptOrder() {
- return lastAttemptOrder;
+ public Integer getNumberOfAttempts() {
+ return numberOfAttempts;
}
- public void setLastAttemptOrder(Integer lastAttemptOrder) {
- this.lastAttemptOrder = lastAttemptOrder;
+ public void setNumberOfAttempts(Integer numberOfAttempts) {
+ this.numberOfAttempts = numberOfAttempts;
}
public Integer getLastAttemptTotalMark() {
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/pojos/McUsrAttempt.java
===================================================================
diff -u -r9a2c06691bf5157039ae82f36ec2f84c32eda8cb -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/pojos/McUsrAttempt.java (.../McUsrAttempt.java) (revision 9a2c06691bf5157039ae82f36ec2f84c32eda8cb)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/pojos/McUsrAttempt.java (.../McUsrAttempt.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -37,12 +37,11 @@
*/
public class McUsrAttempt implements Serializable {
+ private static final long serialVersionUID = 4514268732673337338L;
+
/** identifier field */
private Long uid;
- /** persistent field */
- private Long attemptId;
-
/** nullable persistent field */
private Date attemptTime;
@@ -52,94 +51,36 @@
private boolean passed;
- private Integer attemptOrder;
-
private Long queUsrId;
private Long mcQueContentId;
/** persistent field */
- private org.lamsfoundation.lams.tool.mc.pojos.McQueContent mcQueContent;
+ private McQueContent mcQueContent;
/** persistent field */
- private org.lamsfoundation.lams.tool.mc.pojos.McQueUsr mcQueUsr;
+ private McQueUsr mcQueUsr;
/** persistent field */
- private org.lamsfoundation.lams.tool.mc.pojos.McOptsContent mcOptionsContent;
+ private McOptsContent mcOptionsContent;
- /** full constructor */
- public McUsrAttempt(Long attemptId, Date attemptTime,
- org.lamsfoundation.lams.tool.mc.pojos.McQueContent mcQueContent,
- org.lamsfoundation.lams.tool.mc.pojos.McQueUsr mcQueUsr,
- org.lamsfoundation.lams.tool.mc.pojos.McOptsContent mcOptionsContent) {
- this.attemptId = attemptId;
+ public McUsrAttempt(Date attemptTime, McQueContent mcQueContent,
+ McQueUsr mcQueUsr,
+ McOptsContent mcOptionsContent, Integer mark, boolean passed,
+ boolean attemptCorrect) {
this.attemptTime = attemptTime;
this.mcQueContent = mcQueContent;
this.mcQueUsr = mcQueUsr;
this.mcOptionsContent = mcOptionsContent;
- }
-
- public McUsrAttempt(Date attemptTime, org.lamsfoundation.lams.tool.mc.pojos.McQueContent mcQueContent,
- org.lamsfoundation.lams.tool.mc.pojos.McQueUsr mcQueUsr,
- org.lamsfoundation.lams.tool.mc.pojos.McOptsContent mcOptionsContent) {
- this.attemptTime = attemptTime;
- this.mcQueContent = mcQueContent;
- this.mcQueUsr = mcQueUsr;
- this.mcOptionsContent = mcOptionsContent;
- }
-
- public McUsrAttempt(Date attemptTime, org.lamsfoundation.lams.tool.mc.pojos.McQueContent mcQueContent,
- org.lamsfoundation.lams.tool.mc.pojos.McQueUsr mcQueUsr,
- org.lamsfoundation.lams.tool.mc.pojos.McOptsContent mcOptionsContent, Integer mark, boolean passed) {
- this.attemptTime = attemptTime;
- this.mcQueContent = mcQueContent;
- this.mcQueUsr = mcQueUsr;
- this.mcOptionsContent = mcOptionsContent;
this.mark = mark;
this.passed = passed;
- }
-
- public McUsrAttempt(Date attemptTime, org.lamsfoundation.lams.tool.mc.pojos.McQueContent mcQueContent,
- org.lamsfoundation.lams.tool.mc.pojos.McQueUsr mcQueUsr,
- org.lamsfoundation.lams.tool.mc.pojos.McOptsContent mcOptionsContent, Integer mark, boolean passed,
- Integer attemptOrder) {
- this.attemptTime = attemptTime;
- this.mcQueContent = mcQueContent;
- this.mcQueUsr = mcQueUsr;
- this.mcOptionsContent = mcOptionsContent;
- this.mark = mark;
- this.passed = passed;
- this.attemptOrder = attemptOrder;
- }
-
- public McUsrAttempt(Date attemptTime, org.lamsfoundation.lams.tool.mc.pojos.McQueContent mcQueContent,
- org.lamsfoundation.lams.tool.mc.pojos.McQueUsr mcQueUsr,
- org.lamsfoundation.lams.tool.mc.pojos.McOptsContent mcOptionsContent, Integer mark, boolean passed,
- Integer attemptOrder, boolean attemptCorrect) {
- this.attemptTime = attemptTime;
- this.mcQueContent = mcQueContent;
- this.mcQueUsr = mcQueUsr;
- this.mcOptionsContent = mcOptionsContent;
- this.mark = mark;
- this.passed = passed;
- this.attemptOrder = attemptOrder;
this.attemptCorrect = attemptCorrect;
}
/** default constructor */
public McUsrAttempt() {
}
- /** minimal constructor */
- public McUsrAttempt(Long attemptId, org.lamsfoundation.lams.tool.mc.pojos.McQueContent mcQueContent,
- org.lamsfoundation.lams.tool.mc.pojos.McQueUsr mcQueUsr,
- org.lamsfoundation.lams.tool.mc.pojos.McOptsContent mcOptionsContent) {
- this.attemptId = attemptId;
- this.mcQueContent = mcQueContent;
- this.mcQueUsr = mcQueUsr;
- this.mcOptionsContent = mcOptionsContent;
- }
-
public Long getUid() {
return this.uid;
}
@@ -148,14 +89,6 @@
this.uid = uid;
}
- public Long getAttemptId() {
- return this.attemptId;
- }
-
- public void setAttemptId(Long attemptId) {
- this.attemptId = attemptId;
- }
-
public Date getAttemptTime() {
return this.attemptTime;
}
@@ -218,8 +151,8 @@
* @param passed
* The passed to set.
*/
- public void setPassed(boolean passed) {
- this.passed = passed;
+ public void setPassed(boolean isPassed) {
+ this.passed = isPassed;
}
/**
@@ -238,21 +171,6 @@
}
/**
- * @return Returns the attemptOrder.
- */
- public Integer getAttemptOrder() {
- return attemptOrder;
- }
-
- /**
- * @param attemptOrder
- * The attemptOrder to set.
- */
- public void setAttemptOrder(Integer attemptOrder) {
- this.attemptOrder = attemptOrder;
- }
-
- /**
* @return Returns the mcQueContentId.
*/
public Long getMcQueContentId() {
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java
===================================================================
diff -u -r9a2c06691bf5157039ae82f36ec2f84c32eda8cb -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java (.../IMcService.java) (revision 9a2c06691bf5157039ae82f36ec2f84c32eda8cb)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java (.../IMcService.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -4,15 +4,15 @@
* License Information: http://lamsfoundation.org/licensing/lams/2.0/
*
* This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+ * it under the terms of the GNU General License as published by
* the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * GNU General License for more details.
*
- * You should have received a copy of the GNU General Public License
+ * You should have received a copy of the GNU General License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
@@ -36,6 +36,7 @@
import org.lamsfoundation.lams.tool.exception.SessionDataExistsException;
import org.lamsfoundation.lams.tool.exception.ToolException;
import org.lamsfoundation.lams.tool.mc.McApplicationException;
+import org.lamsfoundation.lams.tool.mc.McLearnerAnswersDTO;
import org.lamsfoundation.lams.tool.mc.pojos.McContent;
import org.lamsfoundation.lams.tool.mc.pojos.McOptsContent;
import org.lamsfoundation.lams.tool.mc.pojos.McQueContent;
@@ -51,209 +52,185 @@
* Interface that defines the contract that all MCQ service provider must follow.
*/
public interface IMcService {
- public void configureContentRepository() throws McApplicationException;
+ void configureContentRepository() throws McApplicationException;
- public void createMc(McContent mcContent) throws McApplicationException;
+ void createMc(McContent mcContent) throws McApplicationException;
- public McContent retrieveMc(Long toolContentId) throws McApplicationException;
+ McContent retrieveMc(Long toolContentId) throws McApplicationException;
- public void createMcQue(McQueContent mcQueContent) throws McApplicationException;
+ void createMcQue(McQueContent mcQueContent) throws McApplicationException;
- public void updateMcQueContent(McQueContent mcQueContent) throws McApplicationException;
+ void updateMcQueContent(McQueContent mcQueContent) throws McApplicationException;
- public List retrieveMcQueContentsByToolContentId(long mcContentId) throws McApplicationException;
+ List retrieveMcQueContentsByToolContentId(long mcContentId) throws McApplicationException;
- public McQueContent getQuestionContentByDisplayOrder(final Long displayOrder, final Long mcContentUid)
+ McQueContent getQuestionByDisplayOrder(final Long displayOrder, final Long mcContentUid)
throws McApplicationException;
- public void createMcSession(McSession mcSession) throws McApplicationException;
+ void createMcSession(McSession mcSession) throws McApplicationException;
- public void createMcQueUsr(McQueUsr mcQueUsr) throws McApplicationException;
+ McQueUsr createMcUser(Long toolSessionId) throws McApplicationException;
- public McQueUsr getMcUserBySession(final Long queUsrId, final Long mcSessionId) throws McApplicationException;
+ McQueUsr getMcUserBySession(final Long queUsrId, final Long mcSessionUid) throws McApplicationException;
- public McQueUsr retrieveMcQueUsr(Long userId) throws McApplicationException;
+ McQueUsr retrieveMcQueUsr(Long userId) throws McApplicationException;
- public void createMcUsrAttempt(McUsrAttempt mcUsrAttempt) throws McApplicationException;
+ void saveUserAttempt(McQueUsr user, List selectedQuestionAndCandidateAnswersDTO);
- public void updateMcUsrAttempt(McUsrAttempt mcUsrAttempt) throws McApplicationException;
+ void updateMcUsrAttempt(McUsrAttempt mcUsrAttempt) throws McApplicationException;
- public McQueContent retrieveMcQueContentByUID(Long uid) throws McApplicationException;
+ McQueContent retrieveMcQueContentByUID(Long uid) throws McApplicationException;
- public void removeMcQueContent(McQueContent mcQueContent) throws McApplicationException;
+ void removeMcQueContent(McQueContent mcQueContent) throws McApplicationException;
- public McQueContent getMcQueContentByUID(Long uid) throws McApplicationException;
+ McQueContent getMcQueContentByUID(Long uid) throws McApplicationException;
- public void saveOrUpdateMcQueContent(McQueContent mcQueContent) throws McApplicationException;
+ void saveOrUpdateMcQueContent(McQueContent mcQueContent) throws McApplicationException;
- public void removeQuestionContentByMcUid(final Long mcContentUid) throws McApplicationException;
+ void removeQuestionContentByMcUid(final Long mcContentUid) throws McApplicationException;
- public McOptsContent getMcOptionsContentByUID(Long uid) throws McApplicationException;
+ McOptsContent getMcOptionsContentByUID(Long uid) throws McApplicationException;
- public void resetAllQuestions(final Long mcContentUid) throws McApplicationException;
+ void resetAllQuestions(final Long mcContentUid) throws McApplicationException;
- public List refreshQuestionContent(final Long mcContentId) throws McApplicationException;
+ List refreshQuestionContent(final Long mcContentId) throws McApplicationException;
- public List getAllQuestionEntriesSorted(final long mcContentId) throws McApplicationException;
+ List getAllQuestionEntriesSorted(final long mcContentId) throws McApplicationException;
- public List findMcOptionUidsByQueId(Long mcQueContentId) throws McApplicationException;
+ McQueContent getQuestionByUid(Long uid) throws McApplicationException;
- public McQueContent findMcQuestionContentByUid(Long uid) throws McApplicationException;
+ void removeMcOptionsContentByQueId(Long mcQueContentId) throws McApplicationException;
- public void removeMcOptionsContentByQueId(Long mcQueContentId) throws McApplicationException;
+ void removeMcOptionsContent(McOptsContent mcOptsContent);
- public void removeMcOptionsContent(McOptsContent mcOptsContent);
+ McQueContent getQuestionContentByQuestionText(final String question, final Long mcContentUid);
- public McQueContent getQuestionContentByQuestionText(final String question, final Long mcContentUid);
+ void removeMcQueContentByUID(Long uid) throws McApplicationException;
- public List getPersistedSelectedOptions(Long mcQueContentId);
+ McQueUsr getMcUserByUID(Long uid) throws McApplicationException;
- public void removeMcQueContentByUID(Long uid) throws McApplicationException;
+ List getAllQuestionEntries(final Long mcContentId) throws McApplicationException;
- public McQueUsr getMcUserByUID(Long uid) throws McApplicationException;
+ McSession getMcSessionById(Long mcSessionId) throws McApplicationException;
- public List getCorrectOption(Long mcQueContentId);
+ McContent retrieveMcBySessionId(Long mcSessionId) throws McApplicationException;
- public List getAllQuestionEntries(final Long mcContentId) throws McApplicationException;
+ void updateMc(McContent mc) throws McApplicationException;
- public McSession retrieveMcSession(Long mcSessionId) throws McApplicationException;
+ void updateMcSession(McSession mcSession) throws McApplicationException;
- public McContent retrieveMcBySessionId(Long mcSessionId) throws McApplicationException;
+ void updateMcQueUsr(McQueUsr mcQueUsr) throws McApplicationException;
- public void updateMc(McContent mc) throws McApplicationException;
+ List populateCandidateAnswersDTO(Long mcQueContentId) throws McApplicationException;
- public void updateMcSession(McSession mcSession) throws McApplicationException;
+ McSession getMcSessionByUID(Long uid) throws McApplicationException;
- public void updateMcQueUsr(McQueUsr mcQueUsr) throws McApplicationException;
+ List getFinalizedUserAttempts(final McQueUsr user) throws McApplicationException;
- public List populateCandidateAnswersDTO(Long mcQueContentId) throws McApplicationException;
+ void deleteMc(McContent mc) throws McApplicationException;
- public McSession getMcSessionByUID(Long uid) throws McApplicationException;
+ void deleteMcById(Long mcId) throws McApplicationException;
- public List getLatestAttemptsForAUser(final Long queUserUid) throws McApplicationException;
+ void deleteMcQueUsr(McQueUsr mcQueUsr) throws McApplicationException;
- public void deleteMc(McContent mc) throws McApplicationException;
+ List findMcOptionsContentByQueId(Long mcQueContentId) throws McApplicationException;
- public void deleteMcById(Long mcId) throws McApplicationException;
+ void saveMcOptionsContent(McOptsContent mcOptsContent) throws McApplicationException;
- public void removeAttempt(McUsrAttempt attempt) throws McApplicationException;
+ McOptsContent getOptionContentByOptionText(final String option, final Long mcQueContentUid);
- public void deleteMcQueUsr(McQueUsr mcQueUsr) throws McApplicationException;
+ void updateMcOptionsContent(McOptsContent mcOptsContent) throws McApplicationException;
- public List findMcOptionsContentByQueId(Long mcQueContentId) throws McApplicationException;
+ void deleteMcOptionsContent(McOptsContent mcOptsContent) throws McApplicationException;
- public void saveMcOptionsContent(McOptsContent mcOptsContent) throws McApplicationException;
+ void deleteMcOptionsContentByUID(Long uid) throws McApplicationException;
- public McOptsContent getOptionContentByOptionText(final String option, final Long mcQueContentUid);
+ User getCurrentUserData(String username) throws McApplicationException;
- public void updateMcOptionsContent(McOptsContent mcOptsContent) throws McApplicationException;
+ Lesson getCurrentLesson(long lessonId) throws McApplicationException;
- public void deleteMcOptionsContent(McOptsContent mcOptsContent) throws McApplicationException;
+ void saveMcContent(McContent mc) throws McApplicationException;
- public void deleteMcOptionsContentByUID(Long uid) throws McApplicationException;
+ boolean studentActivityOccurredGlobal(McContent mcContent) throws McApplicationException;
- public User getCurrentUserData(String username) throws McApplicationException;
-
- public Lesson getCurrentLesson(long lessonId) throws McApplicationException;
-
- public void saveMcContent(McContent mc) throws McApplicationException;
-
- public boolean studentActivityOccurredGlobal(McContent mcContent) throws McApplicationException;
-
- /**
- *
- * gets all the attempts for one questions for one user in one tool session queUsrId, ordered by the
- * attempt id. If there is more than one option selected for a question, the attempts are "batched".
- *
- *
- * @param queUsrId
- * @return
- */
- public List getAllAttemptsForAUserForOneQuestionContentOrderByAttempt(Long queUsrUid,
- Long mcQueContentId) throws McApplicationException;
-
- public List getLatestAttemptsForAUserForOneQuestionContent(Long queUsrUid, Long mcQueContentId)
+ McUsrAttempt getUserAttemptByQuestion(Long queUsrUid, Long mcQueContentId)
throws McApplicationException;
- public int countIncompleteSession(McContent mc) throws McApplicationException;
+ int countIncompleteSession(McContent mc) throws McApplicationException;
- public boolean studentActivityOccurred(McContent mc) throws McApplicationException;
+ boolean studentActivityOccurred(McContent mc) throws McApplicationException;
- public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException;
+ void copyToolContent(Long fromContentId, Long toContentId) throws ToolException;
- public void setAsForceCompleteSession(Long toolSessionId) throws McApplicationException;
+ void setAsForceCompleteSession(Long toolSessionId) throws McApplicationException;
- public void setAsForceComplete(Long userId) throws McApplicationException;
+ void setAsForceComplete(Long userId) throws McApplicationException;
- public void setAsDefineLater(Long toolContentId, boolean value) throws DataMissingException, ToolException;
+ void setAsDefineLater(Long toolContentId, boolean value) throws DataMissingException, ToolException;
- public void setAsRunOffline(Long toolContentId, boolean value) throws DataMissingException, ToolException;
+ void setAsRunOffline(Long toolContentId, boolean value) throws DataMissingException, ToolException;
- public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException,
+ void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException,
ToolException;
- public boolean existsSession(Long toolSessionId);
+ boolean existsSession(Long toolSessionId);
- public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException;
+ void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException;
- public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException;
+ void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException;
- public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException;
+ String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException;
- public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException;
+ ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException;
- public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException,
+ ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException,
ToolException;
- public IToolVO getToolBySignature(String toolSignature) throws McApplicationException;
+ IToolVO getToolBySignature(String toolSignature) throws McApplicationException;
- public long getToolDefaultContentIdBySignature(String toolSignature) throws McApplicationException;
+ long getToolDefaultContentIdBySignature(String toolSignature) throws McApplicationException;
- public McQueContent getToolDefaultQuestionContent(long contentId) throws McApplicationException;
+ McQueContent getToolDefaultQuestionContent(long contentId) throws McApplicationException;
- public ITicket getRepositoryLoginTicket() throws McApplicationException;
+ ITicket getRepositoryLoginTicket() throws McApplicationException;
- public void deleteFromRepository(Long uuid, Long versionID);
+ void deleteFromRepository(Long uuid, Long versionID);
- public NodeKey uploadFileToRepository(InputStream stream, String fileName) throws McApplicationException;
+ NodeKey uploadFileToRepository(InputStream stream, String fileName) throws McApplicationException;
- public InputStream downloadFile(Long uuid, Long versionID) throws McApplicationException;
+ InputStream downloadFile(Long uuid, Long versionID) throws McApplicationException;
- public void persistFile(String uuid, boolean isOnlineFile, String fileName, McContent mcContent)
+ void persistFile(String uuid, boolean isOnlineFile, String fileName, McContent mcContent)
throws McApplicationException;
- public McSession findMcSessionById(Long mcSessionId) throws McApplicationException;
+ List getNextAvailableDisplayOrder(final long mcContentId) throws McApplicationException;
- public List getNextAvailableDisplayOrder(final long mcContentId) throws McApplicationException;
-
- public NodeKey uploadFile(InputStream istream, String filename, String contentType, String fileType)
+ NodeKey uploadFile(InputStream istream, String filename, String contentType, String fileType)
throws RepositoryCheckedException;
- public NodeKey copyFile(Long uuid) throws RepositoryCheckedException;
+ NodeKey copyFile(Long uuid) throws RepositoryCheckedException;
- public List findMcOptionCorrectByQueId(Long mcQueContentId) throws McApplicationException;
+ List findMcOptionCorrectByQueId(Long mcQueContentId) throws McApplicationException;
- public List findMcOptionNamesByQueId(Long mcQueContentId) throws McApplicationException;
+ Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String entry);
- public Long createNotebookEntry(Long id, Integer idType, String signature, Integer userID, String entry);
+ NotebookEntry getEntry(Long id, Integer idType, String signature, Integer userID);
- public NotebookEntry getEntry(Long id, Integer idType, String signature, Integer userID);
+ void updateEntry(NotebookEntry notebookEntry);
- public void updateEntry(NotebookEntry notebookEntry);
+ void persistFile(McContent content, McUploadedFile file) throws McApplicationException;
- public void persistFile(McContent content, McUploadedFile file) throws McApplicationException;
+ void removeFile(Long submissionId) throws McApplicationException;
- public void removeFile(Long submissionId) throws McApplicationException;
+ List retrieveMcUploadedFiles(McContent mcContent) throws McApplicationException;
- public List retrieveMcUploadedFiles(McContent mcContent) throws McApplicationException;
-
/**
* Return the top, lowest and average mark for all learners for one particular tool session.
*
* @param request
* @return top mark, lowest mark, average mark in that order
*/
- public Integer[] getMarkStatistics(McSession mcSession);
+ Integer[] getMarkStatistics(McSession mcSession);
/**
* Returns whether activity is grouped and therefore it is expected more than one tool session.
@@ -262,5 +239,12 @@
* @return
*/
boolean isGroupedActivity(long toolContentID);
+
+ /**
+ * @param mcContent
+ * @param user user; pass null if there is no need to populate previous answers
+ * @return
+ */
+ List buildLearnerAnswersDTOList(McContent mcContent, McQueUsr user);
}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/MCOutputFactory.java
===================================================================
diff -u -r8ddb4345fdfc8904e5a7ff156cc63053e63741ca -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/MCOutputFactory.java (.../MCOutputFactory.java) (revision 8ddb4345fdfc8904e5a7ff156cc63053e63741ca)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/MCOutputFactory.java (.../MCOutputFactory.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -70,7 +70,7 @@
TreeMap output = new TreeMap();
- McSession session = mcService.findMcSessionById(toolSessionId);
+ McSession session = mcService.getMcSessionById(toolSessionId);
if (session != null) {
McQueUsr queUser = mcService.getMcUserBySession(learnerId, session.getUid());
@@ -90,7 +90,7 @@
public ToolOutput getToolOutput(String name, IMcService mcService, Long toolSessionId, Long learnerId) {
if (name != null) {
- McSession session = mcService.findMcSessionById(toolSessionId);
+ McSession session = mcService.getMcSessionById(toolSessionId);
if (session != null) {
McQueUsr queUser = mcService.getMcUserBySession(learnerId, session.getUid());
@@ -133,16 +133,16 @@
// written to cope with more than one correct option for each question but only tested with
// one correct option for a question.
- private boolean allQuestionsCorrect(IMcService mcService, McQueUsr queUser) {
+ private boolean allQuestionsCorrect(IMcService mcService, McQueUsr user) {
// Build a list of all the correct answers. If we hit any options that are not a correct option
// we can abort as we know there is a wrong answer.
// Otherwise count the number of correct options overall (for comparison later).
long correctlearnerOptions = 0;
- List latestAttempts = (List) mcService.getLatestAttemptsForAUser(queUser.getUid());
- for (McUsrAttempt mcUsrAttempt : latestAttempts) {
- McOptsContent mcOptsContent = mcUsrAttempt.getMcOptionsContent();
- if (!mcOptsContent.isCorrectOption()) {
+ List userAttempts = (List) mcService.getFinalizedUserAttempts(user);
+ for (McUsrAttempt userAttempt : userAttempts) {
+ McOptsContent option = userAttempt.getMcOptionsContent();
+ if (!option.isCorrectOption()) {
// wrong answer so no point going any further
return false;
} else {
@@ -152,7 +152,7 @@
// now count the overall number of correct options
long correctOptions = 0;
- McContent mcContent = queUser.getMcSession().getMcContent();
+ McContent mcContent = user.getMcSession().getMcContent();
Iterator questionIterator = mcContent.getMcQueContents().iterator();
while (questionIterator.hasNext()) {
McQueContent mcQueContent = (McQueContent) questionIterator.next();
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java
===================================================================
diff -u -r33da76d05725a84e191a5f6dca50b394cca3c1ee -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java (.../McServicePOJO.java) (revision 33da76d05725a84e191a5f6dca50b394cca3c1ee)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java (.../McServicePOJO.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -23,15 +23,20 @@
package org.lamsfoundation.lams.tool.mc.service;
import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.Date;
import java.util.Hashtable;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeSet;
import java.util.Vector;
+import javax.servlet.http.HttpSession;
+
import org.apache.log4j.Logger;
import org.lamsfoundation.lams.contentrepository.AccessDeniedException;
import org.lamsfoundation.lams.contentrepository.FileException;
@@ -66,6 +71,8 @@
import org.lamsfoundation.lams.tool.exception.ToolException;
import org.lamsfoundation.lams.tool.mc.McAppConstants;
import org.lamsfoundation.lams.tool.mc.McApplicationException;
+import org.lamsfoundation.lams.tool.mc.McLearnerAnswersDTO;
+import org.lamsfoundation.lams.tool.mc.McUtils;
import org.lamsfoundation.lams.tool.mc.dao.IMcContentDAO;
import org.lamsfoundation.lams.tool.mc.dao.IMcOptionsContentDAO;
import org.lamsfoundation.lams.tool.mc.dao.IMcQueContentDAO;
@@ -89,6 +96,8 @@
import org.lamsfoundation.lams.util.audit.IAuditService;
import org.lamsfoundation.lams.util.wddx.WDDXProcessor;
import org.lamsfoundation.lams.util.wddx.WDDXProcessorConversionException;
+import org.lamsfoundation.lams.web.session.SessionManager;
+import org.lamsfoundation.lams.web.util.AttributeNames;
import org.springframework.dao.DataAccessException;
/**
@@ -100,9 +109,7 @@
*
*/
public class McServicePOJO implements IMcService, ToolContentManager, ToolSessionManager, ToolContentImport102Manager,
- McAppConstants
-
-{
+ McAppConstants {
static Logger logger = Logger.getLogger(McServicePOJO.class.getName());
/* repository access related constants */
@@ -202,7 +209,7 @@
}
}
- public McQueContent getQuestionContentByDisplayOrder(final Long displayOrder, final Long mcContentUid)
+ public McQueContent getQuestionByDisplayOrder(final Long displayOrder, final Long mcContentUid)
throws McApplicationException {
try {
return mcQueContentDAO.getQuestionContentByDisplayOrder(displayOrder, mcContentUid);
@@ -282,10 +289,20 @@
+ e.getMessage(), e);
}
}
-
- public void createMcQueUsr(McQueUsr mcQueUsr) throws McApplicationException {
+
+ public McQueUsr createMcUser(Long toolSessionID) throws McApplicationException {
try {
- mcUserDAO.saveMcUser(mcQueUsr);
+ HttpSession ss = SessionManager.getSession();
+ UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ Long userId = toolUser.getUserID().longValue();
+ String userName = toolUser.getLogin();
+ String fullName = toolUser.getFirstName() + " " + toolUser.getLastName();
+ McSession mcSession = getMcSessionById(toolSessionID.longValue());
+
+ McQueUsr user = new McQueUsr(userId, userName, fullName, mcSession, new TreeSet());
+ mcUserDAO.saveMcUser(user);
+
+ return user;
} catch (DataAccessException e) {
throw new McApplicationException("Exception occured when lams is creating mc QueUsr: " + e.getMessage(), e);
}
@@ -299,9 +316,9 @@
}
}
- public McQueUsr getMcUserBySession(final Long queUsrId, final Long mcSessionId) throws McApplicationException {
+ public McQueUsr getMcUserBySession(final Long queUsrId, final Long mcSessionUid) throws McApplicationException {
try {
- return mcUserDAO.getMcUserBySession(queUsrId, mcSessionId);
+ return mcUserDAO.getMcUserBySession(queUsrId, mcSessionUid);
} catch (DataAccessException e) {
throw new McApplicationException("Exception occured when lams is getting mc QueUsr: " + e.getMessage(), e);
}
@@ -325,12 +342,53 @@
}
}
- public void createMcUsrAttempt(McUsrAttempt mcUsrAttempt) throws McApplicationException {
- try {
- mcUsrAttemptDAO.saveMcUsrAttempt(mcUsrAttempt);
- } catch (DataAccessException e) {
- throw new McApplicationException(
- "Exception occured when lams is creating mc UsrAttempt: " + e.getMessage(), e);
+ @Override
+ public void saveUserAttempt(McQueUsr user, List selectedQuestionAndCandidateAnswersDTO) {
+
+ Date attemptTime = McUtils.getGMTDateTime();
+
+ for (McLearnerAnswersDTO mcLearnerAnswersDTO : selectedQuestionAndCandidateAnswersDTO) {
+
+ Long questionUid = mcLearnerAnswersDTO.getQuestionUid();
+ McQueContent question = this.getQuestionByUid(questionUid);
+ if (question == null) {
+ throw new McApplicationException("Can't find question with specified question uid: " + mcLearnerAnswersDTO.getQuestionUid());
+ }
+
+ McOptsContent answerOption = mcLearnerAnswersDTO.getAnswerOption();
+ if (answerOption != null) {
+
+ Integer mark = mcLearnerAnswersDTO.getMark();
+ boolean passed = user.isMarkPassed(mark);
+ boolean isAttemptCorrect = new Boolean(mcLearnerAnswersDTO.getAttemptCorrect());
+
+ McUsrAttempt userAttempt = this.getUserAttemptByQuestion(user.getUid(), questionUid);
+ if (userAttempt != null) {
+
+ McOptsContent previosAnswer = userAttempt.getMcOptionsContent();
+ // check if answer hasn't been changed since the last time
+ if (previosAnswer.getUid().equals(answerOption.getUid())) {
+ // don't save anything
+ continue;
+
+ } else {
+ // in case answer has been changed update userttempt
+ userAttempt.setAttemptTime(attemptTime);
+ userAttempt.setMcOptionsContent(answerOption);
+ userAttempt.setMark(mark);
+ userAttempt.setPassed(passed);
+ userAttempt.setAttemptCorrect(isAttemptCorrect);
+ }
+
+ } else {
+ // create new userAttempt
+ userAttempt = new McUsrAttempt(attemptTime, question, user, answerOption, mark, passed, isAttemptCorrect);
+
+ }
+
+ mcUsrAttemptDAO.saveMcUsrAttempt(userAttempt);
+
+ }
}
}
@@ -342,39 +400,73 @@
"Exception occured when lams is updating mc UsrAttempt: " + e.getMessage(), e);
}
}
+
+ @Override
+ public List buildLearnerAnswersDTOList(McContent mcContent, McQueUsr user) {
+ List learnerAnswersDTOList = new LinkedList();
+ List questions = this.getAllQuestionEntries(mcContent.getUid());
- public List getLatestAttemptsForAUser(final Long queUserUid) throws McApplicationException {
+ for (McQueContent question : questions) {
+ McLearnerAnswersDTO learnerAnswersDTO = new McLearnerAnswersDTO();
+ Set optionSet = question.getMcOptionsContents();
+ List optionList = new LinkedList(optionSet);
+
+ boolean randomize = mcContent.isRandomize();
+ if (randomize) {
+ ArrayList shuffledList = new ArrayList(optionList);
+ Collections.shuffle(shuffledList);
+ optionList = new LinkedList(shuffledList);
+ }
+
+ learnerAnswersDTO.setQuestion(question.getQuestion());
+ learnerAnswersDTO.setDisplayOrder(question.getDisplayOrder().toString());
+ learnerAnswersDTO.setQuestionUid(question.getUid());
+
+ learnerAnswersDTO.setMark(question.getMark());
+ learnerAnswersDTO.setOptions(optionList);
+
+ learnerAnswersDTOList.add(learnerAnswersDTO);
+ }
+
+ //populate answers
+ if (user != null) {
+
+ for (McLearnerAnswersDTO learnerAnswersDTO : learnerAnswersDTOList) {
+ Long questionUid = learnerAnswersDTO.getQuestionUid();
+
+ McUsrAttempt dbAttempt = this.getUserAttemptByQuestion(user.getUid(), questionUid);
+ if (dbAttempt != null) {
+ Long selectedOptionUid = dbAttempt.getMcOptionsContent().getUid();
+
+ //mark selected option as selected
+ for (McOptsContent option : learnerAnswersDTO.getOptions()) {
+ if (selectedOptionUid.equals(option.getUid())) {
+ option.setSelected(true);
+ }
+ }
+ }
+ }
+ }
+
+ return learnerAnswersDTOList;
+ }
+
+ public List getFinalizedUserAttempts(final McQueUsr user) throws McApplicationException {
try {
- return mcUsrAttemptDAO.getLatestAttemptsForAUser(queUserUid);
+ List finalizedUserAttempts = (user.isResponseFinalised()) ? mcUsrAttemptDAO
+ .getUserAttempts(user.getUid()) : new LinkedList();
+ return finalizedUserAttempts;
} catch (DataAccessException e) {
throw new McApplicationException(
"Exception occured when lams is getting the learner's attempts by user id and que content id and attempt order: "
+ e.getMessage(), e);
}
}
- /**
- *
- * gets all the attempts for one questions for one user in one tool session queUsrId, ordered by the
- * attempt id. If there is more than one option selected for a question, the attempts are "batched".
- *
- *
- * @param queUsrId
- * @return
- */
- public List getAllAttemptsForAUserForOneQuestionContentOrderByAttempt(final Long queUsrUid,
- final Long mcQueContentId) throws McApplicationException {
- try {
- return mcUsrAttemptDAO.getAllAttemptsForAUserForOneQuestionContentOrderByAttempt(queUsrUid, mcQueContentId);
- } catch (DataAccessException e) {
- throw new McApplicationException("Exception occured when lams is getting attempts. " + e.getMessage(), e);
- }
- }
-
- public List getLatestAttemptsForAUserForOneQuestionContent(Long queUsrUid, Long mcQueContentId)
+ public McUsrAttempt getUserAttemptByQuestion(Long queUsrUid, Long mcQueContentId)
throws McApplicationException {
try {
- return mcUsrAttemptDAO.getLatestAttemptsForAUserForOneQuestionContent(queUsrUid, mcQueContentId);
+ return mcUsrAttemptDAO.getUserAttemptByQuestion(queUsrUid, mcQueContentId);
} catch (DataAccessException e) {
throw new McApplicationException(
"Exception occured when lams is getting the learner's attempts by user id and que content id and attempt order: "
@@ -446,16 +538,6 @@
}
}
- public List getPersistedSelectedOptions(Long mcQueContentId) throws McApplicationException {
- try {
- return mcOptionsContentDAO.getPersistedSelectedOptions(mcQueContentId);
- } catch (DataAccessException e) {
- throw new McApplicationException("Exception occured when lams is gettong persisted selected"
- + " the mc options content: " + e.getMessage(), e);
- }
-
- }
-
public McQueContent getQuestionContentByQuestionText(final String question, final Long mcContentId) {
try {
return mcQueContentDAO.getQuestionContentByQuestionText(question, mcContentId);
@@ -465,25 +547,15 @@
}
}
- public McSession retrieveMcSession(Long mcSessionId) throws McApplicationException {
+ public McSession getMcSessionById(Long mcSessionId) throws McApplicationException {
try {
- return mcSessionDAO.findMcSessionById(mcSessionId);
+ return mcSessionDAO.getMcSessionById(mcSessionId);
} catch (DataAccessException e) {
throw new McApplicationException("Exception occured when lams is retrieving by id mc session : "
+ e.getMessage(), e);
}
}
- public McSession findMcSessionById(Long mcSessionId) throws McApplicationException {
- try {
- return mcSessionDAO.findMcSessionById(mcSessionId);
- } catch (DataAccessException e) {
- throw new McApplicationException("Exception occured when lams is retrieving by id mc session : "
- + e.getMessage(), e);
- }
-
- }
-
public McContent retrieveMcBySessionId(Long mcSessionId) throws McApplicationException {
try {
return mcContentDAO.getMcContentBySession(mcSessionId);
@@ -529,15 +601,6 @@
}
}
- public void removeAttempt(McUsrAttempt attempt) throws McApplicationException {
- try {
- mcUsrAttemptDAO.removeMcUsrAttempt(attempt);
- } catch (DataAccessException e) {
- throw new McApplicationException("Exception occured when lams is removing" + " the attempt: "
- + e.getMessage(), e);
- }
- }
-
/**
* Return the top, lowest and average mark for all learners for one particular tool session.
*
@@ -585,16 +648,8 @@
}
}
- public List findMcOptionUidsByQueId(Long mcQueContentId) throws McApplicationException {
+ public McQueContent getQuestionByUid(Long uid) throws McApplicationException {
try {
- return mcOptionsContentDAO.findMcOptionUidsByQueId(mcQueContentId);
- } catch (DataAccessException e) {
- throw new McApplicationException("Exception occured when lams is getting opt uids" + e.getMessage(), e);
- }
- }
-
- public McQueContent findMcQuestionContentByUid(Long uid) throws McApplicationException {
- try {
return mcQueContentDAO.findMcQuestionContentByUid(uid);
} catch (DataAccessException e) {
throw new McApplicationException("Exception occured when lams is getting que content by uid"
@@ -620,15 +675,6 @@
}
}
- public List getCorrectOption(Long mcQueContentId) {
- try {
- return mcOptionsContentDAO.getCorrectOption(mcQueContentId);
- } catch (DataAccessException e) {
- throw new McApplicationException("Exception occured when lams is returning the " + " correct option: "
- + e.getMessage(), e);
- }
- }
-
public void updateMcOptionsContent(McOptsContent mcOptsContent) throws McApplicationException {
try {
mcOptionsContentDAO.updateMcOptionsContent(mcOptsContent);
@@ -657,16 +703,6 @@
}
}
- public List findMcOptionNamesByQueId(Long mcQueContentId) throws McApplicationException {
- try {
- return mcOptionsContentDAO.findMcOptionNamesByQueId(mcQueContentId);
- } catch (DataAccessException e) {
- throw new McApplicationException("Exception occured when lams is finding" + " the mc options name: "
- + e.getMessage(), e);
- }
-
- }
-
public void removeMcOptionsContentByQueId(Long mcQueContentId) throws McApplicationException {
try {
mcOptionsContentDAO.removeMcOptionsContentByQueId(mcQueContentId);
@@ -888,12 +924,8 @@
Iterator sessionUsersIterator = mcSession.getMcQueUsers().iterator();
while (sessionUsersIterator.hasNext()) {
McQueUsr mcQueUsr = (McQueUsr) sessionUsersIterator.next();
-
- Iterator sessionUsersAttemptsIterator = mcQueUsr.getMcUsrAttempts().iterator();
- while (sessionUsersAttemptsIterator.hasNext()) {
- McUsrAttempt mcUsrAttempt = (McUsrAttempt) sessionUsersAttemptsIterator.next();
- removeAttempt(mcUsrAttempt);
- }
+
+ mcUsrAttemptDAO.removeAllUserAttempts(mcQueUsr.getUid());
}
}
mcContentDAO.removeMcById(toolContentId);
@@ -912,7 +944,7 @@
* toolSessionId
*/
public void setAsForceCompleteSession(Long toolSessionId) throws McApplicationException {
- McSession mcSession = retrieveMcSession(toolSessionId);
+ McSession mcSession = getMcSessionById(toolSessionId);
mcSession.setSessionStatus(McSession.COMPLETED);
updateMcSession(mcSession);
}
@@ -933,7 +965,7 @@
if (mcSession != null) {
Long usersToolSessionId = mcSession.getMcSessionId();
- mcSession = retrieveMcSession(usersToolSessionId);
+ mcSession = getMcSessionById(usersToolSessionId);
mcSession.setSessionStatus(McSession.COMPLETED);
updateMcSession(mcSession);
@@ -1110,7 +1142,7 @@
* @return boolean
*/
public boolean existsSession(Long toolSessionId) {
- McSession mcSession = retrieveMcSession(toolSessionId);
+ McSession mcSession = getMcSessionById(toolSessionId);
return mcSession != null;
}
@@ -1200,7 +1232,7 @@
McSession mcSession = null;
try {
- mcSession = retrieveMcSession(toolSessionId);
+ mcSession = getMcSessionById(toolSessionId);
} catch (McApplicationException e) {
throw new DataMissingException("error retrieving mcSession: " + e);
} catch (Exception e) {
@@ -1248,7 +1280,7 @@
McSession mcSession = null;
try {
- mcSession = retrieveMcSession(toolSessionId);
+ mcSession = getMcSessionById(toolSessionId);
} catch (McApplicationException e) {
throw new DataMissingException("error retrieving mcSession: " + e);
} catch (Exception e) {
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java
===================================================================
diff -u -r87ff0b33fa2d006a084b2ae9b7ff14d4c4be0f6d -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision 87ff0b33fa2d006a084b2ae9b7ff14d4c4be0f6d)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java (.../AuthoringUtil.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -28,7 +28,6 @@
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
-import java.util.TreeSet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@@ -1170,7 +1169,7 @@
new Integer(currentMark), currentFeedback, mcContent, null, null);
/* checks if the question is already recorded */
- McQueContent existingMcQueContent = mcService.getQuestionContentByDisplayOrder(new Long(displayOrder),
+ McQueContent existingMcQueContent = mcService.getQuestionByDisplayOrder(new Long(displayOrder),
mcContent.getUid());
if (existingMcQueContent == null) {
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/ExportServlet.java
===================================================================
diff -u -r8ddb4345fdfc8904e5a7ff156cc63053e63741ca -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/ExportServlet.java (.../ExportServlet.java) (revision 8ddb4345fdfc8904e5a7ff156cc63053e63741ca)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/ExportServlet.java (.../ExportServlet.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -86,7 +86,7 @@
if (toolContentID != null) {
content = mcService.retrieveMc(toolContentID);
} else {
- McSession session = mcService.retrieveMcSession(toolSessionID);
+ McSession session = mcService.getMcSessionById(toolSessionID);
if (session != null)
content = session.getMcContent();
}
@@ -117,7 +117,7 @@
throw new McApplicationException(error);
}
- McSession mcSession = mcService.retrieveMcSession(toolSessionID);
+ McSession mcSession = mcService.getMcSessionById(toolSessionID);
// If the learner hasn't selected any options yet, then they won't exist in the session.
// Yet we might be asked for their page, as the activity has been commenced. So need to do a "blank" page in
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java
===================================================================
diff -u -r8ddb4345fdfc8904e5a7ff156cc63053e63741ca -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java (.../LearningUtil.java) (revision 8ddb4345fdfc8904e5a7ff156cc63053e63741ca)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java (.../LearningUtil.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -22,32 +22,16 @@
/* $$Id$$ */
package org.lamsfoundation.lams.tool.mc.web;
-import java.util.Collection;
-import java.util.Date;
import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
-import java.util.Random;
-import java.util.TreeMap;
-import java.util.TreeSet;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.lamsfoundation.lams.tool.mc.McAppConstants;
-import org.lamsfoundation.lams.tool.mc.McComparator;
import org.lamsfoundation.lams.tool.mc.McGeneralLearnerFlowDTO;
import org.lamsfoundation.lams.tool.mc.McLearnerAnswersDTO;
-import org.lamsfoundation.lams.tool.mc.McRandomizedListsDTO;
-import org.lamsfoundation.lams.tool.mc.McUtils;
import org.lamsfoundation.lams.tool.mc.pojos.McContent;
-import org.lamsfoundation.lams.tool.mc.pojos.McOptsContent;
-import org.lamsfoundation.lams.tool.mc.pojos.McQueContent;
-import org.lamsfoundation.lams.tool.mc.pojos.McQueUsr;
-import org.lamsfoundation.lams.tool.mc.pojos.McSession;
-import org.lamsfoundation.lams.tool.mc.pojos.McUsrAttempt;
-import org.lamsfoundation.lams.tool.mc.service.IMcService;
/**
*
@@ -60,12 +44,7 @@
static Logger logger = Logger.getLogger(LearningUtil.class.getName());
/**
- * void saveFormRequestData(HttpServletRequest request, McLearningForm mcLearningForm, boolean
- * prepareViewAnswersDataMode)
*
- * @param request
- * @param mcLearningForm
- * @param prepareViewAnswersDataMode
*/
public static void saveFormRequestData(HttpServletRequest request, McLearningForm mcLearningForm,
boolean prepareViewAnswersDataMode) {
@@ -95,158 +74,8 @@
}
/**
- * A question is correct if the number of correct options and the number of checked options is the same, plus all
- * the checked options appears in the correct options list.
- *
- * @param mapGeneralCorrectOptions
- * @param checkedOptionsUIDs
- * @return
+ * buildMcGeneralLearnerFlowDTO
*/
- public static boolean isQuestionCorrect(Collection correctOptions, List checkedOptionIds) {
-
- for (McOptsContent mcOptsContent : correctOptions) {
- String optionId = mcOptsContent.getUid().toString();
- if (!optionId.equals(checkedOptionIds.get(checkedOptionIds.size() - 1))) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * McQueUsr getUser(HttpServletRequest request, IMcService mcService, String toolSessionId)
- *
- * @param request
- * @param mcService
- * @param toolSessionId
- * @return
- */
- public static McQueUsr getUser(HttpServletRequest request, IMcService mcService, String toolSessionId) {
- Long queUsrId = McUtils.getUserId();
-
- McSession mcSession = mcService.retrieveMcSession(new Long(toolSessionId));
- McQueUsr mcQueUsr = mcService.getMcUserBySession(queUsrId, mcSession.getUid());
- return mcQueUsr;
- }
-
- /**
- * creates the user in the db createUser(HttpServletRequest request)
- *
- * @param request
- */
- public static McQueUsr createUser(HttpServletRequest request, IMcService mcService, Long toolSessionId) {
- Long queUsrId = McUtils.getUserId();
- String username = McUtils.getUserName();
- String fullname = McUtils.getUserFullName();
-
- McSession mcSession = mcService.retrieveMcSession(toolSessionId);
- McQueUsr mcQueUsr = new McQueUsr(queUsrId, username, fullname, mcSession, new TreeSet());
- mcService.createMcQueUsr(mcQueUsr);
- return mcQueUsr;
- }
-
- /**
- * createLearnerAttempt(HttpServletRequest request, McQueUsr mcQueUsr, List selectedQuestionAndCandidateAnswersDTO,
- * Integer totalMark, boolean passed, int highestAttemptOrder, Map mapLeanerAssessmentResults, IMcService mcService)
- *
- * @param request
- * @param mcQueUsr
- * @param selectedQuestionAndCandidateAnswersDTO
- * @param mark
- * @param passed
- * @param highestAttemptOrder
- * @param mapLeanerAssessmentResults
- * @param mcService
- */
- public static void createLearnerAttempt(HttpServletRequest request, McQueUsr mcQueUsr,
- List selectedQuestionAndCandidateAnswersDTO, boolean passed, Integer highestAttemptOrder,
- Map mapLeanerAssessmentResults, IMcService mcService) {
- Date attemptTime = McUtils.getGMTDateTime();
-
- Iterator itSelectedMap = selectedQuestionAndCandidateAnswersDTO.iterator();
- while (itSelectedMap.hasNext()) {
- McLearnerAnswersDTO mcLearnerAnswersDTO = (McLearnerAnswersDTO) itSelectedMap.next();
-
- McQueContent mcQueContent = mcService.findMcQuestionContentByUid(mcLearnerAnswersDTO.getQuestionUid());
-
- createIndividualOptions(request, mcLearnerAnswersDTO.getCandidateAnswers(), mcQueContent, mcQueUsr,
- attemptTime, mcLearnerAnswersDTO.getMark(), passed, highestAttemptOrder,
- mcLearnerAnswersDTO.getAttemptCorrect(), mcService);
- }
-
- }
-
- /**
- *
- * createIndividualOptions(HttpServletRequest request, Map candidateAnswers, McQueContent mcQueContent, McQueUsr
- * mcQueUsr, Date attempTime, String timeZone, int mark, boolean passed, Integer highestAttemptOrder, String
- * isAttemptCorrect, IMcService mcService)
- *
- * @param request
- * @param candidateAnswers
- * @param mcQueContent
- * @param mcQueUsr
- * @param attemptTime
- * @param mark
- * @param passed
- * @param highestAttemptOrder
- * @param isAttemptCorrect
- * @param mcService
- */
- public static void createIndividualOptions(HttpServletRequest request, Map candidateAnswers,
- McQueContent mcQueContent, McQueUsr mcQueUsr, Date attemptTime, int mark, boolean passed,
- Integer highestAttemptOrder, String isAttemptCorrect, IMcService mcService) {
- Integer IntegerMark = new Integer(mark);
-
- if (mcQueContent != null) {
- if (candidateAnswers != null) {
- Iterator itCheckedMap = candidateAnswers.entrySet().iterator();
- while (itCheckedMap.hasNext()) {
- Map.Entry checkedPairs = (Map.Entry) itCheckedMap.next();
- McOptsContent mcOptsContent = mcService.getOptionContentByOptionText(checkedPairs.getValue()
- .toString(), mcQueContent.getUid());
- if (mcOptsContent != null) {
- McUsrAttempt mcUsrAttempt = new McUsrAttempt(attemptTime, mcQueContent, mcQueUsr,
- mcOptsContent, IntegerMark, passed, highestAttemptOrder,
- new Boolean(isAttemptCorrect).booleanValue());
- mcService.createMcUsrAttempt(mcUsrAttempt);
- // created mcUsrAttempt in the db
- }
- }
- }
- }
- }
-
- /**
- * Map buildMarksMap(HttpServletRequest request, Long toolContentId, IMcService mcService)
- *
- * @param request
- * @param toolContentId
- * @param mcService
- * @return
- */
- public static Map buildMarksMap(HttpServletRequest request, Long toolContentId, IMcService mcService) {
- Map mapMarks = new TreeMap(new McComparator());
- McContent mcContent = mcService.retrieveMc(toolContentId);
-
- List questionsContent = mcService.refreshQuestionContent(mcContent.getUid());
-
- Iterator listIterator = questionsContent.iterator();
- Long mapIndex = new Long(1);
- while (listIterator.hasNext()) {
- McQueContent mcQueContent = (McQueContent) listIterator.next();
- mapMarks.put(mapIndex.toString(), mcQueContent.getMark().toString());
- mapIndex = new Long(mapIndex.longValue() + 1);
- }
- return mapMarks;
- }
-
- /**
- * McGeneralLearnerFlowDTO buildMcGeneralLearnerFlowDTO(McContent mcContent)
- *
- * @param mcContent
- * @return
- */
public static McGeneralLearnerFlowDTO buildMcGeneralLearnerFlowDTO(McContent mcContent) {
McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO = new McGeneralLearnerFlowDTO();
mcGeneralLearnerFlowDTO.setRetries(new Boolean(mcContent.isRetries()).toString());
@@ -266,229 +95,7 @@
return mcGeneralLearnerFlowDTO;
}
- public static McRandomizedListsDTO randomizeList(List listCandidateAnswers, List listCandidateAnswerUids) {
-
- McRandomizedListsDTO mcRandomizedListsDTO = new McRandomizedListsDTO();
-
- int caCount = listCandidateAnswers.size();
-
- Random generator = new Random();
-
- boolean listNotComplete = true;
- int randomInt = 0;
-
- List randomList = new LinkedList();
- List randomUidList = new LinkedList();
- while (listNotComplete) {
- randomInt = generator.nextInt(caCount);
-
- String ca = (String) listCandidateAnswers.get(randomInt);
-
- String caUid = (String) listCandidateAnswerUids.get(randomInt);
-
- if (!isEntryStored(ca, randomList)) {
- // adding ca, since it is a new candidate
- randomList.add(ca);
- randomUidList.add(caUid);
-
- LearningUtil.logger.debug("randomList size: " + randomList.size());
- if (randomList.size() == listCandidateAnswers.size()) {
- // the list is populated completely
- listNotComplete = false;
- }
- }
- }
-
- listCandidateAnswerUids = randomUidList;
-
- mcRandomizedListsDTO.setListCandidateAnswers(randomList);
- mcRandomizedListsDTO.setListCandidateAnswerUids(listCandidateAnswerUids);
-
- return mcRandomizedListsDTO;
- }
-
- public static boolean isEntryStored(String ca, List randomList) {
-
- Iterator randomListIterator = randomList.iterator();
-
- while (randomListIterator.hasNext()) {
- String caStored = (String) randomListIterator.next();
-
- if (caStored.equals(ca)) {
- // this ca already is stored
- return true;
- }
- }
-
- return false;
- }
-
/**
- * List buildQuestionAndCandidateAnswersDTO(HttpServletRequest request, McContent mcContent, IMcService mcService)
- *
- * @param request
- * @param mcContent
- * @param mcService
- * @return
- */
- public static List buildQuestionAndCandidateAnswersDTO(HttpServletRequest request,
- McContent mcContent, boolean randomize, IMcService mcService) {
- List questionAndCandidateAnswersList = new LinkedList();
- List listQuestionEntries = mcService.getAllQuestionEntries(mcContent.getUid());
-
- Iterator listQuestionEntriesIterator = listQuestionEntries.iterator();
- while (listQuestionEntriesIterator.hasNext()) {
- McQueContent mcQueContent = (McQueContent) listQuestionEntriesIterator.next();
- McLearnerAnswersDTO mcLearnerAnswersDTO = new McLearnerAnswersDTO();
- List listCandidateAnswers = mcService.findMcOptionNamesByQueId(mcQueContent.getUid());
- List listCandidateAnswerUids = mcService.findMcOptionUidsByQueId(mcQueContent.getUid());
- if (randomize) {
- // listCandidateAnswers=randomizeList(listCandidateAnswers, listCandidateAnswerUids);
- McRandomizedListsDTO mcRandomizedListsDTO = randomizeList(listCandidateAnswers, listCandidateAnswerUids);
- listCandidateAnswers = mcRandomizedListsDTO.getListCandidateAnswers();
- listCandidateAnswerUids = mcRandomizedListsDTO.getListCandidateAnswerUids();
- }
- Map mapCandidateAnswers = convertToStringMap(listCandidateAnswers);
- Map mapCandidateAnswerUids = convertToStringMap(listCandidateAnswerUids);
-
- String question = mcQueContent.getQuestion();
-
- mcLearnerAnswersDTO.setQuestion(question);
- mcLearnerAnswersDTO.setDisplayOrder(mcQueContent.getDisplayOrder().toString());
- mcLearnerAnswersDTO.setQuestionUid(mcQueContent.getUid());
-
- mcLearnerAnswersDTO.setMark(mcQueContent.getMark());
- mcLearnerAnswersDTO.setCandidateAnswerUids(mapCandidateAnswerUids);
- mcLearnerAnswersDTO.setCandidateAnswers(mapCandidateAnswers);
-
- questionAndCandidateAnswersList.add(mcLearnerAnswersDTO);
- }
-
- return questionAndCandidateAnswersList;
- }
-
- /**
- * Map convertToStringMap(List list)
- *
- * @param list
- * @return
- */
- public static Map convertToStringMap(List list) {
- Map map = new TreeMap(new McComparator());
-
- Iterator listIterator = list.iterator();
- Long mapIndex = new Long(1);
-
- while (listIterator.hasNext()) {
- String data = (String) listIterator.next();
- map.put(mapIndex.toString(), data);
- mapIndex = new Long(mapIndex.longValue() + 1);
- }
- return map;
- }
-
- /**
- * Gets the various maps used by jsps to display a learner's attempts.
- *
- * @return Map[mapFinalAnswersIsContent, mapFinalAnswersContent, mapQueAttempts, mapQueCorrectAttempts,
- * mapQueIncorrectAttempts, mapMarks]
- */
- public static Map[] getAttemptMapsForUser(int intTotalQuestionCount, Long toolContentUID, boolean allowRetries,
- IMcService mcService, McQueUsr mcQueUsr) {
-
- Map mapFinalAnswersIsContent = new TreeMap(new McComparator());
- Map mapFinalAnswersContent = new TreeMap(new McComparator());
-
- // mapQueAttempts: key is the question display order, the value is the mapAttempOrderAttempts map.
- // mapAttemptOrderAttempts: key is the attempt order, the value is the mapAttempt map.
- // mapAttemptMap: key is an artificial ordering, the value is the actual value for the question
- // at the moment, there will only be one attempt for each question of each learner in a tool session
- // so mapAttemptMap will only have one value.
- // The mapQueCorrectAttempts and mapQueIncorrectAttempts work in a similar way
- Map mapQueAttempts = new TreeMap(new McComparator());
- Map mapQueCorrectAttempts = new TreeMap(new McComparator());
- Map mapQueIncorrectAttempts = new TreeMap(new McComparator());
-
- for (int i = 1; i <= intTotalQuestionCount; i++) {
- McQueContent mcQueContent = mcService.getQuestionContentByDisplayOrder(new Long(i), toolContentUID);
-
- McUsrAttempt mcUsrAttemptFinal = null;
-
- List userAttempts = mcService.getAllAttemptsForAUserForOneQuestionContentOrderByAttempt(mcQueUsr.getUid(),
- mcQueContent.getUid());
- Iterator userAttemptsIter = userAttempts.iterator();
-
- Map mapAttemptOrderAttempts = new TreeMap(new McComparator());
- Map mapAttemptOrderCorrectAttempts = new TreeMap(new McComparator());
- Map mapAttemptOrderIncorrectAttempts = new TreeMap(new McComparator());
-
- while (userAttemptsIter.hasNext()) {
- McUsrAttempt mcUsrAttempt = (McUsrAttempt) userAttemptsIter.next();
-
- if (mcUsrAttemptFinal == null
- || mcUsrAttempt.getAttemptOrder().compareTo(mcUsrAttemptFinal.getAttemptOrder()) > 0) {
- mcUsrAttemptFinal = mcUsrAttempt;
- }
-
- addToAttemptMaps(mapAttemptOrderAttempts, mapAttemptOrderCorrectAttempts,
- mapAttemptOrderIncorrectAttempts, mcUsrAttempt);
- }
-
- String questionDisplayOrderString = new Integer(i).toString();
-
- Integer mark = null;
- if (mcUsrAttemptFinal != null) {
- mapFinalAnswersIsContent.put(questionDisplayOrderString,
- new Boolean(mcUsrAttemptFinal.isAttemptCorrect()).toString());
- mapFinalAnswersContent.put(questionDisplayOrderString, mcUsrAttemptFinal.getMcOptionsContent()
- .getMcQueOptionText().toString());
- }
- if (mapAttemptOrderAttempts.size() > 0) {
- mapQueAttempts.put(questionDisplayOrderString, mapAttemptOrderAttempts);
- }
- if (mapAttemptOrderCorrectAttempts.size() > 0) {
- mapQueCorrectAttempts.put(questionDisplayOrderString, mapAttemptOrderCorrectAttempts);
- }
- if (mapAttemptOrderIncorrectAttempts.size() > 0) {
- mapQueIncorrectAttempts.put(questionDisplayOrderString, mapAttemptOrderIncorrectAttempts);
- }
- }
-
- return new Map[] { mapFinalAnswersIsContent, mapFinalAnswersContent, mapQueAttempts, mapQueCorrectAttempts,
- mapQueIncorrectAttempts };
- }
-
- private static void addToAttemptMaps(Map mapAttemptOrderAttempts, Map mapAttemptOrderCorrectAttempts,
- Map mapAttemptOrderIncorrectAttempts, McUsrAttempt mcUsrAttempt) {
- String attemptOrderString = mcUsrAttempt.getAttemptOrder().toString();
-
- Map attemptMap = (Map) mapAttemptOrderAttempts.get(attemptOrderString);
- Map correctAttemptMap = (Map) mapAttemptOrderCorrectAttempts.get(attemptOrderString);
- Map incorrectAttemptMap = (Map) mapAttemptOrderIncorrectAttempts.get(attemptOrderString);
-
- if (attemptMap == null) {
- attemptMap = new TreeMap(new McComparator());
- mapAttemptOrderAttempts.put(attemptOrderString, attemptMap);
-
- correctAttemptMap = new TreeMap(new McComparator());
- mapAttemptOrderCorrectAttempts.put(attemptOrderString, correctAttemptMap);
-
- incorrectAttemptMap = new TreeMap(new McComparator());
- mapAttemptOrderIncorrectAttempts.put(attemptOrderString, incorrectAttemptMap);
- }
-
- int mapSize = attemptMap.size();
- String mapIndex = (new Integer(mapSize + 1)).toString();
- attemptMap.put(mapIndex, mcUsrAttempt.getMcOptionsContent().getMcQueOptionText());
- if (mcUsrAttempt.isAttemptCorrect()) {
- correctAttemptMap.put(mapIndex, mcUsrAttempt.getMcOptionsContent().getMcQueOptionText());
- } else {
- incorrectAttemptMap.put(mapIndex, mcUsrAttempt.getMcOptionsContent().getMcQueOptionText());
- }
-
- }
-
- /**
* Should we show the marks for each question - we show the marks if any of the questions have a mark > 1.
*/
public static Boolean isShowMarksOnQuestion(List listQuestionAndCandidateAnswersDTO) {
@@ -501,4 +108,6 @@
}
return Boolean.FALSE;
}
+
+
}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java
===================================================================
diff -u -r9a2c06691bf5157039ae82f36ec2f84c32eda8cb -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java (.../McLearningAction.java) (revision 9a2c06691bf5157039ae82f36ec2f84c32eda8cb)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java (.../McLearningAction.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -23,14 +23,12 @@
package org.lamsfoundation.lams.tool.mc.web;
import java.io.IOException;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
-import java.util.TreeSet;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
@@ -39,12 +37,9 @@
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
-import org.apache.struts.Globals;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
-import org.apache.struts.action.ActionMessage;
-import org.apache.struts.action.ActionMessages;
import org.lamsfoundation.lams.learning.web.util.LearningWebUtil;
import org.lamsfoundation.lams.notebook.model.NotebookEntry;
import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants;
@@ -54,7 +49,6 @@
import org.lamsfoundation.lams.tool.mc.McComparator;
import org.lamsfoundation.lams.tool.mc.McGeneralLearnerFlowDTO;
import org.lamsfoundation.lams.tool.mc.McLearnerAnswersDTO;
-import org.lamsfoundation.lams.tool.mc.McStringComparator;
import org.lamsfoundation.lams.tool.mc.McTempDataHolderDTO;
import org.lamsfoundation.lams.tool.mc.McUtils;
import org.lamsfoundation.lams.tool.mc.pojos.McContent;
@@ -72,33 +66,12 @@
import org.lamsfoundation.lams.web.util.SessionMap;
/**
- * *
- *
* @author Ozgur Demirtas
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
- *
*/
public class McLearningAction extends LamsDispatchAction implements McAppConstants {
- static Logger logger = Logger.getLogger(McLearningAction.class.getName());
+ private static Logger logger = Logger.getLogger(McLearningAction.class.getName());
+
+ private static IMcService mcService;
/**
* main content/question content management and workflow logic
@@ -128,55 +101,43 @@
public ActionForward displayMc(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
McLearningForm mcLearningForm = (McLearningForm) form;
- IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext());
+ if (mcService == null) {
+ mcService = McServiceProxy.getMcService(getServlet().getServletContext());
+ }
String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID);
mcLearningForm.setToolSessionID(toolSessionID);
- McSession mcSession = mcService.retrieveMcSession(new Long(toolSessionID));
+ McSession mcSession = mcService.getMcSessionById(new Long(toolSessionID));
String toolContentId = mcSession.getMcContent().getMcContentId().toString();
mcLearningForm.setToolContentID(toolContentId);
+
+ //setContentInUse
+ McContent mcContent = mcService.retrieveMc(new Long(toolContentId));
+ mcContent.setContentInUse(true);
+ mcService.saveMcContent(mcContent);
+
+ LearningUtil.saveFormRequestData(request, mcLearningForm, false);
if (mcLearningForm.getNextQuestionSelected() != null && !mcLearningForm.getNextQuestionSelected().equals("")) {
- LearningUtil.saveFormRequestData(request, mcLearningForm, false);
mcLearningForm.resetParameters();
- setContentInUse(request, toolContentId, mcService);
return getNextOptions(mapping, form, request, response);
}
-
if (mcLearningForm.getContinueOptionsCombined() != null) {
- LearningUtil.saveFormRequestData(request, mcLearningForm, false);
- setContentInUse(request, toolContentId, mcService);
return continueOptionsCombined(mapping, form, request, response);
} else if (mcLearningForm.getNextOptions() != null) {
- LearningUtil.saveFormRequestData(request, mcLearningForm, false);
- setContentInUse(request, toolContentId, mcService);
return getNextOptions(mapping, form, request, response);
} else if (mcLearningForm.getRedoQuestions() != null) {
- LearningUtil.saveFormRequestData(request, mcLearningForm, false);
- setContentInUse(request, toolContentId, mcService);
- return redoQuestions(mapping, form, request, response);
- } else if (mcLearningForm.getRedoQuestionsOk() != null) {
- LearningUtil.saveFormRequestData(request, mcLearningForm, false);
- setContentInUse(request, toolContentId, mcService);
return redoQuestions(request, mcLearningForm, mapping);
} else if (mcLearningForm.getViewAnswers() != null) {
- LearningUtil.saveFormRequestData(request, mcLearningForm, false);
- setContentInUse(request, toolContentId, mcService);
mcLearningForm.setLearnerProgress(new Boolean(false).toString());
return viewAnswers(mapping, mcLearningForm, request, response);
} else if (mcLearningForm.getSubmitReflection() != null) {
- LearningUtil.saveFormRequestData(request, mcLearningForm, false);
- setContentInUse(request, toolContentId, mcService);
return submitReflection(mapping, form, request, response);
} else if (mcLearningForm.getForwardtoReflection() != null) {
- LearningUtil.saveFormRequestData(request, mcLearningForm, false);
- setContentInUse(request, toolContentId, mcService);
return forwardtoReflection(mapping, form, request, response);
} else if (mcLearningForm.getLearnerFinished() != null) {
- LearningUtil.saveFormRequestData(request, mcLearningForm, false);
- setContentInUse(request, toolContentId, mcService);
return endLearning(mapping, form, request, response);
}
@@ -199,12 +160,14 @@
public ActionForward endLearning(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
McLearningForm mcLearningForm = (McLearningForm) form;
- IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext());
+ if (mcService == null) {
+ mcService = McServiceProxy.getMcService(getServlet().getServletContext());
+ }
String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID);
mcLearningForm.setToolSessionID(toolSessionID);
- McSession mcSession = mcService.retrieveMcSession(new Long(toolSessionID));
+ McSession mcSession = mcService.getMcSessionById(new Long(toolSessionID));
String toolContentId = mcSession.getMcContent().getMcContentId().toString();
mcLearningForm.setToolContentID(toolContentId);
@@ -241,229 +204,105 @@
}
McQueUsr mcQueUsr = mcService.getMcUserBySession(new Long(userID), mcSession.getUid());
-
- /* it is possible that mcQueUsr can be null if the content is set as runoffline and reflection is on */
- if (mcQueUsr == null) {
-
- UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER);
-
- String userName = toolUser.getLogin();
- String fullName = toolUser.getFirstName() + " " + toolUser.getLastName();
-
- Long userId = new Long(toolUser.getUserID().longValue());
-
- mcQueUsr = new McQueUsr(userId, userName, fullName, mcSession, new TreeSet());
- mcService.createMcQueUsr(mcQueUsr);
-
- mcService.createMcQueUsr(mcQueUsr);
- }
-
mcQueUsr.setResponseFinalised(true);
mcService.updateMcQueUsr(mcQueUsr);
response.sendRedirect(nextUrl);
return null;
}
-
+
/**
*
- *
- * @param learnerInput
- * @param mcContent
- * @param mcService
- * @return
*/
- protected Set parseLearnerInput(List learnerInput, McContent mcContent, IMcService mcService) {
+ protected List buildSelectedQuestionAndCandidateAnswersDTO(List learnerInput,
+ McTempDataHolderDTO mcTempDataHolderDTO, McContent content) {
- Set questionUids = new HashSet();
-
- Iterator listLearnerInputIterator = learnerInput.iterator();
- while (listLearnerInputIterator.hasNext()) {
- String input = (String) listLearnerInputIterator.next();
- int pos = input.indexOf("-");
- String questionUid = input.substring(0, pos);
- questionUids.add(questionUid);
- }
-
- List questionEntriesOrdered = mcService.getAllQuestionEntries(mcContent.getUid());
-
- Set questionOrderedUids = new TreeSet(new McComparator());
- Iterator questionEntriesOrderedIterator = questionEntriesOrdered.iterator();
- while (questionEntriesOrderedIterator.hasNext()) {
- McQueContent mcQueContent = (McQueContent) questionEntriesOrderedIterator.next();
-
- Iterator questionUidsIterator = questionUids.iterator();
- while (questionUidsIterator.hasNext()) {
- String questionUid = (String) questionUidsIterator.next();
-
- if (questionUid.equals(mcQueContent.getUid().toString())) {
- questionOrderedUids.add(questionUid);
- }
- }
- }
- return questionOrderedUids;
- }
-
- /**
- *
- *
- * @param learnerInput
- * @param mcTempDataHolderDTO
- * @param mcService
- * @param mcContent
- * @return
- */
- protected List buildSelectedQuestionAndCandidateAnswersDTO(List learnerInput,
- McTempDataHolderDTO mcTempDataHolderDTO, IMcService mcService, McContent mcContent) {
-
- int learnerMarks = 0;
+ int learnerMark = 0;
int totalMarksPossible = 0;
- Set questionUids = parseLearnerInput(learnerInput, mcContent, mcService);
+ List questionAndCandidateAnswersList = new LinkedList();
- List questionAndCandidateAnswersList = new LinkedList();
-
- Iterator questionIterator = mcContent.getMcQueContents().iterator();
- while (questionIterator.hasNext()) {
- McQueContent mcQueContent = (McQueContent) questionIterator.next();
- String currentQuestionUid = mcQueContent.getUid().toString();
- int currentMark = mcQueContent.getMark().intValue();
+ for (McQueContent question : (Set)content.getMcQueContents()) {
+ String questionUid = question.getUid().toString();
+ int currentMark = question.getMark().intValue();
totalMarksPossible += currentMark;
McLearnerAnswersDTO mcLearnerAnswersDTO = new McLearnerAnswersDTO();
- mcLearnerAnswersDTO.setQuestion(mcQueContent.getQuestion());
- mcLearnerAnswersDTO.setDisplayOrder(mcQueContent.getDisplayOrder().toString());
- mcLearnerAnswersDTO.setQuestionUid(mcQueContent.getUid());
- mcLearnerAnswersDTO.setFeedback(mcQueContent.getFeedback() != null ? mcQueContent.getFeedback() : "");
+ mcLearnerAnswersDTO.setQuestion(question.getQuestion());
+ mcLearnerAnswersDTO.setDisplayOrder(question.getDisplayOrder().toString());
+ mcLearnerAnswersDTO.setQuestionUid(question.getUid());
+ mcLearnerAnswersDTO.setFeedback(question.getFeedback() != null ? question.getFeedback() : "");
- Map caMap = new TreeMap(new McStringComparator());
- List caIds = new LinkedList();
- long mapIndex = new Long(1);
-
- Iterator listLearnerInputIterator = learnerInput.iterator();
- while (listLearnerInputIterator.hasNext()) {
- String input = (String) listLearnerInputIterator.next();
+ //search for according answer
+ McOptsContent answerOption = null;
+ for (String input : learnerInput) {
int pos = input.indexOf("-");
- String localQuestionUid = input.substring(0, pos);
+ String inputQuestionUid = input.substring(0, pos);
- if (currentQuestionUid.equals(localQuestionUid)) {
- String caUid = input.substring(pos + 1);
- McOptsContent mcOptsContent = mcQueContent.getOptionsContentByUID(new Long(caUid));
- String mapIndexAsString = new Long(mapIndex).toString();
- caMap.put(mapIndexAsString, mcOptsContent.getMcQueOptionText());
- caIds.add(caUid);
- mapIndex++;
+ if (questionUid.equals(inputQuestionUid)) {
+ String answerOptionUid = input.substring(pos + 1);
+ answerOption = question.getOptionsContentByUID(new Long(answerOptionUid));
+ mcLearnerAnswersDTO.setAnswerOption(answerOption);
+ break;
}
}
- mcLearnerAnswersDTO.setCandidateAnswers(caMap);
- List correctOptions = mcService.getPersistedSelectedOptions(mcQueContent.getUid());
- boolean compareResult = LearningUtil.isQuestionCorrect(correctOptions, caIds);
- mcLearnerAnswersDTO.setAttemptCorrect(new Boolean(compareResult).toString());
- if (compareResult) {
- mcLearnerAnswersDTO.setFeedbackCorrect(mcQueContent.getFeedback());
+ boolean isCorrect = (answerOption != null) && answerOption.isCorrectOption();
+ mcLearnerAnswersDTO.setAttemptCorrect(new Boolean(isCorrect).toString());
+ if (isCorrect) {
+ mcLearnerAnswersDTO.setFeedbackCorrect(question.getFeedback());
mcLearnerAnswersDTO.setMark(new Integer(currentMark));
- learnerMarks += currentMark;
+ learnerMark += currentMark;
} else {
- mcLearnerAnswersDTO.setFeedbackIncorrect(mcQueContent.getFeedback());
+ mcLearnerAnswersDTO.setFeedbackIncorrect(question.getFeedback());
mcLearnerAnswersDTO.setMark(new Integer(0));
}
questionAndCandidateAnswersList.add(mcLearnerAnswersDTO);
- }// end question iterator
+ }
- mcTempDataHolderDTO.setLearnerMark(new Integer(learnerMarks));
+ mcTempDataHolderDTO.setLearnerMark(new Integer(learnerMark));
mcTempDataHolderDTO.setTotalMarksPossible(new Integer(totalMarksPossible));
return questionAndCandidateAnswersList;
}
/**
* responses to learner when they answer all the questions on a single page
- *
- * @param request
- * @param form
- * @param mapping
- * @return ActionForward
*/
public ActionForward continueOptionsCombined(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
McLearningForm mcLearningForm = (McLearningForm) form;
- IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext());
+ if (mcService == null) {
+ mcService = McServiceProxy.getMcService(getServlet().getServletContext());
+ }
String httpSessionID = mcLearningForm.getHttpSessionID();
+ SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
-
String questionListingMode = mcLearningForm.getQuestionListingMode();
- List learnerInput = new LinkedList();
+ List learnerInput = McLearningAction.parseLearnerAnswers(mcLearningForm, request);
+
if (questionListingMode.equals(McAppConstants.QUESTION_LISTING_MODE_SEQUENTIAL)) {
-
- List sequentialCheckedCa = (List) sessionMap.get(McAppConstants.QUESTION_AND_CANDIDATE_ANSWERS_KEY);
-
- Iterator sequentialCheckedCaIterator = sequentialCheckedCa.iterator();
-
- while (sequentialCheckedCaIterator.hasNext()) {
- String input = (String) sequentialCheckedCaIterator.next();
- }
-
- /* checkedCa refers to candidate answers */
- String[] checkedCa = mcLearningForm.getCheckedCa();
-
- if (checkedCa != null) {
- mcLearningForm.resetCa(mapping, request);
-
- for (int i = 0; i < checkedCa.length; i++) {
- String currentCa = checkedCa[i];
- sequentialCheckedCa.add(currentCa);
- }
- }
-
- sequentialCheckedCaIterator = sequentialCheckedCa.iterator();
-
- while (sequentialCheckedCaIterator.hasNext()) {
- String input = (String) sequentialCheckedCaIterator.next();
- }
-
- sessionMap.put(McAppConstants.QUESTION_AND_CANDIDATE_ANSWERS_KEY, sequentialCheckedCa);
- request.getSession().setAttribute(httpSessionID, sessionMap);
-
- learnerInput = sequentialCheckedCa;
-
- } else {
- Map parameters = request.getParameterMap();
- Iterator iter = parameters.keySet().iterator();
- while (iter.hasNext()) {
- String key = (String) iter.next();
- if (key.startsWith("checkedCa")) {
- String currentCheckedCa = request.getParameter(key);
- if (currentCheckedCa != null) {
- learnerInput.add(currentCheckedCa);
- }
- }
- }
-
- mcLearningForm.resetCa(mapping, request);
+ sessionMap.put(McAppConstants.QUESTION_AND_CANDIDATE_ANSWERS_KEY, learnerInput);
}
+
+ mcLearningForm.resetCa(mapping, request);
String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID);
-
- McSession mcSession = mcService.retrieveMcSession(new Long(toolSessionID));
-
+ McSession mcSession = mcService.getMcSessionById(new Long(toolSessionID));
String toolContentId = mcSession.getMcContent().getMcContentId().toString();
-
/* process the answers */
McContent mcContent = mcService.retrieveMc(new Long(toolContentId));
McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO = LearningUtil.buildMcGeneralLearnerFlowDTO(mcContent);
McTempDataHolderDTO mcTempDataHolderDTO = new McTempDataHolderDTO();
-
- List selectedQuestionAndCandidateAnswersDTO = buildSelectedQuestionAndCandidateAnswersDTO(learnerInput,
- mcTempDataHolderDTO, mcService, mcContent);
+ List selectedQuestionAndCandidateAnswersDTO = buildSelectedQuestionAndCandidateAnswersDTO(
+ learnerInput, mcTempDataHolderDTO, mcContent);
request.setAttribute(McAppConstants.LIST_SELECTED_QUESTION_CANDIDATEANSWERS_DTO,
selectedQuestionAndCandidateAnswersDTO);
@@ -476,46 +315,21 @@
mcGeneralLearnerFlowDTO.setTotalMarksPossible(mcTempDataHolderDTO.getTotalMarksPossible());
request.getSession().setAttribute(httpSessionID, sessionMap);
-
- Long toolSessionUid = mcSession.getUid();
-
- boolean isUserDefined = false;
-
- String userID = "";
+
HttpSession ss = SessionManager.getSession();
+ UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ String userID = user.getUserID().toString();
+ McQueUsr mcQueUsr = mcService.getMcUserBySession(new Long(userID), mcSession.getUid());
- if (ss != null) {
- UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
- if (user != null && user.getUserID() != null) {
- userID = user.getUserID().toString();
- }
- }
-
- McQueUsr existingMcQueUsr = mcService.getMcUserBySession(new Long(userID), mcSession.getUid());
-
- if (existingMcQueUsr != null) {
- isUserDefined = true;
- }
-
- McQueUsr mcQueUsr = null;
- if (isUserDefined == false) {
- mcQueUsr = LearningUtil.createUser(request, mcService, new Long(toolSessionID));
- } else {
- mcQueUsr = existingMcQueUsr;
- }
-
- Integer currentHighestAttemptOrder = mcQueUsr.getLastAttemptOrder();
- int newHighestAttempOrder = currentHighestAttemptOrder != null ? currentHighestAttemptOrder.intValue() + 1 : 1;
-
// Have to work out in advance if passed so that we can store it against the attempts
boolean passed = mcQueUsr.isMarkPassed(learnerMark);
mcGeneralLearnerFlowDTO.setUserOverPassMark(new Boolean(passed).toString());
mcGeneralLearnerFlowDTO.setPassMarkApplicable(new Boolean(mcContent.getPassMark() != null).toString());
- LearningUtil.createLearnerAttempt(request, mcQueUsr, selectedQuestionAndCandidateAnswersDTO, passed,
- newHighestAttempOrder, null, mcService);
+ mcService.saveUserAttempt(mcQueUsr, selectedQuestionAndCandidateAnswersDTO);
- mcQueUsr.setLastAttemptOrder(newHighestAttempOrder);
+ Integer numberOfAttempts = mcQueUsr.getNumberOfAttempts() + 1;
+ mcQueUsr.setNumberOfAttempts(numberOfAttempts);
mcQueUsr.setLastAttemptTotalMark(learnerMark);
mcService.updateMcQueUsr(mcQueUsr);
@@ -528,14 +342,11 @@
mcGeneralLearnerFlowDTO.setLowestMark(markStatistics[1]);
mcGeneralLearnerFlowDTO.setAverageMark(markStatistics[2]);
} else {
- Integer zero = new Integer(0);
- mcGeneralLearnerFlowDTO.setTopMark(zero);
- mcGeneralLearnerFlowDTO.setLowestMark(zero);
- mcGeneralLearnerFlowDTO.setAverageMark(zero);
+ mcGeneralLearnerFlowDTO.setTopMark(0);
+ mcGeneralLearnerFlowDTO.setLowestMark(0);
+ mcGeneralLearnerFlowDTO.setAverageMark(0);
}
- Map mapQuestionMarks = LearningUtil.buildMarksMap(request, mcContent.getMcContentId(), mcService);
-
mcGeneralLearnerFlowDTO.setReflection(new Boolean(mcContent.isReflect()).toString());
String reflectionSubject = McUtils.replaceNewLines(mcContent.getReflectionSubject());
@@ -559,58 +370,39 @@
public ActionForward getNextOptions(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
McLearningForm mcLearningForm = (McLearningForm) form;
- IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext());
-
- String questionIndex = mcLearningForm.getQuestionIndex();
-
- String httpSessionID = mcLearningForm.getHttpSessionID();
-
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
-
- List sequentialCheckedCa = (List) sessionMap.get(McAppConstants.QUESTION_AND_CANDIDATE_ANSWERS_KEY);
-
- Iterator sequentialCheckedCaIterator = sequentialCheckedCa.iterator();
- while (sequentialCheckedCaIterator.hasNext()) {
- String input = (String) sequentialCheckedCaIterator.next();
+ if (mcService == null) {
+ mcService = McServiceProxy.getMcService(getServlet().getServletContext());
}
-
- /* checkedCa refers to candidate answers */
- String[] checkedCa = mcLearningForm.getCheckedCa();
-
- if (checkedCa != null) {
- mcLearningForm.resetCa(mapping, request);
-
- for (int i = 0; i < checkedCa.length; i++) {
- String currentCa = checkedCa[i];
- sequentialCheckedCa.add(currentCa);
- }
- }
-
- sequentialCheckedCaIterator = sequentialCheckedCa.iterator();
- while (sequentialCheckedCaIterator.hasNext()) {
- String input = (String) sequentialCheckedCaIterator.next();
- }
-
- sessionMap.put(McAppConstants.QUESTION_AND_CANDIDATE_ANSWERS_KEY, sequentialCheckedCa);
- request.getSession().setAttribute(httpSessionID, sessionMap);
-
String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID);
-
- McSession mcSession = mcService.retrieveMcSession(new Long(toolSessionID));
-
+ McSession mcSession = mcService.getMcSessionById(new Long(toolSessionID));
String toolContentId = mcSession.getMcContent().getMcContentId().toString();
-
McContent mcContent = mcService.retrieveMc(new Long(toolContentId));
+
+ HttpSession ss = SessionManager.getSession();
+ UserDTO userDto = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ String userID = userDto.getUserID().toString();
+ McQueUsr user = mcService.getMcUserBySession(new Long(userID), mcSession.getUid());
- boolean randomize = mcContent.isRandomize();
+ String httpSessionID = mcLearningForm.getHttpSessionID();
+ SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
+
+ //parse learner input
+ List learnerInput = McLearningAction.parseLearnerAnswers(mcLearningForm, request);
+ sessionMap.put(McAppConstants.QUESTION_AND_CANDIDATE_ANSWERS_KEY, learnerInput);
+
+ //save user attempt
+ List selectedQuestionAndCandidateAnswersDTO = buildSelectedQuestionAndCandidateAnswersDTO(
+ learnerInput, new McTempDataHolderDTO(), mcContent);
+ mcService.saveUserAttempt(user, selectedQuestionAndCandidateAnswersDTO);
- List listQuestionAndCandidateAnswersDTO = LearningUtil.buildQuestionAndCandidateAnswersDTO(request, mcContent,
- randomize, mcService);
- request.setAttribute(McAppConstants.LIST_QUESTION_CANDIDATEANSWERS_DTO, listQuestionAndCandidateAnswersDTO);
+ McQueUsr mcQueUsr = getCurrentUser(toolSessionID);
+ List learnerAnswersDTOList = mcService.buildLearnerAnswersDTOList(mcContent, mcQueUsr);
+ request.setAttribute(McAppConstants.LEARNER_ANSWERS_DTO_LIST, learnerAnswersDTOList);
McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO = LearningUtil.buildMcGeneralLearnerFlowDTO(mcContent);
Integer totalQuestionCount = mcGeneralLearnerFlowDTO.getTotalQuestionCount();
+ String questionIndex = mcLearningForm.getQuestionIndex();
Integer intQuestionIndex = new Integer(questionIndex);
if (totalQuestionCount.equals(intQuestionIndex)) {
mcGeneralLearnerFlowDTO.setTotalCountReached(new Boolean(true).toString());
@@ -635,109 +427,22 @@
}
/**
- *
- * redoQuestions(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
- *
- * allows the learner to take the activity again
- *
- * @param request
- * @param form
- * @param mapping
- * @return ActionForward
+ * prepareViewAnswersData
*/
- public ActionForward redoQuestions(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) throws IOException, ServletException {
- McLearningForm mcLearningForm = (McLearningForm) form;
- IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext());
-
- String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID);
-
- McSession mcSession = mcService.retrieveMcSession(new Long(toolSessionID));
-
- String toolContentId = mcSession.getMcContent().getMcContentId().toString();
- McContent mcContent = mcService.retrieveMc(new Long(toolContentId));
-
- boolean randomize = mcContent.isRandomize();
-
- List listQuestionAndCandidateAnswersDTO = LearningUtil.buildQuestionAndCandidateAnswersDTO(request, mcContent,
- randomize, mcService);
- request.setAttribute(McAppConstants.LIST_QUESTION_CANDIDATEANSWERS_DTO, listQuestionAndCandidateAnswersDTO);
-
- McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO = LearningUtil.buildMcGeneralLearnerFlowDTO(mcContent);
- mcGeneralLearnerFlowDTO.setCurrentQuestionIndex(new Integer(1));
- mcGeneralLearnerFlowDTO.setTotalCountReached(new Boolean(false).toString());
-
- /* use existing session to extract PASSMARK_APPLICABLE and USER_OVER_PASSMARK */
- String httpSessionID = mcLearningForm.getHttpSessionID();
-
- /* create a new session */
- SessionMap sessionMap = new SessionMap();
- List sequentialCheckedCa = new LinkedList();
- sessionMap.put(McAppConstants.QUESTION_AND_CANDIDATE_ANSWERS_KEY, sequentialCheckedCa);
- request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap);
- mcLearningForm.setHttpSessionID(sessionMap.getSessionID());
-
- String userID = "";
- HttpSession ss = SessionManager.getSession();
-
- if (ss != null) {
- UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
- if (user != null && user.getUserID() != null) {
- userID = user.getUserID().toString();
- }
- }
-
- McQueUsr mcQueUsr = mcService.getMcUserBySession(new Long(userID), mcSession.getUid());
-
- mcGeneralLearnerFlowDTO.setLatestAttemptMark(mcQueUsr.getLastAttemptTotalMark());
-
- String passMarkApplicable = new Boolean(mcContent.isPassMarkApplicable()).toString();
- mcGeneralLearnerFlowDTO.setPassMarkApplicable(passMarkApplicable);
- mcLearningForm.setPassMarkApplicable(passMarkApplicable);
-
- String userOverPassMark = new Boolean(mcQueUsr.isLastAttemptMarkPassed()).toString();
- mcGeneralLearnerFlowDTO.setUserOverPassMark(userOverPassMark);
- mcLearningForm.setUserOverPassMark(userOverPassMark);
-
- mcGeneralLearnerFlowDTO.setReflection(new Boolean(mcContent.isReflect()).toString());
-
- String reflectionSubject = McUtils.replaceNewLines(mcContent.getReflectionSubject());
- mcGeneralLearnerFlowDTO.setReflectionSubject(reflectionSubject);
-
- mcGeneralLearnerFlowDTO.setRetries(new Boolean(mcContent.isRetries()).toString());
-
- mcGeneralLearnerFlowDTO.setTotalMarksPossible(mcContent.getTotalMarksPossible());
-
- request.setAttribute(McAppConstants.MC_GENERAL_LEARNER_FLOW_DTO, mcGeneralLearnerFlowDTO);
-
- LearningWebUtil.putActivityPositionInRequestByToolSessionId(new Long(toolSessionID), request, getServlet()
- .getServletContext());
-
- return mapping.findForward(McAppConstants.REDO_QUESTIONS);
- }
-
- /**
- * void prepareViewAnswersData(ActionMapping mapping, McLearningForm mcLearningForm, HttpServletRequest request,
- * HttpServletResponse response)
- *
- * @param mapping
- * @param mcLearningForm
- * @param request
- * @param response
- */
public void prepareViewAnswersData(ActionMapping mapping, McLearningForm mcLearningForm,
HttpServletRequest request, ServletContext servletContext) {
// may have to get service from the form - if class has been created by starter action, rather than by struts
- IMcService mcService = null;
- if (getServlet() != null) {
- mcService = McServiceProxy.getMcService(getServlet().getServletContext());
- } else {
- mcService = mcLearningForm.getMcService();
+ if (mcService == null) {
+ if (getServlet() != null) {
+ mcService = McServiceProxy.getMcService(getServlet().getServletContext());
+ } else {
+ mcService = mcLearningForm.getMcService();
+ }
}
String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID);
- McSession mcSession = mcService.retrieveMcSession(new Long(toolSessionID));
+ McSession mcSession = mcService.getMcSessionById(new Long(toolSessionID));
String toolContentId = mcSession.getMcContent().getMcContentId().toString();
McContent mcContent = mcService.retrieveMc(new Long(toolContentId));
@@ -769,21 +474,27 @@
McQueUsr mcQueUsr = null;
if (learnerProgressOn.equals(Boolean.FALSE)) {
- mcQueUsr = LearningUtil.getUser(request, mcService, toolSessionID);
+ mcQueUsr = getCurrentUser(toolSessionID);
} else {
mcQueUsr = mcService.getMcUserBySession(new Long(learnerProgressUserId), mcSession.getUid());
}
Long toolContentUID = mcContent.getUid();
- Map[] attemptMaps = LearningUtil.getAttemptMapsForUser(mcContent.getMcQueContents().size(), toolContentUID,
- mcContent.isRetries(), mcService, mcQueUsr);
- mcGeneralLearnerFlowDTO.setMapFinalAnswersIsContent(attemptMaps[0]);
- mcGeneralLearnerFlowDTO.setMapFinalAnswersContent(attemptMaps[1]);
- mcGeneralLearnerFlowDTO.setMapQueAttempts(attemptMaps[2]);
- mcGeneralLearnerFlowDTO.setMapQueCorrectAttempts(attemptMaps[3]);
- mcGeneralLearnerFlowDTO.setMapQueIncorrectAttempts(attemptMaps[4]);
+ //create attemptMap for displaying on jsp
+ Map attemptMap = new TreeMap(new McComparator());
+ for (int i = 1; i <= mcContent.getMcQueContents().size(); i++) {
+ McQueContent question = mcService.getQuestionByDisplayOrder(new Long(i), toolContentUID);
+ McUsrAttempt userAttempt = mcService.getUserAttemptByQuestion(mcQueUsr.getUid(),
+ question.getUid());
+
+ if (userAttempt != null) {
+ attemptMap.put(new Integer(i).toString(), userAttempt);
+ }
+ }
+ mcGeneralLearnerFlowDTO.setAttemptMap(attemptMap);
+
mcGeneralLearnerFlowDTO.setReflection(new Boolean(mcContent.isReflect()).toString());
String reflectionSubject = McUtils.replaceNewLines(mcContent.getReflectionSubject());
mcGeneralLearnerFlowDTO.setReflectionSubject(reflectionSubject);
@@ -835,47 +546,27 @@
}
/**
- * indicates that some learners are using the content
*
- * @param request
- * @param toolContentId
- * @param mcService
*/
- protected void setContentInUse(HttpServletRequest request, String toolContentId, IMcService mcService) {
-
- McContent mcContent = mcService.retrieveMc(new Long(toolContentId));
- mcContent.setContentInUse(true);
- mcService.saveMcContent(mcContent);
- }
-
- /**
- *
- *
- * @param request
- * @param mcLearningForm
- * @param mapping
- * @return
- */
public ActionForward redoQuestions(HttpServletRequest request, McLearningForm mcLearningForm, ActionMapping mapping) {
- IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext());
-
- /* reset the checked options MAP */
- Map mapGeneralCheckedOptionsContent = new TreeMap(new McComparator());
-
+ if (mcService == null) {
+ mcService = McServiceProxy.getMcService(getServlet().getServletContext());
+ }
String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID);
-
- McSession mcSession = mcService.retrieveMcSession(new Long(toolSessionID));
-
+ McSession mcSession = mcService.getMcSessionById(new Long(toolSessionID));
String toolContentId = mcSession.getMcContent().getMcContentId().toString();
-
McContent mcContent = mcService.retrieveMc(new Long(toolContentId));
+ McQueUsr mcQueUsr = getCurrentUser(toolSessionID);
+
+ //clear sessionMap
+ String httpSessionID = mcLearningForm.getHttpSessionID();
+ SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
+ List sequentialCheckedCa = new LinkedList();
+ sessionMap.put(McAppConstants.QUESTION_AND_CANDIDATE_ANSWERS_KEY, sequentialCheckedCa);
+
+ List learnerAnswersDTOList = mcService.buildLearnerAnswersDTOList(mcContent, mcQueUsr);
+ request.setAttribute(McAppConstants.LEARNER_ANSWERS_DTO_LIST, learnerAnswersDTOList);
- boolean randomize = mcContent.isRandomize();
-
- List listQuestionAndCandidateAnswersDTO = LearningUtil
- .buildQuestionAndCandidateAnswersDTO(request, mcContent, randomize, mcService);
- request.setAttribute(McAppConstants.LIST_QUESTION_CANDIDATEANSWERS_DTO, listQuestionAndCandidateAnswersDTO);
-
McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO = LearningUtil.buildMcGeneralLearnerFlowDTO(mcContent);
mcGeneralLearnerFlowDTO.setQuestionIndex(new Integer(1));
@@ -898,26 +589,14 @@
// should we show the marks for each question - we show the marks if any of the questions
// have a mark > 1.
- Boolean showMarks = LearningUtil.isShowMarksOnQuestion(listQuestionAndCandidateAnswersDTO);
+ Boolean showMarks = LearningUtil.isShowMarksOnQuestion(learnerAnswersDTOList);
mcGeneralLearnerFlowDTO.setShowMarks(showMarks.toString());
-
+
request.setAttribute(McAppConstants.MC_GENERAL_LEARNER_FLOW_DTO, mcGeneralLearnerFlowDTO);
return mapping.findForward(McAppConstants.LOAD_LEARNER);
}
/**
- * persists error messages to request scope
- *
- * @param request
- * @param message
- */
- public void persistError(HttpServletRequest request, String message) {
- ActionMessages errors = new ActionMessages();
- errors.add(Globals.ERROR_KEY, new ActionMessage(message));
- saveErrors(request, errors);
- }
-
- /**
* submitReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse
* response)
*
@@ -934,7 +613,9 @@
HttpServletResponse response) throws IOException, ServletException, ToolException {
McLearningForm mcLearningForm = (McLearningForm) form;
- IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext());
+ if (mcService == null) {
+ mcService = McServiceProxy.getMcService(getServlet().getServletContext());
+ }
String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID);
mcLearningForm.setToolSessionID(toolSessionID);
@@ -943,27 +624,6 @@
mcLearningForm.setUserID(userID);
String reflectionEntry = request.getParameter(McAppConstants.ENTRY_TEXT);
-
- McSession mcSession = mcService.retrieveMcSession(new Long(toolSessionID));
-
- McQueUsr mcQueUsr = mcService.getMcUserBySession(new Long(userID), mcSession.getUid());
-
- /* it is possible that mcQueUsr can be null if the content is set as runoffline and reflection is on */
- if (mcQueUsr == null) {
- // attempt creating user record since it must exist for the runOffline + reflection screens
- HttpSession ss = SessionManager.getSession();
-
- UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER);
-
- String userName = toolUser.getLogin();
- String fullName = toolUser.getFirstName() + " " + toolUser.getLastName();
-
- Long userId = new Long(toolUser.getUserID().longValue());
-
- mcQueUsr = new McQueUsr(userId, userName, fullName, mcSession, new TreeSet());
- mcService.createMcQueUsr(mcQueUsr);
- mcService.createMcQueUsr(mcQueUsr);
- }
NotebookEntry notebookEntry = mcService.getEntry(new Long(toolSessionID), CoreNotebookConstants.NOTEBOOK_TOOL,
McAppConstants.MY_SIGNATURE, new Integer(userID));
@@ -993,11 +653,13 @@
public ActionForward forwardtoReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException, ToolException {
McLearningForm mcLearningForm = (McLearningForm) form;
- IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext());
+ if (mcService == null) {
+ mcService = McServiceProxy.getMcService(getServlet().getServletContext());
+ }
String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID);
- McSession mcSession = mcService.retrieveMcSession(new Long(toolSessionID));
+ McSession mcSession = mcService.getMcSessionById(new Long(toolSessionID));
McContent mcContent = mcSession.getMcContent();
@@ -1032,5 +694,90 @@
return mapping.findForward(McAppConstants.NOTEBOOK);
}
+
+ /**
+ * auto saves responses
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ * @throws IOException
+ * @throws ServletException
+ */
+ public ActionForward autoSaveAnswers(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws IOException, ServletException {
+ if (mcService == null) {
+ mcService = McServiceProxy.getMcService(getServlet().getServletContext());
+ }
+ McLearningForm mcLearningForm = (McLearningForm) form;
+ String toolSessionID = request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID);
+ McSession mcSession = mcService.getMcSessionById(new Long(toolSessionID));
+ McContent mcContent = mcSession.getMcContent();
+
+ HttpSession ss = SessionManager.getSession();
+ UserDTO userDto = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ String userID = userDto.getUserID().toString();
+ McQueUsr user = mcService.getMcUserBySession(new Long(userID), mcSession.getUid());
+ List learnerInput = McLearningAction.parseLearnerAnswers(mcLearningForm, request);
+
+ List selectedQuestionAndCandidateAnswersDTO = buildSelectedQuestionAndCandidateAnswersDTO(
+ learnerInput, new McTempDataHolderDTO(), mcContent);
+ mcService.saveUserAttempt(user, selectedQuestionAndCandidateAnswersDTO);
+
+ return null;
+ }
+
+ private static List parseLearnerAnswers(McLearningForm mcLearningForm, HttpServletRequest request) {
+ String httpSessionID = mcLearningForm.getHttpSessionID();
+ SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(httpSessionID);
+
+ String questionListingMode = mcLearningForm.getQuestionListingMode();
+
+ List learnerInput = new LinkedList();
+ if (questionListingMode.equals(McAppConstants.QUESTION_LISTING_MODE_SEQUENTIAL)) {
+
+ List previousLearnerInput = (List) sessionMap.get(McAppConstants.QUESTION_AND_CANDIDATE_ANSWERS_KEY);
+ learnerInput.addAll(previousLearnerInput);
+
+ /* checkedCa refers to candidate answers */
+ String[] checkedCa = mcLearningForm.getCheckedCa();
+
+ if (checkedCa != null) {
+ for (int i = 0; i < checkedCa.length; i++) {
+ String currentCa = checkedCa[i];
+ learnerInput.add(currentCa);
+ }
+ }
+
+ } else {
+ Map parameters = request.getParameterMap();
+ Iterator iter = parameters.keySet().iterator();
+ while (iter.hasNext()) {
+ String key = (String) iter.next();
+ if (key.startsWith("checkedCa")) {
+ String currentCheckedCa = request.getParameter(key);
+ if (currentCheckedCa != null) {
+ learnerInput.add(currentCheckedCa);
+ }
+ }
+ }
+ }
+
+ return learnerInput;
+ }
+
+ private McQueUsr getCurrentUser(String toolSessionId) {
+ McSession mcSession = mcService.getMcSessionById(new Long(toolSessionId));
+
+ // get back login user DTO
+ HttpSession ss = SessionManager.getSession();
+ UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ Long userId = new Long(toolUser.getUserID().longValue());
+
+ return mcService.getMcUserBySession(userId, mcSession.getUid());
+ }
+
}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java
===================================================================
diff -u -r8ddb4345fdfc8904e5a7ff156cc63053e63741ca -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java (.../McLearningForm.java) (revision 8ddb4345fdfc8904e5a7ff156cc63053e63741ca)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java (.../McLearningForm.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -41,7 +41,6 @@
protected String redoQuestions;
protected String viewAnswers;
protected String learnerFinished;
- protected String redoQuestionsOk;
protected String donePreview;
protected String doneLearnerProgress;
protected String submitReflection;
@@ -87,7 +86,6 @@
this.setContinueOptionsCombined(null);
this.setRedoQuestions(null);
this.setViewAnswers(null);
- this.setRedoQuestionsOk(null);
this.setLearnerFinished(null);
this.setDonePreview(null);
this.setDoneLearnerProgress(null);
@@ -156,23 +154,8 @@
public void setViewAnswers(String viewAnswers) {
this.viewAnswers = viewAnswers;
}
-
+
/**
- * @return Returns the redoQuestionsOk.
- */
- public String getRedoQuestionsOk() {
- return redoQuestionsOk;
- }
-
- /**
- * @param redoQuestionsOk
- * The redoQuestionsOk to set.
- */
- public void setRedoQuestionsOk(String redoQuestionsOk) {
- this.redoQuestionsOk = redoQuestionsOk;
- }
-
- /**
* @return Returns the nextOptions.
*/
public String getNextOptions() {
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java
===================================================================
diff -u -r8d08470e039ba4617cee1068b9f5946e680c1121 -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java (.../McLearningStarterAction.java) (revision 8d08470e039ba4617cee1068b9f5946e680c1121)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java (.../McLearningStarterAction.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -26,9 +26,7 @@
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
import java.util.TimeZone;
-import java.util.TreeMap;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -45,9 +43,9 @@
import org.apache.struts.action.ActionMessages;
import org.lamsfoundation.lams.notebook.model.NotebookEntry;
import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants;
+import org.lamsfoundation.lams.tool.ToolAccessMode;
import org.lamsfoundation.lams.tool.mc.McAppConstants;
import org.lamsfoundation.lams.tool.mc.McApplicationException;
-import org.lamsfoundation.lams.tool.mc.McComparator;
import org.lamsfoundation.lams.tool.mc.McGeneralLearnerFlowDTO;
import org.lamsfoundation.lams.tool.mc.McLearnerAnswersDTO;
import org.lamsfoundation.lams.tool.mc.McLearnerStarterDTO;
@@ -59,100 +57,33 @@
import org.lamsfoundation.lams.tool.mc.service.McServiceProxy;
import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
import org.lamsfoundation.lams.util.DateUtil;
+import org.lamsfoundation.lams.util.WebUtil;
import org.lamsfoundation.lams.web.session.SessionManager;
import org.lamsfoundation.lams.web.util.AttributeNames;
import org.lamsfoundation.lams.web.util.SessionMap;
/**
+ * Note: Because of MCQ's learning reporting structure, Show Learner Report is always ON even if in authoring it is set
+ * to false.
*
* @author Ozgur Demirtas
- *
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- *
*/
-
-/**
- *
- * Note: Because of MCQ's learning reporting structure, Show Learner Report is always ON even if in authoring it is set
- * to false.
- */
public class McLearningStarterAction extends Action implements McAppConstants {
- static Logger logger = Logger.getLogger(McLearningStarterAction.class.getName());
+
+ private static Logger logger = Logger.getLogger(McLearningStarterAction.class.getName());
+
+ private static IMcService mcService;
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException, McApplicationException {
- /*
- * By now, the passed tool session id MUST exist in the db through the calling of: public void
- * createToolSession(Long toolSessionId, Long toolContentId) by the container.
- *
- * make sure this session exists in tool's session table by now.
- */
-
McUtils.cleanUpSessionAbsolute(request);
- Map mapQuestionsContent = new TreeMap(new McComparator());
- Map mapAnswers = new TreeMap(new McComparator());
+ if (mcService == null) {
+ mcService = McServiceProxy.getMcService(getServlet().getServletContext());
+ }
- IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext());
-
McLearningForm mcLearningForm = (McLearningForm) form;
mcLearningForm.setMcService(mcService);
mcLearningForm.setPassMarkApplicable(new Boolean(false).toString());
@@ -163,8 +94,8 @@
return validateParameters;
}
- SessionMap sessionMap = new SessionMap();
- List sequentialCheckedCa = new LinkedList();
+ SessionMap sessionMap = new SessionMap();
+ List sequentialCheckedCa = new LinkedList();
sessionMap.put(McAppConstants.QUESTION_AND_CANDIDATE_ANSWERS_KEY, sequentialCheckedCa);
request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap);
mcLearningForm.setHttpSessionID(sessionMap.getSessionID());
@@ -177,7 +108,7 @@
* retrieve it and the relavent content
*/
- McSession mcSession = mcService.retrieveMcSession(new Long(toolSessionID));
+ McSession mcSession = mcService.getMcSessionById(new Long(toolSessionID));
if (mcSession == null) {
McUtils.cleanUpSessionAbsolute(request);
@@ -231,17 +162,53 @@
return mapping.findForward(McAppConstants.RUN_OFFLINE);
}
}
+
+ String mode = request.getParameter(McAppConstants.MODE);
+ McQueUsr user = null;
+ if ((mode != null) && mode.equals(ToolAccessMode.TEACHER.toString())) {
+ // monitoring mode - user is specified in URL
+ // user may be null if the user was force completed.
+ user = getSpecifiedUser(toolSessionID, WebUtil.readIntParam(request, AttributeNames.PARAM_USER_ID, false));
+ } else {
+ user = getCurrentUser(toolSessionID);
+ }
/*
* Is the tool activity been checked as Run Offline in the property inspector?
*/
mcLearnerStarterDTO.setToolActivityOffline(new Boolean(mcContent.isRunOffline()).toString());
mcLearnerStarterDTO.setActivityTitle(mcContent.getTitle());
request.setAttribute(McAppConstants.MC_LEARNER_STARTER_DTO, mcLearnerStarterDTO);
-
mcLearningForm.setToolContentID(mcContent.getMcContentId().toString());
- commonContentSetup(request, mcContent, mcService, mcLearningForm, toolSessionID);
+
+ McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO = LearningUtil.buildMcGeneralLearnerFlowDTO(mcContent);
+ mcGeneralLearnerFlowDTO.setTotalCountReached(new Boolean(false).toString());
+ mcGeneralLearnerFlowDTO.setQuestionIndex(new Integer(1));
+ Boolean displayAnswers = mcContent.isDisplayAnswers();
+ mcGeneralLearnerFlowDTO.setDisplayAnswers(displayAnswers.toString());
+ mcGeneralLearnerFlowDTO.setReflection(new Boolean(mcContent.isReflect()).toString());
+ String reflectionSubject = McUtils.replaceNewLines(mcContent.getReflectionSubject());
+ mcGeneralLearnerFlowDTO.setReflectionSubject(reflectionSubject);
+
+ String userID = mcLearningForm.getUserID();
+ NotebookEntry notebookEntry = mcService.getEntry(new Long(toolSessionID), CoreNotebookConstants.NOTEBOOK_TOOL,
+ McAppConstants.MY_SIGNATURE, new Integer(userID));
+
+ if (notebookEntry != null) {
+ String notebookEntryPresentable = McUtils.replaceNewLines(notebookEntry.getEntry());
+ mcGeneralLearnerFlowDTO.setNotebookEntry(notebookEntryPresentable);
+ }
+ request.setAttribute(McAppConstants.MC_GENERAL_LEARNER_FLOW_DTO, mcGeneralLearnerFlowDTO);
+
+
+ List learnerAnswersDTOList = mcService.buildLearnerAnswersDTOList(mcContent, user);
+ request.setAttribute(McAppConstants.LEARNER_ANSWERS_DTO_LIST, learnerAnswersDTOList);
+ // should we show the marks for each question - we show the marks if any of the questions
+ // have a mark > 1.
+ Boolean showMarks = LearningUtil.isShowMarksOnQuestion(learnerAnswersDTOList);
+ mcGeneralLearnerFlowDTO.setShowMarks(showMarks.toString());
+
/*
* find out if the content is set to run offline or online. If it is set to run offline , the learners are
* informed about that.
@@ -257,51 +224,12 @@
return (mapping.findForward(McAppConstants.DEFINE_LATER));
}
- /*
- * Is the request for a preview by the author? Preview The tool must be able to show the specified content as if
- * it was running in a lesson. It will be the learner url with tool access mode set to ToolAccessMode.AUTHOR 3
- * modes are: author teacher learner
- */
+ if (mode.equals("teacher")) {
- /* handle PREVIEW mode */
- // String mode=mcLearningForm.getLearningMode();
- String mode = request.getParameter(McAppConstants.MODE);
-
- /*
- * by now, we know that the mode is either teacher or learner check if the mode is teacher and request is for
- * Learner Progress
- */
- String userId = request.getParameter(McAppConstants.USER_ID);
-
- if ((userId != null) && (mode.equals("teacher"))) {
-
/* LEARNER_PROGRESS for jsp */
mcLearningForm.setLearnerProgress(new Boolean(true).toString());
- mcLearningForm.setLearnerProgressUserId(userId);
+ mcLearningForm.setLearnerProgressUserId(user.getQueUsrId().toString());
- /*
- * pay attention that this userId is the learner's userId passed by the request parameter. It is differerent
- * than USER_ID kept in the session of the current system user
- */
-
- McQueUsr mcQueUsr = mcService.getMcUserBySession(new Long(userId), mcSession.getUid());
- if (mcQueUsr == null) {
- McLearningStarterAction.logger.error("error.learner.required");
- persistError(request, "error.learner.required");
- McLearningStarterAction.logger.error("forwarding to: " + McAppConstants.SIMPLE_LEARNING_ERROR);
- return (mapping.findForward(McAppConstants.SIMPLE_LEARNING_ERROR));
- }
-
- /* check whether the user's session really referrs to the session id passed to the url */
- Long sessionUid = mcQueUsr.getMcSessionId();
- McSession mcSessionLocal = mcService.getMcSessionByUID(sessionUid);
-
- toolSessionID = mcLearningForm.getToolSessionID();
-
- if ((mcSessionLocal == null)
- || (mcSessionLocal.getMcSessionId().longValue() != new Long(toolSessionID).longValue())) {
- McLearningStarterAction.logger.error("error.learner.sessionId.inconsistent");
- }
LearningUtil.saveFormRequestData(request, mcLearningForm, true);
request.setAttribute(McAppConstants.REQUEST_BY_STARTER, new Boolean(true).toString());
@@ -311,92 +239,20 @@
return mcLearningAction.viewAnswers(mapping, mcLearningForm, request, response);
}
- /* by now, we know that the mode is learner */
- /*
- * verify that userId does not already exist in the db. If it does exist, that means, that user already
- * responded to the content and his answers must be displayed read-only
- */
-
- Integer userID = null;
- HttpSession ss = SessionManager.getSession();
- if (ss != null) {
- UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
- if (user != null) {
- userID = user.getUserID();
- }
- }
-
- McQueUsr mcQueUsr = mcService.getMcUserBySession(new Long(userID.longValue()), mcSession.getUid());
-
request.setAttribute(McAppConstants.MC_LEARNER_STARTER_DTO, mcLearnerStarterDTO);
- /* if the user's session id AND user id exists in the tool tables go to redo questions. */
- if (mcQueUsr != null) {
- Long sessionUid = mcQueUsr.getMcSessionId();
- McSession mcUserSession = mcService.getMcSessionByUID(sessionUid);
- String userSessionId = mcUserSession.getMcSessionId().toString();
-
- if (toolSessionID.equals(userSessionId)) {
- McLearningAction mcLearningAction = new McLearningAction();
- request.setAttribute(McAppConstants.REQUEST_BY_STARTER, (Boolean.TRUE).toString());
- mcLearningAction.prepareViewAnswersData(mapping, mcLearningForm, request, getServlet()
- .getServletContext());
- return mapping.findForward(McAppConstants.VIEW_ANSWERS);
- }
- } else if (mode.equals("teacher")) {
+ /* user already responded to the content - go to redo questions. */
+ if (user.isResponseFinalised()) {
McLearningAction mcLearningAction = new McLearningAction();
- mcLearningAction.setServlet(servlet);
- mcLearningForm.setLearnerProgress(new Boolean(true).toString());
- mcLearningForm.setLearnerProgressUserId(userId);
- return mcLearningAction.viewAnswers(mapping, mcLearningForm, request, response);
+ request.setAttribute(McAppConstants.REQUEST_BY_STARTER, (Boolean.TRUE).toString());
+ mcLearningAction.prepareViewAnswersData(mapping, mcLearningForm, request, getServlet().getServletContext());
+ return mapping.findForward(McAppConstants.VIEW_ANSWERS);
}
+
request.setAttribute(McAppConstants.MC_LEARNER_STARTER_DTO, mcLearnerStarterDTO);
return (mapping.findForward(McAppConstants.LOAD_LEARNER));
}
- /**
- * sets up question and candidate answers maps commonContentSetup(HttpServletRequest request, McContent mcContent)
- *
- * @param request
- * @param mcContent
- */
- protected void commonContentSetup(HttpServletRequest request, McContent mcContent, IMcService mcService,
- McLearningForm mcLearningForm, String toolSessionID) {
- Map mapQuestionsContent = new TreeMap(new McComparator());
-
- boolean randomize = mcContent.isRandomize();
-
- List listQuestionAndCandidateAnswersDTO = LearningUtil
- .buildQuestionAndCandidateAnswersDTO(request, mcContent, randomize, mcService);
-
- request.setAttribute(McAppConstants.LIST_QUESTION_CANDIDATEANSWERS_DTO, listQuestionAndCandidateAnswersDTO);
- McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO = LearningUtil.buildMcGeneralLearnerFlowDTO(mcContent);
- mcGeneralLearnerFlowDTO.setTotalCountReached(new Boolean(false).toString());
- mcGeneralLearnerFlowDTO.setQuestionIndex(new Integer(1));
-
- // should we show the marks for each question - we show the marks if any of the questions
- // have a mark > 1.
- Boolean showMarks = LearningUtil.isShowMarksOnQuestion(listQuestionAndCandidateAnswersDTO);
- mcGeneralLearnerFlowDTO.setShowMarks(showMarks.toString());
-
- Boolean displayAnswers = mcContent.isDisplayAnswers();
- mcGeneralLearnerFlowDTO.setDisplayAnswers(displayAnswers.toString());
- mcGeneralLearnerFlowDTO.setReflection(new Boolean(mcContent.isReflect()).toString());
- String reflectionSubject = McUtils.replaceNewLines(mcContent.getReflectionSubject());
- mcGeneralLearnerFlowDTO.setReflectionSubject(reflectionSubject);
-
- String userID = mcLearningForm.getUserID();
- NotebookEntry notebookEntry = mcService.getEntry(new Long(toolSessionID), CoreNotebookConstants.NOTEBOOK_TOOL,
- McAppConstants.MY_SIGNATURE, new Integer(userID));
-
- if (notebookEntry != null) {
- String notebookEntryPresentable = McUtils.replaceNewLines(notebookEntry.getEntry());
- mcGeneralLearnerFlowDTO.setNotebookEntry(notebookEntryPresentable);
- }
-
- request.setAttribute(McAppConstants.MC_GENERAL_LEARNER_FLOW_DTO, mcGeneralLearnerFlowDTO);
- }
-
protected ActionForward validateParameters(HttpServletRequest request, McLearningForm mcLearningForm,
ActionMapping mapping) {
/*
@@ -443,7 +299,33 @@
return null;
}
+
+ private McQueUsr getCurrentUser(String toolSessionId) {
+ // get back login user DTO
+ HttpSession ss = SessionManager.getSession();
+ UserDTO toolUser = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ Long userId = new Long(toolUser.getUserID().longValue());
+
+ McSession mcSession = mcService.getMcSessionById(new Long(toolSessionId));
+ McQueUsr qaUser = mcService.getMcUserBySession(userId, mcSession.getUid());
+ if (qaUser == null) {
+ qaUser = mcService.createMcUser(new Long(toolSessionId));
+ }
+
+ return qaUser;
+ }
+
+ private McQueUsr getSpecifiedUser(String toolSessionId, Integer userId) {
+ McSession mcSession = mcService.getMcSessionById(new Long(toolSessionId));
+ McQueUsr qaUser = mcService.getMcUserBySession(new Long(userId.intValue()), mcSession.getUid());
+ if (qaUser == null) {
+ logger.error("Unable to find specified user for Q&A activity. Screens are likely to fail. SessionId="
+ + new Long(toolSessionId) + " UserId=" + userId);
+ }
+ return qaUser;
+ }
+
/**
* persists error messages to request scope
*
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringAction.java
===================================================================
diff -u -r1cf6e4e342f35fb8695a240eb6b7f8b6b640e4dc -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringAction.java (.../McMonitoringAction.java) (revision 1cf6e4e342f35fb8695a240eb6b7f8b6b640e4dc)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McMonitoringAction.java (.../McMonitoringAction.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -148,7 +148,7 @@
mcGeneralMonitoringDTO.setSelectionCase(new Long(2));
request.setAttribute(SELECTION_CASE, new Long(2));
} else {
- McSession mcSession = mcService.retrieveMcSession(new Long(currentMonitoredToolSession));
+ McSession mcSession = mcService.getMcSessionById(new Long(currentMonitoredToolSession));
MonitoringUtil.setupAllSessionsData(request, mcContent, mcService);
@@ -3241,7 +3241,8 @@
Integer[] marks = userMark.getMarks();
for (int i = 0; i < marks.length; i++) {
cell = row.createCell(count++);
- cell.setCellValue(marks[i]);
+ Integer mark = (marks[i] == null) ? 0 : marks[i];
+ cell.setCellValue(mark);
}
cell = row.createCell(count++);
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McPedagogicalPlannerAction.java
===================================================================
diff -u -r9a2c06691bf5157039ae82f36ec2f84c32eda8cb -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McPedagogicalPlannerAction.java (.../McPedagogicalPlannerAction.java) (revision 9a2c06691bf5157039ae82f36ec2f84c32eda8cb)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McPedagogicalPlannerAction.java (.../McPedagogicalPlannerAction.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -103,7 +103,7 @@
plannerForm.removeQuestion(questionIndex - 1);
} else {
if (questionIndex <= mcContent.getMcQueContents().size()) {
- McQueContent mcQueContent = getMcService().getQuestionContentByDisplayOrder(
+ McQueContent mcQueContent = getMcService().getQuestionByDisplayOrder(
(long) questionIndex, mcContent.getUid());
mcQueContent.setQuestion(question);
int candidateAnswerDTOIndex = 0;
@@ -145,7 +145,7 @@
}
} while (questionIndex <= plannerForm.getQuestionCount());
for (; questionIndex <= mcContent.getMcQueContents().size(); questionIndex++) {
- McQueContent mcQueContent = getMcService().getQuestionContentByDisplayOrder((long) questionIndex,
+ McQueContent mcQueContent = getMcService().getQuestionByDisplayOrder((long) questionIndex,
mcContent.getUid());
mcContent.getMcQueContents().remove(mcQueContent);
getMcService().removeMcQueContent(mcQueContent);
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/MonitoringUtil.java
===================================================================
diff -u -r8ddb4345fdfc8904e5a7ff156cc63053e63741ca -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision 8ddb4345fdfc8904e5a7ff156cc63053e63741ca)
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/MonitoringUtil.java (.../MonitoringUtil.java) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -91,9 +91,23 @@
List listCandidateAnswersDTO = mcService.populateCandidateAnswersDTO(mcQueContent.getUid());
mcMonitoredAnswersDTO.setCandidateAnswersCorrect(listCandidateAnswersDTO);
+
+ Map questionAttemptData = new TreeMap(new McStringComparator());
- Map questionAttemptData = buildGroupsAttemptData(request, mcContent, mcQueContent,
- mcQueContent.getUid(), mcService, null);
+ Iterator sessionIterator = mcContent.getMcSessions().iterator();
+ while (sessionIterator.hasNext()) {
+ McSession mcSession = (McSession) sessionIterator.next();
+ Set listMcUsers = mcSession.getMcQueUsers();
+ List monitoredUserDTOs = new LinkedList();
+ for (McQueUsr mcQueUsr : listMcUsers) {
+ McMonitoredUserDTO mcMonitoredUserDTO = getUserAttempt(request, mcService, mcQueUsr, mcSession,
+ mcQueContent.getUid());
+ monitoredUserDTOs.add(mcMonitoredUserDTO);
+ }
+
+ questionAttemptData.put(mcSession.getSession_name(), monitoredUserDTOs);
+ }
+
mcMonitoredAnswersDTO.setQuestionAttempts(questionAttemptData);
listMonitoredAnswersContainerDTO.add(mcMonitoredAnswersDTO);
@@ -133,8 +147,10 @@
// Get the attempts for this user. The maps must match the maps in buildGroupsAttemptData or the jsp
// won't work.
- List listMonitoredUserContainerDTO = getAttemptEntries(request, mcService, mcQueUsr, mcSession,
- mcQueContent.getUid(), new LinkedList(), false);
+ McMonitoredUserDTO mcMonitoredUserDTO = getUserAttempt(request, mcService, mcQueUsr, mcSession,
+ mcQueContent.getUid());
+ List listMonitoredUserContainerDTO = new LinkedList();
+ listMonitoredUserContainerDTO.add(mcMonitoredUserDTO);
Map questionAttemptData = new TreeMap(new McStringComparator());
questionAttemptData.put(mcSession.getSession_name(), listMonitoredUserContainerDTO);
@@ -172,14 +188,14 @@
Long mapIndex = new Long(1);
while (usersIterator.hasNext()) {
- McQueUsr mcQueUsr = (McQueUsr) usersIterator.next();
+ McQueUsr user = (McQueUsr) usersIterator.next();
McUserMarkDTO mcUserMarkDTO = new McUserMarkDTO();
mcUserMarkDTO.setSessionId(mcSession.getMcSessionId().toString());
mcUserMarkDTO.setSessionName(mcSession.getSession_name().toString());
- mcUserMarkDTO.setFullName(mcQueUsr.getFullname());
- mcUserMarkDTO.setUserName(mcQueUsr.getUsername());
- mcUserMarkDTO.setQueUsrId(mcQueUsr.getUid().toString());
+ mcUserMarkDTO.setFullName(user.getFullname());
+ mcUserMarkDTO.setUserName(user.getUsername());
+ mcUserMarkDTO.setQueUsrId(user.getUid().toString());
// The marks for the user must be listed in the display order of the question.
// Other parts of the code assume that the questions will be in consecutive display
@@ -192,7 +208,7 @@
// we need to check if we've already processed this question in the total.
Integer[] userMarks = new Integer[numQuestions];
Date attemptTime = null;
- Iterator attemptIterator = mcService.getLatestAttemptsForAUser(mcQueUsr.getUid()).iterator();
+ Iterator attemptIterator = mcService.getFinalizedUserAttempts(user).iterator();
long totalMark = 0;
while (attemptIterator.hasNext()) {
McUsrAttempt attempt = (McUsrAttempt) attemptIterator.next();
@@ -204,7 +220,8 @@
// We get the mark for the attempt if the answer is correct and we don't allow
// retries, or if the answer is correct and the learner has met the passmark if
// we do allow retries.
- Integer mark = attempt.getMarkForShow(mcSession.getMcContent().isRetries());
+ boolean isRetries = mcSession.getMcContent().isRetries();
+ Integer mark = attempt.getMarkForShow(isRetries);
userMarks[arrayIndex] = mark;
totalMark += mark.intValue();
}
@@ -230,86 +247,20 @@
/**
*
- * helps populating user's attempt history
- *
- * @param request
- * @param mcContent
- * @param mcQueContent
- * @return Map
*/
- public static Map buildGroupsAttemptData(HttpServletRequest request, McContent mcContent,
- McQueContent mcQueContent, Long questionUid, IMcService mcService, McQueUsr mcQueUsr) {
- Map mapMonitoredAttemptsContainerDTO = new TreeMap(new McStringComparator());
+ public static McMonitoredUserDTO getUserAttempt(HttpServletRequest request, IMcService mcService, McQueUsr mcQueUsr,
+ McSession mcSession, Long questionUid) {
- Iterator sessionIterator = mcContent.getMcSessions().iterator();
- while (sessionIterator.hasNext()) {
- McSession mcSession = (McSession) sessionIterator.next();
- Set listMcUsers = mcSession.getMcQueUsers();
- List sessionUsersAttempts = populateSessionUsersAttempts(request, mcSession.getMcSessionId(), listMcUsers,
- questionUid, mcService);
- mapMonitoredAttemptsContainerDTO.put(mcSession.getSession_name(), sessionUsersAttempts);
- }
-
- return mapMonitoredAttemptsContainerDTO;
- }
-
- /**
- *
- * ends up populating all the user's attempt data of a particular tool session
- *
- * if userID is not null, it only gets the attempts for that user.
- *
- * @param request
- * @param listMcUsers
- * @return List
- */
- public static List populateSessionUsersAttempts(HttpServletRequest request, Long sessionId, Set listMcUsers,
- Long questionUid, IMcService mcService) {
-
- McSession mcSession = mcService.retrieveMcSession(sessionId);
-
- List listMonitoredUserContainerDTO = new LinkedList();
- Iterator itUsers = listMcUsers.iterator();
- while (itUsers.hasNext()) {
- McQueUsr mcQueUsr = (McQueUsr) itUsers.next();
- listMonitoredUserContainerDTO = getAttemptEntries(request, mcService, mcQueUsr, mcSession, questionUid,
- listMonitoredUserContainerDTO, true);
- }
-
- return listMonitoredUserContainerDTO;
- }
-
- /**
- *
- * @param request
- * @param mcService
- * @param mcQueUsr
- * @param mcSession
- * @param questionUid
- * @param listMonitoredUserContainerDTO
- * @param mapMonitoredUserContainerDTO
- * @return
- */
- public static List getAttemptEntries(HttpServletRequest request, IMcService mcService, McQueUsr mcQueUsr,
- McSession mcSession, Long questionUid, List listMonitoredUserContainerDTO, boolean latestOnly) {
-
+ McMonitoredUserDTO mcMonitoredUserDTO = new McMonitoredUserDTO();
if (mcQueUsr != null) {
-
- McMonitoredUserDTO mcMonitoredUserDTO = new McMonitoredUserDTO();
mcMonitoredUserDTO.setUserName(mcQueUsr.getFullname());
mcMonitoredUserDTO.setSessionId(mcSession.getMcSessionId().toString());
mcMonitoredUserDTO.setQuestionUid(questionUid.toString());
mcMonitoredUserDTO.setQueUsrId(mcQueUsr.getUid().toString());
- List listUserAttempts = null;
- if (latestOnly)
- listUserAttempts = mcService.getLatestAttemptsForAUserForOneQuestionContent(mcQueUsr.getUid(),
- questionUid);
- else
- listUserAttempts = mcService.getAllAttemptsForAUserForOneQuestionContentOrderByAttempt(
- mcQueUsr.getUid(), questionUid);
+ McUsrAttempt userAttempt = mcService.getUserAttemptByQuestion(mcQueUsr.getUid(), questionUid);
- if (listUserAttempts.size() == 0) {
+ if (!mcQueUsr.isResponseFinalised() || (userAttempt == null)) {
mcMonitoredUserDTO.setMark(new Integer(0));
@@ -323,20 +274,16 @@
// retries, or if the answer is correct and the learner has met the passmark if
// we do allow retries.
- Map attemptMap = new TreeMap();
- for (McUsrAttempt attempt : listUserAttempts) {
- attemptMap.put(attempt.getAttemptOrder(), attempt.getMcOptionsContent().getMcQueOptionText());
- mcMonitoredUserDTO.setMark(attempt.getMarkForShow(mcSession.getMcContent().isRetries()));
- mcMonitoredUserDTO.setIsCorrect(new Boolean(attempt.isAttemptCorrect()).toString());
- }
- mcMonitoredUserDTO.setUsersAttempts(attemptMap);
+ String userAnswer = userAttempt.getMcOptionsContent().getMcQueOptionText();
+ boolean isRetries = mcSession.getMcContent().isRetries();
+ mcMonitoredUserDTO.setMark(userAttempt.getMarkForShow(isRetries));
+ mcMonitoredUserDTO.setIsCorrect(new Boolean(userAttempt.isAttemptCorrect()).toString());
+ mcMonitoredUserDTO.setUserAnswer(userAnswer);
}
- listMonitoredUserContainerDTO.add(mcMonitoredUserDTO);
-
}
- return listMonitoredUserContainerDTO;
+ return mcMonitoredUserDTO;
}
/**
Index: lams_tool_lamc/web/export/exportportfolio.jsp
===================================================================
diff -u -rf04e5eaf5a3b6bd01c39426e993609857686d936 -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/web/export/exportportfolio.jsp (.../exportportfolio.jsp) (revision f04e5eaf5a3b6bd01c39426e993609857686d936)
+++ lams_tool_lamc/web/export/exportportfolio.jsp (.../exportportfolio.jsp) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -1,26 +1,4 @@
-<%--
-Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
-License Information: http://lamsfoundation.org/licensing/lams/2.0/
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2 as
- published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- USA
-
- http://www.gnu.org/licenses/gpl.txt
---%>
-
-
-
<%@ include file="/common/taglibs.jsp"%>
Index: lams_tool_lamc/web/export/learner.jsp
===================================================================
diff -u -rf04e5eaf5a3b6bd01c39426e993609857686d936 -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/web/export/learner.jsp (.../learner.jsp) (revision f04e5eaf5a3b6bd01c39426e993609857686d936)
+++ lams_tool_lamc/web/export/learner.jsp (.../learner.jsp) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -42,13 +42,11 @@
()
-
- :
+
-
Index: lams_tool_lamc/web/learning/AnswersContent.jsp
===================================================================
diff -u -r15cfa42a1cce71ee86152e5fedde483c213d4e0c -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/web/learning/AnswersContent.jsp (.../AnswersContent.jsp) (revision 15cfa42a1cce71ee86152e5fedde483c213d4e0c)
+++ lams_tool_lamc/web/learning/AnswersContent.jsp (.../AnswersContent.jsp) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -1,24 +1,3 @@
-<%--
-Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
-License Information: http://lamsfoundation.org/licensing/lams/2.0/
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2 as
- published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- USA
-
- http://www.gnu.org/licenses/gpl.txt
---%>
-
@@ -34,11 +13,34 @@
-
-
-
+
+
+
+
-
+
Index: lams_tool_lamc/web/learning/CombinedAnswersContent.jsp
===================================================================
diff -u -r58154c639fa5b4a8cb4426f53ac927158f73d4fd -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/web/learning/CombinedAnswersContent.jsp (.../CombinedAnswersContent.jsp) (revision 58154c639fa5b4a8cb4426f53ac927158f73d4fd)
+++ lams_tool_lamc/web/learning/CombinedAnswersContent.jsp (.../CombinedAnswersContent.jsp) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -1,23 +1,3 @@
-<%--
-Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
-License Information: http://lamsfoundation.org/licensing/lams/2.0/
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2 as
- published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- USA
-
- http://www.gnu.org/licenses/gpl.txt
---%>
<%@ include file="/common/taglibs.jsp"%>
@@ -33,15 +13,14 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
@@ -53,7 +32,7 @@
-
+
@@ -73,21 +52,16 @@
-
-
+
-
+ checked="checked">
-
-
-
-
-
-
-
-
+
+
+
@@ -96,7 +70,6 @@
-
Index: lams_tool_lamc/web/learning/IndividualLearnerResults.jsp
===================================================================
diff -u -rf8549174934683116cbc7f86f7906e0b82d56fd2 -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/web/learning/IndividualLearnerResults.jsp (.../IndividualLearnerResults.jsp) (revision f8549174934683116cbc7f86f7906e0b82d56fd2)
+++ lams_tool_lamc/web/learning/IndividualLearnerResults.jsp (.../IndividualLearnerResults.jsp) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -1,23 +1,3 @@
-<%--
-Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
-License Information: http://lamsfoundation.org/licensing/lams/2.0/
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2 as
- published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- USA
-
- http://www.gnu.org/licenses/gpl.txt
---%>
@@ -42,10 +22,11 @@
elem.disabled = true;
}
}
- function submitForm(methodName){
- var f = document.getElementById('Form1');
- f.submit();
- }
+
+ function submitForm(methodName){
+ var f = document.getElementById('Form1');
+ f.submit();
+ }
@@ -145,28 +126,24 @@
@@ -206,7 +183,7 @@
-
+
Index: lams_tool_lamc/web/learning/Notebook.jsp
===================================================================
diff -u -r2a05e87cdb64f53ee491a536f01405c1bbc58ca9 -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/web/learning/Notebook.jsp (.../Notebook.jsp) (revision 2a05e87cdb64f53ee491a536f01405c1bbc58ca9)
+++ lams_tool_lamc/web/learning/Notebook.jsp (.../Notebook.jsp) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -1,24 +1,3 @@
-<%--
-Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
-License Information: http://lamsfoundation.org/licensing/lams/2.0/
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2 as
- published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- USA
-
- http://www.gnu.org/licenses/gpl.txt
---%>
-
Fisheye: Tag c369c0326857e08851d03a29d39d4337091f5253 refers to a dead (removed) revision in file `lams_tool_lamc/web/learning/RedoQuestions.jsp'.
Fisheye: No comparison available. Pass `N' to diff?
Index: lams_tool_lamc/web/learning/RunOffline.jsp
===================================================================
diff -u -r8aded0b18a5a7712622ae56f38923fa297449977 -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/web/learning/RunOffline.jsp (.../RunOffline.jsp) (revision 8aded0b18a5a7712622ae56f38923fa297449977)
+++ lams_tool_lamc/web/learning/RunOffline.jsp (.../RunOffline.jsp) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -1,24 +1,3 @@
-<%--
-Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
-License Information: http://lamsfoundation.org/licensing/lams/2.0/
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2 as
- published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- USA
-
- http://www.gnu.org/licenses/gpl.txt
---%>
-
Index: lams_tool_lamc/web/learning/SimpleLearnerError.jsp
===================================================================
diff -u -r18e5e690d2e1a7c3d918759f7a2827c8205feaac -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/web/learning/SimpleLearnerError.jsp (.../SimpleLearnerError.jsp) (revision 18e5e690d2e1a7c3d918759f7a2827c8205feaac)
+++ lams_tool_lamc/web/learning/SimpleLearnerError.jsp (.../SimpleLearnerError.jsp) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -1,24 +1,3 @@
-<%--
-Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
-License Information: http://lamsfoundation.org/licensing/lams/2.0/
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2 as
- published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- USA
-
- http://www.gnu.org/licenses/gpl.txt
---%>
-
Index: lams_tool_lamc/web/learning/SingleQuestionAnswersContent.jsp
===================================================================
diff -u -r58154c639fa5b4a8cb4426f53ac927158f73d4fd -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/web/learning/SingleQuestionAnswersContent.jsp (.../SingleQuestionAnswersContent.jsp) (revision 58154c639fa5b4a8cb4426f53ac927158f73d4fd)
+++ lams_tool_lamc/web/learning/SingleQuestionAnswersContent.jsp (.../SingleQuestionAnswersContent.jsp) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -1,23 +1,3 @@
-<%--
-Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
-License Information: http://lamsfoundation.org/licensing/lams/2.0/
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2 as
- published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- USA
-
- http://www.gnu.org/licenses/gpl.txt
---%>
<%@ include file="/common/taglibs.jsp"%>
@@ -41,8 +21,7 @@
-
+ ( )
@@ -52,7 +31,7 @@
-
+
@@ -72,20 +51,16 @@
-
+
-
+ checked="checked">
-
-
-
-
-
-
-
-
+
+
+
Index: lams_tool_lamc/web/learning/ViewAnswers.jsp
===================================================================
diff -u -r494a9dd71dac07608a07f40aad1d6879b98a421b -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/web/learning/ViewAnswers.jsp (.../ViewAnswers.jsp) (revision 494a9dd71dac07608a07f40aad1d6879b98a421b)
+++ lams_tool_lamc/web/learning/ViewAnswers.jsp (.../ViewAnswers.jsp) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -1,24 +1,3 @@
-<%--
-Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
-License Information: http://lamsfoundation.org/licensing/lams/2.0/
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2 as
- published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
- USA
-
- http://www.gnu.org/licenses/gpl.txt
---%>
-
@@ -110,22 +89,23 @@
-
-
-
+
+
+
-
-
-
- images/tick.gif" border="0" class="middle">
-
-
- images/cross.gif" border="0" class="middle">
-
+
+
+
+
+ images/tick.gif" border="0" class="middle">
+
+
+ images/cross.gif" border="0" class="middle">
+
+
Index: lams_tool_lamc/web/learning/defineLater.jsp
===================================================================
diff -u -rf78a1aae1affd6cb6f8325dd43929b2358c36b44 -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/web/learning/defineLater.jsp (.../defineLater.jsp) (revision f78a1aae1affd6cb6f8325dd43929b2358c36b44)
+++ lams_tool_lamc/web/learning/defineLater.jsp (.../defineLater.jsp) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -1,24 +1,3 @@
-<%--
-Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
-License Information: http://lamsfoundation.org/licensing/lams/2.0/
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License version 2 as
- published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
- USA
-
- http://www.gnu.org/licenses/gpl.txt
---%>
-
Index: lams_tool_lamc/web/learning/mobile/AnswersContent.jsp
===================================================================
diff -u -r34d42662e65de84dc105cdd7df52a9d622392b2d -rc369c0326857e08851d03a29d39d4337091f5253
--- lams_tool_lamc/web/learning/mobile/AnswersContent.jsp (.../AnswersContent.jsp) (revision 34d42662e65de84dc105cdd7df52a9d622392b2d)
+++ lams_tool_lamc/web/learning/mobile/AnswersContent.jsp (.../AnswersContent.jsp) (revision c369c0326857e08851d03a29d39d4337091f5253)
@@ -8,7 +8,29 @@
<%@ include file="/common/mobileheader.jsp"%>
+
+
+
+
@@ -121,28 +121,24 @@