-
+
Disable ID/Student Number Safeguard and Force Change of Conflicting IDs
(only do if you know what you are doing)
-
-
+
+
+
ENDSENROLL
}
-# ========================================================= Menu Phase Two Drop
+# =================================================== 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 {
+ $tmp =~ s/^error://;
+ return ($tmp,undef);
+ }
+}
+# ========================================================= Menu Phase Two Drop
sub menu_phase_two_drop {
my $r=shift;
+ $r->print("
Drop Students
");
my $cid=$ENV{'request.course.id'};
- my $classlst=&Apache::lonnet::reply
- ('dump:'.$ENV{'course.'.$cid.'.domain'}.':'.
- $ENV{'course.'.$cid.'.num'}.':classlist',
- $ENV{'course.'.$cid.'.home'});
- my %currentlist=();
- my $now=time;
- unless ($classlst=~/^error\:/) {
- foreach (split(/\&/,$classlst)) {
- my ($name,$value)=split(/\=/,$_);
- my ($end,$start)=split(/\:/,
- &Apache::lonnet::unescape($value));
- my $active=1;
- if (($end) && ($now>$end)) { $active=0; }
- if ($active) {
- $currentlist{&Apache::lonnet::unescape($name)}=1;
- }
- }
-# ----------------------------------------------------------- Print out choices
- &show_drop_list($r,%currentlist);
- } else {
- $r->print(
- '
Could not access classlist: '.$classlst.
- '
');
- }
+ my ($error,%currentlist)=&get_current_classlist
+ ($ENV{'course.'.$cid.'.domain'},$ENV{'course.'.$cid.'.num'});
+ if (defined($error)) {
+ if ($error =~ /^No such file or directory/) {
+ $r->print("There are no students currently enrolled.\n");
+ } else {
+ $r->print("
ERROR:$error
");
+ }
+ } elsif (!defined(%currentlist)) {
+ $r->print("There are no students currently enrolled.\n");
+ } else {
+ # Print out the available choices
+ &show_drop_list($r,%currentlist);
+ }
+}
+
+# ============================================== view classlist
+sub menu_phase_two_view {
+ my $r=shift;
+ $r->print(<Current Classlist
+CSV format
+END
+ my $cid=$ENV{'request.course.id'};
+ my ($error,%currentlist)=&get_current_classlist
+ ($ENV{'course.'.$cid.'.domain'},$ENV{'course.'.$cid.'.num'});
+ if (defined($error)) {
+ if ($error =~ /^No such file or directory/) {
+ $r->print("There are no students currently enrolled.\n");
+ } else {
+ $r->print("
ERROR:$error
");
+ }
+ } elsif (!defined(%currentlist)) {
+ $r->print("There are no students currently enrolled.\n");
+ } else {
+ # Print out the available choices
+ &show_class_list($r,'view',%currentlist);
+ }
+}
+
+# ============================================== view classlist
+sub menu_phase_two_viewcsv {
+ my $r=shift;
+ my $cid=$ENV{'request.course.id'};
+ my ($error,%currentlist)=&get_current_classlist
+ ($ENV{'course.'.$cid.'.domain'},$ENV{'course.'.$cid.'.num'});
+ if (defined($error)) {
+ if ($error =~ /^No such file or directory/) {
+ $r->print("There are no students currently enrolled.\n");
+ } else {
+ $r->print("
ERROR:$error
");
+ }
+ } elsif (!defined(%currentlist)) {
+ $r->print("There are no students currently enrolled.\n");
+ } else {
+ &show_class_list($r,'csv',%currentlist);
+ }
}
# =================================================== Show student list to drop
+sub show_class_list {
+ my ($r,$mode,%currentlist)=@_;
+ my $cid=$ENV{'request.course.id'};
+ # Print out header
+ if ($mode eq 'view') {
+ $r->print(<
+
') if ($mode eq 'view');
+}
+# =================================================== Show student list to drop
sub show_drop_list {
my ($r,%currentlist)=@_;
my $cid=$ENV{'request.course.id'};
+ $r->print(<<'END');
+
+
+
+
+
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.'
');
- $r->print('');
+#
+# Print out the initial form to get the courselist file
+#
+sub print_first_courselist_upload_form {
+ my $r=shift;
+ my $upfile_select=&Apache::loncommon::upfile_select_html();
+ my $create_classlist_help =
+ &Apache::loncommon::help_open_topic("Course_Create_Class_List",
+ "How do I create a class list from a spreadsheet");
+ my $create_csv_help =
+ &Apache::loncommon::help_open_topic("Course_Convert_To_CSV",
+ "How do I create a CSV file from a spreadsheet");
+ $r->print(<
+
+