version 1.49.2.28.2.4, 2022/02/07 18:29:01
|
version 1.108, 2022/04/05 12:27:39
|
Line 52 This module is used for configuration of
|
Line 52 This module is used for configuration of
|
|
|
=item process_changes() |
=item process_changes() |
|
|
|
=item process_linkprot() |
|
|
=item get_sec_str() |
=item get_sec_str() |
|
|
=item check_clone() |
=item check_clone() |
|
|
=item store_changes() |
=item store_changes() |
|
|
|
=item store_linkprot() |
|
|
=item update_env() |
=item update_env() |
|
|
=item display_disallowed() |
=item display_disallowed() |
Line 220 use Apache::lonparmset;
|
Line 224 use Apache::lonparmset;
|
use Apache::courseclassifier; |
use Apache::courseclassifier; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
|
use Crypt::CBC; |
|
|
my $registered_cleanup; |
my $registered_cleanup; |
my $modified_courses; |
my $modified_courses; |
Line 310 sub handler {
|
Line 315 sub handler {
|
idnu => 'Course ID or number', |
idnu => 'Course ID or number', |
unco => 'Unique code', |
unco => 'Unique code', |
desc => 'Course Description', |
desc => 'Course Description', |
cred => 'Student credits', |
cred => 'Student credits', |
ownr => 'Course Owner', |
ownr => 'Course Owner', |
cown => 'Course Co-owners', |
cown => 'Course Co-owners', |
catg => 'Categorize course', |
catg => 'Categorize course', |
Line 365 sub handler {
|
Line 370 sub handler {
|
} |
} |
|
|
my %values=&Apache::lonnet::dump('environment',$cdom,$cnum); |
my %values=&Apache::lonnet::dump('environment',$cdom,$cnum); |
my %lti=&Apache::lonnet::dump('lti',$cdom,$cnum,undef,undef,undef,1); |
my %linkprot=&Apache::lonnet::dump('lti',$cdom,$cnum,undef,undef,undef,1); |
my %ltienc = &Apache::lonnet::dump('nohist_ltienc',$cdom,$cnum,undef,undef,undef,1); |
my %ltienc = &Apache::lonnet::dump('nohist_ltienc',$cdom,$cnum,undef,undef,undef,1); |
foreach my $id (keys(%lti)) { |
foreach my $id (keys(%linkprot)) { |
if (ref($lti{$id}) eq 'HASH') { |
if (ref($linkprot{$id}) eq 'HASH') { |
if (ref($ltienc{$id}) eq 'HASH') { |
if (ref($ltienc{$id}) eq 'HASH') { |
$values{'linkprotection'}{$id} = { %{$lti{$id}}, %{$ltienc{$id}} }; |
$values{'linkprot'}{$id} = { %{$linkprot{$id}}, %{$ltienc{$id}} }; |
} else { |
} else { |
$values{'linkprotection'}{$id} = $lti{$id}; |
$values{'linkprot'}{$id} = $linkprot{$id}; |
} |
} |
} |
} |
unless ($phase eq 'process') { |
unless ($phase eq 'process') { |
if (ref($values{'linkprotection'}{$id}) eq 'HASH') { |
if (ref($values{'linkprot'}{$id}) eq 'HASH') { |
delete($values{'linkprotection'}{$id}{'secret'}); |
delete($values{'linkprot'}{$id}{'secret'}); |
} |
} |
} |
} |
} |
} |
if ($lti{'lock'}) { |
if ($linkprot{'lock'}) { |
delete($lti{'lock'}); |
delete($linkprot{'lock'}); |
} |
} |
my @prefs_order = ('courseinfo','localization','feedback','discussion', |
my @prefs_order = ('courseinfo','localization','feedback','discussion', |
'classlists','appearance','grading','printouts', |
'classlists','appearance','grading','printouts', |
'menuitems','linkprotection','spreadsheet','bridgetasks', |
'menuitems','linkprot','spreadsheet','bridgetasks', |
'other'); |
'lti','other'); |
|
|
my %prefs = ( |
my %prefs = ( |
'courseinfo' => |
'courseinfo' => |
Line 402 sub handler {
|
Line 407 sub handler {
|
'co-owners' => $lt{'cown'}, |
'co-owners' => $lt{'cown'}, |
'description' => $lt{'desc'}, |
'description' => $lt{'desc'}, |
'courseid' => $lt{'idnu'}, |
'courseid' => $lt{'idnu'}, |
'uniquecode' => $lt{'unco'}, |
'uniquecode' => $lt{'unco'}, |
'categories' => $lt{'catg'}, |
'categories' => $lt{'catg'}, |
'hidefromcat' => $lt{'excc'}, |
'hidefromcat' => $lt{'excc'}, |
'cloners' => $lt{'clon'}, |
'cloners' => $lt{'clon'}, |
Line 439 sub handler {
|
Line 444 sub handler {
|
{ text => 'Discussion and Chat', |
{ text => 'Discussion and Chat', |
help => 'Course_Prefs_Discussions', |
help => 'Course_Prefs_Discussions', |
ordered => ['pch.roles.denied','pch.users.denied', |
ordered => ['pch.roles.denied','pch.users.denied', |
|
'pac.roles.denied','pac.users.denied', |
'plc.roles.denied','plc.users.denied', |
'plc.roles.denied','plc.users.denied', |
'allow_limited_html_in_feedback', |
'allow_limited_html_in_feedback', |
'allow_discussion_post_editing', |
'allow_discussion_post_editing', |
Line 448 sub handler {
|
Line 454 sub handler {
|
'pch.users.denied' => 'No Resource Discussion', |
'pch.users.denied' => 'No Resource Discussion', |
'plc.roles.denied' => 'No Chat room use', |
'plc.roles.denied' => 'No Chat room use', |
'plc.users.denied' => 'No Chat room use', |
'plc.users.denied' => 'No Chat room use', |
|
'pac.roles.denied' => 'No Anonymous Resource Discussion', |
|
'pac.users.denied' => 'No Anonymous Resource Discussion', |
allow_limited_html_in_feedback => 'Allow limited HTML in discussion', |
allow_limited_html_in_feedback => 'Allow limited HTML in discussion', |
allow_discussion_post_editing => 'Users can edit/delete own discussion posts', |
allow_discussion_post_editing => 'Users can edit/delete own discussion posts', |
discussion_post_fonts => 'Discussion post fonts based on likes/unlikes', |
discussion_post_fonts => 'Discussion post fonts based on likes/unlikes', |
}, |
}, |
}, |
}, |
'classlists' => |
'classlists' => |
Line 514 sub handler {
|
Line 522 sub handler {
|
help => 'Course_Prefs_Printouts', |
help => 'Course_Prefs_Printouts', |
ordered => ['problem_stream_switch','suppress_tries', |
ordered => ['problem_stream_switch','suppress_tries', |
'default_paper_size','print_header_format', |
'default_paper_size','print_header_format', |
'disableexampointprint'], |
'disableexampointprint','canuse_pdfforms'], |
itemtext => { |
itemtext => { |
problem_stream_switch => 'Allow problems to be split over pages', |
problem_stream_switch => 'Allow problems to be split over pages', |
suppress_tries => 'Suppress number of tries in printing', |
suppress_tries => 'Suppress number of tries in printing', |
Line 548 sub handler {
|
Line 556 sub handler {
|
suppress_embed_prompt => 'Hide upload references prompt if uploading file to portfolio', |
suppress_embed_prompt => 'Hide upload references prompt if uploading file to portfolio', |
}, |
}, |
}, |
}, |
|
'lti' => |
|
{ |
|
text => 'LTI provider settings', |
|
help => 'Course_Prefs_LTIProvider', |
|
ordered => ['lti.override','lti.topmenu','lti.inlinemenu','lti.lcmenu'], |
|
itemtext => { |
|
'lti.override' => 'Override domain defaults', |
|
'lti.topmenu' => 'Display LON-CAPA page header', |
|
'lti.inlinemenu' => 'Display LON-CAPA inline menu', |
|
'lti.lcmenu' => 'Menu items', |
|
}, |
|
}, |
'menuitems' => |
'menuitems' => |
{ |
{ |
text => 'Menu display', |
text => 'Menu display', |
Line 563 sub handler {
|
Line 583 sub handler {
|
menucollections => 'Menu collections', |
menucollections => 'Menu collections', |
}, |
}, |
}, |
}, |
'linkprotection' => |
'linkprot' => |
{ |
{ |
text => 'Link protection', |
text => 'Link protection', |
help => 'Course_Prefs_Linkprotection', |
help => 'Course_Prefs_Linkprotection', |
Line 581 sub handler {
|
Line 601 sub handler {
|
); |
); |
if (($phase eq 'process') && ($parm_permission->{'process'})) { |
if (($phase eq 'process') && ($parm_permission->{'process'})) { |
my @allitems = &get_allitems(%prefs); |
my @allitems = &get_allitems(%prefs); |
&Apache::lonconfigsettings::make_changes($r,$cdom,$phase,$context, |
my $result = &Apache::lonconfigsettings::make_changes($r,$cdom,$phase,$context, |
\@prefs_order,\%prefs,\%values, |
\@prefs_order,\%prefs,\%values, |
$cnum,undef,\@allitems, |
$cnum,undef,\@allitems, |
'coursepref',$parm_permission); |
'coursepref',$parm_permission); |
|
if ((ref($result) eq 'HASH') && (keys(%{$result}))) { |
|
$r->rflush(); |
|
&devalidate_remote_courseprefs($cdom,$cnum,$result); |
|
} |
} elsif (($phase eq 'display') && ($parm_permission->{'display'})) { |
} elsif (($phase eq 'display') && ($parm_permission->{'display'})) { |
my $noedit; |
my $noedit; |
if (ref($parm_permission) eq 'HASH') { |
if (ref($parm_permission) eq 'HASH') { |
Line 774 sub print_config_box {
|
Line 798 sub print_config_box {
|
$output .= &print_spreadsheet($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit); |
$output .= &print_spreadsheet($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit); |
} elsif ($action eq 'bridgetasks') { |
} elsif ($action eq 'bridgetasks') { |
$output .= &print_bridgetasks($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit); |
$output .= &print_bridgetasks($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit); |
|
} elsif ($action eq 'lti') { |
|
$output .= &print_lti($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit); |
} elsif ($action eq 'menuitems') { |
} elsif ($action eq 'menuitems') { |
$output .= &print_menuitems('bottom',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit); |
$output .= &print_menuitems('bottom',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit); |
} elsif ($action eq 'linkprotection') { |
} elsif ($action eq 'linkprot') { |
$output .= &print_linkprotection($cdom,$cnum,$settings,\$rowtotal,$crstype,$noedit); |
$output .= &print_linkprotection($cdom,$cnum,$settings,\$rowtotal,$crstype,$noedit,'course'); |
} elsif ($action eq 'other') { |
} elsif ($action eq 'other') { |
$output .= &print_other($cdom,$settings,$allitems,\$rowtotal,$crstype,$noedit); |
$output .= &print_other($cdom,$settings,$allitems,\$rowtotal,$crstype,$noedit); |
} |
} |
Line 790 sub print_config_box {
|
Line 816 sub print_config_box {
|
} |
} |
|
|
sub process_changes { |
sub process_changes { |
my ($cdom,$cnum,$action,$values,$item,$changes,$allitems,$disallowed,$crstype) = @_; |
my ($cdom,$cnum,$action,$values,$item,$changes,$allitems,$disallowed,$crstype,$lastactref) = @_; |
my (%newvalues,%lti,%ltienc,$ltiauth,$errors); |
my (%newvalues,$errors); |
if (ref($item) eq 'HASH') { |
if (ref($item) eq 'HASH') { |
if (ref($changes) eq 'HASH') { |
if (ref($changes) eq 'HASH') { |
my @ordered; |
my @ordered; |
Line 808 sub process_changes {
|
Line 834 sub process_changes {
|
} |
} |
} |
} |
} |
} |
} elsif ($action eq 'linkprotection') { |
} elsif ($action eq 'linkprot') { |
if (ref($values->{$action}) eq 'HASH') { |
if (ref($values->{$action}) eq 'HASH') { |
foreach my $id (keys(%{$values->{$action}})) { |
foreach my $id (keys(%{$values->{$action}})) { |
if ($id =~ /^\d+$/) { |
if ($id =~ /^\d+$/) { |
push(@ordered,$id); |
push(@ordered,$id); |
unless (ref($values->{$action}->{$id}) eq 'HASH') { |
|
$lti{$id} = ''; |
|
} |
|
} |
} |
} |
} |
} |
} |
Line 823 sub process_changes {
|
Line 846 sub process_changes {
|
if (($env{'form.linkprot_add'}) && ($env{'form.linkprot_maxnum'} =~ /^\d+$/)) { |
if (($env{'form.linkprot_add'}) && ($env{'form.linkprot_maxnum'} =~ /^\d+$/)) { |
push(@ordered,$env{'form.linkprot_maxnum'}); |
push(@ordered,$env{'form.linkprot_maxnum'}); |
} |
} |
if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) { |
|
$ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'}; |
|
} else { |
|
my %domdefs = &Apache::lonnet::get_domain_defaults($cdom); |
|
$ltiauth = $domdefs{'crsltiauth'}; |
|
} |
|
} elsif (ref($item->{'ordered'}) eq 'ARRAY') { |
} elsif (ref($item->{'ordered'}) eq 'ARRAY') { |
if ($action eq 'courseinfo') { |
if ($action eq 'courseinfo') { |
my ($can_toggle_cat,$can_categorize) = |
my ($can_toggle_cat,$can_categorize) = |
Line 966 sub process_changes {
|
Line 983 sub process_changes {
|
} elsif ($values->{'menucollections'}) { |
} elsif ($values->{'menucollections'}) { |
$changes->{'menucollections'} = ''; |
$changes->{'menucollections'} = ''; |
} |
} |
} elsif ($action eq 'linkprotection') { |
} elsif ($action eq 'linkprot') { |
my %menutitles = <imenu_titles(); |
if (ref($values) eq 'HASH') { |
my $switchserver = &check_switchserver($cdom,$cnum); |
$errors = &process_linkprot($cdom,$cnum,$values->{$action},$changes,'course',$lastactref); |
my (@items,%deletions,%itemids,%haschanges); |
|
if ($env{'form.linkprot_add'}) { |
|
my $name = $env{'form.linkprot_name_add'}; |
|
$name =~ s/(`)/'/g; |
|
my ($newid,$error) = &get_courselti_id($cdom,$cnum,$name); |
|
if ($newid) { |
|
$itemids{'add'} = $newid; |
|
push(@items,'add'); |
|
$haschanges{$newid} = 1; |
|
} else { |
|
$errors .= '<span class="LC_error">'. |
|
&mt('Failed to acquire unique ID for link protection'). |
|
'</span>'; |
|
} |
|
} |
|
if (ref($values->{$action}) eq 'HASH') { |
|
my @todelete = &Apache::loncommon::get_env_multiple('form.linkprot_del'); |
|
my $maxnum = $env{'form.linkprot_maxnum'}; |
|
for (my $i=0; $i<=$maxnum; $i++) { |
|
my $itemid = $env{'form.linkprot_id_'.$i}; |
|
$itemid =~ s/\D+//g; |
|
if ($itemid) { |
|
if (ref($values->{$action}->{$itemid}) eq 'HASH') { |
|
push(@items,$i); |
|
$itemids{$i} = $itemid; |
|
if ((@todelete > 0) && (grep(/^$i$/,@todelete))) { |
|
$deletions{$itemid} = $values->{$action}->{$itemid}->{'name'}; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
foreach my $idx (@items) { |
|
my $itemid = $itemids{$idx}; |
|
next unless ($itemid); |
|
if (exists($deletions{$itemid})) { |
|
$lti{$itemid} = $deletions{$itemid}; |
|
$haschanges{$itemid} = 1; |
|
next; |
|
} |
|
my %current; |
|
if (ref($values->{$action}) eq 'HASH') { |
|
if (ref($values->{$action}->{$itemid}) eq 'HASH') { |
|
foreach my $key (keys(%{$values->{$action}->{$itemid}})) { |
|
$current{$key} = $values->{$action}->{$itemid}->{$key}; |
|
} |
|
} |
|
} |
|
foreach my $inner ('name','lifetime','version') { |
|
my $formitem = 'form.linkprot_'.$inner.'_'.$idx; |
|
$env{$formitem} =~ s/(`)/'/g; |
|
if ($inner eq 'lifetime') { |
|
$env{$formitem} =~ s/[^\d.]//g; |
|
} |
|
unless ($idx eq 'add') { |
|
if ($current{$inner} ne $env{$formitem}) { |
|
$haschanges{$itemid} = 1; |
|
} |
|
} |
|
if ($env{$formitem} ne '') { |
|
$lti{$itemid}{$inner} = $env{$formitem}; |
|
} |
|
} |
|
if ($ltiauth) { |
|
my $reqitem = 'form.linkprot_requser_'.$idx; |
|
$env{$reqitem} =~ s/(`)/'/g; |
|
unless ($idx eq 'add') { |
|
if ($current{'requser'} ne $env{$reqitem}) { |
|
$haschanges{$itemid} = 1; |
|
} |
|
} |
|
if ($env{$reqitem} ne '') { |
|
$lti{$itemid}{'requser'} = $env{$reqitem}; |
|
foreach my $inner ('mapuser','notstudent') { |
|
my $formitem = 'form.linkprot_'.$inner.'_'.$idx; |
|
$env{$formitem} =~ s/(`)/'/g; |
|
if ($inner eq 'mapuser') { |
|
if ($env{$formitem} eq 'other') { |
|
my $mapuser = $env{'form.linkprot_customuser_'.$idx}; |
|
$mapuser =~ s/(`)/'/g; |
|
$mapuser =~ s/^\s+|\s+$//g; |
|
if ($mapuser ne '') { |
|
$lti{$itemid}{$inner} = $mapuser; |
|
} else { |
|
delete($lti{$itemid}{'requser'}); |
|
last; |
|
} |
|
} elsif ($env{$formitem} eq 'sourcedid') { |
|
$lti{$itemid}{$inner} = 'lis_person_sourcedid'; |
|
} elsif ($env{$formitem} eq 'email') { |
|
$lti{$itemid}{$inner} = 'lis_person_contact_email_primary'; |
|
} |
|
} else { |
|
$lti{$itemid}{$inner} = $env{$formitem}; |
|
} |
|
unless ($idx eq 'add') { |
|
if ($current{$inner} ne $lti{$itemid}{$inner}) { |
|
$haschanges{$itemid} = 1; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
unless ($switchserver) { |
|
my $keyitem = 'form.linkprot_key_'.$idx; |
|
$env{$keyitem} =~ s/(`)/'/g; |
|
unless ($idx eq 'add') { |
|
if ($current{'key'} ne $env{$keyitem}) { |
|
$haschanges{$itemid} = 1; |
|
} |
|
} |
|
if ($env{$keyitem} ne '') { |
|
$lti{$itemid}{'key'} = $env{$keyitem}; |
|
} |
|
my $secretitem = 'form.linkprot_secret_'.$idx; |
|
$env{$secretitem} =~ s/(`)/'/g; |
|
if ($current{'usable'}) { |
|
if ($env{'form.linkprot_changesecret_'.$idx}) { |
|
if ($env{$secretitem} ne '') { |
|
$lti{$itemid}{'secret'} = $env{$secretitem}; |
|
$haschanges{$itemid} = 1; |
|
} |
|
} else { |
|
$lti{$itemid}{'secret'} = $current{'secret'}; |
|
} |
|
} elsif ($env{$secretitem} ne '') { |
|
$lti{$itemid}{'secret'} = $env{$secretitem}; |
|
$haschanges{$itemid} = 1; |
|
} |
|
} |
|
} |
|
if (keys(%haschanges)) { |
|
foreach my $entry (keys(%haschanges)) { |
|
$changes->{$entry} = $lti{$entry}; |
|
} |
|
} |
} |
} else { |
} else { |
foreach my $entry (@ordered) { |
foreach my $entry (@ordered) { |
Line 1352 sub process_changes {
|
Line 1234 sub process_changes {
|
} |
} |
} |
} |
} |
} |
} elsif (($entry eq 'plc.roles.denied') || ($entry eq 'pch.roles.denied')) { |
} elsif (($entry eq 'plc.roles.denied') || ($entry eq 'pch.roles.denied') || |
|
($entry eq 'pac.roles.denied')) { |
my @denied = &Apache::loncommon::get_env_multiple('form.'.$entry); |
my @denied = &Apache::loncommon::get_env_multiple('form.'.$entry); |
@denied = sort(@denied); |
@denied = sort(@denied); |
my $deniedstr = ''; |
my $deniedstr = ''; |
Line 1360 sub process_changes {
|
Line 1243 sub process_changes {
|
$deniedstr = join(',',@denied); |
$deniedstr = join(',',@denied); |
} |
} |
$newvalues{$entry} = $deniedstr; |
$newvalues{$entry} = $deniedstr; |
} elsif (($entry eq 'plc.users.denied') || ($entry eq 'pch.users.denied')) { |
} elsif (($entry eq 'plc.users.denied') || ($entry eq 'pch.users.denied') || |
|
($entry eq 'pac.users.denied')) { |
my $total = $env{'form.'.$entry.'_total'}; |
my $total = $env{'form.'.$entry.'_total'}; |
my $userstr = ''; |
my $userstr = ''; |
my @denied; |
my @denied; |
Line 1412 sub process_changes {
|
Line 1296 sub process_changes {
|
my ($classorder,$classtitles) = &discussion_vote_classes(); |
my ($classorder,$classtitles) = &discussion_vote_classes(); |
my $fontchange = 0; |
my $fontchange = 0; |
foreach my $class (@{$classorder}) { |
foreach my $class (@{$classorder}) { |
my $ext_entry = $entry.'_'.$class; |
my $ext_entry = $entry.'_'.$class; |
my $size = $env{'form.'.$ext_entry.'_size'}; |
my $size = $env{'form.'.$ext_entry.'_size'}; |
my $unit = $env{'form.'.$ext_entry.'_unit'}; |
my $unit = $env{'form.'.$ext_entry.'_unit'}; |
my $weight = $env{'form.'.$ext_entry.'_weight'}; |
my $weight = $env{'form.'.$ext_entry.'_weight'}; |
my $style = $env{'form.'.$ext_entry.'_style'}; |
my $style = $env{'form.'.$ext_entry.'_style'}; |
my $other = $env{'form.'.$ext_entry.'_other'}; |
my $other = $env{'form.'.$ext_entry.'_other'}; |
$size =~ s/,//g; |
$size =~ s/,//g; |
$unit =~ s/,//g; |
$unit =~ s/,//g; |
$weight =~ s/,//g; |
$weight =~ s/,//g; |
$style =~ s/,//g; |
$style =~ s/,//g; |
$other =~ s/[^\w;:\s\-\%.]//g; |
$other =~ s/[^\w;:\s\-\%.]//g; |
Line 1427 sub process_changes {
|
Line 1311 sub process_changes {
|
$newvalues{$ext_entry} = join(',',($size.$unit,$weight,$style,$other)); |
$newvalues{$ext_entry} = join(',',($size.$unit,$weight,$style,$other)); |
my $current = $values->{$ext_entry}; |
my $current = $values->{$ext_entry}; |
if ($values->{$ext_entry} eq '') { |
if ($values->{$ext_entry} eq '') { |
$current = ',,,'; |
$current = ',,,'; |
} |
} |
if ($newvalues{$ext_entry} ne $current) { |
if ($newvalues{$ext_entry} ne $current) { |
$changes->{$ext_entry} = $newvalues{$ext_entry}; |
$changes->{$ext_entry} = $newvalues{$ext_entry}; |
Line 1436 sub process_changes {
|
Line 1320 sub process_changes {
|
} |
} |
if ($fontchange) { |
if ($fontchange) { |
$changes->{$entry} = 1; |
$changes->{$entry} = 1; |
} |
} |
} elsif ($entry eq 'nothideprivileged') { |
} elsif ($entry eq 'nothideprivileged') { |
my @curr_nothide; |
my @curr_nothide; |
my @new_nothide; |
my @new_nothide; |
Line 1511 sub process_changes {
|
Line 1395 sub process_changes {
|
my $newtext = $maxnum-1; |
my $newtext = $maxnum-1; |
$newhdr[$env{'form.printfmthdr_pos_'.$newtext}] = $env{'form.printfmthdr_text_'.$newtext}; |
$newhdr[$env{'form.printfmthdr_pos_'.$newtext}] = $env{'form.printfmthdr_text_'.$newtext}; |
$newvalues{$entry} = join('',@newhdr); |
$newvalues{$entry} = join('',@newhdr); |
} elsif (($entry eq 'languages') || |
} elsif (($entry eq 'languages') || |
($entry eq 'checkforpriv')) { |
($entry eq 'checkforpriv')) { |
my $settings; |
my $settings; |
my $total = $env{'form.'.$entry.'_total'}; |
my $total = $env{'form.'.$entry.'_total'}; |
Line 1527 sub process_changes {
|
Line 1411 sub process_changes {
|
} |
} |
if ($env{'form.'.$entry.'_'.$total} ne '') { |
if ($env{'form.'.$entry.'_'.$total} ne '') { |
my $new = $env{'form.'.$entry.'_'.$total}; |
my $new = $env{'form.'.$entry.'_'.$total}; |
if ($entry eq 'languages') { |
if ($entry eq 'languages') { |
my %langchoices = &get_lang_choices(); |
my %langchoices = &get_lang_choices(); |
if ($langchoices{$new}) { |
if ($langchoices{$new}) { |
$settings .= $new; |
$settings .= $new; |
Line 1548 sub process_changes {
|
Line 1432 sub process_changes {
|
$settings =~ s/,$//; |
$settings =~ s/,$//; |
} |
} |
$newvalues{$entry} = $settings; |
$newvalues{$entry} = $settings; |
|
} elsif ($action eq 'lti') { |
|
if ($entry eq 'lti.override') { |
|
$newvalues{$entry} = $env{'form.'.$entry}; |
|
} elsif (($entry eq 'lti.topmenu') || ($entry eq 'lti.inlinemenu')) { |
|
if ($env{'form.lti.override'}) { |
|
$newvalues{$entry} = $env{'form.'.$entry}; |
|
} else { |
|
$newvalues{$entry} = ''; |
|
} |
|
} elsif ($entry eq 'lti.lcmenu') { |
|
if (($env{'form.lti.override'}) && |
|
(($env{'form.lti.topmenu'}) || ($env{'form.lti.inlinemenu'}))) { |
|
my @lcmenu = &Apache::loncommon::get_env_multiple('form.lti.lcmenu'); |
|
my @newlcmenu; |
|
if (@lcmenu) { |
|
my @menuitems = ('fullname','coursetitle','role','logout','grades'); |
|
foreach my $item (@menuitems) { |
|
next if (($item eq 'grades') && (!$newvalues{'lti.inlinemenu'})); |
|
if (grep(/^\Q$item\E$/,@lcmenu)) { |
|
push(@newlcmenu,$item); |
|
} |
|
} |
|
} |
|
if (@newlcmenu) { |
|
$newvalues{$entry} = join(',',@newlcmenu); |
|
} else { |
|
$newvalues{$entry} = 'none'; |
|
} |
|
} else { |
|
$newvalues{$entry} = ''; |
|
} |
|
} |
} else { |
} else { |
$newvalues{$entry} = $env{'form.'.$entry}; |
$newvalues{$entry} = $env{'form.'.$entry}; |
} |
} |
Line 1564 sub process_changes {
|
Line 1480 sub process_changes {
|
return $errors; |
return $errors; |
} |
} |
|
|
sub get_courselti_id { |
sub process_linkprot { |
my ($cdom,$cnum,$name) = @_; |
my ($cdom,$cnum,$values,$changes,$context,$lastactref) = @_; |
# get lock on lti db in course |
my ($home,$dest,$ltiauth,$privkey,$privnum,$cipher,$errors,%linkprot); |
|
if (ref($values) eq 'HASH') { |
|
foreach my $id (keys(%{$values})) { |
|
if ($id =~ /^\d+$/) { |
|
unless (ref($values->{$id}) eq 'HASH') { |
|
$linkprot{$id} = ''; |
|
} |
|
} |
|
} |
|
} |
|
my %domdefs = &Apache::lonnet::get_domain_defaults($cdom); |
|
my @ids=&Apache::lonnet::current_machine_ids(); |
|
if ($context eq 'domain') { |
|
$home = &Apache::lonnet::domain($cdom,'primary'); |
|
} else { |
|
$home = &Apache::lonnet::homeserver($cnum,$cdom); |
|
} |
|
if ((($context eq 'domain') && ($domdefs{'linkprotenc_dom'})) || |
|
(($context eq 'course') && ($domdefs{'linkprotenc_crs'}))) { |
|
unless (($home eq 'no_host') || ($home eq '')) { |
|
if (grep(/^\Q$home\E$/,@ids)) { |
|
if (ref($domdefs{'privhosts'}) eq 'ARRAY') { |
|
if (grep(/^\Q$home\E$/,@{$domdefs{'privhosts'}})) { |
|
my %privhash = &Apache::lonnet::restore_dom('lti','private',$cdom,$home,1); |
|
$privkey = $privhash{'key'}; |
|
$privnum = $privhash{'version'}; |
|
if (($privnum) && ($privkey ne '')) { |
|
$cipher = Crypt::CBC->new({'key' => $privkey, |
|
'cipher' => 'DES'}); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if ($context eq 'domain') { |
|
$dest = '/adm/domainprefs'; |
|
$ltiauth = 1; |
|
} else { |
|
$dest = '/adm/courseprefs'; |
|
if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) { |
|
$ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'}; |
|
} else { |
|
my %domdefs = &Apache::lonnet::get_domain_defaults($cdom); |
|
$ltiauth = $domdefs{'crsltiauth'}; |
|
} |
|
} |
|
my $switchserver = &check_switchserver($cdom,$cnum,$context,$dest); |
|
my (@items,%deletions,%itemids,%haschanges); |
|
if ($env{'form.linkprot_add'}) { |
|
my $name = $env{'form.linkprot_name_add'}; |
|
$name =~ s/(`)/'/g; |
|
my ($newid,$error) = &get_linkprot_id($cdom,$cnum,$name,$context); |
|
if ($newid) { |
|
$itemids{'add'} = $newid; |
|
push(@items,'add'); |
|
$haschanges{$newid} = 1; |
|
} else { |
|
$errors .= '<span class="LC_error">'. |
|
&mt('Failed to acquire unique ID for link protection'). |
|
'</span>'; |
|
} |
|
} |
|
if (ref($values) eq 'HASH') { |
|
my @todelete = &Apache::loncommon::get_env_multiple('form.linkprot_del'); |
|
my $maxnum = $env{'form.linkprot_maxnum'}; |
|
for (my $i=0; $i<=$maxnum; $i++) { |
|
my $itemid = $env{'form.linkprot_id_'.$i}; |
|
$itemid =~ s/\D+//g; |
|
if ($itemid) { |
|
if (ref($values->{$itemid}) eq 'HASH') { |
|
push(@items,$i); |
|
$itemids{$i} = $itemid; |
|
if ((@todelete > 0) && (grep(/^$i$/,@todelete))) { |
|
$deletions{$itemid} = $values->{$itemid}->{'name'}; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
foreach my $idx (@items) { |
|
my $itemid = $itemids{$idx}; |
|
next unless ($itemid); |
|
if (exists($deletions{$itemid})) { |
|
$linkprot{$itemid} = $deletions{$itemid}; |
|
$haschanges{$itemid} = 1; |
|
next; |
|
} |
|
my %current; |
|
if (ref($values) eq 'HASH') { |
|
if (ref($values->{$itemid}) eq 'HASH') { |
|
foreach my $key (keys(%{$values->{$itemid}})) { |
|
$current{$key} = $values->{$itemid}->{$key}; |
|
} |
|
} |
|
} |
|
foreach my $inner ('name','lifetime','version') { |
|
my $formitem = 'form.linkprot_'.$inner.'_'.$idx; |
|
$env{$formitem} =~ s/(`)/'/g; |
|
if ($inner eq 'lifetime') { |
|
$env{$formitem} =~ s/[^\d.]//g; |
|
} |
|
unless ($idx eq 'add') { |
|
if ($current{$inner} ne $env{$formitem}) { |
|
$haschanges{$itemid} = 1; |
|
} |
|
} |
|
if ($env{$formitem} ne '') { |
|
$linkprot{$itemid}{$inner} = $env{$formitem}; |
|
} |
|
} |
|
if ($ltiauth) { |
|
my $reqitem = 'form.linkprot_requser_'.$idx; |
|
$env{$reqitem} =~ s/(`)/'/g; |
|
unless ($idx eq 'add') { |
|
if ((!$current{'requser'} && $env{$reqitem}) || |
|
($current{'requser'} && !$env{$reqitem})) { |
|
$haschanges{$itemid} = 1; |
|
} |
|
} |
|
if ($env{$reqitem} == 1) { |
|
$linkprot{$itemid}{'requser'} = $env{$reqitem}; |
|
foreach my $inner ('mapuser','notstudent') { |
|
my $formitem = 'form.linkprot_'.$inner.'_'.$idx; |
|
$env{$formitem} =~ s/(`)/'/g; |
|
if ($inner eq 'mapuser') { |
|
if ($env{$formitem} eq 'other') { |
|
my $mapuser = $env{'form.linkprot_customuser_'.$idx}; |
|
$mapuser =~ s/(`)/'/g; |
|
$mapuser =~ s/^\s+|\s+$//g; |
|
if ($mapuser ne '') { |
|
$linkprot{$itemid}{$inner} = $mapuser; |
|
} else { |
|
delete($linkprot{$itemid}{'requser'}); |
|
last; |
|
} |
|
} elsif ($env{$formitem} eq 'sourcedid') { |
|
$linkprot{$itemid}{$inner} = 'lis_person_sourcedid'; |
|
} elsif ($env{$formitem} eq 'email') { |
|
$linkprot{$itemid}{$inner} = 'lis_person_contact_email_primary'; |
|
} |
|
} else { |
|
$linkprot{$itemid}{$inner} = $env{$formitem}; |
|
} |
|
unless ($idx eq 'add') { |
|
if ($current{$inner} ne $linkprot{$itemid}{$inner}) { |
|
$haschanges{$itemid} = 1; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
unless ($switchserver) { |
|
my $keyitem = 'form.linkprot_key_'.$idx; |
|
$env{$keyitem} =~ s/(`)/'/g; |
|
unless ($idx eq 'add') { |
|
if ($current{'key'} ne $env{$keyitem}) { |
|
$haschanges{$itemid} = 1; |
|
} |
|
} |
|
if ($env{$keyitem} ne '') { |
|
$linkprot{$itemid}{'key'} = $env{$keyitem}; |
|
} |
|
my $secretitem = 'form.linkprot_secret_'.$idx; |
|
$env{$secretitem} =~ s/(`)/'/g; |
|
if ($current{'usable'}) { |
|
if ($env{'form.linkprot_changesecret_'.$idx}) { |
|
if ($env{$secretitem} ne '') { |
|
if ($privnum && $cipher) { |
|
$linkprot{$itemid}{'secret'} = $cipher->encrypt_hex($env{$secretitem}); |
|
$linkprot{$itemid}{'cipher'} = $privnum; |
|
} else { |
|
$linkprot{$itemid}{'secret'} = $env{$secretitem}; |
|
} |
|
$haschanges{$itemid} = 1; |
|
} |
|
} else { |
|
$linkprot{$itemid}{'secret'} = $current{'secret'}; |
|
$linkprot{$itemid}{'cipher'} = $current{'cipher'}; |
|
} |
|
} elsif ($env{$secretitem} ne '') { |
|
if ($privnum && $cipher) { |
|
$linkprot{$itemid}{'secret'} = $cipher->encrypt_hex($env{$secretitem}); |
|
$linkprot{$itemid}{'cipher'} = $privnum; |
|
} else { |
|
$linkprot{$itemid}{'secret'} = $env{$secretitem}; |
|
} |
|
$haschanges{$itemid} = 1; |
|
} |
|
} |
|
} |
|
if (keys(%haschanges)) { |
|
foreach my $entry (keys(%haschanges)) { |
|
$changes->{$entry} = $linkprot{$entry}; |
|
} |
|
if (ref($lastactref) eq 'HASH') { |
|
$lastactref->{'courselti'} = 1'; |
|
} |
|
} |
|
return $errors; |
|
} |
|
|
|
sub get_linkprot_id { |
|
my ($cdom,$cnum,$name,$context) = @_; |
|
# get lock on lti db in course or linkprot db in domain |
my $lockhash = { |
my $lockhash = { |
lock => $env{'user.name'}. |
lock => $env{'user.name'}. |
':'.$env{'user.domain'}, |
':'.$env{'user.domain'}, |
}; |
}; |
my $tries = 0; |
my $tries = 0; |
my $gotlock = &Apache::lonnet::newput('lti',$lockhash,$cdom,$cnum); |
my $gotlock; |
|
if ($context eq 'domain') { |
|
$gotlock = &Apache::lonnet::newput_dom('linkprot',$lockhash,$cdom); |
|
} else { |
|
$gotlock = &Apache::lonnet::newput('lti',$lockhash,$cdom,$cnum); |
|
} |
my ($id,$error); |
my ($id,$error); |
while (($gotlock ne 'ok') && ($tries<10)) { |
while (($gotlock ne 'ok') && ($tries<10)) { |
$tries ++; |
$tries ++; |
sleep (0.1); |
sleep (0.1); |
$gotlock = &Apache::lonnet::newput('lti',$lockhash,$cdom,$cnum); |
if ($context eq 'domain') { |
|
$gotlock = &Apache::lonnet::newput_dom('linkprot',$lockhash,$cdom); |
|
} else { |
|
$gotlock = &Apache::lonnet::newput('lti',$lockhash,$cdom,$cnum); |
|
} |
} |
} |
if ($gotlock eq 'ok') { |
if ($gotlock eq 'ok') { |
my %currids = &Apache::lonnet::dump('lti',$cdom,$cnum,undef,undef,undef,1); |
my %currids; |
|
if ($context eq 'domain') { |
|
%currids = &Apache::lonnet::dump_dom('linkprot',$cdom); |
|
} else { |
|
%currids = &Apache::lonnet::dump('lti',$cdom,$cnum,undef,undef,undef,1); |
|
} |
if ($currids{'lock'}) { |
if ($currids{'lock'}) { |
delete($currids{'lock'}); |
delete($currids{'lock'}); |
if (keys(%currids)) { |
if (keys(%currids)) { |
Line 1594 sub get_courselti_id {
|
Line 1728 sub get_courselti_id {
|
$id = 1; |
$id = 1; |
} |
} |
if ($id) { |
if ($id) { |
unless (&Apache::lonnet::newput('lti',{ $id => $name },$cdom,$cnum) eq 'ok') { |
if ($context eq 'domain') { |
$error = 'nostore'; |
unless (&Apache::lonnet::newput_dom('linkprot',{ $id => $name },$cdom) eq 'ok') { |
|
$error = 'nostore'; |
|
} |
|
} else { |
|
unless (&Apache::lonnet::newput('lti',{ $id => $name },$cdom,$cnum) eq 'ok') { |
|
$error = 'nostore'; |
|
} |
} |
} |
} else { |
} else { |
$error = 'nonumber'; |
$error = 'nonumber'; |
} |
} |
} |
} |
my $dellockoutcome = &Apache::lonnet::del('lti',['lock'],$cdom,$cnum); |
my $dellockoutcome; |
|
if ($context eq 'domain') { |
|
$dellockoutcome = &Apache::lonnet::del_dom('linkprot',['lock'],$cdom); |
|
} else { |
|
$dellockoutcome = &Apache::lonnet::del('lti',['lock'],$cdom,$cnum); |
|
} |
} else { |
} else { |
$error = 'nolock'; |
$error = 'nolock'; |
} |
} |
Line 1652 sub store_changes {
|
Line 1797 sub store_changes {
|
my ($chome,$output); |
my ($chome,$output); |
my (%storehash,@delkeys,@need_env_update,@oldcloner,%oldlinkprot); |
my (%storehash,@delkeys,@need_env_update,@oldcloner,%oldlinkprot); |
if ((ref($values) eq 'HASH') && (ref($changes) eq 'HASH')) { |
if ((ref($values) eq 'HASH') && (ref($changes) eq 'HASH')) { |
if (ref($values->{'linkprotection'}) eq 'HASH') { |
if (ref($values->{'linkprot'}) eq 'HASH') { |
%oldlinkprot = %{$values->{'linkprotection'}}; |
%oldlinkprot = %{$values->{'linkprot'}}; |
} |
} |
delete($values->{'linkprotection'}); |
delete($values->{'linkprot'}); |
%storehash = %{$values}; |
%storehash = %{$values}; |
} else { |
} else { |
if ($crstype eq 'Community') { |
if ($crstype eq 'Community') { |
Line 1668 sub store_changes {
|
Line 1813 sub store_changes {
|
my ($numchanges,$skipstore); |
my ($numchanges,$skipstore); |
if (ref($changes) eq 'HASH') { |
if (ref($changes) eq 'HASH') { |
$numchanges = scalar(keys(%{$changes})); |
$numchanges = scalar(keys(%{$changes})); |
if (($numchanges == 1) && (exists($changes->{'linkprotection'}))) { |
if (($numchanges == 1) && (exists($changes->{'linkprot'}))) { |
$skipstore = 1; |
$skipstore = 1; |
} elsif (!$numchanges) { |
} elsif (!$numchanges) { |
if ($crstype eq 'Community') { |
if ($crstype eq 'Community') { |
Line 1704 sub store_changes {
|
Line 1849 sub store_changes {
|
"'$storehash{$key}'")).'</li>'; |
"'$storehash{$key}'")).'</li>'; |
} |
} |
} |
} |
} elsif ($item eq 'linkprotection') { |
} elsif ($item eq 'linkprot') { |
my ($ltiauth,%ltienc,$lti_save_error); |
$output .= &store_linkprot($cdom,$cnum,'course',$changes->{$item},\%oldlinkprot); |
if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) { |
|
$ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'}; |
|
} else { |
|
my %domdefs = &Apache::lonnet::get_domain_defaults($cdom); |
|
$ltiauth = $domdefs{'crsltiauth'}; |
|
} |
|
if (ref($changes->{$item}) eq 'HASH') { |
|
foreach my $id (sort { $a <=> $b } keys(%{$changes->{$item}})) { |
|
if (ref($changes->{$item}->{$id}) eq 'HASH') { |
|
if (exists($changes->{$item}->{$id}->{'key'})) { |
|
$ltienc{$id}{'key'} = $changes->{$item}->{$id}->{'key'}; |
|
delete($changes->{$item}->{$id}->{'key'}); |
|
} |
|
if (exists($changes->{$item}->{$id}->{'secret'})) { |
|
$ltienc{$id}{'secret'} = $changes->{$item}->{$id}->{'secret'}; |
|
delete($changes->{$item}->{$id}->{'secret'}); |
|
} elsif (ref($oldlinkprot{$id}) eq 'HASH') { |
|
if (exists($oldlinkprot{$id}{'usable'})) { |
|
$changes->{$item}->{$id}->{'usable'} = 1; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if (keys(%ltienc) > 0) { |
|
if (&Apache::lonnet::put('nohist_ltienc',\%ltienc,$cdom,$cnum,1) eq 'ok') { |
|
foreach my $id (keys(%ltienc)) { |
|
if (exists($ltienc{$id}{'secret'})) { |
|
$changes->{$item}->{$id}->{'usable'} = 1; |
|
} |
|
} |
|
} else { |
|
$lti_save_error = 1; |
|
} |
|
} |
|
unless ($lti_save_error) { |
|
if (&Apache::lonnet::put('lti',$changes->{$item},$cdom,$cnum,1) eq 'ok') { |
|
my $hashid=$cdom.'_'.$cnum; |
|
&Apache::lonnet::devalidate_cache_new('courselti',$hashid); |
|
$chome = &Apache::lonnet::homeserver($cnum,$cdom); |
|
unless (($chome eq 'no_host') || ($chome eq '')) { |
|
my @ids=&Apache::lonnet::current_machine_ids(); |
|
if (grep(/^\Q$chome\E$/,@ids)) { |
|
&Apache::lonnet::devalidate_cache_new('courseltienc',$hashid); |
|
} |
|
} |
|
foreach my $id (sort { $a <=> $b } %{$changes->{$item}}) { |
|
if (ref($changes->{$item}->{$id}) eq 'HASH') { |
|
my %values = %{$changes->{$item}->{$id}}; |
|
my %desc = &linkprot_names(); |
|
my $display; |
|
foreach my $title ('name','lifetime','version','key','secret') { |
|
if (($title eq 'key') || ($title eq 'secret')) { |
|
if (ref($ltienc{$id}) eq 'HASH') { |
|
if (exists($ltienc{$id}{$title})) { |
|
if ($title eq 'secret') { |
|
my $length = length($ltienc{$id}{$title}); |
|
$display .= $desc{$title}.': '.('*' x $length).', '; |
|
} else { |
|
$display .= $desc{$title}.': '.$ltienc{$id}{$title}.', '; |
|
} |
|
} |
|
} |
|
} elsif ($title eq 'version') { |
|
if ($values{$title} eq 'LTI-1p0') { |
|
$display .= $desc{$title}.': 1.1, '; |
|
} |
|
} else { |
|
$display .= $desc{$title}.': '.$values{$title}.', '; |
|
} |
|
} |
|
if ($ltiauth) { |
|
if (($values{'requser'}) && ($values{'mapuser'} ne '')) { |
|
if ($values{'mapuser'} eq 'lis_person_contact_email_primary') { |
|
$display .= &mt('Source of username: Email address [_1]', |
|
'(lis_person_contact_email_primary)').', '; |
|
} elsif ($values{'mapuser'} eq 'lis_person_sourcedid') { |
|
$display .= &mt('Source of username: User ID [_1]', |
|
'(lis_person_sourcedid)').', '; |
|
} else { |
|
$display .= &mt('Source of username: [_1]',$values{'mapuser'}).', '; |
|
} |
|
if ($values{'notstudent'} eq 'auth') { |
|
$display .= &mt('Display LON-CAPA login page if no match').', '; |
|
} elsif ($values{'notstudent'} eq 'reject') { |
|
$display .= &mt('Discontinue launch if no match').', '; |
|
} |
|
} |
|
} |
|
$display =~ s/, $//; |
|
$output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]','<i>'.$id.'</i>', |
|
"'$display'")).'</li>'; |
|
} elsif (ref($oldlinkprot{$id}) eq 'HASH') { |
|
my $oldname = $oldlinkprot{$id}{'name'}; |
|
$output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]','<i>'."$id ($oldname)".'</i>')).'</li>'; |
|
} |
|
} |
|
} else { |
|
$lti_save_error = 1; |
|
} |
|
} |
|
unless ($lti_save_error) { |
|
my @deletions; |
|
foreach my $id (sort { $a <=> $b } keys(%{$changes->{$item}})) { |
|
unless (ref($changes->{$item}->{$id}) eq 'HASH') { |
|
push (@deletions,$id); |
|
} |
|
} |
|
if (@deletions) { |
|
&Apache::lonnet::del('nohist_ltienc',\@deletions,$cdom,$cnum); |
|
} |
|
} |
|
if ($lti_save_error) { |
|
$output .= '<li>'. |
|
'<span class="LC_error">'. |
|
&mt('An error occurred when saving changes to link protection settings, which remain unchanged.'). |
|
'</span>'. |
|
'</li>'; |
|
} |
|
} else { |
} else { |
if (ref($prefs->{$item}->{'ordered'}) eq 'ARRAY') { |
if (ref($prefs->{$item}->{'ordered'}) eq 'ARRAY') { |
my @settings = @{$prefs->{$item}->{'ordered'}}; |
my @settings = @{$prefs->{$item}->{'ordered'}}; |
Line 1941 sub store_changes {
|
Line 1967 sub store_changes {
|
} |
} |
} |
} |
$displayname = &mt($text); |
$displayname = &mt($text); |
|
} elsif ($item eq 'lti') { |
|
if ($key eq 'lti.lcmenu') { |
|
if ($changes->{$item}{$key} eq 'none') { |
|
$displayval = &mt('None of the configurable menu items displayed'); |
|
} else { |
|
my %ltititles = <imenu_titles(); |
|
$displayval = join(', ', map { $ltititles{$_}; } split(/,/,$changes->{$item}{$key})); |
|
} |
|
} else { |
|
if ($changes->{$item}{$key} eq '1') { |
|
$displayval = &mt('Yes'); |
|
} elsif ($changes->{$item}{$key} eq '') { |
|
$displayval = &mt('No'); |
|
} |
|
} |
|
$displayname = &mt($text); |
} elsif ($item eq 'menuitems') { |
} elsif ($item eq 'menuitems') { |
unless ($changes->{$item}{$key} eq '') { |
unless ($changes->{$item}{$key} eq '') { |
if ($key eq 'menudefault') { |
if ($key eq 'menudefault') { |
Line 2014 sub store_changes {
|
Line 2056 sub store_changes {
|
} |
} |
} elsif ($changes->{$item}{$key} eq '') { |
} elsif ($changes->{$item}{$key} eq '') { |
push(@delkeys,$key); |
push(@delkeys,$key); |
if ($item eq 'menuitems') { |
if ($item eq 'lti') { |
|
if (($key eq 'lti.override') || (($key ne 'lti.override') && ($env{'form.lti.override'} ne ''))) { |
|
if (($key eq 'lti.lcmenu') && |
|
((!$env{'form.lti.topmenu'}) && (!$env{'form.lti.inlinemenu'}))) { |
|
$output .= '<li>'.&mt('LTI settings for menu items only saved if page header and/or inline menu is set to be displayed').'</li>'; |
|
} else { |
|
$output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]', |
|
'<i>'.$displayname.'</i>', |
|
"'<b>$displayval</b>'")).'</li>'; |
|
} |
|
} elsif (!exists($changes->{$item}{'lti.override'})) { |
|
$output .= '<li>'.&mt('LTI settings only saved if Override is set to "Yes"').'</li>'; |
|
} |
|
} elsif ($item eq 'menuitems') { |
if ($key eq 'menudefault') { |
if ($key eq 'menudefault') { |
$output .= '<li>'.&mt("Default collection of menu items set to: 'Standard' (all menus shown)").'</li>'; |
$output .= '<li>'.&mt("Default collection of menu items set to: 'Standard' (all menus shown)").'</li>'; |
} elsif ($key eq 'menucollections') { |
} elsif ($key eq 'menucollections') { |
Line 2065 sub store_changes {
|
Line 2120 sub store_changes {
|
} |
} |
if (($key eq 'description') || ($key eq 'cloners') || |
if (($key eq 'description') || ($key eq 'cloners') || |
($key eq 'hidefromcat') || ($key eq 'categories') || |
($key eq 'hidefromcat') || ($key eq 'categories') || |
($key eq 'co-owners')) { |
($key eq 'co-owners') || ($key eq 'lti.override') || |
|
($key eq 'lti.topmenu') || ($key eq 'lti.inlinemenu') || |
|
($key eq 'lti.lcmenu')) { |
push(@need_env_update,$key); |
push(@need_env_update,$key); |
} |
} |
} |
} |
Line 2127 sub store_changes {
|
Line 2184 sub store_changes {
|
return $output; |
return $output; |
} |
} |
|
|
|
sub store_linkprot { |
|
my ($cdom,$cnum,$context,$changes,$oldlinkprot) = @_; |
|
my ($ltiauth,$home,$lti_save_error,$output,$error,%ltienc,@deletions); |
|
if ($context eq 'domain') { |
|
$ltiauth = 1; |
|
$home = &Apache::lonnet::domain($cdom,'primary'); |
|
} else { |
|
$home = &Apache::lonnet::homeserver($cnum,$cdom); |
|
if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) { |
|
$ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'}; |
|
} else { |
|
my %domdefs = &Apache::lonnet::get_domain_defaults($cdom); |
|
$ltiauth = $domdefs{'crsltiauth'}; |
|
} |
|
} |
|
if (ref($changes) eq 'HASH') { |
|
foreach my $id (sort { $a <=> $b } keys(%{$changes})) { |
|
if (ref($changes->{$id}) eq 'HASH') { |
|
if (exists($changes->{$id}->{'key'})) { |
|
$ltienc{$id}{'key'} = $changes->{$id}->{'key'}; |
|
delete($changes->{$id}->{'key'}); |
|
} |
|
if (exists($changes->{$id}->{'secret'})) { |
|
$ltienc{$id}{'secret'} = $changes->{$id}->{'secret'}; |
|
delete($changes->{$id}->{'secret'}); |
|
} elsif (ref($oldlinkprot->{$id}) eq 'HASH') { |
|
if (exists($oldlinkprot->{$id}{'usable'})) { |
|
$changes->{$id}->{'usable'} = 1; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
my @ids=&Apache::lonnet::current_machine_ids(); |
|
if (keys(%ltienc) > 0) { |
|
if ($context eq 'domain') { |
|
foreach my $id (keys(%ltienc)) { |
|
if (exists($ltienc{$id}{'secret'})) { |
|
$changes->{$id}->{'usable'} = 1; |
|
} |
|
} |
|
} else { |
|
unless (($home eq 'no_host') || ($home eq '')) { |
|
my $allowed; |
|
foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } |
|
if ($allowed) { |
|
if (&Apache::lonnet::put('nohist_ltienc',\%ltienc,$cdom,$cnum,1) eq 'ok') { |
|
foreach my $id (keys(%ltienc)) { |
|
if (exists($ltienc{$id}{'secret'})) { |
|
$changes->{$id}->{'usable'} = 1; |
|
} |
|
} |
|
} else { |
|
$lti_save_error = 1; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
unless ($lti_save_error) { |
|
if ($context eq 'course') { |
|
if (&Apache::lonnet::put('lti',$changes,$cdom,$cnum,1) eq 'ok') { |
|
my $hashid=$cdom.'_'.$cnum; |
|
&Apache::lonnet::devalidate_cache_new('courselti',$hashid); |
|
unless (($home eq 'no_host') || ($home eq '')) { |
|
if (grep(/^\Q$home\E$/,@ids)) { |
|
&Apache::lonnet::devalidate_cache_new('courseltienc',$hashid); |
|
} |
|
} |
|
} else { |
|
$lti_save_error = 1; |
|
} |
|
} |
|
unless ($lti_save_error) { |
|
foreach my $id (sort { $a <=> $b } %{$changes}) { |
|
if (ref($changes->{$id}) eq 'HASH') { |
|
my %values = %{$changes->{$id}}; |
|
my %desc = &linkprot_names(); |
|
my $display; |
|
foreach my $title ('name','lifetime','version','key','secret') { |
|
if (($title eq 'key') || ($title eq 'secret')) { |
|
if (ref($ltienc{$id}) eq 'HASH') { |
|
if (exists($ltienc{$id}{$title})) { |
|
if ($title eq 'secret') { |
|
my $length = length($ltienc{$id}{$title}); |
|
$display .= $desc{$title}.': ['.&mt('not shown').'], '; |
|
} else { |
|
$display .= $desc{$title}.': '.$ltienc{$id}{$title}.', '; |
|
} |
|
} |
|
} |
|
} elsif ($title eq 'version') { |
|
if ($values{$title} eq 'LTI-1p0') { |
|
$display .= $desc{$title}.': 1.1, '; |
|
} |
|
} else { |
|
$display .= $desc{$title}.': '.$values{$title}.', '; |
|
} |
|
} |
|
if ($ltiauth) { |
|
if (($values{'requser'}) && ($values{'mapuser'} ne '')) { |
|
if ($values{'mapuser'} eq 'lis_person_contact_email_primary') { |
|
$display .= &mt('Source of username: Email address [_1]', |
|
'(lis_person_contact_email_primary)').', '; |
|
} elsif ($values{'mapuser'} eq 'lis_person_sourcedid') { |
|
$display .= &mt('Source of username: User ID [_1]', |
|
'(lis_person_sourcedid)').', '; |
|
} else { |
|
$display .= &mt('Source of username: [_1]',$values{'mapuser'}).', '; |
|
} |
|
if ($values{'notstudent'} eq 'auth') { |
|
$display .= &mt('Display LON-CAPA login page if no match').', '; |
|
} elsif ($values{'notstudent'} eq 'reject') { |
|
$display .= &mt('Discontinue launch if no match').', '; |
|
} |
|
} |
|
} |
|
$display =~ s/, $//; |
|
$output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]','<i>'.$id.'</i>', |
|
"'$display'")).'</li>'; |
|
} elsif (ref($oldlinkprot->{$id}) eq 'HASH') { |
|
my $oldname = $oldlinkprot->{$id}{'name'}; |
|
$output .= '<li>'.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]','<i>'."$id ($oldname)".'</i>')).'</li>'; |
|
} |
|
} |
|
} else { |
|
$lti_save_error = 1; |
|
} |
|
} |
|
unless ($lti_save_error) { |
|
foreach my $id (sort { $a <=> $b } keys(%{$changes})) { |
|
unless (ref($changes->{$id}) eq 'HASH') { |
|
push(@deletions,$id); |
|
} |
|
} |
|
if (@deletions) { |
|
if ($context eq 'course') { |
|
&Apache::lonnet::del('nohist_ltienc',\@deletions,$cdom,$cnum); |
|
} |
|
} |
|
} |
|
if ($lti_save_error) { |
|
$output .= '<li>'. |
|
'<span class="LC_error">'. |
|
&mt('An error occurred when saving changes to link protection settings, which remain unchanged.'). |
|
'</span>'. |
|
'</li>'; |
|
} |
|
return $output; |
|
} |
|
|
sub update_env { |
sub update_env { |
my ($cnum,$cdom,$chome,$need_env_update,$storehash) = @_; |
my ($cnum,$cdom,$chome,$need_env_update,$storehash) = @_; |
my $count = 0; |
my $count = 0; |
Line 2152 sub update_env {
|
Line 2360 sub update_env {
|
my @coowners = split(',',$storehash->{'internal.'.$key}); |
my @coowners = split(',',$storehash->{'internal.'.$key}); |
$crsinfo{$env{'request.course.id'}}{'co-owners'} = \@coowners; |
$crsinfo{$env{'request.course.id'}}{'co-owners'} = \@coowners; |
$count ++; |
$count ++; |
|
} elsif ($key =~ /^lti\./) { |
|
&Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$key => $storehash->{$key}}); |
} |
} |
} |
} |
if ($count) { |
if ($count) { |
Line 2280 sub get_jscript {
|
Line 2490 sub get_jscript {
|
$local_to_standard{$code_order[$i]} = $standardnames[$i]; |
$local_to_standard{$code_order[$i]} = $standardnames[$i]; |
} |
} |
foreach my $cloner (@cloners) { |
foreach my $cloner (@cloners) { |
if (($cloner !~ /^\Q*:\E$match_domain$/) && |
if (($cloner !~ /^\Q*:\E$match_domain$/) && |
($cloner !~ /^$match_username\:$match_domain$/)) { |
($cloner !~ /^$match_username\:$match_domain$/)) { |
foreach my $item (split(/\&/,$cloner)) { |
foreach my $item (split(/\&/,$cloner)) { |
my ($key,$val) = split(/\=/,$item); |
my ($key,$val) = split(/\=/,$item); |
Line 2464 function toggleAddmenucoll() {
|
Line 2674 function toggleAddmenucoll() {
|
} |
} |
ENDSCRIPT |
ENDSCRIPT |
} |
} |
my $linkprotector_js = <<"ENDSCRIPT"; |
|
function toggleLTI(form,num,item) { |
|
var radioname = ''; |
|
var currdivid = ''; |
|
var newdivid = ''; |
|
if ((document.getElementById('linkprot_divcurr'+item+'_'+num)) && |
|
(document.getElementById('linkprot_divchg'+item+'_'+num))) { |
|
currdivid = document.getElementById('linkprot_divcurr'+item+'_'+num); |
|
newdivid = document.getElementById('linkprot_divchg'+item+'_'+num); |
|
radioname = form.elements['linkprot_change'+item+'_'+num]; |
|
if (radioname) { |
|
if (radioname.length > 0) { |
|
var setvis; |
|
for (var i=0; i<radioname.length; i++) { |
|
if (radioname[i].checked == true) { |
|
if (radioname[i].value == 1) { |
|
newdivid.style.display = 'inline-block'; |
|
currdivid.style.display = 'none'; |
|
setvis = 1; |
|
} |
|
break; |
|
} |
|
} |
|
if (!setvis) { |
|
newdivid.style.display = 'none'; |
|
currdivid.style.display = 'inline-block'; |
|
} |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
|
function toggleLTIReqUser(form,item,extra,valon,styleon,num) { |
|
if (document.getElementById('linkprot_'+extra+'_'+num)) { |
|
var extraid = document.getElementById('linkprot_'+extra+'_'+num); |
|
var itemname = form.elements['linkprot_'+item+'_'+num]; |
|
if (itemname) { |
|
if (itemname.length > 0) { |
|
var setvis; |
|
for (var i=0; i<itemname.length; i++) { |
|
if (itemname[i].checked == true) { |
|
if (itemname[i].value == valon) { |
|
extraid.style.display = styleon; |
|
setvis = 1; |
|
} |
|
break; |
|
} |
|
} |
|
if (!setvis) { |
|
extraid.style.display = 'none'; |
|
} |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
ENDSCRIPT |
|
$jscript = '<script type="text/javascript" language="Javascript">'."\n". |
$jscript = '<script type="text/javascript" language="Javascript">'."\n". |
'// <![CDATA['."\n". |
'// <![CDATA['."\n". |
$browse_js."\n".$categorize_js."\n".$loncaparev_js."\n". |
$browse_js."\n".$categorize_js."\n".$loncaparev_js."\n". |
$cloners_js."\n".$instcode_js. |
$cloners_js."\n".$instcode_js. |
$syllabus_js."\n".$menuitems_js."\n". |
$syllabus_js."\n".$menuitems_js."\n". |
$linkprotector_js."\n".'//]]>'."\n". |
&linkprot_javascript()."\n".'//]]>'."\n". |
'</script>'."\n".$stubrowse_js."\n"; |
'</script>'."\n".$stubrowse_js."\n"; |
return $jscript; |
return $jscript; |
} |
} |
Line 2613 function getIndexByName(item) {
|
Line 2765 function getIndexByName(item) {
|
ENDSCRIPT |
ENDSCRIPT |
} |
} |
|
|
|
sub linkprot_javascript { |
|
return <<"ENDSCRIPT"; |
|
function toggleLinkProt(form,num,item) { |
|
var radioname = ''; |
|
var currdivid = ''; |
|
var newdivid = ''; |
|
if ((document.getElementById('linkprot_divcurr'+item+'_'+num)) && |
|
(document.getElementById('linkprot_divchg'+item+'_'+num))) { |
|
currdivid = document.getElementById('linkprot_divcurr'+item+'_'+num); |
|
newdivid = document.getElementById('linkprot_divchg'+item+'_'+num); |
|
radioname = form.elements['linkprot_change'+item+'_'+num]; |
|
if (radioname) { |
|
if (radioname.length > 0) { |
|
var setvis; |
|
for (var i=0; i<radioname.length; i++) { |
|
if (radioname[i].checked == true) { |
|
if (radioname[i].value == 1) { |
|
newdivid.style.display = 'inline-block'; |
|
currdivid.style.display = 'none'; |
|
setvis = 1; |
|
} |
|
break; |
|
} |
|
} |
|
if (!setvis) { |
|
newdivid.style.display = 'none'; |
|
currdivid.style.display = 'inline-block'; |
|
} |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
|
function toggleLinkProtReqUser(form,item,extra,valon,styleon,num) { |
|
if (document.getElementById('linkprot_'+extra+'_'+num)) { |
|
var extraid = document.getElementById('linkprot_'+extra+'_'+num); |
|
var itemname = form.elements['linkprot_'+item+'_'+num]; |
|
if (itemname) { |
|
if (itemname.length > 0) { |
|
var setvis; |
|
for (var i=0; i<itemname.length; i++) { |
|
if (itemname[i].checked == true) { |
|
if (itemname[i].value == valon) { |
|
extraid.style.display = styleon; |
|
setvis = 1; |
|
} |
|
break; |
|
} |
|
} |
|
if (!setvis) { |
|
extraid.style.display = 'none'; |
|
} |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
|
function uncheckLinkProtMakeVis(item,num) { |
|
if (document.getElementById('linkprot_'+item+'_'+num)) { |
|
var currtype = document.getElementById('linkprot_'+item+'_'+num).type; |
|
if (currtype.toLowerCase() == 'checkbox') { |
|
document.getElementById('linkprot_'+item+'_'+num).checked = false; |
|
} |
|
} |
|
return; |
|
} |
|
ENDSCRIPT |
|
|
|
} |
|
|
|
|
sub print_courseinfo { |
sub print_courseinfo { |
my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_; |
my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_; |
Line 2707 sub print_courseinfo {
|
Line 2931 sub print_courseinfo {
|
&mt('Modification may make assessment data inaccessible!'). |
&mt('Modification may make assessment data inaccessible!'). |
'</span>'; |
'</span>'; |
$editsyllabus = &mt('[_1]Edit[_2]','<a href="/public/'.$cdom.'/'.$cnum.'/syllabus?forceedit=1">', |
$editsyllabus = &mt('[_1]Edit[_2]','<a href="/public/'.$cdom.'/'.$cnum.'/syllabus?forceedit=1">', |
'</a>'); |
'</a>'); |
} |
} |
my %items = ( |
my %items = ( |
'url' => { |
'url' => { |
Line 2788 sub print_courseinfo {
|
Line 3012 sub print_courseinfo {
|
next if (!$env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'}); |
next if (!$env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'}); |
} |
} |
unless (($item eq 'cloners') || ($item eq 'rolenames')) { |
unless (($item eq 'cloners') || ($item eq 'rolenames')) { |
$colspan = 2; |
$colspan = 2; |
} |
} |
$count ++; |
$count ++; |
if (exists $items{$item}{advanced} && $items{$item}{advanced} == 1) { |
if (exists $items{$item}{advanced} && $items{$item}{advanced} == 1) { |
Line 2832 sub print_courseinfo {
|
Line 3056 sub print_courseinfo {
|
$default = '0'; |
$default = '0'; |
} |
} |
$datatable .= &new_cloners_dom_row($cdom,'0',$default); |
$datatable .= &new_cloners_dom_row($cdom,'0',$default); |
} |
} |
} elsif ($settings->{$item} ne '*') { |
} elsif ($settings->{$item} ne '*') { |
my @entries = split(/,/,$settings->{$item}); |
my @entries = split(/,/,$settings->{$item}); |
if (@entries > 0) { |
if (@entries > 0) { |
Line 2971 sub print_courseinfo {
|
Line 3195 sub print_courseinfo {
|
if ($clonesrc =~ m{/$match_domain/$match_courseid}) { |
if ($clonesrc =~ m{/$match_domain/$match_courseid}) { |
my %clonesrcinfo = &Apache::lonnet::coursedescription($clonesrc); |
my %clonesrcinfo = &Apache::lonnet::coursedescription($clonesrc); |
if ($clonesrcinfo{'description'}) { |
if ($clonesrcinfo{'description'}) { |
$clonedfrom = $clonesrcinfo{'description'}.' '.($clonesrc); |
$clonedfrom = $clonesrcinfo{'description'}.' '.($clonesrc); |
} |
} |
} |
} |
$datatable .= $clonedfrom; |
$datatable .= $clonedfrom; |
} elsif ($item eq 'uniquecode') { |
} elsif ($item eq 'uniquecode') { |
my $code = $env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'}; |
my $code = $env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'}; |
if ($code) { |
if ($code) { |
$datatable .= $code; |
$datatable .= $code; |
} |
} |
Line 3023 sub print_courseinfo {
|
Line 3247 sub print_courseinfo {
|
} elsif ($uploaded) { |
} elsif ($uploaded) { |
$datatable .= &mt('Uploaded file'); |
$datatable .= &mt('Uploaded file'); |
} else { |
} else { |
$datatable .= &mt('Standard template'); |
$datatable .= &mt('Standard template'); |
} |
} |
$datatable .= (' ' x 2). |
$datatable .= (' ' x 2). |
&mt('[_1]View[_2]', |
&mt('[_1]View[_2]', |
'<a href="javascript:syllabusinfo();">', |
'<a href="javascript:syllabusinfo();">', |
'</a>'); |
'</a>'); |
} elsif ($item eq 'loncaparev') { |
} elsif ($item eq 'loncaparev') { |
my $loncaparev = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'}; |
my $loncaparev = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'}; |
my $showreqd; |
my $showreqd; |
Line 3053 sub new_cloners_dom_row {
|
Line 3277 sub new_cloners_dom_row {
|
my ($output,$checkedon,$checkedoff); |
my ($output,$checkedon,$checkedoff); |
if ($newdom ne '') { |
if ($newdom ne '') { |
if ($num eq $default) { |
if ($num eq $default) { |
$checkedon = 'checked="checked" '; |
$checkedon = 'checked="checked" '; |
} else { |
} else { |
$checkedoff = 'checked="checked" '; |
$checkedoff = 'checked="checked" '; |
} |
} |
Line 3204 ENDSCRIPT
|
Line 3428 ENDSCRIPT
|
|
|
sub display_loncaparev_constraints { |
sub display_loncaparev_constraints { |
my ($r,$navmap,$loncaparev,$crstype) = @_; |
my ($r,$navmap,$loncaparev,$crstype) = @_; |
my ($reqdmajor,$reqdminor); |
my ($reqdmajor,$reqdminor); |
my $cid = $env{'request.course.id'}; |
my $cid = $env{'request.course.id'}; |
my $cdom = $env{'course.'.$cid.'.domain'}; |
my $cdom = $env{'course.'.$cid.'.domain'}; |
my $cnum = $env{'course.'.$cid.'.num'}; |
my $cnum = $env{'course.'.$cid.'.num'}; |
Line 3221 sub display_loncaparev_constraints {
|
Line 3445 sub display_loncaparev_constraints {
|
$Apache::lonrelrequtils::checkcrstypes{$crstype}).'</h4>'; |
$Apache::lonrelrequtils::checkcrstypes{$crstype}).'</h4>'; |
} |
} |
my (%fromparam,%rowspan,%bymap,%byresource,@scopeorder,%toshow,%allmaps, |
my (%fromparam,%rowspan,%bymap,%byresource,@scopeorder,%toshow,%allmaps, |
%byresponsetype,%bysubmission,%fromblocks); |
%byresponsetype,%bysubmission,%fromblocks,%bycrsrestype); |
@scopeorder = ('all','section/group','user'); |
@scopeorder = ('all','section/group','user'); |
my $now = time; |
my $now = time; |
my $resourcedata = &Apache::lonparmset::readdata($cnum,$cdom); |
my $resourcedata = &Apache::lonparmset::readdata($cnum,$cdom); |
if (ref($resourcedata) eq 'HASH') { |
if (ref($resourcedata) eq 'HASH') { |
foreach my $key (keys(%{$resourcedata})) { |
foreach my $key (keys(%{$resourcedata})) { |
|
my %found; |
foreach my $item (keys(%Apache::lonrelrequtils::checkparms)) { |
foreach my $item (keys(%Apache::lonrelrequtils::checkparms)) { |
if ($key =~ /(\Q$item\E)$/) { |
if ($key =~ /(\Q$item\E)$/) { |
if (ref($Apache::lonrelrequtils::checkparms{$item}) eq 'ARRAY') { |
if (ref($Apache::lonrelrequtils::checkparms{$item}) eq 'ARRAY') { |
my $value = $resourcedata->{$key}; |
my $value = $resourcedata->{$key}; |
if ($item eq 'examcode') { |
if ($item eq 'examcode') { |
if (&Apache::lonnet::validCODE($value)) { |
if (&Apache::lonnet::validCODE($value)) { |
$value = 'valid'; |
$value = 'valid'; |
} else { |
} else { |
$value = ''; |
$value = ''; |
} |
} |
} elsif ($item eq 'printstartdate') { |
} elsif ($item eq 'printstartdate') { |
if ($value =~ /^\d+$/) { |
if ($value =~ /^\d+$/) { |
if ($value > $now) { |
if ($value > $now) { |
$value = 'future'; |
$value = 'future'; |
} |
} |
} |
} |
} elsif ($item eq 'printenddate') { |
} elsif ($item eq 'printenddate') { |
if ($value =~ /^\d+$/) { |
if ($value =~ /^\d+$/) { |
if ($value < $now) { |
if ($value < $now) { |
$value = 'past'; |
$value = 'past'; |
} |
} |
} |
} |
|
} |
} |
if (grep(/^\Q$value\E$/,@{$Apache::lonrelrequtils::checkparms{$item}})) { |
my ($middle,$scope,$which,$level,$map,$resource); |
my $stdtype = &Apache::lonparmset::standard_parameter_types($item); |
if (grep(/^\Q$value\E$/,@{$Apache::lonrelrequtils::checkparms{$item}})) { |
$found{$item}{'valname'} = &get_param_description($stdtype,$value); |
my $stdtype = &Apache::lonparmset::standard_parameter_types($item); |
$found{$item}{'rev'} = $Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value.'::'}; |
my $stdname = &Apache::lonparmset::standard_parameter_names($item); |
} |
my $valname = &get_param_description($stdtype,$value); |
} |
my $rev = $Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value}; |
} |
my $start = $cid.'.'; |
} |
if ($key =~ /^\Q$start\E(\[useropt\:($match_username\:$match_domain)\]\.)/) { |
foreach my $item (keys(%Apache::lonrelrequtils::checkparmvalsmatch)) { |
$middle = $1; |
if (ref($Apache::lonrelrequtils::checkparmvalsmatch{$item}) eq 'ARRAY') { |
$which = $2; |
my $value = $resourcedata->{$key}; |
$scope = 'user'; |
foreach my $valuematch (@{$Apache::lonrelrequtils::checkparmvalsmatch{$item}}) { |
} elsif ($key =~ /^\Q$start\E(\[(\w+)\]\.)/) { |
if ($value =~ /$valuematch/) { |
$middle = $1; |
my $stdtype = &Apache::lonparmset::standard_parameter_types($item); |
$which = $2; |
$found{$item}{'valname'} = &get_param_description($stdtype,$value,1); |
$scope = 'section/group'; |
$found{$item}{'rev'} = |
} else { |
$Apache::lonnet::needsrelease{'parameter:'.$item.'::'.$valuematch.':'}; |
$scope = 'all'; |
last; |
} |
} |
my $what="$stdname=$valname"; |
} |
if ($key =~ /^\Q$start$middle\E\w+\.\Q$item\E$/) { |
} |
$level = 'general'; |
} |
if ($scope eq 'all') { |
foreach my $item (keys(%Apache::lonrelrequtils::checkparmnamesmatch)) { |
if (ref($fromparam{$rev}{$scope}) eq 'ARRAY') { |
my $regexp; |
unless(grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}})) { |
if ($item eq 'maplevelrecurse') { |
push(@{$fromparam{$rev}{$scope}},$what); |
$regexp = '\.(?:sequence|page)___\(rec\)\.'; |
} |
} |
} else { |
if ($regexp ne '') { |
push(@{$fromparam{$rev}{$scope}},$what); |
if ($key =~ /$regexp.*\.(\w+)$/) { |
} |
my $name = $1; |
} else { |
my $value = $resourcedata->{$key}; |
if (ref($fromparam{$rev}{$scope}{$which}) eq 'ARRAY') { |
if ($name eq 'type') { |
unless (grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}{$which}})) { |
last unless (($value eq 'problem') || ($value eq 'practice') || ($value eq 'exam') || |
push(@{$fromparam{$rev}{$scope}{$which}},$what); |
($value eq 'survey') || ($value eq 'surveycred') || ($value eq 'anonsurvey') || |
} |
($value eq 'anonsurveycred') || ($value eq 'randomizetry') || ($value eq 'library')); |
} else { |
} |
push(@{$fromparam{$rev}{$scope}{$which}},$what); |
my $stdtype = &Apache::lonparmset::standard_parameter_types($name); |
} |
$found{$name}{'valname'} = &get_param_description($stdtype,$value); |
} |
$found{$name}{'extra'} = &mt('Recursive into sub-folders'); |
$rowspan{$rev} ++; |
$found{$name}{'rev'} = |
} elsif ($key =~ /^\Q$start$middle\E(.+)___\(all\).\w+\.\Q$item\E$/) { |
$Apache::lonnet::needsrelease{'parameter::::'.$item}; |
$level = 'folder'; |
} |
$map = $1; |
} |
if ($scope eq 'all') { |
} |
if (ref($bymap{$map}{$rev}{$scope}) eq 'ARRAY') { |
foreach my $item (keys(%found)) { |
unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}})) { |
my $stdname = &Apache::lonparmset::standard_parameter_names($item); |
push(@{$bymap{$map}{$rev}{$scope}},$what); |
my $rev = $found{$item}{'rev'}; |
} |
my $valname = $found{$item}{'valname'}; |
} else { |
my $extra = $found{$item}{'extra'}; |
push(@{$bymap{$map}{$rev}{$scope}},$what); |
my ($middle,$scope,$which,$level,$map,$resource); |
} |
my $start = $cid.'.'; |
} else { |
if ($key =~ /^\Q$start\E(\[useropt\:($match_username\:$match_domain)\]\.)/) { |
if (ref($bymap{$map}{$rev}{$scope}{$which}) eq 'ARRAY') { |
$middle = $1; |
unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}{$which}})) { |
$which = $2; |
push(@{$bymap{$map}{$rev}{$scope}{$which}},$what); |
$scope = 'user'; |
} |
} elsif ($key =~ /^\Q$start\E(\[(\w+)\]\.)/) { |
} else { |
$middle = $1; |
push(@{$bymap{$map}{$rev}{$scope}{$which}},$what); |
$which = $2; |
} |
$scope = 'section/group'; |
} |
} else { |
} elsif ($key =~ /^\Q$start$middle\E(.+)\.\w+\.\Q$item\E$/) { |
$scope = 'all'; |
$level = 'resource'; |
} |
$resource = $1; |
my $what="$stdname=$valname"; |
if ($scope eq 'all') { |
if ($extra) { |
if (ref($byresource{$resource}{$rev}{$scope}) eq 'ARRAY') { |
$what .= "<br/>$extra<br />"; |
unless(grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}})) { |
} |
push(@{$byresource{$resource}{$rev}{$scope}},$what); |
if ($key =~ /^\Q$start$middle\E\w+\.\Q$item\E$/) { |
} |
$level = 'general'; |
} else { |
if ($scope eq 'all') { |
push(@{$byresource{$resource}{$rev}{$scope}},$what); |
if (ref($fromparam{$rev}{$scope}) eq 'ARRAY') { |
} |
unless(grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}})) { |
} else { |
push(@{$fromparam{$rev}{$scope}},$what); |
if (ref($byresource{$resource}{$rev}{$scope}{$which}) eq 'ARRAY') { |
} |
unless (grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}{$which}})) { |
} else { |
push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what); |
push(@{$fromparam{$rev}{$scope}},$what); |
} |
} |
} else { |
} else { |
push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what); |
if (ref($fromparam{$rev}{$scope}{$which}) eq 'ARRAY') { |
} |
unless (grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}{$which}})) { |
} |
push(@{$fromparam{$rev}{$scope}{$which}},$what); |
} |
} |
|
} else { |
|
push(@{$fromparam{$rev}{$scope}{$which}},$what); |
|
} |
|
} |
|
$rowspan{$rev} ++; |
|
} elsif ($key =~ /^\Q$start$middle\E(.+)___\((all|rec)\).\w+\.\Q$item\E$/) { |
|
$level = 'folder'; |
|
$map = $1; |
|
if ($scope eq 'all') { |
|
if (ref($bymap{$map}{$rev}{$scope}) eq 'ARRAY') { |
|
unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}})) { |
|
push(@{$bymap{$map}{$rev}{$scope}},$what); |
|
} |
|
} else { |
|
push(@{$bymap{$map}{$rev}{$scope}},$what); |
|
} |
|
} else { |
|
if (ref($bymap{$map}{$rev}{$scope}{$which}) eq 'ARRAY') { |
|
unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}{$which}})) { |
|
push(@{$bymap{$map}{$rev}{$scope}{$which}},$what); |
|
} |
|
} else { |
|
push(@{$bymap{$map}{$rev}{$scope}{$which}},$what); |
|
} |
|
} |
|
} elsif ($key =~ /^\Q$start$middle\E(.+)\.\w+\.\Q$item\E$/) { |
|
$level = 'resource'; |
|
$resource = $1; |
|
if ($scope eq 'all') { |
|
if (ref($byresource{$resource}{$rev}{$scope}) eq 'ARRAY') { |
|
unless(grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}})) { |
|
push(@{$byresource{$resource}{$rev}{$scope}},$what); |
|
} |
|
} else { |
|
push(@{$byresource{$resource}{$rev}{$scope}},$what); |
|
} |
|
} else { |
|
if (ref($byresource{$resource}{$rev}{$scope}{$which}) eq 'ARRAY') { |
|
unless (grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}{$which}})) { |
|
push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what); |
|
} |
|
} else { |
|
push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what); |
} |
} |
} |
} |
} |
} |
Line 3430 sub display_loncaparev_constraints {
|
Line 3698 sub display_loncaparev_constraints {
|
if (ref($fromblocks{$type}) eq 'HASH') { |
if (ref($fromblocks{$type}) eq 'HASH') { |
foreach my $rev (keys(%{$fromblocks{$type}})) { |
foreach my $rev (keys(%{$fromblocks{$type}})) { |
my ($major,$minor) = split(/\./,$rev); |
my ($major,$minor) = split(/\./,$rev); |
($reqdmajor,$reqdminor) = |
($reqdmajor,$reqdminor) = |
&Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor); |
&Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor); |
$output .= &Apache::loncommon::start_data_table_row(). |
$output .= &Apache::loncommon::start_data_table_row(). |
'<td>'.$rev.'</td><td>'.$lt{$type}.'</td><td>'; |
'<td>'.$rev.'</td><td>'.$lt{$type}.'</td><td>'; |
Line 3448 sub display_loncaparev_constraints {
|
Line 3716 sub display_loncaparev_constraints {
|
|
|
if (defined($navmap)) { |
if (defined($navmap)) { |
my %anonsubms=&Apache::lonnet::dump('nohist_anonsurveys',$cdom,$cnum); |
my %anonsubms=&Apache::lonnet::dump('nohist_anonsurveys',$cdom,$cnum); |
my $rev_anonsurv=$Apache::lonnet::needsrelease{'parameter:type:anonsurvey'}; |
my $rev_anonsurv=$Apache::lonnet::needsrelease{'parameter:type:anonsurvey::'}; |
my %randtrysubms=&Apache::lonnet::dump('nohist_randomizetry',$cdom,$cnum); |
my %randtrysubms=&Apache::lonnet::dump('nohist_randomizetry',$cdom,$cnum); |
my $rev_randtry=$Apache::lonnet::needsrelease{'parameter:type:randomizetry'}; |
my $rev_randtry=$Apache::lonnet::needsrelease{'parameter:type:randomizetry::'}; |
|
my $rev_exttool=$Apache::lonnet::needsrelease{'course:courserestype:exttool'}; |
my $stdtype=&Apache::lonparmset::standard_parameter_types('type'); |
my $stdtype=&Apache::lonparmset::standard_parameter_types('type'); |
my $stdname=&Apache::lonparmset::standard_parameter_names('type'); |
my $stdname=&Apache::lonparmset::standard_parameter_names('type'); |
my $valanon=&get_param_description($stdtype,'anonsurvey'); |
my $valanon=&get_param_description($stdtype,'anonsurvey'); |
my $valrandtry=&get_param_description($stdtype,'randomizetry'); |
my $valrandtry=&get_param_description($stdtype,'randomizetry'); |
my %checkedrev; |
my %checkedrev; |
foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_problem() },1,0)) { |
foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_problem() || $_[0]->is_tool() },1,0)) { |
my @parts = @{$res->parts()}; |
my @parts = @{$res->parts()}; |
my $symb = $res->symb(); |
my $symb = $res->symb(); |
my $enclosing_map = &Apache::lonnet::declutter($res->enclosing_map_src()); |
my $enclosing_map = &Apache::lonnet::declutter($res->enclosing_map_src()); |
|
if ($res->is_tool()) { |
|
my $rev = $rev_exttool; |
|
$bycrsrestype{$symb}{$rev} = &mt('External Tool'); |
|
$allmaps{$enclosing_map} = 1; |
|
next; |
|
} |
foreach my $part (@parts) { |
foreach my $part (@parts) { |
if (exists($anonsubms{$symb."\0".$part})) { |
if (exists($anonsubms{$symb."\0".$part})) { |
my $rev = $rev_anonsurv; |
my $rev = $rev_anonsurv; |
Line 3510 sub display_loncaparev_constraints {
|
Line 3785 sub display_loncaparev_constraints {
|
&Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor, |
&Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor, |
$reqdmajor,$reqdminor); |
$reqdmajor,$reqdminor); |
$checkedrev{$key} = 1; |
$checkedrev{$key} = 1; |
} |
} |
push(@{$byresponsetype{$symb}{$rev}},$key); |
push(@{$byresponsetype{$symb}{$rev}},$key); |
$allmaps{$enclosing_map} = 1; |
$allmaps{$enclosing_map} = 1; |
} |
} |
Line 3547 sub display_loncaparev_constraints {
|
Line 3822 sub display_loncaparev_constraints {
|
} |
} |
} |
} |
} |
} |
|
my $suppmap = 'supplemental.sequence'; |
|
my ($suppcount,$supptools,$errors) = (0,0,0); |
|
($suppcount,$supptools,$errors) = &Apache::loncommon::recurse_supplemental($cnum,$cdom, |
|
$suppmap,$suppcount,$supptools,$errors); |
my $mapres_header = '<h4>'. |
my $mapres_header = '<h4>'. |
&mt('Requirements for specific folders or resources'). |
&mt('Requirements for specific folders or resources'). |
'</h4>'; |
'</h4>'; |
Line 3561 sub display_loncaparev_constraints {
|
Line 3840 sub display_loncaparev_constraints {
|
$r->print($start_page.$top_header); |
$r->print($start_page.$top_header); |
if ($output) { |
if ($output) { |
$r->print($output); |
$r->print($output); |
if (defined($navmap)) { |
if (defined($navmap) || $supptools) { |
&show_contents_view($r,$navmap,$cid,\%toshow,\%bymap,\%byresource,\%bysubmission, |
&show_contents_view($r,$navmap,$cid,\%toshow,\%bymap,\%byresource,\%bysubmission, |
\%byresponsetype,\@scopeorder,\%lt); |
\%byresponsetype,\%bycrsrestype,\@scopeorder,\%lt,$supptools); |
} |
} |
$r->print('<br /><br />'); |
$r->print('<br /><br />'); |
} else { |
} else { |
Line 3581 sub display_loncaparev_constraints {
|
Line 3860 sub display_loncaparev_constraints {
|
|
|
sub show_contents_view { |
sub show_contents_view { |
my ($r,$navmap,$cid,$toshow,$bymap,$byresource,$bysubmission,$byresponsetype, |
my ($r,$navmap,$cid,$toshow,$bymap,$byresource,$bysubmission,$byresponsetype, |
$scopeorder,$lt) = @_; |
$bycrsrestype,$scopeorder,$lt,$supptools) = @_; |
if ((keys(%{$toshow}) > 0) || (keys(%{$byresource}) > 0) || |
my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons"); |
(keys(%{$bysubmission}) > 0) || (keys(%{$byresponsetype}) > 0)) { |
my $whitespace = '<img src="'.$location.'/whitespace_21.gif" alt="" />'; |
my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons"); |
my $showmaincontent; |
my $whitespace = '<img src="'.$location.'/whitespace_21.gif" alt="" />'; |
if ((ref($navmap)) && |
my $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />'; |
((keys(%{$toshow}) > 0) || (keys(%{$byresource}) > 0) || |
|
(keys(%{$bysubmission}) > 0) || (keys(%{$byresponsetype}) > 0) || |
|
(keys(%{$bycrsrestype}) > 0))) { |
|
$showmaincontent = 1; |
|
} |
|
if ($showmaincontent || $supptools) { |
|
$r->print(&Apache::loncommon::start_data_table()); |
|
} |
|
if ($showmaincontent) { |
|
my $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />'; |
my $topmap = $env{'course.'.$cid.'.url'}; |
my $topmap = $env{'course.'.$cid.'.url'}; |
$r->print(&Apache::loncommon::start_data_table(). |
$r->print(&Apache::loncommon::start_data_table_header_row(). |
&Apache::loncommon::start_data_table_header_row(). |
|
'<th>'.&mt('Location').'</th><th>'.&mt('Release').'</th>'. |
'<th>'.&mt('Location').'</th><th>'.&mt('Release').'</th>'. |
'<th>'.&mt('Attribute/Setting').'</th>'. |
'<th>'.&mt('Attribute/Setting').'</th>'. |
&Apache::loncommon::end_data_table_header_row(). |
&Apache::loncommon::end_data_table_header_row(). |
&Apache::loncommon::start_data_table_row(). |
&Apache::loncommon::start_data_table_row(). |
'<td> '.$icon.' '.&mt('Main Content').'</td>'); |
'<td> '.$icon.' '.&mt('Main Content').'</td>'); |
&releases_by_map($r,$bymap,$topmap,$scopeorder,$lt); |
&releases_by_map($r,$bymap,$topmap,$scopeorder,$lt); |
$r->print(&Apache::loncommon::end_data_table_row()); |
$r->print(&Apache::loncommon::end_data_table_row()); |
my $it=$navmap->getIterator(undef,undef,undef,1,1,undef); |
my $it=$navmap->getIterator(undef,undef,undef,1,1,undef); |
my $curRes; |
my $curRes; |
my $depth = 0; |
my $depth = 0; |
Line 3647 sub show_contents_view {
|
Line 3934 sub show_contents_view {
|
if (ref($byresponsetype->{$symb}) eq 'HASH') { |
if (ref($byresponsetype->{$symb}) eq 'HASH') { |
$rowspan += scalar(keys(%{$byresponsetype->{$symb}})); |
$rowspan += scalar(keys(%{$byresponsetype->{$symb}})); |
} |
} |
|
if (ref($bycrsrestype->{$symb}) eq 'HASH') { |
|
$rowspan += scalar(keys(%{$bycrsrestype->{$symb}})); |
|
} |
next if (!$rowspan); |
next if (!$rowspan); |
$icon = '<img class="LC_contentImage" src="'.$location.'/problem.gif" alt="'. |
$icon = '<img class="LC_contentImage" src="'.$location.'/problem.gif" alt="'. |
&mt('Problem').'" />'; |
&mt('Problem').'" />'; |
Line 3711 sub show_contents_view {
|
Line 4001 sub show_contents_view {
|
$r->print('</td>'); |
$r->print('</td>'); |
} |
} |
$r->print(&Apache::loncommon::end_data_table_row()); |
$r->print(&Apache::loncommon::end_data_table_row()); |
|
$newrow = 1; |
|
} |
|
if (ref($bycrsrestype->{$symb}) eq 'HASH') { |
|
foreach my $rev (sort(keys(%{$bycrsrestype->{$symb}}))) { |
|
if ($newrow) { |
|
$r->print(&Apache::loncommon::continue_data_table_row()); |
|
} |
|
$r->print('<td>'.$rev.'</td><td>'.$bycrsrestype->{$symb}{$rev}.'</td>'); |
|
} |
|
$r->print(&Apache::loncommon::end_data_table_row()); |
} |
} |
} |
} |
} |
} |
} |
} |
|
} |
|
if ($supptools) { |
|
my $icon = '<img src="'.$location.'/navmap.folder.open.gif" alt="" />'; |
|
$r->print(&Apache::loncommon::start_data_table_header_row(). |
|
'<th>'.&mt('Location').'</th><th>'.&mt('Release').'</th>'. |
|
'<th>'.&mt('Resource Type').'</th>'. |
|
&Apache::loncommon::end_data_table_header_row(). |
|
&Apache::loncommon::start_data_table_row(). |
|
'<td> '.$icon.' '.&mt('Supplemental Content').'</td>'. |
|
'<td valign="middle">'. |
|
$Apache::lonrelrequtils::exttool{'major'}.'.'. |
|
$Apache::lonrelrequtils::exttool{'minor'}. |
|
'</td><td>'.&mt('[quant,_1,External Tool,External Tools]', |
|
$supptools).'</td>'. |
|
&Apache::loncommon::end_data_table_row()); |
|
} |
|
if ($showmaincontent || $supptools) { |
$r->print(&Apache::loncommon::end_data_table()); |
$r->print(&Apache::loncommon::end_data_table()); |
} |
} |
return; |
return; |
Line 3723 sub show_contents_view {
|
Line 4040 sub show_contents_view {
|
sub releases_by_map { |
sub releases_by_map { |
my ($r,$bymap,$url,$scopeorder,$lt) = @_; |
my ($r,$bymap,$url,$scopeorder,$lt) = @_; |
return unless ((ref($bymap) eq 'HASH') && (ref($scopeorder) eq 'ARRAY')); |
return unless ((ref($bymap) eq 'HASH') && (ref($scopeorder) eq 'ARRAY')); |
my $newrow = 0; |
my $newrow = 0; |
if (ref($bymap->{$url}) eq 'HASH') { |
if (ref($bymap->{$url}) eq 'HASH') { |
foreach my $rev (sort(keys(%{$bymap->{$url}}))) { |
foreach my $rev (sort(keys(%{$bymap->{$url}}))) { |
if ($newrow) { |
if ($newrow) { |
Line 3760 sub releases_by_map {
|
Line 4077 sub releases_by_map {
|
} |
} |
|
|
sub get_param_description { |
sub get_param_description { |
my ($stdtype,$value) = @_; |
my ($stdtype,$value,$regexp) = @_; |
my $name = $value; |
my ($name,$parammatches,$paramstrings,@possibles); |
my $paramstrings = &Apache::lonparmset::standard_string_options($stdtype); |
if ($stdtype =~ /^string/) { |
unless (ref($paramstrings) eq 'ARRAY') { |
$paramstrings = &Apache::lonparmset::standard_string_options($stdtype); |
return $name; |
} elsif ($stdtype eq 'date_interval') { |
|
$paramstrings = &Apache::lonparmset::standard_interval_options($stdtype); |
|
} |
|
if ($regexp) { |
|
if ($stdtype =~ /^string/) { |
|
$parammatches = &Apache::lonparmset::standard_string_matches($stdtype); |
|
} elsif ($stdtype eq 'date_interval') { |
|
$parammatches = &Apache::lonparmset::standard_interval_matches($stdtype); |
|
} |
|
if (ref($parammatches) eq 'ARRAY') { |
|
@possibles = @{$parammatches}; |
|
} else { |
|
undef($regexp); |
|
$name = $value; |
|
} |
|
} |
|
unless ($regexp) { |
|
$name = $value; |
|
if (ref($paramstrings) eq 'ARRAY') { |
|
@possibles = @{$paramstrings}; |
|
} else { |
|
if (($stdtype eq 'date_start') || ($stdtype eq 'date_end')) { |
|
if ($name == 0) { |
|
$name = &mt('Never'); |
|
} elsif (($name ne '') && ($name !~ /\D/)) { |
|
$name = &Apache::lonlocal::locallocaltime($name); |
|
} |
|
} |
|
return $name; |
|
} |
} |
} |
foreach my $possibilities (@{$paramstrings}) { |
foreach my $possibilities (@possibles) { |
next unless (ref($possibilities) eq 'ARRAY'); |
next unless (ref($possibilities) eq 'ARRAY'); |
my ($thing, $description) = @{ $possibilities }; |
my $gotregexmatch = ''; |
if ($thing eq $value) { |
if ($regexp) { |
$name = $description; |
last if ($gotregexmatch); |
last; |
my ($item,$pattern) = @{ $possibilities }; |
|
if ($value =~ /$pattern/) { |
|
if (ref($paramstrings) eq 'ARRAY') { |
|
foreach my $possibles (@{$paramstrings}) { |
|
next unless (ref($possibles) eq 'ARRAY'); |
|
my ($thing,$description) = @{$possibles}; |
|
if ($thing eq $item) { |
|
$name = $description; |
|
$gotregexmatch = 1; |
|
last; |
|
} |
|
} |
|
last if ($gotregexmatch); |
|
} |
|
} |
|
} else { |
|
my ($thing,$description) = @{ $possibilities }; |
|
if ($thing eq $value) { |
|
$name = $description; |
|
last; |
|
} |
} |
} |
} |
} |
return $name; |
return $name; |
Line 3981 sub print_localization {
|
Line 4347 sub print_localization {
|
undef,$includeempty,$disabled); |
undef,$includeempty,$disabled); |
} else { |
} else { |
if ($settings->{$item} eq '') { |
if ($settings->{$item} eq '') { |
unless ($noedit) { |
unless ($noedit) { |
$datatable .= '</td><td align="right">'. |
$datatable .= '</td><td align="right">'. |
&Apache::loncommon::select_language('languages_0','',1); |
&Apache::loncommon::select_language('languages_0','',1); |
} |
} |
Line 4011 sub print_localization {
|
Line 4377 sub print_localization {
|
} |
} |
} |
} |
unless ($noedit) { |
unless ($noedit) { |
$datatable .= |
$datatable .= |
&Apache::loncommon::start_data_table_row(). |
&Apache::loncommon::start_data_table_row(). |
'<td align="left"><span class="LC_nobreak">'. |
'<td align="left"><span class="LC_nobreak">'. |
&mt('Additional language:'). '</span><br />'. |
&mt('Additional language:'). '</span><br />'. |
&Apache::loncommon::select_language('languages_'.$num,'',1). |
&Apache::loncommon::select_language('languages_'.$num,'',1). |
'<input type="hidden" name="languages_total" value="'.$num.'" />'. |
'<input type="hidden" name="languages_total" value="'.$num.'" />'. |
'</td>'.&Apache::loncommon::end_data_table_row(); |
'</td>'.&Apache::loncommon::end_data_table_row(); |
} |
} |
$datatable .= &Apache::loncommon::end_data_table().'<br />'; |
$datatable .= &Apache::loncommon::end_data_table().'<br />'; |
} |
} |
} |
} |
$datatable .= &item_table_row_end(); |
$datatable .= &item_table_row_end(); |
Line 4107 sub user_table {
|
Line 4473 sub user_table {
|
if ($currvalue eq '') { |
if ($currvalue eq '') { |
unless ($noedit) { |
unless ($noedit) { |
$output .= &select_recipient($item,'0',$cdom,$sections); |
$output .= &select_recipient($item,'0',$cdom,$sections); |
} |
} |
} else { |
} else { |
my $num = 0; |
my $num = 0; |
my @curr = split(/,/,$currvalue); |
my @curr = split(/,/,$currvalue); |
Line 4259 sub print_discussion {
|
Line 4625 sub print_discussion {
|
&mt('(specific user(s))'), |
&mt('(specific user(s))'), |
input => 'checkbox', |
input => 'checkbox', |
}, |
}, |
|
|
|
'pac.roles.denied' => { |
|
text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pac.roles.denied'}).'</b>'. |
|
&Apache::loncommon::help_open_topic("Course_Disable_Anonymous_Discussion").'</span><br />'. |
|
&mt('(role-based)'), |
|
input => 'checkbox', |
|
}, |
|
|
|
'pac.users.denied' => { |
|
text => '<span class="LC_nobreak"><b>'.&mt($itemtext->{'pac.users.denied'}).'</b><br />'. |
|
&mt('(specific user(s))'), |
|
input => 'checkbox', |
|
}, |
|
|
'allow_limited_html_in_feedback' => { |
'allow_limited_html_in_feedback' => { |
text => '<b>'.&mt($itemtext->{'allow_limited_html_in_feedback'}).'</b>', |
text => '<b>'.&mt($itemtext->{'allow_limited_html_in_feedback'}).'</b>', |
input => 'radio', |
input => 'radio', |
Line 4291 sub print_discussion {
|
Line 4671 sub print_discussion {
|
my $colspan; |
my $colspan; |
if ($item eq 'allow_limited_html_in_feedback') { |
if ($item eq 'allow_limited_html_in_feedback') { |
$colspan = 2; |
$colspan = 2; |
} |
} |
$datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan); |
$datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan); |
if ($item eq 'plc.roles.denied') { |
if ($item eq 'plc.roles.denied') { |
$datatable .= '</td><td align="right">'. |
$datatable .= '</td><td align="right">'. |
Line 4309 sub print_discussion {
|
Line 4689 sub print_discussion {
|
$datatable .= '</td><td align="right">'. |
$datatable .= '</td><td align="right">'. |
&user_table($cdom,$item,undef, |
&user_table($cdom,$item,undef, |
$settings->{$item},\%lt,$noedit); |
$settings->{$item},\%lt,$noedit); |
|
} elsif ($item eq 'pac.roles.denied') { |
|
$datatable .= '</td><td align="right">'. |
|
'<table>'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit). |
|
'</table>'; |
|
} elsif ($item eq 'pac.users.denied') { |
|
$datatable .= '</td><td align="right">'. |
|
&user_table($cdom,$item,undef, |
|
$settings->{$item},\%lt,$noedit); |
} elsif ($item eq 'allow_limited_html_in_feedback') { |
} elsif ($item eq 'allow_limited_html_in_feedback') { |
$datatable .= &yesno_radio($item,$settings,undef,undef,undef,$noedit); |
$datatable .= &yesno_radio($item,$settings,undef,undef,undef,$noedit); |
} elsif ($item eq 'allow_discussion_post_editing') { |
} elsif ($item eq 'allow_discussion_post_editing') { |
Line 4328 sub print_discussion {
|
Line 4716 sub print_discussion {
|
'<th align="center">'.&mt('font-size').'</th>'. |
'<th align="center">'.&mt('font-size').'</th>'. |
'<th align="center">'.&mt('font-weight').'</th>'. |
'<th align="center">'.&mt('font-weight').'</th>'. |
'<th align="center">'.&mt('font-style').'</th>'. |
'<th align="center">'.&mt('font-style').'</th>'. |
'<th align="center">'.&mt('Other css').'</th>'. |
'<th align="center">'.&mt('Other css').'</th>'. |
&Apache::loncommon::end_data_table_row(). |
&Apache::loncommon::end_data_table_row(). |
&set_discussion_fonts($cdom,$cnum,$item,$settings,$noedit). |
&set_discussion_fonts($cdom,$cnum,$item,$settings,$noedit). |
&Apache::loncommon::end_data_table().'<br />'; |
&Apache::loncommon::end_data_table().'<br />'; |
Line 4380 sub role_checkboxes {
|
Line 4768 sub role_checkboxes {
|
my $count = 0; |
my $count = 0; |
my $disabled; |
my $disabled; |
if ($noedit) { |
if ($noedit) { |
$disabled = ' disabled="disabled"'; |
$disabled = ' disabled="disabled"'; |
} |
} |
foreach my $role (@roles) { |
foreach my $role (@roles) { |
my $checked = ''; |
my $checked = ''; |
Line 4508 sub set_discussion_fonts {
|
Line 4896 sub set_discussion_fonts {
|
|
|
sub discussion_vote_classes { |
sub discussion_vote_classes { |
my $classorder = ['twoplus','oneplus','zero','oneminus','twominus']; |
my $classorder = ['twoplus','oneplus','zero','oneminus','twominus']; |
my %classtitles = &Apache::lonlocal::texthash( |
my %classtitles = &Apache::lonlocal::texthash( |
'twoplus' => 'Two sigma above mean', |
'twoplus' => 'Two sigma above mean', |
'oneplus' => 'One sigma above mean', |
'oneplus' => 'One sigma above mean', |
'zero' => 'Within one sigma of mean', |
'zero' => 'Within one sigma of mean', |
Line 4574 sub print_classlists {
|
Line 4962 sub print_classlists {
|
'defaultcredits' => { |
'defaultcredits' => { |
text => '<b>'.&mt($itemtext->{'defaultcredits'}).'</b>', |
text => '<b>'.&mt($itemtext->{'defaultcredits'}).'</b>', |
}, |
}, |
|
|
'nothideprivileged' => { |
'nothideprivileged' => { |
text => '<b>'.&mt($itemtext->{'nothideprivileged'}).'</b>', |
text => '<b>'.&mt($itemtext->{'nothideprivileged'}).'</b>', |
input => 'checkbox', |
input => 'checkbox', |
Line 4681 sub print_grading {
|
Line 5069 sub print_grading {
|
input => 'selectbox', |
input => 'selectbox', |
options => { |
options => { |
standard => &mt('Standard: shows points'), |
standard => &mt('Standard: shows points'), |
|
categories => &mt('Categories: shows points according to categories'), |
external => &mt('External: shows number of completed parts and totals'), |
external => &mt('External: shows number of completed parts and totals'), |
externalnototals => &mt('External: shows only number of completed parts'), |
externalnototals => &mt('External: shows only number of completed parts'), |
spreadsheet => &mt('Spreadsheet: (with link to detailed scores)'), |
spreadsheet => &mt('Spreadsheet: (with link to detailed scores)'), |
}, |
}, |
order => ['standard','external','externalnototals','spreadsheet'], |
order => ['standard','categories','external','externalnototals','spreadsheet'], |
}, |
}, |
'rndseed' => { |
'rndseed' => { |
text => '<b>'.&mt($itemtext->{'rndseed'}).'</b>'. |
text => '<b>'.&mt($itemtext->{'rndseed'}).'</b>'. |
Line 4855 sub print_bridgetasks {
|
Line 5244 sub print_bridgetasks {
|
return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'bridgetasks',$noedit); |
return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'bridgetasks',$noedit); |
} |
} |
|
|
|
sub print_lti { |
|
my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_; |
|
unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) { |
|
return; |
|
} |
|
my @menuitems = ('fullname','coursetitle','role','logout','grades'); |
|
my %menutitles = <imenu_titles(); |
|
my ($domdefs,$displaydefs); |
|
if ($env{'request.lti.login'}) { |
|
my %lti = &Apache::lonnet::get_domain_lti($cdom,'provider'); |
|
my @domdefsmenu; |
|
if (ref($lti{$env{'request.lti.login'}}) eq 'HASH') { |
|
if ($lti{$env{'request.lti.login'}}{'topmenu'}) { |
|
$domdefs = &mt('Header shown').', '; |
|
} |
|
if ($lti{$env{'request.lti.login'}}{'inlinemenu'}) { |
|
$domdefs .= &mt('Inline menu shown'); |
|
} |
|
$domdefs =~ s/,\s$//; |
|
if (!$domdefs) { |
|
$domdefs = &mt('No header or inline menu shown'); |
|
} |
|
$domdefs = ' ('.&mt('Domain default').': '.$domdefs.')'; |
|
if (ref($lti{$env{'request.lti.login'}}{'lcmenu'}) eq 'ARRAY') { |
|
@domdefsmenu = @{$lti{$env{'request.lti.login'}}{'lcmenu'}}; |
|
} |
|
} |
|
$displaydefs = &mt('Domain defaults'); |
|
if (@domdefsmenu) { |
|
my @diffs = &Apache::loncommon::compare_arrays(\@menuitems,\@domdefsmenu); |
|
if (@diffs) { |
|
my $missing; |
|
foreach my $item (@menuitems) { |
|
unless (grep(/^\Q$item\E$/,@domdefsmenu)) { |
|
$missing .= ' '.$menutitles{$item}.','; |
|
} |
|
} |
|
$missing =~ s/,$//; |
|
$displaydefs .= ': '.&mt('Not shown').' --'.$missing; |
|
} else { |
|
$displaydefs .= ': '.&mt('All shown'); |
|
} |
|
} else { |
|
$displaydefs .= ': '.&mt('Not shown').' -- '.join(', ', map { $menutitles{$_}; } @menuitems); |
|
} |
|
} else { |
|
$displaydefs = &mt('Domain defaults only available in LTI context'); |
|
} |
|
my %items = ( |
|
'lti.override' => { |
|
text => '<b>'.&mt($itemtext->{'lti.override'}).'</b>'.$domdefs, |
|
input => 'radio', |
|
}, |
|
'lti.topmenu' => { |
|
text => '<b>'.&mt($itemtext->{'lti.topmenu'}).'</b>', |
|
input => 'radio', |
|
}, |
|
'lti.inlinemenu' => { |
|
text => '<b>'.&mt($itemtext->{'lti.inlinemenu'}).'</b>', |
|
input => 'radio', |
|
}, |
|
'lti.lcmenu' => { |
|
text => '<b>'.&mt($itemtext->{'lti.lcmenu'}).'</b><br />'.$displaydefs, |
|
input => 'custom', |
|
}, |
|
); |
|
return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'lti',$noedit); |
|
} |
|
|
|
sub lcmenu_checkboxes { |
|
my ($cdom,$caller,$settings,$crstype,$noedit) = @_; |
|
my @menuitems = ('fullname','coursetitle','role','logout','grades'); |
|
my %menutitles = <imenu_titles(); |
|
my (@current,@domdefs); |
|
if ($env{'request.lti.login'}) { |
|
my %lti = &Apache::lonnet::get_domain_lti($cdom,'provider'); |
|
if (ref($lti{$env{'request.lti.login'}}) eq 'HASH') { |
|
if (ref($lti{$env{'request.lti.login'}}{'lcmenu'}) eq 'ARRAY') { |
|
@domdefs = @{$lti{$env{'request.lti.login'}}{'lcmenu'}}; |
|
} |
|
} |
|
} |
|
if (ref($settings) eq 'HASH') { |
|
if ($settings->{'lti.lcmenu'}) { |
|
unless ($settings->{'lti.lcmenu'} eq 'none') { |
|
@current = split(',',$settings->{'lti.lcmenu'}); |
|
} |
|
} else { |
|
@current = @domdefs; |
|
} |
|
} else { |
|
@current = @domdefs; |
|
} |
|
my $numinrow = 3; |
|
my $count = 0; |
|
my $disabled; |
|
if ($noedit) { |
|
$disabled = ' disabled="disabled"'; |
|
} |
|
my $output = '<table>'; |
|
foreach my $item (@menuitems) { |
|
my $checked = ''; |
|
if (grep(/^\Q$item\E$/,@current)) { |
|
$checked = ' checked="checked" '; |
|
} |
|
my $rem = $count%($numinrow); |
|
if ($rem == 0) { |
|
if ($count > 0) { |
|
$output .= '</tr>'; |
|
} |
|
$output .= '<tr>'; |
|
} |
|
$output .= '<td align="left"><span class="LC_nobreak"><label><input type="checkbox" '. |
|
'name="lti.lcmenu" value="'.$item.'"'.$checked.$disabled.'/> '. |
|
$menutitles{$item}.'</label></span></td>'; |
|
$count ++; |
|
} |
|
my $rem = $count%($numinrow); |
|
my $colsleft = $numinrow - $rem; |
|
if ($colsleft > 1 ) { |
|
$output .= '<td colspan="'.$colsleft.'" class="LC_left_item">'. |
|
' </td>'; |
|
} elsif ($colsleft == 1) { |
|
$output .= '<td class="LC_left_item"> </td>'; |
|
} |
|
$output .= '</tr></table>'; |
|
} |
|
|
sub ltimenu_titles { |
sub ltimenu_titles { |
return &Apache::lonlocal::texthash( |
return &Apache::lonlocal::texthash( |
fullname => 'Full name', |
fullname => 'Full name', |
Line 5004 sub menuitems_categories {
|
Line 5521 sub menuitems_categories {
|
my %categories = ( |
my %categories = ( |
shown => ['top','inline','foot','main'], |
shown => ['top','inline','foot','main'], |
text => ['name','role','crs','disc','fdbk'], |
text => ['name','role','crs','disc','fdbk'], |
links => ['pers','logo','comm','roles','help','logout'], |
links => ['pers','logo','menu','comm','roles','help','logout'], |
list => ['about','prefs','port','wish','anno','rss'], |
list => ['about','prefs','port','wish','anno','rss'], |
inline => ['cont','grades','chat','people','groups','resv','syll','feeds'], |
inline => ['cont','grades','chat','people','groups','resv','syll','feeds'], |
); |
); |
Line 5029 sub menuitems_fields {
|
Line 5546 sub menuitems_fields {
|
main => 'Access to main menu', |
main => 'Access to main menu', |
pers => 'Personal', |
pers => 'Personal', |
logo => 'LON-CAPA', |
logo => 'LON-CAPA', |
|
menu => 'Home', |
comm => 'Messages', |
comm => 'Messages', |
roles => 'Roles/Courses', |
roles => 'Roles/Courses', |
help => 'Help', |
help => 'Help', |
Line 5099 sub menucollections_display {
|
Line 5617 sub menucollections_display {
|
'<legend>'.$menutitles{$category}.'</legend>'."\n"; |
'<legend>'.$menutitles{$category}.'</legend>'."\n"; |
if ($category eq 'text') { |
if ($category eq 'text') { |
$output .= '<b>'.&mt('Header Text').'</b><br /><br />'; |
$output .= '<b>'.&mt('Header Text').'</b><br /><br />'; |
} |
} |
foreach my $field (@{$categories{$category}}) { |
foreach my $field (@{$categories{$category}}) { |
if ($field eq 'disc') { |
if ($field eq 'disc') { |
$output .= '<br /><b>'.&mt('Footer Text').'</b><br /><br />'; |
$output .= '<br /><b>'.&mt('Footer Text').'</b><br /><br />'; |
Line 5122 sub menucollections_display {
|
Line 5640 sub menucollections_display {
|
} |
} |
|
|
sub print_linkprotection { |
sub print_linkprotection { |
my ($cdom,$cnum,$settings,$rowtotal,$crstype,$noedit) = @_; |
my ($cdom,$cnum,$settings,$rowtotal,$crstype,$noedit,$context) = @_; |
unless (ref($settings) eq 'HASH') { |
|
return; |
|
} |
|
|
|
my %linkprotection; |
my %linkprotection; |
my $count = 0; |
my $count = 0; |
my $next = 1; |
my $next = 1; |
my ($datatable,$disabled,$css_class); |
my ($datatable,$disabled,$css_class,$dest); |
if ($noedit) { |
if ($noedit) { |
$disabled = ' disabled="disabled"'; |
$disabled = ' disabled="disabled"'; |
} |
} |
Line 5142 sub print_linkprotection {
|
Line 5657 sub print_linkprotection {
|
my $itemcount = 0; |
my $itemcount = 0; |
|
|
my $ltiauth; |
my $ltiauth; |
if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) { |
if ($context eq 'domain') { |
$ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'}; |
$ltiauth = 1; |
|
} else { |
|
if (exists($env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'})) { |
|
$ltiauth = $env{'course.'.$env{'request.course.id'}.'.internal.ltiauth'}; |
|
} else { |
|
my %domdefs = &Apache::lonnet::get_domain_defaults($cdom); |
|
$ltiauth = $domdefs{'crsltiauth'}; |
|
} |
|
} |
|
if ($context eq 'domain') { |
|
$dest = '/adm/domainprefs'; |
} else { |
} else { |
my %domdefs = &Apache::lonnet::get_domain_defaults($cdom); |
$dest = '/adm/courseprefs'; |
$ltiauth = $domdefs{'crsltiauth'}; |
} |
|
|
|
my ($switchserver,$switchmessage); |
|
$switchserver = &check_switchserver($cdom,$cnum,$context,$dest); |
|
if ($switchserver) { |
|
if ($context eq 'domain') { |
|
$switchmessage = &mt("submit from domain's primary library server: [_1].",$switchserver); |
|
} elsif ($crstype eq 'Community') { |
|
$switchmessage = &mt("submit from community's home server: [_1].",$switchserver); |
|
} else { |
|
$switchmessage = &mt("submit from course's home server: [_1].",$switchserver); |
|
} |
} |
} |
my $switchserver = &check_switchserver($cdom,$cnum); |
|
|
|
if (ref($settings->{'linkprotection'}) eq 'HASH') { |
if ((ref($settings) eq 'HASH') && (ref($settings->{'linkprot'}) eq 'HASH')) { |
if (keys(%{$settings->{'linkprotection'}})) { |
if (keys(%{$settings->{'linkprot'}})) { |
my @current = sort { $a <=> $b } keys(%{$settings->{'linkprotection'}}); |
my @current = sort { $a <=> $b } keys(%{$settings->{'linkprot'}}); |
$next += $current[-1]; |
$next += $current[-1]; |
for (my $i=0; $i<@current; $i++) { |
for (my $i=0; $i<@current; $i++) { |
my $num = $current[$i]; |
my $num = $current[$i]; |
my %values; |
my %values; |
if (ref($settings->{'linkprotection'}->{$num}) eq 'HASH') { |
if (ref($settings->{'linkprot'}->{$num}) eq 'HASH') { |
%values = %{$settings->{'linkprotection'}->{$num}}; |
%values = %{$settings->{'linkprot'}->{$num}}; |
} else { |
} else { |
next; |
next; |
} |
} |
Line 5174 sub print_linkprotection {
|
Line 5709 sub print_linkprotection {
|
my ($usersty,$onclickrequser,%checkedrequser); |
my ($usersty,$onclickrequser,%checkedrequser); |
if ($ltiauth) { |
if ($ltiauth) { |
$usersty = 'display:none'; |
$usersty = 'display:none'; |
$onclickrequser = ' onclick="toggleLTIReqUser(this.form,'."'requser','optional','1','block','$i'".');"'; |
$onclickrequser = ' onclick="toggleLinkProtReqUser(this.form,'."'requser','optional','1','block','$i'".');"'; |
%checkedrequser = ( |
%checkedrequser = ( |
no => ' checked="checked"', |
no => ' checked="checked"', |
yes => '', |
yes => '', |
Line 5184 sub print_linkprotection {
|
Line 5719 sub print_linkprotection {
|
$checkedrequser{'no'} = ''; |
$checkedrequser{'no'} = ''; |
} |
} |
$datatable .= '<fieldset><legend>'.$lt{'requ'}.'</legend>'; |
$datatable .= '<fieldset><legend>'.$lt{'requ'}.'</legend>'; |
if ($values{'requser'}) { |
if ($values{'requser'}) { |
$usersty = 'display:inline-block'; |
$usersty = 'display:inline-block'; |
} |
} |
} |
} |
$datatable .= |
$datatable .= |
'<span class="LC_nobreak">'.$desc{'name'}. |
'<span class="LC_nobreak">'.$desc{'name'}. |
':<input type="text" size="15" name="linkprot_name_'.$i.'" value="'.$values{'name'}.'" autocomplete="off"'.$disabled.' /></span> '. |
':<input type="text" size="15" name="linkprot_name_'.$i.'" value="'.$values{'name'}.'" autocomplete="off"'.$disabled.' /></span> '. |
(' 'x2). |
(' 'x2). |
Line 5225 sub print_linkprotection {
|
Line 5760 sub print_linkprotection {
|
$datatable .= '<div id="linkprot_divcurrsecret_'.$i.'" style="display:inline-block" /><span class="LC_nobreak">'. |
$datatable .= '<div id="linkprot_divcurrsecret_'.$i.'" style="display:inline-block" /><span class="LC_nobreak">'. |
$desc{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'</span></div>'. |
$desc{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'</span></div>'. |
'<span class="LC_nobreak">'.&mt('Change secret?'). |
'<span class="LC_nobreak">'.&mt('Change secret?'). |
'<label><input type="radio" value="0" name="linkprot_changesecret_'.$i.'" onclick="javascript:toggleLTI(this.form,'."'$i','secret'".');" checked="checked"'.$disabled.' />'.&mt('No').'</label>'. |
'<label><input type="radio" value="0" name="linkprot_changesecret_'.$i.'" onclick="javascript:toggleLinkProt(this.form,'."'$i','secret'".');" checked="checked"'.$disabled.' />'.&mt('No').'</label>'. |
(' 'x2). |
(' 'x2). |
'<label><input type="radio" value="1" name="linkprot_changesecret_'.$i.'" onclick="javascript:toggleLTI(this.form,'."'$i','secret'".');" '.$disabled.' />'.&mt('Yes').'</label>'.(' 'x2). |
'<label><input type="radio" value="1" name="linkprot_changesecret_'.$i.'" onclick="javascript:toggleLinkProt(this.form,'."'$i','secret'".');" '.$disabled.' />'.&mt('Yes').'</label>'.(' 'x2). |
'</span><div id="linkprot_divchgsecret_'.$i.'" style="display:none" />'. |
'</span><div id="linkprot_divchgsecret_'.$i.'" style="display:none" />'. |
'<span class="LC_nobreak"> - '.&mt("submit from course's home server: [_1].",$switchserver).'</span>'. |
'<span class="LC_nobreak"> - '.$switchmessage.'</span>'. |
'</div>'; |
'</div>'; |
} elsif ($values{'key'} eq '') { |
} elsif ($values{'key'} eq '') { |
$datatable .= '<span class="LC_nobreak">'.&mt('Key and Secret are required').' - '.&mt("submit from course's home server: [_1].",$switchserver).'</span>'."\n"; |
$datatable .= '<span class="LC_nobreak">'.&mt('Key and Secret are required').' - '.$switchmessage.'</span>'."\n"; |
} else { |
} else { |
$datatable .= '<span class="LC_nobreak">'.&mt('Secret required').' - '.&mt("submit from course's home server: [_1].",$switchserver).'</span>'."\n"; |
$datatable .= '<span class="LC_nobreak">'.&mt('Secret required').' - '.$switchmessage.'</span>'."\n"; |
} |
} |
} else { |
} else { |
if ($values{'usable'} ne '') { |
if ($values{'usable'} ne '') { |
$datatable .= '<div id="linkprot_divcurrsecret_'.$i.'" style="display:inline-block" /><span class="LC_nobreak">'. |
$datatable .= '<div id="linkprot_divcurrsecret_'.$i.'" style="display:inline-block" /><span class="LC_nobreak">'. |
$desc{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'</span></div>'. |
$desc{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'</span></div>'. |
'<span class="LC_nobreak">'.&mt('Change?'). |
'<span class="LC_nobreak">'.&mt('Change?'). |
'<label><input type="radio" value="0" name="linkprot_changesecret_'.$i.'" onclick="javascript:toggleLTI(this.form,'."'$i','secret'".');" checked="checked"'.$disabled.' />'.&mt('No').'</label>'. |
'<label><input type="radio" value="0" name="linkprot_changesecret_'.$i.'" onclick="javascript:toggleLinkProt(this.form,'."'$i','secret'".');" checked="checked"'.$disabled.' />'.&mt('No').'</label>'. |
(' 'x2). |
(' 'x2). |
'<label><input type="radio" value="1" name="linkprot_changesecret_'.$i.'" onclick="javascript:toggleLTI(this.form,'."'$i','secret'".');"'.$disabled.' />'.&mt('Yes'). |
'<label><input type="radio" value="1" name="linkprot_changesecret_'.$i.'" onclick="javascript:toggleLinkProt(this.form,'."'$i','secret'".');"'.$disabled.' />'.&mt('Yes'). |
'</label> </span><div id="linkprot_divchgsecret_'.$i.'" style="display:none" />'. |
'</label> </span><div id="linkprot_divchgsecret_'.$i.'" style="display:none" />'. |
'<span class="LC_nobreak">'.&mt('New Secret').':'. |
'<span class="LC_nobreak">'.&mt('New Secret').':'. |
'<input type="password" size="20" name="linkprot_secret_'.$i.'" value="" autocomplete="off"'.$disabled.' />'. |
'<input type="password" size="20" name="linkprot_secret_'.$i.'" value="" autocomplete="off"'.$disabled.' />'. |
'<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.linkprot_secret_'.$i.'.type='."'text'".' } else { this.form.linkprot_secret_'.$i.'.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label>'. |
'<label><input type="checkbox" name="linkprot_visible_'.$i.'" id="linkprot_visible_'.$i.'" onclick="if (this.checked) { this.form.linkprot_secret_'.$i.'.type='."'text'".' } else { this.form.linkprot_secret_'.$i.'.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label>'. |
'<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" /></span></div>'; |
'<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" /></span></div>'; |
} else { |
} else { |
$datatable .= |
$datatable .= |
'<span class="LC_nobreak">'.$desc{'secret'}.':'. |
'<span class="LC_nobreak">'.$desc{'secret'}.':'. |
'<input type="password" size="20" name="linkprot_secret_'.$i.'" value="" autocomplete="off"'.$disabled.' />'. |
'<input type="password" size="20" name="linkprot_secret_'.$i.'" value="" autocomplete="off"'.$disabled.' />'. |
'<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.linkprot_secret_'.$i.'.type='."'text'".' } else { this.form.linkprot_secret_'.$i.'.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label>'. |
'<label><input type="checkbox" name="linkprot_visible_'.$i.'" id="linkprot_visible_'.$i.'" onclick="if (this.checked) { this.form.linkprot_secret_'.$i.'.type='."'text'".' } else { this.form.linkprot_secret_'.$i.'.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label>'. |
'<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" /></span>'; |
'<input type="hidden" name="linkprot_id_'.$i.'" value="'.$num.'" /></span>'; |
} |
} |
} |
} |
if ($ltiauth) { |
if ($ltiauth) { |
$datatable .= |
$datatable .= |
'</fieldset>'. |
'</fieldset>'. |
'<fieldset id="linkprot_optional_'.$i.'" style="'.$usersty.'"><legend>'.$lt{'opti'}.'</legend>'. |
'<fieldset id="linkprot_optional_'.$i.'" style="'.$usersty.'"><legend>'.$lt{'opti'}.'</legend>'. |
&linkprot_options($i,$itemcount,$disabled,\%values,\%desc). |
&linkprot_options($i,$itemcount,$disabled,\%values,\%desc). |
Line 5273 sub print_linkprotection {
|
Line 5808 sub print_linkprotection {
|
$datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'."\n". |
$datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'."\n". |
'<input type="hidden" name="linkprot_maxnum" value="'.$next.'" />'."\n". |
'<input type="hidden" name="linkprot_maxnum" value="'.$next.'" />'."\n". |
'<input type="checkbox" name="linkprot_add" value="1"'.$disabled.' />'.&mt('Add').'</span></td>'."\n". |
'<input type="checkbox" name="linkprot_add" value="1"'.$disabled.' />'.&mt('Add').'</span></td>'."\n". |
'<td>'; |
'<td width="100%">'; |
my ($usersty,$onclickrequser,%checkedrequser); |
my ($usersty,$onclickrequser,%checkedrequser); |
if ($ltiauth) { |
if ($ltiauth) { |
$usersty = 'display:none'; |
$usersty = 'display:none'; |
$onclickrequser = ' onclick="toggleLTIReqUser(this.form,'."'requser','optional','1','block','add'".');"'; |
$onclickrequser = ' onclick="toggleLinkProtReqUser(this.form,'."'requser','optional','1','block','add'".');"'; |
%checkedrequser = ( |
%checkedrequser = ( |
no => ' checked="checked"', |
no => ' checked="checked"', |
yes => '', |
yes => '', |
Line 5300 sub print_linkprotection {
|
Line 5835 sub print_linkprotection {
|
} |
} |
$datatable .= '<br /><br />'; |
$datatable .= '<br /><br />'; |
if ($switchserver) { |
if ($switchserver) { |
$datatable .= '<span class="LC_nobreak">'.&mt('Key and Secret are required').' - '.&mt("submit from course's home server: [_1].",$switchserver).'</span>'."\n"; |
$datatable .= '<span class="LC_nobreak">'.&mt('Key and Secret are required').' - '.$switchmessage.'</span>'."\n"; |
} else { |
} else { |
$datatable .= '<span class="LC_nobreak">'.$desc{'key'}.':<input type="text" size="25" name="linkprot_key_add" value="" autocomplete="off"'.$disabled.' /></span> '."\n". |
$datatable .= '<span class="LC_nobreak">'.$desc{'key'}.':<input type="text" size="25" name="linkprot_key_add" value="" autocomplete="off"'.$disabled.' /></span> '."\n". |
(' 'x2). |
(' 'x2). |
'<span class="LC_nobreak">'.$desc{'secret'}.':<input type="password" size="20" name="linkprot_secret_add" value="" autocomplete="off"'.$disabled.' />'. |
'<span class="LC_nobreak">'.$desc{'secret'}.':<input type="password" size="20" name="linkprot_secret_add" value="" autocomplete="off"'.$disabled.' />'. |
'<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.linkprot_secret_add.type='."'text'".' } else { this.form.linkprot_secret_add.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label></span> '."\n"; |
'<label><input type="checkbox" name="linkprot_visible_add" id="linkprot_visible_add" onclick="if (this.checked) { this.form.linkprot_secret_add.type='."'text'".' } else { this.form.linkprot_secret_add.type='."'password'".' }"'.$disabled.' />'.&mt('Visible input').'</label></span> '."\n"; |
} |
} |
if ($ltiauth) { |
if ($ltiauth) { |
$datatable .= '</fieldset>'. |
$datatable .= '</fieldset>'. |
Line 5335 sub linkprot_names {
|
Line 5870 sub linkprot_names {
|
} |
} |
|
|
sub check_switchserver { |
sub check_switchserver { |
my ($cdom,$cnum) = @_; |
my ($cdom,$cnum,$context,$dest) = @_; |
my ($allowed,$switchserver); |
my ($allowed,$switchserver,$home); |
my $home = &Apache::lonnet::homeserver($cnum,$cdom); |
if ($context eq 'domain') { |
unless ($home eq 'no_host') { |
$home = &Apache::lonnet::domain($cdom,'primary'); |
|
} else { |
|
$home = &Apache::lonnet::homeserver($cnum,$cdom); |
|
} |
|
unless (($home eq 'no_host') || ($home eq '')) { |
my @ids=&Apache::lonnet::current_machine_ids(); |
my @ids=&Apache::lonnet::current_machine_ids(); |
foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } |
foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } |
if (!$allowed) { |
if (!$allowed) { |
$switchserver='<a href="/adm/switchserver?otherserver='.$home.'&role='. |
$switchserver='<a href="/adm/switchserver?otherserver='.$home.'&role='. |
&HTML::Entities::encode($env{'request.role'},'\'<>"&'). |
&HTML::Entities::encode($env{'request.role'},'\'<>"&'). |
'&destinationurl=/adm/courseprefs">'.&mt('Switch Server').'</a>'; |
'&destinationurl='.$dest.'">'.&mt('Switch Server').'</a>'; |
} |
} |
} |
} |
return $switchserver; |
return $switchserver; |
Line 5376 sub linkprot_options {
|
Line 5915 sub linkprot_options {
|
$checked{'auth'} = ' checked="checked"'; |
$checked{'auth'} = ' checked="checked"'; |
} |
} |
} |
} |
my $onclickuser = ' onclick="toggleLTIReqUser(this.form,'."'mapuser','userfield','other','inline-block','$num'".');"'; |
my $onclickuser = ' onclick="toggleLinkProtReqUser(this.form,'."'mapuser','userfield','other','inline-block','$num'".');"'; |
my $output = '<div class="LC_floatleft"><span class="LC_nobreak">'. |
my $output = '<div class="LC_floatleft"><span class="LC_nobreak">'. |
&mt('Source of LON-CAPA username in LTI request').': '; |
&mt('Source of LON-CAPA username in LTI request').': '; |
foreach my $option ('sourcedid','email','other') { |
foreach my $option ('sourcedid','email','other') { |
Line 5591 sub make_item_rows {
|
Line 6130 sub make_item_rows {
|
$datatable .= &checkforpriv_row($cdom,$item,$settings,$crstype,$noedit); |
$datatable .= &checkforpriv_row($cdom,$item,$settings,$crstype,$noedit); |
} elsif ($item eq 'print_header_format') { |
} elsif ($item eq 'print_header_format') { |
$datatable .= &print_hdrfmt_row($item,$settings,$noedit); |
$datatable .= &print_hdrfmt_row($item,$settings,$noedit); |
|
} elsif ($item eq 'lti.lcmenu') { |
|
$datatable .= &lcmenu_checkboxes($cdom,$item,$settings,$crstype,$noedit); |
} elsif ($items->{$item}{input} eq 'dates') { |
} elsif ($items->{$item}{input} eq 'dates') { |
my $disabled; |
my $disabled; |
if ($noedit) { |
if ($noedit) { |
Line 5608 sub make_item_rows {
|
Line 6149 sub make_item_rows {
|
} |
} |
$valueyes = "1"; |
$valueyes = "1"; |
$valueno = "0"; |
$valueno = "0"; |
|
} elsif (($item eq 'lti.topmenu') || ($item eq 'lti.inlinemenu')) { |
|
$valueyes = '1'; |
} |
} |
$datatable .= &yesno_radio($item,$settings,$unsetdefault,$valueyes,$valueno,$noedit); |
$datatable .= &yesno_radio($item,$settings,$unsetdefault,$valueyes,$valueno,$noedit); |
} elsif ($items->{$item}{input} eq 'selectbox') { |
} elsif ($items->{$item}{input} eq 'selectbox') { |
Line 5655 sub nothidepriv_row {
|
Line 6198 sub nothidepriv_row {
|
} |
} |
} |
} |
if ($settings->{'checkforpriv'}) { |
if ($settings->{'checkforpriv'}) { |
@checkdoms = split(/,/,$settings->{'checkforpriv'}); |
@checkdoms = split(/,/,$settings->{'checkforpriv'}); |
} |
} |
} |
} |
push(@checkdoms,$cdom); |
push(@checkdoms,$cdom); |
Line 5669 sub nothidepriv_row {
|
Line 6212 sub nothidepriv_row {
|
if ($end == -1 || $start == -1) { |
if ($end == -1 || $start == -1) { |
next; |
next; |
} |
} |
foreach my $dom (@checkdoms) { |
foreach my $dom (@checkdoms) { |
if (&Apache::lonnet::privileged($uname,$udom,\@checkdoms,['dc','su'])) { |
if (&Apache::lonnet::privileged($uname,$udom,\@checkdoms,['dc','su'])) { |
unless (grep(/^\Q$user\E$/,@privusers)) { |
unless (grep(/^\Q$user\E$/,@privusers)) { |
push(@privusers,$user); |
push(@privusers,$user); |
Line 5745 sub checkforpriv_row {
|
Line 6288 sub checkforpriv_row {
|
my $domdesc = &Apache::lonnet::domain($currdom,'description'); |
my $domdesc = &Apache::lonnet::domain($currdom,'description'); |
if ($domdesc eq '') { |
if ($domdesc eq '') { |
$domdesc = $currdom; |
$domdesc = $currdom; |
} |
} |
$datatable .= |
$datatable .= |
&Apache::loncommon::start_data_table_row(). |
&Apache::loncommon::start_data_table_row(). |
'<td align="left"><span class="LC_nobreak">'. |
'<td align="left"><span class="LC_nobreak">'. |
Line 5757 sub checkforpriv_row {
|
Line 6300 sub checkforpriv_row {
|
&mt('Delete').'</label></span></td>'. |
&mt('Delete').'</label></span></td>'. |
&Apache::loncommon::end_data_table_row(); |
&Apache::loncommon::end_data_table_row(); |
$num ++; |
$num ++; |
unless (grep(/^\Q$currdom\E$/,@excdoms)) { |
unless (grep(/^\Q$currdom\E$/,@excdoms)) { |
push(@excdoms,$currdom); |
push(@excdoms,$currdom); |
} |
} |
} |
} |
} |
} |
if ((scalar(keys(%domains)) - scalar(@excdoms)) > 0) { |
if ((scalar(keys(%domains)) - scalar(@excdoms)) > 0) { |
$datatable .= |
$datatable .= |
&Apache::loncommon::start_data_table_row(). |
&Apache::loncommon::start_data_table_row(). |
'<td align="left"><span class="LC_nobreak">'. |
'<td align="left"><span class="LC_nobreak">'. |
&mt('Additional domain:'). '</span><br />'. |
&mt('Additional domain:'). '</span><br />'. |
Line 5876 ENDJS
|
Line 6419 ENDJS
|
$output .= '</tr>'; |
$output .= '</tr>'; |
} |
} |
} |
} |
my $pos = $currnum+1; |
my $pos = $currnum+1; |
unless ($noedit) { |
unless ($noedit) { |
$output .= |
$output .= |
'<tr>'. |
'<tr>'. |
'<td align="left"><span class="LC_nobreak">'. |
'<td align="left"><span class="LC_nobreak">'. |
Line 6015 sub change_clone {
|
Line 6558 sub change_clone {
|
} |
} |
} |
} |
} |
} |
|
return; |
|
} |
|
|
|
sub devalidate_remote_courseprefs { |
|
my ($cdom,$cnum,$cachekeys) = @_; |
|
return unless (ref($cachekeys) eq 'HASH'); |
|
my %servers = &Apache::lonnet::internet_dom_servers($cdom); |
|
my %thismachine; |
|
map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids(); |
|
my @posscached = ('courselti'); |
|
if (keys(%servers)) { |
|
foreach my $server (keys(%servers)) { |
|
next if ($thismachine{$server}); |
|
my @cached; |
|
foreach my $name (@posscached) { |
|
if ($cachekeys->{$name}) { |
|
push(@cached,&escape($name).':'.&escape($cdom.'_'.$cnum)); |
|
} |
|
} |
|
if (@cached) { |
|
&Apache::lonnet::remote_devalidate_cache($server,\@cached); |
|
} |
|
} |
|
} |
return; |
return; |
} |
} |
|
|