--- loncom/interface/courseprefs.pm 2022/08/29 16:02:09 1.49.2.28.2.12 +++ loncom/interface/courseprefs.pm 2022/02/01 23:13:19 1.99 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set configuration settings for a course # -# $Id: courseprefs.pm,v 1.49.2.28.2.12 2022/08/29 16:02:09 raeburn Exp $ +# $Id: courseprefs.pm,v 1.99 2022/02/01 23:13:19 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -52,16 +52,12 @@ This module is used for configuration of =item process_changes() -=item process_linkprot() - =item get_sec_str() =item check_clone() =item store_changes() -=item store_linkprot() - =item update_env() =item display_disallowed() @@ -224,7 +220,6 @@ use Apache::lonparmset; use Apache::courseclassifier; use Apache::lonlocal; use LONCAPA qw(:DEFAULT :match); -use Crypt::CBC; my $registered_cleanup; my $modified_courses; @@ -315,7 +310,7 @@ sub handler { idnu => 'Course ID or number', unco => 'Unique code', desc => 'Course Description', - cred => 'Student credits', + cred => 'Student credits', ownr => 'Course Owner', cown => 'Course Co-owners', catg => 'Categorize course', @@ -370,29 +365,29 @@ sub handler { } my %values=&Apache::lonnet::dump('environment',$cdom,$cnum); - my %linkprot=&Apache::lonnet::dump('lti',$cdom,$cnum,undef,undef,undef,1); + my %lti=&Apache::lonnet::dump('lti',$cdom,$cnum,undef,undef,undef,1); my %ltienc = &Apache::lonnet::dump('nohist_ltienc',$cdom,$cnum,undef,undef,undef,1); - foreach my $id (keys(%linkprot)) { - if (ref($linkprot{$id}) eq 'HASH') { + foreach my $id (keys(%lti)) { + if (ref($lti{$id}) eq 'HASH') { if (ref($ltienc{$id}) eq 'HASH') { - $values{'linkprot'}{$id} = { %{$linkprot{$id}}, %{$ltienc{$id}} }; + $values{'linkprotection'}{$id} = { %{$lti{$id}}, %{$ltienc{$id}} }; } else { - $values{'linkprot'}{$id} = $linkprot{$id}; + $values{'linkprotection'}{$id} = $lti{$id}; } } unless ($phase eq 'process') { - if (ref($values{'linkprot'}{$id}) eq 'HASH') { - delete($values{'linkprot'}{$id}{'secret'}); + if (ref($values{'linkprotection'}{$id}) eq 'HASH') { + delete($values{'linkprotection'}{$id}{'secret'}); } } } - if ($linkprot{'lock'}) { - delete($linkprot{'lock'}); + if ($lti{'lock'}) { + delete($lti{'lock'}); } my @prefs_order = ('courseinfo','localization','feedback','discussion', 'classlists','appearance','grading','printouts', - 'menuitems','linkprot','spreadsheet','bridgetasks', - 'other'); + 'menuitems','linkprotection','spreadsheet','bridgetasks', + 'lti','other'); my %prefs = ( 'courseinfo' => @@ -407,7 +402,7 @@ sub handler { 'co-owners' => $lt{'cown'}, 'description' => $lt{'desc'}, 'courseid' => $lt{'idnu'}, - 'uniquecode' => $lt{'unco'}, + 'uniquecode' => $lt{'unco'}, 'categories' => $lt{'catg'}, 'hidefromcat' => $lt{'excc'}, 'cloners' => $lt{'clon'}, @@ -444,6 +439,7 @@ sub handler { { text => 'Discussion and Chat', help => 'Course_Prefs_Discussions', ordered => ['pch.roles.denied','pch.users.denied', + 'pac.roles.denied','pac.users.denied', 'plc.roles.denied','plc.users.denied', 'allow_limited_html_in_feedback', 'allow_discussion_post_editing', @@ -453,9 +449,11 @@ sub handler { 'pch.users.denied' => 'No Resource Discussion', 'plc.roles.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_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' => @@ -489,8 +487,7 @@ sub handler { help => 'Course_Prefs_Display', ordered => ['default_xml_style','pageseparators', 'disable_receipt_display','texengine', - 'tthoptions','uselcmath','usejsme', - 'inline_chem','extresource'], + 'tthoptions','uselcmath','usejsme','inline_chem'], itemtext => { default_xml_style => 'Default XML style file', pageseparators => 'Visibly Separate Items on Pages', @@ -500,7 +497,6 @@ sub handler { uselcmath => 'Student formula entry uses inline preview, not DragMath pop-up', usejsme => 'Molecule editor uses JSME (HTML5) in place of JME (Java)', inline_chem => 'Chemical reaction response uses inline preview, not pop-up', - extresource => 'Display of external resources', }, }, 'grading' => @@ -521,7 +517,7 @@ sub handler { help => 'Course_Prefs_Printouts', ordered => ['problem_stream_switch','suppress_tries', 'default_paper_size','print_header_format', - 'disableexampointprint'], + 'disableexampointprint','canuse_pdfforms'], itemtext => { problem_stream_switch => 'Allow problems to be split over pages', suppress_tries => 'Suppress number of tries in printing', @@ -555,6 +551,18 @@ sub handler { 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' => { text => 'Menu display', @@ -570,7 +578,7 @@ sub handler { menucollections => 'Menu collections', }, }, - 'linkprot' => + 'linkprotection' => { text => 'Link protection', help => 'Course_Prefs_Linkprotection', @@ -588,14 +596,10 @@ sub handler { ); if (($phase eq 'process') && ($parm_permission->{'process'})) { my @allitems = &get_allitems(%prefs); - my $result = &Apache::lonconfigsettings::make_changes($r,$cdom,$phase,$context, - \@prefs_order,\%prefs,\%values, - $cnum,undef,\@allitems, - 'coursepref',$parm_permission); - if ((ref($result) eq 'HASH') && (keys(%{$result}))) { - $r->rflush(); - &devalidate_remote_courseprefs($cdom,$cnum,$result); - } + &Apache::lonconfigsettings::make_changes($r,$cdom,$phase,$context, + \@prefs_order,\%prefs,\%values, + $cnum,undef,\@allitems, + 'coursepref',$parm_permission); } elsif (($phase eq 'display') && ($parm_permission->{'display'})) { my $noedit; if (ref($parm_permission) eq 'HASH') { @@ -785,10 +789,12 @@ sub print_config_box { $output .= &print_spreadsheet($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit); } elsif ($action eq 'bridgetasks') { $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') { $output .= &print_menuitems('bottom',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit); - } elsif ($action eq 'linkprot') { - $output .= &print_linkprotection($cdom,$cnum,$settings,\$rowtotal,$crstype,$noedit,'course'); + } elsif ($action eq 'linkprotection') { + $output .= &print_linkprotection($cdom,$cnum,$settings,\$rowtotal,$crstype,$noedit); } elsif ($action eq 'other') { $output .= &print_other($cdom,$settings,$allitems,\$rowtotal,$crstype,$noedit); } @@ -801,8 +807,8 @@ sub print_config_box { } sub process_changes { - my ($cdom,$cnum,$action,$values,$item,$changes,$allitems,$disallowed,$crstype,$lastactref) = @_; - my (%newvalues,$errors); + my ($cdom,$cnum,$action,$values,$item,$changes,$allitems,$disallowed,$crstype) = @_; + my (%newvalues,%lti,%ltienc,$errors); if (ref($item) eq 'HASH') { if (ref($changes) eq 'HASH') { my @ordered; @@ -819,11 +825,14 @@ sub process_changes { } } } - } elsif ($action eq 'linkprot') { + } elsif ($action eq 'linkprotection') { if (ref($values->{$action}) eq 'HASH') { foreach my $id (keys(%{$values->{$action}})) { if ($id =~ /^\d+$/) { push(@ordered,$id); + unless (ref($values->{$action}->{$id}) eq 'HASH') { + $lti{$id} = ''; + } } } } @@ -968,9 +977,105 @@ sub process_changes { } elsif ($values->{'menucollections'}) { $changes->{'menucollections'} = ''; } - } elsif ($action eq 'linkprot') { - if (ref($values) eq 'HASH') { - $errors = &process_linkprot($cdom,$cnum,$values->{$action},$changes,'course',$lastactref); + } elsif ($action eq 'linkprotection') { + my %menutitles = <imenu_titles(); + my $switchserver = &check_switchserver($cdom,$cnum); + 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 .= ''. + &mt('Failed to acquire unique ID for link protection'). + ''; + } + } + 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}; + } + } + 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 { foreach my $entry (@ordered) { @@ -1219,7 +1324,8 @@ 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); @denied = sort(@denied); my $deniedstr = ''; @@ -1227,7 +1333,8 @@ sub process_changes { $deniedstr = join(',',@denied); } $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 $userstr = ''; my @denied; @@ -1279,14 +1386,14 @@ sub process_changes { my ($classorder,$classtitles) = &discussion_vote_classes(); my $fontchange = 0; foreach my $class (@{$classorder}) { - my $ext_entry = $entry.'_'.$class; + my $ext_entry = $entry.'_'.$class; my $size = $env{'form.'.$ext_entry.'_size'}; my $unit = $env{'form.'.$ext_entry.'_unit'}; my $weight = $env{'form.'.$ext_entry.'_weight'}; my $style = $env{'form.'.$ext_entry.'_style'}; my $other = $env{'form.'.$ext_entry.'_other'}; $size =~ s/,//g; - $unit =~ s/,//g; + $unit =~ s/,//g; $weight =~ s/,//g; $style =~ s/,//g; $other =~ s/[^\w;:\s\-\%.]//g; @@ -1294,7 +1401,7 @@ sub process_changes { $newvalues{$ext_entry} = join(',',($size.$unit,$weight,$style,$other)); my $current = $values->{$ext_entry}; if ($values->{$ext_entry} eq '') { - $current = ',,,'; + $current = ',,,'; } if ($newvalues{$ext_entry} ne $current) { $changes->{$ext_entry} = $newvalues{$ext_entry}; @@ -1303,7 +1410,7 @@ sub process_changes { } if ($fontchange) { $changes->{$entry} = 1; - } + } } elsif ($entry eq 'nothideprivileged') { my @curr_nothide; my @new_nothide; @@ -1378,7 +1485,7 @@ sub process_changes { my $newtext = $maxnum-1; $newhdr[$env{'form.printfmthdr_pos_'.$newtext}] = $env{'form.printfmthdr_text_'.$newtext}; $newvalues{$entry} = join('',@newhdr); - } elsif (($entry eq 'languages') || + } elsif (($entry eq 'languages') || ($entry eq 'checkforpriv')) { my $settings; my $total = $env{'form.'.$entry.'_total'}; @@ -1394,7 +1501,7 @@ sub process_changes { } if ($env{'form.'.$entry.'_'.$total} ne '') { my $new = $env{'form.'.$entry.'_'.$total}; - if ($entry eq 'languages') { + if ($entry eq 'languages') { my %langchoices = &get_lang_choices(); if ($langchoices{$new}) { $settings .= $new; @@ -1415,36 +1522,42 @@ sub process_changes { $settings =~ s/,$//; } $newvalues{$entry} = $settings; - } elsif ($entry eq 'extresource') { - if ($env{'form.'.$entry} =~ /^iframe|tab|window$/) { + } elsif ($action eq 'lti') { + if ($entry eq 'lti.override') { $newvalues{$entry} = $env{'form.'.$entry}; - if ($env{'form.'.$entry} ne 'iframe') { - if ($env{'form.extwintabreuse'}) { - $newvalues{$entry} .= ':1'; - } else { - $newvalues{$entry} .= ':0'; - } - if ($env{'form.'.$entry} eq 'window') { - foreach my $dim ('width','height') { - $env{'form.extreswin'.$dim} =~ s/^\s+|\s+$//g; - if ($env{'form.extreswin'.$dim} =~ /^\d+$/) { - $newvalues{$entry} .= ':'.$env{'form.extreswin'.$dim}; - } else { - $newvalues{$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); } } } - } - } - unless (($newvalues{$entry} eq 'iframe') && ($values->{$entry} eq '')) { - if ($newvalues{$entry} ne $values->{$entry}) { - $changes->{$entry} = $newvalues{$entry}; + if (@newlcmenu) { + $newvalues{$entry} = join(',',@newlcmenu); + } else { + $newvalues{$entry} = 'none'; + } + } else { + $newvalues{$entry} = ''; } } } else { $newvalues{$entry} = $env{'form.'.$entry}; } - unless (($entry eq 'co-owners') || ($entry eq 'discussion_post_fonts') || ($entry eq 'extresource')) { + unless (($entry eq 'co-owners') || ($entry eq 'discussion_post_fonts')) { if ($newvalues{$entry} ne $values->{$entry}) { $changes->{$entry} = $newvalues{$entry}; } @@ -1457,257 +1570,23 @@ sub process_changes { return $errors; } -sub process_linkprot { - my ($cdom,$cnum,$values,$changes,$context,$lastactref) = @_; - 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 .= ''. - &mt('Failed to acquire unique ID for link protection'). - ''; - } - } - 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}; - } - } - my $urlitem = 'form.linkprot_returnurl_'.$idx; - my $urlparamname = 'form.linkprot_urlparam_'.$idx; - if ($env{$urlitem} == 1) { - $env{$urlparamname} =~ s/(`)/'/g; - } elsif (exists($env{$urlparamname})) { - $env{$urlparamname} = ''; - } - unless ($idx eq 'add') { - if ((!$current{'returnurl'} && ($env{$urlparamname} ne '')) || - ($current{'returnurl'} && ($env{$urlparamname} eq ''))) { - $haschanges{$itemid} = 1; - } - } - if ($env{$urlparamname} ne '') { - $linkprot{$itemid}{'returnurl'} = $env{$urlparamname}; - } - 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 +sub get_courselti_id { + my ($cdom,$cnum,$name) = @_; + # get lock on lti db in course my $lockhash = { lock => $env{'user.name'}. ':'.$env{'user.domain'}, }; my $tries = 0; - my $gotlock; - if ($context eq 'domain') { - $gotlock = &Apache::lonnet::newput_dom('linkprot',$lockhash,$cdom); - } else { - $gotlock = &Apache::lonnet::newput('lti',$lockhash,$cdom,$cnum); - } + my $gotlock = &Apache::lonnet::newput('lti',$lockhash,$cdom,$cnum); my ($id,$error); while (($gotlock ne 'ok') && ($tries<10)) { $tries ++; sleep (0.1); - if ($context eq 'domain') { - $gotlock = &Apache::lonnet::newput_dom('linkprot',$lockhash,$cdom); - } else { - $gotlock = &Apache::lonnet::newput('lti',$lockhash,$cdom,$cnum); - } + $gotlock = &Apache::lonnet::newput('lti',$lockhash,$cdom,$cnum); } if ($gotlock eq 'ok') { - 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); - } + my %currids = &Apache::lonnet::dump('lti',$cdom,$cnum,undef,undef,undef,1); if ($currids{'lock'}) { delete($currids{'lock'}); if (keys(%currids)) { @@ -1721,25 +1600,14 @@ sub get_linkprot_id { $id = 1; } if ($id) { - if ($context eq 'domain') { - 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'; - } + unless (&Apache::lonnet::newput('lti',{ $id => $name },$cdom,$cnum) eq 'ok') { + $error = 'nostore'; } } else { $error = 'nonumber'; } } - my $dellockoutcome; - if ($context eq 'domain') { - $dellockoutcome = &Apache::lonnet::del_dom('linkprot',['lock'],$cdom); - } else { - $dellockoutcome = &Apache::lonnet::del('lti',['lock'],$cdom,$cnum); - } + my $dellockoutcome = &Apache::lonnet::del('lti',['lock'],$cdom,$cnum); } else { $error = 'nolock'; } @@ -1790,10 +1658,10 @@ sub store_changes { my ($chome,$output); my (%storehash,@delkeys,@need_env_update,@oldcloner,%oldlinkprot); if ((ref($values) eq 'HASH') && (ref($changes) eq 'HASH')) { - if (ref($values->{'linkprot'}) eq 'HASH') { - %oldlinkprot = %{$values->{'linkprot'}}; + if (ref($values->{'linkprotection'}) eq 'HASH') { + %oldlinkprot = %{$values->{'linkprotection'}}; } - delete($values->{'linkprot'}); + delete($values->{'linkprotection'}); %storehash = %{$values}; } else { if ($crstype eq 'Community') { @@ -1806,7 +1674,7 @@ sub store_changes { my ($numchanges,$skipstore); if (ref($changes) eq 'HASH') { $numchanges = scalar(keys(%{$changes})); - if (($numchanges == 1) && (exists($changes->{'linkprot'}))) { + if (($numchanges == 1) && (exists($changes->{'linkprotection'}))) { $skipstore = 1; } elsif (!$numchanges) { if ($crstype eq 'Community') { @@ -1842,8 +1710,103 @@ sub store_changes { "'$storehash{$key}'")).''; } } - } elsif ($item eq 'linkprot') { - $output .= &store_linkprot($cdom,$cnum,'course',$changes->{$item},\%oldlinkprot); + } elsif ($item eq 'linkprotection') { + my (%ltienc,$lti_save_error); + 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(); + unless (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}.', '; + } + } + $display =~ s/, $//; + $output .= '
  • '.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',''.$id.'', + "'$display'")).'
  • '; + } elsif (ref($oldlinkprot{$id}) eq 'HASH') { + my $oldname = $oldlinkprot{$id}{'name'}; + $output .= '
  • '.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',''."$id ($oldname)".'')).'
  • '; + } + } + } 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 .= '
  • '. + ''. + &mt('An error occurred when saving changes to link protection settings, which remain unchanged.'). + ''. + '
  • '; + } } else { if (ref($prefs->{$item}->{'ordered'}) eq 'ARRAY') { my @settings = @{$prefs->{$item}->{'ordered'}}; @@ -1880,7 +1843,7 @@ sub store_changes { my ($displayname,$text); $text = $prefs->{$item}->{'itemtext'}{$key}; my $displayval; - unless (($key eq 'co-owners') || ($key eq 'discussion_post_fonts') || ($key eq 'extresource')) { + unless (($key eq 'co-owners') || ($key eq 'discussion_post_fonts')) { $displayval = $changes->{$item}{$key}; } if ($item eq 'feedback') { @@ -1960,6 +1923,22 @@ sub store_changes { } } $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') { unless ($changes->{$item}{$key} eq '') { if ($key eq 'menudefault') { @@ -1989,37 +1968,6 @@ sub store_changes { } elsif ($changes->{$item}{$key} eq '0') { $displayval = &mt('No'); } - } elsif ($key eq 'extresource') { - if ($changes->{$item}{$key} eq 'iframe') { - $displayval = &mt('In iframe'); - } else { - my ($selected,$reuse,$width,$height) = split(/:/,$changes->{$item}{$key}); - if ($selected eq 'tab') { - if ($reuse) { - $displayval = &mt('[_1]In tab[_2],[_3] and tab re-used for different external resources in course', - "'","'",'
    '); - } else { - $displayval = &mt('[_1]In tab[_2],[_3] with new tab for each external resource in course', - "'","'",'
    '); - } - } elsif ($selected eq 'window') { - if ($reuse) { - $displayval = &mt('[_1]In pop-up window[_2],[_3] and window re-used for different external resources in course', - "'","'",'
    '); - } else { - $displayval = &mt('[_1]In pop-up window[_2],[_3] with new window for each external resource in course', - "'","'",'
    '); - } - if (($width ne '') || ($height ne '')) { - if ($width ne '') { - $displayval .= '
    '.&mt('Window width: [_1]px',$width); - } - if ($height ne '') { - $displayval .= '
    '.&mt('Window height: [_1]px',$height); - } - } - } - } } if ($key eq 'co-owners') { if (ref($changes->{$item}{$key}) eq 'HASH') { @@ -2064,7 +2012,20 @@ sub store_changes { } } elsif ($changes->{$item}{$key} eq '') { 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 .= '
  • '.&mt('LTI settings for menu items only saved if page header and/or inline menu is set to be displayed').'
  • '; + } else { + $output .= '
  • '.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]', + ''.$displayname.'', + "'$displayval'")).'
  • '; + } + } elsif (!exists($changes->{$item}{'lti.override'})) { + $output .= '
  • '.&mt('LTI settings only saved if Override is set to "Yes"').'
  • '; + } + } elsif ($item eq 'menuitems') { if ($key eq 'menudefault') { $output .= '
  • '.&mt("Default collection of menu items set to: 'Standard' (all menus shown)").'
  • '; } elsif ($key eq 'menucollections') { @@ -2078,11 +2039,9 @@ sub store_changes { $output .= '
  • '.&Apache::lonhtmlcommon::confirm_success(&mt('Numbered menu collections:')).'
    '. $displayval.'
  • '; } else { - unless (($key eq 'extresource') && ($changes->{$item}{$key} ne 'iframe')) { - $displayval = "'$displayval'"; - } $output .= '
  • '.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]', - ''.$displayname.'',$displayval)); + ''.$displayname.'', + "'$displayval'")); if ($key eq 'url') { my $bkuptime=time; $output .= (' 'x2).&mt('(Previous URL backed up)').': '. @@ -2117,7 +2076,9 @@ sub store_changes { } if (($key eq 'description') || ($key eq 'cloners') || ($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); } } @@ -2179,164 +2140,6 @@ sub store_changes { 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; - } - if (exists($oldlinkprot->{$id}{'cipher'})) { - $changes->{$id}->{'cipher'} = $oldlinkprot->{$id}{'cipher'}; - } - } - } - } - } - 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','returnurl') { - 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, '; - } - } elsif ($title eq 'returnurl') { - if ($values{$title}) { - $display .= &mt('Return URL parameter').': '.$values{$title}.', '; - } - } 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 .= '
  • '.&Apache::lonhtmlcommon::confirm_success(&mt('[_1] set to [_2]',''.$id.'', - "'$display'")).'
  • '; - } elsif (ref($oldlinkprot->{$id}) eq 'HASH') { - my $oldname = $oldlinkprot->{$id}{'name'}; - $output .= '
  • '.&Apache::lonhtmlcommon::confirm_success(&mt('Deleted setting for [_1]',''."$id ($oldname)".'')).'
  • '; - } - } - } 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 .= '
  • '. - ''. - &mt('An error occurred when saving changes to link protection settings, which remain unchanged.'). - ''. - '
  • '; - } - return $output; -} - sub update_env { my ($cnum,$cdom,$chome,$need_env_update,$storehash) = @_; my $count = 0; @@ -2362,6 +2165,8 @@ sub update_env { my @coowners = split(',',$storehash->{'internal.'.$key}); $crsinfo{$env{'request.course.id'}}{'co-owners'} = \@coowners; $count ++; + } elsif ($key =~ /^lti\./) { + &Apache::lonnet::appenv({'course.'.$env{'request.course.id'}.'.'.$key => $storehash->{$key}}); } } if ($count) { @@ -2467,7 +2272,7 @@ sub get_course { sub get_jscript { my ($cid,$cdom,$phase,$crstype,$settings,$noedit) = @_; my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype); - my ($jscript,$categorize_js,$loncaparev_js,$instcode_js,$extresource_js); + my ($jscript,$categorize_js,$loncaparev_js,$instcode_js); my $stubrowse_js = &Apache::loncommon::studentbrowser_javascript(); my $browse_js = &Apache::loncommon::browser_and_searcher_javascript('parmset'); my $cloners_js = &cloners_javascript($phase); @@ -2490,7 +2295,7 @@ sub get_jscript { $local_to_standard{$code_order[$i]} = $standardnames[$i]; } foreach my $cloner (@cloners) { - if (($cloner !~ /^\Q*:\E$match_domain$/) && + if (($cloner !~ /^\Q*:\E$match_domain$/) && ($cloner !~ /^$match_username\:$match_domain$/)) { foreach my $item (split(/\&/,$cloner)) { my ($key,$val) = split(/\=/,$item); @@ -2674,39 +2479,45 @@ function toggleAddmenucoll() { } ENDSCRIPT } - $extresource_js = <<"ENDSCRIPT"; -function toggleExtRes() { - if (document.getElementById('LC_extresource')) { - var extressel = document.getElementById('LC_extresource').value; - if (document.getElementById('LC_extresreusediv')) { - var extresreuse = document.getElementById('LC_extresreusediv'); - if (document.getElementById('LC_extressize')) { - var extressize = document.getElementById('LC_extressize'); + 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; - if ((extressel == 'tab') || (extressel == 'window')) { - extresreuse.style.display = 'inline-block'; - setvis = 1; - if (extressel == 'window') { - extressize.style.display = 'inline-block'; - } else { - extressize.style.display = 'none'; + for (var i=0; i'."\n". + $syllabus_js."\n".$menuitems_js."\n". + $linkprotector_js."\n".'//]]>'."\n". ''."\n".$stubrowse_js."\n"; return $jscript; } @@ -2792,78 +2603,6 @@ function getIndexByName(item) { 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 0) { - var setvis; - for (var i=0; i'; $editsyllabus = &mt('[_1]Edit[_2]','', - ''); + ''); } my %items = ( 'url' => { @@ -3039,7 +2778,7 @@ sub print_courseinfo { next if (!$env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'}); } unless (($item eq 'cloners') || ($item eq 'rolenames')) { - $colspan = 2; + $colspan = 2; } $count ++; if (exists $items{$item}{advanced} && $items{$item}{advanced} == 1) { @@ -3083,7 +2822,7 @@ sub print_courseinfo { $default = '0'; } $datatable .= &new_cloners_dom_row($cdom,'0',$default); - } + } } elsif ($settings->{$item} ne '*') { my @entries = split(/,/,$settings->{$item}); if (@entries > 0) { @@ -3222,12 +2961,12 @@ sub print_courseinfo { if ($clonesrc =~ m{/$match_domain/$match_courseid}) { my %clonesrcinfo = &Apache::lonnet::coursedescription($clonesrc); if ($clonesrcinfo{'description'}) { - $clonedfrom = $clonesrcinfo{'description'}.' '.($clonesrc); + $clonedfrom = $clonesrcinfo{'description'}.' '.($clonesrc); } } $datatable .= $clonedfrom; } 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) { $datatable .= $code; } @@ -3274,12 +3013,12 @@ sub print_courseinfo { } elsif ($uploaded) { $datatable .= &mt('Uploaded file'); } else { - $datatable .= &mt('Standard template'); + $datatable .= &mt('Standard template'); } $datatable .= (' ' x 2). &mt('[_1]View[_2]', '', - ''); + ''); } elsif ($item eq 'loncaparev') { my $loncaparev = $env{'course.'.$env{'request.course.id'}.'.internal.releaserequired'}; my $showreqd; @@ -3304,7 +3043,7 @@ sub new_cloners_dom_row { my ($output,$checkedon,$checkedoff); if ($newdom ne '') { if ($num eq $default) { - $checkedon = 'checked="checked" '; + $checkedon = 'checked="checked" '; } else { $checkedoff = 'checked="checked" '; } @@ -3455,7 +3194,7 @@ ENDSCRIPT sub display_loncaparev_constraints { my ($r,$navmap,$loncaparev,$crstype) = @_; - my ($reqdmajor,$reqdminor); + my ($reqdmajor,$reqdminor); my $cid = $env{'request.course.id'}; my $cdom = $env{'course.'.$cid.'.domain'}; my $cnum = $env{'course.'.$cid.'.num'}; @@ -3472,116 +3211,160 @@ sub display_loncaparev_constraints { $Apache::lonrelrequtils::checkcrstypes{$crstype}).''; } my (%fromparam,%rowspan,%bymap,%byresource,@scopeorder,%toshow,%allmaps, - %byresponsetype,%bysubmission,%fromblocks); + %byresponsetype,%bysubmission,%fromblocks,%bycrsrestype); @scopeorder = ('all','section/group','user'); my $now = time; my $resourcedata = &Apache::lonparmset::readdata($cnum,$cdom); if (ref($resourcedata) eq 'HASH') { foreach my $key (keys(%{$resourcedata})) { + my %found; foreach my $item (keys(%Apache::lonrelrequtils::checkparms)) { if ($key =~ /(\Q$item\E)$/) { - if (ref($Apache::lonrelrequtils::checkparms{$item}) eq 'ARRAY') { - my $value = $resourcedata->{$key}; - if ($item eq 'examcode') { - if (&Apache::lonnet::validCODE($value)) { - $value = 'valid'; - } else { - $value = ''; - } - } elsif ($item eq 'printstartdate') { - if ($value =~ /^\d+$/) { - if ($value > $now) { - $value = 'future'; - } - } - } elsif ($item eq 'printenddate') { - if ($value =~ /^\d+$/) { - if ($value < $now) { - $value = 'past'; - } - } - - } - my ($middle,$scope,$which,$level,$map,$resource); - if (grep(/^\Q$value\E$/,@{$Apache::lonrelrequtils::checkparms{$item}})) { - my $stdtype = &Apache::lonparmset::standard_parameter_types($item); - 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)\]\.)/) { - $middle = $1; - $which = $2; - $scope = 'user'; - } elsif ($key =~ /^\Q$start\E(\[(\w+)\]\.)/) { - $middle = $1; - $which = $2; - $scope = 'section/group'; - } else { - $scope = 'all'; - } - my $what="$stdname=$valname"; - if ($key =~ /^\Q$start$middle\E\w+\.\Q$item\E$/) { - $level = 'general'; - if ($scope eq 'all') { - if (ref($fromparam{$rev}{$scope}) eq 'ARRAY') { - unless(grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}})) { - push(@{$fromparam{$rev}{$scope}},$what); - } - } else { - push(@{$fromparam{$rev}{$scope}},$what); - } - } else { - 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\).\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); - } - } - } + if (ref($Apache::lonrelrequtils::checkparms{$item}) eq 'ARRAY') { + my $value = $resourcedata->{$key}; + if ($item eq 'examcode') { + if (&Apache::lonnet::validCODE($value)) { + $value = 'valid'; + } else { + $value = ''; + } + } elsif ($item eq 'printstartdate') { + if ($value =~ /^\d+$/) { + if ($value > $now) { + $value = 'future'; + } + } + } elsif ($item eq 'printenddate') { + if ($value =~ /^\d+$/) { + if ($value < $now) { + $value = 'past'; + } + } + } + if (grep(/^\Q$value\E$/,@{$Apache::lonrelrequtils::checkparms{$item}})) { + my $stdtype = &Apache::lonparmset::standard_parameter_types($item); + $found{$item}{'valname'} = &get_param_description($stdtype,$value); + $found{$item}{'rev'} = $Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value.'::'}; + } + } + } + } + foreach my $item (keys(%Apache::lonrelrequtils::checkparmvalsmatch)) { + if (ref($Apache::lonrelrequtils::checkparmvalsmatch{$item}) eq 'ARRAY') { + my $value = $resourcedata->{$key}; + foreach my $valuematch (@{$Apache::lonrelrequtils::checkparmvalsmatch{$item}}) { + if ($value =~ /$valuematch/) { + my $stdtype = &Apache::lonparmset::standard_parameter_types($item); + $found{$item}{'valname'} = &get_param_description($stdtype,$value,1); + $found{$item}{'rev'} = + $Apache::lonnet::needsrelease{'parameter:'.$item.'::'.$valuematch.':'}; + last; + } + } + } + } + foreach my $item (keys(%Apache::lonrelrequtils::checkparmnamesmatch)) { + my $regexp; + if ($item eq 'maplevelrecurse') { + $regexp = '\.(?:sequence|page)___\(rec\)\.'; + } + if ($regexp ne '') { + if ($key =~ /$regexp.*\.(\w+)$/) { + my $name = $1; + my $value = $resourcedata->{$key}; + if ($name eq 'type') { + last unless (($value eq 'problem') || ($value eq 'practice') || ($value eq 'exam') || + ($value eq 'survey') || ($value eq 'surveycred') || ($value eq 'anonsurvey') || + ($value eq 'anonsurveycred') || ($value eq 'randomizetry') || ($value eq 'library')); + } + my $stdtype = &Apache::lonparmset::standard_parameter_types($name); + $found{$name}{'valname'} = &get_param_description($stdtype,$value); + $found{$name}{'extra'} = &mt('Recursive into sub-folders'); + $found{$name}{'rev'} = + $Apache::lonnet::needsrelease{'parameter::::'.$item}; + } + } + } + foreach my $item (keys(%found)) { + my $stdname = &Apache::lonparmset::standard_parameter_names($item); + my $rev = $found{$item}{'rev'}; + my $valname = $found{$item}{'valname'}; + my $extra = $found{$item}{'extra'}; + my ($middle,$scope,$which,$level,$map,$resource); + my $start = $cid.'.'; + if ($key =~ /^\Q$start\E(\[useropt\:($match_username\:$match_domain)\]\.)/) { + $middle = $1; + $which = $2; + $scope = 'user'; + } elsif ($key =~ /^\Q$start\E(\[(\w+)\]\.)/) { + $middle = $1; + $which = $2; + $scope = 'section/group'; + } else { + $scope = 'all'; + } + my $what="$stdname=$valname"; + if ($extra) { + $what .= "
    $extra
    "; + } + if ($key =~ /^\Q$start$middle\E\w+\.\Q$item\E$/) { + $level = 'general'; + if ($scope eq 'all') { + if (ref($fromparam{$rev}{$scope}) eq 'ARRAY') { + unless(grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}})) { + push(@{$fromparam{$rev}{$scope}},$what); + } + } else { + push(@{$fromparam{$rev}{$scope}},$what); + } + } else { + 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); } } } @@ -3681,7 +3464,7 @@ sub display_loncaparev_constraints { if (ref($fromblocks{$type}) eq 'HASH') { foreach my $rev (keys(%{$fromblocks{$type}})) { my ($major,$minor) = split(/\./,$rev); - ($reqdmajor,$reqdminor) = + ($reqdmajor,$reqdminor) = &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor); $output .= &Apache::loncommon::start_data_table_row(). ''.$rev.''.$lt{$type}.''; @@ -3699,18 +3482,25 @@ sub display_loncaparev_constraints { if (defined($navmap)) { 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 $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 $stdname=&Apache::lonparmset::standard_parameter_names('type'); my $valanon=&get_param_description($stdtype,'anonsurvey'); my $valrandtry=&get_param_description($stdtype,'randomizetry'); 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 $symb = $res->symb(); 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) { if (exists($anonsubms{$symb."\0".$part})) { my $rev = $rev_anonsurv; @@ -3761,7 +3551,7 @@ sub display_loncaparev_constraints { &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor, $reqdmajor,$reqdminor); $checkedrev{$key} = 1; - } + } push(@{$byresponsetype{$symb}{$rev}},$key); $allmaps{$enclosing_map} = 1; } @@ -3798,6 +3588,10 @@ 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 = '

    '. &mt('Requirements for specific folders or resources'). '

    '; @@ -3812,9 +3606,9 @@ sub display_loncaparev_constraints { $r->print($start_page.$top_header); if ($output) { $r->print($output); - if (defined($navmap)) { + if (defined($navmap) || $supptools) { &show_contents_view($r,$navmap,$cid,\%toshow,\%bymap,\%byresource,\%bysubmission, - \%byresponsetype,\@scopeorder,\%lt); + \%byresponsetype,\%bycrsrestype,\@scopeorder,\%lt,$supptools); } $r->print('

    '); } else { @@ -3832,22 +3626,30 @@ sub display_loncaparev_constraints { sub show_contents_view { my ($r,$navmap,$cid,$toshow,$bymap,$byresource,$bysubmission,$byresponsetype, - $scopeorder,$lt) = @_; - if ((keys(%{$toshow}) > 0) || (keys(%{$byresource}) > 0) || - (keys(%{$bysubmission}) > 0) || (keys(%{$byresponsetype}) > 0)) { - my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons"); - my $whitespace = ''; - my $icon = ''; + $bycrsrestype,$scopeorder,$lt,$supptools) = @_; + my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons"); + my $whitespace = ''; + my $showmaincontent; + if ((ref($navmap)) && + ((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 = ''; my $topmap = $env{'course.'.$cid.'.url'}; - $r->print(&Apache::loncommon::start_data_table(). - &Apache::loncommon::start_data_table_header_row(). + $r->print(&Apache::loncommon::start_data_table_header_row(). ''.&mt('Location').''.&mt('Release').''. ''.&mt('Attribute/Setting').''. &Apache::loncommon::end_data_table_header_row(). &Apache::loncommon::start_data_table_row(). ' '.$icon.' '.&mt('Main Content').''); - &releases_by_map($r,$bymap,$topmap,$scopeorder,$lt); - $r->print(&Apache::loncommon::end_data_table_row()); + &releases_by_map($r,$bymap,$topmap,$scopeorder,$lt); + $r->print(&Apache::loncommon::end_data_table_row()); my $it=$navmap->getIterator(undef,undef,undef,1,1,undef); my $curRes; my $depth = 0; @@ -3898,6 +3700,9 @@ sub show_contents_view { if (ref($byresponsetype->{$symb}) eq 'HASH') { $rowspan += scalar(keys(%{$byresponsetype->{$symb}})); } + if (ref($bycrsrestype->{$symb}) eq 'HASH') { + $rowspan += scalar(keys(%{$bycrsrestype->{$symb}})); + } next if (!$rowspan); $icon = ''.
                             &mt('Problem').''; @@ -3962,10 +3767,37 @@ sub show_contents_view { $r->print(''); } $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(''.$rev.''.$bycrsrestype->{$symb}{$rev}.''); + } + $r->print(&Apache::loncommon::end_data_table_row()); } } } } + } + if ($supptools) { + my $icon = ''; + $r->print(&Apache::loncommon::start_data_table_header_row(). + ''.&mt('Location').''.&mt('Release').''. + ''.&mt('Resource Type').''. + &Apache::loncommon::end_data_table_header_row(). + &Apache::loncommon::start_data_table_row(). + ' '.$icon.' '.&mt('Supplemental Content').''. + ''. + $Apache::lonrelrequtils::exttool{'major'}.'.'. + $Apache::lonrelrequtils::exttool{'minor'}. + ''.&mt('[quant,_1,External Tool,External Tools]', + $supptools).''. + &Apache::loncommon::end_data_table_row()); + } + if ($showmaincontent || $supptools) { $r->print(&Apache::loncommon::end_data_table()); } return; @@ -3974,7 +3806,7 @@ sub show_contents_view { sub releases_by_map { my ($r,$bymap,$url,$scopeorder,$lt) = @_; return unless ((ref($bymap) eq 'HASH') && (ref($scopeorder) eq 'ARRAY')); - my $newrow = 0; + my $newrow = 0; if (ref($bymap->{$url}) eq 'HASH') { foreach my $rev (sort(keys(%{$bymap->{$url}}))) { if ($newrow) { @@ -4011,18 +3843,67 @@ sub releases_by_map { } sub get_param_description { - my ($stdtype,$value) = @_; - my $name = $value; - my $paramstrings = &Apache::lonparmset::standard_string_options($stdtype); - unless (ref($paramstrings) eq 'ARRAY') { - return $name; + my ($stdtype,$value,$regexp) = @_; + my ($name,$parammatches,$paramstrings,@possibles); + if ($stdtype =~ /^string/) { + $paramstrings = &Apache::lonparmset::standard_string_options($stdtype); + } 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'); - my ($thing, $description) = @{ $possibilities }; - if ($thing eq $value) { - $name = $description; - last; + my $gotregexmatch = ''; + if ($regexp) { + last if ($gotregexmatch); + 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; @@ -4232,7 +4113,7 @@ sub print_localization { undef,$includeempty,$disabled); } else { if ($settings->{$item} eq '') { - unless ($noedit) { + unless ($noedit) { $datatable .= ''. &Apache::loncommon::select_language('languages_0','',1); } @@ -4262,15 +4143,15 @@ sub print_localization { } } unless ($noedit) { - $datatable .= + $datatable .= &Apache::loncommon::start_data_table_row(). ''. &mt('Additional language:'). '
    '. &Apache::loncommon::select_language('languages_'.$num,'',1). ''. ''.&Apache::loncommon::end_data_table_row(); - } - $datatable .= &Apache::loncommon::end_data_table().'
    '; + } + $datatable .= &Apache::loncommon::end_data_table().'
    '; } } $datatable .= &item_table_row_end(); @@ -4358,7 +4239,7 @@ sub user_table { if ($currvalue eq '') { unless ($noedit) { $output .= &select_recipient($item,'0',$cdom,$sections); - } + } } else { my $num = 0; my @curr = split(/,/,$currvalue); @@ -4510,6 +4391,20 @@ sub print_discussion { &mt('(specific user(s))'), input => 'checkbox', }, + + 'pac.roles.denied' => { + text => ''.&mt($itemtext->{'pac.roles.denied'}).''. + &Apache::loncommon::help_open_topic("Course_Disable_Anonymous_Discussion").'
    '. + &mt('(role-based)'), + input => 'checkbox', + }, + + 'pac.users.denied' => { + text => ''.&mt($itemtext->{'pac.users.denied'}).'
    '. + &mt('(specific user(s))'), + input => 'checkbox', + }, + 'allow_limited_html_in_feedback' => { text => ''.&mt($itemtext->{'allow_limited_html_in_feedback'}).'', input => 'radio', @@ -4542,7 +4437,7 @@ sub print_discussion { my $colspan; if ($item eq 'allow_limited_html_in_feedback') { $colspan = 2; - } + } $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan); if ($item eq 'plc.roles.denied') { $datatable .= ''. @@ -4560,6 +4455,14 @@ sub print_discussion { $datatable .= ''. &user_table($cdom,$item,undef, $settings->{$item},\%lt,$noedit); + } elsif ($item eq 'pac.roles.denied') { + $datatable .= ''. + ''.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit). + '
    '; + } elsif ($item eq 'pac.users.denied') { + $datatable .= ''. + &user_table($cdom,$item,undef, + $settings->{$item},\%lt,$noedit); } elsif ($item eq 'allow_limited_html_in_feedback') { $datatable .= &yesno_radio($item,$settings,undef,undef,undef,$noedit); } elsif ($item eq 'allow_discussion_post_editing') { @@ -4579,7 +4482,7 @@ sub print_discussion { ''.&mt('font-size').''. ''.&mt('font-weight').''. ''.&mt('font-style').''. - ''.&mt('Other css').''. + ''.&mt('Other css').''. &Apache::loncommon::end_data_table_row(). &set_discussion_fonts($cdom,$cnum,$item,$settings,$noedit). &Apache::loncommon::end_data_table().'
    '; @@ -4631,7 +4534,7 @@ sub role_checkboxes { my $count = 0; my $disabled; if ($noedit) { - $disabled = ' disabled="disabled"'; + $disabled = ' disabled="disabled"'; } foreach my $role (@roles) { my $checked = ''; @@ -4759,7 +4662,7 @@ sub set_discussion_fonts { sub discussion_vote_classes { my $classorder = ['twoplus','oneplus','zero','oneminus','twominus']; - my %classtitles = &Apache::lonlocal::texthash( + my %classtitles = &Apache::lonlocal::texthash( 'twoplus' => 'Two sigma above mean', 'oneplus' => 'One sigma above mean', 'zero' => 'Within one sigma of mean', @@ -4825,7 +4728,7 @@ sub print_classlists { 'defaultcredits' => { text => ''.&mt($itemtext->{'defaultcredits'}).'', }, - + 'nothideprivileged' => { text => ''.&mt($itemtext->{'nothideprivileged'}).'', input => 'checkbox', @@ -4916,16 +4819,6 @@ sub print_appearance { text => ''.&mt($itemtext->{'inline_chem'}).'', input => 'radio', }, - 'extresource' => { - text => ''.&mt($itemtext->{'extresource'}).'', - input => 'selectbox', - options => { - iframe => 'In iframe', - tab => 'In new tab', - window => 'In pop-up window', - }, - order => ['iframe','tab','window'], - }, ); return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'appearance',$noedit); } @@ -4942,11 +4835,12 @@ sub print_grading { input => 'selectbox', options => { standard => &mt('Standard: shows points'), + categories => &mt('Categories: shows points according to categories'), external => &mt('External: shows number of completed parts and totals'), externalnototals => &mt('External: shows only number of completed parts'), spreadsheet => &mt('Spreadsheet: (with link to detailed scores)'), }, - order => ['standard','external','externalnototals','spreadsheet'], + order => ['standard','categories','external','externalnototals','spreadsheet'], }, 'rndseed' => { text => ''.&mt($itemtext->{'rndseed'}).''. @@ -5116,6 +5010,134 @@ sub print_bridgetasks { 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 => ''.&mt($itemtext->{'lti.override'}).''.$domdefs, + input => 'radio', + }, + 'lti.topmenu' => { + text => ''.&mt($itemtext->{'lti.topmenu'}).'', + input => 'radio', + }, + 'lti.inlinemenu' => { + text => ''.&mt($itemtext->{'lti.inlinemenu'}).'', + input => 'radio', + }, + 'lti.lcmenu' => { + text => ''.&mt($itemtext->{'lti.lcmenu'}).'
    '.$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 = ''; + 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 .= ''; + } + $output .= ''; + } + $output .= ''; + $count ++; + } + my $rem = $count%($numinrow); + my $colsleft = $numinrow - $rem; + if ($colsleft > 1 ) { + $output .= ''; + } elsif ($colsleft == 1) { + $output .= ''; + } + $output .= '
    '. + '  
    '; +} + sub ltimenu_titles { return &Apache::lonlocal::texthash( fullname => 'Full name', @@ -5265,7 +5287,7 @@ sub menuitems_categories { my %categories = ( shown => ['top','inline','foot','main'], 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'], inline => ['cont','grades','chat','people','groups','resv','syll','feeds'], ); @@ -5290,6 +5312,7 @@ sub menuitems_fields { main => 'Access to main menu', pers => 'Personal', logo => 'LON-CAPA', + menu => 'Home', comm => 'Messages', roles => 'Roles/Courses', help => 'Help', @@ -5360,7 +5383,7 @@ sub menucollections_display { ''.$menutitles{$category}.''."\n"; if ($category eq 'text') { $output .= ''.&mt('Header Text').'

    '; - } + } foreach my $field (@{$categories{$category}}) { if ($field eq 'disc') { $output .= '
    '.&mt('Footer Text').'

    '; @@ -5383,60 +5406,32 @@ sub menucollections_display { } sub print_linkprotection { - my ($cdom,$cnum,$settings,$rowtotal,$crstype,$noedit,$context) = @_; + my ($cdom,$cnum,$settings,$rowtotal,$crstype,$noedit) = @_; + unless (ref($settings) eq 'HASH') { + return; + } my %linkprotection; my $count = 0; my $next = 1; - my ($datatable,$disabled,$css_class,$dest); + my ($datatable,$disabled,$css_class); if ($noedit) { $disabled = ' disabled="disabled"'; } - my %desc = &linkprot_names(); - my %lt = &Apache::lonlocal::texthash ( - 'requ' => 'Required settings', - 'opti' => 'Optional settings', - ); + my %lt = &linkprot_names(); my $itemcount = 0; - my $ltiauth; - if ($context eq 'domain') { - $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 { - $dest = '/adm/courseprefs'; - } + my $switchserver = &check_switchserver($cdom,$cnum); - 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); - } - } - - if ((ref($settings) eq 'HASH') && (ref($settings->{'linkprot'}) eq 'HASH')) { - if (keys(%{$settings->{'linkprot'}})) { - my @current = sort { $a <=> $b } keys(%{$settings->{'linkprot'}}); + if (ref($settings->{'linkprotection'}) eq 'HASH') { + if (keys(%{$settings->{'linkprotection'}})) { + my @current = sort { $a <=> $b } keys(%{$settings->{'linkprotection'}}); $next += $current[-1]; for (my $i=0; $i<@current; $i++) { my $num = $current[$i]; my %values; - if (ref($settings->{'linkprot'}->{$num}) eq 'HASH') { - %values = %{$settings->{'linkprot'}->{$num}}; + if (ref($settings->{'linkprotection'}->{$num}) eq 'HASH') { + %values = %{$settings->{'linkprotection'}->{$num}}; } else { next; } @@ -5448,44 +5443,18 @@ sub print_linkprotection { $datatable .= ''. ''; - my ($usersty,$onclickrequser,%checkedrequser,$onclickreturnurl,%checkedreturnurl); - if ($ltiauth) { - $usersty = 'display:none'; - $onclickrequser = ' onclick="toggleLinkProtExtra(this.form,'."'requser','optional','1','block','$i'".');"'; - %checkedrequser = ( - no => ' checked="checked"', - yes => '', - ); - if ($values{'requser'}) { - $checkedrequser{'yes'} = $checkedrequser{'no'}; - $checkedrequser{'no'} = ''; - } - $datatable .= '
    '.$lt{'requ'}.''; - if ($values{'requser'}) { - $usersty = 'display:inline-block'; - } - } - $onclickreturnurl = ' onclick="toggleLinkProtExtra(this.form,'."'returnurl','divurlparam','1','inline-block','$i'".');"'; - %checkedreturnurl = ( - no => ' checked="checked"', - yes => '', - ); - if ($values{'returnurl'} ne '') { - $checkedreturnurl{'yes'} = $checkedreturnurl{'no'}; - $checkedreturnurl{'no'} = ''; - } - $datatable .= - ''.$desc{'name'}. + &mt('Delete?').''. + ''.$lt{'name'}. ': '. (' 'x2). - ''.$desc{'version'}.':'. ' '."\n". (' 'x2). - ''.$desc{'lifetime'}.':

    '; + ''.$lt{'lifetime'}.':'. + '

    '; if ($values{'key'} ne '') { - $datatable .= ''.$desc{'key'}; + $datatable .= ''.$lt{'key'}; if ($noedit) { $datatable .= ': ['.&mt('not shown').']'; } elsif ($switchserver) { @@ -5495,69 +5464,47 @@ sub print_linkprotection { } $datatable .= ' '.(' 'x2); } elsif (!$switchserver) { - $datatable .= ''.$desc{'key'}.':'. + $datatable .= ''.$lt{'key'}.':'. ''. ' '.(' 'x2); } if ($switchserver) { if ($values{'usable'} ne '') { $datatable .= '
    '. - $desc{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'
    '. + $lt{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'
    '. ''.&mt('Change secret?'). - ''. + ''. (' 'x2). - ''.(' 'x2). + ''.(' 'x2). ''; } elsif ($values{'key'} eq '') { - $datatable .= ''.&mt('Key and Secret are required').' - '.$switchmessage.''."\n"; + $datatable .= ''.&mt('Key and Secret are required').' - '.&mt("submit from course's home server: [_1].",$switchserver).''."\n"; } else { - $datatable .= ''.&mt('Secret required').' - '.$switchmessage.''."\n"; + $datatable .= ''.&mt('Secret required').' - '.&mt("submit from course's home server: [_1].",$switchserver).''."\n"; } - $datatable .= ''; } else { if ($values{'usable'} ne '') { $datatable .= '
    '. - $desc{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'
    '. + $lt{'secret'}.': ['.&mt('not shown').'] '.(' 'x2).'
    '. ''.&mt('Change?'). - ''. + ''. (' 'x2). - ''; } else { $datatable .= - ''.$desc{'secret'}.':'. + ''.$lt{'secret'}.':'. ''. - ''. + ''. ''; } } - $datatable .= '

    '. - ''.$desc{'returnurl'}.'?'. - ' '. - ''. - '  
    '; - if ($ltiauth) { - $datatable .= (' 'x2).''.$desc{'requser'}.'?'. - ' '. - ''. - '
    '. - '
    '.$lt{'opti'}.''. - &linkprot_options($i,$itemcount,$disabled,\%values,\%desc). - '
    '; - } $datatable .= ''; $itemcount ++; } @@ -5567,190 +5514,55 @@ sub print_linkprotection { $datatable .= ''."\n". ''."\n". ''.&mt('Add').''."\n". - ''; - my ($usersty,$onclickrequser,%checkedrequser,$onclickreturnurl,%checkedreturnurl); - if ($ltiauth) { - $usersty = 'display:none'; - $onclickrequser = ' onclick="toggleLinkProtExtra(this.form,'."'requser','optional','1','block','add'".');"'; - %checkedrequser = ( - no => ' checked="checked"', - yes => '', - ); - $datatable .= '
    '.$lt{'requ'}.''; - } - $onclickreturnurl = ' onclick="toggleLinkProtExtra(this.form,'."'returnurl','divurlparam','1','inline-block','add'".');"'; - %checkedreturnurl = ( - no => ' checked="checked"', - yes => '', - ); - $datatable .= ''.$desc{'name'}. + ''. + ''.$lt{'name'}. ': '."\n". (' 'x2). - ''.$desc{'version'}.':'. ' '."\n". (' 'x2). - ''.$desc{'lifetime'}.': '."\n". + ''.$lt{'lifetime'}.': '."\n". '

    '; if ($switchserver) { - $datatable .= ''.&mt('Key and Secret are required').' - '.$switchmessage.''."\n"; + $datatable .= ''.&mt('Key and Secret are required').' - '.&mt("submit from course's home server: [_1].",$switchserver).''."\n"; } else { - $datatable .= ''.$desc{'key'}.': '."\n". + $datatable .= ''.$lt{'key'}.': '."\n". (' 'x2). - ''.$desc{'secret'}.':'. - ' '."\n"; - } - $datatable .= '

    '. - ''.$desc{'returnurl'}.'?'. - ' '. - ''. - '  
    '; - if ($ltiauth) { - $datatable .= (' 'x2).''.$desc{'requser'}.'?'. - ' '. - ''. - '
    '. - '
    '.$lt{'opti'}.''. - &linkprot_options('add',$itemcount,$disabled,{},\%desc). - '
    '; + ''.$lt{'secret'}.':'. + ' '."\n"; } $datatable .= ''; $$rowtotal ++; - return $datatable; + return $datatable;; } sub linkprot_names { - return &Apache::lonlocal::texthash( + my %lt = &Apache::lonlocal::texthash( 'version' => 'LTI Version', 'key' => 'Key', 'lifetime' => 'Nonce lifetime (s)', - 'name' => 'Launcher Application', + 'name' => 'Launcher Application Name', 'secret' => 'Secret', - 'returnurl' => 'Launcher return URL', - 'requser' => 'Use identity', - 'email' => 'Email address', - 'sourcedid' => 'User ID', - 'other' => 'Other', - 'auth' => 'Display LON-CAPA login page', - 'reject' => 'Discontinue launch process', ); + return %lt; } sub check_switchserver { - my ($cdom,$cnum,$context,$dest) = @_; - my ($allowed,$switchserver,$home); - if ($context eq 'domain') { - $home = &Apache::lonnet::domain($cdom,'primary'); - } else { - $home = &Apache::lonnet::homeserver($cnum,$cdom); - } - unless (($home eq 'no_host') || ($home eq '')) { + my ($cdom,$cnum) = @_; + my ($allowed,$switchserver); + my $home = &Apache::lonnet::homeserver($cnum,$cdom); + unless ($home eq 'no_host') { my @ids=&Apache::lonnet::current_machine_ids(); foreach my $id (@ids) { if ($id eq $home) { $allowed=1; } } if (!$allowed) { $switchserver=''.&mt('Switch Server').''; + '&destinationurl=/adm/courseprefs">'.&mt('Switch Server').''; } } return $switchserver; } -sub linkprot_options { - my ($num,$itemcount,$disabled,$current,$desc) = @_; - my %lt; - if (ref($desc) eq 'HASH') { - %lt = %{$desc}; - } - my $userfieldsty = 'none'; - my (%checked,$userfield); - $checked{'sourcedid'} = ' checked="checked"'; - $checked{'reject'} = ' checked="checked"'; - if (ref($current) eq 'HASH') { - if (($current->{'mapuser'} ne '') && ($current->{'mapuser'} ne 'lis_person_sourcedid')) { - $checked{'sourcedid'} = ''; - if ($current->{'mapuser'} eq 'lis_person_contact_email_primary') { - $checked{'email'} = ' checked="checked"'; - } else { - $checked{'other'} = ' checked="checked"'; - $userfield = $current->{'mapuser'}; - $userfieldsty = 'inline-block'; - } - } - if (($current->{'notstudent'} ne '') && ($current->{'notstudent'} ne 'reject')) { - $checked{'reject'} = ''; - $checked{'auth'} = ' checked="checked"'; - } - } - my $onclickuser = ' onclick="toggleLinkProtExtra(this.form,'."'mapuser','userfield','other','inline-block','$num'".');"'; - my $output = '
    '. - &mt('Source of LON-CAPA username in LTI request').': '; - foreach my $option ('sourcedid','email','other') { - $output .= ''. - ($option eq 'other' ? '' : (' 'x2) ); - } - $output .= '
    '. - '
    '. - '
    '; - $output .= '
    '. - '
    '. - &mt('Action when username is not for an enrolled student').': '; - foreach my $option ('reject','auth') { - $output .= ''. - ($option eq 'auth' ? '' : (' 'x2) ); - } - $output .= '
    '; - return $output; -} - -sub print_extresource_row { - my ($item,$config,$curr,$noedit) = @_; - my $onchange; - unless ($noedit) { - $onchange = ' onchange="javascript:toggleExtRes();"'; - } - my $id = 'LC_'.$item; - my ($selected,$reuse,$width,$height) = split(/:/,$curr); - my $output = &select_from_options($item,$config->{'order'}, - $config->{'options'},$selected, - $config->{'nullval'}, - undef,undef,$onchange,$noedit,$id); - my ($checked,$reusesty,$sizesty); - if ($reuse) { - $checked = ' checked="checked"'; - } - $reusesty = 'none'; - $sizesty = 'none'; - if (($selected eq 'window') || ($selected eq 'tab')) { - $reusesty = 'inline-block'; - if ($selected eq 'window') { - $sizesty = 'inline-block'; - } - } - $output .= '
    '. - ''. - ''. - '
    '. - '
    '. - ''.&mt('Window size (optional)').''. - ''. - &mt('width').':px'. - (' ' x 3). - &mt('height').':px'. - '
    '; - return $output; -} - sub print_other { my ($cdom,$settings,$allitems,$rowtotal,$crstype,$noedit) = @_; unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) { @@ -5922,16 +5734,10 @@ sub make_item_rows { (($caller eq 'printouts') && ($item ne 'print_header_format'))) { $colspan = 2; } - my $rowdesc; - if ($caller eq 'appearance') { - $rowdesc = ''.$items->{$item}{text}.''; - } else { - $rowdesc = $items->{$item}{text}; - } if (exists $items->{$item}{advanced} && $items->{$item}{advanced} == 1) { - $datatable .= &item_table_row_start($rowdesc,$count,"advanced",$colspan); + $datatable .= &item_table_row_start($items->{$item}{text},$count,"advanced",$colspan); } else { - $datatable .= &item_table_row_start($rowdesc,$count,undef,$colspan); + $datatable .= &item_table_row_start($items->{$item}{text},$count,undef,$colspan); } if ($item eq 'defaultcredits') { my $defaultcredits = $env{'course.'.$env{'request.course.id'}.'.internal.defaultcredits'}; @@ -5948,8 +5754,8 @@ sub make_item_rows { $datatable .= &checkforpriv_row($cdom,$item,$settings,$crstype,$noedit); } elsif ($item eq 'print_header_format') { $datatable .= &print_hdrfmt_row($item,$settings,$noedit); - } elsif ($item eq 'extresource') { - $datatable .= &print_extresource_row($item,$items->{$item},$settings->{$item},$noedit); + } elsif ($item eq 'lti.lcmenu') { + $datatable .= &lcmenu_checkboxes($cdom,$item,$settings,$crstype,$noedit); } elsif ($items->{$item}{input} eq 'dates') { my $disabled; if ($noedit) { @@ -5967,6 +5773,8 @@ sub make_item_rows { } $valueyes = "1"; $valueno = "0"; + } elsif (($item eq 'lti.topmenu') || ($item eq 'lti.inlinemenu')) { + $valueyes = '1'; } $datatable .= &yesno_radio($item,$settings,$unsetdefault,$valueyes,$valueno,$noedit); } elsif ($items->{$item}{input} eq 'selectbox') { @@ -6014,7 +5822,7 @@ sub nothidepriv_row { } } if ($settings->{'checkforpriv'}) { - @checkdoms = split(/,/,$settings->{'checkforpriv'}); + @checkdoms = split(/,/,$settings->{'checkforpriv'}); } } push(@checkdoms,$cdom); @@ -6028,7 +5836,7 @@ sub nothidepriv_row { if ($end == -1 || $start == -1) { next; } - foreach my $dom (@checkdoms) { + foreach my $dom (@checkdoms) { if (&Apache::lonnet::privileged($uname,$udom,\@checkdoms,['dc','su'])) { unless (grep(/^\Q$user\E$/,@privusers)) { push(@privusers,$user); @@ -6104,7 +5912,7 @@ sub checkforpriv_row { my $domdesc = &Apache::lonnet::domain($currdom,'description'); if ($domdesc eq '') { $domdesc = $currdom; - } + } $datatable .= &Apache::loncommon::start_data_table_row(). ''. @@ -6116,13 +5924,13 @@ sub checkforpriv_row { &mt('Delete').''. &Apache::loncommon::end_data_table_row(); $num ++; - unless (grep(/^\Q$currdom\E$/,@excdoms)) { + unless (grep(/^\Q$currdom\E$/,@excdoms)) { push(@excdoms,$currdom); } } } if ((scalar(keys(%domains)) - scalar(@excdoms)) > 0) { - $datatable .= + $datatable .= &Apache::loncommon::start_data_table_row(). ''. &mt('Additional domain:'). '
    '. @@ -6235,8 +6043,8 @@ ENDJS $output .= ''; } } - my $pos = $currnum+1; - unless ($noedit) { + my $pos = $currnum+1; + unless ($noedit) { $output .= ''. ''. @@ -6374,30 +6182,6 @@ 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; }