Index: lams_tool_scribe/conf/language/ApplicationResources.properties =================================================================== diff -u -r676776bec1c35957910e6911d9f7d280f646d28d -r74267305b37a60850dca2e40d5dcb975fe2efc32 --- lams_tool_scribe/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision 676776bec1c35957910e6911d9f7d280f646d28d) +++ lams_tool_scribe/conf/language/ApplicationResources.properties (.../ApplicationResources.properties) (revision 74267305b37a60850dca2e40d5dcb975fe2efc32) @@ -19,6 +19,8 @@ label.authoring.basic.title =Title: label.authoring.basic.content =Content: label.authoring.basic.instructions =Instructions: +label.authoring.basic.heading = Headings +label.authoring.basic.heading.add = Add Heading advanced.lockOnFinished =Lock when finished advanced.reflectOnActivity = Reflect on scribe advanced.selectScribe = Select Scribe @@ -36,6 +38,7 @@ link.view =View link.download =Download link.delete =Delete +link.edit = Edit message.updateSuccess =Changes saved message.unsavedChanges =Page contains unsaved changes pageTitle.learning =Online Scribe @@ -55,6 +58,7 @@ heading.totalLearnersInGroup =Total Number of Learners in Group: message.contentInUseSet =The modification of content is not allowed since one or more students has attempted the activity. message.summary =There is no summary available for this tool. +message.noHeadings =No Headings Available summary.openScribe =Open Scribe button.send =Send button.clear =Clear @@ -89,5 +93,4 @@ heading.numPosts = No. of posts heading.learner = Learner heading.reflection = Reflection - Index: lams_tool_scribe/db/sql/create_lams_tool_scribe.sql =================================================================== diff -u -r676776bec1c35957910e6911d9f7d280f646d28d -r74267305b37a60850dca2e40d5dcb975fe2efc32 --- lams_tool_scribe/db/sql/create_lams_tool_scribe.sql (.../create_lams_tool_scribe.sql) (revision 676776bec1c35957910e6911d9f7d280f646d28d) +++ lams_tool_scribe/db/sql/create_lams_tool_scribe.sql (.../create_lams_tool_scribe.sql) (revision 74267305b37a60850dca2e40d5dcb975fe2efc32) @@ -2,14 +2,17 @@ SET FOREIGN_KEY_CHECKS=0; drop table if exists tl_lascrb11_attachment; +drop table if exists tl_lascrb11_heading; drop table if exists tl_lascrb11_scribe; drop table if exists tl_lascrb11_session; drop table if exists tl_lascrb11_user; create table tl_lascrb11_attachment (uid bigint not null auto_increment, file_version_id bigint, file_type varchar(255), file_name varchar(255), file_uuid bigint, create_date datetime, scribe_uid bigint, primary key (uid)); +create table tl_lascrb11_heading (uid bigint not null auto_increment, heading text, report text, scribe_uid bigint, display_order integer, primary key (uid)); create table tl_lascrb11_scribe (uid bigint not null auto_increment, create_date datetime, update_date datetime, create_by bigint, title varchar(255), instructions text, run_offline bit, lock_on_finished bit, auto_select_scribe bit, reflect_on_activity bit, reflect_instructions text, online_instructions text, offline_instructions text, content_in_use bit, define_later bit, tool_content_id bigint, primary key (uid)); create table tl_lascrb11_session (uid bigint not null auto_increment, session_end_date datetime, session_start_date datetime, status integer, session_id bigint, session_name varchar(250), scribe_uid bigint, primary key (uid)); create table tl_lascrb11_user (uid bigint not null auto_increment, user_id bigint, last_name varchar(255), login_name varchar(255), first_name varchar(255), finishedActivity bit, scribe_session_uid bigint, primary key (uid)); alter table tl_lascrb11_attachment add index FK57953706B3FA1495 (scribe_uid), add constraint FK57953706B3FA1495 foreign key (scribe_uid) references tl_lascrb11_scribe (uid); +alter table tl_lascrb11_heading add index FK428A22FFB3FA1495 (scribe_uid), add constraint FK428A22FFB3FA1495 foreign key (scribe_uid) references tl_lascrb11_scribe (uid); alter table tl_lascrb11_session add index FK89732793B3FA1495 (scribe_uid), add constraint FK89732793B3FA1495 foreign key (scribe_uid) references tl_lascrb11_scribe (uid); alter table tl_lascrb11_user add index FK187DAFEE1C266FAE (scribe_session_uid), add constraint FK187DAFEE1C266FAE foreign key (scribe_session_uid) references tl_lascrb11_session (uid); Index: lams_tool_scribe/db/sql/table-schema.sql =================================================================== diff -u -r676776bec1c35957910e6911d9f7d280f646d28d -r74267305b37a60850dca2e40d5dcb975fe2efc32 --- lams_tool_scribe/db/sql/table-schema.sql (.../table-schema.sql) (revision 676776bec1c35957910e6911d9f7d280f646d28d) +++ lams_tool_scribe/db/sql/table-schema.sql (.../table-schema.sql) (revision 74267305b37a60850dca2e40d5dcb975fe2efc32) @@ -1,14 +1,18 @@ alter table tl_lascrb11_attachment drop foreign key FK57953706B3FA1495; +alter table tl_lascrb11_heading drop foreign key FK428A22FFB3FA1495; alter table tl_lascrb11_session drop foreign key FK89732793B3FA1495; alter table tl_lascrb11_user drop foreign key FK187DAFEE1C266FAE; drop table if exists tl_lascrb11_attachment; +drop table if exists tl_lascrb11_heading; drop table if exists tl_lascrb11_scribe; drop table if exists tl_lascrb11_session; drop table if exists tl_lascrb11_user; create table tl_lascrb11_attachment (uid bigint not null auto_increment, file_version_id bigint, file_type varchar(255), file_name varchar(255), file_uuid bigint, create_date datetime, scribe_uid bigint, primary key (uid)); +create table tl_lascrb11_heading (uid bigint not null auto_increment, heading text, report text, scribe_uid bigint, display_order integer, primary key (uid)); create table tl_lascrb11_scribe (uid bigint not null auto_increment, create_date datetime, update_date datetime, create_by bigint, title varchar(255), instructions text, run_offline bit, lock_on_finished bit, auto_select_scribe bit, reflect_on_activity bit, reflect_instructions text, online_instructions text, offline_instructions text, content_in_use bit, define_later bit, tool_content_id bigint, primary key (uid)); create table tl_lascrb11_session (uid bigint not null auto_increment, session_end_date datetime, session_start_date datetime, status integer, session_id bigint, session_name varchar(250), scribe_uid bigint, primary key (uid)); create table tl_lascrb11_user (uid bigint not null auto_increment, user_id bigint, last_name varchar(255), login_name varchar(255), first_name varchar(255), finishedActivity bit, scribe_session_uid bigint, primary key (uid)); alter table tl_lascrb11_attachment add index FK57953706B3FA1495 (scribe_uid), add constraint FK57953706B3FA1495 foreign key (scribe_uid) references tl_lascrb11_scribe (uid); +alter table tl_lascrb11_heading add index FK428A22FFB3FA1495 (scribe_uid), add constraint FK428A22FFB3FA1495 foreign key (scribe_uid) references tl_lascrb11_scribe (uid); alter table tl_lascrb11_session add index FK89732793B3FA1495 (scribe_uid), add constraint FK89732793B3FA1495 foreign key (scribe_uid) references tl_lascrb11_scribe (uid); alter table tl_lascrb11_user add index FK187DAFEE1C266FAE (scribe_session_uid), add constraint FK187DAFEE1C266FAE foreign key (scribe_session_uid) references tl_lascrb11_session (uid); Index: lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/dao/IScribeHeadingDAO.java =================================================================== diff -u --- lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/dao/IScribeHeadingDAO.java (revision 0) +++ lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/dao/IScribeHeadingDAO.java (revision 74267305b37a60850dca2e40d5dcb975fe2efc32) @@ -0,0 +1,36 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +/* $Id$ */ + +package org.lamsfoundation.lams.tool.scribe.dao; + +import org.lamsfoundation.lams.dao.IBaseDAO; +import org.lamsfoundation.lams.tool.scribe.model.ScribeHeading; + +/** + * DAO for accessing the ScribeHeading objects - interface defining + * methods to be implemented by the Hibernate or other implementation. + */ +public interface IScribeHeadingDAO extends IBaseDAO { + +} \ No newline at end of file Index: lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/dao/hibernate/ScribeHeadingDAO.java =================================================================== diff -u --- lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/dao/hibernate/ScribeHeadingDAO.java (revision 0) +++ lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/dao/hibernate/ScribeHeadingDAO.java (revision 74267305b37a60850dca2e40d5dcb975fe2efc32) @@ -0,0 +1,32 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +/* $Id$ */ + +package org.lamsfoundation.lams.tool.scribe.dao.hibernate; + +import org.lamsfoundation.lams.dao.hibernate.BaseDAO; +import org.lamsfoundation.lams.tool.scribe.dao.IScribeHeadingDAO; + +public class ScribeHeadingDAO extends BaseDAO implements IScribeHeadingDAO { + +} Index: lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/model/Scribe.java =================================================================== diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -r74267305b37a60850dca2e40d5dcb975fe2efc32 --- lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/model/Scribe.java (.../Scribe.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf) +++ lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/model/Scribe.java (.../Scribe.java) (revision 74267305b37a60850dca2e40d5dcb975fe2efc32) @@ -29,8 +29,6 @@ import java.util.Iterator; import java.util.Set; -import middlegen.Column; - import org.apache.log4j.Logger; import org.lamsfoundation.lams.contentrepository.ItemNotFoundException; import org.lamsfoundation.lams.contentrepository.NodeKey; @@ -91,7 +89,9 @@ private Set scribeSessions; + private Set scribeHeadings; + //*********** NON Persisit fields private IToolContentHandler toolContentHandler; @@ -355,7 +355,20 @@ public void setScribeSessions(Set scribeSessions) { this.scribeSessions = scribeSessions; } + + /** + * @hibernate.set lazy="true" inverse="true" cascade="all-delete-orphan" + * @hibernate.collection-key column="scribe_uid" + * @hibernate.collection-one-to-many class="org.lamsfoundation.lams.tool.scribe.model.ScribeHeading" + */ + public Set getScribeHeadings() { + return scribeHeadings; + } + public void setScribeHeadings(Set scribeHeadings) { + this.scribeHeadings = scribeHeadings; + } + /** * toString * @@ -433,9 +446,26 @@ } scribe.scribeAttachments = set; } + + if (scribeHeadings != null) { + // create copy of headings + Iterator iter = scribeHeadings.iterator(); + Set set = new HashSet(); + while (iter.hasNext()) { + ScribeHeading originalHeading = (ScribeHeading) iter.next(); + ScribeHeading newHeading = (ScribeHeading)originalHeading.clone(); + set.add(newHeading); + } + scribe.scribeHeadings = set; + + } + + // create an empty set for the scribeSession scribe.scribeSessions = new HashSet(); + + } catch (CloneNotSupportedException cnse) { log.error("Error cloning " + Scribe.class); } catch (ItemNotFoundException infe) { @@ -453,4 +483,4 @@ public void setToolContentHandler(IToolContentHandler toolContentHandler) { this.toolContentHandler = toolContentHandler; } -} +} \ No newline at end of file Index: lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/model/ScribeHeading.java =================================================================== diff -u --- lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/model/ScribeHeading.java (revision 0) +++ lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/model/ScribeHeading.java (revision 74267305b37a60850dca2e40d5dcb975fe2efc32) @@ -0,0 +1,147 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +/* $Id$ */ + +package org.lamsfoundation.lams.tool.scribe.model; + +import org.apache.log4j.Logger; + +/** + * @author Anthony Sukkar + * + * @hibernate.class table="tl_lascrb11_heading" + * + */ +public class ScribeHeading implements java.io.Serializable, Comparable{ + + private static final long serialVersionUID = -5643334348072895714L; + + private static final Logger log = Logger.getLogger(ScribeHeading.class); + + // Properties + private Long uid; + + private Scribe scribe; + + private String headingText; + + private String report; + + private int displayOrder; + + public ScribeHeading() { + } + + public ScribeHeading(int displayOrder) { + this.displayOrder = displayOrder; + } + + // Getters / Setters + + /** + * @hibernate.property column="heading" type="text" + */ + public String getHeadingText() { + return headingText; + } + + public void setHeadingText(String headingText) { + this.headingText = headingText; + } + + /** + * @hibernate.property column="report" type="text" + */ + public String getReport() { + return report; + } + + public void setReport(String report) { + this.report = report; + } + + /** + * + * @hibernate.many-to-one not-null="true" + * @hibernate.column name="scribe_uid" + */ + public Scribe getScribe() { + return scribe; + } + + public void setScribe(Scribe scribe) { + this.scribe = scribe; + } + + /** + * @hibernate.id generator-class="native" type="java.lang.Long" column="uid" + * + */ + public Long getUid() { + return uid; + } + + public void setUid(Long uid) { + this.uid = uid; + } + + /** + * + * @hibernate.property column="display_order" + */ + public int getDisplayOrder() { + return displayOrder; + } + + public void setDisplayOrder(int displayOrder) { + this.displayOrder = displayOrder; + } + + @Override + public Object clone() { + Object obj = null; + try { + obj = super.clone(); + ((ScribeHeading) obj).setUid(null); + } catch (CloneNotSupportedException e) { + log.error("Failed to clone " + ScribeHeading.class); + } + + return obj; + } + + public int compareTo(ScribeHeading o) { + int returnValue; + + returnValue = new Integer(this.displayOrder).compareTo(new Integer(o.displayOrder)); + + if (!this.equals(o) && returnValue == 0) { + // something is wrong. return -1 to maintain natural ordering. + log.debug("Encountered two different scribe headings with equal displayOrder"); + returnValue = -1; + } + + return returnValue; + } + +} Index: lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/scribeApplicationContext.xml =================================================================== diff -u -r676776bec1c35957910e6911d9f7d280f646d28d -r74267305b37a60850dca2e40d5dcb975fe2efc32 --- lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/scribeApplicationContext.xml (.../scribeApplicationContext.xml) (revision 676776bec1c35957910e6911d9f7d280f646d28d) +++ lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/scribeApplicationContext.xml (.../scribeApplicationContext.xml) (revision 74267305b37a60850dca2e40d5dcb975fe2efc32) @@ -19,6 +19,7 @@ org/lamsfoundation/lams/tool/scribe/model/ScribeSession.hbm.xml org/lamsfoundation/lams/tool/scribe/model/ScribeUser.hbm.xml org/lamsfoundation/lams/tool/scribe/model/ScribeAttachment.hbm.xml + org/lamsfoundation/lams/tool/scribe/model/ScribeHeading.hbm.xml Index: lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/IScribeService.java =================================================================== diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -r74267305b37a60850dca2e40d5dcb975fe2efc32 --- lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/IScribeService.java (.../IScribeService.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf) +++ lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/IScribeService.java (.../IScribeService.java) (revision 74267305b37a60850dca2e40d5dcb975fe2efc32) @@ -24,13 +24,11 @@ package org.lamsfoundation.lams.tool.scribe.service; -import java.util.List; -import java.util.Map; - import org.apache.struts.upload.FormFile; import org.lamsfoundation.lams.notebook.model.NotebookEntry; import org.lamsfoundation.lams.tool.scribe.model.Scribe; import org.lamsfoundation.lams.tool.scribe.model.ScribeAttachment; +import org.lamsfoundation.lams.tool.scribe.model.ScribeHeading; import org.lamsfoundation.lams.tool.scribe.model.ScribeSession; import org.lamsfoundation.lams.tool.scribe.model.ScribeUser; import org.lamsfoundation.lams.tool.scribe.util.ScribeException; @@ -151,4 +149,6 @@ public NotebookEntry getEntry(Long id, Integer idType, String signature, Integer userID); -} + +// public void saveOrUpdateScribeHeading(ScribeHeading heading); +} \ No newline at end of file Index: lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/ScribeService.java =================================================================== diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -r74267305b37a60850dca2e40d5dcb975fe2efc32 --- lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/ScribeService.java (.../ScribeService.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf) +++ lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/service/ScribeService.java (.../ScribeService.java) (revision 74267305b37a60850dca2e40d5dcb975fe2efc32) @@ -61,6 +61,7 @@ import org.lamsfoundation.lams.tool.exception.ToolException; import org.lamsfoundation.lams.tool.scribe.dao.IScribeAttachmentDAO; import org.lamsfoundation.lams.tool.scribe.dao.IScribeDAO; +import org.lamsfoundation.lams.tool.scribe.dao.IScribeHeadingDAO; import org.lamsfoundation.lams.tool.scribe.dao.IScribeSessionDAO; import org.lamsfoundation.lams.tool.scribe.dao.IScribeUserDAO; import org.lamsfoundation.lams.tool.scribe.model.Scribe; @@ -93,6 +94,8 @@ private IScribeUserDAO scribeUserDAO = null; private IScribeAttachmentDAO scribeAttachmentDAO = null; + + private IScribeHeadingDAO scribeHeadingDAO = null; private ILearnerService learnerService; @@ -397,6 +400,10 @@ scribeUserDAO.saveOrUpdate(scribeUser); } +// public void saveOrUpdateScribeHeading(ScribeHeading heading) { +// scribeHeadingDAO.saveOrUpdate(heading); +// } + public synchronized ScribeUser createScribeUser(UserDTO user, ScribeSession scribeSession) { ScribeUser scribeUser = new ScribeUser(user, scribeSession); @@ -608,6 +615,5 @@ scribe.setReflectOnActivity(Boolean.TRUE); scribe.setReflectInstructions(description); } - //========================================================================================= -} +} \ No newline at end of file Index: lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/web/actions/AuthoringAction.java =================================================================== diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -r74267305b37a60850dca2e40d5dcb975fe2efc32 --- lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/web/actions/AuthoringAction.java (.../AuthoringAction.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf) +++ lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/web/actions/AuthoringAction.java (.../AuthoringAction.java) (revision 74267305b37a60850dca2e40d5dcb975fe2efc32) @@ -24,11 +24,13 @@ package org.lamsfoundation.lams.tool.scribe.web.actions; +import java.util.Collections; import java.util.Date; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.ListIterator; import java.util.Set; import javax.servlet.http.HttpServletRequest; @@ -45,16 +47,16 @@ import org.lamsfoundation.lams.tool.ToolAccessMode; import org.lamsfoundation.lams.tool.scribe.model.Scribe; import org.lamsfoundation.lams.tool.scribe.model.ScribeAttachment; -import org.lamsfoundation.lams.tool.scribe.service.ScribeServiceProxy; +import org.lamsfoundation.lams.tool.scribe.model.ScribeHeading; import org.lamsfoundation.lams.tool.scribe.service.IScribeService; +import org.lamsfoundation.lams.tool.scribe.service.ScribeServiceProxy; import org.lamsfoundation.lams.tool.scribe.util.ScribeConstants; import org.lamsfoundation.lams.tool.scribe.web.forms.AuthoringForm; import org.lamsfoundation.lams.util.WebUtil; import org.lamsfoundation.lams.web.action.LamsDispatchAction; import org.lamsfoundation.lams.web.util.AttributeNames; import org.lamsfoundation.lams.web.util.SessionMap; - /** * @author * @version @@ -64,6 +66,10 @@ * * @struts.action-forward name="success" path="tiles:/authoring/main" * @struts.action-forward name="message_page" path="tiles:/generic/message" + * @struts.action-forward name="heading_form" + * path="tiles:/authoring/headingForm" + * @struts.action-forward name="heading_response" + * path="tiles:/authoring/headingResponse" */ public class AuthoringAction extends LamsDispatchAction { @@ -72,6 +78,10 @@ public IScribeService scribeService; // Authoring SessionMap key names + private static final String KEY_TOOL_CONTENT_ID = "toolContentID"; + + private static final String KEY_CONTENT_FOLDER_ID = "contentFolderID"; + private static final String KEY_MODE = "mode"; private static final String KEY_ONLINE_FILES = "onlineFiles"; @@ -84,6 +94,8 @@ private static final String KEY_DELETED_FILES = "deletedFiles"; + private static final String KEY_HEADINGS = "headings"; + /** * Default method when no dispatch parameter is specified. It is expected * that the parameter toolContentID will be passed in. This @@ -96,13 +108,14 @@ // Extract toolContentID from parameters. Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID)); - - String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID); + String contentFolderID = WebUtil.readStrParam(request, + AttributeNames.PARAM_CONTENT_FOLDER_ID); + // set up scribeService if (scribeService == null) { - scribeService = ScribeServiceProxy.getScribeService(this.getServlet() - .getServletContext()); + scribeService = ScribeServiceProxy.getScribeService(this + .getServlet().getServletContext()); } // retrieving Scribe with given toolContentID @@ -130,17 +143,16 @@ // Set up the authForm. AuthoringForm authForm = (AuthoringForm) form; updateAuthForm(authForm, scribe); - + // Set up sessionMap - SessionMap map = createSessionMap(scribe, getAccessMode(request)); + SessionMap map = createSessionMap(scribe, + getAccessMode(request), contentFolderID, toolContentID); authForm.setSessionMapID(map.getSessionID()); - - authForm.setContentFolderID(contentFolderID); // add the sessionMap to HTTPSession. request.getSession().setAttribute(map.getSessionID(), map); request.setAttribute(ScribeConstants.ATTR_SESSION_MAP, map); - + return mapping.findForward("success"); } @@ -153,7 +165,8 @@ SessionMap map = getSessionMap(request, authForm); // get scribe content. - Scribe scribe = scribeService.getScribeByContentId(authForm.getToolContentID()); + Scribe scribe = scribeService.getScribeByContentId((Long) map + .get(KEY_TOOL_CONTENT_ID)); // update scribe content using form inputs. updateScribe(scribe, authForm); @@ -170,14 +183,23 @@ .getFileVersionId()); attachments.remove(att); } - + // add unsaved attachments attachments.addAll(getAttList(KEY_UNSAVED_ONLINE_FILES, map)); attachments.addAll(getAttList(KEY_UNSAVED_OFFLINE_FILES, map)); - + // set attachments in case it didn't exist scribe.setScribeAttachments(attachments); + // update headings. + List updatedHeadings = getHeadingList(map); + Set currentHeadings = scribe.getScribeHeadings(); + currentHeadings.clear(); + for (ScribeHeading heading : updatedHeadings) { + heading.setUid(null); + currentHeadings.add(heading); + } + // set the update date scribe.setUpdateDate(new Date()); @@ -188,12 +210,12 @@ request.setAttribute(AuthoringConstants.LAMS_AUTHORING_SUCCESS_FLAG, Boolean.TRUE); - + // add the sessionMapID to form authForm.setSessionMapID(map.getSessionID()); request.setAttribute(ScribeConstants.ATTR_SESSION_MAP, map); - + return mapping.findForward("success"); } @@ -235,6 +257,114 @@ IToolContentHandler.TYPE_OFFLINE, request); } + public ActionForward loadHeadingForm(ActionMapping mapping, + ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + String sessionMapID = WebUtil.readStrParam(request, "sessionMapID"); + Integer headingIndex = WebUtil.readIntParam(request, "headingIndex", true); + + AuthoringForm authForm = ((AuthoringForm) form); + + if (headingIndex == null) { + headingIndex = -1; + } + + authForm.setHeadingIndex(headingIndex); + authForm.setSessionMapID(sessionMapID); + + return mapping.findForward("heading_form"); + } + + public ActionForward addOrUpdateHeading(ActionMapping mapping, + ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + AuthoringForm authForm = (AuthoringForm) form; + SessionMap map = getSessionMap(request, authForm); + + String headingText = authForm.getHeading(); + Integer headingIndex = authForm.getHeadingIndex(); + Long toolContentID = getToolContentID(map); + + Scribe scribe = scribeService.getScribeByContentId(toolContentID); + + if (headingIndex == -1) { + // create a new heading + List headings = getHeadingList(map); + + ScribeHeading scribeHeading = new ScribeHeading(headings.size()); + scribeHeading.setScribe(scribe); + scribeHeading.setHeadingText(headingText); + + headings.add(scribeHeading); + } else { + // update the existing heading + ScribeHeading heading = getHeadingList(map).get(headingIndex); + heading.setHeadingText(headingText); + } + + request.setAttribute("sessionMapID", map.getSessionID()); + return mapping.findForward("heading_response"); + } + + public ActionForward moveHeading(ActionMapping mapping, + ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + AuthoringForm authForm = (AuthoringForm) form; + SessionMap map = getSessionMap(request, authForm); + + int headingIndex = WebUtil.readIntParam(request, "headingIndex"); + String direction = WebUtil.readStrParam(request, "direction"); + + ListIterator iter = getHeadingList(map).listIterator(headingIndex); + + ScribeHeading heading = iter.next(); + iter.remove(); + + // move to correct location + if (direction.equals("up")) { + if (iter.hasPrevious()) + iter.previous(); + } else if (direction.equals("down")) { + if (iter.hasNext()) + iter.next(); + } else { + // invalid direction, don't move anywhere. + log.error("moveHeading: received invalid direction : " + direction); + } + + // adding heading back into list + iter.add(heading); + + // update the displayOrder + int i = 0; + for(ScribeHeading elem : getHeadingList(map)) { + elem.setDisplayOrder(i); + i++; + } + + request.setAttribute("sessionMapID", map.getSessionID()); + return mapping.findForward("heading_response"); + } + + public ActionForward deleteHeading(ActionMapping mapping, + ActionForm form, HttpServletRequest request, + HttpServletResponse response) { + + AuthoringForm authForm = (AuthoringForm) form; + SessionMap map = getSessionMap(request, authForm); + + Integer headingIndex = authForm.getHeadingIndex(); + + getHeadingList(map).remove(headingIndex.intValue()); + + request.setAttribute("sessionMapID", map.getSessionID()); + return mapping.findForward("heading_response"); + + } + /* ========== Private Methods ********** */ private ActionForward uploadFile(ActionMapping mapping, @@ -257,8 +387,8 @@ } // upload file to repository - ScribeAttachment newAtt = scribeService.uploadFileToContent(authForm - .getToolContentID(), file, type); + ScribeAttachment newAtt = scribeService.uploadFileToContent((Long) map + .get(KEY_TOOL_CONTENT_ID), file, type); // Add attachment to unsavedFiles // check to see if file with same name exists @@ -369,7 +499,6 @@ * @return */ private void updateAuthForm(AuthoringForm authForm, Scribe scribe) { - authForm.setToolContentID(scribe.getToolContentId()); authForm.setTitle(scribe.getTitle()); authForm.setInstructions(scribe.getInstructions()); authForm.setOnlineInstruction(scribe.getOnlineInstructions()); @@ -384,19 +513,24 @@ * Updates SessionMap using Scribe content. * * @param scribe - * @param mode + * @param mode */ - private SessionMap createSessionMap(Scribe scribe, ToolAccessMode mode) { - + private SessionMap createSessionMap(Scribe scribe, + ToolAccessMode mode, String contentFolderID, Long toolContentID) { + SessionMap map = new SessionMap(); - + map.put(KEY_MODE, mode); + map.put(KEY_CONTENT_FOLDER_ID, contentFolderID); + map.put(KEY_TOOL_CONTENT_ID, toolContentID); map.put(KEY_ONLINE_FILES, new LinkedList()); map.put(KEY_OFFLINE_FILES, new LinkedList()); map.put(KEY_UNSAVED_ONLINE_FILES, new LinkedList()); map.put(KEY_UNSAVED_OFFLINE_FILES, new LinkedList()); - map.put(KEY_DELETED_FILES, new LinkedList()); - + map.put(KEY_DELETED_FILES, new LinkedList()); + map.put(KEY_HEADINGS, new LinkedList()); + + // adding attachments Iterator iter = scribe.getScribeAttachments().iterator(); while (iter.hasNext()) { ScribeAttachment attachment = (ScribeAttachment) iter.next(); @@ -409,6 +543,16 @@ } } + // adding headings + iter = scribe.getScribeHeadings().iterator(); + while (iter.hasNext()) { + ScribeHeading element = (ScribeHeading) iter.next(); + getHeadingList(map).add(element); + } + + // sorting headings according to displayOrder. + Collections.sort(getHeadingList(map)); + return map; } @@ -431,43 +575,35 @@ } /** - * Set up SessionMap for first use. Creates empty lists and sets the access - * mode. - * - * @param map - * @param request - */ - private void initSessionMap(SessionMap map, HttpServletRequest request) { - map.put(KEY_MODE, getAccessMode(request)); - map.put(KEY_ONLINE_FILES, new LinkedList()); - map.put(KEY_OFFLINE_FILES, new LinkedList()); - map.put(KEY_UNSAVED_ONLINE_FILES, new LinkedList()); - map.put(KEY_UNSAVED_OFFLINE_FILES, new LinkedList()); - map.put(KEY_DELETED_FILES, new LinkedList()); - } - - /** * Retrieves a List of attachments from the map using the key. * * @param key * @param map * @return */ - private List getAttList(String key, SessionMap map) { - List list = (List) map.get(key); - return list; + private List getAttList(String key, + SessionMap map) { + return (List) map.get(key); } + private List getHeadingList(SessionMap map) { + return (List) map.get(KEY_HEADINGS); + } + /** * Retrieve the SessionMap from the HttpSession. * * @param request * @param authForm * @return */ - private SessionMap getSessionMap(HttpServletRequest request, - AuthoringForm authForm) { + private SessionMap getSessionMap( + HttpServletRequest request, AuthoringForm authForm) { return (SessionMap) request.getSession().getAttribute( authForm.getSessionMapID()); } -} + + private Long getToolContentID(SessionMap map) { + return (Long) map.get(KEY_TOOL_CONTENT_ID); + } +} \ No newline at end of file Index: lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/web/forms/AuthoringForm.java =================================================================== diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -r74267305b37a60850dca2e40d5dcb975fe2efc32 --- lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/web/forms/AuthoringForm.java (.../AuthoringForm.java) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf) +++ lams_tool_scribe/src/java/org/lamsfoundation/lams/tool/scribe/web/forms/AuthoringForm.java (.../AuthoringForm.java) (revision 74267305b37a60850dca2e40d5dcb975fe2efc32) @@ -33,7 +33,6 @@ import org.apache.struts.action.ActionMessage; import org.apache.struts.action.ActionMessages; import org.apache.struts.upload.FormFile; -import org.lamsfoundation.lams.web.util.SessionMap; /** * @struts.form name="authoringForm" @@ -51,11 +50,7 @@ String offlineInstruction; String onlineInstruction; - - Long toolContentID; - String contentFolderID; - boolean lockOnFinished; boolean reflectOnActivity; @@ -75,9 +70,12 @@ String sessionMapID; Long deleteFileUuid; - - SessionMap sessionMap; + // Properties for AddHeading.jsp page + + String heading; + Integer headingIndex; + @Override public ActionErrors validate(ActionMapping arg0, HttpServletRequest arg1) { ActionErrors ac = new ActionErrors(); @@ -166,23 +164,6 @@ this.title = title; } - public Long getToolContentID() { - return toolContentID; - } - - public void setToolContentID(Long toolContentID) { - this.toolContentID = toolContentID; - } - - public void setSessionMap(SessionMap sessionMap) { - this.sessionMap = sessionMap; - - } - - public SessionMap getSessionMap() { - return sessionMap; - } - public Long getDeleteFileUuid() { return deleteFileUuid; } @@ -207,19 +188,27 @@ this.reflectInstructions = reflectInstructions; } - public String getContentFolderID() { - return contentFolderID; - } - - public void setContentFolderID(String contentFolderID) { - this.contentFolderID = contentFolderID; - } - public boolean isAutoSelectScribe() { return autoSelectScribe; } public void setAutoSelectScribe(boolean autoSelectScribe) { this.autoSelectScribe = autoSelectScribe; } -} + + public String getHeading() { + return heading; + } + + public void setHeading(String heading) { + this.heading = heading; + } + + public Integer getHeadingIndex() { + return headingIndex; + } + + public void setHeadingIndex(Integer headingIndex) { + this.headingIndex = headingIndex; + } +} \ No newline at end of file Index: lams_tool_scribe/web/WEB-INF/struts/tiles-defs.xml =================================================================== diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -r74267305b37a60850dca2e40d5dcb975fe2efc32 --- lams_tool_scribe/web/WEB-INF/struts/tiles-defs.xml (.../tiles-defs.xml) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf) +++ lams_tool_scribe/web/WEB-INF/struts/tiles-defs.xml (.../tiles-defs.xml) (revision 74267305b37a60850dca2e40d5dcb975fe2efc32) @@ -36,6 +36,11 @@ + + + + + @@ -76,6 +81,17 @@ + + + + + + + + + + + @@ -136,4 +152,4 @@ - + \ No newline at end of file Index: lams_tool_scribe/web/WEB-INF/tags/AuthoringButton.tag =================================================================== diff -u -r08950e1090443c3423a3d1c587416a2fccd8bbdf -r74267305b37a60850dca2e40d5dcb975fe2efc32 --- lams_tool_scribe/web/WEB-INF/tags/AuthoringButton.tag (.../AuthoringButton.tag) (revision 08950e1090443c3423a3d1c587416a2fccd8bbdf) +++ lams_tool_scribe/web/WEB-INF/tags/AuthoringButton.tag (.../AuthoringButton.tag) (revision 74267305b37a60850dca2e40d5dcb975fe2efc32) @@ -82,7 +82,7 @@ } } -

+

Index: lams_tool_scribe/web/images/delete.gif =================================================================== diff -u Binary files differ Index: lams_tool_scribe/web/images/down.gif =================================================================== diff -u Binary files differ Index: lams_tool_scribe/web/images/up.gif =================================================================== diff -u Binary files differ Index: lams_tool_scribe/web/layouts/blankLayout.jsp =================================================================== diff -u --- lams_tool_scribe/web/layouts/blankLayout.jsp (revision 0) +++ lams_tool_scribe/web/layouts/blankLayout.jsp (revision 74267305b37a60850dca2e40d5dcb975fe2efc32) @@ -0,0 +1,11 @@ + + +<%@ include file="/common/taglibs.jsp"%> + + + + + + + \ No newline at end of file Index: lams_tool_scribe/web/layouts/defaultLayout.jsp =================================================================== diff -u -r676776bec1c35957910e6911d9f7d280f646d28d -r74267305b37a60850dca2e40d5dcb975fe2efc32 --- lams_tool_scribe/web/layouts/defaultLayout.jsp (.../defaultLayout.jsp) (revision 676776bec1c35957910e6911d9f7d280f646d28d) +++ lams_tool_scribe/web/layouts/defaultLayout.jsp (.../defaultLayout.jsp) (revision 74267305b37a60850dca2e40d5dcb975fe2efc32) @@ -5,7 +5,7 @@ - +

Index: lams_tool_scribe/web/layouts/learningLayout.jsp =================================================================== diff -u -r676776bec1c35957910e6911d9f7d280f646d28d -r74267305b37a60850dca2e40d5dcb975fe2efc32 --- lams_tool_scribe/web/layouts/learningLayout.jsp (.../learningLayout.jsp) (revision 676776bec1c35957910e6911d9f7d280f646d28d) +++ lams_tool_scribe/web/layouts/learningLayout.jsp (.../learningLayout.jsp) (revision 74267305b37a60850dca2e40d5dcb975fe2efc32) @@ -5,7 +5,7 @@ - +
Index: lams_tool_scribe/web/layouts/tabLayout.jsp =================================================================== diff -u -r676776bec1c35957910e6911d9f7d280f646d28d -r74267305b37a60850dca2e40d5dcb975fe2efc32 --- lams_tool_scribe/web/layouts/tabLayout.jsp (.../tabLayout.jsp) (revision 676776bec1c35957910e6911d9f7d280f646d28d) +++ lams_tool_scribe/web/layouts/tabLayout.jsp (.../tabLayout.jsp) (revision 74267305b37a60850dca2e40d5dcb975fe2efc32) @@ -5,7 +5,7 @@ - +
Index: lams_tool_scribe/web/pages/authoring/authoring.jsp =================================================================== diff -u -r77eb2c44ff2c1c9b5956d01bb7f931f27ca71a24 -r74267305b37a60850dca2e40d5dcb975fe2efc32 --- lams_tool_scribe/web/pages/authoring/authoring.jsp (.../authoring.jsp) (revision 77eb2c44ff2c1c9b5956d01bb7f931f27ca71a24) +++ lams_tool_scribe/web/pages/authoring/authoring.jsp (.../authoring.jsp) (revision 74267305b37a60850dca2e40d5dcb975fe2efc32) @@ -14,8 +14,6 @@
- - @@ -48,13 +46,13 @@ + contentFolderID="${sessionMap.contentFolderID}" />
- + \ No newline at end of file Index: lams_tool_scribe/web/pages/authoring/basic.jsp =================================================================== diff -u -r676776bec1c35957910e6911d9f7d280f646d28d -r74267305b37a60850dca2e40d5dcb975fe2efc32 --- lams_tool_scribe/web/pages/authoring/basic.jsp (.../basic.jsp) (revision 676776bec1c35957910e6911d9f7d280f646d28d) +++ lams_tool_scribe/web/pages/authoring/basic.jsp (.../basic.jsp) (revision 74267305b37a60850dca2e40d5dcb975fe2efc32) @@ -13,6 +13,8 @@ area.src=url; area.style.display="block"; } + + document.getElementById("authoringButton").style.visibility="hidden"; } function hideMessage(){ var area=document.getElementById("iframeArea"); @@ -21,14 +23,19 @@ area.style.height="0px"; area.style.display="none"; } + + document.getElementById("authoringButton").style.visibility="visible"; } - + + + @@ -45,16 +52,30 @@
- + + + + +
+
+ +
+
+ <%@ include file="parts/headingList.jsp"%> +
+
+ ');"> + +
Index: lams_tool_scribe/web/pages/authoring/headingForm.jsp =================================================================== diff -u --- lams_tool_scribe/web/pages/authoring/headingForm.jsp (revision 0) +++ lams_tool_scribe/web/pages/authoring/headingForm.jsp (revision 74267305b37a60850dca2e40d5dcb975fe2efc32) @@ -0,0 +1,31 @@ +<%@ include file="/common/taglibs.jsp"%> + + + + + + + + + + +

+ +

+ + + + + ${sessionMap.headings[formBean.headingIndex].headingText} + + + + + + + +
+ Index: lams_tool_scribe/web/pages/authoring/headingResponse.jsp =================================================================== diff -u --- lams_tool_scribe/web/pages/authoring/headingResponse.jsp (revision 0) +++ lams_tool_scribe/web/pages/authoring/headingResponse.jsp (revision 74267305b37a60850dca2e40d5dcb975fe2efc32) @@ -0,0 +1,19 @@ +<%@ include file="/common/taglibs.jsp"%> + +
+ +
+ <%@ include file="parts/headingList.jsp"%> +
+ + + +
+ + Index: lams_tool_scribe/web/pages/authoring/parts/headingList.jsp =================================================================== diff -u --- lams_tool_scribe/web/pages/authoring/parts/headingList.jsp (revision 0) +++ lams_tool_scribe/web/pages/authoring/parts/headingList.jsp (revision 74267305b37a60850dca2e40d5dcb975fe2efc32) @@ -0,0 +1,71 @@ +<%@ include file="/common/taglibs.jsp"%> + + + + + + + + + + + + + + + + + + + + + + +
+ + <%-- TODO should we ever reach this state ??--%> + +
+
+ ${heading.headingText} +
+
+ + + + + + " + onclick="showMessage('${moveUpURL}')"> + + + + + + + " + onclick="showMessage('${moveDownURL}')"> + + + + + + " + onclick="showMessage('${editURL}')"> + + + + + " + onclick="showMessage('${deleteURL}')"> + + +