Disable ID/Student Number Safeguard and Force Change of Conflicting IDs
-(only do if you know what you are doing)
-
-
+(only do if you know what you are doing)
+
+
-ENDSENROLL
+END
+ return;
}
# =================================================== get the current classlist
sub get_current_classlist {
- my ($domain,$identifier) = @_;
- # domain is the domain the class is being run in
- # identifier is the internal, unique identifier for the class.
- my %currentlist=();
- my $now=time;
- my %results=&Apache::lonnet::dump('classlist',$domain,$identifier);
- my ($tmp) = keys(%results);
- if ($tmp !~ /^(con_lost|error|no_such_host)/i) {
- foreach my $student (keys(%results)) {
- # Extract the start and end dates
- my ($end,$start)=split(/\:/,$results{$student});
- # If the class isn't over, put it in the list
- unless (($end) && ($now>$end)) {
- $currentlist{$student}=1;
- }
- }
- return (undef,%currentlist);
- } else {
- return ($tmp,undef);
- }
+ my $r = shift;
+ # Call DownloadClasslist
+ my $cid = $ENV{'request.course.id'};
+ my $c = $r->connection;
+ my $classlisthash = &Apache::loncoursedata::DownloadClasslist
+ ($cid,'Not downloaded',$c);
+ # Call ProcessClasslist
+ my %cache;
+ my @students = &Apache::loncoursedata::ProcessClasslist(\%cache,
+ $classlisthash,
+ $cid,$c);
+ return (\@students,\%cache);
}
# ========================================================= Menu Phase Two Drop
-sub menu_phase_two_drop {
+sub print_drop_menu {
my $r=shift;
+ $r->print("
Drop Students
");
my $cid=$ENV{'request.course.id'};
- my ($error,%currentlist)=&get_current_classlist($ENV{'course.'.$cid.'.domain'},
- $ENV{'course.'.$cid.'.num'});
- if (defined($error)) {
- $r->print('
ERROR:$error
');
+ my ($student_array,$student_data)=&get_current_classlist($r);
+ if (! scalar(@$student_array)) {
+ $r->print("There are no students currently enrolled.\n");
+ return;
}
- if (!defined(%currentlist)) {
+ # Print out the available choices
+ &show_drop_list($student_array,$student_data,$r);
+ return;
+}
+
+# ============================================== view classlist
+sub print_html_classlist {
+ my $r=shift;
+ $r->print(<
+Current Classlist
+CSV format
+
+END
+ my $cid=$ENV{'request.course.id'};
+ my ($student_array,$student_data)=&get_current_classlist($r);
+ if (! scalar(@$student_array)) {
$r->print("There are no students currently enrolled.\n");
} else {
# Print out the available choices
- &show_drop_list($r,%currentlist);
+ if ($ENV{'form.action'} eq 'modifystudent') {
+ &show_class_list($r,'view','modify','modifystudent',
+ 'any',$student_array,$student_data);
+ } else {
+ &show_class_list($r,'view','aboutme','classlist',
+ 'any',$student_array,$student_data);
+ }
+ }
+}
+
+# ============================================== view classlist
+sub print_csv_classlist {
+ my $r=shift;
+ my $cid=$ENV{'request.course.id'};
+ my ($student_array,$student_data)=&get_current_classlist($r);
+ if (! scalar(@$student_array)) {
+ $r->print("There are no students currently enrolled.\n");
+ } else {
+ &show_class_list($r,'csv','nolink','csv',
+ 'any',$student_array,$student_data);
}
}
# =================================================== Show student list to drop
-sub show_drop_list {
- my ($r,%currentlist)=@_;
+sub show_class_list {
+ my ($r,$mode,$linkto,$action,$statusmode,$students,$s_data)=@_;
my $cid=$ENV{'request.course.id'};
- $r->print(<<'END');
-
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['sortby']);
+ my $sortby = $ENV{'form.sortby'};
+ if ($sortby !~ /^(username|domain|section|fullname|id)$/) {
+ $sortby = 'username';
+ }
+ # Print out header
+ if ($mode eq 'view') {
+ if ($linkto eq 'aboutme') {
+ $r->print('Select a user name to view the users page.');
+ } elsif ($linkto eq 'modify') {
+ $r->print('Select a user name to modify the students information');
+ }
+ $r->print(<
+
-
username
domain
-
ID
student name
generation
-
section
-END
- foreach (sort keys %currentlist) {
- my ($sname,$sdom)=split(/\:/,$_);
- my %reply=&Apache::lonnet::idrget($sdom,$sname);
- my $ssec=&Apache::lonnet::usection($sdom,$sname,$cid);
- my %info=&Apache::lonnet::get('environment',
- ['firstname','middlename',
- 'lastname','generation'],
- $sdom, $sname);
- my ($tmp) = keys(%info);
- if ($tmp =~ /^(con_lost|error|no_such_host)/i) {
- $r->print('
'.
- 'Internal error: unable to get environment '.
- 'for '.$sname.' in domain '.$sdom.'
'.
+ 'Error'.
+ 'Error retrieving data for '.
+ join('@',split(/:/,$student)).
+ ', '.$error.'
'."\n");
+ next;
+ }
+ my $username = $s_data->{$student.':username'};
+ my $domain = $s_data->{$student.':domain'};
+ my $section = $s_data->{$student.':section'};
+ my $name = $s_data->{$student.':fullname'};
+ my $status = $s_data->{$student.':Status'};
+ my $id = $s_data->{$student.':id'};
+ next if (($statusmode ne 'any') && ($status ne $statusmode));
+ if ($mode eq 'view') {
+ $r->print("
+END
+ } elsif ($mode eq 'csv') {
+ # no need to bother with $linkto
+ my @line = ();
+ foreach ($username,$domain,$id,$name,$section) {
+ push @line,&Apache::loncommon::csv_translate($_);
+ }
+ my $tmp = $";
+ $" = '","';
+ $r->print("\"@line\"\n");
+ $" = $tmp;
+ }
+ }
+ $r->print('
') if ($mode eq 'view');
+}
+
+
+#
+# print out form for modification of a single students data
+#
+sub print_modify_student_form {
+ my $r = shift();
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['sdom','sname','sortby']);
+ my $sname = $ENV{'form.sname'};
+ my $sdom = $ENV{'form.sdom'};
+ my $sortby = $ENV{'form.sortby'};
+ # determine the students name information
+ my %info=&Apache::lonnet::get('environment',
+ ['firstname','middlename',
+ 'lastname','generation','id'],
+ $sdom, $sname);
+ my ($tmp) = keys(%info);
+ if ($tmp =~ /^(con_lost|error|no_such_host)/i) {
+ $r->print('Error'.
+ '
'.
+ 'Unable to retrieve environment data for '.$sname.
+ 'in domain '.$sdom.'
'.
+ 'Please contact your LON-CAPA administrator '.
+ 'regarding this situation.