[LON-CAPA-cvs] cvs: loncom(GCI_3) /interface lonrequestcourse.pm

raeburn raeburn@source.lon-capa.org
Sun, 20 Dec 2009 01:58:48 -0000


This is a MIME encoded message

--raeburn1261274328
Content-Type: text/plain

raeburn		Sun Dec 20 01:58:48 2009 EDT

  Modified files:              (Branch: GCI_3)
    /loncom/interface	lonrequestcourse.pm 
  Log:
  - Customization for GCI_3.
    - New subroutine: &acquire_cc_role() to set requestor's role to CC in new course
      when request is processed.
    - Concept Test courses are cloned from Template course.
  
  
--raeburn1261274328
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20091220015848.txt"

Index: loncom/interface/lonrequestcourse.pm
diff -u loncom/interface/lonrequestcourse.pm:1.41.2.1 loncom/interface/lonrequestcourse.pm:1.41.2.2
--- loncom/interface/lonrequestcourse.pm:1.41.2.1	Tue Dec 15 13:36:16 2009
+++ loncom/interface/lonrequestcourse.pm	Sun Dec 20 01:58:48 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Request a course
 #
-# $Id: lonrequestcourse.pm,v 1.41.2.1 2009/12/15 13:36:16 raeburn Exp $
+# $Id: lonrequestcourse.pm,v 1.41.2.2 2009/12/20 01:58:48 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -627,6 +627,9 @@
         } else {
             $loaditems{'onload'} = 'javascript:setFormElements(document.requestcrs)';
         }
+        if (($state eq 'process') && ($env{'form.concepttest'} eq 'editmyown')) {
+            $loaditems{'onload'} = 'javascript:setInitialVisibility()';
+        }
     }
     return \%loaditems;
 }
@@ -893,6 +896,8 @@
             }
         } elsif ($state eq 'personnel') {
             $js .= "\n".&section_check_javascript()."\n".&personnel_lcsec_js();
+        } elsif (($state eq 'process') && ($env{'form.concepttest'} eq 'editmyown')) {
+            $js .= "\n".&Apache::londocsgci::builder_javascript()."\n";
         }
         my $title;
         if ($env{'form.crstype'} eq 'community') {
@@ -1437,7 +1442,9 @@
                 $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('<a href="/adm/requestcourse">'.&mt('Make another request').'</a></p>');
+            unless ($env{'form.concepttest'}) {
+                $r->print('<a href="/adm/requestcourse">'.&mt('Make another request').'</a></p>');
+            }
             return;
         }
     }
@@ -2888,6 +2895,16 @@
                     accessend      => $accessend,
                     personnel      => \%personnel,
                   };
+    if ($dom eq 'gcitest') {
+        if ($env{'form.concepttest'} eq 'editmyown') {
+            $details->{'firstres'} = 'nav'; 
+        } else {
+            $details->{'firstres'} = 'blank';
+        }
+        $details->{'clonedom'} = 'gci';
+        $details->{'clonecrs'} = '8v226795a882b4bcagcil1';
+        $details->{'datemode'} = 'delete';
+    }
     my (@inststatuses,$storeresult,$creationresult);
     my $val = &get_processtype($dom,$crstype,\@inststatuses,\%domconfig);
     if ($val eq '') {
@@ -2973,18 +2990,6 @@
             if ($result eq 'created') {
                 $disposition = 'created';
                 $reqstatus = 'created';
-                my $parmoutput;
-                if ($dom eq 'gcitest') {
-                    my $caller = 'requestcrs';
-                    if ($env{'form.concepttest'} eq 'defchosen') {
-                        &Apache::londocsgci::setdefaults();
-                        &Apache::londocsgci::evaluate($caller);
-                        &Apache::londocsgci::store($r,$caller,$dom,$cnum);
-                    }
-                    my ($furl,$ferr)= &Apache::lonuserstate::readmap($dom.'/'.$cnum);
-                    my %parmresult = 
-                        &store_crsparms($dom,$cnum,$now,$accessstart,$accessend);
-                }
                 my $role_result = &update_requestors_roles($dom,$cnum,$crstype,$details,
                                                            \%longroles);
                 if ($crstype eq 'community') {
@@ -2992,7 +2997,41 @@
                 } else {
                     $output = '<p>'.&mt('Your course request has been processed and the course has been created.');
                 }
-                $output .= '<br />'.$role_result.'</p>';
+                if ($dom eq 'gcitest') {
+                    my $caller = 'requestcrs';
+                    &acquire_cc_role($dom,$cnum,'cc./'.$dom.'/'.$cnum);
+                    my %parmresult =
+                        &store_crsparms($dom,$cnum,$now,$accessstart,$accessend);
+                    &Apache::londocsgci::setdefaults();
+                    if ($env{'form.concepttest'} eq 'defchosen') {
+                        $output .= '<br />';
+                        my $error = &Apache::londocsgci::store($caller,$dom,$cnum);
+                        if ($error) {
+                            $output .= '<span class="LC_error">'.
+                                       &mt('An error occurred saving an auto-generated concept test: [_1].',$error).
+                                       '</span>';
+                        } else {
+                            &Apache::lonuserstate::readmap($dom.'/'.$cnum);
+                            $output .= &mt('A concept test has also been generated.');
+                        }
+                        $output .= '</p>'.
+    '<p>'.&mt('If you have a text file available containing student e-mail addresses and initial passwords, you may upload it now.').'<br />'.
+    &mt('You may also enroll students at a later date by visiting the [_1]"Menu"[_2] page and choosing: [_1]"Manage Enrollment"[_2].','<i>','</i>').'</p>'.
+    '</form><form name="studentform" method="post" enctype="multipart/form-data" '.
+    ' action="/adm/createuser">'."\n";
+                        $r->print($output); 
+                        &Apache::lonuserutils::print_first_users_upload_form($r,'course');
+                        $r->print('</form>');
+                        $output = '';
+                    } else {
+                        $output .= '</form><br />'.&mt('The next step is to chose which questions are to be included in the Concept Test.').'</p>';
+                        $r->print($output);
+                        &Apache::londocsgci::editor($r,'requestcrs',$dom,$cnum);
+                        $output = '';
+                    }
+                } else {
+                    $output .= '<br />'.$role_result.'</p>';
+                }
                 $creationresult = 'created';
             } else {
                 $output = '<span class="LC_error">';
@@ -3218,6 +3257,43 @@
     return $output;
 }
 
+sub acquire_cc_role {
+    my ($cdom,$cnum,$trolecode,$csec) = @_;
+    my %coursegroups = &Apache::lonnet::get_active_groups(
+                        $env{'user.domain'},$env{'user.name'},$cdom, $cnum);
+    my $cgrps = join(':',keys(%coursegroups));
+    if ($env{'environment.recentroles'}) {
+        my %frozen_roles =
+            &Apache::lonhtmlcommon::get_recent_frozen('roles',$env{'environment.recentrolesn'});
+        &Apache::lonhtmlcommon::store_recent('roles',$trolecode,' ',
+                                            $frozen_roles{$trolecode});
+    }
+
+    &Apache::lonnet::appenv({"request.course.id"   => '',
+                             "request.course.fn"   => '',
+                             "request.course.uri"  => '',
+                             "request.course.sec"  => '',
+                             "request.role"        => 'cm',
+                             "request.role.adv"    => $env{'user.adv'},
+                             "request.role.domain" => $env{'user.domain'}});
+
+    &Apache::lonnet::log($env{'user.domain'},
+                         $env{'user.name'},
+                         $env{'user.home'},
+                         "Role ".$trolecode);
+
+    &Apache::lonnet::appenv(
+                            {'request.role'        => $trolecode,
+                             'request.role.domain' => $cdom,
+                             'request.course.sec'  => $csec,
+                             'request.course.groups' => $cgrps});
+    my ($furl,$ferr) = &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
+    my $tadv;
+    if (&Apache::lonnet::allowed('adv') eq 'F') { $tadv=1; }
+    &Apache::lonnet::appenv({'request.role.adv'=>$tadv});
+    return;
+}
+
 sub store_crsparms {
     my ($cdom,$cnum,$now,$accessstart,$accessend) = @_;
     my $topsymb = '___0___uploaded/'.$cdom.'/'.$cnum.'/default.sequence';

--raeburn1261274328--