--- loncom/interface/loncreateuser.pm 2004/01/17 18:12:05 1.77
+++ loncom/interface/loncreateuser.pm 2004/12/02 21:32:51 1.90
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.77 2004/01/17 18:12:05 www Exp $
+# $Id: loncreateuser.pm,v 1.90 2004/12/02 21:32:51 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -123,10 +123,7 @@ sub print_username_entry_form {
my $defdom=$ENV{'request.role.domain'};
my @domains = &Apache::loncommon::get_domains();
my $domform = &Apache::loncommon::select_dom_form($defdom,'ccdomain');
- my $bodytag =&Apache::loncommon::bodytag(
- 'Create Users, Change User Privileges').
- &Apache::loncommon::help_open_faq(282).
- &Apache::loncommon::help_open_bug('Instructor Interface');
+ my $bodytag =&Apache::loncommon::bodytag('Create Users, Change User Privileges').&Apache::loncommon::help_open_menu('',undef,undef,'',282,'Instructor Interface');
my $selscript=&Apache::loncommon::studentbrowser_javascript();
my $sellink=&Apache::loncommon::selectstudent_link
('crtuser','ccuname','ccdomain');
@@ -177,8 +174,8 @@ sub print_user_modification_page {
my $ccuname=$ENV{'form.ccuname'};
my $ccdomain=$ENV{'form.ccdomain'};
- $ccuname=~s/\W//gs;
- $ccdomain=~s/\W//gs;
+ $ccuname=~s/[\W|_]//gs;
+ $ccdomain=~s/[\W|_]//gs;
unless (($ccuname) && ($ccdomain)) {
&print_username_entry_form($r);
@@ -200,6 +197,81 @@ sub print_user_modification_page {
$ccuname=~s/\W//g;
$ccdomain=~s/\W//g;
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
+ my $dc_setcourse_code = '';
+ my $loaditem;
+ if ($ENV{'request.role'} =~ m-^dc\./(\w+)/$-) {
+ my $dcdom = $1;
+ $loaditem = qq|OnLoad="document.cu.coursedesc.value=''"|;
+ $dc_setcourse_code = <<"ENDSCRIPT";
+ function setCourse() {
+ var course = document.cu.dccourse.value;
+ if (course != "") {
+ if (document.cu.dcdomain.value != document.cu.origdom.value) {
+ alert("You must select a course in the current domain");
+ return;
+ }
+ var userrole = document.cu.role.options[document.cu.role.selectedIndex].value
+ var section;
+ var numsections = 0;
+ for (var i=0; i 1)) {
+ 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;
+ }
+ 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.");
+ section = "";
+ }
+ var numcourse = getIndex(document.cu.dccourse);
+ if (numcourse == "-1") {
+ alert("There was a problem with your course selection");
+ return
+ }
+ else {
+ var coursename = "_$dcdom"+"_"+course+"_"+userrole
+ document.cu.elements[numcourse].name = "act"+coursename
+ document.cu.elements[numcourse+4].name = "sec"+coursename
+ document.cu.elements[numcourse+4].value = section
+ document.cu.elements[numcourse+5].name = "start"+coursename
+ document.cu.elements[numcourse+6].name = "end"+coursename
+ }
+ }
+ document.cu.submit();
+ }
+
+ function getIndex(caller) {
+ for (var i=0;i
@@ -213,6 +285,7 @@ sub print_user_modification_page {
}
$pjump_def
+ $dc_setcourse_code
function dateset() {
eval("document.cu."+document.cu.pres_marker.value+
@@ -220,11 +293,71 @@ sub print_user_modification_page {
pclose();
}
+ function setSections() {
+ var re1 = /^currsec_/;
+ for (var i=0;i 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 {
+ document.cu.elements[i+2].value = sections;
+ }
+ }
+ }
+ }
+ }
+ document.cu.submit();
+ }
ENDDOCHEAD
$r->print(&Apache::loncommon::bodytag(
- 'Create Users, Change User Privileges'));
+ 'Create Users, Change User Privileges',undef,$loaditem));
my $forminfo =<<"ENDFORMINFO";