version 1.112, 2006/04/10 19:59:53
|
version 1.113, 2006/05/08 21:40:20
|
Line 170 ENDCUSTOM
|
Line 170 ENDCUSTOM
|
|
|
|
|
sub user_modification_js { |
sub user_modification_js { |
my ($pjump_def, $dc_setcourse_code)=@_; |
my ($pjump_def,$dc_setcourse_code,$nondc_setsection_code,$groupslist)=@_; |
|
|
return <<END; |
return <<END; |
<script type="text/javascript" language="Javascript"> |
<script type="text/javascript" language="Javascript"> |
|
|
Line 189 sub user_modification_js {
|
Line 190 sub user_modification_js {
|
pclose(); |
pclose(); |
} |
} |
|
|
|
$nondc_setsection_code |
|
|
function setSections() { |
function setSections() { |
var re1 = /^currsec_/; |
var re1 = /^currsec_/; |
|
var groups = new Array($groupslist); |
for (var i=0;i<document.cu.elements.length;i++) { |
for (var i=0;i<document.cu.elements.length;i++) { |
var str = document.cu.elements[i].name; |
var str = document.cu.elements[i].name; |
var checkcurr = str.match(re1); |
var checkcurr = str.match(re1); |
Line 226 sub user_modification_js {
|
Line 230 sub user_modification_js {
|
if (numsec > 0) { |
if (numsec > 0) { |
if (document.cu.elements[i+1].value != "" && document.cu.elements[i+1].value != null) { |
if (document.cu.elements[i+1].value != "" && document.cu.elements[i+1].value != null) { |
sections = sections + "," + document.cu.elements[i+1].value; |
sections = sections + "," + document.cu.elements[i+1].value; |
} |
} |
} |
} |
else { |
else { |
sections = document.cu.elements[i+1].value; |
sections = document.cu.elements[i+1].value; |
Line 240 sub user_modification_js {
|
Line 244 sub user_modification_js {
|
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.") |
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; |
return; |
} |
} |
else { |
else { |
|
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.elements[i+2].value = sections; |
} |
} |
} |
} |
Line 283 sub print_user_modification_page {
|
Line 300 sub print_user_modification_page {
|
$ccdomain=~s/\W//g; |
$ccdomain=~s/\W//g; |
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); |
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); |
my $dc_setcourse_code = ''; |
my $dc_setcourse_code = ''; |
|
my $nondc_setsection_code = ''; |
my %loaditem; |
my %loaditem; |
|
my (%curr_groups,$groupslist,$numgroups); |
|
if (exists($env{'request.course.id'})) { |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
$numgroups = &Apache::loncommon::coursegroups(\%curr_groups,$cdom, |
|
$cnum); |
|
} |
|
if ($numgroups > 0) { |
|
$groupslist = join('","',sort(keys(%curr_groups))); |
|
$groupslist = '"'.$groupslist.'"'; |
|
} |
if ($env{'request.role'} =~ m-^dc\./(\w+)/$-) { |
if ($env{'request.role'} =~ m-^dc\./(\w+)/$-) { |
my $dcdom = $1; |
my $dcdom = $1; |
$loaditem{'onload'} = "document.cu.coursedesc.value=''"; |
$loaditem{'onload'} = "document.cu.coursedesc.value=''"; |
Line 326 sub print_user_modification_page {
|
Line 355 sub print_user_modification_page {
|
alert("In each course, each user may only have one student role at a time. You had selected "+numsections+" sections.\\nPlease modify your selections so they include no more than one section.") |
alert("In each course, each user may only have one student role at a time. You had selected "+numsections+" sections.\\nPlease modify your selections so they include no more than one section.") |
return; |
return; |
} |
} |
|
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; |
|
} |
|
if (document.cu.groups.value != '') { |
|
var groups = document.cu.groups.value.split(/,/g); |
|
for (var k=0; k<groups.length; k++) { |
|
if (numsplit[j] == groups[k]) { |
|
alert("'"+numsplit[j]+"' may not be used as the name for a section, as it is the name of a course group.\\nSection names and group names must be distinct. Please choose a different section name."); |
|
return; |
|
} |
|
} |
|
} |
|
} |
if ((userrole == 'cc') && (numsections > 0)) { |
if ((userrole == 'cc') && (numsections > 0)) { |
alert("Section designations do not apply to Course Coordinator roles.\\nA course coordinator role will be added with access to all sections."); |
alert("Section designations do not apply to Course Coordinator roles.\\nA course coordinator role will be added with access to all sections."); |
section = ""; |
section = ""; |
Line 356 sub print_user_modification_page {
|
Line 400 sub print_user_modification_page {
|
return -1; |
return -1; |
} |
} |
ENDSCRIPT |
ENDSCRIPT |
|
} else { |
|
$nondc_setsection_code = <<"ENDSECCODE"; |
|
function setSections() { |
|
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) { |
|
var re2 = /^currsec_[a-zA-Z0-9]+_[a-zA-Z0-9]+_(\\w+)\$/; |
|
if (document.cu.elements[i-1].checked == true) { |
|
var re2 = /^currsec_[a-zA-Z0-9]+_[a-zA-Z0-9]+_(\\w+)\$/; |
|
match = re2.exec(str); |
|
var role = match[1]; |
|
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; |
|
if (newsecs != null && newsecs != "") { |
|
var 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 { |
|
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); |
my $start_page = |
my $start_page = |
&Apache::loncommon::start_page('Create Users, Change User Privileges', |
&Apache::loncommon::start_page('Create Users, Change User Privileges', |
$js,{'add_entries' => \%loaditem,}); |
$js,{'add_entries' => \%loaditem,}); |
Line 548 END
|
Line 669 END
|
$bgcol=~s/[^7-9a-e]//g; |
$bgcol=~s/[^7-9a-e]//g; |
$bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',2,6); |
$bgcol=substr($bgcol.$bgcol.$bgcol.'ffffff',2,6); |
if ($area=~/^\/(\w+)\/(\d\w+)\/(\w+)/) { |
if ($area=~/^\/(\w+)\/(\d\w+)\/(\w+)/) { |
$carea.='<br />Section/Group: '.$3; |
$carea.='<br />Section: '.$3; |
$sortkey.="\0$3"; |
$sortkey.="\0$3"; |
} |
} |
$area=$carea; |
$area=$carea; |
Line 884 sub update_user_data {
|
Line 1005 sub update_user_data {
|
$title='Modify User Privileges'; |
$title='Modify User Privileges'; |
} |
} |
$r->print(&Apache::loncommon::start_page($title)); |
$r->print(&Apache::loncommon::start_page($title)); |
|
my %disallowed; |
# Check Inputs |
# Check Inputs |
if (! $env{'form.ccuname'} ) { |
if (! $env{'form.ccuname'} ) { |
$r->print($error.&mt('No login name specified').'.'.$end); |
$r->print($error.&mt('No login name specified').'.'.$end); |
Line 1087 END
|
Line 1209 END
|
} |
} |
} |
} |
## |
## |
|
my %curr_groups; |
my $now=time; |
my $now=time; |
$r->print('<h3>'.&mt('Modifying Roles').'</h3>'); |
$r->print('<h3>'.&mt('Modifying Roles').'</h3>'); |
foreach (keys (%env)) { |
foreach (keys (%env)) { |
Line 1113 END
|
Line 1236 END
|
} |
} |
if ($_=~/^form\.rev\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) { |
if ($_=~/^form\.rev\:([^\_]+)\_cr\.cr\/(\w+)\/(\w+)\/(\w+)$/) { |
# Revoke custom role |
# Revoke custom role |
$r->print(&mt('Revoking custom role'). |
$r->print(&mt('Revoking custom role:'). |
' '.$4.' by '.$3.'@'.$2.' in '.$1.': <b>'. |
' '.$4.' by '.$3.'@'.$2.' in '.$1.': <b>'. |
&Apache::lonnet::revokecustomrole($env{'form.ccdomain'}, |
&Apache::lonnet::revokecustomrole($env{'form.ccdomain'}, |
$env{'form.ccuname'},$1,$2,$3,$4). |
$env{'form.ccuname'},$1,$2,$3,$4). |
Line 1136 END
|
Line 1259 END
|
&Apache::lonnet::escape($now.':'), |
&Apache::lonnet::escape($now.':'), |
$env{'course.'.$cid.'.home'}).'</b><br />'); |
$env{'course.'.$cid.'.home'}).'</b><br />'); |
} |
} |
} |
} |
} elsif ($_=~/^form\.ren/) { |
} elsif ($_=~/^form\.ren/) { |
my $udom = $env{'form.ccdomain'}; |
my $udom = $env{'form.ccdomain'}; |
my $uname = $env{'form.ccuname'}; |
my $uname = $env{'form.ccuname'}; |
Line 1164 END
|
Line 1287 END
|
$role,$url,$result).'<br />'; |
$role,$url,$result).'<br />'; |
} |
} |
$r->print($output); |
$r->print($output); |
} |
} |
} elsif ($_=~/^form\.act/) { |
} elsif ($_=~/^form\.act/) { |
my $udom = $env{'form.ccdomain'}; |
my $udom = $env{'form.ccdomain'}; |
my $uname = $env{'form.ccuname'}; |
my $uname = $env{'form.ccuname'}; |
Line 1187 END
|
Line 1310 END
|
if ($num_sections == 0) { |
if ($num_sections == 0) { |
$r->print(&commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end)); |
$r->print(&commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end)); |
} else { |
} else { |
foreach (sort {$a cmp $b} keys %sections) { |
my $numgrp=&Apache::loncommon::coursegroups(\%curr_groups, |
my $securl = $url.'/'.$_; |
$one,$two); |
|
foreach my $sec (sort {$a cmp $b} keys %sections) { |
|
if (($sec eq 'none') || ($sec eq 'all') || |
|
exists($curr_groups{$sec})) { |
|
$disallowed{$sec} = $url; |
|
next; |
|
} |
|
my $securl = $url.'/'.$sec; |
$r->print(&commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end)); |
$r->print(&commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end)); |
} |
} |
} |
} |
Line 1210 END
|
Line 1340 END
|
if ($num_sections == 0) { |
if ($num_sections == 0) { |
$r->print(&commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'')); |
$r->print(&commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'')); |
} else { |
} else { |
|
my $numgrp=&Apache::loncommon::coursegroups(\%curr_groups, |
|
$one,$two); |
my $emptysec = 0; |
my $emptysec = 0; |
foreach my $sec (sort {$a cmp $b} keys %sections) { |
foreach my $sec (sort {$a cmp $b} keys %sections) { |
$sec =~ s/\W//g; |
$sec =~ s/\W//g; |
if ($sec ne '') { |
if ($sec ne '') { |
|
if (($sec eq 'none') || ($sec eq 'all') || |
|
exists($curr_groups{$sec})) { |
|
$disallowed{$sec} = $url; |
|
next; |
|
} |
my $securl = $url.'/'.$sec; |
my $securl = $url.'/'.$sec; |
$r->print(&commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec)); |
$r->print(&commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec)); |
} else { |
} else { |
Line 1256 END
|
Line 1393 END
|
} else { |
} else { |
$r->print('<p>'.&mt('ERROR').': '.&mt('Unknown command').' <tt>'.$_.'</tt></p><br />'); |
$r->print('<p>'.&mt('ERROR').': '.&mt('Unknown command').' <tt>'.$_.'</tt></p><br />'); |
} |
} |
} |
foreach my $key (sort(keys(%disallowed))) { |
|
if (($key eq 'none') || ($key eq 'all')) { |
|
$r->print('<p>'.&mt('[_1] may not be used as the name for a section, as it is a reserved word.',$key)); |
|
} else { |
|
$r->print('<p>'.&mt('[_1] may not be used as the name for a section, as it is the name of a course group.',$key)); |
|
} |
|
$r->print(' '.&mt('Please <a href="javascript:history.go(-1)">go back</a> and choose a different section name.').'</p><br />'); |
|
} |
|
} |
} # End of foreach (keys(%env)) |
} # End of foreach (keys(%env)) |
# Flush the course logs so reverse user roles immediately updated |
# Flush the course logs so reverse user roles immediately updated |
&Apache::lonnet::flushcourselogs(); |
&Apache::lonnet::flushcourselogs(); |
Line 1342 sub commit_studentrole {
|
Line 1487 sub commit_studentrole {
|
} |
} |
} else { |
} else { |
$$logmsg .= "Incomplete course id defined. Addition of user $uname from domain $udom to course $one\_$two, section $sec not completed.$linefeed"; |
$$logmsg .= "Incomplete course id defined. Addition of user $uname from domain $udom to course $one\_$two, section $sec not completed.$linefeed"; |
$result = "Error: incomplete course id\n"; |
$result = "error: incomplete course id\n"; |
} |
} |
return $result; |
return $result; |
} |
} |
Line 1604 sub course_level_table {
|
Line 1749 sub course_level_table {
|
'act' => "Activate", |
'act' => "Activate", |
'rol' => "Role", |
'rol' => "Role", |
'ext' => "Extent", |
'ext' => "Extent", |
'grs' => "Group/Section", |
'grs' => "Section", |
'sta' => "Start", |
'sta' => "Start", |
'end' => "End" |
'end' => "End" |
); |
); |
Line 1753 sub course_level_dc {
|
Line 1898 sub course_level_dc {
|
'crl' => "Course Level", |
'crl' => "Course Level", |
'crt' => "Course Title", |
'crt' => "Course Title", |
'rol' => "Role", |
'rol' => "Role", |
'grs' => "Group/Section", |
'grs' => "Section", |
'exs' => "Existing sections", |
'exs' => "Existing sections", |
'new' => "Define new section", |
'new' => "Define new section", |
'sta' => "Start", |
'sta' => "Start", |
Line 1782 sub course_level_dc {
|
Line 1927 sub course_level_dc {
|
' <option value=""><--'.&mt('Pick course first').'</select></td>'. |
' <option value=""><--'.&mt('Pick course first').'</select></td>'. |
'<td> </td>'. |
'<td> </td>'. |
'<td valign="top"> <b>'.$lt{'new'}.'</b><br />'. |
'<td valign="top"> <b>'.$lt{'new'}.'</b><br />'. |
'<input type="text" name="newsec" value="" /></td>'. |
'<input type="text" name="newsec" value="" />'. |
|
'<input type="hidden" name="groups" value="" /></td>'. |
'</tr></table></td>'; |
'</tr></table></td>'; |
$otheritems .= <<ENDTIMEENTRY; |
$otheritems .= <<ENDTIMEENTRY; |
<td><input type=hidden name="start" value=''> |
<td><input type=hidden name="start" value=''> |