--- loncom/interface/lonrequestcourse.pm 2009/08/27 00:06:18 1.26
+++ loncom/interface/lonrequestcourse.pm 2010/02/26 22:38:31 1.41.2.6
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Request a course
#
-# $Id: lonrequestcourse.pm,v 1.26 2009/08/27 00:06:18 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.41.2.6 2010/02/26 22:38:31 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -44,24 +44,28 @@ described at http://www.lon-capa.org.
=item handler()
+=item get_breadcrumbs()
+
=item header()
=item form_elements()
=item onload_action()
-=item check_can_request()
-
-=item course_types()
-
=item print_main_menu()
=item request_administration()
+=item close_popup_form()
+
+=item get_instcode()
+
=item print_request_form()
=item print_enrollment_menu()
+=item show_invalid_crosslists()
+
=item inst_section_selector()
=item date_setting_table()
@@ -94,12 +98,14 @@ described at http://www.lon-capa.org.
=item check_autolimit()
-=item build_batchcreatehash()
-
=item retrieve_settings()
=item get_request_settings()
+=item extract_instcode()
+
+=item generate_date_items()
+
=back
=cut
@@ -112,6 +118,7 @@ use Apache::lonnet;
use Apache::loncommon;
use Apache::lonlocal;
use Apache::loncoursequeueadmin;
+use Apache::lonuserutils;
use LONCAPA qw(:DEFAULT :match);
sub handler {
@@ -122,14 +129,61 @@ sub handler {
return OK;
}
- &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['action','showdom','cnum']);
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['action','showdom','cnum','state','crstype']);
&Apache::lonhtmlcommon::clear_breadcrumbs();
my $dom = &get_course_dom();
my $action = $env{'form.action'};
my $state = $env{'form.state'};
- my %stored;
- my $jscript;
- my ($uname,$udom,$result,$warning);
+ my (%states,%stored);
+ my ($jscript,$uname,$udom,$result,$warning);
+
+ $states{'display'} = ['details'];
+ $states{'view'} = ['pick_request','details','cancel','removal'];
+ $states{'log'} = ['filter','display'];
+ $states{'new'} = ['courseinfo','enrollment','personnel','review','process'];
+
+ if ($dom eq 'gcitest') {
+ $states{'new'} = ['courseinfo','review','process'];
+ }
+
+ if (($action eq 'new') && ($env{'form.crstype'} eq 'official')) {
+ unless ($env{'form.state'} eq 'crstype') {
+ unshift(@{$states{'new'}},'codepick');
+ }
+ }
+
+ foreach my $key (keys(%states)) {
+ if (ref($states{$key}) eq 'ARRAY') {
+ unshift (@{$states{$key}},'crstype');
+ }
+ }
+
+ my @invalidcrosslist;
+ my %trail = (
+ crstype => 'Request Action',
+ codepick => 'Category',
+ courseinfo => 'Description',
+ enrollment => 'Access Dates',
+ personnel => 'Personnel',
+ review => 'Review',
+ process => 'Result',
+ pick_request => 'Display Summary',
+ details => 'Request Details',
+ cancel => 'Cancel Request',
+ removal => 'Outcome',
+ );
+ if ($dom eq 'gcitest') {
+ $trail{'crstype'} = 'Building a Test';
+ $trail{'courseinfo'} = 'Test Information';
+ }
+
+ if (($env{'form.crstype'} eq 'official') && (&Apache::lonnet::auto_run('',$dom))) {
+ $trail{'enrollment'} = 'Enrollment';
+ }
+
+ my ($page,$crumb,$newinstcode,$codechk,$checkedcode,$description) =
+ &get_breadcrumbs($dom,$action,\$state,\%states,\%trail);
if ($action eq 'display') {
if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) {
my $namespace = 'courserequestqueue';
@@ -146,22 +200,76 @@ sub handler {
if (($udom =~ /^$match_domain$/) && ($uname =~ /^$match_username$/)) {
$result = &retrieve_settings($dom,$cnum,$udom,$uname);
} else {
- $warning = &mt('Invalid username or domain for course requestor');
+ if ($env{'form.crstype'} eq 'community') {
+ $warning = &mt('Invalid username or domain for community requestor');
+ } else {
+ $warning = &mt('Invalid username or domain for course requestor');
+ }
}
} else {
- $warning = &mt('No information was found for this course request.');
+ if ($env{'form.crstype'} eq 'community') {
+ $warning = &mt('No information was found for this community request.');
+ } else {
+ $warning = &mt('No information was found for this course request.');
+ }
}
} else {
$warning = &mt('No course request ID provided.');
}
} else {
- $warning = &mt('You do not have rights to view course request information.');
+ if ($env{'form.crstype'} eq 'any') {
+ $warning = &mt('You do not have rights to view course or community request information.');
+ } elsif ($env{'form.crstype'} eq 'community') {
+ $warning = &mt('You do not have rights to view community request information.');
+ } else {
+ $warning = &mt('You do not have rights to view course request information.');
+ }
}
} elsif ((defined($state)) && (defined($action))) {
if (($action eq 'view') && ($state eq 'details')) {
if ((defined($env{'form.showdom'})) && (defined($env{'form.cnum'}))) {
my $result = &retrieve_settings($env{'form.showdom'},$env{'form.cnum'});
}
+ } elsif ($env{'form.crstype'} eq 'official') {
+ if (&Apache::lonnet::auto_run('',$dom)) {
+ if (($action eq 'new') && (($state eq 'enrollment') ||
+ ($state eq 'personnel'))) {
+ my $checkcrosslist = 0;
+ for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
+ if ($env{'form.crosslist_'.$i}) {
+ $checkcrosslist ++;
+ }
+ }
+ if ($checkcrosslist) {
+ my %codechk;
+ my (@codetitles,%cat_titles,%cat_order,@code_order,$lastitem);
+ &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,
+ \%cat_titles,
+ \%cat_order,
+ \@code_order);
+ my $numtitles = scalar(@codetitles);
+ if ($numtitles) {
+ for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
+ if ($env{'form.crosslist_'.$i}) {
+ my $codecheck;
+ my $crosslistcode = '';
+ foreach my $item (@code_order) {
+ $crosslistcode .= $env{'form.crosslist_'.$i.'_'.$item};
+ }
+ if ($crosslistcode ne '') {
+ ($codechk{$i}, my $rest) =
+ &Apache::lonnet::auto_validate_instcode('',$dom,$crosslistcode);
+ }
+ unless ($codechk{$i} eq 'valid') {
+ $env{'form.crosslist_'.$i} = '';
+ push(@invalidcrosslist,$crosslistcode);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
}
my %elements = &form_elements($dom);
my $elementsref = {};
@@ -173,109 +281,45 @@ sub handler {
if (($state eq 'courseinfo') && ($env{'form.clonedom'} eq '')) {
$env{'form.clonedom'} = $dom;
}
- $jscript = &Apache::lonhtmlcommon::set_form_elements($elementsref,\%stored);
+ if ($state eq 'crstype') {
+ $jscript = &mainmenu_javascript();
+ } else {
+ $jscript = &Apache::lonhtmlcommon::set_form_elements($elementsref,\%stored);
+ if ($state eq 'courseinfo') {
+ $jscript .= &cloning_javascript();
+ }
+ }
}
if ($state eq 'personnel') {
$jscript .= "\n".&Apache::loncommon::userbrowser_javascript();
}
- my $loaditems = &onload_action($action,$state);
-
- my %states;
- $states{'display'} = ['details'];
- $states{'view'} = ['pick_request','details','cancel','removal'];
- $states{'log'} = ['filter','display'];
- $states{'new'} = ['courseinfo','enrollment','personnel','review','process'];
-
- if (($action eq 'new') && ($env{'form.crstype'} eq 'official')) {
- unless ($env{'form.state'} eq 'crstype') {
- unshift(@{$states{'new'}},'codepick');
- }
- }
-
- foreach my $key (keys(%states)) {
- if (ref($states{$key}) eq 'ARRAY') {
- unshift (@{$states{$key}},'crstype');
- }
- }
+ my $loaditems = &onload_action($action,$state,$dom);
- my %trail = (
- crstype => 'Course Request Action',
- codepick => 'Category',
- courseinfo => 'Description',
- enrollment => 'Access Dates',
- personnel => 'Personnel',
- review => 'Review',
- process => 'Result',
- pick_request => 'Display Summary',
- details => 'Request Details',
- cancel => 'Cancel Request',
- removal => 'Outcome',
- );
-
- if (($env{'form.crstype'} eq 'official') && (&Apache::lonnet::auto_run('',$dom))) {
- $trail{'enrollment'} = 'Enrollment';
- }
-
- my $page = 0;
- my $crumb;
- if (defined($action)) {
- my $done = 0;
- my $i=0;
- if (ref($states{$action}) eq 'ARRAY') {
- while ($i<@{$states{$action}} && !$done) {
- if ($states{$action}[$i] eq $state) {
- $page = $i;
- $done = 1;
- }
- $i++;
- }
- }
- for (my $i=0; $i<@{$states{$action}}; $i++) {
- if ($state eq $states{$action}[$i]) {
- &Apache::lonhtmlcommon::add_breadcrumb(
- {text=>"$trail{$state}"});
- $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests');
- last;
- } else {
- if (($state eq 'process') && ($i > 0)) {
- &Apache::lonhtmlcommon::add_breadcrumb(
- {href=>"javascript:backPage(document.requestcrs,'$states{$action}[0]')",
- text=>"$trail{$states{$action}[$i]}"});
- } else {
- &Apache::lonhtmlcommon::add_breadcrumb(
- {href=>"javascript:backPage(document.requestcrs,'$states{$action}[$i]')",
- text=>"$trail{$states{$action}[$i]}"});
- }
- }
- }
- } else {
- &Apache::lonhtmlcommon::add_breadcrumb(
- {text=>'Pick Action'});
- $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests');
- }
-
- my %can_request;
- my $canreq = &check_can_request($dom,\%can_request);
+ my (%can_request,%request_domains);
+ my $canreq =
+ &Apache::lonnet::check_can_request($dom,\%can_request,\%request_domains);
if ($action eq 'new') {
if ($canreq) {
if ($state eq 'crstype') {
&print_main_menu($r,\%can_request,\%states,$dom,$jscript,$loaditems,
- $crumb);
+ $crumb,\%request_domains);
} else {
- &request_administration($r,$action,$state,$page,\%states,$dom,$jscript,
- $loaditems,$crumb);
+ &request_administration($r,$action,$state,$page,\%states,$dom,
+ $jscript,$loaditems,$crumb,$newinstcode,
+ $codechk,$checkedcode,$description,
+ \@invalidcrosslist);
}
} else {
- $r->print(&header('Course Requests').$crumb.
+ $r->print(&header('Course/Community Requests').$crumb.
'
'.
- &mt('You do not have privileges to request creation of courses.').
+ &mt('You do not have privileges to request creation of courses or communities.').
'
'.
&close_popup_form());
} else {
&request_administration($r,$action,$state,$page,\%states,$dom,$jscript,
- $loaditems,$crumb,$uname,$udom);
+ $loaditems,$crumb,'','','','','',$uname,$udom);
}
} elsif ($action eq 'log') {
&print_request_logs($jscript,$loaditems,$crumb);
} else {
- &print_main_menu($r,\%can_request,\%states,$dom,$jscript,'',$crumb);
+ &print_main_menu($r,\%can_request,\%states,$dom,$jscript,'',$crumb,\%request_domains);
}
return OK;
}
+sub mainmenu_javascript {
+ return <<"END";
+function setType(courseForm) {
+ for (var i=0; i 1) {
+ for (var i=0; i{$action}) eq 'ARRAY') {
+ while ($i<@{$states->{$action}} && !$done) {
+ if ($states->{$action}[$i] eq $$state) {
+ $page = $i;
+ $done = 1;
+ }
+ $i++;
+ }
+ }
+ if ($env{'form.crstype'} eq 'official') {
+ if ($page > 1) {
+ if ($states->{$action}[$page-1] eq 'codepick') {
+ if ($env{'form.instcode'} eq '') {
+ ($newinstcode,$numtitles) = &get_instcode($dom);
+ if ($numtitles) {
+ if ($newinstcode eq '') {
+ $$state = 'codepick';
+ $page --;
+ } else {
+ ($codechk,$description) =
+ &Apache::lonnet::auto_validate_instcode('',
+ $dom,$newinstcode);
+ if ($codechk ne 'valid') {
+ $$state = 'codepick';
+ $page --;
+ }
+ $checkedcode = 1;
+ }
+ }
+ }
+ }
+ }
+ }
+ for (my $i=0; $i<@{$states->{$action}}; $i++) {
+ if ($$state eq $states->{$action}[$i]) {
+ &Apache::lonhtmlcommon::add_breadcrumb(
+ {text=>"$trail->{$$state}"});
+ $crumb = &Apache::lonhtmlcommon::breadcrumbs($crumbtitle,$crumbhelp);
+ last;
+ } else {
+ if (($$state eq 'process') || ($$state eq 'removal')) {
+ &Apache::lonhtmlcommon::add_breadcrumb(
+ { href => '/adm/requestcourse',
+ text => "$trail->{$states->{$action}[$i]}",
+ }
+ );
+ } else {
+ &Apache::lonhtmlcommon::add_breadcrumb(
+ { href => "javascript:backPage(document.requestcrs,'$states->{$action}[$i]')",
+ text => "$trail->{$states->{$action}[$i]}", }
+ );
+ }
+ }
+ }
+ } else {
+ &Apache::lonhtmlcommon::add_breadcrumb(
+ {text=>$firstcrumb});
+ $crumb = &Apache::lonhtmlcommon::breadcrumbs($crumbtitle,$crumbhelp);
+ }
+ } else {
+ &Apache::lonhtmlcommon::add_breadcrumb(
+ {text=>$firstcrumb});
+ $crumb = &Apache::lonhtmlcommon::breadcrumbs($crumbtitle,$crumbhelp);
+ }
+ return ($page,$crumb,$newinstcode,$codechk,$checkedcode,$description);
+}
+
sub header {
my ($bodytitle,$jscript,$loaditems,$jsextra,$args) = @_;
if ($jscript) {
@@ -332,6 +499,7 @@ sub form_elements {
},
courseinfo => {
cdescr => 'text',
+ cloning => 'radio',
clonecrs => 'text',
clonedom => 'selectbox',
datemode => 'radio',
@@ -367,12 +535,27 @@ sub form_elements {
},
);
my %servers = &Apache::lonnet::get_servers($dom,'library');
+ if ($dom eq 'gcitest') {
+ %{$elements{'new'}{'courseinfo'}} = (
+ cdescr => 'text',
+ concepttest => 'radio',
+ );
+ if (&show_cloneable()) {
+ $elements{'new'}{'courseinfo'}{'clonecrs'} = 'selectbox';
+ $elements{'new'}{'courseinfo'}{'clonedom'} = 'hidden';
+ $elements{'new'}{'courseinfo'}{'cloneroster'} = 'checkbox';
+ }
+ }
my $numlib = keys(%servers);
if ($numlib > 1) {
$elements{'new'}{'courseinfo'}{'chome'} = 'selectbox';
} else {
$elements{'new'}{'courseinfo'}{'chome'} = 'hidden';
}
+ if ($dom eq 'gcitest') {
+ my %mergedhash = (%{$elements{'new'}{'courseinfo'}},%{$elements{'new'}{'enrollment'}});
+ %{$elements{'new'}{'courseinfo'}} = %mergedhash;
+ }
my (@codetitles,%cat_titles,%cat_order,@code_order,$lastitem);
&Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
\%cat_order,\@code_order);
@@ -401,16 +584,15 @@ sub form_elements {
enrollend_year => 'text',
enrollend_minute => 'text',
enrollend_second => 'text',
- crosslisttotal => 'hidden',
addcrosslist => 'checkbox',
autoadds => 'radio',
autodrops => 'radio',
);
if ($env{'form.sectotal'} > 0) {
for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
- $extras{'sec_'.$i} = 'checkbox',
- $extras{'secnum_'.$i} = 'text',
- $extras{'loncapasec_'.$i} = 'text',
+ $extras{'sec_'.$i} = 'radio';
+ $extras{'secnum_'.$i} = 'text';
+ $extras{'loncapasec_'.$i} = 'text';
}
}
my $crosslisttotal = $env{'form.crosslisttotal'};
@@ -420,6 +602,7 @@ sub form_elements {
if (!$crosslisttotal) {
$crosslisttotal = 1;
}
+
for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
if ($numtitles) {
$extras{'crosslist_'.$i.'_'.$lastitem} = 'text';
@@ -464,60 +647,29 @@ sub onload_action {
my ($action,$state) = @_;
my %loaditems;
if (($action eq 'new') || ($action eq 'view')) {
- $loaditems{'onload'} = 'javascript:setFormElements(document.requestcrs)';
- }
- return \%loaditems;
-}
-
-sub check_can_request {
- my ($dom,$can_request) = @_;
- my $canreq = 0;
- my ($types,$typename) = &course_types();
- my @options = ('approval','validate','autolimit');
- my $optregex = join('|',@options);
- if ((ref($can_request) eq 'HASH') && (ref($types) eq 'ARRAY')) {
- foreach my $type (@{$types}) {
- if (&Apache::lonnet::usertools_access($env{'user.name'},
- $env{'user.domain'},
- $type,undef,'requestcourses')) {
- $canreq ++;
- if ($dom eq $env{'user.domain'}) {
- $can_request->{$type} = 1;
- }
- }
- if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
- my @curr = split(',',$env{'environment.reqcrsotherdom.'.$type});
- if (@curr > 0) {
- $canreq ++;
- unless ($dom eq $env{'user.domain'}) {
- if (grep(/^\Q$dom\E:($optregex)(=?\d*)$/,@curr)) {
- $can_request->{$type} = 1;
- }
- }
- }
+ if ($state eq 'crstype') {
+ $loaditems{'onload'} = 'javascript:setAction(document.mainmenu_action);javascript:setType(document.mainmenu_coursetype)';
+ } else {
+ $loaditems{'onload'} = 'javascript:setFormElements(document.requestcrs);';
+ }
+ if ($state eq 'courseinfo') {
+ if (&show_cloneable()) {
+ $loaditems{'onload'} .= 'javascript:setCloneDisplay(document.requestcrs);';
}
}
+ if (($state eq 'process') && ($env{'form.concepttest'} eq 'editmyown')) {
+ $loaditems{'onload'} = 'javascript:setInitialVisibility()';
+ }
}
- return $canreq;
-}
-
-sub course_types {
- my @types = ('official','unofficial','community');
- my %typename = (
- official => 'Official course',
- unofficial => 'Unofficial course',
- community => 'Community',
- );
- return (\@types,\%typename);
+ return \%loaditems;
}
-
sub print_main_menu {
- my ($r,$can_request,$states,$dom,$jscript,$loaditems,$crumb) = @_;
- my ($types,$typename) = &course_types();
+ my ($r,$can_request,$states,$dom,$jscript,$loaditems,$crumb,$request_domains) = @_;
+ my ($types,$typename) = &Apache::loncommon::course_types();
my $onchange;
unless ($env{'form.interface'} eq 'textual') {
- $onchange = 1;
+ $onchange = 'this.form.submit()';
}
my $nextstate_setter = "\n";
@@ -533,17 +685,21 @@ sub print_main_menu {
}
}
- my $js = <<"END";
+ my $js;
+ unless ($dom eq 'gcitest') {
+ $js = <<"END";
function nextPage(formname) {
- var crschoice = document.requestcrs.crstype.value;
- var actionchoice = document.requestcrs.action.value;
+ var crschoice = document.mainmenu_coursetype.crstype.value;
+ var actionchoice = document.mainmenu_action.action.value;
if (check_can_request(crschoice,actionchoice) == true) {
if ((actionchoice == 'new') && (crschoice == 'official')) {
nextstate = 'codepick';
} else {
$nextstate_setter
- }
+ }
+ formname.crstype.value = crschoice;
+ formname.action.value = actionchoice;
formname.state.value= nextstate;
formname.submit();
}
@@ -555,19 +711,20 @@ function check_can_request(crschoice,act
var unofficial = '';
var community = '';
END
-
- foreach my $item (keys(%{$can_request})) {
- $js .= "
- $item = 1;
+ if (ref($can_request) eq 'HASH') {
+ foreach my $item (keys(%{$can_request})) {
+ $js .= "
+ $item = 1;
";
- }
- my %lt = &Apache::lonlocal::texthash(
- official => 'You are not permitted to request creation of an official course in this domain.',
- unofficial => 'You are not permitted to request creation of an unofficial course in this domain.',
- community => 'You are not permitted to request creation of a community this domain.',
- all => 'You must choose a specific course type when making a new course request.\\nAll types is not allowed.',
- );
- $js .= < 'You are not permitted to request creation of an official course in this domain.',
+ unofficial => 'You are not permitted to request creation of an unofficial course in this domain.',
+ community => 'You are not permitted to request creation of a community this domain.',
+ all => 'You must choose a specific course type when making a new course request.\\nAll types is not allowed.',
+ );
+ $js .= <{'official'}) || ($can_request->{'unofficial'})) {
+ if ($can_request->{'community'}) {
+ $pagetitle = 'Course/Community Requests';
+ $pageinfo = &mt('Request creation of a new course or community, or review your pending requests.');
+ $domaintitle = &mt('Course/Community Domain');
+ } else {
+ $pagetitle = 'Course Requests';
+ $pageinfo = &mt('Request creation of a new course, or review your pending course requests.');
+ $domaintitle = &mt('Course Domain');
+ }
+ } elsif ($can_request->{'community'}) {
+ $pagetitle = 'Community Requests';
+ $pageinfo = &mt('Request creation of a new course, or review your pending requests.');
+ $domaintitle = &mt('Community Domain');
+ } else {
+ $pagetitle = 'Course/Community Requests';
+ $pageinfo = &mt('You do not have rights to request creation of courses in this domain; please choose a different domain.');
+ $domaintitle = &mt('Course/Community Domain');
+ }
+ }
+
+ if ($dom eq 'gcitest') {
+ my $formname = 'requestcrs';
+ my $nexttext = &mt('Continue');
+ $r->print(&header($pagetitle,$js.$jscript,$loaditems).$crumb.
+ '
'.&mt('Deployment of a Concept Test requires completion of the following three steps:').'
'.
+ '
'.&mt('Creation of a course "container" and setting of access dates').'
'.
+ '
'.&mt('Assembly of a valid test from Concept Inventory questions').'
'.
+ '
'.&mt('Enrollment of students').'
'.
+ '
'.&mt('When assembling a test you may:').
+ ' '.&mt('(a) have a valid test built automatically by the WebCenter, or').' '.&mt('(b) select the questions to include by combining questions chosen from eleven bins with four mandatory questions, or').
+ ' '.&mt('(c) copy one of your existing tests (including optional copying of the student roster)').'
'.&mt('The most efficient way to enroll students is to upload a text file containing usernames and passwords.').' '.&mt("Students' full e-mail addresses should be used as their usernames to ensure uniqueness.").'
'.
&close_popup_form());
@@ -800,6 +1102,166 @@ END
return;
}
+sub enrollment_lcsec_js {
+ my %alerts = §ion_check_alerts();
+ my $secname = $alerts{'badsec'};
+ my $secnone = $alerts{'reserved'};
+ my $output = '
+function validateEnrollSections(formname,nextstate) {
+ var badsectotal = 0;
+ var reservedtotal = 0;
+ var secTest = "";
+';
+ for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
+ $output .= "
+ var selSec = 0;
+ for (var j=0; j "You need to change one or more LON-CAPA section names - none is a reserved word in the system, and may not be used.",
+ badsec => 'You need to change one or more LON-CAPA section names - names may only contain letters or numbers.',
+ separate => 'Separate multiple sections with a comma.'
+ );
+ return %lt;
+}
+
+sub section_check_javascript {
+ return <<"END";
+function validsection(field,mult) {
+ var str = field.value;
+ var badsec=0;
+ var reserved=0;
+ if (window.RegExp) {
+ var badsecnum=0;
+ var reservednum=0;
+ var pattern=/[^a-zA-Z0-9]/;
+ str = str.replace(/(^\\s*)|(\\s*\$)/gi,"");
+ str = str.replace(/[ ]{2,}/gi," ");
+ if (mult == '1') {
+ var sections = new Array();
+ sections = str.split(/\\s*[\\s,;:]\\s*/);
+ var i;
+ for (i=0; i 0) {
+ return 'badsec';
+ }
+ if (reservednum > 0) {
+ return 'reserved';
+ }
+ }
+ return;
+}
+END
+}
+
sub close_popup_form {
my $close= &mt('Close Window');
return << "END";
@@ -809,8 +1271,25 @@ sub close_popup_form {
END
}
+sub get_instcode {
+ my ($dom) = @_;
+ my ($instcode,$numtitles);
+ my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk);
+ &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
+ \%cat_order,\@code_order);
+ $numtitles = scalar(@codetitles);
+ if (@code_order > 0) {
+ my $message;
+ foreach my $item (@code_order) {
+ $instcode .= $env{'form.instcode_'.$item};
+ }
+ }
+ return ($instcode,$numtitles);
+}
+
sub print_request_form {
- my ($r,$action,$state,$page,$states,$dom) = @_;
+ my ($r,$action,$state,$page,$states,$dom,$newinstcode,$codechk,$checkedcode,
+ $description,$invalidcrosslist) = @_;
my $formname = 'requestcrs';
my ($next,$prev,$message,$output,$codepicker,$crstype);
$prev = $states->{$action}[$page-1];
@@ -820,45 +1299,29 @@ sub print_request_form {
next => 'Next',
);
$crstype = $env{'form.crstype'};
- $r->print('