[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm loncreateuser.pm lonuserutils.pm

raeburn raeburn at source.lon-capa.org
Tue Feb 19 12:30:35 EST 2013


raeburn		Tue Feb 19 17:30:35 2013 EDT

  Modified files:              
    /loncom/interface	loncreateuser.pm lonuserutils.pm loncommon.pm 
  Log:
  - Changes for Domain Coordinator's user listings screen
    - "extent" column
      - not shown/selectable if role type is domain.
      - text for checkbox changed dynamically by javascript when role type of
        course, community, or author selected.
    - "status column"
       - not selectable  if role type is course or community.   
  
  
-------------- next part --------------
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.373 loncom/interface/loncreateuser.pm:1.374
--- loncom/interface/loncreateuser.pm:1.373	Wed Feb  6 16:10:27 2013
+++ loncom/interface/loncreateuser.pm	Tue Feb 19 17:30:35 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.373 2013/02/06 16:10:27 bisitz Exp $
+# $Id: loncreateuser.pm,v 1.374 2013/02/19 17:30:35 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1319,7 +1319,7 @@
         $r->print($portfolioform.$domroleform);
         if ($env{'form.action'} eq 'singlestudent') {
             $r->print(&date_sections_select($context,$newuser,$formname,
-                                            $permission));
+                                            $permission,$crstype));
         }
         $r->print('</div><div class="LC_clear_float_footer"></div>');
     } else { # user already exists
@@ -1421,8 +1421,9 @@
             unless ($gotdiv) {
                 $r->print('<div class="LC_left_float">');
             }
-            $r->print(&date_sections_select($context,$newuser,$formname));
-        } 
+            $r->print(&date_sections_select($context,$newuser,$formname,
+                                            $permission,$crstype));
+        }
         if ($gotdiv) {
             $r->print('</div><div class="LC_clear_float_footer"></div>');
         }
@@ -1495,7 +1496,7 @@
 }
 
 sub date_sections_select {
-    my ($context,$newuser,$formname,$permission) = @_;
+    my ($context,$newuser,$formname,$permission,$crstype) = @_;
     my $cid = $env{'request.course.id'};
     my ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity($cid);
     my $date_table = '<h3>'.&mt('Starting and Ending Dates').'</h3>'."\n".
@@ -1504,7 +1505,7 @@
     my $rowtitle = 'Section';
     my $secbox = '<h3>'.&mt('Section').'</h3>'."\n".
         &Apache::lonuserutils::section_picker($cdom,$cnum,'st',$rowtitle,
-                                              $permission);
+                                              $permission,$context,'',$crstype);
     my $output = $date_table.$secbox;
     return $output;
 }
@@ -3435,7 +3436,8 @@
                 my $output;
                 if ($role eq 'st') {
                     if ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) {
-                        my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3);
+                        my ($cdom,$cnum,$csec) = ($1,$2,$3);
+                        my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$cdom,$cnum,$csec,$context);
                         if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course') || ($result eq 'refused')) {
                             if ($result eq 'refused' && $logmsg) {
                                 $output = $logmsg;
@@ -4558,6 +4560,11 @@
 
 sub verify_user_display {
     my ($context) = @_;
+    my %lt = &Apache::lonlocal::texthash (
+        course    => 'course(s): description, section(s), status',
+        community => 'community(s): description, section(s), status',
+        author    => 'author',
+    );
     my $photos;
     if (($context eq 'course') && $env{'request.course.id'}) {
         $photos = $env{'course.'.$env{'request.course.id'}.'.internal.showphoto'};
@@ -4581,16 +4588,25 @@
     var context = '$context';
     var photos = '$photos';
     if (caller == 'Status') {
-        if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') {
-            document.getElementById('showcolstatus').checked = true;
-            document.getElementById('showcolstatus').disabled = '';
-            document.getElementById('showcolstart').checked = true;
-            document.getElementById('showcolend').checked = true;
-        } else {
+        if ((context == 'domain') && 
+            ((document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'course') ||
+             (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community'))) {
             document.getElementById('showcolstatus').checked = false;
             document.getElementById('showcolstatus').disabled = 'disabled';
             document.getElementById('showcolstart').checked = false;
             document.getElementById('showcolend').checked = false;
+        } else {
+            if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') {
+                document.getElementById('showcolstatus').checked = true;
+                document.getElementById('showcolstatus').disabled = '';
+                document.getElementById('showcolstart').checked = true;
+                document.getElementById('showcolend').checked = true;
+            } else {
+                document.getElementById('showcolstatus').checked = false;
+                document.getElementById('showcolstatus').disabled = 'disabled';
+                document.getElementById('showcolstart').checked = false;
+                document.getElementById('showcolend').checked = false;
+            }
         }
     }
     if (caller == 'output') {
@@ -4616,6 +4632,45 @@
             document.getElementById('showcolrole').checked = false;
             document.getElementById('showcolrole').disabled = 'disabled';
         }
+        if (context == 'domain') {
+            if ((document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'course') ||
+                (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community')) {
+                document.getElementById('showcolstatus').checked = false;
+                document.getElementById('showcolstatus').disabled = 'disabled';
+                document.getElementById('showcolstart').checked = false;
+                document.getElementById('showcolend').checked = false;
+            } else {
+                if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') {
+                    document.getElementById('showcolstatus').checked = true;
+                    document.getElementById('showcolstatus').disabled = '';
+                    document.getElementById('showcolstart').checked = true;
+                    document.getElementById('showcolend').checked = true;
+                }
+            }
+            if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'domain') {
+                document.getElementById('showcolextent').disabled = 'disabled';
+                document.getElementById('showcolextent').checked = 'false';
+                document.getElementById('showextent').style.display='none';
+                document.getElementById('showcoltextextent').innerHTML = '';
+            } else {
+                document.getElementById('showextent').style.display='block';
+                document.getElementById('showextent').style.textAlign='left';
+                document.getElementById('showextent').style.textFace='normal';
+                if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'author') {
+                    document.getElementById('showcolextent').disabled = '';
+                    document.getElementById('showcolextent').checked = 'true';
+                    document.getElementById('showcoltextextent').innerHTML="$lt{'author'}";
+                } else {
+                    document.getElementById('showcolextent').disabled = '';
+                    document.getElementById('showcolextent').checked = 'true';
+                    if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community') {
+                        document.getElementById('showcoltextextent').innerHTML="$lt{'community'}";
+                    } else {
+                        document.getElementById('showcoltextextent').innerHTML="$lt{'course'}";
+                    }
+                }
+            }
+        }
     }
     return;
 }
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.148 loncom/interface/lonuserutils.pm:1.149
--- loncom/interface/lonuserutils.pm:1.148	Tue Feb  5 16:22:27 2013
+++ loncom/interface/lonuserutils.pm	Tue Feb 19 17:30:35 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Utility functions for managing LON-CAPA user accounts
 #
-# $Id: lonuserutils.pm,v 1.148 2013/02/05 16:22:27 bisitz Exp $
+# $Id: lonuserutils.pm,v 1.149 2013/02/19 17:30:35 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -237,6 +237,8 @@
     # Role types
     my @roletypes = ('domain','author','course','community');
     my %lt = &role_type_names();
+    my $onchangefirst = "updateCols('showrole')";
+    my $onchangesecond = "updateCols('showrole')";
     #
     # build up the menu information to be passed to
     # &Apache::loncommon::linked_select_forms
@@ -283,7 +285,8 @@
     my $result = &Apache::loncommon::linked_select_forms
         ('studentform',(' 'x3).&mt('Role: '),$env{'form.roletype'},
          'roletype','showrole',\%select_menus,
-         ['domain','author','course','community']);
+         ['domain','author','course','community'],$onchangefirst,
+         $onchangesecond);
     return $result;
 }
 
@@ -1527,20 +1530,22 @@
     }
     $r->print('</div><div class="LC_left_float">'.
               &column_checkboxes($context,$mode,$formname).
-              '</div><br clear="all" />');
+              '</div>');
     if ($env{'form.phase'} eq '') {
-        $r->print(&list_submit_button(&mt('Display List of Users'))."\n".
+        $r->print('<br clear="all" />'.
+                  &list_submit_button(&mt('Display List of Users'))."\n".
                   '<input type="hidden" name="phase" value="" /></form>');
         return;
     }
     if (!(($context eq 'domain') && 
           (($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community')))) {
-        $r->print(&list_submit_button(&mt('Update Display'))."\n");
+        $r->print('<br clear="all" />'.
+                  &list_submit_button(&mt('Update Display'))."\n");
     }
 
     my @cols = &infocolumns($context,$mode);  
     if (!@cols) {
-         $r->print('<hr /><span class="LC_warning">'.
+         $r->print('<hr clear="all" /><span class="LC_warning">'.
                    &mt('No user information selected for display.').'</span>'.
                    '<input type="hidden" name="phase" value="display" /></form>'."\n");
          return;
@@ -1583,7 +1588,7 @@
             $r->print('<hr />'.&mt('Searching ...').'<br /> <br />');
         }
     } else {
-        $r->print('<hr /><div id="searching">'.&mt('Searching ...').'</div>');
+        $r->print('<hr clear="all" /><div id="searching">'.&mt('Searching ...').'</div>');
     }
     $r->rflush();
     if ($context eq 'course') {
@@ -1880,9 +1885,6 @@
             push(@cols,'section');
         }
         push(@cols,('start','end','role'));
-        if ($context eq 'domain') {
-            push (@cols,'extent');
-        }
         unless (($mode eq 'autoenroll') && ($env{'form.Status'} ne 'Any')) {
             push(@cols,'status');
         }
@@ -1897,6 +1899,9 @@
             ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'})) {
             push(@cols,'photos');
         }
+        if ($context eq 'domain') {
+            push (@cols,'extent');
+        }
     }
     return @cols;
 }
@@ -1911,8 +1916,10 @@
         if ($context eq 'course') {
             $disabledchk{'role'} = 1;
             $unchecked{'photo'} = 1;
+            $unchecked{'clicker'} = 1;
+        } elsif ($context eq 'domain') { 
+            $unchecked{'extent'} = 1; 
         }
-        $unchecked{'clicker'} = 1;
         $unchecked{'start'} = 1;
         $unchecked{'end'} = 1;
     } else {
@@ -1922,9 +1929,17 @@
         if (($env{'form.showrole'} ne 'Any') && ($env{'form.showrole'} ne 'cr')) {
             $disabledchk{'role'} = 1;
         }
+        if ($context eq 'domain') {
+            if (($env{'form.roletype'} eq 'course') || 
+                ($env{'form.roletype'} eq 'community')) {
+                $disabledchk{'status'} = 1;
+            } elsif ($env{'form.roletype'} eq 'domain') {
+                $disabledchk{'extent'} = 1; 
+            }
+        }
     }
     my $numposs = scalar(@cols);
-    my $numinrow = 8;
+    my $numinrow = 7;
     my %lt = &get_column_names($context);
     my $output = '<fieldset><legend>'.&mt('Information to show').'</legend>'."\n".'<span class="LC_nobreak">'.
                  '<input type="button" onclick="javascript:checkAll(document.'.$formname.'.showcol);" value="'.&mt('check all').'" />'.
@@ -1964,9 +1979,16 @@
         } else {
             $output .= '<td>';
         }
-        $output .= '<label><input id="showcol'.$cols[$i].'" type="checkbox" name="showcol" value="'.$cols[$i].'"'.$checked.' />'.
-                   $lt{$cols[$i]}.'</label></td>';
-
+        my $style;
+        if ($cols[$i] eq 'extent') {
+            if (($env{'form.roletype'} eq 'domain') || ($env{'form.roletype'} eq '')) {
+                $style = ' style="display: none;"';
+            } 
+        } 
+        $output .= '<span id="show'.$cols[$i].'"'.$style.'><label>'.
+                   '<input id="showcol'.$cols[$i].'" type="checkbox" name="showcol" value="'.$cols[$i].'"'.$checked.' /><span id="showcoltext'.$cols[$i].'">'.
+                   $lt{$cols[$i]}.'</span>'.
+                   '</label></span></td>';
     }
     $output .= '</tr></table></fieldset>';
     return $output;
@@ -2000,11 +2022,12 @@
         'clicker'    => "clicker-ID",
     );
     if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {
-        $lt{'extent'} = &mt('Course(s): description, section(s), status');
+        $lt{'extent'} = &mt('course(s): description, section(s), status');
     } elsif ($context eq 'domain' && $env{'form.roletype'} eq 'community') {
-        $lt{'extent'} = &mt('Communities: description, section(s), status');
-    } elsif ($context eq 'author') {
-        $lt{'extent'} = &mt('Author');
+        $lt{'extent'} = &mt('communities: description, section(s), status');
+    } elsif (($context eq 'author') || 
+             ($context eq 'domain' && $env{'form.roletype'} eq 'author')) {
+        $lt{'extent'} = &mt('author');
     }
     return %lt;
 }
@@ -2935,7 +2958,7 @@
                         } else {
                              $r->print('<td> </td>'."\n");
                         } 
-                    } 
+                    }
                 } else {
                     $r->print('<td>'.$in{$item}.'</td>'."\n");
                 }
@@ -3429,7 +3452,7 @@
                    '<input type="hidden" name="sections" value="" />'."\n".
                    '</td></tr></table>'."\n";
     } else {
-       $secbox .= '<input type="hidden" name="sections" value="'.
+        $secbox .= '<input type="hidden" name="sections" value="'.
                    $env{'request.course.sec'}.'" />'.
                    $env{'request.course.sec'};
     }
@@ -3989,7 +4012,7 @@
         } elsif ($setting eq 'course') {
             $defaultrole = $env{'form.courserole'};
             $defaultsec = $env{'form.sections'};
-        }  
+        }
     } elsif ($context eq 'author') {
         $defaultrole = $env{'form.defaultrole'};
     } elsif ($context eq 'course') {
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1114 loncom/interface/loncommon.pm:1.1115
--- loncom/interface/loncommon.pm:1.1114	Wed Jan 23 15:23:19 2013
+++ loncom/interface/loncommon.pm	Tue Feb 19 17:30:35 2013
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.1114 2013/01/23 15:23:19 raeburn Exp $
+# $Id: loncommon.pm,v 1.1115 2013/02/19 17:30:35 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1059,6 +1059,12 @@
 
 =item * $menuorder, the order of values in the first menu
 
+=item * $onchangefirst, additional javascript call to execute for an onchange
+        event for the first <select> tag
+
+=item * $onchangesecond, additional javascript call to execute for an onchange
+        event for the second <select> tag
+
 =back 
 
 Below is an example of such a hash.  Only the 'text', 'default', and 
@@ -1112,6 +1118,8 @@
         $secondselectname, 
         $hashref,
         $menuorder,
+        $onchangefirst,
+        $onchangesecond
         ) = @_;
     my $second = "document.$formname.$secondselectname";
     my $first = "document.$formname.$firstselectname";
@@ -1168,7 +1176,7 @@
 </script>
 END
     # output the initial values for the selection lists
-    $result .= "<select size=\"1\" name=\"$firstselectname\" onchange=\"select1_changed()\">\n";
+    $result .= "<select size=\"1\" name=\"$firstselectname\" onchange=\"select1_changed();$onchangefirst\">\n";
     my @order = sort(keys(%{$hashref}));
     if (ref($menuorder) eq 'ARRAY') {
         @order = @{$menuorder};
@@ -1181,7 +1189,11 @@
     $result .= "</select>\n";
     my %select2 = %{$hashref->{$firstdefault}->{'select2'}};
     $result .= $middletext;
-    $result .= "<select size=\"1\" name=\"$secondselectname\">\n";
+    $result .= "<select size=\"1\" name=\"$secondselectname\"";
+    if ($onchangesecond) {
+        $result .= ' onchange="'.$onchangesecond.'"';
+    }
+    $result .= ">\n";
     my $seconddefault = $hashref->{$firstdefault}->{'default'};
     
     my @secondorder = sort(keys(%select2));
@@ -13263,7 +13275,7 @@
             }
         }
         if (($expire_role_result eq 'ok') || ($secchange == 0)) {
-            $modify_section_result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,'','',$cid,'',$context);
+            $modify_section_result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,'','',$cid,'',$context); 
             if ($modify_section_result =~ /^ok/) {
                 if ($secchange == 1) {
                     if ($sec eq '') {
@@ -13285,7 +13297,7 @@
                     }
                 }
             } else {
-                if ($secchange) {       
+                if ($secchange) { 
                     $$logmsg .= &mt('Error when attempting section change for [_1] from old section "[_2]" to new section: "[_3]" in course [_4] -error:',$uname,$oldsec,$sec,$cid).' '.$modify_section_result.$linefeed;
                 } else {
                     $$logmsg .= &mt('Error when attempting to modify role for [_1] for section: "[_2]" in course [_3] -error:',$uname,$sec,$cid).' '.$modify_section_result.$linefeed;


More information about the LON-CAPA-cvs mailing list