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 %currentlist;
- } else {
- return undef;
+# ========================================================= Menu Phase Two Drop
+sub print_drop_menu {
+ my $r=shift;
+ $r->print("
Drop Students
");
+ my $cid=$ENV{'request.course.id'};
+ my ($classlist,$keylist) = &Apache::loncoursedata::get_classlist();
+ if (! defined($classlist)) {
+ $r->print("There are no students currently enrolled.\n");
+ return;
}
+ # Print out the available choices
+ &show_drop_list($r,$classlist,$keylist);
+ return;
}
-# ========================================================= Menu Phase Two Drop
-sub menu_phase_two_drop {
+# ============================================== view classlist
+sub print_html_classlist {
my $r=shift;
+ if (! exists($ENV{'form.sortby'})) {
+ $ENV{'form.sortby'} = 'username';
+ }
+ if ($ENV{'form.Status'} !~ /^(Any|Expired|Active)$/) {
+ $ENV{'form.Status'} = 'Active';
+ }
+ my $status_select = &Apache::lonhtmlcommon::StatusOptions
+ ($ENV{'form.Status'},'studentform');
+ $r->print(<
+
+
+Current Classlist
+
+END
+ if ($ENV{'form.action'} ne 'modifystudent') {
+ $r->print(<
+CSV format
+
+Excel format
+
+
+Student Status:
+END
+ }
+ $r->print($status_select."
\n");
my $cid=$ENV{'request.course.id'};
- my %currentlist=&get_current_classlist($ENV{'course.'.$cid.'.domain'},
- $ENV{'course.'.$cid.'.num'});
- if (!defined(%currentlist)) {
- $r->print(''.
- '
Could not access classlist.
');
+ my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist();
+ if (! defined($classlist)) {
+ $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',
+ $ENV{'form.Status'},$classlist,$keylist);
+ } else {
+ &show_class_list($r,'view','aboutme','classlist',
+ $ENV{'form.Status'},$classlist,$keylist);
+ }
+ }
+}
+
+# ============================================== view classlist
+sub print_formatted_classlist {
+ my $r=shift;
+ my $mode = shift;
+ my $cid=$ENV{'request.course.id'};
+ my ($classlist,$keylist)=&Apache::loncoursedata::get_classlist();
+ if (! defined($classlist)) {
+ $r->print("There are no students currently enrolled.\n");
+ } else {
+ &show_class_list($r,$mode,'nolink','csv',
+ $ENV{'form.Status'},$classlist,$keylist);
}
}
# =================================================== Show student list to drop
-sub show_drop_list {
- my ($r,%currentlist)=@_;
+sub show_class_list {
+ my ($r,$mode,$linkto,$action,$statusmode,$classlist,$keylist)=@_;
my $cid=$ENV{'request.course.id'};
- $r->print(<<'END');
-
+ #
+ # Variables for excel output
+ my ($excel_workbook, $excel_sheet, $excel_filename,$row);
+ #
+ 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 personal 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.'
'."\n");
+ }
+}
+
+
+#
+# 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']);
+ 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.