--- loncom/interface/lonrequestcourse.pm	2012/08/14 15:45:06	1.64
+++ loncom/interface/lonrequestcourse.pm	2012/08/15 14:37:13	1.65
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Request a course
 #
-# $Id: lonrequestcourse.pm,v 1.64 2012/08/14 15:45:06 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.65 2012/08/15 14:37:13 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -147,6 +147,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 +168,7 @@ sub handler {
                  personnel     => 'Personnel',
                  review        => 'Review',
                  process       => 'Result',
+                 reqauthor     => 'Authoring Space Result',
                  pick_request  => 'Display Summary',
                  details       => 'Request Details',
                  cancel        => 'Cancel Request',
@@ -439,7 +446,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]}",
@@ -1444,13 +1451,71 @@ sub print_request_form {
                                                            \@code_order);
         $r->print($result);
         if (($storeresult eq 'ok') || ($storeresult eq 'created')) {
-            $r->print('<p>');
             if ($storeresult eq 'ok') {
-                $r->print('<a href="/adm/requestcourse?action=view&state=details&showdom='.$dom.'&cnum='. $env{'form.cnum'}.'">'.
-                          &mt('Modify this request').'</a>'.('&nbsp;'x4));
+                $r->print('<p><a href="/adm/requestcourse?action=view&state=details&showdom='.$dom.'&cnum='. $env{'form.cnum'}.'">'.
+                          &mt('Modify this request').'</a>'.('&nbsp;'x4).
+                          '<a href="/adm/requestcourse">'.&mt('Make another request').'</a></p>');
+            }
+            if (&Apache::loncoursequeueadmin::author_prompt()) {
+                $r->print('<h3>'.&mt('Access to authoring space').'</h3>'.
+                          '<p>'.
+                          &mt('Although assessment items can be created directly inside a course, such items only use part of the assessment capabilities of LON-CAPA.').
+                          '<br />'.
+                          &mt('By contrast, items created in authoring space, then imported into a course, can use all of the features of the assessment engine.').'</p>'.
+                          '<p>'.&mt('Request authoring space access now?').
+                          '<span class="LC_nobreak">&nbsp;'.
+                          '<label><input type="radio" name="requestauthor" value="1" />'.&mt('Yes').'</label>'.
+                          ('&nbsp;'x2).
+                          '<label><input type="radio" name="requestauthor" value="0" checked="checked"/>'.&mt('No').'</label>'.
+                          '</span></p>'.
+                          '<input type="submit" name="newauthor" value="'.&mt('Submit authoring request').'" />'.
+                          '<input type="hidden" name="state" value="reqauthor" />'.
+                          '<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'.
+                          '<input type="hidden" name="cnum" value="'.$env{'form.cnum'}.'" />'.
+                          '<input type="hidden" name="showdom" value="'.$env{'form.showdom'}.'" />'.
+                          '<input type="hidden" name="crstype" value="'.$env{'form.crstype'}.'" />'.
+                          '<input type="hidden" name="disposition" value="'.$storeresult.'" />'.
+                          '<br />');
+            } elsif ($storeresult eq 'created') {
+                $r->print('<p><a href="/adm/requestcourse">'.&mt('Make another request').'</a></p>');
+            }
+        }
+    } elsif ($state eq 'reqauthor') {
+        my ($result,@links); 
+        if ($env{'form.requestauthor'}) {
+            $r->print(&Apache::loncoursequeueadmin::process_reqauthor(\$result));
+            if ($result eq 'created') {
+                my $role = 'au';
+                my $spec = "$role./$env{'form.showdom'}/";
+                push(@links,&mt('Enter your authoring space with role: [_1]',
+                                '<a href="/adm/roles?selectrole=1&amp;'.$spec.'=1">'.
+                                &Apache::lonnet::plaintext($role).'</a>'));
+            }
+        }
+        if (($env{'form.disposition'} eq 'created') &&
+            ($env{'form.cnum'} =~ /^$match_courseid$/) &&
+            ($env{'form.showdom'} =~ /^$match_domain$/)) {
+            my ($spec,$area,$role,$type);
+            my $role = 'cc';
+            my $spec = "$role./$env{'form.showdom'}/$env{'form.cnum'}";
+            my $type = 'Course';
+            if ($env{'form.crstype'} eq 'community') {
+                $type = 'Community';
             }
-            $r->print('<a href="/adm/requestcourse">'.&mt('Make another request').'</a></p>');
-            return;
+            my $showrole = &Apache::lonnet::plaintext($role,$type);
+            unshift(@links,&mt('Enter new course with role: [_1]',
+                               '<a href="/adm/roles?selectrole=1&amp;'.$spec.'=1">'.$showrole.'</a>'));
+        }
+        if (@links > 1) {
+            $r->print(&mt('New roles will be listed on your [_1]Roles[_2] page.',
+                          '<a href="/adm/roles">','</a>').'&nbsp'.&mt('Choose a role:').
+                       '<ul>');
+            foreach my $link (@links) {
+                $r->print('<li>'.$link.'</li>');
+            }
+            $r->print('</ul>');
+        } elsif (@links == 1) {
+            $r->print('<p>'.$links[0].'</p>');
         }
     }
     my @excluded = &get_excluded_elements($dom,$states,$action,$state);
@@ -1480,15 +1545,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).'</form>');
-    &display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},$next,
-                        $navtxt{'next'},$state);
+    if (($state eq 'process') || ($state eq 'reqauthor')) {
+        $r->print('</form>');
+    } else {
+        $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'</form>');
+        &display_navbuttons($r,$dom,$formname,$prev,$navtxt{'prev'},$next,
+                            $navtxt{'next'},$state);
+    }
     return;
 }