--- loncom/interface/lonrequestcourse.pm 2014/05/06 18:09:40 1.79
+++ loncom/interface/lonrequestcourse.pm 2016/04/04 01:09:48 1.98
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Request a course
#
-# $Id: lonrequestcourse.pm,v 1.79 2014/05/06 18:09:40 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.98 2016/04/04 01:09:48 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -172,13 +172,29 @@ sub handler {
if ($can_request{'textbook'}) {
&process_textbook_request($r,$dom,$action,\%domdefs,\%domconfig,\%can_request);
} else {
- &textbook_request_disabled($r,$dom,\%can_request);
+ &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,\%can_request);
+ &textbook_request_disabled($r,$dom,$action,\%can_request);
}
}
return OK;
@@ -232,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'}))) {
@@ -334,6 +311,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();
}
}
}
@@ -436,7 +415,7 @@ function setCloneDisplay(courseForm) {
for (var i=0; i{$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') || ($$state eq 'reqauthor')) {
+ 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'});
@@ -720,6 +712,9 @@ sub onload_action {
if ($state eq 'courseinfo') {
$loaditems{'onload'} .= 'javascript:setCloneDisplay(document.requestcrs);';
}
+ if ($state eq 'process') {
+ $loaditems{'onload'} .= 'javascript:hideProcessing();';
+ }
}
return \%loaditems;
}
@@ -765,6 +760,7 @@ function check_can_request(crschoice,act
var unofficial = '';
var community = '';
var textbook = '';
+ var placement = '';
END
if (ref($can_request) eq 'HASH') {
foreach my $item (keys(%{$can_request})) {
@@ -773,42 +769,51 @@ 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 in this domain.',
textbook => 'You are not permitted to request creation of a textbook course in this domain',
+ placement => 'You are not permitted to request creation of a placement test 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'}) || $can_request->{'textbook'}) {
+ if (($can_request->{'official'}) || ($can_request->{'unofficial'}) || ($can_request->{'textbook'}) || ($can_request->{'placement'})) {
if ($can_request->{'community'}) {
$pagetitle = 'Course/Community Requests';
$pageinfo = &mt('Request creation of a new course or community, or review your pending requests.');
@@ -944,7 +949,8 @@ END
if ($action eq 'new') {
my $jsextra;
if (($state eq 'courseinfo') || ($state eq 'codepick')) {
- $jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom);
+ $jsextra = "\n".&Apache::loncommon::coursebrowser_javascript($dom,'','','','','',
+ $newinstcode);
} elsif ($state eq 'enrollment') {
if (($env{'form.crstype'} eq 'official') &&
(&Apache::lonnet::auto_run('',$dom))) {
@@ -995,6 +1001,8 @@ END
$title = &mt('Pending requests for unofficial courses');
} elsif ($env{'form.crstype'} eq 'textbook') {
$title = &mt('Pending requests for textbook courses');
+ } elsif ($env{'form.crstype'} eq 'textbook') {
+ $title = &mt('Pending requests for placement tests');
} else {
$title = &mt('Pending course/community requests');
}
@@ -1129,10 +1137,58 @@ 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'};
my $secnone = $alerts{'reserved'};
+ &js_escape(\$secname);
+ &js_escape(\$secnone);
my $output = '
function validateEnrollSections(formname,nextstate) {
var badsectotal = 0;
@@ -1190,8 +1246,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;
@@ -1527,8 +1585,8 @@ sub print_request_form {
\%cat_order,\@code_order);
}
my $lonhost = $r->dir_config('lonHostID');
- my ($storeresult,$result) = &print_request_outcome($lonhost,$dom,\@codetitles,
- \@code_order,$instcredits);
+ my ($storeresult,$result,$customized) = &print_request_outcome($r,$lonhost,$dom,\@codetitles,
+ \@code_order,$instcredits);
$r->print($result);
if (($storeresult eq 'ok') || ($storeresult eq 'created')) {
if ($storeresult eq 'ok') {
@@ -1537,10 +1595,14 @@ sub print_request_form {
''.&mt('Make another request').'');
}
if (&Apache::loncoursequeueadmin::author_prompt()) {
- &print_author_prompt($r,$env{'form.action'},$env{'form.cnum'},$env{'form.showdom'},
- $env{'form.crstype'},$storeresult);
+ unless ($customized) {
+ &print_author_prompt($r,$env{'form.action'},$env{'form.cnum'},$env{'form.showdom'},
+ $env{'form.crstype'},$storeresult);
+ }
} elsif ($storeresult eq 'created') {
- $r->print(''.&mt('Make another request').'
');
+ unless ($customized) {
+ $r->print(''.&mt('Make another request').'
');
+ }
}
}
} elsif ($state eq 'reqauthor') {
@@ -2042,7 +2104,8 @@ sub print_personnel_menu {
official => 'Requestor is automatically assigned Course Coordinator role.',
);
$lt{'unofficial'} = $lt{'official'};
- $lt{'textbook'} = $lt{'textbook'};
+ $lt{'textbook'} = $lt{'official'};
+ $lt{'placement'} = $lt{'official'};
$output .= &Apache::lonhtmlcommon::row_headline().
''.&Apache::loncommon::help_open_topic('Course_Request_Personnel').' '.$lt{$crstype}.' '.&mt('Include other personnel?').'
';
}
@@ -2374,8 +2437,9 @@ ENDJS
}
sub viewcancel_javascript {
- my $alert = &mt('Are you sure you want to cancel this request?').'\\n'.
+ 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')) {
@@ -2452,7 +2516,7 @@ sub print_request_logs {
if (ref($domconfig{'requestcourses'}) eq 'HASH') {
if (ref($domconfig{'requestcourses'}{'uniquecode'}) eq 'HASH') {
if ($curr{'crstype'} eq 'any') {
- my @types = qw(official unofficial community textbook);
+ my @types = qw(official unofficial community textbook placement);
foreach my $type (@types) {
if ($domconfig{'requestcourses'}{'uniquecode'}{$type}) {
$showuniquecode = 1;
@@ -2620,7 +2684,7 @@ sub reqstatus_names {
rejected => 'Request rejected',
cancelled => 'Request cancelled',
);
- if (($crstype eq 'official') || ($crstype eq 'unofficial') || ($crstype eq 'textbook')) {
+ if (($crstype eq 'official') || ($crstype eq 'unofficial') || ($crstype eq 'textbook') || ($crstype eq 'placement')) {
$statusnames{'created'} = &mt('Course created');
} elsif ($crstype eq 'community') {
$statusnames{'created'} = &mt('Community created');
@@ -2747,6 +2811,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}) {
@@ -2762,6 +2827,11 @@ 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.' | ';
@@ -2849,7 +2919,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'));
@@ -3011,19 +3081,21 @@ 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'};
- $lt{'textbook'} = $lt{'official'};
+ &js_escape(\%js_lt);
+ $js_lt{'unofficial'} = $js_lt{'official'};
+ $js_lt{'textbook'} = $js_lt{'official'};
+ $js_lt{'placement'} = $js_lt{'official'};
my $js_validate = <<"ENDJS";