--- loncom/interface/courseprefs.pm 2013/11/24 16:00:53 1.62 +++ loncom/interface/courseprefs.pm 2016/10/24 17:20:19 1.81 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set configuration settings for a course # -# $Id: courseprefs.pm,v 1.62 2013/11/24 16:00:53 raeburn Exp $ +# $Id: courseprefs.pm,v 1.81 2016/10/24 17:20:19 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,6 +308,7 @@ sub handler { edit => 'Edit Course Settings', gens => 'General course settings', idnu => 'Course ID or number', + unco => 'Unique code', desc => 'Course Description', cred => 'Student credits', ownr => 'Course Owner', @@ -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,13 +374,15 @@ 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'}, @@ -371,6 +390,7 @@ sub handler { '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' => @@ -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 = '
'.&mt('Or').
@@ -1942,7 +2181,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) {
@@ -1963,7 +2208,7 @@ sub print_courseinfo {
' '. ' | '.
&Apache::loncommon::end_data_table_row();
$num ++;
@@ -1986,7 +2231,8 @@ sub print_courseinfo {
''.
$add_domtitle.' '. &Apache::loncommon::select_dom_form('','cloners_newdom', - $includeempty). + $includeempty,undef,undef, + undef,undef,$noedit). ''. ' | '.&Apache::loncommon::end_data_table_row().
&Apache::loncommon::end_data_table().
@@ -1998,9 +2244,40 @@ sub print_courseinfo {
&mt('Specific users').' ('.
&mt('user:domain,user:domain').')
'.&mt('And'). + ' |
'. ''. ''.(' 'x2). @@ -3023,7 +3587,7 @@ sub user_table { if (@{$sections}) { $currusers.= (' 'x3).$lt->{'sec'}.' '. &select_sections($item,$num,$sections, - \@selsec); + \@selsec,$noedit); } } $currusers .= ' |