version 1.318, 2017/11/30 01:52:14
|
version 1.319, 2017/11/30 02:17:50
|
Line 2586 ENDSCRIPT
|
Line 2586 ENDSCRIPT
|
|
|
sub ltitools_javascript { |
sub ltitools_javascript { |
my ($settings) = @_; |
my ($settings) = @_; |
return unless(ref($settings) eq 'HASH'); |
my $togglejs = <itools_toggle_js(); |
|
unless (ref($settings) eq 'HASH') { |
|
return $togglejs; |
|
} |
my (%ordered,$total,%jstext); |
my (%ordered,$total,%jstext); |
$total = 0; |
$total = 0; |
foreach my $item (keys(%{$settings})) { |
foreach my $item (keys(%{$settings})) { |
Line 2604 sub ltitools_javascript {
|
Line 2607 sub ltitools_javascript {
|
return <<"ENDSCRIPT"; |
return <<"ENDSCRIPT"; |
<script type="text/javascript"> |
<script type="text/javascript"> |
// <![CDATA[ |
// <![CDATA[ |
function reorderLTI(form,item) { |
function reorderLTITools(form,item) { |
var changedVal; |
var changedVal; |
$jstext |
$jstext |
var newpos = 'ltitools_add_pos'; |
var newpos = 'ltitools_add_pos'; |
Line 2649 $jstext
|
Line 2652 $jstext
|
// ]]> |
// ]]> |
</script> |
</script> |
|
|
|
$togglejs |
|
|
|
ENDSCRIPT |
|
} |
|
|
|
sub ltitools_toggle_js { |
|
return <<"ENDSCRIPT"; |
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
|
|
function toggleLTITools(form,setting,item) { |
|
var radioname = ''; |
|
var divid = ''; |
|
if ((setting == 'passback') || (setting == 'roster')) { |
|
radioname = 'ltitools_'+setting+'_'+item; |
|
divid = 'ltitools_'+setting+'time_'+item; |
|
var num = form.elements[radioname].length; |
|
if (num) { |
|
var setvis = ''; |
|
for (var i=0; i<num; i++) { |
|
if (form.elements[radioname][i].checked) { |
|
if (form.elements[radioname][i].value == '1') { |
|
if (document.getElementById(divid)) { |
|
document.getElementById(divid).style.display = 'inline-block'; |
|
} |
|
setvis = 1; |
|
} |
|
break; |
|
} |
|
} |
|
} |
|
if (!setvis) { |
|
if (document.getElementById(divid)) { |
|
document.getElementById(divid).style.display = 'none'; |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
// ]]> |
|
</script> |
|
|
ENDSCRIPT |
ENDSCRIPT |
} |
} |
|
|
Line 3896 sub print_ltitools {
|
Line 3941 sub print_ltitools {
|
$imgsrc = '<img src="'.$image.'" alt="'.&mt('Tool Provider icon').'" />'; |
$imgsrc = '<img src="'.$image.'" alt="'.&mt('Tool Provider icon').'" />'; |
} |
} |
} |
} |
my $chgstr = ' onchange="javascript:reorderLTI(this.form,'."'ltitools_".$item."'".');"'; |
my $chgstr = ' onchange="javascript:reorderLTITools(this.form,'."'ltitools_".$item."'".');"'; |
$datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">' |
$datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">' |
.'<select name="ltitools_'.$item.'"'.$chgstr.'>'; |
.'<select name="ltitools_'.$item.'"'.$chgstr.'>'; |
for (my $k=0; $k<=$maxnum; $k++) { |
for (my $k=0; $k<=$maxnum; $k++) { |
Line 3923 sub print_ltitools {
|
Line 3968 sub print_ltitools {
|
'<span class="LC_nobreak">'.$lt{'url'}.':<input type="text" size="30" name="ltitools_url_'.$i.'"'. |
'<span class="LC_nobreak">'.$lt{'url'}.':<input type="text" size="30" name="ltitools_url_'.$i.'"'. |
' value="'.$url.'" /></span>'. |
' value="'.$url.'" /></span>'. |
(' 'x2). |
(' 'x2). |
'<span class="LC_nobreak">'.$lt{'key'}. |
'<span class="LC_nobreak">'.$lt{'key'}.':'. |
'<input type="text" size="25" name="ltitools_key_'.$i.'" value="'.$key.'" /></span> '. |
'<input type="text" size="25" name="ltitools_key_'.$i.'" value="'.$key.'" /></span> '. |
(' 'x2). |
(' 'x2). |
'<span class="LC_nobreak">'.$lt{'secret'}.':'. |
'<span class="LC_nobreak">'.$lt{'secret'}.':'. |
Line 3969 sub print_ltitools {
|
Line 4014 sub print_ltitools {
|
'<div class="LC_left_float">'.$lt{'explanation'}.'<br />'. |
'<div class="LC_left_float">'.$lt{'explanation'}.'<br />'. |
'<textarea name="ltitools_explanation_'.$i.'" rows="5" cols="40">'.$currdisp{'explanation'}. |
'<textarea name="ltitools_explanation_'.$i.'" rows="5" cols="40">'.$currdisp{'explanation'}. |
'</textarea></div><div style=""></div><br />'; |
'</textarea></div><div style=""></div><br />'; |
$datatable .= '<br />'; |
my %units = ( |
|
'passback' => 'days', |
|
'roster' => 'seconds', |
|
); |
foreach my $extra ('passback','roster') { |
foreach my $extra ('passback','roster') { |
|
my $validsty = 'none'; |
|
my $currvalid; |
my $checkedon = ''; |
my $checkedon = ''; |
my $checkedoff = ' checked="checked"'; |
my $checkedoff = ' checked="checked"'; |
if ($settings->{$item}->{$extra}) { |
if ($settings->{$item}->{$extra}) { |
$checkedon = $checkedoff; |
$checkedon = $checkedoff; |
$checkedoff = ''; |
$checkedoff = ''; |
} |
$validsty = 'inline-block'; |
$datatable .= $lt{$extra}.' '. |
if ($settings->{$item}->{$extra.'valid'} =~ /^\d+\.?\d*$/) { |
'<label><input type="radio" name="ltitools_'.$extra.'_'.$i.'" value="1"'.$checkedon.' />'. |
$currvalid = $settings->{$item}->{$extra.'valid'}; |
&mt('Yes').'</label>'.(' 'x2). |
} |
'<label><input type="radio" name="ltitools_'.$extra.'_'.$i.'" value="0"'.$checkedoff.' />'. |
} |
&mt('No').'</label>'.(' 'x4); |
my $onclick = ' onclick="toggleLTITools(this.form,'."'$extra','$i'".');"'; |
|
$datatable .= '<div class="LC_floatleft"><span class="LC_nobreak">'.$lt{$extra}.' '. |
|
'<label><input type="radio" name="ltitools_'.$extra.'_'.$i.'" value="0"'.$checkedoff.$onclick.' />'. |
|
&mt('No').'</label>'.(' 'x2). |
|
'<label><input type="radio" name="ltitools_'.$extra.'_'.$i.'" value="1"'.$checkedon.$onclick.' />'. |
|
&mt('Yes').'</label></span></div>'. |
|
'<div class="LC_floatleft" style="display:'.$validsty.';" id="ltitools_'.$extra.'time_'.$i.'">'. |
|
'<span class="LC_nobreak">'. |
|
&mt("at least [_1] $units{$extra} after launch", |
|
'<input type="text" name="ltitools_'.$extra.'valid_'.$i.'" value="'.$currvalid.'" />'). |
|
'</span></div><div style="padding:0;clear:both;margin:0;border:0"></div>'; |
} |
} |
$datatable .= '<br /><br /><span class="LC_nobreak">'.$lt{'icon'}.': '; |
$datatable .= '<span class="LC_nobreak">'.$lt{'icon'}.': '; |
if ($imgsrc) { |
if ($imgsrc) { |
$datatable .= $imgsrc. |
$datatable .= $imgsrc. |
'<label><input type="checkbox" name="ltitools_image_del"'. |
'<label><input type="checkbox" name="ltitools_image_del"'. |
Line 4083 sub print_ltitools {
|
Line 4143 sub print_ltitools {
|
} |
} |
} |
} |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
my $chgstr = ' onchange="javascript:reorderLTI(this.form,'."'ltitools_add_pos'".');"'; |
my $chgstr = ' onchange="javascript:reorderLTITools(this.form,'."'ltitools_add_pos'".');"'; |
$datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'."\n". |
$datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'."\n". |
'<input type="hidden" name="ltitools_maxnum" value="'.$maxnum.'" />'."\n". |
'<input type="hidden" name="ltitools_maxnum" value="'.$maxnum.'" />'."\n". |
'<select name="ltitools_add_pos"'.$chgstr.'>'; |
'<select name="ltitools_add_pos"'.$chgstr.'>'; |
Line 4134 sub print_ltitools {
|
Line 4194 sub print_ltitools {
|
'<div class="LC_left_float">'.$lt{'explanation'}.'<br />'. |
'<div class="LC_left_float">'.$lt{'explanation'}.'<br />'. |
'<textarea name=ltitools_add_explanation" rows="5" cols="40"></textarea>'. |
'<textarea name=ltitools_add_explanation" rows="5" cols="40"></textarea>'. |
'</div><div style=""></div><br />'; |
'</div><div style=""></div><br />'; |
|
my %units = ( |
|
'passback' => 'days', |
|
'roster' => 'seconds', |
|
); |
|
my %defaulttimes = ( |
|
'passback' => '7', |
|
'roster' => '300', |
|
); |
foreach my $extra ('passback','roster') { |
foreach my $extra ('passback','roster') { |
$datatable .= $lt{$extra}.' '. |
my $onclick = ' onclick="toggleLTITools(this.form,'."'$extra','add'".');"'; |
'<label><input type="radio" name="ltitools_add_'.$extra.'" value="1" />'. |
$datatable .= '<div class="LC_floatleft"><span class="LC_nobreak">'.$lt{$extra}.' '. |
&mt('Yes').'</label>'.(' 'x2). |
'<label><input type="radio" name="ltitools_'.$extra.'_add" value="0" checked="checked"'.$onclick.' />'. |
'<label><input type="radio" name="ltitools_add_'.$extra.'" value="0" checked="checked" />'. |
&mt('No').'</label></span>'.(' 'x2).'<span class="LC_nobreak">'. |
&mt('No').'</label>'.(' 'x4); |
'<label><input type="radio" name="ltitools_'.$extra.'_add" value="1"'.$onclick.' />'. |
|
&mt('Yes').'</label></span></div>'. |
|
'<div class="LC_floatleft" style="display:none;" id="ltitools_'.$extra.'time_add">'. |
|
'<span class="LC_nobreak">'. |
|
&mt("at least [_1] $units{$extra} after launch", |
|
'<input type="text" name="ltitools_'.$extra.'valid_add" value="'.$defaulttimes{$extra}.'" />'). |
|
'</span></div><div style="padding:0;clear:both;margin:0;border:0"></div>'; |
} |
} |
$datatable .= '<br /><br /><span class="LC_nobreak">'.$lt{'icon'}.': '. |
$datatable .= '<span class="LC_nobreak">'.$lt{'icon'}.': '. |
'('.&mt('if larger than 21x21 pixels, image will be scaled').') '; |
'('.&mt('if larger than 21x21 pixels, image will be scaled').') '; |
if ($switchserver) { |
if ($switchserver) { |
$datatable .= &mt('Upload to library server: [_1]',$switchserver); |
$datatable .= &mt('Upload to library server: [_1]',$switchserver); |
Line 10104 sub modify_ltitools {
|
Line 10178 sub modify_ltitools {
|
$confhash{$newid}{'display'}{'target'} = 'iframe'; |
$confhash{$newid}{'display'}{'target'} = 'iframe'; |
} |
} |
foreach my $item ('passback','roster') { |
foreach my $item ('passback','roster') { |
if ($env{'form.ltitools_add_'.$item}) { |
if ($env{'form.ltitools_'.$item.'_add'}) { |
$confhash{$newid}{$item} = 1; |
$confhash{$newid}{$item} = 1; |
|
if ($env{'form.ltitools_'.$item.'valid_add'} ne '') { |
|
my $lifetime = $env{'form.ltitools_'.$item.'valid_add'}; |
|
$lifetime =~ s/^\s+|\s+$//g; |
|
if ($lifetime =~ /^\d+\.?\d*$/) { |
|
$confhash{$newid}{$item.'valid'} = $lifetime; |
|
} |
|
} |
} |
} |
} |
} |
if ($env{'form.ltitools_add_image.filename'} ne '') { |
if ($env{'form.ltitools_add_image.filename'} ne '') { |
Line 10255 sub modify_ltitools {
|
Line 10336 sub modify_ltitools {
|
foreach my $extra ('passback','roster') { |
foreach my $extra ('passback','roster') { |
if ($env{'form.ltitools_'.$extra.'_'.$i}) { |
if ($env{'form.ltitools_'.$extra.'_'.$i}) { |
$confhash{$itemid}{$extra} = 1; |
$confhash{$itemid}{$extra} = 1; |
|
if ($env{'form.ltitools_'.$extra.'valid_'.$i} ne '') { |
|
my $lifetime = $env{'form.ltitools_'.$extra.'valid_add'}; |
|
$lifetime =~ s/^\s+|\s+$//g; |
|
if ($lifetime =~ /^\d+\.?\d*$/) { |
|
$confhash{$itemid}{$extra.'valid'} = $lifetime; |
|
} |
|
} |
} |
} |
if ($domconfig{$action}{$itemid}{$extra} ne $confhash{$itemid}{$extra}) { |
if ($domconfig{$action}{$itemid}{$extra} ne $confhash{$itemid}{$extra}) { |
$changes{$itemid} = 1; |
$changes{$itemid} = 1; |
} |
} |
|
if ($domconfig{$action}{$itemid}{$extra.'valid'} ne $confhash{$itemid}{$extra.'valid'}) { |
|
$changes{$itemid} = 1; |
|
} |
} |
} |
my @courseconfig = &Apache::loncommon::get_env_multiple('form.ltitools_courseconfig_'.$i); |
my @courseconfig = &Apache::loncommon::get_env_multiple('form.ltitools_courseconfig_'.$i); |
foreach my $item ('label','title','target','linktext','explanation','append') { |
foreach my $item ('label','title','target','linktext','explanation','append') { |
Line 10470 sub modify_ltitools {
|
Line 10561 sub modify_ltitools {
|
$resulttext .= '<li>'.$lt{$item}.' '; |
$resulttext .= '<li>'.$lt{$item}.' '; |
if ($confhash{$itemid}{$item}) { |
if ($confhash{$itemid}{$item}) { |
$resulttext .= &mt('Yes'); |
$resulttext .= &mt('Yes'); |
|
if ($confhash{$itemid}{$item.'valid'}) { |
|
if ($item eq 'passback') { |
|
$resulttext .= ' '.&mt('valid for at least [quant,_1,day] after launch', |
|
$confhash{$itemid}{$item.'valid'}); |
|
} else { |
|
$resulttext .= ' '.&mt('valid for at least [quant,_1,second] after launch', |
|
$confhash{$itemid}{$item.'valid'}); |
|
} |
|
} |
} else { |
} else { |
$resulttext .= &mt('No'); |
$resulttext .= &mt('No'); |
} |
} |