From 86f49362ec2a9a0fb99ca5c22491bcc7da3cdbe3 Mon Sep 17 00:00:00 2001 From: Damian Sobieralski Date: Wed, 13 Sep 2023 09:48:48 -0400 Subject: [PATCH 1/7] LMSA-7975 - first pass (not done) at feature --- .../controller/CrosslistController.java | 88 ++++++++ .../lms/crosslist/model/FindParentModel.java | 45 ++++ .../lms/crosslist/model/FindParentResult.java | 47 ++++ .../resources/templates/findParentCourse.html | 207 ++++++++++++++++++ 4 files changed, 387 insertions(+) create mode 100644 src/main/java/edu/iu/uits/lms/crosslist/model/FindParentModel.java create mode 100644 src/main/java/edu/iu/uits/lms/crosslist/model/FindParentResult.java create mode 100644 src/main/resources/templates/findParentCourse.html diff --git a/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java b/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java index e41d168..c1b0e39 100644 --- a/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java +++ b/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java @@ -34,6 +34,7 @@ */ import com.fasterxml.jackson.databind.ObjectMapper; +import edu.iu.uits.lms.canvas.config.CanvasConfiguration; import edu.iu.uits.lms.canvas.model.CanvasTerm; import edu.iu.uits.lms.canvas.model.Course; import edu.iu.uits.lms.canvas.model.Section; @@ -43,6 +44,8 @@ import edu.iu.uits.lms.canvas.services.TermService; import edu.iu.uits.lms.common.session.CourseSessionService; import edu.iu.uits.lms.crosslist.CrosslistConstants; +import edu.iu.uits.lms.crosslist.model.FindParentModel; +import edu.iu.uits.lms.crosslist.model.FindParentResult; import edu.iu.uits.lms.crosslist.model.ImpersonationModel; import edu.iu.uits.lms.crosslist.model.SectionUIDisplay; import edu.iu.uits.lms.crosslist.model.SectionWrapper; @@ -127,6 +130,9 @@ public class CrosslistController extends OidcTokenAwareController { @Autowired private CourseSessionService courseSessionService; + @Autowired + private CanvasConfiguration canvasConfiguration; + private Course getValidatedCourse(OidcAuthenticationToken token, HttpSession session) { OidcTokenUtils oidcTokenUtils = new OidcTokenUtils(token); String courseId = oidcTokenUtils.getCourseId(); @@ -904,6 +910,88 @@ public String endSelfImpersonation(@PathVariable("courseId") String courseId, @M return main(courseId, model, session); } + @RequestMapping("/lookup-launch") + @Secured({LTIConstants.ADMIN_AUTHORITY, LTIConstants.INSTRUCTOR_AUTHORITY}) + public String lookupLaunch(@ModelAttribute FindParentModel findParentModel, Model model, HttpServletRequest request) { + OidcAuthenticationToken token = getTokenWithoutContext(); + OidcTokenUtils oidcTokenUtils = new OidcTokenUtils(token); + String courseId = oidcTokenUtils.getCourseId(); + + OidcAuthenticationToken sessionToken = courseSessionService.getAttributeFromSession(request.getSession(), courseId, OidcTokenAwareController.SESSION_TOKEN_KEY, OidcAuthenticationToken.class); + + if (sessionToken == null) { + courseSessionService.addAttributeToSession(request.getSession(), courseId, OidcTokenAwareController.SESSION_TOKEN_KEY, token); + } + +// model.addAttribute("courseId", courseId); +// model.addAttribute("hideFooter", true); + +// SubmissionStatus status = new SubmissionStatus(); +// status.setStatusClass(CrosslistConstants.STATUS_SUCCESS); +// status.setStatusMessage("Ta dah!"); +// +// model.addAttribute("submissionStatus", status); + + return "findParentCourse"; + } + + @PostMapping(value = "/lookup-search-sisid") + @Secured({LTIConstants.BASE_USER_AUTHORITY}) + public String lookupSearchBySisId(@ModelAttribute FindParentModel findParentModel, Model model, HttpSession session) { + log.info("SIS search text = {}", findParentModel.getSisIdSearch()); + + FindParentResult findParentResult = new FindParentResult(); + + if (findParentModel.getSisIdSearch() != null && ! findParentModel.getSisIdSearch().trim().isEmpty()) { + Section section = sectionService.getSection(String.format("sis_section_id:%s", findParentModel.getSisIdSearch())); + + if (section != null) { + log.info("Found section = {}", section); + + if (section.getSis_course_id() != null && section.getSis_section_id() != null && + ! section.getSis_course_id().isEmpty() && ! section.getSis_section_id().isEmpty() && + ! section.getSis_course_id().equals(section.getSis_section_id())) { + Course course = courseService.getCourse(section.getCourse_id()); + + if (course != null) { + log.info("section is crosslisted to {} with name {}", + section.getSis_course_id(), course.getName()); + log.info("course {}", course); + + findParentResult.setShowCourseInfo(true); + findParentResult.setStatusMessage("WOOOOO!!!!"); + findParentResult.setName(course.getName()); + findParentResult.setSisCourseId(course.getSisCourseId()); + findParentResult.setUrl(canvasConfiguration.getBaseUrl()); + findParentResult.setStatusCssClass(CrosslistConstants.STATUS_SUCCESS); + findParentResult.setStatusIconCssClasses("rvt-color-green rvt-bg-green-100"); + } + } else { + log.info("Section is NOT crosslisted"); + } + } else { + log.info("Couldn't find section = {}", section); + } + } + + model.addAttribute("findParentResult", findParentResult); + return "findParentCourse"; + } + + @PostMapping(value = "/lookup-search-termandclassnumber") + @Secured({LTIConstants.BASE_USER_AUTHORITY}) + public String lookupSearchByTermAndClassNUmber(@ModelAttribute FindParentModel findParentModel, Model model, HttpSession session) { + log.info("Term by Class Number = {}", findParentModel.getTermByClassNumber()); + log.info("Class Number search text = {}", findParentModel.getClassNumberSearch()); + return "findParentCourse"; + } + + @PostMapping(value = "/lookup-search-canvascourseid") + @Secured({LTIConstants.BASE_USER_AUTHORITY}) + public String lookupSearchByCourseId(@ModelAttribute FindParentModel findParentModel, Model model, HttpSession session) { + log.info("Canvas CourseId search text = {}", findParentModel.getCanvasCourseIdSearch()); + return "findParentCourse"; + } private List removeSectionUiDisplayBySectionName(@NonNull List oldList, @NonNull String toRemoveSectionName) { List newList = new ArrayList(); diff --git a/src/main/java/edu/iu/uits/lms/crosslist/model/FindParentModel.java b/src/main/java/edu/iu/uits/lms/crosslist/model/FindParentModel.java new file mode 100644 index 0000000..a153e1d --- /dev/null +++ b/src/main/java/edu/iu/uits/lms/crosslist/model/FindParentModel.java @@ -0,0 +1,45 @@ +package edu.iu.uits.lms.crosslist.model; + +/*- + * #%L + * lms-lti-crosslist + * %% + * Copyright (C) 2015 - 2023 Indiana University + * %% + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the Indiana University nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +import lombok.Data; + +@Data +public class FindParentModel { + private String radioSearch; + private String sisIdSearch; + private String termByClassNumber; + private String classNumberSearch; + private String canvasCourseIdSearch; +} \ No newline at end of file diff --git a/src/main/java/edu/iu/uits/lms/crosslist/model/FindParentResult.java b/src/main/java/edu/iu/uits/lms/crosslist/model/FindParentResult.java new file mode 100644 index 0000000..808ef07 --- /dev/null +++ b/src/main/java/edu/iu/uits/lms/crosslist/model/FindParentResult.java @@ -0,0 +1,47 @@ +package edu.iu.uits.lms.crosslist.model; + +/*- + * #%L + * lms-lti-crosslist + * %% + * Copyright (C) 2015 - 2023 Indiana University + * %% + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the Indiana University nor the names of its contributors + * may be used to endorse or promote products derived from this software without + * specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE + * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +import lombok.Data; + +@Data +public class FindParentResult { + private String url; + private String name; + private String sisCourseId; + private boolean showCourseInfo; + private String statusMessage; + private String statusCssClass; + private String statusIconCssClasses; +} diff --git a/src/main/resources/templates/findParentCourse.html b/src/main/resources/templates/findParentCourse.html new file mode 100644 index 0000000..bccfc1c --- /dev/null +++ b/src/main/resources/templates/findParentCourse.html @@ -0,0 +1,207 @@ + + + + + + + Find parent course + + +
+
+

Find parent course

+
+ +
+ This tool will only return exact matches. +
+ +
+ Find by +
    +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
  • +
    + + +
    +
  • +
+
+ +
+
+ +
Example: SP22-BL-FOLK-E295-4441
+
+ +
+
+ +
+ +
+
+ +
+
+ + +
+
+ +
Example: 4441
+
+ +
+
+ +
+ +
+
+ +
+
+ +
Example: 2167456
+
+ +
+
+ +
+ +
+
+ +
+ +
+ +

Parent course found

+
+
+ +
+ SP22-BL-FOLK-E295-1234 +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + \ No newline at end of file From bd6dda823c966998d91455c0532545451860dbf7 Mon Sep 17 00:00:00 2001 From: Damian Sobieralski Date: Tue, 19 Sep 2023 11:45:53 -0400 Subject: [PATCH 2/7] LMSA-7975 - next pass (not done) at feature --- examples/crosslisting-lookup.json | 28 ++++++ pom.xml | 2 +- .../lms/crosslist/CrosslistConstants.java | 8 ++ .../controller/CrosslistController.java | 92 ++++++++++++------- .../lms/crosslist/model/FindParentModel.java | 2 +- .../lms/crosslist/model/FindParentResult.java | 2 +- .../crosslist/service/CrosslistService.java | 63 +++++++++++++ .../resources/static/css/crosslisting.css | 4 + .../resources/templates/findParentCourse.html | 12 ++- src/main/resources/templates/layout.html | 3 + 10 files changed, 173 insertions(+), 43 deletions(-) create mode 100644 examples/crosslisting-lookup.json diff --git a/examples/crosslisting-lookup.json b/examples/crosslisting-lookup.json new file mode 100644 index 0000000..372aaba --- /dev/null +++ b/examples/crosslisting-lookup.json @@ -0,0 +1,28 @@ +{ + "title": "Cross-listing Lookup Parent", + "description": "For Looking up a course's parent course if cross-listed in Canvas.", + "oidc_initiation_url": "http://localhost:8080/lti/login_initiation/lms_lti_crosslisting", + "target_link_uri": "http://localhost:8080/app/lookup-launch", + "extensions": [ + { + "domain": "localhost", + "platform": "canvas.instructure.com", + "privacy_level": "public", + "settings": { + "placements": [ + { + "enabled": true, + "placement": "course_settings_sub_navigation", + "message_type": "LtiResourceLinkRequest" + } + ] + } + } + ], + "public_jwk_url": "http://localhost:8080/.well-known/jwks.json", + "custom_fields": { + "instructure_membership_roles": "$com.Instructure.membership.roles", + "canvas_course_id": "$Canvas.course.id", + "canvas_user_login_id": "$Canvas.user.loginId" + } +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 6db8641..c847871 100644 --- a/pom.xml +++ b/pom.xml @@ -76,7 +76,7 @@ 17 3.7.1 5.2.5.2 - 5.2.15 + 5.2.16-SNAPSHOT 4.8 2021.0.8 0.47 diff --git a/src/main/java/edu/iu/uits/lms/crosslist/CrosslistConstants.java b/src/main/java/edu/iu/uits/lms/crosslist/CrosslistConstants.java index 861ecbb..0c8b6ca 100644 --- a/src/main/java/edu/iu/uits/lms/crosslist/CrosslistConstants.java +++ b/src/main/java/edu/iu/uits/lms/crosslist/CrosslistConstants.java @@ -50,6 +50,14 @@ public interface CrosslistConstants { String ACTION_IMPERSONATE = "impersonate"; String ACTION_END_IMPERSONATE = "end_impersonate"; + String LOOKUP_SUCCESS_FOUND_MESSAGE = "Parent course is found"; + String LOOKUP_FAILURE_COURSE_NOT_CROSSLISTED_MESSAGE = "This course has not been crosslisted"; + String LOOKUP_FAILURE_SECTION_NOT_FOUND_IN_CANVAS_MESSAGE = "This section has not been found in Canvas"; + String LOOKUP_FAILURE_SECTION_NOT_FOUND_IN_SIS_MESSAGE = "Section not found in SIS"; + + String LOOKUP_SUCCESS_CSS = "rvt-color-green rvt-bg-green-100"; + String LOOKUP_FAILURE_CSS = "rvt-orange-green rvt-bg-orange-100"; + String MODE_EDIT = "editMode"; String STATUS_SUCCESS = "rvt-alert--success"; diff --git a/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java b/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java index f336d1a..a0b44af 100644 --- a/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java +++ b/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java @@ -34,7 +34,6 @@ */ import com.fasterxml.jackson.databind.ObjectMapper; -import edu.iu.uits.lms.canvas.config.CanvasConfiguration; import edu.iu.uits.lms.canvas.model.CanvasTerm; import edu.iu.uits.lms.canvas.model.Course; import edu.iu.uits.lms.canvas.model.Section; @@ -130,9 +129,6 @@ public class CrosslistController extends OidcTokenAwareController { @Autowired private CourseSessionService courseSessionService; - @Autowired - private CanvasConfiguration canvasConfiguration; - private Course getValidatedCourse(OidcAuthenticationToken token, HttpSession session) { OidcTokenUtils oidcTokenUtils = new OidcTokenUtils(token); String courseId = oidcTokenUtils.getCourseId(); @@ -911,49 +907,50 @@ public String lookupLaunch(@ModelAttribute FindParentModel findParentModel, Mode public String lookupSearchBySisId(@ModelAttribute FindParentModel findParentModel, Model model, HttpSession session) { log.info("SIS search text = {}", findParentModel.getSisIdSearch()); - FindParentResult findParentResult = new FindParentResult(); + FindParentResult findParentResult = null; if (findParentModel.getSisIdSearch() != null && ! findParentModel.getSisIdSearch().trim().isEmpty()) { - Section section = sectionService.getSection(String.format("sis_section_id:%s", findParentModel.getSisIdSearch())); +// Section section = sectionService.getSection(String.format("sis_section_id:%s", findParentModel.getSisIdSearch())); - if (section != null) { - log.info("Found section = {}", section); - - if (section.getSis_course_id() != null && section.getSis_section_id() != null && - ! section.getSis_course_id().isEmpty() && ! section.getSis_section_id().isEmpty() && - ! section.getSis_course_id().equals(section.getSis_section_id())) { - Course course = courseService.getCourse(section.getCourse_id()); - - if (course != null) { - log.info("section is crosslisted to {} with name {}", - section.getSis_course_id(), course.getName()); - log.info("course {}", course); - - findParentResult.setShowCourseInfo(true); - findParentResult.setStatusMessage("WOOOOO!!!!"); - findParentResult.setName(course.getName()); - findParentResult.setSisCourseId(course.getSisCourseId()); - findParentResult.setUrl(canvasConfiguration.getBaseUrl()); - findParentResult.setStatusCssClass(CrosslistConstants.STATUS_SUCCESS); - findParentResult.setStatusIconCssClasses("rvt-color-green rvt-bg-green-100"); - } - } else { - log.info("Section is NOT crosslisted"); - } - } else { - log.info("Couldn't find section = {}", section); - } + SisCourse sisCourse = sisService.getSisCourseBySiteId(findParentModel.getSisIdSearch().trim()); + findParentResult = crosslistService.processSisLookup(sisCourse); + } + + if (findParentResult != null) { + model.addAttribute("findParentResult", findParentResult); } - model.addAttribute("findParentResult", findParentResult); return "findParentCourse"; } @PostMapping(value = "/lookup-search-termandclassnumber") @Secured({LTIConstants.BASE_USER_AUTHORITY}) public String lookupSearchByTermAndClassNUmber(@ModelAttribute FindParentModel findParentModel, Model model, HttpSession session) { - log.info("Term by Class Number = {}", findParentModel.getTermByClassNumber()); + log.info("Term by Class Number = {}", findParentModel.getTermByClassNumberSearch()); log.info("Class Number search text = {}", findParentModel.getClassNumberSearch()); + + FindParentResult findParentResult = null; + + if (findParentModel.getTermByClassNumberSearch() != null && ! findParentModel.getTermByClassNumberSearch().trim().isEmpty() && + findParentModel.getClassNumberSearch() != null && ! findParentModel.getClassNumberSearch().trim().isEmpty()) { + + final String strm = findParentModel.getTermByClassNumberSearch().trim(); + final String classNumber = findParentModel.getClassNumberSearch().trim(); + + final String iuSiteId = sisService.getIuSiteIdFromStrmAndClassNumber(strm, classNumber); + + SisCourse sisCourse = sisService.getSisCourseBySiteId(iuSiteId); + +// Section section = sectionService.getSection(String.format("sis_section_id:%s", iuSiteId)); + + findParentResult = crosslistService.processSisLookup(sisCourse); + } + + if (findParentResult != null) { + model.addAttribute("findParentResult", findParentResult); + } + + return "findParentCourse"; } @@ -961,6 +958,31 @@ public String lookupSearchByTermAndClassNUmber(@ModelAttribute FindParentModel f @Secured({LTIConstants.BASE_USER_AUTHORITY}) public String lookupSearchByCourseId(@ModelAttribute FindParentModel findParentModel, Model model, HttpSession session) { log.info("Canvas CourseId search text = {}", findParentModel.getCanvasCourseIdSearch()); + + FindParentResult findParentResult = null; + + if (findParentModel.getCanvasCourseIdSearch() != null && ! findParentModel.getCanvasCourseIdSearch().trim().isEmpty()) { + List
sections = courseService.getCourseSections(findParentModel.getCanvasCourseIdSearch().trim()); + + boolean isCrosslisted = false; + + for (Section section : sections) { + if (section.getSis_section_id() != null && ! section.getSis_section_id().isEmpty() && + section.getSis_course_id() != null && ! section.getSis_course_id().isEmpty() && + ! section.getSis_section_id().equals(section.getSis_course_id())) { + SisCourse sisCourse = new SisCourse(); + findParentResult = crosslistService.processSisLookup(sisCourse); + + } + + } + + } + + if (findParentResult != null) { + model.addAttribute("findParentResult", findParentResult); + } + return "findParentCourse"; } diff --git a/src/main/java/edu/iu/uits/lms/crosslist/model/FindParentModel.java b/src/main/java/edu/iu/uits/lms/crosslist/model/FindParentModel.java index a153e1d..4e4fdc1 100644 --- a/src/main/java/edu/iu/uits/lms/crosslist/model/FindParentModel.java +++ b/src/main/java/edu/iu/uits/lms/crosslist/model/FindParentModel.java @@ -39,7 +39,7 @@ public class FindParentModel { private String radioSearch; private String sisIdSearch; - private String termByClassNumber; + private String termByClassNumberSearch; private String classNumberSearch; private String canvasCourseIdSearch; } \ No newline at end of file diff --git a/src/main/java/edu/iu/uits/lms/crosslist/model/FindParentResult.java b/src/main/java/edu/iu/uits/lms/crosslist/model/FindParentResult.java index 808ef07..5cc5bb4 100644 --- a/src/main/java/edu/iu/uits/lms/crosslist/model/FindParentResult.java +++ b/src/main/java/edu/iu/uits/lms/crosslist/model/FindParentResult.java @@ -33,6 +33,7 @@ * #L% */ +import edu.iu.uits.lms.crosslist.CrosslistConstants; import lombok.Data; @Data @@ -42,6 +43,5 @@ public class FindParentResult { private String sisCourseId; private boolean showCourseInfo; private String statusMessage; - private String statusCssClass; private String statusIconCssClasses; } diff --git a/src/main/java/edu/iu/uits/lms/crosslist/service/CrosslistService.java b/src/main/java/edu/iu/uits/lms/crosslist/service/CrosslistService.java index 0e5102f..f633a00 100644 --- a/src/main/java/edu/iu/uits/lms/crosslist/service/CrosslistService.java +++ b/src/main/java/edu/iu/uits/lms/crosslist/service/CrosslistService.java @@ -33,6 +33,7 @@ * #L% */ +import edu.iu.uits.lms.canvas.config.CanvasConfiguration; import edu.iu.uits.lms.canvas.helpers.CanvasDateFormatUtil; import edu.iu.uits.lms.canvas.model.Account; import edu.iu.uits.lms.canvas.model.CanvasTerm; @@ -40,8 +41,10 @@ import edu.iu.uits.lms.canvas.model.Section; import edu.iu.uits.lms.canvas.services.AccountService; import edu.iu.uits.lms.canvas.services.CourseService; +import edu.iu.uits.lms.canvas.services.SectionService; import edu.iu.uits.lms.common.session.CourseSessionService; import edu.iu.uits.lms.crosslist.CrosslistConstants; +import edu.iu.uits.lms.crosslist.model.FindParentResult; import edu.iu.uits.lms.crosslist.model.SectionUIDisplay; import edu.iu.uits.lms.iuonly.model.SisCourse; import edu.iu.uits.lms.iuonly.services.FeatureAccessServiceImpl; @@ -88,6 +91,13 @@ public class CrosslistService { @Autowired private SisServiceImpl sisService; + @Autowired + private SectionService sectionService; + + @Autowired + private CanvasConfiguration canvasConfiguration; + + // self reference so can use the cache for getCourseSections() from within this service @Lazy @Autowired @@ -380,6 +390,59 @@ public boolean canCoursesBeCrosslistedBasedOnEtexts(String sourceSisCourseSiteId return sourceCourseEtextIsbns.equals(destinationCourseEtextIsbns); } + public FindParentResult processSisLookup(SisCourse sisCourse) { + FindParentResult findParentResult = new FindParentResult(); + + if (sisCourse == null || sisCourse.getIuSiteId() == null) { + findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_SECTION_NOT_FOUND_IN_SIS_MESSAGE); + findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS); + return findParentResult; + } + + Section section = sectionService.getSection(String.format("sis_section_id:%s", sisCourse.getIuSiteId())); + + if (section == null) { + findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_SECTION_NOT_FOUND_IN_CANVAS_MESSAGE); + findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS); + return findParentResult; + } + + if (section.getSis_course_id() == null || section.getSis_section_id() == null) { + findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_SECTION_NOT_FOUND_IN_CANVAS_MESSAGE); + findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS); + return findParentResult; + } + + Course course = courseService.getCourse(section.getCourse_id()); + + if (course == null) { + findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_SECTION_NOT_FOUND_IN_CANVAS_MESSAGE); + findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS); + return findParentResult; + } + + if (section.getSis_course_id().equals(section.getSis_section_id())) { + findParentResult.setShowCourseInfo(true); + findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_COURSE_NOT_CROSSLISTED_MESSAGE); + findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS); + findParentResult.setName(course.getName()); + findParentResult.setSisCourseId(course.getSisCourseId()); + findParentResult.setUrl(String.format("%s/courses/%s", + canvasConfiguration.getBaseUrl(), course.getId())); + return findParentResult; + } + + findParentResult.setShowCourseInfo(true); + findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_SUCCESS_FOUND_MESSAGE); + findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_SUCCESS_CSS); + findParentResult.setName(course.getName()); + findParentResult.setSisCourseId(course.getSisCourseId()); + findParentResult.setUrl(String.format("%s/courses/%s", + canvasConfiguration.getBaseUrl(), course.getId())); + + return findParentResult; + } + @Data private class CourseSisNaturalAndAlien { String courseId; diff --git a/src/main/resources/static/css/crosslisting.css b/src/main/resources/static/css/crosslisting.css index 3bbb09d..014333f 100644 --- a/src/main/resources/static/css/crosslisting.css +++ b/src/main/resources/static/css/crosslisting.css @@ -92,3 +92,7 @@ .toggler { margin-bottom: 0.5rem; } + +.alertThing { + width: max-content; +} \ No newline at end of file diff --git a/src/main/resources/templates/findParentCourse.html b/src/main/resources/templates/findParentCourse.html index bccfc1c..b5f7b58 100644 --- a/src/main/resources/templates/findParentCourse.html +++ b/src/main/resources/templates/findParentCourse.html @@ -98,10 +98,11 @@

Find parent course

th:action="@{|/app/lookup-search-termandclassnumber|}" method="post">
- +
@@ -138,7 +139,7 @@

Find parent course

-
+
@@ -146,9 +147,10 @@

SP22-BL-FOLK-E295-1234 diff --git a/src/main/resources/templates/layout.html b/src/main/resources/templates/layout.html index 96e4a29..02a9abe 100644 --- a/src/main/resources/templates/layout.html +++ b/src/main/resources/templates/layout.html @@ -43,6 +43,7 @@ + @@ -68,6 +69,8 @@ + + From bedcd0c2a96a2fb9467a881ab1bd1f1aec1dd614 Mon Sep 17 00:00:00 2001 From: Damian Sobieralski Date: Tue, 19 Sep 2023 18:31:26 -0400 Subject: [PATCH 3/7] LMSA-7975 - last pass at feature before code review --- .../lms/crosslist/CrosslistConstants.java | 4 +- .../controller/CrosslistController.java | 92 ++++----- .../lms/crosslist/model/FindParentModel.java | 1 - .../crosslist/service/CrosslistService.java | 12 +- .../resources/static/css/crosslisting.css | 2 +- .../resources/templates/findParentCourse.html | 133 ++++++------- .../services/CrosslistServiceImplTest.java | 184 ++++++++++++++++++ 7 files changed, 285 insertions(+), 143 deletions(-) diff --git a/src/main/java/edu/iu/uits/lms/crosslist/CrosslistConstants.java b/src/main/java/edu/iu/uits/lms/crosslist/CrosslistConstants.java index 0c8b6ca..8a80667 100644 --- a/src/main/java/edu/iu/uits/lms/crosslist/CrosslistConstants.java +++ b/src/main/java/edu/iu/uits/lms/crosslist/CrosslistConstants.java @@ -52,8 +52,8 @@ public interface CrosslistConstants { String LOOKUP_SUCCESS_FOUND_MESSAGE = "Parent course is found"; String LOOKUP_FAILURE_COURSE_NOT_CROSSLISTED_MESSAGE = "This course has not been crosslisted"; - String LOOKUP_FAILURE_SECTION_NOT_FOUND_IN_CANVAS_MESSAGE = "This section has not been found in Canvas"; - String LOOKUP_FAILURE_SECTION_NOT_FOUND_IN_SIS_MESSAGE = "Section not found in SIS"; + String LOOKUP_FAILURE_NOT_FOUND_IN_CANVAS_MESSAGE = "Not found in Canvas"; + String LOOKUP_FAILURE_NOT_FOUND_IN_SIS_MESSAGE = "Not found in SIS"; String LOOKUP_SUCCESS_CSS = "rvt-color-green rvt-bg-green-100"; String LOOKUP_FAILURE_CSS = "rvt-orange-green rvt-bg-orange-100"; diff --git a/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java b/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java index a0b44af..f794d8a 100644 --- a/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java +++ b/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java @@ -879,25 +879,20 @@ public String endSelfImpersonation(@PathVariable("courseId") String courseId, @M @RequestMapping("/lookup-launch") @Secured({LTIConstants.ADMIN_AUTHORITY, LTIConstants.INSTRUCTOR_AUTHORITY}) - public String lookupLaunch(@ModelAttribute FindParentModel findParentModel, Model model, HttpServletRequest request) { - OidcAuthenticationToken token = getTokenWithoutContext(); - OidcTokenUtils oidcTokenUtils = new OidcTokenUtils(token); - String courseId = oidcTokenUtils.getCourseId(); + public String lookupLaunch(@ModelAttribute FindParentModel findParentModel, Model model, HttpSession session) { + getTokenWithoutContext(); - OidcAuthenticationToken sessionToken = courseSessionService.getAttributeFromSession(request.getSession(), courseId, OidcTokenAwareController.SESSION_TOKEN_KEY, OidcAuthenticationToken.class); + List terms = termService.getEnrollmentTerms() + .stream() + .filter(term -> term.getSisTermId().compareTo("4218") >= 0 && term.getSisTermId().charAt(0) == '4') + .sorted(Comparator.comparing(CanvasTerm::getSisTermId)) + .toList(); - if (sessionToken == null) { - courseSessionService.addAttributeToSession(request.getSession(), courseId, OidcTokenAwareController.SESSION_TOKEN_KEY, token); + if (courseSessionService.getAttributeFromSession(session, "all", "terms", List.class) == null) { + courseSessionService.addAttributeToSession(session, "all", "terms", terms); } -// model.addAttribute("courseId", courseId); -// model.addAttribute("hideFooter", true); - -// SubmissionStatus status = new SubmissionStatus(); -// status.setStatusClass(CrosslistConstants.STATUS_SUCCESS); -// status.setStatusMessage("Ta dah!"); -// -// model.addAttribute("submissionStatus", status); + model.addAttribute("terms", terms); return "findParentCourse"; } @@ -905,17 +900,24 @@ public String lookupLaunch(@ModelAttribute FindParentModel findParentModel, Mode @PostMapping(value = "/lookup-search-sisid") @Secured({LTIConstants.BASE_USER_AUTHORITY}) public String lookupSearchBySisId(@ModelAttribute FindParentModel findParentModel, Model model, HttpSession session) { - log.info("SIS search text = {}", findParentModel.getSisIdSearch()); + getTokenWithoutContext(); FindParentResult findParentResult = null; - if (findParentModel.getSisIdSearch() != null && ! findParentModel.getSisIdSearch().trim().isEmpty()) { -// Section section = sectionService.getSection(String.format("sis_section_id:%s", findParentModel.getSisIdSearch())); + List terms = courseSessionService.getAttributeFromSession(session, "all", + "terms", List.class); + if (findParentModel.getSisIdSearch() == null || findParentModel.getSisIdSearch().trim().isEmpty()) { + findParentResult = new FindParentResult(); + findParentResult.setStatusMessage("SIS ID needs to have a value"); + findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS); + } else { SisCourse sisCourse = sisService.getSisCourseBySiteId(findParentModel.getSisIdSearch().trim()); findParentResult = crosslistService.processSisLookup(sisCourse); } + model.addAttribute("terms", terms); + if (findParentResult != null) { model.addAttribute("findParentResult", findParentResult); } @@ -926,58 +928,32 @@ public String lookupSearchBySisId(@ModelAttribute FindParentModel findParentMode @PostMapping(value = "/lookup-search-termandclassnumber") @Secured({LTIConstants.BASE_USER_AUTHORITY}) public String lookupSearchByTermAndClassNUmber(@ModelAttribute FindParentModel findParentModel, Model model, HttpSession session) { - log.info("Term by Class Number = {}", findParentModel.getTermByClassNumberSearch()); - log.info("Class Number search text = {}", findParentModel.getClassNumberSearch()); + getTokenWithoutContext(); FindParentResult findParentResult = null; - if (findParentModel.getTermByClassNumberSearch() != null && ! findParentModel.getTermByClassNumberSearch().trim().isEmpty() && - findParentModel.getClassNumberSearch() != null && ! findParentModel.getClassNumberSearch().trim().isEmpty()) { - + List terms = courseSessionService.getAttributeFromSession(session, "all", + "terms", List.class); + + if (findParentModel.getTermByClassNumberSearch() == null || findParentModel.getTermByClassNumberSearch().trim().isEmpty()) { + findParentResult = new FindParentResult(); + findParentResult.setStatusMessage("Term needs to have a value"); + findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS); + } else if (findParentModel.getClassNumberSearch() == null || findParentModel.getClassNumberSearch().trim().isEmpty()) { + findParentResult = new FindParentResult(); + findParentResult.setStatusMessage("Class Number needs to have a value"); + findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS); + } else { final String strm = findParentModel.getTermByClassNumberSearch().trim(); final String classNumber = findParentModel.getClassNumberSearch().trim(); final String iuSiteId = sisService.getIuSiteIdFromStrmAndClassNumber(strm, classNumber); SisCourse sisCourse = sisService.getSisCourseBySiteId(iuSiteId); - -// Section section = sectionService.getSection(String.format("sis_section_id:%s", iuSiteId)); - findParentResult = crosslistService.processSisLookup(sisCourse); } - if (findParentResult != null) { - model.addAttribute("findParentResult", findParentResult); - } - - - return "findParentCourse"; - } - - @PostMapping(value = "/lookup-search-canvascourseid") - @Secured({LTIConstants.BASE_USER_AUTHORITY}) - public String lookupSearchByCourseId(@ModelAttribute FindParentModel findParentModel, Model model, HttpSession session) { - log.info("Canvas CourseId search text = {}", findParentModel.getCanvasCourseIdSearch()); - - FindParentResult findParentResult = null; - - if (findParentModel.getCanvasCourseIdSearch() != null && ! findParentModel.getCanvasCourseIdSearch().trim().isEmpty()) { - List
sections = courseService.getCourseSections(findParentModel.getCanvasCourseIdSearch().trim()); - - boolean isCrosslisted = false; - - for (Section section : sections) { - if (section.getSis_section_id() != null && ! section.getSis_section_id().isEmpty() && - section.getSis_course_id() != null && ! section.getSis_course_id().isEmpty() && - ! section.getSis_section_id().equals(section.getSis_course_id())) { - SisCourse sisCourse = new SisCourse(); - findParentResult = crosslistService.processSisLookup(sisCourse); - - } - - } - - } + model.addAttribute("terms", terms); if (findParentResult != null) { model.addAttribute("findParentResult", findParentResult); diff --git a/src/main/java/edu/iu/uits/lms/crosslist/model/FindParentModel.java b/src/main/java/edu/iu/uits/lms/crosslist/model/FindParentModel.java index 4e4fdc1..21201be 100644 --- a/src/main/java/edu/iu/uits/lms/crosslist/model/FindParentModel.java +++ b/src/main/java/edu/iu/uits/lms/crosslist/model/FindParentModel.java @@ -41,5 +41,4 @@ public class FindParentModel { private String sisIdSearch; private String termByClassNumberSearch; private String classNumberSearch; - private String canvasCourseIdSearch; } \ No newline at end of file diff --git a/src/main/java/edu/iu/uits/lms/crosslist/service/CrosslistService.java b/src/main/java/edu/iu/uits/lms/crosslist/service/CrosslistService.java index f633a00..9346cec 100644 --- a/src/main/java/edu/iu/uits/lms/crosslist/service/CrosslistService.java +++ b/src/main/java/edu/iu/uits/lms/crosslist/service/CrosslistService.java @@ -394,7 +394,8 @@ public FindParentResult processSisLookup(SisCourse sisCourse) { FindParentResult findParentResult = new FindParentResult(); if (sisCourse == null || sisCourse.getIuSiteId() == null) { - findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_SECTION_NOT_FOUND_IN_SIS_MESSAGE); + findParentResult.setShowCourseInfo(false); + findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_SIS_MESSAGE); findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS); return findParentResult; } @@ -402,13 +403,15 @@ public FindParentResult processSisLookup(SisCourse sisCourse) { Section section = sectionService.getSection(String.format("sis_section_id:%s", sisCourse.getIuSiteId())); if (section == null) { - findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_SECTION_NOT_FOUND_IN_CANVAS_MESSAGE); + findParentResult.setShowCourseInfo(false); + findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_CANVAS_MESSAGE); findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS); return findParentResult; } if (section.getSis_course_id() == null || section.getSis_section_id() == null) { - findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_SECTION_NOT_FOUND_IN_CANVAS_MESSAGE); + findParentResult.setShowCourseInfo(false); + findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_CANVAS_MESSAGE); findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS); return findParentResult; } @@ -416,7 +419,8 @@ public FindParentResult processSisLookup(SisCourse sisCourse) { Course course = courseService.getCourse(section.getCourse_id()); if (course == null) { - findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_SECTION_NOT_FOUND_IN_CANVAS_MESSAGE); + findParentResult.setShowCourseInfo(false); + findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_CANVAS_MESSAGE); findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS); return findParentResult; } diff --git a/src/main/resources/static/css/crosslisting.css b/src/main/resources/static/css/crosslisting.css index 014333f..f307f54 100644 --- a/src/main/resources/static/css/crosslisting.css +++ b/src/main/resources/static/css/crosslisting.css @@ -93,6 +93,6 @@ margin-bottom: 0.5rem; } -.alertThing { +.resultsWidth { width: max-content; } \ No newline at end of file diff --git a/src/main/resources/templates/findParentCourse.html b/src/main/resources/templates/findParentCourse.html index b5f7b58..9049735 100644 --- a/src/main/resources/templates/findParentCourse.html +++ b/src/main/resources/templates/findParentCourse.html @@ -55,54 +55,52 @@

Find parent course

  • -
  • -
  • -
  • -
    - - -
    -
-
+
- -
Example: SP22-BL-FOLK-E295-4441
+ +
Example: SP22-BL-FOLK-E295-4441
- +
+
-
+
@@ -116,31 +114,15 @@

Find parent course

-
- -
- - -
-
- -
Example: 2167456
-
- -
-
-
- +
-
- +

Parent course found

@@ -156,53 +138,50 @@

SP22-BL-FOLK-E295-1234

- - - - - - - - - - - - - - - - - - - - - - - - - - - -

diff --git a/src/test/java/edu/iu/uits/lms/crosslist/services/CrosslistServiceImplTest.java b/src/test/java/edu/iu/uits/lms/crosslist/services/CrosslistServiceImplTest.java index ab368ee..8b209d2 100644 --- a/src/test/java/edu/iu/uits/lms/crosslist/services/CrosslistServiceImplTest.java +++ b/src/test/java/edu/iu/uits/lms/crosslist/services/CrosslistServiceImplTest.java @@ -33,10 +33,14 @@ * #L% */ +import edu.iu.uits.lms.canvas.config.CanvasConfiguration; import edu.iu.uits.lms.canvas.model.CanvasTerm; import edu.iu.uits.lms.canvas.model.Course; import edu.iu.uits.lms.canvas.model.Section; import edu.iu.uits.lms.canvas.services.CourseService; +import edu.iu.uits.lms.canvas.services.SectionService; +import edu.iu.uits.lms.crosslist.CrosslistConstants; +import edu.iu.uits.lms.crosslist.model.FindParentResult; import edu.iu.uits.lms.crosslist.model.SectionUIDisplay; import edu.iu.uits.lms.crosslist.service.CrosslistService; import edu.iu.uits.lms.iuonly.model.SisCourse; @@ -63,10 +67,18 @@ public class CrosslistServiceImplTest { @InjectMocks private CrosslistService crosslistService = null; + @Autowired + @Mock + private CanvasConfiguration canvasConfiguration = null; + @Autowired @Mock private CourseService courseService = null; + @Autowired + @Mock + private SectionService sectionService = null; + @Autowired @Mock private SisServiceImpl sisService = null; @@ -706,6 +718,178 @@ public void first_sis_course_with_many_etexts_second_sis_course_with_many_etext_ Assertions.assertFalse(crosslistService.canCoursesBeCrosslistedBasedOnEtexts(sourceSisCourseSiteId1, sourceSisCourseSiteId2)); } + @Test + public void nullSisCourse_processSisLookup() { + FindParentResult findParentResult = crosslistService.processSisLookup(null); + + Assertions.assertFalse(findParentResult.isShowCourseInfo()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_SIS_MESSAGE, findParentResult.getStatusMessage()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_CSS, findParentResult.getStatusIconCssClasses()); + } + + @Test + public void nullIuSiteId_processSisLookup() { + SisCourse sisCourse = new SisCourse(); + + FindParentResult findParentResult = crosslistService.processSisLookup(sisCourse); + + Assertions.assertFalse(findParentResult.isShowCourseInfo()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_SIS_MESSAGE, findParentResult.getStatusMessage()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_CSS, findParentResult.getStatusIconCssClasses()); + } + + @Test + public void nullSection_processSisLookup() { + SisCourse sisCourse = new SisCourse(); + + final String iuSiteId = "TestIuSiteId"; + + sisCourse.setIuSiteId(iuSiteId); + + FindParentResult findParentResult = crosslistService.processSisLookup(sisCourse); + + Assertions.assertFalse(findParentResult.isShowCourseInfo()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_CANVAS_MESSAGE, findParentResult.getStatusMessage()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_CSS, findParentResult.getStatusIconCssClasses()); + } + + @Test + public void nullSectionSisCourseId_processSisLookup() { + SisCourse sisCourse = new SisCourse(); + + final String iuSiteId = "TestIuSiteId"; + + sisCourse.setIuSiteId(iuSiteId); + + Section section = new Section(); + section.setSis_section_id("123"); + + Mockito.when(sectionService.getSection(String.format("sis_section_id:%s", sisCourse.getIuSiteId()))).thenReturn(section); + + FindParentResult findParentResult = crosslistService.processSisLookup(sisCourse); + + Assertions.assertFalse(findParentResult.isShowCourseInfo()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_CANVAS_MESSAGE, findParentResult.getStatusMessage()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_CSS, findParentResult.getStatusIconCssClasses()); + } + + @Test + public void nullSectionSisSectionId_processSisLookup() { + SisCourse sisCourse = new SisCourse(); + + final String iuSiteId = "TestIuSiteId"; + + sisCourse.setIuSiteId(iuSiteId); + + Section section = new Section(); + section.setSis_course_id("123"); + + Mockito.when(sectionService.getSection(String.format("sis_section_id:%s", sisCourse.getIuSiteId()))).thenReturn(section); + + FindParentResult findParentResult = crosslistService.processSisLookup(sisCourse); + + Assertions.assertFalse(findParentResult.isShowCourseInfo()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_CANVAS_MESSAGE, findParentResult.getStatusMessage()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_CSS, findParentResult.getStatusIconCssClasses()); + } + + @Test + public void nullCourse_processSisLookup() { + SisCourse sisCourse = new SisCourse(); + + final String iuSiteId = "TestIuSiteId"; + + sisCourse.setIuSiteId(iuSiteId); + + Section section = new Section(); + section.setSis_course_id("123"); + section.setSis_section_id("123"); + + Mockito.when(sectionService.getSection(String.format("sis_section_id:%s", sisCourse.getIuSiteId()))).thenReturn(section); + + FindParentResult findParentResult = crosslistService.processSisLookup(sisCourse); + + Assertions.assertFalse(findParentResult.isShowCourseInfo()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_CANVAS_MESSAGE, findParentResult.getStatusMessage()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_CSS, findParentResult.getStatusIconCssClasses()); + } + + @Test + public void notCrosslistedBecauseSectionSisCourseIdEqualsSectionSisSectionId_processSisLookup() { + SisCourse sisCourse = new SisCourse(); + + final String iuSiteId = "TestIuSiteId"; + + sisCourse.setIuSiteId(iuSiteId); + + Section section = new Section(); + section.setSis_course_id("123"); + section.setSis_section_id("123"); + + final String baseUrl = "https://testsite.org"; + + final String courseName = "Course Name 1"; + final String sisCourseId = "123"; + + Course course = new Course(); + course.setId("1"); + course.setName(courseName); + course.setSisCourseId(sisCourseId); + + Mockito.when(sectionService.getSection(String.format("sis_section_id:%s", sisCourse.getIuSiteId()))).thenReturn(section); + Mockito.when(courseService.getCourse(section.getCourse_id())).thenReturn(course); + Mockito.when(canvasConfiguration.getBaseUrl()).thenReturn(baseUrl); + + FindParentResult findParentResult = crosslistService.processSisLookup(sisCourse); + + // findParentResult.setName(course.getName()); + // findParentResult.setSisCourseId(course.getSisCourseId()); + + Assertions.assertTrue(findParentResult.isShowCourseInfo()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_COURSE_NOT_CROSSLISTED_MESSAGE, findParentResult.getStatusMessage()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_CSS, findParentResult.getStatusIconCssClasses()); + Assertions.assertEquals(String.format("%s/courses/%s", canvasConfiguration.getBaseUrl(), course.getId()), findParentResult.getUrl()); + Assertions.assertEquals(courseName, findParentResult.getName()); + Assertions.assertEquals(sisCourseId, findParentResult.getSisCourseId()); + } + + @Test + public void parentFoundSuccess_processSisLookup() { + SisCourse sisCourse = new SisCourse(); + + final String iuSiteId = "TestIuSiteId"; + + sisCourse.setIuSiteId(iuSiteId); + + Section section = new Section(); + section.setSis_course_id("123"); + section.setSis_section_id("456"); + + final String baseUrl = "https://testsite.org"; + + final String courseName = "Course Name 1"; + final String sisCourseId = "123"; + + Course course = new Course(); + course.setId("1"); + course.setName(courseName); + course.setSisCourseId(sisCourseId); + + Mockito.when(sectionService.getSection(String.format("sis_section_id:%s", sisCourse.getIuSiteId()))).thenReturn(section); + Mockito.when(courseService.getCourse(section.getCourse_id())).thenReturn(course); + Mockito.when(canvasConfiguration.getBaseUrl()).thenReturn(baseUrl); + + FindParentResult findParentResult = crosslistService.processSisLookup(sisCourse); + + Assertions.assertTrue(findParentResult.isShowCourseInfo()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_SUCCESS_FOUND_MESSAGE, findParentResult.getStatusMessage()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_SUCCESS_CSS, findParentResult.getStatusIconCssClasses()); + Assertions.assertEquals(String.format("%s/courses/%s", canvasConfiguration.getBaseUrl(), course.getId()), findParentResult.getUrl()); + Assertions.assertEquals(courseName, findParentResult.getName()); + Assertions.assertEquals(sisCourseId, findParentResult.getSisCourseId()); + } + + private Course createCourse(String courseId, String sisCourseId) { Course course = new Course(); course.setId(courseId); From 78eac0915fc2806a60691416b64b12df10027ff5 Mon Sep 17 00:00:00 2001 From: Damian Sobieralski Date: Thu, 21 Sep 2023 17:09:19 -0400 Subject: [PATCH 4/7] LMSA-7975 - changes made after code review --- pom.xml | 2 +- .../lms/crosslist/CrosslistConstants.java | 3 + .../controller/CrosslistController.java | 45 ++++------ .../lms/crosslist/model/FindParentResult.java | 1 + .../crosslist/service/CrosslistService.java | 14 ++-- .../resources/templates/findParentCourse.html | 84 ++++++++++++++++--- .../services/CrosslistServiceImplTest.java | 8 ++ 7 files changed, 108 insertions(+), 49 deletions(-) diff --git a/pom.xml b/pom.xml index c847871..35020be 100644 --- a/pom.xml +++ b/pom.xml @@ -76,7 +76,7 @@ 17 3.7.1 5.2.5.2 - 5.2.16-SNAPSHOT + 5.2.16 4.8 2021.0.8 0.47 diff --git a/src/main/java/edu/iu/uits/lms/crosslist/CrosslistConstants.java b/src/main/java/edu/iu/uits/lms/crosslist/CrosslistConstants.java index 8a80667..3ab4b93 100644 --- a/src/main/java/edu/iu/uits/lms/crosslist/CrosslistConstants.java +++ b/src/main/java/edu/iu/uits/lms/crosslist/CrosslistConstants.java @@ -58,6 +58,9 @@ public interface CrosslistConstants { String LOOKUP_SUCCESS_CSS = "rvt-color-green rvt-bg-green-100"; String LOOKUP_FAILURE_CSS = "rvt-orange-green rvt-bg-orange-100"; + String LOOKUP_SUCCESS_ICON_NAME = "check"; + String LOOKUP_FAILURE_ICON_NAME = "close"; + String MODE_EDIT = "editMode"; String STATUS_SUCCESS = "rvt-alert--success"; diff --git a/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java b/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java index f794d8a..ab4fe80 100644 --- a/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java +++ b/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java @@ -34,6 +34,7 @@ */ import com.fasterxml.jackson.databind.ObjectMapper; +import edu.iu.uits.lms.canvas.helpers.CanvasDateFormatUtil; import edu.iu.uits.lms.canvas.model.CanvasTerm; import edu.iu.uits.lms.canvas.model.Course; import edu.iu.uits.lms.canvas.model.Section; @@ -81,6 +82,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; +import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; @@ -882,10 +884,13 @@ public String endSelfImpersonation(@PathVariable("courseId") String courseId, @M public String lookupLaunch(@ModelAttribute FindParentModel findParentModel, Model model, HttpSession session) { getTokenWithoutContext(); + Date nowDate = new Date(); + List terms = termService.getEnrollmentTerms() .stream() .filter(term -> term.getSisTermId().compareTo("4218") >= 0 && term.getSisTermId().charAt(0) == '4') - .sorted(Comparator.comparing(CanvasTerm::getSisTermId)) + .filter(term -> CanvasDateFormatUtil.string2DateOnly(term.getStartAt()).compareTo(nowDate) < 0) + .sorted(Comparator.comparing(CanvasTerm::getSisTermId).reversed()) .toList(); if (courseSessionService.getAttributeFromSession(session, "all", "terms", List.class) == null) { @@ -905,16 +910,10 @@ public String lookupSearchBySisId(@ModelAttribute FindParentModel findParentMode FindParentResult findParentResult = null; List terms = courseSessionService.getAttributeFromSession(session, "all", - "terms", List.class); - - if (findParentModel.getSisIdSearch() == null || findParentModel.getSisIdSearch().trim().isEmpty()) { - findParentResult = new FindParentResult(); - findParentResult.setStatusMessage("SIS ID needs to have a value"); - findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS); - } else { - SisCourse sisCourse = sisService.getSisCourseBySiteId(findParentModel.getSisIdSearch().trim()); - findParentResult = crosslistService.processSisLookup(sisCourse); - } + "terms", List.class); + + SisCourse sisCourse = sisService.getSisCourseBySiteId(findParentModel.getSisIdSearch().trim().toUpperCase()); + findParentResult = crosslistService.processSisLookup(sisCourse); model.addAttribute("terms", terms); @@ -935,23 +934,13 @@ public String lookupSearchByTermAndClassNUmber(@ModelAttribute FindParentModel f List terms = courseSessionService.getAttributeFromSession(session, "all", "terms", List.class); - if (findParentModel.getTermByClassNumberSearch() == null || findParentModel.getTermByClassNumberSearch().trim().isEmpty()) { - findParentResult = new FindParentResult(); - findParentResult.setStatusMessage("Term needs to have a value"); - findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS); - } else if (findParentModel.getClassNumberSearch() == null || findParentModel.getClassNumberSearch().trim().isEmpty()) { - findParentResult = new FindParentResult(); - findParentResult.setStatusMessage("Class Number needs to have a value"); - findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS); - } else { - final String strm = findParentModel.getTermByClassNumberSearch().trim(); - final String classNumber = findParentModel.getClassNumberSearch().trim(); - - final String iuSiteId = sisService.getIuSiteIdFromStrmAndClassNumber(strm, classNumber); - - SisCourse sisCourse = sisService.getSisCourseBySiteId(iuSiteId); - findParentResult = crosslistService.processSisLookup(sisCourse); - } + final String strm = findParentModel.getTermByClassNumberSearch().trim(); + final String classNumber = findParentModel.getClassNumberSearch().trim(); + + final String iuSiteId = sisService.getIuSiteIdFromStrmAndClassNumber(strm, classNumber); + + SisCourse sisCourse = sisService.getSisCourseBySiteId(iuSiteId); + findParentResult = crosslistService.processSisLookup(sisCourse); model.addAttribute("terms", terms); diff --git a/src/main/java/edu/iu/uits/lms/crosslist/model/FindParentResult.java b/src/main/java/edu/iu/uits/lms/crosslist/model/FindParentResult.java index 5cc5bb4..ca1a627 100644 --- a/src/main/java/edu/iu/uits/lms/crosslist/model/FindParentResult.java +++ b/src/main/java/edu/iu/uits/lms/crosslist/model/FindParentResult.java @@ -44,4 +44,5 @@ public class FindParentResult { private boolean showCourseInfo; private String statusMessage; private String statusIconCssClasses; + private String statusIconName; } diff --git a/src/main/java/edu/iu/uits/lms/crosslist/service/CrosslistService.java b/src/main/java/edu/iu/uits/lms/crosslist/service/CrosslistService.java index 9346cec..1b0d67a 100644 --- a/src/main/java/edu/iu/uits/lms/crosslist/service/CrosslistService.java +++ b/src/main/java/edu/iu/uits/lms/crosslist/service/CrosslistService.java @@ -397,22 +397,17 @@ public FindParentResult processSisLookup(SisCourse sisCourse) { findParentResult.setShowCourseInfo(false); findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_SIS_MESSAGE); findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS); + findParentResult.setStatusIconName(CrosslistConstants.LOOKUP_FAILURE_ICON_NAME); return findParentResult; } Section section = sectionService.getSection(String.format("sis_section_id:%s", sisCourse.getIuSiteId())); - if (section == null) { - findParentResult.setShowCourseInfo(false); - findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_CANVAS_MESSAGE); - findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS); - return findParentResult; - } - - if (section.getSis_course_id() == null || section.getSis_section_id() == null) { + if (section == null || section.getSis_course_id() == null || section.getSis_section_id() == null) { findParentResult.setShowCourseInfo(false); findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_CANVAS_MESSAGE); findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS); + findParentResult.setStatusIconName(CrosslistConstants.LOOKUP_FAILURE_ICON_NAME); return findParentResult; } @@ -422,6 +417,7 @@ public FindParentResult processSisLookup(SisCourse sisCourse) { findParentResult.setShowCourseInfo(false); findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_CANVAS_MESSAGE); findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS); + findParentResult.setStatusIconName(CrosslistConstants.LOOKUP_FAILURE_ICON_NAME); return findParentResult; } @@ -429,6 +425,7 @@ public FindParentResult processSisLookup(SisCourse sisCourse) { findParentResult.setShowCourseInfo(true); findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_FAILURE_COURSE_NOT_CROSSLISTED_MESSAGE); findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_FAILURE_CSS); + findParentResult.setStatusIconName(CrosslistConstants.LOOKUP_FAILURE_ICON_NAME); findParentResult.setName(course.getName()); findParentResult.setSisCourseId(course.getSisCourseId()); findParentResult.setUrl(String.format("%s/courses/%s", @@ -439,6 +436,7 @@ public FindParentResult processSisLookup(SisCourse sisCourse) { findParentResult.setShowCourseInfo(true); findParentResult.setStatusMessage(CrosslistConstants.LOOKUP_SUCCESS_FOUND_MESSAGE); findParentResult.setStatusIconCssClasses(CrosslistConstants.LOOKUP_SUCCESS_CSS); + findParentResult.setStatusIconName(CrosslistConstants.LOOKUP_SUCCESS_ICON_NAME); findParentResult.setName(course.getName()); findParentResult.setSisCourseId(course.getSisCourseId()); findParentResult.setUrl(String.format("%s/courses/%s", diff --git a/src/main/resources/templates/findParentCourse.html b/src/main/resources/templates/findParentCourse.html index 9049735..1771e0d 100644 --- a/src/main/resources/templates/findParentCourse.html +++ b/src/main/resources/templates/findParentCourse.html @@ -70,19 +70,29 @@

Find parent course

-
+
Example: SP22-BL-FOLK-E295-4441
+ aria-describedby="sisid-search-description" th:field="*{sisIdSearch}" /> +
+
+ + + + + + + SIS ID needs to be supplied.
-
@@ -91,13 +101,9 @@

Find parent course

+ th:action="@{|/app/lookup-search-termandclassnumber|}" onsubmit="return validateTermAndClassNumberForm()" method="post">
- + aria-describedby="class-number-search-description" th:field="*{classNumberSearch}" /> +
+
+ + + + + + + Class Number needs to be supplied.
-
@@ -124,7 +139,7 @@

Find parent course

- +

Parent course found

@@ -176,12 +191,57 @@

diff --git a/src/test/java/edu/iu/uits/lms/crosslist/services/CrosslistServiceImplTest.java b/src/test/java/edu/iu/uits/lms/crosslist/services/CrosslistServiceImplTest.java index 8b209d2..8b66a87 100644 --- a/src/test/java/edu/iu/uits/lms/crosslist/services/CrosslistServiceImplTest.java +++ b/src/test/java/edu/iu/uits/lms/crosslist/services/CrosslistServiceImplTest.java @@ -725,6 +725,7 @@ public void nullSisCourse_processSisLookup() { Assertions.assertFalse(findParentResult.isShowCourseInfo()); Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_SIS_MESSAGE, findParentResult.getStatusMessage()); Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_CSS, findParentResult.getStatusIconCssClasses()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_ICON_NAME, findParentResult.getStatusIconName()); } @Test @@ -736,6 +737,7 @@ public void nullIuSiteId_processSisLookup() { Assertions.assertFalse(findParentResult.isShowCourseInfo()); Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_SIS_MESSAGE, findParentResult.getStatusMessage()); Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_CSS, findParentResult.getStatusIconCssClasses()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_ICON_NAME, findParentResult.getStatusIconName()); } @Test @@ -751,6 +753,7 @@ public void nullSection_processSisLookup() { Assertions.assertFalse(findParentResult.isShowCourseInfo()); Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_CANVAS_MESSAGE, findParentResult.getStatusMessage()); Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_CSS, findParentResult.getStatusIconCssClasses()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_ICON_NAME, findParentResult.getStatusIconName()); } @Test @@ -771,6 +774,7 @@ public void nullSectionSisCourseId_processSisLookup() { Assertions.assertFalse(findParentResult.isShowCourseInfo()); Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_CANVAS_MESSAGE, findParentResult.getStatusMessage()); Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_CSS, findParentResult.getStatusIconCssClasses()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_ICON_NAME, findParentResult.getStatusIconName()); } @Test @@ -791,6 +795,7 @@ public void nullSectionSisSectionId_processSisLookup() { Assertions.assertFalse(findParentResult.isShowCourseInfo()); Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_CANVAS_MESSAGE, findParentResult.getStatusMessage()); Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_CSS, findParentResult.getStatusIconCssClasses()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_ICON_NAME, findParentResult.getStatusIconName()); } @Test @@ -812,6 +817,7 @@ public void nullCourse_processSisLookup() { Assertions.assertFalse(findParentResult.isShowCourseInfo()); Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_NOT_FOUND_IN_CANVAS_MESSAGE, findParentResult.getStatusMessage()); Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_CSS, findParentResult.getStatusIconCssClasses()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_ICON_NAME, findParentResult.getStatusIconName()); } @Test @@ -848,6 +854,7 @@ public void notCrosslistedBecauseSectionSisCourseIdEqualsSectionSisSectionId_pro Assertions.assertTrue(findParentResult.isShowCourseInfo()); Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_COURSE_NOT_CROSSLISTED_MESSAGE, findParentResult.getStatusMessage()); Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_CSS, findParentResult.getStatusIconCssClasses()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_FAILURE_ICON_NAME, findParentResult.getStatusIconName()); Assertions.assertEquals(String.format("%s/courses/%s", canvasConfiguration.getBaseUrl(), course.getId()), findParentResult.getUrl()); Assertions.assertEquals(courseName, findParentResult.getName()); Assertions.assertEquals(sisCourseId, findParentResult.getSisCourseId()); @@ -884,6 +891,7 @@ public void parentFoundSuccess_processSisLookup() { Assertions.assertTrue(findParentResult.isShowCourseInfo()); Assertions.assertEquals(CrosslistConstants.LOOKUP_SUCCESS_FOUND_MESSAGE, findParentResult.getStatusMessage()); Assertions.assertEquals(CrosslistConstants.LOOKUP_SUCCESS_CSS, findParentResult.getStatusIconCssClasses()); + Assertions.assertEquals(CrosslistConstants.LOOKUP_SUCCESS_ICON_NAME, findParentResult.getStatusIconName()); Assertions.assertEquals(String.format("%s/courses/%s", canvasConfiguration.getBaseUrl(), course.getId()), findParentResult.getUrl()); Assertions.assertEquals(courseName, findParentResult.getName()); Assertions.assertEquals(sisCourseId, findParentResult.getSisCourseId()); From e87d08efa9a5f55f88ac5523fbe68231e80c2365 Mon Sep 17 00:00:00 2001 From: Damian Sobieralski Date: Thu, 21 Sep 2023 17:37:17 -0400 Subject: [PATCH 5/7] LMSA-7975 - remove alert --- src/main/resources/templates/findParentCourse.html | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/resources/templates/findParentCourse.html b/src/main/resources/templates/findParentCourse.html index 1771e0d..156e8c3 100644 --- a/src/main/resources/templates/findParentCourse.html +++ b/src/main/resources/templates/findParentCourse.html @@ -221,7 +221,6 @@

Date: Fri, 22 Sep 2023 12:43:18 -0400 Subject: [PATCH 6/7] LMSA-7975 - changed secure level and some text changes --- README.md | 34 +++++++++++++++++++ examples/crosslisting-lookup.json | 3 +- .../controller/CrosslistController.java | 6 ++-- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 7b966b7..785a471 100644 --- a/README.md +++ b/README.md @@ -124,3 +124,37 @@ that need to be accounted for while using this setup. This is marked as experimental due to the fact that we aren't running with this option at IU. We are running into CORS issues when trying to talk to our OAuth2 service via swagger, so we can't verify if it really works or not! + +# Crosslister Lookup +The Cross-listing Assistant in Canvas at Indiana University has a secondary launch that brings up a user interface to search for a parent +crosslisted course. This is restricted to administrator users only. Configuration is the same as the crosslister with the exceptions listed below. + +## Test a local launch +Startup the application with the `LTI_CLIENTREGISTRATION_DEFAULTCLIENT` value set to `saltire`. +Use an LTI tool consumer launcher, like https://saltire.lti.app/platform. +Default values are fine, with the below exceptions... + +In the `Message` section, set the following: + + + +
PropertyValue
Custom parameters + +``` +canvas_user_login_id=johnsmith +instructure_membership_roles=http://purl.imsglobal.org/vocab/lis/v2/institution/person#Administrator +``` + +
+ +Use an appropriate `canvas_user_login_id`. + +From the `Security Model` section, set the following: + + + + + + + +
PropertyValue
LTI version1.3.0
Message URLhttp://localhost:8080/app/lookup-launch
Client IDdev (or whatever is appropriate based on the record inserted in the database table from above)
Initiate login URLhttp://localhost:8080/lti/login_initiation/lms_lti_crosslisting
Redirection URI(s)http://localhost:8080/lti/login
diff --git a/examples/crosslisting-lookup.json b/examples/crosslisting-lookup.json index 372aaba..68ee67a 100644 --- a/examples/crosslisting-lookup.json +++ b/examples/crosslisting-lookup.json @@ -12,7 +12,7 @@ "placements": [ { "enabled": true, - "placement": "course_settings_sub_navigation", + "placement": "account_navigation", "message_type": "LtiResourceLinkRequest" } ] @@ -22,7 +22,6 @@ "public_jwk_url": "http://localhost:8080/.well-known/jwks.json", "custom_fields": { "instructure_membership_roles": "$com.Instructure.membership.roles", - "canvas_course_id": "$Canvas.course.id", "canvas_user_login_id": "$Canvas.user.loginId" } } \ No newline at end of file diff --git a/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java b/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java index ab4fe80..8494c05 100644 --- a/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java +++ b/src/main/java/edu/iu/uits/lms/crosslist/controller/CrosslistController.java @@ -880,7 +880,7 @@ public String endSelfImpersonation(@PathVariable("courseId") String courseId, @M } @RequestMapping("/lookup-launch") - @Secured({LTIConstants.ADMIN_AUTHORITY, LTIConstants.INSTRUCTOR_AUTHORITY}) + @Secured({LTIConstants.ADMIN_AUTHORITY}) public String lookupLaunch(@ModelAttribute FindParentModel findParentModel, Model model, HttpSession session) { getTokenWithoutContext(); @@ -903,7 +903,7 @@ public String lookupLaunch(@ModelAttribute FindParentModel findParentModel, Mode } @PostMapping(value = "/lookup-search-sisid") - @Secured({LTIConstants.BASE_USER_AUTHORITY}) + @Secured({LTIConstants.ADMIN_AUTHORITY}) public String lookupSearchBySisId(@ModelAttribute FindParentModel findParentModel, Model model, HttpSession session) { getTokenWithoutContext(); @@ -925,7 +925,7 @@ public String lookupSearchBySisId(@ModelAttribute FindParentModel findParentMode } @PostMapping(value = "/lookup-search-termandclassnumber") - @Secured({LTIConstants.BASE_USER_AUTHORITY}) + @Secured({LTIConstants.ADMIN_AUTHORITY}) public String lookupSearchByTermAndClassNUmber(@ModelAttribute FindParentModel findParentModel, Model model, HttpSession session) { getTokenWithoutContext(); From 7d1185e1b61abf9b543ff9a5465676593b72367f Mon Sep 17 00:00:00 2001 From: Damian Sobieralski Date: Fri, 22 Sep 2023 15:32:22 -0400 Subject: [PATCH 7/7] LMSA-7975 - added focus --- src/main/resources/templates/findParentCourse.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/resources/templates/findParentCourse.html b/src/main/resources/templates/findParentCourse.html index 156e8c3..6c20a38 100644 --- a/src/main/resources/templates/findParentCourse.html +++ b/src/main/resources/templates/findParentCourse.html @@ -170,6 +170,12 @@