Index: lams_webct_integration/src/org/lamsfoundation/integration/webct/LamsModule.java =================================================================== diff -u -r2654d999eb449c7c2223997b0386cb8798186646 -rca43ebd62595ee69242f85efc7be18aeb4af08c0 --- lams_webct_integration/src/org/lamsfoundation/integration/webct/LamsModule.java (.../LamsModule.java) (revision 2654d999eb449c7c2223997b0386cb8798186646) +++ lams_webct_integration/src/org/lamsfoundation/integration/webct/LamsModule.java (.../LamsModule.java) (revision ca43ebd62595ee69242f85efc7be18aeb4af08c0) @@ -185,7 +185,7 @@ String action = request.getParameter("form_action"); - if(action==null || action.trim().length()==0 ||action.equals("preview")) + if(action==null || action.trim().length()==0) { try{ @@ -251,23 +251,6 @@ authorUrl = generateRequestURL(user, lcID, "author"); params.put("authorUrl", authorUrl); - - - String previewUrl = LamsSecurityUtil.generatePreviewUrl( - lamsServerUrl, - lamsServerId, - lamsServerSecretKey, - webctRequestSource, - user.getUserId(), - "" +lcID, - "en", - "US", - user.getFirstname(), - user.getLastname(), - user.getEmail()); - params.put("previewUrl", previewUrl); - - // get the learning designs to display the workspace tree learningDesigns = getLearningDesigns(user, lcID); params.put("learningDesigns", learningDesigns); @@ -330,7 +313,8 @@ user.getEmail(), seqID, title, - description); + description, + "start"); if (lsID==-1) @@ -382,6 +366,49 @@ throw new LoginException("Error creating LAMS lesson created page: " + e.getMessage()); } } + else if(action.equals("preview")) + { + String title = request.getParameter("title"); + String description = request.getParameter("description"); + String ldID = request.getParameter("sequence_id"); + + if (ldID==null || ldID.equals("")) + { + throw new LoginException("Bad preview request."); + } + + if (title==null) {title="";} + if (description==null) {description="";} + + try{ + long pvID = LamsSecurityUtil.startLesson( + lamsServerUrl, + lamsServerId, + lamsServerSecretKey, + webctRequestSource, + user.getUserId(), + "" + lcID, + "en", + "US", + user.getFirstname(), + user.getLastname(), + user.getEmail(), + ldID, + title, + description, + "preview"); + + String previewUrl = generateRequestURL(user, lcID, "learner") + "&lsid=" +pvID; + System.out.println("PREVIEW URL: " + previewUrl); + super.setRedirectUrl(previewUrl); + } + catch (Exception e) + { + log.error("Error generating LAMS preview", e); + throw new LoginException("Error generating LAMS preview"); + } + return true; + } super.setResponseContent(html); Index: lams_webct_integration/src/org/lamsfoundation/integration/webct/LamsSecurityUtil.java =================================================================== diff -u -r2654d999eb449c7c2223997b0386cb8798186646 -rca43ebd62595ee69242f85efc7be18aeb4af08c0 --- lams_webct_integration/src/org/lamsfoundation/integration/webct/LamsSecurityUtil.java (.../LamsSecurityUtil.java) (revision 2654d999eb449c7c2223997b0386cb8798186646) +++ lams_webct_integration/src/org/lamsfoundation/integration/webct/LamsSecurityUtil.java (.../LamsSecurityUtil.java) (revision ca43ebd62595ee69242f85efc7be18aeb4af08c0) @@ -247,7 +247,8 @@ String email, String ldId, String title, - String desc) + String desc, + String method) { long error = -1; if (serverId == null || serverAddr == null || secretKey == null ) { @@ -271,7 +272,7 @@ + "&ldId=" + ldId + "&country=" + country + "&lang=" + lang - + "&method=" + "start" + + "&method=" + method + "&title=" + URLEncoder.encode(title, "utf8").trim() + "&desc=" + URLEncoder.encode(desc, "utf8").trim(); @@ -338,7 +339,7 @@ } } - + /* public static String generatePreviewUrl( String serverAddr, String serverId, @@ -350,7 +351,10 @@ String country, String firstName, String lastName, - String email + String email, + String title, + String description, + String ldID ) throws Exception { String url=""; @@ -377,6 +381,9 @@ + "&firstName=" + firstName + "&lastName=" + lastName + "&email=" + email + + "&title=" + title + + "&description=" + description + + "&ldId=" + ldID + "&method=preview"; } catch (UnsupportedEncodingException e) { throw new RuntimeException(); @@ -386,7 +393,7 @@ System.out.println("PREVIEW: " + url); return url; - } + }*/ /** Index: lams_webct_integration/web/create.vm =================================================================== diff -u -r2654d999eb449c7c2223997b0386cb8798186646 -rca43ebd62595ee69242f85efc7be18aeb4af08c0 --- lams_webct_integration/web/create.vm (.../create.vm) (revision 2654d999eb449c7c2223997b0386cb8798186646) +++ lams_webct_integration/web/create.vm (.../create.vm) (revision ca43ebd62595ee69242f85efc7be18aeb4af08c0) @@ -84,7 +84,6 @@ url = '${url}?sequence_id=' +document.getElementById("sequence_id").value+ '&${id_param_name}=${pt_id}&page_id=${page_id}&form_action=preview'; - alert(url); window.open(url,'LAMS-Preview','height=600,width=800,resizable'); return true;