Index: lams_tool_laqa/build.xml
===================================================================
diff -u -r80a367726b9e7607851be28429bda54d9b306159 -ra82189db31f6fb6dd4a25a50a688b2812e93ddce
--- lams_tool_laqa/build.xml (.../build.xml) (revision 80a367726b9e7607851be28429bda54d9b306159)
+++ lams_tool_laqa/build.xml (.../build.xml) (revision a82189db31f6fb6dd4a25a50a688b2812e93ddce)
@@ -213,6 +213,7 @@
+
Index: lams_tool_laqa/conf/language/lams/ApplicationResources.properties
===================================================================
diff -u -r80a367726b9e7607851be28429bda54d9b306159 -ra82189db31f6fb6dd4a25a50a688b2812e93ddce
--- lams_tool_laqa/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 80a367726b9e7607851be28429bda54d9b306159)
+++ lams_tool_laqa/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision a82189db31f6fb6dd4a25a50a688b2812e93ddce)
@@ -230,7 +230,11 @@
wizard.author.info1 = This wizard helps you choose the right type of question you might want to ask your learners.
wizard.author.info2 = Choose a category and then the second menu will display the cognitive skill.
wizard.author.info3 = After you select a cognitive skill, you'll be presented with a question template you can use.
+wizard.export.export =Export Wizard
+wizard.export.savefirst =Your wizard design has been altered, please save before exporting.
+wizard.import.import =Import Wizard
+wizard.import.nofile =Please select an xml file to import first.
+wizard.import.warn =Are you sure you want to import a new wizard? This will overwrite the existing wizard design.
+wizard.import.error =Failed to import the wizard, make sure the imported file is in the expected xml format.
-
-
#======= End labels: Exported 193 labels for en AU =====
Index: lams_tool_laqa/conf/language/lams/ApplicationResources_en_AU.properties
===================================================================
diff -u -r80a367726b9e7607851be28429bda54d9b306159 -ra82189db31f6fb6dd4a25a50a688b2812e93ddce
--- lams_tool_laqa/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 80a367726b9e7607851be28429bda54d9b306159)
+++ lams_tool_laqa/conf/language/lams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision a82189db31f6fb6dd4a25a50a688b2812e93ddce)
@@ -239,5 +239,10 @@
wizard.author.info1 = This wizard helps you choose the right type of question you might want to ask your learners.
wizard.author.info2 = Choose a category and then the second menu will display the cognitive skill.
wizard.author.info3 = After you select a cognitive skill, you'll be presented with a question template you can use.
-
+wizard.export.export =Export Wizard
+wizard.export.savefirst =Your wizard design has been altered, please save before exporting.
+wizard.import.import =Import Wizard
+wizard.import.nofile =Please select an xml file to import first.
+wizard.import.warn =Are you sure you want to import a new wizard? This will overwrite the existing wizard design.
+wizard.import.error =Failed to import the wizard, make sure the imported file is in the expected xml format.
#======= End labels: Exported 168 labels for en AU =====
Index: lams_tool_laqa/conf/language/rams/ApplicationResources.properties
===================================================================
diff -u -r80a367726b9e7607851be28429bda54d9b306159 -ra82189db31f6fb6dd4a25a50a688b2812e93ddce
--- lams_tool_laqa/conf/language/rams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 80a367726b9e7607851be28429bda54d9b306159)
+++ lams_tool_laqa/conf/language/rams/ApplicationResources.properties (.../ApplicationResources.properties) (revision a82189db31f6fb6dd4a25a50a688b2812e93ddce)
@@ -202,7 +202,11 @@
wizard.author.info1 = This wizard helps you choose the right type of question you might want to ask your learners.
wizard.author.info2 = Choose a category and then the second menu will display the cognitive skill.
wizard.author.info3 = After you select a cognitive skill, you'll be presented with a question template you can use.
+wizard.export.export =Export Wizard
+wizard.export.savefirst =Your wizard design has been altered, please save before exporting.
+wizard.import.import =Import Wizard
+wizard.import.nofile =Please select an xml file to import first.
+wizard.import.warn =Are you sure you want to import a new wizard? This will overwrite the existing wizard design.
+wizard.import.error =Failed to import the wizard, make sure the imported file is in the expected xml format.
-
-
#======= End labels: Exported 164 labels for en AU =====
Index: lams_tool_laqa/conf/language/rams/ApplicationResources_en_AU.properties
===================================================================
diff -u -r80a367726b9e7607851be28429bda54d9b306159 -ra82189db31f6fb6dd4a25a50a688b2812e93ddce
--- lams_tool_laqa/conf/language/rams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision 80a367726b9e7607851be28429bda54d9b306159)
+++ lams_tool_laqa/conf/language/rams/ApplicationResources_en_AU.properties (.../ApplicationResources_en_AU.properties) (revision a82189db31f6fb6dd4a25a50a688b2812e93ddce)
@@ -202,7 +202,11 @@
wizard.author.info1 = This wizard helps you choose the right type of question you might want to ask your learners.
wizard.author.info2 = Choose a category and then the second menu will display the cognitive skill.
wizard.author.info3 = After you select a cognitive skill, you'll be presented with a question template you can use.
+wizard.export.export =Export Wizard
+wizard.export.savefirst =Your wizard design has been altered, please save before exporting.
+wizard.import.import =Import Wizard
+wizard.import.nofile =Please select an xml file to import first.
+wizard.import.warn =Are you sure you want to import a new wizard? This will overwrite the existing wizard design.
+wizard.import.error =Failed to import the wizard, make sure the imported file is in the expected xml format.
-
-
#======= End labels: Exported 164 labels for en AU =====
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaWizardCategory.java
===================================================================
diff -u -r80a367726b9e7607851be28429bda54d9b306159 -ra82189db31f6fb6dd4a25a50a688b2812e93ddce
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaWizardCategory.java (.../QaWizardCategory.java) (revision 80a367726b9e7607851be28429bda54d9b306159)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaWizardCategory.java (.../QaWizardCategory.java) (revision a82189db31f6fb6dd4a25a50a688b2812e93ddce)
@@ -18,28 +18,34 @@
*
* http://www.gnu.org/licenses/gpl.txt
* ****************************************************************
- */
-
-/* $Id$ */
+ */
+
+/* $Id$ */
package org.lamsfoundation.lams.tool.qa;
import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.Set;
+import java.util.TreeSet;
+import org.apache.log4j.Logger;
+
/**
- * This class maps to a single category in the q&a wizard, it
- * contains a set of cognitive skills
+ * This class maps to a single category in the q&a wizard, it contains a set of
+ * cognitive skills
*
* @hibernate.class table="tl_laqa11_wizard_category"
- */
-public class QaWizardCategory implements Serializable, Comparable {
-
+ */
+public class QaWizardCategory implements Serializable, Comparable, Cloneable {
+
public static final long serialVersionUID = 1234165196523665452L;
-
+ private static Logger logger = Logger.getLogger(QaWizardCategory.class.getName());
+
private Long uid;
private String title;
private Set cognitiveSkills;
-
+
public QaWizardCategory() {
}
@@ -55,22 +61,22 @@
*
*/
public Long getUid() {
- return uid;
+ return uid;
}
public void setUid(Long uid) {
- this.uid = uid;
+ this.uid = uid;
}
/**
* @hibernate.property column="title" length="255" not-null="true"
*/
public String getTitle() {
- return title;
+ return title;
}
public void setTitle(String title) {
- this.title = title;
+ this.title = title;
}
/**
@@ -80,22 +86,42 @@
*
*/
public Set getCognitiveSkills() {
- return cognitiveSkills;
+ return cognitiveSkills;
}
public void setCognitiveSkills(Set cognitiveSkills) {
- this.cognitiveSkills = cognitiveSkills;
+ this.cognitiveSkills = cognitiveSkills;
}
-
+
public int compareTo(QaWizardCategory category) {
- if (category.getUid()!=null && uid != null)
- {
+ if (category.getUid() != null && uid != null) {
return category.getUid().compareTo(uid) * -1;
- }
- else
- {
+ } else {
return 1;
}
}
+
+ public Object clone() {
+
+ QaWizardCategory category = null;
+ try {
+ category = (QaWizardCategory) super.clone();
+ category.setUid(null);
+ category.setTitle(getTitle());
+ Set skills = new TreeSet();
+
+ if (cognitiveSkills != null) {
+ // create a copy of the skills
+ for(QaWizardCognitiveSkill skill : cognitiveSkills)
+ {
+ QaWizardCognitiveSkill newSkill = (QaWizardCognitiveSkill)skill.clone();
+ skills.add(newSkill);
+ }
+ category.setCognitiveSkills(skills);
+ }
+ } catch (CloneNotSupportedException cnse) {
+ logger.error("Error cloning " + QaWizardCategory.class, cnse);
+ }
+ return category;
+ }
}
-
\ No newline at end of file
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaWizardCognitiveSkill.java
===================================================================
diff -u -r80a367726b9e7607851be28429bda54d9b306159 -ra82189db31f6fb6dd4a25a50a688b2812e93ddce
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaWizardCognitiveSkill.java (.../QaWizardCognitiveSkill.java) (revision 80a367726b9e7607851be28429bda54d9b306159)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaWizardCognitiveSkill.java (.../QaWizardCognitiveSkill.java) (revision a82189db31f6fb6dd4a25a50a688b2812e93ddce)
@@ -18,34 +18,39 @@
*
* http://www.gnu.org/licenses/gpl.txt
* ****************************************************************
- */
-
-/* $Id$ */
+ */
+
+/* $Id$ */
package org.lamsfoundation.lams.tool.qa;
import java.io.Serializable;
import java.util.Set;
import java.util.SortedSet;
+import java.util.TreeSet;
+import org.apache.log4j.Logger;
+
/**
- * This class maps to a single cognitive skill in the q&a wizard, it
- * contains a set of questions
+ * This class maps to a single cognitive skill in the q&a wizard, it contains a
+ * set of questions
*
* @hibernate.class table="tl_laqa11_wizard_cognitive_skill"
- */
-public class QaWizardCognitiveSkill implements Serializable, Comparable {
-
+ */
+public class QaWizardCognitiveSkill implements Serializable, Comparable, Cloneable {
+
public static final long serialVersionUID = 6732784345784895744L;
-
+ private static Logger logger = Logger.getLogger(QaWizardCognitiveSkill.class.getName());
+
private Long uid;
private String title;
private QaWizardCategory category;
private Set questions;
-
+
public QaWizardCognitiveSkill() {
}
- public QaWizardCognitiveSkill(Long uid, String title, QaWizardCategory category, SortedSet questions) {
+ public QaWizardCognitiveSkill(Long uid, String title, QaWizardCategory category,
+ SortedSet questions) {
super();
this.uid = uid;
this.title = title;
@@ -58,37 +63,37 @@
*
*/
public Long getUid() {
- return uid;
+ return uid;
}
public void setUid(Long uid) {
- this.uid = uid;
+ this.uid = uid;
}
/**
* @hibernate.property column="title" length="255" not-null="true"
*/
public String getTitle() {
- return title;
+ return title;
}
public void setTitle(String title) {
- this.title = title;
+ this.title = title;
}
/**
*
* @hibernate.many-to-one cascade="none"
- * class="org.lamsfoundation.lams.tool.qa.QaWizardCategory"
- * column="category_uid"
+ * class="org.lamsfoundation.lams.tool.qa.QaWizardCategory"
+ * column="category_uid"
*
*/
public QaWizardCategory getCategory() {
- return category;
+ return category;
}
public void setCategory(QaWizardCategory category) {
- this.category = category;
+ this.category = category;
}
/**
@@ -99,22 +104,43 @@
*
*/
public Set getQuestions() {
- return questions;
+ return questions;
}
public void setQuestions(Set questions) {
- this.questions = questions;
+ this.questions = questions;
}
-
+
public int compareTo(QaWizardCognitiveSkill skill) {
- if (skill.getUid()!=null && uid != null)
- {
+ if (skill.getUid() != null && uid != null) {
return skill.getUid().compareTo(uid) * -1;
- }
- else
- {
+ } else {
return 1;
}
}
+
+ public Object clone() {
+
+ QaWizardCognitiveSkill skill = null;
+ try {
+ skill = (QaWizardCognitiveSkill) super.clone();
+ skill.setUid(null);
+ skill.setCategory(null);
+ skill.setTitle(getTitle());
+ Set newQuestions = new TreeSet();
+
+ if (questions != null) {
+ // create a copy of the skills
+ for(QaWizardQuestion question : questions)
+ {
+ QaWizardQuestion newQuestion = (QaWizardQuestion)question.clone();
+ newQuestions.add(newQuestion);
+ }
+ skill.setQuestions(newQuestions);
+ }
+ } catch (CloneNotSupportedException cnse) {
+ logger.error("Error cloning " + QaWizardCognitiveSkill.class, cnse);
+ }
+ return skill;
+ }
}
-
\ No newline at end of file
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaWizardDTO.java
===================================================================
diff -u
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaWizardDTO.java (revision 0)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaWizardDTO.java (revision a82189db31f6fb6dd4a25a50a688b2812e93ddce)
@@ -0,0 +1,51 @@
+/****************************************************************
+ * Copyright (C) 2008 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.0
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+
+/* $Id$ */
+package org.lamsfoundation.lams.tool.qa;
+
+import java.io.Serializable;
+import java.util.SortedSet;
+
+public class QaWizardDTO implements Serializable{
+
+ public static final long serialVersionUID = 3481234912412784515L;
+
+ SortedSet qaWizardCategories;
+
+ public QaWizardDTO() {}
+
+ public QaWizardDTO(SortedSet categories)
+ {
+
+
+ }
+
+ public SortedSet getQaWizardCategories() {
+ return qaWizardCategories;
+ }
+
+ public void setQaWizardCategories(SortedSet qaWizardCategories) {
+ this.qaWizardCategories = qaWizardCategories;
+ }
+}
+
\ No newline at end of file
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaWizardQuestion.java
===================================================================
diff -u -r80a367726b9e7607851be28429bda54d9b306159 -ra82189db31f6fb6dd4a25a50a688b2812e93ddce
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaWizardQuestion.java (.../QaWizardQuestion.java) (revision 80a367726b9e7607851be28429bda54d9b306159)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/QaWizardQuestion.java (.../QaWizardQuestion.java) (revision a82189db31f6fb6dd4a25a50a688b2812e93ddce)
@@ -18,27 +18,32 @@
*
* http://www.gnu.org/licenses/gpl.txt
* ****************************************************************
- */
-
-/* $Id$ */
+ */
+
+/* $Id$ */
package org.lamsfoundation.lams.tool.qa;
import java.io.Serializable;
+import java.util.Set;
+import java.util.TreeSet;
+import org.apache.log4j.Logger;
+
/**
- * This class maps to a sample question in the q&a wizard, it has a parent
+ * This class maps to a sample question in the q&a wizard, it has a parent
* cognitive skill which in turn has a parent category
*
* @hibernate.class table="tl_laqa11_wizard_question"
- */
-public class QaWizardQuestion implements Serializable, Comparable{
+ */
+public class QaWizardQuestion implements Serializable, Comparable, Cloneable {
public static final long serialVersionUID = 4353787904539453783L;
-
+ private static Logger logger = Logger.getLogger(QaWizardQuestion.class.getName());
+
private Long uid;
private QaWizardCognitiveSkill cognitiveSkill;
private String question;
-
+
public QaWizardQuestion() {
}
@@ -54,49 +59,58 @@
*
*/
public Long getUid() {
- return uid;
+ return uid;
}
public void setUid(Long uid) {
- this.uid = uid;
+ this.uid = uid;
}
/**
*
* @hibernate.many-to-one cascade="none"
- * class="org.lamsfoundation.lams.tool.qa.QaWizardCognitiveSkill"
- * column="cognitive_skill_uid"
+ * class="org.lamsfoundation.lams.tool.qa.QaWizardCognitiveSkill"
+ * column="cognitive_skill_uid"
*
*/
public QaWizardCognitiveSkill getCognitiveSkill() {
- return cognitiveSkill;
+ return cognitiveSkill;
}
public void setCognitiveSkill(QaWizardCognitiveSkill cognitiveSkill) {
- this.cognitiveSkill = cognitiveSkill;
+ this.cognitiveSkill = cognitiveSkill;
}
/**
* @hibernate.property column="title" length="1027" not-null="true"
*/
public String getQuestion() {
- return question;
+ return question;
}
public void setQuestion(String question) {
- this.question = question;
+ this.question = question;
}
-
+
public int compareTo(QaWizardQuestion question) {
- if (question.getUid() != null && uid != null)
- {
+ if (question.getUid() != null && uid != null) {
return question.getUid().compareTo(uid) * -1;
- }
- else
- {
+ } else {
return 1;
}
}
+ public Object clone() {
+ QaWizardQuestion question = null;
+ try {
+ question = (QaWizardQuestion) super.clone();
+ question.setUid(null);
+ question.setCognitiveSkill(null);
+ question.setQuestion(getQuestion());
+ } catch (CloneNotSupportedException cnse) {
+ logger.error("Error cloning " + QaWizardQuestion.class, cnse);
+ }
+ return question;
+ }
+
}
-
\ No newline at end of file
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaWizardDAO.java
===================================================================
diff -u -r80a367726b9e7607851be28429bda54d9b306159 -ra82189db31f6fb6dd4a25a50a688b2812e93ddce
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaWizardDAO.java (.../IQaWizardDAO.java) (revision 80a367726b9e7607851be28429bda54d9b306159)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/IQaWizardDAO.java (.../IQaWizardDAO.java) (revision a82189db31f6fb6dd4a25a50a688b2812e93ddce)
@@ -35,5 +35,6 @@
void deleteWizardCategoryByUID(Long uid);
void deleteWizardSkillByUID(Long uid);
void deleteWizardQuestionByUID(Long uid);
+ void deleteAllWizardCategories();
}
\ No newline at end of file
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaWizardDAO.java
===================================================================
diff -u -r80a367726b9e7607851be28429bda54d9b306159 -ra82189db31f6fb6dd4a25a50a688b2812e93ddce
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaWizardDAO.java (.../QaWizardDAO.java) (revision 80a367726b9e7607851be28429bda54d9b306159)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/dao/hibernate/QaWizardDAO.java (.../QaWizardDAO.java) (revision a82189db31f6fb6dd4a25a50a688b2812e93ddce)
@@ -41,7 +41,7 @@
public class QaWizardDAO extends BaseDAO implements IQaWizardDAO {
private static final String QUERY_FIND_ALL_CATEGORIES = "from " + QaWizardCategory.class.getName();
-
+ private static final String QUERY_DELETE_ALL_CATEGORIES = "from " + QaWizardCategory.class.getName();
private static final String QUERY_GET_CATEGORY = "from " + QaWizardCategory.class.getName() + " c where c.uid=?";
private static final String QUERY_GET_SKILL = "from " + QaWizardCognitiveSkill.class.getName() + " c where c.uid=?";
private static final String QUERY_GET_QUESTION = "from " + QaWizardQuestion.class.getName() + " q where q.uid=?";
@@ -123,5 +123,10 @@
return null;
}
}
+
+ public void deleteAllWizardCategories()
+ {
+ this.getHibernateTemplate().deleteAll(getWizardCategories());
+ }
}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java
===================================================================
diff -u -r80a367726b9e7607851be28429bda54d9b306159 -ra82189db31f6fb6dd4a25a50a688b2812e93ddce
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java (.../IQaService.java) (revision 80a367726b9e7607851be28429bda54d9b306159)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/IQaService.java (.../IQaService.java) (revision a82189db31f6fb6dd4a25a50a688b2812e93ddce)
@@ -342,4 +342,9 @@
* @param uid
*/
public void deleteWizardQuestionByUID(Long uid);
+
+ /**
+ * Deletes all categories, sub skills and sub questions
+ */
+ public void deleteAllWizardCategories();
}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java
===================================================================
diff -u -r80a367726b9e7607851be28429bda54d9b306159 -ra82189db31f6fb6dd4a25a50a688b2812e93ddce
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java (.../QaServicePOJO.java) (revision 80a367726b9e7607851be28429bda54d9b306159)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/service/QaServicePOJO.java (.../QaServicePOJO.java) (revision a82189db31f6fb6dd4a25a50a688b2812e93ddce)
@@ -1947,4 +1947,12 @@
public void deleteWizardQuestionByUID(Long uid){
qaWizardDAO.deleteWizardQuestionByUID(uid);
}
+
+ /**
+ * Deletes all categories, sub skills and sub questions
+ */
+ public void deleteAllWizardCategories()
+ {
+ qaWizardDAO.deleteAllWizardCategories();
+ }
}
\ No newline at end of file
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAdminAction.java
===================================================================
diff -u -r80a367726b9e7607851be28429bda54d9b306159 -ra82189db31f6fb6dd4a25a50a688b2812e93ddce
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAdminAction.java (.../QaAdminAction.java) (revision 80a367726b9e7607851be28429bda54d9b306159)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAdminAction.java (.../QaAdminAction.java) (revision a82189db31f6fb6dd4a25a50a688b2812e93ddce)
@@ -23,8 +23,17 @@
/* $Id$ */
package org.lamsfoundation.lams.tool.qa.web;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
import java.io.StringReader;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
@@ -34,17 +43,20 @@
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import org.apache.commons.fileupload.DiskFileUpload;
+import org.apache.commons.fileupload.FileItem;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
+import org.lamsfoundation.lams.learningdesign.service.ExportToolContentException;
import org.lamsfoundation.lams.tool.qa.QaConfigItem;
import org.lamsfoundation.lams.tool.qa.QaWizardCategory;
import org.lamsfoundation.lams.tool.qa.QaWizardCognitiveSkill;
import org.lamsfoundation.lams.tool.qa.QaWizardQuestion;
import org.lamsfoundation.lams.tool.qa.service.IQaService;
import org.lamsfoundation.lams.tool.qa.service.QaServiceProxy;
-import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.util.FileUtil;
import org.lamsfoundation.lams.web.action.LamsDispatchAction;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -54,6 +66,8 @@
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+import com.thoughtworks.xstream.XStream;
+
/**
* Handles the admin page for question and answer which includes the settings
* and items for the q&a question wizard
@@ -73,6 +87,7 @@
public static final String ATTR_TITLE = "title";
public static final String ATTR_UID = "uid";
public static final String NULL = "null";
+ public static final String FILE_EXPORT = "qa-wizard.xml";
IQaService qaService;
@@ -81,7 +96,7 @@
*/
public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
- // set up mdlForumService
+ // set up qaService
if (qaService == null) {
qaService = QaServiceProxy.getQaService(this.getServlet().getServletContext());
}
@@ -100,6 +115,7 @@
/**
* Saves admin page, if the wizard is enabled, saves the wizard content
+ *
* @param mapping
* @param form
* @param request
@@ -114,12 +130,12 @@
if (qaService == null) {
qaService = QaServiceProxy.getQaService(this.getServlet().getServletContext());
}
-
+
QaConfigItem enableQaWizard = qaService.getConfigItem(QaConfigItem.KEY_ENABLE_QAWIZARD);
if (adminForm.getQaWizardEnabled() != null && adminForm.getQaWizardEnabled()) {
enableQaWizard.setConfigValue(QaAdminForm.TRUE);
-
+
// get the wizard content and save
if (adminForm.getSerialiseXML() != null && !adminForm.getSerialiseXML().trim().equals("")) {
updateWizardFromXML(adminForm.getSerialiseXML().trim());
@@ -128,20 +144,20 @@
// remove any wizard items that were removed
removeWizardItems(adminForm.getDeleteCategoriesCSV(), adminForm.getDeleteSkillsCSV(), adminForm
.getDeleteQuestionsCSV());
- }
- else {
+ } else {
enableQaWizard.setConfigValue(QaAdminForm.FALSE);
}
qaService.saveOrUpdateConfigItem(enableQaWizard);
request.setAttribute(ATTR_CATEGORIES, getQaWizardCategories());
request.setAttribute("savedSuccess", true);
return mapping.findForward("config");
-
+
}
/**
* Gets the complete set of wizard categories
+ *
* @return
*/
public SortedSet getQaWizardCategories() {
@@ -156,7 +172,7 @@
* @param questionsCSV
*/
public void removeWizardItems(String categoriesCSV, String skillsCSV, String questionsCSV) {
-
+
// remove categories
if (categoriesCSV != null && !categoriesCSV.equals("")) {
String categoryUIDs[] = categoriesCSV.split(",");
@@ -184,6 +200,7 @@
/**
* Saves all the wizard items from the xml serialisation sent from the form
+ *
* @param xmlStr
*/
@SuppressWarnings("unchecked")
@@ -268,4 +285,117 @@
qaService.saveOrUpdateQaWizardCategories(newCategories);
}
+
+ /**
+ * Exports the wizard categories list so it can be imported elsewhere The
+ * export format is the same xml format used by the export ld servlet
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ */
+ public ActionForward exportWizard(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ // set up mdlForumService
+ if (qaService == null) {
+ qaService = QaServiceProxy.getQaService(this.getServlet().getServletContext());
+ }
+
+ // now start the export
+ SortedSet exportCategories = new TreeSet();
+ for (QaWizardCategory category : getQaWizardCategories()) {
+ exportCategories.add((QaWizardCategory) category.clone());
+ }
+
+ // exporting XML
+ XStream designXml = new XStream();
+ String exportXml = designXml.toXML(exportCategories);
+
+ response.setContentType("application/x-download");
+ response.setHeader("Content-Disposition", "attachment;filename=" + FILE_EXPORT);
+ OutputStream out = null;
+ try {
+ out = response.getOutputStream();
+ out.write(exportXml.getBytes());
+ response.setContentLength(exportXml.getBytes().length);
+ out.flush();
+ } catch (Exception e) {
+ log.error("Exception occured writing out file:" + e.getMessage());
+ throw new ExportToolContentException(e);
+ } finally {
+ try {
+ if (out != null)
+ out.close();
+ } catch (Exception e) {
+ log.error("Error Closing file. File already written out - no exception being thrown.", e);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Imports the wizard model from an xml file and replaces the current model
+ * First, saves the configurations, then performs the import using xstream
+ *
+ * @param mapping
+ * @param form
+ * @param request
+ * @param response
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ public ActionForward importWizard(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response){
+ QaAdminForm adminForm = (QaAdminForm) form;
+
+ if (qaService == null) {
+ qaService = QaServiceProxy.getQaService(this.getServlet().getServletContext());
+ }
+
+ // First save the config items
+ QaConfigItem enableQaWizard = qaService.getConfigItem(QaConfigItem.KEY_ENABLE_QAWIZARD);
+
+ if (adminForm.getQaWizardEnabled() != null && adminForm.getQaWizardEnabled()) {
+ enableQaWizard.setConfigValue(QaAdminForm.TRUE);
+
+ // get the wizard content and save
+ if (adminForm.getSerialiseXML() != null && !adminForm.getSerialiseXML().trim().equals("")) {
+ updateWizardFromXML(adminForm.getSerialiseXML().trim());
+ }
+
+ // remove any wizard items that were removed
+ removeWizardItems(adminForm.getDeleteCategoriesCSV(), adminForm.getDeleteSkillsCSV(), adminForm
+ .getDeleteQuestionsCSV());
+ } else {
+ enableQaWizard.setConfigValue(QaAdminForm.FALSE);
+ }
+ qaService.saveOrUpdateConfigItem(enableQaWizard);
+
+
+ // Now perform the import
+ try {
+ String xml = new String(adminForm.getImportFile().getFileData());
+ XStream conversionXml = new XStream();
+ SortedSet exportCategories = (SortedSet)conversionXml.fromXML(xml);
+
+ qaService.deleteAllWizardCategories();
+ qaService.saveOrUpdateQaWizardCategories(exportCategories);
+ } catch (Exception e) {
+ logger.error("Failed to import wizard model", e);
+ request.setAttribute("error", true);
+ request.setAttribute("errorKey", "wizard.import.error");
+ request.setAttribute(ATTR_CATEGORIES, getQaWizardCategories());
+ return mapping.findForward("config");
+ }
+
+ request.setAttribute(ATTR_CATEGORIES, getQaWizardCategories());
+ request.setAttribute("savedSuccess", true);
+ return mapping.findForward("config");
+
+ }
+
}
Index: lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAdminForm.java
===================================================================
diff -u -r80a367726b9e7607851be28429bda54d9b306159 -ra82189db31f6fb6dd4a25a50a688b2812e93ddce
--- lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAdminForm.java (.../QaAdminForm.java) (revision 80a367726b9e7607851be28429bda54d9b306159)
+++ lams_tool_laqa/src/java/org/lamsfoundation/lams/tool/qa/web/QaAdminForm.java (.../QaAdminForm.java) (revision a82189db31f6fb6dd4a25a50a688b2812e93ddce)
@@ -24,6 +24,7 @@
package org.lamsfoundation.lams.tool.qa.web;
import org.apache.struts.action.ActionForm;
+import org.apache.struts.upload.FormFile;
public class QaAdminForm extends ActionForm {
@@ -37,6 +38,7 @@
private String deleteCategoriesCSV;
private String deleteSkillsCSV;
private String deleteQuestionsCSV;
+ private FormFile importFile;
public QaAdminForm() {}
@@ -83,6 +85,12 @@
public void setDeleteQuestionsCSV(String deleteQuestionsCSV) {
this.deleteQuestionsCSV = deleteQuestionsCSV;
}
-
-
+
+ public FormFile getImportFile() {
+ return importFile;
+ }
+
+ public void setImportFile(FormFile importFile) {
+ this.importFile = importFile;
+ }
}
Index: lams_tool_laqa/web/admin/config.jsp
===================================================================
diff -u -r80a367726b9e7607851be28429bda54d9b306159 -ra82189db31f6fb6dd4a25a50a688b2812e93ddce
--- lams_tool_laqa/web/admin/config.jsp (.../config.jsp) (revision 80a367726b9e7607851be28429bda54d9b306159)
+++ lams_tool_laqa/web/admin/config.jsp (.../config.jsp) (revision a82189db31f6fb6dd4a25a50a688b2812e93ddce)
@@ -1,5 +1,4 @@
-
+
<%@ include file="/common/taglibs.jsp"%>
@@ -128,6 +127,7 @@
categoryArray.splice(catMenu.selectedIndex-1, 1);
setUpTripleMenu();
+ disableExport();
}
}
}
@@ -152,6 +152,7 @@
categoryArray[catMenu.selectedIndex-1].skills.splice(skillMenu.selectedIndex-1, 1);
changeCategory();
+ disableExport();
}
}
}
@@ -176,6 +177,7 @@
categoryArray[catMenu.selectedIndex-1].skills[skillMenu.selectedIndex-1].questions.splice(qMenu.selectedIndex-1, 1);
changeSkill();
+ disableExport();
}
}
}
@@ -204,6 +206,8 @@
function openDialog(inputType, isAdd, titleStr)
{
+ disableExport();
+
$("#catDialog").dialog(
{
buttons:
@@ -227,7 +231,7 @@
title: titleStr
}
);
-
+ document.getElementById("inputText").focus();
}
function handleDialogInput(inputType, isAdd)
@@ -404,6 +408,33 @@
document.laqa11AdminForm.submit();
}
+
+ function customSubmit(dispatch)
+ {
+ document.getElementById("dispatch").value = dispatch;
+ document.laqa11AdminForm.submit();
+ }
+
+ function disableExport()
+ {
+ msg = ''
+ document.getElementById("exportButton").href = "javascript:alert('" + msg + "');";
+ }
+
+ function importFile()
+ {
+ if (document.getElementById("importFile").value.length == 0)
+ {
+ alert("");
+ }
+ else
+ {
+ if(confirm(''))
+ {
+ customSubmit("importWizard");
+ }
+ }
+ }
//-->
@@ -425,7 +456,7 @@
-
+
@@ -502,9 +533,17 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+