[Ils-source] r1390 - trunk/webapp

scribe at crosswire.org scribe at crosswire.org
Wed Feb 3 15:59:59 MST 2016


Author: scribe
Date: 2016-02-03 15:59:59 -0700 (Wed, 03 Feb 2016)
New Revision: 1390

Modified:
   trunk/webapp/report_employeecourseatt.jsp
Log:
Group course attempts by course on employee records report


Modified: trunk/webapp/report_employeecourseatt.jsp
===================================================================
--- trunk/webapp/report_employeecourseatt.jsp	2016-02-03 17:28:56 UTC (rev 1389)
+++ trunk/webapp/report_employeecourseatt.jsp	2016-02-03 22:59:59 UTC (rev 1390)
@@ -8,10 +8,14 @@
 <%@ page import="java.util.Comparator" %>
 <%@ page import="java.util.Date" %>
 <%@ page import="java.io.File" %>
+<%@ page import="java.io.StringWriter" %>
 <%@ page import="java.net.URL" %>
 <%@ page import="java.text.SimpleDateFormat" %>
 <%@ page import="org.apache.log4j.Logger" %>
 
+<%!
+    static SimpleDateFormat df  = new SimpleDateFormat("MM/dd/yyyy");
+%>
 <%
 	Logger logger = Logger.getLogger(this.getClass());
     ILSSession ilsSession = (ILSSession)session.getAttribute("ilsSession");
@@ -106,9 +110,7 @@
     }
     
     
-    SimpleDateFormat df  = new SimpleDateFormat("MM/dd/yyyy");
     Vector courses       = Course.getAllUserCourses(ilsSession, current.getUserProfileID());
-//    Course.appendUserCoursesFromAttempts(courses, ilsSession, current.getUserProfileID());
     int wordNum = 0;
 
     Vector<CourseAttempt> courseAttempts = new Vector<CourseAttempt>();
@@ -197,6 +199,7 @@
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <link href="lms_style.css" rel="stylesheet" type="text/css">
 <script type="text/javascript" src="crosswire.js"></script>
+<script type="text/javascript" src="js/jquery/jquery.min.js"></script>
 <script type="text/javascript">
 <!--
 var rcid=0;
@@ -229,7 +232,22 @@
 	document.getElementById('passReason').value=reason + 'Pass Forced';
 	document.forcePassForm.submit();
 }
+function toggleCourseDetails(courseID) {
+	if ($('.subCourseID_'+courseID+':first').is(":visible")) {
+		$('#courseHeader_'+courseID).html('▶');
+		$('.subCourseID_'+courseID).hide();
+	}
+	else {
+		$('#courseHeader_'+courseID).html('▼');
+		$('.subCourseID_'+courseID).show();
+	}
+}
 
+$(document).ready(function() {
+	$('.subCourseDetail').hide();
+});
+
+
 -->
 </script>
 </head>
@@ -266,6 +284,7 @@
                       <tr>
                         <td><table class="tableDataList">
                             <tr>
+                              <th>&nbsp;</th>
 <% if (managing) { %>                            
                               <th>Comments</th>
 <% } %>                              
@@ -279,63 +298,32 @@
                               <th>Cert</th>
                             </tr>
 <%
-    for (int j = 0; j < courseAttempts.size(); j++) {
-        CourseAttempt ca = courseAttempts.get(j);
-        Date tDate = ca.getCourseAttemptStartDate();
-        String startDate = (tDate != null) ? df.format(tDate) : "";
-        tDate = ca.getCourseAttemptCompleteDate();
-        String endDate = (tDate != null) ? df.format(tDate) : "";
-        String status = ca.getStringValue("status");
-%>
-       <tr>
-<%
-	if (managing) {
-%> <td> <%
-		if ("Passed".equals(status)) {
-			if (!ca.isCourseAttemptExpired()) {
-%>
-				<a href="#" onClick="retake(<%=ca.getCourseAttemptID()%>);return false;" class="Assign">Assign Retake</a>
-<%
+	while (courseAttempts.size() > 0) {
+		CourseAttempt ca = courseAttempts.get(0);
+
+		String html = getCourseAttemptHTML(ca, managing, user, ++wordNum);
+		courseAttempts.remove(ca);
+		String moreHTML = "";
+		for (int j = 0; j < courseAttempts.size(); ++j) {
+			CourseAttempt ca2 = courseAttempts.get(j);
+			if (ca2.getCourseAttemptCourseID() == ca.getCourseAttemptCourseID()) {
+				moreHTML += "<tr class=\"subCourseDetail subCourseID_"+ca2.getCourseAttemptCourseID()+"\"><td></td>"+getCourseAttemptHTML(ca2, managing, user, ++wordNum)+"</tr>";
+				courseAttempts.remove(ca2);
+				--j;
 			}
 		}
-		else if (!"Awaiting <t:t>Manager</t:t> Approval".equals(status) && user.getUserProfileAccessLevel() > UserProfile.ACCESS_MANAGER || user.hasAccess(UserProfile.ACCESS_MODE_STUDENTREC_PASS_OVERRIDE)) {
-%>
-			  <a href="#" onClick="forcePass(<%=ca.getCourseAttemptID()%>, <%=ca.getCourseAttemptCourseID()%>);return false;" class="Assign">Force Pass</a>
-	        
-<%
-		}
 
-		String val = "";
-		if (ca.isCourseAttemptExpired()) {
-			val += ca.getCourseAttemptExpiredReason() + "<br/>" + df.format(ca.getCourseAttemptExpiredDate());
+		out.print("<tr>");
+		out.print("<td>");
+		if (moreHTML.length() > 0) {
+			out.write("<span id=\"courseHeader_"+ca.getCourseAttemptCourseID()+"\" onclick=\"toggleCourseDetails('"+ca.getCourseAttemptCourseID()+"');return false;\"> ▶ </span>");
 		}
-		if (ca.isCourseAttemptForcePass()) {
-			if (val.length() > 0) val += "<br/>";
-			val += ca.getCourseAttemptForcePassReason() + "<br/>" + df.format(ca.getCourseAttemptForcePassDate());
-		}
-%>
-		<%=val%></td>
-<%
+		out.write("</td>");
+		out.write(html);
+		out.write("</tr>");
+		out.write(moreHTML);
 	}
 %>
-          <td><%=status%></td>
-          <td><%=ca.getStringValue("coursenum")%></td>
-          <td><a href="#"
-              onclick="p('course','<%=ca.getCourseAttemptCourseID()%>','<%=wordNum++%>');"><strong>
-            <%=ca.getStringValue("coursename")%></strong></a></td>
-          <td> <%=ca.getStringValue("seattimetext")%> </td>
-          <td> <%=startDate%> </td>
-          <td> <%=endDate  %> </td>
-          <td> <%=ca.getStringValue("score")%> </td>
-          <td> 
-<% if (ca.getSavedCertificate() != null) { %>
-<a target="_blank" href="api/courseattempt/cert/get?courseAttemptID=<%=ca.getCourseAttemptID()%>"><img src="images/certificate_saved.png"/></a>
-<% } %>
-	  </td>
-        </tr>
-<%
-    }
-%>
                         </table></td>
                       </tr>
     </table>
@@ -360,3 +348,53 @@
 
 </body>
 </html>
+
+<%!
+	public static String getCourseAttemptHTML(CourseAttempt ca, boolean managing, UserProfile user, int wordNum) {
+
+		StringWriter out = new StringWriter();
+		Date tDate = ca.getCourseAttemptStartDate();
+		String startDate = (tDate != null) ? df.format(tDate) : "";
+		tDate = ca.getCourseAttemptCompleteDate();
+		String endDate = (tDate != null) ? df.format(tDate) : "";
+		String status = ca.getStringValue("status");
+		if (managing) {
+			out.write("<td>");
+			if ("Passed".equals(status)) {
+				if (!ca.isCourseAttemptExpired()) {
+					out.write("<a href=\"#\" onClick=\"retake("+ca.getCourseAttemptID()+");return false;\" class=\"Assign\">Assign Retake</a>");
+				}
+			}
+			else if (!"Awaiting <t:t>Manager</t:t> Approval".equals(status) && user.getUserProfileAccessLevel() > UserProfile.ACCESS_MANAGER || user.hasAccess(UserProfile.ACCESS_MODE_STUDENTREC_PASS_OVERRIDE)) {
+				out.write("<a href=\"#\" onClick=\"forcePass("+ca.getCourseAttemptID()+", "+ca.getCourseAttemptCourseID()+");return false;\" class=\"Assign\">Force Pass</a>");
+	        
+			}
+
+			String val = "";
+			if (ca.isCourseAttemptExpired()) {
+				val += ca.getCourseAttemptExpiredReason() + "<br/>" + df.format(ca.getCourseAttemptExpiredDate());
+			}
+			if (ca.isCourseAttemptForcePass()) {
+				if (val.length() > 0) val += "<br/>";
+				val += ca.getCourseAttemptForcePassReason() + "<br/>" + df.format(ca.getCourseAttemptForcePassDate());
+			}
+			out.write(val+"</td>");
+		}
+
+		out.write("<td>"+status+"</td>");
+		out.write("<td>"+ca.getStringValue("coursenum")+"</td>");
+		out.write("<td><a href=\"#\" onclick=\"p('course','"+ca.getCourseAttemptCourseID()+"','"+wordNum+"');\"><strong>"+ca.getStringValue("coursename")+"</strong></a></td>");
+		out.write("<td>"+ca.getStringValue("seattimetext")+"</td>");
+		out.write("<td>"+startDate+"</td>");
+		out.write("<td>"+endDate+"</td>");
+		out.write("<td>"+ca.getStringValue("score")+"</td>");
+		out.write("<td>");
+
+		if (ca.getSavedCertificate() != null) {
+			out.write("<a target=\"_blank\" href=\"api/courseattempt/cert/get?courseAttemptID="+ca.getCourseAttemptID()+"\"><img src=\"images/certificate_saved.png\"/></a>");
+		}
+		out.write("</td>");
+
+		return out.toString();
+	}
+%>




More information about the Ils-source mailing list