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 SubmitFilesException
+ */
+ private ITicket getRepositoryLoginTicket() throws DotLRNForumException {
+ repositoryService = RepositoryProxy.getRepositoryService();
+ ICredentials credentials = new SimpleCredentials(
+ DotLRNForumToolContentHandler.repositoryUser,
+ DotLRNForumToolContentHandler.repositoryId);
+ try {
+ ITicket ticket = repositoryService.login(credentials,
+ DotLRNForumToolContentHandler.repositoryWorkspaceName);
+ return ticket;
+ } catch (AccessDeniedException ae) {
+ throw new DotLRNForumException("Access Denied to repository."
+ + ae.getMessage());
+ } catch (WorkspaceNotFoundException we) {
+ throw new DotLRNForumException("Workspace not found."
+ + we.getMessage());
+ } catch (LoginException e) {
+ throw new DotLRNForumException("Login failed." + e.getMessage());
+ }
+ }
+
+ /* ===============Methods implemented from ToolContentImport102Manager =============== */
+
+
+ /**
+ * Import the data for a 1.0.2 DotLRNForum
+ */
+ public void import102ToolContent(Long toolContentId, UserDTO user, Hashtable importValues)
+ {
+ Date now = new Date();
+ DotLRNForum dotLRNForum = new DotLRNForum();
+ dotLRNForum.setCreateDate(now);
+ dotLRNForum.setDefineLater(Boolean.FALSE);
+ dotLRNForum.setRunOffline(Boolean.FALSE);
+ dotLRNForum.setToolContentId(toolContentId);
+ dotLRNForum.setUpdateDate(now);
+
+ dotLRNForumDAO.saveOrUpdate(dotLRNForum);
+ }
+
+ /** 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 {
+
+ logger.warn("Setting the reflective field on a dotLRNForum. This doesn't make sense as the dotLRNForum is for reflection and we don't reflect on reflection!");
+ DotLRNForum dotLRNForum = getDotLRNForumByContentId(toolContentId);
+ if ( dotLRNForum == null ) {
+ throw new DataMissingException("Unable to set reflective data titled "+title
+ +" on activity toolContentId "+toolContentId
+ +" as the tool content does not exist.");
+ }
+
+ //dotLRNForum.setInstructions(description);
+ }
+
+ //=========================================================================================
+ /* ********** Used by Spring to "inject" the linked objects ************* */
+
+ public IDotLRNForumDAO getDotLRNForumDAO() {
+ return dotLRNForumDAO;
+ }
+
+ public void setDotLRNForumDAO(IDotLRNForumDAO dotLRNForumDAO) {
+ this.dotLRNForumDAO = dotLRNForumDAO;
+ }
+
+ public IDotLRNForumConfigItemDAO getDotLRNForumConfigItemDAO() {
+ return dotLRNForumConfigItemDAO;
+ }
+
+ public void setDotLRNForumConfigItemDAO(
+ IDotLRNForumConfigItemDAO dotLRNForumConfigItemDAO) {
+ this.dotLRNForumConfigItemDAO = dotLRNForumConfigItemDAO;
+ }
+
+ public IToolContentHandler getDotLRNForumToolContentHandler() {
+ return dotLRNForumToolContentHandler;
+ }
+
+ public void setDotLRNForumToolContentHandler(
+ IToolContentHandler dotLRNForumToolContentHandler) {
+ this.dotLRNForumToolContentHandler = dotLRNForumToolContentHandler;
+ }
+
+ public IDotLRNForumSessionDAO getDotLRNForumSessionDAO() {
+ return dotLRNForumSessionDAO;
+ }
+
+ public void setDotLRNForumSessionDAO(IDotLRNForumSessionDAO sessionDAO) {
+ this.dotLRNForumSessionDAO = sessionDAO;
+ }
+
+ public ILamsToolService getToolService() {
+ return toolService;
+ }
+
+ public void setToolService(ILamsToolService toolService) {
+ this.toolService = toolService;
+ }
+
+ public IDotLRNForumUserDAO getDotLRNForumUserDAO() {
+ return dotLRNForumUserDAO;
+ }
+
+ public void setDotLRNForumUserDAO(IDotLRNForumUserDAO userDAO) {
+ this.dotLRNForumUserDAO = userDAO;
+ }
+
+ public ILearnerService getLearnerService() {
+ return learnerService;
+ }
+
+ public void setLearnerService(ILearnerService learnerService) {
+ this.learnerService = learnerService;
+ }
+
+ public IExportToolContentService getExportContentService() {
+ return exportContentService;
+ }
+
+ public void setExportContentService(
+ IExportToolContentService exportContentService) {
+ this.exportContentService = exportContentService;
+ }
+
+ public ICoreNotebookService getCoreNotebookService() {
+ return coreNotebookService;
+ }
+
+ public void setCoreNotebookService(ICoreNotebookService coreNotebookService) {
+ this.coreNotebookService = coreNotebookService;
+ }
+
+ public DotLRNForumOutputFactory getDotLRNForumOutputFactory() {
+ if (dotLRNForumOutputFactory == null)
+ {
+ dotLRNForumOutputFactory = new DotLRNForumOutputFactory();
+ }
+ return dotLRNForumOutputFactory;
+ }
+
+ public void setDotLRNForumOutputFactory(
+ DotLRNForumOutputFactory dotLRNForumOutputFactory) {
+ this.dotLRNForumOutputFactory = dotLRNForumOutputFactory;
+ }
+
+ /**
+ * TODO: Use spring injection instead of hacking a context
+ * @return
+ */
+ public IIntegrationService getIntegrationService() {
+
+ if (integrationService==null)
+ {
+ String contexts[] = {"/org/lamsfoundation/lams/applicationContext.xml",
+ "/org/lamsfoundation/lams/lesson/lessonApplicationContext.xml",
+ "/org/lamsfoundation/lams/toolApplicationContext.xml",
+ "/org/lamsfoundation/lams/integrationContext.xml",
+ "/org/lamsfoundation/lams/learning/learningApplicationContext.xml",
+ "/org/lamsfoundation/lams/contentrepository/applicationContext.xml",
+ "/org/lamsfoundation/lams/tool/dlfrum/dotLRNForumApplicationContext.xml",
+ "/org/lamsfoundation/lams/commonContext.xml"};
+
+ ApplicationContext context = new ClassPathXmlApplicationContext(contexts);
+
+ if ( context == null )
+ throw new DotLRNForumException("Unable to access application context. Cannot create integration service object.");
+
+ IIntegrationService service =(IIntegrationService)context.getBean("integrationService");
+ return service;
+ }
+ else
+ {
+ return integrationService;
+ }
+ }
+
+ public void setIntegrationService(IIntegrationService integrationService) {
+ this.integrationService = integrationService;
+ }
+}
Index: tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/service/DotLRNForumServiceProxy.java
===================================================================
diff -u
--- tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/service/DotLRNForumServiceProxy.java (revision 0)
+++ tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/service/DotLRNForumServiceProxy.java (revision 8d072a352b5fc25f73957ce4c9230b644f2af15d)
@@ -0,0 +1,80 @@
+/****************************************************************
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+/* $$Id$$ */
+
+package org.lamsfoundation.lams.tool.dlfrum.service;
+
+import javax.servlet.ServletContext;
+
+import org.lamsfoundation.lams.integration.service.IIntegrationService;
+import org.lamsfoundation.lams.tool.ToolContentManager;
+import org.lamsfoundation.lams.tool.ToolSessionManager;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+
+/**
+ * This class act as the proxy between web layer and service layer. It is + * designed to decouple the presentation logic and business logic completely. + * In this way, the presentation tier will no longer be aware of the changes in + * service layer. Therefore we can feel free to switch the business logic + * implementation.
+ */ + +public class DotLRNForumServiceProxy { + + public static final IDotLRNForumService getDotLRNForumService(ServletContext servletContext) + { + return (IDotLRNForumService)getDotLRNForumDomainService(servletContext); + } + + private static Object getDotLRNForumDomainService(ServletContext servletContext) + { + WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); + return wac.getBean("dotLRNForumService"); + } + + /* + * Return the dotLRNForum tool version of tool session manager implementation. + * It will delegate to the Spring helper method to retrieve the proper + * bean from Spring bean factory. + * @param servletContext the servletContext for current application + * @return noticeboard service object.*/ + public static final ToolSessionManager getDotLRNForumSessionManager(ServletContext servletContext) + { + return (ToolSessionManager)getDotLRNForumDomainService(servletContext); + } + + + /* + * Return the dotLRNForum tool version of tool content manager implementation. + * It will delegate to the Spring helper method to retrieve the proper + * bean from Spring bean factory. + * @param servletContext the servletContext for current application + * @return noticeboard service object. */ + public static final ToolContentManager getDotLRNForumContentManager(ServletContext servletContext) + { + return (ToolContentManager)getDotLRNForumDomainService(servletContext); + } + +} Index: tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/service/IDotLRNForumService.java =================================================================== diff -u --- tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/service/IDotLRNForumService.java (revision 0) +++ tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/service/IDotLRNForumService.java (revision 8d072a352b5fc25f73957ce4c9230b644f2af15d) @@ -0,0 +1,223 @@ +/**************************************************************** + * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 + * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +/* $$Id$$ */ + +package org.lamsfoundation.lams.tool.dlfrum.service; + +import java.util.HashMap; + +import org.lamsfoundation.lams.integration.ExtServerOrgMap; +import org.lamsfoundation.lams.tool.dlfrum.model.DotLRNForum; +import org.lamsfoundation.lams.tool.dlfrum.model.DotLRNForumConfigItem; +import org.lamsfoundation.lams.tool.dlfrum.model.DotLRNForumSession; +import org.lamsfoundation.lams.tool.dlfrum.model.DotLRNForumUser; +import org.lamsfoundation.lams.tool.dlfrum.util.DotLRNForumException; +import org.lamsfoundation.lams.tool.service.ILamsToolService; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; + +/** + * Defines the services available to the web layer from the DotLRNForum Service + */ +public interface IDotLRNForumService { + + public static final String EXT_SERVER_METHOD_CLONE = "clone"; + public static final String EXT_SERVER_METHOD_IMPORT = "import"; + public static final String EXT_SERVER_METHOD_EXPORT = "export"; + public static final String EXT_SERVER_METHOD_OUTPUT = "output"; + public static final String EXT_SERVER_METHOD_EXPORT_PORTFOLIO = "export_portfolio"; + + + /** + * Makes a copy of the default content and assigns it a newContentID + * + * @params newContentID + * @return + */ + public DotLRNForum copyDefaultContent(Long newContentID); + + /** + * Returns an instance of the DotLRNForum tools default content. + * + * @return + */ + public DotLRNForum getDefaultContent(); + + /** + * @param toolSignature + * @return + */ + public Long getDefaultContentIdBySignature(String toolSignature); + + /** + * @param toolContentID + * @return + */ + public DotLRNForum getDotLRNForumByContentId(Long toolContentID); + + + /** + * @param uuid + * @param versionID + */ + public void deleteFromRepository(Long uuid, Long versionID) + throws DotLRNForumException; + + + /** + * @param dotLRNForum + */ + public void saveOrUpdateDotLRNForum(DotLRNForum dotLRNForum); + + /** + * @param toolSessionId + * @return + */ + public DotLRNForumSession getSessionBySessionId(Long toolSessionId); + + /** + * @param dotLRNForumSession + */ + public void saveOrUpdateDotLRNForumSession(DotLRNForumSession dotLRNForumSession); + + + /** + * Get the dotLRNForum config item by key + * @param key + * @return + */ + public DotLRNForumConfigItem getConfigItem(String key); + + /** + * Save a dotLRN configItem + * @param item + */ + public void saveOrUpdateDotLRNForumConfigItem(DotLRNForumConfigItem item); + + /** + * + * @param userId + * @param toolSessionId + * @return + */ + public DotLRNForumUser getUserByUserIdAndSessionId(Long userId, + Long toolSessionId); + + /** + * + * @param uid + * @return + */ + public DotLRNForumUser getUserByUID(Long uid); + + /** + * Gets the external organisation map for this tool adapter + * @return + */ + public ExtServerOrgMap getExtServerOrgMap(); + + /** + * Creates a hash for talking to the external server + * @param serverMap + * @param extUsername + * @param timestamp + * @return + */ + public String hash(ExtServerOrgMap serverMap, String extUsername, String timestamp); + + /** + * + * @param dotLRNForumUser + */ + public void saveOrUpdateDotLRNForumUser(DotLRNForumUser dotLRNForumUser); + + /** + * + * @param user + * @param dotLRNForumSession + * @return + */ + public DotLRNForumUser createDotLRNForumUser(UserDTO user,DotLRNForumSession dotLRNForumSession); + + + /** + * + * @return toolService + */ + ILamsToolService getToolService(); + + /** + * gets the tool output for the external server + * @param outputName + * @param extCourseId + * @param userId + * @param extToolContentId + * @param toolSessionId + * @return + */ + public int getExternalToolOutputInt(String outputName, String extCourseId, Long userId, String extToolContentId, Long toolSessionId); + + + /** + * Converts the customCSV parameter into a hashmap + * @param customCSV + * @return + */ + public HashMaptoolContentID
will be passed in. This
+ * will be used to retrieve content for this tool.
+ *
+ */
+ protected ActionForward unspecified(ActionMapping mapping, ActionForm form,
+ HttpServletRequest request, HttpServletResponse response) {
+
+ // Extract toolContentID, contentFolderID and ToolAccessMode from parameters.
+ Long toolContentID = new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_TOOL_CONTENT_ID));
+ String contentFolderID = WebUtil.readStrParam(request,AttributeNames.PARAM_CONTENT_FOLDER_ID);
+ ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, KEY_MODE,true);
+
+ // set up dotLRNForumService
+ if (dotLRNForumService == null) {
+ dotLRNForumService = DotLRNForumServiceProxy.getDotLRNForumService(this.getServlet().getServletContext());
+ }
+
+ // retrieving DotLRNForum with given toolContentID
+ // if is a new instance, customCSV should be passed, and used for the course url, otherwise the saved value should be used
+ DotLRNForum dotLRNForum = dotLRNForumService.getDotLRNForumByContentId(toolContentID);
+
+ // Getting the custom csv from the request
+ String customCSV = WebUtil.readStrParam(request, "customCSV", true);
+ String userFromCSV = null;
+ String courseFromCSV = null;
+ String courseUrlFromCSV = null;
+ if(customCSV==null && dotLRNForum==null)
+ {
+ logger.error("CustomCSV required if dotLRNForum is null");
+ throw new ToolException("CustomCSV required if dotLRNForum is null");
+ }
+ else if (customCSV!=null)
+ {
+ String splitCSV[] = customCSV.split(",");
+ if (splitCSV.length != 3)
+ {
+ logger.error("dotLRNForum tool customCSV not in required (user,course,courseURL) form: " + customCSV);
+ throw new ToolException("dotLRNForum tool cusomCSV not in required (user,course,courseURL) form: " + customCSV);
+ }
+ else
+ {
+ userFromCSV = splitCSV[0];
+ courseFromCSV = splitCSV[1];
+ courseUrlFromCSV = splitCSV[2];
+ }
+ }
+
+ if (dotLRNForum == null)
+ {
+ dotLRNForum = dotLRNForumService.copyDefaultContent(toolContentID);
+ dotLRNForum.setExtUsername(userFromCSV);
+ dotLRNForum.setExtUsername(courseFromCSV);
+ dotLRNForum.setExtCourseUrl(courseUrlFromCSV);
+ dotLRNForum.setCreateDate(new Date());
+ dotLRNForumService.saveOrUpdateDotLRNForum(dotLRNForum);
+ // TODO NOTE: this causes DB orphans when LD not saved.
+ }
+
+ if (mode != null && mode.isTeacher()) {
+ // Set the defineLater flag so that learners cannot use content
+ // while we
+ // are editing. This flag is released when updateContent is called.
+ dotLRNForum.setDefineLater(true);
+ dotLRNForumService.saveOrUpdateDotLRNForum(dotLRNForum);
+ }
+
+ // if no external content id, open the dotLRN author page, otherwise, open the edit page
+ try{
+
+ // If the dotLRNForum has a saved course url, use it, otherwise use the one giving in the request in customCSV
+ String courseUrlToBeUsed = (dotLRNForum.getExtCourseUrl() != null) ? dotLRNForum.getExtCourseUrl() : courseUrlFromCSV;
+ if (dotLRNForum.getExtToolContentId()==null)
+ {
+ String responseUrl = courseUrlToBeUsed + DOTLRN_AUTHOR_RELATIVE_URL +
+ "?" +AttributeNames.PARAM_TOOL_CONTENT_ID + "=" + toolContentID.toString()
+ + "&lamsUpdateURL=" + URLEncoder.encode(TOOL_APP_URL + "/authoring.do?dispatch=updateContent", "UTF8");
+
+ log.debug("Sending to dotLRN forum author page: " + responseUrl);
+ response.sendRedirect(responseUrl);
+ }
+ else
+ {
+ String responseUrl = courseUrlToBeUsed + DOTLRN_EDIT_RELATIVE_URL +
+ "?" +AttributeNames.PARAM_TOOL_CONTENT_ID + "=" + toolContentID.toString()
+ + "&forum_id=" + dotLRNForum.getExtToolContentId()
+ + "&lamsUpdateURL=" + URLEncoder.encode(TOOL_APP_URL + "/authoring.do?dispatch=updateContent", "UTF8");
+
+ log.debug("Sending to dotLRN forum edit page: " + responseUrl);
+ response.sendRedirect(responseUrl);
+
+ }
+ }
+ catch (Exception e)
+ {
+ log.error("Could not redirect to dotLRN forum authoring", e);
+ }
+ return null;
+ }
+
+ public ActionForward updateContent(ActionMapping mapping, ActionForm form,
+ HttpServletRequest request, HttpServletResponse response) {
+ // TODO need error checking.
+
+ Long toolContentID = new Long(WebUtil.readLongParam(request,KEY_TOOL_CONTENT_ID));
+ Long externalToolContentID = new Long(WebUtil.readLongParam(request,KEY_EXTERNAL_TOOL_CONTENT_ID));
+ //String sessionMapID = WebUtil.readStrParam(request,"sessionMapID");
+
+ // get dotLRNForum content.
+ DotLRNForum dotLRNForum = dotLRNForumService.getDotLRNForumByContentId(toolContentID);
+ dotLRNForum.setExtToolContentId(externalToolContentID);
+ dotLRNForum.setUpdateDate(new Date());
+ dotLRNForum.setDefineLater(false);
+ dotLRNForumService.saveOrUpdateDotLRNForum(dotLRNForum);
+
+ String redirectString = Configuration.get(ConfigurationKeys.SERVER_URL)
+ + "/tool/" + DotLRNForumConstants.TOOL_SIGNATURE + "/clearsession.do"
+ + "?action=confirm&mode=author"
+ + "&signature=" + DotLRNForumConstants.TOOL_SIGNATURE
+ + "&toolContentID=" + toolContentID.toString()
+ + "&defineLater=no"
+ + "&customiseSessionID="
+ + "&contentFolderID=0";
+
+ log.debug("Manual redirect for DotLRNForum to: " + redirectString);
+
+ try
+ {
+ response.sendRedirect(redirectString);
+ }
+ catch(Exception e)
+ {
+ log.error("Could not redirect to clear session action for DotLRNForum", e);
+ }
+
+ return null;
+ }
+}
Index: tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/actions/ClearSessionAction.java
===================================================================
diff -u
--- tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/actions/ClearSessionAction.java (revision 0)
+++ tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/actions/ClearSessionAction.java (revision 8d072a352b5fc25f73957ce4c9230b644f2af15d)
@@ -0,0 +1,51 @@
+/****************************************************************
+ * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.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.dlfrum.web.actions;
+
+import javax.servlet.http.HttpSession;
+
+import org.lamsfoundation.lams.authoring.web.LamsAuthoringFinishAction;
+import org.lamsfoundation.lams.tool.ToolAccessMode;
+
+/**
+ * This class give a chance to clear HttpSession when user save/close authoring page.
+ * @author Steve.Ni
+ * ----------------XDoclet Tags--------------------
+ *
+ * @struts:action path="/clearsession" validate="false"
+ *
+ * @version $Revision$
+ */
+public class ClearSessionAction extends LamsAuthoringFinishAction {
+
+ @Override
+ public void clearSession(String customiseSessionID,HttpSession session, ToolAccessMode mode) {
+ if(mode.isAuthor()){
+ session.removeAttribute(customiseSessionID);
+ }
+ }
+
+
+}
Index: tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/actions/LearningAction.java
===================================================================
diff -u
--- tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/actions/LearningAction.java (revision 0)
+++ tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/actions/LearningAction.java (revision 8d072a352b5fc25f73957ce4c9230b644f2af15d)
@@ -0,0 +1,213 @@
+/****************************************************************
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+/* $$Id$$ */
+
+package org.lamsfoundation.lams.tool.dlfrum.web.actions;
+
+import java.io.IOException;
+import java.net.URLEncoder;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+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.tool.ToolSessionManager;
+import org.lamsfoundation.lams.tool.dlfrum.dto.DotLRNForumDTO;
+import org.lamsfoundation.lams.tool.dlfrum.model.DotLRNForum;
+import org.lamsfoundation.lams.tool.dlfrum.model.DotLRNForumSession;
+import org.lamsfoundation.lams.tool.dlfrum.model.DotLRNForumUser;
+import org.lamsfoundation.lams.tool.dlfrum.service.DotLRNForumServiceProxy;
+import org.lamsfoundation.lams.tool.dlfrum.service.IDotLRNForumService;
+import org.lamsfoundation.lams.tool.dlfrum.util.DotLRNForumConstants;
+import org.lamsfoundation.lams.tool.dlfrum.util.DotLRNForumException;
+import org.lamsfoundation.lams.tool.exception.DataMissingException;
+import org.lamsfoundation.lams.tool.exception.ToolException;
+import org.lamsfoundation.lams.usermanagement.dto.UserDTO;
+import org.lamsfoundation.lams.util.Configuration;
+import org.lamsfoundation.lams.util.ConfigurationKeys;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.action.LamsDispatchAction;
+import org.lamsfoundation.lams.web.session.SessionManager;
+import org.lamsfoundation.lams.web.util.AttributeNames;
+
+/**
+ * @author
+ * @version
+ *
+ * @struts.action path="/learning" parameter="dispatch" scope="request" name="learningForm"
+ * @struts.action-forward name="dotLRNForum" path="tiles:/learning/main"
+ * @struts.action-forward name="runOffline" path="tiles:/learning/runOffline"
+ * @struts.action-forward name="defineLater" path="tiles:/learning/defineLater"
+ */
+public class LearningAction extends LamsDispatchAction {
+
+ private static Logger log = Logger.getLogger(LearningAction.class);
+
+ private static final boolean MODE_OPTIONAL = false;
+
+ private static final String TOOL_APP_URL = Configuration.get(ConfigurationKeys.SERVER_URL) + "/tool/" + DotLRNForumConstants.TOOL_SIGNATURE + "/";
+
+ private IDotLRNForumService dotLRNForumService;
+
+ public ActionForward unspecified(ActionMapping mapping, ActionForm form,
+ HttpServletRequest request, HttpServletResponse response)
+ throws Exception {
+
+ //LearningForm learningForm = (LearningForm) form;
+
+ // 'toolSessionID' and 'mode' paramters are expected to be present.
+ // TODO need to catch exceptions and handle errors.
+ //ToolAccessMode mode = WebUtil.readToolAccessModeParam(request,AttributeNames.PARAM_MODE, MODE_OPTIONAL);
+
+ Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID);
+
+ // set up dotLRNForumService
+ if (dotLRNForumService == null) {
+ dotLRNForumService = DotLRNForumServiceProxy.getDotLRNForumService(this.getServlet().getServletContext());
+ }
+
+ // Retrieve the session and content.
+ DotLRNForumSession dotLRNForumSession = dotLRNForumService.getSessionBySessionId(toolSessionID);
+ if (dotLRNForumSession == null) {
+ throw new DotLRNForumException("Cannot retreive session with toolSessionID: "+ toolSessionID);
+ }
+
+ DotLRNForum dotLRNForum = dotLRNForumSession.getDotLRNForum();
+
+ // check defineLater
+ if (dotLRNForum.isDefineLater()) {
+ return mapping.findForward("defineLater");
+ }
+
+ // set mode, toolSessionID and DotLRNForumDTO
+ //request.setAttribute("mode", mode.toString());
+ //learningForm.setToolSessionID(toolSessionID);
+
+ DotLRNForumDTO dotLRNForumDTO = new DotLRNForumDTO();
+
+
+ request.setAttribute("dotLRNForumDTO", dotLRNForumDTO);
+
+ // Set the content in use flag.
+ if (!dotLRNForum.isContentInUse()) {
+ dotLRNForum.setContentInUse(new Boolean(true));
+ dotLRNForumService.saveOrUpdateDotLRNForum(dotLRNForum);
+ }
+
+ // check runOffline
+ if (dotLRNForum.isRunOffline()) {
+ return mapping.findForward("runOffline");
+ }
+
+ if (dotLRNForum.getExtToolContentId()!=null)
+ {
+ try{
+ String returnUrl = TOOL_APP_URL + "learning.do?"
+ + AttributeNames.PARAM_TOOL_SESSION_ID + "=" + toolSessionID.toString()
+ + "&dispatch=finishActivity";
+ returnUrl = URLEncoder.encode(returnUrl, "UTF8");
+
+ String responseUrl = dotLRNForum.getExtCourseUrl() + "/forums/forum-view?"
+ + "forum_id=" + dotLRNForumSession.getExtSessionId()
+ + "&" + AttributeNames.PARAM_TOOL_SESSION_ID + "=" + toolSessionID.toString()
+ + "&returnUrl=" + returnUrl;
+
+ /*
+ String responseUrl = dotLRNForum.getExtCourseUrl() + "/forums/forum-view?"
+ + "forum_id=" + dotLRNForum.getExtToolContentId()
+ + "&" + AttributeNames.PARAM_TOOL_SESSION_ID + "=" + toolSessionID.toString()
+ + "&returnUrl=" + returnUrl;
+ */
+
+ log.debug("Redirecting for dotLRN forum learner: " + responseUrl);
+ response.sendRedirect(responseUrl);
+ }
+ catch (Exception e)
+ {
+ log.error("Could not redirect to dotLRN forum authoring", e);
+ }
+ }
+ else
+ {
+ throw new DotLRNForumException ("External content id null for learner");
+ }
+ return null;
+ }
+
+ private DotLRNForumUser getCurrentUser(Long toolSessionId) {
+ UserDTO user = (UserDTO) SessionManager.getSession().getAttribute(
+ AttributeNames.USER);
+
+ // attempt to retrieve user using userId and toolSessionId
+ DotLRNForumUser dotLRNForumUser = dotLRNForumService
+ .getUserByUserIdAndSessionId(new Long(user.getUserID()
+ .intValue()), toolSessionId);
+
+ if (dotLRNForumUser == null) {
+ DotLRNForumSession dotLRNForumSession = dotLRNForumService
+ .getSessionBySessionId(toolSessionId);
+ dotLRNForumUser = dotLRNForumService.createDotLRNForumUser(user,
+ dotLRNForumSession);
+ }
+
+ return dotLRNForumUser;
+ }
+
+ public ActionForward finishActivity(ActionMapping mapping, ActionForm form,
+ HttpServletRequest request, HttpServletResponse response) {
+
+ Long toolSessionID = WebUtil.readLongParam(request, "toolSessionID");
+
+ DotLRNForumUser dotLRNForumUser = getCurrentUser(toolSessionID);
+
+ if (dotLRNForumUser != null) {
+ dotLRNForumUser.setFinishedActivity(true);
+ dotLRNForumService.saveOrUpdateDotLRNForumUser(dotLRNForumUser);
+ } else {
+ log.error("finishActivity(): couldn't find DotLRNForumUser with id: "
+ + dotLRNForumUser.getUserId() + "and toolSessionID: "
+ + toolSessionID);
+ }
+
+ ToolSessionManager sessionMgrService = DotLRNForumServiceProxy
+ .getDotLRNForumSessionManager(getServlet().getServletContext());
+
+ String nextActivityUrl;
+ try {
+ nextActivityUrl = sessionMgrService.leaveToolSession(toolSessionID,
+ dotLRNForumUser.getUserId());
+ response.sendRedirect(nextActivityUrl);
+ } catch (DataMissingException e) {
+ throw new DotLRNForumException(e);
+ } catch (ToolException e) {
+ throw new DotLRNForumException(e);
+ } catch (IOException e) {
+ throw new DotLRNForumException(e);
+ }
+
+ return null; // TODO need to return proper page.
+ }
+}
Index: tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/actions/MonitoringAction.java
===================================================================
diff -u
--- tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/actions/MonitoringAction.java (revision 0)
+++ tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/actions/MonitoringAction.java (revision 8d072a352b5fc25f73957ce4c9230b644f2af15d)
@@ -0,0 +1,101 @@
+/****************************************************************
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+ * USA
+ *
+ * http://www.gnu.org/licenses/gpl.txt
+ * ****************************************************************
+ */
+/* $$Id$$ */
+
+package org.lamsfoundation.lams.tool.dlfrum.web.actions;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+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.notebook.model.NotebookEntry;
+import org.lamsfoundation.lams.tool.dlfrum.dto.DotLRNForumDTO;
+import org.lamsfoundation.lams.tool.dlfrum.dto.DotLRNForumUserDTO;
+import org.lamsfoundation.lams.tool.dlfrum.model.DotLRNForum;
+import org.lamsfoundation.lams.tool.dlfrum.model.DotLRNForumUser;
+import org.lamsfoundation.lams.tool.dlfrum.service.IDotLRNForumService;
+import org.lamsfoundation.lams.tool.dlfrum.service.DotLRNForumServiceProxy;
+import org.lamsfoundation.lams.tool.dlfrum.util.DotLRNForumConstants;
+import org.lamsfoundation.lams.util.Configuration;
+import org.lamsfoundation.lams.util.ConfigurationKeys;
+import org.lamsfoundation.lams.util.WebUtil;
+import org.lamsfoundation.lams.web.action.LamsDispatchAction;
+import org.lamsfoundation.lams.web.util.AttributeNames;
+
+/**
+ * @author
+ * @version
+ *
+ * @struts.action path="/monitoring" parameter="dispatch" scope="request" name="monitoringForm" validate="false"
+ *
+ * @struts.action-forward name="success" path="tiles:/monitoring/main"
+ *
+ */
+public class MonitoringAction extends LamsDispatchAction {
+
+ private static Logger log = Logger.getLogger(MonitoringAction.class);
+
+ private static final String TOOL_APP_URL = Configuration.get(ConfigurationKeys.SERVER_URL) + "/tool/" + DotLRNForumConstants.TOOL_SIGNATURE + "/";
+
+
+ public IDotLRNForumService dotLRNForumService;
+
+ public ActionForward unspecified(ActionMapping mapping, ActionForm form,
+ HttpServletRequest request, HttpServletResponse response) {
+
+ setupService();
+
+ Long toolContentID = new Long(WebUtil.readLongParam(request,AttributeNames.PARAM_TOOL_CONTENT_ID));
+
+ String contentFolderID = WebUtil.readStrParam(request,AttributeNames.PARAM_CONTENT_FOLDER_ID);
+
+ DotLRNForum dotLRNForum = dotLRNForumService.getDotLRNForumByContentId(toolContentID);
+
+
+ if (dotLRNForum == null) {
+ // TODO error page.
+ }
+
+ DotLRNForumDTO dotLRNForumDT0 = new DotLRNForumDTO(dotLRNForum);
+
+ Long currentTab = WebUtil.readLongParam(request, AttributeNames.PARAM_CURRENT_TAB,true);
+ dotLRNForumDT0.setCurrentTab(currentTab);
+
+ request.setAttribute("dotLRNForumDTO", dotLRNForumDT0);
+ request.setAttribute("contentFolderID", contentFolderID);
+ return mapping.findForward("success");
+ }
+
+ /**
+ * set up dotLRNForumService
+ */
+ private void setupService() {
+ if (dotLRNForumService == null) {
+ dotLRNForumService = DotLRNForumServiceProxy.getDotLRNForumService(this
+ .getServlet().getServletContext());
+ }
+ }
+}
Index: tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/forms/AdminForm.java
===================================================================
diff -u
--- tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/forms/AdminForm.java (revision 0)
+++ tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/forms/AdminForm.java (revision 8d072a352b5fc25f73957ce4c9230b644f2af15d)
@@ -0,0 +1,43 @@
+package org.lamsfoundation.lams.tool.dlfrum.web.forms;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.struts.action.ActionErrors;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionMessage;
+import org.apache.struts.action.ActionMessages;
+
+/**
+ * @struts.form name="dlfrum10AdminForm"
+ */
+public class AdminForm extends ActionForm
+{
+ private static final long serialVersionUID = 8872637862875198L;
+
+ String toolAdapterServlet;
+ String serverIdMapping;
+
+ @Override
+ public ActionErrors validate(ActionMapping arg0, HttpServletRequest arg1) {
+ ActionErrors ac = new ActionErrors();
+ ac.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("this is an error"));
+ return ac;
+ }
+
+ public String getToolAdapterServlet() {
+ return toolAdapterServlet;
+ }
+
+ public void setToolAdapterServlet(String toolAdapterServlet) {
+ this.toolAdapterServlet = toolAdapterServlet;
+ }
+
+ public String getServerIdMapping() {
+ return serverIdMapping;
+ }
+
+ public void setServerIdMapping(String serverIdMapping) {
+ this.serverIdMapping = serverIdMapping;
+ }
+}
Index: tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/forms/AuthoringForm.java
===================================================================
diff -u
--- tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/forms/AuthoringForm.java (revision 0)
+++ tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/forms/AuthoringForm.java (revision 8d072a352b5fc25f73957ce4c9230b644f2af15d)
@@ -0,0 +1,218 @@
+/****************************************************************
+ * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.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.dlfrum.web.forms;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.struts.action.ActionErrors;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionMapping;
+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"
+ */
+public class AuthoringForm extends ActionForm {
+
+ private static final long serialVersionUID = 3950453134542135495L;
+
+ // Properties
+
+ String title;
+
+ String instructions;
+
+ String offlineInstruction;
+
+ String onlineInstruction;
+
+ boolean lockOnFinished;
+
+ boolean allowRichEditor;
+
+ boolean evalcomixEvaluationByLearners;
+
+ boolean evalcomixEvaluationByTeachers;
+
+ String evalcomixInstrumentFormAndViewUrl;
+
+ FormFile onlineFile;
+
+ FormFile offlineFile;
+
+ String currentTab;
+
+ String dispatch;
+
+ String sessionMapID;
+
+ Long deleteFileUuid;
+
+ SessionMap sessionMap;
+
+ @Override
+ public ActionErrors validate(ActionMapping arg0, HttpServletRequest arg1) {
+ ActionErrors ac = new ActionErrors();
+ ac.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("this is an error"));
+
+ return ac;
+ }
+
+ public String getSessionMapID() {
+ return sessionMapID;
+ }
+
+ public void setSessionMapID(String sessionMapID) {
+ this.sessionMapID = sessionMapID;
+ }
+
+ public String getCurrentTab() {
+ return currentTab;
+ }
+
+ public void setCurrentTab(String currentTab) {
+ this.currentTab = currentTab;
+ }
+
+ public String getDispatch() {
+ return dispatch;
+ }
+
+ public void setDispatch(String dispatch) {
+ this.dispatch = dispatch;
+ }
+
+ public String getInstructions() {
+ return instructions;
+ }
+
+ public void setInstructions(String instructions) {
+ this.instructions = instructions;
+ }
+
+ public boolean isLockOnFinished() {
+ return lockOnFinished;
+ }
+
+ public void setLockOnFinished(boolean lockOnFinished) {
+ this.lockOnFinished = lockOnFinished;
+ }
+
+ public FormFile getOfflineFile() {
+ return offlineFile;
+ }
+
+ public void setOfflineFile(FormFile offlineFile) {
+ this.offlineFile = offlineFile;
+ }
+
+ public String getOfflineInstruction() {
+ return offlineInstruction;
+ }
+
+ public void setOfflineInstruction(String offlineInstruction) {
+ this.offlineInstruction = offlineInstruction;
+ }
+
+ public FormFile getOnlineFile() {
+ return onlineFile;
+ }
+
+ public void setOnlineFile(FormFile onlineFile) {
+ this.onlineFile = onlineFile;
+ }
+
+ public String getOnlineInstruction() {
+ return onlineInstruction;
+ }
+
+ public void setOnlineInstruction(String onlineInstruction) {
+ this.onlineInstruction = onlineInstruction;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public void setSessionMap(SessionMap sessionMap) {
+ this.sessionMap = sessionMap;
+ }
+
+ public SessionMap getSessionMap() {
+ return sessionMap;
+ }
+
+ public Long getDeleteFileUuid() {
+ return deleteFileUuid;
+ }
+
+ public void setDeleteFileUuid(Long deleteFile) {
+ this.deleteFileUuid = deleteFile;
+ }
+
+ public boolean isAllowRichEditor() {
+ return allowRichEditor;
+ }
+
+ public void setAllowRichEditor(boolean allowRichEditor) {
+ this.allowRichEditor = allowRichEditor;
+ }
+
+ public String getEvalcomixInstrumentFormAndViewUrl() {
+ return evalcomixInstrumentFormAndViewUrl;
+ }
+
+ public void setEvalcomixInstrumentFormAndViewUrl(
+ String evalcomixInstrumentFormAndViewUrl) {
+ this.evalcomixInstrumentFormAndViewUrl = evalcomixInstrumentFormAndViewUrl;
+ }
+
+ public boolean isEvalcomixEvaluationByLearners() {
+ return evalcomixEvaluationByLearners;
+ }
+
+ public void setEvalcomixEvaluationByLearners(
+ boolean evalcomixEvaluationByLearners) {
+ this.evalcomixEvaluationByLearners = evalcomixEvaluationByLearners;
+ }
+
+ public boolean isEvalcomixEvaluationByTeachers() {
+ return evalcomixEvaluationByTeachers;
+ }
+
+ public void setEvalcomixEvaluationByTeachers(
+ boolean evalcomixEvaluationByTeachers) {
+ this.evalcomixEvaluationByTeachers = evalcomixEvaluationByTeachers;
+ }
+
+}
Index: tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/forms/LearningForm.java
===================================================================
diff -u
--- tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/forms/LearningForm.java (revision 0)
+++ tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/forms/LearningForm.java (revision 8d072a352b5fc25f73957ce4c9230b644f2af15d)
@@ -0,0 +1,96 @@
+/****************************************************************
+ * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.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.dlfrum.web.forms;
+
+import org.apache.struts.action.ActionForm;
+
+/**
+ *
+ * @author Anthony Sukkar
+ *
+ * @struts.form name="learningForm"
+ */
+public class LearningForm extends ActionForm {
+
+ private static final long serialVersionUID = -4728946254882237144L;
+
+ String title;
+ String instructions;
+
+ String dispatch;
+ Long toolSessionID;
+ String mode;
+
+ String entryText;
+
+ public String getMode() {
+ return mode;
+ }
+
+ public void setMode(String mode) {
+ this.mode = mode;
+ }
+
+ public String getDispatch() {
+ return dispatch;
+ }
+
+ public void setDispatch(String dispatch) {
+ this.dispatch = dispatch;
+ }
+
+ public Long getToolSessionID() {
+ return toolSessionID;
+ }
+
+ public void setToolSessionID(Long toolSessionID) {
+ this.toolSessionID = toolSessionID;
+ }
+
+ public String getInstructions() {
+ return instructions;
+ }
+
+ public void setInstructions(String instructions) {
+ this.instructions = instructions;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getEntryText() {
+ return entryText;
+ }
+
+ public void setEntryText(String entryText) {
+ this.entryText = entryText;
+ }
+}
Index: tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/forms/MonitoringForm.java
===================================================================
diff -u
--- tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/forms/MonitoringForm.java (revision 0)
+++ tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/forms/MonitoringForm.java (revision 8d072a352b5fc25f73957ce4c9230b644f2af15d)
@@ -0,0 +1,83 @@
+/****************************************************************
+ * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.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.dlfrum.web.forms;
+
+import org.apache.struts.action.ActionForm;
+
+/**
+ * @struts.form name="monitoringForm"
+ */
+public class MonitoringForm extends ActionForm {
+
+ private static final long serialVersionUID = 9096908688391850595L;
+
+ String dispatch;
+ boolean teacherVisible;
+ Long toolSessionID;
+
+ // editing message page.
+ Long messageUID;
+ String messageBody;
+ boolean messageHidden;
+
+ public String getMessageBody() {
+ return messageBody;
+ }
+ public void setMessageBody(String messageBody) {
+ this.messageBody = messageBody;
+ }
+ public Long getMessageUID() {
+ return messageUID;
+ }
+ public void setMessageUID(Long messageUID) {
+ this.messageUID = messageUID;
+ }
+ public String getDispatch() {
+ return dispatch;
+ }
+ public void setDispatch(String dispatch) {
+ this.dispatch = dispatch;
+ }
+ public Long getToolSessionID() {
+ return toolSessionID;
+ }
+ public void setToolSessionID(Long toolSessionID) {
+ this.toolSessionID = toolSessionID;
+ }
+ public boolean isTeacherVisible() {
+ return teacherVisible;
+ }
+ public void setTeacherVisible(boolean visible) {
+ this.teacherVisible = visible;
+ }
+ public boolean isMessageHidden() {
+ return messageHidden;
+ }
+ public void setMessageHidden(boolean messageHidden) {
+ this.messageHidden = messageHidden;
+ }
+
+}
Index: tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/servlets/ExportServlet.java
===================================================================
diff -u
--- tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/servlets/ExportServlet.java (revision 0)
+++ tool_adapters/dotlrn/lams_tool_dlforum/src/java/org/lamsfoundation/lams/tool/dlfrum/web/servlets/ExportServlet.java (revision 8d072a352b5fc25f73957ce4c9230b644f2af15d)
@@ -0,0 +1,206 @@
+/****************************************************************
+ * Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org)
+ * =============================================================
+ * License Information: http://lamsfoundation.org/licensing/lams/2.0/
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2.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.dlfrum.web.servlets;
+
+import java.io.BufferedOutputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Set;
+
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.lamsfoundation.lams.tool.ToolAccessMode;
+import org.lamsfoundation.lams.tool.dlfrum.dto.DotLRNForumDTO;
+import org.lamsfoundation.lams.tool.dlfrum.model.DotLRNForum;
+import org.lamsfoundation.lams.tool.dlfrum.model.DotLRNForumConfigItem;
+import org.lamsfoundation.lams.tool.dlfrum.model.DotLRNForumSession;
+import org.lamsfoundation.lams.tool.dlfrum.service.DotLRNForumServiceProxy;
+import org.lamsfoundation.lams.tool.dlfrum.service.IDotLRNForumService;
+import org.lamsfoundation.lams.tool.dlfrum.util.DotLRNForumException;
+import org.lamsfoundation.lams.tool.dlfrum.util.WebUtility;
+import org.lamsfoundation.lams.web.servlet.AbstractExportPortfolioServlet;
+import org.lamsfoundation.lams.web.util.AttributeNames;
+
+public class ExportServlet extends AbstractExportPortfolioServlet {
+
+ private static final long serialVersionUID = -2829707715037631881L;
+
+ private static Logger logger = Logger.getLogger(ExportServlet.class);
+
+ private final String FILENAME = "dotLRNForum_main.html";
+
+ private IDotLRNForumService dotLRNForumService;
+
+ protected String doExport(HttpServletRequest request,
+ HttpServletResponse response, String directoryName, Cookie[] cookies) {
+
+ if (dotLRNForumService == null) {
+ dotLRNForumService = DotLRNForumServiceProxy.getDotLRNForumService(getServletContext());
+ }
+
+ try {
+ if (StringUtils.equals(mode, ToolAccessMode.LEARNER.toString())) {
+ request.getSession().setAttribute(AttributeNames.ATTR_MODE,
+ ToolAccessMode.LEARNER);
+ doLearnerExport(request, response, directoryName, cookies);
+ } else if (StringUtils.equals(mode, ToolAccessMode.TEACHER
+ .toString())) {
+ request.getSession().setAttribute(AttributeNames.ATTR_MODE,
+ ToolAccessMode.TEACHER);
+ doTeacherExport(request, response, directoryName, cookies);
+ String basePath = request.getScheme() + "://" + request.getServerName()
+ + ":" + request.getServerPort() + request.getContextPath();
+ writeResponseToFile(basePath + "/pages/export/exportPortfolio.jsp",
+ directoryName, FILENAME, cookies);
+
+
+ }
+ } catch (DotLRNForumException e) {
+ logger.error("Cannot perform export for dotLRNForum tool.");
+ }
+ return FILENAME;
+ }
+
+ protected String doOfflineExport(HttpServletRequest request, HttpServletResponse response, String directoryName, Cookie[] cookies) {
+ if (toolContentID == null && toolSessionID == null) {
+ logger.error("Tool content Id or and session Id are null. Unable to activity title");
+ } else {
+ if (dotLRNForumService == null) {
+ dotLRNForumService = DotLRNForumServiceProxy.getDotLRNForumService(getServletContext());
+ }
+
+ DotLRNForum content = null;
+ if ( toolContentID != null ) {
+ content = dotLRNForumService.getDotLRNForumByContentId(toolContentID);
+ } else {
+ DotLRNForumSession session=dotLRNForumService.getSessionBySessionId(toolSessionID);
+ if ( session != null )
+ content = session.getDotLRNForum();
+ }
+ if ( content != null ) {
+ //activityTitle = content.getTitle();
+ }
+ }
+ return super.doOfflineExport(request, response, directoryName, cookies);
+ }
+
+ private void doLearnerExport(HttpServletRequest request,
+ HttpServletResponse response, String directoryName, Cookie[] cookies)
+ throws DotLRNForumException {
+
+ logger.debug("doExportLearner: toolContentID:" + toolSessionID);
+
+ // check if toolSessionID available
+ if (toolSessionID == null) {
+ String error = "Tool Session ID is missing. Unable to continue";
+ logger.error(error);
+ throw new DotLRNForumException(error);
+ }
+
+ DotLRNForumSession dotLRNForumSession = dotLRNForumService.getSessionBySessionId(toolSessionID);
+
+ DotLRNForum dotLRNForum = dotLRNForumSession.getDotLRNForum();
+
+ try{
+ exportFileFromExternalServer(request, response,
+ dotLRNForumSession.getExtSessionId(), dotLRNForum.getExtCourseId(),
+ directoryName + "/" + FILENAME);
+ }
+ catch (Exception e)
+ {
+ logger.error("Could not fetch export file from external servlet", e);
+ throw new DotLRNForumException("Could not fetch export file from external servlet", e);
+ }
+ }
+
+ private void doTeacherExport(HttpServletRequest request,
+ HttpServletResponse response, String directoryName, Cookie[] cookies)
+ throws DotLRNForumException {
+
+ logger.debug("doExportTeacher: toolContentID:" + toolContentID);
+
+ // check if toolContentID available
+ if (toolContentID == null) {
+ String error = "Tool Content ID is missing. Unable to continue";
+ logger.error(error);
+ throw new DotLRNForumException(error);
+ }
+
+ DotLRNForum dotLRNForum = dotLRNForumService.getDotLRNForumByContentId(toolContentID);
+ DotLRNForumDTO dotLRNForumDTO = new DotLRNForumDTO(dotLRNForum);
+ request.getSession().setAttribute("dotLRNForumDTO", dotLRNForumDTO);
+
+ Set Copyright (C) 2006 LAMS Foundation (http://lamsfoundation.org
Index: tool_adapters/dotlrn/lams_tool_dlforum/web/common/header.jsp =================================================================== diff -u --- tool_adapters/dotlrn/lams_tool_dlforum/web/common/header.jsp (revision 0) +++ tool_adapters/dotlrn/lams_tool_dlforum/web/common/header.jsp (revision 8d072a352b5fc25f73957ce4c9230b644f2af15d) @@ -0,0 +1,17 @@ +<%@ include file="/common/taglibs.jsp"%> + ++ ${requestScope.message}; +
Index: tool_adapters/dotlrn/lams_tool_dlforum/web/common/taglibs.jsp =================================================================== diff -u --- tool_adapters/dotlrn/lams_tool_dlforum/web/common/taglibs.jsp (revision 0) +++ tool_adapters/dotlrn/lams_tool_dlforum/web/common/taglibs.jsp (revision 8d072a352b5fc25f73957ce4c9230b644f2af15d) @@ -0,0 +1,11 @@ +<%@ page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%> + +<%@ taglib uri="tags-bean" prefix="bean"%> +<%@ taglib uri="tags-logic" prefix="logic"%> +<%@ taglib uri="tags-tiles" prefix="tiles"%> +<%@ taglib uri="tags-html" prefix="html"%> +<%@ taglib uri="tags-core" prefix="c"%> +<%@ taglib uri="tags-fmt" prefix="fmt"%> +<%@ taglib uri="tags-lams" prefix="lams"%> +<%@ taglib uri="fck-editor" prefix="fck"%> + Index: tool_adapters/dotlrn/lams_tool_dlforum/web/error.jsp =================================================================== diff -u --- tool_adapters/dotlrn/lams_tool_dlforum/web/error.jsp (revision 0) +++ tool_adapters/dotlrn/lams_tool_dlforum/web/error.jsp (revision 8d072a352b5fc25f73957ce4c9230b644f2af15d) @@ -0,0 +1,91 @@ +<%-- +Copyright (C) 2005 LAMS Foundation (http://lamsfoundation.org) +License Information: http://lamsfoundation.org/licensing/lams/2.0/ + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License version 2 as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + http://www.gnu.org/licenses/gpl.txt +--%> + + + +<%@ page language="java" isErrorPage="true" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%> +<%@ taglib uri="tags-lams" prefix="lams"%> +<%@ taglib uri="tags-core" prefix="c"%> +<%@ taglib uri="tags-fmt" prefix="fmt"%> + +
+
+ + ${session.sessionName} ++ |
+
+ |
+ + ${session.numberOfLearners} + | +
+ |
+ + ${session.numberOfFinishedLearners} + | +