--- loncom/interface/Attic/londropadd.pm 2007/08/31 03:22:51 1.169
+++ loncom/interface/Attic/londropadd.pm 2009/02/04 13:21:48 1.178
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to drop and add students in courses
#
-# $Id: londropadd.pm,v 1.169 2007/08/31 03:22:51 raeburn Exp $
+# $Id: londropadd.pm,v 1.178 2009/02/04 13:21:48 hauer Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -26,8 +26,23 @@
# http://www.lon-capa.org/
#
#
-###############################################################
-##############################################################
+
+=head1 NAME
+
+Apache::londropadd.pm
+
+=head1 SYNOPSIS
+
+drop & add students
+
+This is part of the LearningOnline Network with CAPA project
+described at http://www.lon-capa.org.
+
+=head1 SUBROUTINES
+
+=over
+
+=cut
package Apache::londropadd;
@@ -42,8 +57,6 @@ use Apache::lonlocal;
use Apache::longroup;
use LONCAPA();
-###############################################################
-###############################################################
sub header {
my ($jscript,$loaditems) = @_;
my $start_page;
@@ -59,9 +72,14 @@ $start_page
ENDHEAD
}
-###############################################################
-###############################################################
-# Drop student from all sections of a course, except optional $csec
+=pod
+
+=item modifystudent()
+
+ Drop student from all sections of a course, except optional $csec
+
+=cut
+
sub modifystudent {
my ($udom,$unam,$courseid,$csec,$desiredhost)=@_;
# if $csec is undefined, drop the student from all the courses matching
@@ -104,9 +122,14 @@ sub modifystudent {
return $result;
}
-###############################################################
-###############################################################
-# build a domain and server selection form
+=pod
+
+=item domain_form()
+
+ build a domain and server selection form
+
+=cut
+
sub domain_form {
my ($defdom) = @_;
# Set up domain and server selection forms
@@ -135,9 +158,14 @@ sub domain_form {
return $result;
}
-###############################################################
-###############################################################
-# Menu Phase One
+=pod
+
+=item print_main_menu()
+
+ Menu Phase One
+
+=cut
+
sub print_main_menu {
my ($r,$permission)=@_;
#
@@ -224,13 +252,15 @@ sub print_main_menu {
return;
}
-###############################################################
-###############################################################
+
+
sub hidden_input {
my ($name,$value) = @_;
return ''."\n";
}
+
+
sub print_upload_manager_header {
my ($r,$datatoken,$distotal,$krbdefdom)=@_;
my $javascript;
@@ -262,8 +292,9 @@ sub print_upload_manager_header {
$password_choice = 'int';
}
#
- my $javascript_validations=&javascript_validations('auth',$krbdefdom,
- $password_choice);
+ my $javascript_validations =
+ &javascript_validations('auth',$krbdefdom,$password_choice,undef,
+ $env{'request.role.domain'});
my $checked=(($env{'form.noFirstLine'})?' checked="checked" ':'');
$r->print('
'.&mt('Uploading Class List')."
\n".
"\n".
@@ -290,10 +321,12 @@ sub print_upload_manager_header {
$javascript."\n".$javascript_validations.'');
}
-###############################################################
-###############################################################
+
+
+
+
sub javascript_validations {
- my ($mode,$krbdefdom,$curr_authtype,$curr_authfield)=@_;
+ my ($mode,$krbdefdom,$curr_authtype,$curr_authfield,$domain)=@_;
my $authheader;
if ($mode eq 'auth') {
my %param = ( formname => 'studentform',
@@ -302,7 +335,7 @@ sub javascript_validations {
$authheader = &Apache::loncommon::authform_header(%param);
} elsif ($mode eq 'createcourse') {
my %param = ( formname => 'ccrs',
- kerb_def_dom => $krbdefdom,
+ kerb_def_dom => $krbdefdom,
curr_authtype => $curr_authtype );
$authheader = &Apache::loncommon::authform_header(%param);
} elsif ($mode eq 'modifycourse') {
@@ -323,7 +356,7 @@ sub javascript_validations {
name => 'The optional name field was not specified.',
snum => 'The optional student number field was not specified.',
section => 'The optional section field was not specified.',
- email => 'The optional email address field was not specified.',
+ email => 'The optional e-mail address field was not specified.',
continue => 'Continue enrollment?',
);
@@ -331,6 +364,7 @@ sub javascript_validations {
my $function_name =(< 1) {
+ $auth_checks .= (< "Personal Data",
'fn' => "First Name",
'mn' => "Middle Name",
'ln' => "Last Name",
'gen' => "Generation",
'hs' => "Home Server",
- 'pswd' => "Password",
+ 'pswd' => "Login Data",
'psam' => "Please select an authentication mechanism",
- 'mail' => "Email Address"
+ 'mail' => "E-mail Address"
);
my $authhelp=&Apache::loncommon::help_open_topic('Auth_Options');
$user_data_html = <
$lt{'pswd'}
$lt{'psam'}$authhelp
-
-$krbform
-
-$intform
-
-$locform
-
END
+ if ($krbform ne '') {
+ $user_data_html .= $krbform.' ';
+ }
+ if ($intform ne '') {
+ $user_data_html .= $intform.' ';
+ }
+ if ($locform ne '') {
+ $user_data_html .= $locform.' ';
+ }
+ $user_data_html .= "\n\n"
} else {
# User already exists. Do not worry about authentication
my %uenv = &Apache::lonnet::dump('environment',$ccdomain,$ccuname);
- $javascript_validations = &javascript_validations('noauth');
+ $javascript_validations = &Apache::lonuserutils::javascript_validations('noauth');
my %lt=&Apache::lonlocal::texthash(
'udf' => "User Data for",
'fn' => "First Name",
'mn' => "Middle Name",
'ln' => "Last Name",
'gen' => "Generation",
- 'mail' => "Email Address",
+ 'mail' => "E-mail Address",
);
$user_data_html = <$lt{'udf'} $ccuname:$ccdomain
@@ -1147,7 +1203,7 @@ END
END
}
- my $date_table = &date_setting_table();
+ my $date_table = &Apache::lonuserutils::date_setting_table();
# Print it all out
my %lt=&Apache::lonlocal::texthash(
'cd' => "Course Data",
@@ -1236,7 +1292,14 @@ END
return;
}
-# ========================================================= Menu Phase Two Drop
+=pod
+
+=item print_drop_menu()
+
+ Menu Phase Two Drop
+
+=cut
+
sub print_drop_menu {
my $r=shift;
$r->print("
".&mt('Drop Students')."
");
@@ -1251,7 +1314,15 @@ sub print_drop_menu {
return;
}
-# ============================================== view classlist
+
+=pod
+
+=item print_html_classlist()
+
+ view classlist
+
+=cut
+
sub print_html_classlist {
my ($r,$mode,$permission) = @_;
if (! exists($env{'form.sortby'})) {
@@ -1341,7 +1412,15 @@ sub print_html_classlist {
}
}
-# =================================================== Show student list to drop
+
+=pod
+
+=item show_class_list()
+
+ Show student list to drop
+
+=cut
+
sub show_class_list {
my ($r,$mode,$linkto,$statusmode,$classlist,$keylist)=@_;
my $cid=$env{'request.course.id'};
@@ -1365,6 +1444,11 @@ sub show_class_list {
}
my $displayphotos = $env{'form.displayphotos'};
+ if (! exists($env{'form.displayclickers'})) {
+ $env{'form.displayclickers'} = 'off';
+ }
+ my $displayclickers = $env{'form.displayclickers'};
+
# Print out header
unless ($mode eq 'autoenroll') {
$r->print(<print(<
+
END
if ($mode eq 'html' || $mode eq 'view' || $mode eq 'autoenroll') {
if ($linkto eq 'aboutme') {
@@ -1390,7 +1475,8 @@ END
'start' => "start date",
'end' => "end date",
'type' => "enroll type/action",
- 'email' => "email address",
+ 'email' => "e-mail address",
+ 'clicker'=> "clicker id",
'photo' => "photo",
);
unless ($mode eq 'autoenroll') {
@@ -1447,6 +1533,24 @@ function photowindow(photolink) {
$lt{'email'}
END
+
+# Clicker display on or off?
+
+ my %clicker_options = &Apache::lonlocal::texthash(
+ 'on' => 'Show',
+ 'off' => 'Hide',
+ );
+ my $clickerchg = 'on';
+ if ($displayclickers eq 'on') {
+ $clickerchg = 'off';
+ }
+ $r->print('
'."\n");
+
+# Photo display on or off?
if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) {
my %photo_options = &Apache::lonlocal::texthash(
'on' => 'Show',
@@ -1463,6 +1567,9 @@ END
' '."\n");
}
$r->print(" \n");
+
+# Done with the HTML header line
+
} elsif ($mode eq 'csv') {
#
# Open a file
@@ -1471,9 +1578,9 @@ END
time.'_'.rand(1000000000).'.csv';
unless ($CSVfile = Apache::File->new('>/home/httpd'.$CSVfilename)) {
$r->log_error("Couldn't open $CSVfilename for output $!");
- $r->print("Problems occured in writing the csv file. ".
- "This error has been logged. ".
- "Please alert your LON-CAPA administrator.");
+ $r->print(&mt('Problems occurred in writing the csv file. '
+ .'This error has been logged. '
+ .'Please alert your LON-CAPA administrator.'));
$CSVfile = undef;
}
#
@@ -1515,6 +1622,9 @@ END
"active groups","email address"],
$format->{'bold'});
}
+
+# Done with header lines in all formats
+
#
# Sort the students
my %index;
@@ -1623,6 +1733,19 @@ END
$active_groups
$email
END
+
+# Clickers
+ if ($displayclickers eq 'on') {
+ my $clickers =
+ (&Apache::lonnet::userenvironment($domain,$username,'clickers'))[1];
+ if ($clickers!~/\w/) { $clickers='-'; }
+ $r->print('
'.$clickers.'
');
+ } else {
+ $r->print('
');
+ }
+
+# Photos
+
if ($env{'course.'.$env{'request.course.id'}.
'.internal.showphoto'}) {
if ($displayphotos eq 'on') {
@@ -1699,9 +1822,14 @@ END
}
-#
-# print out form for modification of a single students data
-#
+=pod
+
+=item print_modify_student_form()
+
+ print out form for modification of a single students data
+
+=cut
+
sub print_modify_student_form {
my $r = shift();
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
@@ -1752,7 +1880,8 @@ sub print_modify_student_form {
&Apache::lonlocal::locallocaltime($endtime)).' ';
}
- my $date_table = &date_setting_table($starttime,$endtime);
+ my $date_table =
+ &Apache::lonuserutils::date_setting_table($starttime,$endtime);
#
if (! exists($env{'form.Status'}) ||
$env{'form.Status'} !~ /^(Any|Expired|Active|Future)$/) {
@@ -1774,7 +1903,7 @@ sub print_modify_student_form {
'sm' => "Submit Modifications",
);
# Check if section name is valid
- my $section_check = §ion_check_js();
+ my $section_check = &Apache::lonuserutils::section_check_js();
$r->print(<<"END");
';
+ &Apache::loncreateuser::restore_prev_selections();
+ my $srch;
+ foreach my $item (@search) {
+ $srch->{$item} = $env{'form.'.$item};
+ }
+
if ($env{'form.state'} eq 'gotusername') {
- my $srch;
- foreach my $item (@search) {
- $srch->{$item} = $env{'form.'.$item};
- }
if ($env{'form.phase'} eq 'get_user_info') {
my ($currstate,$response,$forcenewuser,$results) =
&Apache::loncreateuser::user_search_result($srch);
+ if ($env{'form.currstate'} eq 'modify') {
+ $currstate = $env{'form.currstate'};
+ }
if ($currstate eq 'select') {
$r->print(&header());
&Apache::lonhtmlcommon::add_breadcrumb
@@ -2753,7 +2902,7 @@ sub handler {
&print_enroll_single_student_form($r,$jscript,$ccuname,
$ccdomain,$srch);
} else {
- &get_student_username_domain_form($r,$elements);
+ &get_student_username_domain_form($r,$elements,undef,$srch);
}
} elsif ($env{'form.state'} eq 'enrolling') {
$r->print(&header($jscript));
@@ -2774,7 +2923,7 @@ sub handler {
'Course_Add_Student'));
&enroll_single_student($r,\@search);
} else {
- &get_student_username_domain_form($r,$elements);
+ &get_student_username_domain_form($r,$elements,undef,$srch);
}
} elsif ($env{'form.action'} eq 'classlist' && $permission->{'view'}) {
$r->print(&header());
@@ -2823,10 +2972,12 @@ sub handler {
return OK;
}
-###################################################################
-###################################################################
1;
__END__
+=pod
+
+=back
+=cut