Moodle 2.7 Create Quiz from Outside

Moodle 2.7 Create Quiz from Outside

by Karl Morey -
Number of replies: 14

Hi folks!

My team and I are trying to develop some LTI-style intercommunications between differing platforms, and one of our goals was to be able to more or less "import" a full quiz directly in to Moodle.

My question to you fine folks is in regard to the normal process of creating a quiz by hand. What calls are made in the actual PHP that I'd need to extend (or at least emulate) in order to do this over, for example, a web service call? I know the structure of the web service API and such--I'm banging my head trying to follow the process of tacking a quiz on to a course.

Thanks for reading!

Average of ratings: -
In reply to Karl Morey

Re: Moodle 2.7 Create Quiz from Outside

by dawn alderson -

Karl,

I will warn you now-I get on peeps pip for asking a question with one word...

Why?

Can you give some more info...it is otherwise (to me) unjustified for L&T.

Please feel free to ignore me too, if this confuses the issue.

Cheers, smile

Dawn

In reply to Karl Morey

Re: Moodle 2.7 Create Quiz from Outside

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I don't understand what your question has got to do with LTI.

http://docs.moodle.org/dev/Finding_your_way_into_the_Moodle_code is good generic advice.

However, if you want a single thing to look at, this test mod/quiz/tests/attempt_walkthrough_test.php is probably a good thing to read.

In reply to Tim Hunt

Re: Moodle 2.7 Create Quiz from Outside

by Karl Morey -

Hi Tim,

Our goal is to take what is effectively a quiz from a different LMS and cross the whole thing--quiz, questions, and all--wholesale into Moodle. We've figured out how to add questions to the bank (at least in 2.5.5), it's just the quiz itself.

It *looks* to me like I want to invoke create_module and then, maybe add_course_module? Or add_course_cm_to_section? This is where I'm starting to trip up.

Does this make it any clearer?

In reply to Karl Morey

Re: Moodle 2.7 Create Quiz from Outside

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

I could understand wanting people to take Moodle quizzes from another LMS using LTI, as it is something I attempted to do and then got distracted. But I don't know why you would create/take a quiz in a different LMS from within Moodle. Could you elaborate?

In reply to Marcus Green

Re: Moodle 2.7 Create Quiz from Outside

by Karl Morey -

I'm sorry, I must be explaining it poorly.

The goal is to use the quiz, start to finish, in the other system. We want to take advantage of Moodle's gradebooking utility, though, because holy cow is it exactly what we're looking for. Our approach, then, is to create/take the quiz on "our" end, submit the whole shebang to Moodle, and have it cached in the database for grading purposes.

In reply to Karl Morey

Re: Moodle 2.7 Create Quiz from Outside

by dawn alderson -

Marcus, love it when peeps repeat my point-ta.

The elephant in the room here remains to be 'why'?

What are you grasping for Karl? Why does it sound to me that your reach extends further than your grasp?

Sorry, dialogue is healthy-I promise ;)

Dawn

In reply to dawn alderson

Re: Moodle 2.7 Create Quiz from Outside

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

So you want to create the quiz in your LMS, the student takes the quiz in your LMS but the results are written to the Moodle LMS?

Why not use LTI to allow the student to seamlessly take the Moodle quiz and at the end they are in your LMS (the magic of LTI)


In reply to Marcus Green

Re: Moodle 2.7 Create Quiz from Outside

by Karl Morey -

Primarily because the quiz content will have already existed on our side as opposed to the Moodle side. This is ideally for courses that have accumulated plenty of content already, so that a teacher/instructor/whichever noun is appropriate won't have to recreate everything in Moodle.

In reply to Karl Morey

Re: Moodle 2.7 Create Quiz from Outside

by dawn alderson -

right, OK-got you.

Language/code needs to be compatible and database OpSource-for ease, so MySQL....can have separate database management system however...but, hasssley, you will end up running two systems as I understand it e.g. Foxpro...just as an example in terms of DMS- know this from working with other stuff....MySQL fabric...sounds nice and a bit go-lightly on the server (s)....for storage of inports.

Could be wrong.

D

In reply to Karl Morey

Re: Moodle 2.7 Create Quiz from Outside

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I am wonder if you need the whole quiz? Is it enough just to import the final grades into the gradebook?

If so, look at the XML format import/export into the gradebook using a custom grade-item. Or Moodle's LTI module that can link to an external activity and return the grades at the end.

If, however, you want to import an entire quiz, then you will need to work out the API.

Alternatively, look at Moodle's backup and restore system. A Moodle backup is basically a .zip file containing XML. Try exporting a quiz in Moodle and see what you get. To import things into Moodle, sometimes it is easiest to construct a backup file, and then restore it. (And, restoring a backup can be scripted. http://docs.moodle.org/dev/Restore_2.0_for_developers#Automatically_triggering_restore_in_code ). However, it is not always easiest.

Average of ratings: Useful (1)
In reply to Tim Hunt

Re: Moodle 2.7 Create Quiz from Outside

by dawn alderson -

am thinking work out the API is a good suggestion.

Reason:

there may be a need to draw on those questions to aid the creation of summative assess.


In reply to Tim Hunt

Re: Moodle 2.7 Create Quiz from Outside

by Binoj D -

API is an interesting option. I would also allow people to take advantage of the robust quizzing system of moodle. Can you give pointers on how to make one? 

In reply to Binoj D

Re: Moodle 2.7 Create Quiz from Outside

by dawn alderson -

Hello Binoj D,

Thanks for this.  Gives me a chance to stumble and trip....to learn something along the way, cool.

OK.  My understanding is that you need to aim to evolve the core API...bit of mimicry required.  The main reason for this, arguably, is to do with accessibility and fitness for purpose both in terms of the user. So, in other words, refactoring in view of your spec.  I hear the name of it should drive your development, or at least might be helpful for you and in the long-term for the Moodle quiz feature.

Developing an API....might be akin to the detail/info in the following thread:

https://moodle.org/mod/forum/discuss.php?d=259503

I would suggest having a look at that thread, specifically for some pointers.

A bit limited in terms of knowledge/support here, but may be useful.

On another note, it doesn't seem to me that you just get new questions from another source and insert into the moodle database-STACK plays a part too....and less is more, because you can always add to the api...but tricky to undo it.

Cheers, ( I am sure I will be corrected, if wrong-please ;)

Dawn