[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface domainprefs.pm
raeburn
raeburn at source.lon-capa.org
Fri May 22 10:12:10 EDT 2015
raeburn Fri May 22 14:12:10 2015 EDT
Modified files: (Branch: version_2_11_X)
/loncom/interface domainprefs.pm
Log:
- For 2.11
- Backport rev. 1.264
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.160.6.63 loncom/interface/domainprefs.pm:1.160.6.64
--- loncom/interface/domainprefs.pm:1.160.6.63 Tue May 12 00:20:42 2015
+++ loncom/interface/domainprefs.pm Fri May 22 14:12:08 2015
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.160.6.63 2015/05/12 00:20:42 raeburn Exp $
+# $Id: domainprefs.pm,v 1.160.6.64 2015/05/22 14:12:08 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2891,6 +2891,7 @@
uselcmath => 'Math preview uses LON-CAPA previewer (javascript) in place of DragMath (Java)',
usejsme => 'Molecule editor uses JSME (HTML5) in place of JME (Java)',
postsubmit => 'Disable submit button/keypress following student submission',
+ canclone => "People who may clone a course (besides course's owner and coordinators)",
);
my %staticdefaults = (
anonsurvey_threshold => 10,
@@ -2901,10 +2902,82 @@
%defaultchecked = (
'uselcmath' => 'on',
'usejsme' => 'on',
+ 'canclone' => 'none',
);
@toggles = ('uselcmath','usejsme');
($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked,
\%choices,$itemcount);
+ $css_class = $itemcount%2?' class="LC_odd_row"':'';
+ $datatable .=
+ '<tr'.$css_class.'><td valign="top">'.
+ '<span class="LC_nobreak">'.$choices{'canclone'}.
+ '</span></td><td class="LC_left_item">';
+ my $currcanclone = 'none';
+ my $onclick;
+ my @cloneoptions = ('none','domain');
+ my %clonetitles = (
+ none => 'No additional course requesters',
+ domain => "Any course requester in course's domain",
+ instcode => 'Course requests for official courses ...',
+ );
+ my (%codedefaults, at code_order, at posscodes);
+ if (&Apache::lonnet::auto_instcode_defaults($dom,\%codedefaults,
+ \@code_order) eq 'ok') {
+ if (@code_order > 0) {
+ push(@cloneoptions,'instcode');
+ $onclick = ' onclick="toggleDisplay(this.form,'."'cloneinstcode'".');"';
+ }
+ }
+ if (ref($settings) eq 'HASH') {
+ if ($settings->{'canclone'}) {
+ if (ref($settings->{'canclone'}) eq 'HASH') {
+ if (ref($settings->{'canclone'}{'instcode'}) eq 'ARRAY') {
+ if (@code_order > 0) {
+ $currcanclone = 'instcode';
+ @posscodes = @{$settings->{'canclone'}{'instcode'}};
+ }
+ }
+ } elsif ($settings->{'canclone'} eq 'domain') {
+ $currcanclone = $settings->{'canclone'};
+ }
+ }
+ }
+ foreach my $option (@cloneoptions) {
+ my ($checked,$additional);
+ if ($currcanclone eq $option) {
+ $checked = ' checked="checked"';
+ }
+ if ($option eq 'instcode') {
+ if (@code_order) {
+ my $show = 'none';
+ if ($checked) {
+ $show = 'block';
+ }
+ $additional = '<div id="cloneinstcode" style="display:'.$show.'" />'.
+ &mt('Institutional codes for new and cloned course have identical:').
+ '<br />';
+ foreach my $item (@code_order) {
+ my $codechk;
+ if ($checked) {
+ if (grep(/^\Q$item\E$/, at posscodes)) {
+ $codechk = ' checked="checked"';
+ }
+ }
+ $additional .= '<label>'.
+ '<input type="checkbox" name="clonecode" value="'.$item.'"'.$codechk.' />'.
+ $item.'</label>';
+ }
+ $additional .= (' 'x2).'('.&mt('check as many as needed').')</div>';
+ }
+ }
+ $datatable .=
+ '<span class="LC_nobreak"><label><input type="radio" name="canclone"'.$checked.
+ ' value="'.$option.'"'.$onclick.' />'.$clonetitles{$option}.
+ '</label> '.$additional.'</span><br />';
+ }
+ $datatable .= '</td>'.
+ '</tr>';
+ $itemcount ++;
} else {
$css_class = $itemcount%2 ? ' class="LC_odd_row"' : '';
my ($currdefresponder,%defcredits,%curruploadquota,%deftimeout);
@@ -10297,7 +10370,42 @@
}
}
}
-
+ my $currclone = $domconfig{'coursedefaults'}{'canclone'};
+ my @currclonecode;
+ if (ref($currclone) eq 'HASH') {
+ if (ref($currclone->{'instcode'}) eq 'ARRAY') {
+ @currclonecode = @{$currclone->{'instcode'}};
+ }
+ }
+ my $newclone;
+ if ($env{'form.canclone'} =~ /^(none|domain|instcode)$/) {
+ $newclone = $env{'form.canclone'};
+ }
+ if ($newclone eq 'instcode') {
+ my @newcodes = &Apache::loncommon::get_env_multiple('form.clonecode');
+ my (%codedefaults, at code_order, at clonecode);
+ &Apache::lonnet::auto_instcode_defaults($dom,\%codedefaults,
+ \@code_order);
+ foreach my $item (@code_order) {
+ if (grep(/^\Q$item\E$/, at newcodes)) {
+ push(@clonecode,$item);
+ }
+ }
+ if (@clonecode) {
+ $defaultshash{'coursedefaults'}{'canclone'} = { $newclone => \@clonecode };
+ my @diffs = &Apache::loncommon::compare_arrays(\@currclonecode,\@clonecode);
+ if (@diffs) {
+ $changes{'canclone'} = 1;
+ }
+ } else {
+ $newclone eq '';
+ }
+ } elsif ($newclone ne '') {
+ $defaultshash{'coursedefaults'}{'canclone'} = $newclone;
+ }
+ if ($newclone ne $currclone) {
+ $changes{'canclone'} = 1;
+ }
my %credits;
foreach my $type (@types) {
unless ($type eq 'community') {
@@ -10381,7 +10489,8 @@
if (keys(%changes) > 0) {
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
if (($changes{'uploadquota'}) || ($changes{'postsubmit'}) ||
- ($changes{'coursecredits'}) || ($changes{'uselcmath'}) || ($changes{'usejsme'})) {
+ ($changes{'coursecredits'}) || ($changes{'uselcmath'}) || ($changes{'usejsme'}) ||
+ ($changes{'canclone'})) {
foreach my $item ('uselcmath','usejsme') {
if ($changes{$item}) {
$domdefaults{$item}=$defaultshash{'coursedefaults'}{$item};
@@ -10413,6 +10522,18 @@
}
}
}
+ if ($changes{'canclone'}) {
+ if (ref($defaultshash{'coursedefaults'}{'canclone'}) eq 'HASH') {
+ if (ref($defaultshash{'coursedefaults'}{'canclone'}{'instcode'}) eq 'ARRAY') {
+ my @clonecodes = @{$defaultshash{'coursedefaults'}{'canclone'}{'instcode'}};
+ if (@clonecodes) {
+ $domdefaults{'canclone'} = join('+', at clonecodes);
+ }
+ }
+ } else {
+ $domdefaults{'canclone'}=$defaultshash{'coursedefaults'}{'canclone'};
+ }
+ }
my $cachetime = 24*60*60;
&Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime);
if (ref($lastactref) eq 'HASH') {
@@ -10501,6 +10622,17 @@
} else {
$resulttext .= '<li>'.&mt('Student credits not in use for courses in this domain').'</li>';
}
+ } elsif ($item eq 'canclone') {
+ if (ref($defaultshash{'coursedefaults'}{'canclone'}) eq 'HASH') {
+ if (ref($defaultshash{'coursedefaults'}{'canclone'}{'instcode'}) eq 'ARRAY') {
+ my $clonecodes = join(' '.&mt('and').' ',@{$defaultshash{'coursedefaults'}{'canclone'}{'instcode'}});
+ $resulttext .= '<li>'.&mt('By default, official courses can be cloned from existing courses with the same: [_1]','<b>'.$clonecodes.'</b>').'</li>';
+ }
+ } elsif ($defaultshash{'coursedefaults'}{'canclone'} eq 'domain') {
+ $resulttext .= '<li>'.&mt('By default, a course requester can clone any course from his/her domain.').'</li>';
+ } else {
+ $resulttext .= '<li>'.&mt('By default, only course owner and coordinators may clone a course.').'</li>';
+ }
}
}
$resulttext .= '</ul>';
@@ -12010,12 +12142,18 @@
if (document.getElementById(caller)) {
var divitem = document.getElementById(caller);
var optionsElement = domForm.coursecredits;
+ var checkval = 1;
+ var dispval = 'block';
if (caller == 'emailoptions') {
optionsElement = domForm.cancreate_email;
}
if (caller == 'studentsubmission') {
optionsElement = domForm.postsubmit;
}
+ if (caller == 'cloneinstcode') {
+ optionsElement = domForm.canclone;
+ checkval = 'instcode';
+ }
if (optionsElement.length) {
var currval;
for (var i=0; i<optionsElement.length; i++) {
@@ -12023,8 +12161,8 @@
currval = optionsElement[i].value;
}
}
- if (currval == 1) {
- divitem.style.display = 'block';
+ if (currval == checkval) {
+ divitem.style.display = dispval;
} else {
divitem.style.display = 'none';
}
More information about the LON-CAPA-cvs
mailing list