--- loncom/interface/lonrequestcourse.pm 2013/07/22 18:06:51 1.68 +++ loncom/interface/lonrequestcourse.pm 2013/12/27 14:34:52 1.72 @@ -1,7 +1,7 @@ # The LearningOnline Network # Request a course # -# $Id: lonrequestcourse.pm,v 1.68 2013/07/22 18:06:51 bisitz Exp $ +# $Id: lonrequestcourse.pm,v 1.72 2013/12/27 14:34:52 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -134,12 +134,42 @@ sub handler { my $action = $env{'form.action'}; my $state = $env{'form.state'}; my (%states,%stored); - my ($jscript,$uname,$udom,$result,$warning,$showcredits,$instcredits); + my ($jscript,$uname,$udom,$result,$warning,$showcredits,$instcredits,%can_request, + %request_domains,@incdoms); my %domdefs = &Apache::lonnet::get_domain_defaults($dom); - if ($domdefs{'officialcredits'} || $domdefs{'unofficialcredits'}) { + if ($domdefs{'officialcredits'} || $domdefs{'unofficialcredits'} || $domdefs{'textbookcredits'}) { $showcredits = 1; } + my $canreq = + &Apache::lonnet::check_can_request($dom,\%can_request,\%request_domains); + + foreach my $item (keys(%request_domains)) { + if (ref($request_domains{$item}) eq 'ARRAY') { + foreach my $possdom (@{$request_domains{$item}}) { + unless(grep(/^\Q$possdom\E$/,@incdoms)) { + push(@incdoms,$possdom); + } + } + } + } + + if ($canreq) { + if ((scalar(keys(%can_request)) == 1) && ($can_request{'textbook'})) { + my %domconfig = &Apache::lonnet::get_dom('configuration',['requestcourses'],$dom); + if ($action eq 'log') { + &Apache::lonhtmlcommon::add_breadcrumb({text=>'Course Request'}); + my $crumb = &Apache::lonhtmlcommon::breadcrumbs('Course Requests','Course_Requests'); + &print_request_logs($r,$dom,undef,undef,$crumb); + } elsif ($action eq 'process') { + &process_textbook_request($r,$dom,$action,\%domdefs,\%domconfig); + } else { + &print_textbook_form($r,$dom,\@incdoms,\%domdefs,$domconfig{'requestcourses'}); + } + return OK; + } + } + $states{'display'} = ['details']; $states{'view'} = ['pick_request','details','cancel','removal']; $states{'log'} = ['display']; @@ -299,14 +329,11 @@ sub handler { my $loaditems = &onload_action($action,$state); - 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,\%request_domains); + $crumb,\@incdoms); } else { &request_administration($r,$action,$state,$page,\%states,$dom, $jscript,$loaditems,$crumb,$newinstcode, @@ -321,7 +348,7 @@ sub handler { } } elsif ($action eq 'view') { if ($state eq 'crstype') { - &print_main_menu($r,\%can_request,\%states,$dom,$jscript,$loaditems,$crumb,\%request_domains); + &print_main_menu($r,\%can_request,\%states,$dom,$jscript,$loaditems,$crumb,\@incdoms); } else { &request_administration($r,$action,$state,$page,\%states,$dom,$jscript, $loaditems,$crumb,'','','','',$showcredits); @@ -340,7 +367,7 @@ sub handler { } } elsif ($action eq 'log') { if ($state eq 'crstype') { - &print_main_menu($r,\%can_request,\%states,$dom,$jscript,'',$crumb,\%request_domains); + &print_main_menu($r,\%can_request,\%states,$dom,$jscript,'',$crumb,\@incdoms); } else { $jscript .= < '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.', + community => 'You are not permitted to request creation of a community in this domain.', + textbook => 'You are not permitted to request creation of a textbook course in this domain', all => 'You must choose a specific course type when making a new course request.', allt => '"All types" is not allowed.', ); @@ -756,10 +785,17 @@ END return false; } } else { - if (actionchoice == 'new') { - alert('$lt{'all'}'+'\\n'+'$lt{'allt'}'); - return false; - } + if (crschoice == 'textbook') { + if (textbook != 1) { + alert("$lt{'community'}"); + return false; + } + } else { + if (actionchoice == 'new') { + alert('$lt{'all'}'+'\\n'+'$lt{'allt'}'); + return false; + } + } } } } @@ -768,7 +804,7 @@ END END my ($pagetitle,$pageinfo,$domaintitle); if (ref($can_request) eq 'HASH') { - if (($can_request->{'official'}) || ($can_request->{'unofficial'})) { + if (($can_request->{'official'}) || ($can_request->{'unofficial'}) || $can_request->{'textbook'}) { if ($can_request->{'community'}) { $pagetitle = 'Course/Community Requests'; $pageinfo = &mt('Request creation of a new course or community, or review your pending requests.'); @@ -788,31 +824,19 @@ END $domaintitle = &mt('Course/Community Domain'); } } - my @incdoms; - if (ref($request_domains) eq 'HASH') { - foreach my $item (keys(%{$request_domains})) { - if (ref($request_domains->{$item}) eq 'ARRAY') { - foreach my $possdom (@{$request_domains->{$item}}) { - unless(grep(/^\Q$possdom\E$/,@incdoms)) { - push(@incdoms,$possdom); - } - } - } - } - } $r->print(&header($pagetitle,$js.$jscript,$loaditems).$crumb. '

'.$pageinfo.'

'. '
'. &Apache::lonhtmlcommon::start_pick_box(). &Apache::lonhtmlcommon::row_title($domaintitle). '
'. - &Apache::loncommon::select_dom_form($dom,'showdom','',1,$onchange,\@incdoms)); + &Apache::loncommon::select_dom_form($dom,'showdom','',1,$onchange,$incdoms)); if (!$onchange) { $r->print(' '); } unless ((ref($can_request) eq 'HASH') && (keys(%{$can_request}) > 0)) { - $r->print(&Apache::lonhtmlcommon::row_closure(1)."\n". + $r->print('
'.&Apache::lonhtmlcommon::row_closure(1)."\n". &Apache::lonhtmlcommon::end_pick_box().'
'."\n". &Apache::loncommon::end_page()); return; @@ -945,6 +969,8 @@ END $title = &mt('Pending requests for official courses'); } elsif ($env{'form.crstype'} eq 'unofficial') { $title = &mt('Pending requests for unofficial courses'); + } elsif ($env{'form.crstype'} eq 'textbook') { + $title = &mt('Pending requests for textbook courses'); } else { $title = &mt('Pending course/community requests'); } @@ -1477,25 +1503,8 @@ sub print_request_form { ''.&mt('Make another request').'

'); } if (&Apache::loncoursequeueadmin::author_prompt()) { - $r->print('

'.&mt('Access to authoring space').'

'. - '

'. - &mt('Although assessment items can be created directly inside a course, such items only use part of the assessment capabilities of LON-CAPA.'). - '
'. - &mt('By contrast, items created in authoring space, then imported into a course, can use all of the features of the assessment engine.').'

'. - '

'.&mt('Request authoring space access now?'). - ' '. - ''. - (' 'x2). - ''. - '

'. - ''. - ''. - ''. - ''. - ''. - ''. - ''. - '
'); + &print_author_prompt($r,$env{'form.action'},$env{'form.cnum'},$env{'form.showdom'}, + $env{'form.crstype'},$storeresult); } elsif ($storeresult eq 'created') { $r->print('

'.&mt('Make another request').'

'); } @@ -1580,6 +1589,29 @@ sub print_request_form { return; } +sub print_author_prompt { + my ($r,$action,$cnum,$showdom,$crstype,$storeresult) = @_; + $r->print('

'.&mt('Access to authoring space').'

'. + '

'. + &mt('Although assessment items can be created directly inside a course, such items only use part of the assessment capabilities of LON-CAPA.'). + '
'. + &mt('By contrast, items created in authoring space, then imported into a course, can use all of the features of the assessment engine.').'

'. + '

'.&mt('Request authoring space access now?'). + ' '. + ''. + (' 'x2). + ''. + '

'. + ''. + ''. + ''. + ''. + ''. + ''. + ''. + '
'); +} + sub get_usertype { my ($persondom,$personname,$curr_rules,$got_rules) = @_; my ($rules,$ruleorder) = @@ -1771,7 +1803,7 @@ sub print_enrollment_menu { $hascredits = 1; } } - } elsif ($env{'form.crstype'} eq 'unofficial') { + } elsif (($env{'form.crstype'} eq 'unofficial') || ($env{'form.crstype'} eq 'textbook')) { if ($showcredits) { $creditsrow = ''. ' 'Requestor is automatically assigned Course Coordinator role.', ); $lt{'unofficial'} = $lt{'official'}; + $lt{'textbook'} = $lt{'textbook'}; $output .= &Apache::lonhtmlcommon::row_headline(). '

'.&Apache::loncommon::help_open_topic('Course_Request_Personnel').' '.$lt{$crstype}.' '.&mt('Include other personnel?').'

'; } @@ -2514,7 +2547,7 @@ sub reqstatus_names { rejected => 'Request rejected', cancelled => 'Request cancelled', ); - if (($crstype eq 'official') || ($crstype eq 'unofficial')) { + if (($crstype eq 'official') || ($crstype eq 'unofficial') || ($crstype eq 'textbook')) { $statusnames{'created'} = &mt('Course created'); } elsif ($crstype eq 'community') { $statusnames{'created'} = &mt('Community created'); @@ -2731,7 +2764,7 @@ sub print_review { $section_values .= $xlistinfo; } $section_values .= ''; - } elsif ($env{'form.crstype'} eq 'unofficial') { + } elsif (($env{'form.crstype'} eq 'unofficial') || ($env{'form.crstype'} eq 'textbook')) { $inst_headers .= ''.&mt('Credits').''; $inst_values .= ''.$env{'form.coursecredits'}.''; } @@ -2910,6 +2943,7 @@ sub courseinfo_form { community => 'You must provide a (brief) community description.' ); $lt{'unofficial'} = $lt{'official'}; + $lt{'textbook'} = $lt{'official'}; my $js_validate = <<"ENDJS";