diff --git a/Dockerfile b/Dockerfile index 8a1610744a..6f413e5280 100644 --- a/Dockerfile +++ b/Dockerfile @@ -85,7 +85,7 @@ RUN mkdir -p $APP_ROOT/courses $APP_ROOT/libraries $APP_ROOT/webwork2 # Block to include webwork2 in the container, when needed, instead of getting it from a bind mount. # Uncomment when needed, and set the correct branch name on the following line. -#ENV WEBWORK_BRANCH=master # need a valid branch name from https://github.com/openwebwork/webwork2 +#ENV WEBWORK_BRANCH=develop # need a valid branch name from https://github.com/openwebwork/webwork2 #RUN curl -fSL https://github.com/openwebwork/webwork2/archive/${WEBWORK_BRANCH}.tar.gz -o /tmp/${WEBWORK_BRANCH}.tar.gz \ # && cd /tmp \ # && tar xzf /tmp/${WEBWORK_BRANCH}.tar.gz \ diff --git a/PG_VERSION b/PG_VERSION index c2a29f7f1a..9ac8801102 100644 --- a/PG_VERSION +++ b/PG_VERSION @@ -1,4 +1,4 @@ -$PG_VERSION ='PG-2.14'; +$PG_VERSION ='develop'; $PG_COPYRIGHT_YEARS = '1996-2019'; 1; diff --git a/README b/README index ca428fb85d..0777afbc52 100644 --- a/README +++ b/README @@ -3,8 +3,8 @@ Version 2.* Branch: github.com/openwebwork - http://webwork.maa.org/wiki/Release_notes_for_WeBWorK_2.13 - Copyright 2000-2017, The WeBWorK Project + http://webwork.maa.org/wiki/Release_notes_for_WeBWorK_2.14 + Copyright 2000-2019, The WeBWorK Project http://webwork.maa.org All rights reserved. diff --git a/VERSION b/VERSION index 7fa863cf31..81710a9d6b 100644 --- a/VERSION +++ b/VERSION @@ -1,5 +1,5 @@ -$WW_VERSION = 'WeBWorK-2.14'; +$WW_VERSION = 'develop'; $WW_COPYRIGHT_YEARS = '1996-2019'; 1; diff --git a/bin/OPL-update b/bin/OPL-update index 72382f38cd..95e2206442 100755 --- a/bin/OPL-update +++ b/bin/OPL-update @@ -21,7 +21,6 @@ use File::Basename; use Cwd; use DBI; - #(maximum varchar length is 255 for mysql version < 5.0.3. #You can increase path length to 4096 for mysql > 5.0.3) @@ -93,9 +92,12 @@ my $dbh = DBI->connect( { PrintError => 0, RaiseError => 1, + mysql_enable_utf8 => 1, }, ); +$dbh->prepare("SET NAMES 'utf8'")->execute(); + my $libraryRoot = $ce->{problemLibrary}->{root}; $libraryRoot =~ s|/+$||; my $libraryVersion = $ce->{problemLibrary}->{version}; @@ -346,7 +348,7 @@ my ($name,$pgfile,$pgpath); #### First read in textbook information -if(open(IN, "$libraryRoot/Textbooks")) { +if(open(IN, '<:encoding(UTF-8)', "$libraryRoot/Textbooks")) { print "Reading in textbook data from Textbooks in the library $libraryRoot.\n"; my %textinfo = ( TitleText => '', EditionText =>'', AuthorText=>''); my $bookid = undef; @@ -445,10 +447,10 @@ my $tagtaxo = []; my ($chaplist, $seclist) = ([],[]); my $canopenfile = 0; -if(open(IN, "$libraryRoot/Taxonomy2")) { +if(open(IN, '<:encoding(UTF-8)', "$libraryRoot/Taxonomy2")) { print "Reading in OPL taxonomy from Taxonomy2 in the library $libraryRoot.\n"; $canopenfile = 1; -} elsif(open(IN, "$libraryRoot/Taxonomy")) { +} elsif(open(IN, '<:encoding(UTF-8)', "$libraryRoot/Taxonomy")) { print "Reading in OPL taxonomy from Taxonomy in the library $libraryRoot.\n"; $canopenfile = 1; } else { @@ -516,6 +518,7 @@ if($canopenfile) { my $webwork_htdocs = $ce->{webwork_dir}."/htdocs"; my $file = "$webwork_htdocs/DATA/tagging-taxonomy.json"; open(OUTF, ">$file") or die "Cannot open $file"; +binmode(OUTF,':encoding(UTF-8)'); print OUTF to_json($tagtaxo,{pretty=>1}) or die "Cannot write to $file"; close(OUTF); print "Saved taxonomy to $file.\n"; diff --git a/bin/addcourse b/bin/addcourse index c360808c47..111d256be2 100755 --- a/bin/addcourse +++ b/bin/addcourse @@ -1,8 +1,7 @@ #!/usr/bin/env perl ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ -# $CVSHeader: webwork2/bin/addcourse,v 1.20 2006/12/09 03:29:56 sh002i Exp $ +# Copyright © 2000-2018 The WeBWorK Project, https://github.com/openwebwork # # This program is free software; you can redistribute it and/or modify it under # the terms of either: (a) the GNU General Public License as published by the diff --git a/bin/check_latex.tex b/bin/check_latex.tex index b75cb28180..0238df7a53 100644 --- a/bin/check_latex.tex +++ b/bin/check_latex.tex @@ -1,6 +1,6 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % WeBWorK Online Homework Delivery System -% Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +% Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ % $CVSHeader: webwork2/bin/check_latex.tex,v 1.2 2004/10/06 21:09:33 gage Exp $ % % This program is free software; you can redistribute it and/or modify it under diff --git a/bin/delcourse b/bin/delcourse index eb49d0c2c3..3c6e432066 100755 --- a/bin/delcourse +++ b/bin/delcourse @@ -1,7 +1,7 @@ #!/usr/bin/env perl ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/bin/delcourse,v 1.4 2006/01/25 23:13:45 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/bin/dump_past_answers b/bin/dump_past_answers index 6b45ae45a5..ace64481ee 100755 --- a/bin/dump_past_answers +++ b/bin/dump_past_answers @@ -2,7 +2,7 @@ ############################################################################## # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/bin/wwdb,v 1.13 2006/01/25 23:13:45 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/bin/fix_copyright.sh b/bin/fix_copyright.sh new file mode 100755 index 0000000000..a44a16034e --- /dev/null +++ b/bin/fix_copyright.sh @@ -0,0 +1,14 @@ +#!/bin/sh +sed -i .bak '/Copyright/c\ +# Copyright © 2000-2019. The WeBWorK Project. https://github.com/openwebwork/webwork2\ +' $1 + + + +#obtained by trial and error after much toil -- mostly error. +# this version works on a mac +# the space after -i might need to be removed for linux. +# produces $1.bak file + +# use with the find command: +# find . -name course.conf -exec /opt/webwork/webwork2/bin/fix_copyright.sh {} ';' \ No newline at end of file diff --git a/bin/integrity_check.pl b/bin/integrity_check.pl index 69bf341075..523e513029 100644 --- a/bin/integrity_check.pl +++ b/bin/integrity_check.pl @@ -1,7 +1,7 @@ #!/usr/bin/env perl ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/bin/wwdb_upgrade,v 1.17 2007/08/13 22:59:50 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/bin/newpassword b/bin/newpassword index 60c40818db..358a54262b 100755 --- a/bin/newpassword +++ b/bin/newpassword @@ -1,7 +1,7 @@ #!/usr/bin/env perl ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/bin/newpassword,v 1.3 2006/01/25 23:13:45 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/bin/old_scripts/timing b/bin/old_scripts/timing index b44e004f55..64db42617f 100755 --- a/bin/old_scripts/timing +++ b/bin/old_scripts/timing @@ -1,7 +1,7 @@ #!/usr/bin/env perl ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/bin/timing,v 1.5 2006/01/25 23:13:45 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/bin/old_scripts/wwaddindexing b/bin/old_scripts/wwaddindexing index a258d7edfa..7dfa7418a8 100755 --- a/bin/old_scripts/wwaddindexing +++ b/bin/old_scripts/wwaddindexing @@ -1,7 +1,7 @@ #!/usr/bin/env perl ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/bin/wwaddindexing,v 1.3 2006/01/25 23:13:45 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/bin/old_scripts/wwdb_addgw b/bin/old_scripts/wwdb_addgw index 939bbf7c94..3ca4c12c1e 100755 --- a/bin/old_scripts/wwdb_addgw +++ b/bin/old_scripts/wwdb_addgw @@ -1,7 +1,7 @@ #!/usr/bin/perl -w ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/bin/wwdb_addgw,v 1.3 2006/01/25 23:13:45 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/bin/old_scripts/wwdb_check b/bin/old_scripts/wwdb_check index a624523058..2b4e00207a 100755 --- a/bin/old_scripts/wwdb_check +++ b/bin/old_scripts/wwdb_check @@ -1,7 +1,7 @@ #!/usr/bin/env perl ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/bin/wwdb_check,v 1.7 2006/08/14 17:23:56 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/bin/old_scripts/wwdb_upgrade b/bin/old_scripts/wwdb_upgrade index 9a4b6ac859..208f33239b 100755 --- a/bin/old_scripts/wwdb_upgrade +++ b/bin/old_scripts/wwdb_upgrade @@ -1,7 +1,7 @@ #!/usr/bin/env perl ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/bin/wwdb_upgrade,v 1.16 2007/07/22 05:24:20 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/bin/pg-append-textbook-tags b/bin/pg-append-textbook-tags index 009ab087c9..4275f831b0 100755 --- a/bin/pg-append-textbook-tags +++ b/bin/pg-append-textbook-tags @@ -1,7 +1,7 @@ #!/usr/bin/env perl ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/bin/pg-append-textbook-tags,v 1.1 2007/10/17 16:56:16 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/bin/pg-find-tags b/bin/pg-find-tags index 1cd81486bc..3136a0f9d2 100755 --- a/bin/pg-find-tags +++ b/bin/pg-find-tags @@ -1,7 +1,7 @@ #!/usr/bin/env perl ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/bin/pg-find-tags,v 1.1 2007/10/17 16:56:16 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/bin/pg-pull b/bin/pg-pull index 143d3a3fe2..c54208b467 100755 --- a/bin/pg-pull +++ b/bin/pg-pull @@ -1,7 +1,7 @@ #!/usr/bin/env perl ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/bin/pg-pull,v 1.3 2007/10/22 20:32:38 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/bin/remove_stale_images b/bin/remove_stale_images index bb2aac50f5..f0780a0350 100755 --- a/bin/remove_stale_images +++ b/bin/remove_stale_images @@ -1,7 +1,7 @@ #!/usr/bin/env perl ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/bin/remove_stale_images,v 1.7 2008/06/24 22:54:03 gage Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/bin/setfilepermissions b/bin/setfilepermissions index eb9ab9e03c..09ab0e5595 100755 --- a/bin/setfilepermissions +++ b/bin/setfilepermissions @@ -1,7 +1,7 @@ #!/usr/bin/env perl ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/bin/newpassword,v 1.3 2006/01/25 23:13:45 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/bin/update-OPL-statistics b/bin/update-OPL-statistics index 528b165f1c..6e59e2a2bc 100755 --- a/bin/update-OPL-statistics +++ b/bin/update-OPL-statistics @@ -2,7 +2,7 @@ ############################################################################## # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/bin/wwdb,v 1.13 2006/01/25 23:13:45 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/bin/upgrade_admin_db.pl b/bin/upgrade_admin_db.pl index 21b45ee6ed..73cc8166d7 100755 --- a/bin/upgrade_admin_db.pl +++ b/bin/upgrade_admin_db.pl @@ -2,7 +2,7 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/bin/wwdb,v 1.13 2006/01/25 23:13:45 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/bin/upload-OPL-statistics b/bin/upload-OPL-statistics index 6f26e85ea9..49a354358c 100755 --- a/bin/upload-OPL-statistics +++ b/bin/upload-OPL-statistics @@ -2,7 +2,7 @@ ############################################################################## # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/bin/wwdb,v 1.13 2006/01/25 23:13:45 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/bin/wwapache2ctl.dist b/bin/wwapache2ctl.dist index 4b263b25f0..4a3e310b7e 100755 --- a/bin/wwapache2ctl.dist +++ b/bin/wwapache2ctl.dist @@ -1,7 +1,7 @@ #!/bin/sh ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/bin/wwapache2ctl.dist,v 1.3 2007/08/13 22:59:50 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/bin/wwapachectl.dist b/bin/wwapachectl.dist index 3a6b8a6cc6..83363e82d8 100755 --- a/bin/wwapachectl.dist +++ b/bin/wwapachectl.dist @@ -1,7 +1,7 @@ #!/bin/sh ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/bin/wwapachectl.dist,v 1.17 2006/05/31 18:25:18 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/bin/wwdb b/bin/wwdb index 834fadf86d..44aa435c00 100755 --- a/bin/wwdb +++ b/bin/wwdb @@ -1,7 +1,7 @@ #!/usr/bin/perl ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/bin/wwdb,v 1.13 2006/01/25 23:13:45 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/bin/wwsh b/bin/wwsh index 75c3ecfd7f..9219fec6b9 100755 --- a/bin/wwsh +++ b/bin/wwsh @@ -1,7 +1,7 @@ #!/usr/bin/perl ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/bin/wwsh,v 1.10 2006/05/31 01:07:25 gage Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/clients/sendXMLRPC.pl b/clients/sendXMLRPC.pl index 68b6a8573a..6e8f355cac 100755 --- a/clients/sendXMLRPC.pl +++ b/clients/sendXMLRPC.pl @@ -269,6 +269,7 @@ BEGIN } $ENV{MOD_PERL_API_VERSION} = 2; use lib "$main::dirname"; +print "home directory ".$main::dirname; #use lib "."; # is this needed? # some files such as FormatRenderedProblem.pm may need to be in the same directory @@ -290,7 +291,7 @@ BEGIN } } - +use lib "$WeBWorK::Constants::WEBWORK_DIRECTORY/lib"; use Carp; diff --git a/conf/database.conf.dist b/conf/database.conf.dist index e6458f3920..0da6b717cf 100644 --- a/conf/database.conf.dist +++ b/conf/database.conf.dist @@ -1,7 +1,7 @@ #!perl ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/conf/database.conf.dist,v 1.38 2007/08/13 22:59:51 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/conf/defaults.config b/conf/defaults.config index 7773cb771a..ae54771b43 100644 --- a/conf/defaults.config +++ b/conf/defaults.config @@ -1,7 +1,7 @@ #!perl ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright � 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/conf/defaults.config,v 1.225 2010/05/18 18:03:31 apizer Exp $ # # This program is free software; you can redistribute it and/or modify it under @@ -223,6 +223,14 @@ $pg{options}{periodicRandomizationPeriod} = 5; $language = "en"; # tr = turkish, en=english +# $perProblemLangAndDirSettingMode controls how and whether LANG and/or DIR +# attributes are added to the DIV element enveloping a problem +# which helps handle proper display of problems with a text direction +# different from that used course-wide. Ex: enables English problems to +# be displayed properly in a Hebrew course site, which helps select problems +# to be translated to Hebrew. +$perProblemLangAndDirSettingMode = "force::ltr"; + ################################################################################ # System-wide locations (directories and URLs) ################################################################################ @@ -1211,6 +1219,8 @@ $pg{specialPGEnvironmentVars}{problemPostamble} = { TeX => '', HTML=>'' }; # should appear as [qw(Mymodule.pm, Dependency1.pm, Dependency2.pm)] ${pg}{modules} = [ + [qw(Encode)], + [qw(Encode::Encoding)], [qw(HTML::Parser)], [qw(HTML::Entities)], [qw(DynaLoader)], @@ -1439,6 +1449,12 @@ $ConfigValues = [ values => [qw(en tr es fr zh_hk heb)], type => 'popuplist' }, + { var => 'perProblemLangAndDirSettingMode', + doc => 'Mode in which the LANG and DIR settings for a single problem are determined.', + doc2 => 'Mode in which the LANG and DIR settings for a single problem are determined.
The system will set the LANGuage attribute to either a value determined from the problem, a course-wide default, or the system default of en-US, depending on the mode selected. The tag will only be added to the DIV enclosing the problem if it is different than the value which should be set in the main HTML tag set for the entire course based on the course language.
There are two options for the DIRection attribute: \"ltr\" for left-to-write sripts, and \"rtl\" for right-to-left scripts like Arabic and Hebrew.
The DIRection attribute is needed to trigger proper display of the question text when the problem text-direction is different than that used by the current language of the course. For example, English problems from the library browser would display improperly in RTL mode for a Hebrew course, unless the problen Direction is set to LTR.
The feature to set a problem language and direction was only added in 2018 to the PG language, so most problems will not declare their language, and the system needs to fall back to determining the language and direction in a different manner. The OPL itself is all English, so the system wide fallback is to en-US in LTR mode.
Since the defaults fall back to the LTR direction, most sites should be fine with the \"auto::\" mode, but may want to select the one which matches their course language. The mode \"force::ltr\" would also be an option for a course which runs into trouble with the \"auto\" modes.
Modes:
This value should be entered as a number, so as 3600 instead of 60*60 for one hour', diff --git a/conf/site.conf.dist b/conf/site.conf.dist index 3a3c273577..022e020076 100644 --- a/conf/site.conf.dist +++ b/conf/site.conf.dist @@ -1,7 +1,7 @@ #!perl ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/conf/site.conf.dist,v 1.225 2010/05/18 18:03:31 apizer Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/conf/snippets/hardcopyThemes/oneColumn/hardcopyPreamble.tex b/conf/snippets/hardcopyThemes/oneColumn/hardcopyPreamble.tex index 1cf495954b..95e98fe653 100644 --- a/conf/snippets/hardcopyThemes/oneColumn/hardcopyPreamble.tex +++ b/conf/snippets/hardcopyThemes/oneColumn/hardcopyPreamble.tex @@ -11,7 +11,13 @@ \usepackage{epsfig} \usepackage{pslatex} \usepackage{fullpage} + \usepackage[utf8]{inputenc} + +\usepackage{eurosym} % the euro symbol +\DeclareUnicodeCharacter{20AC}{\euro} % make it possible to use the UTF-8 character for the euro symbol in problems + + \pagestyle{plain} \def\endline{\bigskip\hrule width \hsize height 0.8pt } \newcommand{\lt}{<} diff --git a/conf/snippets/hardcopyThemes/twoColumn/hardcopyPreamble.tex b/conf/snippets/hardcopyThemes/twoColumn/hardcopyPreamble.tex index dd6522997a..8c57181151 100644 --- a/conf/snippets/hardcopyThemes/twoColumn/hardcopyPreamble.tex +++ b/conf/snippets/hardcopyThemes/twoColumn/hardcopyPreamble.tex @@ -10,7 +10,12 @@ \usepackage{epsf} \usepackage{epsfig} \usepackage{pslatex} + \usepackage[utf8]{inputenc} + +\usepackage{eurosym} % the euro symbol +\DeclareUnicodeCharacter{20AC}{\euro} % make it possible to use the UTF-8 character for the euro symbol in problems + \pagestyle{plain} \textheight 9in \oddsidemargin = -0.42in diff --git a/courses.dist/modelCourse/course.conf b/courses.dist/modelCourse/course.conf index 43d5e40ab2..a41321518d 100644 --- a/courses.dist/modelCourse/course.conf +++ b/courses.dist/modelCourse/course.conf @@ -1,7 +1,7 @@ #!perl ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2016 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # # This program is free software; you can redistribute it and/or modify it under # the terms of either: (a) the GNU General Public License as published by the diff --git a/htdocs/helpFiles/Grades.html b/htdocs/helpFiles/Grades.html index 4560895fd9..9108e1182f 100644 --- a/htdocs/helpFiles/Grades.html +++ b/htdocs/helpFiles/Grades.html @@ -2,7 +2,7 @@
+Warning -- there may be something wrong with this question. Please inform your instructor including the warning messages below.
-Warning -- there may be something wrong with this question. Please inform your instructor including the warning messages below.
-The system will set the LANGuage attribute to either a value determined from the problem, a course-wide default, or the system default of en-US, depending on the mode selected. The tag will only be added to the DIV enclosing the problem if it is different than the value which should be set in the main HTML tag set for the entire course based on the course language.
There are two options for the DIRection attribute: \"ltr\" for left-to-write sripts, and \"rtl\" for right-to-left scripts like Arabic and Hebrew.
The DIRection attribute is needed to trigger proper display of the question text when the problem text-direction is different than that used by the current language of the course. For example, English problems from the library browser would display improperly in RTL mode for a Hebrew course, unless the problen Direction is set to LTR.
The feature to set a problem language and direction was only added in 2018 to the PG language, so most problems will not declare their language, and the system needs to fall back to determining the language and direction in a different manner. The OPL itself is all English, so the system wide fallback is to en-US in LTR mode.
Since the defaults fall back to the LTR direction, most sites should be fine with the \"auto::\" mode, but may want to select the one which matches their course language. The mode \"force::ltr\" would also be an option for a course which runs into trouble with the \"auto\" modes.
Modes:
This value should be entered as a number, so as 3600 instead of 60*60 for one hour'), diff --git a/lib/WeBWorK/Localize/en.po b/lib/WeBWorK/Localize/en.po index 066e2e2773..281021e529 100644 --- a/lib/WeBWorK/Localize/en.po +++ b/lib/WeBWorK/Localize/en.po @@ -8733,7 +8733,8 @@ msgstr "" "any users answers using the form below and the answers will be colored " "according to correctness." -#: /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Instructor/UserList2.pm:467 +# +#: /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Instructor/UserList2.pm:464 msgid "_CLASSLIST_EDITOR_DESCRIPTION" msgstr "" "This is the classlist editor page, where you can view and edit the records " @@ -8753,6 +8754,7 @@ msgstr "" "%1 uses an external authentication system. You've authenticated through " "that system, but aren't allowed to log in to this course." +# #. (CGI::b($r->maketext("Guest Login") #: /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Login.pm:285 msgid "_GUEST_LOGIN_MESSAGE" @@ -8760,6 +8762,7 @@ msgstr "" "This course supports guest logins. Click %1 to log into this course as a " "guest." +# #: /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Instructor/ProblemSetList2.pm:528 msgid "_HMWKSETS_EDITOR_DESCRIPTION" msgstr "" @@ -8798,6 +8801,7 @@ msgstr "" "in the edit assigned users field contains links which take you to a page " "where you can edit what students the set is assigned to." +# #: /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator.pm:2094 msgid "_REQUEST_ERROR" msgstr "" @@ -8807,8 +8811,9 @@ msgstr "" "corrected. If you are a professor, please consult the error output below for " "more information." -#: /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Instructor/UserList2.pm:1871 -#: /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Instructor/UserList2.pm:1873 +# +#: /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Instructor/UserList2.pm:1868 +#: /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Instructor/UserList2.pm:1870 msgid "_USER_TABLE_SUMMARY" msgstr "" "A table showing all the current users along with several fields of user " diff --git a/lib/WeBWorK/Localize/en_us.po b/lib/WeBWorK/Localize/en_us.po index 066e2e2773..4deffc900a 100644 --- a/lib/WeBWorK/Localize/en_us.po +++ b/lib/WeBWorK/Localize/en_us.po @@ -8712,6 +8712,7 @@ msgid "[Edit]" msgstr "[Edit]" #: /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Instructor/AchievementList.pm:265 +#, fuzzy msgid "_ACHIEVEMENTS_EDITOR_DESCRIPTION" msgstr "" "This is the homework sets editor page where you can view and edit the " @@ -8737,8 +8738,8 @@ msgstr "" msgid "_CLASSLIST_EDITOR_DESCRIPTION" msgstr "" "This is the classlist editor page, where you can view and edit the records " -"of all the students currently enrolled in this course. The top of the page " -"contains forms which allow you to filter which students to view, sort your " +"of all the studentscurrently enrolled in this course. The top of the page " +"contains forms which allow you to filterwhich students to view, sort your " "students in a chosen order, edit student records, give new passwords to " "students, import/export student records from/to external files, or add/" "delete students. To use, please select the action you would like to perform, " @@ -8746,6 +8747,7 @@ msgstr "" "Action!\" button at the bottom of the form. The bottom of the page contains " "a table containing the student usernames and their information." +# #. (CGI::strong($r->maketext($course) #: /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Login.pm:199 msgid "_EXTERNAL_AUTH_MESSAGE" @@ -8787,42 +8789,22 @@ msgstr "" #: /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Instructor/ProblemSetList2.pm:2761 #: /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Instructor/ProblemSetList2.pm:2763 msgid "_PROBLEM_SET_SUMMARY" -msgstr "" -"This is a table showing the current Homework sets for this class. The " -"fields from left to right are: Edit Set Data, Edit Problems, Edit Assigned " -"Users, Visibility to students, Reduced Scoring Enabled, Date it was opened, " -"Date it is due, and the Date during which the answers are posted. The Edit " -"Set Data field contains checkboxes for selection and a link to the set data " -"editing page. The cells in the Edit Problems fields contain links which " -"take you to a page where you can edit the containing problems, and the cells " -"in the edit assigned users field contains links which take you to a page " -"where you can edit what students the set is assigned to." +msgstr "_PROBLEM_SET_SUMMARY" #: /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator.pm:2094 msgid "_REQUEST_ERROR" msgstr "" -"WeBWorK has encountered a software error while attempting to process this " -"problem. It is likely that there is an error in the problem itself. If you " -"are a student, report this error message to your professor to have it " +"WeBWorK has encountered a software error while attempting to process " +"thisproblem. It is likely that there is an error in the problem itself. If " +"you are a student, report this error message to your professor to have it " "corrected. If you are a professor, please consult the error output below for " "more information." + #: /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Instructor/UserList2.pm:1871 #: /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Instructor/UserList2.pm:1873 msgid "_USER_TABLE_SUMMARY" -msgstr "" -"A table showing all the current users along with several fields of user " -"information. The fields from left to right are: Login Name, Login Status, " -"Assigned Sets, First Name, Last Name, Email Address, Student ID, Enrollment " -"Status, Section, Recitation, Comments, and Permission Level. Clicking on " -"the links in the column headers will sort the table by the field it " -"corresponds to. The Login Name fields contain checkboxes for selecting the " -"user. Clicking the link of the name itself will allow you to act as the " -"selected user. There will also be an image link following the name which " -"will take you to a page where you can edit the selected user's information. " -"Clicking the emails will allow you to email the corresponding user. " -"Clicking the links in the entries in the assigned sets columns will take you " -"to a page where you can view and reassign the sets for the selected user." +msgstr "_USER_TABLE_SUMMARY" # Context is "Create set ______ as a duplicate of the first selected set" #: /opt/webwork/webwork2/lib/WeBWorK/ContentGenerator/Instructor/AchievementList.pm:707 diff --git a/lib/WeBWorK/NPL.pm b/lib/WeBWorK/NPL.pm index 3447388149..d38e16dd48 100644 --- a/lib/WeBWorK/NPL.pm +++ b/lib/WeBWorK/NPL.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WeBWorK/NPL.pm,v 1.1 2007/10/17 16:56:16 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/lib/WeBWorK/PG.pm b/lib/WeBWorK/PG.pm index 04d340a619..a2063e0b03 100644 --- a/lib/WeBWorK/PG.pm +++ b/lib/WeBWorK/PG.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WeBWorK/PG.pm,v 1.76 2009/07/18 02:52:51 gage Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/lib/WeBWorK/PG/Local.pm b/lib/WeBWorK/PG/Local.pm index da17988032..20997a7e4d 100644 --- a/lib/WeBWorK/PG/Local.pm +++ b/lib/WeBWorK/PG/Local.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WeBWorK/PG/Local.pm,v 1.28 2009/10/17 15:50:33 apizer Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/lib/WeBWorK/PG/Remote.pm b/lib/WeBWorK/PG/Remote.pm index a46cdefac5..573c396eed 100644 --- a/lib/WeBWorK/PG/Remote.pm +++ b/lib/WeBWorK/PG/Remote.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WeBWorK/PG/Remote.pm,v 1.6 2007/08/13 22:59:58 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/lib/WeBWorK/RPC.pm b/lib/WeBWorK/RPC.pm index aa5a1087ab..0f05245cd3 100644 --- a/lib/WeBWorK/RPC.pm +++ b/lib/WeBWorK/RPC.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WeBWorK/RPC.pm,v 1.2 2006/08/05 02:15:31 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/lib/WeBWorK/RPC/Request.pm b/lib/WeBWorK/RPC/Request.pm index 0219d2d58f..2b5ab44070 100644 --- a/lib/WeBWorK/RPC/Request.pm +++ b/lib/WeBWorK/RPC/Request.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WeBWorK/RPC/Request.pm,v 1.1 2006/07/28 04:33:28 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/lib/WeBWorK/Request.pm b/lib/WeBWorK/Request.pm index 2715e8385f..6353ab539f 100644 --- a/lib/WeBWorK/Request.pm +++ b/lib/WeBWorK/Request.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WeBWorK/Request.pm,v 1.10 2007/07/23 04:06:32 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under @@ -28,7 +28,7 @@ use warnings; use mod_perl; use constant MP2 => ( exists $ENV{MOD_PERL_API_VERSION} and $ENV{MOD_PERL_API_VERSION} >= 2 ); - +use Encode; use WeBWorK::Localize; @@ -58,10 +58,14 @@ sub mutable_param { my $self = shift; if (not defined $self->{paramcache}) { - my @names = $self->SUPER::param; - @{$self->{paramcache}}{@names} = map { [ $self->SUPER::param($_) ] } @names; + my @names = $self->SUPER::param(); + foreach my $name (@names) { + my @params = $self->SUPER::param($name); + @params = map {Encode::decode_utf8($_)} @params; + $self->{paramcache}{$name} = [@params]; + } } - + @_ or return keys %{$self->{paramcache}}; my $name = shift; diff --git a/lib/WeBWorK/Template.pm b/lib/WeBWorK/Template.pm index a80088286d..0024fefde2 100644 --- a/lib/WeBWorK/Template.pm +++ b/lib/WeBWorK/Template.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WeBWorK/Template.pm,v 1.3 2006/01/25 23:13:51 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/lib/WeBWorK/Upload.pm b/lib/WeBWorK/Upload.pm index 7e452a6806..34257f89bb 100644 --- a/lib/WeBWorK/Upload.pm +++ b/lib/WeBWorK/Upload.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WeBWorK/Upload.pm,v 1.7 2006/01/25 23:13:51 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/lib/WeBWorK/Utils.pm b/lib/WeBWorK/Utils.pm index 890ae5162d..2487822af3 100644 --- a/lib/WeBWorK/Utils.pm +++ b/lib/WeBWorK/Utils.pm @@ -31,15 +31,20 @@ use DateTime; use DateTime::TimeZone; use Date::Parse; use Date::Format; +use Encode qw(encode_utf8 decode_utf8); use File::Copy; use File::Spec::Functions qw(canonpath); use Time::Zone; -use MIME::Base64; +use MIME::Base64 qw(encode_base64 decode_base64); use Errno; use File::Path qw(rmtree); use Storable; use Carp; #use Mail::Sender; +use Storable qw(nfreeze thaw); + + +use open IO => ':encoding(UTF-8)'; use constant MKDIR_ATTEMPTS => 10; @@ -68,8 +73,10 @@ our @EXPORT_OK = qw( constituency_hash cryptPassword decodeAnswers + decode_utf8_base64 dequote encodeAnswers + encode_utf8_base64 fisher_yates_shuffle formatDateTime has_aux_files @@ -78,6 +85,7 @@ our @EXPORT_OK = qw( listFilesRecursive makeTempDirectory max + nfreeze_base64 not_blank parseDateTime path_is_subdir @@ -93,6 +101,7 @@ our @EXPORT_OK = qw( textDateTime timeToSec trim_spaces + thaw_base64 undefstr writeCourseLog writeLog @@ -179,11 +188,41 @@ sub force_eoln($) { sub readFile($) { my $fileName = shift; + # debugging code: found error in CourseEnvironment.pm with this +# if ($fileName =~ /___/ or $fileName =~ /the-course-should-be-determined-at-run-time/) { +# print STDERR "File $fileName not found.\n Usually an unnecessary call to readFile from\n", +# join("\t ", caller()), "\n"; +# return(); +# } local $/ = undef; # slurp the whole thing into one string - open my $dh, "<", $fileName - or croak "failed to read file $fileName: $!"; - my $result = <$dh>; - close $dh; + my $result=''; # need this initialized because the file (e.g. simple.conf) may not exist + if (-r $fileName) { + eval{ + # CODING WARNING: + # if (open my $dh, "<", $fileName){ + # will cause a utf8 "\xA9" does not map to Unicode warning if © is in latin-1 file + # use the following instead + if (open my $dh, "<:raw", $fileName){ + $result = <$dh>; + decode_utf8($result) or die "failed to decode $fileName"; + close $dh; + } else { + print STDERR "File $fileName cannot be read."; # this is not a fatal error. + } + }; + if ($@) { + print STDERR "reading $fileName: error in Utils::readFile: $@\n"; + } + utf8::decode($result) or warn "Non-fatal warning: file $fileName contains at least one character code which ". + "is not valid in UTF-8. (The copyright sign is often a culprit -- use '©' instead.)\n". + "While this is not fatal you should fix it\n"; + # FIXME + # utf8::decode($result) raises an error about the copyright sign + # decode_utf8 and Encode::decode_utf8 do not -- which is doing the right thing? + # Done:: should direct this to warn instead of STDERR to debug files written with accents + # in latin-1 files /Done + } + # returns the empty string if the file cannot be read return force_eoln($result); } @@ -777,7 +816,7 @@ sub writeCourseLog($$@) { my $logFile = $ce->{courseFiles}->{logs}->{$facility}; surePathToFile($ce->{courseDirs}->{root}, $logFile); local *LOG; - if (open LOG, ">>", $logFile) { + if (open LOG, ">>:utf8", $logFile) { print LOG "[", time2str("%a %b %d %H:%M:%S %Y", time), "] @message\n"; close LOG; } else { @@ -889,6 +928,10 @@ sub decodeAnswers($) { } } +sub decode_utf8_base64 { + return decode_utf8(decode_base64(shift)); +} + sub encodeAnswers(\%\@) { my %hash = %{shift()}; my @order = @{shift()}; @@ -900,8 +943,30 @@ sub encodeAnswers(\%\@) { } +sub encode_utf8_base64 { + return encode_base64(encode_utf8(shift)); +} + +sub nfreeze_base64 { + return encode_base64(nfreeze(shift)); +} + +sub thaw_base64 { + my $string = shift; + my $result; + eval { + $result = thaw(decode_base64($string)); + }; + if ($@) { + warn("Deleting corrupted achievement data."); + return {}; + } else { + return $result; + } + +} sub max(@) { my $soFar; foreach my $item (@_) { diff --git a/lib/WeBWorK/Utils/AttemptsTable.pm b/lib/WeBWorK/Utils/AttemptsTable.pm index 79775b82a5..aef254ccc9 100644 --- a/lib/WeBWorK/Utils/AttemptsTable.pm +++ b/lib/WeBWorK/Utils/AttemptsTable.pm @@ -3,7 +3,7 @@ use 5.010; ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WebworkClient.pm,v 1.1 2010/06/08 11:46:38 gage Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/lib/WeBWorK/Utils/CourseIntegrityCheck.pm b/lib/WeBWorK/Utils/CourseIntegrityCheck.pm index 2121c1ee63..bea62c55e3 100644 --- a/lib/WeBWorK/Utils/CourseIntegrityCheck.pm +++ b/lib/WeBWorK/Utils/CourseIntegrityCheck.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WeBWorK/Utils/CourseIntegrityCheck.pm,v 1.8 2010/06/12 01:44:33 gage Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/lib/WeBWorK/Utils/CourseManagement.pm b/lib/WeBWorK/Utils/CourseManagement.pm index d809036841..46d262e07f 100644 --- a/lib/WeBWorK/Utils/CourseManagement.pm +++ b/lib/WeBWorK/Utils/CourseManagement.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WeBWorK/Utils/CourseManagement.pm,v 1.48 2009/10/01 21:28:46 gage Exp $ # # This program is free software; you can redistribute it and/or modify it under @@ -279,7 +279,7 @@ sub addCourse { ##### step 4: write course.conf file ##### my $courseEnvFile = $ce->{courseFiles}->{environment}; - open my $fh, ">", $courseEnvFile + open my $fh, ">:utf8", $courseEnvFile or die "failed to open $courseEnvFile for writing.\n"; writeCourseConf($fh, $ce, %courseOptions); close $fh; @@ -1247,7 +1247,7 @@ sub writeCourseConf { #!perl ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright 2000-2016 The WeBWorK Project, http://openwebwork.sf.net/ # # This program is free software; you can redistribute it and/or modify it under # the terms of either: (a) the GNU General Public License as published by the diff --git a/lib/WeBWorK/Utils/CourseManagement/sql_moodle.pm b/lib/WeBWorK/Utils/CourseManagement/sql_moodle.pm index 8966f651ae..c7d4ba242b 100644 --- a/lib/WeBWorK/Utils/CourseManagement/sql_moodle.pm +++ b/lib/WeBWorK/Utils/CourseManagement/sql_moodle.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WeBWorK/Utils/CourseManagement/sql_moodle.pm,v 1.2 2006/09/29 19:41:36 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/lib/WeBWorK/Utils/CourseManagement/sql_single.pm b/lib/WeBWorK/Utils/CourseManagement/sql_single.pm index 5ef059474d..719432f21e 100644 --- a/lib/WeBWorK/Utils/CourseManagement/sql_single.pm +++ b/lib/WeBWorK/Utils/CourseManagement/sql_single.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WeBWorK/Utils/CourseManagement/sql_single.pm,v 1.16 2007/07/21 19:13:10 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/lib/WeBWorK/Utils/DBImportExport.pm b/lib/WeBWorK/Utils/DBImportExport.pm index 36878bb7a1..6977f131e6 100644 --- a/lib/WeBWorK/Utils/DBImportExport.pm +++ b/lib/WeBWorK/Utils/DBImportExport.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WeBWorK/Utils/DBImportExport.pm,v 1.10 2006/09/26 15:57:41 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/lib/WeBWorK/Utils/DBUpgrade.pm b/lib/WeBWorK/Utils/DBUpgrade.pm index bea9d3b10b..91ff790d50 100644 --- a/lib/WeBWorK/Utils/DBUpgrade.pm +++ b/lib/WeBWorK/Utils/DBUpgrade.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WeBWorK/Utils/DBUpgrade.pm,v 1.4 2007/08/13 22:59:59 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/lib/WeBWorK/Utils/DatePickerScripts.pm b/lib/WeBWorK/Utils/DatePickerScripts.pm index 9990f39e40..930e910518 100644 --- a/lib/WeBWorK/Utils/DatePickerScripts.pm +++ b/lib/WeBWorK/Utils/DatePickerScripts.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WeBWorK/Utils/CourseManagement.pm,v 1.48 2009/10/01 21:28:46 gage Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/lib/WeBWorK/Utils/DelayedMailer.pm b/lib/WeBWorK/Utils/DelayedMailer.pm index 060997feaf..4f5311c9d1 100644 --- a/lib/WeBWorK/Utils/DelayedMailer.pm +++ b/lib/WeBWorK/Utils/DelayedMailer.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WeBWorK/Utils/DelayedMailer.pm,v 1.2 2007/08/13 22:59:59 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/lib/WeBWorK/Utils/DetermineProblemLangAndDirection.pm b/lib/WeBWorK/Utils/DetermineProblemLangAndDirection.pm new file mode 100644 index 0000000000..c3c2fdeef1 --- /dev/null +++ b/lib/WeBWorK/Utils/DetermineProblemLangAndDirection.pm @@ -0,0 +1,207 @@ +################################################################################ +# WeBWorK Online Homework Delivery System +# Copyright © 2000-2017 The WeBWorK Project, http://openwebwork.sf.net/ +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of either: (a) the GNU General Public License as published by the +# Free Software Foundation; either version 2, or (at your option) any later +# version, or (b) the "Artistic License" which comes with this package. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the +# Artistic License for more details. +################################################################################ + +package WeBWorK::Utils::DetermineProblemLangAndDirection; +use base qw(Exporter); + +=head1 NAME + +WeBWorK::Utils::DetermineProblemLangAndDirection - utilities to determine +the language and text direction of a problem based on settings from the +PG flags, the course configuration variable $perProblemLangAndDirSettingMode, +and the course language. + +=head1 SYNOPSIS + + use WeBWorK::Utils::DetermineProblemLangAndDirection; + +=head1 DESCRIPTION + +This module provides s function which determines the "recommended" +language and text direction of a problem based on settings from the +PG flags, the course configuration variable $perProblemLangAndDirSettingMode, and the course language. + +=cut + +use strict; +use warnings; +use Carp; +use WeBWorK::PG; +use WeBWorK::Debug; + +our @EXPORT = qw(get_problem_lang_and_dir); +our @EXPORT_OK = (); + + +=head1 FUNCTIONS + +=over + +=item get_problem_lang_and_dir subroutine + + @output = get_problem_lang_and_dir( $self, $pg ); + +returns an array of tagname tagvalue pairs. + +In some cases, the result is empty. + +=cut + +# get_problem_lang_and_dir subroutine + +# used to determine the language and maybe also the dir setting for the +# DIV tag attributes, if needed by the PROBLEM language + +# Return an array of key-value pairs key1 val1 key2 val2 + +sub get_problem_lang_and_dir { + my $self = shift; + my $pg = shift; + + my @result = (); + + my $ce_requested_mode = $self->r->ce->{perProblemLangAndDirSettingMode}; # Mode requested + + if ( $ce_requested_mode eq "none" ) { + # Requested mode is "none" so no output should be made. + return( @result ); + } + + # Get course-wide language setting + my $ce_lang = $self->r->ce->{language}; # Course wide setting + my $ce_dir = "ltr"; # default + + if ( $ce_lang =~ /^he/i ) { # supports also the current "heb" option + # Hebrew - requires RTL direction + $ce_lang = "he"; # Hebrew - standard form + $ce_dir = "rtl"; # RTL + } elsif ( $ce_lang =~ /^ar/i ) { + # Arabic - requires RTL direction + $ce_lang = "ar"; # Arabic + $ce_dir = "rtl"; # RTL + } + + my @tmp1 = split(':',$ce_requested_mode); + my $reqMode = $tmp1[0]; + my $reqLang = $tmp1[1]; + my $reqDir = $tmp1[2]; + + $reqLang = "none" if ( ! defined( $reqMode ) ); + $reqLang = "" if ( ! defined( $reqLang ) ); + $reqDir = "" if ( ! defined( $reqDir ) ); + + if ( $reqMode eq "force" ) { + # Requested mode is to force the LANG and DIR attributes regardless of lang data from problem PG code. + if ( $reqLang ne "" ) { + push( @result, "lang", $reqLang ); # forced setting + } + push( @result, "dir", $reqDir ); # forced setting + return( @result ); + } + + if ( $reqMode ne "auto" ) { + # The mode setting is not valid, treat like none + return( @result ); + } + + # We are now handling an "auto" setting, so want to handle data from PG + + my $pg_lang = "en-US"; # system default + my $pg_dir = "ltr"; # system default + + # Determine the language code to use + if ( defined( $pg->{flags}->{language} ) ) { + # Language set by PG + $pg_lang = $pg->{flags}->{language}; + } else { + # Language not set by PG, use provided default language (if set) or fall back to the system default + if ( $reqLang ne "" ) { + $pg_lang = $reqLang; + } + } + + # Determine the direction code to use + # we changed the order of precedence here. + if ( defined( $pg->{flags}->{textdirection} ) ) { + # Direction set by PG + $pg_dir = $pg->{flags}->{textdirection}; + } elsif ( defined( $pg->{flags}->{language} ) ) { + # Direction not set by PG, + # but PG did set the language. + # Fallback is to use LTR, except for Hebrew and Arabic. + $pg_dir = "ltr"; # correct for most languages + if ( ( $pg->{flags}->{language} =~ /^he/i ) || + ( $pg->{flags}->{language} =~ /^ar/i ) ) { + $pg_dir = "rtl"; # should be correct for these languages + } + } elsif ( $reqDir ne "" ) { + # We have a request for a direction when PG did not set it + $pg_dir = $reqDir; + } else { + # Direction not set by PG, nor was a default setting provided + # and PG did NOT set the language. + # For SetMaker, we are assuming that a problem without a PG direction + # setting should be in LTR mode. + $pg_dir = "ltr"; # correct for most languages + + # Even for Arabic and Hebrew do NOT change to RTL. + # The teacher should add the language and direction setting to + # the PG file of the problem. + } + + # Make these string all lowercase (just in case) + $pg_lang = lc( $pg_lang ); + $pg_dir = lc( $pg_dir ); + $ce_lang = lc( $ce_lang ); + $ce_dir = lc( $ce_dir ); + + # We are ALWAYS setting this for this mode. + push( @result, "lang", $pg_lang ); # send the problem language that was selected + + if ( ( $ce_dir eq "rtl" ) && # Possible hack for RTL direction courses and OPL problems + ( $reqDir eq "rtl" ) && + ! defined( $pg->{flags}->{textdirection} ) && # problem does not set the language or + ! defined( $pg->{flags}->{language} ) ) { # the text direction + # In a RTL language course, we may really want to force LTR use for unknown problems. + # that would best be handled by always including the language setting in RTL language + # problems, and using a setting which falls back to LTR when there is no setting from + # the problem (expected on OPL problems). + + # May want to issue a warning + + # Right now - we are not trying to do the following + # push( @result, "dir", "ltr" ); # override to problem textdirection or "expected" LTR textdirection + } + + # We are ALWAYS setting this for this mode. + push( @result, "dir", $pg_dir ); # override to $pg_dir + + # " ce_lang $ce_lang ce_dir $ce_dir reqMain $reqMain reqLang $reqLand reqDir $reqDir result_lang $pg_lang result_dir $pg_dir "; + + return( @result ); +} + + +=back + +=cut + +=head1 AUTHOR + +Written by Nathan Wallach, tani (at) mathnet.technion.ac.il + +=cut + +1; diff --git a/lib/WeBWorK/Utils/FilterRecords.pm b/lib/WeBWorK/Utils/FilterRecords.pm index fcfba4a1fa..0832ebc017 100644 --- a/lib/WeBWorK/Utils/FilterRecords.pm +++ b/lib/WeBWorK/Utils/FilterRecords.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WeBWorK/Utils/FilterRecords.pm,v 1.5 2006/09/25 22:14:54 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/lib/WeBWorK/Utils/FormatRecords.pm b/lib/WeBWorK/Utils/FormatRecords.pm index 457df47c38..da92c073d0 100644 --- a/lib/WeBWorK/Utils/FormatRecords.pm +++ b/lib/WeBWorK/Utils/FormatRecords.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WeBWorK/Utils/FormatRecords.pm,v 1.9 2007/04/09 21:01:50 glarose Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/lib/WeBWorK/Utils/ListingDB.pm b/lib/WeBWorK/Utils/ListingDB.pm index 987c1e9d9b..b94c303a3c 100644 --- a/lib/WeBWorK/Utils/ListingDB.pm +++ b/lib/WeBWorK/Utils/ListingDB.pm @@ -439,6 +439,12 @@ sub getDBListings { my $subj = $r->param('library_subjects') || ""; my $chap = $r->param('library_chapters') || ""; my $sec = $r->param('library_sections') || ""; + + # Make sure these strings are internally encoded in UTF-8 + utf8::upgrade($subj); + utf8::upgrade($chap); + utf8::upgrade($sec); + my $keywords = $r->param('library_keywords') || ""; # Next could be an array, an array reference, or nothing my @levels = $r->param('level'); @@ -510,6 +516,7 @@ sub getDBListings { # $kw2"; my $pg_id_ref; + $dbh->do(qq{SET NAMES 'utf8';}); if($haveTextInfo) { my $query = "SELECT $selectwhat from `$tables{pgfile}` pgf, `$tables{dbsection}` dbsc, `$tables{dbchapter}` dbc, `$tables{dbsubject}` dbsj, diff --git a/lib/WeBWorK/Utils/RestrictedClosureClass.pm b/lib/WeBWorK/Utils/RestrictedClosureClass.pm index 87051db478..5c603d4f40 100644 --- a/lib/WeBWorK/Utils/RestrictedClosureClass.pm +++ b/lib/WeBWorK/Utils/RestrictedClosureClass.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WeBWorK/Utils/RestrictedClosureClass.pm,v 1.4 2007/08/10 00:27:14 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/lib/WeBWorK/Utils/RestrictedMailer.pm b/lib/WeBWorK/Utils/RestrictedMailer.pm index c9124a326d..0b8bf659b6 100644 --- a/lib/WeBWorK/Utils/RestrictedMailer.pm +++ b/lib/WeBWorK/Utils/RestrictedMailer.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WeBWorK/Utils/RestrictedMailer.pm,v 1.2 2006/12/05 20:57:53 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/lib/WeBWorK/Utils/SortRecords.pm b/lib/WeBWorK/Utils/SortRecords.pm index b6668fbd5e..93e2d6ed38 100644 --- a/lib/WeBWorK/Utils/SortRecords.pm +++ b/lib/WeBWorK/Utils/SortRecords.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WeBWorK/Utils/SortRecords.pm,v 1.7 2006/09/25 22:14:54 sh002i Exp $ # # This program is free software; you can redistribute it and/or modify it under diff --git a/lib/WeBWorK/Utils/Tags.pm b/lib/WeBWorK/Utils/Tags.pm index 6a1f7fdc5f..4333c7bb39 100644 --- a/lib/WeBWorK/Utils/Tags.pm +++ b/lib/WeBWorK/Utils/Tags.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright � 2000-1307 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-1307 The WeBWorK Project, http://openwebwork.sf.net/ # # This program is free software; you can redistribute it and/or modify it under # the terms of either: (a) the GNU General Public License as published by the @@ -203,7 +203,7 @@ sub new { my $textno; my $textinfo=[]; - open(IN,"$name") or die "can not open $name: $!"; + open(IN,'<:encoding(UTF-8)',"$name") or die "can not open $name: $!"; if ($name !~ /pg$/ && $name !~ /\.pg\.[-a-zA-Z0-9_.@]*\.tmp$/) { warn "Not a pg file"; #print caused trouble with XMLRPC $self->{file}= undef; diff --git a/lib/WeBWorK/Utils/Tasks.pm b/lib/WeBWorK/Utils/Tasks.pm index cae73ec2c5..e83ab8d263 100644 --- a/lib/WeBWorK/Utils/Tasks.pm +++ b/lib/WeBWorK/Utils/Tasks.pm @@ -1,6 +1,6 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # # This program is free software; you can redistribute it and/or modify it under # the terms of either: (a) the GNU General Public License as published by the diff --git a/lib/WebworkClient.pm b/lib/WebworkClient.pm index 8916c5ba38..190a1db861 100755 --- a/lib/WebworkClient.pm +++ b/lib/WebworkClient.pm @@ -2,7 +2,7 @@ ################################################################################ # WeBWorK Online Homework Delivery System -# Copyright © 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ +# Copyright © 2000-2018 The WeBWorK Project, http://openwebwork.sf.net/ # $CVSHeader: webwork2/lib/WebworkClient.pm,v 1.1 2010/06/08 11:46:38 gage Exp $ # # This program is free software; you can redistribute it and/or modify it under @@ -108,8 +108,7 @@ use Crypt::SSLeay; # needed for https use lib "$WeBWorK::Constants::WEBWORK_DIRECTORY/lib"; use lib "$WeBWorK::Constants::PG_DIRECTORY/lib"; use XMLRPC::Lite; -use MIME::Base64 qw( encode_base64 decode_base64); -use WeBWorK::Utils qw( wwRound); +use WeBWorK::Utils qw( wwRound encode_utf8_base64 decode_utf8_base64); use WeBWorK::Utils::AttemptsTable; use WeBWorK::CourseEnvironment; @@ -322,12 +321,12 @@ sub xmlrpcCall { $self->fault(1); # set fault flag to true return $self; } else { - if (ref($result->result())=~/HASH/ and defined($result->result()->{text}) ) { - $result->result()->{text} = decode_base64($result->result()->{text}); - } - if (ref($result->result())=~/HASH/ and defined($result->result()->{header_text}) ) { - $result->result()->{header_text} = decode_base64($result->result()->{header_text}); - } + if (ref($result->result())=~/HASH/ and defined($result->result()->{text}) ) { + $result->result()->{text} = decode_utf8_base64($result->result()->{text}); + } + if (ref($result->result())=~/HASH/ and defined($result->result()->{header_text}) ) { + $result->result()->{header_text} = decode_utf8_base64($result->result()->{header_text}); + } $self->return_object($result->result()); # print "\n retrieve result ", keys %{$self->return_object}; @@ -393,7 +392,7 @@ sub jsXmlrpcCall { sub encodeSource { my $self = shift; my $source = shift||''; - $self->{encoded_source} =encode_base64($source); + $self->{encoded_source} =encode_utf8_base64($source); } =head2 Accessor methods @@ -628,7 +627,7 @@ sub formatRenderedProblem { if ( defined ($rh_result->{WARNINGS}) and $rh_result->{WARNINGS} ){ $warnings = "
WARNINGS
".decode_base64($rh_result->{WARNINGS})."
WARNINGS
".decode_utf8_base64($rh_result->{WARNINGS})."