--- loncom/interface/courseprefs.pm 2016/10/24 18:10:08 1.49.2.21
+++ loncom/interface/courseprefs.pm 2024/07/06 16:43:10 1.49.2.31
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set configuration settings for a course
#
-# $Id: courseprefs.pm,v 1.49.2.21 2016/10/24 18:10:08 raeburn Exp $
+# $Id: courseprefs.pm,v 1.49.2.31 2024/07/06 16:43:10 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -375,7 +375,7 @@ sub handler {
help => 'Course_Prefs_General',
ordered => ['owner','co-owners','loncaparev','description',
'clonedfrom','courseid','uniquecode','categories',
- 'hidefromcat','externalsyllabus','cloners','url',
+ 'hidefromcat','syllabus','cloners','url',
'rolenames'],
itemtext => {
'owner' => $lt{'ownr'},
@@ -386,7 +386,7 @@ sub handler {
'categories' => $lt{'catg'},
'hidefromcat' => $lt{'excc'},
'cloners' => $lt{'clon'},
- 'externalsyllabus' => 'Syllabus status',
+ 'syllabus' => 'Syllabus status',
'url' => 'Top Level Map',
'rolenames' => $lt{'rept'},
'loncaparev' => $lt{'lcrv'},
@@ -464,7 +464,7 @@ sub handler {
help => 'Course_Prefs_Display',
ordered => ['default_xml_style','pageseparators',
'disable_receipt_display','texengine',
- 'tthoptions','uselcmath','usejsme'],
+ 'tthoptions','uselcmath','usejsme','inline_chem'],
itemtext => {
default_xml_style => 'Default XML style file',
pageseparators => 'Visibly Separate Items on Pages',
@@ -473,6 +473,7 @@ sub handler {
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)',
+ inline_chem => 'Chemical reaction response uses inline preview, not pop-up',
},
},
'grading' =>
@@ -542,10 +543,16 @@ sub handler {
$cnum,undef,\@allitems,
'coursepref',$parm_permission);
} elsif (($phase eq 'display') && ($parm_permission->{'display'})) {
- my $jscript = &get_jscript($cid,$cdom,$phase,$crstype,\%values);
+ my $noedit;
+ if (ref($parm_permission) eq 'HASH') {
+ unless ($parm_permission->{'process'}) {
+ $noedit = 1;
+ }
+ }
+ my $jscript = &get_jscript($cid,$cdom,$phase,$crstype,\%values,$noedit);
my @allitems = &get_allitems(%prefs);
&Apache::lonconfigsettings::display_settings($r,$cdom,$phase,$context,
- \@prefs_order,\%prefs,\%values,undef,$jscript,\@allitems,$crstype,
+ \@prefs_order,\%prefs,\%values,$cnum,$jscript,\@allitems,$crstype,
'coursepref',$parm_permission);
} else {
&Apache::lonconfigsettings::display_choices($r,$phase,$context,
@@ -598,7 +605,7 @@ sub get_allitems {
}
sub print_config_box {
- my ($r,$cdom,$phase,$action,$item,$settings,$allitems,$crstype,$parm_permission) = @_;
+ my ($r,$cdom,$cnum,$phase,$action,$item,$settings,$allitems,$crstype,$parm_permission) = @_;
my $ordered = $item->{'ordered'};
my $itemtext = $item->{'itemtext'};
my $noedit;
@@ -715,7 +722,7 @@ sub print_config_box {
} elsif ($action eq 'appearance') {
$output .= &print_appearance($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
} elsif ($action eq 'grading') {
- $output .= &print_grading($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
+ $output .= &print_grading($cdom,$cnum,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
} elsif ($action eq 'printouts') {
$output .= &print_printouts($cdom,$settings,$ordered,$itemtext,\$rowtotal,$crstype,$noedit);
} elsif ($action eq 'spreadsheet') {
@@ -763,7 +770,8 @@ sub process_changes {
(!$can_categorize));
next if (($entry eq 'loncaparev') ||
($entry eq 'owner') ||
- ($entry eq 'clonedfrom'));
+ ($entry eq 'clonedfrom') ||
+ ($entry eq 'syllabus'));
push(@ordered,$entry);
}
} elsif ($action eq 'classlists') {
@@ -942,7 +950,9 @@ sub process_changes {
$autocoowner = $domconf{'autoenroll'}{'co-owners'};
}
}
- unless ($autocoowner) {
+ if ($autocoowner) {
+ $newvalues{'co-owners'} = $values->{'internal.co-owners'};
+ } else {
my @keepcoowners = &Apache::loncommon::get_env_multiple('form.coowners');
my @pendingcoowners = &Apache::loncommon::get_env_multiple('form.pendingcoowners');
my @invitecoowners = &Apache::loncommon::get_env_multiple('form.invitecoowners');
@@ -966,19 +976,19 @@ sub process_changes {
my $udom = $env{'user.domain'};
my $pendingcoowners = $values->{'internal.pendingco-owners'};
my @pendingcoown = split(',',$pendingcoowners);
- if ($env{'form.pending_coowoner'}) {
+ if ($env{'form.pending_coowner'}) {
foreach my $item (@pendingcoown) {
unless ($item eq $uname.':'.$udom) {
push(@newpending,$item);
}
}
@newcoown = @currcoown;
- if ($env{'form.pending_coowoner'} eq 'accept') {
+ if ($env{'form.pending_coowner'} eq 'accept') {
unless (grep(/^\Q$uname\E:\Q$udom\E$/,@currcoown)) {
push(@newcoown,$uname.':'.$udom);
}
}
- } elsif ($env{'form.remove_coowoner'}) {
+ } elsif ($env{'form.remove_coowner'}) {
foreach my $item (@currcoown) {
unless ($item eq $uname.':'.$udom) {
push(@newcoown,$item);
@@ -987,6 +997,8 @@ sub process_changes {
if ($pendingcoowners ne '') {
@newpending = @pendingcoown;
}
+ } else {
+ @newcoown = @currcoown;
}
$newvalues{'pendingco-owners'} = join(',',sort(@newpending));
$newvalues{'co-owners'} = join(',',sort(@newcoown));
@@ -1252,6 +1264,33 @@ sub process_changes {
$settings =~ s/,$//;
}
$newvalues{$entry} = $settings;
+ } elsif ($entry eq 'grading') {
+ if ($env{'form.'.$entry} eq 'standard') {
+ if ($env{'form.hidetotals'}) {
+ my %sections = &Apache::loncommon::get_sections($cdom,$cnum);
+ if (keys(%sections)) {
+ my @secs = &Apache::loncommon::get_env_multiple('form.hidetotals_sections');
+ if (grep(/^all$/,@secs)) {
+ $newvalues{'hidetotals'} = 'all';
+ } elsif (@secs) {
+ $newvalues{'hidetotals'} = '';
+ foreach my $sec (sort {$a <=> $b} @secs) {
+ if (exists($sections{$sec})) {
+ $newvalues{'hidetotals'} .= $sec.','
+ }
+ }
+ $newvalues{'hidetotals'} =~ s/,$//;
+ }
+ } else {
+ $newvalues{'hidetotals'} = 'all';
+ }
+ }
+ }
+ if ($newvalues{'hidetotals'} ne $values->{'hidetotals'}) {
+ $changes->{'hidetotals'} = $newvalues{'hidetotals'};
+ $changes->{'grading'} = $env{'form.'.$entry};
+ }
+ $newvalues{$entry} = $env{'form.'.$entry};
} else {
$newvalues{$entry} = $env{'form.'.$entry};
}
@@ -1385,6 +1424,40 @@ sub store_changes {
unless (($key eq 'co-owners') || ($key eq 'discussion_post_fonts')) {
$displayval = $changes->{$item}{$key};
}
+ if (($item eq 'grading') && ($key eq 'grading')) {
+ if ($displayval eq 'standard') {
+ my $hidetotals;
+ if (exists($changes->{$item}{'hidetotals'})) {
+ if ($changes->{$item}{'hidetotals'} eq '') {
+ if (exists($values->{'hidetotals'})) {
+ push(@delkeys,'hidetotals');
+ }
+ } else {
+ $hidetotals = $changes->{$item}{'hidetotals'};
+ }
+ } elsif (exists($values->{'hidetotals'})) {
+ $hidetotals = $values->{'hidetotals'};
+ }
+ if ($hidetotals eq '') {
+ $displayval = &mt('standard with "hide course totals" set to "No"');
+ if (exists($values->{'hidetotals'})) {
+ push(@delkeys,'hidetotals');
+ }
+ } elsif ($hidetotals =~ /^([\w,]+)$/) {
+ my $secstr = $1;
+ my @secs = split(/,/,$secstr);
+ if (grep(/^all$/,@secs)) {
+ $displayval = &mt('standard with "hide course totals" set to "Yes" for all users');
+ $hidetotals = 'all';
+ } else {
+ $displayval = &mt('standard with "hide course totals" set to "Yes" for users in section(s): [_1]',join(', ',@secs));
+ }
+ $storehash{'hidetotals'} = $hidetotals;
+ }
+ } elsif (exists($values->{'hidetotals'})) {
+ push(@delkeys,'hidetotals');
+ }
+ }
if ($item eq 'feedback') {
if ($key =~ /^(question|policy|comment)(\.email)\.text$/) {
$text = $prefs->{$item}->{'itemtext'}{$1.$2};
@@ -1474,7 +1547,8 @@ sub store_changes {
$displayval = &Apache::lonlocal::locallocaltime($displayval);
} elsif ($key eq 'categories') {
$displayval = $env{'form.categories_display'};
- } elsif (($key eq 'canuse_pdfforms') || ($key eq 'usejsme') || ($key eq 'uselcmath')) {
+ } elsif (($key eq 'canuse_pdfforms') || ($key eq 'usejsme') ||
+ ($key eq 'uselcmath') || ($key eq 'inline_chem')) {
if ($changes->{$item}{$key} eq '1') {
$displayval = &mt('Yes');
} elsif ($changes->{$item}{$key} eq '0') {
@@ -1506,12 +1580,12 @@ sub store_changes {
}
}
unless (&Apache::lonnet::is_course_owner($cdom,$cnum)) {
- if ($env{'form.pending_coowoner'} eq 'accept') {
+ if ($env{'form.pending_coowner'} eq 'accept') {
$displayval = &mt('on');
- } elsif ($env{'form.pending_coowoner'} eq 'decline') {
+ } elsif ($env{'form.pending_coowner'} eq 'decline') {
$displayval = '';
$output .= '
'.&Apache::lonhtmlcommon::confirm_success(&mt('Invitation to be co-owner declined')).'';
- } elsif ($env{'form.remove_coowoner'}) {
+ } elsif ($env{'form.remove_coowner'}) {
$displayval = &mt('off');
}
if ($displayval) {
@@ -1751,7 +1825,7 @@ sub get_course {
}
sub get_jscript {
- my ($cid,$cdom,$phase,$crstype,$settings) = @_;
+ 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);
my $stubrowse_js = &Apache::loncommon::studentbrowser_javascript();
@@ -1877,11 +1951,56 @@ function syllabusinfo() {
}
}
ENDSCRIPT
+ my $grading_js;
+ unless ($noedit) {
+ $grading_js = <<"ENDSCRIPT";
+function toggleGrading(form) {
+ if (document.getElementById('hidetotalsdiv')) {
+ var totalsdivid = document.getElementById('hidetotalsdiv');
+ var selname = form.elements['grading'];
+ if (selname) {
+ var current = selname.options[selname.selectedIndex].value
+ if (current == 'standard') {
+ totalsdivid.style.display = 'inline-block';
+ } else {
+ totalsdivid.style.display = 'none';
+ }
+ }
+ }
+ return;
+}
+
+function toggleHiddenTotalsSec(form) {
+ if (document.getElementById('sectotalsdiv')) {
+ var sectotalsdivid = document.getElementById('sectotalsdiv');
+ var radioname = form.elements['hidetotals'];
+ if (radioname) {
+ if (radioname.length > 0) {
+ var setvis;
+ for (var i=0; i'."\n".
'// '."\n".
+ $syllabus_js."\n".$grading_js."\n".'//]]>'."\n".
''."\n".$stubrowse_js."\n";
return $jscript;
}
@@ -1973,7 +2092,10 @@ sub print_courseinfo {
unless ((ref($settings) eq 'HASH') && (ref($ordered) eq 'ARRAY') && (ref($itemtext) eq 'HASH')) {
return;
}
- my ($cathash,$categoriesform,$autocoowner,$clonedefaults);
+ my ($cathash,$categoriesform,$autocoowner,$clonedefaults,$disabled);
+ if ($noedit) {
+ $disabled = ' disabled="disabled"';
+ }
my %domconf =
&Apache::lonnet::get_dom('configuration',
['coursecategories','autoenroll','coursedefaults'],$cdom);
@@ -1982,7 +2104,7 @@ sub print_courseinfo {
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') {
@@ -2049,14 +2171,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
@@ -2098,11 +2226,10 @@ sub print_courseinfo {
size => '20',
advanced => 1
},
- 'externalsyllabus' => {
- text => ''.&mt($itemtext->{'externalsyllabus'}).'
'.
+ 'syllabus' => {
+ text => ''.&mt($itemtext->{'syllabus'}).'
'.
&mt('(Syllabus type in use)').(' ' x2).
- &mt('[_1]Edit[_2]','',
- ''),
+ $editsyllabus,
},
'hidefromcat' => {
text => ''.&mt($itemtext->{'hidefromcat'}).'
'.
@@ -2124,10 +2251,6 @@ sub print_courseinfo {
);
my $datatable;
my $count = 0;
- my $disabled;
- if ($noedit) {
- $disabled = ' disabled="disabled"';
- }
foreach my $item (@{$ordered}) {
my $colspan;
if ($item eq 'hidefromcat') {
@@ -2349,7 +2472,7 @@ sub print_courseinfo {
$datatable .= &manage_coownership($cnum,$cdom,\@currcoown,$noedit);
}
}
- } elsif ($item eq 'externalsyllabus') {
+ } elsif ($item eq 'syllabus') {
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'};
@@ -3166,7 +3289,7 @@ sub coowner_invitations {
@pendingcoown = split(',',$pendingcoowners);
}
if (ref($currcoownref) eq 'ARRAY') {
- @currcoown == @{$currcoownref};
+ @currcoown = @{$currcoownref};
}
my $disabled;
if ($noedit) {
@@ -3230,7 +3353,7 @@ sub manage_coownership {
@pendingcoown = split(',',$pendingcoowners);
}
if (ref($currcoownref) eq 'ARRAY') {
- @currcoown == @{$currcoownref};
+ @currcoown = @{$currcoownref};
}
my $disabled;
if ($noedit) {
@@ -3265,10 +3388,10 @@ sub manage_coownership {
}
$output .= '';
if ($is_coowner) {
- $output .= &mt('You are currently a co-owner:').' ';
+ $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) {
@@ -3526,7 +3649,7 @@ sub select_recipient {
my $domform = &Apache::loncommon::select_dom_form($cdom,$item.'_udom_'.$num,$includeempty);
my $selectlink =
&Apache::loncommon::selectstudent_link('display',$item.'_uname_'.$num,
- $item.'_udom_'.$num,1);
+ $item.'_udom_'.$num,'only');
my $output =
''.&mt('Username').' '.
' | '.
@@ -3543,7 +3666,7 @@ sub select_recipient {
}
sub select_sections {
- my ($item,$num,$sections,$selected,$noedit) = @_;
+ my ($item,$num,$sections,$selected,$noedit,$allval) = @_;
my ($output,@currsecs,$allsec,$disabled);
if (ref($selected) eq 'ARRAY') {
@currsecs = @{$selected};
@@ -3559,16 +3682,24 @@ sub select_sections {
my $mult;
if (@{$sections} > 1) {
$mult = ' multiple="multiple"';
+ my $size;
if (@{$sections} > 3) {
- $mult .= ' size="4"';
+ $size = 4;
+ } else {
+ $size = 1 + scalar(@{$sections});
}
+ $mult .= ' size="'.$size.'"';
}
- $output = '