[LON-CAPA-cvs] cvs: modules /studip studip.pm

www www at source.lon-capa.org
Wed Jul 27 04:46:47 EDT 2011


www		Wed Jul 27 08:46:47 2011 EDT

  Modified files:              
    /modules/studip	studip.pm 
  Log:
  Verifying the parameters that are passed:
  * See if the user is indeed in the course
  * See if the user has indeed advanced privileges
  
  
Index: modules/studip/studip.pm
diff -u modules/studip/studip.pm:1.2 modules/studip/studip.pm:1.3
--- modules/studip/studip.pm:1.2	Thu Jul 21 20:01:20 2011
+++ modules/studip/studip.pm	Wed Jul 27 08:46:47 2011
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Landing point for incoming StudIP requests 
 #
-# $Id: studip.pm,v 1.2 2011/07/21 20:01:20 www Exp $
+# $Id: studip.pm,v 1.3 2011/07/27 08:46:47 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -70,9 +70,10 @@
         return OK;
     }
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['sess_id','domain','course','studip_course','studip_perm']);
+    &Apache::lonlocal::get_language_handle($r);
 
-    $r->print(&Apache::loncommon::start_page('StudIP Link'));
-    $r->print('<h3>'.&mt('StudIP Link').'</h3>');
+    $r->print(&Apache::loncommon::start_page('Stud.IP Link'));
+    $r->print('<h3>'.&mt('Stud.IP Link').'</h3>');
     $r->print('Sess_id: '.$env{'form.sess_id'}.'<br />');
     $r->print('Domain: '.$env{'form.domain'}.'<br />');
     $r->print('Course: '.$env{'form.course'}.'<br />');
@@ -83,10 +84,57 @@
     my ($commands,$error, at returned)=&send('get_session_username',$env{'form.sess_id'});
     
     $r->print('<hr />Talking to: '.$url.'<br />');
-    $r->print('Commands sent:<br /><textarea cols="80" rows="6">'.$commands.'</textarea><br />');
     $r->print('Error:'.$error.'<br />');
     $r->print('Responses: '.join(',', at returned).'<br />');
-
+    $r->print('User:'.$returned[1].'<br />');
+    my $user=$returned[1];
+    my $adv=($env{'form.studip_perm'} eq 'dozent');
+# Is the user in the class?
+    if ($user) {
+       $r->print("Found user!<br />");
+       my ($commands,$error, at returned)=&send('get_participants',$env{'form.studip_course'});
+       $r->print('Error:'.$error.'<br />');
+       $r->print('Responses: '.join(',', at returned).'<br />');
+       my $found=0;
+       for (my $i=1;$i<=$#returned;$i+=2) {
+           if ($returned[$i] eq $user) {
+              $found=1;
+              last;
+           }
+       }
+       if ($found) {
+          $r->print("Found user in course.<br />");
+# Check for advanced privileges
+          if ($adv) {
+             my ($commands,$error, at returned1)=&send('get_admins_for_seminar',$env{'form.studip_course'});
+             my ($commands,$error, at returned2)=&send('get_lecturers_for_seminar',$env{'form.studip_course'});
+             my @returned=(@returned1, at returned2);
+             $r->print('Responses: '.join(',', at returned).'<br />');
+             my $found=0;
+             for (my $i=1;$i<=$#returned;$i+=2) {
+                if ($returned[$i] eq $user) {
+                   $found=1;
+                   last;
+                }
+             }
+             if ($found) {
+                $r->print("User is administrator/lecturer.<br />");
+             } else {
+                $r->print("User is not really administrator/lecturer.<br />");
+                $adv=0;
+             }
+#
+# User is in the class and session should be entered. If $adv is true, the user can enter an advanced role in the course
+#
+          }
+       } else {
+          $r->print("<h1>".&mt("Sorry ...")."</h1>");
+          $r->print("<p>".&mt("You are not currently enrolled in the Stud.IP course that corresponds to your LON-CAPA course")."</p>");
+       } 
+    } else {
+       $r->print("<h1>".&mt("Sorry ...")."</h1>");
+       $r->print("<p>".&mt("This is not a valid session. You might have to reload the 'Learning modules' page in Stud.IP and press 'Start' again.")."</p>");
+    }
     $r->print(&Apache::loncommon::end_page());
     return OK;
 }




More information about the LON-CAPA-cvs mailing list