Index: lams_webct_integration/DeployableComponentConfig.xml =================================================================== diff -u -r2654d999eb449c7c2223997b0386cb8798186646 -r1e48e51fc873467eef72ce5af99d865c5a0d818c --- lams_webct_integration/DeployableComponentConfig.xml (.../DeployableComponentConfig.xml) (revision 2654d999eb449c7c2223997b0386cb8798186646) +++ lams_webct_integration/DeployableComponentConfig.xml (.../DeployableComponentConfig.xml) (revision 1e48e51fc873467eef72ce5af99d865c5a0d818c) @@ -4,7 +4,7 @@ - 0.0.12 + 0.0.13 1.0 lams.integration @@ -191,6 +191,15 @@ optional="false" read-only="false" default-value="@reqSrc@" /> + + Index: lams_webct_integration/build.properties =================================================================== diff -u -r2654d999eb449c7c2223997b0386cb8798186646 -r1e48e51fc873467eef72ce5af99d865c5a0d818c --- lams_webct_integration/build.properties (.../build.properties) (revision 2654d999eb449c7c2223997b0386cb8798186646) +++ lams_webct_integration/build.properties (.../build.properties) (revision 1e48e51fc873467eef72ce5af99d865c5a0d818c) @@ -32,4 +32,6 @@ # Resuest source name for your WebCt server reqSrc=WebCt +# Url location of image folder containing the images for this integration +imgUrl=/webct/images/ ############################# \ No newline at end of file Index: lams_webct_integration/build.xml =================================================================== diff -u -r2654d999eb449c7c2223997b0386cb8798186646 -r1e48e51fc873467eef72ce5af99d865c5a0d818c --- lams_webct_integration/build.xml (.../build.xml) (revision 2654d999eb449c7c2223997b0386cb8798186646) +++ lams_webct_integration/build.xml (.../build.xml) (revision 1e48e51fc873467eef72ce5af99d865c5a0d818c) @@ -79,13 +79,26 @@ + - + - + + + + + + + + + + + + + @@ -107,6 +120,8 @@ + + Index: lams_webct_integration/db/sql/createTable.sql =================================================================== diff -u -r2654d999eb449c7c2223997b0386cb8798186646 -r1e48e51fc873467eef72ce5af99d865c5a0d818c --- lams_webct_integration/db/sql/createTable.sql (.../createTable.sql) (revision 2654d999eb449c7c2223997b0386cb8798186646) +++ lams_webct_integration/db/sql/createTable.sql (.../createTable.sql) (revision 1e48e51fc873467eef72ce5af99d865c5a0d818c) @@ -19,7 +19,7 @@ [hidden] [bit] NOT NULL CONSTRAINT [DF_LAMS_LESSON_hidden] DEFAULT ((0)), [schedule] [bit] NOT NULL CONSTRAINT [DF_LAMS_LESSON_schedule] DEFAULT ((0)), [start_date_time] [datetime] NULL, - [end_date_time] [nchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL, + [end_date_time] [datetime] NULL, CONSTRAINT [PK_LAMS_LESSON] PRIMARY KEY CLUSTERED ( [lesson_id] ASC Index: lams_webct_integration/src/org/lamsfoundation/integration/dao/LamsLessonDaoJDBC.java =================================================================== diff -u -r4865b414bb4cd9300d03e34944495747361432ad -r1e48e51fc873467eef72ce5af99d865c5a0d818c --- lams_webct_integration/src/org/lamsfoundation/integration/dao/LamsLessonDaoJDBC.java (.../LamsLessonDaoJDBC.java) (revision 4865b414bb4cd9300d03e34944495747361432ad) +++ lams_webct_integration/src/org/lamsfoundation/integration/dao/LamsLessonDaoJDBC.java (.../LamsLessonDaoJDBC.java) (revision 1e48e51fc873467eef72ce5af99d865c5a0d818c) @@ -5,6 +5,7 @@ import java.sql.SQLException; import java.sql.Statement; import java.sql.ResultSet; +import java.sql.Timestamp; import java.util.ArrayList; import org.apache.log4j.Logger; @@ -134,8 +135,8 @@ lesson.setOwnerLastName(rs.getString("owner_last_name")); lesson.setHidden(rs.getBoolean("hidden")); lesson.setSchedule(rs.getBoolean("schedule")); - lesson.setStartDate(rs.getDate("start_date_time")); - lesson.setEndDate(rs.getDate("end_date_time")); + lesson.setStartTimestamp(rs.getTimestamp("start_date_time")); + lesson.setEndTimestamp(rs.getTimestamp("end_date_time")); lessons.add(lesson); } @@ -151,6 +152,83 @@ return lessons; } + public ArrayList getDBLessonsForLearner(long learningContextId, + long ptId, + Timestamp now) throws Exception + { + ArrayList lessons = new ArrayList(); + Connection connection; + try + { + connection = getConnection(); + Statement stmt = connection.createStatement(); + + String query = "SELECT [lesson_id]," + + "[learning_context_id]," + + "[sequence_id]," + + "[owner_id]," + + "[owner_first_name]," + + "[owner_last_name]," + + "[title]," + + "[description]," + + "[hidden]," + + "[schedule]," + + "[start_date_time]," + + "[end_date_time] " + + "FROM [webctdatabase].[dbo].[LAMS_LESSON] " + + "WHERE " + + "(" + + "(learning_context_id=" +learningContextId+ ") " + + "AND (pt_id=" +ptId+ ") " + + "AND (hidden='false') " + + "AND (" + + "(schedule='false') " + + "OR (" + + "(start_date_time <= '" +now.toString()+ "') " + + "AND (end_date_time >='" +now.toString()+ "\')" + + ")" + + "OR (" + + "(start_date_time <= '" +now.toString()+ "') " + + "AND (end_date_time IS null)" + + ")" + + ")" + + ")"; + + + System.out.println("SQL INSERT: " +query); + + ResultSet rs = stmt.executeQuery(query); + + while (rs.next()) + { + LamsLesson lesson = new LamsLesson(); + lesson.setLessonId(rs.getLong("lesson_id")); + lesson.setLearningContextId(rs.getLong("learning_context_id")); + lesson.setSequenceId(rs.getLong("sequence_id")); + lesson.setTitle(rs.getString("title")); + lesson.setDescription(rs.getString("description")); + lesson.setOwnerId(rs.getString("owner_id")); + lesson.setOwnerFirstName(rs.getString("owner_first_name")); + lesson.setOwnerLastName(rs.getString("owner_last_name")); + lesson.setHidden(rs.getBoolean("hidden")); + lesson.setSchedule(rs.getBoolean("schedule")); + lesson.setStartTimestamp(rs.getTimestamp("start_date_time")); + lesson.setEndTimestamp(rs.getTimestamp("end_date_time")); + + lessons.add(lesson); + } + + stmt.close(); + connection.close(); + } + catch (SQLException e) + { + log.error("Failed to get a list of LAMS lessons.", e); + throw new Exception ("Failed to get a list of LAMS lessons."); + } + return lessons; + } + public boolean createDbLesson(LamsLesson lesson) throws Exception { Connection connection; @@ -163,6 +241,24 @@ if (lesson.getHidden()) {hidden=1;} if (lesson.getSchedule()) {schedule=1;} + String startTimeStamp = "null"; + if (lesson.getStartTimestamp()!=null) + { + startTimeStamp = "\'" +lesson.getStartTimestamp(); + startTimeStamp = startTimeStamp.replaceAll("-", "") + "\'"; + } + + String endTimeStamp = "null"; + if (lesson.getEndTimestamp()!=null) + { + endTimeStamp = "\'" + lesson.getEndTimestamp(); + endTimeStamp = endTimeStamp.replaceAll("-", "") + "\'"; + } + + System.out.println("START: " +startTimeStamp); + System.out.println("END: " +endTimeStamp); + + try { connection = getConnection(); @@ -195,8 +291,8 @@ "\'" +lesson.getDescription()+ "\'," + "" +hidden+ ","+ "" +schedule+ "," + - "\'" +lesson.getStartDate()+ "\'," + - "\'" +lesson.getEndDate()+ "\')"; + "" +startTimeStamp+ "," + + "" +endTimeStamp+ ")"; System.out.println("SQL INSERT: " +insert); @@ -227,6 +323,15 @@ connection = getConnection(); Statement stmt = connection.createStatement(); + String startTimeStamp = "null"; + if (lesson.getStartTimestamp()!=null) + startTimeStamp = lesson.getStartTimestamp().toString().replaceAll("-", ""); + + String endTimeStamp = "null"; + if (lesson.getEndTimestamp()!=null) + endTimeStamp = lesson.getEndTimestamp().toString().replaceAll("-", ""); + + String update="UPDATE [webctdatabase].[dbo].[LAMS_LESSON]" + " SET [pt_id] = " +lesson.getPtId()+ ",[learning_context_id] = " +lesson.getLearningContextId()+ @@ -238,10 +343,10 @@ ",[description] = \'" +lesson.getDescription()+ "\'" + ",[hidden] = \'" +lesson.getHidden()+ "\'" + ",[schedule] = \'" +lesson.getSchedule()+ "\'" + - ",[start_date_time] = \'" +lesson.getStartDate()+ "\'" + - ",[end_date_time] = \'" +lesson.getEndDate()+ "\' " + + ",[start_date_time] = \'" +startTimeStamp+ "\'" + + ",[end_date_time] = \'" +endTimeStamp+ "\' " + "WHERE [lesson_id] = " + lesson.getLessonId(); - + System.out.println("UPDATE: " + update); rows = stmt.executeUpdate(update); @@ -335,8 +440,8 @@ lesson.setOwnerLastName(rs.getString("owner_last_name")); lesson.setHidden(rs.getBoolean("hidden")); lesson.setSchedule(rs.getBoolean("schedule")); - lesson.setStartDate(rs.getDate("start_date_time")); - lesson.setEndDate(rs.getDate("end_date_time")); + lesson.setStartTimestamp(rs.getTimestamp("start_date_time")); + lesson.setEndTimestamp(rs.getTimestamp("end_date_time")); stmt.close(); connection.close(); Index: lams_webct_integration/src/org/lamsfoundation/integration/util/Constants.java =================================================================== diff -u -r2654d999eb449c7c2223997b0386cb8798186646 -r1e48e51fc873467eef72ce5af99d865c5a0d818c --- lams_webct_integration/src/org/lamsfoundation/integration/util/Constants.java (.../Constants.java) (revision 2654d999eb449c7c2223997b0386cb8798186646) +++ lams_webct_integration/src/org/lamsfoundation/integration/util/Constants.java (.../Constants.java) (revision 1e48e51fc873467eef72ce5af99d865c5a0d818c) @@ -29,6 +29,9 @@ */ public class Constants { + public static final String DEFAULT_LANGUAGE="en"; + public static final String DEFAULT_COUNTRY="US"; + public static final String PARAM_USER_ID = "uid"; public static final String PARAM_SERVER_ID = "sid"; public static final String PARAM_TIMESTAMP = "ts"; Index: lams_webct_integration/src/org/lamsfoundation/integration/webct/LamsLesson.java =================================================================== diff -u -r2654d999eb449c7c2223997b0386cb8798186646 -r1e48e51fc873467eef72ce5af99d865c5a0d818c --- lams_webct_integration/src/org/lamsfoundation/integration/webct/LamsLesson.java (.../LamsLesson.java) (revision 2654d999eb449c7c2223997b0386cb8798186646) +++ lams_webct_integration/src/org/lamsfoundation/integration/webct/LamsLesson.java (.../LamsLesson.java) (revision 1e48e51fc873467eef72ce5af99d865c5a0d818c) @@ -1,7 +1,7 @@ package org.lamsfoundation.integration.webct; -import java.sql.Date; +import java.sql.Timestamp; /** @@ -23,8 +23,8 @@ private String ownerLastName; // webct user second name private boolean hidden; // only visible to owner if true private boolean schedule; - private Date startDate; - private Date endDate; + private Timestamp startTimestamp; + private Timestamp endTimestamp; @@ -57,8 +57,8 @@ String ownerLastName, boolean hidden, boolean schedule, - Date startDate, - Date endDate) + Timestamp startTimestamp, + Timestamp endTimestamp) { this.lessonId = lessonId; this.ptId = ptId; @@ -71,8 +71,8 @@ this.ownerLastName = ownerLastName; this.hidden = hidden; this.schedule = schedule; - this.startDate = startDate; - this.endDate = endDate; + this.startTimestamp = startTimestamp; + this.endTimestamp = endTimestamp; } @@ -125,17 +125,17 @@ public void setSchedule(boolean schedule) { this.schedule = schedule; } - public Date getStartDate() { - return startDate; + public Timestamp getStartTimestamp() { + return startTimestamp; } - public void setStartDate(Date startDate) { - this.startDate = startDate; + public void setStartTimestamp(Timestamp startTimestamp) { + this.startTimestamp = startTimestamp; } - public Date getEndDate() { - return endDate; + public Timestamp getEndTimestamp() { + return endTimestamp; } - public void setEndDate(Date endDate) { - this.endDate = endDate; + public void setEndTimestamp(Timestamp endTimestamp) { + this.endTimestamp = endTimestamp; } public long getLearningContextId() { @@ -179,8 +179,8 @@ + "ownerLastName = " + this.ownerLastName + TAB + "hidden = " + this.hidden + TAB + "schedule = " + this.schedule + TAB - + "startDate = " + this.startDate + TAB - + "endDate = " + this.endDate + TAB + + "startTimestamp = " + this.startTimestamp + TAB + + "endTimestamp = " + this.endTimestamp + TAB + " )"; return retValue; Index: lams_webct_integration/src/org/lamsfoundation/integration/webct/LamsModule.java =================================================================== diff -u -r4865b414bb4cd9300d03e34944495747361432ad -r1e48e51fc873467eef72ce5af99d865c5a0d818c --- lams_webct_integration/src/org/lamsfoundation/integration/webct/LamsModule.java (.../LamsModule.java) (revision 4865b414bb4cd9300d03e34944495747361432ad) +++ lams_webct_integration/src/org/lamsfoundation/integration/webct/LamsModule.java (.../LamsModule.java) (revision 1e48e51fc873467eef72ce5af99d865c5a0d818c) @@ -8,38 +8,24 @@ import java.util.Iterator; import java.util.Map; import java.util.List; -import java.util.ArrayList; import java.util.Properties; import javax.security.auth.Subject; import javax.security.auth.callback.CallbackHandler; +import java.sql.Date; +import java.sql.Timestamp; import javax.security.auth.login.LoginException; import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import com.webct.platform.sdk.context.gen.*; -import com.webct.platform.sdk.context.client.*; + + import com.webct.platform.sdk.security.authentication.module.AuthenticationModule; -import com.webct.platform.sdk.proxytool.common.ProcessCallback; -import com.webct.platform.sdk.security.authentication.module.WebCTSSOContext; -import com.webct.platform.sdk.context.client.ContextSDK; -import com.webct.platform.sdk.context.gen.SessionVO; -import com.webct.platform.sdk.context.gen.LearningCtxtVO; import com.webct.platform.sdkext.authmoduledata.*; -import com.webct.platform.sdk.context.gen.SessionVO; -//-------- Velocity imports -------------- -import java.io.StringWriter; -import java.rmi.RemoteException; -import java.sql.Date; import org.apache.velocity.VelocityContext; import org.apache.velocity.Template; import org.apache.velocity.app.VelocityEngine; -import org.apache.velocity.exception.*; -//import org.apache.axis.AxisFault; - -import java.net.URL; import org.apache.log4j.Logger; import org.lamsfoundation.integration.webct.LamsSecurityUtil; @@ -229,7 +215,10 @@ // test //List lessons = lessonDao.getDBLessons(1); - List lessons = lessonDao.getDBLessons(lcID.longValue(), Long.parseLong(ptid)); + java.util.Date today = new java.util.Date(); + Timestamp now = new Timestamp(today.getTime()); + + List lessons = lessonDao.getDBLessonsForLearner(lcID.longValue(), Long.parseLong(ptid), now); params.put("lessons", lessons); @@ -306,8 +295,8 @@ webctRequestSource, user.getUserId(), "" + seqID, - "en", - "US", + Constants.DEFAULT_LANGUAGE, + Constants.DEFAULT_COUNTRY, user.getFirstname(), user.getLastname(), user.getEmail(), @@ -323,7 +312,30 @@ } else { - LamsLessonDaoJDBC lessonDao = new LamsLessonDaoJDBC(settings); + Timestamp start = null; + Timestamp end = null; + + if (request.getParameter("schedule").equals("true")) + { + if (request.getParameter("dateStart")!=null && !request.getParameter("dateStart").equals("")) + { + start = getTimeStamp(request.getParameter("dateStart"), + request.getParameter("startHour"), + request.getParameter("startMin"), + request.getParameter("startAMPM")); + } + + if (request.getParameter("dateEnd")!=null && !request.getParameter("dateEnd").equals("")) + { + + end = getTimeStamp(request.getParameter("dateEnd"), + request.getParameter("endHour"), + request.getParameter("endMin"), + request.getParameter("endAMPM")); + } + } + + LamsLessonDaoJDBC lessonDao = new LamsLessonDaoJDBC(settings); LamsLesson lesson = new LamsLesson( lsID, Long.parseLong(ptid), @@ -334,10 +346,10 @@ user.getUserId(), user.getFirstname(), user.getLastname(), - false, - false, - new Date(0), - new Date(0) + request.getParameter("isAvailable").equals("false"), + request.getParameter("schedule").equals("true"), + start, + end ); try{ @@ -388,8 +400,8 @@ webctRequestSource, user.getUserId(), "" + lcID, - "en", - "US", + Constants.DEFAULT_LANGUAGE, + Constants.DEFAULT_COUNTRY, user.getFirstname(), user.getLastname(), user.getEmail(), @@ -419,8 +431,8 @@ params.put("lsID", request.getParameter("lsID")); params.put("title", modLesson.getTitle()); params.put("description", modLesson.getDescription()); - params.put("start", modLesson.getStartDate()); - params.put("end", modLesson.getEndDate()); + params.put("start", modLesson.getStartTimestamp()); + params.put("end", modLesson.getEndTimestamp()); if (modLesson.getHidden()) @@ -470,10 +482,6 @@ modLesson.setSchedule(request.getParameter("schedule").equals("true")); - //TODO: DO SOMETHING ABOUT DATES - //Date start = new Date(0); - //Date end = new Date(0); - boolean success = lessonDao.updateLesson(modLesson); @@ -551,8 +559,8 @@ webctRequestSource, user.getUserId(), "" + lcID, - "en", - "AU", + Constants.DEFAULT_LANGUAGE, + Constants.DEFAULT_COUNTRY, user.getFirstname(), user.getLastname(), user.getEmail(), @@ -583,8 +591,8 @@ lamsServerSecretKey, user.getUserId(), "" + lcID, - "en", - "AU", + Constants.DEFAULT_LANGUAGE, + Constants.DEFAULT_COUNTRY, user.getFirstname(), user.getLastname(), user.getEmail(), @@ -604,7 +612,29 @@ } } - + public Timestamp getTimeStamp(String date, String hours, String minutes, String ampm) + { + + String dateSplit[] = date.split("/"); + + date = dateSplit[2] + "-" + dateSplit[1] + "-" + dateSplit[0]; + + if (ampm.equals("PM")) + { + int hoursInt = Integer.parseInt(hours); + hoursInt += 12; + hours = "" + hoursInt; + } + + String timestampStr = date + " " + hours + ":" + minutes + ":" + "00"; + System.out.println("TIMESTAMP: " + timestampStr); + + + Timestamp t = Timestamp.valueOf(timestampStr); + System.out.println("TIMESTAMP To String: " + t.toString()); + return t; + + } public boolean logout() throws LoginException { return super.logout(); Index: lams_webct_integration/web/create.vm =================================================================== diff -u -r7270334471e73c186bfa26adeec6d7575dcbdbca -r1e48e51fc873467eef72ce5af99d865c5a0d818c --- lams_webct_integration/web/create.vm (.../create.vm) (revision 7270334471e73c186bfa26adeec6d7575dcbdbca) +++ lams_webct_integration/web/create.vm (.../create.vm) (revision 1e48e51fc873467eef72ce5af99d865c5a0d818c) @@ -25,14 +25,31 @@ LAMS: Start Lesson + +