Skip to content

openstax/raise-moodle-spikes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RAISE Moodle Spikes

This repository contains spike code from Moodle related experimentation for the RAISE project. As such, everything here should be considered as quick and dirty prototypes created to better understand and / or demonstrate potential capabilities.

Directory structure

The following table describes the directories in this repo:

Directory Description
moodle Docker files for building development Moodle images that can be deployed locally using docker compose or on Kubernetes using helm
deploy Deployment automation code
plugins Moodle plugins
services Ancillary services used to implement / demonstrate functionality
demos Miscellaneous code / files used for demos
scripts Utility / helper scripts

How Tos

Deploying a local environment

You can use the following commands to get a basic local environment running using docker compose (you may want to modify values in .env beforehand):

$ docker compose up -d
$ docker compose exec moodle php admin/cli/install_database.php --agree-license --fullname="Local Dev" --shortname="Local Dev" --summary="Local Dev" --adminpass="admin" --adminemail="[email protected]"

The site will then be available at http://localhost:8000/.

Setup pgadmin to view moodle database

To log into the server go to http://localhost:5050/

Log in:

On the home page click "Add new server" Give the new server a name. Example: "my_db"

Go to the connection tab and set the following perameters

  • Hostname/address: postgres
  • Port: 5432
  • Username: moodle
  • Password: moodledbpassword

Click "Save"

Debugging in a local environment

You can configure your local development environment to debug Moodle in VScode using the following steps:

  1. Install xdebug in your environment
  2. Install the php-debug extension in VS Code
  3. Create a launch.json with an appropriate pathMappings if you want to set break points in the editor:
{
    "name": "Listen for Xdebug",
    "type": "php",
    "request": "launch",
    "port": 9003,
    "pathMappings": {
        "/var/www/html/admin/tool/events": "${workspaceFolder}/plugins/events"
    }
}
  1. Setup moodle container for debugging:
$ MOODLE_TARGET=dbg docker compose up --build -d

Moodle settings for debugging

If you are debugging / developing, you may want to modify the following settings within Moodle as well:

  • Site Administration -> Development -> Debugging: Set "Debug messages" to "Developer"
  • Site Administration -> Appearance -> AJAX and Javascript: Clear the flag for "Cache Javascript"

Access mail sent by Moodle

It's sometimes useful to be able to see the emails Moodle is trying to send to users. The environments in this repo configure MailHog so developers can inspect these emails without a real SMTP setup. In a local docker environment, you can navigate to http://localhost:8025 to see the MailHog web interface. If you have enableMailhog enabled for a Kubernetes deployment, the interface can be opened on your development machine by using kubectl to port forward:

$ kubectl port-forward $(kubectl get po -l "app=raise-spikes-mailhog-<deploymentName>" -o name) 8025:8025

Running phpunit tests

Tests can be invoked after setting up phpunit:

$ docker compose exec moodle php admin/tool/phpunit/cli/init.php
$ docker compose exec moodle vendor/bin/phpunit --testsuite local_raisecli_testsuite
$ docker compose exec moodle vendor/bin/phpunit --testsuite local_raise_testsuite

Creating a Moodle backup file for git storage

The environment in this repo can be used to create a .mbz file for git storage of course backup data from an arbritrary instance. All this script really does is load the content in a clean database and re-export using automated steps for consistency.

NOTE: Running this script will delete all of the data in your local Moodle instance.

Example steps:

$ ./scripts/gitify_mbz.sh -i input.mbz -o output.mbz

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •