[Ils-source] r1589 - in trunk: db/mssql src/com/resolutions/ils/data webapp

scribe at crosswire.org scribe at crosswire.org
Mon Jul 16 16:35:06 MST 2018


Author: scribe
Date: 2018-07-16 16:35:06 -0700 (Mon, 16 Jul 2018)
New Revision: 1589

Modified:
   trunk/db/mssql/upgrade1.82.0-1.sql
   trunk/src/com/resolutions/ils/data/Course.java
   trunk/src/com/resolutions/ils/data/CourseAttempt.java
   trunk/webapp/admin_coursenew.jsp
   trunk/webapp/admin_studentrecords.jsp
   trunk/webapp/aicc.jsp
   trunk/webapp/report_employeecourseatt.jsp
Log:
Added capture of course attempt seat time ILS-117
Added course extra config params which are configurable in course edit pane and passed to course on startup


Modified: trunk/db/mssql/upgrade1.82.0-1.sql
===================================================================
--- trunk/db/mssql/upgrade1.82.0-1.sql	2018-07-16 19:47:33 UTC (rev 1588)
+++ trunk/db/mssql/upgrade1.82.0-1.sql	2018-07-16 23:35:06 UTC (rev 1589)
@@ -1 +1,3 @@
-alter table USERPROFILE add USERPMGRCOMPLEMAILSOVERRIDE char(1) DEFAULT 'F';
+ALTER TABLE USERPROFILE ADD USERPMGRCOMPLEMAILSOVERRIDE CHAR(1) DEFAULT 'F';
+ALTER TABLE COURSE ADD COURSEXTRAPARAMS VARCHAR(255) DEFAULT NULL;
+ALTER TABLE COURSEATTEMPT ADD CASEATSECONDS INTEGER DEFAULT 0;

Modified: trunk/src/com/resolutions/ils/data/Course.java
===================================================================
--- trunk/src/com/resolutions/ils/data/Course.java	2018-07-16 19:47:33 UTC (rev 1588)
+++ trunk/src/com/resolutions/ils/data/Course.java	2018-07-16 23:35:06 UTC (rev 1589)
@@ -466,6 +466,17 @@
 		return getNiceTimeText(getCourseSeatMinutes());
 	}
 
+	public String getCourseExtraParams() {
+		String val = getStringValue("COURSEXTRAPARAMS");
+		if (val != null && val.trim().length() == 0) val = null;
+		return val;
+	}
+
+	public void setCourseExtraParams(String val) {
+		if (val != null && val.trim().length() == 0) val = null;
+		setValue("COURSEXTRAPARAMS", val);
+	}
+
 	public static String getNiceTimeText(int minutes) {
 		int seatMinutes = minutes;
 		int seatDays = seatMinutes / (60 * 24);

Modified: trunk/src/com/resolutions/ils/data/CourseAttempt.java
===================================================================
--- trunk/src/com/resolutions/ils/data/CourseAttempt.java	2018-07-16 19:47:33 UTC (rev 1588)
+++ trunk/src/com/resolutions/ils/data/CourseAttempt.java	2018-07-16 23:35:06 UTC (rev 1589)
@@ -371,6 +371,7 @@
 			long endDate     = 0;
 			int  score       = 0;
 			int  courseCount = 0;
+			int  seatSeconds = 0;
 
 			for (Course c : courses) {
 				isPassed = false;
@@ -392,6 +393,7 @@
 								++courseCount;
 								score += s;
 							}
+							seatSeconds += ca.getCourseAttemptSeatSeconds();
 							isPassed = true;
 logger.info("course is passed: " + c.getCourseName());
 							break;
@@ -416,6 +418,7 @@
 				ca.setCourseAttemptUserProfileID(userProfileID);
 				ca.setCourseAttemptStatusID(ca.STATUS_PASSED);
 				ca.setCourseAttemptScore(score);
+				ca.setCourseAttemptSeatSeconds(seatSeconds);
 
 				// TODO: timeframe?
 
@@ -628,6 +631,32 @@
 		setIntValue("CASCORE", val);
 	}
 
+	public int getCourseAttemptSeatSeconds() {
+		return getIntValue("CASEATSECONDS");
+	}
+
+	// hhh:mm:ss
+	public static String formatDuration(int seconds) {
+		String seatTime = "";
+		try {
+			seatTime = String.format("%02d", (int)(seconds / (60*60)));
+			seconds %= (60*60);
+			seatTime += String.format(":%02d", (int)(seconds / 60));
+			seconds %= 60;
+			seatTime += String.format(":%02d", seconds);
+		}
+		catch (Exception e) { logger.error("error formatting seat time: " + seconds, e); }
+		return seatTime;
+	}
+
+	public String getCourseAttemptSeatSecondsFormatted() {
+		return CourseAttempt.formatDuration(getCourseAttemptSeatSeconds());
+	}
+
+	public void setCourseAttemptSeatSeconds(int val) {
+		setIntValue("CASEATSECONDS", val);
+	}
+
 	public String getCourseAttemptStage() {
 		return getStringValue("CASTAGE");
 	}

Modified: trunk/webapp/admin_coursenew.jsp
===================================================================
--- trunk/webapp/admin_coursenew.jsp	2018-07-16 19:47:33 UTC (rev 1588)
+++ trunk/webapp/admin_coursenew.jsp	2018-07-16 23:35:06 UTC (rev 1589)
@@ -117,6 +117,9 @@
               else if ("desc".equals(fi.getFieldName())) {
                 if (fi.getString() != null) current.setCourseDesc(fi.getString());
               }
+              else if ("extraParams".equals(fi.getFieldName())) {
+                if (fi.getString() != null) current.setCourseExtraParams(fi.getString());
+              }
               else if ("statusID".equals(fi.getFieldName())) {
                 if (fi.getString() != null) try { current.setCourseActive(Integer.parseInt(fi.getString())>0); } catch (Exception e) { logger.error(e); }
               }
@@ -507,7 +510,21 @@
                         <td class="formHeadings">Upload Approval Checklist  : </td>
                         <td><input name="file" type="file" size="40" /></td>
                       </tr>
+
+	                            <tr>
+	                              <td class="formHeadingsTitle">Advanced Settings</td>
+	                              <td colspan="2">&nbsp;</td>
+	                            </tr>
                       <tr>
+                       <td>&nbsp;</td>
+                       <td colspan="2">&nbsp;</td>
+                     </tr>
+                      <tr>
+                        <td class="formHeadings">Custom Configuration Parameters :<br/></td>
+                        <td><textarea id="courseExtraParams" style="width:100%" name="extraParams" rows="7" cols="40"><%=current.getCourseExtraParams()%></textarea></td>
+                      </tr>
+
+                      <tr>
                         <td class="formHeadings">&nbsp;</td>
                         <td colspan="2"><a href="#" onClick="document.coursesave.submit()"><br>
                         <img border="0" src="images/save_btn.gif" width="68" height="24" hspace="3" alt=""/></a><a href="admin_coursemanagement.jsp"><img border="0" src="images/cancel_btn.gif" width="72" height="24" alt=""/></a></td>

Modified: trunk/webapp/admin_studentrecords.jsp
===================================================================
--- trunk/webapp/admin_studentrecords.jsp	2018-07-16 19:47:33 UTC (rev 1588)
+++ trunk/webapp/admin_studentrecords.jsp	2018-07-16 23:35:06 UTC (rev 1589)
@@ -20,6 +20,7 @@
 <%@ page import="java.util.Collections" %>
  
 <%
+	Logger logger = Logger.getLogger(this.getClass());
     String statusMsg = "";
     String validError = "";
     int PAGE_MAX = 25;
@@ -35,7 +36,7 @@
     UserProfile user = ilsSession.getCurrentUserProfile();
     if (user.getUserProfileAccessLevel() < UserProfile.ACCESS_MANAGER) {
         out.print("<html><body><h1>Access Forbidden</h1></body></html>");
-        Logger.getLogger(this.getClass()).info("Access denied to user ["+user.getUserProfileNum()+"]");
+        logger.info("Access denied to user ["+user.getUserProfileNum()+"]");
         return;
     }
 
@@ -198,6 +199,7 @@
                 tDate             = ca.getCourseAttemptCompleteDate();
                 String eDate      = (tDate != null) ? df.format(tDate) : "";
                 String score      = "";
+                Integer time      = ca.getCourseAttemptSeatSeconds();
                 String status     = "";
                 switch (ca.getCourseAttemptStatusID()) {
                     case CourseAttempt.STATUS_IN_PROGRESS:
@@ -226,6 +228,7 @@
                 ca.setValue("cnum",     cc.getCourseNum());
                 ca.setValue("cname",    cc.getCourseName());
                 ca.setValue("score",    score);
+                ca.setValue("time",     time);
                 ca.setValue("status",   status);
             }
             session.setAttribute("lastDataset", courseAttempts);
@@ -325,6 +328,9 @@
                         if (ca2.getStringValue("score").length() < 1) s2 = -1;
                         return s2 - s1;
                     }
+                    if ("time".equals(sort)) {
+                        return ca2.getIntValue("time") - ca1.getIntValue("time");
+                    }
                     if ("eDate".equals(sort)) {
                         Date d1 = ca1.getCourseAttemptCompleteDate();
                         Date d2 = ca2.getCourseAttemptCompleteDate();
@@ -810,6 +816,7 @@
                               <th><a href="admin_studentrecords.jsp?sort=cname">Course Name</a></th>
                               <th><a href="admin_studentrecords.jsp?sort=sDate">Date started</a></th>
                               <th><a href="admin_studentrecords.jsp?sort=eDate">Date completed</a></th>
+                              <th><a href="admin_studentrecords.jsp?sort=time">Time</a></th>
                               <th><a href="admin_studentrecords.jsp?sort=score">Score</a></th>
                               <th><a href="admin_studentrecords.jsp?sort=status">Status</a></th>
                             </tr>
@@ -838,6 +845,7 @@
 	out.print("Course Name,");
 	out.print("Date Started,");
 	out.print("Date Completed,");
+	out.print("Time,");
 	out.print("Score,");
 	out.print("Status\n");
     }
@@ -851,6 +859,9 @@
         String sDate = (tDate != null) ? df.format(tDate) : "";
         tDate = ca.getCourseAttemptCompleteDate();
         String eDate = (tDate != null) ? df.format(tDate) : "";
+logger.debug("About to get seconds formatted.");
+        String time = ca.getCourseAttemptSeatSecondsFormatted();
+logger.debug("Got seconds formatted: " + time);
         String s = ca.getStringValue("score");
         if ("-1".equals(s)) s = "";
 
@@ -896,6 +907,7 @@
                  <td><a href="#" onClick="p('course','<%=ca.getIntValue("cid")%>','<%=wordNum++%>');return false;"> <%=ca.getStringValue("cname")%></a></td>
                  <td width="75" align="right"> <%= sDate %> </td>
                  <td width="70" align="right"> <%= eDate %> </td>
+                 <td width="45" align="right"> <%= time %> </td>
                  <td width="60" align="right"> <%= s %> </td>
                  <td> <%= ca.getStringValue("status") %> </td>
         </tr>
@@ -924,6 +936,7 @@
 		out.print("\""+ca.getStringValue("cname").replaceAll("\"", "\"\"") + "\",");
 		out.print(sDate + ",");
 		out.print(eDate + ",");
+		out.print(time + ",");
 		out.print(s + ",");
 		out.print(ca.getStringValue("status") + "\n");
          }

Modified: trunk/webapp/aicc.jsp
===================================================================
--- trunk/webapp/aicc.jsp	2018-07-16 19:47:33 UTC (rev 1588)
+++ trunk/webapp/aicc.jsp	2018-07-16 23:35:06 UTC (rev 1589)
@@ -5,6 +5,7 @@
 <%@page import="com.resolutions.ils.data.*"%>
 <%@page import="java.util.HashMap"%>
 <%@page import="java.util.Date"%>
+<%@page import="java.time.Duration"%>
 <%@page import="java.util.List"%>
 <%@page import="java.io.File"%>
 <%@page import="java.io.FileWriter"%>
@@ -127,10 +128,12 @@
 
       ca = ca.saveNew(ilsSession);
 
-	  if (aicc_userdata != null) {
-	  	//If I saveNew with CASTAGE set I get an index out of bounds error
+	  if (aicc_userdata != null || course.getCourseExtraParams() != null) {
 	  	CourseAttempt orig = (CourseAttempt) ca.clone();
-	  	ca.setCourseAttemptStage(CourseAttempt.mergeINIValues(AICC_INITIAL_DATA, aicc_userdata));
+		String aiccData = AICC_INITIAL_DATA;
+		if (aicc_userdata                 != null) aiccData = CourseAttempt.mergeINIValues(aiccData, aicc_userdata);
+	  	if (course.getCourseExtraParams() != null) aiccData = CourseAttempt.mergeINIValues(aiccData, course.getCourseExtraParams());
+	  	ca.setCourseAttemptStage(aiccData);
 	  	ca.save(orig);
 	  }
 
@@ -166,11 +169,14 @@
         logger.info("Launching in progress course...");
       }
 		// check for aicc_userdata
-		if (aicc_userdata != null) {
+		if (aicc_userdata != null || course.getCourseExtraParams() != null) {
 			CourseAttempt orig = (CourseAttempt) ca.clone();
 			String caStage = ca.getCourseAttemptStage();
 logger.info("******** relaunching course: aicc_data existing: " + caStage);
-	  		ca.setCourseAttemptStage(CourseAttempt.mergeINIValues((caStage != null && caStage.length() >= 2) ? caStage : AICC_INITIAL_DATA, aicc_userdata));
+	  		if (caStage == null || caStage.trim().length() < 2) caStage = AICC_INITIAL_DATA;
+	  		if (aicc_userdata != null) caStage = CourseAttempt.mergeINIValues(caStage, aicc_userdata);
+	  		if (course.getCourseExtraParams() != null) caStage = CourseAttempt.mergeINIValues(caStage, course.getCourseExtraParams());
+	  		ca.setCourseAttemptStage(caStage);
 logger.info("******** relaunching course: aicc_data adjusted: " + ca.getCourseAttemptStage());
 			ca.save(orig);
 	  	}
@@ -202,6 +208,7 @@
     logger.info("session_id: " + asid);
     logger.info("aicc_data: \n" + aicc_data);
     logger.info("stored score: " + ca.getCourseAttemptScore());
+    logger.info("stored seat seconds: " + ca.getCourseAttemptSeatSeconds());
     if (aicc_data == null) {
         aicc_data = ca.getCourseAttemptStage();
         logger.info("aicc_data pulled from last putparam: \n" + aicc_data);
@@ -251,6 +258,13 @@
 	String status = CourseAttempt.getINIValue(aicc_data, "lesson_status");
 	if (status != null && status.length() > 1) status = status.substring(0,1);
 	String score = CourseAttempt.getINIValue(aicc_data, "score");
+	String seatTime = CourseAttempt.getINIValue(aicc_data, "time");
+	int seatSeconds = 0;
+	if (seatTime != null && seatTime.trim().length() > 0 && seatTime.split(":").length > 1) {
+		if (seatTime.split(":").length == 2) try { seatSeconds = (int)Duration.parse("PT"+seatTime.split(":")[0]+"M"+seatTime.split(":")[1]+"S").getSeconds(); } catch (Exception e) { logger.error("error parsing seat time: " + seatTime, e); }
+		if (seatTime.split(":").length == 3) try { seatSeconds = (int)Duration.parse("PT"+seatTime.split(":")[0]+"H"+seatTime.split(":")[1]+"M"+seatTime.split(":")[2]+"S").getSeconds(); } catch (Exception e) { logger.error("error parsing seat time: " + seatTime, e); }
+	  if (seatSeconds > ca.getCourseAttemptSeatSeconds() && ca.getCourseAttemptStatusID() != ca.STATUS_PASSED) ca.setCourseAttemptSeatSeconds(seatSeconds);
+	}
 	int index = -1;
 	if (score != null) index = score.indexOf(",");
 	if (index > -1) score = score.substring(0,index);
@@ -305,7 +319,7 @@
       // HANDLE GETPARAM
       // code to get [core] node by session_id form value.
       aicc_data = ca.getCourseAttemptStage();
-      if ((aicc_data == null) || (aicc_data.length() < 2)) {
+      if ((aicc_data == null) || (aicc_data.trim().length() < 2)) {
 		aicc_data = AICC_INITIAL_DATA;
       }
       else {
@@ -313,6 +327,23 @@
             aicc_data = CourseAttempt.setINIValue(aicc_data, "lesson_location", "0");
         }
       }
+	if (course.getCourseExtraParams() != null) aicc_data = CourseAttempt.mergeINIValues(aicc_data, course.getCourseExtraParams());
+
+/*
+	// TRY TO SET SESSION TIME TO CUMMULATIVE
+	String seatTime = CourseAttempt.getINIValue(aicc_data, "time");
+	int seatSeconds = 0;
+	if (seatTime != null && seatTime.trim().length() > 0 && seatTime.split(":").length > 1) {
+		if (seatTime.split(":").length == 2) try { seatSeconds = (int)Duration.parse("PT"+seatTime.split(":")[0]+"M"+seatTime.split(":")[1]+"S").getSeconds(); } catch (Exception e) { logger.error("error parsing seat time: " + seatTime, e); }
+		if (seatTime.split(":").length == 3) try { seatSeconds = (int)Duration.parse("PT"+seatTime.split(":")[0]+"H"+seatTime.split(":")[1]+"M"+seatTime.split(":")[2]+"S").getSeconds(); } catch (Exception e) { logger.error("error parsing seat time: " + seatTime, e); }
+		if (seatSeconds < ca.getCourseAttemptSeatSeconds() && ca.getCourseAttemptStatusID() != ca.STATUS_PASSED)  {
+			seatSeconds += ca.getCourseAttemptSeatSeconds();
+			seatTime = CourseAttempt.formatDuration(seatSeconds);
+			aicc_data = CourseAttempt.setINIValue(aicc_data, "time", seatTime);
+logger.info("resetting session time to: " + seatTime);
+		}
+	}
+*/
       out.print(aicc_data);
       logger.info("sending aicc_data: " + aicc_data);
     }

Modified: trunk/webapp/report_employeecourseatt.jsp
===================================================================
--- trunk/webapp/report_employeecourseatt.jsp	2018-07-16 19:47:33 UTC (rev 1588)
+++ trunk/webapp/report_employeecourseatt.jsp	2018-07-16 23:35:06 UTC (rev 1589)
@@ -159,6 +159,7 @@
 			ca.setValue("status", status);
 			ca.setIntValue("statusSort", statusSort);
 			ca.setValue("score", score);
+			ca.setIntValue("time", ca.getCourseAttemptSeatSeconds());
 			ca.setValue("coursenum", mainCourse.getCourseNum());
 			ca.setValue("coursename", mainCourse.getCourseName());
 			ca.setValue("seattimetext", mainCourse.getCourseSeatTimeText());
@@ -310,6 +311,7 @@
                               <th style="width: 70px !important;">Timeframe</th>
                               <th style="width: 70px !important;">Start Date </th>
                               <th style="width: 70px !important;">End Date</th>
+                              <th style="width: 50px !important;">Time</th>
                               <th style="width: 50px !important;">Score %</th>
                               <th style="width: 35px !important;">Cert</th>
                             </tr>
@@ -459,9 +461,10 @@
 		Map<String, Object>values = new HashMap<String, Object>();
 		computeCurriculumStats(curr.getCourseID(), courses, courseCurriculum, courseCourseAttempts, values);
 		int  timeFrame         = (Integer)values.get("timeFrame");
-		long sDate         = (Long)values.get("startDate");
-		long eDate           = (Long)values.get("endDate");
+		long sDate             = (Long)values.get("startDate");
+		long eDate             = (Long)values.get("endDate");
 		int  score             = (Integer)values.get("score");
+		int  seatSeconds       = (Integer)values.get("time");
 		int  inProgressCourseCount = (Integer)values.get("inProgressCourseCount");
 		int  passedCourseCount = (Integer)values.get("passedCourseCount");
 		int  totalCourseCount  = (Integer)values.get("totalCourseCount");
@@ -513,6 +516,7 @@
 	out.write("<td>"+ca.getStringValue("seattimetext")+"</td>");
 	out.write("<td>"+startDate+"</td>");
 	out.write("<td>"+endDate+"</td>");
+	out.write("<td>"+CourseAttempt.formatDuration(ca.getIntValue("time"))+"</td>");
 	out.write("<td>"+ca.getStringValue("score")+"</td>");
 	out.write("<td>");
 
@@ -537,6 +541,7 @@
 	long startDate         = 0;
 	long endDate           = 0;
 	int  score             = 0;
+	int  seatSeconds       = 0;
 	int  inProgressCourseCount = 0;
 	int  passedCourseCount = 0;
 	int  totalCourseCount  = 0;
@@ -567,9 +572,13 @@
 							score += s;
 							inProgress = false;
 						}
+						seatSeconds += ca.getCourseAttemptSeatSeconds();
 						break;
 					}
-					else if (ca.getCourseAttemptStatusID() == CourseAttempt.STATUS_IN_PROGRESS) inProgress = true;
+					else if (ca.getCourseAttemptStatusID() == CourseAttempt.STATUS_IN_PROGRESS) {
+						inProgress = true;
+						seatSeconds += ca.getCourseAttemptSeatSeconds();
+					}
 				}
 				if (inProgress) ++inProgressCourseCount;
 			}
@@ -585,6 +594,7 @@
 	values.put("passedCourseCount", passedCourseCount);
 	values.put("totalCourseCount", totalCourseCount);
 	values.put("timeFrame", timeFrame);
+	values.put("time", seatSeconds);
 
 logger.debug("curriculum: " + curriculumID + "; values: " + values);
 }




More information about the Ils-source mailing list