local/sanitychecker/view: Difference between revisions
From MoodleDocs
(added page for Moodle docs for this add-on)) |
(tidy up) |
||
Line 5: | Line 5: | ||
Moodle 2.3 or newer | Moodle 2.3 or newer | ||
==Installation== | ==Installation for Moodle 2.3 and 2.4== | ||
* Go to the right directory | |||
Before all, change your working directory to | * Before all, change your working directory to YOUR_MOODLE_DIRROOT/local where : YOUR_MOODLE_DIRROOT represents the root directory of your moodle site. | ||
YOUR_MOODLE_DIRROOT/local | |||
where : YOUR_MOODLE_DIRROOT represents the root directory of your moodle site. | |||
===get the plugin=== | ===get the plugin=== | ||
using git | * using git | ||
* Clone the plugin repository by running : | |||
Clone the plugin repository by running : | git clone https://github.com/eviweb/moodle-local_sanitychecker.git sanitychecker | ||
git clone https://github.com/eviweb/moodle-local_sanitychecker.git sanitychecker | |||
===using archive=== | ===using archive=== | ||
* Download the zip archive directly from github and uncompress under sanitychecker directory : | |||
wget -c https://github.com/eviweb/moodle-local_sanitychecker/archive/master.zip | |||
unzip master.zip && mv moodle-local_sanitychecker-master sanitychecker | |||
wget -c https://github.com/eviweb/moodle-local_sanitychecker/archive/master.zip | |||
unzip master.zip && mv moodle-local_sanitychecker-master sanitychecker | |||
===finalize the installation=== | ===finalize the installation=== | ||
Authenticate with an administrator account and go to the notifications page to finish the install. This page is located under : | * Authenticate with an administrator account and go to the notifications page to finish the install. | ||
http(s)://YOUR_MOODLE_SITE/admin/index.php | * This page is located under : | ||
where : YOUR_MOODLE_SITE is the domain of your moodle site. | http(s)://YOUR_MOODLE_SITE/admin/index.php | ||
where : YOUR_MOODLE_SITE is the domain of your moodle site. | |||
==How to use this feature== | ==How to use this feature== | ||
*Once installed you will find a link under | |||
Once installed you will find a link under | Settings > Site administration | ||
Settings > Site administration | * called Sanity checker. By clicking on it, you will be redirected to the plugin dashboard. | ||
called | * Its table lists all the available sanity checkers under four columns : | ||
Sanity checker | |||
Its table lists all the available sanity checkers under four columns : | |||
Name : the implementation name | Name : the implementation name | ||
Line 48: | Line 41: | ||
Information : displays contextual information about what is done | Information : displays contextual information about what is done | ||
So choose which test you want to run and click on Run test. | *So choose which test you want to run and click on Run test. | ||
If a problem is found the previous action link is renamed Resolve issue. | * If a problem is found the previous action link is renamed Resolve issue. | ||
Click on it to apply the fix. | * Click on it to apply the fix. | ||
==Create an implementation of the SanityChecker interface== | ==How to create a new sanity checker== | ||
* implement the API | |||
===Create an implementation of the SanityChecker interface=== | |||
interface SanityChecker | interface SanityChecker | ||
Line 94: | Line 88: | ||
or extends the abstract | ===or extends the abstract DatabaseSanityChecker=== | ||
DatabaseSanityChecker | |||
which is a class helper to perform sanity checks on database records. | which is a class helper to perform sanity checks on database records. | ||
register the service implementation | ===register the service implementation=== | ||
Add the class full name of your implementation on a new line in the | Add the class full name of your implementation on a new line in the | ||
Line 111: | Line 104: | ||
META-INF | META-INF | ||
, represents a part of the class namespace. | , represents a part of the class namespace. | ||
Sanity Checker List | * To illustrate this, the SanityChecker interface is declared under the namespace evidevmoodleplugins and is located at | ||
./classes/evidev/moodle/plugins/SanityChecker.php | |||
==See also== | |||
* [https://github.com/eviweb/moodle-local_sanitychecker/wiki Sanity Checker List wiki page] | |||
==Download page== | ==Download page== |
Revision as of 15:39, 5 September 2013
This plugin provides an interface to implement sanity checks on moodle.
Moodle version
Moodle 2.3 or newer
Installation for Moodle 2.3 and 2.4
- Go to the right directory
- Before all, change your working directory to YOUR_MOODLE_DIRROOT/local where : YOUR_MOODLE_DIRROOT represents the root directory of your moodle site.
get the plugin
- using git
- Clone the plugin repository by running :
git clone https://github.com/eviweb/moodle-local_sanitychecker.git sanitychecker
using archive
- Download the zip archive directly from github and uncompress under sanitychecker directory :
wget -c https://github.com/eviweb/moodle-local_sanitychecker/archive/master.zip unzip master.zip && mv moodle-local_sanitychecker-master sanitychecker
finalize the installation
- Authenticate with an administrator account and go to the notifications page to finish the install.
- This page is located under :
http(s)://YOUR_MOODLE_SITE/admin/index.php where : YOUR_MOODLE_SITE is the domain of your moodle site.
How to use this feature
- Once installed you will find a link under
Settings > Site administration
- called Sanity checker. By clicking on it, you will be redirected to the plugin dashboard.
- Its table lists all the available sanity checkers under four columns :
Name : the implementation name Description : should describe what the checker is supposed to do Actions : here is displayed a dynamic link to run the actions to perform > check : to run the tests > resolve : in case a problem is found, apply the fix Information : displays contextual information about what is done
- So choose which test you want to run and click on Run test.
- If a problem is found the previous action link is renamed Resolve issue.
- Click on it to apply the fix.
How to create a new sanity checker
- implement the API
Create an implementation of the SanityChecker interface
interface SanityChecker {
/** * get the sanity checker name * * @return string returns the name of this implementation */ public function getName();
/** * get the description of what this sanity check does * * @return string returns the description of this implementation */ public function getDescription();
/** * perform the test * * @return boolean returns true if the test succeeds, false if it fails */ public function doCheck();
/** * get information on the problem detected * * @return string returns information related to the detected problem * or an empty string if there is no issue */ public function getInformationOnIssue();
/** * resolve the problem */ public function resolveIssue();
}
or extends the abstract DatabaseSanityChecker
which is a class helper to perform sanity checks on database records.
register the service implementation
Add the class full name of your implementation on a new line in the ./classes/META-INF/services/evidev.moodle.plugins.sanitychecker file.
For now, you add to take care about providing a way to load your class by your own or to install it under the ./classes directory.
Each folder under the subtree of this directory, except META-INF , represents a part of the class namespace.
- To illustrate this, the SanityChecker interface is declared under the namespace evidevmoodleplugins and is located at
./classes/evidev/moodle/plugins/SanityChecker.php