version 1.320, 2006/07/14 17:18:24
|
version 1.339, 2006/10/07 20:02:16
|
Line 524 sub valout {
|
Line 524 sub valout {
|
# Values of zero are valid. |
# Values of zero are valid. |
if (! $value && $value ne '0') { |
if (! $value && $value ne '0') { |
if ($editable) { |
if ($editable) { |
$result = '<img src="/adm/lonIcons/clickhere.gif" border="0" />'; |
$result = '<span class="LC_clickhere">*</span>'; |
} else { |
} else { |
$result=' '; |
$result=' '; |
} |
} |
Line 660 sub startpage {
|
Line 660 sub startpage {
|
&page_js(), |
&page_js(), |
{'add_entries' => \%loaditems,}); |
{'add_entries' => \%loaditems,}); |
my $breadcrumbs = |
my $breadcrumbs = |
&Apache::lonhtmlcommon::breadcrumbs('Table Mode Parameter Setting'); |
&Apache::lonhtmlcommon::breadcrumbs('Table Mode Parameter Setting','Table_Mode'); |
$r->print(<<ENDHEAD); |
$r->print(<<ENDHEAD); |
$start_page |
$start_page |
$breadcrumbs |
$breadcrumbs |
Line 1514 sub assessparms {
|
Line 1514 sub assessparms {
|
$message="\n<p>\n".&mt("Full Name").": ". |
$message="\n<p>\n".&mt("Full Name").": ". |
$name{'firstname'}.' '.$name{'middlename'}.' ' |
$name{'firstname'}.' '.$name{'middlename'}.' ' |
.$name{'lastname'}.' '.$name{'generation'}. |
.$name{'lastname'}.' '.$name{'generation'}. |
"<br>\n".&mt('ID').": ".$name{'id'}.'<p>'; |
"<br />\n".&mt('ID').": ".$name{'id'}.'<p>'; |
} |
} |
@usersgroups = &Apache::lonnet::get_users_groups( |
@usersgroups = &Apache::lonnet::get_users_groups( |
$udom,$uname,$env{'request.course.id'}); |
$udom,$uname,$env{'request.course.id'}); |
Line 1562 sub assessparms {
|
Line 1562 sub assessparms {
|
foreach ('tolerance','date_default','date_start','date_end', |
foreach ('tolerance','date_default','date_start','date_end', |
'date_interval','int','float','string') { |
'date_interval','int','float','string') { |
$r->print('<input type="hidden" value="'. |
$r->print('<input type="hidden" value="'. |
$env{'form.recent_'.$_}.'" name="recent_'.$_.'">'); |
$env{'form.recent_'.$_}.'" name="recent_'.$_.'" />'); |
} |
} |
|
|
if (!$pssymb) { |
if (!$pssymb) { |
Line 1639 sub assessparms {
|
Line 1639 sub assessparms {
|
); |
); |
$r->print(<<ENDTABLETWO); |
$r->print(<<ENDTABLETWO); |
<th rowspan=3>$lt{'pie'}</th> |
<th rowspan=3>$lt{'pie'}</th> |
<th rowspan=3>$lt{'csv'}<br>($csuname $lt{'at'} $csudom)</th> |
<th rowspan=3>$lt{'csv'}<br />($csuname $lt{'at'} $csudom)</th> |
</tr><tr><td colspan=5></td><th colspan=2>$lt{'ic'}</th><th colspan=2>$lt{'rl'}</th> |
</tr><tr><td colspan=5></td><th colspan=2>$lt{'ic'}</th><th colspan=2>$lt{'rl'}</th> |
<th colspan=1>$lt{'ic'}</th> |
<th colspan=1>$lt{'ic'}</th> |
|
|
Line 1740 ENDTABLEHEADFOUR
|
Line 1740 ENDTABLEHEADFOUR
|
"<a href=\"javascript:openWindow('". |
"<a href=\"javascript:openWindow('". |
&Apache::lonnet::clutter($uri).'?symb='. |
&Apache::lonnet::clutter($uri).'?symb='. |
&escape($symbp{$rid}). |
&escape($symbp{$rid}). |
"', 'metadatafile', '450', '500', 'no', 'yes')\";". |
"', 'metadatafile', '450', '500', 'no', 'yes');\"". |
" TARGET=_self>$title"); |
" target=\"_self\">$title"); |
|
|
if ($thistitle) { |
if ($thistitle) { |
$r->print(' ('.$thistitle.')'); |
$r->print(' ('.$thistitle.')'); |
Line 2005 sub crsenv {
|
Line 2005 sub crsenv {
|
('environment', |
('environment', |
{'top level map backup '.$bkuptime => $tmp[1] }, |
{'top level map backup '.$bkuptime => $tmp[1] }, |
$dom,$crs). |
$dom,$crs). |
'<br>'; |
'<br />'; |
} |
} |
# |
# |
# Deal with modified default spreadsheets |
# Deal with modified default spreadsheets |
Line 2116 sub crsenv {
|
Line 2116 sub crsenv {
|
'default_xml_style' => '<b>'.&mt('Default XML Style File').'</b> '. |
'default_xml_style' => '<b>'.&mt('Default XML Style File').'</b> '. |
'<a href="javascript:openbrowser'. |
'<a href="javascript:openbrowser'. |
"('envform','default_xml_style'". |
"('envform','default_xml_style'". |
",'sty')\">$SelectStyleFile</a><br>", |
",'sty')\">$SelectStyleFile</a><br />", |
'question.email' => '<b>'.&mt('Feedback Addresses for Resource Content Question'). |
'question.email' => '<b>'.&mt('Feedback Addresses for Resource Content Question'). |
'</b><br />(<tt>user:domain,'. |
'</b><br />(<tt>user:domain,'. |
'user:domain(section;section;...;*;...),...</tt>)', |
'user:domain(section;section;...;*;...),...</tt>)', |
Line 2310 sub crsenv {
|
Line 2310 sub crsenv {
|
'</script>'; |
'</script>'; |
|
|
my $start_page = |
my $start_page = |
&Apache::loncommon::start_page('Set Course Environment Parameters', |
&Apache::loncommon::start_page('Set Course Environment', |
$browse_js); |
$browse_js); |
my $end_page = |
my $end_page = |
&Apache::loncommon::end_page(); |
&Apache::loncommon::end_page(); |
Line 2432 sub storedata {
|
Line 2432 sub storedata {
|
} |
} |
&Apache::lonnet::devalidateuserresdata($tuname,$tudom); |
&Apache::lonnet::devalidateuserresdata($tuname,$tudom); |
} else { |
} else { |
push (@deldata,$thiskey); |
push (@deldata,$thiskey,$thiskey.'.type'); |
} |
} |
} elsif ($cmd eq 'datepointer') { |
} elsif ($cmd eq 'datepointer') { |
my $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_}); |
my $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_}); |
Line 2589 sub listdata {
|
Line 2589 sub listdata {
|
$oldpart=$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 |
# Ready to print |
# |
# |
$r->print(&tablestart(). |
$r->print(&tablestart(). |
Line 2613 sub listdata {
|
Line 2604 sub listdata {
|
&Apache::lonhtmlcommon::date_setter('parmform', |
&Apache::lonhtmlcommon::date_setter('parmform', |
$jskey, |
$jskey, |
$$resourcedata{$thiskey}, |
$$resourcedata{$thiskey}, |
'',1,'','',$hour,$min,$sec). |
'',1,'',''). |
'<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'. |
'<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'. |
&date_sanity_info($$resourcedata{$thiskey}) |
&date_sanity_info($$resourcedata{$thiskey}) |
); |
); |
Line 2621 sub listdata {
|
Line 2612 sub listdata {
|
my $showval; |
my $showval; |
if (defined($$resourcedata{$thiskey})) { |
if (defined($$resourcedata{$thiskey})) { |
$showval=$$resourcedata{$thiskey}; |
$showval=$$resourcedata{$thiskey}; |
} else { |
|
$showval=$val; |
|
} |
} |
$r->print('<label><input type="radio" name="set_'.$thiskey. |
$r->print('<label><input type="radio" name="set_'.$thiskey. |
'" value="yes"'); |
'" value="yes"'); |
Line 2640 sub listdata {
|
Line 2629 sub listdata {
|
my $showval; |
my $showval; |
if (defined($$resourcedata{$thiskey})) { |
if (defined($$resourcedata{$thiskey})) { |
$showval=$$resourcedata{$thiskey}; |
$showval=$$resourcedata{$thiskey}; |
} else { |
|
$showval=$val; |
|
} |
} |
$r->print('<input type="text" name="set_'.$thiskey.'" value="'. |
$r->print('<input type="text" name="set_'.$thiskey.'" value="'. |
$showval.'">'); |
$showval.'">'); |
Line 2845 ENDOVER
|
Line 2832 ENDOVER
|
&Apache::loncommon::end_page()); |
&Apache::loncommon::end_page()); |
} |
} |
|
|
|
sub clean_parameters { |
|
my ($r) = @_; |
|
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
|
|
my $start_page=&Apache::loncommon::start_page('Clean Parameters'); |
|
my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Clean'); |
|
$r->print(<<ENDOVER); |
|
$start_page |
|
$breadcrumbs |
|
<form method="post" action="/adm/parmset?action=cleanparameters" name="parmform"> |
|
ENDOVER |
|
# Store modified |
|
|
|
&storedata($r,$crs,$dom); |
|
|
|
# Read modified data |
|
|
|
my $resourcedata=&readdata($crs,$dom); |
|
|
|
# List data |
|
|
|
$r->print('<h3>'. |
|
&mt('These parameters refer to resources that do not exist.'). |
|
'</h3>'. |
|
'<input type="submit" value="'.&mt('Delete Checked Parameters').'" />'.'<br />'. |
|
'<br />'); |
|
$r->print(&Apache::loncommon::start_data_table(). |
|
'<tr>'. |
|
'<th>'.&mt('Delete').'</th>'. |
|
'<th>'.&mt('Parameter').'</th>'. |
|
'</tr>'); |
|
foreach my $thiskey (sort(keys(%{$resourcedata}))) { |
|
next if (!exists($resourcedata->{$thiskey.'.type'}) |
|
&& $thiskey=~/\.type$/); |
|
my %data = &parse_key($thiskey); |
|
if (exists($data{'realm_exists'}) |
|
&& !$data{'realm_exists'}) { |
|
$r->print(&Apache::loncommon::start_data_table_row(). |
|
'<tr>'. |
|
'<td><input type="checkbox" name="del_'.$thiskey.'" /></td>' ); |
|
|
|
$r->print('<td>'); |
|
$r->print(&mt('Parameter: "[_1]" with value: "[_2]"', |
|
&standard_parameter_names($data{'parameter_name'}), |
|
$resourcedata->{$thiskey})); |
|
$r->print('<br />'); |
|
if ($data{'scope_type'} eq 'all') { |
|
$r->print(&mt('All users')); |
|
} elsif ($data{'scope_type'} eq 'user') { |
|
$r->print(&mt('User: [_1]',join(':',@{$data{'scope'}}))); |
|
} elsif ($data{'scope_type'} eq 'section') { |
|
$r->print(&mt('Section: [_1]',$data{'scope'})); |
|
} elsif ($data{'scope_type'} eq 'group') { |
|
$r->print(&mt('Group: [_1]',$data{'scope'})); |
|
} |
|
$r->print('<br />'); |
|
if ($data{'realm_type'} eq 'all') { |
|
$r->print(&mt('All Resources')); |
|
} elsif ($data{'realm_type'} eq 'folder') { |
|
$r->print(&mt('Folder: [_1]'),$data{'realm'}); |
|
} elsif ($data{'realm_type'} eq 'symb') { |
|
my ($map,$resid,$url) = |
|
&Apache::lonnet::decode_symb($data{'realm'}); |
|
$r->print(&mt('Resource: [_1] <br /> with ID: [_2] <br /> in folder [_3]', |
|
$url,$resid,$map)); |
|
} |
|
$r->print(&mt('Part: [_1]',$data{'parameter_part'})); |
|
$r->print('</td></tr>'); |
|
|
|
} |
|
} |
|
$r->print(&Apache::loncommon::end_data_table().'<p>'. |
|
'<input type="submit" value="'.&mt('Delete Checked Parameters').'" />'. |
|
'</p></form>'. |
|
&Apache::loncommon::end_page()); |
|
} |
|
|
|
sub parse_key { |
|
my ($key) = @_; |
|
my %data; |
|
my ($middle,$part,$name)= |
|
($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/); |
|
$data{'scope_type'} = 'all'; |
|
if ($middle=~/^\[(.*)\]/) { |
|
$data{'scope'} = $1; |
|
if ($data{'scope'}=~/^useropt\:(\w+)\:(\w+)/) { |
|
$data{'scope_type'} = 'user'; |
|
$data{'scope'} = [$1,$2]; |
|
} else { |
|
#FIXME check for group scope |
|
$data{'scope_type'} = 'section'; |
|
} |
|
$middle=~s/^\[(.*)\]//; |
|
} |
|
$middle=~s/\.+$//; |
|
$middle=~s/^\.+//; |
|
$data{'realm_type'}='all'; |
|
if ($middle=~/^(.+)\_\_\_\(all\)$/) { |
|
$data{'realm'} = $1; |
|
$data{'realm_type'} = 'folder'; |
|
$data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'}); |
|
($data{'realm_exists'}) = &Apache::lonnet::is_on_map($data{'realm'}); |
|
&Apache::lonnet::logthis($1." siad ". $data{'realm_exists'} ); |
|
} elsif ($middle) { |
|
$data{'realm'} = $middle; |
|
$data{'realm_type'} = 'symb'; |
|
$data{'realm_title'} = &Apache::lonnet::gettitle($data{'realm'}); |
|
my ($map,$resid,$url) = &Apache::lonnet::decode_symb($data{'realm'}); |
|
$data{'realm_exists'} = &Apache::lonnet::symbverify($data{'realm'},$url); |
|
} |
|
|
|
$data{'parameter_part'} = $part; |
|
$data{'parameter_name'} = $name; |
|
|
|
return %data; |
|
} |
|
|
################################################## |
################################################## |
################################################## |
################################################## |
|
|
=pod |
=pod |
|
|
=item check_cloners |
=item check_cloners |
Line 3008 ENDMAINFORMHEAD
|
Line 3113 ENDMAINFORMHEAD
|
my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'}); |
my $vgr = &Apache::lonnet::allowed('vgr',$env{'request.course.id'}); |
|
|
my @menu = |
my @menu = |
( |
( { divider=>'Settings for Your Course', |
{ text => 'Set Course Environment Parameters', |
}, |
|
{ text => 'Set Course Environment', |
action => 'crsenv', |
action => 'crsenv', |
permission => $parm_permission, |
permission => $parm_permission, |
|
help => 'Course_Environment', |
}, |
}, |
{ text => 'Set Portfolio Metadata', |
{ text => 'Set Portfolio Metadata', |
action => 'setrestrictmeta', |
action => 'setrestrictmeta', |
Line 3021 ENDMAINFORMHEAD
|
Line 3128 ENDMAINFORMHEAD
|
url => '/adm/slotrequest?command=showslots', |
url => '/adm/slotrequest?command=showslots', |
permission => $vgr, |
permission => $vgr, |
}, |
}, |
{ divider => 1, |
{ text => 'Set Parameter Setting Default Actions', |
|
action => 'setdefaults', |
|
permission => $parm_permission, |
|
}, |
|
{ divider => 'New and Existing Parameter Settings for Your Resources', |
}, |
}, |
{ text => 'Set/Modify Resource Parameters - Helper Mode', |
{ text => 'Set/Modify Resource Parameters - Helper Mode', |
url => '/adm/helper/parameter.helper', |
url => '/adm/helper/parameter.helper', |
permission => $parm_permission, |
permission => $parm_permission, |
|
help => 'Parameter_Helper', |
}, |
}, |
{ text => 'Modify Resource Parameters - Overview Mode', |
{ text => 'Set/Modify Resource Parameters - Overview Mode', |
action => 'setoverview', |
|
permission => $parm_permission, |
|
}, |
|
{ text => 'Set Resource Parameters - Overview Mode', |
|
action => 'newoverview', |
action => 'newoverview', |
permission => $parm_permission, |
permission => $parm_permission, |
|
help => 'Parameter_Overview', |
}, |
}, |
{ text => 'Set/Modify Resource Parameters - Table Mode', |
{ text => 'Set/Modify Resource Parameters - Table Mode', |
action => 'settable', |
action => 'settable', |
permission => $parm_permission, |
permission => $parm_permission, |
help => 'Cascading_Parameters', |
help => 'Table_Mode', |
}, |
}, |
{ text => 'Set Parameter Setting Default Actions', |
{ divider => 'Existing Parameter Settings for Your Resources', |
action => 'setdefaults', |
}, |
|
{ text => 'Modify Resource Parameters - Overview Mode', |
|
action => 'setoverview', |
permission => $parm_permission, |
permission => $parm_permission, |
}, |
help => 'Parameter_Overview', |
|
}, |
{ text => 'Parameter Change Log and Course Blog Posting/User Notification', |
{ text => 'Parameter Change Log and Course Blog Posting/User Notification', |
action => 'parameterchangelog', |
action => 'parameterchangelog', |
permission => $parm_permission, |
permission => $parm_permission, |
Line 3052 ENDMAINFORMHEAD
|
Line 3164 ENDMAINFORMHEAD
|
my $menu_html = ''; |
my $menu_html = ''; |
foreach my $menu_item (@menu) { |
foreach my $menu_item (@menu) { |
if ($menu_item->{'divider'}) { |
if ($menu_item->{'divider'}) { |
$menu_html .= '<hr />'; |
$menu_html .= '<h3>'.&mt($menu_item->{'divider'}).'</h3>'; |
next; |
next; |
} |
} |
next if (! $menu_item->{'permission'}); |
next if (! $menu_item->{'permission'}); |
Line 3076 ENDMAINFORMHEAD
|
Line 3188 ENDMAINFORMHEAD
|
} |
} |
### Set portfolio metadata |
### Set portfolio metadata |
sub output_row { |
sub output_row { |
my ($r, $field_name, $field_text) = @_; |
my ($r, $field_name, $field_text, $added_flag) = @_; |
my $output; |
my $output; |
my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'}; |
my $options=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.options'}; |
my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'}; |
my $values=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name.'.values'}; |
unless (defined($options)) { |
if (!defined($options)) { |
$options = 'active,stuadd'; |
$options = 'active,stuadd'; |
$values = ''; |
$values = ''; |
} |
} |
$output.='<strong>'.$field_text.':</strong>'; |
if (!($options =~ /deleted/)) { |
$output.='<input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /><br />'; |
$output.='<strong>'.$field_text.':</strong>'; |
|
$output.='<input name="'.$field_name.'_values" type="text" value="'.$values.'" size="80" /><br />'; |
|
|
my @options= ( ['active', 'Show to student'], |
my @options= ( ['active', 'Show to student'], |
['onlyone','Student may select only one choice'], |
['onlyone','Student may select only one choice'], |
['stuadd', 'Student may type choices']); |
['stuadd', 'Student may type choices']); |
foreach my $opt (@options) { |
if ($added_flag) { |
my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ; |
push @options,['deleted', 'Delete Metadata Field']; |
$output.=(' 'x5).'<label><input type="checkbox" name="'. |
} |
$field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'. |
foreach my $opt (@options) { |
&mt($opt->[1]).'</label> <br />'; |
my $checked = ($options =~ m/$opt->[0]/) ? ' checked="checked" ' : '' ; |
|
$output.=(' 'x5).'<label><input type="checkbox" name="'. |
|
$field_name.'_'.$opt->[0].'" value="yes"'.$checked.' />'. |
|
&mt($opt->[1]).'</label> <br />'; |
|
} |
} |
} |
return ($output); |
return ($output); |
} |
} |
|
sub addmetafield { |
|
my ($r)=@_; |
|
$r->print(&Apache::loncommon::start_page('Add Metadata Field')); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Add Metadata Field')); |
|
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'); |
|
foreach my $meta_field(@meta_fields) { |
|
my $options = $env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.options'}; |
|
$options =~ s/deleted//; |
|
$options =~ s/,,/,/; |
|
my $put_result = &Apache::lonnet::put('environment', |
|
{'metadata.'.$meta_field.'.options'=>$options},$dom,$crs); |
|
|
|
$r->print('Undeleted Metadata Field <strong>'.$env{'course.'.$env{'request.course.id'}.'.metadata.'.$meta_field.'.added'}."</strong> with result ".$put_result.'<br />'); |
|
} |
|
$r->print('<form action="" method="post">'); |
|
$r->print('<input type="hidden" name="action" value="setrestrictmeta" />'); |
|
$r->print('<input type="submit" value="Continue" />'); |
|
} elsif (exists($env{'form.fieldname'})) { |
|
my $meta_field = $env{'form.fieldname'}; |
|
my $display_field = $env{'form.fieldname'}; |
|
$meta_field =~ s/\W/_/g; |
|
$meta_field =~ tr/A-Z/a-z/; |
|
my $put_result = &Apache::lonnet::put('environment', |
|
{'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); |
|
} else { |
|
my $fields = &get_deleted_meta_fieldnames(); |
|
if ($fields) { |
|
$r->print('You may undelete previously deleted fields.<br />Check those you wish to undelete and click Undelete.<br />'); |
|
$r->print('<form method="post" action="">'); |
|
foreach my $key(keys(%$fields)) { |
|
$r->print('<input type="checkbox" name="undelete" value="'.$key.'" />'.$$fields{$key}.'<br /'); |
|
} |
|
$r->print('<input type="submit" name="undelete" value="Undelete" />'); |
|
$r->print('</form>'); |
|
} |
|
$r->print('<hr /><strong>Or</strong> you may enter a new metadata field name.<form method="post" action="/adm/parmset?action=addmetadata"'); |
|
$r->print('<input type="text" name="fieldname" /><br />'); |
|
$r->print('<input type="submit" value="Add Metadata Field" />'); |
|
$r->print('</form>'); |
|
} |
|
} |
sub setrestrictmeta { |
sub setrestrictmeta { |
my ($r)=@_; |
my ($r)=@_; |
my $next_meta; |
my $next_meta; |
my $output; |
my $output; |
my $item_num; |
my $item_num; |
my $put_result; |
my $put_result; |
|
|
$r->print(&Apache::loncommon::start_page('Restrict Metadata')); |
$r->print(&Apache::loncommon::start_page('Restrict Metadata')); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata')); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Restrict Metadata')); |
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
Line 3129 sub setrestrictmeta {
|
Line 3291 sub setrestrictmeta {
|
if ($env{'form.'.$meta_field.'_active'}) { |
if ($env{'form.'.$meta_field.'_active'}) { |
$options.='active,'; |
$options.='active,'; |
} |
} |
|
if ($env{'form.'.$meta_field.'_deleted'}) { |
|
$options.='deleted,'; |
|
} |
|
|
my $name = $save_field; |
my $name = $save_field; |
$put_result = &Apache::lonnet::put('environment', |
$put_result = &Apache::lonnet::put('environment', |
{'metadata.'.$meta_field.'.options'=>$options, |
{'metadata.'.$meta_field.'.options'=>$options, |
Line 3140 sub setrestrictmeta {
|
Line 3306 sub setrestrictmeta {
|
} |
} |
&Apache::lonnet::coursedescription($env{'request.course.id'}, |
&Apache::lonnet::coursedescription($env{'request.course.id'}, |
{'freshen_cache' => 1}); |
{'freshen_cache' => 1}); |
|
# Get the default metadata fields |
my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio'); |
my %metadata_fields = &Apache::lonmeta::fieldnames('portfolio'); |
|
# Now get possible added metadata fields |
|
my $added_metadata_fields = &get_added_meta_fieldnames(\%metadata_fields); |
foreach my $field (sort(keys(%metadata_fields))) { |
foreach my $field (sort(keys(%metadata_fields))) { |
&Apache::lonnet::logthis ($field); |
|
if ($field ne 'courserestricted') { |
if ($field ne 'courserestricted') { |
$output.= &output_row($r, $field, $metadata_fields{$field}); |
$output.= &output_row($r, $field, $metadata_fields{$field}); |
} |
} |
} |
} |
|
my $added_flag = 1; |
|
foreach my $field (sort(keys(%$added_metadata_fields))) { |
|
$output.= &output_row($r, $field, $$added_metadata_fields{$field},$added_flag); |
|
} |
$r->print(<<ENDenv); |
$r->print(<<ENDenv); |
<form method="post" action="/adm/parmset?action=setrestrictmeta" name="form"> |
<form method="post" action="/adm/parmset?action=setrestrictmeta" name="form"> |
<p> |
<p> |
$output |
$output |
<input type="submit" name="restrictmeta" value="Update Metadata Restrictions"> |
<input type="submit" name="restrictmeta" value="Update Metadata Restrictions"> |
|
</form><br /> |
|
<form method="post" action="/adm/parmset?action=addmetadata" name="form"> |
|
<input type="submit" name="restrictmeta" value="Add a Metadata Field"> |
</form> |
</form> |
ENDenv |
ENDenv |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
return 'ok'; |
return 'ok'; |
} |
} |
################################################## |
################################################## |
|
sub get_added_meta_fieldnames { |
|
my %fields; |
|
my ($default_fields) = @_; |
|
foreach my $key(%env) { |
|
if ($key =~ m/\.metadata\.(.+)\.added$/) { |
|
my $field_name = $1; |
|
my ($display_field_name) = $env{$key}; |
|
$fields{$field_name} = $display_field_name; |
|
} |
|
} |
|
return \%fields; |
|
} |
|
sub get_deleted_meta_fieldnames { |
|
my %fields; |
|
my ($default_fields) = @_; |
|
foreach my $key(%env) { |
|
if ($key =~ m/\.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}; |
|
$fields{$field_name} = $display_field_name; |
|
} |
|
} |
|
} |
|
return \%fields; |
|
} |
sub defaultsetter { |
sub defaultsetter { |
my ($r) = @_; |
my ($r) = @_; |
|
|
Line 3320 ENDYESNO
|
Line 3520 ENDYESNO
|
} |
} |
|
|
sub components { |
sub components { |
my ($key,$uname,$udom,$exeuser,$exedomain)=@_; |
my ($key,$uname,$udom,$exeuser,$exedomain,$typeflag)=@_; |
my $typeflag=0; |
|
if ($key=~/\.type$/) { |
if ($typeflag) { |
$key=~s/\.type$//; |
$key=~s/\.type$//; |
$typeflag=1; |
|
} |
} |
|
|
|
my ($middle,$part,$name)= |
|
($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/); |
my $issection; |
my $issection; |
my ($middle,$part,$name)=($key=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/); |
|
my $section=&mt('All Students'); |
my $section=&mt('All Students'); |
if ($middle=~/^\[(.*)\]/) { |
if ($middle=~/^\[(.*)\]/) { |
$issection=$1; |
$issection=$1; |
Line 3351 sub components {
|
Line 3553 sub components {
|
$realmdescription=&mt('resource').' '.&Apache::lonnet::gettitle($middle); |
$realmdescription=&mt('resource').' '.&Apache::lonnet::gettitle($middle); |
} |
} |
my $what=$part.'.'.$name; |
my $what=$part.'.'.$name; |
return ($realm,$section,$name,$part,$typeflag, |
return ($realm,$section,$name,$part, |
$what,$middle,$uname,$udom,$issection,$realmdescription); |
$what,$middle,$uname,$udom,$issection,$realmdescription); |
} |
} |
|
|
|
my %standard_parms; |
|
sub load_parameter_names { |
|
open(my $config,"<$Apache::lonnet::perlvar{'lonTabDir'}/packages.tab"); |
|
while (my $configline=<$config>) { |
|
if ($configline !~ /\S/ || $configline=~/^\#/) { next; } |
|
chomp($configline); |
|
my ($short,$plain)=split(/:/,$configline); |
|
my (undef,$name,$type)=split(/\&/,$short,3); |
|
if ($type eq 'display') { |
|
$standard_parms{$name} = $plain; |
|
} |
|
} |
|
close($config); |
|
$standard_parms{'int_pos'} = 'Positive Integer'; |
|
$standard_parms{'int_zero_pos'} = 'Positive Integer or Zero'; |
|
%standard_parms=&Apache::lonlocal::texthash(%standard_parms); |
|
} |
|
|
sub standard_parameter_names { |
sub standard_parameter_names { |
my ($name)=@_; |
my ($name)=@_; |
my %standard_parms=&Apache::lonlocal::texthash('duedate' => 'Due Date', |
if (!%standard_parms) { |
'answerdate' => 'Answer Date', |
&load_parameter_names(); |
'opendate' => 'Open Date', |
} |
'maxtries' => 'Max. Number of Tries', |
|
'weight' => 'Weight', |
|
'date_start' => 'Starting Date', |
|
'date_end' => 'Ending Date', |
|
'interval' => 'Time Interval Length', |
|
'tol' => 'Numerical Tolerance', |
|
'sig' => 'Significant Digits', |
|
'contentopen' => 'Content Opening Date', |
|
'contentclose' => 'Content Closing Date', |
|
'discussend' => 'End of Discussion Time', |
|
'discusshide' => 'Discussion Hidden', |
|
'problemstatus' => 'Problem Status Visible', |
|
'int_pos' => 'Positive Integer', |
|
'int_zero_pos' => 'Positive Integer or Zero', |
|
'hinttries' => 'Number of Tries till Hints appear', |
|
'numbubbles' => 'Number of Bubbles in Exam Mode'); |
|
if ($standard_parms{$name}) { |
if ($standard_parms{$name}) { |
return $standard_parms{$name}; |
return $standard_parms{$name}; |
} else { |
} else { |
Line 3390 sub standard_parameter_names {
|
Line 3594 sub standard_parameter_names {
|
|
|
sub parm_change_log { |
sub parm_change_log { |
my ($r)=@_; |
my ($r)=@_; |
&startpage($r); |
$r->print(&Apache::loncommon::start_page('Parameter Change Log')); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Parameter Change Log')); |
|
|
my %parmlog=&Apache::lonnet::dump('nohist_parameterlog', |
my %parmlog=&Apache::lonnet::dump('nohist_parameterlog', |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$env{'course.'.$env{'request.course.id'}.'.domain'}, |
$env{'course.'.$env{'request.course.id'}.'.num'}); |
$env{'course.'.$env{'request.course.id'}.'.num'}); |
|
|
if ((keys(%parmlog))[0]=~/^error\:/) { undef(%parmlog); } |
if ((keys(%parmlog))[0]=~/^error\:/) { undef(%parmlog); } |
|
|
$r->print('<form action="/adm/parmset?action=settable" |
$r->print('<form action="/adm/parmset?action=parameterchangelog" |
method="post" name"parameterlog"> |
method="post" name="parameterlog">'); |
<input type="hidden" name="action" |
|
value="parameterchangelog" />'); |
|
|
|
my %saveable_parameters = ('show' => 'scalar',); |
my %saveable_parameters = ('show' => 'scalar',); |
&Apache::loncommon::store_course_settings('parameter_log', |
&Apache::loncommon::store_course_settings('parameter_log', |
Line 3414 sub parm_change_log {
|
Line 3618 sub parm_change_log {
|
(&mt('all'),10,20,50,100,1000,10000)); |
(&mt('all'),10,20,50,100,1000,10000)); |
|
|
$r->print('<nobr>'.&mt('[_1] Records',$countselect).'</nobr>'. |
$r->print('<nobr>'.&mt('[_1] Records',$countselect).'</nobr>'. |
'<input type="submit" value="'.&mt('Display').'" />'); |
'<label>'.&Apache::lonhtmlcommon::checkbox('includetypes',$env{'form.includetypes'},'1'). |
|
' '.&mt('Include parameter types').'</label>'. |
|
'<input type="submit" value="'.&mt('Display').'" /></form>'); |
|
|
my $courseopt=&Apache::lonnet::get_courseresdata($env{'course.'.$env{'request.course.id'}.'.num'}, |
my $courseopt=&Apache::lonnet::get_courseresdata($env{'course.'.$env{'request.course.id'}.'.num'}, |
$env{'course.'.$env{'request.course.id'}.'.domain'}); |
$env{'course.'.$env{'request.course.id'}.'.domain'}); |
Line 3425 sub parm_change_log {
|
Line 3631 sub parm_change_log {
|
my $shown=0; |
my $shown=0; |
foreach my $id (sort { $parmlog{$b}{'exe_time'}<=>$parmlog{$a}{'exe_time'} } (keys(%parmlog))) { |
foreach my $id (sort { $parmlog{$b}{'exe_time'}<=>$parmlog{$a}{'exe_time'} } (keys(%parmlog))) { |
my @changes=keys(%{$parmlog{$id}{'logentry'}}); |
my @changes=keys(%{$parmlog{$id}{'logentry'}}); |
my $count=$#changes+1; |
my $count = 0; |
my $time = |
my $time = |
&Apache::lonlocal::locallocaltime($parmlog{$id}{'exe_time'}); |
&Apache::lonlocal::locallocaltime($parmlog{$id}{'exe_time'}); |
my $plainname = |
my $plainname = |
Line 3444 sub parm_change_log {
|
Line 3650 sub parm_change_log {
|
$parmlog{$id}{'exe_udom'}); |
$parmlog{$id}{'exe_udom'}); |
} |
} |
my $row_start=&Apache::loncommon::start_data_table_row(); |
my $row_start=&Apache::loncommon::start_data_table_row(); |
$r->print($row_start.'<td rowspan="'.$count.'">'.$time.'</td> |
$r->print($row_start); |
<td rowspan="'.$count.'">'.$about_me_link. |
|
'<br /><tt>'.$parmlog{$id}{'exe_uname'}. |
|
':'.$parmlog{$id}{'exe_udom'}.'</tt>'. |
|
$send_msg_link.'</td>'); |
|
my $makenewrow=0; |
my $makenewrow=0; |
my %istype=(); |
my %istype=(); |
|
my $output; |
foreach my $changed (reverse(sort(@changes))) { |
foreach my $changed (reverse(sort(@changes))) { |
my $value=$parmlog{$id}{'logentry'}->{$changed}; |
my $value=$parmlog{$id}{'logentry'}{$changed}; |
my ($realm,$section,$parmname,$part,$typeflag,$what,$middle,$uname,$udom,$issection,$realmdescription)= |
my $typeflag = ($changed =~/\.type$/ && |
&components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'}); |
!exists($parmlog{$id}{'logentry'}{$changed.'.type'})); |
if ($typeflag) { $istype{$parmname}=$value; } |
my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)= |
if ($makenewrow) { $r->print($row_start); } else { $makenewrow=1; } |
&components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag); |
$r->print('<td>'.$realm.'</td><td>'.$section.'</td><td>'. |
if ($typeflag) { |
|
$istype{$parmname}=$value; |
|
if (!$env{'form.includetypes'}) { next; } |
|
} |
|
$count++; |
|
if ($makenewrow) { |
|
$output .= $row_start; |
|
} else { |
|
$makenewrow=1; |
|
} |
|
$output .='<td>'.$realm.'</td><td>'.$section.'</td><td>'. |
&standard_parameter_names($parmname).'</td><td>'. |
&standard_parameter_names($parmname).'</td><td>'. |
($part?&mt('Part: [_1]',$part):&mt('All Parts')).'</td><td>'); |
($part?&mt('Part: [_1]',$part):&mt('All Parts')).'</td><td>'; |
my $stillactive=0; |
my $stillactive=0; |
if ($parmlog{$id}{'deleteflag'}) { |
if ($parmlog{$id}{'delflag'}) { |
$r->print(&mt('Deleted')); |
$output .= &mt('Deleted'); |
} else { |
} else { |
if ($typeflag) { |
if ($typeflag) { |
$r->print(&mt('Type: [_1]',&standard_parameter_names($value))); |
$output .= &mt('Type: [_1]',&standard_parameter_names($value)); |
} else { |
} else { |
my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what), |
my ($level,@all)=&parmval_by_symb($what,$middle,&Apache::lonnet::metadata($middle,$what), |
$uname,$udom,$issection,$issection,$courseopt); |
$uname,$udom,$issection,$issection,$courseopt); |
if (&isdateparm($istype{$parmname})) { |
if (&isdateparm($istype{$parmname})) { |
$r->print(&Apache::lonlocal::locallocaltime($value)); |
$output .= &Apache::lonlocal::locallocaltime($value); |
} else { |
} else { |
$r->print($value); |
$output .= $value; |
} |
} |
if ($value ne $all[$level]) { |
if ($value ne $all[$level]) { |
$r->print('<br /><span class="LC_warning">'.&mt('Not active anymore').'</span>'); |
$output .= '<br /><span class="LC_warning">'.&mt('Not active anymore').'</span>'; |
} else { |
} else { |
$stillactive=1; |
$stillactive=1; |
} |
} |
} |
} |
} |
} |
$r->print('</td>'); |
$output .= '</td><td>'; |
if ($stillactive) { |
if ($stillactive) { |
my $title=&mt('Changed [_1]',&standard_parameter_names($parmname)); |
my $title=&mt('Changed [_1]',&standard_parameter_names($parmname)); |
my $description=&mt('Changed [_1] for [_2] to [_3]',&standard_parameter_names($parmname),$realmdescription, |
my $description=&mt('Changed [_1] for [_2] to [_3]',&standard_parameter_names($parmname),$realmdescription, |
(&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value)); |
(&isdateparm($istype{$parmname})?&Apache::lonlocal::locallocaltime($value):$value)); |
if (($uname) && ($udom)) { |
if (($uname) && ($udom)) { |
$r->print('<td>'. |
$output .= |
&Apache::loncommon::messagewrapper('Notify User',$uname,$udom,$title,$description). |
&Apache::loncommon::messagewrapper('Notify User', |
'</td>'); |
$uname,$udom,$title, |
|
$description); |
} else { |
} else { |
$r->print('<td>'. |
$output .= |
&Apache::lonrss::course_blog_link($id,$title,$description). |
&Apache::lonrss::course_blog_link($id,$title, |
'</td>'); |
$description); |
} |
} |
} else { |
|
$r->print('<td> </td>'); |
|
} |
} |
$r->print(&Apache::loncommon::end_data_table_row()); |
$output .= '</td>'.&Apache::loncommon::end_data_table_row(); |
} |
} |
|
$r->print('<td rowspan="'.$count.'">'.$time.'</td> |
|
<td rowspan="'.$count.'">'.$about_me_link. |
|
'<br /><tt>'.$parmlog{$id}{'exe_uname'}. |
|
':'.$parmlog{$id}{'exe_udom'}.'</tt>'. |
|
$send_msg_link.'</td>'.$output); |
|
|
$shown++; |
$shown++; |
if (!($env{'form.show'} eq &mt('all') |
if (!($env{'form.show'} eq &mt('all') |
|| $shown<=$env{'form.show'})) { last; } |
|| $shown<=$env{'form.show'})) { last; } |
} |
} |
$r->print(&Apache::loncommon::end_data_table()); |
$r->print(&Apache::loncommon::end_data_table()); |
$r->print('</form>'); |
|
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
} |
} |
|
|
Line 3544 sub handler {
|
Line 3761 sub handler {
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset", |
&Apache::lonhtmlcommon::add_breadcrumb({href=>"/adm/parmset", |
text=>"Parameter Manager", |
text=>"Parameter Manager", |
faq=>10, |
faq=>10, |
bug=>'Instructor Interface'}); |
bug=>'Instructor Interface', |
|
help => 'Parameter_Manager'}); |
|
|
# ----------------------------------------------------- Needs to be in a course |
# ----------------------------------------------------- Needs to be in a course |
my $parm_permission = |
my $parm_permission = |
Line 3569 sub handler {
|
Line 3787 sub handler {
|
# the table mode |
# the table mode |
if ((($env{'form.command'} eq 'set') && ($env{'form.url'}) |
if ((($env{'form.command'} eq 'set') && ($env{'form.url'}) |
&& (!$env{'form.dis'})) || ($env{'form.symb'})) { |
&& (!$env{'form.dis'})) || ($env{'form.symb'})) { |
|
&Apache::lonhtmlcommon::add_breadcrumb({help=>'Problem_Parameters', |
|
text=>"Problem Parameters"}); |
&assessparms($r); |
&assessparms($r); |
|
|
} elsif (! exists($env{'form.action'})) { |
} elsif (! exists($env{'form.action'})) { |
Line 3583 sub handler {
|
Line 3803 sub handler {
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', |
text=>"Overview Mode"}); |
text=>"Overview Mode"}); |
&overview($r); |
&overview($r); |
|
} elsif ($env{'form.action'} eq 'addmetadata' && $parm_permission) { |
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=addmetadata', |
|
text=>"Add Metadata Field"}); |
|
&addmetafield($r); |
} elsif ($env{'form.action'} eq 'setrestrictmeta' && $parm_permission) { |
} elsif ($env{'form.action'} eq 'setrestrictmeta' && $parm_permission) { |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta', |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setrestrictmeta', |
text=>"Restrict Metadata"}); |
text=>"Restrict Metadata"}); |
Line 3604 sub handler {
|
Line 3828 sub handler {
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable', |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=settable', |
text=>"Parameter Change Log"}); |
text=>"Parameter Change Log"}); |
&parm_change_log($r); |
&parm_change_log($r); |
|
} elsif ($env{'form.action'} eq 'cleanparameters' && $parm_permission) { |
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=cleanparameters', |
|
text=>"Clean Parameters"}); |
|
&clean_parameters($r); |
} |
} |
} else { |
} else { |
# ----------------------------- Not in a course, or not allowed to modify parms |
# ----------------------------- Not in a course, or not allowed to modify parms |