--- loncom/interface/lonrequestcourse.pm 2010/11/08 21:44:55 1.41.2.8
+++ loncom/interface/lonrequestcourse.pm 2014/06/16 01:42:22 1.85
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Request a course
#
-# $Id: lonrequestcourse.pm,v 1.41.2.8 2010/11/08 21:44:55 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.85 2014/06/16 01:42:22 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,98 @@ 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','tabs']);
+ &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,%can_request,
+ %request_domains,@incdoms);
+ my %domdefs = &Apache::lonnet::get_domain_defaults($dom);
+ if ($domdefs{'officialcredits'} || $domdefs{'unofficialcredits'} || $domdefs{'textbookcredits'}) {
+ $showcredits = 1;
+ }
+
+ my $canreq =
+ &Apache::lonnet::check_can_request($dom,\%can_request,\%request_domains);
+
+ foreach my $item (keys(%request_domains)) {
+ if (ref($request_domains{$item}) eq 'ARRAY') {
+ foreach my $possdom (@{$request_domains{$item}}) {
+ unless(grep(/^\Q$possdom\E$/,@incdoms)) {
+ push(@incdoms,$possdom);
+ }
+ }
+ }
+ }
+
+ if ($canreq) {
+ if (($env{'form.crstype'} eq 'textbook') ||
+ (scalar(keys(%can_request)) == 1) && ($can_request{'textbook'})) {
+ my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$dom);
+ if ($action eq 'log') {
+ my $usetabs;
+ if ((scalar(keys(%can_request)) == 1) && ($can_request{'textbook'})) {
+ $usetabs = 1;
+ } elsif ($env{'form.tabs'} eq 'on') {
+ $usetabs = 1;
+ }
+ &Apache::lonhtmlcommon::add_breadcrumb({text=>'Course Request'});
+ my $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests');
+ &print_request_logs($r,$dom,undef,undef,$crumb,$usetabs);
+ } elsif ($action eq 'process') {
+ if ($can_request{'textbook'}) {
+ &process_textbook_request($r,$dom,$action,\%domdefs,\%domconfig,\%can_request);
+ } else {
+ &textbook_request_disabled($r,$dom,$action,\%can_request);
+ }
+ } elsif ($action eq 'display') {
+ my ($uname,$udom,$result,$warning) = &domcoord_display($dom);
+ if ($warning ne '') {
+ my $args = { only_body => 1 };
+ $r->print(&header('Course/Community Requests','','' ,'',$args).
+ '
'.&mt('Course/Community Request Details').'
'.
+ '
'.$warning.'
'.
+ &close_popup_form());
+ } else {
+ $states{'display'} = ['details'];
+ my $loaditems = &onload_action($action,$state);
+ my $page = 0;
+ &request_administration($r,$action,$state,$page,\%states,$dom,$jscript,
+ $loaditems,'','','','','',$showcredits,'','',
+ $uname,$udom);
+ }
+ } else {
+ if ($can_request{'textbook'}) {
+ &print_textbook_form($r,$dom,\@incdoms,\%domdefs,$domconfig{'requestcourses'},\%can_request);
+ } else {
+ &textbook_request_disabled($r,$dom,$action,\%can_request);
+ }
+ }
+ return OK;
+ }
+ }
$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');
@@ -176,74 +226,29 @@ sub generate_page {
my @invalidcrosslist;
my %trail = (
- crstype => 'Request Action',
+ crstype => 'Pick Action',
codepick => 'Category',
courseinfo => 'Description',
enrollment => 'Access Dates',
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 $namespace = 'courserequestqueue';
- my $domconfig = &Apache::lonnet::get_domainconfiguser($dom);
- my %queued =
- &Apache::lonnet::get($namespace,[$reqkey],$dom,$domconfig);
- if (ref($queued{$reqkey}) eq 'HASH') {
- $uname = $queued{$reqkey}{'ownername'};
- $udom = $queued{$reqkey}{'ownerdom'};
- if (($udom =~ /^$match_domain$/) && ($uname =~ /^$match_username$/)) {
- $result = &retrieve_settings($dom,$cnum,$udom,$uname);
- } else {
- 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 {
- 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 {
- 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.');
- }
- }
+ ($uname,$udom,$result,$warning) = &domcoord_display($dom);
} elsif ((defined($state)) && (defined($action))) {
if (($action eq 'view') && ($state eq 'details')) {
if ((defined($env{'form.showdom'})) && (defined($env{'form.cnum'}))) {
@@ -290,22 +295,24 @@ 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') {
$jscript .= &cloning_javascript();
+ } elsif ($state eq 'process') {
+ $jscript .= &processing_javascript();
}
}
}
@@ -314,25 +321,18 @@ 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 =
- &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,\%request_domains);
+ $crumb,\@incdoms);
} else {
&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.
@@ -342,32 +342,49 @@ sub generate_page {
}
} elsif ($action eq 'view') {
if ($state eq 'crstype') {
- &print_main_menu($r,\%can_request,\%states,$dom,$jscript,$loaditems,$crumb,\%request_domains);
+ &print_main_menu($r,\%can_request,\%states,$dom,$jscript,$loaditems,$crumb,\@incdoms);
} 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,\@incdoms);
+ } 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);
- last;
- } else {
- if (($$state eq 'process') || ($$state eq 'removal')) {
+ if (ref($states->{$action}) eq 'ARRAY') {
+ for (my $i=0; $i<@{$states->{$action}}; $i++) {
+ if ($$state eq $states->{$action}[$i]) {
&Apache::lonhtmlcommon::add_breadcrumb(
- { href => '/adm/requestcourse',
- text => "$trail->{$states->{$action}[$i]}",
- }
- );
+ {text=>"$trail->{$$state}"});
+ $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course/Community Requests','Course_Requests');
+ last;
} 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]}", }
- );
- }
+ if (($$state eq 'process') || ($$state eq 'removal') || ($$state eq 'reqauthor')) {
+ &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]')",
@@ -513,13 +501,13 @@ sub get_breadcrumbs {
}
} 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 +523,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 +546,7 @@ sub form_elements {
},
courseinfo => {
cdescr => 'text',
- cloning => 'radio',
+ cloning => 'radio',
clonecrs => 'text',
clonedom => 'selectbox',
datemode => 'radio',
@@ -595,27 +582,12 @@ 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);
@@ -631,7 +603,6 @@ sub form_elements {
}
if (&Apache::lonnet::auto_run('',$dom)) {
my %extras = (
- sectotal => 'hidden',
enrollstart_month => 'selectbox',
enrollstart_hour => 'selectbox',
enrollend_month => 'selectbox',
@@ -647,12 +618,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'};
@@ -662,7 +660,6 @@ sub form_elements {
if (!$crosslisttotal) {
$crosslisttotal = 1;
}
-
for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
if ($numtitles) {
$extras{'crosslist_'.$i.'_'.$lastitem} = 'text';
@@ -700,7 +697,7 @@ sub form_elements {
}
my %personnelhash = (%{$elements{'new'}{'personnel'}},%people);
%{$elements{'new'}{'personnel'}} = %personnelhash;
- return %elements;
+ return (\%elements,$instcredits);;
}
sub onload_action {
@@ -712,18 +709,20 @@ sub onload_action {
} else {
$loaditems{'onload'} = 'javascript:setFormElements(document.requestcrs);';
}
+ if ($state eq 'courseinfo') {
+ $loaditems{'onload'} .= 'javascript:setCloneDisplay(document.requestcrs);';
+ }
+ if ($state eq 'process') {
+ $loaditems{'onload'} .= 'javascript:hideProcessing();';
+ }
}
return \%loaditems;
}
sub print_main_menu {
- my ($r,$can_request,$states,$dom,$jscript,$loaditems,$crumb,$request_domains) = @_;
+ my ($r,$can_request,$states,$dom,$jscript,$loaditems,$crumb,$incdoms) = @_;
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})) {
@@ -737,13 +736,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';
@@ -751,7 +748,7 @@ function nextPage(formname) {
$nextstate_setter
}
formname.crstype.value = crschoice;
- formname.reqaction.value = actionchoice;
+ formname.action.value = actionchoice;
formname.state.value= nextstate;
formname.submit();
}
@@ -761,22 +758,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.');
@@ -822,72 +828,34 @@ END
$pagetitle = 'Community Requests';
$pageinfo = &mt('Request creation of a new course, or review your pending requests.');
$domaintitle = &mt('Community Domain');
- } else {
+ } elsif ((ref($incdoms) eq 'ARRAY') && ((@{$incdoms} > 1) ||
+ ((@{$incdoms} == 1) && ($incdoms->[0] ne $dom)))) {
$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');
+ } else {
+ $pagetitle = 'Course/Community Requests';
+ $pageinfo = &mt('You do not have rights to request creation of courses or communities.');
+ $earlyout = 1;
}
}
-
- 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.").'
'.&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.').'
'.
+ &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.').'
';
@@ -2575,12 +3051,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,$dom,$cnum,$now,$code,$postprocess) = @_;
my %emails = &Apache::loncommon::getemails();
my $address;
if (($emails{'permanentemail'} ne '') || ($emails{'notification'} ne '')) {
@@ -3697,110 +4079,146 @@ sub notification_information {
}
if ($req_notifylist) {
my $fullname = &Apache::loncommon::plainname($env{'user.name'},
- $env{'user.domain'});
+ $env{'user.domain'});
my $sender = $env{'user.name'}.':'.$env{'user.domain'};
- &Apache::loncoursequeueadmin::send_selfserve_notification($req_notifylist,"$fullname ($env{'user.name'}:$env{'user.domain'})",$cnum,$env{'form.cdescr'},$now,'coursereq',$sender);
+ &Apache::loncoursequeueadmin::send_selfserve_notification($req_notifylist,"$fullname ($env{'user.name'}:$env{'user.domain'})",
+ 'undef',$env{'form.cdescr'},$now,'coursereq',$sender);
+ }
+ if (ref($postprocess) eq 'HASH') {
+ if (ref($postprocess->{'queuedmsg'}) eq 'ARRAY') {
+ if (scalar(@{$postprocess->{'queuedmsg'}}) > 0) {
+ my $recipient = $env{'user.name'}.':'.$env{'user.domain'};
+ my $sender = $recipient;
+ my $addmsg = [];
+ foreach my $item (@{$postprocess->{'queuedmsg'}}) {
+ if (ref($item) eq 'HASH') {
+ if ($item->{'mt'} ne '') {
+ push(@{$addmsg},$item);
+ }
+ }
+ }
+ if (scalar(@{$addmsg}) > 0) {
+ &Apache::loncoursequeueadmin::send_selfserve_notification($recipient,$addmsg,undef,
+ $env{'form.cdescr'},$now,
+ 'queuedcrsreq',$sender);
+ }
+ }
+ }
+ if ($postprocess->{'queuedweb'}) {
+ $output .= $postprocess->{'queuedweb'};
+ }
}
} elsif ($disposition eq 'pending') {
- $output .= '
'.
+ my $pending_default = '
'.
&mt('Your request has been placed in a queue pending administrative action.').' '.
&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.').
- '
';
+ '
';
+ if (ref($postprocess) eq 'HASH') {
+ if ($postprocess->{'pendingweb'}) {
+ $output .= $postprocess->{'pendingweb'};
+ } else {
+ $output .= $pending_default;
+ }
+ } else {
+ $output .= $pending_default;
+ }
+ } elsif ($disposition eq 'created') {
+ if (($code) || ((ref($postprocess) eq 'HASH') &&
+ ((ref($postprocess->{'createdmsg'}) eq 'ARRAY') || ($postprocess->{'createdweb'})))) {
+ my $addmsg = [];
+ my $recipient = $env{'user.name'}.':'.$env{'user.domain'};
+ my $sender = $recipient;
+ if ($code) {
+ push(@{$addmsg},{
+ mt => 'Students can automatically select your course: "[_1]" by entering this code: [_2]',
+ args => [$env{'form.cdescr'},$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('An e-mail has also been sent to: [_1] with this code.',$address);
+ }
+ $output .= '
';
+ }
+ if (ref($postprocess) eq 'HASH') {
+ if (ref($postprocess->{'createdmsg'}) eq 'ARRAY') {
+ foreach my $item (@{$postprocess->{'createdmsg'}}) {
+ if (ref($item) eq 'HASH') {
+ if ($item->{'mt'} ne '') {
+ push(@{$addmsg},$item);
+ }
+ }
+ }
+ }
+ if ($postprocess->{'createdweb'}) {
+ $output .= $postprocess->{'createdweb'}
+ }
+ }
+ if (scalar(@{$addmsg}) > 0) {
+ my $type = 'createdcrsreq';
+ if ($code) {
+ $type = 'uniquecode';
+ }
+ &Apache::loncoursequeueadmin::send_selfserve_notification($recipient,$addmsg,$dom.'_'.$cnum,$env{'form.cdescr'},
+ $now,$type,$sender);
+ }
+ }
} else {
$output .= '
'.
- &mt('Your request status is: [_1].',$disposition).
- '
'
+ &mt('Your request status is: [_1].',$disposition).
+ '';
}
return $output;
}
-sub get_processtype {
- my ($dom,$crstype,$inststatuses,$domconfig) = @_;
- return unless ((ref($inststatuses) eq 'ARRAY') && (ref($domconfig) eq 'HASH'));
- my (%userenv,%settings,$val);
- my @options = ('autolimit','validate','approval');
- if ($dom eq $env{'user.domain'}) {
- %userenv =
- &Apache::lonnet::userenvironment($env{'user.domain'},$env{'user.name'},
- 'requestcourses.'.$crstype,'inststatus');
- if ($userenv{'requestcourses.'.$crstype}) {
- $val = $userenv{'requestcourses.'.$crstype};
- @{$inststatuses} = ('_custom_');
- } else {
- my ($task,%alltasks);
- if (ref($domconfig->{'requestcourses'}) eq 'HASH') {
- %settings = %{$domconfig->{'requestcourses'}};
- if (ref($settings{$crstype}) eq 'HASH') {
- if (($env{'user.adv'}) && ($settings{$crstype}{'_LC_adv'} ne '')) {
- $val = $settings{$crstype}{'_LC_adv'};
- @{$inststatuses} = ('_LC_adv_');
- } else {
- if ($userenv{'inststatus'} ne '') {
- @{$inststatuses} = split(',',$userenv{'inststatus'});
- } else {
- @{$inststatuses} = ('default');
- }
- foreach my $status (@{$inststatuses}) {
- if (exists($settings{$crstype}{$status})) {
- my $value = $settings{$crstype}{$status};
- next unless ($value);
- unless (exists($alltasks{$value})) {
- if (ref($alltasks{$value}) eq 'ARRAY') {
- unless(grep(/^\Q$status\E$/,@{$alltasks{$value}})) {
- push(@{$alltasks{$value}},$status);
- }
- } else {
- @{$alltasks{$value}} = ($status);
- }
- }
- }
- }
- my $maxlimit = 0;
-
- foreach my $key (sort(keys(%alltasks))) {
- if ($key =~ /^autolimit=(\d*)$/) {
- if ($1 eq '') {
- $val ='autolimit=';
- last;
- } elsif ($1 > $maxlimit) {
- $maxlimit = $1;
- }
- }
- }
- if ($maxlimit) {
- $val = 'autolimit='.$maxlimit;
- } else {
- foreach my $option (@options) {
- if ($alltasks{$option}) {
- $val = $option;
- last;
- }
- }
- }
+sub pending_validation_form {
+ my ($cdom,$cnum,$crstype,$now,$token,$lonhost,$cdesc) = @_;
+ my $output;
+ my %postvalues = (
+ 'owner' => $env{'user.name'}.':'.$env{'user.domain'},
+ 'course' => $cdom.'_'.$cnum,
+ 'coursetype' => $crstype,
+ );
+ my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$cdom);
+
+ if (ref($domconfig{'requestcourses'}) eq 'HASH') {
+ my ($url,$buttontext,$code,@fields);
+ if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') {
+ $postvalues{'description'} = $cdesc;
+ $url = $domconfig{'requestcourses'}{'validation'}{'url'};
+ if (ref($domconfig{'requestcourses'}{'validation'}{'fields'}) eq 'ARRAY') {
+ @fields = @{$domconfig{'requestcourses'}{'validation'}{'fields'}};
+ }
+ $buttontext = $domconfig{'requestcourses'}{'validation'}{'button'};
+ $output .= $domconfig{'requestcourses'}{'validation'}{'markup'};
+ if (($url =~ m{^(https?\://|/)}) && (@fields > 0)) {
+ $output .= ''."\n";
}
- @{$inststatuses} = ('_external_');
}
}
- return $val;
+ return $output;
}
sub check_autolimit {
@@ -3817,7 +4235,7 @@ sub check_autolimit {
if (($crstype eq 'community') &&
(exists($crsroles{$cnum.':'.$cdom.':co'}))) {
$count ++;
- } elsif ((($crstype eq 'official') || ($crstype eq 'unofficial')) &&
+ } elsif ((($crstype eq 'official') || ($crstype eq 'unofficial') || ($crstype eq 'textbook')) &&
(exists($crsroles{$cnum.':'.$cdom.':cc'}))) {
$count ++;
}
@@ -3863,18 +4281,31 @@ sub retrieve_settings {
}
$env{'form.clonecrs'} = $reqinfo{'clonecrs'};
$env{'form.clonedom'} = $reqinfo{'clonedom'};
+ if (($reqinfo{'clonecrs'} ne '') && ($reqinfo{'clonedom'} ne '')) {
+ $env{'form.cloning'} = 1;
+ }
$env{'form.datemode'} = $reqinfo{'datemode'};
$env{'form.dateshift'} = $reqinfo{'dateshift'};
- if (($reqinfo{'crstype'} eq 'official') && ($reqinfo{'instcode'} ne '')) {
- $env{'form.sectotal'} = $reqinfo{'sectotal'};
- $env{'form.crosslisttotal'} = $reqinfo{'crosslisttotal'};
- $env{'form.autoadds'} = $reqinfo{'autoadds'};
- $env{'form.autdrops'} = $reqinfo{'autodrops'};
- $env{'form.instcode'} = $reqinfo{'instcode'};
- my $crscode = {
- $cnum => $reqinfo{'instcode'},
- };
- &extract_instcode($dom,'instcode',$crscode,$cnum);
+ if ($reqinfo{'crstype'} eq 'official') {
+ $env{'form.autoadds'} = $reqinfo{'autoadds'};
+ $env{'form.autodrops'} = $reqinfo{'autodrops'};
+ if ($reqinfo{'instcode'} ne '') {
+ $env{'form.sectotal'} = $reqinfo{'sectotal'};
+ $env{'form.crosslisttotal'} = $reqinfo{'crosslisttotal'};
+ $env{'form.instcode'} = $reqinfo{'instcode'};
+ my $crscode = {
+ $cnum => $reqinfo{'instcode'},
+ };
+ &extract_instcode($dom,'instcode',$crscode,$cnum);
+ (undef,undef,my $instcredits) =
+ &Apache::lonnet::auto_validate_instcode(undef,$dom,
+ $reqinfo{'instcode'});
+ if ($instcredits ne $reqinfo{'defaultcredits'}) {
+ $env{'form.coursecredits'} = $reqinfo{'defaultcredits'};
+ }
+ }
+ } elsif (($reqinfo{'crstype'} eq 'unofficial') || ($reqinfo{'crstype'} eq 'textbook')) {
+ $env{'form.coursecredits'} = $reqinfo{'defaultcredits'};
}
my @currsec;
if (ref($reqinfo{'sections'}) eq 'HASH') {
@@ -4005,16 +4436,626 @@ sub generate_date_items {
return;
}
-sub show_cloneable {
- my $showclone;
- if (&Apache::loncommon::needs_gci_custom()) {
- my %courses = &Apache::loncommon::existing_gcitest_courses('cc');
- my $numcourses = scalar(keys(%courses));
- return $numcourses;
+sub print_textbook_form {
+ my ($r,$dom,$incdoms,$domdefs,$settings,$can_request) = @_;
+ my (%prefab,%ordered,%numprefab);
+ my $crstype = 'textbook';
+#
+# Retrieve list of prefabricated courses (textbook courses and templates) cloneable by user
+#
+ foreach my $type ('textbooks','templates') {
+ $numprefab{$type} = 0;
+ if (ref($settings) eq 'HASH') {
+ $prefab{$type} = $settings->{$type};
+ if (ref($prefab{$type}) eq 'HASH') {
+ foreach my $item (keys(%{$prefab{$type}})) {
+ my ($clonedom,$clonecrs) = split(/_/,$item);
+ if (ref($prefab{$type}{$item}) eq 'HASH') {
+ if (&Apache::loncoursequeueadmin::can_clone_course($env{'user.name'},
+ $env{'user.domain'},$clonecrs,$clonedom,$crstype)) {
+
+ my $num = $prefab{$type}{$item}{'order'};
+ $ordered{$type}{$num} = $item;
+ $numprefab{$type} ++;
+ }
+ }
+ }
+ }
+ }
+ }
+
+#
+# Check if domain has multiple library servers
+#
+ my ($home_server_pick,$numlib) =
+ &Apache::loncommon::home_server_form_item($dom,'chome',
+ 'default','hide');
+ if ($numlib > 1) {
+ $home_server_pick = &mt('Home Server for Course').': '.$home_server_pick.' ';
+ }
+
+#
+# Retrieve information about courses owned by user, or in which user has an active or future
+# Course Coordinator role
+#
+ my $numcurrent;
+ my %cloneable = &Apache::lonnet::courseiddump($dom,'.',1,'.',$env{'user.name'}.':'.$env{'user.domain'},
+ undef,undef,undef,'Course');
+ my %ccroles = &Apache::lonnet::get_my_roles($env{'user.name'},$env{'user.domain'},'userroles',
+ ['active','future'],['cc']);
+ foreach my $role (keys(%ccroles)) {
+ my ($cnum,$cdom,$rest) = split(/:/,$role,3);
+ unless (exists($cloneable{$cdom.'_'.$cnum})) {
+ my %courseinfo = &Apache::lonnet::coursedescription($cdom.'_'.$cnum,{'one_time' => 1});
+ $cloneable{$cdom.'_'.$cnum} = \%courseinfo;
+ }
+ }
+
+ my $numcurrent = scalar(keys(%cloneable));
+
+ my $jscript = &textbook_request_javascript(\%numprefab,$numcurrent);
+ my %loaditems;
+ $loaditems{'onload'} = 'javascript:uncheckAllRadio();';
+ $r->print(&header('Course Request',$jscript,\%loaditems));
+
+ if (ref($can_request) eq 'HASH') {
+ unless ((scalar(keys(%{$can_request})) == 1) && ($can_request->{'textbook'})) {
+ &Apache::lonhtmlcommon::add_breadcrumb(
+ { href => '/adm/requestcourse',
+ text => 'Pick action',
+ });
+ }
+ }
+ &Apache::lonhtmlcommon::add_breadcrumb({text=>'Course Request'});
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests'));
+
+ &startContentScreen($r,'textbookrequests');
+#
+# Show domain selector form, if required.
+#
+ if (@{$incdoms} > 1) {
+ my $onchange = 'this.form.submit()';
+ $r->print('