version 1.236, 2005/06/28 15:56:35
|
version 1.252, 2005/09/28 13:29:17
|
Line 1330 sub assessparms {
|
Line 1330 sub assessparms {
|
} else { |
} else { |
my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb); |
my ($map,$id,$resource)=&Apache::lonnet::decode_symb($pssymb); |
$r->print(&mt('Specific Resource').": ".$resource. |
$r->print(&mt('Specific Resource').": ".$resource. |
'<input type="hidden" value="'.$pssymb.'" name="symb"><br />'); |
'<input type="hidden" value="'.$pssymb.'" name="symb">'. |
|
'<br /><label><b>'.&mt('Show all parts').': <input type="checkbox" name="psprt" value="all"'. |
|
($env{'form.psprt'}?' checked="checked"':'').' /></b></label><br />'); |
} |
} |
&usermenu($r,$uname,$id,$udom,$csec); |
&usermenu($r,$uname,$id,$udom,$csec); |
|
|
Line 1475 ENDTABLEHEADFOUR
|
Line 1477 ENDTABLEHEADFOUR
|
|
|
$r->print('<td bgcolor='.$defbgone. |
$r->print('<td bgcolor='.$defbgone. |
' rowspan='.$totalparms. |
' rowspan='.$totalparms. |
'><tt><font size=-1>'); |
'>'.$maptitles{$mapp{$rid}}.'</td>'); |
|
|
$r->print(' / res / '); |
|
$r->print(join(' / ', split(/\//,$mapp{$rid}))); |
|
|
|
$r->print('</font></tt></td>'); |
|
|
|
foreach (&keysinorder_bytype(\%name,\%keyorder)) { |
foreach (&keysinorder_bytype(\%name,\%keyorder)) { |
unless ($firstrow) { |
unless ($firstrow) { |
Line 1772 sub crsenv {
|
Line 1769 sub crsenv {
|
# |
# |
# Let the user know we made the changes |
# Let the user know we made the changes |
if ($name && defined($value)) { |
if ($name && defined($value)) { |
|
my $failed_cloners; |
if ($name eq 'cloners') { |
if ($name eq 'cloners') { |
|
$value =~ s/\s//g; |
$value =~ s/^,//; |
$value =~ s/^,//; |
$value =~ s/,$//; |
$value =~ s/,$//; |
|
# check requested clones are valid users. |
|
$failed_cloners = &check_cloners(\$value,\@oldcloner); |
} |
} |
my $put_result = &Apache::lonnet::put('environment', |
my $put_result = &Apache::lonnet::put('environment', |
{$name=>$value},$dom,$crs); |
{$name=>$value},$dom,$crs); |
Line 1791 sub crsenv {
|
Line 1792 sub crsenv {
|
$setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to'). |
$setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to'). |
' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />'; |
' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />'; |
} |
} |
|
if (($name eq 'cloners') && ($failed_cloners)) { |
|
$setoutput.= &mt('Unable to include').' - <b>'.$failed_cloners.'</b>, '. |
|
&mt('reason').' - '.&mt('LON-CAPA user(s) do(es) not exist'). |
|
'.<br />'.&mt('Please '). |
|
' <a href="/adm/createuser">'. |
|
&mt('add the user(s)').'</a>, '. |
|
&mt('and then return to the '). |
|
'<a href="/admparmset?action=crsenv">'. |
|
&mt('Course Parameters page').'</a> '. |
|
&mt('to add the new user(s) to the list of possible cloners'). |
|
'.<br />'; |
|
} |
} |
} |
} |
} |
# ------------------------- Re-init course environment entries for this session |
# ------------------------- Re-init course environment entries for this session |
Line 1908 sub crsenv {
|
Line 1921 sub crsenv {
|
'disablesigfigs' |
'disablesigfigs' |
=> '<b>'.&mt('Disable checking of Significant Figures').'</b><br />'. |
=> '<b>'.&mt('Disable checking of Significant Figures').'</b><br />'. |
' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')', |
' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')', |
|
'disableexampointprint' |
|
=> '<b>'.&mt('Disable automatically printing point values onto exams.').'</b><br />'. |
|
' ('.&mt('"[_1]" to disable, anything else if not','<tt>yes</tt>').')', |
'tthoptions' |
'tthoptions' |
=> '<b>'.&mt('Default set of options to pass to tth/m when converting tex').'</b>' |
=> '<b>'.&mt('Default set of options to pass to tth/m when converting tex').'</b>' |
); |
); |
Line 1934 sub crsenv {
|
Line 1950 sub crsenv {
|
'default_enrollment_start_date', |
'default_enrollment_start_date', |
'default_enrollment_end_date', |
'default_enrollment_end_date', |
'tthoptions', |
'tthoptions', |
'disablesigfigs' |
'disablesigfigs', |
|
'disableexampointprint' |
); |
); |
foreach my $parameter (sort(keys(%values))) { |
foreach my $parameter (sort(keys(%values))) { |
unless ($parameter =~ m/^internal\./) { |
unless (($parameter =~ m/^internal\./)||($parameter =~ m/^metadata\./)) { |
if (! $descriptions{$parameter}) { |
if (! $descriptions{$parameter}) { |
$descriptions{$parameter}=$parameter; |
$descriptions{$parameter}=$parameter; |
push(@Display_Order,$parameter); |
push(@Display_Order,$parameter); |
Line 2176 sub listdata {
|
Line 2193 sub listdata {
|
my $pointer=0; |
my $pointer=0; |
$tableopen=0; |
$tableopen=0; |
my $foundkeys=0; |
my $foundkeys=0; |
|
my %keyorder=&standardkeyorder(); |
foreach my $thiskey (sort { |
foreach my $thiskey (sort { |
if ($sortorder eq 'realmstudent') { |
if ($sortorder eq 'realmstudent') { |
my ($astudent,$arealm)=($a=~/^$env{'request.course.id'}\.([^\.]+)\.(.+)\.[^\.]+$/); |
my ($astudent,$arealm)=($a=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/); |
my ($bstudent,$brealm)=($b=~/^$env{'request.course.id'}\.([^\.]+)\.(.+)\.[^\.]+$/); |
my ($bstudent,$brealm)=($b=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/); |
($arealm cmp $brealm) || ($astudent cmp $bstudent); |
if (!defined($astudent)) { |
|
($arealm)=($a=~/^\Q$env{'request.course.id'}\E\.(.+)$/); |
|
} |
|
if (!defined($bstudent)) { |
|
($brealm)=($b=~/^\Q$env{'request.course.id'}\E\.(.+)$/); |
|
} |
|
$arealm=~s/\.type//; |
|
my ($ares, $aparm) = ($arealm=~/^(.*)\.(.*)$/); |
|
$aparm=$keyorder{'parameter_0_'.$aparm}; |
|
$brealm=~s/\.type//; |
|
my ($bres, $bparm) = ($brealm=~/^(.*)\.(.*)$/); |
|
$bparm=$keyorder{'parameter_0_'.$bparm}; |
|
if ($ares eq $bres) { |
|
if (defined($aparm) && defined($bparm)) { |
|
($aparm <=> $bparm); |
|
} elsif (defined($aparm)) { |
|
-1; |
|
} elsif (defined($bparm)) { |
|
1; |
|
} else { |
|
($arealm cmp $brealm) || ($astudent cmp $bstudent); |
|
} |
|
} else { |
|
($arealm cmp $brealm) || ($astudent cmp $bstudent); |
|
} |
} else { |
} else { |
$a cmp $b; |
$a cmp $b; |
} |
} |
} keys %{$listdata}) { |
} keys %{$listdata}) { |
|
|
if ($$listdata{$thiskey.'.type'}) { |
if ($$listdata{$thiskey.'.type'}) { |
my $thistype=$$listdata{$thiskey.'.type'}; |
my $thistype=$$listdata{$thiskey.'.type'}; |
if ($$resourcedata{$thiskey.'.type'}) { |
if ($$resourcedata{$thiskey.'.type'}) { |
Line 2488 ENDOVER
|
Line 2531 ENDOVER
|
################################################## |
################################################## |
|
|
=pod |
=pod |
|
|
=item change clone |
=item check_cloners |
|
|
|
Checks if new users included in list of allowed cloners |
|
are valid users. Replaces supplied list with |
|
cleaned list containing only users with valid usernames |
|
and domains. |
|
|
|
Inputs: $clonelist, $oldcloner |
|
where $clonelist is ref to array of requested cloners, |
|
and $oldcloner is ref to array of currently allowed |
|
cloners. |
|
|
|
Returns: string - comma separated list of requested |
|
cloners (username:domain) who do not exist in system. |
|
|
|
=item change_clone |
|
|
Modifies the list of courses a user can clone (stored |
Modifies the list of courses a user can clone (stored |
in the user's environemnt.db file), called when a |
in the user's environment.db file), called when a |
change is made to the list of users allowed to clone |
change is made to the list of users allowed to clone |
a course. |
a course. |
|
|
Inputs: $action,$cloner |
Inputs: $action,$cloner |
where $action is add or drop, and $cloner is identity of |
where $action is add or drop, and $cloner is identity of |
user for whom cloning ability is to be changed in course. |
user for whom cloning ability is to be changed in course. |
|
|
Returns: |
|
|
|
=cut |
=cut |
|
|
################################################## |
################################################## |
################################################## |
################################################## |
|
|
|
sub extract_cloners { |
|
my ($clonelist,$allowclone) = @_; |
|
if ($clonelist =~ /,/) { |
|
@{$allowclone} = split/,/,$clonelist; |
|
} else { |
|
$$allowclone[0] = $clonelist; |
|
} |
|
} |
|
|
|
|
|
sub check_cloners { |
|
my ($clonelist,$oldcloner) = @_; |
|
my ($clean_clonelist,$disallowed); |
|
my @allowclone = (); |
|
&extract_cloners($$clonelist,\@allowclone); |
|
foreach my $currclone (@allowclone) { |
|
if (!grep/^$currclone$/,@$oldcloner) { |
|
my ($uname,$udom) = split/:/,$currclone; |
|
if ($uname && $udom) { |
|
if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') { |
|
$disallowed .= $currclone.','; |
|
} else { |
|
$clean_clonelist .= $currclone.','; |
|
} |
|
} |
|
} else { |
|
$clean_clonelist .= $currclone.','; |
|
} |
|
} |
|
if ($disallowed) { |
|
$disallowed =~ s/,$//; |
|
} |
|
if ($clean_clonelist) { |
|
$clean_clonelist =~ s/,$//; |
|
} |
|
$$clonelist = $clean_clonelist; |
|
return $disallowed; |
|
} |
|
|
sub change_clone { |
sub change_clone { |
my ($clonelist,$oldcloner) = @_; |
my ($clonelist,$oldcloner) = @_; |
Line 2516 sub change_clone {
|
Line 2610 sub change_clone {
|
my $clone_crs = $cnum.':'.$cdom; |
my $clone_crs = $cnum.':'.$cdom; |
|
|
if ($cnum && $cdom) { |
if ($cnum && $cdom) { |
my @allowclone = (); |
my @allowclone; |
if ($clonelist =~ /,/) { |
&extract_cloners($clonelist,\@allowclone); |
@allowclone = split/,/,$clonelist; |
|
} else { |
|
$allowclone[0] = $clonelist; |
|
} |
|
foreach my $currclone (@allowclone) { |
foreach my $currclone (@allowclone) { |
if (!grep/^$currclone$/,@$oldcloner) { |
if (!grep/^$currclone$/,@$oldcloner) { |
($uname,$udom) = split/:/,$currclone; |
($uname,$udom) = split/:/,$currclone; |
Line 2612 ENDMAINFORMHEAD
|
Line 2702 ENDMAINFORMHEAD
|
action => 'crsenv', |
action => 'crsenv', |
permission => $parm_permission, |
permission => $parm_permission, |
}, |
}, |
|
{ text => 'Set Instructor Defined Metadata', |
|
action => 'setinstmeta', |
|
permission => $parm_permission, |
|
}, |
{ 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, |
Line 2655 ENDMAINFORMHEAD
|
Line 2749 ENDMAINFORMHEAD
|
$r->print($menu_html); |
$r->print($menu_html); |
return; |
return; |
} |
} |
|
### Set instructor defined metadata |
|
sub output_row { |
|
my ($field_name) = @_; |
|
my $output; |
|
my $meta_hash_ref=$env{'course.'.$env{'request.course.id'}.'.metadata.'.$field_name}; |
|
my $values=$$meta_hash_ref{'values'}; |
|
my $checked; |
|
unless (defined($$meta_hash_ref{'active'})) { |
|
$$meta_hash_ref{'active'} = 'no'; |
|
$$meta_hash_ref{'stu_add_values'} = 'yes'; |
|
$$meta_hash_ref{'values'} = 'Type a list of values separated by commas.'; |
|
$$meta_hash_ref{'stu_pick_many'} = 'yes'; |
|
} |
|
$output.='<tr><td><strong>'.$field_name.'</strong></td>'; |
|
$output.='<td><input name="'.$field_name.'_values" type="text" value="'.$$meta_hash_ref{'values'}.'" /></td>'; |
|
if ($$meta_hash_ref{'stu_add_values'}eq'yes') { |
|
$checked = ' CHECKED '; |
|
} else { |
|
$checked = ' '; |
|
} |
|
$output.='<td><center><input type="checkbox" name="'.$field_name.'_onlyone"" value="one"'.$checked.' /></center></td>'; |
|
if ($$meta_hash_ref{'stu_pick_many'}eq'yes') { |
|
$checked = ' CHECKED '; |
|
} else { |
|
$checked = ' '; |
|
} |
|
$output.='<td><input type="checkbox" name="'.$field_name.'_stuadd" value="one"'.$checked.' /></td>'; |
|
$output.='</tr>'; |
|
|
|
return ($output); |
|
} |
|
sub setinstmeta { |
|
my ($r)=@_; |
|
my $next_meta; |
|
my $output; |
|
my $item_num; |
|
my $put_result; |
|
$r->print(&Apache::lonxml::xmlbegin()); |
|
$r->print('<head> |
|
<title>LON-CAPA Set Instructor Metadata</title> |
|
</head>'); |
|
$r->print(&Apache::loncommon::bodytag('Set Instructor Metadata')); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs(undef, |
|
'Set Instructor Metadata')); |
|
my $dom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $crs = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $key_base = $env{'course.'.$env{'request.course.id'}.'.metadata.'}; |
|
my $save_field = ''; |
|
my %meta_hash; |
|
if ($env{'form.instmeta'}) { |
|
foreach my $field (sort %env) { |
|
if ($field=~m/^form.(.+)_(.+)$/) { |
|
my $meta_field = $1; |
|
my $meta_key = $2; |
|
if ($save_field eq $meta_field) { |
|
%meta_hash = {$meta_key=>[$env{$field}]}; |
|
} else { |
|
if ($save_field ne '') { |
|
%meta_hash = {active=>'yes'}; |
|
my $value = \%meta_hash; |
|
my $name = $save_field; |
|
$r->print('Saving '.$name.' meta<br />'); |
|
$put_result = &Apache::lonnet::put('environment', |
|
{$name=>$value},$dom,$crs); |
|
} |
|
$save_field = $meta_field; |
|
%meta_hash = {$meta_key=>[$env{$field}]}; |
|
} |
|
} |
|
|
|
|
|
} |
|
%meta_hash = {active=>'yes'}; |
|
my $value = \%meta_hash; |
|
my $name = $save_field; |
|
$r->print('Saving '.$name.' meta<br />'); |
|
$put_result = &Apache::lonnet::put('environment', |
|
{$name=>$value},$dom,$crs); |
|
} |
|
foreach my $field (%env) { |
|
# start by looking for populated fields |
|
if ($field=~m/type(\d+)/) { |
|
my $name; |
|
my $value; |
|
$put_result = &Apache::lonnet::put('environment', |
|
{$name=>$value},$dom,$crs); |
|
$put_result = &Apache::lonnet::put('environment', |
|
{$name=>$value},$dom,$crs); |
|
} |
|
if ($field=~m/newfield/) { |
|
my $name = 'metadata.'.$env{'form.titlenew'}; |
|
my %meta_hash = {values=>[$env{'form.valuesnew'}], |
|
allow_pick=>'many', |
|
allow_type=>'no'}; |
|
|
|
my $value = \%meta_hash; |
|
$put_result = &Apache::lonnet::put('environment', |
|
{$name=>$value},$dom,$crs); |
|
} |
|
} |
|
&Apache::lonnet::coursedescription($env{'request.course.id'}); |
|
$output.= &output_row("Title"); |
|
$output.= &output_row("Subject"); |
|
$output.= &output_row("Keywords"); |
|
# foreach my $key (sort keys %env) { |
|
# if ($key=~m/^course\.$env{'request.course.id'}\.metadata\.(.+)$/) { |
|
# my $meta_data_item = $1; |
|
# my $meta_hash=$env{$key}; |
|
# # keys are 'values', stu_pick_many, stu_add_values, active |
|
# |
|
# $output.='<tr><td>'.$meta_data_item.'</td>'; |
|
# $output.='<td>Select one: <input type="checkbox" name="" value="one" /><br />'; |
|
# $output.='Select many: <input type="checkbox" name="type" value="many" /></td>'; |
|
# $output.='<td><input name="values" type="text" value="$env{$key_base.$item_num.'.'" /></td></tr>'; |
|
# } |
|
# } |
|
# $output.='<tr><td><i>Create new instructor metadata item</i><br />'; |
|
# $output.='<input type="text" name="titlenew" /></td>'; |
|
# $output.='<td>students must pick only one: <input type="checkbox" name="pickonenew" value="one" /><br />'; |
|
# $output.='Allow student to type extra info: <input type="checkbox" name="typeextranew" value="extra" /></td>'; |
|
# $output.='<td><input name="valuesnew" type="text" value="" /></td></tr>'; |
|
# $output.='<input type="hidden" name="serial" value="'.$next_meta.'" />'; |
|
# $output.='<input type="hidden" name="state" value="save" /></tr>'; |
|
$r->print(<<ENDenv); |
|
<form method="post" action="/adm/parmset?action=setinstmeta" name="form"> |
|
|
|
<p> |
|
<table border=2> |
|
<tr><th>Metadata Item</th><th>Values</th><th>Only One Choice</th><th>Student Can Add Choices</th></tr> |
|
$output |
|
</table> |
|
<input type="submit" name="instmeta" value="Update Instructor Metadata"> |
|
</form> |
|
|
|
ENDenv |
|
|
|
|
|
$r->print('</body> |
|
</html>'); |
|
return 'ok'; |
|
} |
################################################## |
################################################## |
|
|
sub defaultsetter { |
sub defaultsetter { |
Line 2842 sub handler {
|
Line 3075 sub handler {
|
'pres_marker', |
'pres_marker', |
'pres_value', |
'pres_value', |
'pres_type', |
'pres_type', |
'udom','uname','symb']); |
'udom','uname','symb','serial']); |
|
|
|
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
Line 2889 sub handler {
|
Line 3122 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 'setinstmeta' && $parm_permission) { |
|
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setinstmeta', |
|
text=>"Instructor Metadata"}); |
|
&setinstmeta($r); |
} elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) { |
} elsif ($env{'form.action'} eq 'newoverview' && $parm_permission) { |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', |
&Apache::lonhtmlcommon::add_breadcrumb({href=>'/adm/parmset?action=setoverview', |
text=>"Overview Mode"}); |
text=>"Overview Mode"}); |