[Ils-source] r1392 - in branches/1.6: . src/com/resolutions/ils/data webapp/WEB-INF/classes webapp/WEB-INF/lib webapp/api/course/get webapp/api/courseattempt/get

scribe at crosswire.org scribe at crosswire.org
Tue Feb 16 16:22:04 MST 2016


Author: scribe
Date: 2016-02-16 16:22:04 -0700 (Tue, 16 Feb 2016)
New Revision: 1392

Modified:
   branches/1.6/
   branches/1.6/src/com/resolutions/ils/data/Course.java
   branches/1.6/src/com/resolutions/ils/data/CourseAttempt.java
   branches/1.6/webapp/WEB-INF/classes/versions.properties
   branches/1.6/webapp/WEB-INF/lib/crosswire.jar
   branches/1.6/webapp/WEB-INF/lib/ils.jar
   branches/1.6/webapp/api/course/get/index.jsp
   branches/1.6/webapp/api/courseattempt/get/index.jsp
Log:
update to normalize: course/get, courseattempt/get, and callback POST fields of completed CourseAttempt records
release of 1.80.4



Property changes on: branches/1.6
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk:796-1303,1306-1307,1309-1311,1319-1320,1322-1323,1325,1328-1330,1332,1334-1335,1337,1339,1349-1355,1360-1365,1380-1383
   + /trunk:796-1303,1306-1307,1309-1311,1319-1320,1322-1323,1325,1328-1330,1332,1334-1335,1337,1339,1349-1355,1360-1365,1380-1383,1391

Modified: branches/1.6/src/com/resolutions/ils/data/Course.java
===================================================================
--- branches/1.6/src/com/resolutions/ils/data/Course.java	2016-02-16 23:07:51 UTC (rev 1391)
+++ branches/1.6/src/com/resolutions/ils/data/Course.java	2016-02-16 23:22:04 UTC (rev 1392)
@@ -311,6 +311,10 @@
         return getStringValue("COURSISIPRESTRICTED");
     }
 
+    public boolean isCourseIPRestricted() {
+        return ("T".equals(getValue("COURSISIPRESTRICTED")));
+    }
+
     public boolean isCourseCurriculum() {
         return ("T".equals(getValue("COURSISCURRICULUM")));
     }
@@ -404,6 +408,10 @@
         setValue("COURSISIPRESTRICTED", val);
     }
 
+    public void setCourseIPRestricted(boolean val) {
+        setValue("COURSISIPRESTRICTED", (val) ? "T" : "F");
+    }
+
     public String getCourseSeatTimeText() {
         return getNiceTimeText(getCourseSeatMinutes());
     }
@@ -515,25 +523,36 @@
         }
         return super.equals(o);
     }
-	public String toFormattedXML() {
-		
+
+	public String toXML() {
+		return toXML(DETAIL_COMPLETE);
+	}
+
+	public String toXML(int detail) {
 		StringBuffer xml = new StringBuffer();
-		xml.append("<Course");
-		xml.append(" id=\""+ getCourseID()+"\"");
-		xml.append(" courseNum=\""+getCourseNum()+"\"");
-		xml.append(">\n");
-		xml.append(" <CourseName>"+HTTPUtils.canonize(getCourseName())+"</CourseName>\n");
-		xml.append(" <CourseDescription>"+HTTPUtils.canonize(getCourseDesc())+"</CourseDescription>\n");
-		xml.append(" <CourseType typeID=\""+getCourseTypeID()+"\">"+HTTPUtils.canonize(getCourseType())+"</CourseType>\n");
-		xml.append(" <CourseIPRestricted>"+HTTPUtils.canonize(getCourseIPRestricted())+"</CourseIPRestricted>\n");
-		xml.append(" <CourseSeatTime minutes=\""+getCourseSeatMinutes()+"\">"+HTTPUtils.canonize(getCourseSeatTimeText())+"</CourseSeatTime>\n");
-		xml.append(" <CourseURL>"+HTTPUtils.canonize(getCourseURL())+"</CourseURL>\n");
-		xml.append(" <CourseCost>"+getCourseCost()+"</CourseCost>\n");
-		xml.append(" <CoursePass>"+getCoursePass()+"</CoursePass>\n");
-		xml.append(" <CoursePassExpireDays>"+getCoursePassExpireDays()+"</CoursePassExpireDays>\n");
-		xml.append(" <CoursePostDate>"+getCoursePostDate()+"</CoursePostDate>\n");
-		xml.append(" <CourseReassignBeforeDays>"+getCourseReassignBeforeDays()+"</CourseReassignBeforeDays>\n");
-		xml.append("</Course>\n");
+		xml.append("<course courseID=\"").append(getCourseID()+"\"");
+		xml.append(" courseTypeID=\"").append(getCourseTypeID()+"\"");
+		xml.append(" courseNumber=\"").append(HTTPUtils.canonize(getCourseNum())+"\"");
+		xml.append(" userData=\""+getStringValue("USERDATA")+"\"");
+		if (detail == DETAIL_HEADERONLY) {
+			xml.append("/>");
+		}
+		else {
+			xml.append(">");
+			xml.append("<courseName>"+HTTPUtils.canonize(getCourseName())+"</courseName>");
+			if (detail > DETAIL_BRIEF) {
+				xml.append("<description>"+HTTPUtils.canonize(getCourseDesc())+"</description>");
+				xml.append("<isIPRestricted>"+isCourseIPRestricted()+"</isIPRestricted>");
+				xml.append("<seatTime minutes=\""+getCourseSeatMinutes()+"\">"+HTTPUtils.canonize(getCourseSeatTimeText())+"</seatTime>");
+				xml.append("<courseURL>"+HTTPUtils.canonize(getCourseURL())+"</courseURL>");
+				xml.append("<cost>"+getCourseCost()+"</cost>");
+				xml.append("<passScore>"+getCoursePass()+"</passScore>");
+				xml.append("<passExpireDays>"+getCoursePassExpireDays()+"</passExpireDays>");
+				xml.append("<postDate>"+getCoursePostDate()+"</postDate>");
+				xml.append("<reassignBeforeDays>"+getCourseReassignBeforeDays()+"</reassignBeforeDays>");
+			}
+			xml.append("</course>");
+		}
 
 		return xml.toString();
 	}

Modified: branches/1.6/src/com/resolutions/ils/data/CourseAttempt.java
===================================================================
--- branches/1.6/src/com/resolutions/ils/data/CourseAttempt.java	2016-02-16 23:07:51 UTC (rev 1391)
+++ branches/1.6/src/com/resolutions/ils/data/CourseAttempt.java	2016-02-16 23:22:04 UTC (rev 1392)
@@ -301,8 +301,6 @@
 
 	}
 
-
-
 	static public Vector getSearchUserCourseAttempts(ILSSession session, int locID, int roleID,
 			String lName, String empNum, int statusID, int accessLevel, Date hireStartDate, Date hireEndDate,
 			int managerID, int courseID, int complianceID, Date sDate, Date eDate, boolean reqApprov) {
@@ -597,24 +595,22 @@
 		    	StringBuffer params = new StringBuffer();
 		    	UserProfile user = UserProfile.getUserProfile(session, getCourseAttemptUserProfileID());
 		    	Course course = Course.getCourse(session, getCourseAttemptCourseID());
-		    	params.append("USERDATA=").append(URLEncoder.encode(user.getStringValue("USERDATA"), "UTF-8"));
-		    	params.append("&COMPANYID=").append(getCompanyID());
-		    	params.append("&USERPRID=").append(user.getUserProfileID());
-		    	params.append("&USERPRNUM=").append(URLEncoder.encode(user.getUserProfileNum(), "UTF-8"));
-		    	params.append("&COURSID=").append(course.getCourseID());
-		    	params.append("&COURSNUM=").append(URLEncoder.encode(course.getCourseNum(), "UTF-8"));
-		    	params.append("&COURSNAME=").append(URLEncoder.encode(course.getCourseName(), "UTF-8"));
-		    	params.append("&CASTARTDATE=").append(URLEncoder.encode(getCourseAttemptStartDate().toString(), "UTF-8"));
-		    	params.append("&CACOMPLETEDATE=").append(URLEncoder.encode(getCourseAttemptCompleteDate().toString(), "UTF-8"));
-		    	params.append("&CASCORE=").append(getCourseAttemptScore());
-		    	params.append("&CASTATUSID=").append(getCourseAttemptStatusID());
-		    	params.append("&CASTATUSDESC=").append(passedFailed);
-		    	params.append("&CASTAGE=").append(URLEncoder.encode(getCourseAttemptStage(), "UTF-8"));
-		    	params.append("&CAISMGRAPPRVL=").append(isCourseAttemptManagerApproved());
-		    	params.append("&COURSATTID=").append(getCourseAttemptID());
-		    	// deprecated. for backward compat.
-		    	params.append("&COURSEATTEMPTID=").append(getCourseAttemptID());
-		    	params.append("&COURSENAME=").append(URLEncoder.encode(course.getCourseName(), "UTF-8"));
+		    	params.append("companyID=").append(getCompanyID());
+		    	params.append("&courseAttemptID=").append(getCourseAttemptID());
+		    	params.append("&userProfileUserData=").append(URLEncoder.encode(user.getStringValue("USERDATA"), "UTF-8"));
+		    	params.append("&userProfileID=").append(user.getUserProfileID());
+		    	params.append("&userProfileLoginID=").append(URLEncoder.encode(user.getUserProfileNum(), "UTF-8"));
+		    	params.append("&courseID=").append(course.getCourseID());
+		    	params.append("&courseNumber=").append(URLEncoder.encode(course.getCourseNum(), "UTF-8"));
+		    	params.append("&courseUserData=").append(URLEncoder.encode(course.getStringValue("USERDATA"), "UTF-8"));
+		    	params.append("&courseName=").append(URLEncoder.encode(course.getCourseName(), "UTF-8"));
+		    	params.append("&startDate=").append(URLEncoder.encode(getCourseAttemptStartDate().toString(), "UTF-8"));
+		    	params.append("&completeDate=").append(URLEncoder.encode(getCourseAttemptCompleteDate().toString(), "UTF-8"));
+		    	params.append("&score=").append(getCourseAttemptScore());
+		    	params.append("&statusID=").append(getCourseAttemptStatusID());
+		    	params.append("&statusDescription=").append(passedFailed);
+		    	params.append("&aiccStage=").append(URLEncoder.encode(getCourseAttemptStage(), "UTF-8"));
+		    	params.append("&isManagerApproved=").append(isCourseAttemptManagerApproved());
 logger.debug("POSTING to callback URL: " + callbackURL);
 logger.debug("POSTING data: " + params);
 		    	result = HTTPUtils.postURL(callbackURL, params.toString());
@@ -655,7 +651,11 @@
 	}
 
 
-	public String toFormattedXML() {
+	public String toXML() {
+		return toXML(DETAIL_COMPLETE);
+	}
+
+	public String toXML(int detail) {
 		boolean error = false;
 		
 		ILSSession session = ILSSession.getAnonymous(getCompanyID());
@@ -673,25 +673,26 @@
 		StringBuffer xml = new StringBuffer();
 		UserProfile user = UserProfile.getUserProfile(session, getCourseAttemptUserProfileID());
 		Course course = Course.getCourse(session, getCourseAttemptCourseID());
-		xml.append("<CourseAttempt");
-		xml.append(" id=\""+getCourseAttemptID()+"\"");
-		xml.append(" companyID=\""+getCompanyID()+"\"");
-		xml.append(">\n");
-		xml.append(" <UserData>"+HTTPUtils.canonize(user.getStringValue("USERDATA"))+"</UserData>\n");
-		xml.append(" <UserProfileID>"+user.getUserProfileID()+"</UserProfileID>\n");
-		xml.append(" <UserProfileLogin>"+HTTPUtils.canonize(user.getUserProfileNum())+"</UserProfileLogin>\n");
-		xml.append(" <CourseID>").append(course.getCourseID()+"</CourseID>\n");
-		xml.append(" <CourseNumber>").append(HTTPUtils.canonize(course.getCourseNum())+"</CourseNumber>\n");
-		xml.append(" <CourseName>").append(HTTPUtils.canonize(course.getCourseName())+"</CourseName>\n");
-		xml.append(" <CourseAttemptStartDate>").append(HTTPUtils.canonize(df.format(getCourseAttemptStartDate()))+"</CourseAttemptStartDate>\n");
-		xml.append(" <CourseAttemptCompleteDate>").append(HTTPUtils.canonize(df.format(getCourseAttemptCompleteDate()))+"</CourseAttemptCompleteDate>\n");
-		xml.append(" <CourseAttemptScore>").append(getCourseAttemptScore()+"</CourseAttemptScore>\n");
-		xml.append(" <CourseAttemptStatus>").append(getCourseAttemptStatusID()+"</CourseAttemptStatus>\n");
-		xml.append(" <CourseAttemptStatusDescription>").append(passedFailed+"</CourseAttemptStatusDescription>\n");
-		xml.append(" <CourseAttemptAICCStage>").append(HTTPUtils.canonize(getCourseAttemptStage())+"</CourseAttemptAICCStage>\n");
-		xml.append(" <CourseAttemptIsManagerApproved>").append(isCourseAttemptManagerApproved()+"</CourseAttemptIsManagerApproved>\n");
-		xml.append("</CourseAttempt>\n");
+		xml.append("<courseAttempt");
+		xml.append(" courseAttemptID=\""+getCourseAttemptID()+"\"");
+		if (detail == DETAIL_HEADERONLY) {
+			xml.append("/>");
+		}
+		else {
+			xml.append(">");
 
+			xml.append(user.toXML(DETAIL_HEADERONLY));
+			xml.append(course.toXML(DETAIL_BRIEF));
+
+			xml.append("<startDate>").append(HTTPUtils.canonize(df.format(getCourseAttemptStartDate()))+"</startDate>");
+			xml.append("<completeDate>").append(HTTPUtils.canonize(df.format(getCourseAttemptCompleteDate()))+"</completeDate>");
+			xml.append("<score>").append(getCourseAttemptScore()+"</score>");
+			xml.append("<status statusID=\"").append(getCourseAttemptStatusID()+"\">"+passedFailed+"</status>");
+			xml.append("<aiccStage>").append(HTTPUtils.canonize(getCourseAttemptStage())+"</aiccStage>");
+			xml.append("<isManagerApproved>").append(isCourseAttemptManagerApproved()+"</isManagerApproved>");
+			xml.append("</courseAttempt>");
+		}
+
 		return xml.toString();
 	}
 

Modified: branches/1.6/webapp/WEB-INF/classes/versions.properties
===================================================================
--- branches/1.6/webapp/WEB-INF/classes/versions.properties	2016-02-16 23:07:51 UTC (rev 1391)
+++ branches/1.6/webapp/WEB-INF/classes/versions.properties	2016-02-16 23:22:04 UTC (rev 1392)
@@ -1 +1 @@
-LMS=V1.80.3
+LMS=V1.80.4

Modified: branches/1.6/webapp/WEB-INF/lib/crosswire.jar
===================================================================
(Binary files differ)

Modified: branches/1.6/webapp/WEB-INF/lib/ils.jar
===================================================================
(Binary files differ)

Modified: branches/1.6/webapp/api/course/get/index.jsp
===================================================================
--- branches/1.6/webapp/api/course/get/index.jsp	2016-02-16 23:07:51 UTC (rev 1391)
+++ branches/1.6/webapp/api/course/get/index.jsp	2016-02-16 23:22:04 UTC (rev 1392)
@@ -20,36 +20,37 @@
 
 <%
 
+	// standard service header ---------------------------------------
 	response.setContentType("text/xml");
-	String errorMsg = "";
-	//-- Company logic from login.jsp -------
-	// TODO: consolidate this somewhere
-	String requestURL = request.getRequestURL().toString() + "?" + request.getQueryString();
-	String co = com.resolutions.ils.Utils.getCompanyFromConfig(session, requestURL);
-	if (co == null) co = com.resolutions.ils.Utils.getSysConfig(session).getProperty("Company", null);
-	if (co == null) co = request.getParameter("co");
-	if (co != null) session.setAttribute("co", co);
-	co = (String) session.getAttribute("co");
-	Company company = Company.getCompany((co != null) ? Integer.parseInt(co):1);
-
+	int errCode = 0;
+	Company company = Company.getCompany(request);
+    
 	boolean apiEnabled = "on".equals(Utils.getSysConfig(session.getServletContext(), company.getCompanyID()).getProperty("APIEnable", "off"));
+	++errCode;
 	if (!apiEnabled) {
-		out.print("<error message=\"API not enabled in system management settings.\" />");
-	return;
+		out.print("<error code=\""+errCode+"\" message=\"API not enabled in system management settings.\"/>");
+		return;
 	}
-	//-----------------------
-	ILSSession ilsSession = null;
+
 	String userID = request.getParameter("ILSUSER");
 	String userPw = request.getParameter("ILSPASSWD");
-	ilsSession = ILSSession.login(company.getCompanyName(), userID, userPw);
+	ILSSession ilsSession = (userID != null && userPw != null)
+			? ILSSession.login(company.getCompanyName(), userID, userPw)
+			: (ILSSession)session.getAttribute("ilsSession");
+	++errCode;
 	if (ilsSession == null) {
-		out.print("<error message=\"Your iLS sign in information is not valid. Please try again.\" />");
+		out.print("<error code=\""+errCode+"\" message=\"Your iLS sign in information is not valid.\"/>");
 		return;
 	}
+	String detail = request.getParameter("detail");
+	int detailLevel = Course.DETAIL_COMPLETE;
+	if ("headeronly".equals(detail)) detailLevel = Course.DETAIL_HEADERONLY;
+	else if ("brief".equals(detail)) detailLevel = Course.DETAIL_BRIEF;
+	// end standard service header -----------------------------------
     
 	int courseID = -2; try { courseID = Integer.parseInt(request.getParameter("courseID")); } catch (Exception e) {}
 	if (courseID == -2) if ("ALL".equals(request.getParameter("courseID"))) courseID = -1;
-	String courseNum = request.getParameter("courseNum");
+	String courseNumber = request.getParameter("courseNumber");
 
 	Logger logger = Logger.getLogger(this.getClass());
 	Logger eventsLogger = Logger.getLogger("EVENTS");
@@ -59,34 +60,38 @@
 	SimpleDateFormat df_out = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
 	df_out.setTimeZone(TimeZone.getTimeZone("GMT"));
 
-	if (courseID > -2 || courseNum != null) {
+	if (courseID > -2 || courseNumber != null) {
 		Vector<Course> courses = null;
 		if (courseID == -1) courses = Course.getAllCourses(ilsSession);
 		else {
 			courses = new Vector<Course>();
 			if (courseID > -1) try { courses.add((Course)Course.getCourse(ilsSession, courseID)); } catch (Exception e) {}
-			else if (courseNum != null) try { courses.add((Course)Course.getCourseByNum(ilsSession, courseNum)); } catch (Exception e) {}
+			else if (courseNumber != null) try { courses.add((Course)Course.getCourseByNum(ilsSession, courseNumber)); } catch (Exception e) {}
 		}
-		out.print("<Courses count=\""+courses.size()+"\">\n");
+		out.print("<courses count=\""+courses.size()+"\">\n");
 		for (Object o : courses) {
-			out.print(((Course)o).toFormattedXML());
+			out.print(((Course)o).toXML(detailLevel));
 		}
-		out.print("</Courses>\n");
+		out.print("</courses>\n");
 		return;
 	}
 
 	response.setContentType("text/html");
 %>
 <html>
+<style>th { text-align:left; }</style>
 <body>
 <h1>course/get</h1>
 <p>Retrieve Courses</p>
 <h3>Parameters</h3>
 <table border="1">
-<tr><td><b>courseID</b></td><td>CourseID to retrieve; ALL, for entire course catalog</td></tr>
-<tr><td><b>courseNum</b></td><td>CourseNum to retrieve</td></tr>
-<tr><td><b>ILSUSER</b></td><td>ILS Login Credentials. Used to validate this API request.</td></tr>
-<tr><td><b>ILSPASSWD</b></td><td>ILS Login Credentials. Used to validate this API request.</td></tr>
+<tbody>
+<tr><th>courseID</th><td>CourseID to retrieve; ALL, for entire course catalog</td></tr>
+<tr><th>courseNumber</th><td>Course Number to retrieve</td></tr>
+<tr><th>detail</th><td>(complete), brief, headeronly</td></tr>
+<tr><th>ILSUSER</th><td>ILS Login Credentials. Used to validate this API request.</td></tr>
+<tr><th>ILSPASSWD</th><td>ILS Login Credentials. Used to validate this API request.</td></tr>
+</tbody>
 <table>
 </body>
 </html>

Modified: branches/1.6/webapp/api/courseattempt/get/index.jsp
===================================================================
--- branches/1.6/webapp/api/courseattempt/get/index.jsp	2016-02-16 23:07:51 UTC (rev 1391)
+++ branches/1.6/webapp/api/courseattempt/get/index.jsp	2016-02-16 23:22:04 UTC (rev 1392)
@@ -19,54 +19,60 @@
 <%@ page import="org.apache.log4j.Logger" %>
 
 <%
-
+	// standard service header ---------------------------------------
 	response.setContentType("text/xml");
-	String errorMsg = "";
-	//-- Company logic from login.jsp -------
-	// TODO: consolidate this somewhere
-	String requestURL = request.getRequestURL().toString() + "?" + request.getQueryString();
-	String co = com.resolutions.ils.Utils.getCompanyFromConfig(session, requestURL);
-	if (co == null) co = com.resolutions.ils.Utils.getSysConfig(session).getProperty("Company", null);
-	if (co == null) co = request.getParameter("co");
-	if (co != null) session.setAttribute("co", co);
-	co = (String) session.getAttribute("co");
-	Company company = Company.getCompany((co != null) ? Integer.parseInt(co):1);
-	ILSSession ilsSession = (ILSSession)session.getAttribute("ilsSession");
-
+	int errCode = 0;
+	Company company = Company.getCompany(request);
+    
 	boolean apiEnabled = "on".equals(Utils.getSysConfig(session.getServletContext(), company.getCompanyID()).getProperty("APIEnable", "off"));
-	if (!apiEnabled && ilsSession == null) {
-		out.print("<error message=\"API not enabled in system management settings.\" />");
-	return;
+	++errCode;
+	if (!apiEnabled) {
+		out.print("<error code=\""+errCode+"\" message=\"API not enabled in system management settings.\"/>");
+		return;
 	}
-	//-----------------------
+
 	String userID = request.getParameter("ILSUSER");
 	String userPw = request.getParameter("ILSPASSWD");
-	if (userID != null && userPw != null) {
-		ilsSession = ILSSession.login(company.getCompanyName(), userID, userPw);
-	}
-     
+	ILSSession ilsSession = (userID != null && userPw != null)
+			? ILSSession.login(company.getCompanyName(), userID, userPw)
+			: (ILSSession)session.getAttribute("ilsSession");
+	++errCode;
 	if (ilsSession == null) {
-		out.print("<error message=\"Your iLS sign in information is not valid. Please try again.\" />");
+		out.print("<error code=\""+errCode+"\" message=\"Your iLS sign in information is not valid.\"/>");
 		return;
 	}
+	String detail = request.getParameter("detail");
+	int detailLevel = org.crosswire.data.DataObject.DETAIL_COMPLETE;
+	if ("headeronly".equals(detail)) detailLevel = org.crosswire.data.DataObject.DETAIL_HEADERONLY;
+	else if ("brief".equals(detail)) detailLevel = org.crosswire.data.DataObject.DETAIL_BRIEF;
+	// end standard service header -----------------------------------
+
     
 	Logger logger = Logger.getLogger(this.getClass());
 	Logger eventsLogger = Logger.getLogger("EVENTS");
-	String statusMsg = "";
 	SimpleDateFormat df = new SimpleDateFormat("yyyyMMddhhmm");
 	df.setTimeZone(TimeZone.getTimeZone("GMT"));
 	SimpleDateFormat df_out = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
 	df_out.setTimeZone(TimeZone.getTimeZone("GMT"));
 
-	UserProfile current = new UserProfile();
-	current.defaultAll();
-	int currentRoleID = -1;
-	int currentLocationID = -1;
-	int profileID = -1;
+	int courseAttemptID = -1; try { courseAttemptID = Integer.parseInt( request.getParameter("courseAttemptID") ); } catch(Exception e) {}
 
 	String val = request.getParameter("startDateTime");
-	Date startDateTime = null;
-	try { startDateTime = df.parse(val); } catch (Exception e) {}
+	Date startDateTime = null; try { startDateTime = df.parse(val); } catch (Exception e) {}
+
+	Vector<CourseAttempt> cas = null;
+
+	++errCode;
+	if (courseAttemptID != -1) {
+		cas = new Vector<CourseAttempt>();
+		CourseAttempt ca = CourseAttempt.getCourseAttempt(ilsSession, courseAttemptID);
+
+		if (ca == null) {
+			out.print("<error code=\""+errCode+"\" message=\"Course Attempt ID not found.\"/>");
+			return;
+		}
+		cas.add(ca);
+	}
 	if (startDateTime != null) {
 		val = request.getParameter("endDateTime");
 		Date endDateTime = null;
@@ -75,27 +81,35 @@
 			return;
 		}
 
-		Vector cas = CourseAttempt.getCourseAttempts(ilsSession, startDateTime, endDateTime);
-		out.print("<CourseAttempts count=\""+cas.size()+"\" startDateTime=\""+df_out.format(startDateTime)+"\">\n");
+		cas = CourseAttempt.getCourseAttempts(ilsSession, startDateTime, endDateTime);
+	}
+
+	if (cas != null) {
+		out.print("<courseAttempts count=\""+cas.size()+"\""+(startDateTime != null ? (" startDateTime=\""+df_out.format(startDateTime)+"\""):"")+">\n");
 		for (Object o : cas) {
-			out.print(((CourseAttempt)o).toFormattedXML());
+			out.print(((CourseAttempt)o).toXML(detailLevel));
 		}
-		out.print("</CourseAttempts>\n");
+		out.print("</courseAttempts>\n");
 		return;
 	}
 	response.setContentType("text/html");
 %>
 <html>
+<style>th { text-align:left; }</style>
 <body>
 <h1>courseattempt/get</h1>
 <p>Retrieve Course Attempt records</p>
 <h3>Parameters</h3>
 <table border="1">
-<tr><td><b>startDateTime</b></td><td>the start of the date and time range for which to retrieve Course Attempt records, inclusive (yyyyMMddhhmm), e.g., 201201240000</td></tr>
-<tr><td><b>endDateTime</b></td><td>(optional) the end of the date and time range for which to retrieve Course Attempt records, exclusive (yyyyMMddhhmm), e.g., 201201250000</td></tr>
-<tr><td><b>profileID</b></td><td>(optional) restrict results to a single user</td></tr>
-<tr><td><b>ILSUSER</b></td><td>ILS Login Credentials. Used to validate this API request.</td></tr>
-<tr><td><b>ILSPASSWD</b></td><td>ILS Login Credentials. Used to validate this API request.</td></tr>
+<tbody>
+<tr><th>courseAttemptID</th><td>retrieve a specific course attempt by ID</td></tr>
+<tr><th>startDateTime</th><td>retrieve a set of course attempts by filters, the start of the date and time range for which to retrieve Course Attempt records, inclusive (yyyyMMddhhmm), e.g., 201201240000</td></tr>
+<tr><th>endDateTime</th><td>(optional) the end of the date and time range for which to retrieve Course Attempt records, exclusive (yyyyMMddhhmm), e.g., 201201250000</td></tr>
+<tr><th>profileID</th><td>(optional) restrict results to a single user</td></tr>
+<tr><th>detail</th><td>(complete), brief, headeronly</td></tr>
+<tr><th>ILSUSER</th><td>ILS Login Credentials. Used to validate this API request.</td></tr>
+<tr><th>ILSPASSWD</th><td>ILS Login Credentials. Used to validate this API request.</td></tr>
+</tbody>
 <table>
 </body>
 </html>




More information about the Ils-source mailing list