Skip to content

Commit

Permalink
Add LTI configuration info to the LTI course map page.
Browse files Browse the repository at this point in the history
  • Loading branch information
drgrice1 committed Nov 12, 2024
1 parent 5289d8b commit 0277062
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 4 deletions.
31 changes: 29 additions & 2 deletions lib/WeBWorK/ContentGenerator/CourseAdmin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
<caption><%= maketext('LTI Course Map') %></caption>
<thead class="table-group-divider">
<tr>
<th><%= maketext('Course ID') %></th>
<th id="lms-context-id-header"><%= maketext('LMS Context ID') %></th>
<th class="text-nowrap"><%= maketext('Course ID') %></th>
<th class="text-nowrap" id="lms-context-id-header"><%= maketext('LMS Context ID') %></th>
<th class="text-nowrap"><%= maketext('LTI Version') %></th>
<th class="text-nowrap"><%= maketext('LTI Configuration') %></th>
</tr>
</thead>
<tbody class="table-group-divider">
Expand All @@ -21,6 +23,83 @@
class => 'form-control form-control-sm d-inline w-auto',
'aria-labelledby' => 'lms-context-id-header' =%>
</td>
<td class="text-center">
<%= $ltiConfigs->{$_}{LTIVersion} && $ltiConfigs->{$_}{LTIVersion} eq 'v1p1' ? '1.1'
: $ltiConfigs->{$_}{LTIVersion} && $ltiConfigs->{$_}{LTIVersion} eq 'v1p3' ? '1.3'
: maketext('Disabled') %>
</td>
<td class="text-center">
% if ($ltiConfigs->{$_}{LTIVersion} && $ltiConfigs->{$_}{LTIVersion} =~ /^v1p[13]$/) {
<a href="#" role="button" data-bs-toggle="modal"
data-bs-target="#<%= $_ %>-config-modal">
<i class="fa-solid fa-circle-question fa-xl"></i>
<span class="visually-hidden"><%= maketext('LTI Configuration') %></span>
</a>
<div class="modal fade" id="<%= $_ %>-config-modal" tabindex="-1"
aria-labelledby="<%= $_ %>-lti-config" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-6" id="<%= $_ %>-lti-config">
<%= maketext('LTI Configuration for [_1]', $_) %>
</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal"
aria-label="<%= maketext('close') %>">
</button>
</div>
<div class="modal-body">
<table class="table table-sm table-light table-bordered
table-striped-columns mb-0">
<tbody>
% if ($ltiConfigs->{$_}{LTIVersion} eq 'v1p1') {
<tr>
<th class="text-nowrap">
<%= maketext('Consumer Key') %>
</th>
<td class="text-nowrap">
<%= $ltiConfigs->{$_}{ConsumerKey}
|| maketext('Unset') %>
</td>
</tr>
% } elsif ($ltiConfigs->{$_}{LTIVersion} eq 'v1p3') {
<tr>
<th class="text-nowrap">
<%= maketext('Platform ID') %>
</th>
<td class="text-nowrap">
<%= $ltiConfigs->{$_}{PlatformID}
|| maketext('Unset') %>
</td>
</tr>
<tr>
<th class="text-nowrap">
<%= maketext('Client ID') %>
</th>
<td class="text-nowrap">
<%= $ltiConfigs->{$_}{ClientID}
|| maketext('Unset') %>
</td>
</tr>
<tr>
<th class="text-nowrap">
<%= maketext('Deployment ID') %>
</th>
<td class="text-nowrap">
<%= $ltiConfigs->{$_}{DeploymentID}
|| maketext('Unset') %>
</td>
</tr>
% }
</tbody>
</table>
</div>
</div>
</div>
</div>
% } else {
<%= maketext('Not Configured') =%>
% }
</td>
</tr>
% }
</tbody>
Expand Down

0 comments on commit 0277062

Please sign in to comment.