--- loncom/interface/domainprefs.pm 2021/11/22 23:40:59 1.391 +++ loncom/interface/domainprefs.pm 2021/11/28 18:43:37 1.393 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.391 2021/11/22 23:40:59 raeburn Exp $ +# $Id: domainprefs.pm,v 1.393 2021/11/28 18:43:37 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -6129,7 +6129,8 @@ sub lti_options { my (%checked,%rolemaps,$crssecsrc,$userfield,$cidfield,$callback); $checked{'mapuser'}{'sourcedid'} = ' checked="checked"'; $checked{'mapcrs'}{'course_offering_sourcedid'} = ' checked="checked"'; - $checked{'makecrs'}{'N'} = ' checked="checked"'; + $checked{'storecrs'}{'Y'} = ' checked="checked"'; + $checked{'makecrs'}{'N'} = ' checked="checked"'; $checked{'mapcrstype'} = {}; $checked{'makeuser'} = {}; $checked{'selfenroll'} = {}; @@ -6187,6 +6188,10 @@ sub lti_options { $checked{'mapcrstype'}{$type} = ' checked="checked"'; } } + if (!$current->{'storecrs'}) { + $checked{'storecrs'}{'N'} = $checked{'storecrs'}{'Y'}; + $checked{'storecrs'}{'Y'} = ''; + } if ($current->{'makecrs'}) { $checked{'makecrs'}{'Y'} = ' checked="checked"'; } @@ -6294,7 +6299,7 @@ sub lti_options { my $onclicklcauth = ' onclick="toggleLTI(this.form,'."'lcauth','$num'".')"'; my $onclickmenu = ' onclick="toggleLTI(this.form,'."'lcmenu','$num'".');"'; my $output = '
'.&mt('Logout options').''. - '
'.&mt('Callback on logout').': '. + '
'.&mt('Callback to logout LON-CAPA on log out from Consumer').': '. ''.(' 'x2). ''. (' 'x2); } - $output .= '
'. + $output .= '

'. + ''.&mt('Store mapping of course identifier to LON-CAPA CourseID').': '. + ''.(' 'x2). + ''. + ''. '
'.&mt('Mapping course roles').''; foreach my $ltirole (@lticourseroles) { my ($selected,$selectnone); @@ -7780,7 +7791,8 @@ sub print_wafproxy { ''. ''. + &mt('A.B.C.D/N or A.B.C.D-E.F.G.H').'
'. + &mt('Range(s) stored in CIDR notation').''. '
'.&mt('Domain: [_1]',''.$dom.'').'

'. '
'.&mt('Format for comma separated IP ranges').':
'. - &mt('A.B.C.D/N or A.B.C.D-E.F.G.H').'
'. ''. '
'.$lt{'remoteip'}.': '. @@ -14775,13 +14787,14 @@ sub modify_lti { my @courseroles = ('cc','in','ta','ep','st'); my @ltiroles = qw(Learner Instructor ContentDeveloper TeachingAssistant Mentor Member Manager Administrator); my @lticourseroles = qw(Instructor TeachingAssistant Mentor Learner); - my @coursetypes = ('official','unofficial','community','textbook','placement'); + my @coursetypes = ('official','unofficial','community','textbook','placement','lti'); my %coursetypetitles = &Apache::lonlocal::texthash ( official => 'Official', unofficial => 'Unofficial', community => 'Community', textbook => 'Textbook', placement => 'Placement Test', + lti => 'LTI Provider', ); my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles(); my %lt = <i_names(); @@ -14939,6 +14952,9 @@ sub modify_lti { } } $confhash{$itemid}{'mapcrstype'} = \@crstypes; + if ($env{'form.lti_storecrs_'.$idx}) { + $confhash{$itemid}{'storecrs'} = 1; + } if ($env{'form.lti_makecrs_'.$idx}) { $confhash{$itemid}{'makecrs'} = 1; } @@ -14983,7 +14999,7 @@ sub modify_lti { } unless (($idx eq 'add') || ($changes{$itemid})) { if ($confhash{$itemid}{'crsinc'}) { - foreach my $field ('mapcrs','makecrs','section','passback','roster') { + foreach my $field ('mapcrs','storecrs','makecrs','section','passback','roster') { if ($domconfig{$action}{$itemid}{$field} ne $confhash{$itemid}{$field}) { $changes{$itemid} = 1; } @@ -15145,7 +15161,7 @@ sub modify_lti { if ($confhash{$itemid}{'callback'}) { $resulttext .= '
  • '.&mt('Callback setting').': '.$confhash{$itemid}{'callback'}.'
  • '; } else { - $resulttext .= '
  • '.&mt('No callback to logout LON-CAPA session when user logs out of Comsumer').'
  • '; + $resulttext .= '
  • '.&mt('Callback to logout LON-CAPA on log out from Consumer').'
  • '; } if ($confhash{$itemid}{'mapuser'}) { my $shownmapuser; @@ -15234,6 +15250,9 @@ sub modify_lti { $resulttext .= '
  • '.&mt('No mapping to LON-CAPA courses').'
  • '; } } + if ($confhash{$itemid}{'storecrs'}) { + $resulttext .= '
  • '.&mt('Store mapping of course identifier to LON-CAPA CourseID').': '.$confhash{$itemid}{'storecrs'}.'
  • '; + } if ($confhash{$itemid}{'makecrs'}) { $resulttext .= '
  • '.&mt('Instructor may create course (if absent).').'
  • '; } else { @@ -20491,18 +20510,17 @@ sub modify_wafproxy { $possible =~ s/[\r\n]+/\s/g; $possible =~ s/\s*-\s*/-/g; $possible =~ s/\s+/,/g; + $possible =~ s/,+/,/g; } $count = 0; if ($possible ne '') { foreach my $poss (split(/\,/,$possible)) { $count ++; - if (&validate_ip_pattern($poss)) { + $poss = &validate_ip_pattern($poss); + if ($poss ne '') { push(@ok,$poss); } } - if (@ok) { - $wafproxy{$item} = join(',',@ok); - } my $diff = $count - scalar(@ok); if ($diff) { push(@warnings,'
  • '. @@ -20510,6 +20528,13 @@ sub modify_wafproxy { $diff,$warn{$item}). '
  • '); } + if (@ok) { + my @cidr_list; + foreach my $item (@ok) { + @cidr_list = &Net::CIDR::cidradd($item,@cidr_list); + } + $wafproxy{$item} = join(',',@cidr_list); + } } } if ($wafproxy{$item} ne $currvalue{$item}) { @@ -20701,12 +20726,17 @@ sub validate_ip_pattern { if ($pattern =~ /^([^-]+)\-([^-]+)$/) { my ($start,$end) = ($1,$2); if ((&Net::CIDR::cidrvalidate($start)) && (&Net::CIDR::cidrvalidate($end))) { - return 1; + if (($start !~ m{/}) && ($end !~ m{/})) { + return $start.'-'.$end; + } + } + } elsif ($pattern ne '') { + $pattern = &Net::CIDR::cidrvalidate($pattern); + if ($pattern ne '') { + return $pattern; } - } elsif (&Net::CIDR::cidrvalidate($pattern)) { - return 1; } - return + return; } sub modify_usersessions {