Using an URL shortener on the MoodleBox
For a workshop with teachers, I needed to shorten the URLs for the MoodleBox to a maximum of 17 characters. But first things first ...
Task
For my workshop "MoodleBox in the forest" on behalf of LiGa Sachsen-Anhalt, I was supposed to give teachers various ideas for digital teaching situations in the open air. With the OpenSource app OsmAnd (iOS, Android) and the digital map OpenStreetMap, the teachers should find and search for several GPS coordinates in the vicinity of the conference building. https://machmitnetz.de/course/view.php?id=182
A MoodleBox should be hidden at each of the target points, on which various tasks should be carried out. The URLs to the tasks should be provided digitally via iBeacons. Actually, my first idea was to use QR codes to direct teachers to the tasks to be done. However, in order to be able to show a "vandalism-proof" idea, the QR codes failed quickly, because QR codes on paper can be lost in a real implementation because they rain wet, become very dirty or can be torn off. So I quickly found pleasure in the iBeacons for providing the URLs.
Implementation
In order to complete specific tasks, the participants each need a URL to the task. As mentioned above, iBeacons should be used. With the Calliope mini or the Micro:bit, iBeacons can be created very easily in the school environment. The MakeCode programming environment has the appropriate commands for this ... see http://moodlebox.home/mod/page/view.php?id=231, but only with a maximum of 17 characters long URLs. The materials and activities on the MoodleBox are usually accessed via a link like the one mentioned above. An iBeacon can only process URLs with a maximum of 17 characters, so that the mentioned link to http://moodlebox.home/mo would be cut off and does not work.
The URL to the start page http://moodlebox.home/ alone has 15 characters, whereby the protocol specification http:// must of course also be saved, but not counting to the 17 characters ... see https://makecode.microbit.org/reference/bluetooth/advertise-url . Okay, the MoodleBox can also be called up via http://moodlebox/ with only 10 characters ... 5 characters saved ... and 7 more characters remain for forwarding. This is usually still not enough for a Moodle URL. When preparing for the workshop with two teams, I configured the MoodleBox so that the team areas could be accessed via the addresses http://moodlebox/x/t1 for team1 and http://moodlebox/u/t2 for team2. For this I had to create a subdirectory u in the Moodle source code and in it two further subdirectories t1 and t2 ... I coded the forwarding files index.php contained therein by hand for the workshop. However, this requires direct access to the Moodle source code and knowledge of creating a PHP redirect.
Such a technical intervention cannot be expected for implementation in normal lessons, especially since it is very inflexible and error-prone. No teacher would want to deal with it on the side, which is why I was looking for an easy-to-use solution.
URL shortener on the internet
The usual online services https://kurzelinks.de, https://t1p.de, https://is.gd, https://bit.ly, https://goo.gl, https://tiny.cc or https://tinyurl.com on the Internet are out of the question because the URL shortener must also work offline and be able to provide the URLs without an Internet connection. If there is no internet connection, as in the "MoodleBox in the forrest" workshop, these URL shorteners would not decode a short link.
URL shortener YOURLS locally on the MoodleBox
After several function tests, I also installed the open source software YOURLS - Your Own URL Shortener http://yourls.org on the MoodleBox. In addition, I made it possible in the /etc/hosts
file to be able to call up the MoodleBox via the short URL http://mb/. Now there are short URLs of the form http://mb/x/c7s2/ ... these are only 10 characters out of the 17 maximum possible ... and now the iBeacons also work without any problems.
The YOURLS software can be freely downloaded from https://github.com/YOURLS/. The directory yourls is on the MoodleBox in the directory /var/www/yourls
next to /var/www/moodle
and is integrated into Moodle with a symbolic link x
pointing to /var/www/yourls
.
My configuration consists of three parts, the change in the /etc/hosts
file, the settings in the /var/www/yourls/user/config.txt
file and the addition in the /etc/nginx/sites-available/default
file .
This is all! The yourls database was created automatically when the administration page http://mb/x/admin/ was opened for the first time.
I have created several short links, e.g. the URL http://moodlebox.home/course/view.php?id=2 with the short link http://mb/x/c2/ ... very short and very memorable! The next tested URL http://moodlebox.home/course/view.php?id=7§ion=2 has the short link http://mb/u/c7s2/.
Further references of the project implementation
https://machmitnetz.de/course/view.php?id=182
https://github.com/moodlebox/moodlebox/issues/90
https://ckblog2016.wordpress.com/2017/08/11/calliope-mini-als-ble-beacon/
https://makecode.microbit.org/v1/reference/bluetooth/advertise-url
https://yourls.org
Configuration files
/etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
10.0.0.1 moodlebox mb
/etc/nginx/sites-available/default
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate /etc/nginx/ssl/moodlebox.pem;
ssl_certificate_key /etc/nginx/ssl/moodlebox.key;
root /var/www/moodle;
index index.php index.html index.htm index.nginx-debian.html;
server_name moodlebox;
location / {
try_files $uri $uri/ =404;
}
location /dataroot/ {
internal;
alias /var/www/moodledata/;
}
location ~ [^/]\.php(/|$) {
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_read_timeout 300;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "max_execution_time=300\n upload_max_filesize=50M\n post_max_size=50M\n max_input_vars=5000";
client_max_body_size 50M;
}
### for yourls url shortener
location /x/ {
try_files $uri $uri/ /x/yourls-loader.php$is_args$args;
}
###
}
/var/www/yourls/user/config.txt
/** MySQL database settings */
define( 'YOURLS_DB_USER', 'moodlebox' );
/** MySQL database password */
define( 'YOURLS_DB_PASS', 'Moodlebox4$' );
/** The name of the database for YOURLS */
define( 'YOURLS_DB_NAME', 'yourls' );
/** MySQL hostname.
** If using a non standard port, specify it like 'hostname:port',
** eg. 'localhost:9999' or '127.0.0.1:666' */
define( 'YOURLS_DB_HOST', 'localhost' );
/** MySQL tables prefix */
define( 'YOURLS_DB_PREFIX', 'yourls_' );
/** MySQL database engine */
define( 'YOURLS_DB_DRIVER', 'mysqli' );
/** YOURLS installation URL -- all lowercase and with no trailing slash. */
define( 'YOURLS_SITE', 'http://mb/x' );