[LON-CAPA-cvs] cvs: loncom /interface londropadd.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Tue, 24 Sep 2002 18:24:43 -0000
matthew Tue Sep 24 14:24:43 2002 EDT
Modified files:
/loncom/interface londropadd.pm
Log:
Can now modify a single students data. Woo!
Index: loncom/interface/londropadd.pm
diff -u loncom/interface/londropadd.pm:1.51 loncom/interface/londropadd.pm:1.52
--- loncom/interface/londropadd.pm:1.51 Wed Sep 18 10:17:47 2002
+++ loncom/interface/londropadd.pm Tue Sep 24 14:24:43 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to drop and add students in courses
#
-# $Id: londropadd.pm,v 1.51 2002/09/18 14:17:47 matthew Exp $
+# $Id: londropadd.pm,v 1.52 2002/09/24 18:24:43 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -773,9 +773,9 @@
} else {
# Print out the available choices
if ($ENV{'form.action'} eq 'modifystudent') {
- &show_class_list($r,'view','modify',$student_array,$student_data);
+ &show_class_list($r,'view','modify','any',$student_array,$student_data);
} else {
- &show_class_list($r,'view','aboutme',$student_array,$student_data);
+ &show_class_list($r,'view','aboutme','any',$student_array,$student_data);
}
}
}
@@ -788,13 +788,13 @@
if (! scalar(@$student_array)) {
$r->print("There are no students currently enrolled.\n");
} else {
- &show_class_list($r,'csv','nolink',$student_array,$student_data);
+ &show_class_list($r,'csv','nolink','any',$student_array,$student_data);
}
}
# =================================================== Show student list to drop
sub show_class_list {
- my ($r,$mode,$linkto,$students,$student_data)=@_;
+ my ($r,$mode,$linkto,$statusmode,$students,$student_data)=@_;
my $cid=$ENV{'request.course.id'};
# Print out header
if ($mode eq 'view') {
@@ -814,13 +814,25 @@
"section")).'"'."\n");
}
foreach my $student (@$students) {
+ my $error;
+ if (exists($student_data->{$student.':error'})) {
+ $error = $student_data->{$student.':error'};
+ }
+ if ($error) {
+ $r->print('<tr><td colspan="6">'.
+ '<font color="#FF8888">Error</font>'.
+ 'Error retrieving data for '.
+ join('@',split(/:/,$student)).
+ ', '.$error.'</td></tr>'."\n");
+ next;
+ }
my $username = $student_data->{$student.':username'};
my $domain = $student_data->{$student.':domain'};
my $section = $student_data->{$student.':section'};
my $name = $student_data->{$student.':fullname'};
my $status = $student_data->{$student.':Status'};
my $id = $student_data->{$student.':id'};
- next if ($status ne 'Active');
+ next if (($statusmode ne 'any') && ($status ne $statusmode));
if ($mode eq 'view') {
$r->print("<tr>\n <td>\n ");
if ($linkto eq 'nothing') {
@@ -871,7 +883,7 @@
# determine the students name information
my %info=&Apache::lonnet::get('environment',
['firstname','middlename',
- 'lastname','generation'],
+ 'lastname','generation','id'],
$sdom, $sname);
my ($tmp) = keys(%info);
if ($tmp =~ /^(con_lost|error|no_such_host)/i) {
@@ -894,6 +906,11 @@
$endtime);
# Make sure student is enrolled in course
$r->print(<<END);
+<p>
+<font size="+1">
+Only domain coordinators can change a users password.
+</font>
+</p>
<input type="hidden" name="slogin" value="$sname" />
<input type="hidden" name="sdomain" value="$sdom" />
<input type="hidden" name="action" value="modifystudent" />
@@ -911,6 +928,8 @@
<input type="text" name="generation" value="$info{'generation'}" /></td></tr>
</table>
</p><p>
+<b>Student ID</b>: <input type="text" name="id" value="$info{'id'}" size="12"/>
+</p><p>
<b>Section</b>: <input type="text" name="section" value="$section" size="4"/>
</p><p>
<table>
@@ -938,6 +957,7 @@
my $courseid = $ENV{'request.course.id'};
my $sname = $ENV{'form.slogin'};
my $sdom = $ENV{'form.sdomain'};
+ my $sid = $ENV{'form.id'};
my $starttime = &Apache::lonhtmlcommon::get_date_from_form('startdate',
time);
my $endtime = &Apache::lonhtmlcommon::get_date_from_form('enddate',
@@ -946,7 +966,7 @@
my $displayable_endtime = localtime($endtime);
# talk to the user about what we are going to do
$r->print(<<END);
-Modifying data for user: $sname \@ $sdom <br />
+<h2>Modifying data for user $sname \@ $sdom </h2>
<h3>Student Information</h3>
<table>
<tr><td>First name </td><td> $firstname </td></tr>
@@ -960,25 +980,30 @@
<tr><td>Start Time </td><td> $displayable_starttime </td></tr>
<tr><td>End Time </td><td> $displayable_endtime </td></tr>
</table>
+<p>
END
- # send request(s) to modify data
- my $roleresults = 'refused';
- #my $roleresults = &Apache::lonnet::assignrole($sdom,$sname,
- # $courseid.'/'.$section,
- # 'st',
- # $endtime,$starttime);
+ # Send request(s) to modify data
+ # The '1' in the call to modifystudent is to force the students
+ # id to be changed.
+ my $roleresults = &Apache::lonnet::modifystudent
+ ($sdom,$sname,$sid,undef,undef,$firstname,$middlename,$lastname,
+ $generation,$section,$endtime,$starttime,1);
if ($roleresults =~/refused/) {
$r->print("Your request to change the role information for this ".
"student was refused.");
} elsif ($roleresults !~ /ok/) {
$r->print("An error occurred during the attempt to change the role".
- " information for this student. The error reported was ".
+ " information for this student. <br />".
+ "The error reported was ".
$roleresults);
} else { # everything is okay!
- $r->print("Student role updated successfully.");
+ $r->print("Student information updated successfully. <br />".
+ "The student must log out and log in again to see ".
+ "these changes.");
}
- #
$r->print(<<END);
+</p><p>
+<a href="/adm/dropadd?action=modifystudent">Modify another students data</a>
</body></html>
END
return;
@@ -1042,6 +1067,18 @@
<th>ID</th><th>student name</th><th>section</th></tr>
END
foreach my $student (@$students) {
+ my $error;
+ if (exists($student_data->{$student.':error'})) {
+ $error = $student_data->{$student.':error'};
+ }
+ if ($error) {
+ $r->print('<tr><td colspan="6">'.
+ '<font color="#FF8888">Error</font>'.
+ 'Error retrieving data for '.
+ join('@',split(/:/,$student)).
+ ', '.$error.'</td></tr>'."\n");
+ next;
+ }
my $username = $student_data->{$student.':username'};
my $domain = $student_data->{$student.':domain'};
my $section = $student_data->{$student.':section'};