--- loncom/interface/lonparmset.pm 2020/02/12 19:54:47 1.522.2.27 +++ loncom/interface/lonparmset.pm 2024/07/01 15:45:44 1.522.2.29 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.522.2.27 2020/02/12 19:54:47 raeburn Exp $ +# $Id: lonparmset.pm,v 1.522.2.29 2024/07/01 15:45:44 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1099,9 +1099,7 @@ sub print_td { $nolink = 1; } } elsif ($mprefix =~ /availablestudent\&$/) { - if ($which > 3) { - $nolink = 1; - } + $nolink = 1; } elsif ($mprefix =~ /examcode\&$/) { unless ($which == 2) { $nolink = 1; @@ -2308,6 +2306,7 @@ sub assessparms { my $chome = $env{'course.'.$env{'request.course.id'}.'.home'}; my ($got_chostname,$chostname,$cmajor,$cminor); my $totalstored = 0; + my $totalskippeduser = 0; my $now = time; for (my $i=0;$i<=$#markers;$i++) { my ($needsrelease,$needsnewer,$name); @@ -2316,6 +2315,11 @@ sub assessparms { } if ($markers[$i] =~ /\&(6|5|4)$/) { next if ($noeditgrp); + } elsif ($markers[$i] =~ /\&(3|2|1)$/) { + if ($uname eq '') { + $totalskippeduser ++; + next; + } } if ($markers[$i] =~ /^[\d.]+\&0_availablestudent\&(1|2|3)$/) { my (@ok_slots,@fail_slots,@del_slots); @@ -2393,9 +2397,27 @@ sub assessparms { # ---------------------------------------------------------------- Done storing if ($totalstored) { $message.='

' + .&mt('Changes for [quant,_1,parameter] saved.',$totalstored) + .'
' .&mt('Changes can take up to 10 minutes before being active for all students.') .&Apache::loncommon::help_open_topic('Caching') .'

'; + } else { + $message.='

'.&mt('No parameter changes saved.').'

'; + } + if ($totalskippeduser) { + $message .= '

'; + if ($uhome eq 'no_host') { + $message .= &mt('Changes for [quant,_1,user-specific parameter] not saved because the username or ID was invalid.', + $totalskippeduser); + } elsif ($env{'form.userroles'} eq 'any') { + $message .= &mt('Changes for [quant,_1,user-specific parameter] not saved because the user does not have a course role.', + $totalskippeduser); + } else { + $message .= &mt('Changes for [quant,_1,user-specific parameter] not saved because the user is not a student.', + $totalskippeduser); + } + $message .= '

'; } } #----------------------------------------------- if all selected, fill in array @@ -3252,6 +3274,8 @@ sub listdata { ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/); my $section=&mt('All Students'); $readonly = $readonlyall; + my $userscope; + my $showval = $$resourcedata{$thiskey}; if ($middle=~/^\[(.*)\]/) { my $issection=$1; if ($issection=~/^useropt\:($match_username)\:($match_domain)/) { @@ -3264,6 +3288,7 @@ sub listdata { } } $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2); + $userscope = 1; } else { if (($env{'request.course.sec'} ne '') && ($caller eq 'overview')) { if (exists($grouphash{$issection})) { @@ -3328,8 +3353,13 @@ sub listdata { ''.&mt($parmitem). ''); unless ($readonly) { + my $disabled; + if (($name eq 'availablestudent') && + (($showval eq '') || ($userscope))) { + $disabled = ' disabled="disabled"'; + } $r->print(''); + $thiskey.'"'.$disabled.' />'); } $r->print(''); $foundkeys++; @@ -3357,6 +3387,9 @@ sub listdata { $r->print(&date_interval_selector($thiskey, $$resourcedata{$thiskey},$readonly)); } elsif ($thistype =~ m/^string/) { + if ($name eq 'availablestudent') { + $readonly = 1; + } $r->print(&string_selector($thistype,$thiskey, $$resourcedata{$thiskey},$name,$readonly)); } else {