--- loncom/interface/lonrequestcourse.pm 2009/09/08 13:05:00 1.31
+++ loncom/interface/lonrequestcourse.pm 2010/12/05 17:27:00 1.41.2.11
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Request a course
#
-# $Id: lonrequestcourse.pm,v 1.31 2009/09/08 13:05:00 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.41.2.11 2010/12/05 17:27:00 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()
@@ -132,13 +128,21 @@ sub handler {
if ($r->header_only) {
return OK;
}
-
&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'};
+ my $action = $env{'form.reqaction'};
my $state = $env{'form.state'};
+ my $context;
+ &generate_page($r,$action,$state,$context);
+ return OK;
+}
+
+sub generate_page {
+ my ($r,$action,$state,$context) = @_;
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['action','showdom','cnum','state','crstype']);
+ my $dom = &get_course_dom();
my (%states,%stored);
my ($jscript,$uname,$udom,$result,$warning);
@@ -147,8 +151,19 @@ sub handler {
$states{'log'} = ['filter','display'];
$states{'new'} = ['courseinfo','enrollment','personnel','review','process'];
+ if ($dom =~ /^\w+citest$/) {
+ $states{'new'} = ['courseinfo','review','process'];
+ if ($env{'form.concepttest'} eq 'editmyown') {
+ push(@{$states{'new'}},'chooseitems','uploadroster','enrolling');
+ } elsif (($env{'form.concepttest'} eq 'defchosen') ||
+ (($env{'form.concepttest'} eq 'cloning') && (!$env{'form.cloneroster'}))) {
+ push(@{$states{'new'}},'uploadroster','enrolling');
+ } else {
+ push(@{$states{'new'}},'done');
+ }
+ }
if (($action eq 'new') && ($env{'form.crstype'} eq 'official')) {
- unless ($env{'form.state'} eq 'crstype') {
+ unless ($state eq 'crstype') {
unshift(@{$states{'new'}},'codepick');
}
}
@@ -161,24 +176,32 @@ sub handler {
my @invalidcrosslist;
my %trail = (
- crstype => 'Course Request Action',
+ crstype => 'Request Action',
codepick => 'Category',
courseinfo => 'Description',
enrollment => 'Access Dates',
personnel => 'Personnel',
review => 'Review',
- process => 'Result',
+ process => 'Request Outcome',
pick_request => 'Display Summary',
details => 'Request Details',
cancel => 'Cancel Request',
removal => 'Outcome',
+ chooseitems => 'Saved Test',
+ uploadroster => 'Upload Roster',
+ enrolling => 'Completed',
+ done => 'Completed',
);
+ if ($dom =~ /^\w+citest$/) {
+ $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))) {
@@ -196,16 +219,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')) {
@@ -239,7 +276,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') {
@@ -264,9 +301,12 @@ sub handler {
$env{'form.clonedom'} = $dom;
}
if ($state eq 'crstype') {
- $jscript = &mainmenu_javascript();
+ $jscript = &mainmenu_javascript($action);
} else {
$jscript = &Apache::lonhtmlcommon::set_form_elements($elementsref,\%stored);
+ if ($state eq 'courseinfo') {
+ $jscript .= &cloning_javascript();
+ }
}
}
@@ -274,29 +314,35 @@ sub handler {
$jscript .= "\n".&Apache::loncommon::userbrowser_javascript();
}
- my $loaditems = &onload_action($action,$state);
+ my $loaditems = &onload_action($action,$state,$dom);
- 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);
+ if ($state eq 'chooseitems' || $state eq 'uploadroster' ||
+ $state eq 'enrolling') {
+ return $canreq;
+ }
}
} 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;
+ return;
}
sub mainmenu_javascript {
+ my ($action) = @_;
return <<"END";
function setType(courseForm) {
for (var i=0; i 1) {
+ for (var i=0; i 'requestcrs',
+ uploadroster => 'studentform',
+ enrolling => 'requestcrs',
+ done => 'requestcrs',
+ );
+ my $lastidx;
+ for (my $i=0; $i<@{$states->{$action}}; $i++) {
+ if ($$state eq $states->{$action}[$i]) {
+ $lastidx = $i;
+ last;
+ }
+ }
for (my $i=0; $i<@{$states->{$action}}; $i++) {
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')) {
@@ -399,24 +483,45 @@ sub get_breadcrumbs {
}
);
} else {
- &Apache::lonhtmlcommon::add_breadcrumb(
+ if (($$state eq 'chooseitems') || ($$state eq 'uploadroster') ||
+ ($$state eq 'enrolling') || ($$state eq 'done')) {
+ if (($states->{$action}[$i] ne 'process') &&
+ ($states->{$action}[$i] ne 'chooseitems') &&
+ ($states->{$action}[$i] ne 'uploadroster') &&
+ ($states->{$action}[$i] ne 'enrolling') &&
+ ($states->{$action}[$i] ne 'done')) {
+ &Apache::lonhtmlcommon::add_breadcrumb(
+ { href => '/adm/requestcourse',
+ text => "$trail->{$states->{$action}[$i]}",
+ }
+ );
+ } else {
+ my $diff = $i-$lastidx;
+ &Apache::lonhtmlcommon::add_breadcrumb(
+ { href => "javascript:history.go($diff)",
+ 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'});
- $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 {
@@ -430,11 +535,13 @@ sub header {
if (ref($args) eq 'HASH') {
my %loadhash = (
'add_entries' => $loaditems,
+ 'function' => 'norole',
);
my %arghash = (%loadhash,%{$args});
- $args = \%arghash;
+ $args = \%arghash;
} else {
- $args = {'add_entries' => $loaditems,};
+ $args = {'add_entries' => $loaditems,
+ 'function' => 'norole'};
}
}
return &Apache::loncommon::start_page($bodytitle,$jscript.$jsextra,$args);
@@ -452,6 +559,7 @@ sub form_elements {
},
courseinfo => {
cdescr => 'text',
+ cloning => 'radio',
clonecrs => 'text',
clonedom => 'selectbox',
datemode => 'radio',
@@ -487,12 +595,28 @@ sub form_elements {
},
);
my %servers = &Apache::lonnet::get_servers($dom,'library');
+ if ($dom =~ /^\w+citest$/) {
+ %{$elements{'new'}{'courseinfo'}} = (
+ cdescr => 'text',
+ concepttest => 'radio',
+ );
+ $elements{'new'}{'enrollment'}{'timezone'} = 'selectbox';
+ if (&show_cloneable()) {
+ $elements{'new'}{'courseinfo'}{'clonecrs'} = 'selectbox';
+ $elements{'new'}{'courseinfo'}{'clonedom'} = 'hidden';
+ $elements{'new'}{'courseinfo'}{'cloneroster'} = 'checkbox';
+ }
+ }
my $numlib = keys(%servers);
if ($numlib > 1) {
$elements{'new'}{'courseinfo'}{'chome'} = 'selectbox';
} else {
$elements{'new'}{'courseinfo'}{'chome'} = 'hidden';
}
+ if ($dom =~ /^\w+citest$/) {
+ 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);
@@ -587,61 +711,18 @@ sub onload_action {
if ($state eq 'crstype') {
$loaditems{'onload'} = 'javascript:setAction(document.mainmenu_action);javascript:setType(document.mainmenu_coursetype)';
} else {
- $loaditems{'onload'} = 'javascript:setFormElements(document.requestcrs)';
+ $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;
- }
- }
- }
- }
- }
- }
- return $canreq;
-}
-
-sub course_types {
- my @types = ('official','unofficial','community');
- my %typename = (
- official => 'Official course',
- unofficial => 'Unofficial course',
- community => 'Community',
- );
- return (\@types,\%typename);
-}
-
-
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";
@@ -657,11 +738,13 @@ sub print_main_menu {
}
}
- my $js = <<"END";
+ my $js;
+ unless ($dom =~ /^\w+citest$/) {
+ $js = <<"END";
function nextPage(formname) {
var crschoice = document.mainmenu_coursetype.crstype.value;
- var actionchoice = document.mainmenu_action.action.value;
+ var actionchoice = document.mainmenu_action.reqaction.value;
if (check_can_request(crschoice,actionchoice) == true) {
if ((actionchoice == 'new') && (crschoice == 'official')) {
nextstate = 'codepick';
@@ -669,7 +752,7 @@ function nextPage(formname) {
$nextstate_setter
}
formname.crstype.value = crschoice;
- formname.action.value = actionchoice;
+ formname.reqaction.value = actionchoice;
formname.state.value= nextstate;
formname.submit();
}
@@ -681,19 +764,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 =~ /^\w+citest$/) {
+ 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:').
+ ' '.&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, or').
+ ' '.&mt('(c) copy one of your existing tests (including optional copying of the student roster)').'
'.&mt('The most efficient way to enroll students is to upload a text file containing usernames and passwords.').' '.&mt("Students' e-mail addresses must be used as their usernames to ensure uniqueness.").'