[LON-CAPA-cvs] cvs: loncom /interface domainprefs.pm
raeburn
raeburn at source.lon-capa.org
Thu May 21 18:59:17 EDT 2015
raeburn Thu May 21 22:59:17 2015 EDT
Modified files:
/loncom/interface domainprefs.pm
Log:
- Course default (applies to all courses), which can be overridden
by course settings in a specific course, for who, besides owner
and coordinator(s) may clone a course.
options - none, any requester in domain, or, for official courses,
where localenroll::instcode_defaults() has been customized, categories
which must match in cloner and cloned (e.g., department and number).
-------------- next part --------------
Index: loncom/interface/domainprefs.pm
diff -u loncom/interface/domainprefs.pm:1.263 loncom/interface/domainprefs.pm:1.264
--- loncom/interface/domainprefs.pm:1.263 Mon May 11 18:11:42 2015
+++ loncom/interface/domainprefs.pm Thu May 21 22:59:16 2015
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set domain-wide configuration settings
#
-# $Id: domainprefs.pm,v 1.263 2015/05/11 18:11:42 raeburn Exp $
+# $Id: domainprefs.pm,v 1.264 2015/05/21 22:59:16 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2910,6 +2910,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,
@@ -2921,10 +2922,82 @@
'canuse_pdfforms' => 'off',
'uselcmath' => 'on',
'usejsme' => 'on',
+ 'canclone' => 'none',
);
@toggles = ('canuse_pdfforms','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);
@@ -10317,7 +10390,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') {
@@ -10401,7 +10509,8 @@
if (keys(%changes) > 0) {
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1);
if (($changes{'canuse_pdfforms'}) || ($changes{'uploadquota'}) || ($changes{'postsubmit'}) ||
- ($changes{'coursecredits'}) || ($changes{'uselcmath'}) || ($changes{'usejsme'})) {
+ ($changes{'coursecredits'}) || ($changes{'uselcmath'}) || ($changes{'usejsme'}) ||
+ ($changes{'canclone'})) {
foreach my $item ('canuse_pdfforms','uselcmath','usejsme') {
if ($changes{$item}) {
$domdefaults{$item}=$defaultshash{'coursedefaults'}{$item};
@@ -10433,6 +10542,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') {
@@ -10527,6 +10648,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>';
@@ -12036,12 +12168,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++) {
@@ -12049,8 +12187,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