version 1.378, 2007/08/30 00:01:56
|
version 1.381, 2007/09/11 01:59:30
|
Line 2109 sub crsenv {
|
Line 2109 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; |
my %failed_cloners; |
if ($name eq 'cloners') { |
if ($name eq 'cloners') { |
$value =~ s/\s//g; |
$value =~ s/\s//g; |
$value =~ s/^,//; |
$value =~ s/^,//; |
$value =~ s/,$//; |
$value =~ s/,$//; |
# check requested clones are valid users. |
# check requested clones are valid users. |
$failed_cloners = &check_cloners(\$value,\@oldcloner); |
%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 2132 sub crsenv {
|
Line 2132 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)) { |
if (($name eq 'cloners') && (keys(%failed_cloners) > 0)) { |
$setoutput.= &mt('Unable to include').' - <b>'.$failed_cloners.'</b>, '. |
$setoutput.= &mt('Unable to include').': '; |
&mt('reason').' - '.&mt('LON-CAPA user(s) do(es) not exist'). |
my @fails; |
'.<br />'.&mt('Please '). |
my $num = 0; |
' <a href="/adm/createuser">'. |
if (defined($failed_cloners{'format'})) { |
&mt('add the user(s)').'</a>, '. |
$fails[$num] .= '<b>'.$failed_cloners{'format'}. |
&mt('and then return to the '). |
'</b>, '.&mt('reason').' - '. |
'<a href="/admparmset?action=crsenv">'. |
&mt('Invalid format'); |
&mt('Course Parameters page').'</a> '. |
$num ++; |
&mt('to add the new user(s) to the list of possible cloners'). |
} |
'.<br />'; |
if (defined($failed_cloners{'domain'})) { |
|
$fails[$num] .= '<b>'.$failed_cloners{'domain'}. |
|
'</b>, '.&mt('reason').' - '. |
|
&mt('Domain does not exist'); |
|
$num ++; |
|
} |
|
if (defined($failed_cloners{'newuser'})) { |
|
$fails[$num] .= '<b>'.$failed_cloners{'newuser'}. '</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="/adm/parmset?action=crsenv">'. |
|
&mt('Course Parameters page').'</a> '. |
|
&mt('to add the new user(s) to the list of possible cloners'); |
|
} |
|
$setoutput .= join('; ',@fails).'.<br />'; |
} |
} |
} |
} |
} |
} |
Line 2173 sub crsenv {
|
Line 2190 sub crsenv {
|
'courseid' => '<b>'.&mt('Course ID or number'). |
'courseid' => '<b>'.&mt('Course ID or number'). |
'</b><br />'. |
'</b><br />'. |
'('.&mt('internal').', '.&mt('optional').')', |
'('.&mt('internal').', '.&mt('optional').')', |
'cloners' => '<b>'.&mt('Users allowed to clone course').'</b><br /><tt>(user:domain,user:domain)</tt><br />'.&mt('Users with active Course Coordinator role in the course automatically have the right to clone it, and can be omitted from list.'), |
'cloners' => '<b>'.&mt('Users allowed to clone course').'</b><br /><tt>(user:domain,user:domain,*:domain)</tt><br />'.&mt('Users with active Course Coordinator role in course are permitted to clone and need not be included.<br /> |
|
Use *:domain to allow course to be cloned by anyone in the specified domain.<br /> |
|
Use * to allow unrestricted cloning in all domains.'), |
'grading' => '<b>'.&mt('Grading').'</b><br />'. |
'grading' => '<b>'.&mt('Grading').'</b><br />'. |
'<tt>"standard", "external", or "spreadsheet"</tt> '.&Apache::loncommon::help_open_topic('GradingOptions'), |
'<tt>"standard", "external", or "spreadsheet"</tt> '.&Apache::loncommon::help_open_topic('GradingOptions'), |
'task_grading' => '<b>'.&mt('Bridge Task Grading').'</b><br />'. |
'task_grading' => '<b>'.&mt('Bridge Task Grading').'</b><br />'. |
Line 2563 sub extractuser {
|
Line 2582 sub extractuser {
|
return ($key=~/^$env{'request.course.id'}.\[useropt\:($match_username)\:($match_domain)\]\./); |
return ($key=~/^$env{'request.course.id'}.\[useropt\:($match_username)\:($match_domain)\]\./); |
} |
} |
|
|
|
sub parse_listdata_key { |
|
my ($key,$listdata) = @_; |
|
# split into student/section affected, and |
|
# the realm (folder/resource part and parameter |
|
my ($student,$realm) = |
|
($key=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)$/); |
|
# if course wide student would be undefined |
|
if (!defined($student)) { |
|
($realm)=($key=~/^\Q$env{'request.course.id'}\E\.(.+)$/); |
|
} |
|
# strip off the .type if it's not the Question type parameter |
|
if ($realm=~/\.type$/ && !exists($listdata->{$key.'.type'})) { |
|
$realm=~s/\.type//; |
|
} |
|
# split into resource+part and parameter name |
|
my ($res, $parm) = ($realm=~/^(.*)\.(.*)$/); |
|
my ($res, $part) = ($res =~/^(.*)\.(.*)$/); |
|
return ($student,$res,$part,$parm); |
|
} |
|
|
sub listdata { |
sub listdata { |
my ($r,$resourcedata,$listdata,$sortorder)=@_; |
my ($r,$resourcedata,$listdata,$sortorder)=@_; |
# Start list output |
# Start list output |
Line 2574 sub listdata {
|
Line 2613 sub listdata {
|
$tableopen=0; |
$tableopen=0; |
my $foundkeys=0; |
my $foundkeys=0; |
my %keyorder=&standardkeyorder(); |
my %keyorder=&standardkeyorder(); |
|
|
foreach my $thiskey (sort { |
foreach my $thiskey (sort { |
|
my ($astudent,$ares,$apart,$aparm) = &parse_listdata_key($a,$listdata); |
|
my ($bstudent,$bres,$bpart,$bparm) = &parse_listdata_key($b,$listdata); |
|
|
|
# get the numerical order for the param |
|
$aparm=$keyorder{'parameter_0_'.$aparm}; |
|
$bparm=$keyorder{'parameter_0_'.$bparm}; |
|
|
|
my $result=0; |
|
|
if ($sortorder eq 'realmstudent') { |
if ($sortorder eq 'realmstudent') { |
my ($astudent,$arealm)=($a=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/); |
if ($ares ne $bres ) { |
my ($bstudent,$brealm)=($b=~/^\Q$env{'request.course.id'}\E\.\[([^\.]+)\]\.(.+)\.[^\.]+$/); |
$result = ($ares cmp $bres); |
if (!defined($astudent)) { |
} elsif ($astudent ne $bstudent) { |
($arealm)=($a=~/^\Q$env{'request.course.id'}\E\.(.+)$/); |
$result = ($astudent cmp $bstudent); |
|
} elsif ($apart ne $bpart ) { |
|
$result = ($apart cmp $bpart); |
} |
} |
if (!defined($bstudent)) { |
} else { |
($brealm)=($b=~/^\Q$env{'request.course.id'}\E\.(.+)$/); |
if ($astudent ne $bstudent) { |
|
$result = ($astudent cmp $bstudent); |
|
} elsif ($ares ne $bres ) { |
|
$result = ($ares cmp $bres); |
|
} elsif ($apart ne $bpart ) { |
|
$result = ($apart cmp $bpart); |
} |
} |
$arealm=~s/\.type//; |
} |
my ($ares, $aparm) = ($arealm=~/^(.*)\.(.*)$/); |
|
$aparm=$keyorder{'parameter_0_'.$aparm}; |
if (!$result) { |
$brealm=~s/\.type//; |
if (defined($aparm) && defined($bparm)) { |
my ($bres, $bparm) = ($brealm=~/^(.*)\.(.*)$/); |
$result = ($aparm <=> $bparm); |
$bparm=$keyorder{'parameter_0_'.$bparm}; |
} elsif (defined($aparm)) { |
if ($ares eq $bres) { |
$result = -1; |
if (defined($aparm) && defined($bparm)) { |
} elsif (defined($bparm)) { |
($aparm <=> $bparm); |
$result = 1; |
} elsif (defined($aparm)) { |
|
-1; |
|
} elsif (defined($bparm)) { |
|
1; |
|
} else { |
|
($arealm cmp $brealm) || ($astudent cmp $bstudent); |
|
} |
|
} else { |
|
($arealm cmp $brealm) || ($astudent cmp $bstudent); |
|
} |
} |
} else { |
|
$a cmp $b; |
|
} |
} |
|
|
|
$result; |
} 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 3063 where $action is add or drop, and $clone
|
Line 3110 where $action is add or drop, and $clone
|
user for whom cloning ability is to be changed in course. |
user for whom cloning ability is to be changed in course. |
|
|
=cut |
=cut |
|
|
################################################## |
################################################## |
################################################## |
################################################## |
|
|
sub extract_cloners { |
sub extract_cloners { |
my ($clonelist,$allowclone) = @_; |
my ($clonelist,$allowclone) = @_; |
if ($clonelist =~ /,/) { |
if ($clonelist =~ /,/) { |
@{$allowclone} = split/,/,$clonelist; |
@{$allowclone} = split(/,/,$clonelist); |
} else { |
} else { |
$$allowclone[0] = $clonelist; |
$$allowclone[0] = $clonelist; |
} |
} |
} |
} |
|
|
|
|
sub check_cloners { |
sub check_cloners { |
my ($clonelist,$oldcloner) = @_; |
my ($clonelist,$oldcloner) = @_; |
my ($clean_clonelist,$disallowed); |
my ($clean_clonelist,%disallowed); |
my @allowclone = (); |
my @allowclone = (); |
&extract_cloners($$clonelist,\@allowclone); |
&extract_cloners($$clonelist,\@allowclone); |
foreach my $currclone (@allowclone) { |
foreach my $currclone (@allowclone) { |
if (!grep/^$currclone$/,@$oldcloner) { |
if (!grep(/^\Q$currclone\E$/,@$oldcloner)) { |
my ($uname,$udom) = split/:/,$currclone; |
if ($currclone eq '*') { |
if ($uname && $udom) { |
$clean_clonelist .= $currclone.','; |
if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') { |
} else { |
$disallowed .= $currclone.','; |
my ($uname,$udom) = split(/:/,$currclone); |
|
if ($uname eq '*') { |
|
if ($udom =~ /^$match_domain$/) { |
|
if (!&Apache::lonnet::domain($udom)) { |
|
$disallowed{'domain'} .= $currclone.','; |
|
} else { |
|
$clean_clonelist .= $currclone.','; |
|
} |
|
} else { |
|
$disallowed{'format'} .= $currclone.','; |
|
} |
|
} elsif ($currclone !~/^($match_username)\:($match_domain)$/) { |
|
$disallowed{'format'} .= $currclone.','; |
} else { |
} else { |
$clean_clonelist .= $currclone.','; |
if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') { |
|
$disallowed{'newuser'} .= $currclone.','; |
|
} else { |
|
$clean_clonelist .= $currclone.','; |
|
} |
} |
} |
} |
} |
} else { |
} else { |
$clean_clonelist .= $currclone.','; |
$clean_clonelist .= $currclone.','; |
} |
} |
} |
} |
if ($disallowed) { |
foreach my $key (keys(%disallowed)) { |
$disallowed =~ s/,$//; |
$disallowed{$key} =~ s/,$//; |
} |
} |
if ($clean_clonelist) { |
if ($clean_clonelist) { |
$clean_clonelist =~ s/,$//; |
$clean_clonelist =~ s/,$//; |
} |
} |
$$clonelist = $clean_clonelist; |
$$clonelist = $clean_clonelist; |
return $disallowed; |
return %disallowed; |
} |
} |
|
|
sub change_clone { |
sub change_clone { |
my ($clonelist,$oldcloner) = @_; |
my ($clonelist,$oldcloner) = @_; |
Line 3117 sub change_clone {
|
Line 3179 sub change_clone {
|
my @allowclone; |
my @allowclone; |
&extract_cloners($clonelist,\@allowclone); |
&extract_cloners($clonelist,\@allowclone); |
foreach my $currclone (@allowclone) { |
foreach my $currclone (@allowclone) { |
if (!grep/^$currclone$/,@$oldcloner) { |
if (!grep(/^$currclone$/,@$oldcloner)) { |
($uname,$udom) = split/:/,$currclone; |
if ($currclone ne '*') { |
if ($uname && $udom) { |
($uname,$udom) = split(/:/,$currclone); |
unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') { |
if ($uname && $udom && $uname ne '*') { |
my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable'); |
if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') { |
if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) { |
my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable'); |
if ($currclonecrs{'cloneable'} eq '') { |
if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) { |
$currclonecrs{'cloneable'} = $clone_crs; |
if ($currclonecrs{'cloneable'} eq '') { |
} else { |
$currclonecrs{'cloneable'} = $clone_crs; |
$currclonecrs{'cloneable'} .= ','.$clone_crs; |
} else { |
|
$currclonecrs{'cloneable'} .= ','.$clone_crs; |
|
} |
|
&Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname); |
} |
} |
&Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname); |
|
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
foreach my $oldclone (@$oldcloner) { |
foreach my $oldclone (@$oldcloner) { |
if (!grep/^$oldclone$/,@allowclone) { |
if (!grep(/^\Q$oldclone\E$/,@allowclone)) { |
($uname,$udom) = split/:/,$oldclone; |
if ($oldclone ne '*') { |
if ($uname && $udom) { |
($uname,$udom) = split(/:/,$oldclone); |
unless (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') { |
if ($uname && $udom && $uname ne '*' ) { |
my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable'); |
if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') { |
my %newclonecrs = (); |
my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable'); |
if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) { |
my %newclonecrs = (); |
if ($currclonecrs{'cloneable'} =~ /,/) { |
if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) { |
my @currclonecrs = split/,/,$currclonecrs{'cloneable'}; |
if ($currclonecrs{'cloneable'} =~ /,/) { |
foreach (@currclonecrs) { |
my @currclonecrs = split/,/,$currclonecrs{'cloneable'}; |
unless ($_ eq $clone_crs) { |
foreach my $crs (@currclonecrs) { |
$newclonecrs{'cloneable'} .= $_.','; |
if ($crs ne $clone_crs) { |
|
$newclonecrs{'cloneable'} .= $crs.','; |
|
} |
} |
} |
|
$newclonecrs{'cloneable'} =~ s/,$//; |
|
} else { |
|
$newclonecrs{'cloneable'} = ''; |
} |
} |
$newclonecrs{'cloneable'} =~ s/,$//; |
&Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname); |
} else { |
|
$newclonecrs{'cloneable'} = ''; |
|
} |
} |
&Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname); |
|
} |
} |
} |
} |
} |
} |