--- loncom/interface/courseprefs.pm 2013/06/27 03:09:17 1.49.2.9 +++ loncom/interface/courseprefs.pm 2018/01/02 14:43:17 1.85 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set configuration settings for a course # -# $Id: courseprefs.pm,v 1.49.2.9 2013/06/27 03:09:17 raeburn Exp $ +# $Id: courseprefs.pm,v 1.85 2018/01/02 14:43:17 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -137,7 +137,7 @@ whether Domain coordinators who are curr advanced course user .db file for a course are to be hidden (e.g., in syllabus, or from course user lists). -Inputs: $cdom,$item,$settings,$crstype +Inputs: $cdom,$item,$settings,$crstype,$noedit where $cdom is course domain, item is nothideprivileged, $settings is HASH ref of the current values for nothideprivileged, $crstype is course type (Course or Community). @@ -215,10 +215,15 @@ use Apache::lonnet; use Apache::loncommon(); use Apache::lonhtmlcommon(); use Apache::lonconfigsettings; +use Apache::lonrelrequtils; use Apache::lonparmset; +use Apache::courseclassifier; use Apache::lonlocal; use LONCAPA qw(:DEFAULT :match); +my $registered_cleanup; +my $modified_courses; + sub handler { my $r=shift; if ($r->header_only) { @@ -228,11 +233,11 @@ sub handler { } my $context = 'course'; my $cid = $env{'request.course.id'}; - my ($cnum,$cdom) = &get_course($cid); + my ($cnum,$cdom,$chome) = &get_course($cid); my $crstype = &Apache::loncommon::course_type(); - my $parm_permission = &Apache::lonnet::allowed('opa',$cid); + my ($parm_permission,$allowed) = &get_permission($cid); my $navmap = Apache::lonnavmaps::navmap->new(); - if ($parm_permission && $navmap) { + if ($allowed && $navmap) { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; } else { @@ -257,6 +262,9 @@ sub handler { return HTTP_NOT_ACCEPTABLE; } + $registered_cleanup=0; + @{$modified_courses}=(); + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['phase','actions','origin']); &Apache::lonhtmlcommon::clear_breadcrumbs(); @@ -272,6 +280,7 @@ sub handler { edit => 'Edit Community Settings', gens => 'General community settings', idnu => 'Community ID or number', + unco => 'Unique code', desc => 'Community Description', ownr => 'Community Owner', cown => 'Community Co-owners', @@ -299,8 +308,9 @@ sub handler { edit => 'Edit Course Settings', gens => 'General course settings', 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', @@ -334,15 +344,22 @@ sub handler { $phase = $env{'form.phase'}; } - if ($phase eq 'categorizecourse') { + if (($phase eq 'categorizecourse') && ($parm_permission->{'categorizecourse'})) { &assign_course_categories($r,$crstype); return OK; } - if ($phase eq 'releaseinfo') { + if (($phase eq 'releaseinfo') && ($parm_permission->{'releaseinfo'})) { my $loncaparev = $env{'course.'.$cid.'.internal.releaserequired'}; if ($loncaparev) { - &display_loncaparev_constraints($r,$navmap,$loncaparev,$crstype); + if (&display_loncaparev_constraints($r,$navmap,$loncaparev,$crstype)) { + push(@{$modified_courses},[$cdom,$cnum,$chome,$crstype]); + unless ($registered_cleanup) { + my $handlers = $r->get_handlers('PerlCleanupHandler'); + $r->set_handlers('PerlCleanupHandler' => [\&update_releasereq,@{$handlers}]); + $registered_cleanup=1; + } + } return OK; } } @@ -357,20 +374,23 @@ sub handler { { text => $lt{'gens'}, help => 'Course_Prefs_General', ordered => ['owner','co-owners','loncaparev','description', - 'courseid','categories','hidefromcat', - 'externalsyllabus','cloners','url','rolenames'], + 'clonedfrom','courseid','uniquecode','categories', + 'hidefromcat','externalsyllabus','cloners','url', + 'rolenames'], itemtext => { 'owner' => $lt{'ownr'}, 'co-owners' => $lt{'cown'}, 'description' => $lt{'desc'}, 'courseid' => $lt{'idnu'}, + 'uniquecode' => $lt{'unco'}, 'categories' => $lt{'catg'}, 'hidefromcat' => $lt{'excc'}, 'cloners' => $lt{'clon'}, - 'externalsyllabus' => 'URL of Syllabus', + 'externalsyllabus' => 'Syllabus status', 'url' => 'Top Level Map', 'rolenames' => $lt{'rept'}, 'loncaparev' => $lt{'lcrv'}, + 'clonedfrom' => 'Cloned from', }, }, 'localization' => @@ -399,6 +419,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', @@ -408,9 +429,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' => @@ -444,13 +467,15 @@ sub handler { help => 'Course_Prefs_Display', ordered => ['default_xml_style','pageseparators', 'disable_receipt_display','texengine', - 'tthoptions'], + 'tthoptions','uselcmath','usejsme'], itemtext => { default_xml_style => 'Default XML style file', pageseparators => 'Visibly Separate Items on Pages', disable_receipt_display => 'Disable display of problem receipts', texengine => 'Force use of a specific math rendering engine', tthoptions => 'Default set of options to pass to tth/m when converting TeX', + uselcmath => 'Student formula entry uses inline preview, not DragMath pop-up', + usejsme => 'Molecule editor uses JSME (HTML5) in place of JME (Java)', }, }, 'grading' => @@ -471,7 +496,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', @@ -513,23 +538,52 @@ sub handler { }], }, ); - if ($phase eq 'process') { + if (($phase eq 'process') && ($parm_permission->{'process'})) { my @allitems = &get_allitems(%prefs); &Apache::lonconfigsettings::make_changes($r,$cdom,$phase,$context, \@prefs_order,\%prefs,\%values, - $cnum,undef,\@allitems,'coursepref'); - } elsif ($phase eq 'display') { - my $jscript = &get_jscript($cid,$cdom,$phase,$crstype); + $cnum,undef,\@allitems, + 'coursepref',$parm_permission); + } elsif (($phase eq 'display') && ($parm_permission->{'display'})) { + my $jscript = &get_jscript($cid,$cdom,$phase,$crstype,\%values); my @allitems = &get_allitems(%prefs); &Apache::lonconfigsettings::display_settings($r,$cdom,$phase,$context, - \@prefs_order,\%prefs,\%values,undef,$jscript,\@allitems,$crstype,'coursepref'); + \@prefs_order,\%prefs,\%values,undef,$jscript,\@allitems,$crstype, + 'coursepref',$parm_permission); } else { &Apache::lonconfigsettings::display_choices($r,$phase,$context, - \@prefs_order,\%prefs,'coursepref'); + \@prefs_order,\%prefs, + 'coursepref',$parm_permission); } return OK; } +sub get_permission { + my ($cid) = @_; + my %permission; + my $allowed = 0; + return (\%permission,$allowed) unless ($cid); + if (&Apache::lonnet::allowed('opa',$cid)) { + %permission= ( + 'pickactions' => 1, + 'categorizecourse' => 1, + 'releaseinfo' => 1, + 'process' => 1, + 'display' => 1, + ); + } elsif (&Apache::lonnet::allowed('vpa',$env{'request.course.id'})) { + %permission = ( + 'pickactions' => 1, + 'releaseinfo' => 1, + 'display' => 1, + ); + } + foreach my $perm (values(%permission)) { + if ($perm) { $allowed=1; last; } + } + return (\%permission,$allowed); +} + sub get_allitems { my (%prefs) = @_; my @allitems; @@ -547,9 +601,15 @@ sub get_allitems { } sub print_config_box { - my ($r,$cdom,$phase,$action,$item,$settings,$allitems,$crstype) = @_; + my ($r,$cdom,$phase,$action,$item,$settings,$allitems,$crstype,$parm_permission) = @_; my $ordered = $item->{'ordered'}; my $itemtext = $item->{'itemtext'}; + my $noedit; + if (ref($parm_permission) eq 'HASH') { + unless ($parm_permission->{'process'}) { + $noedit = 1; + } + } my $rowtotal = 0; my $output = ' @@ -584,9 +644,9 @@ sub print_config_box { } $rowtotal ++; if ($action eq 'feedback') { - $output .= &print_feedback('top',$cdom,$settings,$ordered,$itemtext,\$rowtotal); + $output .= &print_feedback('top',$cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit); } elsif ($action eq 'classlists') { - $output .= &print_classlists('top',$cdom,$settings,$itemtext,\$rowtotal,$crstype); + $output .= &print_classlists('top',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit); } $output .= '
@@ -607,7 +667,7 @@ sub print_config_box { $output .= &mt($item->{'header'}->[1]->{'col2'}).' '; if ($action eq 'classlists') { - $output .= &print_classlists('middle',$cdom,$settings,$itemtext,\$rowtotal,$crstype). + $output .= &print_classlists('middle',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit). ' @@ -646,27 +706,27 @@ sub print_config_box { } $rowtotal ++; if ($action eq 'courseinfo') { - $output .= &print_courseinfo($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype); + $output .= &print_courseinfo($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit); } elsif ($action eq 'localization') { - $output .= &print_localization($cdom,$settings,$ordered,$itemtext,\$rowtotal); + $output .= &print_localization($cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit); } elsif ($action eq 'feedback') { - $output .= &print_feedback('bottom',$cdom,$settings,$ordered,$itemtext,\$rowtotal); + $output .= &print_feedback('bottom',$cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit); } elsif ($action eq 'discussion') { - $output .= &print_discussion($cdom,$settings,$ordered,$itemtext,\$rowtotal); + $output .= &print_discussion($cdom,$settings,$ordered,$itemtext,\$rowtotal,$noedit); } elsif (($action eq 'classlists') || ($action eq 'viewableroster')) { - $output .= &print_classlists('bottom',$cdom,$settings,$itemtext,\$rowtotal,$crstype); + $output .= &print_classlists('bottom',$cdom,$settings,$itemtext,\$rowtotal,$crstype,$noedit); } elsif ($action eq 'appearance') { - $output .= &print_appearance($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype); + $output .= &print_appearance($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit); } elsif ($action eq 'grading') { - $output .= &print_grading($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype); + $output .= &print_grading($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit); } elsif ($action eq 'printouts') { - $output .= &print_printouts($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype); + $output .= &print_printouts($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit); } elsif ($action eq 'spreadsheet') { - $output .= &print_spreadsheet($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype); + $output .= &print_spreadsheet($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit); } elsif ($action eq 'bridgetasks') { - $output .= &print_bridgetasks($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype); + $output .= &print_bridgetasks($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit); } elsif ($action eq 'other') { - $output .= &print_other($cdom,$settings,$allitems,\$rowtotal,$crstype); + $output .= &print_other($cdom,$settings,$allitems,\$rowtotal,$crstype,$noedit); } $output .= ' @@ -705,7 +765,8 @@ sub process_changes { next if (($entry eq 'categories') && (!$can_categorize)); next if (($entry eq 'loncaparev') || - ($entry eq 'owner')); + ($entry eq 'owner') || + ($entry eq 'clonedfrom')); push(@ordered,$entry); } } elsif ($action eq 'classlists') { @@ -764,7 +825,7 @@ sub process_changes { my @clonedoms; if (exists($env{'form.cloners_activate'})) { my $actnum = $env{'form.cloners_activate'}; - if ($actnum ne '') { + if ($actnum ne '-1') { if ($env{'form.cloners_dom_'.$actnum} ne '') { my $clonedom = $env{'form.cloners_dom_'.$actnum}; if (&check_clone($clonedom,$disallowed) eq 'ok') { @@ -782,7 +843,7 @@ sub process_changes { my $clonedom = $env{'form.cloners_dom_'.$i}; if (&check_clone($clonedom,$disallowed) eq 'ok') { if (!grep(/^\*:\Q$clonedom\E$/,@clonedoms)) { - push (@clonedoms,'*:'.$clonedom); + push(@clonedoms,'*:'.$clonedom); } } } @@ -828,6 +889,37 @@ sub process_changes { } } } + if (ref($values) eq 'HASH') { + my (@code_order,%codedefaults); + &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults, + \@code_order); + my $clonebycode; + if ($env{'form.cloners_instcode'}) { + if (@code_order > 0) { + my @standardnames = &Apache::loncommon::get_standard_codeitems(); + my %local_to_standard; + for (my $i=0; $i<@code_order; $i++) { + $local_to_standard{$code_order[$i]} = $standardnames[$i]; + } + foreach my $item (@code_order) { + my $key = $local_to_standard{$item}; + if ($key ne '') { + if ($env{'form.'.$key}) { + $clonebycode .= $key.'='.&escape($env{'form.'.$key}).'&'; + } + } + } + $clonebycode =~ s/\&$//; + } + } + if ($clonebycode) { + if ($newvalues{$entry}) { + $newvalues{$entry} .= ','.$clonebycode; + } else { + $newvalues{$entry} = $clonebycode; + } + } + } } if (ref($disallowed) eq 'HASH') { if (ref($disallowed->{'cloners'}) eq 'HASH') { @@ -967,7 +1059,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 = ''; @@ -975,7 +1068,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; @@ -1027,14 +1121,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; @@ -1042,7 +1136,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}; @@ -1051,7 +1145,7 @@ sub process_changes { } if ($fontchange) { $changes->{$entry} = 1; - } + } } elsif ($entry eq 'nothideprivileged') { my @curr_nothide; my @new_nothide; @@ -1126,7 +1220,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'}; @@ -1142,7 +1236,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; @@ -1385,7 +1479,7 @@ sub store_changes { $displayval = &Apache::lonlocal::locallocaltime($displayval); } elsif ($key eq 'categories') { $displayval = $env{'form.categories_display'}; - } elsif ($key eq 'canuse_pdfforms') { + } elsif (($key eq 'canuse_pdfforms') || ($key eq 'usejsme') || ($key eq 'uselcmath')) { if ($changes->{$item}{$key} eq '1') { $displayval = &mt('Yes'); } elsif ($changes->{$item}{$key} eq '0') { @@ -1657,16 +1751,98 @@ sub get_course { } my $cdom=$env{'course.'.$courseid.'.domain'}; my $cnum=$env{'course.'.$courseid.'.num'}; - return ($cnum,$cdom); + my $chome=$env{'course.'.$courseid.'.home'}; + return ($cnum,$cdom,$chome); } sub get_jscript { - my ($cid,$cdom,$phase,$crstype) = @_; + my ($cid,$cdom,$phase,$crstype,$settings) = @_; my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype); - my ($jscript,$categorize_js,$loncaparev_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); + my @code_order; + if ($crstype ne 'Community') { + if (ref($settings) eq 'HASH') { + my %codedefaults; + &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults, + \@code_order); + if (@code_order > 0) { + if ($phase eq 'display') { + my @actions = &Apache::loncommon::get_env_multiple('form.actions'); + if (grep(/^courseinfo$/,@actions)) { + if ($settings->{'cloners'} ne '') { + unless ($settings->{'cloners'} eq '*') { + my @cloners = split(/,/,$settings->{'cloners'}); + my @standardnames = &Apache::loncommon::get_standard_codeitems(); + my %local_to_standard; + for (my $i=0; $i<@code_order; $i++) { + $local_to_standard{$code_order[$i]} = $standardnames[$i]; + } + foreach my $cloner (@cloners) { + if (($cloner !~ /^\Q*:\E$match_domain$/) && + ($cloner !~ /^$match_username\:$match_domain$/)) { + foreach my $item (split(/\&/,$cloner)) { + my ($key,$val) = split(/\=/,$item); + $val = &unescape($val); + foreach my $code (@code_order) { + if ($key eq $local_to_standard{$code}) { + $env{'form.'.$key} = $val; + } + } + } + } + } + } + } + } + } + my @codetitles; + (undef,$instcode_js) = + &Apache::courseclassifier::instcode_selectors($cdom,'display',undef, + \@codetitles); + $instcode_js .= <'."\n". + $cloners_js."\n".$instcode_js. + $syllabus_js."\n".'//]]>'."\n". ''."\n".$stubrowse_js."\n"; return $jscript; } @@ -1732,7 +1921,7 @@ function update_cloners(caller,num) { if (document.$formname.cloners_activate[i].value == '0') { document.$formname.cloners_activate[i].checked = false; } - if (document.$formname.cloners_activate[i].value == '') { + if (document.$formname.cloners_activate[i].value == '-1') { document.$formname.cloners_activate[i].checked = true; } } @@ -1785,29 +1974,82 @@ ENDSCRIPT sub print_courseinfo { - my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_; + my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_; unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) { return; } - my ($cathash,$categoriesform,$autocoowner); + my ($cathash,$categoriesform,$autocoowner,$clonedefaults,$disabled); + if ($noedit) { + $disabled = ' disabled="disabled"'; + } my %domconf = - &Apache::lonnet::get_dom('configuration',['coursecategories','autoenroll'],$cdom); + &Apache::lonnet::get_dom('configuration', + ['coursecategories','autoenroll','coursedefaults'],$cdom); if (ref($domconf{'coursecategories'}) eq 'HASH') { $cathash = $domconf{'coursecategories'}{'cats'}; if (ref($cathash) eq 'HASH') { $categoriesform = &Apache::loncommon::assign_categories_table($cathash, - $settings->{'categories'},$crstype)."\n"; + $settings->{'categories'},$crstype,$disabled)."\n"; } } if (ref($domconf{'autoenroll'}) eq 'HASH') { $autocoowner = $domconf{'autoenroll'}{'co-owners'}; } + my ($currcanclone,@code_order,$cloner_instcode); + my %codedefaults; + &Apache::lonnet::auto_instcode_defaults($cdom,\%codedefaults, + \@code_order); + if ($settings->{'cloners'}) { + unless ($settings->{'cloners'} eq '*') { + my @currclone = split(/,/,$settings->{'cloners'}); + foreach my $item (@currclone) { + unless ($item eq '*') { + if (($item !~ /\:/) && ($item =~ /=/)) { + $cloner_instcode = 1; + } + } + } + } + } + if (ref($domconf{'coursedefaults'}) eq 'HASH') { + my $canclone = $domconf{'coursedefaults'}{'canclone'}; + if (ref($canclone) eq 'HASH') { + if (ref($canclone->{'instcode'}) eq 'ARRAY') { + if ($settings->{'internal.coursecode'}) { + my @posscodes; + if (@code_order > 0) { + $currcanclone = 'instcode'; + foreach my $item (@{$canclone->{'instcode'}}) { + if (grep(/^\Q$item\E$/,@code_order)) { + push(@posscodes,$item); + } + } + my $codestr = join(' + ',@posscodes); + $clonedefaults = &mt('Default for official courses is to also allow cloning if [_1] match in cloner and cloned.', + '"'.$codestr.'"').'
'; + } + } + } + } elsif ($canclone eq 'domain') { + $clonedefaults = &mt('Default is for any course requester in [_1] domain to be able to clone.', + ''.$cdom.'').'
'; + $currcanclone = 'domain'; + } + if ($clonedefaults) { + if ($settings->{'cloners'} ne '') { + $clonedefaults .= '
'.&mt('Default does [_1]not[_2] currently apply because values have been set in the course.','',''); + } else { + $clonedefaults .= &mt('Default is disregarded if [_1]any[_2] values are set here in the course.','',''); + } + $clonedefaults = '

'.$clonedefaults; + } + } if (!defined($categoriesform)) { $categoriesform = &mt('No categories defined in this domain.'); } - my ($can_toggle_cat,$can_categorize) = &can_modify_catsettings($cdom,$crstype); + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; my $replace; if ($crstype eq 'Community') { @@ -1815,14 +2057,20 @@ sub print_courseinfo { } else { $replace = &mt('To replace the standard title for a course role, enter a title, otherwise leave blank'); } + my ($editmap,$editsyllabus); + unless ($noedit) { + $editmap = (' 'x2). + '". + &mt('Select Map').'
'. + &mt('Modification may make assessment data inaccessible!'). + ''; + $editsyllabus = &mt('[_1]Edit[_2]','', + ''); + } my %items = ( 'url' => { - text => ''.&mt($itemtext->{'url'}).''.(' 'x2). - '". - &mt('Select Map').'
'. - &mt('Modification may make assessment data inaccessible!'). - '', + text => ''.&mt($itemtext->{'url'}).''.$editmap, input => 'textbox', size => '55', advanced => 1 @@ -1838,15 +2086,22 @@ sub print_courseinfo { 'co-owners' => { text => ''.&mt($itemtext->{'co-owners'}).'', }, + 'clonedfrom' => { + text => ''.&mt($itemtext->{'clonedfrom'}).'', + }, 'courseid' => { text => ''.&mt($itemtext->{'courseid'}).'
'.'('. &mt('internal, optional').')', input => 'textbox', size => '25', }, + 'uniquecode' => { + text => ''.&mt($itemtext->{'uniquecode'}).'', + }, 'cloners' => { text => ''.&mt($itemtext->{'cloners'}).'
'. - &mt('Owner and Coordinators included automatically'), + &mt('Owner and Coordinators included automatically'). + $clonedefaults, input => 'textbox', size => '40' }, @@ -1858,10 +2113,9 @@ sub print_courseinfo { advanced => 1 }, 'externalsyllabus' => { - text => ''.&mt($itemtext->{'externalsyllabus'}).'
('. - &mt('not using syllabus template)'), - input => 'textbox', - size => '40', + text => ''.&mt($itemtext->{'externalsyllabus'}).'
'. + &mt('(Syllabus type in use)').(' ' x2). + $editsyllabus, }, 'hidefromcat' => { text => ''.&mt($itemtext->{'hidefromcat'}).'
'. @@ -1889,9 +2143,11 @@ sub print_courseinfo { next if (!$can_toggle_cat); } elsif ($item eq 'categories') { next if (!$can_categorize); + } elsif ($item eq 'uniquecode') { + 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) { @@ -1900,7 +2156,7 @@ sub print_courseinfo { $datatable .= &item_table_row_start($items{$item}{text},$count,undef,$colspan); } if ($items{$item}{input} eq 'radio') { - $datatable .= &yesno_radio($item,$settings); + $datatable .= &yesno_radio($item,$settings,undef,undef,undef,$noedit); } elsif ($item eq 'cloners') { my $includeempty = 1; my $num = 0; @@ -1914,13 +2170,14 @@ sub print_courseinfo { $datatable .= ' checked="checked" '; } $datatable .= 'onchange="javascript:update_cloners('. - "'cloners_all'".');" />'.&mt('Yes').''. - (' 'x2).''.&mt('Yes').''. + (' 'x2).''. + "'cloners_all'".');"'.$disabled.' />'.&mt('No').''. &Apache::loncommon::end_data_table_row(). &Apache::loncommon::end_data_table(). ''. &Apache::loncommon::end_data_table_row(); $num ++; @@ -1972,7 +2235,8 @@ sub print_courseinfo { ''.&Apache::loncommon::end_data_table_row(). &Apache::loncommon::end_data_table(). @@ -1984,9 +2248,40 @@ sub print_courseinfo { &mt('Specific users').' ('. &mt('user:domain,user:domain').')
'. &Apache::lonhtmlcommon::textbox($item,$cloners_str, - $items{$item}{'size'}). + $items{$item}{'size'},$disabled). ''.&Apache::loncommon::end_data_table_row(). &Apache::loncommon::end_data_table(); + if (@code_order > 0) { + my (%cat_items,@codetitles,%cat_titles,%cat_order); + my ($jscript,$totcodes,$numtitles,$lasttitle) = + &Apache::courseclassifier::instcode_selectors_data($cdom,'display', + \%cat_items,\@codetitles, + \%cat_titles,\%cat_order); + my $showncodes = 'off'; + my $checkedoff = ' checked="checked"'; + my $checkedon = ''; + if ($cloner_instcode) { + $checkedon = $checkedoff; + $checkedoff = ''; + $showncodes = 'on'; + } + $datatable .= '
'.&mt('Or'). @@ -1928,7 +2185,13 @@ sub print_courseinfo { &Apache::loncommon::start_data_table(); my @cloners; if ($settings->{$item} eq '') { - $datatable .= &new_cloners_dom_row($cdom,'0'); + unless ($noedit) { + my $default; + if ($currcanclone eq 'domain') { + $default = '0'; + } + $datatable .= &new_cloners_dom_row($cdom,'0',$default); + } } elsif ($settings->{$item} ne '*') { my @entries = split(/,/,$settings->{$item}); if (@entries > 0) { @@ -1949,7 +2212,7 @@ sub print_courseinfo { '
'. '
'. $add_domtitle.'
'. &Apache::loncommon::select_dom_form('','cloners_newdom', - $includeempty). + $includeempty,undef,undef, + undef,undef,$noedit). ''. '
'.&mt('And'). + '
'. + &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_row(). + ''. + &mt('Cloning by official course(s) based on course category').(' 'x2). + ''. + (' '). + ''. + &Apache::courseclassifier::build_instcode_selectors($numtitles, + $lasttitle,\%cat_items,\@codetitles,\%cat_titles,\%cat_order, + $showncodes,'LC_cloners_instcodes','LC_cloners_instcode',$noedit). + ''.&Apache::loncommon::end_data_table_row(). + &Apache::loncommon::end_data_table(); + } } elsif ($item eq 'rolenames') { $datatable .= ''. &Apache::loncommon::start_data_table(); @@ -2004,12 +2299,17 @@ sub print_courseinfo { ''. &Apache::lonhtmlcommon::textbox('rolenames_'.$role, $settings->{$role.'.plaintext'}, - $items{$item}{size}).''. + $items{$item}{size},$disabled).''. &Apache::loncommon::end_data_table_row(); } $datatable .= &Apache::loncommon::end_data_table().''; } elsif ($item eq 'categories') { - my $launcher = 'onfocus="this.blur();javascript:catsbrowser();"'; + my $launcher; + if ($noedit) { + $launcher = $disabled; + } else { + $launcher = 'onfocus="this.blur();javascript:catsbrowser();"'; + } $datatable .= ''. &Apache::lonhtmlcommon::textbox($item.'_display',$settings->{$item}, $items{$item}{size},$launcher); @@ -2024,8 +2324,22 @@ sub print_courseinfo { $owner = &mt('None specified'); } $datatable .= $owner; + } elsif ($item eq 'clonedfrom') { + my $clonesrc = $env{'course.'.$env{'request.course.id'}.'.clonedfrom'}; + my $clonedfrom = &mt('None'); + if ($clonesrc =~ m{/$match_domain/$match_courseid}) { + my %clonesrcinfo = &Apache::lonnet::coursedescription($clonesrc); + if ($clonesrcinfo{'description'}) { + $clonedfrom = $clonesrcinfo{'description'}.' '.($clonesrc); + } + } + $datatable .= $clonedfrom; + } elsif ($item eq 'uniquecode') { + my $code = $env{'course.'.$env{'request.course.id'}.'.internal.uniquecode'}; + if ($code) { + $datatable .= $code; + } } elsif ($item eq 'co-owners') { - my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; my $coowners = $env{'course.'.$env{'request.course.id'}.'.internal.co-owners'}; my @currcoown; if ($coowners) { @@ -2035,15 +2349,45 @@ sub print_courseinfo { if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) { $datatable .= &show_autocoowners(@currcoown); } else { - $datatable .= &coowner_invitations($cnum,$cdom,@currcoown); + $datatable .= &coowner_invitations($cnum,$cdom,\@currcoown,$noedit); } } else { if (($crstype eq 'Course') && ($env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}) && ($autocoowner)) { $datatable .= &show_autocoowners(@currcoown); } else { - $datatable .= &manage_coownership($cnum,$cdom,@currcoown); + $datatable .= &manage_coownership($cnum,$cdom,\@currcoown,$noedit); } } + } elsif ($item eq 'externalsyllabus') { + my $external = $env{'course.'.$env{'request.course.id'}.'.externalsyllabus'}; + my $uploaded = $env{'course.'.$env{'request.course.id'}.'.uploadedsyllabus'}; + my $minimal = $env{'course.'.$env{'request.course.id'}.'.minimalsyllabus'}; + if (($minimal =~/\w/) || ($uploaded =~/\w/)) { + if ($minimal =~/\w/) { + if ($external =~ m{\Q$minimal\E$}) { + undef($external); + } + } elsif ($uploaded =~/\w/) { + if ($external =~ m{\Q$uploaded\E$}) { + undef($external); + } + } + } elsif ($external!~/\w/) { + undef($external); + } + if ($external) { + $datatable .= &mt('External URL'); + } elsif ($minimal) { + $datatable .= &mt('Minimal template'); + } elsif ($uploaded) { + $datatable .= &mt('Uploaded file'); + } else { + $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; @@ -2055,7 +2399,7 @@ sub print_courseinfo { } $datatable .= $showreqd; } else { - $datatable .= &Apache::lonhtmlcommon::textbox($item,$settings->{$item},$items{$item}{size}); + $datatable .= &Apache::lonhtmlcommon::textbox($item,$settings->{$item},$items{$item}{size},$disabled); } $datatable .= &item_table_row_end(); } @@ -2064,19 +2408,24 @@ sub print_courseinfo { } sub new_cloners_dom_row { - my ($newdom,$num) = @_; - my $output; + my ($newdom,$num,$default) = @_; + my ($output,$checkedon,$checkedoff); if ($newdom ne '') { + if ($num eq $default) { + $checkedon = 'checked="checked" '; + } else { + $checkedoff = 'checked="checked" '; + } $output .= &Apache::loncommon::start_data_table_row(). ''. &mt('Any user in domain:').' '.$newdom.''. (' 'x2).''.(' 'x2). ' @@ -2213,6 +2563,7 @@ ENDSCRIPT sub display_loncaparev_constraints { my ($r,$navmap,$loncaparev,$crstype) = @_; + my ($reqdmajor,$reqdminor); my $cid = $env{'request.course.id'}; my $cdom = $env{'course.'.$cid.'.domain'}; my $cnum = $env{'course.'.$cid.'.num'}; @@ -2222,110 +2573,167 @@ sub display_loncaparev_constraints { 'section/group' => 'section/group', 'user' => 'user', ); - my (%checkparms,%checkresponsetypes,%checkcrstypes,%anonsurvey,%randomizetry); - &Apache::loncommon::build_release_hashes(\%checkparms,\%checkresponsetypes, - \%checkcrstypes,\%anonsurvey,\%randomizetry); - if (defined($checkcrstypes{$crstype})) { + &Apache::lonrelrequtils::init_global_hashes(); + if (defined($Apache::lonrelrequtils::checkcrstypes{$crstype})) { + ($reqdmajor,$reqdminor) = split(/\./,$Apache::lonrelrequtils::checkcrstypes{$crstype}); $output .= '

'.&mt('Course type: [_1] requires [_2] or newer',$crstype, - $checkcrstypes{$crstype}).'

'; + $Apache::lonrelrequtils::checkcrstypes{$crstype}).''; } my (%fromparam,%rowspan,%bymap,%byresource,@scopeorder,%toshow,%allmaps, - %byresponsetype,%bysubmission); + %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})) { - foreach my $item (keys(%checkparms)) { + my %found; + foreach my $item (keys(%Apache::lonrelrequtils::checkparms)) { if ($key =~ /(\Q$item\E)$/) { - if (ref($checkparms{$item}) eq 'ARRAY') { - my $value = $resourcedata->{$key}; - if ($item eq 'examcode') { - if (&Apache::lonnet::validCODE($value)) { - $value = 'valid'; - } else { - $value = ''; - } - } - my ($middle,$scope,$which,$level,$map,$resource); - if (grep(/^\Q$value\E$/,@{$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); } } } @@ -2339,6 +2747,9 @@ sub display_loncaparev_constraints { ''.&mt('Extent').''.&mt('Setting').''. &Apache::loncommon::end_data_table_header_row(); foreach my $rev (keys(%fromparam)) { + my ($major,$minor) = split(/\./,$rev); + ($reqdmajor,$reqdminor) = + &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor); $output .= &Apache::loncommon::start_data_table_row(). ''.$rev.''; my $newrow; @@ -2369,20 +2780,96 @@ sub display_loncaparev_constraints { } } + my %comm_blocks = &Apache::lonnet::dump('comm_block',$cdom,$cnum); + my $now = time; + if (keys(%comm_blocks) > 0) { + foreach my $block (keys(%comm_blocks)) { + if ($block =~ /^firstaccess____(.+)$/) { + my $rev = $Apache::lonnet::needsrelease{'course:commblock:timer'}; + if (ref($comm_blocks{$block}) eq 'HASH') { + push(@{$fromblocks{'timer'}{$rev}},&unescape($comm_blocks{$block}{'event'}). + ' '.&mt('set by [_1]', + &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'})))); + } + next; + } elsif ($block =~ /^(\d+)____(\d+)$/) { + my ($start,$end) = ($1,$2); + next if ($end < $now); + } + if (ref($comm_blocks{$block}) eq 'HASH') { + if (ref($comm_blocks{$block}{'blocks'}) eq 'HASH') { + if (ref($comm_blocks{$block}{'blocks'}{'docs'}) eq 'HASH') { + if (keys(%{$comm_blocks{$block}{'blocks'}{'docs'}}) > 0) { + my $rev = $Apache::lonnet::needsrelease{'course:commblock:docs'}; + push(@{$fromblocks{'docs'}{$rev}},&unescape($comm_blocks{$block}{'event'}). + ' '. + &mt('set by [_1]', + &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'})))); + } + } elsif ($comm_blocks{$block}{'blocks'}{'printout'} eq 'on') { + my $rev = $Apache::lonnet::needsrelease{'course:commblock:printout'}; + push(@{$fromblocks{'printout'}{$rev}},&unescape($comm_blocks{$block}{'event'}). + ' '. + &mt('set by [_1]', + &Apache::loncommon::plainname(split(/:/,$comm_blocks{$block}{'setter'})))); + + } + } + } + } + if (keys(%fromblocks)) { + my %lt = ( + docs => 'Content blocking', + printout => 'Printout generation', + timer => 'Timed quiz trigger', + ); + $output .= '

'.&mt('Requirements from exam blocking').'

'. + &Apache::loncommon::start_data_table(). + &Apache::loncommon::start_data_table_header_row(). + ''.&mt('Release').''.&mt('Setting').''. + ''.&mt('Event(s)').''. + &Apache::loncommon::end_data_table_header_row(); + foreach my $type ('docs','printout','timer') { + if (ref($fromblocks{$type}) eq 'HASH') { + foreach my $rev (keys(%{$fromblocks{$type}})) { + my ($major,$minor) = split(/\./,$rev); + ($reqdmajor,$reqdminor) = + &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor,$reqdmajor,$reqdminor); + $output .= &Apache::loncommon::start_data_table_row(). + ''.$rev.''.$lt{$type}.''; + foreach my $event (sort(@{$fromblocks{$type}{$rev}})) { + $output .= $event.'
'; + } + $output =~ s{\Q
\E$}{}; + $output .= ''.&Apache::loncommon::end_data_table_row(); + } + } + } + $output .= &Apache::loncommon::end_data_table().'
'; + } + } + 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'); - - foreach my $res ($navmap->retrieveResources(undef,sub { $_[0]->is_problem() },1,0)) { + my %checkedrev; + 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; @@ -2395,6 +2882,13 @@ sub display_loncaparev_constraints { push(@{$bysubmission{$symb}{$rev}},$what); } $allmaps{$enclosing_map} = 1; + unless ($checkedrev{'anonsurvey'}) { + my ($major,$minor) = split(/\./,$rev); + ($reqdmajor,$reqdminor) = + &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor, + $reqdmajor,$reqdminor); + $checkedrev{'anonsurvey'} = 1; + } } if (exists($randtrysubms{$symb."\0".$part})) { my $rev = $rev_randtry; @@ -2407,12 +2901,27 @@ sub display_loncaparev_constraints { push(@{$bysubmission{$symb}{$rev}},$what); } $allmaps{$enclosing_map} = 1; + unless ($checkedrev{'randomizetry'}) { + my ($major,$minor) = split(/\./,$rev); + ($reqdmajor,$reqdminor) = + &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor, + $reqdmajor,$reqdminor); + $checkedrev{'randomizetry'} = 1; + } } } my %responses = $res->responseTypes(); foreach my $key (keys(%responses)) { - if (exists($checkresponsetypes{$key})) { - push(@{$byresponsetype{$symb}{$checkresponsetypes{$key}}},$key); + if (exists($Apache::lonrelrequtils::checkresponsetypes{$key})) { + my $rev = $Apache::lonrelrequtils::checkresponsetypes{$key}; + unless ($checkedrev{$key}) { + my ($major,$minor) = split(/\./,$rev); + ($reqdmajor,$reqdminor) = + &Apache::lonrelrequtils::update_reqd_loncaparev($major,$minor, + $reqdmajor,$reqdminor); + $checkedrev{$key} = 1; + } + push(@{$byresponsetype{$symb}{$rev}},$key); $allmaps{$enclosing_map} = 1; } } @@ -2430,9 +2939,9 @@ sub display_loncaparev_constraints { } foreach my $map (keys(%allmaps)) { my $mapres = $navmap->getResourceByUrl($map); - my $mapsymb = $mapres->symb(); - $toshow{$mapsymb} = 1; if (ref($mapres)) { + my $mapsymb = $mapres->symb(); + $toshow{$mapsymb} = 1; my $pcslist = $mapres->map_hierarchy(); if ($pcslist ne '') { foreach my $pc (split(/,/,$pcslist)) { @@ -2464,7 +2973,7 @@ sub display_loncaparev_constraints { $r->print($output); if (defined($navmap)) { &show_contents_view($r,$navmap,$cid,\%toshow,\%bymap,\%byresource,\%bysubmission, - \%byresponsetype,\@scopeorder,\%lt); + \%byresponsetype,\%bycrsrestype,\@scopeorder,\%lt); } $r->print('

'); } else { @@ -2473,14 +2982,19 @@ sub display_loncaparev_constraints { '

'); } $r->print(&Apache::loncommon::end_page()); + my ($currmajor,$currminor) = split(/\./,$loncaparev); + if (($currmajor != $reqdmajor) || ($currminor != $reqdminor)) { + return 1; + } return; } sub show_contents_view { my ($r,$navmap,$cid,$toshow,$bymap,$byresource,$bysubmission,$byresponsetype, - $scopeorder,$lt) = @_; + $bycrsrestype,$scopeorder,$lt) = @_; if ((keys(%{$toshow}) > 0) || (keys(%{$byresource}) > 0) || - (keys(%{$bysubmission}) > 0) || (keys(%{$byresponsetype}) > 0)) { + (keys(%{$bysubmission}) > 0) || (keys(%{$byresponsetype}) > 0) || + (keys(%{$bycrsrestype}) > 0)) { my $location=&Apache::loncommon::lonhttpdurl("/adm/lonIcons"); my $whitespace = ''; my $icon = ''; @@ -2544,6 +3058,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').''; @@ -2608,19 +3125,34 @@ 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()); } + return; } sub releases_by_map { my ($r,$bymap,$url,$scopeorder,$lt) = @_; return unless ((ref($bymap) eq 'HASH') && (ref($scopeorder) eq 'ARRAY')); + my $newrow = 0; if (ref($bymap->{$url}) eq 'HASH') { foreach my $rev (sort(keys(%{$bymap->{$url}}))) { + if ($newrow) { + $r->print(&Apache::loncommon::end_data_table_row(). + &Apache::loncommon::continue_data_table_row()); + } $r->print(''.$rev.''); if (ref($bymap->{$url}{$rev}) eq 'HASH') { $r->print(''); @@ -2642,6 +3174,7 @@ sub releases_by_map { $r->print('
'); } $r->print(''); + $newrow = 1; } } else { $r->print(' '); @@ -2650,23 +3183,90 @@ 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; } +sub update_releasereq { + my $readmap = 1; + my $getrelreq = 1; + if (ref($modified_courses) eq 'ARRAY') { + foreach my $item (@{$modified_courses}) { + if (ref($item) eq 'ARRAY') { + my ($cdom,$cnum,$chome,$crstype) = @{$item}; + &Apache::lonrelrequtils::modify_course_relreq(undef,undef,$cnum,$cdom, + $chome,$crstype,$cdom.'_'.$cnum, + $readmap,$getrelreq); + } + } + $modified_courses = []; + } + undef($registered_cleanup); + return; +} + sub show_autocoowners { my (@currcoown) = @_; my $output = ''.&mt('Co-ownership is set automatically when a Course Coordinator role[_1] is assigned to official course personnel (from institutional data).','
').'
'; @@ -2680,13 +3280,20 @@ sub show_autocoowners { } sub coowner_invitations { - my ($cnum,$cdom,@currcoown) = @_; - my ($output,@pendingcoown,@othercoords); + my ($cnum,$cdom,$currcoownref,$noedit) = @_; + my ($output,@pendingcoown,@othercoords,@currcoown); my $pendingcoowners = $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'}; if ($pendingcoowners) { @pendingcoown = split(',',$pendingcoowners); } + if (ref($currcoownref) eq 'ARRAY') { + @currcoown == @{$currcoownref}; + } + my $disabled; + if ($noedit) { + $disabled = ' disabled="disabled"'; + } my $ccrole = 'cc'; my %ccroles = &Apache::lonnet::get_my_roles($cnum,$cdom,undef,undef,[$ccrole]); foreach my $key (sort(keys(%ccroles))) { @@ -2704,7 +3311,7 @@ sub coowner_invitations { ''.&mt('Current co-owners').''; foreach my $person (@currcoown) { my ($co_uname,$co_dom) = split(':',$person); - $output .= ''.(' 'x2).' '; + $output .= ''.(' 'x2).' '; } $output .= ''. &Apache::loncommon::end_data_table_row(); @@ -2714,7 +3321,7 @@ sub coowner_invitations { ''.&mt('Invited as co-owners [_1](agreement pending)','
').'
'; foreach my $person (@pendingcoown) { my ($co_uname,$co_dom) = split(':',$person); - $output .= ''.(' 'x2).' '; + $output .= ''.(' 'x2).' '; } $output .= ''. &Apache::loncommon::end_data_table_row(); @@ -2724,7 +3331,7 @@ sub coowner_invitations { ''.&mt('Invite other Coordinators [_1]to become co-owners','
').'
'; foreach my $person (@othercoords) { my ($co_uname,$co_dom) = split(':',$person); - $output .= ''.(' 'x2).' '; + $output .= ''.(' 'x2).' '; } $output .= ''. &Apache::loncommon::end_data_table_row(); @@ -2737,13 +3344,20 @@ sub coowner_invitations { } sub manage_coownership { - my ($cnum,$cdom,@currcoown) = @_; - my (@pendingcoown); + my ($cnum,$cdom,$currcoownref,$noedit) = @_; + my (@pendingcoown,@currcoown); my $pendingcoowners = $env{'course.'.$env{'request.course.id'}.'.internal.pendingco-owners'}; if ($pendingcoowners) { @pendingcoown = split(',',$pendingcoowners); } + if (ref($currcoownref) eq 'ARRAY') { + @currcoown == @{$currcoownref}; + } + my $disabled; + if ($noedit) { + $disabled = ' disabled="disabled"'; + } my ($is_coowner,$is_pending,$output); my $uname = $env{'user.name'}; my $udom = $env{'user.domain'}; @@ -2775,8 +3389,8 @@ sub manage_coownership { if ($is_coowner) { $output .= &mt('You are currently a co-owner:').' '; } else { - $output .= &mt('The course owner has invited you to become a co-owner:').' '.(' 'x2). - ''; + $output .= &mt('The course owner has invited you to become a co-owner:').' '.(' 'x2). + ''; } $output .= '
'; if (@currcoown) { @@ -2790,7 +3404,7 @@ sub manage_coownership { } sub print_localization { - my ($cdom,$settings,$ordered,$itemtext,$rowtotal) = @_; + my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_; unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) { return; } @@ -2809,8 +3423,11 @@ sub print_localization { input => 'selectbox', }, ); - my $datatable; + my ($datatable,$disabled); my $count = 0; + if ($noedit) { + $disabled = ' disabled="disabled"'; + } foreach my $item (@{$ordered}) { $count ++; my $colspan; @@ -2823,7 +3440,7 @@ sub print_localization { my $timezone = &Apache::lonlocal::gettimezone(); $datatable .= &Apache::loncommon::select_timezone($item,$timezone,undef, - $includeempty); + $includeempty,$disabled); } elsif ($item eq 'datelocale') { my $includeempty = 1; my $locale_obj = &Apache::lonlocal::getdatelocale(); @@ -2833,11 +3450,13 @@ sub print_localization { } $datatable .= &Apache::loncommon::select_datelocale($item,$currdatelocale, - undef,$includeempty); + undef,$includeempty,$disabled); } else { if ($settings->{$item} eq '') { - $datatable .= ''. - &Apache::loncommon::select_language('languages_0','',1); + unless ($noedit) { + $datatable .= ''. + &Apache::loncommon::select_language('languages_0','',1); + } } else { my $num = 0; my @languages = split(/\s*[,;:]\s*/,$settings->{$item}); @@ -2857,19 +3476,22 @@ sub print_localization { '
'. ''. &Apache::loncommon::end_data_table_row(); $num ++; } } - $datatable .= &Apache::loncommon::start_data_table_row(). + unless ($noedit) { + $datatable .= + &Apache::loncommon::start_data_table_row(). ''. &mt('Additional language:'). '
'. &Apache::loncommon::select_language('languages_'.$num,'',1). ''. - ''.&Apache::loncommon::end_data_table_row(). - &Apache::loncommon::end_data_table().'
'; + ''.&Apache::loncommon::end_data_table_row(); + } + $datatable .= &Apache::loncommon::end_data_table().'
'; } } $datatable .= &item_table_row_end(); @@ -2890,7 +3512,7 @@ sub get_lang_choices { } sub print_feedback { - my ($position,$cdom,$settings,$ordered,$itemtext,$rowtotal) = @_; + my ($position,$cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_; unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) { return; } @@ -2925,7 +3547,10 @@ sub print_feedback { del => 'Delete?', sec => 'Sections:', ); - + my $disabled; + if ($noedit) { + $disabled = ' disabled="disabled"'; + } foreach my $item (@{$ordered}) { $count ++; if ($position eq 'top') { @@ -2935,12 +3560,12 @@ sub print_feedback { } if ($position eq 'top') { my $includeempty = 0; - $datatable .= ''. - &user_table($cdom,$item,\@sections, - $settings->{$item},\%lt); + $datatable .= ''. + &user_table($cdom,$item,\@sections, + $settings->{$item},\%lt,$noedit); } else { $datatable .= &Apache::lonhtmlcommon::textbox($item.'.text', - $settings->{$item.'.text'},$items{$item}{size}); + $settings->{$item.'.text'},$items{$item}{size},$disabled); } $datatable .= &item_table_row_end(); } @@ -2949,15 +3574,21 @@ sub print_feedback { } sub user_table { - my ($cdom,$item,$sections,$currvalue,$lt) = @_; + my ($cdom,$item,$sections,$currvalue,$lt,$noedit) = @_; my $output; if ($currvalue eq '') { - $output .= &select_recipient($item,'0',$cdom,$sections); + unless ($noedit) { + $output .= &select_recipient($item,'0',$cdom,$sections); + } } else { my $num = 0; my @curr = split(/,/,$currvalue); $output .= ''; my ($currusers); + my $disabled; + if ($noedit) { + $disabled = ' disabled="disabled"'; + } foreach my $val (@curr) { next if ($val eq ''); my ($uname,$udom,$seclist) = ($val =~ /^($match_username):($match_domain)(\(?[^\)]*\)?)$/); @@ -2969,7 +3600,7 @@ sub user_table { $currusers .= ''. ''; @@ -2998,12 +3629,16 @@ sub user_table { '
'. ''. ''.(' 'x2). @@ -2980,7 +3611,7 @@ sub user_table { if (@{$sections}) { $currusers.= (' 'x3).$lt->{'sec'}.' '. &select_sections($item,$num,$sections, - \@selsec); + \@selsec,$noedit); } } $currusers .= '
'.$currusers.'
'. ''; } - $output .= ''. + unless ($noedit) { + $output .= + ''. ''. $lt->{'add'}.'
'. &select_recipient($item,$num,$cdom,$sections). ''. - ''; + ''; + } + $output .= ''; } return $output; } @@ -3030,14 +3665,17 @@ sub select_recipient { } sub select_sections { - my ($item,$num,$sections,$selected) = @_; - my ($output,@currsecs,$allsec); + my ($item,$num,$sections,$selected,$noedit) = @_; + my ($output,@currsecs,$allsec,$disabled); if (ref($selected) eq 'ARRAY') { @currsecs = @{$selected}; } if (!@currsecs) { $allsec = ' selected="selected"'; } + if ($noedit) { + $disabled = ' disabled="disabled"'; + } if (ref($sections) eq 'ARRAY') { if (@{$sections}) { my $mult; @@ -3047,7 +3685,7 @@ sub select_sections { $mult .= ' size="4"'; } } - $output = ''. ' '; foreach my $sec (@{$sections}) { my $is_sel; @@ -3063,7 +3701,7 @@ sub select_sections { } sub print_discussion { - my ($cdom,$settings,$ordered,$itemtext,$rowtotal) = @_; + my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$noedit) = @_; unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) { return; } @@ -3093,6 +3731,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', @@ -3125,26 +3777,34 @@ 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 .= ''. - ''.&role_checkboxes($cdom,$cnum,$item,$settings). + '
'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit). '
'; } elsif ($item eq 'plc.users.denied') { - $datatable .= ''. - &user_table($cdom,$item,undef, - $settings->{$item},\%lt); + $datatable .= ''. + &user_table($cdom,$item,undef, + $settings->{$item},\%lt,$noedit); } elsif ($item eq 'pch.roles.denied') { $datatable .= ''. - ''.&role_checkboxes($cdom,$cnum,$item,$settings). + '
'.&role_checkboxes($cdom,$cnum,$item,$settings,undef,undef,$noedit). '
'; } elsif ($item eq 'pch.users.denied') { $datatable .= ''. &user_table($cdom,$item,undef, - $settings->{$item},\%lt); + $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); + $datatable .= &yesno_radio($item,$settings,undef,undef,undef,$noedit); } elsif ($item eq 'allow_discussion_post_editing') { $datatable .= '
'. &Apache::loncommon::start_data_table(). @@ -3152,7 +3812,7 @@ sub print_discussion { ''.&mt('Role').''. &mt('Sections').''. &Apache::loncommon::end_data_table_row(). - &role_checkboxes($cdom,$cnum,$item,$settings,1). + &role_checkboxes($cdom,$cnum,$item,$settings,1,undef,$noedit). &Apache::loncommon::end_data_table().'
'; } elsif ($item eq 'discussion_post_fonts') { $datatable .= '
'. @@ -3162,9 +3822,9 @@ 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). + &set_discussion_fonts($cdom,$cnum,$item,$settings,$noedit). &Apache::loncommon::end_data_table().'
'; } $datatable .= &item_table_row_end(); @@ -3174,7 +3834,7 @@ sub print_discussion { } sub role_checkboxes { - my ($cdom,$cnum,$item,$settings,$showsections,$crstype) = @_; + my ($cdom,$cnum,$item,$settings,$showsections,$crstype,$noedit) = @_; my @roles = ('st','ad','ta','ep','in'); if ($crstype eq 'Community') { push(@roles,'co'); @@ -3212,6 +3872,10 @@ sub role_checkboxes { } my $numinrow = 3; my $count = 0; + my $disabled; + if ($noedit) { + $disabled = ' disabled="disabled"'; + } foreach my $role (@roles) { my $checked = ''; if (grep(/^\Q$role\E$/,@current)) { @@ -3230,11 +3894,11 @@ sub role_checkboxes { } } $output .= ''; if ($showsections) { $output .= ''. - &select_sections($item,$role,\@sections,$currsec{$role}). + &select_sections($item,$role,\@sections,$currsec{$role},$noedit). ''; } $count ++; @@ -3262,11 +3926,11 @@ sub role_checkboxes { } } $output .= ''; if ($showsections) { $output .= ''. - &select_sections($item,$role,\@sections,$currsec{$role}). + &select_sections($item,$role,\@sections,$currsec{$role},$noedit). ''.&Apache::loncommon::end_data_table_row(); } $total ++; @@ -3288,11 +3952,15 @@ sub role_checkboxes { } sub set_discussion_fonts { - my ($cdom,$cnum,$item,$settings) = @_; + my ($cdom,$cnum,$item,$settings,$noedit) = @_; my ($classorder,$classtitles) = &discussion_vote_classes(); my ($styleorder,$styleitems) = &discussion_vote_styles(); my $output; if (ref($classorder) eq 'ARRAY') { + my $disabled; + if ($noedit) { + $disabled = ' disabled="disabled"'; + } foreach my $cat (@{$classorder}) { my %curr = (); ($curr{'size'},$curr{'weight'},$curr{'style'},$curr{'other'}) = @@ -3309,12 +3977,12 @@ sub set_discussion_fonts { ($currsize,$currunit) = ($1,$2); $curr{'size'} = $currunit; } - $output .= ''. + $output .= ''. ' '; $selitem = 'unit'; } if ((ref($styleitems) eq 'HASH') && (ref($styleitems->{$item}) eq 'ARRAY')) { - $output .= ''; foreach my $val (@{$styleitems->{$item}}) { my $sel; if ($val eq $curr{$item}) { @@ -3325,7 +3993,7 @@ sub set_discussion_fonts { } } } - $output .= '
'; + $output .= ''; } $output .= &Apache::loncommon::end_data_table_row(); } @@ -3334,7 +4002,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', @@ -3357,7 +4025,7 @@ sub discussion_vote_styles { } sub print_classlists { - my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype) = @_; + my ($position,$cdom,$settings,$itemtext,$rowtotal,$crstype,$noedit) = @_; my @ordered; if ($position eq 'top') { @ordered = ('default_enrollment_start_date', @@ -3400,7 +4068,7 @@ sub print_classlists { 'defaultcredits' => { text => ''.&mt($itemtext->{'defaultcredits'}).'', }, - + 'nothideprivileged' => { text => ''.&mt($itemtext->{'nothideprivileged'}).'', input => 'checkbox', @@ -3431,11 +4099,11 @@ sub print_classlists { ($settings->{'student_classlist_view'} eq 'section')) { $settings->{'student_classlist_view'} = 'disabled'; } - return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'classlists'); + return &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'classlists',$noedit); } sub print_appearance { - my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_; + my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_; unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) { return; } @@ -3467,11 +4135,11 @@ sub print_appearance { text => ''.&mt($itemtext->{'texengine'}).'', input => 'selectbox', options => { - jsMath => 'jsMath', + MathJax => 'MathJax', mimetex => &mt('Convert to Images'), tth => &mt('TeX to HTML'), }, - order => ['jsMath','mimetex','tth'], + order => ['MathJax','mimetex','tth'], nullval => $mathdef, }, 'tthoptions' => { @@ -3479,12 +4147,20 @@ sub print_appearance { input => 'textbox', size => 40, }, + 'uselcmath' => { + text => ''.&mt($itemtext->{'uselcmath'}).'', + input => 'radio', + }, + 'usejsme' => { + text => ''.&mt($itemtext->{'usejsme'}).'', + input => 'radio', + }, ); - return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'appearance'); + return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'appearance',$noedit); } sub print_grading { - my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_; + my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_; unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) { return; } @@ -3495,11 +4171,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'}).''. @@ -3535,11 +4212,11 @@ sub print_grading { input => 'radio', }, ); - return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'grading'); + return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'grading',$noedit); } sub print_printouts { - my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_; + my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_; unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) { return; } @@ -3588,11 +4265,11 @@ sub print_printouts { nullval => &mt('None specified - use domain default'), } ); - return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'printouts'); + return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'printouts',$noedit); } sub print_spreadsheet { - my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_; + my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_; unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) { return; } @@ -3624,11 +4301,11 @@ sub print_spreadsheet { input => 'radio', }, ); - return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'spreadsheet'); + return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'spreadsheet',$noedit); } sub print_bridgetasks { - my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype) = @_; + my ($cdom,$settings,$ordered,$itemtext,$rowtotal,$crstype,$noedit) = @_; unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) { return; } @@ -3666,11 +4343,11 @@ sub print_bridgetasks { input => 'radio', }, ); - return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'bridgetasks'); + return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'bridgetasks',$noedit); } sub print_other { - my ($cdom,$settings,$allitems,$rowtotal,$crstype) = @_; + my ($cdom,$settings,$allitems,$rowtotal,$crstype,$noedit) = @_; unless ((ref($settings) eq 'HASH') && (ref($allitems) eq 'ARRAY')) { return; } @@ -3691,7 +4368,7 @@ sub print_other { input => 'textbox', size => '30', }; - my $output = &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'other'); + my $output = &make_item_rows($cdom,\%items,\@ordered,$settings,$rowtotal,$crstype,'other',$noedit); } sub get_other_items { @@ -3709,7 +4386,9 @@ sub get_other_items { ($parameter =~ m/^selfenroll_/) || ($parameter =~ /_selfenroll$/) || ($parameter eq 'type') || ($parameter =~ m/^(cc|co|in|ta|ep|ad|st)\.plaintext$/) - || ($parameter =~ m/^discussion_post_fonts/)) { + || ($parameter =~ m/^discussion_post_fonts/) || + ($parameter =~ m{^(minimal|updated|uploaded|external)syllabus$}) || + ($parameter eq 'clonedfrom')) { push(@ordered,$parameter); } } @@ -3738,25 +4417,43 @@ sub item_table_row_end { } sub yesno_radio { - my ($item,$settings) = @_; + my ($item,$settings,$unsetdefault,$valueyes,$valueno,$noedit) = @_; my $itemon = ' '; my $itemoff = ' checked="checked" '; + if (($valueyes eq '') && ($valueno eq '')) { + $valueyes = 'yes'; + $valueno = ''; + } if (ref($settings) eq 'HASH') { - if ($settings->{$item} eq 'yes') { + if ($settings->{$item} eq $valueyes) { $itemon = $itemoff; $itemoff = ' '; } + unless (exists($settings->{$item})) { + if ($unsetdefault eq $valueyes) { + $itemon = $itemoff; + $itemoff = ' '; + } + } + } + my $disabled; + if ($noedit) { + $disabled = ' disabled="disabled"'; } return ' '. + $itemon.' value="'.$valueyes.'"'.$disabled.' />'.&mt('Yes').' '. ''; + $itemoff.' value="'.$valueno.'"'.$disabled.' />'.&mt('No').''; } sub select_from_options { - my ($item,$order,$options,$curr,$nullval,$multiple,$maxsize,$onchange) = @_; + my ($item,$order,$options,$curr,$nullval,$multiple,$maxsize,$onchange,$noedit) = @_; my $output; + my $disabled; + if ($noedit) { + $disabled = ' disabled=disabled"'; + } if ((ref($order) eq 'ARRAY') && (ref($options) eq 'HASH')) { $output=''.&mt('Hidden').' '. - ''. + $hideon.' value=""'.$disabled.' />'.&mt('Hidden').' '. + ''. ''; } $datatable .= ''; @@ -3927,7 +4648,7 @@ sub nothidepriv_row { } sub checkforpriv_row { - my ($cdom,$item,$settings,$crstype) = @_; + my ($cdom,$item,$settings,$crstype,$noedit) = @_; my $datatable; my %domains=map { $_ => 1; } &Apache::lonnet::all_domains(); if (keys(%domains) == 1) { @@ -3940,19 +4661,24 @@ sub checkforpriv_row { if ($settings->{$item} eq '') { $datatable = ''. &Apache::loncommon::select_dom_form('','checkforpriv_'.$num, - 1,1,undef,undef,\@excdoms); + 1,1,undef,undef,\@excdoms, + $noedit); } else { my @privdoms = split(/,/,$settings->{$item}); my %domains=map { $_ => 1; } &Apache::lonnet::all_domains(); $datatable = '
'. &Apache::loncommon::start_data_table(); + my $disabled; + if ($noedit) { + $disabled = ' disabled="disabled"'; + } if (@privdoms > 0) { foreach my $currdom (@privdoms) { next unless ($domains{$currdom}); my $domdesc = &Apache::lonnet::domain($currdom,'description'); if ($domdesc eq '') { $domdesc = $currdom; - } + } $datatable .= &Apache::loncommon::start_data_table_row(). ''. @@ -3960,22 +4686,22 @@ sub checkforpriv_row { '
'. ''. &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:'). '
'. &Apache::loncommon::select_dom_form('','checkforpriv_'.$num,1, - 1,undef,undef,\@excdoms). + 1,undef,undef,\@excdoms,$noedit). ''.&Apache::loncommon::end_data_table_row(); } $datatable .= &Apache::loncommon::end_data_table(). @@ -3986,7 +4712,7 @@ sub checkforpriv_row { } sub print_hdrfmt_row { - my ($item,$settings) = @_; + my ($item,$settings,$noedit) = @_; my @curr; my $currnum = 0; my $maxnum = 2; @@ -4059,36 +4785,43 @@ function getIndexByName(item) { ENDJS $output .= '
'. $currstr.''; + my $disabled; + if ($noedit) { + $disabled = ' disabled="disabled"'; + } if (@curr > 0) { for (my $i=0; $i<@curr; $i++) { my $pos = $i+1; $output .= ''. ''; + '"'.$disabled.' />'; if ($curr[$i] =~ /^%\d*[nca]$/) { my ($limit,$subst) = ($curr[$i] =~ /^%(\d*)([nca])$/); $output .= ''; + &substitution_selector($i,$subst,$limit,$disabled).''; } else { $output .= ''; + ' value="'.$curr[$i].'" size="25"'.$disabled.' />'; } $output .= ''; } } - my $pos = $currnum+1; - $output .= ''. + my $pos = $currnum+1; + unless ($noedit) { + $output .= + ''. ''. ''; - $pos ++; - $currnum ++; - $output .= ''. + $pos ++; + $currnum ++; + $output .= + ''. ''. @@ -4097,14 +4830,15 @@ ENDJS '" value="" size ="25" />'. ''. - ''. - '
'. - &position_selector($pos,$i,$maxnum).&mt('Delete:'). + &position_selector($pos,$i,$maxnum,$disabled).&mt('Delete:'). ''. - &substitution_selector($i,$subst,$limit).''.&mt('Text').'
'. '
'. &position_selector($pos,$currnum,$maxnum). ''.&mt('New').''. &substitution_selector($currnum).'
'. &position_selector($pos,$currnum,$maxnum). ''.&mt('New').'

'; + ''; + } + $output .= '
'; return $output; } sub position_selector { - my ($pos,$num,$maxnum) = @_; - my $output = ''; for (my $j=1; $j<=$maxnum; $j++) { my $sel = ''; if ($pos == $j) { @@ -4118,7 +4852,7 @@ sub position_selector { } sub substitution_selector { - my ($num,$subst,$limit,$crstype) = @_; + my ($num,$subst,$limit,$crstype,$disabled) = @_; my ($stunametxt,$crsidtxt); if ($crstype eq 'Community') { $stunametxt = 'member name'; @@ -4133,7 +4867,7 @@ sub substitution_selector { a => 'assignment note', ); my $output .= &mt('Substitution').'
'. - ''; if ($subst eq '') { $output .= ''; } @@ -4147,7 +4881,7 @@ sub substitution_selector { } $output .= ''.&mt('Size limit').'
'. ''; + '" value="'.$limit.'" size="5"'.$disabled.' />'; return $output; } @@ -4165,17 +4899,19 @@ sub change_clone { foreach my $currclone (@allowclone) { if (!grep(/^$currclone$/,@$oldcloner)) { if ($currclone ne '*') { - my ($uname,$udom) = split(/:/,$currclone); - if ($uname && $udom && $uname ne '*') { - if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') { - my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable'); - if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) { - if ($currclonecrs{'cloneable'} eq '') { - $currclonecrs{'cloneable'} = $clone_crs; - } else { - $currclonecrs{'cloneable'} .= ','.$clone_crs; + if ($currclone =~ /:/) { + my ($uname,$udom) = split(/:/,$currclone); + if ($uname && $udom && $uname ne '*') { + if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') { + my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable'); + if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) { + if ($currclonecrs{'cloneable'} eq '') { + $currclonecrs{'cloneable'} = $clone_crs; + } else { + $currclonecrs{'cloneable'} .= ','.$clone_crs; + } + &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname); } - &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname); } } } @@ -4185,24 +4921,26 @@ sub change_clone { foreach my $oldclone (@$oldcloner) { if (!grep(/^\Q$oldclone\E$/,@allowclone)) { if ($oldclone ne '*') { - my ($uname,$udom) = split(/:/,$oldclone); - if ($uname && $udom && $uname ne '*' ) { - if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') { - my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable'); - my %newclonecrs = (); - if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) { - if ($currclonecrs{'cloneable'} =~ /,/) { - my @currclonecrs = split/,/,$currclonecrs{'cloneable'}; - foreach my $crs (@currclonecrs) { - if ($crs ne $clone_crs) { - $newclonecrs{'cloneable'} .= $crs.','; + if ($oldclone =~ /:/) { + my ($uname,$udom) = split(/:/,$oldclone); + if ($uname && $udom && $uname ne '*' ) { + if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') { + my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable'); + my %newclonecrs = (); + if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) { + if ($currclonecrs{'cloneable'} =~ /,/) { + my @currclonecrs = split/,/,$currclonecrs{'cloneable'}; + foreach my $crs (@currclonecrs) { + if ($crs ne $clone_crs) { + $newclonecrs{'cloneable'} .= $crs.','; + } } + $newclonecrs{'cloneable'} =~ s/,$//; + } else { + $newclonecrs{'cloneable'} = ''; } - $newclonecrs{'cloneable'} =~ s/,$//; - } else { - $newclonecrs{'cloneable'} = ''; + &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname); } - &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname); } } }