Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java,v
diff -u -r1.82 -r1.83
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java 14 Jul 2006 05:04:11 -0000 1.82
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McAppConstants.java 20 Jul 2006 21:47:09 -0000 1.83
@@ -208,6 +208,9 @@
/* learner mode contants */
public static final String MAP_QUESTION_CONTENT_LEARNER ="mapQuestionContentLearner";
+ public static final String LIST_QUESTION_CANDIDATEANSWERS_DTO ="listQuestionCandidateAnswersDto";
+ public static final String MC_GENERAL_LEARNER_FLOW_DTO ="mcGeneralLearnerFlowDTO";
+ public static final String LIST_SELECTED_QUESTION_CANDIDATEANSWERS_DTO ="listSelectedQuestionCandidateAnswersDto";
public static final String CURRENT_QUESTION_INDEX ="currentQuestionIndex";
public static final String TOTAL_QUESTION_COUNT ="totalQuestionCount";
public static final String HR_COLUMN_COUNT ="hrColumnCount";
@@ -221,7 +224,7 @@
public static final String REPORT_TITLE_LEARNER ="reportTitleLearner";
public static final String TOTAL_COUNT_REACHED ="totalCountReached";
-
+ public static final String MC_LEARNER_STARTER_DTO ="mcLearnerStarterDTO";
public static final String IS_TOOL_ACTIVITY_OFFLINE ="isToolActivityOffline";
public static final String IS_USERNAME_VISIBLE ="isUsernameVisible";
public static final String IS_CONTENT_IN_USE ="isContentInUse";
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McGeneralLearnerFlowDTO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McGeneralLearnerFlowDTO.java,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McGeneralLearnerFlowDTO.java 20 Jul 2006 21:47:09 -0000 1.1
@@ -0,0 +1,223 @@
+/***************************************************************************
+ * 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 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
+ * ***********************************************************************/
+/* $$Id: McGeneralLearnerFlowDTO.java,v 1.1 2006/07/20 21:47:09 ozgurd Exp $$ */
+package org.lamsfoundation.lams.tool.mc;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+
+
+/**
+ *
DTO that holds learner flow decision properties and some other view-only properties
+ *
+ *
+ * @author Ozgur Demirtas
+ */
+public class McGeneralLearnerFlowDTO implements Comparable
+{
+ protected String retries;
+
+ protected String learnerMark;
+
+ protected String learnerMarkAtLeast;
+
+ protected String totalQuestionCount;
+
+ protected String passMark;
+
+ protected String passMarkApplicable;
+
+ protected String userPassed;
+
+ protected String userOverPassMark;
+
+ protected String reportTitleLearner;
+
+ protected String activityInstructions;
+
+ protected String activityTitle;
+
+
+
+ /**
+ * @return Returns the activityInstructions.
+ */
+ public String getActivityInstructions() {
+ return activityInstructions;
+ }
+ /**
+ * @param activityInstructions The activityInstructions to set.
+ */
+ public void setActivityInstructions(String activityInstructions) {
+ this.activityInstructions = activityInstructions;
+ }
+
+ /**
+ * @return Returns the learnerMark.
+ */
+ public String getLearnerMark() {
+ return learnerMark;
+ }
+ /**
+ * @param learnerMark The learnerMark to set.
+ */
+ public void setLearnerMark(String learnerMark) {
+ this.learnerMark = learnerMark;
+ }
+ /**
+ * @return Returns the learnerMarkAtLeast.
+ */
+ public String getLearnerMarkAtLeast() {
+ return learnerMarkAtLeast;
+ }
+ /**
+ * @param learnerMarkAtLeast The learnerMarkAtLeast to set.
+ */
+ public void setLearnerMarkAtLeast(String learnerMarkAtLeast) {
+ this.learnerMarkAtLeast = learnerMarkAtLeast;
+ }
+ /**
+ * @return Returns the passMark.
+ */
+ public String getPassMark() {
+ return passMark;
+ }
+ /**
+ * @param passMark The passMark to set.
+ */
+ public void setPassMark(String passMark) {
+ this.passMark = passMark;
+ }
+ /**
+ * @return Returns the passMarkApplicable.
+ */
+ public String getPassMarkApplicable() {
+ return passMarkApplicable;
+ }
+ /**
+ * @param passMarkApplicable The passMarkApplicable to set.
+ */
+ public void setPassMarkApplicable(String passMarkApplicable) {
+ this.passMarkApplicable = passMarkApplicable;
+ }
+ /**
+ * @return Returns the reportTitleLearner.
+ */
+ public String getReportTitleLearner() {
+ return reportTitleLearner;
+ }
+ /**
+ * @param reportTitleLearner The reportTitleLearner to set.
+ */
+ public void setReportTitleLearner(String reportTitleLearner) {
+ this.reportTitleLearner = reportTitleLearner;
+ }
+ /**
+ * @return Returns the totalQuestionCount.
+ */
+ public String getTotalQuestionCount() {
+ return totalQuestionCount;
+ }
+ /**
+ * @param totalQuestionCount The totalQuestionCount to set.
+ */
+ public void setTotalQuestionCount(String totalQuestionCount) {
+ this.totalQuestionCount = totalQuestionCount;
+ }
+ /**
+ * @return Returns the userOverPassMark.
+ */
+ public String getUserOverPassMark() {
+ return userOverPassMark;
+ }
+ /**
+ * @param userOverPassMark The userOverPassMark to set.
+ */
+ public void setUserOverPassMark(String userOverPassMark) {
+ this.userOverPassMark = userOverPassMark;
+ }
+
+ public int compareTo(Object o)
+ {
+ McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO = (McGeneralLearnerFlowDTO) o;
+
+ if (mcGeneralLearnerFlowDTO == null)
+ return 1;
+ else
+ return 0;
+ }
+
+ public String toString() {
+ return new ToStringBuilder(this)
+ .append("retries: ", retries)
+ .append("learnerMark : ", learnerMark)
+ .append("learnerMarkAtLeast: ", learnerMarkAtLeast)
+ .append("totalQuestionCount: ", totalQuestionCount)
+ .append("passMark: ", passMark)
+ .append("passMarkApplicable: ", passMarkApplicable)
+ .append("userPassed: ", userPassed)
+ .append("userOverPassMark: ", userOverPassMark)
+ .append("reportTitleLearner: ", reportTitleLearner)
+ .append("activityInstructions: ", activityInstructions)
+ .append("activityTitle: ", activityTitle)
+ .toString();
+ }
+
+
+ /**
+ * @return Returns the retries.
+ */
+ public String getRetries() {
+ return retries;
+ }
+ /**
+ * @param retries The retries to set.
+ */
+ public void setRetries(String retries) {
+ this.retries = retries;
+ }
+ /**
+ * @return Returns the activityTitle.
+ */
+ public String getActivityTitle() {
+ return activityTitle;
+ }
+ /**
+ * @param activityTitle The activityTitle to set.
+ */
+ public void setActivityTitle(String activityTitle) {
+ this.activityTitle = activityTitle;
+ }
+
+ /**
+ * @return Returns the userPassed.
+ */
+ public String getUserPassed() {
+ return userPassed;
+ }
+ /**
+ * @param userPassed The userPassed to set.
+ */
+ public void setUserPassed(String userPassed) {
+ this.userPassed = userPassed;
+ }
+}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McLearnerAnswersDTO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/Attic/McLearnerAnswersDTO.java,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McLearnerAnswersDTO.java 20 Jul 2006 21:47:09 -0000 1.1
@@ -0,0 +1,201 @@
+/***************************************************************************
+ * 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 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
+ * ***********************************************************************/
+/* $$Id: McLearnerAnswersDTO.java,v 1.1 2006/07/20 21:47:09 ozgurd Exp $$ */
+package org.lamsfoundation.lams.tool.mc;
+
+import java.util.Map;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+
+/**
+ * DTO that holds question and candidate answers for the learner environment
+ *
+ *
+ * @author Ozgur Demirtas
+ */
+public class McLearnerAnswersDTO implements Comparable
+{
+ protected String question;
+
+ protected String displayOrder;
+
+ protected String questionUid;
+
+ protected String weight;
+
+ protected String mark;
+
+ protected Map candidateAnswers;
+
+ protected Map candidateAnswerUids;
+
+ protected String attemptCorrect;
+
+ protected String feedbackIncorrect;
+
+ protected String feedbackCorrect;
+
+
+ /**
+ * @return Returns the candidateAnswers.
+ */
+ public Map getCandidateAnswers() {
+ return candidateAnswers;
+ }
+ /**
+ * @param candidateAnswers The candidateAnswers to set.
+ */
+ public void setCandidateAnswers(Map candidateAnswers) {
+ this.candidateAnswers = candidateAnswers;
+ }
+ /**
+ * @return Returns the question.
+ */
+ public String getQuestion() {
+ return question;
+ }
+ /**
+ * @param question The question to set.
+ */
+ public void setQuestion(String question) {
+ this.question = question;
+ }
+ /**
+ * @return Returns the weight.
+ */
+ public String getWeight() {
+ return weight;
+ }
+ /**
+ * @param weight The weight to set.
+ */
+ public void setWeight(String weight) {
+ this.weight = weight;
+ }
+
+
+
+ public String toString() {
+ return new ToStringBuilder(this)
+ .append("question: ", getQuestion())
+ .append("displayOrder: ", getDisplayOrder())
+ .append("candidateAnswers: ", getCandidateAnswers())
+ .toString();
+ }
+
+
+ public int compareTo(Object o)
+ {
+ McLearnerAnswersDTO mcLearnerAnswersDTO = (McLearnerAnswersDTO) o;
+
+ if (mcLearnerAnswersDTO == null)
+ return 1;
+ else
+ return 0;
+ }
+
+ /**
+ * @return Returns the displayOrder.
+ */
+ public String getDisplayOrder() {
+ return displayOrder;
+ }
+ /**
+ * @param displayOrder The displayOrder to set.
+ */
+ public void setDisplayOrder(String displayOrder) {
+ this.displayOrder = displayOrder;
+ }
+ /**
+ * @return Returns the questionUid.
+ */
+ public String getQuestionUid() {
+ return questionUid;
+ }
+ /**
+ * @param questionUid The questionUid to set.
+ */
+ public void setQuestionUid(String questionUid) {
+ this.questionUid = questionUid;
+ }
+ /**
+ * @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() {
+ return feedbackCorrect;
+ }
+ /**
+ * @param feedbackCorrect The feedbackCorrect to set.
+ */
+ public void setFeedbackCorrect(String feedbackCorrect) {
+ this.feedbackCorrect = feedbackCorrect;
+ }
+ /**
+ * @return Returns the attemptCorrect.
+ */
+ public String getAttemptCorrect() {
+ return attemptCorrect;
+ }
+ /**
+ * @param attemptCorrect The attemptCorrect to set.
+ */
+ public void setAttemptCorrect(String attemptCorrect) {
+ this.attemptCorrect = attemptCorrect;
+ }
+ /**
+ * @return Returns the feedbackIncorrect.
+ */
+ public String getFeedbackIncorrect() {
+ return feedbackIncorrect;
+ }
+ /**
+ * @param feedbackIncorrect The feedbackIncorrect to set.
+ */
+ public void setFeedbackIncorrect(String feedbackIncorrect) {
+ this.feedbackIncorrect = feedbackIncorrect;
+ }
+ /**
+ * @return Returns the mark.
+ */
+ public String getMark() {
+ return mark;
+ }
+ /**
+ * @param mark The mark to set.
+ */
+ public void setMark(String mark) {
+ this.mark = mark;
+ }
+}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McLearnerStarterDTO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/Attic/McLearnerStarterDTO.java,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/McLearnerStarterDTO.java 20 Jul 2006 21:47:09 -0000 1.1
@@ -0,0 +1,88 @@
+/***************************************************************************
+ * 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 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
+ * ***********************************************************************/
+/* $$Id: McLearnerStarterDTO.java,v 1.1 2006/07/20 21:47:09 ozgurd Exp $$ */
+package org.lamsfoundation.lams.tool.mc;
+
+
+
+/**
+ * DTO that holds properties for initial screen presentation
+ *
+ *
+ * @author Ozgur Demirtas
+ */
+public class McLearnerStarterDTO implements Comparable
+{
+
+ protected String questionListingMode;
+
+ protected String activityTitle;
+
+ protected String toolActivityOffline;
+
+ /**
+ * @return Returns the toolActivityOffline.
+ */
+ public String getToolActivityOffline() {
+ return toolActivityOffline;
+ }
+ /**
+ * @param toolActivityOffline The toolActivityOffline to set.
+ */
+ public void setToolActivityOffline(String toolActivityOffline) {
+ this.toolActivityOffline = toolActivityOffline;
+ }
+ /**
+ * @return Returns the activityTitle.
+ */
+ public String getActivityTitle() {
+ return activityTitle;
+ }
+ /**
+ * @param activityTitle The activityTitle to set.
+ */
+ public void setActivityTitle(String activityTitle) {
+ this.activityTitle = activityTitle;
+ }
+ /**
+ * @return Returns the questionListingMode.
+ */
+ public String getQuestionListingMode() {
+ return questionListingMode;
+ }
+ /**
+ * @param questionListingMode The questionListingMode to set.
+ */
+ public void setQuestionListingMode(String questionListingMode) {
+ this.questionListingMode = questionListingMode;
+ }
+ public int compareTo(Object o)
+ {
+ McLearnerStarterDTO mcLearnerStarterDTO = (McLearnerStarterDTO) o;
+
+ if (mcLearnerStarterDTO == null)
+ return 1;
+ else
+ return 0;
+ }
+
+}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcOptionsContentDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcOptionsContentDAO.java,v
diff -u -r1.15 -r1.16
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcOptionsContentDAO.java 16 Jun 2006 20:56:38 -0000 1.15
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcOptionsContentDAO.java 20 Jul 2006 21:47:09 -0000 1.16
@@ -42,7 +42,10 @@
*/
public McOptsContent getMcOptionsContentByUID(Long uid);
+ public List findMcOptionUidsByQueId(Long mcQueContentId);
+ public McOptsContent findMcOptionsContentByUid(Long uid);
+
/**
* Return a list of a McOptsContents
* with the given identifier mcQueContentId
, returns null if not found.
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcQueContentDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcQueContentDAO.java,v
diff -u -r1.18 -r1.19
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcQueContentDAO.java 3 Apr 2006 13:31:03 -0000 1.18
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/IMcQueContentDAO.java 20 Jul 2006 21:47:09 -0000 1.19
@@ -175,4 +175,6 @@
*/
public List getNextAvailableDisplayOrder(final long mcContentId);
+ public McQueContent findMcQuestionContentByUid(Long uid);
+
}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McOptionsContentDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McOptionsContentDAO.java,v
diff -u -r1.17 -r1.18
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McOptionsContentDAO.java 19 Jun 2006 23:03:40 -0000 1.17
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McOptionsContentDAO.java 20 Jul 2006 21:47:09 -0000 1.18
@@ -44,6 +44,7 @@
//private static final String FIND_MC_OPTIONS_CONTENT = "from " + McOptsContent.class.getName() + " as mco where mc_que_content_id=?";
private static final String FIND_MC_OPTIONS_CONTENT = "from mcOptsContent in class McOptsContent where mcOptsContent.mcQueContentId=:mcQueContentUid order by mcOptsContent.uid";
+ private static final String FIND_MC_OPTIONS_CONTENT_BY_UID = "from mcOptsContent in class McOptsContent where mcOptsContent.uid=:uid";
private static final String LOAD_OPTION_CONTENT_BY_OPTION_TEXT = "from mcOptsContent in class McOptsContent where mcOptsContent.mcQueOptionText=:option and mcOptsContent.mcQueContentId=:mcQueContentUid";
@@ -70,6 +71,48 @@
return null;
}
+
+ public McOptsContent findMcOptionsContentByUid(Long uid)
+ {
+ HibernateTemplate templ = this.getHibernateTemplate();
+ if ( uid != null) {
+ List list = getSession().createQuery(FIND_MC_OPTIONS_CONTENT_BY_UID)
+ .setLong("uid",uid.longValue())
+ .list();
+
+ if(list != null && list.size() > 0){
+ McOptsContent mco = (McOptsContent) list.get(0);
+ return mco;
+ }
+ }
+ 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)
{
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McQueContentDAO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McQueContentDAO.java,v
diff -u -r1.27 -r1.28
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McQueContentDAO.java 24 Jun 2006 23:36:33 -0000 1.27
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/dao/hibernate/McQueContentDAO.java 20 Jul 2006 21:47:09 -0000 1.28
@@ -27,6 +27,7 @@
import org.apache.log4j.Logger;
import org.hibernate.FlushMode;
+import org.lamsfoundation.lams.tool.mc.pojos.McOptsContent;
import org.lamsfoundation.lams.tool.mc.pojos.McQueContent;
import org.lamsfoundation.lams.tool.mc.dao.IMcQueContentDAO;
import org.springframework.orm.hibernate3.HibernateTemplate;
@@ -45,6 +46,8 @@
private static final String CLEAN_QUESTION_CONTENT_BY_CONTENT_ID_SIMPLE = "from mcQueContent in class McQueContent where mcQueContent.mcContentId=:mcContentId";
+ private static final String FIND_QUESTION_CONTENT_BY_UID = "from mcQueContent in class McQueContent where mcQueContent.uid=:uid";
+
private static final String CLEAN_QUESTION_CONTENT_BY_CONTENT_ID = "from mcQueContent in class McQueContent where mcQueContent.mcContentId=:mcContentId";
private static final String REFRESH_QUESTION_CONTENT = "from mcQueContent in class McQueContent where mcQueContent.mcContentId=:mcContentId order by mcQueContent.displayOrder";
@@ -56,6 +59,24 @@
private static final String GET_NEXT_AVAILABLE_DISPLAY_ORDER = "from mcQueContent in class McQueContent where mcQueContent.mcContentId=:mcContentId";
+ public McQueContent findMcQuestionContentByUid(Long uid)
+ {
+ HibernateTemplate templ = this.getHibernateTemplate();
+ if ( uid != null) {
+ List list = getSession().createQuery(FIND_QUESTION_CONTENT_BY_UID)
+ .setLong("uid",uid.longValue())
+ .list();
+
+ if(list != null && list.size() > 0){
+ McQueContent mcq = (McQueContent) list.get(0);
+ return mcq;
+ }
+ }
+ return null;
+ }
+
+
+
public McQueContent getMcQueContentByUID(Long uid)
{
return (McQueContent) this.getHibernateTemplate()
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java,v
diff -u -r1.51 -r1.52
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java 27 Jun 2006 18:30:13 -0000 1.51
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/IMcService.java 20 Jul 2006 21:47:08 -0000 1.52
@@ -95,6 +95,12 @@
public List refreshQuestionContent(final Long mcContentId) throws McApplicationException;
+ public List findMcOptionUidsByQueId(Long mcQueContentId) throws McApplicationException;
+
+ public McOptsContent findMcOptionsContentByUid(Long uid) throws McApplicationException;
+
+ public McQueContent findMcQuestionContentByUid(Long uid) throws McApplicationException;
+
public void removeMcOptionsContentByQueId(Long mcQueContentId) throws McApplicationException;
public void removeMcOptionsContent(McOptsContent mcOptsContent);
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java,v
diff -u -r1.69 -r1.70
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java 27 Jun 2006 18:30:13 -0000 1.69
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/service/McServicePOJO.java 20 Jul 2006 21:47:08 -0000 1.70
@@ -1008,7 +1008,7 @@
{
try
{
- return getMcOptionsContentByUID(uid);
+ return mcOptionsContentDAO.getMcOptionsContentByUID(uid);
}
catch (DataAccessException e)
{
@@ -1017,7 +1017,45 @@
}
}
+ public List findMcOptionUidsByQueId(Long mcQueContentId) 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"
+ + e.getMessage(),e);
+ }
+ }
+
+ public McOptsContent findMcOptionsContentByUid(Long uid) throws McApplicationException
+ {
+ try
+ {
+ return mcOptionsContentDAO.findMcOptionsContentByUid(uid);
+ }
+ catch (DataAccessException e)
+ {
+ throw new McApplicationException("Exception occured when lams is getting opts by uid"
+ + e.getMessage(),e);
+ }
+ }
+
public void saveMcOptionsContent(McOptsContent mcOptsContent) throws McApplicationException
{
try
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java,v
diff -u -r1.42 -r1.43
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java 24 Jun 2006 23:36:32 -0000 1.42
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/AuthoringUtil.java 20 Jul 2006 21:47:09 -0000 1.43
@@ -1010,8 +1010,42 @@
logger.debug("refreshed Map:" + mapQuestionsContent);
return mapQuestionsContent;
}
-
+
+ public static Map rebuildQuestionUidMap(IMcService mcService, Long toolContentId, Long mcQueContentUid)
+ {
+ logger.debug("starting rebuildQuestionUidMap");
+
+ logger.debug("mcQueContentUid:" + mcQueContentUid);
+ Map mapQuestionsContent= new TreeMap(new McComparator());
+
+ McContent mcContent=mcService.retrieveMc(toolContentId);
+ logger.debug("mcContent:" + mcContent);
+
+ if (mcContent != null)
+ {
+ List list=mcService.refreshQuestionContent(mcContent.getUid());
+ logger.debug("refreshed list:" + list);
+
+ Iterator listIterator=list.iterator();
+ Long mapIndex=new Long(1);
+ while (listIterator.hasNext())
+ {
+ McQueContent mcQueContent=(McQueContent)listIterator.next();
+ logger.debug("mcQueContent:" + mcQueContent);
+ if (mcQueContent.getUid().toString().equals(mcQueContentUid.toString()))
+ {
+ mapQuestionsContent.put(mapIndex.toString(),mcQueContent.getUid());
+ mapIndex=new Long(mapIndex.longValue()+1);
+ }
+ }
+ }
+
+ logger.debug("refreshed Map:" + mapQuestionsContent);
+ return mapQuestionsContent;
+ }
+
+
/**
* returns all the options for all the questions for a content
* generateGeneralOptionsContentMap(HttpServletRequest request, McContent mcContent)
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java,v
diff -u -r1.26 -r1.27
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java 19 Jun 2006 15:09:52 -0000 1.26
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/LearningUtil.java 20 Jul 2006 21:47:09 -0000 1.27
@@ -24,6 +24,7 @@
import java.util.Date;
import java.util.Iterator;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@@ -34,6 +35,9 @@
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.McStringComparator;
import org.lamsfoundation.lams.tool.mc.McUtils;
import org.lamsfoundation.lams.tool.mc.pojos.McContent;
import org.lamsfoundation.lams.tool.mc.pojos.McOptsContent;
@@ -190,6 +194,7 @@
{
String optionCheckBoxSelected=request.getParameter("optionCheckBoxSelected");
logger.debug("parameter optionCheckBoxSelected: " + optionCheckBoxSelected);
+
if ((optionCheckBoxSelected != null) && optionCheckBoxSelected.equals("1"))
{
logger.debug("parameter optionCheckBoxSelected is selected " + optionCheckBoxSelected);
@@ -266,7 +271,7 @@
return mapLeanerAssessmentResults;
}
-
+
/**
* calculateWeights(Map mapLeanerAssessmentResults, Map mapQuestionWeights)
@@ -502,6 +507,25 @@
return mapCorrectOptions;
}
+
+ public static Map buildMapCorrectOptionUids(List correctOptions)
+ {
+ Map mapCorrectOptionUids= new TreeMap(new McComparator());
+ Iterator correctOptionsIterator=correctOptions.iterator();
+ Long mapIndex=new Long(1);
+ while (correctOptionsIterator.hasNext())
+ {
+ McOptsContent mcOptsContent=(McOptsContent)correctOptionsIterator.next();
+ if (mcOptsContent != null)
+ {
+ mapCorrectOptionUids.put(mapIndex.toString(),mcOptsContent.getUid().toString());
+ mapIndex=new Long(mapIndex.longValue()+1);
+ }
+ }
+ logger.debug("mapCorrectOptionUids : " + mapCorrectOptionUids);
+ return mapCorrectOptionUids;
+ }
+
public static Map compare(Map mapGeneralCorrectOptions,Map mapGeneralCheckedOptionsContent)
{
@@ -529,8 +553,8 @@
Map mapCorrectOptions=(Map) pairs.getValue();
Map mapCheckedOptions=(Map) checkedPairs.getValue();
- boolean isEqual=compareMaps(mapCorrectOptions, mapCheckedOptions);
- boolean isEqualCross=compareMapsCross(mapCorrectOptions, mapCheckedOptions);
+ boolean isEqual=compareMapItems(mapCorrectOptions, mapCheckedOptions);
+ boolean isEqualCross=compareMapsItemsCross(mapCorrectOptions, mapCheckedOptions);
compareResult= isEqual && isEqualCross;
mapLeanerAssessmentResults.put(pairs.getKey(), new Boolean(compareResult).toString());
@@ -542,8 +566,9 @@
}
- public static boolean compareMaps(Map mapCorrectOptions, Map mapCheckedOptions)
+ public static boolean compareMapItems(Map mapCorrectOptions, Map mapCheckedOptions)
{
+ logger.debug("performing compareMaps");
logger.debug("mapCorrectOptions: " + mapCorrectOptions);
logger.debug("mapCheckedOptions: " + mapCheckedOptions);
@@ -552,7 +577,9 @@
while (itMap.hasNext())
{
Map.Entry pairs = (Map.Entry)itMap.next();
+ logger.debug("pairs.getValue(): " + pairs.getValue());
boolean optionExists=optionExists(pairs.getValue().toString(), mapCheckedOptions);
+ logger.debug("optionExists: " + optionExists);
if (optionExists == false)
{
@@ -569,8 +596,9 @@
* @param mapCheckedOptions
* @return boolean
*/
- public static boolean compareMapsCross(Map mapCorrectOptions, Map mapCheckedOptions)
+ public static boolean compareMapsItemsCross(Map mapCorrectOptions, Map mapCheckedOptions)
{
+ logger.debug("performing compareMapsCross");
logger.debug("mapCorrectOptions: " + mapCorrectOptions);
logger.debug("mapCheckedOptions: " + mapCheckedOptions);
@@ -579,7 +607,9 @@
while (itMap.hasNext())
{
Map.Entry pairs = (Map.Entry)itMap.next();
- boolean optionExists=optionExists(pairs.getValue().toString(), mapCorrectOptions);
+ logger.debug("pairs.getValue(): " + pairs.getValue());
+ boolean optionExists=optionExists(pairs.getValue().toString(), mapCorrectOptions);
+ logger.debug("optionExists: " + optionExists);
if (optionExists == false)
{
@@ -599,11 +629,16 @@
*/
public static boolean optionExists(String optionValue, Map generalMap)
{
+ logger.debug("performing optionExists: " + optionValue);
+ logger.debug("generalMap: " + generalMap);
+
Iterator itMap = generalMap.entrySet().iterator();
while (itMap.hasNext())
{
Map.Entry pairsChecked = (Map.Entry)itMap.next();
- if (pairsChecked.getValue().equals(optionValue))
+ logger.debug("pairsChecked: " + pairsChecked);
+
+ if (pairsChecked.getValue().toString().equals(optionValue.toString()))
return true;
}
return false;
@@ -631,13 +666,13 @@
*
* @param request
*/
- public static McQueUsr createUser(HttpServletRequest request)
+ public static McQueUsr createUser(HttpServletRequest request, IMcService mcService, Long toolSessionId)
{
- IMcService mcService =McUtils.getToolService(request);
- Long queUsrId=McUtils.getUserId();
+ logger.debug("createUser: using toolSessionId: " + toolSessionId);
+ Long queUsrId=McUtils.getUserId();
String username=McUtils.getUserName();
String fullname=McUtils.getUserFullName();
- Long toolSessionId=(Long) request.getSession().getAttribute(TOOL_SESSION_ID);
+ //Long toolSessionId=(Long) request.getSession().getAttribute(TOOL_SESSION_ID);
McSession mcSession=mcService.retrieveMcSession(toolSessionId);
McQueUsr mcQueUsr= new McQueUsr(queUsrId,
@@ -787,7 +822,92 @@
return mapQuestionsContent;
}
+
+ public static McGeneralLearnerFlowDTO buildMcGeneralLearnerFlowDTO(McContent mcContent)
+ {
+ logger.debug("starting buildMcGeneralLearnerFlowDTO: " + mcContent);
+ McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO =new McGeneralLearnerFlowDTO();
+ mcGeneralLearnerFlowDTO.setRetries(new Boolean(mcContent.isRetries()).toString());
+ mcGeneralLearnerFlowDTO.setActivityTitle(mcContent.getTitle());
+ mcGeneralLearnerFlowDTO.setActivityInstructions(mcContent.getInstructions());
+ mcGeneralLearnerFlowDTO.setPassMark(mcContent.getPassMark().toString());
+ mcGeneralLearnerFlowDTO.setReportTitleLearner(mcContent.getReportTitle());
+
+ logger.debug("continue buildMcGeneralLearnerFlowDTO: " + mcContent);
+ mcGeneralLearnerFlowDTO.setTotalQuestionCount(new Integer(mcContent.getMcQueContents().size()).toString());
+ logger.debug("final mcGeneralLearnerFlowDTO: " + mcGeneralLearnerFlowDTO);
+ return mcGeneralLearnerFlowDTO;
+ }
+
+
+ public static List buildQuestionAndCandidateAnswersDTO(HttpServletRequest request, McContent mcContent, IMcService mcService)
+ {
+ logger.debug("starting buildQuestionAndCandidateAnswersDTO");
+ List questionAndCandidateAnswersList= new LinkedList();
+ logger.debug("mcContent uid : " + mcContent.getUid());
+
+ List listQuestionEntries=mcService.getAllQuestionEntries(mcContent.getUid());
+ logger.debug("listQuestionEntries : " + listQuestionEntries);
+
+ Iterator listQuestionEntriesIterator=listQuestionEntries.iterator();
+ while (listQuestionEntriesIterator.hasNext())
+ {
+ McQueContent mcQueContent=(McQueContent)listQuestionEntriesIterator.next();
+ logger.debug("mcQueContent : " + mcQueContent);
+
+ McLearnerAnswersDTO mcLearnerAnswersDTO= new McLearnerAnswersDTO();
+ logger.debug("mcQueContent uid: " + mcQueContent.getUid());
+
+ List listCandidateAnswers=mcService.findMcOptionNamesByQueId(mcQueContent.getUid());
+ logger.debug("listCandidateAnswers: " + listCandidateAnswers);
+ Map mapCandidateAnswers=convertToStringMap(listCandidateAnswers);
+ logger.debug("mapCandidateAnswers: " + mapCandidateAnswers);
+
+ List listCandidateAnswerUids=mcService.findMcOptionUidsByQueId(mcQueContent.getUid());
+ logger.debug("listCandidateAnswerUids: " + listCandidateAnswerUids);
+ Map mapCandidateAnswerUids=convertToStringMap(listCandidateAnswerUids);
+ logger.debug("mapCandidateAnswerUids: " + mapCandidateAnswerUids);
+
+ mcLearnerAnswersDTO.setQuestion(mcQueContent.getQuestion());
+ mcLearnerAnswersDTO.setDisplayOrder(mcQueContent.getDisplayOrder().toString());
+ mcLearnerAnswersDTO.setQuestionUid(mcQueContent.getUid().toString());
+
+ mcLearnerAnswersDTO.setWeight(mcQueContent.getWeight().toString());
+ mcLearnerAnswersDTO.setCandidateAnswerUids(mapCandidateAnswerUids);
+
+ mcLearnerAnswersDTO.setCandidateAnswers(mapCandidateAnswers);
+ logger.debug("current mcLearnerAnswersDTO: " + mcLearnerAnswersDTO);
+
+ logger.debug("current mcLearnerAnswersDTO: " + mcLearnerAnswersDTO);
+
+ questionAndCandidateAnswersList.add(mcLearnerAnswersDTO);
+ }
+
+ logger.debug("final questionAndCandidateAnswersList: " + questionAndCandidateAnswersList);
+ return questionAndCandidateAnswersList;
+ }
+
+
+ public static Map convertToStringMap(List list)
+ {
+ logger.debug("using convertToStringMap: " + list);
+ Map map= new TreeMap(new McStringComparator());
+
+ 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;
+ }
+
+
+
public static int getLearnerMarkAtLeast(Integer passMark, Map mapQuestionWeights)
{
logger.debug("doing getLearnerMarkAtLeast");
@@ -903,7 +1023,7 @@
*/
public static void cleanUpLearningSession(HttpServletRequest request)
{
- request.getSession().removeAttribute(USER_ID);
+ //request.getSession().removeAttribute(USER_ID);
request.getSession().removeAttribute(TOOL_CONTENT_ID);
request.getSession().removeAttribute(TOOL_SESSION_ID);
request.getSession().removeAttribute(QUESTION_LISTING_MODE);
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java,v
diff -u -r1.24 -r1.25
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java 26 Jun 2006 22:33:25 -0000 1.24
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningAction.java 20 Jul 2006 21:47:09 -0000 1.25
@@ -23,14 +23,18 @@
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 javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
import org.apache.struts.Globals;
@@ -44,14 +48,22 @@
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.McStringComparator;
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;
+import org.lamsfoundation.lams.tool.mc.service.McServiceProxy;
+import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
import org.lamsfoundation.lams.web.action.LamsDispatchAction;
+import org.lamsfoundation.lams.web.session.SessionManager;
+import org.lamsfoundation.lams.web.util.AttributeNames;
/**
* * @author Ozgur Demirtas
@@ -194,7 +206,6 @@
{
McUtils.cleanUpUserExceptions(request);
McAuthoringForm mcAuthoringForm = (McAuthoringForm) form;
- IMcService mcService =McUtils.getToolService(request);
AuthoringUtil.readData(request, mcAuthoringForm);
mcAuthoringForm.resetUserAction();
return null;
@@ -244,55 +255,70 @@
{
McUtils.cleanUpUserExceptions(request);
McLearningForm mcLearningForm = (McLearningForm) form;
- IMcService mcService =McUtils.getToolService(request);
+ IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext());
mcLearningForm.resetParameters();
- LearningUtil.readParameters(request, mcLearningForm);
+ String toolContentId=mcLearningForm.getToolContentId();
+ logger.debug("toolContentId: " + toolContentId);
if (mcLearningForm.getContinueOptionsCombined() != null)
{
- setContentInUse(request);
+ setContentInUse(request, toolContentId, mcService);
return continueOptionsCombined(mapping, form, request, response);
}
else if (mcLearningForm.getNextOptions() != null)
{
- setContentInUse(request);
+ setContentInUse(request, toolContentId, mcService);
return getNextOptions(mapping, form, request, response);
}
else if (mcLearningForm.getOptionCheckBoxSelected() != null)
{
- setContentInUse(request);
+ setContentInUse(request, toolContentId, mcService);
mcLearningForm.resetCommands();
LearningUtil.selectOptionsCheckBox(request,mcLearningForm, mcLearningForm.getQuestionIndex());
}
else if (mcLearningForm.getRedoQuestions() != null)
{
- setContentInUse(request);
+ setContentInUse(request, toolContentId, mcService);
return redoQuestions(mapping, form, request, response);
}
else if (mcLearningForm.getRedoQuestionsOk() != null)
{
- setContentInUse(request);
+ setContentInUse(request, toolContentId, mcService);
logger.debug("requested redoQuestionsOk, user is sure to redo the questions.");
mcLearningForm.resetCommands();
return redoQuestions(request, mcLearningForm, mapping);
}
else if (mcLearningForm.getViewAnswers() != null)
{
- setContentInUse(request);
+ setContentInUse(request, toolContentId, mcService);
return viewAnswers(mapping, form, request, response);
}
else if (mcLearningForm.getViewSummary() != null)
{
- setContentInUse(request);
+ setContentInUse(request, toolContentId, mcService);
return viewSummary(mapping, form, request, response);
}
else if (mcLearningForm.getLearnerFinished() != null)
{
logger.debug("requested learner finished, the learner should be directed to next activity.");
Long toolSessionId = (Long) request.getSession().getAttribute(TOOL_SESSION_ID);
- String userID=(String) request.getSession().getAttribute(USER_ID);
+
+ String userID = "";
+ HttpSession ss = SessionManager.getSession();
+ logger.debug("ss: " + ss);
+
+ if (ss != null)
+ {
+ UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ if ((user != null) && (user.getUserID() != null))
+ {
+ userID = user.getUserID().toString();
+ logger.debug("retrieved userId: " + userID);
+ }
+ }
+
logger.debug("attempting to leave/complete session with toolSessionId:" + toolSessionId + " and userID:"+userID);
McUtils.cleanUpSessionAbsolute(request);
@@ -383,7 +409,133 @@
return (mapping.findForward(LOAD_LEARNER));
}
+
+ protected Set parseLearnerInput(List learnerInput)
+ {
+ logger.debug("learnerInput: " + learnerInput);
+ Set questionUids= new HashSet();
+ Iterator listLearnerInputIterator=learnerInput.iterator();
+ while (listLearnerInputIterator.hasNext())
+ {
+ String input=(String)listLearnerInputIterator.next();
+ logger.debug("input: " + input);
+ int pos=input.indexOf("-");
+ logger.debug("pos: " + pos);
+ String questionUid=input.substring(0,pos);
+ logger.debug("questionUid: " + questionUid);
+ questionUids.add(questionUid);
+ }
+ logger.debug("final set questionUid: " + questionUids);
+ return questionUids;
+ }
+
+
+
+ protected List buildSelectedQuestionAndCandidateAnswersDTO(List learnerInput, Integer learnerMark,
+ Integer totalUserWeight, IMcService mcService)
+ {
+ logger.debug("mcService: " + mcService);
+ logger.debug("learnerInput: " + learnerInput);
+ int mark=0;
+ int userWeight=0;
+
+ Set questionUids=parseLearnerInput(learnerInput);
+ logger.debug("set questionUids: " + questionUids);
+
+ List questionAndCandidateAnswersList= new LinkedList();
+
+ Iterator setQuestionUidsIterator=questionUids.iterator();
+ while (setQuestionUidsIterator.hasNext())
+ {
+ McLearnerAnswersDTO mcLearnerAnswersDTO= new McLearnerAnswersDTO();
+ String questionUid=(String)setQuestionUidsIterator.next();
+ logger.debug("questionUid: " + questionUid);
+
+ McQueContent mcQueContent=mcService.findMcQuestionContentByUid(new Long(questionUid));
+ logger.debug("mcQueContent: " + mcQueContent);
+
+ logger.debug("mcQueContent text: " + mcQueContent.getQuestion());
+
+ mcLearnerAnswersDTO.setQuestion(mcQueContent.getQuestion());
+ mcLearnerAnswersDTO.setDisplayOrder(mcQueContent.getDisplayOrder().toString());
+ mcLearnerAnswersDTO.setWeight(mcQueContent.getWeight().toString());
+ mcLearnerAnswersDTO.setQuestionUid(mcQueContent.getUid().toString());
+
+ Map caMap= new TreeMap(new McStringComparator());
+ Map caIdsMap= new TreeMap(new McStringComparator());
+ Long mapIndex=new Long(1);
+
+ Iterator listLearnerInputIterator=learnerInput.iterator();
+ while (listLearnerInputIterator.hasNext())
+ {
+ String input=(String)listLearnerInputIterator.next();
+ logger.debug("input: " + input);
+ int pos=input.indexOf("-");
+ logger.debug("pos: " + pos);
+ String localQuestionUid=input.substring(0,pos);
+ logger.debug("localQuestionUid: " + localQuestionUid);
+
+ if (questionUid.equals(localQuestionUid))
+ {
+ logger.debug("equal uids found : " + localQuestionUid);
+ String caUid=input.substring(pos+1);
+ logger.debug("caUid: " + caUid);
+ McOptsContent mcOptsContent= mcService.findMcOptionsContentByUid(new Long(caUid));
+ logger.debug("mcOptsContent: " + mcOptsContent);
+ logger.debug("mcOptsContent text: " + mcOptsContent.getMcQueOptionText());
+ caMap.put(mapIndex.toString(), mcOptsContent.getMcQueOptionText());
+ caIdsMap.put(mapIndex.toString(), mcOptsContent.getUid().toString() );
+ mapIndex=new Long(mapIndex.longValue()+1);
+ }
+ }
+ logger.debug("current caMap: " + caMap);
+ logger.debug("current caIdsMap: " + caIdsMap);
+ mcLearnerAnswersDTO.setCandidateAnswers(caMap);
+
+ Long mcQueContentUid= mcQueContent.getUid();
+ logger.debug("mcQueContentUid: " + mcQueContentUid);
+
+ List correctOptions=(List) mcService.getPersistedSelectedOptions(mcQueContentUid);
+ logger.debug("correctOptions: " + correctOptions);
+ Map mapCorrectOptionUids=LearningUtil.buildMapCorrectOptionUids(correctOptions);
+ logger.debug("mapCorrectOptionUids: " + mapCorrectOptionUids);
+
+ boolean isEqual=LearningUtil.compareMapItems(mapCorrectOptionUids, caIdsMap);
+ logger.debug("isEqual: " + isEqual);
+ boolean isEqualCross=LearningUtil.compareMapsItemsCross(mapCorrectOptionUids, caIdsMap);
+ logger.debug("isEqualCross: " + isEqualCross);
+ boolean compareResult= isEqual && isEqualCross;
+ logger.debug("compareResult: " + compareResult);
+
+ mcLearnerAnswersDTO.setAttemptCorrect(new Boolean(compareResult).toString());
+ if (compareResult)
+ {
+ mcLearnerAnswersDTO.setFeedbackCorrect(mcQueContent.getFeedbackCorrect());
+ ++mark;
+ int weight=mcQueContent.getWeight().intValue();
+ logger.debug("weight: " + weight);
+ userWeight=userWeight + weight;
+ }
+ else
+ {
+ mcLearnerAnswersDTO.setFeedbackIncorrect(mcQueContent.getFeedbackIncorrect());
+ }
+ logger.debug("assesment complete");
+ logger.debug("mark:: " + mark);
+
+ questionAndCandidateAnswersList.add(mcLearnerAnswersDTO);
+ }
+ logger.debug("final questionAndCandidateAnswersList: " + questionAndCandidateAnswersList);
+ logger.debug("final mark: " + mark);
+ logger.debug("final userWeight: " + userWeight);
+ learnerMark= new Integer(mark);
+ totalUserWeight= new Integer(userWeight);
+
+ return questionAndCandidateAnswersList;
+ }
+
+
/**
* responses to learner when they answer all the questions on a single page
* continueOptionsCombined(ActionMapping mapping,
@@ -405,43 +557,55 @@
McUtils.cleanUpUserExceptions(request);
logger.debug("dispatching continueOptionsCombined...");
McLearningForm mcLearningForm = (McLearningForm) form;
- IMcService mcService =McUtils.getToolService(request);
+ IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext());
+ logger.debug("retrieving mcService from proxy: " + mcService);
+ String[] checkedCa=mcLearningForm.getCheckedCa();
+ logger.debug("checkedCa: " + checkedCa);
+ logger.debug("checkedCa length: " + checkedCa.length );
+
+ List learnerInput= new LinkedList();
+ for (int i=0; i < checkedCa.length ; i++)
+ {
+ String currentCa=checkedCa[i];
+ logger.debug("currentCa: " + currentCa);
+ learnerInput.add(currentCa);
+ }
+ logger.debug("learnerInput: " + learnerInput);
+
+ String toolContentId=mcLearningForm.getToolContentId();
+ logger.debug("toolContentId: " + toolContentId);
+
+ Integer learnerMark= new Integer(0);
+ Integer totalUserWeight= new Integer(0);
+
+ List selectedQuestionAndCandidateAnswersDTO=buildSelectedQuestionAndCandidateAnswersDTO(learnerInput,learnerMark,
+ totalUserWeight, mcService);
+ logger.debug("selectedQuestionAndCandidateAnswersDTO: " + selectedQuestionAndCandidateAnswersDTO);
+ request.setAttribute(LIST_SELECTED_QUESTION_CANDIDATEANSWERS_DTO, selectedQuestionAndCandidateAnswersDTO);
+ logger.debug("LIST_SELECTED_QUESTION_CANDIDATEANSWERS_DTO: " + request.getAttribute(LIST_SELECTED_QUESTION_CANDIDATEANSWERS_DTO));
+ logger.debug("learnerMark becomes: " + learnerMark);
+ logger.debug("totalUserWeight becomes: " + totalUserWeight);
+
+
/* process the answers */
- Map mapGeneralCheckedOptionsContent=(Map) request.getSession().getAttribute(MAP_GENERAL_CHECKED_OPTIONS_CONTENT);
- logger.debug("final mapGeneralCheckedOptionsContent: " + mapGeneralCheckedOptionsContent);
-
- Long toolContentId=(Long) request.getSession().getAttribute(TOOL_CONTENT_ID);
- logger.debug("toolContentId: " + toolContentId);
-
- McContent mcContent=mcService.retrieveMc(toolContentId);
+ McContent mcContent=mcService.retrieveMc(new Long(toolContentId));
logger.debug("mcContent: " + mcContent);
-
- logger.debug("will assess");
- Integer passMark=(Integer) request.getSession().getAttribute(PASSMARK);
- logger.debug("passMark: " + passMark);
- Map mapLearnerAssessmentResults=LearningUtil.assess(request, mapGeneralCheckedOptionsContent, toolContentId);
- logger.debug("mapLearnerAssessmentResults: " + mapLearnerAssessmentResults);
- logger.debug("assesment complete");
+ McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO=LearningUtil.buildMcGeneralLearnerFlowDTO(mcContent);
+ mcGeneralLearnerFlowDTO.setLearnerMark(learnerMark.toString());
- int mark=LearningUtil.getMark(mapLearnerAssessmentResults);
- logger.debug("mark: " + mark);
- request.getSession().setAttribute(LEARNER_MARK, new Integer(mark).toString());
-
- Map mapQuestionWeights =(Map) request.getSession().getAttribute(MAP_QUESTION_WEIGHTS);
- logger.debug("mapQuestionWeights: " + mapQuestionWeights);
+ Integer passMark=mcContent.getPassMark();
+ logger.debug("passMark: " + passMark);
+ mcGeneralLearnerFlowDTO.setUserOverPassMark(new Boolean(false).toString());
- mcLearningForm.setUserOverPassMark(new Boolean(false).toString());
- mcLearningForm.setPassMarkApplicable(new Boolean(false).toString());
+ mcGeneralLearnerFlowDTO.setPassMarkApplicable(new Boolean(false).toString());
boolean passed=false;
if ((passMark != null))
{
- mcLearningForm.setPassMarkApplicable(new Boolean(true).toString());
- int totalUserWeight=LearningUtil.calculateWeights(mapLearnerAssessmentResults, mapQuestionWeights);
- logger.debug("totalUserWeight: " + totalUserWeight);
-
- if (totalUserWeight < passMark.intValue())
+ mcGeneralLearnerFlowDTO.setPassMarkApplicable(new Boolean(true).toString());
+
+ if (totalUserWeight.intValue() < passMark.intValue())
{
logger.debug("USER FAILED");
logger.debug("totalUserWeight is less than passmark: " + totalUserWeight + " < " + passMark.intValue());
@@ -451,14 +615,14 @@
{
logger.debug("USER PASSED");
passed=true;
- mcLearningForm.setUserOverPassMark(new Boolean(true).toString());
+ mcGeneralLearnerFlowDTO.setUserOverPassMark(new Boolean(true).toString());
}
}
if (passMark == null)
{
- mcLearningForm.setPassMarkApplicable(new Boolean(false).toString());
+ mcGeneralLearnerFlowDTO.setPassMarkApplicable(new Boolean(false).toString());
}
/*
@@ -469,18 +633,34 @@
}
*/
- Long toolSessionId=(Long)request.getSession().getAttribute(TOOL_SESSION_ID);
+ String toolSessionId=mcLearningForm.getToolSessionId();
logger.debug("toolSessionId: " + toolSessionId);
- McSession mcSession=mcService.retrieveMcSession(toolSessionId);
+
+ McSession mcSession=mcService.retrieveMcSession(new Long(toolSessionId));
logger.debug("retrieving mcSession: " + mcSession);
Long toolSessionUid=mcSession.getUid();
logger.debug("toolSessionUid: " + toolSessionUid);
boolean isUserDefined=false;
- String userID=(String)request.getSession().getAttribute(USER_ID);
+
+ String userID = "";
+ HttpSession ss = SessionManager.getSession();
+ logger.debug("ss: " + ss);
+
+ if (ss != null)
+ {
+ UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ if ((user != null) && (user.getUserID() != null))
+ {
+ userID = user.getUserID().toString();
+ logger.debug("retrieved userId: " + userID);
+ }
+ }
+
+
logger.debug("userID: " + userID);
McQueUsr existingMcQueUsr=mcService.getMcUserBySession(new Long(userID), mcSession.getUid());
logger.debug("existingMcQueUsr: " + existingMcQueUsr);
@@ -493,7 +673,7 @@
McQueUsr mcQueUsr=null;
if (isUserDefined == false)
{
- mcQueUsr=LearningUtil.createUser(request);
+ mcQueUsr=LearningUtil.createUser(request, mcService, new Long(toolSessionId));
logger.debug("created user in the db: " + mcQueUsr);
}
else
@@ -523,8 +703,9 @@
logger.debug("new highestAttemptOrder: " + highestAttemptOrder);
+ /*
logger.debug("passed: " + passed);
- LearningUtil.createAttempt(request, mcQueUsr, mapGeneralCheckedOptionsContent, mark, passed, new Integer(highestAttemptOrder).intValue(), mapLearnerAssessmentResults);
+ LearningUtil.createAttempt(request, mcQueUsr, mapGeneralCheckedOptionsContent, learnerMark.intValue(), passed, new Integer(highestAttemptOrder).intValue(), mapLearnerAssessmentResults);
logger.debug("created user attempt in the db");
logger.debug("before getLearnerMarkAtLeast: passMark" + passMark);
@@ -533,10 +714,17 @@
int learnerMarkAtLeast=LearningUtil.getLearnerMarkAtLeast(passMark,mapQuestionWeights);
logger.debug("learnerMarkAtLeast:" + learnerMarkAtLeast);
request.getSession().setAttribute(LEARNER_MARK_ATLEAST, new Integer(learnerMarkAtLeast).toString());
+ mcGeneralLearnerFlowDTO.setLearnerMarkAtLeast (new Integer(learnerMarkAtLeast).toString());
+ */
+
logger.debug("user over passmark:" + mcLearningForm.getUserOverPassMark());
logger.debug("is passmark applicable:" + mcLearningForm.getPassMarkApplicable());
mcLearningForm.resetCommands();
+
+ request.setAttribute(MC_GENERAL_LEARNER_FLOW_DTO, mcGeneralLearnerFlowDTO);
+ logger.debug("MC_GENERAL_LEARNER_FLOW_DTO: " + request.getAttribute(MC_GENERAL_LEARNER_FLOW_DTO));
+
return (mapping.findForward(INDIVIDUAL_REPORT));
}
@@ -562,8 +750,8 @@
McUtils.cleanUpUserExceptions(request);
logger.debug("dispatching getNextOptions...");
McLearningForm mcLearningForm = (McLearningForm) form;
- IMcService mcService =McUtils.getToolService(request);
-
+ IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext());
+
String currentQuestionIndex=(String)request.getSession().getAttribute(CURRENT_QUESTION_INDEX);
logger.debug("currentQuestionIndex:" + currentQuestionIndex);
@@ -577,14 +765,15 @@
{
logger.debug("totalQuestionCount has been reached :" + totalQuestionCount);
request.getSession().setAttribute(TOTAL_COUNT_REACHED, new Boolean(true).toString());
- }
+ }
- mcLearningForm.resetCommands();
+ mcLearningForm.resetCommands();
- int newQuestionIndex=new Integer(currentQuestionIndex).intValue() + 1;
- request.getSession().setAttribute(CURRENT_QUESTION_INDEX, new Integer(newQuestionIndex).toString());
- logger.debug("updated questionIndex:" + request.getSession().getAttribute(CURRENT_QUESTION_INDEX));
- return (mapping.findForward(LOAD_LEARNER));
+ int newQuestionIndex=new Integer(currentQuestionIndex).intValue() + 1;
+ request.getSession().setAttribute(CURRENT_QUESTION_INDEX, new Integer(newQuestionIndex).toString());
+ logger.debug("updated questionIndex:" + request.getSession().getAttribute(CURRENT_QUESTION_INDEX));
+
+ return (mapping.findForward(LOAD_LEARNER));
}
@@ -609,7 +798,7 @@
McUtils.cleanUpUserExceptions(request);
logger.debug("dispatching redoQuestions...");
McLearningForm mcLearningForm = (McLearningForm) form;
- IMcService mcService =McUtils.getToolService(request);
+ IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext());
request.getSession().setAttribute(CURRENT_QUESTION_INDEX, "1");
request.getSession().setAttribute(TOTAL_COUNT_REACHED, new Boolean(false).toString());
@@ -620,9 +809,21 @@
McSession mcSession=mcService.retrieveMcSession(toolSessionId);
logger.debug("retrieving mcSession: " + mcSession);
- String userID=(String)request.getSession().getAttribute(USER_ID);
- logger.debug("userID: " + userID);
-
+ String userID = "";
+ HttpSession ss = SessionManager.getSession();
+ logger.debug("ss: " + ss);
+
+ if (ss != null)
+ {
+ UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ if ((user != null) && (user.getUserID() != null))
+ {
+ userID = user.getUserID().toString();
+ logger.debug("retrieved userId: " + userID);
+ }
+ }
+
+
McQueUsr mcQueUsr=mcService.getMcUserBySession(new Long(userID), mcSession.getUid());
logger.debug("mcQueUsr: " + mcQueUsr);
@@ -659,7 +860,7 @@
McUtils.cleanUpUserExceptions(request);
logger.debug("dispatching viewAnswers...");
McLearningForm mcLearningForm = (McLearningForm) form;
- IMcService mcService =McUtils.getToolService(request);
+ IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext());
String totalQuestionCount= (String) request.getSession().getAttribute(TOTAL_QUESTION_COUNT);
logger.debug("totalQuestionCount: " + totalQuestionCount);
@@ -844,7 +1045,7 @@
McUtils.cleanUpUserExceptions(request);
logger.debug("dispatching viewSummary...");
McLearningForm mcLearningForm = (McLearningForm) form;
- IMcService mcService =McUtils.getToolService(request);
+ IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext());
int countSessionComplete=mcService.countSessionComplete();
int topMark=LearningUtil.getTopMark(request);
@@ -873,13 +1074,12 @@
*
* @param request
*/
- protected void setContentInUse(HttpServletRequest request)
+ protected void setContentInUse(HttpServletRequest request, String toolContentId, IMcService mcService)
{
- IMcService mcService =McUtils.getToolService(request);
- Long toolContentId=(Long)request.getSession().getAttribute(TOOL_CONTENT_ID);
- logger.debug("toolContentId:" + toolContentId);
+ logger.debug("starting setContentInUse");
+ logger.debug("toolContentId:" + toolContentId);
- McContent mcContent=mcService.retrieveMc(toolContentId);
+ McContent mcContent=mcService.retrieveMc(new Long(toolContentId));
logger.debug("mcContent:" + mcContent);
mcContent.setContentInUse(true);
logger.debug("content has been set to inuse");
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java,v
diff -u -r1.15 -r1.16
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java 9 Jun 2006 16:43:07 -0000 1.15
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningForm.java 20 Jul 2006 21:47:09 -0000 1.16
@@ -48,6 +48,14 @@
protected String donePreview;
protected String doneLearnerProgress;
+
+ protected String[] checkedCa;
+ protected String toolContentId;
+ protected String toolContentUID;
+ protected String toolSessionId;
+ protected String learningMode;
+ protected String currentQuestionIndex;
+
protected String userOverPassMark;
protected String passMarkApplicable;
@@ -281,4 +289,81 @@
public void setPassMarkApplicable(String passMarkApplicable) {
this.passMarkApplicable = passMarkApplicable;
}
+ /**
+ * @return Returns the checkedCa.
+ */
+ public String[] getCheckedCa() {
+ return checkedCa;
+ }
+ /**
+ * @param checkedCa The checkedCa to set.
+ */
+ public void setCheckedCa(String[] checkedCa) {
+ this.checkedCa = checkedCa;
+ }
+
+ /**
+ * @return Returns the toolContentId.
+ */
+ public String getToolContentId() {
+ return toolContentId;
+ }
+ /**
+ * @param toolContentId The toolContentId to set.
+ */
+ public void setToolContentId(String toolContentId) {
+ this.toolContentId = toolContentId;
+ }
+ /**
+ * @return Returns the toolSessionId.
+ */
+ public String getToolSessionId() {
+ return toolSessionId;
+ }
+ /**
+ * @param toolSessionId The toolSessionId to set.
+ */
+ public void setToolSessionId(String toolSessionId) {
+ this.toolSessionId = toolSessionId;
+ }
+
+ /**
+ * @return Returns the learningMode.
+ */
+ public String getLearningMode() {
+ return learningMode;
+ }
+ /**
+ * @param learningMode The learningMode to set.
+ */
+ public void setLearningMode(String learningMode) {
+ this.learningMode = learningMode;
+ }
+
+ /**
+ * @return Returns the toolContentUID.
+ */
+ public String getToolContentUID() {
+ return toolContentUID;
+ }
+ /**
+ * @param toolContentUID The toolContentUID to set.
+ */
+ public void setToolContentUID(String toolContentUID) {
+ this.toolContentUID = toolContentUID;
+ }
+
+ /**
+ * @return Returns the currentQuestionIndex.
+ */
+ public String getCurrentQuestionIndex() {
+ return currentQuestionIndex;
+ }
+ /**
+ * @param currentQuestionIndex The currentQuestionIndex to set.
+ */
+ public void setCurrentQuestionIndex(String currentQuestionIndex) {
+ this.currentQuestionIndex = currentQuestionIndex;
+ }
+
}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java,v
diff -u -r1.49 -r1.50
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java 14 Jul 2006 05:04:11 -0000 1.49
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/McLearningStarterAction.java 20 Jul 2006 21:47:09 -0000 1.50
@@ -23,6 +23,7 @@
package org.lamsfoundation.lams.tool.mc.web;
import java.io.IOException;
+import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@@ -42,6 +43,8 @@
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.McLearnerStarterDTO;
import org.lamsfoundation.lams.tool.mc.McUtils;
import org.lamsfoundation.lams.tool.mc.pojos.McContent;
import org.lamsfoundation.lams.tool.mc.pojos.McQueUsr;
@@ -181,51 +184,37 @@
McUtils.cleanUpSessionAbsolute(request);
+ McLearnerStarterDTO mcLearnerStarterDTO= new McLearnerStarterDTO();
+
Map mapQuestionsContent= new TreeMap(new McComparator());
Map mapAnswers= new TreeMap(new McComparator());
- IMcService mcService = McUtils.getToolService(request);
- logger.debug("retrieving mcService from session: " + mcService);
- if (mcService == null)
- {
- mcService = McServiceProxy.getMcService(getServlet().getServletContext());
- logger.debug("retrieving mcService from proxy: " + mcService);
- request.getSession().setAttribute(TOOL_SERVICE, mcService);
- }
+ IMcService mcService = McServiceProxy.getMcService(getServlet().getServletContext());
+ logger.debug("retrieving mcService from proxy: " + mcService);
McLearningForm mcLearningForm = (McLearningForm) form;
mcLearningForm.setPassMarkApplicable(new Boolean(false).toString());
mcLearningForm.setUserOverPassMark(new Boolean(false).toString());
-
- /*
- * initialize available question display modes in the session
- */
- request.getSession().setAttribute(QUESTION_LISTING_MODE_SEQUENTIAL,QUESTION_LISTING_MODE_SEQUENTIAL);
- request.getSession().setAttribute(QUESTION_LISTING_MODE_COMBINED, QUESTION_LISTING_MODE_COMBINED);
+ mcLearnerStarterDTO.setQuestionListingMode(QUESTION_LISTING_MODE_COMBINED);
- request.getSession().setAttribute(QUESTIONS_WITHNO_OPTIONS, new Boolean(false));
-
- /*
- * persist time zone information to session scope.
- */
- McUtils.persistTimeZone(request);
- ActionForward validateParameters=validateParameters(request, mapping);
+ ActionForward validateParameters=validateParameters(request, mcLearningForm, mapping);
logger.debug("validateParameters: " + validateParameters);
if (validateParameters != null)
{
return validateParameters;
}
-
- Long toolSessionID=(Long) request.getSession().getAttribute(AttributeNames.PARAM_TOOL_SESSION_ID);
+
+ String toolSessionID=mcLearningForm.getToolSessionId();
logger.debug("retrieved toolSessionID: " + toolSessionID);
+
/*
* by now, we made sure that the passed tool session id exists in the db as a new record
* Make sure we can retrieve it and the relavent content
*/
- McSession mcSession=mcService.retrieveMcSession(toolSessionID);
+ McSession mcSession=mcService.retrieveMcSession(new Long(toolSessionID));
logger.debug("retrieving mcSession: " + mcSession);
if (mcSession == null)
@@ -248,7 +237,7 @@
McUtils.cleanUpSessionAbsolute(request);
logger.debug("error: The tool expects mcContent.");
persistError(request,"error.content.doesNotExist");
- request.getSession().setAttribute(USER_EXCEPTION_CONTENT_DOESNOTEXIST, new Boolean(true).toString());
+ //request.getSession().setAttribute(USER_EXCEPTION_CONTENT_DOESNOTEXIST, new Boolean(true).toString());
return (mapping.findForward(ERROR_LIST));
}
@@ -257,13 +246,10 @@
* The content we retrieved above must have been created before in Authoring time.
* And the passed tool session id already refers to it.
*/
- setupAttributes(request, mcContent);
-
- request.getSession().setAttribute(TOOL_CONTENT_ID, mcContent.getMcContentId());
- logger.debug("using TOOL_CONTENT_ID: " + mcContent.getMcContentId());
+ setupAttributes(request, mcContent, mcLearnerStarterDTO);
- request.getSession().setAttribute(TOOL_CONTENT_UID, mcContent.getUid());
- logger.debug("using TOOL_CONTENT_UID: " + mcContent.getUid());
+ mcLearningForm.setToolContentId(mcContent.getMcContentId().toString());
+ mcLearningForm.setToolContentUID(mcContent.getUid().toString());
/* 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.
@@ -276,19 +262,21 @@
/* ? CHECK THIS: how do we determine whether preview is requested? Mode is not enough on its own.*/
/*handle PREVIEW mode*/
- String mode=(String) request.getSession().getAttribute(LEARNING_MODE);
+ //String mode=(String) request.getSession().getAttribute(LEARNING_MODE);
+ String mode=mcLearningForm.getLearningMode();
+
logger.debug("mode: " + mode);
if ((mode != null) && (mode.equals("author")))
{
logger.debug("Author requests for a preview of the content.");
logger.debug("existing mcContent:" + mcContent);
- commonContentSetup(request, mcContent);
+ commonContentSetup(request, mcContent, mcService);
/*only allowing combined view in the preview mode. Might be improved to support sequential view as well. */
- request.getSession().setAttribute(QUESTION_LISTING_MODE, QUESTION_LISTING_MODE_COMBINED);
+ mcLearnerStarterDTO.setQuestionListingMode(QUESTION_LISTING_MODE_COMBINED);
/* PREVIEW_ONLY for jsp*/
- //request.getSession().setAttribute(PREVIEW_ONLY, new Boolean(true).toString());
+
request.getSession().setAttribute(CURRENT_QUESTION_INDEX, "1");
McLearningAction mcLearningAction= new McLearningAction();
@@ -305,7 +293,7 @@
if ((userId != null) && (mode.equals("teacher")))
{
logger.debug("request is for learner progress");
- commonContentSetup(request, mcContent);
+ commonContentSetup(request, mcContent, mcService);
/* LEARNER_PROGRESS for jsp*/
request.getSession().setAttribute(LEARNER_PROGRESS_USERID, userId);
@@ -351,7 +339,7 @@
{
McUtils.cleanUpSessionAbsolute(request);
logger.debug("warning to learner: the activity is offline.");
- request.getSession().setAttribute(USER_EXCEPTION_CONTENT_RUNOFFLINE, new Boolean(true).toString());
+ //request.getSession().setAttribute(USER_EXCEPTION_CONTENT_RUNOFFLINE, new Boolean(true).toString());
persistError(request,"label.learning.runOffline");
return (mapping.findForward(ERROR_LIST));
}
@@ -368,33 +356,42 @@
/*
* fetch question content from content
*/
- mapQuestionsContent=LearningUtil.buildQuestionContentMap(request,mcContent);
- logger.debug("mapQuestionsContent: " + mapQuestionsContent);
- request.getSession().setAttribute(MAP_QUESTION_CONTENT_LEARNER, mapQuestionsContent);
- logger.debug("MAP_QUESTION_CONTENT_LEARNER: " + request.getSession().getAttribute(MAP_QUESTION_CONTENT_LEARNER));
- logger.debug("mcContent has : " + mapQuestionsContent.size() + " entries.");
- request.getSession().setAttribute(TOTAL_QUESTION_COUNT, new Long(mapQuestionsContent.size()).toString());
-
+ List listQuestionAndCandidateAnswersDTO=LearningUtil.buildQuestionAndCandidateAnswersDTO(request, mcContent, mcService);
+ logger.debug("listQuestionAndCandidateAnswersDTO: " + listQuestionAndCandidateAnswersDTO);
+ request.setAttribute(LIST_QUESTION_CANDIDATEANSWERS_DTO, listQuestionAndCandidateAnswersDTO);
+ logger.debug("LIST_QUESTION_CANDIDATEANSWERS_DTO: " + request.getAttribute(LIST_QUESTION_CANDIDATEANSWERS_DTO));
+
+ McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO=LearningUtil.buildMcGeneralLearnerFlowDTO(mcContent);
+ request.setAttribute(MC_GENERAL_LEARNER_FLOW_DTO, mcGeneralLearnerFlowDTO);
+ logger.debug("MC_GENERAL_LEARNER_FLOW_DTO: " + request.getAttribute(MC_GENERAL_LEARNER_FLOW_DTO));
+
request.getSession().setAttribute(CURRENT_QUESTION_INDEX, "1");
logger.debug("CURRENT_QUESTION_INDEX: " + request.getSession().getAttribute(CURRENT_QUESTION_INDEX));
- logger.debug("final Options Map for the first question: " + request.getSession().getAttribute(MAP_OPTIONS_CONTENT));
/*also prepare data into mapGeneralOptionsContent for combined answers view */
- Map mapGeneralOptionsContent=AuthoringUtil.generateGeneralOptionsContentMap(request, mcContent);
- logger.debug("returned mapGeneralOptionsContent: " + mapGeneralOptionsContent);
- request.getSession().setAttribute(MAP_GENERAL_OPTIONS_CONTENT, mapGeneralOptionsContent);
/*
* 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
*
*/
- String userID=(String) request.getSession().getAttribute(USER_ID);
- logger.debug("userID:" + userID);
+
+ String userID = "";
+ HttpSession ss = SessionManager.getSession();
+ logger.debug("ss: " + ss);
- //McQueUsr mcQueUsr=mcService.retrieveMcQueUsr(new Long(userID));
+ if (ss != null)
+ {
+ UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ if ((user != null) && (user.getUserID() != null))
+ {
+ userID = user.getUserID().toString();
+ logger.debug("retrieved userId: " + userID);
+ }
+ }
+
McQueUsr mcQueUsr=mcService.getMcUserBySession(new Long(userID), mcSession.getUid());
logger.debug("mcQueUsr:" + mcQueUsr);
@@ -409,22 +406,24 @@
if (highestAttemptOrder == 0)
highestAttemptOrder=1;
logger.debug("highestAttemptOrder: " + highestAttemptOrder);
- request.getSession().setAttribute(LEARNER_LAST_ATTEMPT_ORDER,new Integer(highestAttemptOrder).toString());
+ //request.getSession().setAttribute(LEARNER_LAST_ATTEMPT_ORDER,new Integer(highestAttemptOrder).toString());
int learnerBestMark=LearningUtil.getHighestMark(request, queUsrId);
logger.debug("learnerBestMark: " + learnerBestMark);
- request.getSession().setAttribute(LEARNER_BEST_MARK,new Integer(learnerBestMark).toString());
+ //request.getSession().setAttribute(LEARNER_BEST_MARK,new Integer(learnerBestMark).toString());
}
else
{
logger.debug("mcQueUsr is not available in the db:" + mcQueUsr);
- request.getSession().setAttribute(LEARNER_LAST_ATTEMPT_ORDER,new Integer(1).toString());
- request.getSession().setAttribute(LEARNER_BEST_MARK,new Integer(0).toString());
+ //request.getSession().setAttribute(LEARNER_LAST_ATTEMPT_ORDER,new Integer(1).toString());
+ //request.getSession().setAttribute(LEARNER_BEST_MARK,new Integer(0).toString());
}
- String learningMode=(String) request.getSession().getAttribute(LEARNING_MODE);
+ String learningMode=mcLearningForm.getLearningMode();
logger.debug("users learning mode is: " + learningMode);
+ request.setAttribute(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) && learningMode.equals("learner"))
{
@@ -434,9 +433,10 @@
logger.debug("mcUserSession: " + mcUserSession);
String userSessionId=mcUserSession.getMcSessionId().toString();
logger.debug("userSessionId: " + userSessionId);
- Long toolSessionId=(Long)request.getSession().getAttribute(TOOL_SESSION_ID);
+ String toolSessionId=mcLearningForm.getToolSessionId();
logger.debug("current toolSessionId: " + toolSessionId);
- if (toolSessionId.toString().equals(userSessionId))
+
+ if (toolSessionId.equals(userSessionId))
{
logger.debug("the user's session id AND user id exists in the tool tables go to redo questions. " + toolSessionId + " mcQueUsr: " +
mcQueUsr + " user id: " + mcQueUsr.getQueUsrId());
@@ -461,6 +461,7 @@
return mcLearningAction.viewAnswers(mapping, form, request, response);
}
logger.debug("just presenting standard learner screen");
+ request.setAttribute(MC_LEARNER_STARTER_DTO, mcLearnerStarterDTO);
return (mapping.findForward(LOAD_LEARNER));
}
@@ -472,25 +473,21 @@
* @param request
* @param mcContent
*/
- protected void commonContentSetup(HttpServletRequest request, McContent mcContent)
+ protected void commonContentSetup(HttpServletRequest request, McContent mcContent, IMcService mcService)
{
Map mapQuestionsContent= new TreeMap(new McComparator());
- mapQuestionsContent=LearningUtil.buildQuestionContentMap(request,mcContent);
- logger.debug("mapQuestionsContent: " + mapQuestionsContent);
- request.getSession().setAttribute(MAP_QUESTION_CONTENT_LEARNER, mapQuestionsContent);
- logger.debug("MAP_QUESTION_CONTENT_LEARNER: " + request.getSession().getAttribute(MAP_QUESTION_CONTENT_LEARNER));
- logger.debug("mcContent has : " + mapQuestionsContent.size() + " entries.");
- request.getSession().setAttribute(TOTAL_QUESTION_COUNT, new Long(mapQuestionsContent.size()).toString());
+ List listQuestionAndCandidateAnswersDTO=LearningUtil.buildQuestionAndCandidateAnswersDTO(request, mcContent, mcService);
+ logger.debug("listQuestionAndCandidateAnswersDTO: " + listQuestionAndCandidateAnswersDTO);
+ request.setAttribute(LIST_QUESTION_CANDIDATEANSWERS_DTO, listQuestionAndCandidateAnswersDTO);
+ logger.debug("LIST_QUESTION_CANDIDATEANSWERS_DTO: " + request.getAttribute(LIST_QUESTION_CANDIDATEANSWERS_DTO));
+ McGeneralLearnerFlowDTO mcGeneralLearnerFlowDTO=LearningUtil.buildMcGeneralLearnerFlowDTO(mcContent);
+ request.setAttribute(MC_GENERAL_LEARNER_FLOW_DTO, mcGeneralLearnerFlowDTO);
+ logger.debug("MC_GENERAL_LEARNER_FLOW_DTO: " + request.getAttribute(MC_GENERAL_LEARNER_FLOW_DTO));
+
request.getSession().setAttribute(CURRENT_QUESTION_INDEX, "1");
logger.debug("CURRENT_QUESTION_INDEX: " + request.getSession().getAttribute(CURRENT_QUESTION_INDEX));
- logger.debug("final Options Map for the first question: " + request.getSession().getAttribute(MAP_OPTIONS_CONTENT));
-
- /*also prepare data into mapGeneralOptionsContent for combined answers view */
- Map mapGeneralOptionsContent=AuthoringUtil.generateGeneralOptionsContentMap(request, mcContent);
- logger.debug("returned mapGeneralOptionsContent: " + mapGeneralOptionsContent);
- request.getSession().setAttribute(MAP_GENERAL_OPTIONS_CONTENT, mapGeneralOptionsContent);
}
@@ -501,59 +498,31 @@
* @param request
* @param mcContent
*/
- protected void setupAttributes(HttpServletRequest request, McContent mcContent)
+ protected void setupAttributes(HttpServletRequest request, McContent mcContent, McLearnerStarterDTO mcLearnerStarterDTO)
{
- /* returns Integer: can be 0 or greater than 0, 0 is no passmark, otherwise there is a passmark. */
- logger.debug("PASSMARK: " + mcContent.getPassMark());
- if (mcContent.getPassMark() != null)
- {
- int passMark=mcContent.getPassMark().intValue();
- request.getSession().setAttribute(PASSMARK, mcContent.getPassMark());
- }
- else
- {
- request.getSession().setAttribute(PASSMARK, new Integer(0));
- }
-
- request.getSession().setAttribute(IS_SHOW_LEARNERS_REPORT, new Boolean(mcContent.isShowReport()).toString());
- logger.debug("IS_SHOW_LEARNERS_REPORT: " + new Boolean(mcContent.isShowReport()).toString());
-
/* same as 1 page per question */
logger.debug("IS_QUESTIONS_SEQUENCED: " + mcContent.isQuestionsSequenced());
if (mcContent.isQuestionsSequenced())
{
- request.getSession().setAttribute(QUESTION_LISTING_MODE, QUESTION_LISTING_MODE_SEQUENTIAL);
+ mcLearnerStarterDTO.setQuestionListingMode(QUESTION_LISTING_MODE_SEQUENTIAL);
}
else
{
- request.getSession().setAttribute(QUESTION_LISTING_MODE, QUESTION_LISTING_MODE_COMBINED);
+ mcLearnerStarterDTO.setQuestionListingMode(QUESTION_LISTING_MODE_COMBINED);
}
- logger.debug("QUESTION_LISTING_MODE: " + request.getSession().getAttribute(QUESTION_LISTING_MODE));
+ mcLearnerStarterDTO.setActivityTitle(mcContent.getTitle());
- logger.debug("IS_RETRIES: " + new Boolean(mcContent.isRetries()).toString());
- request.getSession().setAttribute(IS_RETRIES, new Boolean(mcContent.isRetries()).toString());
-
- logger.debug("REPORT_TITLE_LEARNER: " + mcContent.getReportTitle());
- request.getSession().setAttribute(REPORT_TITLE_LEARNER,mcContent.getReportTitle());
-
- logger.debug("IS_CONTENT_IN_USE: " + mcContent.isContentInUse());
- request.getSession().setAttribute(IS_CONTENT_IN_USE, new Boolean(mcContent.isContentInUse()).toString());
-
- request.getSession().setAttribute(ACTIVITY_TITLE, mcContent.getTitle());
- request.getSession().setAttribute(ACTIVITY_INSTRUCTIONS, mcContent.getInstructions());
-
-
/*
* Is the tool activity been checked as Run Offline in the property inspector?
*/
logger.debug("IS_TOOL_ACTIVITY_OFFLINE: " + mcContent.isRunOffline());
- request.getSession().setAttribute(IS_TOOL_ACTIVITY_OFFLINE, new Boolean(mcContent.isRunOffline()).toString());
+ mcLearnerStarterDTO.setToolActivityOffline(new Boolean(mcContent.isRunOffline()).toString());
/* the following attributes are unused for the moment.
* from here...
*/
-
+ /*
logger.debug("IS_USERNAME_VISIBLE: " + mcContent.isUsernameVisible());
request.getSession().setAttribute(IS_USERNAME_VISIBLE, new Boolean(mcContent.isUsernameVisible()).toString());
@@ -581,11 +550,12 @@
Map mapQuestionWeights=LearningUtil.buildWeightsMap(request, mcContent.getMcContentId());
request.getSession().setAttribute(MAP_QUESTION_WEIGHTS, mapQuestionWeights);
logger.debug("MAP_QUESTION_WEIGHTS: " + mapQuestionWeights);
+ */
/* .. till here */
}
- protected ActionForward validateParameters(HttpServletRequest request, ActionMapping mapping)
+ protected ActionForward validateParameters(HttpServletRequest request, McLearningForm mcLearningForm, ActionMapping mapping)
{
/*
* obtain and setup the current user's data
@@ -602,7 +572,6 @@
{
userID = user.getUserID().toString();
logger.debug("retrieved userId: " + userID);
- request.getSession().setAttribute(USER_ID, userID);
}
}
@@ -615,7 +584,6 @@
if ((strToolSessionId == null) || (strToolSessionId.length() == 0))
{
McUtils.cleanUpSessionAbsolute(request);
- request.getSession().setAttribute(USER_EXCEPTION_TOOLSESSIONID_REQUIRED, new Boolean(true).toString());
persistError(request, "error.toolSessionId.required");
return (mapping.findForward(ERROR_LIST));
}
@@ -625,12 +593,11 @@
{
toolSessionId=new Long(strToolSessionId).longValue();
logger.debug("passed TOOL_SESSION_ID : " + new Long(toolSessionId));
- request.getSession().setAttribute(TOOL_SESSION_ID,new Long(toolSessionId));
+ mcLearningForm.setToolSessionId(new Long(toolSessionId).toString());
}
catch(NumberFormatException e)
{
McUtils.cleanUpSessionAbsolute(request);
- request.getSession().setAttribute(USER_EXCEPTION_NUMBERFORMAT, new Boolean(true).toString());
persistError(request, "error.sessionId.numberFormatException");
logger.debug("add error.sessionId.numberFormatException to ActionMessages.");
return (mapping.findForward(ERROR_LIST));
@@ -644,20 +611,18 @@
if ((mode == null) || (mode.length() == 0))
{
McUtils.cleanUpSessionAbsolute(request);
- request.getSession().setAttribute(USER_EXCEPTION_MODE_REQUIRED, new Boolean(true).toString());
persistError(request, "error.mode.required");
return (mapping.findForward(ERROR_LIST));
}
if ((!mode.equals("learner")) && (!mode.equals("teacher")) && (!mode.equals("author")))
{
McUtils.cleanUpSessionAbsolute(request);
- request.getSession().setAttribute(USER_EXCEPTION_MODE_INVALID, new Boolean(true).toString());
persistError(request, "error.mode.invalid");
return (mapping.findForward(ERROR_LIST));
}
logger.debug("session LEARNING_MODE set to:" + mode);
- request.getSession().setAttribute(LEARNING_MODE, mode);
+ mcLearningForm.setLearningMode(mode);
return null;
}
Index: lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/MonitoringUtil.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/MonitoringUtil.java,v
diff -u -r1.23 -r1.24
--- lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/MonitoringUtil.java 24 Jun 2006 23:36:32 -0000 1.23
+++ lams_tool_lamc/src/java/org/lamsfoundation/lams/tool/mc/web/MonitoringUtil.java 20 Jul 2006 21:47:09 -0000 1.24
@@ -1026,7 +1026,7 @@
*/
public static void cleanupMonitoringSession(HttpServletRequest request)
{
- request.getSession().removeAttribute(USER_ID);
+ //request.getSession().removeAttribute(USER_ID);
request.getSession().removeAttribute(TOOL_CONTENT_ID);
request.getSession().removeAttribute(ACTIVE_MODULE);
request.getSession().removeAttribute(CURRENT_MONITORING_TAB);
Index: lams_tool_lamc/web/learning/AnswersContent.jsp
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/web/learning/AnswersContent.jsp,v
diff -u -r1.14 -r1.15
--- lams_tool_lamc/web/learning/AnswersContent.jsp 2 Jul 2006 18:56:40 -0000 1.14
+++ lams_tool_lamc/web/learning/AnswersContent.jsp 20 Jul 2006 21:47:09 -0000 1.15
@@ -42,15 +42,17 @@
-
+
+
+
-
+
Index: lams_tool_lamc/web/learning/CombinedAnswersContent.jsp
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/web/learning/CombinedAnswersContent.jsp,v
diff -u -r1.11 -r1.12
--- lams_tool_lamc/web/learning/CombinedAnswersContent.jsp 2 Jul 2006 18:56:40 -0000 1.11
+++ lams_tool_lamc/web/learning/CombinedAnswersContent.jsp 20 Jul 2006 21:47:09 -0000 1.12
@@ -40,128 +40,65 @@
-
+
|
-
+
|
-
+
|
-
+
- ( )
+ ( )
|
-
-
-
-
-
-
-
-
- |
-
+
-
-
-
-
+ |
+
+
Index: lams_tool_lamc/web/learning/IndividualLearnerResults.jsp
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_lamc/web/learning/Attic/IndividualLearnerResults.jsp,v
diff -u -r1.13 -r1.14
--- lams_tool_lamc/web/learning/IndividualLearnerResults.jsp 2 Jul 2006 18:56:40 -0000 1.13
+++ lams_tool_lamc/web/learning/IndividualLearnerResults.jsp 20 Jul 2006 21:47:09 -0000 1.14
@@ -41,7 +41,7 @@
-
+
@@ -58,20 +58,20 @@
-
+
|
-
+
|
-
+
@@ -82,136 +82,71 @@
|
-
-  
+
+  
 
-
+
|
-
+
 
-  
+  
 
-
+
|
-
-
-
-
-
-
-
- |
-
-
-
-
-
-
-
-
-
-
-
-
- images/dot.jpg" align=left>  
-
- |
-
+
+
+
+ |
+
+
+
+
+
+
+
+
+  [ :
+ ]
+ |
+
+
+
+
+
+
+ |
+
-
-
-
- |
-
-
-
-
-
-
-
-
-
-
-
-
-
- |
-
-
-
-
-
-
-
-
- |
-
-
-
-
-
-
- images/tick.gif" align=right width=20 height=20>
-
-
-
-
-
-
-
- images/cross.gif" align=right width=20 height=20>
-
-
-
-
-
- |
-
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+ |
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- |
-
-
-
-
-
- |
-
-
-
-
+
+
@@ -222,7 +157,7 @@
-
+
@@ -231,7 +166,7 @@
|
-
+
@@ -259,13 +194,3 @@
|