version 1.235, 2005/06/28 15:28:08
|
version 1.245, 2005/08/30 00:40:12
|
Line 1067 sub keysinorder {
|
Line 1067 sub keysinorder {
|
} (keys %{$name}); |
} (keys %{$name}); |
} |
} |
|
|
|
sub keysinorder_bytype { |
|
my ($name,$keyorder)=@_; |
|
return sort { |
|
my $ta=(split('_',$a))[-1]; |
|
my $tb=(split('_',$b))[-1]; |
|
if ($$keyorder{'parameter_0_'.$ta} == $$keyorder{'parameter_0_'.$tb}) { |
|
return ($a cmp $b); |
|
} |
|
$$keyorder{'parameter_0_'.$ta} <=> $$keyorder{'parameter_0_'.$tb}; |
|
} (keys %{$name}); |
|
} |
|
|
sub keysindisplayorder { |
sub keysindisplayorder { |
my ($name,$keyorder)=@_; |
my ($name,$keyorder)=@_; |
return sort { |
return sort { |
Line 1076 sub keysindisplayorder {
|
Line 1088 sub keysindisplayorder {
|
|
|
sub sortmenu { |
sub sortmenu { |
my ($r,$sortorder)=@_; |
my ($r,$sortorder)=@_; |
$r->print('<br /><input type="radio" name="sortorder" value="realmstudent"'); |
$r->print('<br /><label><input type="radio" name="sortorder" value="realmstudent"'); |
if ($sortorder eq 'realmstudent') { |
if ($sortorder eq 'realmstudent') { |
$r->print(' checked="on"'); |
$r->print(' checked="on"'); |
} |
} |
$r->print(' />'.&mt('Sort by realm first, then student (group/section)')); |
$r->print(' />'.&mt('Sort by realm first, then student (group/section)')); |
$r->print('<br /><input type="radio" name="sortorder" value="studentrealm"'); |
$r->print('</label><br /><label><input type="radio" name="sortorder" value="studentrealm"'); |
if ($sortorder eq 'studentrealm') { |
if ($sortorder eq 'studentrealm') { |
$r->print(' checked="on"'); |
$r->print(' checked="on"'); |
} |
} |
$r->print(' />'.&mt('Sort by student (group/section) first, then realm')); |
$r->print(' />'.&mt('Sort by student (group/section) first, then realm'). |
|
'</label>'); |
} |
} |
|
|
sub standardkeyorder { |
sub standardkeyorder { |
Line 1317 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 1462 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(\%name,\%keyorder)) { |
|
unless ($firstrow) { |
unless ($firstrow) { |
$r->print('<tr>'); |
$r->print('<tr>'); |
} else { |
} else { |
Line 1759 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 1778 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 1924 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 2167 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 2475 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 2503 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 2599 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 2642 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; |
|
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.'}; |
|
if ($env{'form.state'}eq 'add') { |
|
$r->print('<strong>Compose a new metadata item:</strong><br />'); |
|
$r->print('<form method="post" action="/adm/parmset">'); |
|
$r->print ('Title of item: '.&Apache::lonhtmlcommon::textbox("title",undef,undef,undef).'<br />'); |
|
$r->print ('List if items (comma separated): '.&Apache::lonhtmlcommon::textbox("values",undef,undef,undef).'<br />'); |
|
$r->print ('Select one: <input type="radio" name="type" value="one"><br />'); |
|
$r->print ('Select many: <input type="radio" name="type" value="many"><br />'); |
|
$r->print('<input type="hidden" name="serial" value="'.$next_meta.'" />'); |
|
$r->print('<input type="hidden" name="action" value="setinstmeta" />'); |
|
$r->print('<input type="hidden" name="state" value="save" />'); |
|
$r->print('<input type="submit" value="Save Metadata">'); |
|
$r->print('</form>'); |
|
} elsif ($env{'form.state'}eq 'save') { |
|
$r->print('Here we save the metadata'); |
|
$key_base.=$env{'form.serial'}.'.'; |
|
$r->print('The title: '.$env{'form.title'}.'<br>'); |
|
$r->print('The values: '.$env{'form.values'}.'<br>'); |
|
$r->print('The type: '.$env{'form.type'}.'<br>'); |
|
$r->print('The number: '.$env{'form.serial'}.'<br>'); |
|
my $name = 'metadata.'.$env{'form.serial'}.'.title'; |
|
my $value = $env{'form.title'}; |
|
my $put_result = &Apache::lonnet::put('environment', |
|
{$name=>$value},$dom,$crs); |
|
$r->print('the put result was: '.$put_result.'<br />'); |
|
$name = 'metadata.'.$env{'form.serial'}.'.type'; |
|
$value = $env{'form.type'}; |
|
$put_result = &Apache::lonnet::put('environment', |
|
{$name=>$value},$dom,$crs); |
|
$name = 'metadata.'.$env{'form.serial'}.'.values'; |
|
$value = $env{'form.values'}; |
|
$put_result = &Apache::lonnet::put('environment', |
|
{$name=>$value},$dom,$crs); |
|
&Apache::lonnet::coursedescription($env{'request.course.id'}); |
|
} else { |
|
|
|
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/; |
|
$item_num = $1; |
|
if ($1 ge $next_meta) { |
|
$next_meta = $1 + 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.'.values'}.'" /></td></tr>'; |
|
} |
|
} |
|
$output.='<tr><td><i>Create new instructor metadata item</i><br />'; |
|
$output.='<input type="text" name="newitem" /></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.='<td><input type="hidden" name="serial" value="'.$next_meta.'" /></td></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 2829 sub handler {
|
Line 3002 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 2876 sub handler {
|
Line 3049 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"}); |