--- loncom/interface/lonrequestcourse.pm 2009/09/06 19:09:54 1.29
+++ 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.29 2009/09/06 19:09:54 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
#
@@ -52,10 +52,6 @@ described at http://www.lon-capa.org.
=item onload_action()
-=item check_can_request()
-
-=item course_types()
-
=item print_main_menu()
=item request_administration()
@@ -122,6 +118,7 @@ use Apache::lonnet;
use Apache::loncommon;
use Apache::lonlocal;
use Apache::loncoursequeueadmin;
+use Apache::lonuserutils;
use LONCAPA qw(:DEFAULT :match);
sub handler {
@@ -133,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'};
@@ -146,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');
@@ -160,7 +161,7 @@ sub handler {
my @invalidcrosslist;
my %trail = (
- crstype => 'Course Request Action',
+ crstype => 'Request Action',
codepick => 'Category',
courseinfo => 'Description',
enrollment => 'Access Dates',
@@ -172,12 +173,16 @@ 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';
}
- my ($page,$crumb,$newinstcode,$codechk,$checkedcode) =
+ 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))) {
@@ -195,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')) {
@@ -238,7 +257,7 @@ sub handler {
$crosslistcode .= $env{'form.crosslist_'.$i.'_'.$item};
}
if ($crosslistcode ne '') {
- $codechk{$i} =
+ ($codechk{$i}, my $rest) =
&Apache::lonnet::auto_validate_instcode('',$dom,$crosslistcode);
}
unless ($codechk{$i} eq 'valid') {
@@ -262,7 +281,11 @@ sub handler {
if (($state eq 'courseinfo') && ($env{'form.clonedom'} eq '')) {
$env{'form.clonedom'} = $dom;
}
- $jscript = &Apache::lonhtmlcommon::set_form_elements($elementsref,\%stored);
+ if ($state eq 'crstype') {
+ $jscript = &mainmenu_javascript();
+ } else {
+ $jscript = &Apache::lonhtmlcommon::set_form_elements($elementsref,\%stored);
+ }
}
if ($state eq 'personnel') {
@@ -271,27 +294,29 @@ sub handler {
my $loaditems = &onload_action($action,$state);
- my %can_request;
- my $canreq = &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,
- $codechk,$checkedcode,\@invalidcrosslist);
+ $codechk,$checkedcode,$description,
+ \@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 {
&request_administration($r,$action,$state,$page,\%states,$dom,$jscript,
- $loaditems,$crumb,'','','','',$uname,$udom);
+ $loaditems,$crumb,'','','','','',$uname,$udom);
}
} 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;
}
+sub mainmenu_javascript {
+ return <<"END";
+function setType(courseForm) {
+ for (var i=0; i{$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')) {
@@ -379,15 +436,15 @@ 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);
+ return ($page,$crumb,$newinstcode,$codechk,$checkedcode,$description);
}
sub header {
@@ -458,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);
@@ -498,9 +565,9 @@ sub form_elements {
);
if ($env{'form.sectotal'} > 0) {
for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
- $extras{'sec_'.$i} = 'checkbox',
- $extras{'secnum_'.$i} = 'text',
- $extras{'loncapasec_'.$i} = 'text',
+ $extras{'sec_'.$i} = 'radio';
+ $extras{'secnum_'.$i} = 'text';
+ $extras{'loncapasec_'.$i} = 'text';
}
}
my $crosslisttotal = $env{'form.crosslisttotal'};
@@ -555,60 +622,21 @@ sub onload_action {
my ($action,$state) = @_;
my %loaditems;
if (($action eq 'new') || ($action eq 'view')) {
- $loaditems{'onload'} = 'javascript:setFormElements(document.requestcrs)';
- }
- return \%loaditems;
-}
-
-sub check_can_request {
- my ($dom,$can_request) = @_;
- my $canreq = 0;
- my ($types,$typename) = &course_types();
- my @options = ('approval','validate','autolimit');
- my $optregex = join('|',@options);
- if ((ref($can_request) eq 'HASH') && (ref($types) eq 'ARRAY')) {
- foreach my $type (@{$types}) {
- if (&Apache::lonnet::usertools_access($env{'user.name'},
- $env{'user.domain'},
- $type,undef,'requestcourses')) {
- $canreq ++;
- if ($dom eq $env{'user.domain'}) {
- $can_request->{$type} = 1;
- }
- }
- if ($env{'environment.reqcrsotherdom.'.$type} ne '') {
- my @curr = split(',',$env{'environment.reqcrsotherdom.'.$type});
- if (@curr > 0) {
- $canreq ++;
- unless ($dom eq $env{'user.domain'}) {
- if (grep(/^\Q$dom\E:($optregex)(=?\d*)$/,@curr)) {
- $can_request->{$type} = 1;
- }
- }
- }
- }
+ if ($state eq 'crstype') {
+ $loaditems{'onload'} = 'javascript:setAction(document.mainmenu_action);javascript:setType(document.mainmenu_coursetype)';
+ } else {
+ $loaditems{'onload'} = 'javascript:setFormElements(document.requestcrs)';
}
}
- return $canreq;
-}
-
-sub course_types {
- my @types = ('official','unofficial','community');
- my %typename = (
- official => 'Official course',
- unofficial => 'Unofficial course',
- community => 'Community',
- );
- return (\@types,\%typename);
+ return \%loaditems;
}
-
sub print_main_menu {
- my ($r,$can_request,$states,$dom,$jscript,$loaditems,$crumb) = @_;
- my ($types,$typename) = &course_types();
+ 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";
@@ -624,7 +652,9 @@ sub print_main_menu {
}
}
- my $js = <<"END";
+ my $js;
+ unless ($dom eq 'gcitest') {
+ $js = <<"END";
function nextPage(formname) {
var crschoice = document.mainmenu_coursetype.crstype.value;
@@ -648,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 .= <{'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.").'