--- loncom/interface/Attic/londropadd.pm 2003/06/20 18:34:52 1.67
+++ loncom/interface/Attic/londropadd.pm 2003/07/02 15:25:46 1.70
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to drop and add students in courses
#
-# $Id: londropadd.pm,v 1.67 2003/06/20 18:34:52 matthew Exp $
+# $Id: londropadd.pm,v 1.70 2003/07/02 15:25:46 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -85,7 +85,8 @@ sub modifystudent {
# 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 +255,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 +516,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:
-
-
-
-
-
-
-
-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;
@@ -650,24 +691,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 $starttime = 'now';
- if (exists($ENV{'course.'.$ENV{'request.course.id'}.
- '.default_enrollment_start_date'})) {
- $starttime = $ENV{'course.'.$ENV{'request.course.id'}.
- '.default_enrollment_start_date'};
- }
- my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
- if (exists($ENV{'course.'.$ENV{'request.course.id'}.
- '.default_enrollment_end_date'})) {
- $endtime = $ENV{'course.'.$ENV{'request.course.id'}.
- '.default_enrollment_end_date'};
- }
- my $startdateform = &Apache::lonhtmlcommon::date_setter('studentform',
- 'startdate',
- $starttime);
- my $enddateform = &Apache::lonhtmlcommon::date_setter('studentform',
- 'enddate',
- $endtime);
+ my $date_table = &date_setting_table();
# Print it all out
$r->print(<
-
+$date_table
-Starting Date $startdateform
-Ending Date $enddateform
@@ -1007,12 +1021,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)$/) { @@ -1052,12 +1061,8 @@ Disable ID/Student Number Safeguard and (only do if you know what you are doing)
Section: -
-
Starting Date: | $startdateform |
Ending Date: | $enddateform |
$date_table