Getting moodle version info, no admin access - moodle

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.

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

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.

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.

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

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

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;
}

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;

Related

How do we add swift compile flag to `gym` when using fastlane

There are not much documentation about this here in the office documentation page https://docs.fastlane.tools/actions/gym/.
The only thing that mentioned compile flag is:
xcargs:
Pass additional arguments to xcodebuild for the build phase. Be sure to quote the setting names and values e.g. OTHER_LDFLAGS="-ObjC -lstdc++"
This is what we have currently:
gym(options.merge(:export_xcargs => "-allowProvisioningUpdates",
:export_method => "development"))
We would like now adding this flag to our build:
-Xfrontend -warn-long-expression-type-checking=100
We don't want to add it to Xcode project file like this https://github.com/fastred/Optimizing-Swift-Build-Times since we only want this check on the build machine which uses fastlane.
So this is what we tried:
gym(options.merge(:export_xcargs => "-allowProvisioningUpdates",
:export_method => "development",
:xcargs => "-Xfrontend -warn-long-expression-type-checking=100"))
But it keeps complaining about this error:
xcodebuild: error: invalid option '-Xfrontend'
How do we add this flag properly?
This works!
gym(options.merge(:export_xcargs => "-allowProvisioningUpdates",
:export_method => "development",
:xcargs => "OTHER_SWIFT_FLAGS='-Xfrontend -warn-long-expression-type-checking=100'"))
Since it's gym, use export_xcargs: instead of xcargs: and see related answer here if you need to assign a value for the flag - https://stackoverflow.com/a/57972046/4970749

Zend Framework 3 share doctrine models between modules of the same project

I am new into Zend Framework 3 programming.
Previously we create a project having all database table's mapping included in one particulare module.
Now, we need to create another module into the same project. So we would like to put outside from the first module the database mapping objects in order to shared tha classes between the both modules.
I try to create a new module only for the mapping, but without succes. The namespaces doesn't existes.
After I look for solution like using ServiceManager, but I didn't really understand how to used it.
Do you know if there is another solution than using a ServiceManager ? And if not, have I change all my previous code using objects included simply with the key word use, in order to use the ServiceManager ?
Thanks.
Finaly in my solution I create a module containing only the sources files for the doctrine mapping under src directory.
/module
/MyApplication
/src
/config
/module.config.php
/Common
/src
/DoctrinMapping
/Entities
composer.json
In composer.json I put :
"autoload": {
"psr-4": {
"MyApplication\\": "module/MyApplication/src/"
,"Common\\":"module/Common/src/"
}
}
At the project root I execute the commande line :
composer dump-autoload
After into module.config.php of the my specifique application I define the doctrine reference as :
,'doctrine' =>
[
'driver' =>
[
'common_entities' =>
[
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver'
,'cache' => 'array'
,'paths' => array(__DIR__ . '/../../Common/src/DoctrineMapping/Entities')
],
'orm_default' =>
[
'drivers' =>
[
'Common\DoctrineMapping\Entities' => 'common_entities'
]
]
]
]
That works, but I don't know if this is the best solution to apply.

Ocramius / Doctrine & Zend validate-schema Acess denied

I am doing the tutorial from Marco Pivetta for Ocramius and Zend, I am stuck at the step where I should validate the schema. (See here: Link to the tutorial )
So actually I am stuck at the same point like at this question, already asked on stackoverflow.
The author on this question found the solution obviously, but for me it's not working.
He writes
And, if you use gitBash don't forget if you have tested your APPLICATION_ENV variable in application.config.php like this tutorial Zf2 advances config setup do in bash_profile file.
export APPLICATION_ENV="development"
I did this in my application.config.php
$env = getenv('APP_ENV') ?: 'development';
// Use the $env value to determine which modules to load
$modules = array(
'ZendDeveloperTools',
'Application',
'DoctrineModule',
'DoctrineORMModule',
);
if ($env == 'production') {
$modules[] = 'ZendDeveloperTools';
}
return array(
'modules' => $modules,
[...]
But I still get the error
[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'username'#'localhost' (using password: YES)
I have to say though, I couldn't figure out what the author means with the
[... ] bash_profile file:
export APPLICATION_ENV="development
His sentence is written without regarding any grammatical sense.
So the problem is:
Somehow my doctrine.local.php in the autoloads is ignored, I can't figure out why.
I am using GitBash for the
./vendor/bin/doctrine-module orm:validate-schema
command.
Got it:
Make sure you are using GitBash and ZendStudio in administrator mode -.-

Symfony 1.4 I get the wrong values in app.yml

Obviously it is not that simple. Let's start from the beginning: I'm working on a shared project and yesterday I've been asked to add the plugin mgI18n. I followed the readme file step by step, but when it came down to run the command line to create the table used by the plugin, I got this:
database "" does not exists
I searched it, and I found out that sfConfig::get('app_mgI18nPlugin_connection'); returned an empty value. It was weird, because I've done every step right, setting the value in my app.yml and clearing symfony cache, so I logged sfConfig::getAll(); and found out that the only values for 'app_' stored here were the ones from the file app.yml in the plugin folder of kdDoctrineGuardFacebookConnectPlugin. I've already tried removing that file and clearing the cache, obtaining only to lose these values.
Here is the file contents:
project/apps/frontend/config/app.yml
all:
#other values
facebook:
appId: yyy
secret: yyy
cookie: true
script_lang: fr_FR
perms: email
mgI18nPlugin:
connection: doctrine
cultures_available:
fr: Français
en: English
it: Italiano
de: Deutsch
project/plugins/kdDoctrineGuardFacebookConnectPlugin/config/app.yml
all:
facebook:
appId: xxx
secret: xxx
cookie: true
script_lang: fr_FR
perms: email
and this is what I get when I log sfConfig::getAll(); :
array('app_facebook_appId' => 'xxx',
'app_facebook_secret' => 'xxx',
'app_facebook_cookie' => true,
'app_facebook_script_lang' => 'fr_FR',
'app_facebook_perms' => 'email',
)
Why the values for the main app.yml are not loaded? How do I correct this behaviour?
Thank you all in advance for your help, if you need more specifics I'll glady add them
If I understood you well you are in a command line task context (some sfTask). Symfony tasks by default do not run in application context. In most cases just call your task as
./symfony namespace:name --application=frontend
and you will have your configs.
If it is your own task just add it an option with default value in your configure method:
$this->addOptions(array(
new sfCommandOption('application', null, sfCommandOption::PARAMETER_REQUIRED, 'The application name', 'frontend'),
...
)
Plugin settings are loaded correctly, because plugins are configured per project not application (you enable them in ProjectConfiguration, not generated frontendConfiguration class)

Zend_Form - The mimetype of file 'foto.jpg' could not be detected

I have a Zend_Form with file element like this:
->addElement('file', 'image', array(
'required' => false,
'label' => 'Venue Image',
'validators' => array(
array('IsImage', false),
array('Size', false, '2097152'),
array('Upload', false),
),
))
And when I'm using localhost the image is uploaded successfully. But when I move to my hosting the validation error shows for image field. The mimetype of file 'foto.jpg' could not be detected. What can be the reason of this?
same thing happened to me, this was crazy stuff, more than 2 hours trying to figure out what's wrong, here is how to fix it:
install fileinfo extension on linux:
pecl install fileinfo
then you need to add to your php.ini this line:
extension=fileinfo.so
restart your apache and you are done!
*if you server is freeBSD you have to do this:
cd /usr/ports/sysutils/pecl-fileinfo/
make install
If you are using XAMPP and localhost just open your php.ini file and uncomment:
extension=php_fileinfo.dll
From the comments in the ZF Reference Guide:
In order to make IsImage working (and maybe all other mime related validators) on Zend Server on win32 I had to replace "magic.mime" supplied on Zend Server ("\etc") by the one on Apache ("\conf" , file is called "magic") (don't forget to restart Apache).
If it still doesn't work then you could try with these alternatives:
$element->addValidator('Mimetype', false, 'image/jpg');
or
$element->addValidator('Extension', false, 'jpg');