version 1.236, 2005/06/28 15:56:35
|
version 1.246, 2005/08/30 01:25:53
|
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 1937 sub crsenv {
|
Line 1950 sub crsenv {
|
'disablesigfigs' |
'disablesigfigs' |
); |
); |
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 2180 sub listdata {
|
Line 2193 sub listdata {
|
if ($sortorder eq 'realmstudent') { |
if ($sortorder eq 'realmstudent') { |
my ($astudent,$arealm)=($a=~/^$env{'request.course.id'}\.([^\.]+)\.(.+)\.[^\.]+$/); |
my ($astudent,$arealm)=($a=~/^$env{'request.course.id'}\.([^\.]+)\.(.+)\.[^\.]+$/); |
my ($bstudent,$brealm)=($b=~/^$env{'request.course.id'}\.([^\.]+)\.(.+)\.[^\.]+$/); |
my ($bstudent,$brealm)=($b=~/^$env{'request.course.id'}\.([^\.]+)\.(.+)\.[^\.]+$/); |
|
if (!defined($astudent) && !defined($bstudent) && |
|
!defined($arealm) && !defined($brealm)) { |
|
($arealm)=($a=~/^$env{'request.course.id'}\.(.+)\.[^\.]+$/); |
|
($brealm)=($b=~/^$env{'request.course.id'}\.(.+)\.[^\.]+$/); |
|
} |
($arealm cmp $brealm) || ($astudent cmp $bstudent); |
($arealm cmp $brealm) || ($astudent cmp $bstudent); |
} else { |
} else { |
$a cmp $b; |
$a cmp $b; |
Line 2488 ENDOVER
|
Line 2506 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 2585 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 2677 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 2724 ENDMAINFORMHEAD
|
$r->print($menu_html); |
$r->print($menu_html); |
return; |
return; |
} |
} |
|
### Set instructor defined metadata |
|
sub setinstmeta { |
|
my ($r)=@_; |
|
my $next_meta; |
|
my $output; |
|
my $item_num; |
|
my $put_result; |
|
if ($env{'form.serial'}) { |
|
$next_meta = $env{'form.serial'}; |
|
} else { |
|
$next_meta = 1; |
|
} |
|
$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.'}; |
|
foreach my $field (%env) { |
|
# start by looking for populated fields |
|
if ($field=~m/type(\d+)/) { |
|
my $item_num = $1; |
|
my $name = 'metadata.'.$item_num.'.type'; |
|
my $value = $env{'form.type'.$item_num}; |
|
$put_result = &Apache::lonnet::put('environment', |
|
{$name=>$value},$dom,$crs); |
|
$name = 'metadata.'.$item_num.'.values'; |
|
$value = $env{'form.values'.$item_num}; |
|
$put_result = &Apache::lonnet::put('environment', |
|
{$name=>$value},$dom,$crs); |
|
} |
|
if ($field=~m/newfield/) { |
|
my $item_num = $env{'form.serial'}; |
|
my $name = 'metadata.'.$item_num.'.type'; |
|
my $value = $env{'form.typenew'}; |
|
$put_result = &Apache::lonnet::put('environment', |
|
{$name=>$value},$dom,$crs); |
|
$name = 'metadata.'.$item_num.'.values'; |
|
$value = $env{'form.valuesnew'}; |
|
$put_result = &Apache::lonnet::put('environment', |
|
{$name=>$value},$dom,$crs); |
|
$name = 'metadata.'.$item_num.'.title'; |
|
$value = $env{'form.titlenew'}; |
|
$put_result = &Apache::lonnet::put('environment', |
|
{$name=>$value},$dom,$crs); |
|
|
|
} |
|
|
|
|
|
} |
|
&Apache::lonnet::coursedescription($env{'request.course.id'}); |
|
foreach my $key (sort keys %env) { |
|
if ($key=~m/^course\.$env{'request.course.id'}\.metadata\.\d+\.title$/) { |
|
$key=~m/(^course\.$env{'request.course.id'}\.metadata\.)(\d+)\.title/; |
|
$key_base = $1; |
|
$item_num = $2; |
|
if ($item_num ge $next_meta) { |
|
$next_meta = $item_num + 1; |
|
} |
|
$output.='<tr><td>'.$env{$key}.'</td>'; |
|
$output.='<td>Select one: <input type="radio" name="type'.$item_num.'" value="one" /><br />'; |
|
$output.='Select many: <input type="radio" name="type'.$item_num.'" value="many" /></td>'; |
|
$output.='<td><input name="values'.$item_num.'" type="text" value="'.$env{$key_base.$item_num.'.values'}.'" /></td></tr>'; |
|
} |
|
} |
|
$output.='<tr><td><i>Create new instructor metadata item</i><br />'; |
|
$output.='<input type="text" name="titlenew" /></td>'; |
|
$output.='<td>Select one: <input type="radio" name="typenew" value="one" /><br />'; |
|
$output.='Select many: <input type="radio" name="typenew" value="many" /></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>Title</th><th>Options</th><th>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 3003 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 3050 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"}); |