--- loncom/interface/lonrequestcourse.pm 2012/08/14 15:45:06 1.64
+++ loncom/interface/lonrequestcourse.pm 2020/02/12 22:16:25 1.95.2.5
@@ -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.95.2.5 2020/02/12 22:16:25 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -119,6 +119,10 @@ use Apache::loncoursequeueadmin;
use Apache::lonuserutils;
use LONCAPA qw(:DEFAULT :match);
+my $registered_flush;
+my $registered_instcats;
+my $modified_dom;
+
sub handler {
my ($r) = @_;
&Apache::loncommon::content_type($r,'text/html');
@@ -127,14 +131,83 @@ sub handler {
return OK;
}
+ $registered_flush = 0;
+ $registered_instcats = 0;
+ $modified_dom = '';
+
&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,$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'];
@@ -147,6 +220,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 +234,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,49 +253,10 @@ 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))) {
- 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'}))) {
@@ -262,11 +303,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 '')) {
@@ -278,6 +319,8 @@ sub handler {
$jscript = &Apache::lonhtmlcommon::set_form_elements($elementsref,\%stored);
if ($state eq 'courseinfo') {
$jscript .= &cloning_javascript();
+ } elsif ($state eq 'process') {
+ $jscript .= &processing_javascript();
}
}
}
@@ -288,19 +331,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 +350,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 +364,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 .= <{$action}}; $i++) {
- if ($$state eq $states->{$action}[$i]) {
- &Apache::lonhtmlcommon::add_breadcrumb(
- {text=>"$trail->{$$state}"});
- $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course/Community Requests','Course_Requests');
- 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 {
- &Apache::lonhtmlcommon::add_breadcrumb(
+ 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]')",
text => "$trail->{$states->{$action}[$i]}", }
- );
- }
- }
- }
+ );
+ }
+ }
+ }
+ }
} else {
&Apache::lonhtmlcommon::add_breadcrumb(
{text=>'Pick Action'});
@@ -488,7 +542,8 @@ sub header {
}
sub form_elements {
- my ($dom) = @_;
+ my ($dom,$showcredits) = @_;
+ my $instcredits;
my %elements =
(
new => {
@@ -596,6 +651,15 @@ sub form_elements {
$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'};
if ($env{'form.addcrosslist'}) {
@@ -641,7 +705,7 @@ sub form_elements {
}
my %personnelhash = (%{$elements{'new'}{'personnel'}},%people);
%{$elements{'new'}{'personnel'}} = %personnelhash;
- return %elements;
+ return (\%elements,$instcredits);;
}
sub onload_action {
@@ -656,12 +720,15 @@ sub onload_action {
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 = 'this.form.submit()';
my $nextstate_setter = "\n";
@@ -699,7 +766,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})) {
@@ -708,44 +776,54 @@ END
";
}
}
- my %lt = &Apache::lonlocal::texthash(
+ my %js_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.\\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_escape(\%js_lt);
$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.');
@@ -759,37 +837,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.
- ''.$pageinfo.'
'.
- ''.
+ '
'.$pageinfo.'
');
+ if ($earlyout) {
+ $r->print(&Apache::loncommon::end_page());
+ return;
+ }
+ $r->print('
'.
&Apache::lonhtmlcommon::start_pick_box().
&Apache::lonhtmlcommon::row_title($domaintitle).
''.&Apache::lonhtmlcommon::row_closure(1)."\n".
&Apache::lonhtmlcommon::end_pick_box().'
'."\n".
&Apache::loncommon::end_page());
return;
@@ -847,8 +922,8 @@ END
sub request_administration {
my ($r,$action,$state,$page,$states,$dom,$jscript,$loaditems,$crumb,
- $newinstcode,$codechk,$checkedcode,$description,$invalidcrosslist,
- $uname,$udom) = @_;
+ $newinstcode,$codechk,$checkedcode,$description,$showcredits,
+ $instcredits,$invalidcrosslist,$uname,$udom) = @_;
my $js;
if (($action eq 'new') || (($action eq 'view') && ($state eq 'pick_request'))) {
$js = <
print(&header($title,$js.$jscript,$loaditems,$jsextra).$crumb);
&print_request_form($r,$action,$state,$page,$states,$dom,$newinstcode,
- $codechk,$checkedcode,$description,$invalidcrosslist);
+ $codechk,$checkedcode,$description,$showcredits,
+ $instcredits,$invalidcrosslist);
} elsif ($action eq 'view') {
my $jsextra;
my $formname = 'requestcrs';
@@ -921,6 +998,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');
}
@@ -944,9 +1023,10 @@ END
}
$r->print(''.$title.' '."\n".$form."\n".
&print_review($dom,\@codetitles,\%cat_titles,\%cat_order,
- \@code_order)."\n".
+ \@code_order,'','','','',$instcredits)."\n".
' '."\n");
- my @excluded = &get_excluded_elements($dom,$states,'new','review');
+ my @excluded = &get_excluded_elements($dom,$states,'new','review',
+ $showcredits);
push(@excluded,'origcnum');
$r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'
');
my $other = 'modify';
@@ -968,7 +1048,8 @@ END
my ($result,$output) = &print_cancel_request($dom,$env{'form.origcnum'});
$r->print(''.$title.' '."\n".$form."\n".
$output);
- my @excluded = &get_excluded_elements($dom,$states,'view','cancel');
+ my @excluded = &get_excluded_elements($dom,$states,'view','cancel',
+ $showcredits);
$r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'
');
my %navtxt = &Apache::lonlocal::texthash (
prev => 'Back',
@@ -1045,17 +1126,66 @@ END
$r->print(&header($title,'','','',{ 'only_body' => 1}).
$crumb."\n".''.$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());
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'};
my $secnone = $alerts{'reserved'};
+ &js_escape(\$secname);
+ &js_escape(\$secnone);
my $output = '
function validateEnrollSections(formname,nextstate) {
var badsectotal = 0;
@@ -1113,8 +1243,10 @@ function validateEnrollSections(formname
sub personnel_lcsec_js {
my %alerts = §ion_check_alerts();
- my $secname = $alerts{'badsec'}.'\\n'.$alerts{'separate'};
+ my $secname = $alerts{'badsec'}."\n".$alerts{'separate'};
my $secnone = $alerts{'reserved'};
+ &js_escape(\$secname);
+ &js_escape(\$secnone);
my $output = '
function validatePersonnelSections(formname,nextstate) {
var badsectotal = 0;
@@ -1239,7 +1371,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 +1444,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 +1560,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 {
@@ -1440,20 +1581,66 @@ 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,
- \@code_order);
+ my $lonhost = $r->dir_config('lonHostID');
+ my ($storeresult,$result,$customized) = &print_request_outcome($r,$lonhost,$dom,\@codetitles,
+ \@code_order,$instcredits);
$r->print($result);
if (($storeresult eq 'ok') || ($storeresult eq 'created')) {
- $r->print('');
if ($storeresult eq 'ok') {
- $r->print(''.
- &mt('Modify this request').' '.(' 'x4));
+ $r->print('
'.
+ &mt('Modify this request').' '.(' 'x4).
+ ''.&mt('Make another request').'
');
+ }
+ if (&Apache::loncoursequeueadmin::author_prompt()) {
+ unless ($customized) {
+ &print_author_prompt($r,$env{'form.action'},$env{'form.cnum'},$env{'form.showdom'},
+ $env{'form.crstype'},$storeresult);
+ }
+ } elsif ($storeresult eq 'created') {
+ unless ($customized) {
+ $r->print(''.&mt('Make another request').'
');
+ }
}
- $r->print(''.&mt('Make another request').' ');
- return;
+ }
+ } elsif ($state eq 'reqauthor') {
+ my ($result,@links);
+ if ($env{'form.requestauthor'}) {
+ $r->print(&Apache::loncoursequeueadmin::process_reqauthor(\$result));
+ if ($result eq 'created') {
+ my $role = 'au';
+ my $spec = "$role./$env{'form.showdom'}/";
+ push(@links,&mt('Enter your Authoring Space with role: [_1]',
+ ''.
+ &Apache::lonnet::plaintext($role).' '));
+ }
+ }
+ if (($env{'form.disposition'} eq 'created') &&
+ ($env{'form.cnum'} =~ /^$match_courseid$/) &&
+ ($env{'form.showdom'} =~ /^$match_domain$/)) {
+ my ($spec,$area,$role,$type);
+ my $role = 'cc';
+ my $spec = "$role./$env{'form.showdom'}/$env{'form.cnum'}";
+ my $type = 'Course';
+ if ($env{'form.crstype'} eq 'community') {
+ $type = 'Community';
+ }
+ my $showrole = &Apache::lonnet::plaintext($role,$type);
+ unshift(@links,&mt('Enter new course with role: [_1]',
+ ''.$showrole.' '));
+ }
+ if (@links > 1) {
+ $r->print(&mt('New roles will be listed on your [_1]Roles[_2] page.',
+ '',' ').' '.&mt('Choose a role:').
+ '');
+ foreach my $link (@links) {
+ $r->print(''.$link.' ');
+ }
+ $r->print(' ');
+ } elsif (@links == 1) {
+ $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 +1667,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('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('Request Authoring Space access now?').
+ ' '.
+ ' '.&mt('Yes').' '.
+ (' 'x2).
+ ' '.&mt('No').' '.
+ '
'.
+ ' '.
+ ' '.
+ ' '.
+ ' '.
+ ' '.
+ ' '.
+ ' '.
+ ' ');
+}
+
sub get_usertype {
my ($persondom,$personname,$curr_rules,$got_rules) = @_;
my ($rules,$ruleorder) =
@@ -1547,18 +1760,19 @@ sub check_newuser_rules {
}
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);
}
}
@@ -1576,8 +1790,9 @@ sub get_excluded_elements {
sub print_enrollment_menu {
my ($formname,$instcode,$dom,$codetitles,$cat_titles,$cat_order,$code_order,
- $invalidcrosslist) =@_;
- my ($sections,$autoenroll,$access_dates,$output,$hasauto);
+ $showcredits,$instcredits,$invalidcrosslist) =@_;
+ my ($sections,$autoenroll,$access_dates,$output,$hasauto,$hascredits,
+ $creditsrow,$domdefcredits);
my $starttime = time;
my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
@@ -1589,6 +1804,12 @@ 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);
@@ -1663,12 +1884,29 @@ sub print_enrollment_menu {
&mt('No').''.
&Apache::lonhtmlcommon::row_closure(1).
&date_setting_table($starttime,$endtime,$formname,'enroll',
- $hasauto,%enrolltitles);
+ $hasauto,undef,%enrolltitles);
+ if ($showcredits) {
+ if ($instcredits) {
+ $creditsrow = &mt('[quant,_1,credit]',$instcredits);
+ } else {
+ $creditsrow = ''.
+ ' ';
+ }
+ $hascredits = 1;
+ }
+ }
+ } elsif (($env{'form.crstype'} eq 'unofficial') || ($env{'form.crstype'} eq 'textbook')) {
+ if ($showcredits) {
+ $creditsrow = ''.
+ ' ';
+ $hascredits = 1;
}
}
my $access_dates =
&date_setting_table($starttime,$endtime,$formname,'access',$hasauto,
- %accesstitles);
+ $hascredits,%accesstitles);
$output .= &Apache::lonhtmlcommon::start_pick_box();
if ($sections) {
$output .= $sections;
@@ -1687,7 +1925,15 @@ sub print_enrollment_menu {
$output .= &Apache::lonhtmlcommon::row_headline('Access').
''.$header.' '.
&Apache::lonhtmlcommon::row_closure(1).
- $access_dates
+ $access_dates;
+ }
+ if ($creditsrow) {
+ $output .= &Apache::lonhtmlcommon::row_headline('Credits').
+ ''.&mt('Credits earned by students').' '.
+ &Apache::lonhtmlcommon::row_closure(1).
+ &Apache::lonhtmlcommon::row_title(&mt('Default credits')).
+ $creditsrow.
+ &Apache::lonhtmlcommon::row_closure(1);
}
return ''.&Apache::lonhtmlcommon::start_pick_box().$output.
&Apache::lonhtmlcommon::end_pick_box().'
';
@@ -1752,7 +1998,7 @@ sub inst_section_selector {
}
sub date_setting_table {
- my ($starttime,$endtime,$formname,$prefix,$hasauto,%datetitles) = @_;
+ my ($starttime,$endtime,$formname,$prefix,$hasauto,$hascredits,%datetitles)=@_;
my ($perpetual,$table);
my $startform = &Apache::lonhtmlcommon::date_setter($formname,$prefix.'start',
$starttime,'','','',1,'','','',1);
@@ -1763,7 +2009,9 @@ sub date_setting_table {
$perpetual = ' '.
' '.
&mt('No end date').' ';
- $closure = '1';
+ unless ($hascredits) {
+ $closure = '1';
+ }
}
my %help_item = (
@@ -1853,9 +2101,22 @@ sub print_personnel_menu {
official => 'Requestor is automatically assigned Course Coordinator role.',
);
$lt{'unofficial'} = $lt{'official'};
+ $lt{'textbook'} = $lt{'textbook'};
$output .= &Apache::lonhtmlcommon::row_headline().
''.&Apache::loncommon::help_open_topic('Course_Request_Personnel').' '.$lt{$crstype}.' '.&mt('Include other personnel?').' ';
}
+ my $cansearch = 1;
+ my @alldoms = &Apache::lonnet::all_domains();
+ if (@alldoms == 1) {
+ my %domsrch = &Apache::lonnet::get_dom('configuration',
+ ['directorysrch'],$alldoms[0]);
+ if (ref($domsrch{'directorysrch'}) eq 'HASH') {
+ if ((!$domsrch{'directorysrch'}{'available'}) &&
+ ($domsrch{'directorysrch'}{'lcavailable'} eq '0')) {
+ $cansearch = 0;
+ }
+ }
+ }
for (my $i=0; $i<$persontotal; $i++) {
my @linkargs = map { 'person_'.$i.'_'.$_ } (@items);
my $linkargstr = join("','",@linkargs);
@@ -1880,9 +2141,14 @@ sub print_personnel_menu {
}
$sectionselector .= $newtitle.
' '."\n";
- my $usersrchlinktxt = &mt('Search for user');
- my $usersrchlink = &Apache::loncommon::selectuser_link($formname,@linkargs,$dom,
- $usersrchlinktxt);
+ my $usersrchlink;
+ if ($cansearch) {
+ my $usersrchlinktxt = &mt('Search for user');
+ $usersrchlink = &Apache::loncommon::selectuser_link($formname,@linkargs,$dom,
+ $usersrchlinktxt);
+ } else {
+ $usersrchlink = ' ';
+ }
my $userchklinktxt = &mt('Check username');
my $userchklink = &Apache::loncommon::selectuser_link($formname,@linkargs,$dom,
$userchklinktxt,'checkusername');
@@ -1970,6 +2236,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 {
@@ -1985,7 +2252,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 '') {
@@ -2183,8 +2450,9 @@ 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.');
+ &js_escape(\$alert);
return << "ENDJS";
function nextPage(formname,nextstate) {
if (confirm('$alert')) {
@@ -2198,7 +2466,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';
@@ -2208,6 +2476,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;
}
@@ -2391,7 +2697,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');
@@ -2485,7 +2791,7 @@ sub requestlog_display_filter {
sub print_review {
my ($dom,$codetitles,$cat_titles,$cat_order,$code_order,$uname,$udom,
- $disallowed,$disallowmsg) = @_;
+ $disallowed,$disallowmsg,$instcredits) = @_;
my ($types,$typename) = &Apache::loncommon::course_types();
my ($owner,$ownername,$owneremail);
if ($uname eq '' || $udom eq '') {
@@ -2518,6 +2824,7 @@ sub print_review {
my $enrollrow_title = &mt('Default Access Dates').' '.
'('.&Apache::lonnet::plaintext('st',$category).')';
+ my $instcode;
if ($env{'form.crstype'} eq 'official') {
if ((ref($codetitles) eq 'ARRAY') && (ref($cat_titles) eq 'HASH')) {
foreach my $title (@{$codetitles}) {
@@ -2533,6 +2840,17 @@ sub print_review {
}
}
}
+ if (ref($code_order) eq 'ARRAY') {
+ foreach my $item (@{$code_order}) {
+ $instcode .= $env{'form.instcode_'.$item};
+ }
+ }
+ $inst_headers .= ' '.&mt('Credits').' ';
+ if ($instcredits) {
+ $inst_values .= ''.$instcredits.' ';
+ } else {
+ $inst_values .= ''.$env{'form.coursecredits'}.' ';
+ }
if (&Apache::lonnet::auto_run('',$dom)) {
$enrollrow_title = &mt('Enrollment');
$enroll_headers = ''.&mt('Automatic Adds').' '.
@@ -2602,6 +2920,9 @@ sub print_review {
$section_values .= $xlistinfo;
}
$section_values .= '';
+ } elsif (($env{'form.crstype'} eq 'unofficial') || ($env{'form.crstype'} eq 'textbook')) {
+ $inst_headers .= ''.&mt('Credits').' ';
+ $inst_values .= ''.$env{'form.coursecredits'}.' ';
}
my %ctxt = &clone_text();
@@ -2611,7 +2932,7 @@ sub print_review {
($env{'form.clonedom'} =~ /^$match_domain$/)) {
my $canclone = &Apache::loncoursequeueadmin::can_clone_course($uname,
$udom,$env{'form.clonecrs'},$env{'form.clonedom'},
- $env{'form.crstype'});
+ $env{'form.crstype'},$dom,$instcode);
if ($canclone) {
my %courseenv = &Apache::lonnet::userenvironment($env{'form.clonedom'},
$env{'form.clonecrs'},('description','internal.coursecode'));
@@ -2773,18 +3094,20 @@ sub dates_from_form {
sub courseinfo_form {
my ($dom,$formname,$crstype,$next,$description) = @_;
- my %lt = &Apache::lonlocal::texthash(
+ my %js_lt = &Apache::lonlocal::texthash(
official => 'You must provide a (brief) course description.',
community => 'You must provide a (brief) community description.'
);
- $lt{'unofficial'} = $lt{'official'};
+ &js_escape(\%js_lt);
+ $js_lt{'unofficial'} = $js_lt{'official'};
+ $js_lt{'textbook'} = $js_lt{'official'};
my $js_validate = <<"ENDJS";