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

raeburn lon-capa-cvs@mail.lon-capa.org
Tue, 23 Nov 2004 07:29:24 -0000


raeburn		Tue Nov 23 02:29:24 2004 EDT

  Modified files:              
    /loncom/auth	lonroles.pm 
    /loncom/interface	loncommon.pm 
  Log:
  DC selection of CC role from all courses in a particular domain modified to work when user is DC in more than one domain. No longer duplicate javascript functions in allcourses_row().
  
  
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.111 loncom/auth/lonroles.pm:1.112
--- loncom/auth/lonroles.pm:1.111	Fri Nov 19 15:17:52 2004
+++ loncom/auth/lonroles.pm	Tue Nov 23 02:29:24 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.111 2004/11/19 20:17:52 albertel Exp $
+# $Id: lonroles.pm,v 1.112 2004/11/23 07:29:24 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -563,7 +563,6 @@
 		    $sortkey=$role.$twhere;
                 }
  
-                $roletext.='<tr bgcolor='.$tbg.'>';
                 $roletext.=&build_roletext($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$ttype,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver);
 		$roletext{$envkey}=$roletext;
 		if (!$sortkey) {$sortkey=$twhere."\0".$envkey;}
@@ -631,6 +630,8 @@
 
     if ($numdc > 0) {
         &display_recent_roles($r,\%roletext,\%recentroles);
+        $r->print(&coursepick_jscript());
+        $r->print(&Apache::loncommon::coursebrowser_javascript());
     }
     foreach my $type ('Construction Space','Course','Domain','System') {
 	my $output;
@@ -647,7 +648,7 @@
 	if ($output) {
 	    if ($doheaders > 0) {
 		$r->print("<tr bgcolor='#BBffBB'>".
-			  "<td align='center' colspan='7'>".&mt($type)."</td>");
+			  "<td align='center' colspan='7'>".&mt($type)."</td></tr>");
 	    }
 	    $r->print($output);	
 	}
@@ -768,7 +769,7 @@
 
 sub build_roletext {
     my ($trolecode,$tdom,$trest,$tstatus,$tryagain,$advanced,$tremark,$tbg,$tfont,$trole,$ttype,$twhere,$tpstart,$tpend,$nochoose,$button,$switchserver) = @_;
-    my $roletext='<tr bgcolor='.$tbg.'>';
+    my $roletext='<tr bgcolor="'.$tbg.'">';
     unless ($nochoose) {
         if (!$button) {
             if ($switchserver) {
@@ -843,26 +844,23 @@
 
 sub courselink {
     my ($dcdom) = @_;
-    my $cb_jscript = &Apache::loncommon::coursebrowser_javascript($dcdom,$dcdom);
-    my $verify_script = &coursepick_jscript($dcdom);
     my $courseform=&Apache::loncommon::selectcourse_link
-                     ('rolechoice','dccourse_'.$dcdom,'dcdomain_'.$dcdom,'coursedesc_'.$dcdom);
+                     ('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="" />';
-    return $cb_jscript.$verify_script.$courseform.$hiddenitems;
+    return $courseform.$hiddenitems;
 }
 
 sub coursepick_jscript {
-    my ($dcdom) = @_;
     my $verify_script = <<"END";
 <script>
 function verifyCoursePick(caller) {
     var numbutton = getIndex(caller)
-    var pickedCourse = document.rolechoice.dccourse_$dcdom.value
-    var pickedDomain = document.rolechoice.dcdomain_$dcdom.value
-    if (document.rolechoice.dcdomain_$dcdom.value == document.rolechoice.origdom_$dcdom.value) {
+    var pickedCourse = document.rolechoice.elements[numbutton+4].value
+    var pickedDomain = document.rolechoice.elements[numbutton+2].value
+    if (document.rolechoice.elements[numbutton+2].value == document.rolechoice.elements[numbutton+3].value) {
         if (pickedCourse != '') {
             if (numbutton != -1) {
                 var courseTarget = "cc./"+pickedDomain+"/"+pickedCourse
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.233 loncom/interface/loncommon.pm:1.234
--- loncom/interface/loncommon.pm:1.233	Sat Nov 20 23:24:49 2004
+++ loncom/interface/loncommon.pm	Tue Nov 23 02:29:24 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.233 2004/11/21 04:24:49 raeburn Exp $
+# $Id: loncommon.pm,v 1.234 2004/11/23 07:29:24 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -375,12 +375,11 @@
 }
 
 sub coursebrowser_javascript {
-    my ($domainfilter,$roleelement)=@_;
+    my ($domainfilter)=@_;
    return (<<ENDSTDBRW);
 <script type="text/javascript" language="Javascript" >
-    var extra_element = "$roleelement" 
     var stdeditbrowser;
-    function opencrsbrowser(formname,uname,udom,desc) {
+    function opencrsbrowser(formname,uname,udom,desc,extra_element) {
         var url = '/adm/pickcourse?';
         var filter;
         if (filter != null) {
@@ -397,8 +396,11 @@
         url += 'form=' + formname + '&cnumelement='+uname+
 	                            '&cdomelement='+udom+
                                     '&cnameelement='+desc;
-        if (extra_element != '') {
-            url += '&roleelement=$roleelement';
+        if (extra_element !=null && extra_element != '' && formname == 'rolechoice') {
+            url += '&roleelement='+extra_element;
+            if (domainfilter == null || domainfilter == '') {
+                url += '&domainfilter='+extra_element;
+            }
         }
         var title = 'Course_Browser';
         var options = 'scrollbars=1,resizable=1,menubar=0';
@@ -411,9 +413,9 @@
 }
 
 sub selectcourse_link {
-   my ($form,$unameele,$udomele,$desc)=@_;
+   my ($form,$unameele,$udomele,$desc,$extra_element)=@_;
     return "<a href='".'javascript:opencrsbrowser("'.$form.'","'.$unameele.
-        '","'.$udomele.'","'.$desc.'");'."'>".&mt('Select Course')."</a>";
+        '","'.$udomele.'","'.$desc.'","'.$extra_element.'");'."'>".&mt('Select Course')."</a>";
 }
 
 =pod