--- loncom/interface/lonrequestcourse.pm 2012/08/14 15:45:06 1.64
+++ 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.64 2012/08/14 15:45:06 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.73 2014/01/03 18:39:51 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -128,13 +128,62 @@ sub handler {
}
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['action','showdom','cnum','state','crstype','queue']);
+ ['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'];
@@ -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,13 +210,14 @@ 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',
@@ -173,7 +229,7 @@ sub handler {
$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))) {
@@ -262,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 '')) {
@@ -288,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.
@@ -310,10 +363,10 @@ 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 '') {
@@ -324,11 +377,12 @@ sub handler {
&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') {
if ($state eq 'crstype') {
- &print_main_menu($r,\%can_request,\%states,$dom,$jscript,'',$crumb,\%request_domains);
+ &print_main_menu($r,\%can_request,\%states,$dom,$jscript,'',$crumb,\@incdoms);
} else {
$jscript .= < '.$pageinfo.' ');
if ($storeresult eq 'ok') {
- $r->print(''.
- &mt('Modify this request').''.(' 'x4));
+ $r->print(' '.
+ &mt('Modify this request').''.(' 'x4).
+ ''.&mt('Make another request').' '.&mt('Make another request').''.$title.'
'.$title.'
'.$header.'
'.
&print_review($dom,\@codetitles,\%cat_titles,\%cat_order,
- \@code_order,$uname,$udom)."\n".''.
+ \@code_order,$uname,$udom,'','',$instcredits)."\n".
+ ''.
&close_popup_form());
}
$r->print(&Apache::loncommon::end_page());
@@ -1239,7 +1307,7 @@ sub get_instcode {
sub print_request_form {
my ($r,$action,$state,$page,$states,$dom,$newinstcode,$codechk,$checkedcode,
- $description,$invalidcrosslist) = @_;
+ $description,$showcredits,$instcredits,$invalidcrosslist) = @_;
my $formname = 'requestcrs';
my ($next,$prev,$message,$output,$codepicker,$crstype);
$prev = $states->{$action}[$page-1];
@@ -1312,7 +1380,7 @@ sub print_request_form {
}
$r->print(&print_enrollment_menu($formname,$instcode,$dom,\@codetitles,
\%cat_titles,\%cat_order,\@code_order,
- $invalidcrosslist));
+ $showcredits,$instcredits,$invalidcrosslist));
} elsif ($state eq 'personnel') {
$r->print(&print_personnel_menu($dom,$formname,$crstype,$invalidcrosslist));
} elsif ($state eq 'review') {
@@ -1428,8 +1496,17 @@ sub print_request_form {
} else {
$r->print(''.&mt('Review course request details before submission').'
');
}
- $r->print(&print_review($dom,\@codetitles,\%cat_titles,\%cat_order,\@code_order,'','',\@disallowed,\%disallowmsg).
+ $r->print(&print_review($dom,\@codetitles,\%cat_titles,\%cat_order,\@code_order,'','',\@disallowed,\%disallowmsg,$instcredits).
'');
+ my $fullname = &Apache::loncommon::plainname($env{'user.name'},
+ $env{'user.domain'});
+ my $postprocess = &Apache::lonnet::auto_crsreq_update($dom,$cnum,$crstype,'review',$env{'user.name'},
+ $env{'user.domain'},$fullname,$env{'form.cdescr'});
+ if (ref($postprocess) eq 'HASH') {
+ if ($postprocess->{'reviewweb'}) {
+ $r->print($postprocess->{'reviewweb'});
+ }
+ }
if ($crstype eq 'community') {
$navtxt{'next'} = &mt('Submit community request');
} else {
@@ -1441,19 +1518,60 @@ sub print_request_form {
\%cat_order,\@code_order);
}
my ($storeresult,$result) = &print_request_outcome($dom,\@codetitles,
- \@code_order);
+ \@code_order,$instcredits);
$r->print($result);
if (($storeresult eq 'ok') || ($storeresult eq 'created')) {
- $r->print('
'.$links[0].'
'); } } - my @excluded = &get_excluded_elements($dom,$states,$action,$state); + my @excluded = &get_excluded_elements($dom,$states,$action,$state,$showcredits); if ($state eq 'personnel') { push(@excluded,'persontotal'); } @@ -1480,18 +1598,44 @@ sub print_request_form { $count ++; } $env{'form.persontotal'} = $count; - } } if ($state eq 'enrollment') { push(@excluded,('sectotal','crosslisttotal')); } - $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).''); - &display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},$next, - $navtxt{'next'},$state); + if (($state eq 'process') || ($state eq 'reqauthor')) { + $r->print(''); + } else { + $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).''); + &display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},$next, + $navtxt{'next'},$state); + } return; } +sub print_author_prompt { + my ($r,$action,$cnum,$showdom,$crstype,$storeresult) = @_; + $r->print(''.
+ &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('Request authoring space access now?'). + ' '. + ''. + (' 'x2). + ''. + '
'. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + '