by Colin Matheson.
I was able to make a plugin to add a quiz to a course page
https://github.com/cytochromec/moodle-block-quizlet_import
The code that actually adds the quiz starts on line 234 of quizlet_import.php (pasted below)
//create an object with all of the neccesary information to build a quiz |
$myQuiz=newstdClass(); |
$myQuiz->modulename='quiz'; |
$myQuiz->name=$title; |
$myQuiz->introformat=0; |
$myQuiz->quizpassword=''; |
$myQuiz->course=$id1; |
$myQuiz->section=$sectionNum; |
$myQuiz->timeopen=0; |
$myQuiz->timeclose=0; |
$myQuiz->timelimit=0; |
$myQuiz->grade=$Points; |
$myQuiz->sumgrades=$Points; |
$myQuiz->gradeperiod=0; |
$myQuiz->attempts=1; |
$myQuiz->preferredbehaviour='deferredfeedback'; |
$myQuiz->attemptonlast=0; |
$myQuiz->shufflequestions=0; |
$myQuiz->grademethod=1; |
$myQuiz->questiondecimalpoints=2; |
$myQuiz->visible=1; |
$myQuiz->questionsperpage=1; |
$myQuiz->introeditor=array('text'=>'A matching quiz','format'=>1); |
//all of the review options |
$myQuiz->attemptduring=1; |
$myQuiz->correctnessduring=1; |
$myQuiz->marksduring=1; |
$myQuiz->specificfeedbackduring=1; |
$myQuiz->generalfeedbackduring=1; |
$myQuiz->rightanswerduring=1; |
$myQuiz->overallfeedbackduring=1; |
$myQuiz->attemptimmediately=1; |
$myQuiz->correctnessimmediately=1; |
$myQuiz->marksimmediately=1; |
$myQuiz->specificfeedbackimmediately=1; |
$myQuiz->generalfeedbackimmediately=1; |
$myQuiz->rightanswerimmediately=1; |
$myQuiz->overallfeedbackimmediately=1; |
$myQuiz->marksopen=1; |
$myQuiz->attemptclosed=1; |
$myQuiz->correctnessclosed=1; |
$myQuiz->marksclosed=1; |
$myQuiz->specificfeedbackclosed=1; |
$myQuiz->generalfeedbackclosed=1; |
$myQuiz->rightanswerclosed=1; |
$myQuiz->overallfeedbackclosed=1; |
//actually make the quiz using the function from course/lib.php |
$myQuiz2= create_module($myQuiz); |
//print_object($myQuiz2); |
//get the last added random short answer matching question (which will likely be the one we just added) |
$result=$DB->get_records('question',array('qtype'=>'randomsamatch')); |
$keys=array_keys($result); |
$count=count($keys); |
//add the quiz question |
quiz_add_quiz_question($result[$keys[$count-1]]->id, $myQuiz2, $page=0, $maxmark=null); |