[LON-CAPA-cvs] cvs: loncom /auth lonroles.pm /interface lonpickcourse.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Thu, 15 Dec 2005 23:31:32 -0000


raeburn		Thu Dec 15 18:31:32 2005 EDT

  Modified files:              
    /loncom/auth	lonroles.pm 
    /loncom/interface	lonpickcourse.pm 
  Log:
  DC's "Select Course" link to become a CC in a course in the domain now works for regular link in "Domain" as well as link in "Recent Roles".
  
  
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.137 loncom/auth/lonroles.pm:1.138
--- loncom/auth/lonroles.pm:1.137	Mon Nov 21 14:08:24 2005
+++ loncom/auth/lonroles.pm	Thu Dec 15 18:31:22 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.137 2005/11/21 19:08:24 raeburn Exp $
+# $Id: lonroles.pm,v 1.138 2005/12/15 23:31:22 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -636,7 +636,7 @@
 	    if (defined($roletext{'user.role.'.$_})) {
 		$output.=$roletext{'user.role.'.$_};
                 if ($_ =~ m-dc\./(\w+)/- && $dcroles{$1}) {
-		    $output .= &allcourses_row($1);
+		    $output .= &allcourses_row($1,'recent');
                 }
 	    } elsif ($numdc > 0) {
                 unless ($_ =~/^error\:/) {
@@ -664,7 +664,7 @@
 		$output.=$roletext{$sortrole{$which}};
                 if ($sortrole{$which} =~ m-dc\./(\w+)/-) {
                     if ($dcroles{$1}) {
-                        $output .= &allcourses_row($1);
+                        $output .= &allcourses_row($1,'');
                     }
                 }
 	    }
@@ -876,13 +876,13 @@
 }
 
 sub courselink {
-    my ($dcdom) = @_;
+    my ($dcdom,$rowtype) = @_;
     my $courseform=&Apache::loncommon::selectcourse_link
-                     ('rolechoice','dccourse_'.$dcdom,'dcdomain_'.$dcdom,'coursedesc_'.$dcdom,$dcdom);
-    my $hiddenitems = '<input type="hidden" name="dcdomain_'.$dcdom.'" value="'.$dcdom.'" />'.
-                      '<input type="hidden" name="origdom_'.$dcdom.'" value="'.$dcdom.'" />'.
-                      '<input type="hidden" name="dccourse_'.$dcdom.'" value="" />'.
-                      '<input type="hidden" name="coursedesc_'.$dcdom.'" value="" />';
+                     ('rolechoice','dccourse'.$rowtype.'_'.$dcdom,'dcdomain'.$rowtype.'_'.$dcdom,'coursedesc'.$rowtype.'_'.$dcdom,$dcdom);
+    my $hiddenitems = '<input type="hidden" name="dcdomain'.$rowtype.'_'.$dcdom.'" value="'.$dcdom.'" />'.
+                      '<input type="hidden" name="origdom'.$rowtype.'_'.$dcdom.'" value="'.$dcdom.'" />'.
+                      '<input type="hidden" name="dccourse'.$rowtype.'_'.$dcdom.'" value="" />'.
+                      '<input type="hidden" name="coursedesc'.$rowtype.'_'.$dcdom.'" value="" />';
     return $courseform.$hiddenitems;
 }
 
@@ -923,34 +923,26 @@
 }
 
 sub processpick {
-    my $dcdom = shift;
     my $process_pick = <<"END";
 <script>
 function process_pick(dom) {
-    var numbutton = getIndex(dom)
-    var pickedCourse = opener.document.rolechoice.dccourse_$dcdom.value
-    var pickedDomain = opener.document.rolechoice.dcdomain_$dcdom.value
-    if (opener.document.rolechoice.dcdomain_$dcdom.value == opener.document.rolechoice.origdom_$dcdom.value) {
+    var pickedCourse=opener.document.rolechoice.$env{'form.cnumelement'}.value;
+    var pickedDomain=opener.document.rolechoice.$env{'form.cdomelement'}.value;
+    var okDomain = 0;
+
+    if (pickedDomain == dom) {
         if (pickedCourse != '') {
-            if (numbutton != -1) {
-                var courseTarget = "cc./"+pickedDomain+"/"+pickedCourse
-                opener.document.rolechoice.elements[numbutton].name = courseTarget
-                opener.document.rolechoice.submit()
-            }
+            var courseTarget = "cc./"+pickedDomain+"/"+pickedCourse
+            opener.document.title='Role selected. Please stand by.';
+            opener.status='Role selected. Please stand by.';
+	    opener.document.rolechoice.newrole.value=courseTarget
+            opener.document.rolechoice.submit()
         }
+    } else {
+        alert("You may only use this screen to select courses in the current domain: "+dom+"\\nPlease return to the roles page window and click the 'Select Course' link for domain: "+pickedDomain+",\\n if you are a Domain Coordinator in that domain, and wish to become a Course Coordinator in a course in the domain");
     }
 }
  
-function getIndex(dom) {
-    var callername = 'ccpick_'+dom
-    for (var i=0;i<opener.document.rolechoice.elements.length;i++) {
-        var elemname = opener.document.rolechoice.elements[i].name
-        if (elemname == callername) {
-            return i;
-        }
-    }
-    return -1;
-}
 </script>
 END
     return $process_pick;
@@ -987,12 +979,10 @@
 }
 
 sub allcourses_row {
-    my $dcdom = shift;
+    my ($dcdom,$rowtype) = @_;
     my $ccrole = Apache::lonnet::plaintext('cc');
-    my $selectlink = &courselink($dcdom);
+    my $selectlink = &courselink($dcdom,$rowtype);
     my $output = '<tr bgcolor="#77FF77">'.
-	'<input type="hidden" name="ccpick_'.$dcdom.'" />'.
-	'<input type="hidden" name="pick_'.$dcdom.'" value="1" />'.
 	'<td colspan="5">'.
 	'<font color="#002200">'.$ccrole.'</font>'.
 	' <b>'.$selectlink.'</b>'.
Index: loncom/interface/lonpickcourse.pm
diff -u loncom/interface/lonpickcourse.pm:1.35 loncom/interface/lonpickcourse.pm:1.36
--- loncom/interface/lonpickcourse.pm:1.35	Tue Nov 15 15:46:40 2005
+++ loncom/interface/lonpickcourse.pm	Thu Dec 15 18:31:32 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Pick a course
 #
-# $Id: lonpickcourse.pm,v 1.35 2005/11/15 20:46:40 raeburn Exp $
+# $Id: lonpickcourse.pm,v 1.36 2005/12/15 23:31:32 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -149,7 +149,7 @@
     my $roledom = $env{'form.roleelement'};
     if ($roledom) {
         $roleelement = '<input type="hidden" name="roleelement" value="'.$roledom.'" />';
-        $submitopener = &Apache::lonroles::processpick($roledom);
+        $submitopener = &Apache::lonroles::processpick();
         $autosubmit = 'process_pick("'.$roledom.'")';
     }
     $r->print(<<ENDSCRIPT);
@@ -329,8 +329,11 @@
         $r->print('<input type="hidden" name="form" value="'.$env{'form.form'}.'" />'."\n".
                    '<input type="hidden" name="pickedcourse" value="" />'."\n".
                    '<input type="hidden" name="cnumelement" value="'.$env{'form.cnumelement'}.'" />'."\n".
-                   '<input type="hidden" name="cdomelement" value="'.$env{'form.cdomelement'}.'" />'."\n".
-                   '</form>');
+                   '<input type="hidden" name="cdomelement" value="'.$env{'form.cdomelement'}.'" />'."\n");
+        if ((exists($env{'form.roleelement'})) && ($env{'form.form'} eq 'rolechoice')) {
+           $r->print('<input type="hidden" name="roleelement" value="'.$env{'form.roleelement'}.'" />'."\n");
+        }
+        $r->print("</form>\n");
     }
     $r->print('</body></html>');
     return OK;