--- loncom/interface/lonparmset.pm 2007/01/18 21:14:04 1.350.2.6 +++ loncom/interface/lonparmset.pm 2007/06/19 22:35:11 1.370 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.350.2.6 2007/01/18 21:14:04 albertel Exp $ +# $Id: lonparmset.pm,v 1.370 2007/06/19 22:35:11 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').'
'. @@ -2194,10 +2226,7 @@ sub crsenv { ' 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').' )', + => &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,7 +2236,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').')', @@ -2217,12 +2246,15 @@ 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', 'plc.roles.denied','plc.users.denied', 'pch.roles.denied','pch.users.denied', @@ -2244,6 +2276,7 @@ sub crsenv { 'default_enrollment_start_date', 'default_enrollment_end_date', 'tthoptions', + 'texengine', 'disablesigfigs', 'disableexampointprint', 'task_messages' @@ -2327,7 +2360,7 @@ $start_header_row $end_header_row $output $end_table - + $end_page ENDENV @@ -2409,11 +2442,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').'
'); + &mt('Error saving parameters').''); } &Apache::lonnet::devalidateuserresdata($tuname,$tudom); } else { @@ -2443,10 +2476,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').'
'); + &mt('Error saving parameters').''); } &Apache::lonnet::devalidateuserresdata($tuname,$tudom); } else { @@ -2475,10 +2508,10 @@ sub storedata { 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').'
'); + &mt('Error saving parameters').''); } &Apache::lonnet::devalidatecourseresdata($crs,$dom); } @@ -2759,7 +2792,7 @@ ENDOVER &listdata($r,$resourcedata,$listdata,$sortorder); } $r->print(&tableend(). - ((($env{'form.store'}) || ($env{'form.dis'}))?'

':''). + ((($env{'form.store'}) || ($env{'form.dis'}))?'

':''). ''.&Apache::loncommon::end_page()); } @@ -2875,6 +2908,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 +2937,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(''); } @@ -3111,6 +3149,7 @@ ENDMAINFORMHEAD my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'}); + my $mgr = &Apache::lonnet::allowed('mgr',$env{'request.course.id'}); my @menu = ( { divider=>'Settings for Your Course', @@ -3128,6 +3167,11 @@ ENDMAINFORMHEAD url => '/adm/slotrequest?command=showslots', permission => $vgr, }, + { text => 'Reset Student Access Times', + url => '/adm/helper/resettimes.helper', + permission => $mgr, + }, + { text => 'Set Parameter Setting Default Actions', action => 'setdefaults', permission => $parm_permission, @@ -3189,7 +3233,6 @@ ENDMAINFORMHEAD ### Set portfolio metadata sub output_row { my ($r, $field_name, $field_text, $added_flag) = @_; - my $row_class; my $output; my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'}; my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'}; @@ -3198,26 +3241,47 @@ sub output_row { $values = ''; } if (!($options =~ /deleted/)) { - $output = &Apache::loncommon::start_data_table_row(); - $output .= ''.$field_text.':'; - # $output .= ''.$field_text.':'; - $output .= ''; - $output .= &Apache::loncommon::end_data_table_row(); my @options= ( ['active', 'Show to student'], - ['onlyone','Student may select only one choice'], - ['stuadd', 'Student may type choices']); + ['stuadd', 'Provide text area for students to type catalog information'], + ['choices','Provide choices for students to select from']); +# ['onlyone','Student may select only one choice']); if ($added_flag) { push @options,['deleted', 'Delete Metadata Field']; } + $output = &Apache::loncommon::start_data_table_row(); + $output .= ''.$field_text.':'; + $output .= &Apache::loncommon::end_data_table_row(); foreach my $opt (@options) { my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ; $output .= &Apache::loncommon::continue_data_table_row(); - $output .= ''.(' ' x 5).' '; + $output .= ''.(' ' x 5).' '; $output .= &Apache::loncommon::end_data_table_row(); } - + $output .= &Apache::loncommon::continue_data_table_row(); + $output .= ''.(' ' x 10).''; + $output .= &Apache::loncommon::end_data_table_row(); + my $multiple_checked; + my $single_checked; + if ($options =~ m/onlyone/) { + $multiple_checked = ""; + $single_checked = " CHECKED "; + } else { + $multiple_checked = " CHECKED "; + $single_checked = ""; + } + $output .= &Apache::loncommon::continue_data_table_row(); + $output .= ''.(' ' x 10).' + + Student may select multiple choices from list'; + $output .= &Apache::loncommon::end_data_table_row(); + $output .= &Apache::loncommon::continue_data_table_row(); + $output .= ''.(' ' x 10).' + + Student may select only one choice from list'; + $output .= &Apache::loncommon::end_data_table_row(); } return ($output); } @@ -3268,7 +3332,7 @@ sub order_meta_fields { {'metadata.addedorder'=>$ordered_fields},$dom,$crs); &Apache::lonnet::appenv('course.'.$env{'request.course.id'}.'.metadata.addedorder' => $ordered_fields); } - my $fields = &get_added_meta_fieldnames(); + my $fields = &get_added_meta_fieldnames($env{'request.course.id'}); my $ordered_fields; my @fields_in_order = split /,/,$env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'}; if (!@fields_in_order) { @@ -3340,7 +3404,7 @@ sub addmetafield { $r->print('Added new Metadata Field '.$env{'form.fieldname'}." with result ".$put_result.'
'); $r->print(&continue()); } else { - my $fields = &get_deleted_meta_fieldnames(); + 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('
'); @@ -3353,8 +3417,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)=@_; @@ -3379,7 +3443,10 @@ sub setrestrictmeta { if ($env{'form.'.$meta_field.'_stuadd'}) { $options.='stuadd,'; } - if ($env{'form.'.$meta_field.'_onlyone'}) { + if ($env{'form.'.$meta_field.'_choices'}) { + $options.='choices,'; + } + if ($env{'form.'.$meta_field.'_onlyone'} eq 'single') { $options.='onlyone,'; } if ($env{'form.'.$meta_field.'_active'}) { @@ -3388,7 +3455,6 @@ sub setrestrictmeta { if ($env{'form.'.$meta_field.'_deleted'}) { $options.='deleted,'; } - my $name = $save_field; $put_result = &Apache::lonnet::put('environment', {'metadata.'.$meta_field.'.options'=>$options, @@ -3403,7 +3469,7 @@ sub setrestrictmeta { # Get the default metadata fields my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio'); # Now get possible added metadata fields - my $added_metadata_fields = &get_added_meta_fieldnames(\%metadata_fields); + my $added_metadata_fields = &get_added_meta_fieldnames($env{'request.course.id'}); my $row_alt = 1; $output .= &Apache::loncommon::start_data_table(); foreach my $field (sort(keys(%metadata_fields))) { @@ -3412,6 +3478,16 @@ sub setrestrictmeta { $output.= &output_row($r, $field, $metadata_fields{$field}); } } + my $buttons = (< +
+
+ +
+
+
+ +ENDButtons my $added_flag = 1; foreach my $field (sort(keys(%$added_metadata_fields))) { $row_alt = $row_alt ? 0 : 1; @@ -3421,14 +3497,7 @@ sub setrestrictmeta { $r->print(< $output - -
-
- -
-
-
- + $buttons
ENDenv $r->print(&Apache::loncommon::end_page()); @@ -3436,9 +3505,10 @@ ENDenv } ################################################## sub get_added_meta_fieldnames { + my ($cid) = @_; my %fields; foreach my $key(%env) { - if ($key =~ m/\.metadata\.(.+)\.added$/) { + if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) { my $field_name = $1; my ($display_field_name) = $env{$key}; $fields{$field_name} = $display_field_name; @@ -3447,10 +3517,10 @@ sub get_added_meta_fieldnames { return \%fields; } sub get_deleted_meta_fieldnames { + my ($cid) = @_; my %fields; - my ($default_fields) = @_; foreach my $key(%env) { - if ($key =~ m/\.metadata\.(.+)\.added$/) { + if ($key =~ m/\Q$cid\E\.metadata\.(.+)\.added$/) { my $field_name = $1; if ($env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'} =~ m/deleted/) { my ($display_field_name) = $env{$key}; @@ -3615,7 +3685,7 @@ ENDYESNO } $r->print(&Apache::loncommon::end_data_table(). "\n\n". + &mt('Save Rules')."' />\n". &Apache::loncommon::end_page()); return; }