--- loncom/interface/lonparmset.pm 2006/10/13 17:17:14 1.341
+++ loncom/interface/lonparmset.pm 2006/12/14 20:34:33 1.354
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set parameters for assessments
#
-# $Id: lonparmset.pm,v 1.341 2006/10/13 17:17:14 banghart Exp $
+# $Id: lonparmset.pm,v 1.354 2006/12/14 20:34:33 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);
@@ -2193,7 +2194,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',
+ => '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').' )',
@@ -2363,8 +2364,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}) {
@@ -2486,7 +2486,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 {
@@ -2544,7 +2544,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;
@@ -2918,7 +2918,7 @@ sub parse_key {
$data{'scope_type'} = 'all';
if ($middle=~/^\[(.*)\]/) {
$data{'scope'} = $1;
- if ($data{'scope'}=~/^useropt\:(\w+)\:(\w+)/) {
+ if ($data{'scope'}=~/^useropt\:($match_username)\:($match_domain)/) {
$data{'scope_type'} = 'user';
$data{'scope'} = [$1,$2];
} else {
@@ -3197,21 +3197,47 @@ sub output_row {
$values = '';
}
if (!($options =~ /deleted/)) {
- $output.=''.$field_text.':';
- $output.='
';
-
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.=(' 'x5).'
';
- }
+ $output .= &Apache::loncommon::continue_data_table_row();
+ $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);
}
@@ -3221,7 +3247,11 @@ sub order_meta_fields {
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'};
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'};
$r->print(&Apache::loncommon::start_page('Order Metadata Fields'));
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('Order Metadata Fields'));
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"/adm/parmset?action=setrestrictmeta",
+ text=>"Restrict Metadata"},
+ {text=>"Order Metadata"});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Order Metadata'));
if ($env{'form.storeorder'}) {
my $newpos = $env{'form.newpos'} - 1;
my $currentpos = $env{'form.currentpos'} - 1;
@@ -3254,9 +3284,9 @@ sub order_meta_fields {
}
}
my $ordered_fields = join ",", @neworder;
- $env{'course.'.$env{'request.course.id'}.'.metadata.addedorder'} = $ordered_fields;
my $put_result = &Apache::lonnet::put('environment',
- {'metadata.addedorder'=>$ordered_fields},$dom,$crs);
+ {'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 $ordered_fields;
@@ -3363,7 +3393,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'}) {
@@ -3372,7 +3405,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,
@@ -3388,27 +3420,34 @@ sub setrestrictmeta {
my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio');
# Now get possible added metadata fields
my $added_metadata_fields = &get_added_meta_fieldnames(\%metadata_fields);
+ my $row_alt = 1;
+ $output .= &Apache::loncommon::start_data_table();
foreach my $field (sort(keys(%metadata_fields))) {
if ($field ne 'courserestricted') {
+ $row_alt = $row_alt ? 0 : 1;
$output.= &output_row($r, $field, $metadata_fields{$field});
}
}
+ my $buttons = (<
+
+
+
+
-
-
-
ENDenv
$r->print(&Apache::loncommon::end_page());
@@ -3692,13 +3731,7 @@ sub parm_change_log {
\%saveable_parameters);
&Apache::loncommon::restore_course_settings('parameter_log',
\%saveable_parameters);
- if (!$env{'form.show'}) { $env{'form.show'}=10; }
-
- my $countselect =
- &Apache::lonmeta::selectbox('show',$env{'form.show'},undef,
- (&mt('all'),10,20,50,100,1000,10000));
-
- $r->print(''.&mt('[_1] Records',$countselect).''.
+ $r->print(&Apache::loncommon::display_filter().
''.
'');
@@ -3710,6 +3743,16 @@ sub parm_change_log {
&mt('Parameter').''.&mt('Part').' | '.&mt('New Value').' | '.&mt('Announce').' | '.
&Apache::loncommon::end_data_table_header_row());
my $shown=0;
+ my $folder='';
+ if ($env{'form.displayfilter'} eq 'currentfolder') {
+ my $last='';
+ if (tie(my %hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db',
+ &GDBM_READER(),0640)) {
+ $last=$hash{'last_known'};
+ untie(%hash);
+ }
+ if ($last) { ($folder) = &Apache::lonnet::decode_symb($last); }
+ }
foreach my $id (sort { $parmlog{$b}{'exe_time'}<=>$parmlog{$a}{'exe_time'} } (keys(%parmlog))) {
my @changes=keys(%{$parmlog{$id}{'logentry'}});
my $count = 0;
@@ -3731,7 +3774,6 @@ sub parm_change_log {
$parmlog{$id}{'exe_udom'});
}
my $row_start=&Apache::loncommon::start_data_table_row();
- $r->print($row_start);
my $makenewrow=0;
my %istype=();
my $output;
@@ -3741,6 +3783,11 @@ sub parm_change_log {
!exists($parmlog{$id}{'logentry'}{$changed.'.type'}));
my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)=
&components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag);
+ if ($env{'form.displayfilter'} eq 'currentfolder') {
+ if ($folder) {
+ if ($middle!~/^\Q$folder\E/) { next; }
+ }
+ }
if ($typeflag) {
$istype{$parmname}=$value;
if (!$env{'form.includetypes'}) { next; }
@@ -3793,13 +3840,20 @@ sub parm_change_log {
}
$output .= ''.&Apache::loncommon::end_data_table_row();
}
- $r->print(''.$time.' |
+ if ($env{'form.displayfilter'} eq 'containing') {
+ my $wholeentry=$about_me_link.':'.
+ $parmlog{$id}{'exe_uname'}.':'.$parmlog{$id}{'exe_udom'}.':'.
+ $output;
+ if ($wholeentry!~/\Q$env{'form.containingphrase'}\E/i) { next; }
+ }
+ if ($count) {
+ $r->print($row_start.''.$time.' |
'.$about_me_link.
' '.$parmlog{$id}{'exe_uname'}.
':'.$parmlog{$id}{'exe_udom'}.''.
$send_msg_link.' | '.$output);
-
- $shown++;
+ $shown++;
+ }
if (!($env{'form.show'} eq &mt('all')
|| $shown<=$env{'form.show'})) { last; }
}