From scribe at crosswire.org  Mon Dec 11 17:39:59 2017
From: scribe at crosswire.org (scribe at crosswire.org)
Date: Mon, 11 Dec 2017 17:39:59 -0700
Subject: [Ils-source] r1560 - in trunk: src/com/resolutions/ils/data webapp
Message-ID: <E1eOYc3-0003J8-Ke@crosswire.org>

Author: scribe
Date: 2017-12-11 17:39:59 -0700 (Mon, 11 Dec 2017)
New Revision: 1560

Modified:
   trunk/src/com/resolutions/ils/data/CourseAttempt.java
   trunk/webapp/admin_systemmanagement.jsp
Log:
Added facility to check callback method


Modified: trunk/src/com/resolutions/ils/data/CourseAttempt.java
===================================================================
--- trunk/src/com/resolutions/ils/data/CourseAttempt.java	2017-11-08 19:04:20 UTC (rev 1559)
+++ trunk/src/com/resolutions/ils/data/CourseAttempt.java	2017-12-12 00:39:59 UTC (rev 1560)
@@ -761,6 +761,7 @@
 		else if (getCourseAttemptStatusID() == CourseAttempt.STATUS_FAILED) {
 			passedFailed = "FAILED";
 		}
+logger.debug("companyID: " + getCompanyID() + "; apiEnabled: " + apiEnabled + "; callbackURL: " + callbackURL + "; passedFailed: " + passedFailed);
 
 		if (apiEnabled && callbackURL != null) {
 			StringBuffer result = new StringBuffer();
@@ -798,6 +799,9 @@
 				save(orig);
 			}
 		}
+		else {
+			logger.debug("Callback not sent. " + (apiEnabled == false ? "API is not enabled" : "No callback URL is specified."));
+		}
 		logger.debug("end sendStatusUpdateEvent (error:"+error+")");
 		return error;
 	}

Modified: trunk/webapp/admin_systemmanagement.jsp
===================================================================
--- trunk/webapp/admin_systemmanagement.jsp	2017-11-08 19:04:20 UTC (rev 1559)
+++ trunk/webapp/admin_systemmanagement.jsp	2017-12-12 00:39:59 UTC (rev 1560)
@@ -415,6 +415,22 @@
     }
     catch (Exception e) { }	// ok, nothing to upload
 
+
+	if ("testCallback".equals(action)) {
+		logger.debug("Sending test Course Attempt");
+		CourseAttempt ca = new CourseAttempt();
+		ca.setValue("COMPANYID", ilsSession.getCompanyID());
+		ca.defaultAll();
+		ca.setCourseAttemptUserProfileID(user.getUserProfileID());
+		ca.setCourseAttemptCourseID(1);
+		ca.setCourseAttemptStartDate(new Date(System.currentTimeMillis()-60000));
+		ca.setCourseAttemptCompleteDate(new Date());
+		ca.setCourseAttemptStatusID(CourseAttempt.STATUS_FAILED);
+		ca.sendStatusUpdateEvent(pageContext.getServletContext());
+		statusMsg = "A test callback has been sent.";
+		logger.debug("Finished Sending test Course Attempt");
+	}
+
     if ("Save".equals(action)) {
     	boolean saveLog = false;
     	boolean saveSysconfig = false;
@@ -1289,7 +1305,7 @@
 	                            </tr>
 	                            <tr>
 	                              <td class="formHeadings">Callback URL - Course Complete: </td>
-	                              <td colspan="2"><input name="apiCallbackCourseComplete" type="text" value="<%=currentAPICallbackCourseComplete%>" size="40"/>                              </td>
+	                              <td colspan="2"><input id="apiCallbackCourseComplete" name="apiCallbackCourseComplete" type="text" value="<%=currentAPICallbackCourseComplete%>" size="40"/>                              </td>
 	                            </tr>
 	                            <tr>
 	                              <td>&nbsp;</td>
@@ -1297,8 +1313,11 @@
 	                            </tr>
 	                            <tr>
 	                              <td>&nbsp;</td>
-	                              <td colspan="2"><a href="#" onClick="document.getElementById('systemsave').submit()"><img style="border:0;margin:0px 3px 0px 3px;" src="images/save_btn.gif" width="72" height="24" alt=""/></a> <a href="employee.jsp"><img style="border:0;" src="images/cancel_btn.gif" width="72" height="24" alt=""/></a></td>
-	                            </tr>
+	                              <td colspan="2">
+					<a href="#" onClick="document.getElementById('systemsave').submit()"><img style="border:0;margin:0px 3px 0px 3px;" src="images/save_btn.gif" width="72" height="24" alt=""/></a> 
+					<a href="employee.jsp"><img style="border:0;" src="images/cancel_btn.gif" width="72" height="24" alt=""/></a>
+					<a href="#" onClick="$('#testAPICallbackCourseComplete').val($('#apiCallbackCourseComplete').val()); document.getElementById('testCallback').submit(); return false"><img style="border:0;margin:0px 3px 0px 3px;" src="images/run_btn.gif" height="24" alt=""/></a> 
+	                            </td></tr>
 				            </table> </td>
 				          </tr>
 	    </table>
@@ -1552,6 +1571,12 @@
 </div>
 <%@ include file="footer.jsp" %>
 </div>
+<div style="display:none;">
+<form id="testCallback" method="get" action="admin_systemmanagement.jsp">
+<input name="action" value="testCallback" type="hidden"/>
+<input id="testAPICallbackCourseComplete" name="apiCallbackCourseComplete" type="hidden"/>                              </td>
+</form>
+</div>
 
 </body>
 </html>



