+
-
+
-
+
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -707,75 +657,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -788,11 +669,11 @@
-
+
-
-
+
+
@@ -801,11 +682,11 @@
-
+
-
-
+
+
@@ -814,11 +695,11 @@
-
+
-
-
+
+
@@ -858,13 +739,13 @@
-
+
-
+
-
-
+
+
@@ -873,11 +754,11 @@
-
+
-
-
+
+
@@ -907,11 +788,24 @@
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -920,6 +814,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -932,13 +839,27 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
Index: lams_tool_daco/db/sql/activity_insert.sql
===================================================================
diff -u -rbe03cfbba16a388e85d82cb8986f63d6b2ad568b -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/db/sql/activity_insert.sql (.../activity_insert.sql) (revision be03cfbba16a388e85d82cb8986f63d6b2ad568b)
+++ lams_tool_daco/db/sql/activity_insert.sql (.../activity_insert.sql) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -44,9 +44,9 @@
VALUES
(
NULL
-, 'Daco'
-, 'Daco'
-, 'Put some help text here.'
+, 'Collecting data with custom structure.'
+, 'Data Collection'
+, 'Asking questions with custom, limited answers.'
, NULL
, NULL
, NULL
Index: lams_tool_daco/db/sql/create_lams_tool_daco.sql
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/db/sql/create_lams_tool_daco.sql (.../create_lams_tool_daco.sql) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/db/sql/create_lams_tool_daco.sql (.../create_lams_tool_daco.sql) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -4,7 +4,6 @@
DROP TABLE if exists tl_ladaco10_contents cascade;
DROP TABLE if exists tl_ladaco10_questions cascade;
DROP TABLE if exists tl_ladaco10_answer_options cascade;
-DROP TABLE if exists tl_ladaco10_question_log cascade;
DROP TABLE if exists tl_ladaco10_sessions cascade;
DROP TABLE if exists tl_ladaco10_users cascade;
DROP TABLE if exists tl_ladaco10_answers cascade;
@@ -55,11 +54,8 @@
CREATE TABLE tl_ladaco10_questions (
uid bigint NOT NULL UNIQUE auto_increment,
description text,
- organization_xml text,
create_by bigint,
create_date datetime ,
- create_by_author tinyint,
- is_hide tinyint DEFAULT 0,
is_required tinyint DEFAULT 0,
question_type tinyint unsigned,
min_constraint float,
@@ -91,17 +87,6 @@
PRIMARY KEY (uid)
)TYPE=innodb;
-CREATE TABLE tl_ladaco10_question_log (
- uid bigint NOT NULL UNIQUE auto_increment,
- access_date datetime ,
- question_uid bigint,
- user_uid bigint,
- complete tinyint,
- session_uid bigint,
- PRIMARY KEY (uid)
-)TYPE=innodb;
-
-
CREATE TABLE tl_ladaco10_answers
(uid bigint NOT NULL UNIQUE auto_increment,
user_uid bigint,
@@ -120,18 +105,16 @@
ALTER TABLE tl_ladaco10_questions ADD INDEX (content_uid), ADD CONSTRAINT QuestionToDaco FOREIGN KEY (content_uid) REFERENCES tl_ladaco10_contents (uid);
ALTER TABLE tl_ladaco10_questions ADD INDEX (session_uid), ADD CONSTRAINT FOREIGN KEY (session_uid) REFERENCES tl_ladaco10_sessions (uid);
ALTER TABLE tl_ladaco10_answer_options ADD INDEX (question_uid), ADD CONSTRAINT FOREIGN KEY (question_uid) REFERENCES tl_ladaco10_questions (uid);
-ALTER TABLE tl_ladaco10_question_log ADD INDEX (question_uid), ADD CONSTRAINT LogToQuestion FOREIGN KEY (question_uid) REFERENCES tl_ladaco10_questions (uid);
-ALTER TABLE tl_ladaco10_question_log ADD INDEX (user_uid), ADD CONSTRAINT LogToUser FOREIGN KEY (user_uid) REFERENCES tl_ladaco10_users (uid);
ALTER TABLE tl_ladaco10_sessions ADD INDEX (content_uid), ADD CONSTRAINT SessionToDaco FOREIGN KEY (content_uid) REFERENCES tl_ladaco10_contents (uid);
ALTER TABLE tl_ladaco10_users ADD INDEX (session_uid), ADD CONSTRAINT UserToSession FOREIGN KEY (session_uid) REFERENCES tl_ladaco10_sessions (uid);
ALTER TABLE tl_ladaco10_users ADD INDEX (content_uid), ADD CONSTRAINT UserToDaco FOREIGN KEY (content_uid) REFERENCES tl_ladaco10_contents (uid);
ALTER TABLE tl_ladaco10_answers ADD INDEX (user_uid), ADD CONSTRAINT AnswerToUser FOREIGN KEY (user_uid) REFERENCES tl_ladaco10_users (uid);
ALTER TABLE tl_ladaco10_answers ADD INDEX (question_uid), ADD CONSTRAINT AnswerToQuestion FOREIGN KEY (question_uid) REFERENCES tl_ladaco10_questions (uid);
INSERT INTO `tl_ladaco10_contents` (`uid`, `create_date`, `update_date`, `create_by`, `title`, `run_offline`, `lock_on_finished`,`min_records`,`max_records`, `instructions`, `online_instructions`, `offline_instructions`, `content_in_use`, `define_later`, `content_id`,`reflect_on_activity`) VALUES
- (1,NULL,NULL,NULL,'Daco',0,0,0,0,'Instructions ',NULL,NULL,0,0,${default_content_id},0);
+ (1,NULL,NULL,NULL,'Data Collection',0,0,0,0,'Instructions',NULL,NULL,0,0,${default_content_id},0);
-INSERT INTO `tl_ladaco10_questions` (`uid`, `description`, `organization_xml`, `create_by`, `create_date`, `create_by_author`, `is_hide`, `is_required`, `question_type`, `min_constraint`, `max_constraint`,`digits_decimal`,`summary`, `content_uid`, `session_uid`) VALUES
- (DEFAULT,'What is your favourite colour?
',NULL,NULL,NOW(),1,0,0,1,NULL,NULL,NULL,NULL,1,NULL);
+INSERT INTO `tl_ladaco10_questions` (`uid`, `description`, `create_by`, `create_date`, `is_required`, `question_type`, `min_constraint`, `max_constraint`,`digits_decimal`,`summary`, `content_uid`, `session_uid`) VALUES
+ (DEFAULT,'What is your favourite colour?
',NULL,NOW(),0,1,NULL,NULL,NULL,NULL,1,NULL);
SET FOREIGN_KEY_CHECKS=1;
\ No newline at end of file
Index: lams_tool_daco/db/sql/drop_lams_tool_daco.sql
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/db/sql/drop_lams_tool_daco.sql (.../drop_lams_tool_daco.sql) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/db/sql/drop_lams_tool_daco.sql (.../drop_lams_tool_daco.sql) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -3,7 +3,6 @@
drop table if exists tl_ladaco10_contents;
drop table if exists tl_ladaco10_questions;
drop table if exists tl_ladaco10_answer_options;
-drop table if exists tl_ladaco10_question_log;
drop table if exists tl_ladaco10_sessions;
drop table if exists tl_ladaco10_users;
drop table if exists tl_ladaco10_answers;
Index: lams_tool_daco/db/sql/library_insert.sql
===================================================================
diff -u -rbe03cfbba16a388e85d82cb8986f63d6b2ad568b -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/db/sql/library_insert.sql (.../library_insert.sql) (revision be03cfbba16a388e85d82cb8986f63d6b2ad568b)
+++ lams_tool_daco/db/sql/library_insert.sql (.../library_insert.sql) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -11,8 +11,8 @@
)
VALUES
(
+'Collecting data with custom structure.',
'Data Collection',
-'Data Collection',
0,
NOW()
)
Index: lams_tool_daco/db/sql/tool_insert.sql
===================================================================
diff -u -rbe03cfbba16a388e85d82cb8986f63d6b2ad568b -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/db/sql/tool_insert.sql (.../tool_insert.sql) (revision be03cfbba16a388e85d82cb8986f63d6b2ad568b)
+++ lams_tool_daco/db/sql/tool_insert.sql (.../tool_insert.sql) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -37,8 +37,8 @@
'ladaco10',
'dacoService',
'Data Collection',
-'Data Collection',
-'shareddaco',
+'Collecting data with custom structure.',
+'daco',
'@tool_version@',
NULL,
NULL,
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/DacoConstants.java
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/DacoConstants.java (.../DacoConstants.java) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/DacoConstants.java (.../DacoConstants.java) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -44,8 +44,7 @@
public static final short QUESTION_TYPE_LONGLAT = 10;
// longitude/latitude maps
- public static final String[] LONGLAT_MAPS_LIST = new String[] { "Google Maps", "Google Earth", "Geabios", "Open Street Map",
- "Multimap" };
+ public static final String[] LONGLAT_MAPS_LIST = new String[] { "Google Maps", "Geabios", "Open Street Map", "Multimap" };
// answer options' constants
public static final int INIT_ANSWER_OPTION_COUNT = 3;
@@ -86,10 +85,9 @@
public static final Long MONITORING_SUMMARY_MATCH_ALL = null;
public static final Long MONITORING_SUMMARY_MATCH_NONE = -1L;
- //common parameters'/attributes' names
- public static final String TOOL_CONTENT_ID = "toolContentID";
- public static final String TOOL_SESSION_ID = "toolSessionID";
public static final String USER_UID = "userUid";
+ public static final String USER_ID = "userId";
+ public static final String USER_FULL_NAME = "userFullName";
// for parameters' name
public static final String PARAM_FILE_VERSION_ID = "fileVersionId";
@@ -120,13 +118,9 @@
public static final String ATTR_SESSION_MAP_ID = "sessionMapID";
public static final String ATTR_DACO_FORM = "dacoForm";
public static final String ATTR_FILE_TYPE_FLAG = "fileTypeFlag";
- public static final String ATTR_TITLE = "title";
public static final String ATTR_USER_FINISHED = "userFinished";
public static final String ATTR_ANSWER_OPTION_LIST = "answerOptionList";
- public static final String ATTR_REFLECTION_ON = "reflectOn";
- public static final String ATTR_REFLECTION_INSTRUCTION = "reflectInstructions";
public static final String ATTR_REFLECTION_ENTRY = "reflectEntry";
- public static final String ATTR_REFLECT_LIST = "reflectList";
public static final String ATTR_RECORD_OPERATION_SUCCESS = "recordOperationSuccess";
public static final String ATTR_DISPLAYED_RECORD_NUMBER = "displayedRecordNumber";
public static final String ATTR_LEARNING_VIEW = "learningView";
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dacoApplicationContext.xml
===================================================================
diff -u -rbe03cfbba16a388e85d82cb8986f63d6b2ad568b -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dacoApplicationContext.xml (.../dacoApplicationContext.xml) (revision be03cfbba16a388e85d82cb8986f63d6b2ad568b)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dacoApplicationContext.xml (.../dacoApplicationContext.xml) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -22,7 +22,6 @@
org/lamsfoundation/lams/tool/daco/model/DacoUser.hbm.xml
org/lamsfoundation/lams/tool/daco/model/Daco.hbm.xml
org/lamsfoundation/lams/tool/daco/model/DacoQuestion.hbm.xml
- org/lamsfoundation/lams/tool/daco/model/DacoQuestionVisitLog.hbm.xml
org/lamsfoundation/lams/tool/daco/model/DacoAttachment.hbm.xml
org/lamsfoundation/lams/tool/daco/model/DacoSession.hbm.xml
org/lamsfoundation/lams/tool/daco/model/DacoAnswer.hbm.xml
@@ -42,18 +41,7 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -70,11 +58,6 @@
-
-
-
-
-
@@ -88,18 +71,9 @@
-
-
-
-
-
-
-
-
-
@@ -127,8 +101,12 @@
-
-
+
+
+
+
+
+
@@ -147,9 +125,6 @@
PROPAGATION_REQUIRED,-java.lang.Exception
PROPAGATION_REQUIRED,-java.lang.Exception
PROPAGATION_REQUIRED,-java.lang.Exception
- PROPAGATION_REQUIRED,-java.lang.Exception
- PROPAGATION_REQUIRED,-java.lang.Exception
- PROPAGATION_REQUIRED,-java.lang.Exception
PROPAGATION_REQUIRED,-java.lang.Exception
PROPAGATION_REQUIRED,-java.lang.Exception
PROPAGATION_REQUIRED,-java.lang.Exception
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/DacoAnswerDAO.java
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/DacoAnswerDAO.java (.../DacoAnswerDAO.java) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/DacoAnswerDAO.java (.../DacoAnswerDAO.java) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -3,19 +3,10 @@
import java.util.List;
import org.lamsfoundation.lams.tool.daco.dto.QuestionSummaryDTO;
-import org.lamsfoundation.lams.tool.daco.model.Daco;
-import org.lamsfoundation.lams.tool.daco.model.DacoAnswer;
public interface DacoAnswerDAO extends DAO {
- List> getRecordsByUserUid(Long userUid);
- List getRecord(Long userUid, Integer recordId);
+ List getQuestionSummaries(Long userUid, List blankSummary);
- List> getAnswersByQuestionUid(Long questionUid);
-
- List> getRecordsByUserUidAndDaco(Long userUid, Daco daco);
-
- List getQuestionSummaries(Long contentUid, Long userUid, List blankSummary);
-
- Integer getTotalRecordCount(Long contentId);
+ Integer getGroupRecordCount(Long sessionId);
}
\ No newline at end of file
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/DacoDAO.java
===================================================================
diff -u -rbe03cfbba16a388e85d82cb8986f63d6b2ad568b -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/DacoDAO.java (.../DacoDAO.java) (revision be03cfbba16a388e85d82cb8986f63d6b2ad568b)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/DacoDAO.java (.../DacoDAO.java) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -30,7 +30,4 @@
Daco getByContentId(Long contentId);
Daco getByUid(Long dacoUid);
-
- void delete(Daco daco);
-
}
\ No newline at end of file
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/DacoQuestionDAO.java
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/DacoQuestionDAO.java (.../DacoQuestionDAO.java) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/DacoQuestionDAO.java (.../DacoQuestionDAO.java) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -23,19 +23,9 @@
/* $$Id$$ */
package org.lamsfoundation.lams.tool.daco.dao;
-import java.util.List;
-
import org.lamsfoundation.lams.tool.daco.model.DacoQuestion;
public interface DacoQuestionDAO extends DAO {
- /**
- * Return all daco questions which is uploaded by author in given dacoUid.
- *
- * @param dacoUid
- * @return
- */
- List getByContentUid(Long dacoId);
-
DacoQuestion getByUid(Long dacoQuestionUid);
}
\ No newline at end of file
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/DacoSessionDAO.java
===================================================================
diff -u -rbe03cfbba16a388e85d82cb8986f63d6b2ad568b -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/DacoSessionDAO.java (.../DacoSessionDAO.java) (revision be03cfbba16a388e85d82cb8986f63d6b2ad568b)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/DacoSessionDAO.java (.../DacoSessionDAO.java) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -33,9 +33,6 @@
List getByContentId(Long toolContentId);
- void delete(DacoSession session);
-
void deleteBySessionId(Long toolSessionId);
-
}
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/DacoUserDAO.java
===================================================================
diff -u -rbe03cfbba16a388e85d82cb8986f63d6b2ad568b -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/DacoUserDAO.java (.../DacoUserDAO.java) (revision be03cfbba16a388e85d82cb8986f63d6b2ad568b)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/DacoUserDAO.java (.../DacoUserDAO.java) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -29,9 +29,9 @@
public interface DacoUserDAO extends DAO {
- DacoUser getUserByUserIDAndSessionID(Long userID, Long sessionId);
+ DacoUser getUserByUserIdAndSessionId(Long userID, Long sessionId);
- DacoUser getUserByUserIDAndContentID(Long userId, Long contentId);
+ DacoUser getUserByUserIdAndContentId(Long userId, Long contentId);
- List getBySessionID(Long sessionId);
+ List getBySessionId(Long sessionId);
}
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/hibernate/DacoAnswerDAOHibernate.java
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/hibernate/DacoAnswerDAOHibernate.java (.../DacoAnswerDAOHibernate.java) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/hibernate/DacoAnswerDAOHibernate.java (.../DacoAnswerDAOHibernate.java) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -1,171 +1,79 @@
package org.lamsfoundation.lams.tool.daco.dao.hibernate;
-import java.util.LinkedList;
import java.util.List;
import org.lamsfoundation.lams.tool.daco.DacoConstants;
import org.lamsfoundation.lams.tool.daco.dao.DacoAnswerDAO;
import org.lamsfoundation.lams.tool.daco.dto.QuestionSummaryDTO;
import org.lamsfoundation.lams.tool.daco.dto.QuestionSummarySingleAnswerDTO;
-import org.lamsfoundation.lams.tool.daco.model.Daco;
import org.lamsfoundation.lams.tool.daco.model.DacoAnswer;
-import org.lamsfoundation.lams.tool.daco.model.DacoQuestion;
+import org.lamsfoundation.lams.tool.daco.model.DacoUser;
public class DacoAnswerDAOHibernate extends BaseDAOHibernate implements DacoAnswerDAO {
- private static final String FIND_BY_USER_UID = "from " + DacoAnswer.class.getName()
- + " as p where p.user.uid=? order by record_id,question_uid";
- private static final String FIND_BY_QUESTION_UID = "from " + DacoAnswer.class.getName()
- + " as p where p.question.uid=? order by user.uid,record_id";
+ private static final String FIND_USER_NUMBER_SUMMARY = "SELECT a.question.uid, " + "SUM(a.answer),AVG(a.answer) FROM "
+ + DacoAnswer.class.getName()
+ + " AS a WHERE a.question.type=:numberQuestionType AND a.user.uid=:userUid AND a.answer IS NOT NULL "
+ + "GROUP BY a.question.uid ORDER BY a.question.uid";
- private static final String FIND_BY_USER_UID_AND_DACO = "from " + DacoAnswer.class.getName()
- + " as p where p.user.uid=? and p.question.uid in ([QUESTION_UID_LIST]) order by record_id,question_uid";
-
- private static final String FIND_USER_NUMBER_SUMMARY = "SELECT q.uid, "
+ private static final String FIND_GROUP_NUMBER_SUMMARY = "SELECT a.question.uid, "
+ "SUM(a.answer),AVG(a.answer) FROM "
+ DacoAnswer.class.getName()
+ " AS a, "
- + DacoQuestion.class.getName()
- + " AS q WHERE a.question.uid=q.uid AND q.daco.uid=:contentUid AND a.user.uid=:userUid AND q.type=:numberQuestionType AND a.answer IS NOT NULL "
- + "GROUP BY q.uid ORDER BY q.uid";
+ + DacoUser.class.getName()
+ + " AS u WHERE a.question.type=:numberQuestionType AND u.uid=:userUid AND a.user.session.sessionId=u.session.sessionId AND a.answer IS NOT NULL "
+ + "GROUP BY a.question.uid ORDER BY a.question.uid";
- private static final String FIND_ALL_NUMBER_SUMMARY = "SELECT q.uid, "
- + "SUM(a.answer),AVG(a.answer) FROM "
+ private static final String FIND_USER_ANSWER_ENUMERATION_QUERY = "SELECT DISTINCT a.question.uid, a.answer, a.question.type, COUNT(*) FROM "
+ DacoAnswer.class.getName()
+ + " AS a WHERE a.user.uid=:userUid AND a.question.type IN (:numberQuestionType,:radioQuestionType,:dropdownQuestionType,:checkboxQuestionType) "
+ + "AND a.answer IS NOT NULL GROUP BY a.question.uid, a.answer ORDER BY a.question.uid,a.answer";
+
+ private static final String FIND_GROUP_ANSWER_ENUMERATION_QUERY = "SELECT DISTINCT a.question.uid, a.answer, a.question.type, COUNT(*) FROM "
+ + DacoAnswer.class.getName()
+ " AS a, "
- + DacoQuestion.class.getName()
- + " AS q WHERE a.question.uid=q.uid AND q.daco.uid=:contentUid AND q.type=:numberQuestionType AND a.answer IS NOT NULL "
- + "GROUP BY q.uid ORDER BY q.uid";
+ + DacoUser.class.getName()
+ + " AS u WHERE a.question.type IN (:numberQuestionType,:radioQuestionType,:dropdownQuestionType,:checkboxQuestionType) "
+ + " AND u.uid=:userUid AND a.user.session.sessionId=u.session.sessionId AND a.answer IS NOT NULL GROUP BY a.question.uid, a.answer ORDER BY a.question.uid,a.answer";
- private static final String FIND_USER_ANSWER_ENUMERATION_QUERY = "SELECT DISTINCT q.uid, a.answer, q.type, COUNT(*) FROM "
- + DacoAnswer.class.getName() + " AS a, " + DacoQuestion.class.getName()
- + " AS q WHERE a.question.uid=q.uid AND q.daco.uid=:contentUid AND a.user.uid=:userUid "
- + "AND q.type IN (:numberQuestionType,:radioQuestionType,:dropdownQuestionType,:checkboxQuestionType) "
- + "AND a.answer IS NOT NULL GROUP BY q.uid, a.answer ORDER BY q.uid,a.answer";
-
- private static final String FIND_ALL_ANSWER_ENUMERATION_QUERY = "SELECT DISTINCT q.uid, a.answer, q.type, COUNT(*) FROM "
- + DacoAnswer.class.getName() + " AS a, " + DacoQuestion.class.getName()
- + " AS q WHERE a.question.uid=q.uid AND q.daco.uid=:contentUid "
- + "AND q.type IN (:numberQuestionType,:radioQuestionType,:dropdownQuestionType,:checkboxQuestionType) "
- + "AND a.answer IS NOT NULL GROUP BY q.uid, a.answer ORDER BY q.uid,a.answer";
-
private static final String FIND_ANSWER_COUNT = "SELECT COUNT(*) FROM " + DacoAnswer.class.getName()
+ " AS a WHERE a.question.uid=? AND a.answer IS NOT NULL";
private static final String FIND_TOTAL_RECORD_COUNT = "SELECT COUNT (DISTINCT a.recordId) FROM " + DacoAnswer.class.getName()
- + " AS a WHERE a.question.daco.contentId=?";
+ + " AS a WHERE a.user.session.sessionId=?";
- private static final String QUESTION_UID_LIST_MARKER = "[QUESTION_UID_LIST]";
+ public List getQuestionSummaries(Long userUid, List summaries) {
- public List> getRecordsByUserUid(Long userUid) {
- List list = getHibernateTemplate().find(DacoAnswerDAOHibernate.FIND_BY_USER_UID, userUid);
- if (list == null || list.size() == 0) {
- return null;
- }
- int recordId = 1;
- List> result = new LinkedList>();
- List record = new LinkedList();
- for (DacoAnswer answer : list) {
- if (recordId != answer.getRecordId()) {
- result.add(record);
- record = new LinkedList();
- }
- record.add(answer);
- }
-
- result.add(record);
- return result;
- }
-
- public List getRecord(Long userUid, Integer recordId) {
- List list = getRecordsByUserUid(userUid);
- if (list == null) {
- return null;
- }
- return (List) list.get(recordId);
- }
-
- public List> getAnswersByQuestionUid(Long questionUid) {
- List list = getHibernateTemplate().find(DacoAnswerDAOHibernate.FIND_BY_QUESTION_UID, questionUid);
- if (list == null || list.size() == 0) {
- return null;
- }
- int userUid = 1;
- List> result = new LinkedList>();
- List user = new LinkedList();
- for (DacoAnswer answer : list) {
- if (userUid != answer.getUser().getUid()) {
- result.add(user);
- user = new LinkedList();
- }
- user.add(answer);
- }
- result.add(user);
- return result;
- }
-
- public List> getRecordsByUserUidAndDaco(Long userUid, Daco daco) {
- StringBuilder set = new StringBuilder();
- List> result = new LinkedList>();
- for (DacoQuestion question : daco.getDacoQuestions()) {
- set.append(question.getUid()).append(',');
- }
- set.deleteCharAt(set.length() - 1);
- String modifiedQuery = DacoAnswerDAOHibernate.FIND_BY_USER_UID_AND_DACO.replace(
- DacoAnswerDAOHibernate.QUESTION_UID_LIST_MARKER, set.toString());
- List list = getHibernateTemplate().find(modifiedQuery, userUid);
- if (list != null && list.size() > 0) {
- int recordNumber = -1;
- List record = null;
- for (DacoAnswer answer : list) {
- if (answer.getRecordId() != recordNumber) {
- if (record != null) {
- result.add(record);
- }
- record = new LinkedList();
- recordNumber = answer.getRecordId();
- }
- record.add(answer);
- }
- result.add(record);
- }
- return result;
- }
-
- public List getQuestionSummaries(Long contentUid, Long userUid, List summaries) {
-
List result = getHibernateTemplate().findByNamedParam(DacoAnswerDAOHibernate.FIND_USER_NUMBER_SUMMARY,
- new String[] { "contentUid", "userUid", "numberQuestionType" },
- new Object[] { contentUid, userUid, DacoConstants.QUESTION_TYPE_NUMBER });
+ new String[] { "userUid", "numberQuestionType" }, new Object[] { userUid, DacoConstants.QUESTION_TYPE_NUMBER });
for (Object[] objectRow : result) {
addNumberSummary(summaries, objectRow, true);
}
- result = getHibernateTemplate().findByNamedParam(DacoAnswerDAOHibernate.FIND_ALL_NUMBER_SUMMARY,
- new String[] { "contentUid", "numberQuestionType" },
- new Object[] { contentUid, DacoConstants.QUESTION_TYPE_NUMBER });
+ result = getHibernateTemplate().findByNamedParam(DacoAnswerDAOHibernate.FIND_GROUP_NUMBER_SUMMARY,
+ new String[] { "userUid", "numberQuestionType" }, new Object[] { userUid, DacoConstants.QUESTION_TYPE_NUMBER });
for (Object[] objectRow : result) {
addNumberSummary(summaries, objectRow, false);
}
result = getHibernateTemplate().findByNamedParam(
DacoAnswerDAOHibernate.FIND_USER_ANSWER_ENUMERATION_QUERY,
- new String[] { "contentUid", "userUid", "numberQuestionType", "radioQuestionType", "dropdownQuestionType",
+ new String[] { "userUid", "numberQuestionType", "radioQuestionType", "dropdownQuestionType",
"checkboxQuestionType" },
- new Object[] { contentUid, userUid, DacoConstants.QUESTION_TYPE_NUMBER, DacoConstants.QUESTION_TYPE_RADIO,
+ new Object[] { userUid, DacoConstants.QUESTION_TYPE_NUMBER, DacoConstants.QUESTION_TYPE_RADIO,
DacoConstants.QUESTION_TYPE_DROPDOWN, DacoConstants.QUESTION_TYPE_CHECKBOX });
for (Object[] objectRow : result) {
addAnswerEnumerationSummary(summaries, objectRow, true);
}
result = getHibernateTemplate().findByNamedParam(
- DacoAnswerDAOHibernate.FIND_ALL_ANSWER_ENUMERATION_QUERY,
- new String[] { "contentUid", "numberQuestionType", "radioQuestionType", "dropdownQuestionType",
+ DacoAnswerDAOHibernate.FIND_GROUP_ANSWER_ENUMERATION_QUERY,
+ new String[] { "userUid", "numberQuestionType", "radioQuestionType", "dropdownQuestionType",
"checkboxQuestionType" },
- new Object[] { contentUid, DacoConstants.QUESTION_TYPE_NUMBER, DacoConstants.QUESTION_TYPE_RADIO,
+ new Object[] { userUid, DacoConstants.QUESTION_TYPE_NUMBER, DacoConstants.QUESTION_TYPE_RADIO,
DacoConstants.QUESTION_TYPE_DROPDOWN, DacoConstants.QUESTION_TYPE_CHECKBOX });
for (Object[] objectRow : result) {
@@ -189,13 +97,13 @@
int answerIndex = 1;
do {
currentSingleAnswer = isUserSummary ? summary.getUserSummarySingleAnswer(answerIndex) : summary
- .getAllSummarySingleAnswer(answerIndex);
+ .getGroupSummarySingleAnswer(answerIndex);
if (currentSingleAnswer == null) {
if (isUserSummary) {
summary.addUserSummarySingleAnswer(answerIndex, singleAnswer);
}
else {
- summary.addAllSummarySingleAnswer(answerIndex, singleAnswer);
+ summary.addGroupSummarySingleAnswer(answerIndex, singleAnswer);
}
currentSingleAnswer = null;
}
@@ -209,7 +117,7 @@
summary.addUserSummarySingleAnswer(answerIndex, singleAnswer);
}
else {
- summary.addAllSummarySingleAnswer(answerIndex, singleAnswer);
+ summary.addGroupSummarySingleAnswer(answerIndex, singleAnswer);
}
}
}
@@ -219,7 +127,7 @@
long currentUid = Long.parseLong(row[DacoConstants.QUESTION_DB_NUMBER_SUMMARY_QUESTION_UID]);
QuestionSummaryDTO summary = summaries.get(findQuestionSequenceNumber(currentUid, summaries));
QuestionSummarySingleAnswerDTO singleAnswer = isUserSummary ? summary.getUserSummarySingleAnswer(0) : summary
- .getAllSummarySingleAnswer(0);
+ .getGroupSummarySingleAnswer(0);
singleAnswer.setSum(row[DacoConstants.QUESTION_DB_NUMBER_SUMMARY_SUM]);
singleAnswer.setAverage(row[DacoConstants.QUESTION_DB_NUMBER_SUMMARY_AVERAGE]);
}
@@ -242,7 +150,7 @@
return row;
}
- public Integer getTotalRecordCount(Long contentId) {
- return (Integer) getHibernateTemplate().find(DacoAnswerDAOHibernate.FIND_TOTAL_RECORD_COUNT, contentId).get(0);
+ public Integer getGroupRecordCount(Long sessionId) {
+ return (Integer) getHibernateTemplate().find(DacoAnswerDAOHibernate.FIND_TOTAL_RECORD_COUNT, sessionId).get(0);
}
}
\ No newline at end of file
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/hibernate/DacoDAOHibernate.java
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/hibernate/DacoDAOHibernate.java (.../DacoDAOHibernate.java) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/hibernate/DacoDAOHibernate.java (.../DacoDAOHibernate.java) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -50,8 +50,4 @@
public Daco getByUid(Long dacoUid) {
return (Daco) getObject(Daco.class, dacoUid);
}
-
- public void delete(Daco daco) {
- this.getHibernateTemplate().delete(daco);
- }
}
\ No newline at end of file
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/hibernate/DacoQuestionDAOHibernate.java
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/hibernate/DacoQuestionDAOHibernate.java (.../DacoQuestionDAOHibernate.java) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/hibernate/DacoQuestionDAOHibernate.java (.../DacoQuestionDAOHibernate.java) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -23,20 +23,11 @@
/* $$Id$$ */
package org.lamsfoundation.lams.tool.daco.dao.hibernate;
-import java.util.List;
-
import org.lamsfoundation.lams.tool.daco.dao.DacoQuestionDAO;
import org.lamsfoundation.lams.tool.daco.model.DacoQuestion;
public class DacoQuestionDAOHibernate extends BaseDAOHibernate implements DacoQuestionDAO {
- private static final String FIND_BY_CONTENT_UID = "from " + DacoQuestion.class.getName()
- + " where daco.uid = ? order by create_date asc";
-
- public List getByContentUid(Long contentUid) {
- return this.getHibernateTemplate().find(DacoQuestionDAOHibernate.FIND_BY_CONTENT_UID, contentUid);
- }
-
public DacoQuestion getByUid(Long dacoQuestionUid) {
return (DacoQuestion) this.getObject(DacoQuestion.class, dacoQuestionUid);
}
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/hibernate/DacoSessionDAOHibernate.java
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/hibernate/DacoSessionDAOHibernate.java (.../DacoSessionDAOHibernate.java) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/hibernate/DacoSessionDAOHibernate.java (.../DacoSessionDAOHibernate.java) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -46,12 +46,7 @@
return getHibernateTemplate().find(DacoSessionDAOHibernate.FIND_BY_CONTENT_ID, toolContentId);
}
- public void delete(DacoSession session) {
- this.getHibernateTemplate().delete(session);
- }
-
public void deleteBySessionId(Long toolSessionId) {
this.removeObject(DacoSession.class, toolSessionId);
}
-
}
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/hibernate/DacoUserDAOHibernate.java
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/hibernate/DacoUserDAOHibernate.java (.../DacoUserDAOHibernate.java) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dao/hibernate/DacoUserDAOHibernate.java (.../DacoUserDAOHibernate.java) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -37,7 +37,7 @@
private static final String FIND_BY_SESSION_ID = "from " + DacoUser.class.getName() + " as u where u.session.sessionId=?";
private static final String FIND_BY_CONTENT_ID = "from " + DacoUser.class.getName() + " as u where u.daco.contentId=?";
- public DacoUser getUserByUserIDAndSessionID(Long userID, Long sessionId) {
+ public DacoUser getUserByUserIdAndSessionId(Long userID, Long sessionId) {
List list = this.getHibernateTemplate().find(DacoUserDAOHibernate.FIND_BY_USER_ID_AND_SESSION_ID,
new Object[] { userID, sessionId });
if (list == null || list.size() == 0) {
@@ -46,7 +46,7 @@
return (DacoUser) list.get(0);
}
- public DacoUser getUserByUserIDAndContentID(Long userId, Long contentId) {
+ public DacoUser getUserByUserIdAndContentId(Long userId, Long contentId) {
List list = this.getHibernateTemplate().find(DacoUserDAOHibernate.FIND_BY_USER_ID_AND_CONTENT_ID,
new Object[] { userId, contentId });
if (list == null || list.size() == 0) {
@@ -55,7 +55,7 @@
return (DacoUser) list.get(0);
}
- public List getBySessionID(Long sessionId) {
+ public List getBySessionId(Long sessionId) {
return this.getHibernateTemplate().find(DacoUserDAOHibernate.FIND_BY_SESSION_ID, sessionId);
}
}
\ No newline at end of file
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dto/MonitoringSummaryUserDTO.java
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dto/MonitoringSummaryUserDTO.java (.../MonitoringSummaryUserDTO.java) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dto/MonitoringSummaryUserDTO.java (.../MonitoringSummaryUserDTO.java) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -10,17 +10,20 @@
public class MonitoringSummaryUserDTO {
private Long uid;
+ private Integer userId;
private String fullName;
private String loginName;
private List> records;
private Integer recordCount;
+ private String reflectionEntry;
public MonitoringSummaryUserDTO() {
}
- public MonitoringSummaryUserDTO(Long uid, String fullName, String loginName) {
+ public MonitoringSummaryUserDTO(Long uid, Integer userId, String fullName, String loginName) {
this.uid = uid;
+ this.userId = userId;
this.fullName = fullName;
this.loginName = loginName;
}
@@ -67,4 +70,20 @@
public void setRecordCount(Integer recordCount) {
this.recordCount = recordCount;
}
+
+ public String getReflectionEntry() {
+ return reflectionEntry;
+ }
+
+ public void setReflectionEntry(String reflectionEntry) {
+ this.reflectionEntry = reflectionEntry;
+ }
+
+ public Integer getUserId() {
+ return userId;
+ }
+
+ public void setUserId(Integer userId) {
+ this.userId = userId;
+ }
}
\ No newline at end of file
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dto/QuestionSummaryDTO.java
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dto/QuestionSummaryDTO.java (.../QuestionSummaryDTO.java) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dto/QuestionSummaryDTO.java (.../QuestionSummaryDTO.java) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -6,21 +6,21 @@
public class QuestionSummaryDTO implements Cloneable {
private List userSummary = new ArrayList();
- private List allSummary = new ArrayList();
+ private List groupSummary = new ArrayList();
private Long questionUid;
- public void addAllSummarySingleAnswer(int number, QuestionSummarySingleAnswerDTO singleAnswer) {
- while (number >= allSummary.size()) {
- allSummary.add(null);
+ public void addGroupSummarySingleAnswer(int number, QuestionSummarySingleAnswerDTO singleAnswer) {
+ while (number >= groupSummary.size()) {
+ groupSummary.add(null);
}
- allSummary.set(number, singleAnswer);
+ groupSummary.set(number, singleAnswer);
}
- public QuestionSummarySingleAnswerDTO getAllSummarySingleAnswer(int number) {
- if (allSummary == null || number >= allSummary.size()) {
+ public QuestionSummarySingleAnswerDTO getGroupSummarySingleAnswer(int number) {
+ if (groupSummary == null || number >= groupSummary.size()) {
return null;
}
- return allSummary.get(number);
+ return groupSummary.get(number);
}
public void addUserSummarySingleAnswer(int number, QuestionSummarySingleAnswerDTO singleAnswer) {
@@ -53,12 +53,12 @@
this.userSummary = userSummary;
}
- public List getAllSummary() {
- return allSummary;
+ public List getGroupSummary() {
+ return groupSummary;
}
- public void setAllSummary(List allSummary) {
- this.allSummary = allSummary;
+ public void setGroupSummary(List groupSummary) {
+ this.groupSummary = groupSummary;
}
@Override
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dto/QuestionSummarySingleAnswerDTO.java
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dto/QuestionSummarySingleAnswerDTO.java (.../QuestionSummarySingleAnswerDTO.java) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/dto/QuestionSummarySingleAnswerDTO.java (.../QuestionSummarySingleAnswerDTO.java) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -54,13 +54,6 @@
@Override
public Object clone() {
- Object clone = null;
- try {
- clone = super.clone();
- }
- catch (CloneNotSupportedException e) {
- e.printStackTrace();
- }
- return clone;
+ return new QuestionSummarySingleAnswerDTO(answer, sum, average, count);
}
}
\ No newline at end of file
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/model/Daco.hbm.xml
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/model/Daco.hbm.xml (.../Daco.hbm.xml) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/model/Daco.hbm.xml (.../Daco.hbm.xml) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -69,7 +69,7 @@
/>
-
-
-
-
-
- answerOptions = new LinkedHashSet();
- private boolean isHide;
- private boolean isCreateByAuthor;
private boolean isRequired;
private Date createDate;
@@ -125,18 +121,6 @@
}
/**
- * @hibernate.property column="organization_xml" length="65535"
- * @return
- */
- public String getOrganizationXml() {
- return organizationXml;
- }
-
- public void setOrganizationXml(String organizationXml) {
- this.organizationXml = organizationXml;
- }
-
- /**
* @hibernate.many-to-one cascade="none" column="create_by" foreign-key="QuestionToUser"
*
* @return
@@ -162,30 +146,6 @@
}
/**
- * @hibernate.property column="create_by_author"
- * @return
- */
- public boolean isCreateByAuthor() {
- return isCreateByAuthor;
- }
-
- public void setCreateByAuthor(boolean isCreateByAuthor) {
- this.isCreateByAuthor = isCreateByAuthor;
- }
-
- /**
- * @hibernate.property column="is_hide"
- * @return
- */
- public boolean isHide() {
- return isHide;
- }
-
- public void setHide(boolean isHide) {
- this.isHide = isHide;
- }
-
- /**
* @hibernate.property column="is_required"
* @return
*/
@@ -258,7 +218,7 @@
}
/**
- * @hibernate.set lazy="false" cascade="all" inverse="false" order-by="sequence_num asc"
+ * @hibernate.set cascade="all" order-by="sequence_num asc"
* @hibernate.collection-key column="question_uid"
* @hibernate.collection-one-to-many class="org.lamsfoundation.lams.tool.daco.model.DacoAnswerOption"
* @return
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/model/DacoSession.hbm.xml
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/model/DacoSession.hbm.xml (.../DacoSession.hbm.xml) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/model/DacoSession.hbm.xml (.../DacoSession.hbm.xml) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -80,7 +80,6 @@
{
- public int compare(ReflectDTO o1, ReflectDTO o2) {
- if (o1 != null && o2 != null) {
- return o1.getFullName().compareTo(o2.getFullName());
- }
- else if (o1 != null) {
- return 1;
- }
- else {
- return -1;
- }
+ public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException {
+ if (toContentId == null) {
+ throw new ToolException("Failed to create the Data Collection tool seession");
}
- }
- public IVersionedNode getFileNode(Long answerUid, String relPathString) throws DacoApplicationException {
- DacoAnswer answer = (DacoAnswer) dacoAnswerDao.getObject(DacoQuestion.class, answerUid);
- if (answer == null) {
- throw new DacoApplicationException("Reource question " + answerUid + " not found.");
+ Daco daco = null;
+ if (fromContentId != null) {
+ daco = dacoDao.getByContentId(fromContentId);
}
-
- return getFile(answer.getFileUuid(), answer.getFileVersionId(), relPathString);
- }
-
- // *******************************************************************************
- // Service method
- // *******************************************************************************
- /**
- * Try to get the file. If forceLogin = false and an access denied exception occurs, call this method again to get a new
- * ticket and retry file lookup. If forceLogin = true and it then fails then throw exception.
- *
- * @param uuid
- * @param versionId
- * @param relativePath
- * @param attemptCount
- * @return file node
- * @throws ImscpApplicationException
- */
- private IVersionedNode getFile(Long uuid, Long versionId, String relativePath) throws DacoApplicationException {
-
- ITicket tic = getRepositoryLoginTicket();
-
- try {
-
- return repositoryService.getFileItem(tic, uuid, versionId, relativePath);
-
+ if (daco == null) {
+ try {
+ daco = getDefaultDaco();
+ }
+ catch (DacoApplicationException e) {
+ throw new ToolException(e);
+ }
}
- catch (AccessDeniedException e) {
- String error = "Unable to access repository to get file uuid " + uuid + " version id " + versionId + " path "
- + relativePath + ".";
-
- error = error + "AccessDeniedException: " + e.getMessage() + " Unable to retry further.";
- DacoServiceImpl.log.error(error);
- throw new DacoApplicationException(error, e);
-
- }
- catch (Exception e) {
-
- String error = "Unable to access repository to get file uuid " + uuid + " version id " + versionId + " path "
- + relativePath + "." + " Exception: " + e.getMessage();
- DacoServiceImpl.log.error(error);
- throw new DacoApplicationException(error, e);
-
- }
+ Daco toContent = Daco.newInstance(daco, toContentId, dacoToolContentHandler);
+ dacoDao.saveObject(toContent);
}
- /**
- * This method verifies the credentials of the Daco Tool and gives it the Ticket
to login and access the
- * Content Repository.
- *
- * A valid ticket is needed in order to access the content from the repository. This method would be called evertime the tool
- * needs to upload/download files from the content repository.
- *
- * @return ITicket The ticket for repostory access
- * @throws DacoApplicationException
- */
- private ITicket getRepositoryLoginTicket() throws DacoApplicationException {
- ICredentials credentials = new SimpleCredentials(dacoToolContentHandler.getRepositoryUser(), dacoToolContentHandler
- .getRepositoryId());
- try {
- ITicket ticket = repositoryService.login(credentials, dacoToolContentHandler.getRepositoryWorkspaceName());
- return ticket;
- }
- catch (AccessDeniedException ae) {
- throw new DacoApplicationException("Access Denied to repository." + ae.getMessage());
- }
- catch (WorkspaceNotFoundException we) {
- throw new DacoApplicationException("Workspace not found." + we.getMessage());
- }
- catch (LoginException e) {
- throw new DacoApplicationException("Login failed." + e.getMessage());
- }
+ public Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId,
+ String entryText) {
+ return coreNotebookService.createNotebookEntry(sessionId, notebookToolType, toolSignature, userId, "", entryText);
}
- public Daco getDacoByContentId(Long contentId) {
- Daco rs = dacoDao.getByContentId(contentId);
- if (rs == null) {
- DacoServiceImpl.log.error("Could not find the content by given ID:" + contentId);
- }
- return rs;
+ public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException {
+ DacoSession session = new DacoSession();
+ session.setSessionId(toolSessionId);
+ session.setSessionName(toolSessionName);
+ Daco daco = dacoDao.getByContentId(toolContentId);
+ session.setDaco(daco);
+ dacoSessionDao.saveObject(session);
}
- public Daco getDefaultContent(Long contentId) throws DacoApplicationException {
- if (contentId == null) {
- String error = messageService.getMessage("error.msg.default.content.not.find");
- DacoServiceImpl.log.error(error);
- throw new DacoApplicationException(error);
- }
-
- Daco defaultContent = getDefaultDaco();
- // save default content by given ID.
- Daco content = new Daco();
- content = Daco.newInstance(defaultContent, contentId, dacoToolContentHandler);
- return content;
- }
-
- public DacoAttachment uploadInstructionFile(FormFile uploadFile, String fileType) throws UploadDacoFileException {
- if (uploadFile == null || StringUtils.isEmpty(uploadFile.getFileName())) {
- throw new UploadDacoFileException(messageService.getMessage("error.msg.upload.file.not.found",
- new Object[] { uploadFile }));
- }
-
- // upload file to repository
- NodeKey nodeKey = processFile(uploadFile, fileType);
-
- // create new attachement
- DacoAttachment file = new DacoAttachment();
- file.setFileType(fileType);
- file.setFileUuid(nodeKey.getUuid());
- file.setFileVersionId(nodeKey.getVersion());
- file.setFileName(uploadFile.getFileName());
- file.setCreated(new Date());
-
- return file;
- }
-
public void createUser(DacoUser dacoUser) {
dacoUserDao.saveObject(dacoUser);
}
- public DacoUser getUserByIDAndContent(Long userId, Long contentId) {
+ public void deleteDacoAnswer(Long uid) {
+ dacoAnswerDao.removeObject(DacoAnswer.class, uid);
+ }
- return dacoUserDao.getUserByUserIDAndContentID(userId, contentId);
+ public void deleteDacoAttachment(Long attachmentUid) {
+ dacoDao.removeObject(DacoAttachment.class, attachmentUid);
}
- public DacoUser getUserByIDAndSession(Long userId, Long sessionId) {
+ public void deleteDacoQuestion(Long uid) {
+ dacoQuestionDao.removeObject(DacoQuestion.class, uid);
+ }
- return dacoUserDao.getUserByUserIDAndSessionID(userId, sessionId);
-
+ public void deleteDacoRecord(List record) {
+ for (DacoAnswer answer : record) {
+ deleteDacoAnswer(answer.getUid());
+ }
}
public void deleteFromRepository(Long fileUuid, Long fileVersionId) throws DacoApplicationException {
@@ -291,154 +186,45 @@
}
}
- public void saveOrUpdateDaco(Daco daco) {
- dacoDao.saveObject(daco);
- }
-
- public void deleteDacoAttachment(Long attachmentUid) {
- dacoAttachmentDao.removeObject(DacoAttachment.class, attachmentUid);
-
- }
-
- public void saveOrUpdateDacoQuestion(DacoQuestion question) {
- dacoQuestionDao.saveObject(question);
- }
-
- public void deleteDacoQuestion(Long uid) {
- dacoQuestionDao.removeObject(DacoQuestion.class, uid);
- }
-
- public void deleteDacoAnswer(Long uid) {
- dacoAnswerDao.removeObject(DacoAnswer.class, uid);
- }
-
- public List> getDacoAnswersByUserAndDaco(Long userUid, Daco daco) {
- return dacoAnswerDao.getRecordsByUserUidAndDaco(userUid, daco);
- }
-
- public List exportBySessionId(Long sessionId, boolean skipHide) {
- DacoSession session = dacoSessionDao.getSessionBySessionId(sessionId);
- if (session == null) {
- DacoServiceImpl.log.error("Failed get DacoSession by ID [" + sessionId + "]");
- return null;
- }
- // initial daco questions list
- List questionList = new ArrayList();
- Set resList = session.getDaco().getDacoQuestions();
- for (DacoQuestion question : resList) {
- if (skipHide && question.isHide()) {
- continue;
+ public void exportToolContent(Long toolContentId, String rootPath) throws DataMissingException, ToolException {
+ Daco toolContentObj = dacoDao.getByContentId(toolContentId);
+ if (toolContentObj == null) {
+ try {
+ toolContentObj = getDefaultDaco();
}
- // if question is create by author
- if (question.isCreateByAuthor()) {
- Summary sum = new Summary(session.getSessionName(), question, false);
- questionList.add(sum);
+ catch (DacoApplicationException e) {
+ throw new DataMissingException(e.getMessage());
}
}
-
- // get this session's all daco questions
- Set sessList = session.getDacoQuestions();
- for (DacoQuestion question : sessList) {
- if (skipHide && question.isHide()) {
- continue;
- }
-
- // to skip all question create by author
- if (!question.isCreateByAuthor()) {
- Summary sum = new Summary(session.getSessionName(), question, false);
- questionList.add(sum);
- }
+ if (toolContentObj == null) {
+ throw new DataMissingException("Unable to find default content for the daco tool");
}
- return questionList;
- }
-
- public List> exportByContentId(Long contentId) {
- Daco daco = dacoDao.getByContentId(contentId);
- List> groupList = new ArrayList();
-
- // create init daco questions list
- List initList = new ArrayList();
- groupList.add(initList);
- Set resList = daco.getDacoQuestions();
- for (DacoQuestion question : resList) {
- if (question.isCreateByAuthor()) {
- Summary sum = new Summary(null, question, true);
- initList.add(sum);
- }
+ // set DacoToolContentHandler as null to avoid copy file node in
+ // repository again.
+ toolContentObj = Daco.newInstance(toolContentObj, toolContentId, null);
+ toolContentObj.setToolContentHandler(null);
+ toolContentObj.setOfflineFileList(null);
+ toolContentObj.setOnlineFileList(null);
+ try {
+ exportContentService.registerFileClassForExport(DacoAttachment.class.getName(), "fileUuid", "fileVersionId");
+ exportContentService.exportToolContent(toolContentId, toolContentObj, dacoToolContentHandler, rootPath);
}
-
- // session by session
- List sessionList = dacoSessionDao.getByContentId(contentId);
- for (DacoSession session : sessionList) {
- List group = new ArrayList();
- // get this session's all daco questions
- Set sessList = session.getDacoQuestions();
- for (DacoQuestion question : sessList) {
- // to skip all question create by author
- if (!question.isCreateByAuthor()) {
- Summary sum = new Summary(session.getSessionName(), question, false);
- group.add(sum);
- }
- }
- if (group.size() == 0) {
- group.add(new Summary(session.getSessionName(), null, false));
- }
- groupList.add(group);
+ catch (ExportToolContentException e) {
+ throw new ToolException(e);
}
-
- return groupList;
}
- public Daco getDacoBySessionId(Long sessionId) {
- DacoSession session = dacoSessionDao.getSessionBySessionId(sessionId);
- // to skip CGLib problem
- Long contentId = session.getDaco().getContentId();
- Daco res = dacoDao.getByContentId(contentId);
- // construct dto fields;
- return res;
+ public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException, ToolException {
+ return null;
}
- public DacoSession getDacoSessionBySessionId(Long sessionId) {
- return dacoSessionDao.getSessionBySessionId(sessionId);
+ public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException {
+ return null;
}
- public void saveOrUpdateDacoSession(DacoSession resSession) {
- dacoSessionDao.saveObject(resSession);
- }
-
- public void setQuestionComplete(Long dacoQuestionUid, Long userId, Long sessionId) {
- DacoQuestionVisitLog log = dacoQuestionVisitDao.getDacoQuestionLog(dacoQuestionUid, userId);
- if (log == null) {
- log = new DacoQuestionVisitLog();
- DacoQuestion question = dacoQuestionDao.getByUid(dacoQuestionUid);
- log.setDacoQuestion(question);
- DacoUser user = dacoUserDao.getUserByUserIDAndSessionID(userId, sessionId);
- log.setUser(user);
- log.setSessionUid(sessionId);
- log.setAccessDate(new Timestamp(new Date().getTime()));
- }
- log.setComplete(true);
- dacoQuestionVisitDao.saveObject(log);
- }
-
- public void setQuestionAccess(Long dacoQuestionUid, Long userId, Long sessionId) {
- DacoQuestionVisitLog log = dacoQuestionVisitDao.getDacoQuestionLog(dacoQuestionUid, userId);
- if (log == null) {
- log = new DacoQuestionVisitLog();
- DacoQuestion question = dacoQuestionDao.getByUid(dacoQuestionUid);
- log.setDacoQuestion(question);
- DacoUser user = dacoUserDao.getUserByUserIDAndSessionID(userId, sessionId);
- log.setUser(user);
- log.setComplete(false);
- log.setSessionUid(sessionId);
- log.setAccessDate(new Timestamp(new Date().getTime()));
- dacoQuestionVisitDao.saveObject(log);
- }
- }
-
public String finishToolSession(Long toolSessionId, Long userId) throws DacoApplicationException {
- DacoUser user = dacoUserDao.getUserByUserIDAndSessionID(userId, toolSessionId);
+ DacoUser user = dacoUserDao.getUserByUserIdAndSessionId(userId, toolSessionId);
user.setSessionFinished(true);
dacoUserDao.saveObject(user);
@@ -455,89 +241,63 @@
return nextUrl;
}
- public DacoQuestion getDacoQuestionByUid(Long questionUid) {
- return dacoQuestionDao.getByUid(questionUid);
+ public ICoreNotebookService getCoreNotebookService() {
+ return coreNotebookService;
}
- public Map> getReflectList(Long contentId) {
- Map> map = new HashMap>();
+ public List> getDacoAnswersByUserUid(Long userUid) {
+ DacoUser user = getUser(userUid);
+ Set answers = user.getAnswers();
+ List> result = new LinkedList>();
+ if (answers != null && answers.size() > 0) {
- List sessionList = dacoSessionDao.getByContentId(contentId);
- for (DacoSession session : sessionList) {
- Long sessionId = session.getSessionId();
- boolean hasRefection = session.getDaco().isReflectOnActivity();
- Set list = new TreeSet(this.new ReflectDTOComparator());
- // get all users in this session
- List users = dacoUserDao.getBySessionID(sessionId);
- for (DacoUser user : users) {
- ReflectDTO ref = new ReflectDTO(user);
- ref.setHasRefection(hasRefection);
- list.add(ref);
+ int recordId = 1;
+
+ List record = new LinkedList();
+ for (DacoAnswer answer : answers) {
+ if (recordId != answer.getRecordId()) {
+ recordId = answer.getRecordId();
+ result.add(record);
+ record = new LinkedList();
+ }
+ record.add(answer);
}
- map.put(sessionId, list);
+ result.add(record);
}
-
- return map;
+ return result;
}
- public List getUserListBySessionQuestion(Long sessionId, Long questionUid) {
- List logList = dacoQuestionVisitDao.getDacoQuestionLogBySession(sessionId, questionUid);
- List userList = new ArrayList(logList.size());
- for (DacoQuestionVisitLog visit : logList) {
- DacoUser user = visit.getUser();
- user.setAccessDate(visit.getAccessDate());
- userList.add(user);
+ public Daco getDacoByContentId(Long contentId) {
+ Daco daco = dacoDao.getByContentId(contentId);
+ if (daco == null) {
+ DacoServiceImpl.log.error("Could not find the content by given ID:" + contentId);
}
- return userList;
+ return daco;
}
- public void setQuestionVisible(Long questionUid, boolean visible) {
- DacoQuestion question = dacoQuestionDao.getByUid(questionUid);
- if (question != null) {
- // createBy should be null for system default value.
- Long userId = 0L;
- String loginName = "No user";
- if (question.getCreateBy() != null) {
- userId = question.getCreateBy().getUserId();
- loginName = question.getCreateBy().getLoginName();
- }
- if (visible) {
- auditService.logShowEntry(DacoConstants.TOOL_SIGNATURE, userId, loginName, question.toString());
- }
- else {
- auditService.logHideEntry(DacoConstants.TOOL_SIGNATURE, userId, loginName, question.toString());
- }
- question.setHide(!visible);
- dacoQuestionDao.saveObject(question);
- }
+ public Daco getDacoBySessionId(Long sessionId) {
+ DacoSession session = dacoSessionDao.getSessionBySessionId(sessionId);
+ return session.getDaco();
}
- public Long createNotebookEntry(Long sessionId, Integer notebookToolType, String toolSignature, Integer userId,
- String entryText) {
- return coreNotebookService.createNotebookEntry(sessionId, notebookToolType, toolSignature, userId, "", entryText);
+ public DacoQuestion getDacoQuestionByUid(Long questionUid) {
+ return dacoQuestionDao.getByUid(questionUid);
}
- public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID) {
- List list = coreNotebookService.getEntry(sessionId, idType, signature, userID);
- if (list == null || list.isEmpty()) {
- return null;
+ public Daco getDefaultContent(Long contentId) throws DacoApplicationException {
+ if (contentId == null) {
+ String error = messageService.getMessage("error.msg.default.content.not.find");
+ DacoServiceImpl.log.error(error);
+ throw new DacoApplicationException(error);
}
- else {
- return list.get(0);
- }
- }
- /**
- * @param notebookEntry
- */
- public void updateEntry(NotebookEntry notebookEntry) {
- coreNotebookService.updateEntry(notebookEntry);
+ Daco defaultContent = getDefaultDaco();
+ // save default content by given ID.
+ Daco content = new Daco();
+ content = Daco.newInstance(defaultContent, contentId, dacoToolContentHandler);
+ return content;
}
- public DacoUser getUser(Long uid) {
- return (DacoUser) dacoUserDao.getObject(DacoUser.class, uid);
- }
-
// *****************************************************************************
// private methods
// *****************************************************************************
@@ -553,195 +313,259 @@
return defaultDaco;
}
- private Long getToolDefaultContentIdBySignature(String toolSignature) throws DacoApplicationException {
- Long contentId = null;
- contentId = new Long(toolService.getToolDefaultContentIdBySignature(toolSignature));
- if (contentId == null) {
- String error = messageService.getMessage("error.msg.default.content.not.find");
- DacoServiceImpl.log.error(error);
- throw new DacoApplicationException(error);
+ public NotebookEntry getEntry(Long sessionId, Integer idType, String signature, Integer userID) {
+ List list = coreNotebookService.getEntry(sessionId, idType, signature, userID);
+ if (list == null || list.isEmpty()) {
+ return null;
}
- return contentId;
+ else {
+ return list.get(0);
+ }
}
+ // *******************************************************************************
+ // Service method
+ // *******************************************************************************
/**
- * Process an uploaded file.
+ * Try to get the file. If forceLogin = false and an access denied exception occurs, call this method again to get a new
+ * ticket and retry file lookup. If forceLogin = true and it then fails then throw exception.
*
- * @throws DacoApplicationException
- * @throws FileNotFoundException
- * @throws IOException
- * @throws RepositoryCheckedException
- * @throws InvalidParameterException
+ * @param uuid
+ * @param versionId
+ * @param relativePath
+ * @param attemptCount
+ * @return file node
+ * @throws ImscpApplicationException
*/
- private NodeKey processFile(FormFile file, String fileType) throws UploadDacoFileException {
- NodeKey node = null;
- if (file != null && !StringUtils.isEmpty(file.getFileName())) {
- String fileName = file.getFileName();
- try {
- node = dacoToolContentHandler.uploadFile(file.getInputStream(), fileName, file.getContentType(), fileType);
- }
- catch (InvalidParameterException e) {
- throw new UploadDacoFileException(messageService.getMessage("error.msg.invaid.param.upload"));
- }
- catch (FileNotFoundException e) {
- throw new UploadDacoFileException(messageService.getMessage("error.msg.file.not.found"));
- }
- catch (RepositoryCheckedException e) {
- throw new UploadDacoFileException(messageService.getMessage("error.msg.repository"));
- }
- catch (IOException e) {
- throw new UploadDacoFileException(messageService.getMessage("error.msg.io.exception"));
- }
- }
- return node;
- }
+ private IVersionedNode getFile(Long uuid, Long versionId, String relativePath) throws DacoApplicationException {
- private NodeKey processPackage(String packageDirectory, String initFile) throws UploadDacoFileException {
- NodeKey node = null;
+ ITicket tic = getRepositoryLoginTicket();
+
try {
- node = dacoToolContentHandler.uploadPackage(packageDirectory, initFile);
+
+ return repositoryService.getFileItem(tic, uuid, versionId, relativePath);
+
}
- catch (InvalidParameterException e) {
- throw new UploadDacoFileException(messageService.getMessage("error.msg.invaid.param.upload"));
+ catch (AccessDeniedException e) {
+
+ String error = "Unable to access repository to get file uuid " + uuid + " version id " + versionId + " path "
+ + relativePath + ".";
+
+ error = error + "AccessDeniedException: " + e.getMessage() + " Unable to retry further.";
+ DacoServiceImpl.log.error(error);
+ throw new DacoApplicationException(error, e);
+
}
- catch (RepositoryCheckedException e) {
- throw new UploadDacoFileException(messageService.getMessage("error.msg.repository"));
- }
- return node;
- }
+ catch (Exception e) {
- public void uploadDacoAnswerFile(DacoAnswer answer, FormFile file) throws UploadDacoFileException {
- try {
- InputStream is = file.getInputStream();
- String fileName = file.getFileName();
- String fileType = file.getContentType();
- // For file only upload one sigle file
- if (answer.getQuestion().getType() == DacoConstants.QUESTION_TYPE_FILE
- || answer.getQuestion().getType() == DacoConstants.QUESTION_TYPE_IMAGE) {
- NodeKey nodeKey = processFile(file, IToolContentHandler.TYPE_ONLINE);
- answer.setFileUuid(nodeKey.getUuid());
- answer.setFileVersionId(nodeKey.getVersion());
- }
+ String error = "Unable to access repository to get file uuid " + uuid + " version id " + versionId + " path "
+ + relativePath + "." + " Exception: " + e.getMessage();
+ DacoServiceImpl.log.error(error);
+ throw new DacoApplicationException(error, e);
- // create the package from the directory contents
- answer.setFileType(fileType);
- answer.setFileName(fileName);
}
- catch (FileNotFoundException e) {
- DacoServiceImpl.log.error(messageService.getMessage("error.msg.file.not.found") + ":" + e.toString());
- throw new UploadDacoFileException(messageService.getMessage("error.msg.file.not.found"));
- }
- catch (IOException e) {
- DacoServiceImpl.log.error(messageService.getMessage("error.msg.io.exception") + ":" + e.toString());
- throw new UploadDacoFileException(messageService.getMessage("error.msg.io.exception"));
- }
}
- // *****************************************************************************
- // set methods for Spring Bean
- // *****************************************************************************
- public void setAuditService(IAuditService auditService) {
- this.auditService = auditService;
- }
+ public IVersionedNode getFileNode(Long answerUid, String relPathString) throws DacoApplicationException {
+ DacoAnswer answer = (DacoAnswer) dacoAnswerDao.getObject(DacoQuestion.class, answerUid);
+ if (answer == null) {
+ throw new DacoApplicationException("Reource question " + answerUid + " not found.");
+ }
- public void setLearnerService(ILearnerService learnerService) {
- this.learnerService = learnerService;
+ return getFile(answer.getFileUuid(), answer.getFileVersionId(), relPathString);
}
- public void setMessageService(MessageService messageService) {
- this.messageService = messageService;
+ public Integer getGroupRecordCount(Long sessionId) {
+ return dacoAnswerDao.getGroupRecordCount(sessionId);
}
- public void setRepositoryService(IRepositoryService repositoryService) {
- this.repositoryService = repositoryService;
+ public Integer getGroupRecordCount(MonitoringSummarySessionDTO monitoringSummary) {
+ if (monitoringSummary == null) {
+ return null;
+ }
+ int groupRecordCount = 0;
+ for (MonitoringSummaryUserDTO user : monitoringSummary.getUsers()) {
+ groupRecordCount += user.getRecords().size();
+ }
+ return groupRecordCount;
}
- public void setDacoAttachmentDao(DacoAttachmentDAO dacoAttachmentDao) {
- this.dacoAttachmentDao = dacoAttachmentDao;
+ public String getLocalisedMessage(String key, Object[] args) {
+ return messageService.getMessage(key, args);
}
- public void setDacoDao(DacoDAO dacoDao) {
- this.dacoDao = dacoDao;
+ public List getMonitoringSummary(Long contentId, Long userUid) {
+ List sessions = dacoSessionDao.getByContentId(contentId);
+ List result = new ArrayList(sessions.size());
+ Daco daco = getDacoByContentId(contentId);
+ for (DacoSession session : sessions) {
+ MonitoringSummarySessionDTO monitoringRecordList = new MonitoringSummarySessionDTO(session.getSessionId(), session
+ .getSessionName());
+ List users = dacoUserDao.getBySessionId(session.getSessionId());
+ List monitoringUsers = new ArrayList(users.size());
+ for (DacoUser user : users) {
+ MonitoringSummaryUserDTO monitoringUser = new MonitoringSummaryUserDTO(user.getUid(),
+ user.getUserId().intValue(), user.getLastName() + " " + user.getFirstName(), user.getLoginName());
+ List> records = getDacoAnswersByUserUid(user.getUid());
+ if (userUid == null || userUid.equals(user.getUid())) {
+ monitoringUser.setRecords(records);
+ NotebookEntry entry = getEntry(session.getSessionId(), CoreNotebookConstants.NOTEBOOK_TOOL,
+ DacoConstants.TOOL_SIGNATURE, user.getUserId().intValue());
+ if (entry != null) {
+ monitoringUser.setReflectionEntry(entry.getEntry());
+ }
+ }
+ else {
+ monitoringUser.setRecordCount(records.size());
+ }
+ monitoringUsers.add(monitoringUser);
+ }
+ monitoringRecordList.setUsers(monitoringUsers);
+ result.add(monitoringRecordList);
+ }
+ return result;
}
- public void setDacoQuestionDao(DacoQuestionDAO dacoQuestionDao) {
- this.dacoQuestionDao = dacoQuestionDao;
+ public List getQuestionSummaries(Long userUid) {
+ List result = new ArrayList();
+ DacoUser user = (DacoUser) dacoUserDao.getObject(DacoUser.class, userUid);
+
+ Set questions = user.getDaco().getDacoQuestions();
+ if (questions.size() > 0) {
+ for (DacoQuestion question : questions) {
+ switch (question.getType()) {
+ case DacoConstants.QUESTION_TYPE_NUMBER: {
+ QuestionSummaryDTO summary = new QuestionSummaryDTO();
+ summary.addUserSummarySingleAnswer(0, new QuestionSummarySingleAnswerDTO());
+ summary.addGroupSummarySingleAnswer(0, new QuestionSummarySingleAnswerDTO());
+ summary.setQuestionUid(question.getUid());
+ result.add(summary);
+ }
+ break;
+ case DacoConstants.QUESTION_TYPE_RADIO:
+ case DacoConstants.QUESTION_TYPE_DROPDOWN:
+ case DacoConstants.QUESTION_TYPE_CHECKBOX: {
+ int answerOptionCount = question.getAnswerOptions().size();
+ QuestionSummaryDTO summary = new QuestionSummaryDTO();
+ summary.setQuestionUid(question.getUid());
+ for (int answerOption = 0; answerOption < answerOptionCount; answerOption++) {
+ QuestionSummarySingleAnswerDTO singleAnswer = new QuestionSummarySingleAnswerDTO(String
+ .valueOf(answerOption + 1), null, "0%", "0");
+ summary.addUserSummarySingleAnswer(answerOption, singleAnswer);
+ singleAnswer = (QuestionSummarySingleAnswerDTO) singleAnswer.clone();
+ summary.addGroupSummarySingleAnswer(answerOption, singleAnswer);
+ }
+ result.add(summary);
+ }
+ break;
+ default:
+ result.add(null);
+ break;
+ }
+ }
+ result = dacoAnswerDao.getQuestionSummaries(userUid, result);
+ }
+ return result;
}
- public void setDacoSessionDao(DacoSessionDAO dacoSessionDao) {
- this.dacoSessionDao = dacoSessionDao;
+ /**
+ * This method verifies the credentials of the Daco Tool and gives it the Ticket
to login and access the
+ * Content Repository.
+ *
+ * A valid ticket is needed in order to access the content from the repository. This method would be called evertime the tool
+ * needs to upload/download files from the content repository.
+ *
+ * @return ITicket The ticket for repostory access
+ * @throws DacoApplicationException
+ */
+ private ITicket getRepositoryLoginTicket() throws DacoApplicationException {
+ ICredentials credentials = new SimpleCredentials(dacoToolContentHandler.getRepositoryUser(), dacoToolContentHandler
+ .getRepositoryId());
+ try {
+ ITicket ticket = repositoryService.login(credentials, dacoToolContentHandler.getRepositoryWorkspaceName());
+ return ticket;
+ }
+ catch (AccessDeniedException ae) {
+ throw new DacoApplicationException("Access Denied to repository." + ae.getMessage());
+ }
+ catch (WorkspaceNotFoundException we) {
+ throw new DacoApplicationException("Workspace not found." + we.getMessage());
+ }
+ catch (LoginException e) {
+ throw new DacoApplicationException("Login failed." + e.getMessage());
+ }
}
- public void setDacoAnswerDao(DacoAnswerDAO dacoAnswerDao) {
- this.dacoAnswerDao = dacoAnswerDao;
+ public DacoSession getSessionBySessionId(Long sessionId) {
+ return dacoSessionDao.getSessionBySessionId(sessionId);
}
- public void setDacoAnswerOptionDao(DacoAnswerOptionDAO dacoOptionDao) {
- dacoAnswerOptionDao = dacoOptionDao;
+ private Long getToolDefaultContentIdBySignature(String toolSignature) throws DacoApplicationException {
+ Long contentId = null;
+ contentId = new Long(toolService.getToolDefaultContentIdBySignature(toolSignature));
+ if (contentId == null) {
+ String error = messageService.getMessage("error.msg.default.content.not.find");
+ DacoServiceImpl.log.error(error);
+ throw new DacoApplicationException(error);
+ }
+ return contentId;
}
- public void setDacoToolContentHandler(DacoToolContentHandler dacoToolContentHandler) {
- this.dacoToolContentHandler = dacoToolContentHandler;
+ /**
+ * Get the tool output for the given tool output names.
+ *
+ * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, java.lang.Long, java.lang.Long)
+ */
+ public SortedMap getToolOutput(List names, Long toolSessionId, Long learnerId) {
+ return new TreeMap();
}
- public void setDacoUserDao(DacoUserDAO dacoUserDao) {
- this.dacoUserDao = dacoUserDao;
+ /**
+ * Get the tool output for the given tool output name.
+ *
+ * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, java.lang.Long, java.lang.Long)
+ */
+ public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) {
+ return null;
}
- public void setToolService(ILamsToolService toolService) {
- this.toolService = toolService;
+ /**
+ * Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions that are
+ * always available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created for a particular
+ * activity such as the answer to the third question contains the word Koala and hence the need for the toolContentId
+ *
+ * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition
+ */
+ public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException {
+ return new TreeMap();
}
- public DacoQuestionVisitDAO getDacoQuestionVisitDao() {
- return dacoQuestionVisitDao;
+ public DacoUser getUser(Long uid) {
+ return (DacoUser) dacoUserDao.getObject(DacoUser.class, uid);
}
- public void setDacoQuestionVisitDao(DacoQuestionVisitDAO dacoQuestionVisitDao) {
- this.dacoQuestionVisitDao = dacoQuestionVisitDao;
+ public DacoUser getUserByUserIdAndContentId(Long userId, Long contentId) {
+
+ return dacoUserDao.getUserByUserIdAndContentId(userId, contentId);
+
}
- // *******************************************************************************
- // ToolContentManager, ToolSessionManager methods
- // *******************************************************************************
+ public DacoUser getUserByUserIdAndSessionId(Long userId, Long sessionId) {
- public void exportToolContent(Long toolContentId, String rootPath) throws DataMissingException, ToolException {
- Daco toolContentObj = dacoDao.getByContentId(toolContentId);
- if (toolContentObj == null) {
- try {
- toolContentObj = getDefaultDaco();
- }
- catch (DacoApplicationException e) {
- throw new DataMissingException(e.getMessage());
- }
- }
- if (toolContentObj == null) {
- throw new DataMissingException("Unable to find default content for the daco tool");
- }
+ return dacoUserDao.getUserByUserIdAndSessionId(userId, sessionId);
- // set DacoToolContentHandler as null to avoid copy file node in
- // repository again.
- toolContentObj = Daco.newInstance(toolContentObj, toolContentId, null);
- toolContentObj.setToolContentHandler(null);
- toolContentObj.setOfflineFileList(null);
- toolContentObj.setOnlineFileList(null);
- try {
- exportContentService.registerFileClassForExport(DacoAttachment.class.getName(), "fileUuid", "fileVersionId");
- exportContentService.registerFileClassForExport(DacoQuestion.class.getName(), "fileUuid", "fileVersionId");
- exportContentService.exportToolContent(toolContentId, toolContentObj, dacoToolContentHandler, rootPath);
- }
- catch (ExportToolContentException e) {
- throw new ToolException(e);
- }
}
+ public IUserManagementService getUserManagementService() {
+ return userManagementService;
+ }
+
public void importToolContent(Long toolContentId, Integer newUserUid, String toolContentPath, String fromVersion,
String toVersion) throws ToolException {
try {
exportContentService.registerFileClassForImport(DacoAttachment.class.getName(), "fileUuid", "fileVersionId",
"fileName", "fileType", null, null);
- exportContentService.registerFileClassForImport(DacoQuestion.class.getName(), "fileUuid", "fileVersionId",
- "fileName", "fileType", null, "initialQuestion");
Object toolPOJO = exportContentService.importToolContent(toolContentPath, dacoToolContentHandler, fromVersion,
toVersion);
@@ -752,7 +576,7 @@
// reset it to new toolContentId
toolContentObj.setContentId(toolContentId);
- DacoUser user = dacoUserDao.getUserByUserIDAndContentID(new Long(newUserUid.longValue()), toolContentId);
+ DacoUser user = dacoUserDao.getUserByUserIdAndContentId(new Long(newUserUid.longValue()), toolContentId);
if (user == null) {
user = new DacoUser();
UserDTO sysUser = ((User) userManagementService.findById(User.class, newUserUid)).getUserDTO();
@@ -776,277 +600,260 @@
}
}
- /**
- * Get the definitions for possible output for an activity, based on the toolContentId. These may be definitions that are
- * always available for the tool (e.g. number of marks for Multiple Choice) or a custom definition created for a particular
- * activity such as the answer to the third question contains the word Koala and hence the need for the toolContentId
- *
- * @return SortedMap of ToolOutputDefinitions with the key being the name of each definition
- */
- public SortedMap getToolOutputDefinitions(Long toolContentId) throws ToolException {
- return new TreeMap();
- }
-
- public void copyToolContent(Long fromContentId, Long toContentId) throws ToolException {
- if (toContentId == null) {
- throw new ToolException("Failed to create the Data Collection tool seession");
+ public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException {
+ if (toolSessionId == null) {
+ DacoServiceImpl.log.error("Fail to leave tool Session based on null tool session id.");
+ throw new ToolException("Fail to remove tool Session based on null tool session id.");
}
+ if (learnerId == null) {
+ DacoServiceImpl.log.error("Fail to leave tool Session based on null learner.");
+ throw new ToolException("Fail to remove tool Session based on null learner.");
+ }
- Daco daco = null;
- if (fromContentId != null) {
- daco = dacoDao.getByContentId(fromContentId);
+ DacoSession session = dacoSessionDao.getSessionBySessionId(toolSessionId);
+ if (session != null) {
+ session.setStatus(DacoConstants.SESSION_COMPLETED);
+ dacoSessionDao.saveObject(session);
}
- if (daco == null) {
+ else {
+ DacoServiceImpl.log.error("Fail to leave tool Session.Could not find shared daco " + "session by given session id: "
+ + toolSessionId);
+ throw new DataMissingException("Fail to leave tool Session."
+ + "Could not find shared daco session by given session id: " + toolSessionId);
+ }
+ return learnerService.completeToolSession(toolSessionId, learnerId);
+ }
+
+ // *******************************************************************************
+ // ToolContentManager, ToolSessionManager methods
+ // *******************************************************************************
+
+ /**
+ * Process an uploaded file.
+ *
+ * @throws DacoApplicationException
+ * @throws FileNotFoundException
+ * @throws IOException
+ * @throws RepositoryCheckedException
+ * @throws InvalidParameterException
+ */
+ private NodeKey processFile(FormFile file, String fileType) throws UploadDacoFileException {
+ NodeKey node = null;
+ if (file != null && !StringUtils.isEmpty(file.getFileName())) {
+ String fileName = file.getFileName();
try {
- daco = getDefaultDaco();
+ node = dacoToolContentHandler.uploadFile(file.getInputStream(), fileName, file.getContentType(), fileType);
}
- catch (DacoApplicationException e) {
- throw new ToolException(e);
+ catch (InvalidParameterException e) {
+ throw new UploadDacoFileException(messageService.getMessage("error.msg.invaid.param.upload"));
}
+ catch (FileNotFoundException e) {
+ throw new UploadDacoFileException(messageService.getMessage("error.msg.file.not.found"));
+ }
+ catch (RepositoryCheckedException e) {
+ throw new UploadDacoFileException(messageService.getMessage("error.msg.repository"));
+ }
+ catch (IOException e) {
+ throw new UploadDacoFileException(messageService.getMessage("error.msg.io.exception"));
+ }
}
+ return node;
+ }
- Daco toContent = Daco.newInstance(daco, toContentId, dacoToolContentHandler);
- dacoDao.saveObject(toContent);
+ private NodeKey processPackage(String packageDirectory, String initFile) throws UploadDacoFileException {
+ NodeKey node = null;
+ try {
+ node = dacoToolContentHandler.uploadPackage(packageDirectory, initFile);
+ }
+ catch (InvalidParameterException e) {
+ throw new UploadDacoFileException(messageService.getMessage("error.msg.invaid.param.upload"));
+ }
+ catch (RepositoryCheckedException e) {
+ throw new UploadDacoFileException(messageService.getMessage("error.msg.repository"));
+ }
+ return node;
}
- public void setAsDefineLater(Long toolContentId, boolean value) throws DataMissingException, ToolException {
- Daco daco = dacoDao.getByContentId(toolContentId);
- if (daco == null) {
- throw new ToolException("No found tool content by given content ID:" + toolContentId);
+ public void releaseAnswersFromCache(Collection answers) {
+ for (DacoAnswer answer : answers) {
+ dacoAnswerDao.releaseFromCache(answer);
}
- daco.setDefineLater(value);
}
- public void setAsRunOffline(Long toolContentId, boolean value) throws DataMissingException, ToolException {
- Daco daco = dacoDao.getByContentId(toolContentId);
- if (daco == null) {
- throw new ToolException("No found tool content by given content ID:" + toolContentId);
+ public void releaseDacoFromCache(Daco daco) {
+ dacoDao.releaseFromCache(daco);
+ for (DacoQuestion question : daco.getDacoQuestions()) {
+ dacoQuestionDao.releaseFromCache(question);
}
- daco.setRunOffline(value);
}
public void removeToolContent(Long toolContentId, boolean removeSessionData) throws SessionDataExistsException, ToolException {
Daco daco = dacoDao.getByContentId(toolContentId);
if (removeSessionData) {
- List list = dacoSessionDao.getByContentId(toolContentId);
- Iterator iter = list.iterator();
- while (iter.hasNext()) {
- DacoSession session = (DacoSession) iter.next();
- dacoSessionDao.delete(session);
+ List list = dacoSessionDao.getByContentId(toolContentId);
+ for (DacoSession session : list) {
+ dacoSessionDao.deleteBySessionId(session.getSessionId());
}
}
- dacoDao.delete(daco);
+ dacoDao.removeObject(Daco.class, daco.getUid());
}
- public void createToolSession(Long toolSessionId, String toolSessionName, Long toolContentId) throws ToolException {
- DacoSession session = new DacoSession();
- session.setSessionId(toolSessionId);
- session.setSessionName(toolSessionName);
- Daco daco = dacoDao.getByContentId(toolContentId);
- session.setDaco(daco);
- dacoSessionDao.saveObject(session);
+ public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException {
+ dacoSessionDao.deleteBySessionId(toolSessionId);
}
- public String leaveToolSession(Long toolSessionId, Long learnerId) throws DataMissingException, ToolException {
- if (toolSessionId == null) {
- DacoServiceImpl.log.error("Fail to leave tool Session based on null tool session id.");
- throw new ToolException("Fail to remove tool Session based on null tool session id.");
- }
- if (learnerId == null) {
- DacoServiceImpl.log.error("Fail to leave tool Session based on null learner.");
- throw new ToolException("Fail to remove tool Session based on null learner.");
- }
+ public void saveOrUpdateAnswer(DacoAnswer answer) {
+ dacoAnswerDao.saveObject(answer);
+ }
- DacoSession session = dacoSessionDao.getSessionBySessionId(toolSessionId);
- if (session != null) {
- session.setStatus(DacoConstants.SESSION_COMPLETED);
- dacoSessionDao.saveObject(session);
- }
- else {
- DacoServiceImpl.log.error("Fail to leave tool Session.Could not find shared daco " + "session by given session id: "
- + toolSessionId);
- throw new DataMissingException("Fail to leave tool Session."
- + "Could not find shared daco session by given session id: " + toolSessionId);
- }
- return learnerService.completeToolSession(toolSessionId, learnerId);
+ public void saveOrUpdateDaco(Daco daco) {
+ dacoDao.saveObject(daco);
}
- public ToolSessionExportOutputData exportToolSession(Long toolSessionId) throws DataMissingException, ToolException {
- return null;
+ public void saveOrUpdateDacoQuestion(DacoQuestion question) {
+ dacoQuestionDao.saveObject(question);
}
- public ToolSessionExportOutputData exportToolSession(List toolSessionIds) throws DataMissingException, ToolException {
- return null;
+ public void saveOrUpdateDacoSession(DacoSession resSession) {
+ dacoSessionDao.saveObject(resSession);
}
- public void removeToolSession(Long toolSessionId) throws DataMissingException, ToolException {
- dacoSessionDao.deleteBySessionId(toolSessionId);
+ public void setAsDefineLater(Long toolContentId, boolean value) throws DataMissingException, ToolException {
+ Daco daco = dacoDao.getByContentId(toolContentId);
+ if (daco == null) {
+ throw new ToolException("No found tool content by given content ID:" + toolContentId);
+ }
+ daco.setDefineLater(value);
}
- /**
- * Get the tool output for the given tool output names.
- *
- * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.util.List, java.lang.Long, java.lang.Long)
- */
- public SortedMap getToolOutput(List names, Long toolSessionId, Long learnerId) {
- return new TreeMap();
+ public void setAsRunOffline(Long toolContentId, boolean value) throws DataMissingException, ToolException {
+ Daco daco = dacoDao.getByContentId(toolContentId);
+ if (daco == null) {
+ throw new ToolException("No found tool content by given content ID:" + toolContentId);
+ }
+ daco.setRunOffline(value);
}
- /**
- * Get the tool output for the given tool output name.
- *
- * @see org.lamsfoundation.lams.tool.ToolSessionManager#getToolOutput(java.lang.String, java.lang.Long, java.lang.Long)
- */
- public ToolOutput getToolOutput(String name, Long toolSessionId, Long learnerId) {
- return null;
+ // *****************************************************************************
+ // set methods for Spring Bean
+ // *****************************************************************************
+ public void setAuditService(IAuditService auditService) {
+ this.auditService = auditService;
}
+ public void setCoreNotebookService(ICoreNotebookService coreNotebookService) {
+ this.coreNotebookService = coreNotebookService;
+ }
+
/*
* ===============Methods implemented from ToolContentImport102Manager ===============
*/
- /**
- * Set the description, throws away the title value as this is not supported in 2.0
- */
- public void setReflectiveData(Long toolContentId, String title, String description) throws ToolException,
- DataMissingException {
+ /* =================================================================================== */
- Daco toolContentObj = getDacoByContentId(toolContentId);
- if (toolContentObj == null) {
- throw new DataMissingException("Unable to set reflective data titled " + title + " on activity toolContentId "
- + toolContentId + " as the tool content does not exist.");
- }
+ public void setDacoDao(DacoDAO dacoDao) {
+ this.dacoDao = dacoDao;
+ }
- toolContentObj.setReflectOnActivity(Boolean.TRUE);
- toolContentObj.setReflectInstructions(description);
+ public void setDacoQuestionDao(DacoQuestionDAO dacoQuestionDao) {
+ this.dacoQuestionDao = dacoQuestionDao;
}
- /* =================================================================================== */
+ public void setDacoSessionDao(DacoSessionDAO dacoSessionDao) {
+ this.dacoSessionDao = dacoSessionDao;
+ }
- public IExportToolContentService getExportContentService() {
- return exportContentService;
+ public void setDacoToolContentHandler(DacoToolContentHandler dacoToolContentHandler) {
+ this.dacoToolContentHandler = dacoToolContentHandler;
}
+ public void setDacoUserDao(DacoUserDAO dacoUserDao) {
+ this.dacoUserDao = dacoUserDao;
+ }
+
public void setExportContentService(IExportToolContentService exportContentService) {
this.exportContentService = exportContentService;
}
- public IUserManagementService getUserManagementService() {
- return userManagementService;
+ public void setLearnerService(ILearnerService learnerService) {
+ this.learnerService = learnerService;
}
- public void setUserManagementService(IUserManagementService userManagementService) {
- this.userManagementService = userManagementService;
+ public void setMessageService(MessageService messageService) {
+ this.messageService = messageService;
}
- public ICoreNotebookService getCoreNotebookService() {
- return coreNotebookService;
+ public void setRepositoryService(IRepositoryService repositoryService) {
+ this.repositoryService = repositoryService;
}
- public void setCoreNotebookService(ICoreNotebookService coreNotebookService) {
- this.coreNotebookService = coreNotebookService;
+ public void setToolService(ILamsToolService toolService) {
+ this.toolService = toolService;
}
- public void saveOrUpdateAnswer(DacoAnswer answer) {
- dacoAnswerDao.saveObject(answer);
+ public void setUserManagementService(IUserManagementService userManagementService) {
+ this.userManagementService = userManagementService;
}
- public String getLocalisedMessage(String key, Object[] args) {
- return messageService.getMessage(key, args);
+ /**
+ * @param notebookEntry
+ */
+ public void updateEntry(NotebookEntry notebookEntry) {
+ coreNotebookService.updateEntry(notebookEntry);
}
- public List getQuestionSummaries(Long contentUid, Long userUid) {
- List result = new ArrayList();
-
- Set questions = dacoDao.getByUid(contentUid).getDacoQuestions();
- if (questions.size() > 0) {
- for (DacoQuestion question : questions) {
- switch (question.getType()) {
- case DacoConstants.QUESTION_TYPE_NUMBER: {
- QuestionSummaryDTO summary = new QuestionSummaryDTO();
- summary.addUserSummarySingleAnswer(0, new QuestionSummarySingleAnswerDTO());
- summary.addAllSummarySingleAnswer(0, new QuestionSummarySingleAnswerDTO());
- summary.setQuestionUid(question.getUid());
- result.add(summary);
- }
- break;
- case DacoConstants.QUESTION_TYPE_RADIO:
- case DacoConstants.QUESTION_TYPE_DROPDOWN:
- case DacoConstants.QUESTION_TYPE_CHECKBOX: {
- int answerOptionCount = question.getAnswerOptions().size();
- QuestionSummaryDTO summary = new QuestionSummaryDTO();
- summary.setQuestionUid(question.getUid());
- for (int answerOption = 0; answerOption < answerOptionCount; answerOption++) {
- QuestionSummarySingleAnswerDTO singleAnswer = new QuestionSummarySingleAnswerDTO(String
- .valueOf(answerOption + 1), null, "0%", "0");
- summary.addUserSummarySingleAnswer(answerOption, singleAnswer);
- singleAnswer = (QuestionSummarySingleAnswerDTO) singleAnswer.clone();
- summary.addAllSummarySingleAnswer(answerOption, singleAnswer);
- }
- result.add(summary);
- }
- break;
- default:
- result.add(null);
- break;
- }
+ public void uploadDacoAnswerFile(DacoAnswer answer, FormFile file) throws UploadDacoFileException {
+ try {
+ InputStream is = file.getInputStream();
+ String fileName = file.getFileName();
+ String fileType = file.getContentType();
+ // For file only upload one sigle file
+ if (answer.getQuestion().getType() == DacoConstants.QUESTION_TYPE_FILE
+ || answer.getQuestion().getType() == DacoConstants.QUESTION_TYPE_IMAGE) {
+ NodeKey nodeKey = processFile(file, IToolContentHandler.TYPE_ONLINE);
+ answer.setFileUuid(nodeKey.getUuid());
+ answer.setFileVersionId(nodeKey.getVersion());
}
- result = dacoAnswerDao.getQuestionSummaries(contentUid, userUid, result);
+
+ // create the package from the directory contents
+ answer.setFileType(fileType);
+ answer.setFileName(fileName);
}
- return result;
+ catch (FileNotFoundException e) {
+ DacoServiceImpl.log.error(messageService.getMessage("error.msg.file.not.found") + ":" + e.toString());
+ throw new UploadDacoFileException(messageService.getMessage("error.msg.file.not.found"));
+ }
+ catch (IOException e) {
+ DacoServiceImpl.log.error(messageService.getMessage("error.msg.io.exception") + ":" + e.toString());
+ throw new UploadDacoFileException(messageService.getMessage("error.msg.io.exception"));
+ }
}
- public void deleteDacoRecord(List record) {
- for (DacoAnswer answer : record) {
- deleteDacoAnswer(answer.getUid());
+ public DacoAttachment uploadInstructionFile(FormFile uploadFile, String fileType) throws UploadDacoFileException {
+ if (uploadFile == null || StringUtils.isEmpty(uploadFile.getFileName())) {
+ throw new UploadDacoFileException(messageService.getMessage("error.msg.upload.file.not.found",
+ new Object[] { uploadFile }));
}
- }
- public List getQuestionByContentUid(Long contentUid) {
- return dacoQuestionDao.getByContentUid(contentUid);
- }
+ // upload file to repository
+ NodeKey nodeKey = processFile(uploadFile, fileType);
- public void releaseDacoFromCache(Daco daco) {
- dacoDao.releaseFromCache(daco);
- for (DacoQuestion question : daco.getDacoQuestions()) {
- dacoQuestionDao.releaseFromCache(question);
- }
- }
+ // create new attachement
+ DacoAttachment file = new DacoAttachment();
+ file.setFileType(fileType);
+ file.setFileUuid(nodeKey.getUuid());
+ file.setFileVersionId(nodeKey.getVersion());
+ file.setFileName(uploadFile.getFileName());
+ file.setCreated(new Date());
- public void releaseAnswersFromCache(Collection answers) {
- for (DacoAnswer answer : answers) {
- dacoAnswerDao.releaseFromCache(answer);
- }
+ return file;
}
- public Integer getTotalRecordCount(Long contentId) {
- return dacoAnswerDao.getTotalRecordCount(contentId);
+ public DacoAnswerDAO getDacoAnswerDao() {
+ return dacoAnswerDao;
}
- public List getMonitoringSummary(Long contentId, Long userUid) {
- List sessions = dacoSessionDao.getByContentId(contentId);
- List result = new ArrayList(sessions.size());
- Daco daco = getDacoByContentId(contentId);
- for (DacoSession session : sessions) {
- MonitoringSummarySessionDTO monitoringRecordList = new MonitoringSummarySessionDTO(session.getSessionId(), session
- .getSessionName());
- List users = dacoUserDao.getBySessionID(session.getSessionId());
- List monitoringUsers = new ArrayList(users.size());
- for (DacoUser user : users) {
- MonitoringSummaryUserDTO monitoringUser = new MonitoringSummaryUserDTO(user.getUid(), user.getLastName() + " "
- + user.getFirstName(), user.getLoginName());
- List> records = getDacoAnswersByUserAndDaco(user.getUid(), daco);
- if (userUid == null || userUid.equals(user.getUid())) {
- monitoringUser.setRecords(records);
- }
- else {
- monitoringUser.setRecordCount(records.size());
- }
- monitoringUsers.add(monitoringUser);
- }
- monitoringRecordList.setUsers(monitoringUsers);
- result.add(monitoringRecordList);
- }
- return result;
+ public void setDacoAnswerDao(DacoAnswerDAO dacoAnswerDao) {
+ this.dacoAnswerDao = dacoAnswerDao;
}
}
\ No newline at end of file
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/IDacoService.java
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/IDacoService.java (.../IDacoService.java) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/service/IDacoService.java (.../IDacoService.java) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -25,16 +25,12 @@
import java.util.Collection;
import java.util.List;
-import java.util.Map;
-import java.util.Set;
import org.apache.struts.upload.FormFile;
import org.lamsfoundation.lams.contentrepository.IVersionedNode;
import org.lamsfoundation.lams.notebook.model.NotebookEntry;
import org.lamsfoundation.lams.tool.daco.dto.MonitoringSummarySessionDTO;
import org.lamsfoundation.lams.tool.daco.dto.QuestionSummaryDTO;
-import org.lamsfoundation.lams.tool.daco.dto.ReflectDTO;
-import org.lamsfoundation.lams.tool.daco.dto.Summary;
import org.lamsfoundation.lams.tool.daco.model.Daco;
import org.lamsfoundation.lams.tool.daco.model.DacoAnswer;
import org.lamsfoundation.lams.tool.daco.model.DacoAttachment;
@@ -43,9 +39,9 @@
import org.lamsfoundation.lams.tool.daco.model.DacoUser;
/**
- * @author Dapeng.Ni
+ * @author Marcin Cieslak
*
- * Interface that defines the contract that all ShareDaco service provider must follow.
+ * Interface that defines the contract that all Data Collection service provider must follow.
*/
public interface IDacoService {
@@ -108,7 +104,7 @@
* @param long1
* @return
*/
- DacoUser getUserByIDAndContent(Long userID, Long contentId);
+ DacoUser getUserByUserIdAndContentId(Long userID, Long contentId);
/**
* Get user by sessionID and UserID
@@ -117,7 +113,7 @@
* @param sessionId
* @return
*/
- DacoUser getUserByIDAndSession(Long long1, Long sessionId);
+ DacoUser getUserByUserIdAndSessionId(Long long1, Long sessionId);
// ********** Repository methods ***********************
/**
@@ -155,11 +151,11 @@
/**
* Return all reource questions within the given toolSessionID.
- *
* @param sessionId
+ *
* @return
*/
- List> getDacoAnswersByUserAndDaco(Long userUid, Daco daco);
+ List> getDacoAnswersByUserUid(Long userUid);
/**
* Get daco which is relative with the special toolSession.
@@ -175,7 +171,7 @@
* @param sessionId
* @return
*/
- DacoSession getDacoSessionBySessionId(Long sessionId);
+ DacoSession getSessionBySessionId(Long sessionId);
/**
* Save or update daco session.
@@ -184,8 +180,6 @@
*/
void saveOrUpdateDacoSession(DacoSession resSession);
- void setQuestionAccess(Long dacoQuestionUid, Long userId, Long sessionId);
-
/**
* If success return next activity's url, otherwise return null.
*
@@ -197,30 +191,7 @@
DacoQuestion getDacoQuestionByUid(Long questionUid);
- List getUserListBySessionQuestion(Long sessionId, Long questionUid);
-
/**
- * Set a daco question visible or not.
- *
- * @param questionUid
- * @param visible
- * true, question is visible. False, question is invisible.
- */
- void setQuestionVisible(Long questionUid, boolean visible);
-
- /**
- * Get daco question Summary
list according to sessionId and skipHide flag.
- *
- * @param sessionId
- * @param skipHide
- * true, don't get daco question if its isHide
flag is true. Otherwise, get all daco question
- * @return
- */
- public List exportBySessionId(Long sessionId, boolean skipHide);
-
- public List> exportByContentId(Long contentId);
-
- /**
* Create refection entry into notebook tool.
*
* @param sessionId
@@ -249,14 +220,6 @@
public void updateEntry(NotebookEntry notebookEntry);
/**
- * Get Reflect DTO list grouped by sessionID.
- *
- * @param contentId
- * @return
- */
- Map> getReflectList(Long contentId);
-
- /**
* Get user by UID
*
* @param uid
@@ -266,15 +229,15 @@
public String getLocalisedMessage(String key, Object[] args);
- public List getQuestionSummaries(Long contentUid, Long userUid);
+ public List getQuestionSummaries(Long userUid);
- public List getQuestionByContentUid(Long contentUid);
-
public void releaseDacoFromCache(Daco daco);
void releaseAnswersFromCache(Collection answers);
- Integer getTotalRecordCount(Long contentId);
+ Integer getGroupRecordCount(Long sessionId);
+ Integer getGroupRecordCount(MonitoringSummarySessionDTO monitoringSummary);
+
List getMonitoringSummary(Long contentId, Long userUid);
}
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/util/DacoToolContentHandler.java
===================================================================
diff -u -rbe03cfbba16a388e85d82cb8986f63d6b2ad568b -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/util/DacoToolContentHandler.java (.../DacoToolContentHandler.java) (revision be03cfbba16a388e85d82cb8986f63d6b2ad568b)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/util/DacoToolContentHandler.java (.../DacoToolContentHandler.java) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -32,37 +32,40 @@
*/
public class DacoToolContentHandler extends ToolContentHandler {
- private static String repositoryWorkspaceName = "shareddacoworkspace";
- private static String repositoryUser = "shareddaco";
- //shareddaco
- private static char[] repositoryId = {'l','a','m','s','-','s','h','a','r','e','d','r','e','s','o','u','r','c','e','s'};
+ private static String repositoryWorkspaceName = "dacoworkspace";
+ private static String repositoryUser = "daco";
+ //lams-daco
+ private static char[] repositoryId = { 'l', 'a', 'm', 's', '-', 'd', 'a', 'c', 'o' };
- /**
- *
- */
- public DacoToolContentHandler() {
- super();
- }
+ /**
+ *
+ */
+ public DacoToolContentHandler() {
+ super();
+ }
- /* (non-Javadoc)
- * @see org.lamsfoundation.lams.contentrepository.client.ToolContentHandler#getRepositoryWorkspaceName()
- */
- public String getRepositoryWorkspaceName() {
- return repositoryWorkspaceName;
- }
+ /* (non-Javadoc)
+ * @see org.lamsfoundation.lams.contentrepository.client.ToolContentHandler#getRepositoryWorkspaceName()
+ */
+ @Override
+ public String getRepositoryWorkspaceName() {
+ return DacoToolContentHandler.repositoryWorkspaceName;
+ }
- /* (non-Javadoc)
- * @see org.lamsfoundation.lams.contentrepository.client.ToolContentHandler#getRepositoryUser()
- */
- public String getRepositoryUser() {
- return repositoryUser;
- }
+ /* (non-Javadoc)
+ * @see org.lamsfoundation.lams.contentrepository.client.ToolContentHandler#getRepositoryUser()
+ */
+ @Override
+ public String getRepositoryUser() {
+ return DacoToolContentHandler.repositoryUser;
+ }
- /* (non-Javadoc)
- * @see org.lamsfoundation.lams.contentrepository.client.ToolContentHandler#getRepositoryId()
- */
- public char[] getRepositoryId() {
- return repositoryId;
- }
+ /* (non-Javadoc)
+ * @see org.lamsfoundation.lams.contentrepository.client.ToolContentHandler#getRepositoryId()
+ */
+ @Override
+ public char[] getRepositoryId() {
+ return DacoToolContentHandler.repositoryId;
+ }
}
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/action/AuthoringAction.java
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/action/AuthoringAction.java (.../AuthoringAction.java) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/action/AuthoringAction.java (.../AuthoringAction.java) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -341,8 +341,6 @@
if (!StringUtils.isBlank(constraint)) {
question.setDigitsDecimal(Short.parseShort(constraint));
}
- question.setCreateByAuthor(true);
- question.setHide(false);
Set answerOptions = new LinkedHashSet();
if (answerOptionList != null) {
@@ -835,7 +833,7 @@
protected ActionForward start(ActionMapping mapping, ActionForm form, HttpServletRequest request) throws ServletException {
// save toolContentID into HTTPSession
- Long contentId = new Long(WebUtil.readLongParam(request, DacoConstants.TOOL_CONTENT_ID));
+ Long contentId = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID));
// get back the daco and question list and display them on page
IDacoService service = getDacoService();
@@ -978,7 +976,7 @@
HttpSession ss = SessionManager.getSession();
// get back login user DTO
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
- DacoUser dacoUser = service.getUserByIDAndContent(new Long(user.getUserID().intValue()), dacoForm.getDaco()
+ DacoUser dacoUser = service.getUserByUserIdAndContentId(new Long(user.getUserID().intValue()), dacoForm.getDaco()
.getContentId());
if (dacoUser == null) {
dacoUser = new DacoUser(user, dacoPO);
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/action/LearningAction.java
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/action/LearningAction.java (.../LearningAction.java) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/action/LearningAction.java (.../LearningAction.java) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -95,15 +95,15 @@
// -----------------------Daco Learner function
// ---------------------------
if (param.equals("start")) {
- return start(mapping, form, request, response);
+ return start(mapping, request);
}
if (param.equals("finish")) {
- return finish(mapping, form, request, response);
+ return finish(mapping, request);
}
if (param.equals("saveOrUpdateRecord")) {
- return saveOrUpdateRecord(mapping, form, request, response);
+ return saveOrUpdateRecord(mapping, form, request);
}
if (param.equals("editRecord")) {
@@ -127,11 +127,11 @@
}
// ================ Reflection =======================
- if (param.equals("newReflection")) {
- return newReflection(mapping, form, request, response);
+ if (param.equals("startReflection")) {
+ return startReflection(mapping, form, request);
}
if (param.equals("submitReflection")) {
- return submitReflection(mapping, form, request, response);
+ return submitReflection(mapping, form, request);
}
return mapping.findForward(DacoConstants.ERROR);
@@ -154,7 +154,7 @@
* This method will avoid read database again and lost un-saved resouce question lost when user "refresh page",
*
*/
- protected ActionForward start(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) {
+ protected ActionForward start(ActionMapping mapping, HttpServletRequest request) {
// initial Session Map
SessionMap sessionMap = new SessionMap();
@@ -163,11 +163,9 @@
// save toolContentID into HTTPSession
ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, AttributeNames.PARAM_MODE, true);
- Long sessionId = new Long(request.getParameter(DacoConstants.TOOL_SESSION_ID));
+ Long sessionId = new Long(request.getParameter(AttributeNames.PARAM_TOOL_SESSION_ID));
request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMap.getSessionID());
- request.setAttribute(AttributeNames.PARAM_TOOL_SESSION_ID, sessionId);
- request.setAttribute(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER, 1);
// get back the daco and question list and display them on page
IDacoService service = getDacoService();
@@ -184,10 +182,10 @@
}
// check whehter finish lock is on/off
- boolean lock = daco.getLockWhenFinished() && dacoUser != null && dacoUser.isSessionFinished();
+ boolean lock = daco.getLockOnFinished() && dacoUser != null && dacoUser.isSessionFinished();
// get notebook entry
- String entryText = new String();
+ String entryText = null;
if (dacoUser != null) {
NotebookEntry notebookEntry = service.getEntry(sessionId, CoreNotebookConstants.NOTEBOOK_TOOL,
DacoConstants.TOOL_SIGNATURE, dacoUser.getUserId().intValue());
@@ -204,13 +202,14 @@
sessionMap.put(DacoConstants.ATTR_DACO, daco);
sessionMap.put(DacoConstants.ATTR_LEARNING_VIEW, DacoConstants.LEARNING_VIEW_VERTICAL);
- List> records = service.getDacoAnswersByUserAndDaco(dacoUser.getUid(), daco);
+ List> records = service.getDacoAnswersByUserUid(dacoUser.getUid());
sessionMap.put(DacoConstants.ATTR_RECORD_LIST, records);
+ request.setAttribute(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER, records.size() + 1);
- List summaries = service.getQuestionSummaries(daco.getUid(), dacoUser.getUid());
+ List summaries = service.getQuestionSummaries(dacoUser.getUid());
sessionMap.put(DacoConstants.ATTR_QUESTION_SUMMARIES, summaries);
- Integer totalRecordCount = service.getTotalRecordCount(daco.getContentId());
+ Integer totalRecordCount = service.getGroupRecordCount(dacoUser.getSession().getSessionId());
sessionMap.put(DacoConstants.ATTR_TOTAL_RECORD_COUNT, totalRecordCount);
// add define later support
@@ -245,8 +244,7 @@
* @param response
* @return
*/
- protected ActionForward finish(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) {
+ protected ActionForward finish(ActionMapping mapping, HttpServletRequest request) {
// get back SessionMap
String sessionMapID = request.getParameter(DacoConstants.ATTR_SESSION_MAP_ID);
@@ -266,11 +264,11 @@
// get sessionId from HttpServletRequest
String nextActivityUrl = null;
try {
- HttpSession ss = SessionManager.getSession();
- UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
- Long userID = new Long(user.getUserID().longValue());
+ HttpSession httpSession = SessionManager.getSession();
+ UserDTO user = (UserDTO) httpSession.getAttribute(AttributeNames.USER);
+ Long userUid = new Long(user.getUserID().longValue());
- nextActivityUrl = service.finishToolSession(sessionId, userID);
+ nextActivityUrl = service.finishToolSession(sessionId, userUid);
request.setAttribute(DacoConstants.ATTR_NEXT_ACTIVITY_URL, nextActivityUrl);
}
catch (DacoApplicationException e) {
@@ -290,14 +288,13 @@
* @param response
* @return
*/
- protected ActionForward saveOrUpdateRecord(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) {
+ protected ActionForward saveOrUpdateRecord(ActionMapping mapping, ActionForm form, HttpServletRequest request) {
RecordForm recordForm = (RecordForm) form;
String sessionMapID = request.getParameter(DacoConstants.ATTR_SESSION_MAP_ID);
SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
Daco daco = (Daco) sessionMap.get(DacoConstants.ATTR_DACO);
Set questionList = daco.getDacoQuestions();
- Long sessionId = (Long) sessionMap.get(DacoConstants.TOOL_SESSION_ID);
+ Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);
IDacoService service = getDacoService();
DacoUser user = getCurrentUser(service, sessionId, daco);
@@ -500,36 +497,41 @@
* @param response
* @return
*/
- protected ActionForward newReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) {
+ protected ActionForward startReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request) {
// get session value
String sessionMapID = WebUtil.readStrParam(request, DacoConstants.ATTR_SESSION_MAP_ID);
+
ActionErrors errors = validateBeforeFinish(request, sessionMapID);
if (!errors.isEmpty()) {
this.addErrors(request, errors);
+ refreshQuestionSummaries(mapping, request);
+ request.setAttribute(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER, request
+ .getParameter(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER));
return mapping.getInputForward();
}
+ SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
- ReflectionForm refForm = (ReflectionForm) form;
- HttpSession ss = SessionManager.getSession();
- UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
+ Long toolSessionID = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);
+ IDacoService service = getDacoService();
+ ReflectionForm reflectionForm = (ReflectionForm) form;
+ HttpSession httpSession = SessionManager.getSession();
+ UserDTO userDTO = (UserDTO) httpSession.getAttribute(AttributeNames.USER);
+ DacoUser user = service.getUserByUserIdAndSessionId(userDTO.getUserID().longValue(), toolSessionID);
- refForm.setUserID(user.getUserID());
- refForm.setSessionMapID(sessionMapID);
+ reflectionForm.setUserId(userDTO.getUserID());
+ reflectionForm.setSessionId(toolSessionID);
// get the existing reflection entry
- IDacoService submitFilesService = getDacoService();
- SessionMap map = (SessionMap) request.getSession().getAttribute(sessionMapID);
- Long toolSessionID = (Long) map.get(AttributeNames.PARAM_TOOL_SESSION_ID);
- NotebookEntry entry = submitFilesService.getEntry(toolSessionID, CoreNotebookConstants.NOTEBOOK_TOOL,
- DacoConstants.TOOL_SIGNATURE, user.getUserID());
+ NotebookEntry entry = service.getEntry(toolSessionID, CoreNotebookConstants.NOTEBOOK_TOOL, DacoConstants.TOOL_SIGNATURE,
+ userDTO.getUserID());
if (entry != null) {
- refForm.setEntryText(entry.getEntry());
+ reflectionForm.setEntryText(entry.getEntry());
}
-
+ request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID);
+ reflectionForm.setSessionMapID(sessionMapID);
return mapping.findForward(DacoConstants.SUCCESS);
}
@@ -542,34 +544,28 @@
* @param response
* @return
*/
- protected ActionForward submitReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) {
- ReflectionForm refForm = (ReflectionForm) form;
- Integer userId = refForm.getUserID();
-
- String sessionMapID = WebUtil.readStrParam(request, DacoConstants.ATTR_SESSION_MAP_ID);
- SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
- Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);
-
+ protected ActionForward submitReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request) {
+ ReflectionForm reflectionForm = (ReflectionForm) form;
+ Integer userId = reflectionForm.getUserId();
+ Long sessionId = reflectionForm.getSessionId();
IDacoService service = getDacoService();
-
// check for existing notebook entry
NotebookEntry entry = service.getEntry(sessionId, CoreNotebookConstants.NOTEBOOK_TOOL, DacoConstants.TOOL_SIGNATURE,
userId);
if (entry == null) {
// create new entry
service.createNotebookEntry(sessionId, CoreNotebookConstants.NOTEBOOK_TOOL, DacoConstants.TOOL_SIGNATURE, userId,
- refForm.getEntryText());
+ reflectionForm.getEntryText());
}
else {
// update existing entry
- entry.setEntry(refForm.getEntryText());
+ entry.setEntry(reflectionForm.getEntryText());
entry.setLastModified(new Date());
service.updateEntry(entry);
}
- return finish(mapping, form, request, response);
+ return finish(mapping, request);
}
// *************************************************************************************
@@ -634,10 +630,10 @@
HttpSession ss = SessionManager.getSession();
// get back login user DTO
UserDTO user = (UserDTO) ss.getAttribute(AttributeNames.USER);
- DacoUser dacoUser = service.getUserByIDAndSession(new Long(user.getUserID().intValue()), sessionId);
+ DacoUser dacoUser = service.getUserByUserIdAndSessionId(new Long(user.getUserID().intValue()), sessionId);
if (dacoUser == null) {
- DacoSession session = service.getDacoSessionBySessionId(sessionId);
+ DacoSession session = service.getSessionBySessionId(sessionId);
dacoUser = new DacoUser(user, session);
dacoUser.setDaco(daco);
service.createUser(dacoUser);
@@ -646,7 +642,7 @@
}
protected DacoUser getSpecifiedUser(IDacoService service, Long sessionId, Integer userId) {
- DacoUser dacoUser = service.getUserByIDAndSession(new Long(userId.intValue()), sessionId);
+ DacoUser dacoUser = service.getUserByUserIdAndSessionId(new Long(userId.intValue()), sessionId);
if (dacoUser == null) {
LearningAction.log.error("Unable to find specified user for daco activity. Screens are likely to fail. SessionId="
+ sessionId + " UserId=" + userId);
@@ -1034,7 +1030,8 @@
request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID);
request.setAttribute(DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER, WebUtil.readIntParam(request,
DacoConstants.ATTR_DISPLAYED_RECORD_NUMBER));
-
+ request.setAttribute(DacoConstants.ATTR_LEARNING_CURRENT_TAB, WebUtil.readIntParam(request,
+ DacoConstants.ATTR_LEARNING_CURRENT_TAB));
String currentView = (String) sessionMap.get(DacoConstants.ATTR_LEARNING_VIEW);
if (DacoConstants.LEARNING_VIEW_HORIZONTAL.equals(currentView)) {
sessionMap.put(DacoConstants.ATTR_LEARNING_VIEW, DacoConstants.LEARNING_VIEW_VERTICAL);
@@ -1049,14 +1046,14 @@
String sessionMapID = WebUtil.readStrParam(request, DacoConstants.ATTR_SESSION_MAP_ID);
SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
Daco daco = (Daco) sessionMap.get(DacoConstants.ATTR_DACO);
- Long sessionId = (Long) sessionMap.get(DacoConstants.TOOL_SESSION_ID);
+ Long sessionId = (Long) sessionMap.get(AttributeNames.PARAM_TOOL_SESSION_ID);
IDacoService service = getDacoService();
DacoUser user = getCurrentUser(service, sessionId, daco);
- List summaries = service.getQuestionSummaries(daco.getUid(), user.getUid());
+ List summaries = service.getQuestionSummaries(user.getUid());
sessionMap.put(DacoConstants.ATTR_QUESTION_SUMMARIES, summaries);
- Integer totalRecordCount = service.getTotalRecordCount(daco.getContentId());
+ Integer totalRecordCount = service.getGroupRecordCount(user.getSession().getSessionId());
sessionMap.put(DacoConstants.ATTR_TOTAL_RECORD_COUNT, totalRecordCount);
request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID);
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/action/MonitoringAction.java
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/action/MonitoringAction.java (.../MonitoringAction.java) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/action/MonitoringAction.java (.../MonitoringAction.java) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -26,8 +26,6 @@
import java.io.IOException;
import java.util.List;
-import java.util.Map;
-import java.util.Set;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
@@ -42,10 +40,9 @@
import org.lamsfoundation.lams.notebook.service.CoreNotebookConstants;
import org.lamsfoundation.lams.tool.daco.DacoConstants;
import org.lamsfoundation.lams.tool.daco.dto.MonitoringSummarySessionDTO;
+import org.lamsfoundation.lams.tool.daco.dto.MonitoringSummaryUserDTO;
import org.lamsfoundation.lams.tool.daco.dto.QuestionSummaryDTO;
-import org.lamsfoundation.lams.tool.daco.dto.ReflectDTO;
import org.lamsfoundation.lams.tool.daco.model.Daco;
-import org.lamsfoundation.lams.tool.daco.model.DacoSession;
import org.lamsfoundation.lams.tool.daco.model.DacoUser;
import org.lamsfoundation.lams.tool.daco.service.IDacoService;
import org.lamsfoundation.lams.util.WebUtil;
@@ -66,12 +63,15 @@
return summary(mapping, request);
}
if (param.equals("viewReflection")) {
- return viewReflection(mapping, form, request, response);
+ return viewReflection(mapping, request);
}
if (param.equals("listRecords")) {
return listRecords(mapping, request);
}
+ if (param.equals("changeView")) {
+ return changeView(mapping, request);
+ }
return mapping.findForward(DacoConstants.ERROR);
}
@@ -82,9 +82,9 @@
Long userUid = WebUtil.readLongParam(request, DacoConstants.USER_UID, true);
Daco daco = (Daco) sessionMap.get(DacoConstants.ATTR_DACO);
IDacoService service = getDacoService();
- request.setAttribute(DacoConstants.ATTR_MONITORING_SUMMARY, service.getMonitoringSummary(daco.getContentId(), userUid));
+ sessionMap.put(DacoConstants.ATTR_MONITORING_SUMMARY, service.getMonitoringSummary(daco.getContentId(), userUid));
request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID);
- sessionMap.put(DacoConstants.ATTR_LEARNING_VIEW, DacoConstants.LEARNING_VIEW_VERTICAL);
+
request.setAttribute(DacoConstants.USER_UID, userUid);
return mapping.findForward(DacoConstants.SUCCESS);
}
@@ -99,7 +99,7 @@
sessionMap = new SessionMap();
sessionMapID = sessionMap.getSessionID();
request.getSession().setAttribute(sessionMapID, sessionMap);
-
+ sessionMap.put(DacoConstants.ATTR_LEARNING_VIEW, DacoConstants.LEARNING_VIEW_VERTICAL);
}
else {
sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
@@ -111,7 +111,6 @@
Daco daco = service.getDacoByContentId(contentId);
daco.toDTO();
- Map> relectList = service.getReflectList(contentId);
List monitoringSummaryList = service.getMonitoringSummary(contentId,
DacoConstants.MONITORING_SUMMARY_MATCH_NONE);
@@ -129,57 +128,66 @@
userUid = monitoringSummaryList.get(0).getUsers().get(0).getUid();
}
if (userUid != null) {
- List summaries = service.getQuestionSummaries(daco.getUid(), userUid);
+ List summaries = service.getQuestionSummaries(userUid);
sessionMap.put(DacoConstants.ATTR_QUESTION_SUMMARIES, summaries);
- Integer totalRecordCount = service.getTotalRecordCount(daco.getContentId());
+
+ Integer totalRecordCount = service.getGroupRecordCount(service.getUser(userUid).getSession().getSessionId());
sessionMap.put(DacoConstants.ATTR_TOTAL_RECORD_COUNT, totalRecordCount);
monitoringSummaryList = service.getMonitoringSummary(contentId, userUid);
}
request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID);
sessionMap.put(DacoConstants.USER_UID, userUid);
sessionMap.put(DacoConstants.PAGE_EDITABLE, !daco.isContentInUse());
- sessionMap.put(DacoConstants.ATTR_REFLECT_LIST, relectList);
sessionMap.put(DacoConstants.ATTR_MONITORING_SUMMARY, monitoringSummaryList);
+
if (newSession) {
sessionMap.put(DacoConstants.ATTR_DACO, daco);
- sessionMap.put(DacoConstants.TOOL_CONTENT_ID, contentId);
+ sessionMap.put(AttributeNames.PARAM_TOOL_CONTENT_ID, contentId);
sessionMap.put(AttributeNames.PARAM_CONTENT_FOLDER_ID, WebUtil.readStrParam(request,
AttributeNames.PARAM_CONTENT_FOLDER_ID));
}
return mapping.findForward(DacoConstants.SUCCESS);
}
- protected ActionForward viewReflection(ActionMapping mapping, ActionForm form, HttpServletRequest request,
- HttpServletResponse response) {
+ protected ActionForward viewReflection(ActionMapping mapping, HttpServletRequest request) {
+ String sessionMapID = request.getParameter(DacoConstants.ATTR_SESSION_MAP_ID);
+ SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
+ Integer userId = WebUtil.readIntParam(request, DacoConstants.USER_ID);
+ Long sessionId = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID);
- Long uid = WebUtil.readLongParam(request, DacoConstants.USER_UID);
- Long sessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID);
-
IDacoService service = getDacoService();
- DacoUser user = service.getUser(uid);
- NotebookEntry notebookEntry = service.getEntry(sessionID, CoreNotebookConstants.NOTEBOOK_TOOL,
- DacoConstants.TOOL_SIGNATURE, user.getUserId().intValue());
+ DacoUser user = service.getUserByUserIdAndSessionId(userId.longValue(), sessionId);
+ NotebookEntry notebookEntry = service.getEntry(sessionId, CoreNotebookConstants.NOTEBOOK_TOOL,
+ DacoConstants.TOOL_SIGNATURE, userId);
- DacoSession session = service.getDacoSessionBySessionId(sessionID);
-
- ReflectDTO refDTO = new ReflectDTO(user);
- if (notebookEntry == null) {
- refDTO.setFinishReflection(false);
- refDTO.setReflect(null);
- }
- else {
- refDTO.setFinishReflection(true);
- refDTO.setReflect(notebookEntry.getEntry());
- }
- refDTO.setReflectInstrctions(session.getDaco().getReflectInstructions());
-
- request.setAttribute("userDTO", refDTO);
- return mapping.findForward("success");
+ MonitoringSummaryUserDTO userDTO = new MonitoringSummaryUserDTO(null, userId, user.getLastName() + " "
+ + user.getFirstName(), null);
+ userDTO.setReflectionEntry(notebookEntry.getEntry());
+ sessionMap.put(DacoConstants.ATTR_USER, userDTO);
+ request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID);
+ return mapping.findForward(DacoConstants.SUCCESS);
}
private IDacoService getDacoService() {
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet().getServletContext());
return (IDacoService) wac.getBean(DacoConstants.DACO_SERVICE);
}
+
+ protected ActionForward changeView(ActionMapping mapping, HttpServletRequest request) {
+ String sessionMapID = WebUtil.readStrParam(request, DacoConstants.ATTR_SESSION_MAP_ID);
+ SessionMap sessionMap = (SessionMap) request.getSession().getAttribute(sessionMapID);
+ request.setAttribute(DacoConstants.ATTR_SESSION_MAP_ID, sessionMapID);
+
+ String currentView = (String) sessionMap.get(DacoConstants.ATTR_LEARNING_VIEW);
+ Long userUid = WebUtil.readLongParam(request, DacoConstants.USER_UID, true);
+ request.setAttribute(DacoConstants.USER_UID, userUid);
+ if (DacoConstants.LEARNING_VIEW_HORIZONTAL.equals(currentView)) {
+ sessionMap.put(DacoConstants.ATTR_LEARNING_VIEW, DacoConstants.LEARNING_VIEW_VERTICAL);
+ }
+ else {
+ sessionMap.put(DacoConstants.ATTR_LEARNING_VIEW, DacoConstants.LEARNING_VIEW_HORIZONTAL);
+ }
+ return mapping.findForward(DacoConstants.SUCCESS);
+ }
}
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/form/DacoForm.java
===================================================================
diff -u -r20efcf1f1ffa7e732d72deaf0c670f34836d9a0a -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/form/DacoForm.java (.../DacoForm.java) (revision 20efcf1f1ffa7e732d72deaf0c670f34836d9a0a)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/form/DacoForm.java (.../DacoForm.java) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -76,7 +76,7 @@
// so need not reset checkbox to refresh value!
if (!StringUtils.equals(param, "start") && !StringUtils.equals(param, "initPage")) {
- daco.setLockWhenFinished(false);
+ daco.setLockOnFinished(false);
daco.setDefineLater(false);
daco.setRunOffline(false);
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/form/ReflectionForm.java
===================================================================
diff -u -rbe03cfbba16a388e85d82cb8986f63d6b2ad568b -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/form/ReflectionForm.java (.../ReflectionForm.java) (revision be03cfbba16a388e85d82cb8986f63d6b2ad568b)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/form/ReflectionForm.java (.../ReflectionForm.java) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -21,7 +21,7 @@
* ****************************************************************
*/
-/* $$Id$$ */
+/* $$Id$$ */
package org.lamsfoundation.lams.tool.daco.web.form;
import org.apache.log4j.Logger;
@@ -36,10 +36,11 @@
public class ReflectionForm extends ValidatorForm {
private static final long serialVersionUID = -9054365604649146735L;
private static Logger logger = Logger.getLogger(ReflectionForm.class.getName());
-
- private Integer userID;
- private String sessionMapID;
+
+ private Integer userId;
+ private Long sessionId;
private String entryText;
+ private String sessionMapID;
public String getEntryText() {
return entryText;
@@ -49,14 +50,22 @@
this.entryText = entryText;
}
- public Integer getUserID() {
- return userID;
+ public Integer getUserId() {
+ return userId;
}
- public void setUserID(Integer userUid) {
- this.userID = userUid;
+ public void setUserId(Integer userUid) {
+ userId = userUid;
}
+ public Long getSessionId() {
+ return sessionId;
+ }
+
+ public void setSessionId(Long sessionMapID) {
+ sessionId = sessionMapID;
+ }
+
public String getSessionMapID() {
return sessionMapID;
}
Index: lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/servlet/ExportServlet.java
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/servlet/ExportServlet.java (.../ExportServlet.java) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/src/java/org/lamsfoundation/lams/tool/daco/web/servlet/ExportServlet.java (.../ExportServlet.java) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -26,7 +26,6 @@
package org.lamsfoundation.lams.tool.daco.web.servlet;
import java.io.File;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -36,10 +35,15 @@
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
+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.daco.DacoConstants;
-import org.lamsfoundation.lams.tool.daco.dto.Summary;
+import org.lamsfoundation.lams.tool.daco.dto.MonitoringSummarySessionDTO;
+import org.lamsfoundation.lams.tool.daco.dto.MonitoringSummaryUserDTO;
+import org.lamsfoundation.lams.tool.daco.dto.QuestionSummaryDTO;
import org.lamsfoundation.lams.tool.daco.model.Daco;
+import org.lamsfoundation.lams.tool.daco.model.DacoAnswer;
import org.lamsfoundation.lams.tool.daco.model.DacoSession;
import org.lamsfoundation.lams.tool.daco.model.DacoUser;
import org.lamsfoundation.lams.tool.daco.service.DacoApplicationException;
@@ -54,44 +58,42 @@
import org.springframework.web.context.support.WebApplicationContextUtils;
/**
- * Export portfolio servlet to export all shared daco into offline HTML package.
+ * Export portfolio servlet to export all Data Collection daco into offline HTML package.
*
- * @author Steve.Ni
+ * @author Marcin Cieslak
*
- * @version $Revision$
*/
public class ExportServlet extends AbstractExportPortfolioServlet {
- private static final long serialVersionUID = -4529093489007108143L;
private static Logger logger = Logger.getLogger(ExportServlet.class);
- private final String FILENAME = "shared_daco_main.html";
-
+ private final String FILENAME = "daco_main.html";
private DacoToolContentHandler handler;
@Override
public String doExport(HttpServletRequest request, HttpServletResponse response, String directoryName, Cookie[] cookies) {
-
- // initial sessionMap
+ handler = getToolContentHandler();
SessionMap sessionMap = new SessionMap();
request.getSession().setAttribute(sessionMap.getSessionID(), sessionMap);
-
+ String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
+ + request.getContextPath();
try {
if (StringUtils.equals(mode, ToolAccessMode.LEARNER.toString())) {
- sessionMap.put(AttributeNames.ATTR_MODE, ToolAccessMode.LEARNER);
- learner(request, response, directoryName, cookies, sessionMap);
+ learnerExport(sessionMap, directoryName);
}
else if (StringUtils.equals(mode, ToolAccessMode.TEACHER.toString())) {
- sessionMap.put(AttributeNames.ATTR_MODE, ToolAccessMode.TEACHER);
- teacher(request, response, directoryName, cookies, sessionMap);
+ File learnerDirectory = new File(new File(directoryName), "learners");
+ learnerDirectory.mkdir();
+ new File(learnerDirectory, "files").mkdir();
+ teacherExport(sessionMap, basePath, learnerDirectory.getAbsolutePath(), cookies);
}
}
catch (DacoApplicationException e) {
ExportServlet.logger.error("Cannot perform export for daco tool.");
}
- String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
- + request.getContextPath();
+ writeResponseToFile(basePath + "/includes/css/daco.css", directoryName, "daco.css", cookies);
+
writeResponseToFile(basePath + "/pages/export/exportportfolio.jsp?sessionMapID=" + sessionMap.getSessionID(),
directoryName, FILENAME, cookies);
@@ -106,117 +108,148 @@
}
else {
IDacoService service = DacoServiceProxy.getDacoService(getServletContext());
- Daco content = null;
+ Daco daco = null;
if (toolContentID != null) {
- content = service.getDacoByContentId(toolContentID);
+ daco = service.getDacoByContentId(toolContentID);
}
else {
- DacoSession session = service.getDacoSessionBySessionId(toolSessionID);
+ DacoSession session = service.getSessionBySessionId(toolSessionID);
if (session != null) {
- content = session.getDaco();
+ daco = session.getDaco();
}
}
- if (content != null) {
- activityTitle = content.getTitle();
+ if (daco != null) {
+ activityTitle = daco.getTitle();
}
}
return super.doOfflineExport(request, response, directoryName, cookies);
}
- public void learner(HttpServletRequest request, HttpServletResponse response, String directoryName, Cookie[] cookies,
- HashMap sessionMap) throws DacoApplicationException {
-
- IDacoService service = DacoServiceProxy.getDacoService(getServletContext());
-
- if (userID == null || toolSessionID == null) {
- String error = "Tool session Id or user Id is null. Unable to continue";
+ private void teacherExport(SessionMap sessionMap, String basePath, String learnerDirectory, Cookie[] cookies)
+ throws DacoApplicationException {
+ if (toolContentID == null) {
+ String error = "Tool Content Id is missing. Unable to continue";
ExportServlet.logger.error(error);
throw new DacoApplicationException(error);
}
-
- DacoUser learner = service.getUserByIDAndSession(userID, toolSessionID);
-
- if (learner == null) {
- String error = "The user with user id " + userID + " does not exist.";
+ IDacoService service = DacoServiceProxy.getDacoService(getServletContext());
+ Daco daco = service.getDacoByContentId(toolContentID);
+ if (daco == null) {
+ String error = "Data is missing from the database. Unable to Continue";
ExportServlet.logger.error(error);
throw new DacoApplicationException(error);
}
+ List monitoringSummary = service.getMonitoringSummary(daco.getContentId(),
+ DacoConstants.MONITORING_SUMMARY_MATCH_ALL);
+ sessionMap.put(DacoConstants.ATTR_MONITORING_SUMMARY, monitoringSummary);
+ sessionMap.put(AttributeNames.ATTR_MODE, ToolAccessMode.TEACHER);
+ sessionMap.put(DacoConstants.ATTR_LEARNING_VIEW, DacoConstants.LEARNING_VIEW_VERTICAL);
+ sessionMap.put(DacoConstants.ATTR_DACO, daco);
- Daco content = service.getDacoBySessionId(toolSessionID);
+ boolean anyRecordsAvailable = false;
+ for (MonitoringSummarySessionDTO session : monitoringSummary) {
+ for (MonitoringSummaryUserDTO user : session.getUsers()) {
+ if (user.getRecordCount() > 0) {
+ anyRecordsAvailable = true;
- if (content == null) {
- String error = "The content for this activity has not been defined yet.";
- ExportServlet.logger.error(error);
- throw new DacoApplicationException(error);
- }
+ List summaries = service.getQuestionSummaries(user.getUid());
+ sessionMap.put(DacoConstants.ATTR_QUESTION_SUMMARIES, summaries);
- List group = service.exportBySessionId(toolSessionID, true);
- saveFileToLocal(group, directoryName);
+ Integer totalRecordCount = service.getGroupRecordCount(session);
+ sessionMap.put(DacoConstants.ATTR_TOTAL_RECORD_COUNT, totalRecordCount);
- List groupList = new ArrayList();
- if (group.size() > 0) {
- groupList.add(group);
+ sessionMap.put(DacoConstants.ATTR_USER, user);
+
+ for (List record : user.getRecords()) {
+ for (DacoAnswer answer : record) {
+ if (answer.getFileUuid() != null) {
+ String fileLocalPath = FileUtil.getFullPath("files", answer.getFileUuid() + "-"
+ + answer.getFileName());
+ try {
+ handler.saveFile(answer.getFileUuid(), FileUtil.getFullPath(learnerDirectory, fileLocalPath));
+ }
+ catch (Exception e) {
+ ExportServlet.logger.error("File export failed: " + e.toString());
+ }
+ }
+ }
+ }
+
+ writeResponseToFile(basePath + "/pages/export/listRecordsTemplate.jsp?sessionMapID="
+ + sessionMap.getSessionID(), learnerDirectory, user.getUid() + "-records.html", cookies);
+ writeResponseToFile(basePath + "/pages/monitoring/notebook.jsp?sessionMapID=" + sessionMap.getSessionID()
+ + "&includeMode=exportportfolio", learnerDirectory, user.getUid() + "-reflection.html", cookies);
+
+ }
+ }
}
- sessionMap.put(DacoConstants.ATTR_TITLE, content.getTitle());
- //sessionMap.put(DacoConstants.ATTR_SUMMARY_LIST, groupList);
+ if (anyRecordsAvailable) {
+ writeResponseToFile(basePath + "/pages/monitoring/listRecords.jsp?sessionMapID=" + sessionMap.getSessionID()
+ + "&includeMode=exportportfolio", learnerDirectory, "allRecords.html", cookies);
+ }
}
- public void teacher(HttpServletRequest request, HttpServletResponse response, String directoryName, Cookie[] cookies,
- HashMap sessionMap) throws DacoApplicationException {
+ private void learnerExport(HashMap sessionMap, String directory) throws DacoApplicationException {
IDacoService service = DacoServiceProxy.getDacoService(getServletContext());
- // check if toolContentId exists in db or not
- if (toolContentID == null) {
- String error = "Tool Content Id is missing. Unable to continue";
+ if (userID == null || toolSessionID == null) {
+ String error = "Tool session Id or user Id is null. Unable to continue";
ExportServlet.logger.error(error);
throw new DacoApplicationException(error);
}
+ DacoUser user = service.getUserByUserIdAndSessionId(userID, toolSessionID);
- Daco content = service.getDacoByContentId(toolContentID);
+ if (user == null) {
+ String error = "The user with user id " + userID + " does not exist.";
+ ExportServlet.logger.error(error);
+ throw new DacoApplicationException(error);
+ }
- if (content == null) {
- String error = "Data is missing from the database. Unable to Continue";
+ Daco daco = user.getDaco();
+
+ if (daco == null) {
+ String error = "The content for this activity has not been defined yet.";
ExportServlet.logger.error(error);
throw new DacoApplicationException(error);
}
- List> groupList = service.exportByContentId(toolContentID);
- if (groupList != null) {
- for (List list : groupList) {
- saveFileToLocal(list, directoryName);
- }
- }
- // put it into HTTPSession
- sessionMap.put(DacoConstants.ATTR_TITLE, content.getTitle());
- //sessionMap.put(DacoConstants.ATTR_SUMMARY_LIST, groupList);
- }
- private void saveFileToLocal(List list, String directoryName) {
- handler = getToolContentHandler();
- for (Summary summary : list) {
- // for learning object, it just display "No offlice pakcage avaliable" information.
- if (summary.getQuestionType() == DacoConstants.QUESTION_TYPE_TEXTFIELD) {
- continue;
- }
- try {
- int index = 1;
- String userName = summary.getUsername();
- String localDir;
- while (true) {
- localDir = FileUtil.getFullPath(directoryName, userName + "/" + index);
- File local = new File(localDir);
- if (!local.exists()) {
- local.mkdirs();
- break;
+ List summaries = service.getQuestionSummaries(user.getUid());
+ sessionMap.put(DacoConstants.ATTR_QUESTION_SUMMARIES, summaries);
+
+ Integer totalRecordCount = service.getGroupRecordCount(toolSessionID);
+ sessionMap.put(DacoConstants.ATTR_TOTAL_RECORD_COUNT, totalRecordCount);
+
+ sessionMap.put(DacoConstants.ATTR_DACO, daco);
+ List> records = service.getDacoAnswersByUserUid(user.getUid());
+ new File(directory, "files").mkdir();
+
+ for (List record : records) {
+ for (DacoAnswer answer : record) {
+ if (answer.getFileUuid() != null) {
+ String fileLocalPath = FileUtil.getFullPath("files", answer.getFileUuid() + "-" + answer.getFileName());
+ try {
+ handler.saveFile(answer.getFileUuid(), FileUtil.getFullPath(directory, fileLocalPath));
}
- index++;
+ catch (Exception e) {
+ e.printStackTrace();
+ ExportServlet.logger.error("File export failed: " + e.toString());
+ }
}
- // REMOVED!!
}
- catch (Exception e) {
- ExportServlet.logger.error("Export forum topic attachment failed: " + e.toString());
- }
}
+ String entryText = null;
+ if (user != null) {
+ NotebookEntry notebookEntry = service.getEntry(toolSessionID, CoreNotebookConstants.NOTEBOOK_TOOL,
+ DacoConstants.TOOL_SIGNATURE, user.getUserId().intValue());
+ if (notebookEntry != null) {
+ entryText = notebookEntry.getEntry();
+ }
+ }
+ sessionMap.put(DacoConstants.ATTR_REFLECTION_ENTRY, entryText);
+ sessionMap.put(DacoConstants.ATTR_RECORD_LIST, records);
+ sessionMap.put(AttributeNames.ATTR_MODE, ToolAccessMode.LEARNER);
+ sessionMap.put(DacoConstants.ATTR_LEARNING_VIEW, DacoConstants.LEARNING_VIEW_VERTICAL);
}
private DacoToolContentHandler getToolContentHandler() {
@@ -226,4 +259,4 @@
}
return handler;
}
-}
+}
\ No newline at end of file
Index: lams_tool_daco/web/WEB-INF/tags/AuthoringButton.tag
===================================================================
diff -u -rbe03cfbba16a388e85d82cb8986f63d6b2ad568b -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/web/WEB-INF/tags/AuthoringButton.tag (.../AuthoringButton.tag) (revision be03cfbba16a388e85d82cb8986f63d6b2ad568b)
+++ lams_tool_daco/web/WEB-INF/tags/AuthoringButton.tag (.../AuthoringButton.tag) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -50,7 +50,7 @@
<%-- Default value for message key --%>
-
+
Index: lams_tool_daco/web/common/header.jsp
===================================================================
diff -u -rbe03cfbba16a388e85d82cb8986f63d6b2ad568b -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/web/common/header.jsp (.../header.jsp) (revision be03cfbba16a388e85d82cb8986f63d6b2ad568b)
+++ lams_tool_daco/web/common/header.jsp (.../header.jsp) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -4,14 +4,14 @@
-
+
-
+
Index: lams_tool_daco/web/common/tabbedheader.jsp
===================================================================
diff -u -rbe03cfbba16a388e85d82cb8986f63d6b2ad568b -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/web/common/tabbedheader.jsp (.../tabbedheader.jsp) (revision be03cfbba16a388e85d82cb8986f63d6b2ad568b)
+++ lams_tool_daco/web/common/tabbedheader.jsp (.../tabbedheader.jsp) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -4,14 +4,14 @@
-
+
-
+
Index: lams_tool_daco/web/includes/css/daco.css
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/web/includes/css/daco.css (.../daco.css) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/web/includes/css/daco.css (.../daco.css) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -1,10 +1,3 @@
-.innerforms {
- border: 0px;
- font-size: small;
- font-style: normal;
- width:100%;
-}
-
div.error, div.message {
background-color: #ffffcc;
border: 1px solid #000;
@@ -30,7 +23,7 @@
margin-right: auto;
text-align: left;
font-weight: normal;
- background: url('../images/css/edit.gif') no-repeat #d8e4f1 10px 8px;
+ background: url('../images/edit.gif') no-repeat #d8e4f1 10px 8px;
width: 70%;
border: 1px solid #3c78b5;
float: none;
@@ -48,15 +41,15 @@
.hint {
font-style: italic;
}
-table.recordList {
+table.recordList { /* delimeter for records in a vertical record list */
border-bottom: thin black solid;
}
form#recordForm input, form#recordForm textarea, form#recordForm select{
margin-top: 6px;
}
-.button-add-div {
+.button-add-div { /* makes a "div" properly padded in tabbed environment */
padding-left: 30px;
}
div.bigNumber{
@@ -70,24 +63,27 @@
height: 100%;
}
-table#horizontalListTable td {
+table#horizontalListTable td { /* delimeter for records in a horizontal record list */
border-left: 1px black solid;
}
table#recordListTable td.fixedCellHeight, table#horizontalListTable td.fixedCellHeight {
+ /* cells must have the same height, otherwise they will be incorrectly aligned in horizontal record list*/
padding-left: 20px;
height: 90px;
vertical-align: middle;
}
table#horizontalListTable td#lastHorizontalQuestion{
+ /* cell with the last question in a record list is smaller because of the horizontal scrollbar */
padding-left: 20px;
height: 75px;
vertical-align: middle;
}
form#recordForm table.alternative-color-inner-table td, table.recordList table.alternative-color-inner-table td,
table#horizontalListTable table.alternative-color-inner-table td, table#summaryTable table.alternative-color-inner-table td{
+ /* makes the table-within-table plain, instead of repeating the style */
margin: 0px;
padding: 0px;
border: none;
@@ -108,3 +104,35 @@
height: 30px;
padding-top: 30px;
}
+
+#content-learner {
+ /* reduced width of tabbed environment since learner is narrower */
+ width: 592px;
+ background: url('../images/body_bg_learner.jpg') repeat-y;
+ padding-bottom:40px;
+ padding-left:15px;
+ padding-right:15px;
+ font-size: 11px;
+ margin-top: -5px
+
+}
+#footer-learner {
+ /* reduced width of tabbed environment since learner is narrower */
+ width: 592px;
+ height: 14px;
+ background: url('../images/footer_bg_learner.jpg') no-repeat bottom;
+}
+
+#header-learner {
+ /* reduced width of tabbed environment since learner is narrower */
+ width:592px;
+ height: 49px;
+ background: url('../images/top_bg_learner.jpg') no-repeat bottom;
+ }
+
+#page-learner {
+ /* reduced width of tabbed environment since learner is narrower */
+ margin: 25px auto;
+ width: 592px;
+ background: url('../images/lams_logo.gif') no-repeat 585px 10px;
+}
\ No newline at end of file
Index: lams_tool_daco/web/includes/images/body_bg_learner.jpg
===================================================================
diff -u
Binary files differ
Index: lams_tool_daco/web/includes/images/footer_bg_learner.jpg
===================================================================
diff -u
Binary files differ
Index: lams_tool_daco/web/includes/images/lams_logo.gif
===================================================================
diff -u
Binary files differ
Index: lams_tool_daco/web/includes/images/top_bg_learner.jpg
===================================================================
diff -u
Binary files differ
Index: lams_tool_daco/web/includes/javascript/dacoAuthoring.js
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/web/includes/javascript/dacoAuthoring.js (.../dacoAuthoring.js) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/web/includes/javascript/dacoAuthoring.js (.../dacoAuthoring.js) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -25,7 +25,7 @@
|| checkNonDefaultValue("min")
|| checkNonDefaultValue("digitsDecimal")
|| $('#questionRequired').attr('checked')
- || !($("#noSummaryOption").attr("selected"))) {
+ || ($("#noSummaryOption").length>0 && !$("#noSummaryOption").attr("selected"))) {
toggleAdditionalOptionsArea();
}
}
Index: lams_tool_daco/web/includes/javascript/dacoCommon.js
===================================================================
diff -u
--- lams_tool_daco/web/includes/javascript/dacoCommon.js (revision 0)
+++ lams_tool_daco/web/includes/javascript/dacoCommon.js (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -0,0 +1,38 @@
+
+ // Finds a corresponding image and shows it
+ function showBusy(targetDiv){
+ if($(targetDiv+"_Busy") != null){
+ $(targetDiv+"_Busy").show();
+ }
+ }
+
+ // Finds a corresponding image and hides it
+ function hideBusy(targetDiv){
+ if($(targetDiv+"_Busy") != null){
+ $(targetDiv+"_Busy").hide();
+ }
+ }
+
+ // Creates an hidden element and adds it to a JSON structure
+ function addToJSON (arr, name, value){
+ var elem = document.createElement('hidden');
+ elem.value=value;
+ elem.name=name;
+ arr[arr.length]=elem;
+ }
+ function checkCheckbox(checkboxName){
+ var checkbox = document.getElementById(checkboxName);
+ checkbox.checked=true;
+ }
+ function setValue(elementName,value){
+ var element = document.getElementById(elementName);
+ element.value=value;
+ }
+
+ function resizeHorizontalRecordListFrame(elementIdPrefix,questionListLength){
+
+ var horizontalRecordListFrame = document.getElementById(elementIdPrefix+'horizontalRecordListFrame');
+ if (horizontalRecordListFrame!=null){
+ horizontalRecordListFrame.style.height=((questionListLength+1)*111)+'px';
+ }
+ }
\ No newline at end of file
Index: lams_tool_daco/web/includes/javascript/dacoLearning.js
===================================================================
diff -u -r2b2611326286bc64cc4e22c9d16642ad038b93c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/web/includes/javascript/dacoLearning.js (.../dacoLearning.js) (revision 2b2611326286bc64cc4e22c9d16642ad038b93c3)
+++ lams_tool_daco/web/includes/javascript/dacoLearning.js (.../dacoLearning.js) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -44,21 +44,24 @@
}
function readHiddenFormValues(){
- var elementCount = document.getElementById("recordForm").elements.length;
- for (var questionNumber=1;questionNumber<=elementCount;questionNumber++){
- var checkboxQuestion=document.getElementById("checkbox-"+questionNumber);
- if (checkboxQuestion!=null){
- var checkboxValues = checkboxQuestion.value.split("&");
- var checkboxNumber = 1;
- var checkbox = document.getElementById("checkbox-"+questionNumber+"-"+checkboxNumber);
- while (checkbox!=null){
- for (var index = 0; index= 0){
- document.location = url+"&userUid="+selectedValue;
+ document.location.href = url+"&userUid="+selectedValue;
}
}
\ No newline at end of file
Index: lams_tool_daco/web/pages/authoring/advanced.jsp
===================================================================
diff -u -r2b2611326286bc64cc4e22c9d16642ad038b93c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/web/pages/authoring/advanced.jsp (.../advanced.jsp) (revision 2b2611326286bc64cc4e22c9d16642ad038b93c3)
+++ lams_tool_daco/web/pages/authoring/advanced.jsp (.../advanced.jsp) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -14,15 +14,15 @@
-
${index}
-
+
@@ -35,9 +35,9 @@
-
-
+
+
Index: lams_tool_daco/web/pages/authoring/authoring.jsp
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/web/pages/authoring/authoring.jsp (.../authoring.jsp) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/web/pages/authoring/authoring.jsp (.../authoring.jsp) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -55,7 +55,7 @@
@@ -78,7 +78,7 @@
-
+
@@ -88,7 +88,7 @@
<%-- Default value
- cancelButtonLabelKey="label.authoring.cancel.button"
+ cancelButtonLabelKey="label.common.cancel"
saveButtonLabelKey="label.authoring.save.button"
cancelConfirmMsgKey="message.authoring.cancel.save"
accessMode="author"
Index: lams_tool_daco/web/pages/authoring/instructions.jsp
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/web/pages/authoring/instructions.jsp (.../instructions.jsp) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/web/pages/authoring/instructions.jsp (.../instructions.jsp) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -83,7 +83,7 @@
-
+
@@ -122,7 +122,7 @@
-
+
\ No newline at end of file
Index: lams_tool_daco/web/pages/authoring/parts/addcheckbox.jsp
===================================================================
diff -u -r9aa7e24878b41bd6baffa35e83ef392e670811c3 -r843648563725cffa91af1dfd96dce9682d39b410
--- lams_tool_daco/web/pages/authoring/parts/addcheckbox.jsp (.../addcheckbox.jsp) (revision 9aa7e24878b41bd6baffa35e83ef392e670811c3)
+++ lams_tool_daco/web/pages/authoring/parts/addcheckbox.jsp (.../addcheckbox.jsp) (revision 843648563725cffa91af1dfd96dce9682d39b410)
@@ -61,7 +61,7 @@