version 1.197, 2007/12/01 03:49:08
|
version 1.198, 2007/12/05 16:49:55
|
Line 627 sub print_user_modification_page {
|
Line 627 sub print_user_modification_page {
|
} |
} |
ENDSCRIPT |
ENDSCRIPT |
} else { |
} else { |
$nondc_setsection_code = <<"ENDSECCODE"; |
$nondc_setsection_code = |
function setSections() { |
&Apache::lonuserutils::setsections_javascript('cu',$groupslist); |
var re1 = /^currsec_/; |
|
var groups = new Array($groupslist); |
|
for (var i=0;i<document.cu.elements.length;i++) { |
|
var str = document.cu.elements[i].name; |
|
var checkcurr = str.match(re1); |
|
if (checkcurr != null) { |
|
if (document.cu.elements[i-1].checked == true) { |
|
var match = str.split('_'); |
|
var role = match[3]; |
|
if (role == 'cc') { |
|
alert("Section designations do not apply to Course Coordinator roles.\\nA course coordinator role will be added with access to all sections."); |
|
} |
|
else { |
|
var sections = ''; |
|
var numsec = 0; |
|
var sections; |
|
for (var j=0; j<document.cu.elements[i].length; j++) { |
|
if (document.cu.elements[i].options[j].selected == true ) { |
|
if (document.cu.elements[i].options[j].value != "") { |
|
if (numsec == 0) { |
|
if (document.cu.elements[i].options[j].value != "") { |
|
sections = document.cu.elements[i].options[j].value; |
|
numsec ++; |
|
} |
|
} |
|
else { |
|
sections = sections + "," + document.cu.elements[i].options[j].value |
|
numsec ++; |
|
} |
|
} |
|
} |
|
} |
|
if (numsec > 0) { |
|
if (document.cu.elements[i+1].value != "" && document.cu.elements[i+1].value != null) { |
|
sections = sections + "," + document.cu.elements[i+1].value; |
|
} |
|
} |
|
else { |
|
sections = document.cu.elements[i+1].value; |
|
} |
|
var newsecs = document.cu.elements[i+1].value; |
|
var numsplit; |
|
if (newsecs != null && newsecs != "") { |
|
numsplit = newsecs.split(/,/g); |
|
numsec = numsec + numsplit.length; |
|
} |
|
|
|
if ((role == 'st') && (numsec > 1)) { |
|
alert("In each course, each user may only have one student role at a time. You had selected "+numsec+" sections.\\nPlease modify your selections so they include no more than one section.") |
|
return; |
|
} |
|
else if (numsplit != null) { |
|
for (var j=0; j<numsplit.length; j++) { |
|
if ((numsplit[j] == 'all') || |
|
(numsplit[j] == 'none')) { |
|
alert("'"+numsplit[j]+"' may not be used as the name for a section, as it is a reserved word.\\nPlease choose a different section name."); |
|
return; |
|
} |
|
for (var k=0; k<groups.length; k++) { |
|
if (numsplit[j] == groups[k]) { |
|
alert("'"+numsplit[j]+"' may not be used as a section name, as it is the name of a course group.\\nSection names and group names must be distinct. Please choose a different section name."); |
|
return; |
|
} |
|
} |
|
} |
|
} |
|
document.cu.elements[i+2].value = sections; |
|
} |
|
} |
|
} |
|
} |
|
document.cu.submit(); |
|
} |
|
ENDSECCODE |
|
} |
} |
my $js = &user_modification_js($pjump_def,$dc_setcourse_code, |
my $js = &user_modification_js($pjump_def,$dc_setcourse_code, |
$nondc_setsection_code,$groupslist); |
$nondc_setsection_code,$groupslist); |
Line 1214 ENDNOPORTPRIV
|
Line 1140 ENDNOPORTPRIV
|
} |
} |
} else { |
} else { |
$r->print(&course_level_table(%inccourses)); |
$r->print(&course_level_table(%inccourses)); |
$r->print('<br /><input type="button" value="'.&mt('Modify User').'" onClick="setSections()" />'."\n"); |
$r->print('<br /><input type="button" value="'.&mt('Modify User').'" onClick="setSections(this.form)" />'."\n"); |
} |
} |
$r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','userrole','ccdomain','prevphase','currstate','ccuname','ccdomain'])); |
$r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','userrole','ccdomain','prevphase','currstate','ccuname','ccdomain'])); |
$r->print('<input type="hidden" name="currstate" value="" />'); |
$r->print('<input type="hidden" name="currstate" value="" />'); |
Line 1876 END
|
Line 1802 END
|
$r->print(&mt('Revoking [_1] in [_2]: [_3]', |
$r->print(&mt('Revoking [_1] in [_2]: [_3]', |
$role,$scope,'<b>'.$result.'</b>').'<br />'); |
$role,$scope,'<b>'.$result.'</b>').'<br />'); |
if ($role eq 'st') { |
if ($role eq 'st') { |
my $result = &classlist_drop($scope,$env{'form.ccuname'}, |
my $result = |
$env{'form.ccdomain'},$now); |
&Apache::lonuserutils::classlist_drop($scope, |
|
$env{'form.ccuname'},$env{'form.ccdomain'}, |
|
$now); |
$r->print($result); |
$r->print($result); |
} |
} |
} |
} |
Line 1901 END
|
Line 1829 END
|
$r->print(&mt('Deleting [_1] in [_2]: [_3]',$role,$scope, |
$r->print(&mt('Deleting [_1] in [_2]: [_3]',$role,$scope, |
'<b>'.$result.'</b>').'<br />'); |
'<b>'.$result.'</b>').'<br />'); |
if ($role eq 'st') { |
if ($role eq 'st') { |
my $result = &classlist_drop($scope,$env{'form.ccuname'}, |
my $result = |
$env{'form.ccdomain'},$now); |
&Apache::lonuserutils::classlist_drop($scope, |
|
$env{'form.ccuname'},$env{'form.ccdomain'}, |
|
$now); |
$r->print($result); |
$r->print($result); |
} |
} |
} |
} |
Line 2101 sub update_result_form {
|
Line 2031 sub update_result_form {
|
return $outcome; |
return $outcome; |
} |
} |
|
|
sub classlist_drop { |
|
my ($scope,$uname,$udom,$now) = @_; |
|
my ($cdom,$cnum) = ($scope=~m{^/($match_domain)/($match_courseid)}); |
|
my $cid=$cdom.'_'.$cnum; |
|
my $user = $uname.':'.$udom; |
|
if (!&active_student_roles($cnum,$cdom,$uname,$udom)) { |
|
my $result = |
|
&Apache::lonnet::cput('classlist', |
|
{ $user => $now }, |
|
$env{'course.'.$cid.'.domain'}, |
|
$env{'course.'.$cid.'.num'}); |
|
return &mt('Drop from classlist: [_1]', |
|
'<b>'.$result.'</b>').'<br />'; |
|
} |
|
} |
|
|
|
sub active_student_roles { |
|
my ($cnum,$cdom,$uname,$udom) = @_; |
|
my %roles = |
|
&Apache::lonnet::get_my_roles($uname,$udom,'userroles', |
|
['future','active'],['st']); |
|
return exists($roles{"$cnum:$cdom:st"}); |
|
} |
|
|
|
sub quota_admin { |
sub quota_admin { |
my ($setquota,$changeHash) = @_; |
my ($setquota,$changeHash) = @_; |
my $quotachanged; |
my $quotachanged; |
Line 3230 sub course_level_table {
|
Line 3136 sub course_level_table {
|
<td>'.$area.'<br />Domain: '.$domain.'</td>'."\n"; |
<td>'.$area.'<br />Domain: '.$domain.'</td>'."\n"; |
if ($role ne 'cc') { |
if ($role ne 'cc') { |
if (%sections_count) { |
if (%sections_count) { |
my $currsec = &course_sections(\%sections_count,$protectedcourse.'_'.$role); |
my $currsec = |
|
&Apache::lonuserutils::course_sections(\%sections_count, |
|
$protectedcourse.'_'.$role); |
$table .= |
$table .= |
'<td><table class="LC_createuser">'. |
'<td><table class="LC_createuser">'. |
'<tr class="LC_section_row"> |
'<tr class="LC_section_row"> |
Line 3270 ENDTIMEENTRY
|
Line 3178 ENDTIMEENTRY
|
<td>'.$plrole.'</td> |
<td>'.$plrole.'</td> |
<td>'.$area.'</td>'."\n"; |
<td>'.$area.'</td>'."\n"; |
if (%sections_count) { |
if (%sections_count) { |
my $currsec = &course_sections(\%sections_count,$customrole); |
my $currsec = |
|
&Apache::lonuserutils::course_sections(\%sections_count, |
|
$customrole); |
$table.= |
$table.= |
'<td><table class="LC_createuser">'. |
'<td><table class="LC_createuser">'. |
'<tr class="LC_section_row"><td valign="top">'. |
'<tr class="LC_section_row"><td valign="top">'. |
Line 3314 $table.
|
Line 3224 $table.
|
return $result; |
return $result; |
} |
} |
|
|
sub course_sections { |
|
my ($sections_count,$role) = @_; |
|
my $output = ''; |
|
my @sections = (sort {$a <=> $b} keys %{$sections_count}); |
|
if (scalar(@sections) == 1) { |
|
$output = '<select name="currsec_'.$role.'" >'."\n". |
|
' <option value="">Select</option>'."\n". |
|
' <option value="">No section</option>'."\n". |
|
' <option value="'.$sections[0].'" >'.$sections[0].'</option>'."\n"; |
|
} else { |
|
$output = '<select name="currsec_'.$role.'" '; |
|
my $multiple = 4; |
|
if (scalar(@sections) < 4) { $multiple = scalar(@sections); } |
|
$output .= 'multiple="multiple" size="'.$multiple.'">'."\n"; |
|
foreach my $sec (@sections) { |
|
$output .= '<option value="'.$sec.'">'.$sec."</option>\n"; |
|
} |
|
} |
|
$output .= '</select>'; |
|
return $output; |
|
} |
|
|
|
sub course_level_dc { |
sub course_level_dc { |
my ($dcdom) = @_; |
my ($dcdom) = @_; |
my %customroles=&Apache::lonuserutils::my_custom_roles(); |
my %customroles=&Apache::lonuserutils::my_custom_roles(); |