--- loncom/interface/lonrequestcourse.pm 2013/08/23 00:47:57 1.63.6.1
+++ loncom/interface/lonrequestcourse.pm 2013/05/11 21:10:31 1.67
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Request a course
#
-# $Id: lonrequestcourse.pm,v 1.63.6.1 2013/08/23 00:47:57 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.67 2013/05/11 21:10:31 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -134,7 +134,11 @@ sub handler {
my $action = $env{'form.action'};
my $state = $env{'form.state'};
my (%states,%stored);
- my ($jscript,$uname,$udom,$result,$warning);
+ my ($jscript,$uname,$udom,$result,$warning,$showcredits,$instcredits);
+ my %domdefs = &Apache::lonnet::get_domain_defaults($dom);
+ if ($domdefs{'officialcredits'} || $domdefs{'unofficialcredits'}) {
+ $showcredits = 1;
+ }
$states{'display'} = ['details'];
$states{'view'} = ['pick_request','details','cancel','removal'];
@@ -147,6 +151,12 @@ sub handler {
}
}
+ if (($action eq 'new') && (&Apache::loncoursequeueadmin::author_prompt())) {
+ if (ref($states{$action}) eq 'ARRAY') {
+ push(@{$states{$action}},'reqauthor');
+ }
+ }
+
foreach my $key (keys(%states)) {
if (ref($states{$key}) eq 'ARRAY') {
unshift (@{$states{$key}},'crstype');
@@ -162,6 +172,7 @@ sub handler {
personnel => 'Personnel',
review => 'Review',
process => 'Result',
+ reqauthor => 'Authoring Space Result',
pick_request => 'Display Summary',
details => 'Request Details',
cancel => 'Cancel Request',
@@ -173,7 +184,7 @@ sub handler {
$trail{'enrollment'} = 'Enrollment';
}
- my ($page,$crumb,$newinstcode,$codechk,$checkedcode,$description) =
+ 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))) {
@@ -262,11 +273,11 @@ sub handler {
}
}
}
- my %elements = &form_elements($dom);
+ (my $elements,$instcredits) = &form_elements($dom,$showcredits);
my $elementsref = {};
- if (ref($elements{$action}) eq 'HASH') {
- if (ref($elements{$action}{$state}) eq 'HASH') {
- $elementsref = $elements{$action}{$state};
+ if ((ref($elements) eq 'HASH') && (ref($elements->{$action}) eq 'HASH')) {
+ if (ref($elements->{$action}{$state}) eq 'HASH') {
+ $elementsref = $elements->{$action}{$state};
}
}
if (($state eq 'courseinfo') && ($env{'form.clonedom'} eq '')) {
@@ -300,7 +311,7 @@ sub handler {
&request_administration($r,$action,$state,$page,\%states,$dom,
$jscript,$loaditems,$crumb,$newinstcode,
$codechk,$checkedcode,$description,
- \@invalidcrosslist);
+ $showcredits,$instcredits,\@invalidcrosslist);
}
} else {
$r->print(&header('Course/Community Requests').$crumb.
@@ -313,7 +324,7 @@ sub handler {
&print_main_menu($r,\%can_request,\%states,$dom,$jscript,$loaditems,$crumb,\%request_domains);
} else {
&request_administration($r,$action,$state,$page,\%states,$dom,$jscript,
- $loaditems,$crumb);
+ $loaditems,$crumb,'','','','',$showcredits);
}
} elsif ($action eq 'display') {
if ($warning ne '') {
@@ -324,7 +335,8 @@ sub handler {
&close_popup_form());
} else {
&request_administration($r,$action,$state,$page,\%states,$dom,$jscript,
- $loaditems,$crumb,'','','','','',$uname,$udom);
+ $loaditems,$crumb,'','','','',$showcredits,'','',
+ $uname,$udom);
}
} elsif ($action eq 'log') {
if ($state eq 'crstype') {
@@ -439,7 +451,7 @@ sub get_breadcrumbs {
$crumb = &Apache::lonhtmlcommon::breadcrumbs('Course/Community Requests','Course_Requests');
last;
} else {
- if (($$state eq 'process') || ($$state eq 'removal')) {
+ if (($$state eq 'process') || ($$state eq 'removal') || ($$state eq 'reqauthor')) {
&Apache::lonhtmlcommon::add_breadcrumb(
{ href => '/adm/requestcourse',
text => "$trail->{$states->{$action}[$i]}",
@@ -488,7 +500,8 @@ sub header {
}
sub form_elements {
- my ($dom) = @_;
+ my ($dom,$showcredits) = @_;
+ my $instcredits;
my %elements =
(
new => {
@@ -596,6 +609,15 @@ sub form_elements {
$extras{'loncapasec_'.$i} = 'text',
}
}
+ (my $outcome,my $desc,$instcredits) =
+ &Apache::lonnet::auto_validate_instcode(undef,$dom,$instcode);
+ if ($showcredits && $instcredits eq '') {
+ $extras{'coursecredits'} = 'text';
+ }
+ } elsif ($env{'form.crstype'} eq 'unofficial') {
+ if ($showcredits) {
+ $extras{'coursecredits'} = 'text';
+ }
}
my $crosslisttotal = $env{'form.crosslisttotal'};
if ($env{'form.addcrosslist'}) {
@@ -641,7 +663,7 @@ sub form_elements {
}
my %personnelhash = (%{$elements{'new'}{'personnel'}},%people);
%{$elements{'new'}{'personnel'}} = %personnelhash;
- return %elements;
+ return (\%elements,$instcredits);;
}
sub onload_action {
@@ -848,8 +870,8 @@ END
sub request_administration {
my ($r,$action,$state,$page,$states,$dom,$jscript,$loaditems,$crumb,
- $newinstcode,$codechk,$checkedcode,$description,$invalidcrosslist,
- $uname,$udom) = @_;
+ $newinstcode,$codechk,$checkedcode,$description,$showcredits,
+ $instcredits,$invalidcrosslist,$uname,$udom) = @_;
my $js;
if (($action eq 'new') || (($action eq 'view') && ($state eq 'pick_request'))) {
$js = < ');
if ($storeresult eq 'ok') {
- $r->print(''.
- &mt('Modify this request').''.(' 'x4));
+ $r->print(' '.
+ &mt('Modify this request').''.(' 'x4).
+ ''.&mt('Make another request').' '.
+ &mt('Although assessment items can be created directly inside a course, such items only use part of the assessment capabilities of LON-CAPA.').
+ ' '.&mt('Request authoring space access now?').
+ ' '.
+ ''.
+ (' 'x2).
+ ''.
+ ' '.&mt('Make another request').''.$title.'
'.$title.'
'.$header.'
'.
&print_review($dom,\@codetitles,\%cat_titles,\%cat_order,
- \@code_order,$uname,$udom)."\n".''.
+ \@code_order,$uname,$udom,'','',$instcredits)."\n".
+ ''.
&close_popup_form());
}
$r->print(&Apache::loncommon::end_page());
@@ -1240,7 +1266,7 @@ sub get_instcode {
sub print_request_form {
my ($r,$action,$state,$page,$states,$dom,$newinstcode,$codechk,$checkedcode,
- $description,$invalidcrosslist) = @_;
+ $description,$showcredits,$instcredits,$invalidcrosslist) = @_;
my $formname = 'requestcrs';
my ($next,$prev,$message,$output,$codepicker,$crstype);
$prev = $states->{$action}[$page-1];
@@ -1313,7 +1339,7 @@ sub print_request_form {
}
$r->print(&print_enrollment_menu($formname,$instcode,$dom,\@codetitles,
\%cat_titles,\%cat_order,\@code_order,
- $invalidcrosslist));
+ $showcredits,$instcredits,$invalidcrosslist));
} elsif ($state eq 'personnel') {
$r->print(&print_personnel_menu($dom,$formname,$crstype,$invalidcrosslist));
} elsif ($state eq 'review') {
@@ -1429,7 +1455,7 @@ sub print_request_form {
} else {
$r->print(''.&mt('Review course request details before submission').'
');
}
- $r->print(&print_review($dom,\@codetitles,\%cat_titles,\%cat_order,\@code_order,'','',\@disallowed,\%disallowmsg).
+ $r->print(&print_review($dom,\@codetitles,\%cat_titles,\%cat_order,\@code_order,'','',\@disallowed,\%disallowmsg,$instcredits).
'');
if ($crstype eq 'community') {
$navtxt{'next'} = &mt('Submit community request');
@@ -1442,19 +1468,77 @@ sub print_request_form {
\%cat_order,\@code_order);
}
my ($storeresult,$result) = &print_request_outcome($dom,\@codetitles,
- \@code_order);
+ \@code_order,$instcredits);
$r->print($result);
if (($storeresult eq 'ok') || ($storeresult eq 'created')) {
- $r->print(''.&mt('Access to authoring space').'
'.
+ '
'.
+ &mt('By contrast, items created in authoring space, then imported into a course, can use all of the features of the assessment engine.').'
');
+ } elsif ($storeresult eq 'created') {
+ $r->print('
'.$links[0].'
'); } } - my @excluded = &get_excluded_elements($dom,$states,$action,$state); + my @excluded = &get_excluded_elements($dom,$states,$action,$state,$showcredits); if ($state eq 'personnel') { push(@excluded,'persontotal'); } @@ -1481,15 +1565,18 @@ sub print_request_form { $count ++; } $env{'form.persontotal'} = $count; - } } if ($state eq 'enrollment') { push(@excluded,('sectotal','crosslisttotal')); } - $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).''); - &display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},$next, - $navtxt{'next'},$state); + if (($state eq 'process') || ($state eq 'reqauthor')) { + $r->print(''); + } else { + $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).''); + &display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},$next, + $navtxt{'next'},$state); + } return; } @@ -1548,18 +1635,19 @@ sub check_newuser_rules { } sub get_excluded_elements { - my ($dom,$states,$action,$state) = @_; + my ($dom,$states,$action,$state,$showcredits) = @_; my @excluded = ('counter'); - my %elements = &form_elements($dom); + my ($elements,$instcredits) = &form_elements($dom,$showcredits); if (ref($states) eq 'HASH') { if (ref($states->{$action}) eq 'ARRAY') { my @items = @{$states->{$action}}; my $numitems = scalar(@items); if ($numitems) { for (my $i=$numitems-1; $i>=0; $i--) { - if (ref($elements{$action}) eq 'HASH') { - if (ref($elements{$action}{$items[$i]}) eq 'HASH') { - foreach my $key (keys(%{$elements{$action}{$items[$i]}})) { + if ((ref($elements) eq 'HASH') && + (ref($elements->{$action}) eq 'HASH')) { + if (ref($elements->{$action}{$items[$i]}) eq 'HASH') { + foreach my $key (keys(%{$elements->{$action}{$items[$i]}})) { push(@excluded,$key); } } @@ -1577,8 +1665,9 @@ sub get_excluded_elements { sub print_enrollment_menu { my ($formname,$instcode,$dom,$codetitles,$cat_titles,$cat_order,$code_order, - $invalidcrosslist) =@_; - my ($sections,$autoenroll,$access_dates,$output,$hasauto); + $showcredits,$instcredits,$invalidcrosslist) =@_; + my ($sections,$autoenroll,$access_dates,$output,$hasauto,$hascredits, + $creditsrow,$domdefcredits); my $starttime = time; my $endtime = time+(6*30*24*60*60); # 6 months from now, approx @@ -1590,6 +1679,12 @@ sub print_enrollment_menu { 'start' => 'Start auto-enrollment', 'end' => 'End auto-enrollment', ); + if ($showcredits) { + unless ($env{'form.crstype'} eq 'community') { + my %domdefs = &Apache::lonnet::get_domain_defaults($dom); + $domdefcredits = $domdefs{$env{'form.crstype'}.'credits'}; + } + } if ($env{'form.crstype'} eq 'official') { if (&Apache::lonnet::auto_run('',$dom)) { $output = &show_invalid_crosslists($invalidcrosslist); @@ -1664,12 +1759,29 @@ sub print_enrollment_menu { &mt('No').''. &Apache::lonhtmlcommon::row_closure(1). &date_setting_table($starttime,$endtime,$formname,'enroll', - $hasauto,%enrolltitles); + $hasauto,undef,%enrolltitles); + if ($showcredits) { + if ($instcredits) { + $creditsrow = &mt('[quant,_1,credit]',$instcredits); + } else { + $creditsrow = ''. + ''; + } + $hascredits = 1; + } + } + } elsif ($env{'form.crstype'} eq 'unofficial') { + if ($showcredits) { + $creditsrow = ''. + ''; + $hascredits = 1; } } my $access_dates = &date_setting_table($starttime,$endtime,$formname,'access',$hasauto, - %accesstitles); + $hascredits,%accesstitles); $output .= &Apache::lonhtmlcommon::start_pick_box(); if ($sections) { $output .= $sections; @@ -1688,7 +1800,15 @@ sub print_enrollment_menu { $output .= &Apache::lonhtmlcommon::row_headline('Access'). '