Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Pado
Asyst Moodle Plugin
Commits
e4b8276b
Commit
e4b8276b
authored
Sep 25, 2024
by
Artem Baranovskyi
Browse files
Few PHPUnit infrastructural fixes.
parent
866f9a08
Changes
4
Hide whitespace changes
Inline
Side-by-side
.env
View file @
e4b8276b
...
...
@@ -9,6 +9,7 @@ MOODLE_DATABASE_USER=moodleuser
MOODLE_DATABASE_PASSWORD=moodlepassword
MOODLE_BASE_DIR=/var/www/html/moodle
MOODLE_BASE_DIR_DATA=/var/www/html/moodledata
MOODLE_PHPUNIT_DATAROOT=/var/www/html/phpunitdata
MOODLE_WWWROOT=https://www.moodle.loc
MOODLE_FULLNAME="Moodle LMS Site"
...
...
docker-compose.yml
View file @
e4b8276b
...
...
@@ -33,6 +33,7 @@ services:
-
MOODLE_DATABASE_NAME=${MOODLE_DATABASE_NAME}
-
MOODLE_DATABASE_USER=${MOODLE_DATABASE_USER}
-
MOODLE_DATABASE_PASSWORD=${MOODLE_DATABASE_PASSWORD}
-
MOODLE_PHPUNIT_DATAROOT=${MOODLE_PHPUNIT_DATAROOT}
ports
:
-
80:80
-
443:443
...
...
@@ -46,6 +47,7 @@ services:
-
${PWD}/asystgrade:${MOODLE_BASE_DIR}/local/asystgrade
# Sync the plugin folder with the container
-
moodle_data:${MOODLE_BASE_DIR}
# Volume for Moodle
-
moodledata:${MOODLE_BASE_DIR_DATA}
# Volume for Moodle data
-
moodle_phpunit_data:${MOODLE_PHPUNIT_DATAROOT}
networks
:
-
network
# Adding the network communication between containers
...
...
@@ -76,6 +78,8 @@ volumes: # Defining local volumes
driver
:
local
flask
:
driver
:
local
moodle_phpunit_data
:
driver
:
local
networks
:
network
:
# Creating a network
\ No newline at end of file
flask/Dockerfile
View file @
e4b8276b
...
...
@@ -15,7 +15,7 @@ COPY . /app
COPY
./asyst /app/asyst
# Installing dependencies
RUN
/opt/myenv/bin/pip
install
--no-cache-dir
-i
https://pypi.tuna.tsinghua.edu.cn/simple
-r
/app/requirements.txt
RUN
/opt/myenv/bin/pip
install
-r
/app/requirements.txt
RUN
/opt/myenv/bin/python3
-m
pip
install
--upgrade
setuptools wheel
...
...
install_moodle.sh
View file @
e4b8276b
...
...
@@ -17,12 +17,17 @@ docker-compose exec moodle mkdir -p ${MOODLE_BASE_DIR_DATA}/temp
docker-compose
exec
moodle
mkdir
-p
${
MOODLE_BASE_DIR_DATA
}
/trashdir
docker-compose
exec
moodle
chown
-R
www-data:www-data
${
MOODLE_BASE_DIR_DATA
}
docker-compose
exec
moodle
chmod
-R
775
${
MOODLE_BASE_DIR_DATA
}
# Ensure correct ownership and permissions after installation
docker-compose
exec
moodle
chown
-R
www-data:www-data
${
MOODLE_BASE_DIR
}
docker-compose
exec
moodle
chmod
-R
755
${
MOODLE_BASE_DIR
}
docker-compose
exec
moodle
mkdir
-p
${
MOODLE_PHPUNIT_DATAROOT
}
docker-compose
exec
moodle
chown
-R
www-data:www-data
${
MOODLE_PHPUNIT_DATAROOT
}
docker-compose
exec
moodle
chmod
-R
755
${
MOODLE_PHPUNIT_DATAROOT
}
# Install Moodle
sleep
5
docker-compose
exec
moodle php
${
MOODLE_BASE_DIR
}
/admin/cli/install.php
\
--wwwroot
=
"
${
MOODLE_WWWROOT
}
"
\
--phpunit_dataroot
=
"
${
MOODLE_WWWROOT
}
"
\
--dataroot
=
"
${
MOODLE_BASE_DIR_DATA
}
"
\
--dbtype
=
"mariadb"
\
--dbname
=
"
${
MOODLE_DATABASE_NAME
}
"
\
...
...
@@ -35,6 +40,10 @@ docker-compose exec moodle php ${MOODLE_BASE_DIR}/admin/cli/install.php \
--agree-license
\
--non-interactive
# Add phpunit_dataroot & phpunit_prefix to config.php
docker-compose
exec
moodle bash
-c
"echo '
\$
CFG->phpunit_dataroot =
\"
${
MOODLE_PHPUNIT_DATAROOT
}
\"
;' >>
${
MOODLE_BASE_DIR
}
/config.php"
docker-compose
exec
moodle bash
-c
"echo '
\$
CFG->phpunit_prefix =
\"
phpu_
\"
;' >>
${
MOODLE_BASE_DIR
}
/config.php"
# Check if database backup exists and restore it if it does
BACKUP_FILE
=
"moodle/moodle_backup.sql"
if
[
-f
"
$BACKUP_FILE
"
]
;
then
...
...
@@ -57,21 +66,26 @@ docker-compose exec moodle bash -c "
php -r
\"
copy('https://getcomposer.org/installer', 'composer-setup.php');
\"
&&
php composer-setup.php --install-dir=/usr/local/bin --filename=composer &&
php -r
\"
unlink('composer-setup.php');
\"
&&
cd
/
app &&
cd app &&
/usr/local/bin/composer install --no-interaction --no-plugins --no-scripts --no-dev --prefer-dist &&
/usr/local/bin/composer dump-autoload
"
# Next, configure PHPUnit for Moodle:
docker-compose
exec
moodle php admin/tool/phpunit/cli/init.php
docker-compose
exec
moodle php admin/tool/phpunit/cli/init.php
# Define the path to the phpunit.xml file
PHPUNIT_XML_PATH
=
"/var/www/html/moodle/phpunit.xml"
# Define the content to insert for your plugin's test suite
TEST_SUITE_ENTRY
=
'<testsuite name="Unit Tests">
<directory>local/asystgrade/tests</directory>
</testsuite>'
TEST_SUITE_ENTRY
=
'<testsuite name="Unit Tests">\n <directory>local/asystgrade/tests</directory>\n</testsuite>'
# Check if phpunit.xml exists
if
[
-f
"
$PHPUNIT_XML_PATH
"
]
;
then
echo
"
$PHPUNIT_XML_PATH
exists."
else
echo
"
$PHPUNIT_XML_PATH
does not exist."
fi
# Check if the plugin suite is already defined in phpunit.xml
if
grep
-q
"local/asystgrade/tests"
"
$PHPUNIT_XML_PATH
"
;
then
...
...
@@ -82,10 +96,6 @@ else
echo
"Test suite for asystgrade plugin added to phpunit.xml."
fi
# Ensure correct ownership and permissions after installation
docker-compose
exec
moodle
chown
-R
www-data:www-data
${
MOODLE_BASE_DIR
}
docker-compose
exec
moodle
chmod
-R
755
${
MOODLE_BASE_DIR
}
# Set correct access rules for the plugin
docker-compose
exec
moodle
chown
-R
www-data:www-data
${
MOODLE_BASE_DIR
}
/local/asystgrade
docker-compose
exec
moodle
chmod
-R
775
${
MOODLE_BASE_DIR
}
/local/asystgrade
...
...
@@ -105,4 +115,9 @@ docker-compose exec flask chmod +x /usr/local/bin/run_sag
docker-compose
exec
flask /usr/local/bin/run_sag
# Adding cron-record at the Moodle container
docker-compose
exec
-u
root moodle bash
-c
"echo '* * * * * /usr/bin/php
${
MOODLE_BASE_DIR
}
/admin/cli/cron.php >/dev/null 2>&1' >> /etc/crontabs/root && crontab /etc/crontabs/root"
docker-compose
exec
-u
root moodle bash
-c
"
mkdir -p /etc/crontabs &&
touch /etc/crontabs/root &&
echo '* * * * * /usr/bin/php
${
MOODLE_BASE_DIR
}
/admin/cli/cron.php >/dev/null 2>&1' >> /etc/crontabs/root &&
crontab /etc/crontabs/root
"
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment