version 1.160.6.71, 2016/09/18 19:22:48
|
version 1.270, 2016/02/19 20:28:46
|
Line 173 use File::Copy;
|
Line 173 use File::Copy;
|
use Locale::Language; |
use Locale::Language; |
use DateTime::TimeZone; |
use DateTime::TimeZone; |
use DateTime::Locale; |
use DateTime::Locale; |
|
use Time::HiRes qw( sleep ); |
|
|
my $registered_cleanup; |
my $registered_cleanup; |
my $modified_urls; |
my $modified_urls; |
Line 213 sub handler {
|
Line 214 sub handler {
|
'quotas','autoenroll','autoupdate','autocreate', |
'quotas','autoenroll','autoupdate','autocreate', |
'directorysrch','usercreation','usermodification', |
'directorysrch','usercreation','usermodification', |
'contacts','defaults','scantron','coursecategories', |
'contacts','defaults','scantron','coursecategories', |
'serverstatuses','requestcourses','coursedefaults', |
'serverstatuses','requestcourses','helpsettings', |
'usersessions','loadbalancing','requestauthor', |
'coursedefaults','usersessions','loadbalancing', |
'selfenrollment','inststatus'],$dom); |
'requestauthor','selfenrollment','inststatus', |
|
'ltitools'],$dom); |
my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll', |
my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll', |
'autoupdate','autocreate','directorysrch','contacts', |
'autoupdate','autocreate','directorysrch','contacts', |
'usercreation','selfcreation','usermodification','scantron', |
'usercreation','selfcreation','usermodification','scantron', |
'requestcourses','requestauthor','coursecategories', |
'requestcourses','requestauthor','coursecategories', |
'serverstatuses','coursedefaults','selfenrollment', |
'serverstatuses','helpsettings','coursedefaults', |
'usersessions'); |
'ltitools','selfenrollment','usersessions'); |
my %existing; |
my %existing; |
if (ref($domconfig{'loadbalancing'}) eq 'HASH') { |
if (ref($domconfig{'loadbalancing'}) eq 'HASH') { |
%existing = %{$domconfig{'loadbalancing'}}; |
%existing = %{$domconfig{'loadbalancing'}}; |
Line 411 sub handler {
|
Line 413 sub handler {
|
print => \&print_serverstatuses, |
print => \&print_serverstatuses, |
modify => \&modify_serverstatuses, |
modify => \&modify_serverstatuses, |
}, |
}, |
|
'helpsettings' => |
|
{text => 'Help page settings', |
|
help => 'Domain_Configuration_Help_Settings', |
|
header => [{col1 => 'Help Settings (logged-in users)', |
|
col2 => 'Value'}], |
|
print => \&print_helpsettings, |
|
modify => \&modify_helpsettings, |
|
}, |
'coursedefaults' => |
'coursedefaults' => |
{text => 'Course/Community defaults', |
{text => 'Course/Community defaults', |
help => 'Domain_Configuration_Course_Defaults', |
help => 'Domain_Configuration_Course_Defaults', |
Line 433 sub handler {
|
Line 443 sub handler {
|
print => \&print_selfenrollment, |
print => \&print_selfenrollment, |
modify => \&modify_selfenrollment, |
modify => \&modify_selfenrollment, |
}, |
}, |
|
'privacy' => |
|
{text => 'User Privacy', |
|
help => 'Domain_Configuration_User_Privacy', |
|
header => [{col1 => 'Setting', |
|
col2 => 'Value',}], |
|
print => \&print_privacy, |
|
modify => \&modify_privacy, |
|
}, |
'usersessions' => |
'usersessions' => |
{text => 'User session hosting/offloading', |
{text => 'User session hosting/offloading', |
help => 'Domain_Configuration_User_Sessions', |
help => 'Domain_Configuration_User_Sessions', |
Line 456 sub handler {
|
Line 474 sub handler {
|
print => \&print_loadbalancing, |
print => \&print_loadbalancing, |
modify => \&modify_loadbalancing, |
modify => \&modify_loadbalancing, |
}, |
}, |
|
'ltitools' => |
|
{text => 'External Tools (LTI)', |
|
help => 'Domain_configuration_LTI_Tools', |
|
header => [{col1 => 'Setting', |
|
col2 => 'Value',}], |
|
print => \&print_ltitools, |
|
modify => \&modify_ltitools, |
|
}, |
|
|
); |
); |
if (keys(%servers) > 1) { |
if (keys(%servers) > 1) { |
$prefs{'login'} = { text => 'Log-in page options', |
$prefs{'login'} = { text => 'Log-in page options', |
Line 619 sub process_changes {
|
Line 646 sub process_changes {
|
$output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig); |
$output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig); |
} elsif ($action eq 'requestauthor') { |
} elsif ($action eq 'requestauthor') { |
$output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig); |
$output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig); |
|
} elsif ($action eq 'helpsettings') { |
|
$output = &modify_helpsettings($r,$dom,$confname,%domconfig); |
} elsif ($action eq 'coursedefaults') { |
} elsif ($action eq 'coursedefaults') { |
$output = &modify_coursedefaults($dom,$lastactref,%domconfig); |
$output = &modify_coursedefaults($dom,$lastactref,%domconfig); |
} elsif ($action eq 'selfenrollment') { |
} elsif ($action eq 'selfenrollment') { |
Line 627 sub process_changes {
|
Line 656 sub process_changes {
|
$output = &modify_usersessions($dom,$lastactref,%domconfig); |
$output = &modify_usersessions($dom,$lastactref,%domconfig); |
} elsif ($action eq 'loadbalancing') { |
} elsif ($action eq 'loadbalancing') { |
$output = &modify_loadbalancing($dom,%domconfig); |
$output = &modify_loadbalancing($dom,%domconfig); |
|
} elsif ($action eq 'ltitools') { |
|
$output = &modify_ltitools($r,$dom,$action,$lastactref,%domconfig); |
} |
} |
return $output; |
return $output; |
} |
} |
Line 886 sub print_config_box {
|
Line 917 sub print_config_box {
|
if ($action eq 'quotas') { |
if ($action eq 'quotas') { |
$output .= &print_quotas($dom,$settings,\$rowtotal,$action); |
$output .= &print_quotas($dom,$settings,\$rowtotal,$action); |
} elsif (($action eq 'autoenroll') || ($action eq 'autocreate') || ($action eq 'directorysrch') || |
} elsif (($action eq 'autoenroll') || ($action eq 'autocreate') || ($action eq 'directorysrch') || |
($action eq 'contacts') || ($action eq 'serverstatuses') || ($action eq 'loadbalancing')) { |
($action eq 'contacts') || ($action eq 'serverstatuses') || ($action eq 'loadbalancing') || |
|
($action eq 'ltitools')) { |
$output .= $item->{'print'}->($dom,$settings,\$rowtotal); |
$output .= $item->{'print'}->($dom,$settings,\$rowtotal); |
} elsif ($action eq 'scantron') { |
} elsif ($action eq 'scantron') { |
$output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal); |
$output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal); |
Line 2240 sub print_textbookcourses {
|
Line 2272 sub print_textbookcourses {
|
(' 'x2). |
(' 'x2). |
'<span class="LC_nobreak">'.&mt('Thumbnail:'); |
'<span class="LC_nobreak">'.&mt('Thumbnail:'); |
if ($image) { |
if ($image) { |
$datatable .= '<span class="LC_nobreak">'. |
$datatable .= $imgsrc. |
$imgsrc. |
|
'<label><input type="checkbox" name="'.$type.'_image_del"'. |
'<label><input type="checkbox" name="'.$type.'_image_del"'. |
' value="'.$key.'" />'.&mt('Delete?').'</label></span> '. |
' value="'.$key.'" />'.&mt('Delete?').'</label></span> '. |
'<span class="LC_nobreak"> '.&mt('Replace:').' '; |
'<span class="LC_nobreak"> '.&mt('Replace:').' '; |
Line 2395 $jstext{'templates'};
|
Line 2426 $jstext{'templates'};
|
ENDSCRIPT |
ENDSCRIPT |
} |
} |
|
|
|
sub ltitools_javascript { |
|
my ($settings) = @_; |
|
return unless(ref($settings) eq 'HASH'); |
|
my (%ordered,$total,%jstext); |
|
$total = 0; |
|
foreach my $item (keys(%{$settings})) { |
|
if (ref($settings->{$item}) eq 'HASH') { |
|
my $num = $settings->{$item}{'order'}; |
|
$ordered{$num} = $item; |
|
} |
|
} |
|
$total = scalar(keys(%{$settings})); |
|
my @jsarray = (); |
|
foreach my $item (sort {$a <=> $b } (keys(%ordered))) { |
|
push(@jsarray,$ordered{$item}); |
|
} |
|
my $jstext = ' var ltitools = Array('."'".join("','",@jsarray)."'".');'."\n"; |
|
return <<"ENDSCRIPT"; |
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
function reorderLTI(form,item) { |
|
var changedVal; |
|
$jstext |
|
var newpos = 'ltitools_add_pos'; |
|
var maxh = 1 + $total; |
|
var current = new Array; |
|
var newitemVal = form.elements[newpos].options[form.elements[newpos].selectedIndex].value; |
|
if (item == newpos) { |
|
changedVal = newitemVal; |
|
} else { |
|
changedVal = form.elements[item].options[form.elements[item].selectedIndex].value; |
|
current[newitemVal] = newpos; |
|
} |
|
for (var i=0; i<ltitools.length; i++) { |
|
var elementName = 'ltitools_'+ltitools[i]; |
|
if (elementName != item) { |
|
if (form.elements[elementName]) { |
|
var currVal = form.elements[elementName].options[form.elements[elementName].selectedIndex].value; |
|
current[currVal] = elementName; |
|
} |
|
} |
|
} |
|
var oldVal; |
|
for (var j=0; j<maxh; j++) { |
|
if (current[j] == undefined) { |
|
oldVal = j; |
|
} |
|
} |
|
if (oldVal < changedVal) { |
|
for (var k=oldVal+1; k<=changedVal ; k++) { |
|
var elementName = current[k]; |
|
form.elements[elementName].selectedIndex = form.elements[elementName].selectedIndex - 1; |
|
} |
|
} else { |
|
for (var k=changedVal; k<oldVal; k++) { |
|
var elementName = current[k]; |
|
form.elements[elementName].selectedIndex = form.elements[elementName].selectedIndex + 1; |
|
} |
|
} |
|
return; |
|
} |
|
|
|
// ]]> |
|
</script> |
|
|
|
ENDSCRIPT |
|
} |
|
|
sub print_autoenroll { |
sub print_autoenroll { |
my ($dom,$settings,$rowtotal) = @_; |
my ($dom,$settings,$rowtotal) = @_; |
my $autorun = &Apache::lonnet::auto_run(undef,$dom), |
my $autorun = &Apache::lonnet::auto_run(undef,$dom), |
my ($defdom,$runon,$runoff,$coownerson,$coownersoff,$failsafe); |
my ($defdom,$runon,$runoff,$coownerson,$coownersoff); |
if (ref($settings) eq 'HASH') { |
if (ref($settings) eq 'HASH') { |
if (exists($settings->{'run'})) { |
if (exists($settings->{'run'})) { |
if ($settings->{'run'} eq '0') { |
if ($settings->{'run'} eq '0') { |
Line 2432 sub print_autoenroll {
|
Line 2531 sub print_autoenroll {
|
if (exists($settings->{'sender_domain'})) { |
if (exists($settings->{'sender_domain'})) { |
$defdom = $settings->{'sender_domain'}; |
$defdom = $settings->{'sender_domain'}; |
} |
} |
if (exists($settings->{'autofailsafe'})) { |
|
$failsafe = $settings->{'autofailsafe'}; |
|
} |
|
} else { |
} else { |
if ($autorun) { |
if ($autorun) { |
$runon = ' checked="checked" '; |
$runon = ' checked="checked" '; |
Line 2470 sub print_autoenroll {
|
Line 2566 sub print_autoenroll {
|
$coownerson.' value="1" />'.&mt('Yes').'</label> '. |
$coownerson.' value="1" />'.&mt('Yes').'</label> '. |
'<label><input type="radio" name="autoassign_coowners"'. |
'<label><input type="radio" name="autoassign_coowners"'. |
$coownersoff.' value="0" />'.&mt('No').'</label></span></td>'. |
$coownersoff.' value="0" />'.&mt('No').'</label></span></td>'. |
'</tr><tr>'. |
'</tr>'; |
'<td>'.&mt('Failsafe for no drops when institutional data missing').'</td>'. |
$$rowtotal += 3; |
'<td class="LC_right_item"><span class="LC_nobreak">'. |
|
'<input type="text" name="autoenroll_failsafe"'. |
|
' value="'.$failsafe.'" size="4" /></td></tr>'; |
|
$$rowtotal += 4; |
|
return $datatable; |
return $datatable; |
} |
} |
|
|
Line 2873 sub radiobutton_prefs {
|
Line 2965 sub radiobutton_prefs {
|
} else { |
} else { |
$datatable .= '<td class="LC_right_item">'; |
$datatable .= '<td class="LC_right_item">'; |
} |
} |
$datatable .= |
$datatable .= |
'<span class="LC_nobreak">'. |
'<span class="LC_nobreak">'. |
'<label><input type="radio" name="'. |
'<label><input type="radio" name="'. |
$item.'" '.$checkedon{$item}.' value="1"'.$onclick.' />'.&mt('Yes'). |
$item.'" '.$checkedon{$item}.' value="1"'.$onclick.' />'.&mt('Yes'). |
Line 2887 sub radiobutton_prefs {
|
Line 2979 sub radiobutton_prefs {
|
return ($datatable,$itemcount); |
return ($datatable,$itemcount); |
} |
} |
|
|
|
sub print_ltitools { |
|
my ($dom,$settings,$rowtotal) = @_; |
|
my $rownum = 0; |
|
my $css_class; |
|
my $itemcount = 1; |
|
my $maxnum = 0; |
|
my %ordered; |
|
if (ref($settings) eq 'HASH') { |
|
foreach my $item (keys(%{$settings})) { |
|
if (ref($settings->{$item}) eq 'HASH') { |
|
my $num = $settings->{$item}{'order'}; |
|
$ordered{$num} = $item; |
|
} |
|
} |
|
} |
|
my $confname = $dom.'-domainconfig'; |
|
my $switchserver = &check_switchserver($dom,$confname); |
|
my $maxnum = scalar(keys(%ordered)); |
|
my $datatable = <itools_javascript($settings); |
|
my %lt = <itools_names(); |
|
my @courseroles = ('cc','in','ta','ep','st'); |
|
my @ltiroles = qw(Instructor ContentDeveloper TeachingAssistant Learner); |
|
my @fields = ('fullname','firstname','lastname','email','user','roles'); |
|
if (keys(%ordered)) { |
|
my @items = sort { $a <=> $b } keys(%ordered); |
|
for (my $i=0; $i<@items; $i++) { |
|
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
|
my $item = $ordered{$items[$i]}; |
|
my ($title,$key,$secret,$url,$imgsrc,$version); |
|
if (ref($settings->{$item}) eq 'HASH') { |
|
$title = $settings->{$item}->{'title'}; |
|
$url = $settings->{$item}->{'url'}; |
|
$key = $settings->{$item}->{'key'}; |
|
$secret = $settings->{$item}->{'secret'}; |
|
my $image = $settings->{$item}->{'image'}; |
|
if ($image ne '') { |
|
$imgsrc = '<img src="'.$image.'" alt="'.&mt('Tool Provider icon').'" />'; |
|
} |
|
} |
|
my $chgstr = ' onchange="javascript:reorderLTI(this.form,'."'ltitools_".$item."'".');"'; |
|
$datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">' |
|
.'<select name="ltitools_'.$item.'"'.$chgstr.'>'; |
|
for (my $k=0; $k<=$maxnum; $k++) { |
|
my $vpos = $k+1; |
|
my $selstr; |
|
if ($k == $i) { |
|
$selstr = ' selected="selected" '; |
|
} |
|
$datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>'; |
|
} |
|
$datatable .= '</select>'.(' 'x2). |
|
'<label><input type="checkbox" name="ltitools_del" value="'.$item.'" />'. |
|
&mt('Delete?').'</label></span></td>'. |
|
'<td colspan="2">'. |
|
'<fieldset><legend>'.&mt('Required settings').'</legend>'. |
|
'<span class="LC_nobreak">'.$lt{'title'}.':<input type="text" size="30" name="ltitools_title_'.$i.'" value="'.$title.'" /></span> '. |
|
(' 'x2). |
|
'<span class="LC_nobreak">'.$lt{'version'}.':<select name="ltitools_version_'.$i.'">'. |
|
'<option value="LTI-1p0" selected="selected">1.1</option></select></span> '. |
|
(' 'x2). |
|
'<span class="LC_nobreak">'.$lt{'msgtype'}.':<select name="ltitools_msgtype_'.$i.'">'. |
|
'<option value="basic-lti-launch-request" selected="selected">Launch</option></select></span> '. |
|
'<br /><br />'. |
|
'<span class="LC_nobreak">'.$lt{'url'}.':<input type="text" size="30" name="ltitools_url_'.$i.'"'. |
|
' value="'.$url.'" /></span>'. |
|
(' 'x2). |
|
'<span class="LC_nobreak">'.$lt{'key'}. |
|
'<input type="text" size="25" name="ltitools_key_'.$i.'" value="'.$key.'" /></span> '. |
|
(' 'x2). |
|
'<span class="LC_nobreak">'.$lt{'secret'}.':'. |
|
'<input type="password" size="20" name="ltitools_secret_'.$i.'" value="'.$secret.'" />'. |
|
'<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.ltitools_secret_'.$i.'.type='."'text'".' } else { this.form.ltitools_secret_'.$i.'.type='."'password'".' }" />'.&mt('Visible input').'</label>'. |
|
'<input type="hidden" name="ltitools_id_'.$i.'" value="'.$item.'" /></span>'. |
|
'</fieldset>'. |
|
'<fieldset><legend>'.&mt('Optional settings').'</legend>'. |
|
'<span class="LC_nobreak">'.&mt('Display target:'); |
|
my %currdisp; |
|
if (ref($settings->{$item}->{'display'}) eq 'HASH') { |
|
if ($settings->{$item}->{'display'}->{'target'} eq 'window') { |
|
$currdisp{'window'} = ' checked="checked"'; |
|
} else { |
|
$currdisp{'iframe'} = ' checked="checked"'; |
|
} |
|
if ($settings->{$item}->{'display'}->{'width'} =~ /^(\d+)$/) { |
|
$currdisp{'width'} = $1; |
|
} |
|
if ($settings->{$item}->{'display'}->{'height'} =~ /^(\d+)$/) { |
|
$currdisp{'height'} = $1; |
|
} |
|
} else { |
|
$currdisp{'iframe'} = ' checked="checked"'; |
|
} |
|
foreach my $disp ('iframe','window') { |
|
$datatable .= '<label><input type="radio" name="ltitools_target_'.$i.'" value="'.$disp.'"'.$currdisp{$disp}.' />'. |
|
$lt{$disp}.'</label>'.(' 'x2); |
|
} |
|
$datatable .= (' 'x4); |
|
foreach my $dimen ('width','height') { |
|
$datatable .= '<label>'.$lt{$dimen}.' '. |
|
'<input type="text" name="ltitools_'.$dimen.'_'.$i.'" size="5" value="'.$currdisp{$dimen}.'" /></label>'. |
|
(' 'x2); |
|
} |
|
$datatable .= '<br />'; |
|
foreach my $extra ('passback','roster') { |
|
my $checkedon = ''; |
|
my $checkedoff = ' checked="checked"'; |
|
if ($settings->{$item}->{$extra}) { |
|
$checkedon = $checkedoff; |
|
$checkedoff = ''; |
|
} |
|
$datatable .= $lt{$extra}.' '. |
|
'<label><input type="radio" name="ltitools_'.$extra.'_'.$i.'" value="1"'.$checkedon.' />'. |
|
&mt('Yes').'</label>'.(' 'x2). |
|
'<label><input type="radio" name="ltitools_'.$extra.'_'.$i.'" value="0"'.$checkedoff.' />'. |
|
&mt('No').'</label>'.(' 'x4); |
|
} |
|
$datatable .= '<br /><br /><span class="LC_nobreak">'.$lt{'icon'}.': '; |
|
if ($imgsrc) { |
|
$datatable .= $imgsrc. |
|
'<label><input type="checkbox" name="ltitools_image_del"'. |
|
' value="'.$item.'" />'.&mt('Delete?').'</label></span> '. |
|
'<span class="LC_nobreak"> '.&mt('Replace:').' '; |
|
} else { |
|
$datatable .= '('.&mt('if larger than 21x21 pixels, image will be scaled').') '; |
|
} |
|
if ($switchserver) { |
|
$datatable .= &mt('Upload to library server: [_1]',$switchserver); |
|
} else { |
|
$datatable .= '<input type="file" name="ltitools_image_'.$i.'" value="" />'; |
|
} |
|
$datatable .= '</span></fieldset>'; |
|
my (%checkedfields,%rolemaps); |
|
if (ref($settings->{$item}) eq 'HASH') { |
|
if (ref($settings->{$item}->{'fields'}) eq 'HASH') { |
|
%checkedfields = %{$settings->{$item}->{'fields'}}; |
|
} |
|
if (ref($settings->{$item}->{'roles'}) eq 'HASH') { |
|
%rolemaps = %{$settings->{$item}->{'roles'}}; |
|
$checkedfields{'roles'} = 1; |
|
} |
|
} |
|
$datatable .= '<fieldset><legend>'.&mt('User data sent on launch').'</legend>'. |
|
'<span class="LC_nobreak">'; |
|
foreach my $field (@fields) { |
|
my $checked; |
|
if ($checkedfields{$field}) { |
|
$checked = ' checked="checked"'; |
|
} |
|
$datatable .= '<label>'. |
|
'<input type="checkbox" name="ltitools_fields_'.$i.'" value="'.$field.'"'.$checked.' />'. |
|
$lt{$field}.'</label>'.(' ' x2); |
|
} |
|
$datatable .= '</span></fieldset>'. |
|
'<fieldset><legend>'.&mt('Role mapping').'</legend><table><tr>'; |
|
foreach my $role (@courseroles) { |
|
my ($selected,$selectnone); |
|
if (!$rolemaps{$role}) { |
|
$selectnone = ' selected="selected"'; |
|
} |
|
$datatable .= '<td align="center">'. |
|
&Apache::lonnet::plaintext($role,'Course').'<br />'. |
|
'<select name="ltitools_roles_'.$role.'_'.$i.'">'. |
|
'<option value=""'.$selectnone.'>'.&mt('Select').'</option>'; |
|
foreach my $ltirole (@ltiroles) { |
|
unless ($selectnone) { |
|
if ($rolemaps{$role} eq $ltirole) { |
|
$selected = ' selected="selected"'; |
|
} else { |
|
$selected = ''; |
|
} |
|
} |
|
$datatable .= '<option value="'.$ltirole.'"'.$selected.'>'.$ltirole.'</option>'; |
|
} |
|
$datatable .= '</select></td>'; |
|
} |
|
$datatable .= '</tr></table></fieldset>'. |
|
'<fieldset><legend>'.&mt('Custom items sent on launch').'</legend>'. |
|
'<table><tr><th>'.&mt('Action').'</th><th>'.&mt('Name').'</th><th>'.&mt('Value').'</th></tr>'; |
|
if (ref($settings->{$item}->{'custom'}) eq 'HASH') { |
|
my %custom = %{$settings->{$item}->{'custom'}}; |
|
if (keys(%custom) > 0) { |
|
foreach my $key (sort(keys(%custom))) { |
|
$datatable .= '<tr><td><span class="LC_nobreak">'. |
|
'<label><input type="checkbox" name="ltitools_customdel_'.$i.'" value="'. |
|
$key.'" />'.&mt('Delete').'</label></span></td><td>'.$key.'</td>'. |
|
'<td><input type="text" name="ltitools_customval_'.$key.'_'.$i.'"'. |
|
' value="'.$custom{$key}.'" /></td></tr>'; |
|
} |
|
} |
|
} |
|
$datatable .= '<tr><td><span class="LC_nobreak">'. |
|
'<label><input type="checkbox" name="ltitools_customadd" value="'.$i.'" />'. |
|
&mt('Add').'</label></span></td><td><input type="text" name="ltitools_custom_name_'.$i.'" />'. |
|
'</td><td><input type="text" name="ltitools_custom_value_'.$i.'" /></td></tr>'; |
|
$datatable .= '</table></fieldset></td></tr>'."\n"; |
|
$itemcount ++; |
|
} |
|
} |
|
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
|
my $chgstr = ' onchange="javascript:reorderLTI(this.form,'."'ltitools_add_pos'".');"'; |
|
$datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'."\n". |
|
'<input type="hidden" name="ltitools_maxnum" value="'.$maxnum.'" />'."\n". |
|
'<select name="ltitools_add_pos"'.$chgstr.'>'; |
|
for (my $k=0; $k<$maxnum+1; $k++) { |
|
my $vpos = $k+1; |
|
my $selstr; |
|
if ($k == $maxnum) { |
|
$selstr = ' selected="selected" '; |
|
} |
|
$datatable .= '<option value="'.$k.'"'.$selstr.'>'.$vpos.'</option>'; |
|
} |
|
$datatable .= '</select> '."\n". |
|
'<input type="checkbox" name="ltitools_add" value="1" />'.&mt('Add').'</td>'."\n". |
|
'<td colspan="2">'. |
|
'<fieldset><legend>'.&mt('Required settings').'</legend>'. |
|
'<span class="LC_nobreak">'.$lt{'title'}.':<input type="text" size="30" name="ltitools_add_title" value="" /></span> '."\n". |
|
(' 'x2). |
|
'<span class="LC_nobreak">'.$lt{'version'}.':<select name="ltitools_add_version">'. |
|
'<option value="LTI-1p0" selected="selected">1.1</option></select></span> '."\n". |
|
(' 'x2). |
|
'<span class="LC_nobreak">'.$lt{'msgtype'}.':<select name="ltitools_add_msgtype">'. |
|
'<option value="basic-lti-launch-request" selected="selected">Launch</option></select></span> '. |
|
'<br />'. |
|
'<span class="LC_nobreak">'.$lt{'url'}.':<input type="text" size="30" name="ltitools_add_url" value="" /></span> '."\n". |
|
(' 'x2). |
|
'<span class="LC_nobreak">'.$lt{'key'}.':<input type="text" size="25" name="ltitools_add_key" value="" /></span> '."\n". |
|
(' 'x2). |
|
'<span class="LC_nobreak">'.$lt{'secret'}.':<input type="password" size="20" name="ltitools_add_secret" value="" />'. |
|
'<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.ltitools_add_secret.type='."'text'".' } else { this.form.ltitools_add_secret.type='."'password'".' }" />'.&mt('Visible input').'</label></span> '."\n". |
|
'</fieldset>'. |
|
'<fieldset><legend>'.&mt('Optional settings').'</legend>'. |
|
'<span class="LC_nobreak">'.&mt('Display target:'); |
|
my %defaultdisp; |
|
$defaultdisp{'iframe'} = ' checked="checked"'; |
|
foreach my $disp ('iframe','window') { |
|
$datatable .= '<label><input type="radio" name="ltitools_add_target" value="'.$disp.'"'.$defaultdisp{$disp}.' />'. |
|
$lt{$disp}.'</label>'.(' 'x2); |
|
} |
|
$datatable .= (' 'x4); |
|
foreach my $dimen ('width','height') { |
|
$datatable .= '<label>'.$lt{$dimen}.' '. |
|
'<input type="text" name="ltitools_add_'.$dimen.'" size="5" /></label>'. |
|
(' 'x2); |
|
} |
|
$datatable .= '<br />'; |
|
foreach my $extra ('passback','roster') { |
|
$datatable .= $lt{$extra}.' '. |
|
'<label><input type="radio" name="ltitools_add_'.$extra.'" value="1" />'. |
|
&mt('Yes').'</label>'.(' 'x2). |
|
'<label><input type="radio" name="ltitools_add_'.$extra.'" value="0" checked="checked" />'. |
|
&mt('No').'</label>'.(' 'x4); |
|
} |
|
$datatable .= '<br /><br /><span class="LC_nobreak">'.$lt{'icon'}.': '. |
|
'('.&mt('if larger than 21x21 pixels, image will be scaled').') '; |
|
if ($switchserver) { |
|
$datatable .= &mt('Upload to library server: [_1]',$switchserver); |
|
} else { |
|
$datatable .= '<input type="file" name="ltitools_add_image" value="" />'; |
|
} |
|
$datatable .= '</span></fieldset>'. |
|
'<fieldset><legend>'.&mt('User data sent on launch').'</legend>'. |
|
'<span class="LC_nobreak">'; |
|
foreach my $field (@fields) { |
|
$datatable .= '<label>'. |
|
'<input type="checkbox" name="ltitools_add_fields" value="'.$field.'" />'. |
|
$lt{$field}.'</label>'.(' ' x2); |
|
} |
|
$datatable .= '</span></fieldset>'. |
|
'<fieldset><legend>'.&mt('Role mapping').'</legend><table><tr>'; |
|
foreach my $role (@courseroles) { |
|
my ($checked,$checkednone); |
|
$datatable .= '<td align="center">'. |
|
&Apache::lonnet::plaintext($role,'Course').'<br />'. |
|
'<select name="ltitools_add_roles_'.$role.'">'. |
|
'<option value="" selected="selected">'.&mt('Select').'</option>'; |
|
foreach my $ltirole (@ltiroles) { |
|
$datatable .= '<option value="'.$ltirole.'">'.$ltirole.'</option>'; |
|
} |
|
$datatable .= '</select></td>'; |
|
} |
|
$datatable .= '</tr></table></fieldset>'. |
|
'<fieldset><legend>'.&mt('Custom items sent on launch').'</legend>'. |
|
'<table><tr><th>'.&mt('Action').'</th><th>'.&mt('Name').'</th><th>'.&mt('Value').'</th></tr>'. |
|
'<tr><td><span class="LC_nobreak">'. |
|
'<label><input type="checkbox" name="ltitools_add_custom" value="1" />'. |
|
&mt('Add').'</label></span></td><td><input type="text" name="ltitools_add_custom_name" />'. |
|
'</td><td><input type="text" name="ltitools_add_custom_value" /></td></tr>'. |
|
'</table></fieldset></td></tr>'."\n". |
|
'</td>'."\n". |
|
'</tr>'."\n"; |
|
$itemcount ++; |
|
return $datatable; |
|
} |
|
|
|
sub ltitools_names { |
|
my %lt = &Apache::lonlocal::texthash( |
|
'title' => 'Title', |
|
'version' => 'Version', |
|
'msgtype' => 'Message Type', |
|
'url' => 'URL', |
|
'key' => 'Key', |
|
'secret' => 'Secret', |
|
'icon' => 'Icon', |
|
'user' => 'Username:domain', |
|
'fullname' => 'Full Name', |
|
'firstname' => 'First Name', |
|
'lastname' => 'Last Name', |
|
'email' => 'E-mail', |
|
'roles' => 'Role', |
|
'window' => 'Window/Tab', |
|
'iframe' => 'iFrame', |
|
'height' => 'Height', |
|
'width' => 'Width', |
|
'passback' => 'Tool can return grades:', |
|
'roster' => 'Tool can retrieve roster:', |
|
); |
|
return %lt; |
|
} |
|
|
sub print_coursedefaults { |
sub print_coursedefaults { |
my ($position,$dom,$settings,$rowtotal) = @_; |
my ($position,$dom,$settings,$rowtotal) = @_; |
my ($css_class,$datatable,%checkedon,%checkedoff,%defaultchecked,@toggles); |
my ($css_class,$datatable,%checkedon,%checkedoff,%defaultchecked,@toggles); |
my $itemcount = 1; |
my $itemcount = 1; |
my %choices = &Apache::lonlocal::texthash ( |
my %choices = &Apache::lonlocal::texthash ( |
|
canuse_pdfforms => 'Course/Community users can create/upload PDF forms', |
uploadquota => 'Default quota for files uploaded directly to course/community using Course Editor (MB)', |
uploadquota => 'Default quota for files uploaded directly to course/community using Course Editor (MB)', |
anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys', |
anonsurvey_threshold => 'Responder count needed before showing submissions for anonymous surveys', |
coursecredits => 'Credits can be specified for courses', |
coursecredits => 'Credits can be specified for courses', |
uselcmath => 'Math preview uses LON-CAPA previewer (javascript) in place of DragMath (Java)', |
uselcmath => 'Math preview uses LON-CAPA previewer (javascript) in place of DragMath (Java)', |
usejsme => 'Molecule editor uses JSME (HTML5) in place of JME (Java)', |
usejsme => 'Molecule editor uses JSME (HTML5) in place of JME (Java)', |
postsubmit => 'Disable submit button/keypress following student submission', |
postsubmit => 'Disable submit button/keypress following student submission', |
canclone => "People who may clone a course (besides course's owner and coordinators)", |
canclone => "People who may clone a course (besides course's owner and coordinators)", |
mysqltables => 'Lifetime (s) of "Temporary" MySQL tables (student performance data) on homeserver', |
|
); |
); |
my %staticdefaults = ( |
my %staticdefaults = ( |
anonsurvey_threshold => 10, |
anonsurvey_threshold => 10, |
uploadquota => 500, |
uploadquota => 500, |
postsubmit => 60, |
postsubmit => 60, |
mysqltables => 172800, |
|
); |
); |
if ($position eq 'top') { |
if ($position eq 'top') { |
%defaultchecked = ( |
%defaultchecked = ( |
|
'canuse_pdfforms' => 'off', |
'uselcmath' => 'on', |
'uselcmath' => 'on', |
'usejsme' => 'on', |
'usejsme' => 'on', |
'canclone' => 'none', |
'canclone' => 'none', |
); |
); |
@toggles = ('uselcmath','usejsme'); |
@toggles = ('canuse_pdfforms','uselcmath','usejsme'); |
($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked, |
($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked, |
\%choices,$itemcount); |
\%choices,$itemcount); |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
Line 2950 sub print_coursedefaults {
|
Line 3361 sub print_coursedefaults {
|
$currcanclone = $settings->{'canclone'}; |
$currcanclone = $settings->{'canclone'}; |
} |
} |
} |
} |
} |
} |
foreach my $option (@cloneoptions) { |
foreach my $option (@cloneoptions) { |
my ($checked,$additional); |
my ($checked,$additional); |
if ($currcanclone eq $option) { |
if ($currcanclone eq $option) { |
Line 2989 sub print_coursedefaults {
|
Line 3400 sub print_coursedefaults {
|
$itemcount ++; |
$itemcount ++; |
} else { |
} else { |
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; |
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; |
my ($currdefresponder,%defcredits,%curruploadquota,%deftimeout,%currmysql); |
my ($currdefresponder,%defcredits,%curruploadquota,%deftimeout); |
my $currusecredits = 0; |
my $currusecredits = 0; |
my $postsubmitclient = 1; |
my $postsubmitclient = 1; |
my @types = ('official','unofficial','community','textbook'); |
my @types = ('official','unofficial','community','textbook'); |
Line 3019 sub print_coursedefaults {
|
Line 3430 sub print_coursedefaults {
|
foreach my $type (@types) { |
foreach my $type (@types) { |
if (ref($settings->{'postsubmit'}->{'timeout'}) eq 'HASH') { |
if (ref($settings->{'postsubmit'}->{'timeout'}) eq 'HASH') { |
if ($settings->{'postsubmit'}->{'timeout'}->{$type} =~ /^\d+$/) { |
if ($settings->{'postsubmit'}->{'timeout'}->{$type} =~ /^\d+$/) { |
$deftimeout{$type} = $settings->{'postsubmit'}->{'timeout'}->{$type}; |
$deftimeout{$type} = $settings->{'postsubmit'}->{'timeout'}->{$type}; |
} else { |
} else { |
$deftimeout{$type} = $staticdefaults{'postsubmit'}; |
$deftimeout{$type} = $staticdefaults{'postsubmit'}; |
} |
} |
Line 3033 sub print_coursedefaults {
|
Line 3444 sub print_coursedefaults {
|
$deftimeout{$type} = $staticdefaults{'postsubmit'}; |
$deftimeout{$type} = $staticdefaults{'postsubmit'}; |
} |
} |
} |
} |
if (ref($settings->{'mysqltables'}) eq 'HASH') { |
|
foreach my $type (keys(%{$settings->{'mysqltables'}})) { |
|
$currmysql{$type} = $settings->{'mysqltables'}{$type}; |
|
} |
|
} else { |
|
foreach my $type (@types) { |
|
$currmysql{$type} = $staticdefaults{'mysqltables'}; |
|
} |
|
} |
|
} else { |
} else { |
foreach my $type (@types) { |
foreach my $type (@types) { |
$deftimeout{$type} = $staticdefaults{'postsubmit'}; |
$deftimeout{$type} = $staticdefaults{'postsubmit'}; |
Line 3119 sub print_coursedefaults {
|
Line 3521 sub print_coursedefaults {
|
$additional .= '</tr></table></div>'."\n"; |
$additional .= '</tr></table></div>'."\n"; |
%defaultchecked = ('postsubmit' => 'on'); |
%defaultchecked = ('postsubmit' => 'on'); |
@toggles = ('postsubmit'); |
@toggles = ('postsubmit'); |
$current = { |
my $current = { |
'postsubmit' => $postsubmitclient, |
'postsubmit' => $postsubmitclient, |
}; |
}; |
($table,$itemcount) = |
($table,$itemcount) = |
&radiobutton_prefs($current,\@toggles,\%defaultchecked, |
&radiobutton_prefs($current,\@toggles,\%defaultchecked, |
\%choices,$itemcount,$onclick,$additional,'left'); |
\%choices,$itemcount,$onclick,$additional,'left'); |
$datatable .= $table; |
$datatable .= $table; |
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; |
|
$datatable .= '<tr'.$css_class.'><td><span class="LC_nobreak">'. |
|
$choices{'mysqltables'}. |
|
'</span></td>'. |
|
'<td align="right" class="LC_right_item">'. |
|
'<table><tr>'; |
|
foreach my $type (@types) { |
|
$datatable .= '<td align="center">'.&mt($type).'<br />'. |
|
'<input type="text" name="mysqltables_'.$type.'"'. |
|
' value="'.$currmysql{$type}.'" size="5" /></td>'; |
|
} |
|
$datatable .= '</tr></table></td></tr>'."\n"; |
|
$itemcount ++; |
|
|
|
} |
} |
$$rowtotal += $itemcount; |
$$rowtotal += $itemcount; |
return $datatable; |
return $datatable; |
Line 3672 sub spares_row {
|
Line 4060 sub spares_row {
|
<span class="LC_nobreak">'. |
<span class="LC_nobreak">'. |
&mt('[_1] when busy, offloads to:' |
&mt('[_1] when busy, offloads to:' |
,'<b>'.$server.'</b>').'</span><br />'. |
,'<b>'.$server.'</b>').'</span><br />'. |
'<span class="LC_nobreak">'."\n". |
'<span class="LC_nobreak">'."\n". |
'<label><input type="checkbox" name="offloadnow" value="'.$server.'"'.$checkednow.' />'. |
'<label><input type="checkbox" name="offloadnow" value="'.$server.'"'.$checkednow.' />'. |
' '.&mt('Switch active users on next access').'</label></span>'. |
' '.&mt('Switch active users on next access').'</label></span>'. |
"\n"; |
"\n"; |
Line 4568 sub email_as_username {
|
Line 4956 sub email_as_username {
|
sub captcha_choice { |
sub captcha_choice { |
my ($context,$settings,$itemcount) = @_; |
my ($context,$settings,$itemcount) = @_; |
my ($keyentry,$currpub,$currpriv,%checked,$rowname,$pubtext,$privtext, |
my ($keyentry,$currpub,$currpriv,%checked,$rowname,$pubtext,$privtext, |
$vertext,$currver); |
$vertext,$currver); |
my %lt = &captcha_phrases(); |
my %lt = &captcha_phrases(); |
$keyentry = 'hidden'; |
$keyentry = 'hidden'; |
if ($context eq 'cancreate') { |
if ($context eq 'cancreate') { |
Line 5423 sub serverstatus_pages {
|
Line 5811 sub serverstatus_pages {
|
|
|
sub defaults_javascript { |
sub defaults_javascript { |
my ($settings) = @_; |
my ($settings) = @_; |
return unless (ref($settings) eq 'HASH'); |
return unless (ref($settings) eq 'HASH'); |
if ((ref($settings->{'inststatusorder'}) eq 'ARRAY') && (ref($settings->{'inststatustypes'}) eq 'HASH')) { |
if ((ref($settings->{'inststatusorder'}) eq 'ARRAY') && (ref($settings->{'inststatustypes'}) eq 'HASH')) { |
my $maxnum = scalar(@{$settings->{'inststatusorder'}}); |
my $maxnum = scalar(@{$settings->{'inststatusorder'}}); |
if ($maxnum eq '') { |
if ($maxnum eq '') { |
Line 6165 sub modify_login {
|
Line 6553 sub modify_login {
|
$errors .= '<li><span class="LC_error">'.$puberror.'</span></li>'; |
$errors .= '<li><span class="LC_error">'.$puberror.'</span></li>'; |
if ((grep(/^\Q$lang\E$/,@currlangs)) && |
if ((grep(/^\Q$lang\E$/,@currlangs)) && |
(!grep(/^\Q$lang\E$/,@delurls))) { |
(!grep(/^\Q$lang\E$/,@delurls))) { |
|
|
$loginhash{'login'}{'helpurl'}{$lang} = $domconfig{'login'}{'helpurl'}{$lang}; |
$loginhash{'login'}{'helpurl'}{$lang} = $domconfig{'login'}{'helpurl'}{$lang}; |
} |
} |
} |
} |
Line 6189 sub modify_login {
|
Line 6576 sub modify_login {
|
if ($domservers{$lonhost}) { |
if ($domservers{$lonhost}) { |
if (ref($domconfig{'login'}{'headtag'}{$lonhost}) eq 'HASH') { |
if (ref($domconfig{'login'}{'headtag'}{$lonhost}) eq 'HASH') { |
$currheadtagurls{$lonhost} = $domconfig{'login'}{'headtag'}{$lonhost}{'url'}; |
$currheadtagurls{$lonhost} = $domconfig{'login'}{'headtag'}{$lonhost}{'url'}; |
$currexempt{$lonhost} = $domconfig{'login'}{'headtag'}{$lonhost}{'exempt'} |
$currexempt{$lonhost} = $domconfig{'login'}{'headtag'}{$lonhost}{'exempt'}; |
} |
} |
} |
} |
} |
} |
Line 6208 sub modify_login {
|
Line 6595 sub modify_login {
|
} elsif ($currheadtagurls{$lonhost}) { |
} elsif ($currheadtagurls{$lonhost}) { |
$loginhash{'login'}{'headtag'}{$lonhost}{'url'} = $currheadtagurls{$lonhost}; |
$loginhash{'login'}{'headtag'}{$lonhost}{'url'} = $currheadtagurls{$lonhost}; |
if ($currexempt{$lonhost}) { |
if ($currexempt{$lonhost}) { |
if ((!exists($possexempt{$lonhost})) || ($possexempt{$lonhost} ne $currexempt{$lonhost})) { |
if ((!exists($possexempt{$lonhost})) || ($possexempt{$lonhost} ne $currexempt{$lonhost})) { |
$changes{'headtag'}{$lonhost} = 1; |
$changes{'headtag'}{$lonhost} = 1; |
} |
} |
} elsif ($possexempt{$lonhost}) { |
} elsif ($possexempt{$lonhost}) { |
Line 6259 sub modify_login {
|
Line 6646 sub modify_login {
|
$errors .= '<li><span class="LC_error">'.$error.'</span></li>'; |
$errors .= '<li><span class="LC_error">'.$error.'</span></li>'; |
} |
} |
} |
} |
|
|
&process_captcha('login',\%changes,$loginhash{'login'},$domconfig{'login'}); |
&process_captcha('login',\%changes,$loginhash{'login'},$domconfig{'login'}); |
|
|
my $defaulthelpfile = '/adm/loginproblems.html'; |
my $defaulthelpfile = '/adm/loginproblems.html'; |
Line 6441 sub modify_login {
|
Line 6827 sub modify_login {
|
return $resulttext; |
return $resulttext; |
} |
} |
|
|
|
|
sub check_exempt_addresses { |
sub check_exempt_addresses { |
my ($iplist) = @_; |
my ($iplist) = @_; |
$iplist =~ s/^\s+//; |
$iplist =~ s/^\s+//; |
Line 6913 sub check_authorstatus {
|
Line 7300 sub check_authorstatus {
|
|
|
sub publishlogo { |
sub publishlogo { |
my ($r,$action,$formname,$dom,$confname,$subdir,$thumbwidth,$thumbheight,$savefileas) = @_; |
my ($r,$action,$formname,$dom,$confname,$subdir,$thumbwidth,$thumbheight,$savefileas) = @_; |
my ($output,$fname,$logourl); |
my ($output,$fname,$logourl,$madethumb); |
if ($action eq 'upload') { |
if ($action eq 'upload') { |
$fname=$env{'form.'.$formname.'.filename'}; |
$fname=$env{'form.'.$formname.'.filename'}; |
chop($env{'form.'.$formname}); |
chop($env{'form.'.$formname}); |
Line 7041 $env{'user.name'}.':'.$env{'user.domain'
|
Line 7428 $env{'user.name'}.':'.$env{'user.domain'
|
$r->set_handlers('PerlCleanupHandler' => [\¬ifysubscribed,@{$handlers}]); |
$r->set_handlers('PerlCleanupHandler' => [\¬ifysubscribed,@{$handlers}]); |
$registered_cleanup=1; |
$registered_cleanup=1; |
} |
} |
|
$madethumb = 1; |
} else { |
} else { |
print $logfile "\nUnable to write ".$copyfile. |
print $logfile "\nUnable to write ".$copyfile. |
':'.$!."\n"; |
':'.$!."\n"; |
Line 7053 $env{'user.name'}.':'.$env{'user.domain'
|
Line 7441 $env{'user.name'}.':'.$env{'user.domain'
|
$output = $versionresult; |
$output = $versionresult; |
} |
} |
} |
} |
return ($output,$logourl); |
return ($output,$logourl,$madethumb); |
} |
} |
|
|
sub logo_versioning { |
sub logo_versioning { |
Line 7350 sub modify_quotas {
|
Line 7738 sub modify_quotas {
|
my $newpos = $env{'form.'.$itemid}; |
my $newpos = $env{'form.'.$itemid}; |
$newpos =~ s/\D+//g; |
$newpos =~ s/\D+//g; |
foreach my $item ('subject','title','publisher','author') { |
foreach my $item ('subject','title','publisher','author') { |
next if ((($item eq 'author') || ($item eq 'publisher')) && |
next if ((($item eq 'author') || ($item eq 'publisher')) && |
($type eq 'templates')); |
($type eq 'templates')); |
$confhash{$type}{$key}{$item} = $env{'form.'.$type.'_'.$item.'_'.$i}; |
$confhash{$type}{$key}{$item} = $env{'form.'.$type.'_'.$item.'_'.$i}; |
if ($domconfig{$action}{$type}{$key}{$item} ne $confhash{$type}{$key}{$item}) { |
if ($domconfig{$action}{$type}{$key}{$item} ne $confhash{$type}{$key}{$item}) { |
Line 7519 sub modify_quotas {
|
Line 7907 sub modify_quotas {
|
} |
} |
} elsif ($confhash{'validation'}{'dc'} ne '') { |
} elsif ($confhash{'validation'}{'dc'} ne '') { |
$changes{'validation'}{'dc'} = $confhash{'validation'}{'dc'}; |
$changes{'validation'}{'dc'} = $confhash{'validation'}{'dc'}; |
} |
} |
} else { |
} else { |
if (ref($domconfig{'requestcourses'}) eq 'HASH') { |
if (ref($domconfig{'requestcourses'}) eq 'HASH') { |
if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') { |
if (ref($domconfig{'requestcourses'}{'validation'}) eq 'HASH') { |
Line 7922 sub process_textbook_image {
|
Line 8310 sub process_textbook_image {
|
return ($url,$error); |
return ($url,$error); |
} |
} |
|
|
|
sub modify_ltitools { |
|
my ($r,$dom,$action,$lastactref,%domconfig) = @_; |
|
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1); |
|
my ($newid,@allpos,%changes,%confhash,$errors,$resulttext); |
|
my $confname = $dom.'-domainconfig'; |
|
my $servadm = $r->dir_config('lonAdmEMail'); |
|
my ($configuserok,$author_ok,$switchserver) = &config_check($dom,$confname,$servadm); |
|
my (%posslti,%possfield); |
|
my @courseroles = ('cc','in','ta','ep','st'); |
|
my @ltiroles = qw(Instructor ContentDeveloper TeachingAssistant Learner); |
|
map { $posslti{$_} = 1; } @ltiroles; |
|
my @allfields = ('fullname','firstname','lastname','email','user','roles'); |
|
map { $possfield{$_} = 1; } @allfields; |
|
my %lt = <itools_names(); |
|
if ($env{'form.ltitools_add'}) { |
|
my $title = $env{'form.ltitools_add_title'}; |
|
$title =~ s/(`)/'/g; |
|
($newid,my $error) = &get_ltitools_id($dom,$title); |
|
if ($newid) { |
|
my $position = $env{'form.ltitools_add_pos'}; |
|
$position =~ s/\D+//g; |
|
if ($position ne '') { |
|
$allpos[$position] = $newid; |
|
} |
|
$changes{$newid} = 1; |
|
foreach my $item ('title','url','key','secret') { |
|
$env{'form.ltitools_add_'.$item} =~ s/(`)/'/g; |
|
if ($env{'form.ltitools_add_'.$item}) { |
|
$confhash{$newid}{$item} = $env{'form.ltitools_add_'.$item}; |
|
} |
|
} |
|
if ($env{'form.ltitools_add_version'} eq 'LTI-1p0') { |
|
$confhash{$newid}{'version'} = $env{'form.ltitools_add_version'}; |
|
} |
|
if ($env{'form.ltitools_add_msgtype'} eq 'basic-lti-launch-request') { |
|
$confhash{$newid}{'msgtype'} = $env{'form.ltitools_add_msgtype'}; |
|
} |
|
foreach my $item ('width','height') { |
|
$env{'form.ltitools_add_'.$item} =~ s/^\s+//; |
|
$env{'form.ltitools_add_'.$item} =~ s/\s+$//; |
|
if ($env{'form.ltitools_add_'.$item} =~ /^\d+$/) { |
|
$confhash{$newid}{'display'}{$item} = $env{'form.ltitools_add_'.$item}; |
|
} |
|
} |
|
if ($env{'form.ltitools_add_target'} eq 'window') { |
|
$confhash{$newid}{'display'}{'target'} = $env{'form.ltitools_add_target'}; |
|
} else { |
|
$confhash{$newid}{'display'}{'target'} = 'iframe'; |
|
} |
|
foreach my $item ('passback','roster') { |
|
if ($env{'form.ltitools_add_'.$item}) { |
|
$confhash{$newid}{$item} = 1; |
|
} |
|
} |
|
if ($env{'form.ltitools_add_image.filename'} ne '') { |
|
my ($imageurl,$error) = |
|
&process_ltitools_image($r,$dom,$confname,'ltitools_add_image',$dom, |
|
$configuserok,$switchserver,$author_ok); |
|
if ($imageurl) { |
|
$confhash{$newid}{'image'} = $imageurl; |
|
} |
|
if ($error) { |
|
&Apache::lonnet::logthis($error); |
|
$errors .= '<li><span class="LC_error">'.$error.'</span></li>'; |
|
} |
|
} |
|
my @fields = &Apache::loncommon::get_env_multiple('form.ltitools_add_fields'); |
|
foreach my $field (@fields) { |
|
if ($possfield{$field}) { |
|
if ($field eq 'roles') { |
|
foreach my $role (@courseroles) { |
|
my $choice = $env{'form.ltitools_add_roles_'.$role}; |
|
if (($choice ne '') && ($posslti{$choice})) { |
|
$confhash{$newid}{'roles'}{$role} = $choice; |
|
if ($role eq 'cc') { |
|
$confhash{$newid}{'roles'}{'co'} = $choice; |
|
} |
|
} |
|
} |
|
} else { |
|
$confhash{$newid}{'fields'}{$field} = 1; |
|
} |
|
} |
|
} |
|
if ($env{'form.ltitools_add_custom'}) { |
|
my $name = $env{'form.ltitools_add_custom_name'}; |
|
my $value = $env{'form.ltitools_add_custom_value'}; |
|
$value =~ s/(`)/'/g; |
|
$name =~ s/(`)/'/g; |
|
$confhash{$newid}{'custom'}{$name} = $value; |
|
} |
|
} else { |
|
my $error = &mt('Failed to acquire unique ID for new external tool'); |
|
$errors .= '<li><span class="LC_error">'.$error.'</span></li>'; |
|
} |
|
} |
|
if (ref($domconfig{$action}) eq 'HASH') { |
|
my %deletions; |
|
my @todelete = &Apache::loncommon::get_env_multiple('form.ltitools_del'); |
|
if (@todelete) { |
|
map { $deletions{$_} = 1; } @todelete; |
|
} |
|
my %customadds; |
|
my @newcustom = &Apache::loncommon::get_env_multiple('form.ltitools_customadd'); |
|
if (@newcustom) { |
|
map { $customadds{$_} = 1; } @newcustom; |
|
} |
|
my %imgdeletions; |
|
my @todeleteimages = &Apache::loncommon::get_env_multiple('form.ltitools_image_del'); |
|
if (@todeleteimages) { |
|
map { $imgdeletions{$_} = 1; } @todeleteimages; |
|
} |
|
my $maxnum = $env{'form.ltitools_maxnum'}; |
|
for (my $i=0; $i<=$maxnum; $i++) { |
|
my $itemid = $env{'form.ltitools_id_'.$i}; |
|
if (ref($domconfig{$action}{$itemid}) eq 'HASH') { |
|
if ($deletions{$itemid}) { |
|
if ($domconfig{$action}{$itemid}{'image'}) { |
|
#FIXME need to obsolete item in RES space |
|
} |
|
$changes{$itemid} = $domconfig{$action}{$itemid}{'title'}; |
|
next; |
|
} else { |
|
my $newpos = $env{'form.ltitools_'.$itemid}; |
|
$newpos =~ s/\D+//g; |
|
foreach my $item ('title','url','key','secret') { |
|
$confhash{$itemid}{$item} = $env{'form.ltitools_'.$item.'_'.$i}; |
|
if ($domconfig{$action}{$itemid}{$item} ne $confhash{$itemid}{$item}) { |
|
$changes{$itemid} = 1; |
|
} |
|
} |
|
if ($env{'form.ltitools_version_'.$i} eq 'LTI-1p0') { |
|
$confhash{$itemid}{'version'} = $env{'form.ltitools_version_'.$i}; |
|
} |
|
if ($env{'form.ltitools_msgtype_'.$i} eq 'basic-lti-launch-request') { |
|
$confhash{$itemid}{'msgtype'} = $env{'form.ltitools_msgtype_'.$i}; |
|
} |
|
foreach my $size ('width','height') { |
|
$env{'form.ltitools_'.$size.'_'.$i} =~ s/^\s+//; |
|
$env{'form.ltitools_'.$size.'_'.$i} =~ s/\s+$//; |
|
if ($env{'form.ltitools_'.$size.'_'.$i} =~ /^\d+$/) { |
|
$confhash{$itemid}{'display'}{$size} = $env{'form.ltitools_'.$size.'_'.$i}; |
|
if (ref($domconfig{$action}{$itemid}{'display'}) eq 'HASH') { |
|
if ($domconfig{$action}{$itemid}{'display'}{$size} ne $confhash{$itemid}{'display'}{$size}) { |
|
$changes{$itemid} = 1; |
|
} |
|
} else { |
|
$changes{$itemid} = 1; |
|
} |
|
} |
|
} |
|
if ($env{'form.ltitools_target_'.$i} eq 'window') { |
|
$confhash{$itemid}{'display'}{'target'} = $env{'form.ltitools_target_'.$i}; |
|
} else { |
|
$confhash{$itemid}{'display'}{'target'} = 'iframe'; |
|
} |
|
if (ref($domconfig{$action}{$itemid}{'display'}) eq 'HASH') { |
|
if ($domconfig{$action}{$itemid}{'display'}{'target'} ne $confhash{$itemid}{'display'}{'target'}) { |
|
$changes{$itemid} = 1; |
|
} |
|
} else { |
|
$changes{$itemid} = 1; |
|
} |
|
foreach my $extra ('passback','roster') { |
|
if ($env{'form.ltitools_'.$extra.'_'.$i}) { |
|
$confhash{$itemid}{$extra} = 1; |
|
} |
|
if ($domconfig{$action}{$itemid}{$extra} ne $confhash{$itemid}{$extra}) { |
|
$changes{$itemid} = 1; |
|
} |
|
} |
|
my @fields = &Apache::loncommon::get_env_multiple('form.ltitools_fields_'.$i); |
|
foreach my $field (@fields) { |
|
if ($possfield{$field}) { |
|
if ($field eq 'roles') { |
|
foreach my $role (@courseroles) { |
|
my $choice = $env{'form.ltitools_roles_'.$role.'_'.$i}; |
|
if (($choice ne '') && ($posslti{$choice})) { |
|
$confhash{$itemid}{'roles'}{$role} = $choice; |
|
if ($role eq 'cc') { |
|
$confhash{$itemid}{'roles'}{'co'} = $choice; |
|
} |
|
} |
|
if (ref($domconfig{$action}{$itemid}{'roles'}) eq 'HASH') { |
|
if ($domconfig{$action}{$itemid}{'roles'}{$role} ne $confhash{$itemid}{'roles'}{$role}) { |
|
$changes{$itemid} = 1; |
|
} |
|
} elsif ($confhash{$itemid}{'roles'}{$role}) { |
|
$changes{$itemid} = 1; |
|
} |
|
} |
|
} else { |
|
$confhash{$itemid}{'fields'}{$field} = 1; |
|
if (ref($domconfig{$action}{$itemid}{'fields'}) eq 'HASH') { |
|
if ($domconfig{$action}{$itemid}{'fields'}{$field} ne $confhash{$itemid}{'fields'}{$field}) { |
|
$changes{$itemid} = 1; |
|
} |
|
} else { |
|
$changes{$itemid} = 1; |
|
} |
|
} |
|
} |
|
} |
|
$allpos[$newpos] = $itemid; |
|
} |
|
if ($imgdeletions{$itemid}) { |
|
$changes{$itemid} = 1; |
|
#FIXME need to obsolete item in RES space |
|
} elsif ($env{'form.ltitools_image_'.$i.'.filename'}) { |
|
my ($imgurl,$error) = &process_ltitools_image($r,$dom,$confname,'ltitools_image_'.$i, |
|
$itemid,$configuserok,$switchserver, |
|
$author_ok); |
|
if ($imgurl) { |
|
$confhash{$itemid}{'image'} = $imgurl; |
|
$changes{$itemid} = 1; |
|
} |
|
if ($error) { |
|
&Apache::lonnet::logthis($error); |
|
$errors .= '<li><span class="LC_error">'.$error.'</span></li>'; |
|
} |
|
} elsif ($domconfig{$action}{$itemid}{'image'}) { |
|
$confhash{$itemid}{'image'} = |
|
$domconfig{$action}{$itemid}{'image'}; |
|
} |
|
if ($customadds{$i}) { |
|
my $name = $env{'form.ltitools_custom_name_'.$i}; |
|
$name =~ s/(`)/'/g; |
|
$name =~ s/^\s+//; |
|
$name =~ s/\s+$//; |
|
my $value = $env{'form.ltitools_custom_value_'.$i}; |
|
$value =~ s/(`)/'/g; |
|
$value =~ s/^\s+//; |
|
$value =~ s/\s+$//; |
|
if ($name ne '') { |
|
$confhash{$itemid}{'custom'}{$name} = $value; |
|
$changes{$itemid} = 1; |
|
} |
|
} |
|
my %customdels; |
|
my @customdeletions = &Apache::loncommon::get_env_multiple('form.ltitools_customdel_'.$i); |
|
if (@customdeletions) { |
|
$changes{$itemid} = 1; |
|
} |
|
map { $customdels{$_} = 1; } @customdeletions; |
|
if (ref($domconfig{$action}{$itemid}{'custom'}) eq 'HASH') { |
|
foreach my $key (keys(%{$domconfig{$action}{$itemid}{'custom'}})) { |
|
unless ($customdels{$key}) { |
|
if ($env{'form.ltitools_customval_'.$key.'_'.$i} ne '') { |
|
$confhash{$itemid}{'custom'}{$key} = $env{'form.ltitools_customval_'.$key.'_'.$i}; |
|
} |
|
if ($domconfig{$action}{$itemid}{'custom'}{$key} ne $env{'form.ltitools_customval_'.$key.'_'.$i}) { |
|
$changes{$itemid} = 1; |
|
} |
|
} |
|
} |
|
} |
|
unless ($changes{$itemid}) { |
|
foreach my $key (keys(%{$domconfig{$action}{$itemid}})) { |
|
if (ref($domconfig{$action}{$itemid}{$key}) eq 'HASH') { |
|
if (ref($confhash{$itemid}{$key}) eq 'HASH') { |
|
foreach my $innerkey (keys(%{$domconfig{$action}{$itemid}{$key}})) { |
|
unless (exists($confhash{$itemid}{$key}{$innerkey})) { |
|
$changes{$itemid} = 1; |
|
last; |
|
} |
|
} |
|
} elsif (keys(%{$domconfig{$action}{$itemid}{$key}}) > 0) { |
|
$changes{$itemid} = 1; |
|
} |
|
} |
|
last if ($changes{$itemid}); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if (@allpos > 0) { |
|
my $idx = 0; |
|
foreach my $itemid (@allpos) { |
|
if ($itemid ne '') { |
|
$confhash{$itemid}{'order'} = $idx; |
|
if (ref($domconfig{$action}) eq 'HASH') { |
|
if (ref($domconfig{$action}{$itemid}) eq 'HASH') { |
|
if ($domconfig{$action}{$itemid}{'order'} ne $idx) { |
|
$changes{$itemid} = 1; |
|
} |
|
} |
|
} |
|
$idx ++; |
|
} |
|
} |
|
} |
|
my %ltitoolshash = ( |
|
$action => { %confhash } |
|
); |
|
my $putresult = &Apache::lonnet::put_dom('configuration',\%ltitoolshash, |
|
$dom); |
|
if ($putresult eq 'ok') { |
|
if (keys(%changes) > 0) { |
|
my $cachetime = 24*60*60; |
|
&Apache::lonnet::do_cache_new('ltitools',$dom,\%confhash,$cachetime); |
|
if (ref($lastactref) eq 'HASH') { |
|
$lastactref->{'ltitools'} = 1; |
|
} |
|
$resulttext = &mt('Changes made:').'<ul>'; |
|
my %bynum; |
|
foreach my $itemid (sort(keys(%changes))) { |
|
my $position = $confhash{$itemid}{'order'}; |
|
$bynum{$position} = $itemid; |
|
} |
|
foreach my $pos (sort { $a <=> $b } keys(%bynum)) { |
|
my $itemid = $bynum{$pos}; |
|
if (ref($confhash{$itemid}) ne 'HASH') { |
|
$resulttext .= '<li>'.&mt('Deleted: [_1]',$changes{$itemid}).'</li>'; |
|
} else { |
|
$resulttext .= '<li><b>'.$confhash{$itemid}{'title'}.'</b>'; |
|
if ($confhash{$itemid}{'image'}) { |
|
$resulttext .= ' '. |
|
'<img src="'.$confhash{$itemid}{'image'}.'"'. |
|
' alt="'.&mt('Tool Provider icon').'" />'; |
|
} |
|
$resulttext .= '</li><ul>'; |
|
my $position = $pos + 1; |
|
$resulttext .= '<li>'.&mt('Order: [_1]',$position).'</li>'; |
|
foreach my $item ('version','msgtype','url','key') { |
|
if ($confhash{$itemid}{$item} ne '') { |
|
$resulttext .= '<li>'.$lt{$item}.': '.$confhash{$itemid}{$item}.'</li>'; |
|
} |
|
} |
|
if ($confhash{$itemid}{'secret'} ne '') { |
|
$resulttext .= '<li>'.$lt{'secret'}.': '; |
|
my $num = length($confhash{$itemid}{'secret'}); |
|
$resulttext .= ('*'x$num).'</li>'; |
|
} |
|
foreach my $item ('passback','roster') { |
|
$resulttext .= '<li>'.$lt{$item}.' '; |
|
if ($confhash{$itemid}{$item}) { |
|
$resulttext .= &mt('Yes'); |
|
} else { |
|
$resulttext .= &mt('No'); |
|
} |
|
$resulttext .= '</li>'; |
|
} |
|
if (ref($confhash{$itemid}{'display'}) eq 'HASH') { |
|
my $displaylist; |
|
if ($confhash{$itemid}{'display'}{'target'}) { |
|
$displaylist = &mt('Display target').': '. |
|
$confhash{$itemid}{'display'}{'target'}.','; |
|
} |
|
foreach my $size ('width','height') { |
|
if ($confhash{$itemid}{'display'}{$size}) { |
|
$displaylist .= (' 'x2).$lt{$size}.': '. |
|
$confhash{$itemid}{'display'}{$size}.','; |
|
} |
|
} |
|
if ($displaylist) { |
|
$displaylist =~ s/,$//; |
|
$resulttext .= '<li>'.$displaylist.'</li>'; |
|
} |
|
} |
|
if (ref($confhash{$itemid}{'fields'}) eq 'HASH') { |
|
my $fieldlist; |
|
foreach my $field (@allfields) { |
|
if ($confhash{$itemid}{'fields'}{$field}) { |
|
$fieldlist .= (' 'x2).$lt{$field}.','; |
|
} |
|
} |
|
if ($fieldlist) { |
|
$fieldlist =~ s/,$//; |
|
$resulttext .= '<li>'.&mt('Data sent').':'.$fieldlist.'</li>'; |
|
} |
|
} |
|
if (ref($confhash{$itemid}{'roles'}) eq 'HASH') { |
|
my $rolemaps; |
|
foreach my $role (@courseroles) { |
|
if ($confhash{$itemid}{'roles'}{$role}) { |
|
$rolemaps .= (' 'x2).&Apache::lonnet::plaintext($role,'Course').'='. |
|
$confhash{$itemid}{'roles'}{$role}.','; |
|
} |
|
} |
|
if ($rolemaps) { |
|
$rolemaps =~ s/,$//; |
|
$resulttext .= '<li>'.&mt('Role mapping:').$rolemaps.'</li>'; |
|
} |
|
} |
|
if (ref($confhash{$itemid}{'custom'}) eq 'HASH') { |
|
my $customlist; |
|
if (keys(%{$confhash{$itemid}{'custom'}})) { |
|
foreach my $key (sort(keys(%{$confhash{$itemid}{'custom'}}))) { |
|
$customlist .= $key.':'.$confhash{$itemid}{'custom'}{$key}.(' 'x2); |
|
} |
|
} |
|
if ($customlist) { |
|
$resulttext .= '<li>'.&mt('Custom items').':'.$customlist.'</li>'; |
|
} |
|
} |
|
$resulttext .= '</ul></li>'; |
|
} |
|
} |
|
$resulttext .= '</ul>'; |
|
} else { |
|
$resulttext = &mt('No changes made.'); |
|
} |
|
} else { |
|
$errors .= '<li><span class="LC_error">'.&mt('Failed to save changes').'</span></li>'; |
|
} |
|
if ($errors) { |
|
$resulttext .= &mt('The following errors occurred: ').'<ul>'. |
|
$errors.'</ul>'; |
|
} |
|
return $resulttext; |
|
} |
|
|
|
sub process_ltitools_image { |
|
my ($r,$dom,$confname,$caller,$itemid,$configuserok,$switchserver,$author_ok) = @_; |
|
my $filename = $env{'form.'.$caller.'.filename'}; |
|
my ($error,$url); |
|
my ($width,$height) = (21,21); |
|
if ($configuserok eq 'ok') { |
|
if ($switchserver) { |
|
$error = &mt('Upload of Tool Provider (LTI) icon is not permitted to this server: [_1]', |
|
$switchserver); |
|
} elsif ($author_ok eq 'ok') { |
|
my ($result,$imageurl,$madethumb) = |
|
&publishlogo($r,'upload',$caller,$dom,$confname, |
|
"ltitools/$itemid/icon",$width,$height); |
|
if ($result eq 'ok') { |
|
if ($madethumb) { |
|
my ($path,$imagefile) = ($imageurl =~ m{^(.+)/([^/]+)$}); |
|
my $imagethumb = "$path/tn-".$imagefile; |
|
$url = $imagethumb; |
|
} else { |
|
$url = $imageurl; |
|
} |
|
} else { |
|
$error = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$filename,$result); |
|
} |
|
} else { |
|
$error = &mt("Upload of [_1] failed because an author role could not be assigned to a Domain Configuration user ([_2]) in domain: [_3]. Error was: [_4].",$filename,$confname,$dom,$author_ok); |
|
} |
|
} else { |
|
$error = &mt("Upload of [_1] failed because a Domain Configuration user ([_2]) could not be created in domain: [_3]. Error was: [_4].",$filename,$confname,$dom,$configuserok); |
|
} |
|
return ($url,$error); |
|
} |
|
|
|
sub get_ltitools_id { |
|
my ($cdom,$title) = @_; |
|
# get lock on ltitools db |
|
my $lockhash = { |
|
lock => $env{'user.name'}. |
|
':'.$env{'user.domain'}, |
|
}; |
|
my $tries = 0; |
|
my $gotlock = &Apache::lonnet::newput_dom('ltitools',$lockhash,$cdom); |
|
my ($id,$error); |
|
|
|
while (($gotlock ne 'ok') && ($tries<10)) { |
|
$tries ++; |
|
sleep (0.1); |
|
$gotlock = &Apache::lonnet::newput_dom('ltitools',$lockhash,$cdom); |
|
} |
|
if ($gotlock eq 'ok') { |
|
my %currids = &Apache::lonnet::dump_dom('ltitools',$cdom); |
|
if ($currids{'lock'}) { |
|
delete($currids{'lock'}); |
|
if (keys(%currids)) { |
|
my @curr = sort { $a <=> $b } keys(%currids); |
|
if ($curr[-1] =~ /^\d+$/) { |
|
$id = 1 + $curr[-1]; |
|
} |
|
} else { |
|
$id = 1; |
|
} |
|
if ($id) { |
|
unless (&Apache::lonnet::newput_dom('ltitools',{ $id => $title },$cdom) eq 'ok') { |
|
$error = 'nostore'; |
|
} |
|
} else { |
|
$error = 'nonumber'; |
|
} |
|
} |
|
my $dellockoutcome = &Apache::lonnet::del_dom('ltitools',['lock'],$cdom); |
|
} else { |
|
$error = 'nolock'; |
|
} |
|
return ($id,$error); |
|
} |
|
|
sub modify_autoenroll { |
sub modify_autoenroll { |
my ($dom,$lastactref,%domconfig) = @_; |
my ($dom,$lastactref,%domconfig) = @_; |
my ($resulttext,%changes); |
my ($resulttext,%changes); |
Line 7934 sub modify_autoenroll {
|
Line 8811 sub modify_autoenroll {
|
my $autorun = &Apache::lonnet::auto_run(undef,$dom), |
my $autorun = &Apache::lonnet::auto_run(undef,$dom), |
my %title = ( run => 'Auto-enrollment active', |
my %title = ( run => 'Auto-enrollment active', |
sender => 'Sender for notification messages', |
sender => 'Sender for notification messages', |
coowners => 'Automatic assignment of co-ownership to instructors of record (institutional data)', |
coowners => 'Automatic assignment of co-ownership to instructors of record (institutional data)'); |
failsafe => 'Failsafe for no drops if institutional data missing for a section'); |
|
my @offon = ('off','on'); |
my @offon = ('off','on'); |
my $sender_uname = $env{'form.sender_uname'}; |
my $sender_uname = $env{'form.sender_uname'}; |
my $sender_domain = $env{'form.sender_domain'}; |
my $sender_domain = $env{'form.sender_domain'}; |
Line 7945 sub modify_autoenroll {
|
Line 8821 sub modify_autoenroll {
|
$sender_domain = ''; |
$sender_domain = ''; |
} |
} |
my $coowners = $env{'form.autoassign_coowners'}; |
my $coowners = $env{'form.autoassign_coowners'}; |
my $failsafe = $env{'form.autoenroll_failsafe'}; |
|
$failsafe =~ s{^\s+|\s+$}{}g; |
|
if ($failsafe =~ /\D/) { |
|
undef($failsafe); |
|
} |
|
my %autoenrollhash = ( |
my %autoenrollhash = ( |
autoenroll => { 'run' => $env{'form.autoenroll_run'}, |
autoenroll => { 'run' => $env{'form.autoenroll_run'}, |
'sender_uname' => $sender_uname, |
'sender_uname' => $sender_uname, |
'sender_domain' => $sender_domain, |
'sender_domain' => $sender_domain, |
'co-owners' => $coowners, |
'co-owners' => $coowners, |
'autofailsafe' => $failsafe, |
|
} |
} |
); |
); |
my $putresult = &Apache::lonnet::put_dom('configuration',\%autoenrollhash, |
my $putresult = &Apache::lonnet::put_dom('configuration',\%autoenrollhash, |
Line 7982 sub modify_autoenroll {
|
Line 8852 sub modify_autoenroll {
|
} |
} |
} elsif ($coowners) { |
} elsif ($coowners) { |
$changes{'coowners'} = 1; |
$changes{'coowners'} = 1; |
} |
} |
if ($currautoenroll{'autofailsafe'} ne $failsafe) { |
|
$changes{'autofailsafe'} = 1; |
|
} |
|
if (keys(%changes) > 0) { |
if (keys(%changes) > 0) { |
$resulttext = &mt('Changes made:').'<ul>'; |
$resulttext = &mt('Changes made:').'<ul>'; |
if ($changes{'run'}) { |
if ($changes{'run'}) { |
Line 8005 sub modify_autoenroll {
|
Line 8872 sub modify_autoenroll {
|
$lastactref->{'domainconfig'} = 1; |
$lastactref->{'domainconfig'} = 1; |
} |
} |
} |
} |
if ($changes{'autofailsafe'}) { |
|
if ($failsafe ne '') { |
|
$resulttext .= '<li>'.&mt("$title{'failsafe'} set to [_1]",$failsafe).'</li>'; |
|
} else { |
|
$resulttext .= '<li>'.&mt("$title{'failsafe'} deleted"); |
|
} |
|
&Apache::lonnet::get_domain_defaults($dom,1); |
|
if (ref($lastactref) eq 'HASH') { |
|
$lastactref->{'domdefaults'} = 1; |
|
} |
|
} |
|
$resulttext .= '</ul>'; |
$resulttext .= '</ul>'; |
} else { |
} else { |
$resulttext = &mt('No changes made to auto-enrollment settings'); |
$resulttext = &mt('No changes made to auto-enrollment settings'); |
Line 10420 sub modify_coursedefaults {
|
Line 11276 sub modify_coursedefaults {
|
my ($dom,$lastactref,%domconfig) = @_; |
my ($dom,$lastactref,%domconfig) = @_; |
my ($resulttext,$errors,%changes,%defaultshash); |
my ($resulttext,$errors,%changes,%defaultshash); |
my %defaultchecked = ( |
my %defaultchecked = ( |
|
'canuse_pdfforms' => 'off', |
'uselcmath' => 'on', |
'uselcmath' => 'on', |
'usejsme' => 'on' |
'usejsme' => 'on' |
); |
); |
my @toggles = ('uselcmath','usejsme'); |
my @toggles = ('canuse_pdfforms','uselcmath','usejsme'); |
my @numbers = ('anonsurvey_threshold','uploadquota_official','uploadquota_unofficial', |
my @numbers = ('anonsurvey_threshold','uploadquota_official','uploadquota_unofficial', |
'uploadquota_community','uploadquota_textbook','mysqltables_official', |
'uploadquota_community','uploadquota_textbook'); |
'mysqltables_unofficial','mysqltables_community','mysqltables_textbook'); |
|
my @types = ('official','unofficial','community','textbook'); |
my @types = ('official','unofficial','community','textbook'); |
my %staticdefaults = ( |
my %staticdefaults = ( |
anonsurvey_threshold => 10, |
anonsurvey_threshold => 10, |
uploadquota => 500, |
uploadquota => 500, |
postsubmit => 60, |
postsubmit => 60, |
mysqltables => 172800, |
|
); |
); |
|
|
$defaultshash{'coursedefaults'} = {}; |
$defaultshash{'coursedefaults'} = {}; |
Line 10473 sub modify_coursedefaults {
|
Line 11328 sub modify_coursedefaults {
|
} |
} |
$defaultshash{'coursedefaults'}{$item} = $newdef; |
$defaultshash{'coursedefaults'}{$item} = $newdef; |
} else { |
} else { |
my ($setting,$type) = ($item =~ /^(uploadquota|mysqltables)_(\w+)$/); |
my ($type) = ($item =~ /^\Quploadquota_\E(\w+)$/); |
if (ref($domconfig{'coursedefaults'}{$setting}) eq 'HASH') { |
if (ref($domconfig{'coursedefaults'}{'uploadquota'}) eq 'HASH') { |
$currdef = $domconfig{'coursedefaults'}{$setting}{$type}; |
$currdef = $domconfig{'coursedefaults'}{'uploadquota'}{$type}; |
} |
} |
$newdef =~ s/[^\w.\-]//g; |
$newdef =~ s/[^\w.\-]//g; |
$defaultshash{'coursedefaults'}{$setting}{$type} = $newdef; |
$defaultshash{'coursedefaults'}{'uploadquota'}{$type} = $newdef; |
} |
} |
if ($currdef ne $newdef) { |
if ($currdef ne $newdef) { |
my $staticdef; |
my $staticdef; |
Line 10486 sub modify_coursedefaults {
|
Line 11341 sub modify_coursedefaults {
|
unless (($currdef eq '') && ($newdef == $staticdefaults{$item})) { |
unless (($currdef eq '') && ($newdef == $staticdefaults{$item})) { |
$changes{$item} = 1; |
$changes{$item} = 1; |
} |
} |
} elsif ($item =~ /^(uploadquota|mysqltables)_/) { |
} else { |
my $setting = $1; |
unless (($currdef eq '') && ($newdef == $staticdefaults{'uploadquota'})) { |
unless (($currdef eq '') && ($newdef == $staticdefaults{$setting})) { |
$changes{'uploadquota'} = 1; |
$changes{$setting} = 1; |
|
} |
} |
} |
} |
} |
} |
Line 10502 sub modify_coursedefaults {
|
Line 11356 sub modify_coursedefaults {
|
} |
} |
} |
} |
my $newclone; |
my $newclone; |
if ($env{'form.canclone'} =~ /^(none|domain|instcode)$/) { |
if ($env{'form.canclone'} =~ /^(none|domain|instcode)$/) { |
$newclone = $env{'form.canclone'}; |
$newclone = $env{'form.canclone'}; |
} |
} |
if ($newclone eq 'instcode') { |
if ($newclone eq 'instcode') { |
Line 10525 sub modify_coursedefaults {
|
Line 11379 sub modify_coursedefaults {
|
$newclone eq ''; |
$newclone eq ''; |
} |
} |
} elsif ($newclone ne '') { |
} elsif ($newclone ne '') { |
$defaultshash{'coursedefaults'}{'canclone'} = $newclone; |
$defaultshash{'coursedefaults'}{'canclone'} = $newclone; |
} |
} |
if ($newclone ne $currclone) { |
if ($newclone ne $currclone) { |
$changes{'canclone'} = 1; |
$changes{'canclone'} = 1; |
} |
} |
Line 10544 sub modify_coursedefaults {
|
Line 11398 sub modify_coursedefaults {
|
$defaultshash{'coursedefaults'}{'coursecredits'}{$type} = $credits{$type}; |
$defaultshash{'coursedefaults'}{'coursecredits'}{$type} = $credits{$type}; |
} |
} |
} else { |
} else { |
if ($env{'form.coursecredits'} eq '1') { |
if ($env{'form.coursecredits'} eq '1') { |
foreach my $type (@types) { |
foreach my $type (@types) { |
unless ($type eq 'community') { |
unless ($type eq 'community') { |
if ($domconfig{'coursedefaults'}{'coursecredits'}{$type} ne $credits{$type}) { |
if ($domconfig{'coursedefaults'}{'coursecredits'}{$type} ne $credits{$type}) { |
$changes{'coursecredits'} = 1; |
$changes{'coursecredits'} = 1; |
} |
} |
$defaultshash{'coursedefaults'}{'coursecredits'}{$type} = $credits{$type}; |
$defaultshash{'coursedefaults'}{'coursecredits'}{$type} = $credits{$type}; |
Line 10590 sub modify_coursedefaults {
|
Line 11444 sub modify_coursedefaults {
|
} |
} |
if (exists($currtimeout{$type})) { |
if (exists($currtimeout{$type})) { |
if ($timeout ne $currtimeout{$type}) { |
if ($timeout ne $currtimeout{$type}) { |
$changes{'postsubmit'} = 1; |
$changes{'postsubmit'} = 1; |
} |
} |
} elsif ($timeout ne '') { |
} elsif ($timeout ne '') { |
$changes{'postsubmit'} = 1; |
$changes{'postsubmit'} = 1; |
Line 10612 sub modify_coursedefaults {
|
Line 11466 sub modify_coursedefaults {
|
if ($putresult eq 'ok') { |
if ($putresult eq 'ok') { |
if (keys(%changes) > 0) { |
if (keys(%changes) > 0) { |
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1); |
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1); |
if (($changes{'uploadquota'}) || ($changes{'postsubmit'}) || |
if (($changes{'canuse_pdfforms'}) || ($changes{'uploadquota'}) || ($changes{'postsubmit'}) || |
($changes{'coursecredits'}) || ($changes{'uselcmath'}) || ($changes{'usejsme'}) || |
($changes{'coursecredits'}) || ($changes{'uselcmath'}) || ($changes{'usejsme'}) || |
($changes{'canclone'}) || ($changes{'mysqltables'})) { |
($changes{'canclone'})) { |
foreach my $item ('uselcmath','usejsme') { |
foreach my $item ('canuse_pdfforms','uselcmath','usejsme') { |
if ($changes{$item}) { |
if ($changes{$item}) { |
$domdefaults{$item}=$defaultshash{'coursedefaults'}{$item}; |
$domdefaults{$item}=$defaultshash{'coursedefaults'}{$item}; |
} |
} |
} |
} |
if ($changes{'coursecredits'}) { |
if ($changes{'coursecredits'}) { |
if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') { |
if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') { |
foreach my $type (keys(%{$defaultshash{'coursedefaults'}{'coursecredits'}})) { |
foreach my $type (keys(%{$defaultshash{'coursedefaults'}{'coursecredits'}})) { |
Line 10666 sub modify_coursedefaults {
|
Line 11520 sub modify_coursedefaults {
|
} |
} |
$resulttext = &mt('Changes made:').'<ul>'; |
$resulttext = &mt('Changes made:').'<ul>'; |
foreach my $item (sort(keys(%changes))) { |
foreach my $item (sort(keys(%changes))) { |
if ($item eq 'uselcmath') { |
if ($item eq 'canuse_pdfforms') { |
|
if ($env{'form.'.$item} eq '1') { |
|
$resulttext .= '<li>'.&mt("Course/Community users can create/upload PDF forms set to 'on'").'</li>'; |
|
} else { |
|
$resulttext .= '<li>'.&mt('Course/Community users can create/upload PDF forms set to "off"').'</li>'; |
|
} |
|
} elsif ($item eq 'uselcmath') { |
if ($env{'form.'.$item} eq '1') { |
if ($env{'form.'.$item} eq '1') { |
$resulttext .= '<li>'.&mt('Math preview uses LON-CAPA previewer (javascript), if supported by browser.').'</li>'; |
$resulttext .= '<li>'.&mt('Math preview uses LON-CAPA previewer (javascript), if supported by browser.').'</li>'; |
} else { |
} else { |
Line 10676 sub modify_coursedefaults {
|
Line 11536 sub modify_coursedefaults {
|
if ($env{'form.'.$item} eq '1') { |
if ($env{'form.'.$item} eq '1') { |
$resulttext .= '<li>'.&mt('Molecule editor uses JSME (HTML5), if supported by browser.').'</li>'; |
$resulttext .= '<li>'.&mt('Molecule editor uses JSME (HTML5), if supported by browser.').'</li>'; |
} else { |
} else { |
$resulttext .= '<li>'.&mt('Molecule editor uses JME (Java), if supported by client OS.').'</li>'; |
$resulttext .= '<li>'.&mt('Molecule editor uses JME (Java), if supported by client OS.').'</li>'; |
} |
} |
} elsif ($item eq 'anonsurvey_threshold') { |
} elsif ($item eq 'anonsurvey_threshold') { |
$resulttext .= '<li>'.&mt('Responder count required for display of anonymous survey submissions set to [_1].',$defaultshash{'coursedefaults'}{'anonsurvey_threshold'}).'</li>'; |
$resulttext .= '<li>'.&mt('Responder count required for display of anonymous survey submissions set to [_1].',$defaultshash{'coursedefaults'}{'anonsurvey_threshold'}).'</li>'; |
Line 10693 sub modify_coursedefaults {
|
Line 11553 sub modify_coursedefaults {
|
} else { |
} else { |
$resulttext .= '<li>'.&mt('Default quota for content uploaded via Course Editor remains default: [_1] MB',$staticdefaults{'uploadquota'}).'</li>'; |
$resulttext .= '<li>'.&mt('Default quota for content uploaded via Course Editor remains default: [_1] MB',$staticdefaults{'uploadquota'}).'</li>'; |
} |
} |
} elsif ($item eq 'mysqltables') { |
|
if (ref($defaultshash{'coursedefaults'}{'mysqltables'}) eq 'HASH') { |
|
$resulttext .= '<li>'.&mt('Lifetime of "Temporary" MySQL tables (student performance data) on homeserver').'<ul>'. |
|
'<li>'.&mt('Official courses: [_1] s','<b>'.$defaultshash{'coursedefaults'}{'mysqltables'}{'official'}.'</b>').'</li>'. |
|
'<li>'.&mt('Unofficial courses: [_1] s','<b>'.$defaultshash{'coursedefaults'}{'mysqltables'}{'unofficial'}.'</b>').'</li>'. |
|
'<li>'.&mt('Textbook courses: [_1] s','<b>'.$defaultshash{'coursedefaults'}{'mysqltables'}{'textbook'}.'</b>').'</li>'. |
|
'<li>'.&mt('Communities: [_1] s','<b>'.$defaultshash{'coursedefaults'}{'mysqltables'}{'community'}.'</b>').'</li>'. |
|
'</ul>'. |
|
'</li>'; |
|
} else { |
|
$resulttext .= '<li>'.&mt('Lifetime of "Temporary" MySQL tables (student performance data) on homeserver remains default: [_1] s',$staticdefaults{'uploadquota'}).'</li>'; |
|
} |
|
} elsif ($item eq 'postsubmit') { |
} elsif ($item eq 'postsubmit') { |
if ($domdefaults{'postsubmit'} eq 'off') { |
if ($domdefaults{'postsubmit'} eq 'off') { |
$resulttext .= '<li>'.&mt('Submit button(s) remain enabled on page after student makes submission.'); |
$resulttext .= '<li>'.&mt('Submit button(s) remain enabled on page after student makes submission.'); |
} else { |
} else { |
$resulttext .= '<li>'.&mt('Submit button(s) disabled on page after student makes submission').'; '; |
$resulttext .= '<li>'.&mt('Submit button(s) disabled on page after student makes submission').'; '; |
if (ref($defaultshash{'coursedefaults'}{'postsubmit'}) eq 'HASH') { |
if (ref($defaultshash{'coursedefaults'}{'postsubmit'}) eq 'HASH') { |
$resulttext .= &mt('durations:').'<ul>'; |
$resulttext .= &mt('durations:').'<ul>'; |
foreach my $type (@types) { |
foreach my $type (@types) { |
$resulttext .= '<li>'; |
$resulttext .= '<li>'; |
Line 10739 sub modify_coursedefaults {
|
Line 11587 sub modify_coursedefaults {
|
} |
} |
$resulttext .= '</ul>'; |
$resulttext .= '</ul>'; |
} |
} |
$resulttext .= '</li>'; |
$resulttext .= '</li>'; |
} |
} |
} elsif ($item eq 'coursecredits') { |
} elsif ($item eq 'coursecredits') { |
if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') { |
if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') { |
Line 10767 sub modify_coursedefaults {
|
Line 11615 sub modify_coursedefaults {
|
} elsif ($defaultshash{'coursedefaults'}{'canclone'} eq 'domain') { |
} elsif ($defaultshash{'coursedefaults'}{'canclone'} eq 'domain') { |
$resulttext .= '<li>'.&mt('By default, a course requester can clone any course from his/her domain.').'</li>'; |
$resulttext .= '<li>'.&mt('By default, a course requester can clone any course from his/her domain.').'</li>'; |
} else { |
} else { |
$resulttext .= '<li>'.&mt('By default, only course owner and coordinators may clone a course.').'</li>'; |
$resulttext .= '<li>'.&mt('By default, only course owner and coordinators may clone a course.').'</li>'; |
} |
} |
} |
} |
} |
} |
Line 11222 sub modify_usersessions {
|
Line 12070 sub modify_usersessions {
|
} |
} |
} |
} |
unless ($changes{'offloadnow'}) { |
unless ($changes{'offloadnow'}) { |
foreach my $lonhost (keys(%{$defaultshash{'usersessions'}{'offloadnow'}})) { |
foreach my $lonhost (keys(%{$defaultshash{'usersessions'}{'offloadnow'}})) { |
unless ($domconfig{'usersessions'}{'offloadnow'}{$lonhost}) { |
unless ($domconfig{'usersessions'}{'offloadnow'}{$lonhost}) { |
$changes{'offloadnow'} = 1; |
$changes{'offloadnow'} = 1; |
last; |
last; |
Line 11447 sub modify_loadbalancing {
|
Line 12295 sub modify_loadbalancing {
|
} |
} |
if ($rule eq 'specific') { |
if ($rule eq 'specific') { |
my $specifiedhost = $env{'form.loadbalancing_singleserver_'.$i.'_'.$type}; |
my $specifiedhost = $env{'form.loadbalancing_singleserver_'.$i.'_'.$type}; |
if (exists($servers{$specifiedhost})) { |
if (exists($servers{$specifiedhost})) { |
$rule = $specifiedhost; |
$rule = $specifiedhost; |
} |
} |
} |
} |
Line 11523 sub modify_loadbalancing {
|
Line 12371 sub modify_loadbalancing {
|
if ($rule eq '') { |
if ($rule eq '') { |
$balancetext = $ruletitles{'default'}; |
$balancetext = $ruletitles{'default'}; |
} elsif (($rule eq 'homeserver') || ($rule eq 'externalbalancer') || |
} elsif (($rule eq 'homeserver') || ($rule eq 'externalbalancer') || |
($type eq '_LC_ipchange') || ($type eq '_LC_ipchangesso')) { |
($type eq '_LC_ipchange') || ($type eq '_LC_ipchangesso')) { |
if (($type eq '_LC_ipchange') || ($type eq '_LC_ipchangesso')) { |
if (($type eq '_LC_ipchange') || ($type eq '_LC_ipchangesso')) { |
foreach my $sparetype (@sparestypes) { |
foreach my $sparetype (@sparestypes) { |
if (ref($defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype}) eq 'ARRAY') { |
if (ref($defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype}) eq 'ARRAY') { |
Line 12265 function updateCaptcha(caller,context) {
|
Line 13113 function updateCaptcha(caller,context) {
|
privtext.innerHTML = "$lt{'priv'}"; |
privtext.innerHTML = "$lt{'priv'}"; |
versionitem.type = 'text'; |
versionitem.type = 'text'; |
versionitem.size = '3'; |
versionitem.size = '3'; |
versiontext.innerHTML = "$lt{'ver'}"; |
versiontext.innerHTML = "$lt{'ver'}"; |
} else { |
} else { |
pubitem.type = 'hidden'; |
pubitem.type = 'hidden'; |
privitem.type = 'hidden'; |
privitem.type = 'hidden'; |
Line 12338 sub captcha_phrases {
|
Line 13186 sub captcha_phrases {
|
original => 'original (CAPTCHA)', |
original => 'original (CAPTCHA)', |
recaptcha => 'successor (ReCAPTCHA)', |
recaptcha => 'successor (ReCAPTCHA)', |
notused => 'unused', |
notused => 'unused', |
ver => 'ReCAPTCHA version (1 or 2)', |
ver => 'ReCAPTCHA version (1 or 2)', |
); |
); |
} |
} |
|
|
Line 12348 sub devalidate_remote_domconfs {
|
Line 13196 sub devalidate_remote_domconfs {
|
my %servers = &Apache::lonnet::internet_dom_servers($dom); |
my %servers = &Apache::lonnet::internet_dom_servers($dom); |
my %thismachine; |
my %thismachine; |
map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids(); |
map { $thismachine{$_} = 1; } &Apache::lonnet::current_machine_ids(); |
my @posscached = ('domainconfig','domdefaults'); |
my @posscached = ('domainconfig','domdefaults','ltitools'); |
if (keys(%servers)) { |
if (keys(%servers)) { |
foreach my $server (keys(%servers)) { |
foreach my $server (keys(%servers)) { |
next if ($thismachine{$server}); |
next if ($thismachine{$server}); |