--- loncom/interface/lonparmset.pm 2003/10/10 16:56:16 1.133 +++ loncom/interface/lonparmset.pm 2004/10/15 22:31:14 1.168.2.3 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.133 2003/10/10 16:56:16 www Exp $ +# $Id: lonparmset.pm,v 1.168.2.3 2004/10/15 22:31:14 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -131,12 +131,12 @@ sub parmval { # -------------------------------------------------------- first, check default - if ($def) { $outpar[11]=$def; $result=11; } + if (defined($def)) { $outpar[11]=$def; $result=11; } # ----------------------------------------------------- second, check map parms my $thisparm=$parmhash{$symbparm}; - if ($thisparm) { $outpar[10]=$thisparm; $result=10; } + if (defined($thisparm)) { $outpar[10]=$thisparm; $result=10; } # --------------------------------------------------------- third, check course @@ -285,7 +285,7 @@ sub plink { sub startpage { - my ($r,$id,$udom,$csec,$uname,$have_assesments)=@_; + my ($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader)=@_; my $bodytag=&Apache::loncommon::bodytag('Set/Modify Course Parameters','', 'onUnload="pclose()"'); @@ -306,6 +306,9 @@ sub startpage { 'oi' => "or ID", 'ad' => "at Domain" ); + my $overallhelp= + &Apache::loncommon::help_open_menu('','Setting Parameters','Course_Setting_Parameters','',10,'Instructor Interface'); + my $assessparmhelp=&Apache::loncommon::help_open_topic("Cascading_Parameters","Assessment Parameters"); $r->print(< @@ -354,12 +357,16 @@ sub startpage { $selscript $bodytag +$overallhelp +ENDHEAD + unless ($trimheader) {$r->print(<

$lt{'cep'}


+$assessparmhelp

$lt{'caphm'}

@@ -370,9 +377,12 @@ $bodytag

+ENDHEAD2 +} + $r->print(<

$lt{'captm'}

-ENDHEAD +ENDHEAD3 if (!$have_assesments) { $r->print(''.&mt('There are no assesment parameters in this course to set.').'
'); @@ -485,21 +495,23 @@ sub print_row { } # end of $brief if/else } # end of $parmlev if/else - if ($parmlev eq 'full' || $parmlev eq 'brief') { - $r->print(''. + $r->print(''. &valout($outpar[$result],$typeoutpar[$result]).''); - } - my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}. + + if ($parmlev eq 'full' || $parmlev eq 'brief') { + my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}. '.'.$$name{$which},$symbp{$rid}); + # this doesn't seem to work, and I don't think is correct # my $sessionvaltype=&Apache::lonnet::EXT('resource.'.$$part{$which}. # '.'.$$name{$which}.'.type',$symbp{$rid}); # this seems to work - my $sessionvaltype=$typeoutpar[$result]; - if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; } - $r->print(''. + my $sessionvaltype=$typeoutpar[$result]; + if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; } + $r->print(''. &valout($sessionval,$sessionvaltype).' '. ''); + } $r->print(''); $r->print("\n"); } @@ -518,20 +530,6 @@ sub print_td { $r->print(''."\n"); } -sub get_env_multiple { - my ($name) = @_; - my @values; - if (defined($ENV{$name})) { - # exists is it an array - if (ref($ENV{$name})) { - @values=@{ $ENV{$name} }; - } else { - $values[0]=$ENV{$name}; - } - } - return(@values); -} - =pod =item B: Given the course data hash, extractResourceInformation extracts lots of information about the course's resources into a variety of hashes. @@ -587,7 +585,8 @@ sub extractResourceInformation { my $resid=$2; my $id=$mapid.'.'.$resid; my $srcf=$$bighash{$_}; - if ($srcf=~/\.(problem|exam|quiz|assess|survey|form)$/) { + if (1) { + $srcf=~/\.(\w+)$/; $$ids[$#$ids+1]=$id; $$typep{$id}=$1; $$keyp{$id}=''; @@ -596,6 +595,10 @@ sub extractResourceInformation { my $key=$_; my $allkey=$1; $allkey=~s/\_/\./g; + if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq + 'parm') { + next; #hide hidden things + } my $display= &Apache::lonnet::metadata($srcf,$key.'.display'); my $name=&Apache::lonnet::metadata($srcf,$key.'.name'); my $part= &Apache::lonnet::metadata($srcf,$key.'.part'); @@ -693,14 +696,15 @@ sub assessparms { $udom=$ENV{'form.udom'}; unless ($udom) { $udom=$r->dir_config('lonDefDomain'); } - my @pscat=&get_env_multiple('form.pscat'); + my @pscat=&Apache::loncommon::get_env_multiple('form.pscat'); my $pschp=$ENV{'form.pschp'}; - my @psprt=&get_env_multiple('form.psprt'); + my @psprt=&Apache::loncommon::get_env_multiple('form.psprt'); if (!@psprt) { $psprt[0]='0'; } my $showoptions=$ENV{'form.showoptions'}; my $pssymb=''; my $parmlev=''; + my $trimheader=''; my $prevvisit=$ENV{'form.prevvisit'}; # unless ($parmlev==$ENV{'form.parmlev'}) { @@ -723,11 +727,13 @@ sub assessparms { if (!@pscat) { @pscat=('all'); } $pschp=''; $parmlev = 'full'; + $trimheader='yes'; } elsif ($ENV{'form.symb'}) { $pssymb=$ENV{'form.symb'}; if (!@pscat) { @pscat=('all'); } $pschp=''; $parmlev = 'full'; + $trimheader='yes'; } else { $ENV{'form.url'}=''; } @@ -917,7 +923,7 @@ sub assessparms { my $have_assesments=1; if (scalar(keys(%allkeys)) eq 0) { $have_assesments=0; } - &startpage($r,$id,$udom,$csec,$uname,$have_assesments); + &startpage($r,$id,$udom,$csec,$uname,$have_assesments,$trimheader); if (!$have_assesments) { untie(%bighash); @@ -940,7 +946,9 @@ sub assessparms { my $submitmessage = &mt('Update Section or Specific User'); if (!$pssymb) { - $r->print(''.&mt('Select Parameter Level').''); + $r->print(''.&mt('Select Parameter Level'). + &Apache::loncommon::help_open_topic('Course_Parameter_Levels'). + ''); $r->print('print(' checked') unless (@pscat); - $r->print('>'.&mt('All Parameters').''); - + $r->print(''); my $cnt=0; foreach $tempkey (sort { $allparms{$a} cmp $allparms{$b} } keys %allparms ) { ++$cnt; - $r->print('') unless ($cnt%2); + $r->print('') if ($cnt%2); $r->print(''); + $r->print('>'.$allparms{$tempkey}.''); + } + $r->print(' + +'); $r->print('
print('value="'.$tempkey.'"'); if ($pscat[0] eq "all" || grep $_ eq $tempkey, @pscat) { $r->print(' checked'); } - $r->print('>'.$allparms{$tempkey}.'
+ + + + +
'); # $r->print('Select Parts'); @@ -1148,8 +1169,10 @@ ENDTABLEHEADFOUR my $rid=$_; my ($inmapid)=($rid=~/\.(\d+)$/); - if (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid}) || - ($pssymb eq $symbp{$rid})) { + if ((!$pssymb && + (($pschp eq 'all') || ($allmaps{$pschp} eq $mapp{$rid}))) + || + ($pssymb && $pssymb eq $symbp{$rid})) { # ------------------------------------------------------ Entry for one resource if ($defbgone eq '"E0E099"') { $defbgone='"E0E0DD"'; @@ -1193,7 +1216,8 @@ ENDTABLEHEADFOUR '>'. join(' / ',split(/\//,$uri)). '

'. - "$title"); @@ -1301,8 +1325,8 @@ ENDTABLEHEADFOUR my $showtitle=$maptitles{$maptitle}.($maptitle!~/^uploaded/?' ['.$maptitle.']':''); $r->print(<

-Set Defaults for All Resources in $foldermap
-$showtitle
+Set Defaults for All Resources in $foldermap
+$showtitle
Specifically for ENDMAPONE if ($uname) { @@ -1310,17 +1334,17 @@ ENDMAPONE ('firstname','middlename','lastname','generation', 'id')); my $person=$name{'firstname'}.' '.$name{'middlename'}.' ' .$name{'lastname'}.' '.$name{'generation'}; - $r->print(&mt("User")." $uname \($person\) ". + $r->print(&mt("User")." $uname \($person\) ". &mt('in')." \n"); } else { - $r->print("".&mt('all').' '.&mt('users in')." \n"); + $r->print("".&mt('all').' '.&mt('users in')." \n"); } - if ($csec) {$r->print(&mt("Section")." $csec ". + if ($csec) {$r->print(&mt("Section")." $csec ". &mt('of')." \n")}; - $r->print("$coursename
"); - $r->print("

\n"); + $r->print("$coursename
"); + $r->print("\n"); #---------------------------------------------------------------- print table $r->print('

'); $r->print(''); @@ -1328,6 +1352,7 @@ ENDMAPONE $r->print(''); foreach (sort keys %name) { + $r->print(''); &print_row($r,$_,\%part,\%name,$mapid,\%default, \%type,\%display,$defbgone,$defbgtwo, $parmlev); @@ -1384,21 +1409,20 @@ ENDMAPONE my $setdef=&mt("Set Defaults for All Resources in Course"); $r->print(<

$setdef - -$coursename
+$coursename
ENDMAPONE if ($uname) { my %name=&Apache::lonnet::userenvironment($udom,$uname, ('firstname','middlename','lastname','generation', 'id')); my $person=$name{'firstname'}.' '.$name{'middlename'}.' ' .$name{'lastname'}.' '.$name{'generation'}; - $r->print(" ".&mt("User")." $uname \($person\) \n"); + $r->print(" ".&mt("User")." $uname \($person\) \n"); } else { - $r->print("".&mt("ALL")." ".&mt("USERS")." \n"); + $r->print(" ".&mt("ALL")." ".&mt("USERS")." \n"); } - if ($csec) {$r->print(&mt("Section")." $csec\n")}; - $r->print("

\n"); + if ($csec) {$r->print(&mt("Section")." $csec\n")}; + $r->print("\n"); #---------------------------------------------------------------- print table $r->print('

'.&mt('Parameter Name').''.&mt('Parameter in Effect').'
'); $r->print(''); @@ -1406,6 +1430,7 @@ ENDMAPONE $r->print(''); foreach (sort keys %name) { + $r->print(''); &print_row($r,$_,\%part,\%name,$mapid,\%default, \%type,\%display,$defbgone,$defbgtwo,$parmlev); # $r->print("\n"); @@ -1494,7 +1519,7 @@ sub crsenv { } # # Let the user know we made the changes - if ($name) { + if ($name && defined($value)) { my $put_result = &Apache::lonnet::put('environment', {$name=>$value},$dom,$crs); if ($put_result eq 'ok') { @@ -1512,94 +1537,111 @@ sub crsenv { # -------------------------------------------------------- Get parameters again my %values=&Apache::lonnet::dump('environment',$dom,$crs); + my $SelectStyleFile=&mt('Select Style File'); + my $SelectSpreadsheetFile=&mt('Select Spreadsheet File'); my $output=''; if (! exists($values{'con_lost'})) { my %descriptions= - ('url' => 'Top Level Map '. + ('url' => ''.&mt('Top Level Map').' '. '". - 'Select Map
'. - 'Modification may make assessment data '. - 'inaccessible', - 'description' => 'Course Description', - 'courseid' => 'Course ID or number
'. - '(internal, optional)', - 'grading' => 'Grading'. - '"standard" or any other value. '. - 'Default for new courses is "standard".', - - 'default_xml_style' => 'Default XML Style File '. + &mt('Select Map').'
'. + &mt('Modification may make assessment data inaccessible'). + '', + 'description' => ''.&mt('Course Description').'', + 'courseid' => ''.&mt('Course ID or number'). + '
'. + '('.&mt('internal').', '.&mt('optional').')', + 'grading' => ''.&mt('Grading').'
'. + '"standard", "external", or "spreadsheet" '.&Apache::loncommon::help_open_topic('GradingOptions'), + 'default_xml_style' => ''.&mt('Default XML Style File').' '. 'Select Style File
", - 'question.email' => 'Feedback Addresses for Resource Content '. - 'Questions
(user:domain,'. + ",'sty')\">$SelectStyleFile
", + 'question.email' => ''.&mt('Feedback Addresses for Resource Content Question'). + '
(user:domain,'. 'user:domain(section;section;...;*;...),...)', - 'comment.email' => 'Feedback Addresses for Course Content Comments
'. + 'comment.email' => ''.&mt('Feedback Addresses for Course Content Comments').'
'. '(user:domain,user:domain(section;section;...;*;...),...)', - 'policy.email' => 'Feedback Addresses for Course Policy'. + 'policy.email' => ''.&mt('Feedback Addresses for Course Policy').''. '
(user:domain,user:domain(section;section;...;*;...),...)', - 'hideemptyrows' => 'Hide Empty Rows in Spreadsheets
'. - '("yes" for default hiding)', - 'pageseparators' => 'Visibly Separate Items on Pages
'. - '("yes" for visible separation, '. - 'changes will not show until next login)', - - 'plc.roles.denied'=> 'Disallow live chatroom use for '. - 'Roles
"st": '. - 'student, "ta": '. + 'hideemptyrows' => ''.&mt('Hide Empty Rows in Spreadsheets').'
'. + '('.&mt('"[_1]" for default hiding','yes').')', + 'pageseparators' => ''.&mt('Visibly Separate Items on Pages').'
'. + '('.&mt('"[_1]" for visible separation','yes').', '. + &mt('changes will not show until next login').')', + + 'plc.roles.denied'=> ''.&mt('Disallow live chatroom use for Roles'). + '
"st": '. + &mt('student').', "ta": '. 'TA, "in": '. - 'instructor;
role,role,...) '. + &mt('instructor').';
'.&mt('role,role,...').') '. Apache::loncommon::help_open_topic("Course_Disable_Discussion"), 'plc.users.denied' => - 'Disallow live chatroom use for Users
'. + ''.&mt('Disallow live chatroom use for Users').'
'. '(user:domain,user:domain,...)', - 'pch.roles.denied'=> 'Disallow Resource Discussion for '. - 'Roles
"st": '. + 'pch.roles.denied'=> ''.&mt('Disallow Resource Discussion for Roles'). + '
"st": '. 'student, "ta": '. 'TA, "in": '. 'instructor;
role,role,...) '. Apache::loncommon::help_open_topic("Course_Disable_Discussion"), 'pch.users.denied' => - 'Disallow Resource Discussion for Users
'. + ''.&mt('Disallow Resource Discussion for Users').'
'. '(user:domain,user:domain,...)', 'spreadsheet_default_classcalc' - => 'Default Course Spreadsheet '. + => ''.&mt('Default Course Spreadsheet').' '. 'Select Spreadsheet File
", + ",'spreadsheet')\">$SelectSpreadsheetFile
", 'spreadsheet_default_studentcalc' - => 'Default Student Spreadsheet '. + => ''.&mt('Default Student Spreadsheet').' '. 'Select Spreadsheet File
", + ",'spreadsheet')\">$SelectSpreadsheetFile
", 'spreadsheet_default_assesscalc' - => 'Default Assessment Spreadsheet '. + => ''.&mt('Default Assessment Spreadsheet').' '. 'Select Spreadsheet File
", + ",'spreadsheet')\">$SelectSpreadsheetFile
", 'allow_limited_html_in_feedback' - => 'Allow limited HTML in discussion posts
'. - '(Set value to "yes" to allow)', + => ''.&mt('Allow limited HTML in discussion posts').'
'. + '('.&mt('Set value to "[_1]" to allow',"yes").')', 'rndseed' - => 'Randomization algorithm used
'. - 'Modifying this will make problems '. - 'have different numbers and answers', + => ''.&mt('Randomization algorithm used').'
'. + ''.&mt('Modifying this will make problems').' '. + &mt('have different numbers and answers').'', + 'receiptalg' + => ''.&mt('Receipt algorithm used').'
'. + &mt('This controls how receipt numbers are generated.'), + 'suppress_tries' + => ''.&mt('Suppress number of tries in printing').'('. + &mt('yes if supress').')', 'problem_stream_switch' - => 'Allow problems to be split over pages
'. - ' ("yes" if allowed, anything else if not)', + => ''.&mt('Allow problems to be split over pages').'
'. + ' ('.&mt('"[_1]" if allowed, anything else if not','yes').')', + 'default_paper_size' + => ''.&mt('Default paper type').'
'. + ' ('.&mt('supported types').': Letter [8 1/2x11 in], Legal [8 1/2x14 in],'. + ' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'. + ' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])', 'anonymous_quiz' - => 'Anonimous quiz/exam
'. - ' (yes to avoid print students names )', - 'default_enrollment_start_date' => 'Default beginning date '. - 'when enrolling students', - 'default_enrollment_end_date' => 'Default ending date '. - 'when enrolling students', - 'languages' => 'Languages used', + => ''.&mt('Anonymous quiz/exam').'
'. + ' ('.&mt('yes').' '.&mt('to avoid print students names').' )', + 'default_enrollment_start_date' => ''.&mt('Default beginning date when enrolling students').'', + 'default_enrollment_end_date' => ''.&mt('Default ending date when enrolling students').'', + 'nothideprivileged' => ''.&mt('Privileged users that should not be hidden on staff listings').''. + '
(user:domain,user:domain,...)', + 'languages' => ''.&mt('Languages used').'', 'disable_receipt_display' - => 'Disable display of problem receipts
'. - ' ("yes" to disable, anything else if not)' + => ''.&mt('Disable display of problem receipts').'
'. + ' ('.&mt('"[_1]" to disable, anything else if not','yes').')', + 'disablesigfigs' + => ''.&mt('Disable checking of Significant Figures').'
'. + ' ('.&mt('"[_1]" to disable, anything else if not','yes').')', + 'tthoptions' + => ''.&mt('Default set of options to pass to tth/m when converting tex').'' ); my @Display_Order = ('url','description','courseid','grading', 'default_xml_style','pageseparators', @@ -1608,8 +1650,12 @@ sub crsenv { 'pch.roles.denied','pch.users.denied', 'allow_limited_html_in_feedback', 'languages', + 'nothideprivileged', 'rndseed', + 'receiptalg', 'problem_stream_switch', + 'suppress_tries', + 'default_paper_size', 'disable_receipt_display', 'spreadsheet_default_classcalc', 'spreadsheet_default_studentcalc', @@ -1617,12 +1663,16 @@ sub crsenv { 'hideemptyrows', 'default_enrollment_start_date', 'default_enrollment_end_date', + 'tthoptions', + 'disablesigfigs' ); foreach my $parameter (sort(keys(%values))) { - if (! $descriptions{$parameter}) { - $descriptions{$parameter}=$parameter; - push(@Display_Order,$parameter); - } + unless ($parameter =~ m/^internal\./) { + if (! $descriptions{$parameter}) { + $descriptions{$parameter}=$parameter; + push(@Display_Order,$parameter); + } + } } foreach my $parameter (@Display_Order) { my $description = $descriptions{$parameter}; @@ -1659,31 +1709,21 @@ sub crsenv { $onchange.' />
'; } + my %lt=&Apache::lonlocal::texthash( + 'par' => 'Parameter', + 'val' => 'Value', + 'set' => 'Set', + 'sce' => 'Set Course Environment' + ); + + my $Parameter=&mt('Parameter'); + my $Value=&mt('Value'); + my $Set=&mt('Set'); + my $browse_js=&Apache::loncommon::browser_and_searcher_javascript('parmset'); $r->print(< LON-CAPA Course Environment @@ -1693,10 +1733,10 @@ $bodytag $setoutput

'.&mt('Parameter Name').''.&mt('Parameter in Effect').'
resource.$part{$_}.$name{$_},$symbp{$mapid}
'. '
- + $output
ParameterValueSet?
$lt{'par'}$lt{'val'}$lt{'set'}?
- + @@ -1757,13 +1797,30 @@ ENDOVER push (@deldata,$thiskey); } elsif ($cmd eq 'datepointer') { my $data=&Apache::lonhtmlcommon::get_date_from_form($ENV{$_}); - if ($olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; } + if (defined($data) and $olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; } } } } # Store - &Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs); - &Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs); + my $delentries=$#deldata+1; + my @newdatakeys=keys %newdata; + my $putentries=$#newdatakeys+1; + if ($delentries) { + if (&Apache::lonnet::del('resourcedata',\@deldata,$dom,$crs) eq 'ok') { + $r->print('

'.&mt('Deleted [_1] parameter(s)

',$delentries)); + } else { + $r->print('

'. + &mt('Error deleting parameters').'

'); + } + } + if ($putentries) { + if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') { + $r->print('

'.&mt('Stored [_1] parameter(s)

',$putentries)); + } else { + $r->print('

'. + &mt('Error storing parameters').'

'); + } + } # Read and display my %resourcedata=&Apache::lonnet::dump('resourcedata',$dom,$crs); my $oldsection=''; @@ -1771,6 +1828,7 @@ ENDOVER my $oldpart=''; my $pointer=0; $tableopen=0; + my $foundkeys=0; foreach my $thiskey (sort keys %resourcedata) { if ($resourcedata{$thiskey.'.type'}) { my ($course,$middle,$part,$name)= @@ -1783,9 +1841,10 @@ ENDOVER $middle=~s/\.$//; my $realm=''.&mt('All Resources').''; if ($middle=~/^(.+)\_\_\_\(all\)$/) { - $realm=''.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).''; + $realm=''.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).'
('.$1.')
'; } elsif ($middle) { - $realm=''.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).''; + my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle); + $realm=''.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).'
('.$url.' in '.$map.' id: '.$id.')
'; } if ($section ne $oldsection) { $r->print(&tableend()."\n

$section

"); @@ -1808,6 +1867,7 @@ ENDOVER $r->print(&tablestart().''.$name. ':'); + $foundkeys++; if ($resourcedata{$thiskey.'.type'}=~/^date/) { my $jskey='key_'.$pointer; $pointer++; @@ -1826,8 +1886,8 @@ ENDOVER } } - $r->print(&tableend(). - '

'); + $r->print(&tableend().'

'. + ($foundkeys?'':&mt('There are no course or section parameters.')).'

'); } ################################################## @@ -1871,7 +1931,10 @@ sub handler { # ----------------------------------------------------- Needs to be in a course if (($ENV{'request.course.id'}) && - (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'}))) { + (&Apache::lonnet::allowed('opa',$ENV{'request.course.id'}) || + &Apache::lonnet::allowed('opa',$ENV{'request.course.id'}.'/'. + $ENV{'request.course.sec'}) + )) { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header;