--- loncom/interface/Attic/londropadd.pm 2003/04/30 15:49:45 1.65
+++ loncom/interface/Attic/londropadd.pm 2003/07/03 19:26:20 1.72
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to drop and add students in courses
#
-# $Id: londropadd.pm,v 1.65 2003/04/30 15:49:45 matthew Exp $
+# $Id: londropadd.pm,v 1.72 2003/07/03 19:26:20 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -79,13 +79,16 @@ sub modifystudent {
# We are in this course
my $section=$1;
$section='' if ($course eq $courseid.'_st');
- if ( ((!$section) && (!$csec)) || ($section ne $csec) ) {
+ if ($section eq $csec) {
+ $result .= 'ok:';
+ } elsif ( ((!$section) && (!$csec)) || ($section ne $csec) ) {
my (undef,$end,$start)=split(/\_/,$roles{$course});
my $now=time;
# if this is an active role
if (!($start && ($now<$start)) || !($end && ($now>$end))) {
my $reply=&Apache::lonnet::modifystudent
- ($udom,$unam,'','','','','','','',
+ # dom name id mode pass f m l g
+ ($udom,$unam,'', '', '',undef,undef,undef,undef,
$section,time,undef,undef,$desiredhost);
$result .= $reply.':';
}
@@ -254,53 +257,18 @@ function verify_message (vf,founduname,f
if (foundname==0) { message='No name fields specified. '; }
if (foundid==0) { message+='No ID or student number field specified. '; }
if (foundsec==0) { message+='No section or group field specified. '; }
- if (vf.startdate.value=='') {
- message+='No starting date set. ';
- }
- if (vf.enddate.value=='') {
- message+='No ending date set. ';
- }
- if ((vf.enddate.value!='') && (vf.startdate.value!='')) {
- if (Math.round(vf.enddate.value)
+
+$date_table
+
@@ -558,6 +518,16 @@ sub print_upload_manager_form {
# ======================================================= Enroll single student
sub enroll_single_student {
my $r=shift;
+ #
+ # We do the dates first because the action of making them the defaul
+ # in the course is entirely seperate from the action of enrolling the
+ # student. Also, a failure in setting the dates as default is not fatal
+ # to the process of enrolling / modifying a student.
+ my ($startdate,$enddate) = &get_dates_from_form();
+ if ($ENV{'form.makedatesdefault'}) {
+ $r->print(&make_dates_default($startdate,$enddate));
+ }
+
$r->print(' Enrolling '.$ENV{'form.cuname'}." \@ ".
$ENV{'form.lcdomain'}.' Group/Section:
-
-
-
-
-
-
-
-Set Ending Date
+$date_table
@@ -986,12 +1023,7 @@ sub print_modify_student_form {
# determine the students starting and ending times and section
my ($starttime,$endtime,$section) = &get_enrollment_data($sname,$sdom);
# Deal with date forms
- my $startdateform = &Apache::lonhtmlcommon::date_setter('studentform',
- 'startdate',
- $starttime);
- my $enddateform = &Apache::lonhtmlcommon::date_setter('studentform',
- 'enddate',
- $endtime);
+ my $date_table = &date_setting_table($starttime,$endtime);
#
if (! exists($ENV{'form.Status'}) ||
$ENV{'form.Status'} !~ /^(Any|Expired|Active)$/) {
@@ -1031,12 +1063,8 @@ Disable ID/Student Number Safeguard and
(only do if you know what you are doing)
Section:
-
-LON-CAPA Domain for Students
LON-CAPA domain: $domform Starting and Ending Dates
-
-
-
-
-
-Set Starting DateFull Update
Full update
(also print list of users not enrolled anymore)Enrolling Student
');
$r->print('\n";
+ $result .= '
\n";
+ return $result;
+}
+
+sub make_dates_default {
+ my ($startdate,$enddate) = @_;
+ my $result = '';
+ my $dom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
+ my $crs = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
+ my $put_result = &Apache::lonnet::put('environment',
+ {'default_enrollment_start_date'=>$startdate,
+ 'default_enrollment_end_date' =>$enddate},$dom,$crs);
+ if ($put_result eq 'ok') {
+ $result .= "Set default start and end dates for course \n";
+ $result .= 'Starting Date '.
+ ''.$startform.' '.
+ ''.$dateDefault.' '." \n";
+ $result .= "Ending Date '.
+ ''.$endform.' '.
+ ''.$perpetual.' '."
";
+ #
+ # Refresh the course environment
+ &Apache::lonnet::coursedescription($ENV{'request.course.id'});
+ } else {
+ $result .= "Unable to set default dates for course:".$put_result.
+ '
';
+ }
+ return $result;
+}
+
# ======================================================= Menu Phase Two Enroll
sub print_enroll_single_student_form {
my $r=shift;
@@ -644,6 +693,7 @@ sub print_enroll_single_student_form {
my $locform = &Apache::loncommon::authform_local(%param);
# Set up domain selection form
my $domform = &domain_form($defdom);
+ my $date_table = &date_setting_table();
# Print it all out
$r->print(<ID/Student Number
-
-Starting Date: $startdateform
-Ending Date: $enddateform
$date_table