Giter Club home page Giter Club logo

moodle-tool_moodlebox's Introduction

MoodleBox Moodle plugin

Build Status GitHub release GitHub Release Date GitHub last commit

A Moodle administration plugin providing a GUI to some settings and management of a MoodleBox, a Moodle server installed on a Raspberry Pi.

This plugin enables a Moodle administrator to monitor some hardware settings, to set the date of the MoodleBox, to allow restart and shutdown of the MoodleBox and changing Raspberry Pi passwords using a GUI. After the installation in Moodle, some steps are required to complete on the Raspberry Pi (see below).

Administrators and users with manager role can moreover restart and shutdown the MoodleBox with buttons in the footer of each Moodle page.

The plugin is compatible with Moodle 3.6 or later. A Raspberry Pi model Zero 2 W, 3A+, 3B, 3B+, 4B or 5 is recommended.

Installation

The MoodleBox plugin must be installed in the Moodle tree of the MoodleBox, in the tool folder. Once installed, an new option MoodleBox will be available in Moodle, under Site administration > Server in the Administration block.

To complete the installation, you have to configure some direvent jobs on the MoodleBox.

  1. Install direvent package:

    sudo apt-get install direvent
  2. Add following lines to file /etc/direvent.conf:

    # This is the configuration file for direvent. Read
    # direvent.conf(5) for more information about how to
    # fill this file.
    
    debug 0;
    
    watcher {
      path /var/www/moodle/admin/tool/moodlebox/;
      file .reboot-server;
      event CLOSE_WRITE;
      command "/sbin/shutdown -r now";
    }
    
    watcher {
      path /var/www/moodle/admin/tool/moodlebox/;
      file .shutdown-server;
      event CLOSE_WRITE;
      command "/sbin/shutdown -h now";
    }
    
    watcher {
      path /var/www/moodle/admin/tool/moodlebox/;
      file .set-server-datetime;
      event CLOSE_WRITE;
      command "/bin/bash /var/www/moodle/admin/tool/moodlebox/.set-server-datetime";
    }
    
    watcher {
      path /var/www/moodle/admin/tool/moodlebox/;
      file .newpassword;
      event CLOSE_WRITE;
      command "/bin/bash /var/www/moodle/admin/tool/moodlebox/bin/changepassword.sh";
    }
    
    watcher {
      path /var/www/moodle/admin/tool/moodlebox/;
      file .wifisettings;
      event CLOSE_WRITE;
      command "/usr/bin/python3 /var/www/moodle/admin/tool/moodlebox/bin/changewifisettings.py";
    }
    
    watcher {
      path /var/www/moodle/admin/tool/moodlebox/;
      file .resize-partition;
      event CLOSE_WRITE;
      command "/bin/bash /var/www/moodle/admin/tool/moodlebox/bin/resizepartition.sh";
    }
  3. Copy the following line at the end of file /etc/sudoers.d/020_www-data-nopasswd (create it if it's not here):

    www-data ALL=(ALL) NOPASSWD:/sbin/parted /dev/mmcblk0 unit MB print free
    www-data ALL=(ALL) NOPASSWD:/usr/bin/vcgencmd
  4. If you use the PiJuice module, you need to install the packages related

    sudo apt-get install pijuice-base

    then allow www-data to access I2C:

    sudo adduser www-data i2c

    and reboot.

Features

  • Info about the MoodleBox (kernel version, Raspberry Pi OS version, free space on SD card, CPU load, CPU temperature, CPU frequency, uptime, DHCP clients and more).
  • Warning when under voltage detected.
  • GUI to set the MoodleBox date and time.
  • GUI to set the MoodleBox password.
  • GUI to set the MoodleBox Wi-Fi settings: SSID and its visibility, regulatory country, channel, password (or remove password) and fixed IP address.
  • GUI to resize the partition of the SD card of the MoodleBox, when needed.
  • GUI to restart and shutdown the MoodleBox.

Availability

The code is available at https://github.com/moodlebox/moodle-tool_moodlebox.

Release notes

See Release notes.

Thanks

  • To Adrian Perez (@adpe), for implementing restart and shutdown buttons in footer.
  • To Vincent Widmer (@smallhacks), for implementing PiJuice support.
  • To Visvanath Ratnaweera (@ratnavis), who kindly donated a Raspberry Pi 3A+ and loaned a Raspberry Pi 4 8GB, enabling support of these Raspberry Pi models.

License

Copyright © 2016 onwards, Nicolas Martignoni [email protected]

  • All the source code is licensed under GPL 3 or any later version
  • The documentation is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. 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 the GNU General Public License for more details.

moodle-tool_moodlebox's People

Contributors

martignoni avatar smallhacks avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

moodle-tool_moodlebox's Issues

Refactor scripts enabling direct execution by user www-data

Idea: get rid of current complicated way to run root-only commands via cron.

How: enable some carefully chosen commands to be run by user www-data using sudo. This involves enabling some commands in /etc/sudoers file, e.g.

www-data ALL=(ALL) NOPASSWD:/usr/sbin/reboot

Enable partition resizing in GUI

Hi Nicolas,
for my workshops I am using my own MoodleBox image. I take your image but I add some Moodle plugins and some Moodle courses to get my workshop setting. I copy this image to some sd cards to use more than only one MoodleBox. And I want to give away my image to my participants so they can start their own MoodleBox with my settings.
To be able to copy the image on all kinds of sd cards I shrinked the partition down to less than 8 GB. I can copy this image to cards with 8, 16 and 32 GB ... or more :-) Yes, it‘s no problem for me to enlarge the partition in Terminal. But most of my participants who want to get their own MoodleBox only can copy the image to the sd card. They can‘t use the Terminal to enlarge the partition size.

What do you think about the following idea. I want to get a button in the MoodleBox plugin which can enlarge the partition size. The button is avalable only when the sd card has some unused space. So also users will be able to copy their own MoodleBox image to a larger sd cards without open the Terminal. Mac users could use ApplePi Baker for backup the MoodleBox card and restore it to a larger one.

Best regards, Ralf

Bundle hidden files

Hidden files needed for full functionalities should be bundled in the plugin, so that the upgrade process works without user intervention.

Font problem with Safari and macOS

Hi Nicolas,
I found that I get a font problem with Safari and macOS on the settings page (1). The source code (3) seems to be okay but there is missing an emoji on the settings page. I switched of the font family (2) in a website admin tool to see the result without this setting.
Ralf
moodlebox-wrong-char-in-ssid-1
moodlebox-wrong-char-in-ssid-2
moodlebox-wrong-char-in-ssid-3

Simplify styles.css by giving the theme actual control

In recent Moodle versions, plugins are encouraged to let the theme do the most of the styling. Instead of specifying how widgets look like - e.g. the buttons in your case - it is generally better to just specify the CSS classes and let the theme do the job. This works particularly well with bootstrap based themes like Clean or Boost.

PHP warning due to direct inclusion of version.php

The index.php directly includes the version.php to be able to later display the release and version information. It throws the following PHP warning:

Warning: Creating default object from empty value in admin/tool/moodlebox/version.php on line 27

To avoid it, please initialize the empty {{$plugin}} object before including the version.php.

Unnecessary calls to exec()

Although in this particular case they all are pretty safe, it is always a bit scary to see Moodle plugins to do any of potentially dangerous calls like exec(). Especially if there is no real reason for them.

For things like exec('awk \'/^Hardware/{print $3}\' /proc/cpuinfo'); or even exec('cat /var/lib/misc/dnsmasq.leases', $leases);, why not to use native PHP commands like file_get_contents().

Similarly, I can't see why there must be exec("touch $reboottriggerfilename"); when there is a PHP wrapper for that http://php.net/manual/en/function.touch.php (by the way, it feels like the path to these triggers could better be explicit).

Was there a special reason why exec() is used instead of the suggested PHP alternatives?

Incomplete description at moodle.org/plugins

The description reads

After the installation in Moodle, some steps are required to complete on the Raspberry Pi (see below).

There is not below and not steps are described there. I assume you wanted to document the cron job watching for the trigger files?

Additionally, the plugin implicitly expects that some kind of Linux is installed on the Raspberry Pi (which even if is the case in 99%, may or may not be always true). That and all other requirements should be properly documented.

PHP warnings due to inexistent file

When used on platform without file '/proc/cpuinfo', following warning throwed:

Notice: Undefined offset: 0 in /Data/home/martignonin/html/admin/tool/moodlebox/index.php on line 50
Notice: Undefined offset: 0 in /Data/home/martignonin/html/admin/tool/moodlebox/index.php on line 52

Add help icons

Enhance simplicity of plugin usage by adding help icons with contextual help text.

We'll use e.g.:

echo $OUTPUT->heading_with_help(get_string('systeminfo', 'tool_moodlebox'), 'systeminfo', 'tool_moodlebox');

and/or

$mform->addHelpButton('currentdatetime', 'currentdatetime', 'tool_moodlebox');

language files

Hello Nicolas,
with the new version you added the language files for de and es_mx into the package.

I think this is not a good idea because nobody will be able to change the text strings. A plugin for Moodle should only come with the english text strings. The other strings will come with the language pack. When I add the german language pack de then I get all strings from the official language distribution ... and this language pack also comes with the file moodlebox.php.

Best regards, Ralf

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.