--- loncom/interface/lonparmset.pm 2007/01/12 20:04:16 1.357 +++ loncom/interface/lonparmset.pm 2007/03/20 00:08:09 1.364 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.357 2007/01/12 20:04:16 raeburn Exp $ +# $Id: lonparmset.pm,v 1.364 2007/03/20 00:08:09 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -554,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; } @@ -934,57 +935,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})) { + 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)'; } } @@ -2034,6 +2044,22 @@ 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$/) { + my ($user,$domain) = split(/:/,$value); + if (!defined($user) || !defined($domain)) { + $setoutput.= '
'. + &mt("Invalid email address specified, address must be of the form username:domain"). + ''; + undef($value); + } elsif (&Apache::lonnet::homeserver($user,$domain) eq 'no_host') { + $setoutput.= '
'. + &mt("Invalid email address specified, user [_1] is unknown.",$value). + ''; + undef($value); + } + } # Get existing cloners my @oldcloner = (); if ($name eq 'cloners') { @@ -2121,10 +2147,16 @@ sub crsenv { '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').'
'. @@ -2207,7 +2239,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').')', @@ -2222,7 +2254,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', @@ -2875,6 +2907,11 @@ ENDOVER '' ); $r->print(''); + my $display_value = $resourcedata->{$thiskey}; + if (&isdateparm($resourcedata->{$thiskey.'.type'})) { + $display_value = + &Apache::lonlocal::locallocaltime($display_value); + } $r->print(&mt('Parameter: "[_1]" with value: "[_2]"', &standard_parameter_names($data{'parameter_name'}), $resourcedata->{$thiskey})); @@ -2899,7 +2936,7 @@ ENDOVER $r->print(&mt('Resource: [_1]
   with ID: [_2]
   in folder [_3]', $url,$resid,$map)); } - $r->print(&mt('Part: [_1]',$data{'parameter_part'})); + $r->print('
   '.&mt('Part: [_1]',$data{'parameter_part'})); $r->print(''); } @@ -3323,6 +3360,13 @@ sub order_meta_fields { $r->print(''); return 'ok'; } +sub continue { + my $output; + $output .= '
'; + $output .= ''; + $output .= ''; + return ($output); +} sub addmetafield { my ($r)=@_; $r->print(&Apache::loncommon::start_page('Add Metadata Field')); @@ -3330,7 +3374,7 @@ sub addmetafield { my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; if (exists($env{'form.undelete'})) { - my @meta_fields = &Apache::loncommon::get_env_multiple('form.undelete'); + my @meta_fields = &Apache::loncommon::get_env_multiple('form.undeletefield'); foreach my $meta_field(@meta_fields) { my $options = $env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.options'}; $options =~ s/deleted//; @@ -3340,9 +3384,7 @@ sub addmetafield { $r->print('Undeleted Metadata Field '.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}." with result ".$put_result.'
'); } - $r->print(''); - $r->print(''); - $r->print(''); + $r->print(&continue()); } elsif (exists($env{'form.fieldname'})) { my $meta_field = $env{'form.fieldname'}; my $display_field = $env{'form.fieldname'}; @@ -3352,14 +3394,15 @@ sub addmetafield { {'metadata.'.$meta_field.'.values'=>"", 'metadata.'.$meta_field.'.added'=>"$display_field", 'metadata.'.$meta_field.'.options'=>""},$dom,$crs); - $r->print('Added new Metadata Field '.$env{'form.fieldname'}." with result ".$put_result); + $r->print('Added new Metadata Field '.$env{'form.fieldname'}." with result ".$put_result.'
'); + $r->print(&continue()); } else { my $fields = &get_deleted_meta_fieldnames($env{'request.course.id'}); if ($fields) { $r->print('You may undelete previously deleted fields.
Check those you wish to undelete and click Undelete.
'); $r->print(''); foreach my $key(keys(%$fields)) { - $r->print(''.$$fields{$key}.'
print(''.$$fields{$key}.'
print(''); $r->print('
'); @@ -3367,8 +3410,8 @@ sub addmetafield { $r->print('
Or you may enter a new metadata field name.
print('
'); $r->print(''); - $r->print('
'); } + $r->print(''); } sub setrestrictmeta { my ($r)=@_;