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 MdlLessonException {
+ repositoryService = RepositoryProxy.getRepositoryService();
+ ICredentials credentials = new SimpleCredentials(MdlLessonToolContentHandler.repositoryUser,
+ MdlLessonToolContentHandler.repositoryId);
+ try {
+ ITicket ticket = repositoryService.login(credentials, MdlLessonToolContentHandler.repositoryWorkspaceName);
+ return ticket;
+ } catch (AccessDeniedException ae) {
+ throw new MdlLessonException("Access Denied to repository." + ae.getMessage());
+ } catch (WorkspaceNotFoundException we) {
+ throw new MdlLessonException("Workspace not found." + we.getMessage());
+ } catch (LoginException e) {
+ throw new MdlLessonException("Login failed." + e.getMessage());
+ }
+ }
+
+ /* ===============Methods implemented from ToolContentImport102Manager =============== */
+
+ /**
+ * Import the data for a 1.0.2 MdlLesson
+ */
+ public void import102ToolContent(Long toolContentId, UserDTO user, Hashtable importValues) {
+ Date now = new Date();
+ MdlLesson mdlLesson = new MdlLesson();
+ mdlLesson.setCreateDate(now);
+ mdlLesson.setDefineLater(Boolean.FALSE);
+ mdlLesson.setRunOffline(Boolean.FALSE);
+ mdlLesson.setToolContentId(toolContentId);
+ mdlLesson.setUpdateDate(now);
+
+ mdlLessonDAO.saveOrUpdate(mdlLesson);
+ }
+
+ /**
+ * 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 mdlLesson. This doesn't make sense as the mdlLesson is for reflection and we don't reflect on reflection!");
+ MdlLesson mdlLesson = getMdlLessonByContentId(toolContentId);
+ if (mdlLesson == null) {
+ throw new DataMissingException("Unable to set reflective data titled " + title
+ + " on activity toolContentId " + toolContentId + " as the tool content does not exist.");
+ }
+
+ //mdlLesson.setInstructions(description);
+ }
+
+ //=========================================================================================
+ /* ********** Used by Spring to "inject" the linked objects ************* */
+
+ public IMdlLessonDAO getMdlLessonDAO() {
+ return mdlLessonDAO;
+ }
+
+ public void setMdlLessonDAO(IMdlLessonDAO mdlLessonDAO) {
+ this.mdlLessonDAO = mdlLessonDAO;
+ }
+
+ public IMdlLessonConfigItemDAO getMdlLessonConfigItemDAO() {
+ return mdlLessonConfigItemDAO;
+ }
+
+ public void setMdlLessonConfigItemDAO(IMdlLessonConfigItemDAO mdlLessonConfigItemDAO) {
+ this.mdlLessonConfigItemDAO = mdlLessonConfigItemDAO;
+ }
+
+ public IToolContentHandler getMdlLessonToolContentHandler() {
+ return mdlLessonToolContentHandler;
+ }
+
+ public void setMdlLessonToolContentHandler(IToolContentHandler mdlLessonToolContentHandler) {
+ this.mdlLessonToolContentHandler = mdlLessonToolContentHandler;
+ }
+
+ public IMdlLessonSessionDAO getMdlLessonSessionDAO() {
+ return mdlLessonSessionDAO;
+ }
+
+ public void setMdlLessonSessionDAO(IMdlLessonSessionDAO sessionDAO) {
+ this.mdlLessonSessionDAO = sessionDAO;
+ }
+
+ public ILamsToolService getToolService() {
+ return toolService;
+ }
+
+ public void setToolService(ILamsToolService toolService) {
+ this.toolService = toolService;
+ }
+
+ public IMdlLessonUserDAO getMdlLessonUserDAO() {
+ return mdlLessonUserDAO;
+ }
+
+ public void setMdlLessonUserDAO(IMdlLessonUserDAO userDAO) {
+ this.mdlLessonUserDAO = 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 MdlLessonOutputFactory getMdlLessonOutputFactory() {
+ if (mdlLessonOutputFactory == null) {
+ mdlLessonOutputFactory = new MdlLessonOutputFactory();
+ }
+ return mdlLessonOutputFactory;
+ }
+
+ public void setMdlLessonOutputFactory(MdlLessonOutputFactory mdlLessonOutputFactory) {
+ this.mdlLessonOutputFactory = mdlLessonOutputFactory;
+ }
+
+ /**
+ * 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/mdlesn/mdlLessonApplicationContext.xml",
+ "/org/lamsfoundation/lams/commonContext.xml" };
+
+ ApplicationContext context = new ClassPathXmlApplicationContext(contexts);
+
+ if (context == null)
+ throw new MdlLessonException(
+ "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/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/service/MdlLessonServiceProxy.java
===================================================================
diff -u
--- tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/service/MdlLessonServiceProxy.java (revision 0)
+++ tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/service/MdlLessonServiceProxy.java (revision 1900d45594cf161971a48d0e596b36fbcf06a0eb)
@@ -0,0 +1,76 @@
+/****************************************************************
+ * 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.mdlesn.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 MdlLessonServiceProxy { + + public static final IMdlLessonService getMdlLessonService(ServletContext servletContext) { + return (IMdlLessonService) getMdlLessonDomainService(servletContext); + } + + private static Object getMdlLessonDomainService(ServletContext servletContext) { + WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); + return wac.getBean("mdlLessonService"); + } + + /* + * Return the mdlLesson 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 getMdlLessonSessionManager(ServletContext servletContext) { + return (ToolSessionManager) getMdlLessonDomainService(servletContext); + } + + /* + * Return the mdlLesson 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 getMdlLessonContentManager(ServletContext servletContext) { + return (ToolContentManager) getMdlLessonDomainService(servletContext); + } + +} Index: tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/util/MdlLessonConstants.java =================================================================== diff -u --- tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/util/MdlLessonConstants.java (revision 0) +++ tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/util/MdlLessonConstants.java (revision 1900d45594cf161971a48d0e596b36fbcf06a0eb) @@ -0,0 +1,50 @@ +/**************************************************************** + * 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.mdlesn.util; + +public interface MdlLessonConstants { + public static final String TOOL_SIGNATURE = "mdlesn10"; + + // MdlLesson session status + public static final Integer SESSION_NOT_STARTED = new Integer(0); + public static final Integer SESSION_IN_PROGRESS = new Integer(1); + public static final Integer SESSION_COMPLETED = new Integer(2); + + public static final String AUTHORING_DEFAULT_TAB = "1"; + public static final String DELETED_ATTACHMENT_LIST = "deletedAttachmentList"; + public static final String AUTH_SESSION_ID_COUNTER = "authoringSessionIdCounter"; + public static final String AUTH_SESSION_ID = "authoringSessionId"; + + public static final int MONITORING_SUMMARY_MAX_MESSAGES = 5; + + // Attribute names + public static final String ATTR_MESSAGE = "message"; + public static final String ATTR_SESSION_MAP = "sessionMap"; + + // Parameter names + public static final String PARAM_PARENT_PAGE = "parentPage"; + + static final String FILTER_REPLACE_TEXT = "***"; +} Index: tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/util/MdlLessonException.java =================================================================== diff -u --- tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/util/MdlLessonException.java (revision 0) +++ tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/util/MdlLessonException.java (revision 1900d45594cf161971a48d0e596b36fbcf06a0eb) @@ -0,0 +1,57 @@ +/**************************************************************** + * 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.mdlesn.util; + +/** + * + * @author lfoxton + * + */ +public class MdlLessonException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = -5518806968051758859L; + + public MdlLessonException(String message) { + super(message); + } + + public MdlLessonException(String message, Throwable cause) { + super(message, cause); + } + + public MdlLessonException() { + super(); + + } + + public MdlLessonException(Throwable cause) { + super(cause); + + } + +} Index: tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/util/MdlLessonToolContentHandler.java =================================================================== diff -u --- tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/util/MdlLessonToolContentHandler.java (revision 0) +++ tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/util/MdlLessonToolContentHandler.java (revision 1900d45594cf161971a48d0e596b36fbcf06a0eb) @@ -0,0 +1,76 @@ +/**************************************************************** + * 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.mdlesn.util; + +import org.lamsfoundation.lams.contentrepository.client.ToolContentHandler; + +/** + * Simple client for accessing the content repository. + */ +public class MdlLessonToolContentHandler extends ToolContentHandler { + + // TODO these three fields were changed to public, since accessor methods + // cannot be made static. Check if we can do this a better way. + public static String repositoryWorkspaceName = "mdlLessonworkspace"; + + public static String repositoryUser = "mdlLesson"; + + public static char[] repositoryId = { 'l', 'a', 'm', 's', '-', 'e', 'x' }; + + /** + * + */ + public MdlLessonToolContentHandler() { + super(); + } + + /* + * (non-Javadoc) + * + * @see org.lamsfoundation.lams.contentrepository.client.ToolContentHandler#getRepositoryWorkspaceName() + */ + public String getRepositoryWorkspaceName() { + return repositoryWorkspaceName; + } + + /* + * (non-Javadoc) + * + * @see org.lamsfoundation.lams.contentrepository.client.ToolContentHandler#getRepositoryUser() + */ + public String getRepositoryUser() { + return repositoryUser; + } + + /* + * (non-Javadoc) + * + * @see org.lamsfoundation.lams.contentrepository.client.ToolContentHandler#getRepositoryId() + */ + public char[] getRepositoryId() { + return repositoryId; + } + +} Index: tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/util/WebUtility.java =================================================================== diff -u --- tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/util/WebUtility.java (revision 0) +++ tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/util/WebUtility.java (revision 1900d45594cf161971a48d0e596b36fbcf06a0eb) @@ -0,0 +1,179 @@ +/**************************************************************** + * 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 + * **************************************************************** + */ +package org.lamsfoundation.lams.tool.mdlesn.util; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.HttpURLConnection; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLConnection; +import java.util.HashMap; +import java.util.Map.Entry; + +import org.apache.log4j.Logger; +import org.lamsfoundation.lams.tool.exception.ToolException; + +public class WebUtility { + static Logger logger = Logger.getLogger(WebUtility.class.getName()); + + /** + * Uploads a file for importing sequences Uses a multi-part http post to + * post the file as well as the user, course, and hash server-authentication + * strings. + * + * Some of the java multipart posting libraries clashed with existing jboss + * libraries So instead, the multipart post is put together manually + * + * @param f + * @param urlString + * @param timestamp + * @param extUsername + * @param extCourseId + * @param hash + * @return + * @throws IOException + */ + public static InputStream performMultipartPost(File f, String fileParamName, String urlString, + 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 mdlLessonService
+ if (mdlLessonService == null) {
+ mdlLessonService = MdlLessonServiceProxy.getMdlLessonService(this.getServlet().getServletContext());
+ }
+
+ // retrieving MdlLesson 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
+ MdlLesson mdlLesson = mdlLessonService.getMdlLessonByContentId(toolContentID);
+
+ // Getting the custom csv from the request
+ String customCSV = WebUtil.readStrParam(request, "customCSV", true);
+ String userFromCSV = null;
+ String courseFromCSV = null;
+ String sectionFromCSV = null;
+ if (customCSV == null && mdlLesson == null) {
+ logger.error("CustomCSV required if mdlLesson is null");
+ throw new ToolException("CustomCSV required if mdlLesson is null");
+ } else if (customCSV != null) {
+ String splitCSV[] = customCSV.split(",");
+ if (splitCSV.length != 3) {
+ logger.error("mdlLesson tool customCSV not in required (user,course,courseURL) form: " + customCSV);
+ throw new ToolException("mdlLesson tool cusomCSV not in required (user,course,courseURL) form: "
+ + customCSV);
+ } else {
+ userFromCSV = splitCSV[0];
+ courseFromCSV = splitCSV[1];
+ sectionFromCSV = splitCSV[2];
+ }
+ }
+
+ if (mdlLesson == null) {
+ mdlLesson = mdlLessonService.copyDefaultContent(toolContentID);
+ mdlLesson.setExtUsername(userFromCSV);
+ mdlLesson.setExtCourseId(courseFromCSV);
+ mdlLesson.setExtSection(sectionFromCSV);
+ mdlLesson.setCreateDate(new Date());
+ }
+
+ 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.
+ mdlLesson.setDefineLater(true);
+ mdlLessonService.saveOrUpdateMdlLesson(mdlLesson);
+ }
+
+ // if no external content id, open the mdl author page, otherwise, open the edit page
+ try {
+
+ // If the mdlLesson has a saved course url, use it, otherwise use the one giving in the request in customCSV
+ //String courseUrlToBeUsed = (mdlLesson.getExtCourseUrl() != null) ? mdlLesson.getExtCourseUrl() : courseUrlFromCSV;
+
+ String responseUrl = mdlLessonService.getConfigItem(MdlLessonConfigItem.KEY_EXTERNAL_SERVER_URL)
+ .getConfigValue();
+ /* responseUrl += RELATIVE_MOODLE_AUTHOR_URL;
+ String returnUpdateUrl = URLEncoder.encode(TOOL_APP_URL + "/authoring.do?dispatch=updateContent" + "&"
+ + AttributeNames.PARAM_TOOL_CONTENT_ID + "=" + toolContentID.toString(), "UTF8");
+ responseUrl += "&lamsUpdateURL=" + returnUpdateUrl;*/
+
+
+ responseUrl += RELATIVE_MOODLE_AUTHOR_URL;
+ String returnUpdateUrl = URLEncoder.encode(TOOL_APP_URL + "/authoring.do?dispatch=updateContent" + "&"
+ + AttributeNames.PARAM_TOOL_CONTENT_ID + "=" + toolContentID.toString(), "UTF8");
+
+
+ returnUpdateUrl = URLEncoder.encode(returnUpdateUrl, "UTF8");
+
+ responseUrl += "lamsUpdateURL=" + returnUpdateUrl;
+
+ String encodedMoodleRelativePath = URLEncoder.encode(MOODLE_EDIT_URL, "UTF8");
+
+ responseUrl += "&dest=" + encodedMoodleRelativePath ;
+
+
+ if (mdlLesson.getExtSection() != null) {
+ responseUrl += "§ion=" + mdlLesson.getExtSection();
+ } else {
+ responseUrl += "§ion=" + sectionFromCSV;
+ }
+
+ if (mdlLesson.getExtToolContentId() != null) {
+ responseUrl += "&id=" + mdlLesson.getExtToolContentId().toString();
+ } else {
+ responseUrl += "&add=lesson";
+ }
+
+ if (mdlLesson.getExtCourseId() != null) {
+ responseUrl += "&course=" + mdlLesson.getExtCourseId();
+ } else {
+ responseUrl += "&course=" + courseFromCSV;
+ }
+
+ log.debug("Sending to moodle lesson edit page: " + responseUrl);
+
+ response.sendRedirect(responseUrl);
+ } catch (Exception e) {
+ log.error("Could not redirect to mdl lesson 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 mdlLesson content.
+ MdlLesson mdlLesson = mdlLessonService.getMdlLessonByContentId(toolContentID);
+ mdlLesson.setExtToolContentId(externalToolContentID);
+ mdlLesson.setUpdateDate(new Date());
+ mdlLesson.setDefineLater(false);
+ mdlLessonService.saveOrUpdateMdlLesson(mdlLesson);
+
+ String redirectString = Configuration.get(ConfigurationKeys.SERVER_URL) + "/tool/"
+ + MdlLessonConstants.TOOL_SIGNATURE + "/clearsession.do" + "?action=confirm&mode=author" + "&signature="
+ + MdlLessonConstants.TOOL_SIGNATURE + "&toolContentID=" + toolContentID.toString() + "&defineLater=no"
+ + "&customiseSessionID=" + "&contentFolderID=0";
+
+ log.debug("Manual redirect for MdlLesson to: " + redirectString);
+
+ try {
+ response.sendRedirect(redirectString);
+ } catch (Exception e) {
+ log.error("Could not redirect to clear session action for MdlLesson", e);
+ }
+
+ return null;
+ }
+}
Index: tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/actions/ClearSessionAction.java
===================================================================
diff -u
--- tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/actions/ClearSessionAction.java (revision 0)
+++ tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/actions/ClearSessionAction.java (revision 1900d45594cf161971a48d0e596b36fbcf06a0eb)
@@ -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.mdlesn.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 lfoxton
+ *
+ * @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/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/actions/LearningAction.java
===================================================================
diff -u
--- tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/actions/LearningAction.java (revision 0)
+++ tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/actions/LearningAction.java (revision 1900d45594cf161971a48d0e596b36fbcf06a0eb)
@@ -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 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.mdlesn.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.ToolAccessMode;
+import org.lamsfoundation.lams.tool.ToolSessionManager;
+import org.lamsfoundation.lams.tool.exception.DataMissingException;
+import org.lamsfoundation.lams.tool.exception.ToolException;
+import org.lamsfoundation.lams.tool.mdlesn.model.MdlLessonUser;
+import org.lamsfoundation.lams.tool.mdlesn.dto.MdlLessonDTO;
+import org.lamsfoundation.lams.tool.mdlesn.model.MdlLesson;
+import org.lamsfoundation.lams.tool.mdlesn.model.MdlLessonConfigItem;
+import org.lamsfoundation.lams.tool.mdlesn.model.MdlLessonSession;
+import org.lamsfoundation.lams.tool.mdlesn.service.IMdlLessonService;
+import org.lamsfoundation.lams.tool.mdlesn.service.MdlLessonServiceProxy;
+import org.lamsfoundation.lams.tool.mdlesn.util.MdlLessonConstants;
+import org.lamsfoundation.lams.tool.mdlesn.util.MdlLessonException;
+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="mdlLesson" 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/"
+ + MdlLessonConstants.TOOL_SIGNATURE + "/";
+
+ public static final String RELATIVE_LEARNER_URL = "course/lamsframes.php?";
+ public static final String MOODLE_VIEW_URL = "mod/lesson/view.php";
+ public static final String RELATIVE_TEACHER_URL = "mod/lesson/view.php?mode=author&";
+
+ private IMdlLessonService mdlLessonService;
+
+ public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) throws Exception {
+
+ Long toolSessionID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_SESSION_ID);
+
+ // set up mdlLessonService
+ if (mdlLessonService == null) {
+ mdlLessonService = MdlLessonServiceProxy.getMdlLessonService(this.getServlet().getServletContext());
+ }
+
+ // Retrieve the session and content.
+ ToolAccessMode mode = WebUtil.readToolAccessModeParam(request,AttributeNames.PARAM_MODE, false);
+ MdlLessonSession mdlLessonSession = mdlLessonService.getSessionBySessionId(toolSessionID);
+ if (mdlLessonSession == null) {
+ throw new MdlLessonException("Cannot retreive session with toolSessionID: " + toolSessionID);
+ }
+
+ MdlLesson mdlLesson = mdlLessonSession.getMdlLesson();
+ MdlLessonUser mdlLessonUser = getCurrentUser(toolSessionID);
+
+ // check defineLater
+ if (mdlLesson.isDefineLater()) {
+ return mapping.findForward("defineLater");
+ }
+
+ MdlLessonDTO mdlLessonDTO = new MdlLessonDTO();
+ request.setAttribute("mdlLessonDTO", mdlLessonDTO);
+
+ // Set the content in use flag.
+ if (!mdlLesson.isContentInUse()) {
+ mdlLesson.setContentInUse(new Boolean(true));
+ mdlLessonService.saveOrUpdateMdlLesson(mdlLesson);
+ }
+
+ // check runOffline
+ if (mdlLesson.isRunOffline()) {
+ return mapping.findForward("runOffline");
+ }
+
+ if (mdlLesson.getExtToolContentId() != null) {
+ try {
+ String responseUrl = mdlLessonService.getConfigItem(MdlLessonConfigItem.KEY_EXTERNAL_SERVER_URL)
+ .getConfigValue();
+
+ if(mode.equals(ToolAccessMode.TEACHER))
+ {
+ responseUrl += RELATIVE_TEACHER_URL;
+ }
+ else if (mode.equals(ToolAccessMode.LEARNER) || mode.equals(ToolAccessMode.AUTHOR))
+ {
+ responseUrl += RELATIVE_LEARNER_URL;
+ }
+
+ String returnUrl = TOOL_APP_URL + "learning.do?" + AttributeNames.PARAM_TOOL_SESSION_ID + "="
+ + toolSessionID.toString() + "&dispatch=finishActivity";
+
+ String encodedMoodleRelativePath = URLEncoder.encode(MOODLE_VIEW_URL, "UTF8");
+
+ returnUrl = URLEncoder.encode(returnUrl, "UTF8");
+
+
+ responseUrl += "&id=" + mdlLessonSession.getExtSessionId() + "&returnUrl=" + returnUrl
+ + "&dest=" + encodedMoodleRelativePath + "&is_learner=1" + "&isFinished=" + mdlLessonUser.isFinishedActivity();
+
+
+ log.debug("Redirecting for mdl lesson learner: " + responseUrl);
+ response.sendRedirect(responseUrl);
+ } catch (Exception e) {
+ log.error("Could not redirect to mdl lesson authoring", e);
+ }
+ } else {
+ throw new MdlLessonException("External content id null for learner");
+ }
+ return null;
+ }
+
+ private MdlLessonUser getCurrentUser(Long toolSessionId) {
+ UserDTO user = (UserDTO) SessionManager.getSession().getAttribute(AttributeNames.USER);
+
+ // attempt to retrieve user using userId and toolSessionId
+ MdlLessonUser mdlLessonUser = mdlLessonService.getUserByUserIdAndSessionId(new Long(user.getUserID().intValue()),
+ toolSessionId);
+
+ if (mdlLessonUser == null) {
+ MdlLessonSession mdlLessonSession = mdlLessonService.getSessionBySessionId(toolSessionId);
+ mdlLessonUser = mdlLessonService.createMdlLessonUser(user, mdlLessonSession);
+ }
+
+ return mdlLessonUser;
+ }
+
+ public ActionForward finishActivity(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) {
+
+ Long toolSessionID = WebUtil.readLongParam(request, "toolSessionID");
+
+ MdlLessonUser mdlLessonUser = getCurrentUser(toolSessionID);
+
+ if (mdlLessonUser != null) {
+ mdlLessonUser.setFinishedActivity(true);
+ mdlLessonService.saveOrUpdateMdlLessonUser(mdlLessonUser);
+ } else {
+ log.error("finishActivity(): couldn't find MdlLessonUser with id: " + mdlLessonUser.getUserId()
+ + "and toolSessionID: " + toolSessionID);
+ }
+
+ ToolSessionManager sessionMgrService = MdlLessonServiceProxy.getMdlLessonSessionManager(getServlet()
+ .getServletContext());
+
+ String nextActivityUrl;
+ try {
+ nextActivityUrl = sessionMgrService.leaveToolSession(toolSessionID, mdlLessonUser.getUserId());
+ response.sendRedirect(nextActivityUrl);
+ } catch (DataMissingException e) {
+ throw new MdlLessonException(e);
+ } catch (ToolException e) {
+ throw new MdlLessonException(e);
+ } catch (IOException e) {
+ throw new MdlLessonException(e);
+ }
+
+ return null; // TODO need to return proper page.
+ }
+}
Index: tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/actions/MonitoringAction.java
===================================================================
diff -u
--- tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/actions/MonitoringAction.java (revision 0)
+++ tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/actions/MonitoringAction.java (revision 1900d45594cf161971a48d0e596b36fbcf06a0eb)
@@ -0,0 +1,122 @@
+/****************************************************************
+ * 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.mdlesn.web.actions;
+
+import java.io.UnsupportedEncodingException;
+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.mdlesn.dto.MdlLessonDTO;
+import org.lamsfoundation.lams.tool.mdlesn.dto.MdlLessonSessionDTO;
+import org.lamsfoundation.lams.tool.mdlesn.model.MdlLesson;
+import org.lamsfoundation.lams.tool.mdlesn.model.MdlLessonConfigItem;
+import org.lamsfoundation.lams.tool.mdlesn.service.IMdlLessonService;
+import org.lamsfoundation.lams.tool.mdlesn.service.MdlLessonServiceProxy;
+import org.lamsfoundation.lams.tool.mdlesn.util.MdlLessonConstants;
+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/"
+ + MdlLessonConstants.TOOL_SIGNATURE + "/";
+
+ public static final String RELATIVE_MONITOR_URL = "mod/lesson/view.php?";
+
+ public IMdlLessonService mdlLessonService;
+
+ 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);
+
+ MdlLesson mdlLesson = mdlLessonService.getMdlLessonByContentId(toolContentID);
+
+ if (mdlLesson == null) {
+ // TODO error page.
+ }
+
+ MdlLessonDTO mdlLessonDT0 = new MdlLessonDTO(mdlLesson);
+
+ Long currentTab = WebUtil.readLongParam(request, AttributeNames.PARAM_CURRENT_TAB, true);
+ mdlLessonDT0.setCurrentTab(currentTab);
+
+ for (MdlLessonSessionDTO sessionDTO : mdlLessonDT0.getSessionDTOs()) {
+ try {
+ String responseUrl = mdlLessonService.getConfigItem(MdlLessonConfigItem.KEY_EXTERNAL_SERVER_URL)
+ .getConfigValue();
+ responseUrl += RELATIVE_MONITOR_URL;
+
+ String returnUrl = TOOL_APP_URL + "learning.do?" + AttributeNames.PARAM_TOOL_SESSION_ID + "="
+ + sessionDTO.getSessionID().toString() + "&dispatch=finishActivity";
+ returnUrl = URLEncoder.encode(returnUrl, "UTF8");
+
+ responseUrl += "&id=" + sessionDTO.getExtSessionID() + "&returnUrl=" + returnUrl;
+
+ sessionDTO.setRunTimeUrl(responseUrl);
+ } catch (UnsupportedEncodingException e) {
+ log.error(e);
+ }
+ }
+
+ request.setAttribute("mdlLessonDTO", mdlLessonDT0);
+ request.setAttribute("contentFolderID", contentFolderID);
+ return mapping.findForward("success");
+ }
+
+ /**
+ * set up mdlLessonService
+ */
+ private void setupService() {
+ if (mdlLessonService == null) {
+ mdlLessonService = MdlLessonServiceProxy.getMdlLessonService(this.getServlet().getServletContext());
+ }
+ }
+}
Index: tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/forms/AdminForm.java
===================================================================
diff -u
--- tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/forms/AdminForm.java (revision 0)
+++ tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/forms/AdminForm.java (revision 1900d45594cf161971a48d0e596b36fbcf06a0eb)
@@ -0,0 +1,77 @@
+/****************************************************************
+ * 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
+ * ****************************************************************
+ */
+package org.lamsfoundation.lams.tool.mdlesn.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="mdlesn10AdminForm"
+ */
+public class AdminForm extends ActionForm {
+ private static final long serialVersionUID = 8872637862875198L;
+
+ String toolAdapterServlet;
+ String extServerUrl;
+ 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;
+ }
+
+ public String getExtServerUrl() {
+ return extServerUrl;
+ }
+
+ public void setExtServerUrl(String extServerUrl) {
+ this.extServerUrl = extServerUrl;
+ }
+
+ public static long getSerialVersionUID() {
+ return serialVersionUID;
+ }
+}
Index: tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/forms/AuthoringForm.java
===================================================================
diff -u
--- tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/forms/AuthoringForm.java (revision 0)
+++ tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/forms/AuthoringForm.java (revision 1900d45594cf161971a48d0e596b36fbcf06a0eb)
@@ -0,0 +1,215 @@
+/****************************************************************
+ * 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.mdlesn.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/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/forms/LearningForm.java
===================================================================
diff -u
--- tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/forms/LearningForm.java (revision 0)
+++ tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/forms/LearningForm.java (revision 1900d45594cf161971a48d0e596b36fbcf06a0eb)
@@ -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.mdlesn.web.forms;
+
+import org.apache.struts.action.ActionForm;
+
+/**
+ *
+ * @author lfoxton
+ *
+ * @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/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/forms/MonitoringForm.java
===================================================================
diff -u
--- tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/forms/MonitoringForm.java (revision 0)
+++ tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/forms/MonitoringForm.java (revision 1900d45594cf161971a48d0e596b36fbcf06a0eb)
@@ -0,0 +1,94 @@
+/****************************************************************
+ * 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.mdlesn.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/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/servlets/ExportServlet.java
===================================================================
diff -u
--- tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/servlets/ExportServlet.java (revision 0)
+++ tool_adapters/moodle/lams_tool_mdllesson/src/java/org/lamsfoundation/lams/tool/mdlesn/web/servlets/ExportServlet.java (revision 1900d45594cf161971a48d0e596b36fbcf06a0eb)
@@ -0,0 +1,194 @@
+/****************************************************************
+ * 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.mdlesn.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.mdlesn.dto.MdlLessonDTO;
+import org.lamsfoundation.lams.tool.mdlesn.model.MdlLesson;
+import org.lamsfoundation.lams.tool.mdlesn.model.MdlLessonConfigItem;
+import org.lamsfoundation.lams.tool.mdlesn.model.MdlLessonSession;
+import org.lamsfoundation.lams.tool.mdlesn.service.MdlLessonServiceProxy;
+import org.lamsfoundation.lams.tool.mdlesn.service.IMdlLessonService;
+import org.lamsfoundation.lams.tool.mdlesn.util.MdlLessonException;
+import org.lamsfoundation.lams.tool.mdlesn.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 = "mdlLesson_main.html";
+
+ private IMdlLessonService mdlLessonService;
+
+ protected String doExport(HttpServletRequest request, HttpServletResponse response, String directoryName,
+ Cookie[] cookies) {
+
+ if (mdlLessonService == null) {
+ mdlLessonService = MdlLessonServiceProxy.getMdlLessonService(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 (MdlLessonException e) {
+ logger.error("Cannot perform export for mdlLesson 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 (mdlLessonService == null) {
+ mdlLessonService = MdlLessonServiceProxy.getMdlLessonService(getServletContext());
+ }
+
+ MdlLesson content = null;
+ if (toolContentID != null) {
+ content = mdlLessonService.getMdlLessonByContentId(toolContentID);
+ } else {
+ MdlLessonSession session = mdlLessonService.getSessionBySessionId(toolSessionID);
+ if (session != null)
+ content = session.getMdlLesson();
+ }
+ 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 MdlLessonException {
+
+ 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 MdlLessonException(error);
+ }
+
+ MdlLessonSession mdlLessonSession = mdlLessonService.getSessionBySessionId(toolSessionID);
+
+ MdlLesson mdlLesson = mdlLessonSession.getMdlLesson();
+
+ try {
+ exportFileFromExternalServer(request, response, mdlLessonSession.getExtSessionId(), mdlLesson, directoryName
+ + "/" + FILENAME);
+ } catch (Exception e) {
+ logger.error("Could not fetch export file from external servlet", e);
+ throw new MdlLessonException("Could not fetch export file from external servlet", e);
+ }
+ }
+
+ private void doTeacherExport(HttpServletRequest request, HttpServletResponse response, String directoryName,
+ Cookie[] cookies) throws MdlLessonException {
+
+ 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 MdlLessonException(error);
+ }
+
+ MdlLesson mdlLesson = mdlLessonService.getMdlLessonByContentId(toolContentID);
+ MdlLessonDTO mdlLessonDTO = new MdlLessonDTO(mdlLesson);
+ request.getSession().setAttribute("mdlLessonDTO", mdlLessonDTO);
+
+ Set
+
+
Copyright (C) 2006 LAMS Foundation (http://lamsfoundation.org
Index: tool_adapters/moodle/lams_tool_mdllesson/web/common/header.jsp =================================================================== diff -u --- tool_adapters/moodle/lams_tool_mdllesson/web/common/header.jsp (revision 0) +++ tool_adapters/moodle/lams_tool_mdllesson/web/common/header.jsp (revision 1900d45594cf161971a48d0e596b36fbcf06a0eb) @@ -0,0 +1,17 @@ +<%@ include file="/common/taglibs.jsp"%> + ++ ${requestScope.message}; +
Index: tool_adapters/moodle/lams_tool_mdllesson/web/common/taglibs.jsp =================================================================== diff -u --- tool_adapters/moodle/lams_tool_mdllesson/web/common/taglibs.jsp (revision 0) +++ tool_adapters/moodle/lams_tool_mdllesson/web/common/taglibs.jsp (revision 1900d45594cf161971a48d0e596b36fbcf06a0eb) @@ -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/moodle/lams_tool_mdllesson/web/error.jsp =================================================================== diff -u --- tool_adapters/moodle/lams_tool_mdllesson/web/error.jsp (revision 0) +++ tool_adapters/moodle/lams_tool_mdllesson/web/error.jsp (revision 1900d45594cf161971a48d0e596b36fbcf06a0eb) @@ -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} + | +