From 02770625ea45c960eaae142a0ac0c1abce6ecdfa Mon Sep 17 00:00:00 2001 From: Glenn Rice Date: Mon, 11 Mar 2024 14:03:40 -0500 Subject: [PATCH] Add LTI configuration info to the LTI course map page. --- lib/WeBWorK/ContentGenerator/CourseAdmin.pm | 31 ++++++- .../manage_lti_course_map_form.html.ep | 83 ++++++++++++++++++- 2 files changed, 110 insertions(+), 4 deletions(-) diff --git a/lib/WeBWorK/ContentGenerator/CourseAdmin.pm b/lib/WeBWorK/ContentGenerator/CourseAdmin.pm index b8274bbf95..d4732a0b6e 100644 --- a/lib/WeBWorK/ContentGenerator/CourseAdmin.pm +++ b/lib/WeBWorK/ContentGenerator/CourseAdmin.pm @@ -2223,11 +2223,38 @@ sub do_unhide_inactive_course ($c) { # LTI Course Map Management sub manage_lti_course_map_form ($c) { - my $ce = $c->ce; + my $ce = $c->ce; + my @courseIDs = listCourses($ce); my %courseMap = map { $_->course_id => $_->lms_context_id } $c->db->getLTICourseMapsWhere; for (@courseIDs) { $courseMap{$_} = '' unless defined $courseMap{$_} } - return $c->include('ContentGenerator/CourseAdmin/manage_lti_course_map_form', courseMap => \%courseMap); + + my %ltiConfigs = map { + my $ce = eval { WeBWorK::CourseEnvironment->new({ courseName => $_ }) }; + $_ => $@ + ? undef + : { + LTIVersion => $ce->{LTIVersion}, + $ce->{LTIVersion} + ? ( + $ce->{LTIVersion} eq 'v1p1' + ? (ConsumerKey => $ce->{LTI}{v1p1}{ConsumerKey}) + : $ce->{LTIVersion} eq 'v1p3' ? ( + PlatformID => $ce->{LTI}{v1p3}{PlatformID}, + ClientID => $ce->{LTI}{v1p3}{ClientID}, + DeploymentID => $ce->{LTI}{v1p3}{DeploymentID} + ) + : () + ) + : () + } + } @courseIDs; + + return $c->include( + 'ContentGenerator/CourseAdmin/manage_lti_course_map_form', + courseMap => \%courseMap, + ltiConfigs => \%ltiConfigs + ); } sub save_lti_course_map_validate ($c) { diff --git a/templates/ContentGenerator/CourseAdmin/manage_lti_course_map_form.html.ep b/templates/ContentGenerator/CourseAdmin/manage_lti_course_map_form.html.ep index c74726ab35..1265bcfa13 100644 --- a/templates/ContentGenerator/CourseAdmin/manage_lti_course_map_form.html.ep +++ b/templates/ContentGenerator/CourseAdmin/manage_lti_course_map_form.html.ep @@ -8,8 +8,10 @@ <%= maketext('LTI Course Map') %> - <%= maketext('Course ID') %> - <%= maketext('LMS Context ID') %> + <%= maketext('Course ID') %> + <%= maketext('LMS Context ID') %> + <%= maketext('LTI Version') %> + <%= maketext('LTI Configuration') %> @@ -21,6 +23,83 @@ class => 'form-control form-control-sm d-inline w-auto', 'aria-labelledby' => 'lms-context-id-header' =%> + + <%= $ltiConfigs->{$_}{LTIVersion} && $ltiConfigs->{$_}{LTIVersion} eq 'v1p1' ? '1.1' + : $ltiConfigs->{$_}{LTIVersion} && $ltiConfigs->{$_}{LTIVersion} eq 'v1p3' ? '1.3' + : maketext('Disabled') %> + + + % if ($ltiConfigs->{$_}{LTIVersion} && $ltiConfigs->{$_}{LTIVersion} =~ /^v1p[13]$/) { + + + <%= maketext('LTI Configuration') %> + + + % } else { + <%= maketext('Not Configured') =%> + % } + % }