--- loncom/interface/lonrequestcourse.pm 2009/10/24 03:56:01 1.36.2.3
+++ loncom/interface/lonrequestcourse.pm 2009/12/15 13:36:16 1.41.2.1
@@ -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.41.2.1 2009/12/15 13:36:16 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -130,7 +130,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'};
@@ -143,6 +143,10 @@ sub handler {
$states{'log'} = ['filter','display'];
$states{'new'} = ['courseinfo','enrollment','personnel','review','process'];
+ if ($dom eq 'gcitest') {
+ $states{'new'} = ['courseinfo','review','process'];
+ }
+
if (($action eq 'new') && ($env{'form.crstype'} eq 'official')) {
unless ($env{'form.state'} eq 'crstype') {
unshift(@{$states{'new'}},'codepick');
@@ -157,7 +161,7 @@ sub handler {
my @invalidcrosslist;
my %trail = (
- crstype => 'Course Request Action',
+ crstype => 'Request Action',
codepick => 'Category',
courseinfo => 'Description',
enrollment => 'Access Dates',
@@ -169,6 +173,10 @@ sub handler {
cancel => 'Cancel Request',
removal => 'Outcome',
);
+ if ($dom eq 'gcitest') {
+ $trail{'crstype'} = 'Building a Test';
+ $trail{'courseinfo'} = 'Test Information';
+ }
if (($env{'form.crstype'} eq 'official') && (&Apache::lonnet::auto_run('',$dom))) {
$trail{'enrollment'} = 'Enrollment';
@@ -192,16 +200,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 +256,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 +294,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 +309,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.').
'
'.
&close_popup_form());
} else {
@@ -312,7 +335,7 @@ sub handler {
} elsif ($action eq 'log') {
&print_request_logs($jscript,$loaditems,$crumb);
} else {
- &print_main_menu($r,\%can_request,\%states,$dom,$jscript,'',$crumb);
+ &print_main_menu($r,\%can_request,\%states,$dom,$jscript,'',$crumb,\%request_domains);
}
return OK;
}
@@ -345,6 +368,14 @@ sub get_breadcrumbs {
my ($dom,$action,$state,$states,$trail) = @_;
my ($crumb,$newinstcode,$codechk,$checkedcode,$numtitles,$description);
my $page = 0;
+ my $firstcrumb = 'Pick Action';
+ my $crumbtitle = 'Course/Community Requests';
+ my $crumbhelp = 'Course_Requests';
+ if ($dom eq 'gcitest') {
+ $firstcrumb = 'Building a Test';
+ $crumbtitle = 'Create Concept Test';
+ $crumbhelp = 'Concept_Test_Creation';
+ }
if ((ref($states) eq 'HASH') && (ref($trail) eq 'HASH') && (ref($state))) {
if (defined($action)) {
my $done = 0;
@@ -386,7 +417,7 @@ sub get_breadcrumbs {
if ($$state eq $states->{$action}[$i]) {
&Apache::lonhtmlcommon::add_breadcrumb(
{text=>"$trail->{$$state}"});
- $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests');
+ $crumb = &Apache::lonhtmlcommon::breadcrumbs($crumbtitle,$crumbhelp);
last;
} else {
if (($$state eq 'process') || ($$state eq 'removal')) {
@@ -405,13 +436,13 @@ sub get_breadcrumbs {
}
} else {
&Apache::lonhtmlcommon::add_breadcrumb(
- {text=>'Pick Action'});
- $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests');
+ {text=>$firstcrumb});
+ $crumb = &Apache::lonhtmlcommon::breadcrumbs($crumbtitle,$crumbhelp);
}
} else {
&Apache::lonhtmlcommon::add_breadcrumb(
- {text=>'Pick Action'});
- $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests');
+ {text=>$firstcrumb});
+ $crumb = &Apache::lonhtmlcommon::breadcrumbs($crumbtitle,$crumbhelp);
}
return ($page,$crumb,$newinstcode,$codechk,$checkedcode,$description);
}
@@ -484,12 +515,22 @@ sub form_elements {
},
);
my %servers = &Apache::lonnet::get_servers($dom,'library');
+ if ($dom eq 'gcitest') {
+ %{$elements{'new'}{'courseinfo'}} = (
+ cdescr => 'text',
+ concepttest => 'radio',
+ );
+ }
my $numlib = keys(%servers);
if ($numlib > 1) {
$elements{'new'}{'courseinfo'}{'chome'} = 'selectbox';
} else {
$elements{'new'}{'courseinfo'}{'chome'} = 'hidden';
}
+ if ($dom eq 'gcitest') {
+ my %mergedhash = (%{$elements{'new'}{'courseinfo'}},%{$elements{'new'}{'enrollment'}});
+ %{$elements{'new'}{'courseinfo'}} = %mergedhash;
+ }
my (@codetitles,%cat_titles,%cat_order,@code_order,$lastitem);
&Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
\%cat_order,\@code_order);
@@ -591,11 +632,11 @@ sub onload_action {
}
sub print_main_menu {
- my ($r,$can_request,$states,$dom,$jscript,$loaditems,$crumb) = @_;
+ my ($r,$can_request,$states,$dom,$jscript,$loaditems,$crumb,$request_domains) = @_;
my ($types,$typename) = &Apache::loncommon::course_types();
my $onchange;
unless ($env{'form.interface'} eq 'textual') {
- $onchange = 1;
+ $onchange = 'this.form.submit()';
}
my $nextstate_setter = "\n";
@@ -611,30 +652,9 @@ sub print_main_menu {
}
}
- my $standby=&mt('Course selected. Please stand by.');
- my $js = <<"END";
-
-function enterrole (thisform,rolecode,buttonname) {
- document.title='$standby';
- window.status='$standby';
- thisform.newrole.value=rolecode;
- thisform.selectrole.value='1';
- thisform.submit();
-}
-
-function ToSyllabus(cdom,cnum) {
- if (cdom == '' || cdom == null) {
- return;
- }
- if (cnum == '' || cnum == null) {
- return;
- }
- var options = 'height=600,width=800,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no';
- var url = "/public/"+cdom+"/"+cnum+"/syllabus";
- syllwin = window.open(url,'',options,1);
- syllwin.focus();
- return;
-}
+ my $js;
+ unless ($dom eq 'gcitest') {
+ $js = <<"END";
function nextPage(formname) {
var crschoice = document.mainmenu_coursetype.crstype.value;
@@ -658,19 +678,20 @@ function check_can_request(crschoice,act
var unofficial = '';
var community = '';
END
-
- foreach my $item (keys(%{$can_request})) {
- $js .= "
- $item = 1;
+ if (ref($can_request) eq 'HASH') {
+ foreach my $item (keys(%{$can_request})) {
+ $js .= "
+ $item = 1;
";
- }
- my %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.\\nAll types is not allowed.',
- );
- $js .= < '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.\\nAll types is not allowed.',
+ );
+ $js .= <print(&header('Concept Test Courses',$js.$jscript,$loaditems).$crumb);
- my $existing = &existing_courses();
- if ($existing) {
- $r->print('
'.
- '
'.&mt('Request creation of a new course').'
');
- } else {
- $r->print('
'.&mt('Request creation of a new course, or review your pending course requests.').'
');
}
- $r->print('
'.
+ my ($pagetitle,$pageinfo,$domaintitle);
+ if (ref($can_request) eq 'HASH') {
+ if (($can_request->{'official'}) || ($can_request->{'unofficial'})) {
+ if ($can_request->{'community'}) {
+ $pagetitle = 'Course/Community Requests';
+ $pageinfo = &mt('Request creation of a new course or community, or review your pending requests.');
+ $domaintitle = &mt('Course/Community Domain');
+ } else {
+ $pagetitle = 'Course Requests';
+ $pageinfo = &mt('Request creation of a new course, or review your pending course requests.');
+ $domaintitle = &mt('Course Domain');
+ }
+ } elsif ($can_request->{'community'}) {
+ $pagetitle = 'Community Requests';
+ $pageinfo = &mt('Request creation of a new course, or review your pending requests.');
+ $domaintitle = &mt('Community Domain');
+ } else {
+ $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');
+ }
+ }
+
+ if ($dom eq 'gcitest') {
+ my $formname = 'requestcrs';
+ my $nexttext = &mt('Continue');
+ $r->print(&header($pagetitle,$js.$jscript,$loaditems).$crumb.
+ '
'.&mt('Deployment of a Concept Test requires completion of the following three steps:').'
'.
+ '
'.&mt('Creation of a course "container" and setting of access dates').'
'.
+ '
'.&mt('Assembly of a valid test from Concept Inventory questions').'
'.
+ '
'.&mt('Enrollment of students').'
'.
+ '
'.&mt('When assembling a test you may either:').
+ ' '.&mt('(a) have a valid test built automatically by the WebCenter, or').' '.&mt('(b) select the questions to include by combining questions chosen from eleven bins with four mandatory questions.').'
'.&mt('The most efficient way to enroll students is to upload a text file containing usernames and passwords.').' '.&mt("Students' full e-mail addresses should be used as their usernames to ensure uniqueness.").'
'."\n".$form."\n".
&print_review($dom,\@codetitles,\%cat_titles,\%cat_order,
\@code_order)."\n".
''."\n");
@@ -1017,8 +971,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 +1027,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 +1046,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.').'