[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm lonmenu.pm lonpickstudent.pm
raeburn
raeburn at source.lon-capa.org
Thu Sep 28 11:56:48 EDT 2023
raeburn Thu Sep 28 15:56:48 2023 EDT
Modified files:
/loncom/interface loncommon.pm lonmenu.pm lonpickstudent.pm
Log:
- Bug 6979 Work in progress.
Reduce width of "View As" form in Functions menu by removing dropdown
list for domain, and only displaying textbox for either username or ID
(radio buttons to toggle between the two). Default domain is course's
domain.
-------------- next part --------------
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.1412 loncom/interface/loncommon.pm:1.1413
--- loncom/interface/loncommon.pm:1.1412 Mon Sep 25 22:36:29 2023
+++ loncom/interface/loncommon.pm Thu Sep 28 15:56:48 2023
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.1412 2023/09/25 22:36:29 raeburn Exp $
+# $Id: loncommon.pm,v 1.1413 2023/09/28 15:56:48 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -437,7 +437,7 @@
<script type="text/javascript" language="Javascript">
// <![CDATA[
var stdeditbrowser;
- function openstdbrowser(formname,uname,udom,clicker,roleflag,ignorefilter,courseadv) {
+ function openstdbrowser(formname,uname,udom,clicker,roleflag,ignorefilter,courseadv,uident) {
var url = '/adm/pickstudent?';
var filter;
if (!ignorefilter) {
@@ -458,6 +458,7 @@
}
}
if ((courseadv == 'only') || (courseadv == 'none')) { url+="&courseadv="+courseadv; }
+ if (uident !== '') { url+="&identelement="+uident; }
var title = 'Student_Browser';
var options = 'scrollbars=1,resizable=1,menubar=0';
options += ',width=700,height=600';
@@ -489,7 +490,7 @@
}
sub selectstudent_link {
- my ($form,$unameele,$udomele,$courseadv,$clickerid)=@_;
+ my ($form,$unameele,$udomele,$courseadv,$clickerid,$identelem)=@_;
my $callargs = "'".&Apache::lonhtmlcommon::entity_encode($form)."','".
&Apache::lonhtmlcommon::entity_encode($unameele)."','".
&Apache::lonhtmlcommon::entity_encode($udomele)."'";
@@ -506,6 +507,11 @@
$callargs .= ",'','','$courseadv'";
} elsif ($courseadv eq 'condition') {
$callargs .= ",'','','$courseadv'";
+ } elsif ($identelem ne '') {
+ $callargs .= ",'','',''";
+ }
+ if ($identelem ne '') {
+ $callargs .= ",'".&Apache::lonhtmlcommon::entity_encode($identelem)."'";
}
return '<span class="LC_nobreak">'.
'<a href="javascript:openstdbrowser('.$callargs.');">'.
Index: loncom/interface/lonmenu.pm
diff -u loncom/interface/lonmenu.pm:1.537 loncom/interface/lonmenu.pm:1.538
--- loncom/interface/lonmenu.pm:1.537 Wed Sep 27 14:07:47 2023
+++ loncom/interface/lonmenu.pm Thu Sep 28 15:56:48 2023
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.537 2023/09/27 14:07:47 raeburn Exp $
+# $Id: lonmenu.pm,v 1.538 2023/09/28 15:56:48 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1105,15 +1105,17 @@
$leftvis = 'inline';
$defdom = $cdom;
}
- my $sellink = &Apache::loncommon::selectstudent_link('userview','vuname','vudom');
+ my $sellink = &Apache::loncommon::selectstudent_link('userview','vuname','vudom','','','vuidentifier');
my $selscript=&Apache::loncommon::studentbrowser_javascript();
my $shownsymb = &HTML::Entities::encode(&Apache::lonenc::check_encrypt($env{'request.symb'}),'<>&"');
- my $input = &mt('User: [_1] or ID: [_2] at: [_3]',
- '<input name="vuname" type="text" size="8" value="'.$vuname.'" />',
- '<input name="vid" type="text" size="8" value="'.$vid.'" />',
- &Apache::loncommon::select_dom_form($defdom,'vudom')).
- '<input name="LC_viewas" type="hidden" value="'.$viewas.'" />',
- '<input name="symb" type="hidden" value="'.$shownsymb.'" />';
+ my $input = &mt('[_1]Username:[_2] or [_3]ID:[_4] | ',
+ '<label><input type="radio" name="vuidentifier" value="uname" checked="checked" onclick="javascript:toggleIdentifier(this.form);" />',
+ '</label><input name="vuname" type="text" size="6" value="'.$vuname.'" id="LC_vuname" />',
+ '<label><input type="radio" name="vuidentifier" value="uid" onclick="javascript:toggleIdentifier(this.form);" />',
+ '</label><input name="vid" type="hidden" size="6" value="'.$vid.'" id="LC_vid" />').
+ '<input name="vudom" type="hidden" value="'.$defdom.'" />'.
+ '<input name="LC_viewas" type="hidden" value="'.$viewas.'" />',
+ '<input name="symb" type="hidden" value="'.$shownsymb.'" />';
my $chooser = <<END;
$selscript
<a href="javascript:toggleViewAsUser('$change');" class="LC_menubuttons_link">
@@ -2380,6 +2382,7 @@
seluserid.style.display = 'inline';
document.getElementById('usexpand').innerHTML='';
document.getElementById('uscollapse').innerHTML='◄ ';
+ toggleIdentifier(document.userview);
}
}
}
@@ -2389,7 +2392,7 @@
function validCourseUser(form,change) {
var possuname = form.elements['vuname'].value;
var possuid = form.elements['vid'].value;
- var possudom = form.elements['vudom'].options[form.elements['vudom'].selectedIndex].value;
+ var possudom = form.elements['vudom'].value;
if ((possuname == '') && (possuid == '')) {
if (change == 'off') {
form.elements['LC_viewas'].value = '';
@@ -2425,6 +2428,30 @@
return false;
}
+function toggleIdentifier(form) {
+ if ((document.getElementById('LC_vuname')) && (document.getElementById('LC_vid'))) {
+ var radioelem = form.elements['vuidentifier'];
+ if (radioelem.length > 0) {
+ var i;
+ for (i=0; i<radioelem.length; i++) {
+ if (radioelem[i].checked == true) {
+ if (radioelem[i].value == 'uname') {
+ document.getElementById('LC_vuname').type = 'text';
+ document.getElementById('LC_vid').type = 'hidden';
+ document.getElementById('LC_vid').value = '';
+ } else {
+ document.getElementById('LC_vuname').type = 'hidden';
+ document.getElementById('LC_vuname').value = '';
+ document.getElementById('LC_vid').type = 'text';
+ }
+ break;
+ }
+ }
+ }
+ }
+ return;
+}
+
END
}
Index: loncom/interface/lonpickstudent.pm
diff -u loncom/interface/lonpickstudent.pm:1.33 loncom/interface/lonpickstudent.pm:1.34
--- loncom/interface/lonpickstudent.pm:1.33 Wed Feb 12 16:25:47 2020
+++ loncom/interface/lonpickstudent.pm Thu Sep 28 15:56:48 2023
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Pick a student from the classlist
#
-# $Id: lonpickstudent.pm,v 1.33 2020/02/12 16:25:47 raeburn Exp $
+# $Id: lonpickstudent.pm,v 1.34 2023/09/28 15:56:48 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -50,7 +50,7 @@
&Apache::loncommon::get_unprocessed_cgi
($ENV{'QUERY_STRING'},['filter','form','unameelement','udomelement',
- 'roles','courseadv','clicker']);
+ 'roles','courseadv','clicker','identelement']);
# Allowed?
my $allowed;
if ($env{'request.course.id'}) {
@@ -79,7 +79,7 @@
<input type="text" name="filter" value="$encoded_filter" />
<input type="submit" name="Change" value="$change" />
FILTER
- foreach my $name ('form','unameelement','udomelement','roles','courseadv','clicker') {
+ foreach my $name ('form','unameelement','udomelement','roles','courseadv','clicker','identelement') {
my $value = &HTML::Entities::encode($env{"form.$name"},'<>&"');
$filterbutton .= <<HIDDEN;
<input type="hidden" name="$name" value="$value" />
@@ -106,11 +106,38 @@
$r->print(<<ENDSCRIPT);
<script type="text/javascript">
function gochoose(uname,udom) {
- opener.document.$env{'form.form'}.elements['$env{'form.unameelement'}'].value=uname;
- var slct=opener.document.$env{'form.form'}.elements['$env{'form.udomelement'}'];
- var i;
- for (i=0;i<slct.length;i++) {
- if (slct.options[i].value==udom) { slct.selectedIndex=i; }
+ var form = opener.document.$env{'form.form'};
+ form.elements["$env{'form.unameelement'}"].value=uname;
+ var slct = form.elements['$env{"form.udomelement"}'];
+ if ((slct.tagName === 'INPUT') && ((slct.type === 'text') || (slct.type === 'hidden'))) {
+ slct.value=udom;
+ } else if (slct.tagName === 'SELECT') {
+ var i;
+ for (i=0;i<slct.length;i++) {
+ if (slct.options[i].value==udom) {
+ slct.selectedIndex=i;
+ break;
+ }
+ }
+ }
+ var identname = "$env{'form.identelement'}";
+ if ((identname != undefined) && (identname != '') && (identname != 'null')) {
+ ident = opener.document.getElementsByName("$env{'form.identelement'}");
+ if (ident.length > 0) {
+ var j;
+ for (j=0; j<ident.length; j++) {
+ if (ident[j].value == 'uname') {
+ if (ident[j].checked) {
+ break;
+ } else {
+ ident[j].checked = true;
+ window.opener.toggleIdentifier(form);
+ }
+ } else {
+ ident[j].checked = false;
+ }
+ }
+ }
}
self.close();
}
More information about the LON-CAPA-cvs
mailing list