Is there a way to obtain version info for a moodle site using only "teacher" level access? It seems as though this ability was removed in versions 1.9.7 and above. I'm trying to automate the process of uploading tests and having the version info would be rather handy.
7 Answers
In order to see the current version of moodle you just need to read this file: http://yourmoodlesite/lib/upgrade.txt
Here's more information about it: https://github.com/moodle/moodle/blob/MOODLE_29_STABLE/lib/upgrade.txt

- 671
- 1
- 5
- 2
-
1This helped me find the version, easily. Can easily compare the upgrade.txt content on GitHub with the one on the website thanks! – Darsh Patel Jul 09 '20 at 15:37
-
1This doesn't get an entry for each upgrade, e.g. not for 3.8.7 and 3.8.8. – Robert Pollak Mar 22 '21 at 09:10
Sorry, these instructions may seem somewhat obscure, but it's the only way I could find to get the version of Moodle with only "teacher" level access.
As a teacher, you should be able to create a backup of any of your courses (though this capability may have been removed in the Moodle you're using). Backups are just zip files, but instead have a .mbz extension. If you change this extension to .zip, you'll be able to extract the zip. With the zip extracted, open "moodle_backup.xml", in there you should find the "moodle_release" item somewhere near the top, giving you the version of Moodle used to create the backup.

- 484
- 3
- 6
-
1This method has worked across all versions of Moodle 2.0+ that I've tested thus far. An excellent workaround, thanks! – hp43 Jul 30 '12 at 22:57
-
Note that the archive is a `.tar.gz` nowadays, so for unpacking use this extension instead. – Robert Pollak Mar 22 '21 at 09:56
Being a TA, I didn't want to mess around with backups which sounds weird but given my unique position, reasonable (to me).
On the implementation of moodle I use, with TA privilege, a link to moodle docs is present at the bottom of the page and if you open this link, it takes you to the moodle docs page with moodle_url/moodle_version/___
.
Maybe this is peculiar to my system, but I believe it's a default setting thing.

- 21
- 1
The most dirty way to do so when no admin or file access, is doing differs from public files between versions. As example, index.php file can be 1024Kb lenght on v1.x and 1033Kb lenght on version 1.2.
Also, check for existance/non existance of a set of files is a common way (css, html, js, icon, etc)
I will edit this again if i find a specific solution.
First edit: For versions 19 or above, you can check version direcly from readme.txt file at https://github.com/moodle/moodle/blob/MOODLE_19_STABLE/README.txt

- 1,986
- 3
- 32
- 45
-
-
1I don't know the focus of your question. Any file can be changed by its owner, so, check for index.php filesize is not best idea, due to it's obviety. This is why we must digg for little details. As i see, moddle has stopping editing versions of non important files to avoid version detection. – m3nda Mar 10 '15 at 06:29
If you don't even have an account on the instance, you may still be able to find out the version. Any authentication errors in the API will return an error message of the form:
[{
"error":true,
"exception":{
"message":"Course or activity not accessible.",
"errorcode":"requireloginerror",
"link":"https:\/\/moodle.example.com\/",
"moreinfourl":"http:\/\/docs.moodle.org\/36\/en\/error\/moodle\/requireloginerror"
}
}]
And the moreinfourl contains an approximate version number (in this case 3.6). For me, this page was requested when I visited the login page for the instance - a POST request to
https://moodle.example.com/lib/ajax/service.php?sesskey=JQrdIcgMn4&info=core_fetch_notifications

- 133
- 7
My helper function here: https://gist.github.com/tigusigalpa/af051a9112512b1b0369572b5dbea2fd
function checkMoodleVersion($version, $checkfor = 'all', $compare = '<=') {
global $CFG;
$versions = [
'3.1' => [
'version' => '2016052300',
'release' => '3.1'
],
'3.2' => [
'version' => '2016120500',
'release' => '3.2'
],
'3.3' => [
'version' => '2017051500',
'release' => '3.3'
],
'3.4' => [
'version' => '2017111300',
'release' => '3.4'
],
'3.5' => [
'version' => '2018051700',
'release' => '3.5'
],
'3.6' => [
'version' => '2018120300',
'release' => '3.6'
]
];
switch ($checkfor) {
case 'all':
if (isset($versions[$version]['version'])) {
return version_compare($versions[$version]['version'], $CFG->version, $compare) &&
version_compare($version, $CFG->release, $compare);
}
break;
case 'version':
case 'release':
if (isset($versions[$version][$checkfor])) {
return version_compare($versions[$version][$checkfor], $CFG->$checkfor, $compare);
}
break;
}
return false;
}

- 755
- 1
- 10
- 22
Not by default as this could be used to harvest out of date moodle sites.
You could create a script to do this fairly easily, eg:
<?php
require_once('config.php');
echo 'Version: '.$CFG->version;
echo 'Humand readable release: '.$CFG->release;

- 575
- 4
- 12
-
2For that script to work, would I not need to have 'admin' access? I don't think that config.php is available to users on a teacher level. – hp43 Jul 20 '12 at 16:51
-
1This script needs file access, not just user privileges. Has no diference about open config.php file then see it... As extra of that comment, for other similar situations, you can fetch version based on public files/paths. Just wath at GIT/SVN for changes between versions :D – m3nda Dec 15 '14 at 12:55