--- loncom/interface/lonrequestcourse.pm 2010/11/29 04:40:12 1.41.2.9
+++ loncom/interface/lonrequestcourse.pm 2013/12/25 09:52:42 1.70
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Request a course
#
-# $Id: lonrequestcourse.pm,v 1.41.2.9 2010/11/29 04:40:12 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.70 2013/12/25 09:52:42 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -94,8 +94,6 @@ described at http://www.lon-capa.org.
=item print_request_outcome()
-=item get_processtype()
-
=item check_autolimit()
=item retrieve_settings()
@@ -128,46 +126,37 @@ sub handler {
if ($r->header_only) {
return OK;
}
- &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['action','showdom','cnum','state','crstype']);
- &Apache::lonhtmlcommon::clear_breadcrumbs();
- my $action = $env{'form.reqaction'};
- my $state = $env{'form.state'};
- my $context;
- &generate_page($r,$action,$state,$context);
- return OK;
-}
-sub generate_page {
- my ($r,$action,$state,$context) = @_;
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['action','showdom','cnum','state','crstype']);
+ ['action','showdom','cnum','state','crstype','queue']);
+ &Apache::lonhtmlcommon::clear_breadcrumbs();
my $dom = &get_course_dom();
+ my $action = $env{'form.action'};
+ my $state = $env{'form.state'};
my (%states,%stored);
- my ($jscript,$uname,$udom,$result,$warning);
+ my ($jscript,$uname,$udom,$result,$warning,$showcredits,$instcredits);
+ my %domdefs = &Apache::lonnet::get_domain_defaults($dom);
+ if ($domdefs{'officialcredits'} || $domdefs{'unofficialcredits'} || $domdefs{'textbookcredits'}) {
+ $showcredits = 1;
+ }
$states{'display'} = ['details'];
$states{'view'} = ['pick_request','details','cancel','removal'];
- $states{'log'} = ['filter','display'];
+ $states{'log'} = ['display'];
$states{'new'} = ['courseinfo','enrollment','personnel','review','process'];
- if ($dom eq 'gcitest') {
- $states{'new'} = ['courseinfo','review','process'];
- if ($env{'form.concepttest'} eq 'editmyown') {
- push(@{$states{'new'}},'chooseitems','uploadroster','enrolling');
- } elsif (($env{'form.concepttest'} eq 'defchosen') ||
- (($env{'form.concepttest'} eq 'cloning') && (!$env{'form.cloneroster'}))) {
- push(@{$states{'new'}},'uploadroster','enrolling');
- } else {
- push(@{$states{'new'}},'done');
- }
- }
if (($action eq 'new') && ($env{'form.crstype'} eq 'official')) {
- unless ($state eq 'crstype') {
+ unless ($env{'form.state'} eq 'crstype') {
unshift(@{$states{'new'}},'codepick');
}
}
+ if (($action eq 'new') && (&Apache::loncoursequeueadmin::author_prompt())) {
+ if (ref($states{$action}) eq 'ARRAY') {
+ push(@{$states{$action}},'reqauthor');
+ }
+ }
+
foreach my $key (keys(%states)) {
if (ref($states{$key}) eq 'ARRAY') {
unshift (@{$states{$key}},'crstype');
@@ -183,32 +172,26 @@ sub generate_page {
personnel => 'Personnel',
review => 'Review',
process => 'Result',
+ reqauthor => 'Authoring Space Result',
pick_request => 'Display Summary',
details => 'Request Details',
cancel => 'Cancel Request',
removal => 'Outcome',
- chooseitems => 'Saved Test',
- uploadroster => 'Upload Roster',
- enrolling => 'Completed',
- done => 'Completed',
+ display => 'Request Logs',
);
- 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) =
+ 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';
if ($env{'form.cnum'} ne '') {
my $cnum = $env{'form.cnum'};
- my $reqkey = $cnum.'_approval';
+ my $queue = $env{'form.queue'};
+ my $reqkey = $cnum.'_'.$queue;
my $namespace = 'courserequestqueue';
my $domconfig = &Apache::lonnet::get_domainconfiguser($dom);
my %queued =
@@ -290,18 +273,18 @@ sub generate_page {
}
}
}
- my %elements = &form_elements($dom);
+ (my $elements,$instcredits) = &form_elements($dom,$showcredits);
my $elementsref = {};
- if (ref($elements{$action}) eq 'HASH') {
- if (ref($elements{$action}{$state}) eq 'HASH') {
- $elementsref = $elements{$action}{$state};
+ if ((ref($elements) eq 'HASH') && (ref($elements->{$action}) eq 'HASH')) {
+ if (ref($elements->{$action}{$state}) eq 'HASH') {
+ $elementsref = $elements->{$action}{$state};
}
}
if (($state eq 'courseinfo') && ($env{'form.clonedom'} eq '')) {
$env{'form.clonedom'} = $dom;
}
if ($state eq 'crstype') {
- $jscript = &mainmenu_javascript($action);
+ $jscript = &mainmenu_javascript();
} else {
$jscript = &Apache::lonhtmlcommon::set_form_elements($elementsref,\%stored);
if ($state eq 'courseinfo') {
@@ -314,7 +297,7 @@ sub generate_page {
$jscript .= "\n".&Apache::loncommon::userbrowser_javascript();
}
- my $loaditems = &onload_action($action,$state,$dom);
+ my $loaditems = &onload_action($action,$state);
my (%can_request,%request_domains);
my $canreq =
@@ -328,11 +311,7 @@ sub generate_page {
&request_administration($r,$action,$state,$page,\%states,$dom,
$jscript,$loaditems,$crumb,$newinstcode,
$codechk,$checkedcode,$description,
- \@invalidcrosslist);
- if ($state eq 'chooseitems' || $state eq 'uploadroster' ||
- $state eq 'enrolling') {
- return $canreq;
- }
+ $showcredits,$instcredits,\@invalidcrosslist);
}
} else {
$r->print(&header('Course/Community Requests').$crumb.
@@ -345,29 +324,46 @@ sub generate_page {
&print_main_menu($r,\%can_request,\%states,$dom,$jscript,$loaditems,$crumb,\%request_domains);
} else {
&request_administration($r,$action,$state,$page,\%states,$dom,$jscript,
- $loaditems,$crumb);
+ $loaditems,$crumb,'','','','',$showcredits);
}
} elsif ($action eq 'display') {
if ($warning ne '') {
my $args = { only_body => 1 };
- $r->print(&header('Course/Community Requests','','',$args).$crumb.
+ $r->print(&header('Course/Community Requests','','' ,'',$args).$crumb.
'
'.&mt('Course/Community Request Details').'
'.
'
'.$warning.'
'.
&close_popup_form());
} else {
&request_administration($r,$action,$state,$page,\%states,$dom,$jscript,
- $loaditems,$crumb,'','','','','',$uname,$udom);
+ $loaditems,$crumb,'','','','',$showcredits,'','',
+ $uname,$udom);
}
} elsif ($action eq 'log') {
- &print_request_logs($jscript,$loaditems,$crumb);
+ if ($state eq 'crstype') {
+ &print_main_menu($r,\%can_request,\%states,$dom,$jscript,'',$crumb,\%request_domains);
+ } else {
+ $jscript .= < 1) {
+ if (courseForm.cloning.length > 1) {
for (var i=0; i 'requestcrs',
- uploadroster => 'studentform',
- enrolling => 'requestcrs',
- done => 'requestcrs',
- );
- my $lastidx;
- for (my $i=0; $i<@{$states->{$action}}; $i++) {
- if ($$state eq $states->{$action}[$i]) {
- $lastidx = $i;
- last;
- }
- }
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);
+ $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course/Community Requests','Course_Requests');
last;
} else {
- if (($$state eq 'process') || ($$state eq 'removal')) {
+ if (($$state eq 'process') || ($$state eq 'removal') || ($$state eq 'reqauthor')) {
&Apache::lonhtmlcommon::add_breadcrumb(
{ href => '/adm/requestcourse',
text => "$trail->{$states->{$action}[$i]}",
}
);
} else {
- if (($$state eq 'chooseitems') || ($$state eq 'uploadroster') ||
- ($$state eq 'enrolling') || ($$state eq 'done')) {
- if (($states->{$action}[$i] ne 'process') &&
- ($states->{$action}[$i] ne 'chooseitems') &&
- ($states->{$action}[$i] ne 'uploadroster') &&
- ($states->{$action}[$i] ne 'enrolling') &&
- ($states->{$action}[$i] ne 'done')) {
- &Apache::lonhtmlcommon::add_breadcrumb(
- { href => '/adm/requestcourse',
- text => "$trail->{$states->{$action}[$i]}",
- }
- );
- } else {
- my $diff = $i-$lastidx;
- &Apache::lonhtmlcommon::add_breadcrumb(
- { href => "javascript:history.go($diff)",
- text => "$trail->{$states->{$action}[$i]}", }
- );
- }
- } else {
- &Apache::lonhtmlcommon::add_breadcrumb(
+ &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);
+ {text=>'Pick Action'});
+ $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course/Community Requests','Course_Requests');
}
} else {
&Apache::lonhtmlcommon::add_breadcrumb(
- {text=>$firstcrumb});
- $crumb = &Apache::lonhtmlcommon::breadcrumbs($crumbtitle,$crumbhelp);
+ {text=>'Pick Action'});
+ $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course/Community Requests','Course_Requests');
}
return ($page,$crumb,$newinstcode,$codechk,$checkedcode,$description);
}
@@ -535,20 +489,19 @@ sub header {
if (ref($args) eq 'HASH') {
my %loadhash = (
'add_entries' => $loaditems,
- 'function' => 'norole',
);
my %arghash = (%loadhash,%{$args});
- $args = \%arghash;
+ $args = \%arghash;
} else {
- $args = {'add_entries' => $loaditems,
- 'function' => 'norole'};
+ $args = {'add_entries' => $loaditems,};
}
}
return &Apache::loncommon::start_page($bodytitle,$jscript.$jsextra,$args);
}
sub form_elements {
- my ($dom) = @_;
+ my ($dom,$showcredits) = @_;
+ my $instcredits;
my %elements =
(
new => {
@@ -559,7 +512,7 @@ sub form_elements {
},
courseinfo => {
cdescr => 'text',
- cloning => 'radio',
+ cloning => 'radio',
clonecrs => 'text',
clonedom => 'selectbox',
datemode => 'radio',
@@ -595,28 +548,12 @@ sub form_elements {
},
);
my %servers = &Apache::lonnet::get_servers($dom,'library');
- if ($dom eq 'gcitest') {
- %{$elements{'new'}{'courseinfo'}} = (
- cdescr => 'text',
- concepttest => 'radio',
- );
- $elements{'new'}{'enrollment'}{'timezone'} = 'selectbox';
- 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);
@@ -632,7 +569,6 @@ sub form_elements {
}
if (&Apache::lonnet::auto_run('',$dom)) {
my %extras = (
- sectotal => 'hidden',
enrollstart_month => 'selectbox',
enrollstart_hour => 'selectbox',
enrollend_month => 'selectbox',
@@ -648,12 +584,39 @@ sub form_elements {
addcrosslist => 'checkbox',
autoadds => 'radio',
autodrops => 'radio',
- );
- if ($env{'form.sectotal'} > 0) {
- for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
- $extras{'sec_'.$i} = 'radio';
- $extras{'secnum_'.$i} = 'text';
- $extras{'loncapasec_'.$i} = 'text';
+ );
+ my ($instcode,$titlescount) = &get_instcode($dom);
+ if ($instcode) {
+ my @sections = &Apache::lonnet::auto_get_sections(undef,$dom,$instcode);
+ if (@sections) {
+ $extras{'sectotal'} = 'hidden';
+ if ($env{'form.sectotal'} > 0) {
+ for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
+ $extras{'sec_'.$i} = 'radio';
+ $extras{'secnum_'.$i} = 'text';
+ $extras{'loncapasec_'.$i} = 'text';
+ }
+ }
+ } else {
+ $extras{'addsection'} = 'checkbox';
+ my $sectotal = $env{'form.sectotal'};
+ if ($env{'form.addsection'}) {
+ $sectotal ++;
+ }
+ for (my $i=0; $i<$sectotal; $i++) {
+ $extras{'sec_'.$i} = 'checkbox';
+ $extras{'secnum_'.$i} = 'text',
+ $extras{'loncapasec_'.$i} = 'text',
+ }
+ }
+ (my $outcome,my $desc,$instcredits) =
+ &Apache::lonnet::auto_validate_instcode(undef,$dom,$instcode);
+ if ($showcredits && $instcredits eq '') {
+ $extras{'coursecredits'} = 'text';
+ }
+ } elsif (($env{'form.crstype'} eq 'unofficial') || ($env{'form.crstype'} eq 'textbook')) {
+ if ($showcredits) {
+ $extras{'coursecredits'} = 'text';
}
}
my $crosslisttotal = $env{'form.crosslisttotal'};
@@ -663,7 +626,6 @@ sub form_elements {
if (!$crosslisttotal) {
$crosslisttotal = 1;
}
-
for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
if ($numtitles) {
$extras{'crosslist_'.$i.'_'.$lastitem} = 'text';
@@ -701,7 +663,7 @@ sub form_elements {
}
my %personnelhash = (%{$elements{'new'}{'personnel'}},%people);
%{$elements{'new'}{'personnel'}} = %personnelhash;
- return %elements;
+ return (\%elements,$instcredits);;
}
sub onload_action {
@@ -713,6 +675,9 @@ sub onload_action {
} else {
$loaditems{'onload'} = 'javascript:setFormElements(document.requestcrs);';
}
+ if ($state eq 'courseinfo') {
+ $loaditems{'onload'} .= 'javascript:setCloneDisplay(document.requestcrs);';
+ }
}
return \%loaditems;
}
@@ -720,11 +685,7 @@ sub onload_action {
sub print_main_menu {
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 = 'this.form.submit()';
- }
-
+ my $onchange = 'this.form.submit()';
my $nextstate_setter = "\n";
if (ref($states) eq 'HASH') {
foreach my $key (keys(%{$states})) {
@@ -738,13 +699,11 @@ sub print_main_menu {
}
}
- my $js;
- unless ($dom eq 'gcitest') {
- $js = <<"END";
+ my $js = <<"END";
function nextPage(formname) {
var crschoice = document.mainmenu_coursetype.crstype.value;
- var actionchoice = document.mainmenu_action.reqaction.value;
+ var actionchoice = document.mainmenu_action.action.value;
if (check_can_request(crschoice,actionchoice) == true) {
if ((actionchoice == 'new') && (crschoice == 'official')) {
nextstate = 'codepick';
@@ -752,7 +711,7 @@ function nextPage(formname) {
$nextstate_setter
}
formname.crstype.value = crschoice;
- formname.reqaction.value = actionchoice;
+ formname.action.value = actionchoice;
formname.state.value= nextstate;
formname.submit();
}
@@ -762,22 +721,25 @@ $nextstate_setter
function check_can_request(crschoice,actionchoice) {
var official = '';
var unofficial = '';
- var community = '';
+ var community = '';
+ var textbook = '';
END
- if (ref($can_request) eq 'HASH') {
- 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 in this domain.',
+ textbook => 'You are not permitted to request creation of a textbook course in this domain',
+ all => 'You must choose a specific course type when making a new course request.',
+ allt => '"All types" is not allowed.',
+ );
+ $js .= <{'official'}) || ($can_request->{'unofficial'})) {
+ if (($can_request->{'official'}) || ($can_request->{'unofficial'}) || $can_request->{'textbook'}) {
if ($can_request->{'community'}) {
$pagetitle = 'Course/Community Requests';
$pageinfo = &mt('Request creation of a new course or community, or review your pending requests.');
@@ -829,41 +797,6 @@ END
$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' e-mail addresses must be used as their usernames to ensure uniqueness.").'
');
+ }
+ if (&Apache::loncoursequeueadmin::author_prompt()) {
+ $r->print('
'.&mt('Access to authoring space').'
'.
+ '
'.
+ &mt('Although assessment items can be created directly inside a course, such items only use part of the assessment capabilities of LON-CAPA.').
+ ' '.
+ &mt('By contrast, items created in authoring space, then imported into a course, can use all of the features of the assessment engine.').'
'.&mt('The following management tools are available via the "[_1]Manage Tests[_2]" tab, or from the toolbar on the [_3]Concept Test Contents[_4] page.[_5]',
- '','','','',' ').
- '
'.
- '
'.&mt('Concept Test Contents').'
'.
- '
'.&mt('Display the Table of Contents for your Concept Test.').'
'.
- '
'.&mt('Assemble Concept Test').'
'.
- '
'.&mt('If no students have attempted the Concept Test you will be able to modify it. You can also change the start and end date of the test itself.').'
'.
- '
'.
- '
'.&mt('Enrollment and Student Activity').'
'.
- '
'.&mt('Display or download a course roster, and view information about completion status and last login. You can also add new students, or change access dates for existing students.').'
'.
- '
'.&mt("What's New?").'
'.
- '
'.&mt('View information about changes in your Concept Test course.').'
'.
- '
'.
- '
'.&mt('Prepare Printable Concept Test').'
'.
- '
'.&mt('Create a PDF which you can send to a printer to create a hardcopy of the Concept Test.').'
'.
- '
'.&mt('Concept Test Statistics').'
'.
- '
'.&mt('After the closing date of the Concept Test you can view and download statistics for the test, as well as anonymized submission data.').'
'.
- '
';
-}
-
-sub get_cancreate_status {
- my ($persondom,$personname,$dom) = @_;
+sub get_usertype {
+ my ($persondom,$personname,$curr_rules,$got_rules) = @_;
my ($rules,$ruleorder) =
&Apache::lonnet::inst_userrules($persondom,'username');
my $usertype = &Apache::lonuserutils::check_usertype($persondom,$personname,
- $rules);
- return &Apache::lonuserutils::can_create_user($dom,'requestcrs',$usertype);
+ $rules,$curr_rules,$got_rules);
+ return $usertype;
}
sub check_newuser_rules {
@@ -1623,7 +1605,7 @@ sub check_newuser_rules {
$got_rules) = @_;
my $allowed = 1;
my $newuser = 1;
- my ($checkhash,$userchkmsg);
+ my ($checkhash,$userchkmsg,$authtype,$authparam);
my $checks = { 'username' => 1 };
$checkhash->{$personname.':'.$persondom} = { 'newuser' => $newuser };
&Apache::loncommon::user_rule_check($checkhash,$checks,$alerts,$rulematch,
@@ -1645,22 +1627,38 @@ sub check_newuser_rules {
}
}
}
- return ($allowed,$userchkmsg);
+ if ($allowed) {
+ if (ref($rulematch) eq 'HASH') {
+ if (ref($rulematch->{$personname.':'.$persondom}) eq 'HASH') {
+ my $matchedrule = $rulematch->{$personname.':'.$persondom}{'username'};
+ my ($rules,$ruleorder) =
+ &Apache::lonnet::inst_userrules($persondom,'username');
+ if (ref($rules) eq 'HASH') {
+ if (ref($rules->{$matchedrule}) eq 'HASH') {
+ $authtype = $rules->{$matchedrule}{'authtype'};
+ $authparam = $rules->{$matchedrule}{'authparm'};
+ }
+ }
+ }
+ }
+ }
+ return ($allowed,$userchkmsg,$authtype,$authparam);
}
sub get_excluded_elements {
- my ($dom,$states,$action,$state) = @_;
+ my ($dom,$states,$action,$state,$showcredits) = @_;
my @excluded = ('counter');
- my %elements = &form_elements($dom);
+ my ($elements,$instcredits) = &form_elements($dom,$showcredits);
if (ref($states) eq 'HASH') {
if (ref($states->{$action}) eq 'ARRAY') {
my @items = @{$states->{$action}};
my $numitems = scalar(@items);
if ($numitems) {
for (my $i=$numitems-1; $i>=0; $i--) {
- if (ref($elements{$action}) eq 'HASH') {
- if (ref($elements{$action}{$items[$i]}) eq 'HASH') {
- foreach my $key (keys(%{$elements{$action}{$items[$i]}})) {
+ if ((ref($elements) eq 'HASH') &&
+ (ref($elements->{$action}) eq 'HASH')) {
+ if (ref($elements->{$action}{$items[$i]}) eq 'HASH') {
+ foreach my $key (keys(%{$elements->{$action}{$items[$i]}})) {
push(@excluded,$key);
}
}
@@ -1673,25 +1671,17 @@ sub get_excluded_elements {
if (grep(/^instcode_/,@excluded)) {
push(@excluded,'instcode');
}
- if ($env{'form.initmap'}) {
- push(@excluded,'initmap');
- }
- if ($env{'form.output'}) {
- push(@excluded,'output');
- }
return @excluded;
}
sub print_enrollment_menu {
- my ($formname,$state,$instcode,$dom,$codetitles,$cat_titles,$cat_order,
- $code_order,$invalidcrosslist) =@_;
- my ($sections,$autoenroll,$access_dates,$output,$hasauto);
+ my ($formname,$instcode,$dom,$codetitles,$cat_titles,$cat_order,$code_order,
+ $showcredits,$instcredits,$invalidcrosslist) =@_;
+ my ($sections,$autoenroll,$access_dates,$output,$hasauto,$hascredits,
+ $creditsrow,$domdefcredits);
my $starttime = time;
- my $diff = 6*30*24*60*60; # 6 months from now, approx
- if (&Apache::loncommon::needs_gci_custom()) {
- $diff = 7*24*60*60; # 7 days from now, approx
- }
- my $endtime = $starttime+$diff;
+ my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
+
my %accesstitles = (
'start' => 'Default start access',
'end' => 'Default end access',
@@ -1700,11 +1690,39 @@ sub print_enrollment_menu {
'start' => 'Start auto-enrollment',
'end' => 'End auto-enrollment',
);
+ if ($showcredits) {
+ unless ($env{'form.crstype'} eq 'community') {
+ my %domdefs = &Apache::lonnet::get_domain_defaults($dom);
+ $domdefcredits = $domdefs{$env{'form.crstype'}.'credits'};
+ }
+ }
if ($env{'form.crstype'} eq 'official') {
if (&Apache::lonnet::auto_run('',$dom)) {
$output = &show_invalid_crosslists($invalidcrosslist);
my ($section_form,$crosslist_form);
- $section_form = &inst_section_selector($dom,$instcode);
+ if ($instcode ne '') {
+ $section_form = &inst_section_selector($dom,$instcode);
+ if ($section_form eq '') {
+ my $sectotal = $env{'form.sectotal'};
+ if (!$sectotal) {
+ $sectotal = 1;
+ }
+ if ($env{'form.addsection'}) {
+ $sectotal ++;
+ }
+ for (my $i=0; $i<$sectotal; $i++) {
+ $section_form .= §ions_form($dom,$instcode,$i);
+ }
+ if ($section_form) {
+ $section_form .=
+ &Apache::lonhtmlcommon::row_title(&mt('Add another')).
+ ''.
+ ''.&mt('Add?').&Apache::lonhtmlcommon::row_closure();
+ }
+ }
+ }
if ($section_form) {
$sections = &Apache::lonhtmlcommon::row_headline().
'
';
}
my $container = 'Course';
@@ -2590,9 +2904,9 @@ sub print_review {
}
sub dates_from_form {
- my ($startname,$endname,$timezone) = @_;
- my $startdate = &Apache::lonhtmlcommon::get_date_from_form($startname,$timezone);
- my $enddate = &Apache::lonhtmlcommon::get_date_from_form($endname,$timezone);
+ my ($startname,$endname) = @_;
+ my $startdate = &Apache::lonhtmlcommon::get_date_from_form($startname);
+ my $enddate = &Apache::lonhtmlcommon::get_date_from_form($endname);
if ($endname eq 'accessend') {
if (exists($env{'form.no_end_date'}) ) {
$enddate = 0;
@@ -2602,12 +2916,13 @@ sub dates_from_form {
}
sub courseinfo_form {
- my ($dom,$formname,$state,$crstype,$next,$description) = @_;
+ my ($dom,$formname,$crstype,$next,$description) = @_;
my %lt = &Apache::lonlocal::texthash(
official => 'You must provide a (brief) course description.',
community => 'You must provide a (brief) community description.'
);
$lt{'unofficial'} = $lt{'official'};
+ $lt{'textbook'} = $lt{'official'};
my $js_validate = <<"ENDJS";
-
-ENDJS
- $r->print('
'.$title.'
'.$output.
- '
'.&mt('Course roster file upload').'
');
- $r->print('
'.&mt('If you have a text file available containing student e-mail addresses and initial passwords, you may upload it now.').' '.
- &mt('You may also enroll students later with the [_1]"Enrollment/Activity"[_2] utility in the management toolbar.','','').'
'.
- '');
-}
-
sub notification_information {
- my ($disposition,$req_notifylist,$cnum,$now) = @_;
+ my ($disposition,$req_notifylist,$cnum,$now,$code) = @_;
my %emails = &Apache::loncommon::getemails();
my $address;
if (($emails{'permanentemail'} ne '') || ($emails{'notification'} ne '')) {
@@ -3742,102 +3838,31 @@ sub notification_information {
&mt("Usually this means that your institution's information systems do not list you among the instructional personnel for this course.").' '.
&mt('The list of instructional personnel for the course will be automatically checked daily, and once you are listed the request will be processed.').
'';
+ } elsif (($disposition eq 'created') && ($code)) {
+ my $codemsg = [{
+ mt => 'Students can automatically select your course by entering this code: [_1]',
+ args => [$code],
+ }];
+ $output .= ' '.
+ &mt('Students can automatically select your course by entering this code: [_1].',''.$code.'').
+ ' '.
+ &mt('A message has been sent to your LON-CAPA account with this information').'';
+ if ($address ne '') {
+ $output.= &mt('And an e-mail has also been sent to: [_1] with this code.',$address).' ';
+ }
+ my $sender = $env{'user.name'}.':'.$env{'user.domain'};
+ if ($code) {
+ &Apache::loncoursequeueadmin::send_selfserve_notification($req_notifylist,$codemsg,$cnum,$env{'form.cdescr'},
+ $now,'uniquecode',$sender);
+ }
} else {
$output .= '
'.
- &mt('Your request status is: [_1].',$disposition).
- '
The server encountered an internal error or
misconfiguration and was unable to complete
your request.
Please contact the server administrator at
root@localhost to inform them of the time this error occurred,
and the actions you performed just before this error.
More information about this error may be available
in the server error log.