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 LeaderselectionException {
+ ICredentials credentials = new SimpleCredentials(LeaderselectionToolContentHandler.repositoryUser,
+ LeaderselectionToolContentHandler.repositoryId);
+ try {
+ ITicket ticket = repositoryService.login(credentials,
+ LeaderselectionToolContentHandler.repositoryWorkspaceName);
+ return ticket;
+ } catch (AccessDeniedException ae) {
+ throw new LeaderselectionException("Access Denied to repository." + ae.getMessage());
+ } catch (WorkspaceNotFoundException we) {
+ throw new LeaderselectionException("Workspace not found." + we.getMessage());
+ } catch (LoginException e) {
+ throw new LeaderselectionException("Login failed." + e.getMessage());
+ }
+ }
+
+ /* ===============Methods implemented from ToolContentImport102Manager =============== */
+
+ @Override
+ public void import102ToolContent(Long toolContentId, UserDTO user, Hashtable importValues) {
+ }
+
+ @Override
+ public void setReflectiveData(Long toolContentId, String title, String description) throws ToolException,
+ DataMissingException {
+
+ Leaderselection leaderselection = getContentByContentId(toolContentId);
+ if (leaderselection == null) {
+ throw new DataMissingException("Unable to set reflective data titled " + title
+ + " on activity toolContentId " + toolContentId + " as the tool content does not exist.");
+ }
+
+ leaderselection.setInstructions(description);
+ }
+
+ // =========================================================================================
+ /* ********** Used by Spring to "inject" the linked objects ************* */
+
+ public ILeaderselectionDAO getLeaderselectionDAO() {
+ return leaderselectionDAO;
+ }
+
+ public void setLeaderselectionDAO(ILeaderselectionDAO leaderselectionDAO) {
+ this.leaderselectionDAO = leaderselectionDAO;
+ }
+
+ public IToolContentHandler getLeaderselectionToolContentHandler() {
+ return leaderselectionToolContentHandler;
+ }
+
+ public void setLeaderselectionToolContentHandler(IToolContentHandler leaderselectionToolContentHandler) {
+ this.leaderselectionToolContentHandler = leaderselectionToolContentHandler;
+ }
+
+ public ILeaderselectionSessionDAO getLeaderselectionSessionDAO() {
+ return leaderselectionSessionDAO;
+ }
+
+ public void setLeaderselectionSessionDAO(ILeaderselectionSessionDAO sessionDAO) {
+ leaderselectionSessionDAO = sessionDAO;
+ }
+
+ public ILamsToolService getToolService() {
+ return toolService;
+ }
+
+ public void setToolService(ILamsToolService toolService) {
+ this.toolService = toolService;
+ }
+
+ public ILeaderselectionUserDAO getLeaderselectionUserDAO() {
+ return leaderselectionUserDAO;
+ }
+
+ public void setLeaderselectionUserDAO(ILeaderselectionUserDAO userDAO) {
+ leaderselectionUserDAO = 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 IRepositoryService getRepositoryService() {
+ return repositoryService;
+ }
+
+ public void setRepositoryService(IRepositoryService repositoryService) {
+ this.repositoryService = repositoryService;
+ }
+
+ public LeaderselectionOutputFactory getLeaderselectionOutputFactory() {
+ return leaderselectionOutputFactory;
+ }
+
+ public void setLeaderselectionOutputFactory(LeaderselectionOutputFactory leaderselectionOutputFactory) {
+ this.leaderselectionOutputFactory = leaderselectionOutputFactory;
+ }
+
+ public boolean isGroupedActivity(long toolContentID) {
+ return toolService.isGroupedActivity(toolContentID);
+ }
+
+ public Class[] getSupportedToolOutputDefinitionClasses(int definitionType) {
+ return getLeaderselectionOutputFactory().getSupportedDefinitionClasses(definitionType);
+ }
+}
Index: lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/service/LeaderselectionServiceProxy.java
===================================================================
RCS file: /usr/local/cvsroot/lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/service/LeaderselectionServiceProxy.java,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/service/LeaderselectionServiceProxy.java 8 Jan 2014 20:13:49 -0000 1.1
@@ -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 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: LeaderselectionServiceProxy.java,v 1.1 2014/01/08 20:13:49 andreyb Exp $$ */
+
+package org.lamsfoundation.lams.tool.leaderselection.service;
+
+import javax.servlet.ServletContext;
+
+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 LeaderselectionServiceProxy { + + public static final ILeaderselectionService getLeaderselectionService(ServletContext servletContext) { + return (ILeaderselectionService) getLeaderselectionDomainService(servletContext); + } + + private static Object getLeaderselectionDomainService(ServletContext servletContext) { + WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext); + return wac.getBean("leaderselectionService"); + } + + /* + * Return the leaderselection 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 getLeaderselectionSessionManager(ServletContext servletContext) { + return (ToolSessionManager) getLeaderselectionDomainService(servletContext); + } + + /* + * Return the leaderselection 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 getLeaderselectionContentManager(ServletContext servletContext) { + return (ToolContentManager) getLeaderselectionDomainService(servletContext); + } + +} Index: lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/util/LeaderselectionConstants.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/util/LeaderselectionConstants.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/util/LeaderselectionConstants.java 8 Jan 2014 20:13:51 -0000 1.1 @@ -0,0 +1,43 @@ +/**************************************************************** + * 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: LeaderselectionConstants.java,v 1.1 2014/01/08 20:13:51 andreyb Exp $$ */ + +package org.lamsfoundation.lams.tool.leaderselection.util; + +public interface LeaderselectionConstants { + public static final String TOOL_SIGNATURE = "lalead11"; + + // Attribute names + public static final String ATTR_SESSION_MAP = "sessionMap"; + public static final String ATTR_GROUP_LEADER = "groupLeader"; + public static final String ATTR_GROUP_USERS = "groupUsers"; + public static final String ATTR_TOOL_SESSION_ID = "toolSessionId"; + public static final String ATTR_CONTENT = "content"; + public static final String ATTR_IS_GROUPED_ACTIVITY = "isGroupedActivity"; + + public static final String ATTR_SESSION_MAP_ID = "sessionMapID"; + + public static final String OUTPUT_NAME_IS_LEARNER_A_LEADER = "user.is.leader"; + public static final String OUTPUT_NAME_LEADER_USERID = "leader.user.id"; + public static final String SUCCESS = "success"; +} Index: lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/util/LeaderselectionException.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/util/LeaderselectionException.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/util/LeaderselectionException.java 8 Jan 2014 20:13:51 -0000 1.1 @@ -0,0 +1,55 @@ +/**************************************************************** + * 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: LeaderselectionException.java,v 1.1 2014/01/08 20:13:51 andreyb Exp $$ */ + +package org.lamsfoundation.lams.tool.leaderselection.util; + +/** + * + */ +public class LeaderselectionException extends RuntimeException { + + /** + * + */ + private static final long serialVersionUID = -5518806968051758859L; + + public LeaderselectionException(String message) { + super(message); + } + + public LeaderselectionException(String message, Throwable cause) { + super(message, cause); + } + + public LeaderselectionException() { + super(); + + } + + public LeaderselectionException(Throwable cause) { + super(cause); + + } + +} Index: lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/util/LeaderselectionToolContentHandler.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/util/LeaderselectionToolContentHandler.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/util/LeaderselectionToolContentHandler.java 8 Jan 2014 20:13:51 -0000 1.1 @@ -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: LeaderselectionToolContentHandler.java,v 1.1 2014/01/08 20:13:51 andreyb Exp $$ */ + +package org.lamsfoundation.lams.tool.leaderselection.util; + +import org.lamsfoundation.lams.contentrepository.client.ToolContentHandler; + +/** + * Simple client for accessing the content repository. + */ +public class LeaderselectionToolContentHandler 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 = "leaderselectionworkspace"; + + public static String repositoryUser = "leaderselection"; + + public static char[] repositoryId = { 'l', 'a', 'm', 's', '-', 'e', 'x' }; + + /** + * + */ + public LeaderselectionToolContentHandler() { + 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: lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/web/actions/AuthoringAction.java =================================================================== RCS file: /usr/local/cvsroot/lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/web/actions/AuthoringAction.java,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_leader/src/java/org/lamsfoundation/lams/tool/leaderselection/web/actions/AuthoringAction.java 8 Jan 2014 20:13:51 -0000 1.1 @@ -0,0 +1,185 @@ +/**************************************************************** + * 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: AuthoringAction.java,v 1.1 2014/01/08 20:13:51 andreyb Exp $$ */ + +package org.lamsfoundation.lams.tool.leaderselection.web.actions; + +import java.util.Date; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.commons.lang.StringUtils; +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.apache.struts.action.ActionMessages; +import org.apache.struts.upload.FormFile; +import org.lamsfoundation.lams.authoring.web.AuthoringConstants; +import org.lamsfoundation.lams.contentrepository.client.IToolContentHandler; +import org.lamsfoundation.lams.tool.ToolAccessMode; +import org.lamsfoundation.lams.tool.leaderselection.model.Leaderselection; +import org.lamsfoundation.lams.tool.leaderselection.service.ILeaderselectionService; +import org.lamsfoundation.lams.tool.leaderselection.service.LeaderselectionServiceProxy; +import org.lamsfoundation.lams.tool.leaderselection.util.LeaderselectionConstants; +import org.lamsfoundation.lams.tool.leaderselection.web.forms.AuthoringForm; +import org.lamsfoundation.lams.util.FileValidatorUtil; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.action.LamsDispatchAction; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.lamsfoundation.lams.web.util.SessionMap; + +/** + * @struts.action path="/authoring" name="authoringForm" parameter="dispatch" scope="request" validate="false" + * + * @struts.action-forward name="success" path="tiles:/authoring/main" + */ +public class AuthoringAction extends LamsDispatchAction { + + private static Logger logger = Logger.getLogger(AuthoringAction.class); + + public ILeaderselectionService leaderselectionService; + + // Authoring SessionMap key names + private static final String KEY_TOOL_CONTENT_ID = "toolContentID"; + private static final String KEY_CONTENT_FOLDER_ID = "contentFolderID"; + private static final String KEY_MODE = "mode"; + + /** + * Default method when no dispatch parameter is specified. It is expected that the parameter + *toolContentID
will be passed in. This will be used to retrieve content for this tool.
+ *
+ */
+ @Override
+ protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
+ HttpServletResponse response) {
+
+ // Extract toolContentID from parameters.
+ Long toolContentID = new Long(WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID));
+
+ String contentFolderID = WebUtil.readStrParam(request, AttributeNames.PARAM_CONTENT_FOLDER_ID);
+
+ ToolAccessMode mode = WebUtil.readToolAccessModeParam(request, "mode", true);
+
+ // set up leaderselectionService
+ if (leaderselectionService == null) {
+ leaderselectionService = LeaderselectionServiceProxy.getLeaderselectionService(this.getServlet()
+ .getServletContext());
+ }
+
+ // retrieving Leaderselection with given toolContentID
+ Leaderselection leaderselection = leaderselectionService.getContentByContentId(toolContentID);
+ if (leaderselection == null) {
+ leaderselection = leaderselectionService.copyDefaultContent(toolContentID);
+ leaderselection.setCreateDate(new Date());
+ leaderselectionService.saveOrUpdateLeaderselection(leaderselection);
+ // 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.
+ leaderselection.setDefineLater(true);
+ leaderselectionService.saveOrUpdateLeaderselection(leaderselection);
+ }
+
+ // Set up the authForm.
+ AuthoringForm authForm = (AuthoringForm) form;
+ authForm.setTitle(leaderselection.getTitle());
+ authForm.setInstructions(leaderselection.getInstructions());
+
+ // Set up sessionMap
+ SessionMap
+
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
+ |
+
Copyright (C) 2006 LAMS Foundation (http://lamsfoundation.org
Index: lams_tool_leader/web/common/header.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_leader/web/common/header.jsp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_leader/web/common/header.jsp 8 Jan 2014 20:13:46 -0000 1.1 @@ -0,0 +1,16 @@ +<%@ include file="/common/taglibs.jsp"%> + ++ ${requestScope.message}; +
Index: lams_tool_leader/web/common/messages.jsp =================================================================== RCS file: /usr/local/cvsroot/lams_tool_leader/web/common/messages.jsp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lams_tool_leader/web/common/messages.jsp 8 Jan 2014 20:13:46 -0000 1.1 @@ -0,0 +1,8 @@ +<%-- Error Messages --%> +
+
+
+
+
+
+
+ |
+
+
+
+ |
+
+
+ +
+ +
+
+
+
+ |
+
+ |
+
+ |
+
+ |
+
+
+ + ${session.sessionName} ++ |
+
+ |
+ + ${session.numberOfLearners} + | +
+ |
+ + ${session.numberOfFinishedLearners} + | +
+ |
+
+ |
+
---|---|
+ ${user.firstName} ${user.lastName} + | +
+ ![]() |
+