--- loncom/interface/lonparmset.pm 2006/04/18 18:10:55 1.293 +++ loncom/interface/lonparmset.pm 2007/10/05 17:56:29 1.376.2.1 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.293 2006/04/18 18:10:55 www Exp $ +# $Id: lonparmset.pm,v 1.376.2.1 2007/10/05 17:56:29 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -63,17 +63,10 @@ use Apache::lonhomework; use Apache::lonxml; use Apache::lonlocal; use Apache::lonnavmaps; +use Apache::longroup; +use Apache::lonrss; +use LONCAPA qw(:DEFAULT :match); -# --- Caches local to lonparmset - -my $parmhashid; -my %parmhash; -my $symbsid; -my %symbs; -my $rulesid; -my %rules; - -# --- end local caches ################################################## ################################################## @@ -90,11 +83,11 @@ Inputs: $what - a parameter spec (inclu Returns: A list, the first item is the index into the remaining list of items of parm valuse that is the active one, the list consists of parm values at the 14 possible levels -14 - General Course -13 - Map or Folder level in course +14- General Course +13- Map or Folder level in course 12- resource default 11- map default -10 - resource level in course +10- resource level in course 9 - General for section 8 - Map or Folder level for section 7 - resource level in section @@ -116,16 +109,17 @@ sub parmval { sub parmval_by_symb { my ($what,$symb,$def,$uname,$udom,$csec,$cgroup,$courseopt)=@_; -# load caches - - &cacheparmhash(); - my $useropt=&Apache::lonnet::get_userresdata($uname,$udom); + my $useropt; + if ($uname ne '' && $udom ne '') { + $useropt = &Apache::lonnet::get_userresdata($uname,$udom); + } my $result=''; my @outpar=(); # ----------------------------------------------------- Cascading lookup scheme my $map=(&Apache::lonnet::decode_symb($symb))[0]; + $map = &Apache::lonnet::deversion($map); my $symbparm=$symb.'.'.$what; my $mapparm=$map.'___(all).'.$what; @@ -161,7 +155,7 @@ sub parmval_by_symb { # ------------------------------------------------------ third, check map parms - my $thisparm=$parmhash{$symbparm}; + my $thisparm=&parmhash($symbparm); if (defined($thisparm)) { $outpar[11]=$thisparm; $result=11; } if (defined($$courseopt{$courselevelr})) { @@ -170,7 +164,7 @@ sub parmval_by_symb { } # ------------------------------------------------------ fourth, back to course - if (defined($csec)) { + if ($csec ne '') { if (defined($$courseopt{$seclevel})) { $outpar[9]=$$courseopt{$seclevel}; $result=9; @@ -186,7 +180,7 @@ sub parmval_by_symb { } } # ------------------------------------------------------ fifth, check course group - if (defined($cgroup)) { + if ($cgroup ne '') { if (defined($$courseopt{$grplevel})) { $outpar[6]=$$courseopt{$grplevel}; $result=6; @@ -203,7 +197,7 @@ sub parmval_by_symb { # ---------------------------------------------------------- fifth, check user - if (defined($uname)) { + if ($uname ne '') { if (defined($$useropt{$courselevel})) { $outpar[3]=$$useropt{$courselevel}; $result=3; @@ -222,60 +216,90 @@ sub parmval_by_symb { return ($result,@outpar); } -sub resetparmhash { - $parmhashid=''; -} -sub cacheparmhash { - if ($parmhashid eq $env{'request.course.fn'}) { return; } - my %parmhashfile; - if (tie(%parmhashfile,'GDBM_File', - $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640)) { - %parmhash=%parmhashfile; - untie %parmhashfile; - $parmhashid=$env{'request.course.fn'}; - } -} -sub resetsymbcache { - $symbsid=''; +# --- Caches local to lonparmset + + +sub reset_caches { + &resetparmhash(); + &resetsymbcache(); + &resetrulescache(); } -sub symbcache { - my $id=shift; - if ($symbsid ne $env{'request.course.id'}) { - %symbs=(); +{ + my $parmhashid; + my %parmhash; + sub resetparmhash { + undef($parmhashid); + undef(%parmhash); } - unless ($symbs{$id}) { - my $navmap = Apache::lonnavmaps::navmap->new(); - if ($id=~/\./) { - my $resource=$navmap->getById($id); - $symbs{$id}=$resource->symb(); - } else { - my $resource=$navmap->getByMapPc($id); - $symbs{$id}=&Apache::lonnet::declutter($resource->src()); + + sub cacheparmhash { + if ($parmhashid eq $env{'request.course.fn'}) { return; } + my %parmhashfile; + if (tie(%parmhashfile,'GDBM_File', + $env{'request.course.fn'}.'_parms.db',&GDBM_READER(),0640)) { + %parmhash=%parmhashfile; + untie(%parmhashfile); + $parmhashid=$env{'request.course.fn'}; } - $symbsid=$env{'request.course.id'}; } - return $symbs{$id}; -} - -sub resetrulescache { - $rulesid=''; -} + + sub parmhash { + my ($id) = @_; + &cacheparmhash(); + return $parmhash{$id}; + } + } + +{ + my $symbsid; + my %symbs; + sub resetsymbcache { + undef($symbsid); + undef(%symbs); + } + + sub symbcache { + my $id=shift; + if ($symbsid ne $env{'request.course.id'}) { + undef(%symbs); + } + if (!$symbs{$id}) { + my $navmap = Apache::lonnavmaps::navmap->new(); + if ($id=~/\./) { + my $resource=$navmap->getById($id); + $symbs{$id}=$resource->symb(); + } else { + my $resource=$navmap->getByMapPc($id); + $symbs{$id}=&Apache::lonnet::declutter($resource->src()); + } + $symbsid=$env{'request.course.id'}; + } + return $symbs{$id}; + } + } -sub rulescache { - my $id=shift; - if ($rulesid ne $env{'request.course.id'}) { - %rules=(); +{ + my $rulesid; + my %rules; + sub resetrulescache { + undef($rulesid); + undef(%rules); } - unless (defined($rules{$id})) { - my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; - my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; - %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs); - $rulesid=$env{'request.course.id'}; + + sub rulescache { + my $id=shift; + if ($rulesid ne $env{'request.course.id'} + && !defined($rules{$id})) { + my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; + %rules=&Apache::lonnet::dump('parmdefactions',$dom,$crs); + $rulesid=$env{'request.course.id'}; + } + return $rules{$id}; } - return $rules{$id}; } sub preset_defaults { @@ -341,7 +365,6 @@ sub storeparm { # - new type # - username # - userdomain - my %recstack; sub storeparm_by_symb { my ($symb,$spnam,$snum,$nval,$ntype,$uname,$udom,$csec,$recflag,$cgroup)=@_; @@ -404,6 +427,8 @@ sub storeparm_by_symb_inner { # ---------------------------------------------------------- Construct prefixes $spnam=~s/\_([^\_]+)$/\.$1/; my $map=(&Apache::lonnet::decode_symb($symb))[0]; + $map = &Apache::lonnet::deversion($map); + my $symbparm=$symb.'.'.$spnam; my $mapparm=$map.'___(all).'.$spnam; @@ -489,7 +514,7 @@ sub storeparm_by_symb_inner { } if ($reply=~/^error\:(.*)/) { - return "Write Error: $1"; + return "Write Error: $1"; } return ''; } @@ -503,21 +528,26 @@ sub storeparm_by_symb_inner { Format a value for output. -Inputs: $value, $type +Inputs: $value, $type, $editable Returns: $value, formatted for output. If $type indicates it is a date, localtime($value) is returned. +$editable will return an icon to click on =cut ################################################## ################################################## sub valout { - my ($value,$type)=@_; + my ($value,$type,$editable)=@_; my $result = ''; # Values of zero are valid. if (! $value && $value ne '0') { - $result = '  '; + if ($editable) { + $result = '*'; + } else { + $result=' '; + } } else { if ($type eq 'date_interval') { my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value); @@ -543,7 +573,8 @@ sub valout { } $result=~s/\s+$//; } elsif (&isdateparm($type)) { - $result = localtime($value).&date_sanity_info($value); + $result = &Apache::lonlocal::locallocaltime($value). + &date_sanity_info($value); } else { $result = $value; } @@ -585,7 +616,7 @@ sub plink { return '
'. ''. - &valout($value,$type).'
'; + &valout($value,$type,1).''; } sub page_js { @@ -650,8 +681,7 @@ sub startpage { &page_js(), {'add_entries' => \%loaditems,}); my $breadcrumbs = - &Apache::lonhtmlcommon::breadcrumbs(undef, - 'Table Mode Parameter Setting'); + &Apache::lonhtmlcommon::breadcrumbs('Table Mode Parameter Setting','Table_Mode'); $r->print(<'; + $parm.='
'.&mt('Automatically sets').' '.join(', ',split(/\:/,$automatic)).'
'; } $r->print(''.$parm.''); @@ -924,57 +954,66 @@ sub extractResourceInformation { $$typep{$id}=$1; $$keyp{$id}=''; $$uris{$id}=$srcf; - foreach (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) { - if ($_=~/^parameter\_(.*)/) { - my $key=$_; + foreach my $key (split(/\,/,&Apache::lonnet::metadata($srcf,'allpossiblekeys'))) { + next if ($key!~/^parameter_/); + # Hidden parameters - if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm') { - next; - } - my $display= &Apache::lonnet::metadata($srcf,$key.'.display'); - my $name=&Apache::lonnet::metadata($srcf,$key.'.name'); - my $part= &Apache::lonnet::metadata($srcf,$key.'.part'); + next if (&Apache::lonnet::metadata($srcf,$key.'.hidden') eq 'parm'); # # allparms is a hash of parameter names # + my $name=&Apache::lonnet::metadata($srcf,$key.'.name'); + if (!exists($$allparms{$name}) || $$allparms{$name} =~ m/^\s*$/ ) { + my $display= &Apache::lonnet::metadata($srcf,$key.'.display'); my $parmdis = $display; $parmdis =~ s/\[Part.*$//g; - $$allparms{$name}=$parmdis; - $$defkeytype{$name}=&Apache::lonnet::metadata($srcf,$key.'.type'); + $$allparms{$name}=$parmdis; + if (ref($defkeytype)) { + $$defkeytype{$name}= + &Apache::lonnet::metadata($srcf,$key.'.type'); + } + } + # # allparts is a hash of all parts # - $$allparts{$part} = "Part: $part"; + my $part= &Apache::lonnet::metadata($srcf,$key.'.part'); + $$allparts{$part} = "Part: $part"; # # Remember all keys going with this resource # - if ($$keyp{$id}) { - $$keyp{$id}.=','.$key; - } else { - $$keyp{$id}=$key; - } + if ($$keyp{$id}) { + $$keyp{$id}.=','.$key; + } else { + $$keyp{$id}=$key; + } # # Put in order # - unless ($$keyorder{$key}) { - $$keyorder{$key}=$keyordercnt; - $keyordercnt++; - } - + unless ($$keyorder{$key}) { + $$keyorder{$key}=$keyordercnt; + $keyordercnt++; } } - $$mapp{$id}= - &Apache::lonnet::declutter($resource->enclosing_map_src()); - $$mapp{$mapid}=$$mapp{$id}; - $$allmaps{$mapid}=$$mapp{$id}; - if ($mapid eq '1') { - $$maptitles{$mapid}='Main Course Documents'; + + + if (!exists($$mapp{$mapid})) { + $$mapp{$id}= + &Apache::lonnet::declutter($resource->enclosing_map_src()); + $$mapp{$mapid}=$$mapp{$id}; + $$allmaps{$mapid}=$$mapp{$id}; + if ($mapid eq '1') { + $$maptitles{$mapid}='Main Course Documents'; + } else { + $$maptitles{$mapid}= + &Apache::lonnet::gettitle($$mapp{$id}); + } + $$maptitles{$$mapp{$id}}=$$maptitles{$mapid}; + $$symbp{$mapid}=$$mapp{$id}.'___(all)'; } else { - $$maptitles{$mapid}=&Apache::lonnet::gettitle(&Apache::lonnet::clutter($$mapp{$id})); + $$mapp{$id} = $$mapp{$mapid}; } - $$maptitles{$$mapp{$id}}=$$maptitles{$mapid}; $$symbp{$id}=&Apache::lonnet::encode_symb($$mapp{$id},$resid,$srcf); - $$symbp{$mapid}=$$mapp{$id}.'___(all)'; } } @@ -1053,15 +1092,17 @@ sub parmmenu { ENDSCRIPT $r->print(); - $r->print("\n"); + $r->print("\n
"); my $cnt=0; foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) { - $r->print("\n'); + $r->print('>'.($$allparms{$tempkey}=~/\S/ ? $$allparms{$tempkey} + : $tempkey) + .''); $cnt++; if ($cnt==3) { $r->print("\n"); @@ -1069,7 +1110,7 @@ ENDSCRIPT } } $r->print(' - + @@ -1748,9 +1771,9 @@ ENDTABLEHEADFOUR '

'. "$title"); + &escape($symbp{$rid}). + "', 'metadatafile', '450', '500', 'no', 'yes');\"". + " target=\"_self\">$title"); if ($thistitle) { $r->print(' ('.$thistitle.')'); @@ -1947,7 +1970,7 @@ ENDMAPONE } if ($csec) {$r->print(&mt("Section")." $csec\n")}; - if ($cgroup) {$r->print(&mt("Group")." $csec\n")}; + if ($cgroup) {$r->print(&mt("Group")." $cgroup\n")}; $r->print("\n"); #---------------------------------------------------------------- print table $r->print('

+
Select All
Select Common Only
@@ -1119,21 +1160,15 @@ sub usermenu { 'oi' => "or ID", 'ad' => "at Domain" ); - my %sectionhash=(); my $sections=''; - my $numsec = &Apache::loncommon::get_sections( - $env{'course.'.$env{'request.course.id'}.'.domain'}, - $env{'course.'.$env{'request.course.id'}.'.num'}, - \%sectionhash); + my %sectionhash = &Apache::loncommon::get_sections(); + my $groups; - my %grouphash; - my $numgrp = &Apache::loncommon::coursegroups( - \%grouphash, - $env{'course.'.$env{'request.course.id'}.'.domain'}, - $env{'course.'.$env{'request.course.id'}.'.num'}); - if ($numsec > 0) { + my %grouphash = &Apache::longroup::coursegroups(); + + if (%sectionhash) { $sections=$lt{'se'}.': print(''); + foreach my $s ('all',sort keys %sectionhash) { + $r->print(' \n"); } - $r->print("\n"); - } + $r->print('>'.$s."\n"); + } + $r->print("\n"); } sub groupmenu { my ($r,$selectedgroups)=@_; - my %grouphash; - my $numgrp = &Apache::loncommon::coursegroups( - \%grouphash, - $env{'course.'.$env{'request.course.id'}.'.domain'}, - $env{'course.'.$env{'request.course.id'}.'.num'}); - if ($numgrp) { - $r->print('\n"); + my %grouphash = &Apache::longroup::coursegroups(); + return if (!%grouphash); + + $r->print('\n"); } @@ -1416,7 +1443,6 @@ sub assessparms { my $uhome; my $csec; my $cgroup; - my $grouplist; my @usersgroups = (); my $coursename=$env{'course.'.$env{'request.course.id'}.'.description'}; @@ -1488,8 +1514,8 @@ sub assessparms { $id=''; } else { $message= - "".&mt("Unknown ID")." '$id' ". - &mt('at domain')." '$udom'"; + ''.&mt("Unknown ID")." '$id' ". + &mt('at domain')." '$udom'"; } } else { $uname=$env{'form.uname'}; @@ -1500,17 +1526,17 @@ sub assessparms { $uhome=&Apache::lonnet::homeserver($uname,$udom); if ($uhome eq 'no_host') { $message= - "".&mt("Unknown user")." '$uname' ". - &mt("at domain")." '$udom'"; + ''.&mt("Unknown user")." '$uname' ". + &mt("at domain")." '$udom'"; $uname=''; } else { $csec=&Apache::lonnet::getsection($udom,$uname, $env{'request.course.id'}); if ($csec eq '-1') { - $message="". + $message=''. &mt("User")." '$uname' ".&mt("at domain")." '$udom' ". - &mt("not in this course").""; + &mt("not in this course").""; $uname=''; $csec=$env{'form.csec'}; $cgroup=$env{'form.cgroup'}; @@ -1520,18 +1546,14 @@ sub assessparms { $message="\n

\n".&mt("Full Name").": ". $name{'firstname'}.' '.$name{'middlename'}.' ' .$name{'lastname'}.' '.$name{'generation'}. - "
\n".&mt('ID').": ".$name{'id'}.'

'; + "
\n".&mt('ID').": ".$name{'id'}.'

'; } - $grouplist = &Apache::lonnet::get_users_groups( + @usersgroups = &Apache::lonnet::get_users_groups( $udom,$uname,$env{'request.course.id'}); - if ($grouplist) { - @usersgroups = &Apache::lonnet::sort_course_groups($grouplist, - $env{'request.course.id'}); - unless (grep/^\Q$cgroup\E$/,@usersgroups) { + if (@usersgroups > 0) { + unless (grep(/^\Q$cgroup\E$/,@usersgroups)) { $cgroup = $usersgroups[0]; - } - } else { - $cgroup = ''; + } } } } @@ -1572,7 +1594,7 @@ sub assessparms { foreach ('tolerance','date_default','date_start','date_end', 'date_interval','int','float','string') { $r->print(''); + $env{'form.recent_'.$_}.'" name="recent_'.$_.'" />'); } if (!$pssymb) { @@ -1587,8 +1609,9 @@ sub assessparms { &displaymenu($r,\%allparms,\%allparts,\@pscat,\@psprt,\%keyorder); } else { my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb); - $r->print(&mt('Specific Resource').": ".$resource. - ''. + my $title = &Apache::lonnet::gettitle($pssymb); + $r->print(&mt('Specific Resource: [_1] ([_2])',$title,$resource). + ''. '

'); } @@ -1648,7 +1671,7 @@ sub assessparms { ); $r->print(<$lt{'pie'} -

$lt{'csv'}
($csuname $lt{'at'} $csudom)
$lt{'csv'}
($csuname $lt{'at'} $csudom)
$lt{'ic'}$lt{'rl'} $lt{'ic'}
'); @@ -1990,8 +2013,8 @@ sub crsenv { my $r=shift; my $setoutput=''; - my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs(undef, - 'Edit Course Environment'); + my $breadcrumbs = + &Apache::lonhtmlcommon::breadcrumbs('Edit Course Environment'); my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; @@ -2014,7 +2037,7 @@ sub crsenv { ('environment', {'top level map backup '.$bkuptime => $tmp[1] }, $dom,$crs). - '
'; + '
'; } # # Deal with modified default spreadsheets @@ -2042,6 +2065,29 @@ sub crsenv { if ($name =~ /^default_enrollment_(start|end)_date$/) { $value=&Apache::lonhtmlcommon::get_date_from_form($name.'_value'); } + # + # Deal with the emails + if ($name =~ /\.email$/) { + foreach my $specifier (split(',',$value)) { + my ($user,$sections_or_groups)= + ($specifier=~/^([^\(]+)\(([^\)]+)\)/); + if (!$sections_or_groups) { + $user = $specifier; + } + my ($name,$domain) = split(':',$user); + if (!defined($user) || !defined($domain)) { + $setoutput.= '
'. + &mt("Invalid email address specified, address must be of the form username:domain what was specified was ([_1])",$user). + ''; + undef($value); + } elsif (&Apache::lonnet::homeserver($user,$domain) eq 'no_host') { + $setoutput.= '
'. + &mt("Invalid email address specified, user [_1] is unknown.",$name). + ''; + undef($value); + } + } + } # Get existing cloners my @oldcloner = (); if ($name eq 'cloners') { @@ -2055,13 +2101,13 @@ sub crsenv { # # Let the user know we made the changes if ($name && defined($value)) { - my $failed_cloners; + my %failed_cloners; if ($name eq 'cloners') { $value =~ s/\s//g; $value =~ s/^,//; $value =~ s/,$//; # check requested clones are valid users. - $failed_cloners = &check_cloners(\$value,\@oldcloner); + %failed_cloners = &check_cloners(\$value,\@oldcloner); } my $put_result = &Apache::lonnet::put('environment', {$name=>$value},$dom,$crs); @@ -2078,23 +2124,45 @@ sub crsenv { $setoutput.=&mt('Unable to set').' '.$name.' '.&mt('to'). ' '.$value.' '.&mt('due to').' '.$put_result.'.
'; } - if (($name eq 'cloners') && ($failed_cloners)) { - $setoutput.= &mt('Unable to include').' - '.$failed_cloners.', '. - &mt('reason').' - '.&mt('LON-CAPA user(s) do(es) not exist'). - '.
'.&mt('Please '). - '
'. - &mt('add the user(s)').', '. - &mt('and then return to the '). - ''. - &mt('Course Parameters page').' '. - &mt('to add the new user(s) to the list of possible cloners'). - '.
'; + if (($name eq 'cloners') && (keys(%failed_cloners) > 0)) { + $setoutput.= &mt('Unable to include').': '; + my @fails; + my $num = 0; + if (defined($failed_cloners{'format'})) { + $fails[$num] .= ''.$failed_cloners{'format'}. + ', '.&mt('reason').' - '. + &mt('Invalid format'); + $num ++; + } + if (defined($failed_cloners{'domain'})) { + $fails[$num] .= ''.$failed_cloners{'domain'}. + ', '.&mt('reason').' - '. + &mt('Domain does not exist'); + $num ++; + } + if (defined($failed_cloners{'newuser'})) { + $fails[$num] .= ''.$failed_cloners{'newuser'}. ', '.&mt('reason').' - '. + &mt('LON-CAPA user(s) do(es) not exist.'). + '.
'.&mt('Please '). + ' '. + &mt('add the user(s)').', '. + &mt('and then return to the '). + ''. + &mt('Course Parameters page').' '. + &mt('to add the new user(s) to the list of possible cloners'); + } + $setoutput .= join(';  ',@fails).'.
'; } } } + + my $start_table =&Apache::loncommon::start_data_table(); + my $start_header_row=&Apache::loncommon::start_data_table_header_row(); + my $end_header_row =&Apache::loncommon::end_data_table_header_row(); # ------------------------- Re-init course environment entries for this session - &Apache::lonnet::coursedescription($env{'request.course.id'}); + &Apache::lonnet::coursedescription($env{'request.course.id'}, + {'freshen_cache' => 1}); # -------------------------------------------------------- Get parameters again @@ -2107,34 +2175,45 @@ sub crsenv { ('url' => ''.&mt('Top Level Map').' '. '". - &mt('Select Map').'
'. + &mt('Select Map').'
'. &mt('Modification may make assessment data inaccessible'). - '
', + '', 'description' => ''.&mt('Course Description').'', 'courseid' => ''.&mt('Course ID or number'). '
'. '('.&mt('internal').', '.&mt('optional').')', - 'cloners' => ''.&mt('Users allowed to clone course').'
(user:domain,user:domain)
'.&mt('Users with active Course Coordinator role in the course automatically have the right to clone it, and can be omitted from list.'), + 'cloners' => ''.&mt('Users allowed to clone course').'
(user:domain,user:domain,*:domain)
'.&mt('Users with active Course Coordinator role in course are permitted to clone and need not be included.
+Use *:domain to allow course to be cloned by anyone in the specified domain.
+Use * to allow unrestricted cloning in all domains.'), 'grading' => ''.&mt('Grading').'
'. '"standard", "external", or "spreadsheet" '.&Apache::loncommon::help_open_topic('GradingOptions'), + 'task_grading' => ''.&mt('Bridge Task Grading').'
'. + &mt('Instructors and TAs in sections, when grading bridge tasks, should be allowed to grade other sections, "[_1]" they are allowed (this is the default), "[_2]" no, they can only grade their own section','any','section'), 'default_xml_style' => ''.&mt('Default XML Style File').' '. '$SelectStyleFile
", + ",'sty')\">$SelectStyleFile
", 'question.email' => ''.&mt('Feedback Addresses for Resource Content Question'). '
(user:domain,'. 'user:domain(section;section;...;*;...),...)', + 'question.email.text' => ''.&mt('Custom Text for Resource Content Question Option in Feedback'). + '', 'comment.email' => ''.&mt('Feedback Addresses for Course Content Comments').'
'. '(user:domain,user:domain(section;section;...;*;...),...)', + 'comment.email.text' => ''.&mt('Custom Text for Course Content Option in Feedback'). + '', 'policy.email' => ''.&mt('Feedback Addresses for Course Policy').''. '
(user:domain,user:domain(section;section;...;*;...),...)', + 'policy.email.text' => ''.&mt('Custom Text for Course Policy Option in Feedback'). + '', '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').')', 'student_classlist_view' => ''.&mt('Allow students to view classlist.').''.&mt('("all":students can view all sections,"section":students can only view their own section.blank or "disabled" prevents student view.'), - + 'student_classlist_portfiles' => ''.&mt('Include link to accessible portfolio files').'
'.&mt('"[_1]" for link to each a listing of each student\'s files.','yes'), + 'student_classlist_opt_in' => ''.&mt("Student's agreement needed for listing in student-viewable roster").'
'.&mt('"[_1]" to require students to opt-in to listing in the roster (on the roster page).','yes'), 'plc.roles.denied'=> ''.&mt('Disallow live chatroom use for Roles'). '
"st": '. &mt('student').', "ta": '. @@ -2180,8 +2259,8 @@ sub crsenv { '('.&mt('or set value to "[_1]" to allow all roles',"yes").')', 'rndseed' => ''.&mt('Randomization algorithm used').'
'. - ''.&mt('Modifying this will make problems').' '. - &mt('have different numbers and answers').'', + ''.&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.'), @@ -2196,9 +2275,8 @@ sub crsenv { ' ('.&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' - => ''.&mt('Anonymous quiz/exam').'
'. - ' ('.&mt('yes').' '.&mt('to avoid print students names').' )', + 'print_header_format' + => &mtn(' Print header format; substitutions : %n student name %c course id %a assignment note, numbers after the % limit the field size.').'
', 'default_enrollment_start_date' => ''.&mt('Default beginning date for student access.').'', 'default_enrollment_end_date' => ''.&mt('Default ending date for student access.').'', 'nothideprivileged' => ''.&mt('Privileged users that should not be hidden on staff listings').''. @@ -2207,6 +2285,8 @@ sub crsenv { 'disable_receipt_display' => ''.&mt('Disable display of problem receipts').'
'. ' ('.&mt('"[_1]" to disable, anything else if not','yes').')', + 'task_messages' + => ''.&mt('Send message to student when clicking Done on Tasks').'
('.&mt('[_1] to send a message only to student, [_2] to send message to student and add record to user information page for instructors. Leave blank to disable.','only_student','student_and_user_notes_screen').')', 'disablesigfigs' => ''.&mt('Disable checking of Significant Figures').'
'. ' ('.&mt('"[_1]" to disable, anything else if not','yes').')', @@ -2216,13 +2296,18 @@ sub crsenv { 'externalsyllabus' => ''.&mt('URL of Syllabus (not using internal handler)').'', 'tthoptions' - => ''.&mt('Default set of options to pass to tth/m when converting tex').'' + => ''.&mt('Default set of options to pass to tth/m when converting tex').'', + + 'texengine' + => ''.&mt('Force all students in the course to use a specific math rendering engine.').'
'.&mt('(Valid options are [_1].)','"tth", "jsMath", "mimetex"').'', ); my @Display_Order = ('url','description','courseid','cloners','grading', 'externalsyllabus', 'default_xml_style','pageseparators', - 'question.email','comment.email','policy.email', + 'question.email','question.email.text','comment.email','comment.email.text','policy.email','policy.email.text', 'student_classlist_view', + 'student_classlist_opt_in', + 'student_classlist_portfiles', 'plc.roles.denied','plc.users.denied', 'pch.roles.denied','pch.users.denied', 'allow_limited_html_in_feedback', @@ -2234,6 +2319,7 @@ sub crsenv { 'problem_stream_switch', 'suppress_tries', 'default_paper_size', + 'print_header_format', 'disable_receipt_display', 'spreadsheet_default_classcalc', 'spreadsheet_default_studentcalc', @@ -2242,8 +2328,10 @@ sub crsenv { 'default_enrollment_start_date', 'default_enrollment_end_date', 'tthoptions', + 'texengine', 'disablesigfigs', - 'disableexampointprint' + 'disableexampointprint', + 'task_messages','task_grading', ); foreach my $parameter (sort(keys(%values))) { unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./)) { @@ -2253,13 +2341,15 @@ sub crsenv { } } } + foreach my $parameter (@Display_Order) { my $description = $descriptions{$parameter}; # onchange is javascript to automatically check the 'Set' button. my $onchange = 'onFocus="javascript:window.document.forms'. "['envform'].elements['".$parameter."_setparmval']". '.checked=true;"'; - $output .= ''; + $output .= &Apache::loncommon::start_data_table_row(). + ''; if ($parameter =~ /^default_enrollment_(start|end)_date$/) { $output .= ''; - $output .= "\n"; + $output .= &Apache::loncommon::end_data_table_row()."\n"; } my $onchange = 'onFocus="javascript:window.document.forms'. '[\'envform\'].elements[\'newp_setparmval\']'. '.checked=true;"'; - $output.=''; + ''. + &Apache::loncommon::end_data_table_row()."\n"; } my %lt=&Apache::lonlocal::texthash( 'par' => 'Parameter', @@ -2304,21 +2396,23 @@ sub crsenv { ''; my $start_page = - &Apache::loncommon::start_page('Set Course Environment Parameters', + &Apache::loncommon::start_page('Set Course Environment', $browse_js); my $end_page = &Apache::loncommon::end_page(); + my $end_table=&Apache::loncommon::end_data_table(); $r->print(< $setoutput -

-

'.$description.''.$description.''. &Apache::lonhtmlcommon::date_setter('envform', @@ -2276,17 +2366,19 @@ sub crsenv { $output .= ''. &Apache::lonhtmlcommon::checkbox($parameter.'_setparmval'). '
'.&mt('Create New Environment Variable').'
'. + $output.=&Apache::loncommon::start_data_table_row(). + '
'.&mt('Create New Environment Variable').'
'. '
'. ''. - '
- +$start_table +$start_header_row + +$end_header_row $output -
$lt{'par'}$lt{'val'}$lt{'set'}?
$lt{'par'}$lt{'val'}$lt{'set'}?
- +$end_table + $end_page ENDENV @@ -2333,7 +2427,7 @@ sub tablestart { return ''; } else { $tableopen=1; - return ''; } } @@ -2341,7 +2435,7 @@ sub tablestart { sub tableend { if ($tableopen) { $tableopen=0; - return '
'.&mt('Parameter').''. + return &Apache::loncommon::start_data_table().'
'.&mt('Parameter').''. &mt('Delete').''.&mt('Set to ...').'
'; + return &Apache::loncommon::end_data_table(); } else { return''; } @@ -2355,8 +2449,7 @@ sub readdata { my $classlist=&Apache::loncoursedata::get_classlist(); foreach (keys %$classlist) { - # the following undefs are for 'domain', and 'username' respectively. - if ($_=~/^(\w+)\:(\w+)$/) { + if ($_=~/^($match_username)\:($match_domain)$/) { my ($tuname,$tudom)=($1,$2); my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom); foreach my $userkey (keys %{$useropt}) { @@ -2401,11 +2494,11 @@ sub storedata { $tkey.'.type' => $typeof}, $tudom,$tuname) eq 'ok') { &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom); - $r->print('
'.&mt('Stored modified parameter for').' '. + $r->print('
'.&mt('Saved modified parameter for').' '. &Apache::loncommon::plainname($tuname,$tudom)); } else { - $r->print('

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

'); + $r->print('
'. + &mt('Error saving parameters').'
'); } &Apache::lonnet::devalidateuserresdata($tuname,$tudom); } else { @@ -2419,12 +2512,12 @@ sub storedata { &log_parmset({$tkey=>''},1,$tuname,$tudom); $r->print('
'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom)); } else { - $r->print('

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

'); + $r->print('
'. + &mt('Error deleting parameters').'
'); } &Apache::lonnet::devalidateuserresdata($tuname,$tudom); } else { - push (@deldata,$thiskey); + push (@deldata,$thiskey,$thiskey.'.type'); } } elsif ($cmd eq 'datepointer') { my $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_}); @@ -2435,10 +2528,10 @@ sub storedata { $tkey.'.type' => $typeof}, $tudom,$tuname) eq 'ok') { &log_parmset({$tkey=>$data,$tkey.'.type' => $typeof},0,$tuname,$tudom); - $r->print('
'.&mt('Stored modified date for').' '.&Apache::loncommon::plainname($tuname,$tudom)); + $r->print('
'.&mt('Saved modified date for').' '.&Apache::loncommon::plainname($tuname,$tudom)); } else { - $r->print('

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

'); + $r->print('
'. + &mt('Error saving parameters').'
'); } &Apache::lonnet::devalidateuserresdata($tuname,$tudom); } else { @@ -2459,18 +2552,18 @@ sub storedata { &log_parmset(\%loghash,1); $r->print('

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

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

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

'); + $r->print('
'. + &mt('Error deleting parameters').'
'); } &Apache::lonnet::devalidatecourseresdata($crs,$dom); } if ($putentries) { if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') { &log_parmset(\%newdata,0); - $r->print('

'.&mt('Stored [_1] parameter(s)',$putentries/2).'

'); + $r->print('

'.&mt('Saved [_1] parameter(s)',$putentries/2).'

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

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

'); + $r->print('
'. + &mt('Error saving parameters').'
'); } &Apache::lonnet::devalidatecourseresdata($crs,$dom); } @@ -2478,7 +2571,7 @@ sub storedata { sub extractuser { my $key=shift; - return ($key=~/^$env{'request.course.id'}.\[useropt\:(\w+)\:(\w+)\]\./); + return ($key=~/^$env{'request.course.id'}.\[useropt\:($match_username)\:($match_domain)\]\./); } sub listdata { @@ -2536,7 +2629,7 @@ sub listdata { my $section=&mt('All Students'); if ($middle=~/^\[(.*)\]/) { my $issection=$1; - if ($issection=~/^useropt\:(\w+)\:(\w+)/) { + if ($issection=~/^useropt\:($match_username)\:($match_domain)/) { $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2); } else { $section=&mt('Group/Section').': '.$issection; @@ -2545,12 +2638,12 @@ sub listdata { } $middle=~s/\.+$//; $middle=~s/^\.+//; - my $realm=''.&mt('All Resources').''; + my $realm=''.&mt('All Resources').''; if ($middle=~/^(.+)\_\_\_\(all\)$/) { - $realm=''.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).'
('.$1.')
'; + $realm=''.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).'
('.$1.')
'; } elsif ($middle) { my ($map,$id,$url)=&Apache::lonnet::decode_symb($middle); - $realm=''.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).'
('.$url.' in '.$map.' id: '.$id.')
'; + $realm=''.&mt('Resource').': '.&Apache::lonnet::gettitle($middle).'
('.$url.' in '.$map.' id: '.$id.')
'; } if ($sortorder eq 'realmstudent') { if ($realm ne $oldrealm) { @@ -2577,22 +2670,15 @@ sub listdata { } if ($part ne $oldpart) { $r->print(&tableend(). - "\n".&mt('Part').": $part"); + "\n".&mt('Part').": $part"); $oldpart=$part; } # -# Preset defaults? -# - my ($hour,$min,$sec,$val)=('','','',''); - unless ($$resourcedata{$thiskey}) { - my ($parmname)=($thiskey=~/\.(\w+)$/); - ($hour,$min,$sec,$val)=&preset_defaults($parmname); - } - -# # Ready to print # - $r->print(&tablestart().''.&standard_parameter_names($name). + $r->print(&tablestart(). + &Apache::loncommon::start_data_table_row(). + ''.&standard_parameter_names($name). ''); $foundkeys++; @@ -2603,7 +2689,7 @@ sub listdata { &Apache::lonhtmlcommon::date_setter('parmform', $jskey, $$resourcedata{$thiskey}, - '',1,'','',$hour,$min,$sec). + '',1,'',''). ''. &date_sanity_info($$resourcedata{$thiskey}) ); @@ -2611,8 +2697,6 @@ sub listdata { my $showval; if (defined($$resourcedata{$thiskey})) { $showval=$$resourcedata{$thiskey}; - } else { - $showval=$val; } $r->print('