Pull Questionnaire data from command line?

Pull Questionnaire data from command line?

by James Battat -
Number of replies: 3

Hi again,

Related to my earlier post (see:  http://moodle.org/mod/forum/discuss.php?d=209411), I'd love to be able to grab Questionnaire responses from my course website without going through the web interface. 

Is it possible to "Download in text format" from a command line (e.g. via something similar to wget or curl), rather than by clicking on a link in a web browser?  Is there a Moodle API for pulling data from a course (I couldn't find anything online about this, so it may be a long shot...)

Thanks,
James

Average of ratings: -
In reply to James Battat

Re: Pull Questionnaire data from command line?

by Bob Puffer -

wget "http://YOURMOODLEROOT/mod/questionnaire/report.php?instance=5876&sid=3978&action='dcsv'&runcron=1&choicecodes=0"

sid= mdl_questionnaire_survey id for the questionnaire being used

instance = mdl_questionnaire id for the questionnaire being used

In reply to Bob Puffer

Re: Pull Questionnaire data from command line?

by James Battat -

Bob,

Thanks for the reply.  A couple of follow-up questions:

1) This command downloads the Moodle username/password identification page.  Is there a way to take care of the moodle account login as well from the command line?  The --user=and --password= options do not do it.  Pehaps with certificates?  Even if I were prompted at the command line for a username and password, this would be a win.

2) It's not clear to me how you would know the sid and instance numbers without using the browser interface in the first place.  Any recommendations there?  I suppose that when the Questionnaire was created I could log the sid and instance for later use...

Thanks again,
James

In reply to James Battat

Re: Pull Questionnaire data from command line?

by Bob Puffer -

Ahh, yes, I had to comment out the require_login() line in report.php in order for this to work.  So, the risk, someone would need command line access to your server with an account having execute capabilities to your MOODLEROOT and need to know the sid and the instanceid in order to surreptiously download reports.