--- loncom/interface/lonrequestcourse.pm 2009/11/04 17:42:17 1.39 +++ 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.39 2009/11/04 17:42:17 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 # @@ -128,13 +128,21 @@ sub handler { if ($r->header_only) { return OK; } - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['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); @@ -143,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'); } } @@ -157,18 +176,26 @@ 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'; @@ -192,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')) { @@ -260,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(); + } } } @@ -270,7 +314,7 @@ sub handler { $jscript .= "\n".&Apache::loncommon::userbrowser_javascript(); } - my $loaditems = &onload_action($action,$state); + my $loaditems = &onload_action($action,$state,$dom); my (%can_request,%request_domains); my $canreq = @@ -285,11 +329,15 @@ sub handler { $jscript,$loaditems,$crumb,$newinstcode, $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('Deployment of a Concept Test requires completion of the following three steps:').'
'.&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.").'
'); @@ -1307,9 +1535,13 @@ sub print_request_form { $r->print(''. &mt('Modify this request').''.(' 'x4)); } - $r->print(''.&mt('Make another request').'
'); + unless ($env{'form.concepttest'}) { + $r->print(''.&mt('Make another request').''); + } return; } + } elsif ($state eq 'uploadroster') { + &roster_upload_form($r,$output,$formname); } my @excluded = &get_excluded_elements($dom,$states,$action,$state); if ($state eq 'personnel') { @@ -1344,12 +1576,39 @@ sub print_request_form { if ($state eq 'enrollment') { push(@excluded,'crosslisttotal'); } - $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).''); - &display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},$next, - $navtxt{'next'},$state); + if ($state eq 'done') { + $r->print(&done_display()); + } else { + $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded)); + &display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},$next, + $navtxt{'next'},$state); + } + $r->print(''); return; } +sub done_display { + return ''.&mt('The following management tools are available via the "[_1]Manage Tests[_2]" tab, or from the toolbar on the [_3]Concept Test Contents[_4] page.[_5]',
+ '','','','','
').
+ '
'.&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".').'
'; + &Apache::lonhtmlcommon::end_pick_box().''.&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".').'
'; + } return $output; } @@ -1750,7 +2045,7 @@ sub current_lc_sections { } sub print_request_status { - my ($dom) = @_; + my ($dom,$action,$state) = @_; my %statusinfo = &Apache::lonnet::dump('courserequests',$env{'user.domain'}, $env{'user.name'},'^status:'.$dom); my ($output,$formname,%queue_by_date); @@ -1793,17 +2088,25 @@ sub print_request_status { } $formname = 'requestcrs'; my @sortedtimes = sort {$a <=> $b} (keys(%queue_by_date)); - $output = ''."\n". + $output = ''."\n". - ''."\n". + ''."\n". ''."\n". ''."\n". ''."\n"; if (@sortedtimes > 0) { + my $desctitle; + if ($env{'form.crstype'} eq 'any') { + $desctitle = &mt('Course/Community Description') + } elsif ($env{'form.crstype'} eq 'community') { + $desctitle = &mt('Community Description') + } else { + $desctitle = &mt('Course Description'); + } $output .= &Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_header_row(). ''.&mt('Your course request has been processed and the course has been created.').
- '
'.$role_result.'
'.&mt('Your community request has been processed and the community has been created.'); + } else { + $output = '
'.&mt('Your course request has been processed and the course has been created.');
+ }
+ if ($dom =~ /^\w+citest$/) {
+ my $caller = 'requestcrs';
+ my $timezone;
+ if (&Apache::lonlocal::gettimezone($env{'form.timezone'}) ne 'local') {
+ $timezone = $env{'form.timezone'};
+ } else {
+ $timezone = Apache::lonlocal::gettimezone();
+ }
+ &acquire_cc_role($dom,$cnum,'cc./'.$dom.'/'.$cnum);
+ my %parmresult =
+ &store_crsparms($dom,$cnum,$now,$accessstart,$accessend);
+ &Apache::londocsgci::setdefaults($dom);
+ my %crsenvhash = (
+ suppress_tries => 'yes',
+ timezone => $timezone,
+ );
+ my $putresult = &Apache::lonnet::put('environment',\%crsenvhash,$dom,$cnum);
+ if ($env{'form.concepttest'} eq 'cloning') {
+ &Apache::lonuserstate::readmap($dom.'/'.$cnum);
+ if (($clonecrs) && ($clonedom =~ /^\w+citest$/)) {
+ my $cloneid = $clonedom.'/'.$clonecrs;
+ my %clonedesc = &Apache::lonnet::coursedescription($cloneid,{'one_time' => 1});
+ my $oldcdesc = $clonedesc{'description'};
+ $output .= '
'.&mt('A concept test has been copied from your existing test: [_1].',''.$oldcdesc.'').'
'.$logging[-1].'
'; + } + } + $output .= ''.&mt('Your course request has been updated').'
'. - ¬ification_information($disposition,$req_notifylist,$cnum,$now); + if ($crstype eq 'community') { + $output .= ''.&mt('Your community request has been updated').'
'; + } else { + $output .= ''.&mt('Your course request has been updated').'
'; + } + $output .= ¬ification_information($disposition,$req_notifylist,$cnum,$now); } if ($validationerror ne '') { $output .= ''.&mt('An error occurred validating your request with institutional data sources: [_1].',$validationerror).''; } } if ($creationresult ne '') { + if ($donedisplay) { + $r->print(''.&mt('If you have a text file available containing student e-mail addresses and initial passwords, you may upload it now.').'
'.
+ &mt('You may also enroll students later with the [_1]"Enrollment/Activity"[_2] utility in the management toolbar.','','').'