iconer
iconer

Reputation: 387

Moodle add exams from php

I'm developing a web service for moodle to add courses and register users. Currently i'm able to add courses using core_course_create_courses function, but there is a way to add there a way to add assignments or exams to a course in moodle from php?

The functions that i'm using are the following:

    core_user_create_users  
    core_course_get_courses 
    core_course_get_categories  
    core_course_create_courses  
    core_course_create_categories   
    core_group_get_course_groups    
    core_group_create_groups    
    enrol_manual_enrol_users    
    core_group_add_group_members

Any ideas to add assignments and exams to a course?

Upvotes: 0

Views: 585

Answers (1)

Tony
Tony

Reputation: 371

Unfortunately there isn't a web service function to create course modules yet, although it is on the roadmap, and there's a tracker issue for it at https://tracker.moodle.org/browse/MDL-40779 (not yet assigned to a developer though).

If you wanted to create your own, the internal function to add an assignment is assign_add_instance() in https://github.com/moodle/moodle/blob/master/mod/assign/lib.php, and the data you'd need to pass it is all the stuff in the $formdata object, as listed in add_instance() in https://github.com/moodle/moodle/blob/master/mod/assign/locallib.php.

Not sure how you'd add an exam. Maybe you could use the quiz module for this, in which case you'll find the corresponding function in https://github.com/moodle/moodle/blob/master/mod/quiz/lib.php (and https://github.com/moodle/moodle/blob/master/mod/quiz/locallib.php).

Upvotes: 3

Related Questions