--- loncom/interface/lonparmset.pm 2006/06/23 03:14:00 1.314 +++ loncom/interface/lonparmset.pm 2007/03/05 02:46:45 1.361 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.314 2006/06/23 03:14:00 albertel Exp $ +# $Id: lonparmset.pm,v 1.361 2007/03/05 02:46:45 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -65,7 +65,7 @@ use Apache::lonlocal; use Apache::lonnavmaps; use Apache::longroup; use Apache::lonrss; -use LONCAPA; +use LONCAPA qw(:DEFAULT :match); # --- Caches local to lonparmset @@ -122,7 +122,10 @@ sub parmval_by_symb { # 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=(); @@ -173,7 +176,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; @@ -189,7 +192,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; @@ -206,7 +209,7 @@ sub parmval_by_symb { # ---------------------------------------------------------- fifth, check user - if (defined($uname)) { + if ($uname ne '') { if (defined($$useropt{$courselevel})) { $outpar[3]=$$useropt{$courselevel}; $result=3; @@ -269,10 +272,8 @@ sub resetrulescache { sub rulescache { my $id=shift; - if ($rulesid ne $env{'request.course.id'}) { - %rules=(); - } - unless (defined($rules{$id})) { + 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); @@ -508,21 +509,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); @@ -548,7 +554,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; } @@ -590,7 +597,7 @@ sub plink { return '
'. ''. - &valout($value,$type).'
'; + &valout($value,$type,1).''; } sub page_js { @@ -655,7 +662,7 @@ sub startpage { &page_js(), {'add_entries' => \%loaditems,}); my $breadcrumbs = - &Apache::lonhtmlcommon::breadcrumbs('Table Mode Parameter Setting'); + &Apache::lonhtmlcommon::breadcrumbs('Table Mode Parameter Setting','Table_Mode'); $r->print(< ENDSCRIPT $r->print(); - $r->print("\n"); + $r->print("\n
"); my $cnt=0; foreach $tempkey (&keysindisplayorder($allparms,$keyorder)) { - $r->print("\n'); + $r->print('>'.$$allparms{$tempkey}.''); $cnt++; if ($cnt==3) { $r->print("\n"); @@ -1073,7 +1080,7 @@ ENDSCRIPT } } $r->print(' - + @@ -1735,8 +1742,8 @@ ENDTABLEHEADFOUR "$title"); + "', 'metadatafile', '450', '500', 'no', 'yes');\"". + " target=\"_self\">$title"); if ($thistitle) { $r->print(' ('.$thistitle.')'); @@ -2000,7 +2007,7 @@ sub crsenv { ('environment', {'top level map backup '.$bkuptime => $tmp[1] }, $dom,$crs). - '
'; + '
'; } # # Deal with modified default spreadsheets @@ -2078,6 +2085,10 @@ sub crsenv { } } } + + 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'}, @@ -2107,14 +2118,20 @@ sub crsenv { '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').'
'. @@ -2183,6 +2200,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])', + 'print_header_format' + => 'Print header format; substitutions: %n student name %c course id %a assignment note, numbers after the % limit the field size', 'anonymous_quiz' => ''.&mt('Anonymous quiz/exam').'
'. ' ('.&mt('yes').' '.&mt('to avoid print students names').' )', @@ -2195,7 +2214,7 @@ sub crsenv { => ''.&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. [_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').'', + => ''.&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').')', @@ -2210,7 +2229,7 @@ sub crsenv { 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', 'plc.roles.denied','plc.users.denied', 'pch.roles.denied','pch.users.denied', @@ -2223,6 +2242,7 @@ sub crsenv { 'problem_stream_switch', 'suppress_tries', 'default_paper_size', + 'print_header_format', 'disable_receipt_display', 'spreadsheet_default_classcalc', 'spreadsheet_default_studentcalc', @@ -2243,13 +2263,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', @@ -2294,20 +2318,22 @@ 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 -

-

+
Select All
Select Common Only
@@ -1509,7 +1516,7 @@ 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'}.'

'; } @usersgroups = &Apache::lonnet::get_users_groups( $udom,$uname,$env{'request.course.id'}); @@ -1557,7 +1564,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) { @@ -1634,7 +1641,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'}
'.$description.''.$description.''. &Apache::lonhtmlcommon::date_setter('envform', @@ -2266,17 +2288,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 @@ -2345,8 +2371,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}) { @@ -2414,7 +2439,7 @@ sub storedata { } &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{$_}); @@ -2468,7 +2493,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 { @@ -2526,7 +2551,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; @@ -2535,12 +2560,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) { @@ -2567,19 +2592,10 @@ 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(). @@ -2595,7 +2611,7 @@ sub listdata { &Apache::lonhtmlcommon::date_setter('parmform', $jskey, $$resourcedata{$thiskey}, - '',1,'','',$hour,$min,$sec). + '',1,'',''). ''. &date_sanity_info($$resourcedata{$thiskey}) ); @@ -2603,8 +2619,6 @@ sub listdata { my $showval; if (defined($$resourcedata{$thiskey})) { $showval=$$resourcedata{$thiskey}; - } else { - $showval=$val; } $r->print('