--- loncom/interface/lonrequestcourse.pm 2010/03/16 22:40:12 1.47
+++ loncom/interface/lonrequestcourse.pm 2014/01/03 18:39:51 1.73
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Request a course
#
-# $Id: lonrequestcourse.pm,v 1.47 2010/03/16 22:40:12 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.73 2014/01/03 18:39:51 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -128,17 +128,66 @@ sub handler {
}
&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,\%can_request);
+ }
+ } else {
+ if ($can_request{'textbook'}) {
+ &print_textbook_form($r,$dom,\@incdoms,\%domdefs,$domconfig{'requestcourses'},\%can_request);
+ } else {
+ &textbook_request_disabled($r,$dom,\%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 (($action eq 'new') && ($env{'form.crstype'} eq 'official')) {
@@ -147,6 +196,12 @@ sub handler {
}
}
+ 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');
@@ -155,30 +210,33 @@ sub handler {
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',
+ display => 'Request Logs',
);
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))) {
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 =
@@ -260,11 +318,11 @@ sub handler {
}
}
}
- 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 '')) {
@@ -286,19 +344,16 @@ sub handler {
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);
+ $showcredits,$instcredits,\@invalidcrosslist);
}
} else {
$r->print(&header('Course/Community Requests').$crumb.
@@ -308,26 +363,44 @@ sub handler {
}
} 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 .= < '/adm/requestcourse',
text => "$trail->{$states->{$action}[$i]}",
@@ -469,7 +542,8 @@ sub header {
}
sub form_elements {
- my ($dom) = @_;
+ my ($dom,$showcredits) = @_;
+ my $instcredits;
my %elements =
(
new => {
@@ -537,7 +611,6 @@ sub form_elements {
}
if (&Apache::lonnet::auto_run('',$dom)) {
my %extras = (
- sectotal => 'hidden',
enrollstart_month => 'selectbox',
enrollstart_hour => 'selectbox',
enrollend_month => 'selectbox',
@@ -553,12 +626,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'};
@@ -568,7 +668,6 @@ sub form_elements {
if (!$crosslisttotal) {
$crosslisttotal = 1;
}
-
for (my $i=0; $i<$env{'form.crosslisttotal'}; $i++) {
if ($numtitles) {
$extras{'crosslist_'.$i.'_'.$lastitem} = 'text';
@@ -606,7 +705,7 @@ sub form_elements {
}
my %personnelhash = (%{$elements{'new'}{'personnel'}},%people);
%{$elements{'new'}{'personnel'}} = %personnelhash;
- return %elements;
+ return (\%elements,$instcredits);;
}
sub onload_action {
@@ -626,13 +725,9 @@ sub onload_action {
}
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})) {
@@ -668,7 +763,8 @@ $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})) {
@@ -680,8 +776,10 @@ END
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.',
+ 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.');
@@ -734,31 +839,19 @@ END
$domaintitle = &mt('Course/Community Domain');
}
}
- my @incdoms;
- if (ref($request_domains) eq 'HASH') {
- 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);
- }
- }
- }
- }
- }
$r->print(&header($pagetitle,$js.$jscript,$loaditems).$crumb.
'
'.
+ &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.').'