--- loncom/interface/lonrequestcourse.pm 2013/03/01 04:48:59 1.66
+++ loncom/interface/lonrequestcourse.pm 2014/05/14 18:20:09 1.83
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Request a course
#
-# $Id: lonrequestcourse.pm,v 1.66 2013/03/01 04:48:59 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.83 2014/05/14 18:20:09 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -128,18 +128,79 @@ 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,$showcredits,$instcredits);
+ 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'}) {
+ 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);
+ }
+ } 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,\%can_request);
+ }
+ }
+ return OK;
+ }
+ }
+
$states{'display'} = ['details'];
$states{'view'} = ['pick_request','details','cancel','removal'];
$states{'log'} = ['display'];
@@ -165,7 +226,7 @@ sub handler {
my @invalidcrosslist;
my %trail = (
- crstype => 'Request Action',
+ crstype => 'Pick Action',
codepick => 'Category',
courseinfo => 'Description',
enrollment => 'Access Dates',
@@ -187,46 +248,7 @@ sub handler {
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 $queue = $env{'form.queue'};
- my $reqkey = $cnum.'_'.$queue;
- 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'}))) {
@@ -299,14 +321,11 @@ 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,
@@ -321,7 +340,7 @@ 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,'','','','',$showcredits);
@@ -340,7 +359,7 @@ sub handler {
}
} 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 .= < '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.\\n\"All 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.');
@@ -781,37 +810,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');
- }
- }
- 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);
- }
- }
- }
+ } else {
+ $pagetitle = 'Course/Community Requests';
+ $pageinfo = &mt('You do not have rights to request creation of courses or communities.');
+ $earlyout = 1;
}
}
$r->print(&header($pagetitle,$js.$jscript,$loaditems).$crumb.
- '
'."\n".
&Apache::loncommon::end_page());
return;
@@ -944,6 +970,8 @@ END
$title = &mt('Pending requests for official courses');
} elsif ($env{'form.crstype'} eq 'unofficial') {
$title = &mt('Pending requests for unofficial courses');
+ } elsif ($env{'form.crstype'} eq 'textbook') {
+ $title = &mt('Pending requests for textbook courses');
} else {
$title = &mt('Pending course/community requests');
}
@@ -1078,6 +1106,52 @@ END
return;
}
+sub domcoord_display {
+ my ($dom) = @_;
+ my ($uname,$udom,$result,$warning);
+ if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) {
+ if ($env{'form.cnum'} ne '') {
+ my $cnum = $env{'form.cnum'};
+ my $queue = $env{'form.queue'};
+ my $reqkey = $cnum.'_'.$queue;
+ 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.');
+ }
+ }
+ return ($uname,$udom,$result,$warning);
+}
+
sub enrollment_lcsec_js {
my %alerts = §ion_check_alerts();
my $secname = $alerts{'badsec'};
@@ -1456,6 +1530,15 @@ sub print_request_form {
}
$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 {
@@ -1466,7 +1549,8 @@ sub print_request_form {
&Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
\%cat_order,\@code_order);
}
- my ($storeresult,$result) = &print_request_outcome($dom,\@codetitles,
+ my $lonhost = $r->dir_config('lonHostID');
+ my ($storeresult,$result) = &print_request_outcome($lonhost,$dom,\@codetitles,
\@code_order,$instcredits);
$r->print($result);
if (($storeresult eq 'ok') || ($storeresult eq 'created')) {
@@ -1476,25 +1560,8 @@ sub print_request_form {
''.&mt('Make another request').'');
}
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.').'
');
}
@@ -1506,7 +1573,7 @@ sub print_request_form {
if ($result eq 'created') {
my $role = 'au';
my $spec = "$role./$env{'form.showdom'}/";
- push(@links,&mt('Enter your authoring space with role: [_1]',
+ push(@links,&mt('Enter your Authoring Space with role: [_1]',
''.
&Apache::lonnet::plaintext($role).''));
}
@@ -1579,6 +1646,29 @@ sub print_request_form {
return;
}
+sub print_author_prompt {
+ my ($r,$action,$cnum,$showdom,$crstype,$storeresult) = @_;
+ $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.').'
'.&Apache::loncommon::help_open_topic('Course_Request_Personnel').' '.$lt{$crstype}.' '.&mt('Include other personnel?').'
';
}
@@ -2092,6 +2183,7 @@ sub sorted_request_history {
my $crstype = $history{'crstype'};
my $disposition = $history{'disposition'};
my $status = $history{'status'};
+ my $uniquecode = $history{'code'};
if ($action eq 'view') {
next if ((exists($history{'status'})) && ($history{'status'} eq 'created'));
} else {
@@ -2107,7 +2199,7 @@ sub sorted_request_history {
$entry = $requestkey.':'.$crstype.':'.
&escape($history{'details'}{'cdescr'});
if ($action eq 'log') {
- $entry .= ':'.$lastupdate.':';
+ $entry .= ':'.$uniquecode.':'.$lastupdate.':';
if ($statusinfo{$key} ne '') {
$entry .= $statusinfo{$key};
} elsif ($status ne '') {
@@ -2305,8 +2397,8 @@ ENDJS
}
sub viewcancel_javascript {
- my $alert = &mt('Are you sure you want to cancel this request?\\n'.
- 'Your request will be removed.');
+ my $alert = &mt('Are you sure you want to cancel this request?').'\\n'.
+ &mt('Your request will be removed.');
return << "ENDJS";
function nextPage(formname,nextstate) {
if (confirm('$alert')) {
@@ -2320,7 +2412,7 @@ ENDJS
}
sub print_request_logs {
- my ($r,$dom,$jscript,$loaditems,$crumb) = @_;
+ my ($r,$dom,$jscript,$loaditems,$crumb,$usetabs) = @_;
my $title;
if ($env{'form.crstype'} eq 'community') {
$title = 'Community Request Logs';
@@ -2330,6 +2422,9 @@ sub print_request_logs {
$title = 'Course Request Logs';
}
$r->print(&header($title,$jscript,$loaditems).$crumb);
+ if ($usetabs) {
+ &startContentScreen($r,'textbooklogs');
+ }
my $formname = 'requestcrs';
$r->print(''.
- &Apache::loncommon::end_page());
+ if ($usetabs) {
+ $r->print('');
+ }
+ $r->print('');
+ if ($usetabs) {
+ &endContentScreen($r);
+ }
+ $r->print(&Apache::loncommon::end_page());
return;
}
@@ -2513,7 +2643,7 @@ sub reqstatus_names {
rejected => 'Request rejected',
cancelled => 'Request cancelled',
);
- if (($crstype eq 'official') || ($crstype eq 'unofficial')) {
+ if (($crstype eq 'official') || ($crstype eq 'unofficial') || ($crstype eq 'textbook')) {
$statusnames{'created'} = &mt('Course created');
} elsif ($crstype eq 'community') {
$statusnames{'created'} = &mt('Community created');
@@ -2730,7 +2860,7 @@ sub print_review {
$section_values .= $xlistinfo;
}
$section_values .= '';
- } elsif ($env{'form.crstype'} eq 'unofficial') {
+ } elsif (($env{'form.crstype'} eq 'unofficial') || ($env{'form.crstype'} eq 'textbook')) {
$inst_headers .= '
'.&mt('Credits').'
';
$inst_values .= '
'.$env{'form.coursecredits'}.'
';
}
@@ -2909,6 +3039,7 @@ sub courseinfo_form {
community => 'You must provide a (brief) community description.'
);
$lt{'unofficial'} = $lt{'official'};
+ $lt{'textbook'} = $lt{'official'};
my $js_validate = <<"ENDJS";