#!perl

# This file is used to set up the default WeBWorK course environment for all
# requests. Values may be overwritten by the course.conf for a specific course.
# All package variables set in this file are added to the course environment.
# If you wish to set a variable here but omit it from the course environment,
# use the "my" keyword. The $webwork_dir variable is set by the webwork2
# Mojolicious app and is available for use here. In addition, the $courseName
# variable holds the name of the current course.

# This file is used to set up the basic paths and URLs specific to your
# installation of WeBWorK, with the exception of the $webwork_dir variable which
# is set by the webwork2 Mojolicious app.  Any customization of global WeBWorK
# settings should be done in localOverrides.conf.

################################################################################
# site.conf  -- this file
################################################################################

# site.conf includes all of the information specific to your server required
# to run WeBWorK.

################################################################################
# Seed variables
################################################################################

# Set these variables to correspond to your configuration.  It is not
# recommended to change any of the settings in this file once your
# web server has been initially configured.

# URL of WeBWorK handler. If WeBWorK is to be on the web server root, use "". Note
# that using "" may not work so we suggest sticking with "/webwork2".
$webwork_url       = '/webwork2';

# The server protocol and domain name, e.g., 'https://webwork.yourschool.edu' or 'http://localhost'
# Note, if running a secure (ssl) server, you probably need 'https://...'.
# Also note that if you use a non-standard port, then that should also be included,
# e.g., 'http://localhost:8080'.
$server_root_url   = 'https://wicswebwork.ee.ncku.edu.tw/';

# This should be set to the group ID under which the webwork2 Mojolicious app is running.
# Note that this is only used by the setfilepermissions script.
#$server_groupID = 'www-data'; # standard for ubuntu if Mojolicious is proxied by apache2
#$server_groupID = 'apache'; # standard for RHEL/CentOS if Mojolicious is proxied by apache2

# The following variable is the address that will be listed in server error
# messages that come from WeBWorK:
#	 "An error occurred while processing your request.
#	 For help, please send mail to this site's webmaster
# 	(mail link to <webwork_server_admin_email>), including all of the following
#	 information as well as what what you were doing when the error occurred... etc..."
# If $webwork_server_admin_email is not defined then the
# ServerAdmin address defined in httpd.conf is used.
# Be sure to use single quotes for the address or the @ sign will be interpreted as an array.
$webwork_server_admin_email = '';

# The following is the name of the admin course where admin level users can create
# courses, delete courses, and more. It is named 'admin' by default but for security,
# you may want to change to something that cannot be guessed.
$admin_course_id = 'admin';

# When new courses are created using the admin course, this setting controls
# whether or not they will be hidden.  Setting this to anything other than
# "hidden" or "visible" (or leaving it unset) means that courses created using
# "Add Courses" are not hidden, and all unarchived courses have whatever hidden
# status they had when archived.
# Setting this to "hidden" means that courses created using "Add Courses" and
# courses created using "Unarchive Courses" with a new course ID will be hidden.
# Unarchived courses that keep their original name will keep their hidden
# status.
# Setting this to "visible" means that courses created using "Add Courses" and
# courses created using "Unarchive Courses" with a new course ID will be visible.
# Unarchived courses that keep their original name will keep their hidden
# status.
#$new_courses_hidden_status = 'hidden';

# password strings (or any other string allowing special characters) should be specified inside single quotes
# otherwise a string such as "someone@nowhere" will interpolate the contents of the array @nowhere -- which is probably
# empty, but still not what you want.  Similar things happen with % and $
################################################################################
# Paths to external programs
################################################################################

# These applications are often found in /bin, but sometimes in /usr/bin
# or even in /opt/local/bin.
# You can use "which tar"  for example to find out where the "tar" program is located

# system utilities
$externalPrograms{tar} = "/usr/bin/tar";
$externalPrograms{git} = "/usr/bin/git";

# equation rendering/hardcopy utiltiies
$externalPrograms{latex}    = "/usr/bin/latex --no-shell-escape";

# xelatex is the default external program used to generate pdf from LaTeX.  It
# supports unicode characters (needed for multilingual use among other things).
# Newer versions of DateTime::Locale use a narrow no-break space in US dates. So
# xelatex is needed even for English.  Note that --no-shell-escape is important
# for security reasons.
$externalPrograms{latex2pdf} = "/usr/bin/xelatex --no-shell-escape";
# You may be able to use pdflatex instead of xelatex if you have an older
# version of DateTime::Locale on your system.  However, pdflatex does not
# support unicode characters.
#$externalPrograms{latex2pdf} = "/usr/bin/pdflatex --no-shell-escape";

$externalPrograms{dvipng}   = "/usr/bin/dvipng";

# In order to use imagemagick convert you need to change the rights for PDF files from
# "none" to "read" in the policy file /etc/ImageMagick-6/policy.xml.  This has possible
# security implications for the server.
$externalPrograms{convert}  = "/usr/bin/convert";

$externalPrograms{dvisvgm}  = "/usr/bin/dvisvgm";
$externalPrograms{pdf2svg}  = "/usr/bin/pdf2svg";

# curl
$externalPrograms{curl}  = "/usr/bin/curl";

# mysql clients
$externalPrograms{mysql}     ="/usr/bin/mysql";
$externalPrograms{mysqldump} ="/usr/bin/mysqldump";

################################################################################
# Database options
################################################################################

# $database_debug = 0;

# Standard permissions command used to initialize the webwork database
# GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, DROP, INDEX, LOCK TABLES ON webwork.* TO webworkWrite@localhost IDENTIFIED BY 'passwordRW';
# where webworkWrite and passwordRW must match the corresponding variables in the next section.

################################################################################
# these variables are used by database.conf. we define them here so that editing
# database.conf isn't necessary.

# You must initialize the database and set the password for webworkWrite.
# Edit the $database_password line and replace 'passwordRW' by the actual password used in the GRANT command above
################################################################################

# The database DSN is the path to the WeBWorK database which you have created.

# Modern database DSN format:
#    DBI:driver:database=$database;host=$hostname;port=$port  (when DB not on localhost)
# or DBI:driver:database=$database;host=127.0.0.1;port=$port  (when DB on localhost, using TCP)
#         See: https://metacpan.org/pod/DBD::MariaDB#port
#              "To connect to a MariaDB or MySQL server on localhost using TCP/IP,
#		you must specify the host as 127.0.0.1 with the optional port, e.g. 3306."
# or DBI:driver:database=$database                            (when DB on localhost, using socket)

# One thing on which it depends is the driver name, which you may want to modify.
# It also depends on the database name, which may be non-standard in some settings,
# as may be the hostname and port of the database server.

# driver should be one of:
#	"mysql"   for the DBD:mysql driver
#	"MariaDB" for the DBD:mysql driver

# Select the desired DB driver:
#$database_driver="mysql";
$database_driver="MariaDB";

$database_host="localhost";
$database_port="3306";
$database_name="webwork";

# For a DB on localhost - default to using Unix socket.
# Change to 0 to use a TCP connection to 127.0.0.1.
$database_use_socket_if_localhost=1;

if ( $database_host eq "localhost" ) {
	if ( $database_use_socket_if_localhost ) {
		$database_dsn="DBI:$database_driver:database=$database_name";
	} else {
		$database_dsn="DBI:$database_driver:database=$database_name;host=127.0.0.1;port=$database_port";
	}
} else {
	$database_dsn="DBI:$database_driver:database=$database_name;host=$database_host;port=$database_port";
}

# The default storange engine to use is set here:
$database_storage_engine = 'myisam';

#########################
# MYSQL compatibility settings for handling international Unicode characters (utf8 and utf8mb)
#########################
# These set the way characters are encoded in mysql and will depend on the version of mysqld being used.
# the default is to use latin1.  With version 2.15 we will move to
# encoding utf8mb4 which allows the encoding of characters from many languages
# including chinese, arabic and hebrew.

$ENABLE_UTF8MB4 =1;    # setting this to 1 enables utf8mb4 encoding, setting this to
					   # 0 sets this for older mysql (pre 5.3) which cannot
					   # handle utf8mb4 characters.

$database_character_set=($ENABLE_UTF8MB4) ? 'utf8mb4' : 'utf8';


# DATABASE login information
# The following two variables must match the GRANT statement run on the mysql server as described above.
$database_username ="webworkWrite";
$database_password ='wicswics';
# password strings (or any other string allowing special characters) should be specified inside single quotes
# otherwise a string such as "someone@nowhere" will interpolate the contents of the array @nowhere -- which is probably
# empty, but still not what you want.  Similar things happen with % and $

#################################################################################
# These variables describe the locations of various components of WeBWorK on your
# server.  You may use the defaults unless you have things in different places.
#################################################################################

# URL and path to htdocs directory.
$webwork_htdocs_url  = "/webwork2_files";
$webwork_htdocs_dir  = "$webwork_dir/htdocs";

# URL for the pg htdocs directory.
$pg_htdocs_url = "/pg_files";

# URL and path to courses directory.
$webwork_courses_url = "/webwork2_course_files";
$webwork_courses_dir = "/opt/webwork/courses"; # a typical place to put course directories


################################################################################
# Mail settings
################################################################################

# The following directives need to be configured in order for your webwork
# server to be able to send mail.

# Mail sent by the mail merge and feedback modules will be sent via this SMTP
# server.  localhost may work if your server is capable of sending email,
# otherwise type the name of your School's outgoing email server.
$mail{smtpServer} = '';  # e.g. 'mail.yourschool.edu' or 'localhost'

$mail{set_return_path} = ''; #sets the return_path to the From: field (sender's email address)
# The return path is used to send error messages about bounced emails
# "noreply\@$mail{smtpServer}" discards error messages,
# The default setting should be adjusted for local domain
# Leaving the return path blank triggers the default which results in Return-Path  being set to the email of the sender.

# Seconds to wait before timing out when connecting to the SMTP server.
#  the default is 120 seconds.
# Change it by uncommenting the following line
# set it to 5 for testing, 30 or larger for production

$mail{smtpTimeout}           = 30;

# TLS is a method for providing secure connections to the smtp server.
# https://en.wikipedia.org/wiki/Transport_Layer_Security
# Allowed values: 'starttls', 'ssl', 'maybestarttls', 0
# Values of 'maybestarttls' and 0 are insecure and are not recommended for
# production environments, except where the smtp server is localhost.

$mail{tls_allowed} = 0;

# Extra settings for SSL/TLS
# You may need to use this setting if your SMTP server uses a self-signed certificate.
# SSL_verify_mode => 0 is not recommended for production environments for security
# reasons.  See https://metacpan.org/pod/IO::Socket::SSL#Common-Usage-Errors

#$mail{smtpSSLOptions} = {SSL_verify_mode => 0};

# errors of the form
# "unable to establish SMTP connection to smtp-gw.rochester.edu port 465"
# indicate that there may be a mismatch between the port number and the use of ssl.
# Many mail servers use port 25 when ssl is off, use port 465 when ssl is on (tls_allowed='ssl'),
# and use port 587 when starttls is used (tls_allowed='starttls').


# Set the SMTP port manually.  Typically this does not need to be done. It will use
# port 25 if insecure, and 465 if ssl is on

#$mail{smtpPort} = 25;

# Debugging tutorial for sending email using ssl/tls
# https://maulwuff.de/research/ssl-debugging.html

# SMTP Authentication
# If your SMTP server requires authentication you can provide the username and password
# for the account on the mail server.
# If you set these credentials, you may need to define the variables $feedback_sender_email,
# $instructor_sender_email and $jitar_sender_email in localOverrides.conf, as some SMTP
# servers require the "From:" address of outgoing emails to match this username.  Setting
# those sender variables will then put the user's email address in the "Reply-to:" field.

#$mail{smtpUsername} = '';
#$mail{smtpPassword} = '';

# Set maxAttachmentSize to the maximum number of megabytes to allow for the size of
# files attached to feedback emails.  Note that this should be set to match the
# limitations of the email server chosen above, and should be set to a value greater
# than zero or no attatchments will work.  This is not intended to be a configuration
# option to disable attachments.

$mail{maxAttachmentSize} = 10;

################################################################################
# Minion job queue options
################################################################################

# This is the Minion backend that will be used by the job queue.
# The corresponding perl package for this backend must be installed.
# Some availabled backends are:
# Minion::Backend::Pg (use 'Pg' below)
# Minion::Backend::mysql (use 'mysql' below)
# Minion::Backend::SQLite (use 'SQLite' below)
# The simplest to use is the SQLite backend as it requires no additional setup.
$job_queue{backend} = 'SQLite';

# Database dsn for the Minion job queue. Some examples of settings for the
# respective backends follow. The postgres and mysql examples will need to be
# modified to work. The default sqlite setting will work as is.
#$job_queue{database_dsn} = 'postgresql://dbuser@/webwork2_job_queue';
#$job_queue{database_dsn} = 'mysql://dbuser:dbpasswd@localhost/webwork2_job_queue';
$job_queue{database_dsn} = "sqlite:$webwork_dir/DATA/webwork2_job_queue.db";

################################################################################
# Problem library options
################################################################################
#
# The problemLibrary configuration data should now be set in localOverrides.conf

# For configuration instructions, see:
# http://webwork.maa.org/wiki/National_Problem_Library
# The directory containing the Open Problem Library files.
# Set the root to "" if no problem
# library is installed. Use version 2.0 for the NPL and use the version 2.5  for the OPL.
# When changing from the NPL to the OPL it is important to change the version number
# because the names of the tables in the database have changed.

# RE-CONFIGURE problemLibrary values in the localOverrides.conf file.
# The settings in site.conf are overridden by settings  in default.config
#################################################
#$problemLibrary{root}        ="/opt/webwork/libraries/webwork-open-problem-library/OpenProblemLibrary";
###########################################################


################################################################################
#Time Zone
################################################################################

# Set the default timezone of courses on this server. To get a list of valid
# timezones, run:
#
#     perl -MDateTime::TimeZone -e 'print join "\n", DateTime::TimeZone::all_names'
#
# To get a list of valid timezone "links" (deprecated names), run:
#
#     perl -MDateTime::TimeZone -e 'print join "\n", DateTime::TimeZone::links'
#
# This can be set per course either in course.conf or via the course configuration.
$siteDefaults{timezone} = "Asia/Taipei";

################################################################################
# Search Engine Indexing Enable/Disable
################################################################################
# sets the default meta robots content for individual course pages
# this will not stop your main course listing page from being indexed
# valid contents: index, noindex, follow, nofollow, noarchive, and
# unavailable_after (example: "index, unavailable_after: 23-Jul-2007 18:00:00 EST")
$options{metaRobotsContent}='noindex, nofollow';

################################################################################
# Third Party Assets CDN/Local
################################################################################
# Set to 1 to serve third party assets files from a CDN.  Otherwise these
# asset files are served from the local node_modules directories.
$options{thirdPartyAssetsUseCDN} = 0;

1; #final line of the file to reassure perl that it was read properly.
