Index: lams_tool_zoom/conf/language/lams/ApplicationResources.properties =================================================================== diff -u -r2cf1e086b82a29fae22136351fc7a44821181323 -reeaae70bac24a36a5f05a5d56638df29c1a495c5 --- lams_tool_zoom/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision 2cf1e086b82a29fae22136351fc7a44821181323) +++ lams_tool_zoom/conf/language/lams/ApplicationResources.properties (.../ApplicationResources.properties) (revision eeaae70bac24a36a5f05a5d56638df29c1a495c5) @@ -37,7 +37,7 @@ label.off =Off label.monitoring.startConference =Start conference label.learning.joinConference =Join conference -label.learning.conferenceNotAvailable =Zoom is not available yet as your instruction hasn't started. Please see your instructor for further details. +label.learning.conferenceNotAvailable =Zoom meeting is not available yet. Please see your instructor for further details. label.refresh =Refresh label.cancel =Cancel message.defineLaterSet =Please wait for the teacher to complete the contents of this activity Index: lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/service/ZoomService.java =================================================================== diff -u -r2cf1e086b82a29fae22136351fc7a44821181323 -reeaae70bac24a36a5f05a5d56638df29c1a495c5 --- lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/service/ZoomService.java (.../ZoomService.java) (revision 2cf1e086b82a29fae22136351fc7a44821181323) +++ lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/service/ZoomService.java (.../ZoomService.java) (revision eeaae70bac24a36a5f05a5d56638df29c1a495c5) @@ -365,6 +365,10 @@ return false; } + public String getContributionURL(Long toolContentId) { + return ZoomConstants.TOOL_CONTRIBUTE_URL + toolContentId; + } + /* IZoomService Methods */ @Override @@ -662,14 +666,8 @@ return zoom.getMeetingStartUrl(); } if (zoom.getApi() == null) { - throw new ZoomException("Can not create a meeting without chosen API keys"); + throw new ZoomException("Can not create a meeting without API keys chosen"); } - URL url = new URL("https://api.zoom.us/v2/users/" + zoom.getApi().getEmail() + "/meetings"); - HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(); - connection.setRequestMethod("POST"); - connection.setRequestProperty("Content-Type", "application/json"); - connection.setRequestProperty("Authorization", "Bearer " + ZoomService.generateJWT(zoom.getApi())); - connection.setDoOutput(true); JSONObject bodyJSON = new JSONObject(); JSONObject settings = new JSONObject(); settings.put("approval_type", 0); @@ -679,8 +677,9 @@ sdf.setTimeZone(TimeZone.getTimeZone("GMT")); String startTime = sdf.format(currentTime); bodyJSON.put("topic", zoom.getTitle()).put("type", 2).put("start_time", startTime).put("settings", settings); - ZoomService.writeRequestBody(connection, bodyJSON.toString()); + HttpURLConnection connection = ZoomService.getZoomConnection("users/" + zoom.getApi().getEmail() + "/meetings", + "POST", bodyJSON.toString(), zoom.getApi()); JSONObject responseJSON = ZoomService.getReponse(connection); String startURL = responseJSON.getString("start_url"); String meetingId = String.valueOf(responseJSON.getLong("id")); @@ -690,6 +689,9 @@ zoom.setMeetingStartUrl(startURL); zoom.setMeetingId(meetingId); zoomDAO.update(zoom); + if (logger.isDebugEnabled()) { + logger.debug("Created meeting: " + meetingId); + } return startURL; } @@ -701,54 +703,74 @@ } ZoomUserDTO userDTO = createUserDTO(user); Zoom zoom = (Zoom) zoomDAO.find(Zoom.class, zoomUid); - URL url = new URL("https://api.zoom.us/v2/meetings/" + zoom.getMeetingId() + "/registrants"); - HttpsURLConnection con = (HttpsURLConnection) url.openConnection(); - con.setRequestMethod("POST"); - con.setRequestProperty("Content-Type", "application/json"); - con.setRequestProperty("Authorization", "Bearer " + ZoomService.generateJWT(zoom.getApi())); - con.setDoOutput(true); + JSONObject bodyJSON = new JSONObject(); String lastName = userDTO.getLastName(); if (!sessionName.endsWith(" learners")) { lastName += " (" + sessionName + ")"; } bodyJSON.put("email", userDTO.getEmail()).put("first_name", userDTO.getFirstName()).put("last_name", lastName); - ZoomService.writeRequestBody(con, bodyJSON.toString()); - JSONObject responseJSON = ZoomService.getReponse(con); + HttpURLConnection connection = ZoomService.getZoomConnection("meetings/" + zoom.getMeetingId() + "/registrants", + "POST", bodyJSON.toString(), zoom.getApi()); + JSONObject responseJSON = ZoomService.getReponse(connection); String meetingJoinURL = responseJSON.getString("join_url"); user.setMeetingJoinUrl(meetingJoinURL); zoomUserDAO.update(user); + if (logger.isDebugEnabled()) { + logger.debug("Registerd user with UID: " + user.getUid() + " for meeting: " + zoom.getMeetingId()); + } return meetingJoinURL; } private static String generateJWT(ZoomApi api) { - Date expiration = new Date(System.currentTimeMillis() + 10000); + Date expiration = new Date(System.currentTimeMillis() + ZoomConstants.JWT_EXPIRATION_MILISECONDS); return Jwts.builder().setHeaderParam("typ", "JWT").setIssuer(api.getKey()).setExpiration(expiration) .signWith(SignatureAlgorithm.HS256, api.getSecret().getBytes()).compact(); } - private static void writeRequestBody(HttpURLConnection connection, String body) throws IOException { - OutputStream os = connection.getOutputStream(); - OutputStreamWriter osw = new OutputStreamWriter(os, "UTF-8"); - osw.write(body); - osw.flush(); - osw.close(); - os.close(); + private static HttpURLConnection getZoomConnection(String urlSuffix, String method, String body, ZoomApi api) + throws IOException { + URL url = new URL(ZoomConstants.ZOOM_API_URL + urlSuffix); + HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(); + switch (method) { + case "PATCH": + ZoomService.setRequestMethod(connection, method); + connection.setRequestProperty("Content-Type", "application/json"); + connection.setRequestProperty("Authorization", "Bearer " + ZoomService.generateJWT(api)); + connection.setDoOutput(true); + break; + case "POST": + connection.setRequestProperty("Content-Type", "application/json"); + connection.setRequestProperty("Authorization", "Bearer " + ZoomService.generateJWT(api)); + connection.setDoOutput(true); + connection.setRequestMethod(method); + break; + default: + connection.setRequestMethod(method); + break; + } + if (body != null) { + OutputStream os = connection.getOutputStream(); + OutputStreamWriter osw = new OutputStreamWriter(os, "UTF-8"); + osw.write(body); + osw.flush(); + osw.close(); + os.close(); + } + return connection; } private static void switchOffRegistrantEmails(ZoomApi api, String meetingId) throws IOException, JSONException { - URL url = new URL("https://api.zoom.us/v2/meetings/" + meetingId); - HttpsURLConnection connection = (HttpsURLConnection) url.openConnection(); - ZoomService.setRequestMethod(connection, "PATCH"); - connection.setRequestProperty("Content-Type", "application/json"); - connection.setRequestProperty("Authorization", "Bearer " + ZoomService.generateJWT(api)); - connection.setDoOutput(true); JSONObject bodyJSON = new JSONObject(); JSONObject settings = new JSONObject(); settings.put("registrants_confirmation_email", false); bodyJSON.put("settings", settings); - ZoomService.writeRequestBody(connection, bodyJSON.toString()); + HttpURLConnection connection = ZoomService.getZoomConnection("meetings/" + meetingId, "PATCH", + bodyJSON.toString(), api); ZoomService.getReponse(connection); + if (logger.isDebugEnabled()) { + logger.debug("Switched off registrant emails for meeting: " + meetingId); + } } private static void setRequestMethod(HttpURLConnection connection, String method) { Index: lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/util/ZoomConstants.java =================================================================== diff -u -r2cf1e086b82a29fae22136351fc7a44821181323 -reeaae70bac24a36a5f05a5d56638df29c1a495c5 --- lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/util/ZoomConstants.java (.../ZoomConstants.java) (revision 2cf1e086b82a29fae22136351fc7a44821181323) +++ lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/util/ZoomConstants.java (.../ZoomConstants.java) (revision eeaae70bac24a36a5f05a5d56638df29c1a495c5) @@ -50,7 +50,12 @@ // Tool signature public static final String TOOL_SIGNATURE = "lazoom10"; + public static final String TOOL_CONTRIBUTE_URL = "tool/" + TOOL_SIGNATURE + + "/monitoring.do?dispatch=startMeeting&toolContentID="; + public static final long JWT_EXPIRATION_MILISECONDS = 5000; + public static final String ZOOM_API_URL = "https://api.zoom.us/v2/"; + private ZoomConstants() { // prevent construction } Index: lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/actions/LearningAction.java =================================================================== diff -u -r2cf1e086b82a29fae22136351fc7a44821181323 -reeaae70bac24a36a5f05a5d56638df29c1a495c5 --- lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/actions/LearningAction.java (.../LearningAction.java) (revision 2cf1e086b82a29fae22136351fc7a44821181323) +++ lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/actions/LearningAction.java (.../LearningAction.java) (revision eeaae70bac24a36a5f05a5d56638df29c1a495c5) @@ -120,22 +120,6 @@ return user; } - public ActionForward openLearnerMeeting(ActionMapping mapping, ActionForm form, HttpServletRequest request, - HttpServletResponse response) throws Exception { - - // get user uid parameter - Long uid = WebUtil.readLongParam(request, ZoomConstants.PARAM_USER_UID); - ZoomUser user = zoomService.getUserByUID(uid); - - org.lamsfoundation.lams.usermanagement.dto.UserDTO lamsUserDTO = (org.lamsfoundation.lams.usermanagement.dto.UserDTO) SessionManager - .getSession().getAttribute(AttributeNames.USER); - - ZoomSession session = zoomService.getSessionBySessionId(user.getZoomSession().getSessionId()); - - return null; - - } - public ActionForward openNotebook(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { @@ -268,6 +252,8 @@ userDTO.setNotebookEntryDTO(new NotebookEntryDTO(entry)); } request.setAttribute(ZoomConstants.ATTR_USER_DTO, userDTO); + // set toolSessionID in request + request.setAttribute(ZoomConstants.ATTR_TOOL_SESSION_ID, session.getSessionId()); // String dispatchValue = new String(); // boolean meetingOpen = false; @@ -277,25 +263,25 @@ // } else { // } - zoomService.chooseApiKeys(zoom.getUid()); - String startURL = zoom.getMeetingStartUrl(); - if (zoom.getMeetingId() == null) { - startURL = zoomService.createMeeting(zoom.getUid()); - } +// String startURL = zoom.getMeetingStartUrl(); +// +// if (zoom.getMeetingId() != null) { +// zoomService.chooseApiKeys(zoom.getUid()); +// startURL = zoomService.createMeeting(zoom.getUid()); +// } - String meetingURL = null; - if (startURL == null) { + String meetingURL = user.getMeetingJoinUrl(); + if (meetingURL == null && zoom.getMeetingId() != null) { meetingURL = zoomService.registerUser(zoom.getUid(), user.getUid(), session.getSessionName()); - } else { - meetingURL = startURL; - zoom.setMeetingStartUrl(null); - zoomService.saveOrUpdateZoom(zoom); } + +// else { +// meetingURL = startURL; +// zoom.setMeetingStartUrl(null); +// zoomService.saveOrUpdateZoom(zoom); +// } request.setAttribute(ZoomConstants.ATTR_MEETING_URL, meetingURL); - // set toolSessionID in request - request.setAttribute(ZoomConstants.ATTR_TOOL_SESSION_ID, session.getSessionId()); - return mapping.findForward("zoom"); } } Index: lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/actions/MonitoringAction.java =================================================================== diff -u -r2cf1e086b82a29fae22136351fc7a44821181323 -reeaae70bac24a36a5f05a5d56638df29c1a495c5 --- lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/actions/MonitoringAction.java (.../MonitoringAction.java) (revision 2cf1e086b82a29fae22136351fc7a44821181323) +++ lams_tool_zoom/src/java/org/lamsfoundation/lams/tool/zoom/web/actions/MonitoringAction.java (.../MonitoringAction.java) (revision eeaae70bac24a36a5f05a5d56638df29c1a495c5) @@ -104,22 +104,21 @@ public ActionForward startMeeting(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { + Long toolContentID = WebUtil.readLongParam(request, AttributeNames.PARAM_TOOL_CONTENT_ID, false); + Zoom zoom = zoomService.getZoomByContentId(toolContentID); - MonitoringForm monitoringForm = (MonitoringForm) form; + ContentDTO contentDTO = new ContentDTO(); + contentDTO.setTitle(zoom.getTitle()); + contentDTO.setInstructions(zoom.getInstructions()); + request.setAttribute(ZoomConstants.ATTR_CONTENT_DTO, contentDTO); - // get zoom session - ZoomSession session = zoomService.getSessionBySessionId(monitoringForm.getToolSessionID()); + String meetingURL = zoom.getMeetingStartUrl(); + if (meetingURL == null) { + zoomService.chooseApiKeys(zoom.getUid()); + meetingURL = zoomService.createMeeting(zoom.getUid()); + } + request.setAttribute(ZoomConstants.ATTR_MEETING_URL, meetingURL); - // Get LAMS userDTO - org.lamsfoundation.lams.usermanagement.dto.UserDTO lamsUserDTO = (org.lamsfoundation.lams.usermanagement.dto.UserDTO) SessionManager - .getSession().getAttribute(AttributeNames.USER); - - String meetingKey; - - // if the meeting is already created, redirect the monitor to the meeting directly - - zoomService.saveOrUpdateZoomSession(session); - - return null; + return mapping.findForward("learning"); } } Index: lams_tool_zoom/web/WEB-INF/struts-config.xml =================================================================== diff -u -r2cf1e086b82a29fae22136351fc7a44821181323 -reeaae70bac24a36a5f05a5d56638df29c1a495c5 --- lams_tool_zoom/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision 2cf1e086b82a29fae22136351fc7a44821181323) +++ lams_tool_zoom/web/WEB-INF/struts-config.xml (.../struts-config.xml) (revision eeaae70bac24a36a5f05a5d56638df29c1a495c5) @@ -64,6 +64,11 @@ path="tiles:/monitoring/zoom_display" redirect="false" /> + - + - function disableFinishButton() { - document.getElementById("finishButton").disabled = true; - } - - function validateForm() { - - // Validates that there's input from the user. - - // disables the Finish button to avoid double submittion - disableFinishButton(); - - if (mode == "learner") { - // if this is learner mode, then we add this validation see (LDEV-1319) - - if (document.learningForm.entryText.value == "") { - - // if the input is blank, then we further inquire to make sure it is correct - if (confirm("message.learner.blank.input")) { - // if correct, submit form - return true; - } else { - // otherwise, focus on the text area - document.learningForm.entryText.focus(); - document.getElementById("finishButton").disabled = false; - return false; - } - } else { - // there was something on the form, so submit the form - return true; - } - } - } - - -
- - - - - -

- -

- - - -
-
- + + +

+ +

+ + + +
+ + + +