--- loncom/interface/lonpopulate.pm 2005/04/07 07:34:52 1.24
+++ loncom/interface/lonpopulate.pm 2006/02/07 22:15:56 1.36
@@ -1,5 +1,5 @@
# automated enrollment configuration handler
-# $Id: lonpopulate.pm,v 1.24 2005/04/07 07:34:52 albertel Exp $
+# $Id: lonpopulate.pm,v 1.36 2006/02/07 22:15:56 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -151,27 +151,8 @@ function process(calling,numauto,nummanu
}
|;
if ($action eq 'viewclass') {
+ $scripttag .= &Apache::loncommon::check_uncheck_jscript();
$scripttag .= qq|
-function checkAll(field) {
- if (field.length > 0) {
- for (i = 0; i < field.length; i++) {
- field[i].checked = true ;
- }
- } else {
- field.checked = true
- }
-}
-
-function uncheckAll(field) {
- if (field.length > 0) {
- for (i = 0; i < field.length; i++) {
- field[i].checked = false ;
- }
- } else {
- field.checked = false ;
- }
-}
-
function countChecked(field) {
var count = 0;
if (field.length > 0) {
@@ -331,7 +312,7 @@ sub print_main_frame {
Use "Section settings" to make changes to the choice of sections included for enrollment in your LON-CAPA course.
-
Use "Student photos" to enable or disable automatic upload of student photos to your course.
+
Use "Student photos settings" to enable or disable automatic import of photos for registered students in your course.
@@ -339,6 +320,10 @@ sub print_main_frame {
+
Use "Update student photos" to import your institution's most current digital photos for registered students in your course.
+
+
+
Use "View students and change type" to display the current course roster, and (optionally) change enrollment type for selected students from 'auto' to 'manual' and vice versa.
@@ -504,15 +489,10 @@ ENDTWO
ENDTWO
} elsif ($action eq "notify") {
- my @notified = ();
- if ($enrollvar{notifylist} =~ m/,/) {
- @notified = split/,/,$enrollvar{notifylist};
- } else {
- @notified = $enrollvar{notifylist};
- }
my $notifycount = 0;
+ my @notified = split(/,/,$enrollvar{notifylist});
foreach (@notified) {
- unless ($_ eq '') { $notifycount ++; }
+ unless ($_ eq '') { $notifycount ++; }
}
my $noteset = '';
if ($notifycount) {
@@ -559,8 +539,8 @@ ENDTWO
my @roleinfo = split/:/,$_;
if ($roleinfo[0] eq 'cc') {
unless (grep/^$roleinfo[1]\@$roleinfo[2]/,@ccs) {
- my $active_cc = &LONCAPA::Enrollment::check_user_status($roleinfo[2],$roleinfo[1],$dom,$crs,'cc');
- if ($active_cc eq 'ok') {
+ my $active_cc = &Apache::loncommon::check_user_status($roleinfo[2],$roleinfo[1],$dom,$crs,'cc');
+ if ($active_cc eq 'active') {
push @ccs, "$roleinfo[1]\@$roleinfo[2]";
$pname{"$roleinfo[1]\@$roleinfo[2]"} = &Apache::loncommon::plainname($roleinfo[1],$roleinfo[2]);
if (grep/^$roleinfo[1]\@$roleinfo[2]$/,@notified) {
@@ -657,11 +637,9 @@ ENDTWO
");
} elsif ($action eq "crosslist") {
- my @xlists = ();
- if ($enrollvar{crosslistings} =~ m/,/) {
- @xlists = split/,/,$enrollvar{crosslistings};
- } elsif ($enrollvar{crosslistings} ne '') {
- $xlists[0] = $enrollvar{crosslistings};
+ my @xlists;
+ if ($enrollvar{crosslistings} ne '') {
+ @xlists = split(/,/,$enrollvar{crosslistings});
}
my $cross_str = @xlists;
$r->print("
@@ -690,7 +668,7 @@ ENDTWO
for (my $i=0; $i<@xlists; $i++) {
my $xl = ' ';
my $gp = ' ';
- if ($xlists[$i] =~ /(\w+):?(.*)$/) {
+ if ($xlists[$i] =~ /^([^:]+):?(.*)$/) {
$xl = $1;
$gp = $2;
}
@@ -742,14 +720,9 @@ ENDTWO
} elsif ($action eq "sections") {
my @sections = ();
@sections = &Apache::lonnet::auto_get_sections($crs,$dom,$enrollvar{coursecode});
- my @storedsections = ();
+ my @storedsections = split(/,/,$enrollvar{sectionnums});
my @currsections = ();
my %sec_id = ();
- if ($enrollvar{sectionnums} =~ m/,/) {
- @storedsections = split/,/,$enrollvar{sectionnums};
- } else {
- $storedsections[0] = $enrollvar{sectionnums};
- }
foreach (@storedsections) {
if ($_ =~ m/^(\w+):(\w*)$/) {
push @currsections, $1;
@@ -914,29 +887,87 @@ your changes.
No
");
}
- $r->print("
+ $r->print('
+
+
+ ');
+ my ($result,$perm_reqd)=&Apache::lonnet::auto_photo_permission($crs,$dom);
+ my $can_enable = 1;
+ my $institution = $Apache::lonnet::domaindescription{$dom};
+ if ($result eq 'ok') {
+ if ($perm_reqd eq 'yes') {
+ if (!($enrollvar{'photopermission'} eq 'yes')) {
+ $can_enable = 0;
+ } else {
+ if ($env{'user.name'} eq $enrollvar{'courseowner'}) {
+ $r->print('
+
+
'.
+&mt('Previously the owner of this course agreed to the conditions of use of digital student photos required by [_1].', $institution).' '.&mt('As a result Course Coordinators can choose to automatically import student photos into this course.').'
+ ');
+ }
+ }
+ }
+ } else {
+ $r->print('
+
+
'.
+&mt('There was a problem determining whether course owner permission is required in order for a course coordinator to have access to student photos in this domain.').' '.&mt('As a result you will not be able to configure access to student photos at this time').'
-
-Note: if you enable automatic import of student photos, your course will automatically have access to photos stored by your institution for all officially registered students, via a conduit established by your LON-CAPA domain coordinator.
+ '.
+&mt('Note: if you enable automatic import of student photos, your course will automatically have access to photos stored by your institution for officially registered students, via a conduit established by your LON-CAPA domain coordinator.').'
'.
+&mt('[_1] requires a course owner to indicate acceptance of conditions of use of digital student photos before enabling automatic import into a course. If you choose to enable import of photos you will be prompted for your agreement on the next page.',$institution).'
+
'.
+&mt('The policies of your institution [_1] require that the course owner [_2] must indicate acceptance of the conditions of use of digital photos of registered students, before they may be made available for use in a course.',$institution,$ownername).'
'.&mt('Please direct the course owner (e-mail: [_1]) to visit the "Student photos" page in the Automated Enrollment Manager to indicate acceptance of these conditions of use',$owneremail).'
");
+ if ($enrollvar{'showphotos'}) {
+ my ($update,$commentary) = &Apache::lonnet::auto_photochoice($crs,
+ $dom);
+ $r->print(' '.$commentary.'
+');
+ } else {
+ $r->print('Update of photos is unavailable, as import of student photos is currently disabled. Enable this first via: '.$$tasktitleref{'photos'}.'');
+ }
+ $r->print('
+
+
');
} elsif ($action eq 'viewclass') {
$r->print("
+';
+ } else {
+ my ($ownername,$owneremail) = &get_oenerinfo($dom,$courseowner);
+ $response = &mt('The policies of your institution [_1] require that the course owner [_2] must indicate acceptance of the conditions of use of digital photos of registered students, before they may be made available for use in a course.',$institution,$ownername).'
'.&mt('Please direct the course owner (e-mail: [_1]) to visit the "Student photos" page in the Automated Enrollment Manager to indicate acceptance of these conditions of use',$owneremail);
+ }
+ &print_reply($r,$response,$$tasktitleref{$action});
+}
+
+sub print_photos_response {
+ my ($r,$realm,$dom,$crs,$action,$tasktitleref,$showphotos,$photopermission,
+ $permissionenv)=@_;
+ my %newenv;
+ if (defined($permissionenv)) {
+ foreach my $key (keys(%{$permissionenv})) {
+ if (exists($env{'request.course.id'})) {
+ $newenv{$env{'request.course.id'}.'.'.$key} =
+ $$permissionenv{$key};
+ }
+ }
+ }
+ my %settings = &Apache::lonnet::get('environment',['internal.showphotos'],
+ $dom,$crs);
+ my $currphotos = $settings{'internal.showphotos'};
my $response = "";
+ if (defined($photopermission)) {
+ if ($photopermission eq 'yes') {
+ $response = &mt('Acceptance of photo use policy recorded.').' '."\n";
+ } else {
+ $response = &mt('Non-acceptance of photo use policy recorded.').' '."\n";
+ $showphotos = 0;
+ }
+ }
my %cenv = ('internal.showphotos' => $showphotos);
my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
if ($reply !~ /^ok$/) {
- $response = "There was a problem processing your requested change. The student photo import setting for this course has been left unchanged. ";
+ $response .= "There was a problem processing your requested change. The student photo retrieval setting for this course has been left unchanged. ";
} else {
if ($showphotos) {
if ($currphotos) {
- $response = "Retrieval of student photos is still enabled ";
+ $response .= "Retrieval of student photos is still enabled. ";
} else {
- $response = "Retrieval of student photos in now enabled ";
+ $response .= "Retrieval of student photos in now enabled. ";
+ my ($update,$commentary) =
+ &Apache::lonnet::auto_photochoice($crs,$dom);
+ if ($update) {
+ $response .= ' '.$commentary.'
+';
+ }
}
} else {
if ($currphotos) {
- $response = "Retrieval of student photos is now disabled ";
+ $response .= "Retrieval of student photos is now disabled. ";
} else {
- $response = "Retrieval of student photos is still disabled ";
+ $response .= "Retrieval of student photos is still disabled. ";
}
}
+ foreach my $key (keys(%cenv)) {
+ if (exists($env{'request.course.id'})) {
+ $newenv{'course.'.$env{'request.course.id'}.'.'.$key} =
+ $cenv{$key};
+ }
+ }
+ }
+ if (keys(%newenv) > 0) {
+ &Apache::lonnet::appenv(%newenv);
}
&print_reply($r,$response,$$tasktitleref{$action});
return;
}
+sub print_photoupdate_response {
+ my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
+ my $response;
+ my %changes;
+ my %lt = &LONCAPA::Enrollment::photo_response_types();
+ my %settings = &Apache::lonnet::get('environment',
+ ['internal.coursecode',
+ 'internal.sectionnums',
+ 'internal.crosslistings'],
+ $dom,$crs);
+ my @allcourses = ();
+ my %LC_code;
+ my %affiliates;
+ my $outcome;
+ &get_institutional_codes(\%settings,,\@allcourses,\%LC_code);
+ if (@allcourses > 0) {
+ @{$affiliates{$crs}} = @allcourses;
+ $outcome = &Apache::lonnet::auto_photoupdate(\%affiliates,$dom,$crs,\%changes);
+ unless ($outcome eq 'ok') {
+ &Apache::lonnet::logthis("lonpopulate::print_photoupdate_response".
+ "failed to update student photos".
+ " for ".$crs."\@".$dom." by ".
+ $env{'user.name'}." \@ ".$env{'user.domain'}.
+ ": ".$outcome);
+ }
+ if ($outcome eq 'ok') {
+ if (keys(%changes) > 0) {
+ $response = &mt('Update of photos for registered students resulted in the following ').':
+';
+ foreach my $type (sort(keys(%changes))) {
+ my @usernames = sort(split(/\&/,$changes{$type}));
+ my $count = @usernames;
+ $response .= ''.&mt('For [_1] students, photos ',
+ $count).$lt{$type}.'