version 1.103, 2023/09/05 03:42:31
|
version 1.105, 2024/04/14 17:12:27
|
Line 433 sub print_modification_menu {
|
Line 433 sub print_modification_menu {
|
'setpostsubmit' => 'View/Modify submit button behavior, post-submission', |
'setpostsubmit' => 'View/Modify submit button behavior, post-submission', |
'setltiauth' => 'View/Modify re-authentication requirement for LTI launch of deep-linked item', |
'setltiauth' => 'View/Modify re-authentication requirement for LTI launch of deep-linked item', |
'setexttool' => 'View/Modify External Tools permissions', |
'setexttool' => 'View/Modify External Tools permissions', |
|
'setcrsauthor' => 'View/Modify In-course Authoring permissions', |
|
'setcrseditors' => 'View/Modify permitted course resource editors', |
); |
); |
} else { |
} else { |
%linktext = ( |
%linktext = ( |
Line 442 sub print_modification_menu {
|
Line 444 sub print_modification_menu {
|
'setpostsubmit' => 'View submit button behavior, post-submission', |
'setpostsubmit' => 'View submit button behavior, post-submission', |
'setltiauth' => 'View re-authentication requirement for LTI launch of deep-linked item', |
'setltiauth' => 'View re-authentication requirement for LTI launch of deep-linked item', |
'setexttool' => 'View External Tools permissions', |
'setexttool' => 'View External Tools permissions', |
|
'setcrsauthor' => 'View In-course Authoring permissions', |
|
'setcrseditors' => 'View permitted course resource editors', |
); |
); |
} |
} |
if ($type eq 'Community') { |
if ($type eq 'Community') { |
Line 582 sub print_modification_menu {
|
Line 586 sub print_modification_menu {
|
permission => $permission->{'setexttool'}, |
permission => $permission->{'setexttool'}, |
linktitle => '', |
linktitle => '', |
}, |
}, |
|
{ |
|
linktext => $linktext{'setcrsauthor'}, |
|
icon => 'crsauthor.png', |
|
#help => '', |
|
url => &phaseurl('setcrsauthor'), |
|
permission => $permission->{'setcrsauthor'}, |
|
linktitle => '', |
|
}, |
|
{ |
|
linktext => $linktext{'setcrseditors'}, |
|
icon => 'crseditors.png', |
|
#help => '', |
|
url => &phaseurl('setcrseditors'), |
|
permission => $permission->{'setcrseditors'}, |
|
linktitle => '', |
|
}, |
] |
] |
}, |
}, |
); |
); |
Line 1301 sub print_selfenrollconfig {
|
Line 1321 sub print_selfenrollconfig {
|
return; |
return; |
} |
} |
|
|
sub print_set_ltiauth { |
sub print_default_overrides { |
my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_; |
my ($r,$cdom,$cnum,$cdesc,$type,$readonly,$item) = @_; |
my %lt = &Apache::lonlocal::texthash( |
my (%titles,$checkeddom,$checkedcrs,$divsty,$currcrsval,$crsdefault,%crschecked, |
'requ' => 'Requirement for re-authentication for student LTI-limited launch of deep-linked item', |
$helpfile,$title,$crselements,@currcrseditors); |
'link' => 'Link protection can be set to accept username for an enrolled student (if sent by Consumer)', |
%titles = &default_overrides_titles($type); |
'logi' => 'Login needed, regardless of user information sent by LTI Consumer in (signed) parameters', |
my ($title,$domdefdisplay,$settings,$optiontext,$options) = |
'used' => 'Use domain default', |
&default_overrides_common($item,$cdom,$cnum,$type,\%titles); |
'cour' => 'Use course-specific setting', |
|
'curd' => 'Current domain default is', |
|
'valu' => 'Value for this course', |
|
'modi' => 'Save', |
|
'back' => 'Pick another action', |
|
); |
|
my ($domdef,$checkeddom,$checkedcrs,$domdefdisplay,$divsty,$authok,$authno); |
|
$domdef = 0; |
|
$checkeddom = ' checked="checked"'; |
$checkeddom = ' checked="checked"'; |
$domdefdisplay = $lt{'logi'}; |
|
$divsty = 'display:none'; |
$divsty = 'display:none'; |
$authno = ' checked="checked"'; |
|
my %domconfig = |
if ($item eq 'ltiauth') { |
&Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom); |
$helpfile = 'Modify_Course_LTI_Authen'; |
if (ref($domconfig{'coursedefaults'}) eq 'HASH') { |
$crsdefault = 0; |
$domdef = $domconfig{'coursedefaults'}{'ltiauth'}; |
} else { |
} |
if ($item eq 'exttool') { |
if ($domdef) { |
$helpfile = 'Modify_Course_External_Tool'; |
$domdefdisplay = $lt{'link'}; |
$crsdefault = 'both'; |
|
} elsif ($item eq 'crsauthor') { |
|
$helpfile = 'Modify_Course_Crsauthor'; |
|
$crsdefault = 1; |
|
} elsif ($item eq 'crseditors') { |
|
$helpfile = 'Modify_Course_Resource_Editors'; |
|
$crsdefault = 'edit,xml'; |
|
} |
} |
} |
my %settings = &Apache::lonnet::get('environment',['internal.ltiauth'],$cdom,$cnum); |
$currcrsval = $settings->{'internal.'.$item}; |
my $ltiauth = $settings{'internal.ltiauth'}; |
if ($currcrsval ne '') { |
|
|
if ($ltiauth ne '') { |
|
$checkedcrs = $checkeddom; |
$checkedcrs = $checkeddom; |
$checkeddom = ''; |
$checkeddom = ''; |
$divsty = 'display:inline-block'; |
$divsty = 'display:inline-block'; |
if ($ltiauth) { |
if ($item eq 'crseditors') { |
$authok = ' checked="checked"'; |
@currcrseditors = split(/,/,$currcrsval); |
} |
} |
} |
foreach my $option (@{$options}) { |
&print_header($r,$type); |
if ($item eq 'crseditors') { |
my $hidden_elements = &hidden_form_elements(); |
if (grep(/^\Q$option\E$/,@currcrseditors)) { |
my ($disabled,$submit); |
$crschecked{$option} = ' checked="checked"'; |
if ($readonly) { |
} |
$disabled = ' disabled="disabled"'; |
} elsif ($currcrsval eq $option) { |
} else { |
$crschecked{$option} = ' checked="checked"'; |
$submit = '<input type="button" onclick="javascript:changePage(this.form,'."'processltiauth'".');" value="'.$lt{'modi'}.'" />'; |
} else { |
} |
$crschecked{$option} = ''; |
my $helpitem = &Apache::loncommon::help_open_topic('Modify_Course_LTI_Authen'); |
|
my $showtype = &mt($type); |
|
$r->print(<<ENDDOCUMENT); |
|
<h3>$helpitem $lt{'requ'}</h3> |
|
<h4><span class="LC_nobreak">$showtype: $cdesc</span></h4> |
|
<form action="/adm/modifycourse" method="post" name="setltiauth"> |
|
<p><span class="LC_nobreak">$lt{'curd'}: <span style="font-style:italic">$domdefdisplay</span></span></p> |
|
<p><span class="LC_nobreak"> |
|
<label><input type="radio" name="ltiauthset" value="dom" onclick="toggleLTIOptions(this.form);"$checkeddom$disabled />$lt{'used'}</label></span><br /> |
|
<span class="LC_nobreak"> |
|
<label><input type="radio" name="ltiauthset" value="course" onclick="toggleLTIOptions(this.form);"$checkedcrs$disabled />$lt{'cour'}</label></span></p> |
|
<fieldset id="crsltiauth" style="$divsty"> |
|
<legend>$lt{'valu'}</legend> |
|
<span class="LC_nobreak"> |
|
<label><input type="radio" name="ltiauth" value="0"$authno$disabled />$lt{'logi'}</label> |
|
</span><br /> |
|
<span class="LC_nobreak"> |
|
<label><input type="radio" name="ltiauth" value="1"$authok$disabled />$lt{'link'}</label> |
|
</span> |
|
</fieldset><p> |
|
$submit |
|
$hidden_elements |
|
</p> |
|
</form> |
|
ENDDOCUMENT |
|
my @actions = |
|
('<a href="javascript:changePage(document.setltiauth,'."'menu'".')">'. |
|
$lt{'back'}.'</a>'); |
|
$r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions)); |
|
return; |
|
} |
|
|
|
sub print_set_exttool { |
|
my ($r,$cdom,$cnum,$cdesc,$type,$readonly) = @_; |
|
my %titles = &exttool_titles($type); |
|
my ($domdef,$domdefdom,$checkeddom,$checkedcrs,$domdefdisplay,$divsty); |
|
$domdef = 0; |
|
$domdefdom = 1; |
|
$checkeddom = ' checked="checked"'; |
|
$divsty = 'display:none'; |
|
my %settings = &Apache::lonnet::get('environment',['internal.coursecode', |
|
'internal.textbook'],$cdom,$cnum); |
|
my $lctype = &get_lctype($type,\%settings); |
|
my %domconfig = |
|
&Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom); |
|
if (ref($domconfig{'coursedefaults'}) eq 'HASH') { |
|
if (ref($domconfig{'coursedefaults'}{'exttool'}) eq 'HASH') { |
|
if (exists($domconfig{'coursedefaults'}{'exttool'}{$lctype})) { |
|
$domdef = $domconfig{'coursedefaults'}{'exttool'}{$lctype}; |
|
} |
|
} |
|
if (ref($domconfig{'coursedefaults'}{'domexttool'}) eq 'HASH') { |
|
if (exists($domconfig{'coursedefaults'}{'domexttool'}{$lctype})) { |
|
$domdefdom = $domconfig{'coursedefaults'}{'domexttool'}{$lctype}; |
|
} |
} |
} |
} |
} |
} else { |
if ($domdef && $domdefdom) { |
if ($item eq 'crseditors') { |
$domdefdisplay = $titles{'both'}; |
my %domdefs = &Apache::lonnet::get_domain_defaults($cdom); |
} elsif ($domdef) { |
@currcrseditors = split(/,/,$domdefs{'crseditors'}); |
$domdefdisplay = $titles{'crs'}; |
} |
} elsif ($domdefdom) { |
foreach my $option (@{$options}) { |
$domdefdisplay = $titles{'dom'}; |
if ($item eq 'crseditors') { |
} else { |
if (grep(/^\Q$option\E$/,@currcrseditors)) { |
$domdefdisplay = $titles{'none'}; |
$crschecked{$option} = ' checked="checked"'; |
} |
} |
my %settings = &Apache::lonnet::get('environment',['internal.exttool'],$cdom,$cnum); |
} elsif ($crsdefault eq $option) { |
my $crsexttool = $settings{'internal.exttool'}; |
|
my %crschecked = ( |
|
both => ' checked="checked"', |
|
dom => '', |
|
crs => '', |
|
none => '', |
|
); |
|
if ($crsexttool ne '') { |
|
$checkedcrs = $checkeddom; |
|
$checkeddom = ''; |
|
$divsty = 'display:inline-block'; |
|
foreach my $option ('both','dom','crs','none') { |
|
if ($crsexttool eq $option) { |
|
$crschecked{$option} = ' checked="checked"'; |
$crschecked{$option} = ' checked="checked"'; |
} else { |
} else { |
$crschecked{$option} = ''; |
$crschecked{$option} = ''; |
} |
} |
} |
} |
} |
} |
&print_header($r,$type); |
my ($disabled,$submit,$inputtype,$separator); |
my $hidden_elements = &hidden_form_elements(); |
|
my ($disabled,$submit); |
|
if ($readonly) { |
if ($readonly) { |
$disabled = ' disabled="disabled"'; |
$disabled = ' disabled="disabled"'; |
} else { |
} else { |
$submit = '<input type="button" onclick="javascript:changePage(this.form,'."'processexttool'".');" value="'.$titles{'modi'}.'" />'; |
$submit = '<input type="button" onclick="javascript:changePage(this.form,'."'process${item}'".');" value="'.$titles{'modi'}.'" />'; |
|
} |
|
if ($item eq 'crseditors') { |
|
$inputtype = 'checkbox'; |
|
$separator = ' 'x2; |
|
} else { |
|
$inputtype = 'radio'; |
|
$separator = '<br />'; |
|
} |
|
foreach my $option (@{$options}) { |
|
$crselements .= '<span class="LC_nobreak">'. |
|
'<label><input type="'.$inputtype.'" name="'.$item.'" value="'.$option.'"'. |
|
$crschecked{$option}.$disabled.' />'.$optiontext->{$option}.'</label>'. |
|
'</span>'.$separator."\n"; |
} |
} |
my $helpitem = &Apache::loncommon::help_open_topic('Modify_Course_External_Tool'); |
&print_header($r,$type); |
|
my $hidden_elements = &hidden_form_elements(); |
|
my $helpitem = &Apache::loncommon::help_open_topic($helpfile); |
my $showtype = &mt($type); |
my $showtype = &mt($type); |
$r->print(<<ENDDOCUMENT); |
$r->print(<<ENDDOCUMENT); |
<h3>$helpitem $titles{'extt'}</h3> |
<h3>$helpitem $title</h3> |
<h4><span class="LC_nobreak">$showtype: $cdesc</span></h4> |
<h4><span class="LC_nobreak">$showtype: $cdesc</span></h4> |
<form action="/adm/modifycourse" method="post" name="setexttool"> |
<form action="/adm/modifycourse" method="post" name="set$item"> |
<p><span class="LC_nobreak">$titles{'curd'}: <span style="font-style:italic">$domdefdisplay</span></span></p> |
<p><span class="LC_nobreak">$titles{'curd'}: <span style="font-style:italic">$domdefdisplay</span></span></p> |
<p><span class="LC_nobreak"> |
<p><span class="LC_nobreak"> |
<label><input type="radio" name="exttoolset" value="dom" onclick="toggleExtToolOptions(this.form);"$checkeddom$disabled />$titles{'used'}</label></span><br /> |
<label><input type="radio" name="${item}set" value="dom" onclick="toggleOptions(this.form,'set$item');"$checkeddom$disabled />$titles{'used'}</label></span><br /> |
<span class="LC_nobreak"> |
<span class="LC_nobreak"> |
<label><input type="radio" name="exttoolset" value="course" onclick="toggleExtToolOptions(this.form);"$checkedcrs$disabled />$titles{'cour'}</label></span></p> |
<label><input type="radio" name="${item}set" value="course" onclick="toggleOptions(this.form,'set$item');"$checkedcrs$disabled />$titles{'cour'}</label></span></p> |
<fieldset id="crsexttool" style="$divsty"> |
<fieldset id="crs$item" style="$divsty"> |
<legend>$titles{'valu'}</legend> |
<legend>$titles{'valu'}</legend> |
<span class="LC_nobreak"> |
$crselements |
<label><input type="radio" name="exttool" value="both"$crschecked{'both'}$disabled />$titles{'both'}</label> |
|
</span><br /> |
|
<span class="LC_nobreak"> |
|
<label><input type="radio" name="exttool" value="dom"$crschecked{'dom'}$disabled />$titles{'dom'}</label> |
|
</span><br /> |
|
<span class="LC_nobreak"> |
|
<label><input type="radio" name="exttool" value="crs"$crschecked{'crs'}$disabled />$titles{'crs'}</label> |
|
</span><br /> |
|
<span class="LC_nobreak"> |
|
<label><input type="radio" name="exttool" value="none"$crschecked{'none'}$disabled />$titles{'none'}</label> |
|
</span> |
|
</fieldset><p> |
</fieldset><p> |
$submit |
$submit |
$hidden_elements |
$hidden_elements |
Line 1473 $hidden_elements
|
Line 1424 $hidden_elements
|
</form> |
</form> |
ENDDOCUMENT |
ENDDOCUMENT |
my @actions = |
my @actions = |
('<a href="javascript:changePage(document.setexttool,'."'menu'".')">'. |
('<a href="javascript:changePage(document.set'.$item.','."'menu'".')">'. |
$titles{'back'}.'</a>'); |
$titles{'back'}.'</a>'); |
$r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions)); |
$r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions)); |
return; |
return; |
} |
} |
|
|
sub exttool_titles { |
sub default_overrides_titles { |
my ($type) = @_; |
my ($type) = @_; |
my %titles = &Apache::lonlocal::texthash( |
my %titles = &Apache::lonlocal::texthash( |
|
'requ' => 'Requirement for re-authentication for student LTI-limited launch of deep-linked item', |
|
'link' => 'Link protection can be set to accept username for an enrolled student (if sent by Consumer)', |
|
'logi' => 'Login needed, regardless of user information sent by LTI Consumer in (signed) parameters', |
'extt' => 'External Tool permissions', |
'extt' => 'External Tool permissions', |
'none' => 'Use of external tools not permitted', |
'none' => 'Use of external tools not permitted', |
'crs' => 'Only external tools defined in course may be used', |
'crs' => 'Only external tools defined in course may be used', |
'dom' => 'Only external tools defined in domain may be used', |
'dom' => 'Only external tools defined in domain may be used', |
'both' => 'External tools defined/configured in either domain or course may be used', |
'both' => 'External tools defined/configured in either domain or course may be used', |
|
'stan' => "'In-course' authoring of standard LON-CAPA problems", |
|
'perc' => 'Permitted course resource editors', |
|
'edit' => 'Standard editor (Edit)', |
|
'xml' => 'Text editor (EditXML)', |
|
'daxe' => 'Daxe editor (Daxe)', |
|
'on' => 'In-course authoring available', |
|
'off' => 'In-course authoring unavailable', |
'used' => 'Use domain default', |
'used' => 'Use domain default', |
'cour' => 'Use course-specific setting', |
'cour' => 'Use course-specific setting', |
'curd' => 'Current domain default is', |
'curd' => 'Current domain default is', |
Line 1503 sub exttool_titles {
|
Line 1464 sub exttool_titles {
|
return %titles; |
return %titles; |
} |
} |
|
|
|
sub default_overrides_common { |
|
my ($item,$cdom,$cnum,$type,$titles) = @_; |
|
my ($title,$domdef,$domdefdom,$domdefdisplay,%settings,%optiontext,@options); |
|
if ($item eq 'ltiauth') { |
|
%settings = &Apache::lonnet::get('environment',['internal.'.$item],$cdom,$cnum); |
|
$title = $titles->{'requ'}; |
|
$domdef = 0; |
|
@options = ('0','1'); |
|
%optiontext = ( |
|
0 => $titles->{'logi'}, |
|
1 => $titles->{'link'}, |
|
); |
|
} else { |
|
%settings = |
|
&Apache::lonnet::get('environment',['internal.'.$item,'internal.coursecode', |
|
'internal.textbook'],$cdom,$cnum); |
|
if ($item eq 'exttool') { |
|
$title = $titles->{'extt'}; |
|
$domdefdom = 1; |
|
$domdef = 0; |
|
@options = ('both','dom','crs','none'); |
|
map { $optiontext{$_} = $titles->{$_}; } @options; |
|
} elsif ($item eq 'crsauthor') { |
|
$title = $titles->{'stan'}; |
|
$domdef = 1; |
|
@options = ('1','0'); |
|
%optiontext = ( |
|
1 => $titles->{'on'}, |
|
0 => $titles->{'off'}, |
|
); |
|
} elsif ($item eq 'crseditors') { |
|
$title = $titles->{'perc'}; |
|
$domdef = 1; |
|
@options = ('edit','xml','daxe'); |
|
map { $optiontext{$_} = $titles->{$_}; } @options; |
|
} |
|
} |
|
my %domconfig = |
|
&Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom); |
|
if (ref($domconfig{'coursedefaults'}) eq 'HASH') { |
|
if (($item eq 'ltiauth') || ($item eq 'crseditors')) { |
|
$domdef = $domconfig{'coursedefaults'}{$item}; |
|
} else { |
|
my $lctype = &get_lctype($type,\%settings); |
|
if (ref($domconfig{'coursedefaults'}{$item}) eq 'HASH') { |
|
if (exists($domconfig{'coursedefaults'}{$item}{$lctype})) { |
|
$domdef = $domconfig{'coursedefaults'}{$item}{$lctype}; |
|
} |
|
} |
|
if ($item eq 'exttool') { |
|
if (ref($domconfig{'coursedefaults'}{'domexttool'}) eq 'HASH') { |
|
if (exists($domconfig{'coursedefaults'}{'domexttool'}{$lctype})) { |
|
$domdefdom = $domconfig{'coursedefaults'}{'domexttool'}{$lctype}; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if ($item eq 'ltiauth') { |
|
if ($domdef) { |
|
$domdefdisplay = $titles->{'link'}; |
|
} else { |
|
$domdefdisplay = $titles->{'logi'}; |
|
} |
|
} elsif ($item eq 'exttool') { |
|
if ($domdef && $domdefdom) { |
|
$domdefdisplay = $titles->{'both'}; |
|
} elsif ($domdef) { |
|
$domdefdisplay = $titles->{'crs'}; |
|
} elsif ($domdefdom) { |
|
$domdefdisplay = $titles->{'dom'}; |
|
} else { |
|
$domdefdisplay = $titles->{'none'}; |
|
} |
|
} elsif ($item eq 'crsauthor') { |
|
if ($domdef) { |
|
$domdefdisplay = $titles->{'on'}; |
|
} else { |
|
$domdefdisplay = $titles->{'off'}; |
|
} |
|
} elsif ($item eq 'crseditors') { |
|
if (ref($domdef) eq 'ARRAY') { |
|
if (@{$domdef} == 0) { |
|
$domdefdisplay = &mt('No permitted editors'); |
|
} elsif (@{$domdef} == 1) { |
|
$domdefdisplay = $titles->{$domdef->[0]}.' ('.&mt('only').')'; |
|
} else { |
|
$domdefdisplay = join(', ', map { $titles->{$_}; } @{$domdef}); |
|
} |
|
} else { |
|
$domdefdisplay = join(', ', map { $titles->{$_}; } ('edit','xml')); |
|
} |
|
} |
|
return ($title,$domdefdisplay,\%settings,\%optiontext,\@options); |
|
} |
|
|
sub modify_selfenrollconfig { |
sub modify_selfenrollconfig { |
my ($r,$type,$cdesc,$coursehash) = @_; |
my ($r,$type,$cdesc,$coursehash) = @_; |
return unless(ref($coursehash) eq 'HASH'); |
return unless(ref($coursehash) eq 'HASH'); |
Line 2508 sub modify_catsettings {
|
Line 2565 sub modify_catsettings {
|
return; |
return; |
} |
} |
|
|
sub modify_ltiauth { |
sub modify_default_overrides { |
my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_; |
my ($r,$cdom,$cnum,$cdesc,$domdesc,$type,$item) = @_; |
my %lt = &Apache::lonlocal::texthash( |
my (%titles,$oldcrsval,$newcrsval,%resulttext,$itemvalue,$nochange,$change,$status,$error); |
'requ' => 'Requirement for re-authentication for student LTI-limited launch of deep-linked item', |
%titles = &default_overrides_titles($type); |
'link' => 'Link protection can be set to accept username for an enrolled student (if sent by Consumer)', |
my ($title,$domdefdisplay,$oldsettings,$optiontext,$options) = |
'logi' => 'Login needed, regardless of user information sent by LTI Consumer in (signed) parameters', |
&default_overrides_common($item,$cdom,$cnum,$type,\%titles); |
'used' => 'Use domain default', |
$oldcrsval = $oldsettings->{'internal.'.$item}; |
'cour' => 'Use course-specific setting', |
if ($item eq 'ltiauth') { |
'modi' => 'Save', |
%resulttext = |
'back' => 'Pick another action', |
&Apache::lonlocal::texthash( |
); |
chg => 'Re-authentication requirement for LTI launch of deep-linked changed', |
|
nochg => 'Re-authentication requirement for LTI launch of deep-linked item is unchanged', |
|
); |
|
} elsif ($item eq 'exttool') { |
|
%resulttext = |
|
&Apache::lonlocal::texthash( |
|
chg => 'External Tool permissions changed', |
|
nochg => 'External Tool permissions unchanged', |
|
); |
|
} elsif ($item eq 'crsauthor') { |
|
%resulttext = |
|
&Apache::lonlocal::texthash( |
|
chg => 'In-course authoring permissions changed', |
|
nochg => 'In-course authoring permissions unchanged', |
|
); |
|
} elsif ($item eq 'crseditors') { |
|
%resulttext = |
|
&Apache::lonlocal::texthash( |
|
chg => 'Permitted course resource editors changed', |
|
nochg => 'Permitted course resource editors unchanged', |
|
); |
|
} |
&print_header($r,$type); |
&print_header($r,$type); |
$r->print('<h3>'.$lt{'requ'}.'</h3>'."\n". |
$r->print('<h3>'.$title.'</h3>'."\n". |
'<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n". |
'<h4><span class="LC_nobreak">'.&mt($type).': '.$cdesc.'</span></h4>'."\n". |
'<form action="/adm/modifycourse" method="post" name="processltiauth">'."\n"); |
'<form action="/adm/modifycourse" method="post" name="process'.$item.'">'."\n"); |
my %oldsettings = &Apache::lonnet::get('environment',['internal.ltiauth'],$cdom,$cnum); |
if ($env{'form.'.$item.'set'} eq 'dom') { |
my $oldltiauth = $oldsettings{'internal.ltiauth'}; |
if ($oldcrsval eq '') { |
my $domdef; |
|
my %domconfig = |
|
&Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom); |
|
if (ref($domconfig{'coursedefaults'}) eq 'HASH') { |
|
$domdef = $domconfig{'coursedefaults'}{'ltiauth'}; |
|
} |
|
my ($newltiauth,$nochange,$change,$status,$error,$ltiauth); |
|
if ($env{'form.ltiauthset'} eq 'dom') { |
|
if ($oldltiauth eq '') { |
|
$nochange = 1; |
$nochange = 1; |
} else { |
} else { |
$change = 1; |
$change = 1; |
} |
} |
} elsif ($env{'form.ltiauthset'} eq 'course') { |
} elsif ($env{'form.'.$item.'set'} eq 'course') { |
if ($env{'form.ltiauth'} =~ /^0|1$/) { |
if ($item eq 'crseditors') { |
$newltiauth = $env{'form.ltiauth'}; |
my @neweditors; |
} |
my @posseditors = &Apache::loncommon::get_env_multiple('form.'.$item); |
if ($oldltiauth == $newltiauth) { |
foreach my $editor (@posseditors) { |
$nochange = 1; |
if (grep(/^\Q$editor\E$/,@{$options})) { |
} else { |
push(@neweditors,$editor); |
$change = 1; |
} |
} |
} |
} |
$newcrsval = join(',',@neweditors); |
if ($change) { |
} else { |
if ($newltiauth ne '') { |
my $posscrsval = $env{'form.'.$item}; |
my %cenv = ( |
if (grep(/^\Q$posscrsval\E$/,@{$options})) { |
'internal.ltiauth' => $newltiauth, |
$newcrsval = $posscrsval; |
); |
|
if (&Apache::lonnet::put('environment',\%cenv,$cdom,$cnum) eq 'ok') { |
|
if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') { |
|
&Apache::lonnet::appenv( |
|
{'course.'.$cdom.'_'.$cnum.'.internal.ltiauth' => $newltiauth}); |
|
} |
|
} else { |
|
$error = 1; |
|
} |
|
} else { |
|
if (&Apache::lonnet::del('environment',['internal.ltiauth'],$cdom,$cnum) eq 'ok') { |
|
if (exists($env{'course.'.$cdom.'_'.$cnum.'.internal.ltiauth'})) { |
|
&Apache::lonnet::delenv('course.'.$cdom.'_'.$cnum.'.internal.ltiauth'); |
|
} |
|
} else { |
|
$error = 1; |
|
} |
|
} |
|
} |
|
if ($error) { |
|
$nochange = 1; |
|
} |
|
if ($nochange) { |
|
$ltiauth = $oldltiauth; |
|
} else { |
|
$ltiauth = $newltiauth; |
|
} |
|
if ($ltiauth eq '') { |
|
$status = $lt{'used'}.': '; |
|
if ($domdef) { |
|
$status .= '<span style="font-style:italic">'.$lt{'link'}.'</span>'; |
|
} else { |
|
$status .= '<span style="font-style:italic">'.$lt{'logi'}.'</span>'; |
|
} |
|
} else { |
|
$status = $lt{'cour'}.': '; |
|
if ($ltiauth) { |
|
$status .= '<span style="font-style:italic">'.$lt{'link'}.'</span>'; |
|
} else { |
|
$status .= '<span style="font-style:italic">'.$lt{'logi'}.'</span>'; |
|
} |
|
} |
|
if ($error) { |
|
$r->print('<p class="LC_warning">'.&mt('An error occurred when saving your changes').'</p>'); |
|
} |
|
$r->print('<p>'); |
|
if ($nochange) { |
|
$r->print(&mt('Re-authentication requirement for LTI launch of deep-linked item is unchanged')); |
|
} elsif ($change) { |
|
$r->print(&mt('Re-authentication requirement for LTI launch of deep-linked changed')); |
|
} |
|
$r->print('<br />'.$status.'</p>'. |
|
&hidden_form_elements().'</form>'); |
|
my @actions = |
|
('<a href="javascript:changePage(document.processltiauth,'."'menu'".')">'. |
|
$lt{'back'}.'</a>'); |
|
$r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions)); |
|
return; |
|
} |
|
|
|
sub modify_exttool { |
|
my ($r,$cdom,$cnum,$cdesc,$domdesc,$type) = @_; |
|
my %titles = &exttool_titles($type); |
|
&print_header($r,$type); |
|
$r->print('<h3>'.$titles{'extt'}.'</h3>'."\n". |
|
'<h4><span class="LC_nobreak">'.$type.': '.$cdesc.'</span></h4>'."\n". |
|
'<form action="/adm/modifycourse" method="post" name="processexttool">'."\n"); |
|
my %oldsettings = &Apache::lonnet::get('environment',['internal.exttool'],$cdom,$cnum); |
|
my $oldcrsexttool = $oldsettings{'internal.exttool'}; |
|
my $domdefdom = 1; |
|
my $domdef = 0; |
|
my $domdefdisplay; |
|
my %settings = &Apache::lonnet::get('environment',['internal.coursecode', |
|
'internal.textbook'],$cdom,$cnum); |
|
my $lctype = &get_lctype($type,\%settings); |
|
my %domconfig = |
|
&Apache::lonnet::get_dom('configuration',['coursedefaults'],$cdom); |
|
if (ref($domconfig{'coursedefaults'}) eq 'HASH') { |
|
if (ref($domconfig{'coursedefaults'}{'domexttool'}) eq 'HASH') { |
|
if (exists($domconfig{'coursedefaults'}{'domexttool'}{$lctype})) { |
|
$domdefdom = $domconfig{'coursedefaults'}{'domexttool'}{$lctype}; |
|
} |
|
} |
|
if (ref($domconfig{'coursedefaults'}{'exttool'}) eq 'HASH') { |
|
if (exists($domconfig{'coursedefaults'}{'exttool'}{$lctype})) { |
|
$domdef = $domconfig{'coursedefaults'}{'exttool'}{$lctype}; |
|
} |
} |
} |
} |
} |
if ($oldcrsval eq $newcrsval) { |
if ($domdef && $domdefdom) { |
|
$domdefdisplay = $titles{'both'}; |
|
} elsif ($domdef) { |
|
$domdefdisplay = $titles{'crs'}; |
|
} elsif ($domdefdom) { |
|
$domdefdisplay = $titles{'dom'}; |
|
} else { |
|
$domdefdisplay = $titles{'none'}; |
|
} |
|
my ($newcrsexttool,$nochange,$change,$status,$error,$exttool); |
|
if ($env{'form.exttoolset'} eq 'dom') { |
|
if ($oldcrsexttool eq '') { |
|
$nochange = 1; |
|
} else { |
|
$change = 1; |
|
} |
|
} elsif ($env{'form.exttoolset'} eq 'course') { |
|
if ($env{'form.exttool'} =~ /^both|dom|crs|none$/) { |
|
$newcrsexttool = $env{'form.exttool'}; |
|
} |
|
if ($oldcrsexttool eq $newcrsexttool) { |
|
$nochange = 1; |
$nochange = 1; |
} else { |
} else { |
$change = 1; |
$change = 1; |
} |
} |
} |
} |
if ($change) { |
if ($change) { |
if ($newcrsexttool ne '') { |
if ($newcrsval ne '') { |
my %cenv = ( |
my %cenv = ( |
'internal.exttool' => $newcrsexttool, |
'internal.'.$item => $newcrsval, |
); |
); |
if (&Apache::lonnet::put('environment',\%cenv,$cdom,$cnum) eq 'ok') { |
if (&Apache::lonnet::put('environment',\%cenv,$cdom,$cnum) eq 'ok') { |
if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') { |
if ($env{'course.'.$cdom.'_'.$cnum.'.description'} ne '') { |
&Apache::lonnet::appenv( |
&Apache::lonnet::appenv( |
{'course.'.$cdom.'_'.$cnum.'.internal.exttool' => $newcrsexttool}); |
{'course.'.$cdom.'_'.$cnum.'.internal.'.$item => $newcrsval}); |
} |
} |
} else { |
} else { |
$error = 1; |
$error = 1; |
} |
} |
} else { |
} else { |
if (&Apache::lonnet::del('environment',['internal.exttool'],$cdom,$cnum) eq 'ok') { |
if (&Apache::lonnet::del('environment',['internal.'.$item],$cdom,$cnum) eq 'ok') { |
if (exists($env{'course.'.$cdom.'_'.$cnum.'.internal.exttool'})) { |
if (exists($env{'course.'.$cdom.'_'.$cnum.'.internal.'.$item})) { |
&Apache::lonnet::delenv('course.'.$cdom.'_'.$cnum.'.internal.exttool'); |
&Apache::lonnet::delenv('course.'.$cdom.'_'.$cnum.'.internal.'.$item); |
} |
} |
} else { |
} else { |
$error = 1; |
$error = 1; |
Line 2694 sub modify_exttool {
|
Line 2656 sub modify_exttool {
|
$nochange = 1; |
$nochange = 1; |
} |
} |
if ($nochange) { |
if ($nochange) { |
$exttool = $oldcrsexttool; |
$itemvalue = $oldcrsval; |
} else { |
} else { |
$exttool = $newcrsexttool; |
$itemvalue = $newcrsval; |
} |
} |
if ($exttool eq '') { |
if ($itemvalue eq '') { |
$status = $titles{'used'}.': <span style="font-style:italic">'.$domdefdisplay.'</span>'; |
$status = $titles{'used'}.': '. |
|
'<span style="font-style:italic">'.$domdefdisplay.'</span>'; |
|
} elsif ($item eq 'crseditors') { |
|
$status = $titles{'cour'}.': '. |
|
'<span style="font-style:italic">'.join(', ', map { $titles{$_}; } split(/,/,$itemvalue)).'</span>'; |
} else { |
} else { |
$status = $titles{'cour'}.': <span style="font-style:italic">'.$titles{$exttool}.'</span>'; |
$status = $titles{'cour'}.': '. |
|
'<span style="font-style:italic">'.$optiontext->{$itemvalue}.'</span>'; |
} |
} |
if ($error) { |
if ($error) { |
$r->print('<p class="LC_warning">'.&mt('An error occurred when saving your changes').'</p>'); |
$r->print('<p class="LC_warning">'.&mt('An error occurred when saving your changes').'</p>'); |
} |
} |
$r->print('<p>'); |
$r->print('<p>'); |
if ($nochange) { |
if ($nochange) { |
$r->print(&mt('External Tool permissions unchanged')); |
$r->print($resulttext{'nochg'}); |
} elsif ($change) { |
} elsif ($change) { |
$r->print(&mt('External Tool permissions changed')); |
$r->print($resulttext{'chg'}); |
} |
} |
$r->print('<br />'.$status.'</p>'. |
$r->print('<br />'.$status.'</p>'. |
&hidden_form_elements().'</form>'); |
&hidden_form_elements().'</form>'); |
my @actions = |
my @actions = |
('<a href="javascript:changePage(document.processexttool,'."'menu'".')">'. |
('<a href="javascript:changePage(document.process'.$item.','."'menu'".')">'. |
$titles{'back'}.'</a>'); |
$titles{'back'}.'</a>'); |
$r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions)); |
$r->print('<br />'.&Apache::lonhtmlcommon::actionbox(\@actions)); |
return; |
return; |
Line 2877 function togglePostsubmit(caller) {
|
Line 2844 function togglePostsubmit(caller) {
|
|
|
ENDSCRIPT |
ENDSCRIPT |
|
|
} elsif ($phase eq 'setltiauth') { |
} elsif (($phase eq 'setltiauth') || ($phase eq 'setexttool') || |
|
($phase eq 'setcrsauthor') || ($phase eq 'setcrseditors')) { |
$js .= <<"ENDJS"; |
$js .= <<"ENDJS"; |
function toggleLTIOptions(form) { |
function toggleOptions(form,phase) { |
var radioname = 'ltiauthset'; |
var radioname; |
var divid = 'crsltiauth'; |
var divid; |
var num = form.elements[radioname].length; |
if (phase == 'setltiauth') { |
if (num) { |
radioname = 'ltiauthset'; |
var setvis = ''; |
divid = 'crsltiauth'; |
for (var i=0; i<num; i++) { |
} else if (phase == 'setexttool') { |
if (form.elements[radioname][i].checked) { |
radioname = 'exttoolset'; |
if (form.elements[radioname][i].value == 'course') { |
divid = 'crsexttool'; |
if (document.getElementById(divid)) { |
} else if (phase == 'setcrsauthor') { |
document.getElementById(divid).style.display = 'inline-block'; |
radioname = 'crsauthorset'; |
} |
divid = 'crscrsauthor'; |
setvis = 1; |
} else if (phase == 'setcrseditors') { |
} |
radioname = 'crseditorsset'; |
break; |
divid = 'crscrseditors'; |
} |
|
} |
|
if (!setvis) { |
|
if (document.getElementById(divid)) { |
|
document.getElementById(divid).style.display = 'none'; |
|
} |
|
} |
|
} |
} |
return; |
|
} |
|
|
|
ENDJS |
|
} elsif ($phase eq 'setexttool') { |
|
$js .= <<"ENDJS"; |
|
function toggleExtToolOptions(form) { |
|
var radioname = 'exttoolset'; |
|
var divid = 'crsexttool'; |
|
var num = form.elements[radioname].length; |
var num = form.elements[radioname].length; |
if (num) { |
if (num) { |
var setvis = ''; |
var setvis = ''; |
Line 2945 ENDJS
|
Line 2897 ENDJS
|
$starthash = { |
$starthash = { |
add_entries => {'onload' => "hide_searching(); courseSet(document.filterpicker.official, 'load');"}, |
add_entries => {'onload' => "hide_searching(); courseSet(document.filterpicker.official, 'load');"}, |
}; |
}; |
} elsif ($env{'form.phase'} eq 'setltiauth') { |
} elsif ($env{'form.phase'} =~ /^set(ltiauth|exttool|crsauthor|crseditors)$/) { |
$starthash = { |
|
add_entries => {'onload' => "toggleLTIOptions(document.setltiauth);"}, |
|
}; |
|
} elsif ($env{'form.phase'} eq 'setexttool') { |
|
$starthash = { |
$starthash = { |
add_entries => {'onload' => "toggleExtToolOptions(document.setexttool);"}, |
add_entries => {'onload' => "toggleOptions(document.$env{'form.phase'},'$env{'form.phase'}');"}, |
}; |
}; |
} |
} |
$r->print(&Apache::loncommon::start_page('View/Modify Course/Community Settings', |
$r->print(&Apache::loncommon::start_page('View/Modify Course/Community Settings', |
Line 3061 sub hidden_form_elements {
|
Line 3009 sub hidden_form_elements {
|
'threshold','postsubmit','postsubtimeout','defaultcredits','uploadquota', |
'threshold','postsubmit','postsubtimeout','defaultcredits','uploadquota', |
'selfenrollmgrdc','selfenrollmgrcc','action','state','currsec_st', |
'selfenrollmgrdc','selfenrollmgrcc','action','state','currsec_st', |
'sections','newsec','mysqltables','nopasswdchg','ltiauth','ltiauthset', |
'sections','newsec','mysqltables','nopasswdchg','ltiauth','ltiauthset', |
'exttoolset','exttool'],['^selfenrollmgr_','^selfenroll_'])."\n". |
'exttoolset','exttool','crsauthorset','crsauthor','crseditorsset','crseditors'], |
|
['^selfenrollmgr_','^selfenroll_'])."\n". |
'<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />'; |
'<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />'; |
return $hidden_elements; |
return $hidden_elements; |
} |
} |
Line 3098 sub get_permission {
|
Line 3047 sub get_permission {
|
processltiauth => 'edit', |
processltiauth => 'edit', |
setexttool => 'edit', |
setexttool => 'edit', |
processexttool => 'edit', |
processexttool => 'edit', |
|
setcrsauthor => 'edit', |
|
processcrsauthor => 'edit', |
|
setcrseditors => 'edit', |
|
processcrseditors => 'edit', |
); |
); |
if ($passwdconf{'crsownerchg'}) { |
if ($passwdconf{'crsownerchg'}) { |
$permission{passwdchg} = 'edit'; |
$permission{passwdchg} = 'edit'; |
Line 3115 sub get_permission {
|
Line 3068 sub get_permission {
|
adhocrole => 'custom', |
adhocrole => 'custom', |
setltiauth => 'view', |
setltiauth => 'view', |
setexttool => 'view', |
setexttool => 'view', |
|
setcrsauthor => 'view', |
|
setcrseditors => 'view', |
); |
); |
if ($passwdconf{'crsownerchg'}) { |
if ($passwdconf{'crsownerchg'}) { |
$permission{passwdchg} = 'view'; |
$permission{passwdchg} = 'view'; |
Line 3321 sub handler {
|
Line 3276 sub handler {
|
} elsif (($phase eq 'setltiauth') && ($permission->{'setltiauth'})) { |
} elsif (($phase eq 'setltiauth') && ($permission->{'setltiauth'})) { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:changePage(document.$phase,'$phase')", |
({href=>"javascript:changePage(document.$phase,'$phase')", |
text=>"Requirement for re-authentication for LTI launch of deep-linked item"}); |
text=>"Authentication post-LTI launch"}); |
&print_set_ltiauth($r,$cdom,$cnum,$cdesc,$type,$readonly); |
&print_default_overrides($r,$cdom,$cnum,$cdesc,$type,$readonly,'ltiauth'); |
} elsif (($phase eq 'processltiauth') && ($permission->{'processltiauth'})) { |
} elsif (($phase eq 'processltiauth') && ($permission->{'processltiauth'})) { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:changePage(document.$phase,'setltiauth')", |
({href=>"javascript:changePage(document.$phase,'setltiauth')", |
text=>"Requirement for re-authentication for LTI launch of deep-linked item"}, |
text=>"Authentication post-LTI launch"}, |
{href=>"javascript:changePage(document.$phase,'$phase')", |
{href=>"javascript:changePage(document.$phase,'$phase')", |
text=>"Result"}); |
text=>"Result"}); |
&modify_ltiauth($r,$cdom,$cnum,$cdesc,$domdesc,$type); |
&modify_default_overrides($r,$cdom,$cnum,$cdesc,$domdesc,$type,'ltiauth'); |
} elsif (($phase eq 'setexttool') && ($permission->{'setexttool'})) { |
} elsif (($phase eq 'setexttool') && ($permission->{'setexttool'})) { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:changePage(document.$phase,'$phase')", |
({href=>"javascript:changePage(document.$phase,'$phase')", |
text=>"External Tool permission"}); |
text=>"External Tool permission"}); |
&print_set_exttool($r,$cdom,$cnum,$cdesc,$type,$readonly); |
&print_default_overrides($r,$cdom,$cnum,$cdesc,$type,$readonly,'exttool'); |
} elsif (($phase eq 'processexttool') && ($permission->{'processexttool'})) { |
} elsif (($phase eq 'processexttool') && ($permission->{'processexttool'})) { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:changePage(document.$phase,'setexttool')", |
({href=>"javascript:changePage(document.$phase,'setexttool')", |
text=>"External Tool permission"}, |
text=>"External Tool permission"}, |
{href=>"javascript:changePage(document.$phase,'$phase')", |
{href=>"javascript:changePage(document.$phase,'$phase')", |
text=>"Result"}); |
text=>"Result"}); |
&modify_exttool($r,$cdom,$cnum,$cdesc,$domdesc,$type); |
&modify_default_overrides($r,$cdom,$cnum,$cdesc,$domdesc,$type,'exttool'); |
|
} elsif (($phase eq 'setcrsauthor') && ($permission->{'setcrsauthor'})) { |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>"javascript:changePage(document.$phase,'$phase')", |
|
text=>"In-course authoring permission"}); |
|
&print_default_overrides($r,$cdom,$cnum,$cdesc,$type,$readonly,'crsauthor'); |
|
} elsif (($phase eq 'processcrsauthor') && ($permission->{'processcrsauthor'})) { |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>"javascript:changePage(document.$phase,'setcrsauthor')", |
|
text=>"In-course authoring permission"}, |
|
{href=>"javascript:changePage(document.$phase,'$phase')", |
|
text=>"Result"}); |
|
&modify_default_overrides($r,$cdom,$cnum,$cdesc,$domdesc,$type,'crsauthor'); |
|
} elsif (($phase eq 'setcrseditors') && ($permission->{'setcrseditors'})) { |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>"javascript:changePage(document.$phase,'$phase')", |
|
text=>"Available course resource editors"}); |
|
&print_default_overrides($r,$cdom,$cnum,$cdesc,$type,$readonly,'crseditors'); |
|
} elsif (($phase eq 'processcrseditors') && ($permission->{'processcrseditors'})) { |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>"javascript:changePage(document.$phase,'setcrseditors')", |
|
text=>"Available course resource editors"}, |
|
{href=>"javascript:changePage(document.$phase,'$phase')", |
|
text=>"Result"}); |
|
&modify_default_overrides($r,$cdom,$cnum,$cdesc,$domdesc,$type,'crseditors'); |
} |
} |
} |
} |
} else { |
} else { |