version 1.92, 2017/04/08 14:58:11
|
version 1.96, 2021/06/15 20:52:26
|
Line 39 use Apache::lonpickcourse;
|
Line 39 use Apache::lonpickcourse;
|
use lib '/home/httpd/lib/perl'; |
use lib '/home/httpd/lib/perl'; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
|
|
|
my $registered_cleanup; |
|
my $modified_dom; |
|
|
sub get_dc_settable { |
sub get_dc_settable { |
my ($type,$cdom) = @_; |
my ($type,$cdom) = @_; |
if ($type eq 'Community') { |
if ($type eq 'Community') { |
Line 49 sub get_dc_settable {
|
Line 52 sub get_dc_settable {
|
if (&showcredits($cdom)) { |
if (&showcredits($cdom)) { |
push(@items,'defaultcredits'); |
push(@items,'defaultcredits'); |
} |
} |
|
my %passwdconf = &Apache::lonnet::get_passwdconf($cdom); |
|
if (($passwdconf{'crsownerchg'}) && ($type ne 'Placement')) { |
|
push(@items,'nopasswdchg'); |
|
} |
return @items; |
return @items; |
} |
} |
} |
} |
Line 101 sub get_enrollment_settings {
|
Line 108 sub get_enrollment_settings {
|
@items = map { 'internal.'.$_; } (@{$internals}); |
@items = map { 'internal.'.$_; } (@{$internals}); |
push(@items,@{$accessdates}); |
push(@items,@{$accessdates}); |
} |
} |
|
push(@items,'internal.nopasswdchg'); |
my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum); |
my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum); |
my %enrollvar; |
my %enrollvar; |
$enrollvar{'autharg'} = ''; |
$enrollvar{'autharg'} = ''; |
Line 126 sub get_enrollment_settings {
|
Line 134 sub get_enrollment_settings {
|
} elsif ($type eq "authtype" |
} elsif ($type eq "authtype" |
|| $type eq "autharg" || $type eq "coursecode" |
|| $type eq "autharg" || $type eq "coursecode" |
|| $type eq "crosslistings" || $type eq "selfenrollmgr" |
|| $type eq "crosslistings" || $type eq "selfenrollmgr" |
|| $type eq "autodropfailsafe") { |
|| $type eq "autodropfailsafe" || $type eq 'nopasswdchg') { |
$enrollvar{$type} = $settings{$item}; |
$enrollvar{$type} = $settings{$item}; |
} elsif ($type eq 'defaultcredits') { |
} elsif ($type eq 'defaultcredits') { |
if (&showcredits($cdom)) { |
if (&showcredits($cdom)) { |
Line 676 sub print_settings_display {
|
Line 684 sub print_settings_display {
|
"<th>$lt{'dcon'}</th>\n". |
"<th>$lt{'dcon'}</th>\n". |
&Apache::loncommon::end_data_table_header_row()."\n"; |
&Apache::loncommon::end_data_table_header_row()."\n"; |
foreach my $item (@items) { |
foreach my $item (@items) { |
|
my $shown = $enrollvar{$item}; |
|
if ($item eq 'crosslistings') { |
|
my (@xlists,@lcsecs); |
|
foreach my $entry (split(/,/,$enrollvar{$item})) { |
|
my ($xlist,$lc_sec) = split(/:/,$entry); |
|
push(@xlists,$xlist); |
|
push(@lcsecs,$lc_sec); |
|
} |
|
if (@xlists) { |
|
my $crskey = $cnum.':'.$enrollvar{'coursecode'}; |
|
my %reformatted = |
|
&Apache::lonnet::auto_instsec_reformat($cdom,'declutter', |
|
{$crskey => \@xlists}); |
|
if (ref($reformatted{$crskey}) eq 'ARRAY') { |
|
my @show; |
|
my @xlcodes = @{$reformatted{$crskey}}; |
|
for (my $i=0; $i<@xlcodes; $i++) { |
|
push(@show,$xlcodes[$i].':'.$lcsecs[$i]); |
|
} |
|
if (@show) { |
|
$shown = join(',',@show); |
|
} |
|
} |
|
} |
|
} |
$disp_table .= &Apache::loncommon::start_data_table_row()."\n". |
$disp_table .= &Apache::loncommon::start_data_table_row()."\n". |
"<td><b>$longtype{$item}</b></td>\n". |
"<td><b>$longtype{$item}</b></td>\n". |
"<td>$enrollvar{$item}</td>\n"; |
"<td>$shown</td>\n"; |
if (grep(/^\Q$item\E$/,@modifiable_params)) { |
if (grep(/^\Q$item\E$/,@modifiable_params)) { |
$disp_table .= '<td align="right">'.&mt('Yes').'</td>'."\n"; |
$disp_table .= '<td align="right">'.&mt('Yes').'</td>'."\n"; |
} else { |
} else { |
Line 1033 sub print_course_modification_page {
|
Line 1066 sub print_course_modification_page {
|
my @specific_managebydc = split(/,/,$settings{'internal.selfenrollmgrdc'}); |
my @specific_managebydc = split(/,/,$settings{'internal.selfenrollmgrdc'}); |
my @specific_managebycc = split(/,/,$settings{'internal.selfenrollmgrcc'}); |
my @specific_managebycc = split(/,/,$settings{'internal.selfenrollmgrcc'}); |
my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom); |
my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom); |
|
my %passwdconf = &Apache::lonnet::get_passwdconf($cdom); |
my @default_managebydc = split(/,/,$domdefaults{$type.'selfenrolladmdc'}); |
my @default_managebydc = split(/,/,$domdefaults{$type.'selfenrolladmdc'}); |
if ($crstype eq 'Community') { |
if ($crstype eq 'Community') { |
$ccrole = 'co'; |
$ccrole = 'co'; |
Line 1107 sub print_course_modification_page {
|
Line 1141 sub print_course_modification_page {
|
if ($crstype eq 'Community') { |
if ($crstype eq 'Community') { |
$r->print(&Apache::lonhtmlcommon::row_title( |
$r->print(&Apache::lonhtmlcommon::row_title( |
&Apache::loncommon::help_open_topic('Modify_Community_Owner'). |
&Apache::loncommon::help_open_topic('Modify_Community_Owner'). |
' '.&mt('Community Owner'))."\n"); |
' '.&mt('Community Owner'))."\n". |
|
$ownertable."\n".&Apache::lonhtmlcommon::row_closure()); |
} else { |
} else { |
$r->print(&Apache::lonhtmlcommon::row_title( |
$r->print(&Apache::lonhtmlcommon::row_title( |
&Apache::loncommon::help_open_topic('Modify_Course_Instcode'). |
&Apache::loncommon::help_open_topic('Modify_Course_Instcode'). |
Line 1117 sub print_course_modification_page {
|
Line 1152 sub print_course_modification_page {
|
if (($crstype eq 'Course') && (&showcredits($cdom))) { |
if (($crstype eq 'Course') && (&showcredits($cdom))) { |
$r->print(&Apache::lonhtmlcommon::row_title( |
$r->print(&Apache::lonhtmlcommon::row_title( |
&Apache::loncommon::help_open_topic('Modify_Course_Credithours'). |
&Apache::loncommon::help_open_topic('Modify_Course_Credithours'). |
' '.&mt('Credits (students)'))."\n". |
' '.&mt('Credits (students)'))."\n". |
'<input type="text" size="3" name="defaultcredits" value="'.$enrollvar{'defaultcredits'}.'"'.$disabled.' />'. |
'<input type="text" size="3" name="defaultcredits" value="'.$enrollvar{'defaultcredits'}.'"'.$disabled.' />'. |
&Apache::lonhtmlcommon::row_closure()); |
&Apache::lonhtmlcommon::row_closure()); |
} |
} |
Line 1127 sub print_course_modification_page {
|
Line 1162 sub print_course_modification_page {
|
$authenitems."\n". |
$authenitems."\n". |
&Apache::lonhtmlcommon::row_closure(). |
&Apache::lonhtmlcommon::row_closure(). |
&Apache::lonhtmlcommon::row_title( |
&Apache::lonhtmlcommon::row_title( |
&Apache::loncommon::help_open_topic('Modify_Course_Owner'). |
&Apache::loncommon::help_open_topic('Modify_Course_Owner'). |
' '.&mt('Course Owner'))."\n"); |
' '.&mt('Course Owner'))."\n". |
|
$ownertable."\n".&Apache::lonhtmlcommon::row_closure()); |
|
if (($passwdconf{'crsownerchg'}) && ($type ne 'Placement')) { |
|
my $checked; |
|
if ($enrollvar{'nopasswdchg'}) { |
|
$checked = ' checked="checked"'; |
|
} |
|
$r->print(&Apache::lonhtmlcommon::row_title( |
|
&Apache::loncommon::help_open_topic('Modify_Course_Chgpasswd'). |
|
' '.&mt('Changing passwords (internal)'))."\n". |
|
'<label><input type="checkbox" value="1" name="nopasswdchg"'.$checked.$disabled.' />'. |
|
&mt('Disable changing password for users with student role by course owner').'<label>'."\n". |
|
&Apache::lonhtmlcommon::row_closure()); |
|
} |
} |
} |
my ($cctitle,$rolename,$currmanages,$ccchecked,$dcchecked,$defaultchecked); |
my ($cctitle,$rolename,$currmanages,$ccchecked,$dcchecked,$defaultchecked); |
my ($selfenrollrows,$selfenrolltitles) = &Apache::lonuserutils::get_selfenroll_titles(); |
my ($selfenrollrows,$selfenrolltitles) = &Apache::lonuserutils::get_selfenroll_titles(); |
Line 1138 sub print_course_modification_page {
|
Line 1186 sub print_course_modification_page {
|
$cctitle = &mt('Course personnel'); |
$cctitle = &mt('Course personnel'); |
} |
} |
|
|
$r->print($ownertable."\n".&Apache::lonhtmlcommon::row_closure(). |
$r->print(&Apache::lonhtmlcommon::row_title( |
&Apache::lonhtmlcommon::row_title( |
|
&Apache::loncommon::help_open_topic('Modify_Course_Selfenrolladmin'). |
&Apache::loncommon::help_open_topic('Modify_Course_Selfenrolladmin'). |
' '.&mt('Self-enrollment configuration')). |
' '.&mt('Self-enrollment configuration')). |
&Apache::loncommon::start_data_table()."\n". |
&Apache::loncommon::start_data_table()."\n". |
Line 1277 sub gather_authenitems {
|
Line 1324 sub gather_authenitems {
|
$curr_authtype = 'int'; |
$curr_authtype = 'int'; |
} elsif ($enrollvar->{'authtype'} eq 'localauth' ) { |
} elsif ($enrollvar->{'authtype'} eq 'localauth' ) { |
$curr_authtype = 'loc'; |
$curr_authtype = 'loc'; |
|
} elsif ($enrollvar->{'authtype'} eq 'lti' ) { |
|
$curr_authtype = 'lti'; |
} |
} |
} |
} |
unless ($curr_authtype eq '') { |
unless ($curr_authtype eq '') { |
Line 1297 sub gather_authenitems {
|
Line 1346 sub gather_authenitems {
|
$authform{'krb'} = &Apache::loncommon::authform_kerberos(%param); |
$authform{'krb'} = &Apache::loncommon::authform_kerberos(%param); |
$authform{'int'} = &Apache::loncommon::authform_internal(%param); |
$authform{'int'} = &Apache::loncommon::authform_internal(%param); |
$authform{'loc'} = &Apache::loncommon::authform_local(%param); |
$authform{'loc'} = &Apache::loncommon::authform_local(%param); |
foreach my $item ('krb','int','loc') { |
$authform{'lti'} = &Apache::loncommon::authform_lti(%param); |
|
foreach my $item ('krb','int','loc','lti') { |
if ($authform{$item} ne '') { |
if ($authform{$item} ne '') { |
$authenitems .= $authform{$item}.'<br />'; |
$authenitems .= $authform{$item}.'<br />'; |
} |
} |
Line 1318 sub modify_course {
|
Line 1368 sub modify_course {
|
if (&showcredits($cdom)) { |
if (&showcredits($cdom)) { |
push(@items,'internal.defaultcredits'); |
push(@items,'internal.defaultcredits'); |
} |
} |
|
my %passwdconf = &Apache::lonnet::get_passwdconf($cdom); |
|
if ($passwdconf{'crsownerchg'}) { |
|
push(@items,'internal.nopasswdchg'); |
|
} |
} |
} |
my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum); |
my %settings = &Apache::lonnet::get('environment',\@items,$cdom,$cnum); |
my $description = $settings{'description'}; |
my $description = $settings{'description'}; |
Line 1333 sub modify_course {
|
Line 1387 sub modify_course {
|
} else { |
} else { |
%changed = ( code => 0, |
%changed = ( code => 0, |
owner => 0, |
owner => 0, |
|
passwd => 0, |
); |
); |
$ccrole = 'cc'; |
$ccrole = 'cc'; |
unless ($settings{'internal.sectionnums'} eq '') { |
unless ($settings{'internal.sectionnums'} eq '') { |
Line 1363 sub modify_course {
|
Line 1418 sub modify_course {
|
if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) { |
if ((defined($env{'form.locarg'})) && ($env{'form.locarg'})) { |
$newattr{'autharg'} = $env{'form.locarg'}; |
$newattr{'autharg'} = $env{'form.locarg'}; |
} |
} |
|
} elsif ($env{'form.login'} eq 'lti') { |
|
$newattr{'authtype'} = 'lti'; |
} |
} |
if ( $newattr{'authtype'}=~ /^krb/) { |
if ( $newattr{'authtype'}=~ /^krb/) { |
if ($newattr{'autharg'} eq '') { |
if ($newattr{'autharg'} eq '') { |
Line 1385 sub modify_course {
|
Line 1442 sub modify_course {
|
$newattr{'mysqltables'} = $env{'form.mysqltables'}; |
$newattr{'mysqltables'} = $env{'form.mysqltables'}; |
$newattr{'mysqltables'} =~ s/\D+//g; |
$newattr{'mysqltables'} =~ s/\D+//g; |
} |
} |
if (($type ne 'Placement') && (&showcredits($cdom) && exists($env{'form.defaultcredits'}))) { |
if ($type ne 'Placement') { |
$newattr{'defaultcredits'}=$env{'form.defaultcredits'}; |
if (&showcredits($cdom) && exists($env{'form.defaultcredits'})) { |
$newattr{'defaultcredits'} =~ s/[^\d\.]//g; |
$newattr{'defaultcredits'}=$env{'form.defaultcredits'}; |
|
$newattr{'defaultcredits'} =~ s/[^\d\.]//g; |
|
} |
|
if (grep(/^nopasswdchg$/,@modifiable_params)) { |
|
if ($env{'form.nopasswdchg'}) { |
|
$newattr{'nopasswdchg'} = 1; |
|
unless ($currattr{'nopasswdchg'}) { |
|
$changed{'passwd'} = 1; |
|
} |
|
} elsif ($currattr{'nopasswdchg'}) { |
|
$changed{'passwd'} = 1; |
|
} |
|
} |
} |
} |
} |
} |
|
|
Line 1422 sub modify_course {
|
Line 1491 sub modify_course {
|
} |
} |
} |
} |
|
|
if ($changed{'owner'} || $changed{'code'}) { |
if ($changed{'owner'} || $changed{'code'} || $changed{'passwd'}) { |
my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum, |
my %crsinfo = &Apache::lonnet::courseiddump($cdom,'.',1,'.','.',$cnum, |
undef,undef,'.'); |
undef,undef,'.'); |
if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') { |
if (ref($crsinfo{$env{'form.pickedcourse'}}) eq 'HASH') { |
Line 1432 sub modify_course {
|
Line 1501 sub modify_course {
|
if ($changed{'owner'}) { |
if ($changed{'owner'}) { |
$crsinfo{$env{'form.pickedcourse'}}{'owner'} = $env{'form.courseowner'}; |
$crsinfo{$env{'form.pickedcourse'}}{'owner'} = $env{'form.courseowner'}; |
} |
} |
|
if ($changed{'passwd'}) { |
|
if ($env{'form.nopasswdchg'}) { |
|
$crsinfo{$env{'form.pickedcourse'}}{'nopasswdchg'} = 1; |
|
} else { |
|
delete($crsinfo{'nopasswdchg'}); |
|
} |
|
} |
my $chome = &Apache::lonnet::homeserver($cnum,$cdom); |
my $chome = &Apache::lonnet::homeserver($cnum,$cdom); |
my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime'); |
my $putres = &Apache::lonnet::courseidput($cdom,\%crsinfo,$chome,'notime'); |
if ($putres eq 'ok') { |
if (($putres eq 'ok') && (($changed{'owner'} || $changed{'code'}))) { |
&update_coowners($cdom,$cnum,$chome,\%settings,\%newattr); |
&update_coowners($cdom,$cnum,$chome,\%settings,\%newattr); |
|
if ($changed{'code'}) { |
|
&Apache::lonnet::devalidate_cache_new('instcats',$cdom); |
|
# Update cache of self-cataloging courses on institution's server(s). |
|
if (&Apache::lonnet::shared_institution($cdom)) { |
|
unless ($registered_cleanup) { |
|
my $handlers = $r->get_handlers('PerlCleanupHandler'); |
|
$r->set_handlers('PerlCleanupHandler' => [\&devalidate_remote_instcats,@{$handlers}]); |
|
$registered_cleanup=1; |
|
$modified_dom = $cdom; |
|
} |
|
} |
|
} |
} |
} |
} |
} |
} |
} |
Line 1481 sub modify_course {
|
Line 1569 sub modify_course {
|
$shown = &mt('None'); |
$shown = &mt('None'); |
} elsif (($attr eq 'mysqltables') && ($shown eq '')) { |
} elsif (($attr eq 'mysqltables') && ($shown eq '')) { |
$shown = &mt('domain default'); |
$shown = &mt('domain default'); |
|
} elsif ($attr eq 'nopasswdchg') { |
|
if ($shown) { |
|
$shown = &mt('Yes'); |
|
} else { |
|
$shown = &mt('No'); |
|
} |
} |
} |
$chgresponse .= '<li>'.&mt('[_1] now set to: [_2]',$longtype{$attr},$shown).'</li>'; |
$chgresponse .= '<li>'.&mt('[_1] now set to: [_2]',$longtype{$attr},$shown).'</li>'; |
} else { |
} else { |
Line 1493 sub modify_course {
|
Line 1587 sub modify_course {
|
$shown = &mt('None'); |
$shown = &mt('None'); |
} elsif (($attr eq 'mysqltables') && ($shown eq '')) { |
} elsif (($attr eq 'mysqltables') && ($shown eq '')) { |
$shown = &mt('domain default'); |
$shown = &mt('domain default'); |
|
} elsif ($attr eq 'nopasswdchg') { |
|
if ($shown) { |
|
$shown = &mt('Yes'); |
|
} else { |
|
$shown = &mt('No'); |
|
} |
} |
} |
$nochgresponse .= '<li>'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'</li>'; |
$nochgresponse .= '<li>'.&mt('[_1] still set to: [_2]',$longtype{$attr},$shown).'</li>'; |
} |
} |
Line 2409 sub course_settings_descrip {
|
Line 2509 sub course_settings_descrip {
|
'selfenrollmgrdc' => "Course-specific self-enrollment configuration by Domain Coordinator", |
'selfenrollmgrdc' => "Course-specific self-enrollment configuration by Domain Coordinator", |
'selfenrollmgrcc' => "Course-specific self-enrollment configuration by Course personnel", |
'selfenrollmgrcc' => "Course-specific self-enrollment configuration by Course personnel", |
'mysqltables' => '"Temporary" student performance tables lifetime (seconds)', |
'mysqltables' => '"Temporary" student performance tables lifetime (seconds)', |
|
'nopasswdchg' => 'Disable changing password for users with student role by course owner', |
); |
); |
} |
} |
return %longtype; |
return %longtype; |
Line 2421 sub hidden_form_elements {
|
Line 2522 sub hidden_form_elements {
|
'locarg','krbarg','krbver','counter','hidefromcat','usecategory', |
'locarg','krbarg','krbver','counter','hidefromcat','usecategory', |
'threshold','postsubmit','postsubtimeout','defaultcredits','uploadquota', |
'threshold','postsubmit','postsubtimeout','defaultcredits','uploadquota', |
'selfenrollmgrdc','selfenrollmgrcc','action','state','currsec_st', |
'selfenrollmgrdc','selfenrollmgrcc','action','state','currsec_st', |
'sections','newsec','mysqltables'],['^selfenrollmgr_','^selfenroll_'])."\n". |
'sections','newsec','mysqltables','nopasswdchg'], |
|
['^selfenrollmgr_','^selfenroll_'])."\n". |
'<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />'; |
'<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />'; |
return $hidden_elements; |
return $hidden_elements; |
} |
} |
Line 2437 sub showcredits {
|
Line 2539 sub showcredits {
|
sub get_permission { |
sub get_permission { |
my ($dom) = @_; |
my ($dom) = @_; |
my ($allowed,%permission); |
my ($allowed,%permission); |
|
my %passwdconf = &Apache::lonnet::get_passwdconf($dom); |
if (&Apache::lonnet::allowed('ccc',$dom)) { |
if (&Apache::lonnet::allowed('ccc',$dom)) { |
$allowed = 1; |
$allowed = 1; |
%permission = ( |
%permission = ( |
Line 2454 sub get_permission {
|
Line 2557 sub get_permission {
|
selfenroll => 'edit', |
selfenroll => 'edit', |
adhocrole => 'coord', |
adhocrole => 'coord', |
); |
); |
|
if ($passwdconf{'crsownerchg'}) { |
|
$permission{passwdchg} = 'edit'; |
|
} |
} elsif (&Apache::lonnet::allowed('rar',$dom)) { |
} elsif (&Apache::lonnet::allowed('rar',$dom)) { |
$allowed = 1; |
$allowed = 1; |
%permission = ( |
%permission = ( |
Line 2466 sub get_permission {
|
Line 2572 sub get_permission {
|
selfenroll => 'view', |
selfenroll => 'view', |
adhocrole => 'custom', |
adhocrole => 'custom', |
); |
); |
|
if ($passwdconf{'crsownerchg'}) { |
|
$permission{passwdchg} = 'view'; |
|
} |
} |
} |
return ($allowed,\%permission); |
return ($allowed,\%permission); |
} |
} |
|
|
|
sub devalidate_remote_instcats { |
|
if ($modified_dom ne '') { |
|
my %servers = &Apache::lonnet::internet_dom_servers($modified_dom); |
|
my %thismachine; |
|
map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids(); |
|
if (keys(%servers)) { |
|
foreach my $server (keys(%servers)) { |
|
next if ($thismachine{$server}); |
|
&Apache::lonnet::remote_devalidate_cache($server,['instcats:'.$modified_dom]); |
|
} |
|
} |
|
$modified_dom = ''; |
|
} |
|
return; |
|
} |
|
|
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
if ($r->header_only) { |
if ($r->header_only) { |
Line 2478 sub handler {
|
Line 2603 sub handler {
|
return OK; |
return OK; |
} |
} |
|
|
|
$registered_cleanup=0; |
|
$modified_dom = ''; |
|
|
my $dom = $env{'request.role.domain'}; |
my $dom = $env{'request.role.domain'}; |
my $domdesc = &Apache::lonnet::domain($dom,'description'); |
my $domdesc = &Apache::lonnet::domain($dom,'description'); |
my ($allowed,$permission) = &get_permission($dom); |
my ($allowed,$permission) = &get_permission($dom); |