--- loncom/interface/lonrequestcourse.pm 2009/10/24 03:56:01 1.36.2.3
+++ loncom/interface/lonrequestcourse.pm 2010/02/21 23:38:51 1.44
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Request a course
#
-# $Id: lonrequestcourse.pm,v 1.36.2.3 2009/10/24 03:56:01 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.44 2010/02/21 23:38:51 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -94,8 +94,6 @@ described at http://www.lon-capa.org.
=item print_request_outcome()
-=item get_processtype()
-
=item check_autolimit()
=item retrieve_settings()
@@ -130,7 +128,7 @@ sub handler {
}
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['action','showdom','cnum','state']);
+ ['action','showdom','cnum','state','crstype']);
&Apache::lonhtmlcommon::clear_breadcrumbs();
my $dom = &get_course_dom();
my $action = $env{'form.action'};
@@ -157,7 +155,7 @@ sub handler {
my @invalidcrosslist;
my %trail = (
- crstype => 'Course Request Action',
+ crstype => 'Request Action',
codepick => 'Category',
courseinfo => 'Description',
enrollment => 'Access Dates',
@@ -178,7 +176,6 @@ sub handler {
&get_breadcrumbs($dom,$action,\$state,\%states,\%trail);
if ($action eq 'display') {
if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) {
- my $namespace = 'courserequestqueue';
if ($env{'form.cnum'} ne '') {
my $cnum = $env{'form.cnum'};
my $reqkey = $cnum.'_approval';
@@ -192,16 +189,30 @@ sub handler {
if (($udom =~ /^$match_domain$/) && ($uname =~ /^$match_username$/)) {
$result = &retrieve_settings($dom,$cnum,$udom,$uname);
} else {
- $warning = &mt('Invalid username or domain for course requestor');
+ 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 {
- $warning = &mt('No information was found for this course request.');
+ 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 {
- $warning = &mt('You do not have rights to view course request information.');
+ 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.');
+ }
}
} elsif ((defined($state)) && (defined($action))) {
if (($action eq 'view') && ($state eq 'details')) {
@@ -234,8 +245,8 @@ sub handler {
foreach my $item (@code_order) {
$crosslistcode .= $env{'form.crosslist_'.$i.'_'.$item};
}
- if ($crosslistcode ne '') {
- ($codechk{$i}, my $rest) =
+ if ($crosslistcode ne '') {
+ ($codechk{$i}, my $rest) =
&Apache::lonnet::auto_validate_instcode('',$dom,$crosslistcode);
}
unless ($codechk{$i} eq 'valid') {
@@ -272,13 +283,14 @@ sub handler {
my $loaditems = &onload_action($action,$state);
- my %can_request;
- my $canreq = &Apache::lonnet::check_can_request($dom,\%can_request);
+ 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);
+ $crumb,\%request_domains);
} else {
&request_administration($r,$action,$state,$page,\%states,$dom,
$jscript,$loaditems,$crumb,$newinstcode,
@@ -286,14 +298,14 @@ sub handler {
\@invalidcrosslist);
}
} else {
- $r->print(&header('Course Requests').$crumb.
+ $r->print(&header('Course/Community Requests').$crumb.
'
'.
- &mt('You do not have privileges to request creation of courses.').
+ &mt('You do not have privileges to request creation of courses or communities.').
'
'."\n".$form."\n".
&print_review($dom,\@codetitles,\%cat_titles,\%cat_order,
\@code_order)."\n".
''."\n");
@@ -1017,8 +905,14 @@ END
$navtxt{'next'},$state,$other,$navtxt{'other'});
$r->print('');
} elsif ($state eq 'cancel') {
+ my $title;
+ if ($env{'form.crstype'} eq 'community') {
+ $title = &mt('Cancel community request');
+ } else {
+ $title = &mt('Cancel course request');
+ }
my ($result,$output) = &print_cancel_request($dom,$env{'form.origcnum'});
- $r->print('
'.&mt('Cancel course request').'
'."\n".$form."\n".
+ $r->print('
'.$title.'
'."\n".$form."\n".
$output);
my @excluded = &get_excluded_elements($dom,$states,'view','cancel');
$r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'
');
@@ -1067,7 +961,11 @@ END
''."\n".
''."\n");
if ($result eq 'ok') {
- $r->print(&mt('Your course request has been cancelled.'));
+ if ($env{'form.crstype'} eq 'community') {
+ $r->print(&mt('Your community request has been cancelled.'));
+ } else {
+ $r->print(&mt('Your course request has been cancelled.'));
+ }
} else {
$r->print('
'.
&mt('The request cancellation process was not complete.').
@@ -1082,8 +980,16 @@ END
&Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
\%cat_order,\@code_order);
}
- $r->print(&header('Course Request','','','',{ 'only_body' => 1}).
- $crumb."\n".'
'.&mt('You may also add users later, once the community has been created, by using the "Manage community users" link, accessible from the "Main Menu".').'
';
+ } else {
+ $output .= '
'.&mt('You may also add users later, once the course has been created, by using the "Manage course users" link, accessible from the "Main Menu".').'
'.&mt('You have no matching course requests awaiting approval by a Domain Coordinator or held in a queue pending administrative action at your institution.').'
';
+ if ($env{'form.crstype'} eq 'any') {
+$output .= '
'.&mt('You have no matching course or community requests awaiting approval by a Domain Coordinator or held in a queue pending administrative action at your institution.').'
'.&mt('You have no matching community requests awaiting approval by a Domain Coordinator or held in a queue pending administrative action at your institution.').'
';
+ } else {
+ $output .= '
'.&mt('You have no matching course requests awaiting approval by a Domain Coordinator or held in a queue pending administrative action at your institution.').'
';
for (my $i=0; $i<$env{'form.persontotal'}; $i++) {
if ($env{'form.person_'.$i.'_uname'} ne '') {
@@ -2321,7 +2261,7 @@ sub print_review {
if ($showsec eq '') {
$showsec = &mt('None');
}
- if ($env{'form.person_'.$i.'_role'} eq 'cc') {
+ if ($env{'form.person_'.$i.'_role'} eq $ccrole) {
$showsec = &mt('None');
}
my $role = $env{'form.person_'.$i.'_role'};
@@ -2415,8 +2355,10 @@ function validateForm() {
ENDJS
my $title = &mt('Brief Course Description');
+ my $clonetitle = &mt('Clone content and settings from an existing course?');
if ($crstype eq 'community') {
$title = &mt('Brief Community Description');
+ $clonetitle = &mt('Clone content and settings from an existing community?');
}
my $output .= $js_validate."\n".'
'.&mt('Your community request has been updated').'
';
+ } else {
+ $output .= '
'.&mt('Your course request has been updated').'
';
+ }
+ $output .= ¬ification_information($disposition,$req_notifylist,$cnum,$now);
}
if ($validationerror ne '') {
- $output .= ''.&mt('An error occurred validating your request with institutional data sources: [_1].',$validationerror).'';
+ $output .= '
'.&mt('An error occurred validating your request with institutional data sources: [_1].',$validationerror).'
';
+ }
+ if ($updateresult) {
+ $output .= $updateresult;
}
}
if ($creationresult ne '') {
@@ -3009,23 +2965,34 @@ sub update_requestors_roles {
my $owner = $env{'user.name'}.':'.$env{'user.domain'};
if (ref($details) eq 'HASH') {
if (ref($details->{'personnel'}) eq 'HASH') {
+ my $ccrole = 'cc';
+ if ($crstype eq 'community') {
+ $ccrole = 'co';
+ }
unless (ref($details->{'personnel'}{$owner}) eq 'HASH') {
$details->{'personnel'}{$owner} = {
- 'roles' => ['cc'],
- 'cc' => { 'usec' => [] },
+ 'roles' => [$ccrole],
+ $ccrole => { 'usec' => [] },
};
}
my @roles;
if (ref($details->{'personnel'}{$owner}{'roles'}) eq 'ARRAY') {
@roles = sort(@{$details->{'personnel'}{$owner}{'roles'}});
- unless (grep(/^cc$/,@roles)) {
- push(@roles,'cc');
+ unless (grep(/^\Q$ccrole\E$/,@roles)) {
+ push(@roles,$ccrole);
}
} else {
- @roles = ('cc');
+ @roles = ($ccrole);
}
foreach my $role (@roles) {
- my $start = $now;
+ my $refresh=$env{'user.refresh.time'};
+ if ($refresh eq '') {
+ $refresh = $env{'user.login.time'};
+ }
+ if ($refresh eq '') {
+ $refresh = $now;
+ }
+ my $start = $refresh-1;
my $end = '0';
if ($role eq 'st') {
if ($details->{'accessstart'} ne '') {
@@ -3036,7 +3003,7 @@ sub update_requestors_roles {
}
}
my @usecs;
- if ($role ne 'cc') {
+ if ($role ne $ccrole) {
if (ref($details->{'personnel'}{$owner}{$role}{'usec'}) eq 'ARRAY') {
@usecs = @{$details->{'personnel'}{$owner}{$role}{'usec'}};
}
@@ -3101,15 +3068,27 @@ sub update_requestors_roles {
}
if ($active) {
if ($numactive == 1) {
- $output = &mt('Use the following link to enter the course:');
+ if ($crstype eq 'Community') {
+ $output = &mt('Use the following link to enter the community:');
+ } else {
+ $output = &mt('Use the following link to enter the course:');
+ }
} else {
- $output = &mt('Use the following links to your new roles to enter the course:');
+ if ($crstype eq 'Community') {
+ $output = &mt('Use the following links to your new roles to enter the community:');
+ } else {
+ $output = &mt('Use the following links to your new roles to enter the course:');
+ }
}
$output .= '
'.$active.'
';
}
if ($future) {
- $output .= &mt('The following course [quant,_1,role] will become available for selection from your [_2]roles page[_3], once the default student access start date - [_4] - has been reached:',$numfuture,'','',&Apache::lonlocal::locallocaltime($details->{'accessstart'})).
- '
'.$future.'
';
+ if ($crstype eq 'Community') {
+ $output .= &mt('The following community [quant,_1,role] will become available for selection from your [_2]roles page[_3], once the default student access start date - [_4] - has been reached:',$numfuture,'','',&Apache::lonlocal::locallocaltime($details->{'accessstart'}))
+ } else {
+ $output .= &mt('The following course [quant,_1,role] will become available for selection from your [_2]roles page[_3], once the default student access start date - [_4] - has been reached:',$numfuture,'','',&Apache::lonlocal::locallocaltime($details->{'accessstart'}));
+ }
+ $output .= '