[Ils-source] r1493 - trunk/webapp
scribe at crosswire.org
scribe at crosswire.org
Wed Oct 26 10:49:22 MST 2016
Author: scribe
Date: 2016-10-26 10:49:22 -0700 (Wed, 26 Oct 2016)
New Revision: 1493
Modified:
trunk/webapp/report_employeecourseatt.jsp
Log:
Added first cut of curriculum stats and print from report
Modified: trunk/webapp/report_employeecourseatt.jsp
===================================================================
--- trunk/webapp/report_employeecourseatt.jsp 2016-10-26 17:32:56 UTC (rev 1492)
+++ trunk/webapp/report_employeecourseatt.jsp 2016-10-26 17:49:22 UTC (rev 1493)
@@ -92,7 +92,10 @@
// map all courses to their parent curriculum
HashMap<Integer, Integer> courseCurriculum = new HashMap<Integer, Integer>();
HashMap<Integer, Boolean> courseSupressRetake = new HashMap<Integer, Boolean>();
+ HashMap<Integer, Course> curriculaList = new HashMap<Integer, Course>();
+ HashMap<Integer, HashSet<CourseAttempt>> courseCourseAttempts = new HashMap<Integer, HashSet<CourseAttempt>>();
for (Course cur : curricula) {
+ curriculaList.put(cur.getCourseID(), cur);
for (Course c : Course.getCurriculumCourses(ilsSession, cur.getCourseID())) {
courseCurriculum.put(c.getCourseID(), cur.getCourseID());
courseSupressRetake.put(c.getCourseID(), !cur.isCourseAllowCurriculumPartRetake());
@@ -103,6 +106,8 @@
Vector<CourseAttempt> courseAttempts = new Vector<CourseAttempt>();
for (int j = 0; j < courses.size(); j++) {
Course mainCourse = (Course)courses.get(j);
+ HashSet<CourseAttempt> meCourseAttempts = new HashSet<CourseAttempt>();
+ courseCourseAttempts.put(mainCourse.getCourseID(), meCourseAttempts);
logger.debug("processing course: " + mainCourse.getCourseName());
Vector cas = CourseAttempt.getUserCourseAttempts(ilsSession, current.getUserProfileID(), mainCourse.getCourseID());
boolean nonExpired = false;
@@ -158,6 +163,7 @@
ca.setCourseAttemptCourseID(mainCourse.getCourseID());
if (mainCourse.isCourseActive() || (ca.getCourseAttemptStatusID() == CourseAttempt.STATUS_FAILED) || (ca.getCourseAttemptStatusID() == CourseAttempt.STATUS_PASSED)) {
courseAttempts.add(ca);
+ meCourseAttempts.add(ca);
}
}
}
@@ -313,23 +319,23 @@
// first see if we're a course in a Curriculum
CourseAttempt ca = courseAttempts.get(0);
- Integer curriculum = courseCurriculum.get(ca.getCourseAttemptCourseID());
+ Integer curriculumID = courseCurriculum.get(ca.getCourseAttemptCourseID());
String html = "";
int startSize = courseAttempts.size();
// process curriculum first
- if (curriculum != null) {
+ if (curriculumID != null) {
// find the first course attempt for the curriculum
for (CourseAttempt caCur : courseAttempts) {
- if (caCur.getCourseAttemptCourseID() == curriculum) {
+ if (caCur.getCourseAttemptCourseID() == curriculumID) {
// set this course attempt be the next processed course attempt
ca = caCur;
break;
}
}
- html = getCurriculumHTML(courseSupressRetake, courseCurriculum, courseAttempts, ca, managing, user, wordNum);
+ html = getCurriculumHTML(courseSupressRetake, courseCurriculum, courseAttempts, ca, managing, user, wordNum, curriculaList, courses, courseCourseAttempts);
}
else {
- html = getCourseHTML(courseAttempts, ca, managing, user, wordNum, null, null, false);
+ html = getCourseHTML(courseAttempts, ca, managing, user, wordNum, null, null, false, courseCurriculum, curriculaList, courses, courseCourseAttempts);
}
int processedSize = courseAttempts.size() - startSize;
@@ -365,19 +371,19 @@
<%!
-public static String getCourseHTML(Vector<CourseAttempt> courseAttempts, CourseAttempt ca, boolean managing, UserProfile user, int wordNum, String headerAddition, String subClassAddition, boolean supressRetake) {
+public static String getCourseHTML(Vector<CourseAttempt> courseAttempts, CourseAttempt ca, boolean managing, UserProfile user, int wordNum, String headerAddition, String subClassAddition, boolean supressRetake, HashMap<Integer, Integer> courseCurriculum, HashMap<Integer, Course> curriculaList, Vector<Course>courses, HashMap<Integer, HashSet<CourseAttempt>>courseCourseAttempts) {
if (subClassAddition == null) subClassAddition = "";
else subClassAddition += " ";
StringWriter out = new StringWriter();
- String html = getCourseAttemptHTML(ca, managing, user, wordNum, supressRetake);
+ String html = getCourseAttemptHTML(ca, managing, user, wordNum, supressRetake, courseCurriculum, curriculaList, courses, courseCourseAttempts);
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=\""+subClassAddition+"subCourseDetail subCourseID_"+ca2.getCourseAttemptCourseID()+"\"><td></td><td></td>"+getCourseAttemptHTML(ca2, managing, user, ++wordNum, supressRetake)+"</tr>";
+ moreHTML += "<tr class=\""+subClassAddition+"subCourseDetail subCourseID_"+ca2.getCourseAttemptCourseID()+"\"><td></td><td></td>"+getCourseAttemptHTML(ca2, managing, user, ++wordNum, supressRetake, courseCurriculum, curriculaList, courses, courseCourseAttempts)+"</tr>";
courseAttempts.remove(ca2);
--j;
}
@@ -398,28 +404,28 @@
return out.toString();
}
-public static String getCurriculumHTML(HashMap<Integer, Boolean> courseSupressRetake, HashMap<Integer, Integer> courseCurriculum, Vector<CourseAttempt> courseAttempts, CourseAttempt caCur, boolean managing, UserProfile user, int wordNum) {
+public static String getCurriculumHTML(HashMap<Integer, Boolean> courseSupressRetake, HashMap<Integer, Integer> courseCurriculum, Vector<CourseAttempt> courseAttempts, CourseAttempt caCur, boolean managing, UserProfile user, int wordNum, HashMap<Integer, Course> curriculaList, Vector<Course>courses, HashMap<Integer, HashSet<CourseAttempt>>courseCourseAttempts) {
Logger logger = Logger.getLogger("getCurriculumHTML");
StringWriter out = new StringWriter();
String headerAddition = ("<span id=\"curriculumHeader_"+caCur.getCourseAttemptCourseID()+"\" onclick=\"toggleCurriculumDetails('"+caCur.getCourseAttemptCourseID()+"');return false;\"> ▶ </span>");
- String html = getCourseHTML(courseAttempts, caCur, managing, user, wordNum, headerAddition, "curriculumHeader", false);
+ String html = getCourseHTML(courseAttempts, caCur, managing, user, wordNum, headerAddition, "curriculumHeader", false, courseCurriculum, curriculaList, courses, courseCourseAttempts);
String moreHTML = "";
for (int j = 0; j < courseAttempts.size(); ++j) {
CourseAttempt ca2 = courseAttempts.get(j);
// see if this course attempt is in our curriculum
- Integer curriculum = courseCurriculum.get(ca2.getCourseAttemptCourseID());
- if (curriculum != null && caCur.getCourseAttemptCourseID() == curriculum.intValue()) {
+ Integer curriculumID = courseCurriculum.get(ca2.getCourseAttemptCourseID());
+ if (curriculumID != null && caCur.getCourseAttemptCourseID() == curriculumID.intValue()) {
logger.info("cours is in cur.");
String subClassAddition = "subCurriculumDetail subCurriculumID_"+caCur.getCourseAttemptCourseID();
Boolean supressRetake = courseSupressRetake.get(ca2.getCourseAttemptCourseID());
- moreHTML += getCourseHTML(courseAttempts, ca2, managing, user, ++wordNum, null, subClassAddition, supressRetake != null && supressRetake.booleanValue());
+ moreHTML += getCourseHTML(courseAttempts, ca2, managing, user, ++wordNum, null, subClassAddition, supressRetake != null && supressRetake.booleanValue(), courseCurriculum, curriculaList, courses, courseCourseAttempts);
--j;
}
else {
-logger.info("cours NOT is in cur. CourseID:"+ca2.getCourseAttemptCourseID()+"; curParent: " + curriculum);
+logger.info("cours NOT is in cur. CourseID:"+ca2.getCourseAttemptCourseID()+"; curParent: " + curriculumID);
}
}
@@ -430,8 +436,33 @@
}
-public static String getCourseAttemptHTML(CourseAttempt ca, boolean managing, UserProfile user, int wordNum, boolean supressRetake) {
+public static String getCourseAttemptHTML(CourseAttempt ca, boolean managing, UserProfile user, int wordNum, boolean supressRetake, HashMap<Integer, Integer> courseCurriculum, HashMap<Integer, Course> curriculaList, Vector<Course>courses, HashMap<Integer, HashSet<CourseAttempt>>courseCourseAttempts) {
+ boolean supressCert = false;
+ // are we IN a curriculum?
+ Integer curriculumID = courseCurriculum.get(ca.getCourseAttemptCourseID());
+ if (curriculumID != null) {
+ Course curr = curriculaList.get(curriculumID);
+ supressCert = curr.isCourseCurriculumCertificate();
+ }
+
+ // are we a curriculum?
+ Course curr = curriculaList.get(ca.getCourseAttemptCourseID());
+ if (curr != null) {
+ HashMap<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");
+ int score = (Integer)values.get("score");
+ int inProgressCourseCount = (Integer)values.get("inProgressCourseCount");
+ int passedCourseCount = (Integer)values.get("passedCourseCount");
+ int totalCourseCount = (Integer)values.get("totalCourseCount");
+ ca.setValue("seattimetext", Course.getNiceTimeText(timeFrame));
+ ca.setValue("status", passedCourseCount == totalCourseCount ? "Passed" : (inProgressCourseCount == 0 && passedCourseCount == 0) ? "New" : "In Progress");
+ if ("In Progress".equals(ca.getValue("status"))) ca.setCourseAttemptStartDate(new Date(sDate));
+ }
+
StringWriter out = new StringWriter();
Date tDate = ca.getCourseAttemptStartDate();
String startDate = (tDate != null) ? df.format(tDate) : "";
@@ -461,6 +492,7 @@
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>");
@@ -473,8 +505,70 @@
if (ca.getSavedCertificate() != null) {
out.write("<a target=\"_blank\" href=\"api/courseattempt/cert/get?courseAttemptID="+ca.getCourseAttemptID()+"\"><img src=\"images/certificate_saved.png\"/></a>");
}
+ else if ("Passed".equals(status) && !supressCert) {
+ Course c = Course.getCourse(ca.getCompanyID(), ca.getCourseAttemptCourseID());
+ String urlString = (c.isCourseCurriculum() ? "certificate_curriculum.jsp" : "certificate.jsp");
+ urlString += "?ca=" + ca.getCourseAttemptID();
+ urlString += "&c=" + c.getCourseID();
+ urlString += "&up=" + ca.getCourseAttemptUserProfileID();
+ out.write("<a target=\"_blank\" href=\""+urlString+"\"><img src=\"images/print_certficate.png\"/></a>");
+ }
out.write("</td>");
return out.toString();
}
+public static void computeCurriculumStats(int curriculumID, Vector<Course> courses, HashMap<Integer, Integer> courseCurriculum, HashMap<Integer, HashSet<CourseAttempt>> courseCourseAttempts, HashMap<String, Object>values) {
+ int timeFrame = 0;
+ long startDate = 0;
+ long endDate = 0;
+ int score = 0;
+ int inProgressCourseCount = 0;
+ int passedCourseCount = 0;
+ int totalCourseCount = 0;
+ int scoredCourseCount = 0;
+
+ for (Course c : courses) {
+ // are we a course in our curriculum?
+ Integer thisCourseCurriculum = courseCurriculum.get(c.getCourseID());
+ if (thisCourseCurriculum != null && curriculumID == thisCourseCurriculum) {
+ ++totalCourseCount;
+
+ timeFrame += c.getCourseSeatMinutes();
+ Set<CourseAttempt> cas = courseCourseAttempts.get(c.getCourseID());
+ if (cas != null) {
+ boolean inProgress = false;
+ for (CourseAttempt ca : cas) {
+ Date d = ca.getCourseAttemptStartDate();
+ startDate = (d != null && (startDate == 0 || startDate > d.getTime())) ? d.getTime() : startDate;
+ d = ca.getCourseAttemptCompleteDate();
+ endDate = (d != null && (endDate == 0 || endDate < d.getTime())) ? d.getTime() : endDate;
+
+ if (ca.getCourseAttemptStatusID() == CourseAttempt.STATUS_PASSED && !ca.isCourseAttemptExpired()) {
+ int s = ca.getCourseAttemptScore();
+ ++passedCourseCount;
+ if (s > -1) {
+ ++scoredCourseCount;
+ score += s;
+ inProgress = false;
+ }
+ break;
+ }
+ else if (ca.getCourseAttemptStatusID() == CourseAttempt.STATUS_IN_PROGRESS) inProgress = true;
+ }
+ if (inProgress) ++inProgressCourseCount;
+ }
+ }
+ }
+
+ if (scoredCourseCount != 0) score /= scoredCourseCount;
+ values.put("timeFrame", timeFrame);
+ values.put("startDate", startDate);
+ values.put("endDate", endDate);
+ values.put("score", score);
+ values.put("inProgressCourseCount", inProgressCourseCount);
+ values.put("passedCourseCount", passedCourseCount);
+ values.put("totalCourseCount", totalCourseCount);
+ values.put("timeFrame", timeFrame);
+
+}
%>
More information about the Ils-source
mailing list