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.
@@ -320,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.
");
+ if ($enrollvar{'showphoto'}) {
+ my ($update,$commentary) = &Apache::lonnet::auto_photochoice($crs,
+ $dom);
+ if ($update) {
+ $r->print(' '.$commentary.'
+
+
+
+
+
');
+ } else {
+ $r->print(&mt('Update of photos via the Automated Enrollment Manager is unavailable in this domain.').'
');
+ }
+ } else {
+ $r->print('Update of photos is unavailable, as import of student photos is currently disabled. Enable this first via: '.$$tasktitleref{'photos'}.'');
+ }
+ $r->print('
");
@@ -1247,13 +1342,13 @@ sub print_chgsettings_response {
}
if ($autodrops) {
if ($currdrops) {
- $response .= "Nightly removals based on classlist changes still enabled ";
+ $response .= "Nightly removals based on classlist changes still enabled ";
} else {
$response .= "Nightly removals based on classlist changes now enabled ";
}
} else {
if ($currdrops) {
- $response .= "Nightly removals based on classlist changes now disabled ";
+ $response .= "Nightly removals based on classlist changes now disabled ";
} else {
$response .= "Nightly removals based on classlist changes still disabled";
}
@@ -1354,7 +1449,7 @@ sub print_setdates_response {
$firstaccess = "a date prior to today";
}
if (($nowstamp >= $autostart) && ($rosterupdated == 0)) {
- $response .= qq| Although you have now set the first enrollment date to $firstaccess, automatic enrollment will not occur until the next automatic enrollment update occurs for all LON-CAPA courses at 1.30 am $nextupdate. If you wish to immediately enroll registered students included in the institutional classlist for this class, please visit the roster update page. |;
+ $response .= qq| Although you have now set the first enrollment date to $firstaccess, automatic enrollment will not occur until the next automatic enrollment update occurs for all LON-CAPA courses at 1.30 am $nextupdate. If you wish to immediately enroll registered students included in the institutional classlist for this class, please visit the roster update page. |;
}
}
$warning = &warning_message($dom,$crs,$action);
@@ -1454,7 +1549,7 @@ $showend. ";
$firstaccess = "a date prior to today";
}
if (($nowstamp >= $startaccess) && ($accessgiven == 0)) {
- $response .= qq| Although you have now set the first access date to $firstaccess, automatic enrollment will not occur until the next automatic enrollment update occurs for all LON-CAPA courses $nextupdate. If you wish to grant immediate course access for registered students included in the institutional classlist for this class, please visit the roster update page. |;
+ $response .= qq| Although you have now set the first access date to $firstaccess, automatic enrollment will not occur until the next automatic enrollment update occurs for all LON-CAPA courses $nextupdate. If you wish to grant immediate course access for registered students included in the institutional classlist for this class, please visit the roster update page. |;
}
}
$warning = &warning_message($dom,$crs,$action);
@@ -1628,13 +1723,13 @@ sub print_crosslistings_menu () {
-
+
-
-
-
+
+
+
);
}
@@ -1911,13 +2006,13 @@ sections which contribute to enrollment
-
+
-
-
-
+
+
+
);
}
@@ -2023,39 +2118,276 @@ sub print_sections_response () {
return;
}
-sub print_photos_response () {
+sub photo_permission {
my ($r,$realm,$dom,$crs,$action,$tasktitleref) = @_;
- my %settings = &Apache::lonnet::get('environment',['internal.showphotos'],$dom,$crs);
- my $currphotos = $settings{'internal.showphotos'};
- my $showphotos = '';
- if ( exists($env{'form.showphotos'}) ) {
- $showphotos=$env{'form.showphotos'};
+ my %settings = &Apache::lonnet::get('environment',
+ ['internal.courseowner',
+ 'internal.photopermission',
+ 'internal.showphoto'],
+ $dom,$crs);
+ my ($showphotos,$response);
+ if (exists($env{'form.cancel_agreement'})) {
+ if ($env{'user.name'} eq $settings{'internal.courseowner'}) {
+ my %cenv = (
+ 'internal.photopermission' => 'no',
+ );
+ my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
+ if ($reply !~ /^ok$/) {
+ $response = &mt('There was a problem processing the record of your agreement to the conditions of use. Settings for this course have been left unchanged.').' '."\n";
+ &print_reply($r,$response,$$tasktitleref{$action});
+ } else {
+ &print_photos_response($r,$realm,$dom,$crs,$action,
+ $tasktitleref,$showphotos,'no',\%cenv);
+ }
+ return;
+ }
+ }
+ if (exists($env{'form.showphotos'})) {
+ $showphotos=$env{'form.showphotos'};
+ }
+ if ($showphotos) {
+ if ($env{'form.photopermission'}) {
+ my %cenv = (
+ 'internal.photopermission' => $env{'form.photopermission'},
+ );
+ my $reply = &Apache::lonnet::put('environment',\%cenv,$dom,$crs);
+ if ($reply !~ /^ok$/) {
+ $response = &mt('There was a problem processing the record of your agreement to the conditions of use. Settings for this course have been left unchanged.').' '."\n";
+ } else {
+ &print_photos_response($r,$realm,$dom,$crs,$action,
+ $tasktitleref,$showphotos,
+ $env{'form.photopermission'},\%cenv);
+ }
+ } else {
+ my ($result,$perm_reqd,$conditions) =
+ &Apache::lonnet::auto_photo_permission($crs,$dom);
+ my $permcheck;
+ if ($result eq 'ok') {
+ if ($perm_reqd eq 'yes') {
+ if ($settings{'internal.photopermission'} eq 'yes') {
+ &print_photos_response($r,$realm,$dom,$crs,$action,
+ $tasktitleref,$showphotos);
+ } else {
+ return(&print_photo_agreement($r,$realm,$dom,$crs,
+ $action,$tasktitleref,
+ $conditions,
+ $settings{'internal.courseowner'}));
+ }
+ } elsif ($perm_reqd eq 'no') {
+ &print_photos_response($r,$realm,$dom,$crs,$action,
+ $tasktitleref,$showphotos);
+ } else {
+ $permcheck = 'fail';
+ }
+ } else {
+ $permcheck = 'fail';
+ }
+ if ($permcheck eq 'fail') {
+ my $response = &mt('There was a problem processing your requested change, because it could not be determined whether course owner permission is required in order for a course coordinator to have access to student photos in this domain.').' '.&mt('The student photo import setting for this course has been left unchanged.').' ';
+ &print_reply($r,$response,$$tasktitleref{$action});
+ }
+ }
+ } else {
+ &print_photos_response($r,$realm,$dom,$crs,$action,$tasktitleref);
}
-
+ return;
+}
+
+sub print_photo_agreement {
+ my ($r,$realm,$dom,$crs,$action,$tasktitleref,$conditions,$courseowner)=@_;
+ my $response;
+ my $institution = $Apache::lonnet::domaindescription{$dom};
+ if ($env{'user.name'} eq $courseowner) {
+ $response = '
+
+
+
+
+
Use of student photos '."\n".
+ &mt('Acceptance by the course owner of the conditions of use of photos is currently [_1] set.','not').' '.&mt('Please indicate your acceptance of the conditions of use of digital photos of registered students in courses at [_1].',$institution).'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+';
+ } 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.showphoto'],
+ $dom,$crs);
+ my $currphotos = $settings{'internal.showphoto'};
my $response = "";
- my %cenv = ('internal.showphotos' => $showphotos);
+ 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.showphoto' => $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}.'