--- loncom/interface/courseprefs.pm 2014/06/13 01:48:26 1.67
+++ loncom/interface/courseprefs.pm 2015/04/28 13:20:41 1.70
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to set configuration settings for a course
#
-# $Id: courseprefs.pm,v 1.67 2014/06/13 01:48:26 raeburn Exp $
+# $Id: courseprefs.pm,v 1.70 2015/04/28 13:20:41 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -463,13 +463,15 @@ sub handler {
help => 'Course_Prefs_Display',
ordered => ['default_xml_style','pageseparators',
'disable_receipt_display','texengine',
- 'tthoptions'],
+ 'tthoptions','uselcmath','usejsme'],
itemtext => {
default_xml_style => 'Default XML style file',
pageseparators => 'Visibly Separate Items on Pages',
disable_receipt_display => 'Disable display of problem receipts',
texengine => 'Force use of a specific math rendering engine',
tthoptions => 'Default set of options to pass to tth/m when converting TeX',
+ uselcmath => 'Student formula entry uses inline preview, not DragMath pop-up',
+ usejsme => 'Molecule editor uses JSME (HTML5) in place of JME (Java)',
},
},
'grading' =>
@@ -1405,7 +1407,7 @@ sub store_changes {
$displayval = &Apache::lonlocal::locallocaltime($displayval);
} elsif ($key eq 'categories') {
$displayval = $env{'form.categories_display'};
- } elsif ($key eq 'canuse_pdfforms') {
+ } elsif (($key eq 'canuse_pdfforms') || ($key eq 'usejsme') || ($key eq 'uselcmath')) {
if ($changes->{$item}{$key} eq '1') {
$displayval = &mt('Yes');
} elsif ($changes->{$item}{$key} eq '0') {
@@ -2323,109 +2325,128 @@ sub display_loncaparev_constraints {
my $resourcedata = &Apache::lonparmset::readdata($cnum,$cdom);
if (ref($resourcedata) eq 'HASH') {
foreach my $key (keys(%{$resourcedata})) {
+ my %found;
foreach my $item (keys(%Apache::lonrelrequtils::checkparms)) {
if ($key =~ /(\Q$item\E)$/) {
- if (ref($Apache::lonrelrequtils::checkparms{$item}) eq 'ARRAY') {
- my $value = $resourcedata->{$key};
- if ($item eq 'examcode') {
- if (&Apache::lonnet::validCODE($value)) {
- $value = 'valid';
- } else {
- $value = '';
- }
- } elsif ($item eq 'printstartdate') {
+ if (ref($Apache::lonrelrequtils::checkparms{$item}) eq 'ARRAY') {
+ my $value = $resourcedata->{$key};
+ if ($item eq 'examcode') {
+ if (&Apache::lonnet::validCODE($value)) {
+ $value = 'valid';
+ } else {
+ $value = '';
+ }
+ } elsif ($item eq 'printstartdate') {
if ($value =~ /^\d+$/) {
- if ($value > $now) {
- $value = 'future';
- }
- }
- } elsif ($item eq 'printenddate') {
- if ($value =~ /^\d+$/) {
- if ($value < $now) {
- $value = 'past';
- }
- }
- }
- my ($middle,$scope,$which,$level,$map,$resource);
- if (grep(/^\Q$value\E$/,@{$Apache::lonrelrequtils::checkparms{$item}})) {
- my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
- my $stdname = &Apache::lonparmset::standard_parameter_names($item);
- my $valname = &get_param_description($stdtype,$value);
- my $rev = $Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value};
- my $start = $cid.'.';
- if ($key =~ /^\Q$start\E(\[useropt\:($match_username\:$match_domain)\]\.)/) {
- $middle = $1;
- $which = $2;
- $scope = 'user';
- } elsif ($key =~ /^\Q$start\E(\[(\w+)\]\.)/) {
- $middle = $1;
- $which = $2;
- $scope = 'section/group';
- } else {
- $scope = 'all';
- }
- my $what="$stdname=$valname";
- if ($key =~ /^\Q$start$middle\E\w+\.\Q$item\E$/) {
- $level = 'general';
- if ($scope eq 'all') {
- if (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
- unless(grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}})) {
- push(@{$fromparam{$rev}{$scope}},$what);
- }
- } else {
- push(@{$fromparam{$rev}{$scope}},$what);
- }
- } else {
- if (ref($fromparam{$rev}{$scope}{$which}) eq 'ARRAY') {
- unless (grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}{$which}})) {
- push(@{$fromparam{$rev}{$scope}{$which}},$what);
- }
- } else {
- push(@{$fromparam{$rev}{$scope}{$which}},$what);
- }
- }
- $rowspan{$rev} ++;
- } elsif ($key =~ /^\Q$start$middle\E(.+)___\(all\).\w+\.\Q$item\E$/) {
- $level = 'folder';
- $map = $1;
- if ($scope eq 'all') {
- if (ref($bymap{$map}{$rev}{$scope}) eq 'ARRAY') {
- unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}})) {
- push(@{$bymap{$map}{$rev}{$scope}},$what);
- }
- } else {
- push(@{$bymap{$map}{$rev}{$scope}},$what);
- }
- } else {
- if (ref($bymap{$map}{$rev}{$scope}{$which}) eq 'ARRAY') {
- unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}{$which}})) {
- push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
- }
- } else {
- push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
- }
- }
- } elsif ($key =~ /^\Q$start$middle\E(.+)\.\w+\.\Q$item\E$/) {
- $level = 'resource';
- $resource = $1;
- if ($scope eq 'all') {
- if (ref($byresource{$resource}{$rev}{$scope}) eq 'ARRAY') {
- unless(grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}})) {
- push(@{$byresource{$resource}{$rev}{$scope}},$what);
- }
- } else {
- push(@{$byresource{$resource}{$rev}{$scope}},$what);
- }
- } else {
- if (ref($byresource{$resource}{$rev}{$scope}{$which}) eq 'ARRAY') {
- unless (grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}{$which}})) {
- push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
- }
- } else {
- push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
- }
- }
- }
+ if ($value > $now) {
+ $value = 'future';
+ }
+ }
+ } elsif ($item eq 'printenddate') {
+ if ($value =~ /^\d+$/) {
+ if ($value < $now) {
+ $value = 'past';
+ }
+ }
+ }
+ if (grep(/^\Q$value\E$/,@{$Apache::lonrelrequtils::checkparms{$item}})) {
+ my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
+ $found{$item}{'valname'} = &get_param_description($stdtype,$value);
+ $found{$item}{'rev'} = $Apache::lonnet::needsrelease{'parameter:'.$item.':'.$value.':'};
+ }
+ }
+ }
+ }
+ foreach my $item (keys(%Apache::lonrelrequtils::checkparmsmatch)) {
+ if (ref($Apache::lonrelrequtils::checkparmsmatch{$item}) eq 'ARRAY') {
+ my $value = $resourcedata->{$key};
+ foreach my $valuematch (@{$Apache::lonrelrequtils::checkparmsmatch{$item}}) {
+ if ($value =~ /$valuematch/) {
+ my $stdtype = &Apache::lonparmset::standard_parameter_types($item);
+ $found{$item}{'valname'} = &get_param_description($stdtype,$value,1);
+ $found{$item}{'rev'} =
+ $Apache::lonnet::needsrelease{'parameter:'.$item.'::'.$valuematch};
+ last;
+ }
+ }
+ }
+ }
+ foreach my $item (keys(%found)) {
+ my $stdname = &Apache::lonparmset::standard_parameter_names($item);
+ my $rev = $found{$item}{'rev'};
+ my $valname = $found{$item}{'valname'};
+ my ($middle,$scope,$which,$level,$map,$resource);
+ my $start = $cid.'.';
+ if ($key =~ /^\Q$start\E(\[useropt\:($match_username\:$match_domain)\]\.)/) {
+ $middle = $1;
+ $which = $2;
+ $scope = 'user';
+ } elsif ($key =~ /^\Q$start\E(\[(\w+)\]\.)/) {
+ $middle = $1;
+ $which = $2;
+ $scope = 'section/group';
+ } else {
+ $scope = 'all';
+ }
+ my $what="$stdname=$valname";
+ if ($key =~ /^\Q$start$middle\E\w+\.\Q$item\E$/) {
+ $level = 'general';
+ if ($scope eq 'all') {
+ if (ref($fromparam{$rev}{$scope}) eq 'ARRAY') {
+ unless(grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}})) {
+ push(@{$fromparam{$rev}{$scope}},$what);
+ }
+ } else {
+ push(@{$fromparam{$rev}{$scope}},$what);
+ }
+ } else {
+ if (ref($fromparam{$rev}{$scope}{$which}) eq 'ARRAY') {
+ unless (grep(/^\Q$what\E$/,@{$fromparam{$rev}{$scope}{$which}})) {
+ push(@{$fromparam{$rev}{$scope}{$which}},$what);
+ }
+ } else {
+ push(@{$fromparam{$rev}{$scope}{$which}},$what);
+ }
+ }
+ $rowspan{$rev} ++;
+ } elsif ($key =~ /^\Q$start$middle\E(.+)___\(all\).\w+\.\Q$item\E$/) {
+ $level = 'folder';
+ $map = $1;
+ if ($scope eq 'all') {
+ if (ref($bymap{$map}{$rev}{$scope}) eq 'ARRAY') {
+ unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}})) {
+ push(@{$bymap{$map}{$rev}{$scope}},$what);
+ }
+ } else {
+ push(@{$bymap{$map}{$rev}{$scope}},$what);
+ }
+ } else {
+ if (ref($bymap{$map}{$rev}{$scope}{$which}) eq 'ARRAY') {
+ unless(grep(/^\Q$what\E$/,@{$bymap{$map}{$rev}{$scope}{$which}})) {
+ push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
+ }
+ } else {
+ push(@{$bymap{$map}{$rev}{$scope}{$which}},$what);
+ }
+ }
+ } elsif ($key =~ /^\Q$start$middle\E(.+)\.\w+\.\Q$item\E$/) {
+ $level = 'resource';
+ $resource = $1;
+ if ($scope eq 'all') {
+ if (ref($byresource{$resource}{$rev}{$scope}) eq 'ARRAY') {
+ unless(grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}})) {
+ push(@{$byresource{$resource}{$rev}{$scope}},$what);
+ }
+ } else {
+ push(@{$byresource{$resource}{$rev}{$scope}},$what);
+ }
+ } else {
+ if (ref($byresource{$resource}{$rev}{$scope}{$which}) eq 'ARRAY') {
+ unless (grep(/^\Q$what\E$/,@{$byresource{$resource}{$rev}{$scope}{$which}})) {
+ push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
+ }
+ } else {
+ push(@{$byresource{$resource}{$rev}{$scope}{$which}},$what);
}
}
}
@@ -2624,9 +2645,9 @@ sub display_loncaparev_constraints {
}
foreach my $map (keys(%allmaps)) {
my $mapres = $navmap->getResourceByUrl($map);
- my $mapsymb = $mapres->symb();
- $toshow{$mapsymb} = 1;
if (ref($mapres)) {
+ my $mapsymb = $mapres->symb();
+ $toshow{$mapsymb} = 1;
my $pcslist = $mapres->map_hierarchy();
if ($pcslist ne '') {
foreach my $pc (split(/,/,$pcslist)) {
@@ -2849,18 +2870,52 @@ sub releases_by_map {
}
sub get_param_description {
- my ($stdtype,$value) = @_;
- my $name = $value;
- my $paramstrings = &Apache::lonparmset::standard_string_options($stdtype);
- unless (ref($paramstrings) eq 'ARRAY') {
- return $name;
+ my ($stdtype,$value,$regexp) = @_;
+ my ($name,$parammatches,$paramstrings,@possibles);
+ $paramstrings = &Apache::lonparmset::standard_string_options($stdtype);
+ if ($regexp) {
+ $parammatches = &Apache::lonparmset::standard_string_matches($stdtype);
+ if (ref($parammatches) eq 'ARRAY') {
+ @possibles = @{$parammatches};
+ } else {
+ undef($regexp);
+ $name = $value;
+ }
+ }
+ unless ($regexp) {
+ $name = $value;
+ if (ref($paramstrings) eq 'ARRAY') {
+ @possibles = @{$paramstrings};
+ } else {
+ return $name;
+ }
}
- foreach my $possibilities (@{$paramstrings}) {
+ foreach my $possibilities (@possibles) {
next unless (ref($possibilities) eq 'ARRAY');
- my ($thing, $description) = @{ $possibilities };
- if ($thing eq $value) {
- $name = $description;
- last;
+ my $gotregexmatch = '';
+ if ($regexp) {
+ last if ($gotregexmatch);
+ my ($item,$pattern) = @{ $possibilities };
+ if ($value =~ /$pattern/) {
+ if (ref($paramstrings) eq 'ARRAY') {
+ foreach my $possibles (@{$paramstrings}) {
+ next unless (ref($possibles) eq 'ARRAY');
+ my ($thing,$description) = @{$possibles};
+ if ($thing eq $item) {
+ $name = $description;
+ $gotregexmatch = 1;
+ last;
+ }
+ }
+ last if ($gotregexmatch);
+ }
+ }
+ } else {
+ my ($thing,$description) = @{ $possibilities };
+ if ($thing eq $value) {
+ $name = $description;
+ last;
+ }
}
}
return $name;
@@ -3697,6 +3752,14 @@ sub print_appearance {
input => 'textbox',
size => 40,
},
+ 'uselcmath' => {
+ text => ''.&mt($itemtext->{'uselcmath'}).'',
+ input => 'radio',
+ },
+ 'usejsme' => {
+ text => ''.&mt($itemtext->{'usejsme'}).'',
+ input => 'radio',
+ },
);
return &make_item_rows($cdom,\%items,$ordered,$settings,$rowtotal,$crstype,'appearance');
}
@@ -3959,20 +4022,30 @@ sub item_table_row_end {
}
sub yesno_radio {
- my ($item,$settings) = @_;
+ my ($item,$settings,$unsetdefault,$valueyes,$valueno) = @_;
my $itemon = ' ';
my $itemoff = ' checked="checked" ';
+ if (($valueyes eq '') && ($valueno eq '')) {
+ $valueyes = 'yes';
+ $valueno = '';
+ }
if (ref($settings) eq 'HASH') {
- if ($settings->{$item} eq 'yes') {
+ if ($settings->{$item} eq $valueyes) {
$itemon = $itemoff;
$itemoff = ' ';
}
+ unless (exists($settings->{$item})) {
+ if ($unsetdefault eq $valueyes) {
+ $itemon = $itemoff;
+ $itemoff = ' ';
+ }
+ }
}
return ' '.
+ $itemon.' value="'.$valueyes.'" />'.&mt('Yes').' '.
'';
+ $itemoff.' value="'.$valueno.'" />'.&mt('No').'';
}
sub select_from_options {
@@ -4057,7 +4130,16 @@ sub make_item_rows {
&Apache::lonhtmlcommon::date_setter('display',$item,
$settings->{$item});
} elsif ($items->{$item}{input} eq 'radio') {
- $datatable .= &yesno_radio($item,$settings);
+ my ($unsetdefault,$valueyes,$valueno);
+ if (($item eq 'usejsme') || ($item eq 'uselcmath')) {
+ my %domdefs = &Apache::lonnet::get_domain_defaults($cdom);
+ unless ($domdefs{$item} eq '0') {
+ $unsetdefault = 1;
+ }
+ $valueyes = "1";
+ $valueno = "0";
+ }
+ $datatable .= &yesno_radio($item,$settings,$unsetdefault,$valueyes,$valueno);
} elsif ($items->{$item}{input} eq 'selectbox') {
my $curr = $settings->{$item};
$datatable .=
@@ -4133,7 +4215,8 @@ sub nothidepriv_row {
' '.
- ''.
+ ''.
'';
}
$datatable .= '';