Index: lams_central/build.xml =================================================================== diff -u -racc8d2acf5b6b0002e0c8129947040a779ab4077 -r2f5473044ec01bd94a2ea8e5262b2a200f1e6da6 --- lams_central/build.xml (.../build.xml) (revision acc8d2acf5b6b0002e0c8129947040a779ab4077) +++ lams_central/build.xml (.../build.xml) (revision 2f5473044ec01bd94a2ea8e5262b2a200f1e6da6) @@ -186,10 +186,6 @@ - - - - @@ -299,6 +295,10 @@ + + + + @@ -311,9 +311,9 @@ - - - + + + Index: lams_central/src/java/org/lamsfoundation/lams/web/TutorialAction.java =================================================================== diff -u --- lams_central/src/java/org/lamsfoundation/lams/web/TutorialAction.java (revision 0) +++ lams_central/src/java/org/lamsfoundation/lams/web/TutorialAction.java (revision 2f5473044ec01bd94a2ea8e5262b2a200f1e6da6) @@ -0,0 +1,173 @@ +/**************************************************************** + * 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.web; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +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.actions.DispatchAction; +import org.lamsfoundation.lams.usermanagement.User; +import org.lamsfoundation.lams.usermanagement.dto.UserDTO; +import org.lamsfoundation.lams.usermanagement.service.IUserManagementService; +import org.lamsfoundation.lams.util.WebUtil; +import org.lamsfoundation.lams.web.session.SessionManager; +import org.lamsfoundation.lams.web.util.AttributeNames; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; + +/** + * Manages tutorial videos - the ones displayed on top of pages, explaining how to use certain features of LAMS. + * + * @struts:action path="/tutorial" parameter="method" + */ +public class TutorialAction extends DispatchAction { + private static Logger log = Logger.getLogger(TutorialAction.class); + + private static IUserManagementService service; + + /** + * Invoked when an user chose not to show a certain video again. + * + * @param mapping + * @param form + * @param req + * @param res + * @return + */ + public ActionForward disableSingleTutorialVideo(ActionMapping mapping, ActionForm form, HttpServletRequest req, + HttpServletResponse res) { + + String pageString = WebUtil.readStrParam(req, AttributeNames.ATTR_PAGE_STR); + + HttpSession ss = SessionManager.getSession(); + UserDTO userDTO = (UserDTO) ss.getAttribute(AttributeNames.USER); + User user = getService().getUserByLogin(userDTO.getLogin()); + + user.getPagesWithDisabledTutorials().add(pageString); + getService().save(user); + + ss.removeAttribute(AttributeNames.USER); + ss.setAttribute(AttributeNames.USER, user.getUserDTO()); + + return null; + } + + /** + * Invoked when an user asked to show a certain video again. + * + * @param mapping + * @param form + * @param req + * @param res + * @return + */ + public ActionForward enableSingleTutorialVideo(ActionMapping mapping, ActionForm form, HttpServletRequest req, + HttpServletResponse res) { + + String pageString = WebUtil.readStrParam(req, AttributeNames.ATTR_PAGE_STR); + + HttpSession ss = SessionManager.getSession(); + UserDTO userDTO = (UserDTO) ss.getAttribute(AttributeNames.USER); + User user = getService().getUserByLogin(userDTO.getLogin()); + + user.getPagesWithDisabledTutorials().remove(pageString); + getService().save(user); + + ss.removeAttribute(AttributeNames.USER); + ss.setAttribute(AttributeNames.USER, user.getUserDTO()); + + return null; + } + + /** + * Gets the value for "Do not show again" checkbox for a cerain video. + * + * @param mapping + * @param form + * @param req + * @param res + * @return + * @throws IOException + */ + public ActionForward getDoNotShowAgainValue(ActionMapping mapping, ActionForm form, HttpServletRequest req, + HttpServletResponse res) throws IOException { + + String pageString = WebUtil.readStrParam(req, AttributeNames.ATTR_PAGE_STR); + + HttpSession ss = SessionManager.getSession(); + UserDTO userDTO = (UserDTO) ss.getAttribute(AttributeNames.USER); + + Boolean doNotShowAgain = userDTO.getPagesWithDisabledTutorials() != null + && userDTO.getPagesWithDisabledTutorials().contains(pageString); + res.setContentType("text/plain"); + PrintWriter writer = res.getWriter(); + writer.println(doNotShowAgain.toString()); + + return null; + } + + /** + * Turns off tutorials. Same as going to user profile and turning them off. Used for dialog displayed after user's + * first login. + * + * @param mapping + * @param form + * @param req + * @param res + * @return + * @throws IOException + */ + public ActionForward disableAllTutorialVideos(ActionMapping mapping, ActionForm form, HttpServletRequest req, + HttpServletResponse res) throws IOException { + + HttpSession ss = SessionManager.getSession(); + UserDTO userDTO = (UserDTO) ss.getAttribute(AttributeNames.USER); + User user = getService().getUserByLogin(userDTO.getLogin()); + + user.setTutorialsDisabled(true); + getService().save(user); + + ss.removeAttribute(AttributeNames.USER); + ss.setAttribute(AttributeNames.USER, user.getUserDTO()); + + return null; + } + + private IUserManagementService getService() { + if (TutorialAction.service == null) { + WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(getServlet() + .getServletContext()); + TutorialAction.service = (IUserManagementService) ctx.getBean("userManagementService"); + } + return TutorialAction.service; + } +} \ No newline at end of file Index: lams_central/web/editprofile.jsp =================================================================== diff -u -r4f33380083bd35fd6d0851de9def290c62ffc3c9 -r2f5473044ec01bd94a2ea8e5262b2a200f1e6da6 --- lams_central/web/editprofile.jsp (.../editprofile.jsp) (revision 4f33380083bd35fd6d0851de9def290c62ffc3c9) +++ lams_central/web/editprofile.jsp (.../editprofile.jsp) (revision 2f5473044ec01bd94a2ea8e5262b2a200f1e6da6) @@ -113,7 +113,6 @@ - : @@ -275,7 +274,7 @@ - + : Index: lams_central/web/includes/javascript/thickbox.patched.js =================================================================== diff -u -r4f33380083bd35fd6d0851de9def290c62ffc3c9 -r2f5473044ec01bd94a2ea8e5262b2a200f1e6da6 --- lams_central/web/includes/javascript/thickbox.patched.js (.../thickbox.patched.js) (revision 4f33380083bd35fd6d0851de9def290c62ffc3c9) +++ lams_central/web/includes/javascript/thickbox.patched.js (.../thickbox.patched.js) (revision 2f5473044ec01bd94a2ea8e5262b2a200f1e6da6) @@ -5,7 +5,7 @@ * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php */ -var tb_pathToImage = pathToImageFolder + "loadingAnimation.gif"; +var tb_pathToImage = "images/loadingAnimation.gif"; // fixed according to: http://jamazon.co.uk/web/2008/03/14/jquerybrowserversion-doesnt-recognise-ie7/ $.browser.msie6 = @@ -72,12 +72,8 @@ var urlString = /\.jpg$|\.jpeg$|\.png$|\.gif$|\.bmp$/; var urlType = baseURL.toLowerCase().match(urlString); - var queryString = url.replace(/^[^\?]+\??/,''); - var params = tb_parseQuery( queryString ); - - - if((!params['TB_iframe'])){//code to show images - + if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp'){//code to show images + TB_PrevCaption = ""; TB_PrevURL = ""; TB_PrevHTML = ""; @@ -115,10 +111,8 @@ var pagesize = tb_getPageSize(); var x = pagesize[0] - 150; var y = pagesize[1] - 150; - var imageWidth = (jQuery.browser.msie) ? parseInt(params['dbWidth']) : imgPreloader.width; - var initialImageWidth = imageWidth; - var imageHeight = (jQuery.browser.msie) ? parseInt(params['dbHeight']) : imgPreloader.height; - var initialImageHeight = imageHeight; + var imageWidth = imgPreloader.width; + var imageHeight = imgPreloader.height; if (imageWidth > x) { imageHeight = imageHeight * (x / imageWidth); imageWidth = x; @@ -138,13 +132,8 @@ TB_WIDTH = imageWidth + 30; TB_HEIGHT = imageHeight + 60; - - if ((initialImageWidth > x) ||(initialImageHeight > y)) { - $("#TB_window").append("" + "
"+caption+"
" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "
close or Esc Key
"); - } else { - $("#TB_window").append(""+caption+"" + "
"+caption+"
" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "
close or Esc Key
"); - } - + $("#TB_window").append(""+caption+"" + "
"+caption+"
" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "
close or Esc Key
"); + $("#TB_closeWindowButton").click(tb_remove); if (!(TB_PrevHTML === "")) { @@ -198,6 +187,9 @@ imgPreloader.src = url; }else{//code to show html + + var queryString = url.replace(/^[^\?]+\??/,''); + var params = tb_parseQuery( queryString ); TB_WIDTH = (params['width']*1) + 30 || 630; //defaults to 630 if no paramaters were added to URL TB_HEIGHT = (params['height']*1) + 40 || 440; //defaults to 440 if no paramaters were added to URL @@ -207,16 +199,11 @@ if(url.indexOf('TB_iframe') != -1){// either iframe or ajax window urlNoQuery = url.split('TB_'); $("#TB_iframeContent").remove(); - - var resize = ""; - if(params['resizeIframe']){ - resize = "resizeIframe();" - } if(params['modal'] != "true"){//iframe no modal - $("#TB_window").append("
"+caption+"
close or Esc Key
"); + $("#TB_window").append("
"+caption+"
close or Esc Key
"); }else{//iframe modal $("#TB_overlay").unbind(); - $("#TB_window").append(""); + $("#TB_window").append(""); } }else{// not an iframe, ajax if($("#TB_window").css("display") != "block"){ @@ -337,6 +324,4 @@ if (userAgent.indexOf('mac') != -1 && userAgent.indexOf('firefox')!=-1) { return true; } -} - - +} \ No newline at end of file Index: lams_central/web/tutorialVideo.jsp =================================================================== diff -u --- lams_central/web/tutorialVideo.jsp (revision 0) +++ lams_central/web/tutorialVideo.jsp (revision 2f5473044ec01bd94a2ea8e5262b2a200f1e6da6) @@ -0,0 +1,102 @@ +<%@ taglib uri="tags-fmt" prefix="fmt"%> +<%@ taglib uri="tags-core" prefix="c" %> +<%@ taglib uri="tags-lams" prefix="lams" %> + + + + + + + + + + + + + + +

${param.title}

+
+ + + + + + + + + + + + + + + + + +
+

The Camtasia Studio video content presented here requires a more recent version of the Adobe Flash Player. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by downloading here.

+
+ +
+ +
+
+
+ +
+ + + \ No newline at end of file Index: lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch0017_updateFrom23-231.sql =================================================================== diff -u -r2f21856ec2ab85b47c93cfcc3fa2c8769be65077 -r2f5473044ec01bd94a2ea8e5262b2a200f1e6da6 --- lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch0017_updateFrom23-231.sql (.../patch0017_updateFrom23-231.sql) (revision 2f21856ec2ab85b47c93cfcc3fa2c8769be65077) +++ lams_common/src/java/org/lamsfoundation/lams/dbupdates/patch0017_updateFrom23-231.sql (.../patch0017_updateFrom23-231.sql) (revision 2f5473044ec01bd94a2ea8e5262b2a200f1e6da6) @@ -22,6 +22,17 @@ CONSTRAINT lams_ext_server_tool_map_fk2 FOREIGN KEY (tool_id) REFERENCES lams_tool (tool_id) ON DELETE CASCADE ON UPDATE CASCADE ) TYPE=InnoDB; +-- LDEV-2369 Add tutorial video support +ALTER TABLE lams_user ADD COLUMN tutorials_disabled TINYINT(1) DEFAULT 0, + ADD COLUMN first_login TINYINT(1) DEFAULT 1; + +CREATE TABLE lams_user_disabled_tutorials ( + user_id BIGINT(20) NOT NULL, + page_str CHAR(5) NOT NULL, + CONSTRAINT FK_lams_user_disabled_tutorials_1 FOREIGN KEY (user_id) REFERENCES lams_user (user_id) ON DELETE CASCADE ON UPDATE CASCADE, + PRIMARY KEY (user_id,page_str) +)TYPE=InnoDB; + ----------------------Put all sql statements above here------------------------- -- If there were no errors, commit and restore autocommit to on