version 1.159, 2013/12/09 21:33:32
|
version 1.170, 2015/06/09 21:22:57
|
Line 401 sub javascript_validations {
|
Line 401 sub javascript_validations {
|
|
|
my $showcredits; |
my $showcredits; |
my %domdefaults = &Apache::lonnet::get_domain_defaults($domain); |
my %domdefaults = &Apache::lonnet::get_domain_defaults($domain); |
if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'}) { |
if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'}) { |
$showcredits = 1; |
$showcredits = 1; |
} |
} |
|
|
Line 450 sub javascript_validations {
|
Line 450 sub javascript_validations {
|
if (($mode eq 'upload') && ($context eq 'domain')) { |
if (($mode eq 'upload') && ($context eq 'domain')) { |
$alert{'inststatus'} = &mt('The optional affiliation field was not specified'); |
$alert{'inststatus'} = &mt('The optional affiliation field was not specified'); |
} |
} |
|
&js_escape(\%alert); |
my $function_name = <<"END"; |
my $function_name = <<"END"; |
$setsections_js |
$setsections_js |
|
|
Line 642 sub upload_manager_javascript_forward_as
|
Line 643 sub upload_manager_javascript_forward_as
|
$numbuttons ++; |
$numbuttons ++; |
} |
} |
if (!$can_assign->{'int'}) { |
if (!$can_assign->{'int'}) { |
my $warning = &mt('You may not specify an initial password for each user, as this is only available when new users use LON-CAPA internal authentication.').'\n'. |
my $warning = &mt('You may not specify an initial password for each user, as this is only available when new users use LON-CAPA internal authentication.')."\n". |
&mt('Your current role does not have rights to create users with that authentication type.'); |
&mt('Your current role does not have rights to create users with that authentication type.'); |
|
&js_escape(\$warning); |
$auth_update = <<"END"; |
$auth_update = <<"END"; |
// Currently the initial password field is only supported for internal auth |
// Currently the initial password field is only supported for internal auth |
// (see bug 6368). |
// (see bug 6368). |
Line 781 sub upload_manager_javascript_reverse_as
|
Line 783 sub upload_manager_javascript_reverse_as
|
if (!$can_assign->{'int'}) { |
if (!$can_assign->{'int'}) { |
my $warning = &mt('You may not specify an initial password, as this is only available when new users use LON-CAPA internal authentication.\n'). |
my $warning = &mt('You may not specify an initial password, as this is only available when new users use LON-CAPA internal authentication.\n'). |
&mt('Your current role does not have rights to create users with that authentication type.'); |
&mt('Your current role does not have rights to create users with that authentication type.'); |
|
&js_escape(\$warning); |
$auth_update = <<"END"; |
$auth_update = <<"END"; |
// Currently the initial password field is only supported for internal auth |
// Currently the initial password field is only supported for internal auth |
// (see bug 6368). |
// (see bug 6368). |
Line 1013 sub print_upload_manager_footer {
|
Line 1016 sub print_upload_manager_footer {
|
.&Apache::lonhtmlcommon::row_closure(); |
.&Apache::lonhtmlcommon::row_closure(); |
} |
} |
if ($context eq 'course' || $context eq 'domain') { |
if ($context eq 'course' || $context eq 'domain') { |
$Str .= &forceid_change($context); |
$Str .= &Apache::lonhtmlcommon::row_title(&mt('Student/Employee ID')) |
|
.&forceid_change($context) |
|
.&Apache::lonhtmlcommon::row_closure(1); # last row in pick_box |
} |
} |
|
|
$Str .= &Apache::lonhtmlcommon::end_pick_box(); |
$Str .= &Apache::lonhtmlcommon::end_pick_box(); |
Line 1047 sub get_defaultcredits {
|
Line 1052 sub get_defaultcredits {
|
return unless(($cdom =~ /^$match_domain$/) && ($cnum =~ /^$match_courseid$/)); |
return unless(($cdom =~ /^$match_domain$/) && ($cnum =~ /^$match_courseid$/)); |
my ($defaultcredits,$domdefcredits); |
my ($defaultcredits,$domdefcredits); |
my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom); |
my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom); |
if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'}) { |
if ($domdefaults{'officialcredits'} || $domdefaults{'unofficialcredits'} || $domdefaults{'textbookcredits'}) { |
my $instcode = $env{'course.'.$cdom.'_'.$cnum.'.internal.coursecode'}; |
my $instcode = $env{'course.'.$cdom.'_'.$cnum.'.internal.coursecode'}; |
if ($instcode) { |
if ($instcode) { |
$domdefcredits = $domdefaults{'officialcredits'}; |
$domdefcredits = $domdefaults{'officialcredits'}; |
|
} elsif ($env{'course.'.$cdom.'_'.$cnum.'.internal.textbook'}) { |
|
$domdefcredits = $domdefaults{'textbookcredits'}; |
} else { |
} else { |
$domdefcredits = $domdefaults{'unofficialcredits'}; |
$domdefcredits = $domdefaults{'unofficialcredits'}; |
} |
} |
Line 1076 sub get_defaultcredits {
|
Line 1083 sub get_defaultcredits {
|
sub forceid_change { |
sub forceid_change { |
my ($context) = @_; |
my ($context) = @_; |
my $output = |
my $output = |
&Apache::lonhtmlcommon::row_title(&mt('Student/Employee ID')) |
'<label><input type="checkbox" name="forceid" value="yes" />' |
.'<label><input type="checkbox" name="forceid" value="yes" />' |
.&mt('Force change of existing ID') |
.&mt('Disable Student/Employee ID Safeguard and force change of conflicting IDs') |
.'</label>'.&Apache::loncommon::help_open_topic('ForceIDChange')."\n"; |
.'</label><br />'."\n" |
|
.&mt('(only do if you know what you are doing.)')."\n"; |
|
if ($context eq 'domain') { |
if ($context eq 'domain') { |
$output .= '<br /><label><input type="checkbox" name="recurseid"'. |
$output .= |
' value="yes" />'. |
'<br />' |
&mt('Update student/employee ID in courses in which user is active/future student,[_1](if forcing change).','<br />'). |
.'<label><input type="checkbox" name="recurseid" value="yes" />' |
'</label>'."\n"; |
.&mt("Update ID in user's course(s).").'</label>'."\n"; |
} |
} |
$output .= &Apache::lonhtmlcommon::row_closure(1); # last row in pick_box |
|
return $output; |
return $output; |
} |
} |
|
|
Line 1392 sub default_role_selector {
|
Line 1396 sub default_role_selector {
|
&default_course_roles($context,$checkpriv,'Course',%customroles)."\n". |
&default_course_roles($context,$checkpriv,'Course',%customroles)."\n". |
'</select></td><td>'. |
'</select></td><td>'. |
'<table class="LC_createuser">'. |
'<table class="LC_createuser">'. |
'<tr class="LC_section_row"><td valign"top">'. |
'<tr class="LC_section_row"><td valign="top">'. |
$lt{'exs'}.'<br /><select name="currsec">'. |
$lt{'exs'}.'<br /><select name="currsec">'. |
' <option value=""><--'.&mt('Pick course first'). |
' <option value=""><--'.&mt('Pick course first'). |
'</select></td>'. |
'</select></td>'. |
'<td> </td>'. |
'<td> </td>'. |
'<td valign="top">'.$lt{'new'}.'<br />'. |
'<td valign="top">'.$lt{'new'}.'<br />'. |
Line 3003 END
|
Line 3007 END
|
if ($mode eq 'autoenroll') { |
if ($mode eq 'autoenroll') { |
my $cellentry; |
my $cellentry; |
if ($in{'type'} eq 'auto') { |
if ($in{'type'} eq 'auto') { |
$cellentry = '<b>'.&mt('auto').'</b> <label><input type="checkbox" name="chgauto" value="'.$in{'username'}.':'.$in{'domain'}.'" /> Change</label>'; |
$cellentry = '<b>'.&mt('auto').'</b> <label><input type="checkbox" name="chgauto" value="'.$in{'username'}.':'.$in{'domain'}.'" /> '.&mt('Change').'</label>'; |
$autocount ++; |
$autocount ++; |
} else { |
} else { |
$cellentry = '<table border="0" cellspacing="0"><tr><td rowspan="2"><b>'.&mt('manual').'</b></td><td><span class="LC_nobreak"><label><input type="checkbox" name="chgmanual" value="'.$in{'username'}.':'.$in{'domain'}.'" /> Change</label></span></td></tr><tr><td><span class="LC_nobreak">'; |
$cellentry = '<table border="0" cellspacing="0"><tr><td rowspan="2"><b>'.&mt('manual').'</b></td><td><span class="LC_nobreak"><label><input type="checkbox" name="chgmanual" value="'.$in{'username'}.':'.$in{'domain'}.'" /> '.&mt('Change').'</label></span></td></tr><tr><td><span class="LC_nobreak">'; |
$manualcount ++; |
$manualcount ++; |
if ($in{'lockedtype'}) { |
if ($in{'lockedtype'}) { |
$cellentry .= '<label><input type="checkbox" name="unlockchg" value="'.$in{'username'}.':'.$in{'domain'}.'" /> '.&mt('Unlock').'</label>'; |
$cellentry .= '<label><input type="checkbox" name="unlockchg" value="'.$in{'username'}.':'.$in{'domain'}.'" /> '.&mt('Unlock').'</label>'; |
Line 3137 END
|
Line 3141 END
|
$r->print(&Apache::loncommon::end_data_table().'<br />'); |
$r->print(&Apache::loncommon::end_data_table().'<br />'); |
} elsif ($mode eq 'excel') { |
} elsif ($mode eq 'excel') { |
$excel_workbook->close(); |
$excel_workbook->close(); |
$r->print(&mt('[_1]Your Excel spreadsheet[_2] is ready for download.', '<p><a href="'.$excel_filename.'">','</a>')."</p>\n"); |
$r->print('<p>'.&mt('[_1]Your Excel spreadsheet[_2] is ready for download.', '<a href="'.$excel_filename.'">','</a>')."</p>\n"); |
} elsif ($mode eq 'csv') { |
} elsif ($mode eq 'csv') { |
close($CSVfile); |
close($CSVfile); |
$r->print(&mt('[_1]Your CSV file[_2] is ready for download.', '<p><a href="'.$CSVfilename.'">','</a>')."</p>\n"); |
$r->print('<p>'.&mt('[_1]Your CSV file[_2] is ready for download.', '<a href="'.$CSVfilename.'">','</a>')."</p>\n"); |
$r->rflush(); |
$r->rflush(); |
} |
} |
if ($mode eq 'autoenroll') { |
if ($mode eq 'autoenroll') { |
Line 3172 sub bulkaction_javascript {
|
Line 3176 sub bulkaction_javascript {
|
my $noaction = &mt("You need to select an action to take for the user(s) you have selected"); |
my $noaction = &mt("You need to select an action to take for the user(s) you have selected"); |
my $singconfirm = &mt(' for a single user?'); |
my $singconfirm = &mt(' for a single user?'); |
my $multconfirm = &mt(' for multiple users?'); |
my $multconfirm = &mt(' for multiple users?'); |
|
&js_escape(\$alert); |
|
&js_escape(\$noaction); |
|
&js_escape(\$singconfirm); |
|
&js_escape(\$multconfirm); |
my $output = <<"ENDJS"; |
my $output = <<"ENDJS"; |
function verify_action (field) { |
function verify_action (field) { |
var numchecked = 0; |
var numchecked = 0; |
Line 3838 sub show_drop_list {
|
Line 3846 sub show_drop_list {
|
$check_uncheck_js |
$check_uncheck_js |
// ]]> |
// ]]> |
</script> |
</script> |
<p> |
|
<input type="hidden" name="phase" value="four" /> |
<input type="hidden" name="phase" value="four" /> |
END |
END |
my ($indexhash,$keylist) = &make_keylist_array(); |
my ($indexhash,$keylist) = &make_keylist_array(); |
Line 3875 END
|
Line 3882 END
|
$classlist,$keylist,$cdom,$cnum); |
$classlist,$keylist,$cdom,$cnum); |
my %lt=&Apache::lonlocal::texthash('usrn' => "username", |
my %lt=&Apache::lonlocal::texthash('usrn' => "username", |
'dom' => "domain", |
'dom' => "domain", |
|
'id' => "ID", |
'sn' => "student name", |
'sn' => "student name", |
'mn' => "member name", |
'mn' => "member name", |
'sec' => "section", |
'sec' => "section", |
Line 3893 END
|
Line 3901 END
|
<th> </th> |
<th> </th> |
<th>$lt{'usrn'}</th> |
<th>$lt{'usrn'}</th> |
<th>$lt{'dom'}</th> |
<th>$lt{'dom'}</th> |
<th>ID</th> |
<th>$lt{'id'}</th> |
<th>$nametitle</th> |
<th>$nametitle</th> |
<th>$lt{'sec'}</th> |
<th>$lt{'sec'}</th> |
<th>$lt{'start'}</th> |
<th>$lt{'start'}</th> |
Line 3907 END
|
Line 3915 END
|
$r->print(<<END); |
$r->print(<<END); |
<th> </th> |
<th> </th> |
<th> |
<th> |
<a href="/adm/createuser?action=$action&sortby=username">$lt{'usrn'}</a> |
<a href="/adm/createuser?action=$action&sortby=username">$lt{'usrn'}</a> |
</th><th> |
</th><th> |
<a href="/adm/createuser?action=$action&sortby=domain">$lt{'dom'}</a> |
<a href="/adm/createuser?action=$action&sortby=domain">$lt{'dom'}</a> |
</th><th> |
</th><th> |
<a href="/adm/createuser?action=$action&sortby=id">ID</a> |
<a href="/adm/createuser?action=$action&sortby=id">$lt{'id'}</a> |
</th><th> |
</th><th> |
<a href="/adm/createuser?action=$action&sortby=fullname">$nametitle</a> |
<a href="/adm/createuser?action=$action&sortby=fullname">$nametitle</a> |
</th><th> |
</th><th> |
<a href="/adm/createuser?action=$action&sortby=section">$lt{'sec'}</a> |
<a href="/adm/createuser?action=$action&sortby=section">$lt{'sec'}</a> |
</th><th> |
</th><th> |
<a href="/adm/createuser?action=$action&sortby=start">$lt{'start'}</a> |
<a href="/adm/createuser?action=$action&sortby=start">$lt{'start'}</a> |
</th><th> |
</th><th> |
<a href="/adm/createuser?action=$action&sortby=end">$lt{'end'}</a> |
<a href="/adm/createuser?action=$action&sortby=end">$lt{'end'}</a> |
</th><th> |
</th><th> |
<a href="/adm/createuser?action=$action&sortby=groups">$lt{'groups'}</a> |
<a href="/adm/createuser?action=$action&sortby=groups">$lt{'groups'}</a> |
</th> |
</th> |
END |
END |
$r->print(&Apache::loncommon::end_data_table_header_row()); |
$r->print(&Apache::loncommon::end_data_table_header_row()); |
Line 3992 END
|
Line 4000 END
|
$btn = $lt{'dm'}; |
$btn = $lt{'dm'}; |
} |
} |
$r->print(<<"END"); |
$r->print(<<"END"); |
</p> |
|
<p> |
<p> |
<input type="button" value="$lt{'ca'}" onclick="javascript:checkAll(document.studentform.droplist)" /> |
<input type="button" value="$lt{'ca'}" onclick="javascript:checkAll(document.studentform.droplist)" /> |
<input type="button" value="$lt{'ua'}" onclick="javascript:uncheckAll(document.studentform.droplist)" /> |
<input type="button" value="$lt{'ua'}" onclick="javascript:uncheckAll(document.studentform.droplist)" /> |
Line 4818 sub print_drop_menu {
|
Line 4825 sub print_drop_menu {
|
} else { |
} else { |
&show_drop_list($r,$classlist,'nosort',$permission,$crstype); |
&show_drop_list($r,$classlist,'nosort',$permission,$crstype); |
} |
} |
$r->print('</form>'. &Apache::loncommon::end_page()); |
$r->print('</form>'); |
return; |
return; |
} |
} |
|
|
Line 5215 sub active_student_roles {
|
Line 5222 sub active_student_roles {
|
|
|
sub section_check_js { |
sub section_check_js { |
my $groupslist= &get_groupslist(); |
my $groupslist= &get_groupslist(); |
|
my %js_lt = &Apache::lonlocal::texthash( |
|
mayn => 'may not be used as the name for a section, as it is a reserved word.', |
|
plch => 'Please choose a different section name.', |
|
mnot => 'may not be used as a section name, as it is the name of a course group.', |
|
secn => 'Section names and group names must be distinct. Please choose a different section name.', |
|
); |
|
&js_escape(\%js_lt); |
return <<"END"; |
return <<"END"; |
function validate(caller) { |
function validate(caller) { |
var groups = new Array($groupslist); |
var groups = new Array($groupslist); |
var secname = caller.value; |
var secname = caller.value; |
if ((secname == 'all') || (secname == 'none')) { |
if ((secname == 'all') || (secname == 'none')) { |
alert("'"+secname+"' may not be used as the name for a section, as it is a reserved word.\\nPlease choose a different section name."); |
alert("'"+secname+"' $js_lt{'mayn'}\\n$js_lt{'plch'}"); |
return 'error'; |
return 'error'; |
} |
} |
if (secname != '') { |
if (secname != '') { |
for (var k=0; k<groups.length; k++) { |
for (var k=0; k<groups.length; k++) { |
if (secname == groups[k]) { |
if (secname == groups[k]) { |
alert("'"+secname+"' may not be used as the name for a section, as it is the name of a course group.\\nSection names and group names must be distinct. Please choose a different section name."); |
alert("'"+secname+"' $js_lt{'mnot'}\\n$js_lt{'secn'}"); |
return 'error'; |
return 'error'; |
} |
} |
} |
} |
Line 5267 sub set_login {
|
Line 5281 sub set_login {
|
sub course_sections { |
sub course_sections { |
my ($sections_count,$role,$current_sec) = @_; |
my ($sections_count,$role,$current_sec) = @_; |
my $output = ''; |
my $output = ''; |
my @sections = (sort {$a <=> $b} keys %{$sections_count}); |
my @sections = (sort {$a <=> $b} keys(%{$sections_count})); |
my $numsec = scalar(@sections); |
my $numsec = scalar(@sections); |
my $is_selected = ' selected="selected"'; |
my $is_selected = ' selected="selected"'; |
if ($numsec <= 1) { |
if ($numsec <= 1) { |
Line 5351 sub setsections_javascript {
|
Line 5365 sub setsections_javascript {
|
} |
} |
$rolecode = "var match = str.split('_'); |
$rolecode = "var match = str.split('_'); |
var role = match[3];\n"; |
var role = match[3];\n"; |
} elsif ($formname eq 'enrollstudent') { |
} elsif (($formname eq 'enrollstudent') || ($formname eq 'selfenroll')) { |
$checkincluded = 'formname.name == "'.$formname.'"'; |
$checkincluded = 'formname.name == "'.$formname.'"'; |
if ($checkauth) { |
if ($checkauth) { |
$finish = "var authcheck = auth_check();\n". |
$finish = "var authcheck = auth_check();\n". |
Line 5385 sub setsections_javascript {
|
Line 5399 sub setsections_javascript {
|
mnot => 'may not be used as a section name, as it is the name of a course group.', |
mnot => 'may not be used as a section name, as it is the name of a course group.', |
secn => 'Section names and group names must be distinct. Please choose a different section name.', |
secn => 'Section names and group names must be distinct. Please choose a different section name.', |
nonw => 'Section names may only contain letters or numbers.', |
nonw => 'Section names may only contain letters or numbers.', |
); |
); |
|
&js_escape(\%alerts); |
$setsection_js .= <<"ENDSECCODE"; |
$setsection_js .= <<"ENDSECCODE"; |
|
|
function setSections(formname,crstype) { |
function setSections(formname,crstype) { |
Line 5396 function setSections(formname,crstype) {
|
Line 5411 function setSections(formname,crstype) {
|
var groups = new Array($groupslist); |
var groups = new Array($groupslist); |
for (var i=0;i<formname.elements.length;i++) { |
for (var i=0;i<formname.elements.length;i++) { |
var str = formname.elements[i].name; |
var str = formname.elements[i].name; |
|
if (typeof(str) === "undefined") { |
|
continue; |
|
} |
var checkcurr = str.match(re1); |
var checkcurr = str.match(re1); |
if (checkcurr != null) { |
if (checkcurr != null) { |
var num = i; |
var num = i; |
Line 5701 sub get_permission {
|
Line 5719 sub get_permission {
|
if (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) { |
if (&Apache::lonnet::allowed('mdg',$env{'request.course.id'})) { |
$permission{'grp_manage'} = 1; |
$permission{'grp_manage'} = 1; |
} |
} |
|
if ($permission{'cusr'}) { |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my %coursehash = ( |
|
'internal.selfenrollmgrdc' => $env{'course.'.$env{'request.course.id'}.'.internal.selfenrollmgrdc'}, |
|
'internal.selfenrollmgrcc' => $env{'course.'.$env{'request.course.id'}.'.internal.selfenrollmgrcc'}, |
|
'internal.coursecode' => $env{'course.'.$env{'request.course.id'}.'.internal.coursecode'}, |
|
'internal.textbook' =>$env{'course.'.$env{'request.course.id'}.'.internal.textbook'}, |
|
); |
|
my ($managed_by_cc,$managed_by_dc) = &selfenrollment_administration($cdom,$cnum,$crstype,\%coursehash); |
|
if (ref($managed_by_cc) eq 'ARRAY') { |
|
if (@{$managed_by_cc}) { |
|
$permission{'selfenrolladmin'} = 1; |
|
} |
|
} |
|
} |
} elsif ($context eq 'author') { |
} elsif ($context eq 'author') { |
$permission{'cusr'} = &authorpriv($env{'user.name'},$env{'request.role.domain'}); |
$permission{'cusr'} = &authorpriv($env{'user.name'},$env{'request.role.domain'}); |
$permission{'view'} = $permission{'cusr'}; |
$permission{'view'} = $permission{'cusr'}; |
Line 6003 sub sectioncheck_alerts {
|
Line 6037 sub sectioncheck_alerts {
|
thwa => 'There was a problem with your course selection', |
thwa => 'There was a problem with your course selection', |
thwc => 'There was a problem with your community selection', |
thwc => 'There was a problem with your community selection', |
); |
); |
|
&js_escape(\%alerts); |
return %alerts; |
return %alerts; |
} |
} |
|
|
Line 6013 sub authcheck_alerts {
|
Line 6048 sub authcheck_alerts {
|
krb => 'You need to specify the Kerberos domain.', |
krb => 'You need to specify the Kerberos domain.', |
ipass => 'You need to specify the initial password.', |
ipass => 'You need to specify the initial password.', |
); |
); |
|
&js_escape(\%alerts); |
return %alerts; |
return %alerts; |
} |
} |
|
|
Line 6031 sub is_courseowner {
|
Line 6067 sub is_courseowner {
|
return; |
return; |
} |
} |
|
|
|
sub get_selfenroll_titles { |
|
my @row = ('types','registered','enroll_dates','access_dates','section', |
|
'approval','limit'); |
|
my %lt = &Apache::lonlocal::texthash ( |
|
types => 'Users allowed to self-enroll', |
|
registered => 'Registration status (official courses)' , |
|
enroll_dates => 'Dates self-enrollment available', |
|
access_dates => 'Access dates for self-enrolling users', |
|
section => "Self-enrolling users' section", |
|
approval => 'Processing of requests', |
|
limit => 'Enrollment limit', |
|
); |
|
return (\@row,\%lt); |
|
} |
|
|
|
sub selfenroll_default_descs { |
|
my %desc = ( |
|
types => { |
|
dom => &mt('Course domain'), |
|
all => &mt('Any domain'), |
|
'' => &mt('None'), |
|
}, |
|
limit => { |
|
none => &mt('No limit'), |
|
allstudents => &mt('Limit by total students'), |
|
selfenrolled => &mt('Limit by total self-enrolled'), |
|
}, |
|
approval => { |
|
'0' => &mt('Processed automatically'), |
|
'1' => &mt('Queued for approval'), |
|
'2' => &mt('Queued, pending validation'), |
|
}, |
|
registered => { |
|
0 => 'No registration required', |
|
1 => 'Registered students only', |
|
}, |
|
); |
|
return %desc; |
|
} |
|
|
|
sub selfenroll_validation_types { |
|
my @items = ('url','fields','button','markup'); |
|
my %names = &Apache::lonlocal::texthash ( |
|
url => 'Web address of validation server/script', |
|
fields => 'Form fields to send to validator', |
|
button => 'Text for validation button', |
|
markup => 'Validation description (HTML)', |
|
); |
|
my @fields = ('username','domain','uniquecode','course','coursetype','description'); |
|
return (\@items,\%names,\@fields); |
|
} |
|
|
|
sub get_extended_type { |
|
my ($cdom,$cnum,$crstype,$current) = @_; |
|
my $type = 'unofficial'; |
|
my %settings; |
|
if (ref($current) eq 'HASH') { |
|
%settings = %{$current}; |
|
} else { |
|
%settings = &Apache::lonnet::get('environment',['internal.coursecode','internal.textbook'],$cdom,$cnum); |
|
} |
|
if ($crstype eq 'Community') { |
|
$type = 'community'; |
|
} elsif ($settings{'internal.coursecode'}) { |
|
$type = 'official'; |
|
} elsif ($settings{'internal.textbook'}) { |
|
$type = 'textbook'; |
|
} |
|
return $type; |
|
} |
|
|
|
sub selfenrollment_administration { |
|
my ($cdom,$cnum,$crstype,$coursehash) = @_; |
|
my %settings; |
|
if (ref($coursehash) eq 'HASH') { |
|
%settings = %{$coursehash}; |
|
} else { |
|
%settings = &Apache::lonnet::get('environment', |
|
['internal.selfenrollmgrdc','internal.selfenrollmgrcc', |
|
'internal.coursecode','internal.textbook'],$cdom,$cnum); |
|
} |
|
my ($possconfigs) = &get_selfenroll_titles(); |
|
my %domdefaults = &Apache::lonnet::get_domain_defaults($cdom); |
|
my $selfenrolltype = &get_extended_type($cdom,$cnum,$crstype,\%settings); |
|
|
|
my (@in_course,@in_domain); |
|
if ($settings{'internal.selfenrollmgrcc'} ne '') { |
|
@in_course = split(/,/,$settings{'internal.selfenrollmgrcc'}); |
|
my @diffs = &Apache::loncommon::compare_arrays($possconfigs,\@in_course); |
|
unless (@diffs) { |
|
return (\@in_course,\@in_domain); |
|
} |
|
} |
|
if ($settings{'internal.selfenrollmgrdc'} ne '') { |
|
my @in_domain = split(/,/,$settings{'internal.selfenrollmgrdc'}); |
|
my @diffs = &Apache::loncommon::compare_arrays(\@in_domain,$possconfigs); |
|
unless (@diffs) { |
|
return (\@in_course,\@in_domain); |
|
} |
|
} |
|
my @combined = @in_course; |
|
push(@combined,@in_domain); |
|
my @diffs = &Apache::loncommon::compare_arrays(\@combined,$possconfigs); |
|
unless (@diffs) { |
|
return (\@in_course,\@in_domain); |
|
} |
|
if ($domdefaults{$selfenrolltype.'selfenrolladmdc'} eq '') { |
|
push(@in_course,@diffs); |
|
} else { |
|
my @defaultdc = split(/,/,$domdefaults{$selfenrolltype.'selfenrolladmdc'}); |
|
foreach my $item (@diffs) { |
|
if (grep(/^\Q$item\E$/,@defaultdc)) { |
|
push(@in_domain,$item); |
|
} else { |
|
push(@in_course,$item); |
|
} |
|
} |
|
} |
|
return (\@in_course,\@in_domain); |
|
} |
|
|
1; |
1; |
|
|