Index: type/webwork/instructorpreview.php =================================================================== --- type/webwork/instructorpreview.php (revision 557) +++ type/webwork/instructorpreview.php (working copy) @@ -71,19 +71,18 @@ } else { $questions[$id]->maxgrade = $questions[$id]->defaultgrade; } + + $cm = get_coursemodule_from_instance("quiz", $quiz->id, $quiz->course); + $context = get_context_instance(CONTEXT_MODULE, $cm->id); + if (!has_capability('mod/quiz:preview', $context)) { + error("You can't preview these questions!"); + } + $quiz->id = 0; // just for safety $quiz->questions = $id; + - if (!$category = get_record("question_categories", "id", $questions[$id]->category)) { - error("This question doesn't belong to a valid category!"); - } - - if (!has_capability('moodle/question:manage', get_context_instance(CONTEXT_COURSE, $category->course)) and !$category->publish) { - error("You can't preview these questions!"); - } - $quiz->course = $category->course; - // Load the question type specific information if (!get_question_options($questions)) { error(get_string('newattemptfail', 'quiz')); Index: type/webwork/emailinstructor.php =================================================================== --- type/webwork/emailinstructor.php (revision 557) +++ type/webwork/emailinstructor.php (working copy) @@ -103,9 +103,11 @@ $message = $info . $message; $msghtml = $message; $msgtext = html_to_text($message); - $context = get_context_instance(CONTEXT_COURSE, $course->id); + $cm = get_coursemodule_from_instance("quiz", $quiz->id, $course->id); + $context = get_context_instance(CONTEXT_MODULE, $cm->id); + $groups = groups_get_user_groups($course->id, $USER->id); $sentsomewhere = false; - if ($users = get_users_by_capability($context, 'moodle/course:viewcoursegrades')) { + if ($users = get_users_by_capability($context, 'mod/quiz:viewreports', '', '', '', '', $groups[0], '', false, false, true)) { foreach ($users as $user) { if(email_to_user($user,$USER,get_string('wwquestion','qtype_webwork'),$msgtext,$msghtml,NULL,NULL,$USER->email,$USER->email,$USER->firstname . ' ' . $USER->lastname)) { $sentsomewhere = true; Index: format/webwork/format.php =================================================================== --- format/webwork/format.php (revision 557) +++ format/webwork/format.php (working copy) @@ -155,7 +155,8 @@ $qdiff = $qend-$qstart; echo "Generated ~($qdiff secs)
"; $question->webwork = $wwquestion; - $question->questiontext = addslashes(base64_decode($wwquestion->render(0,array(),0))); + $answers = array(); + $question->questiontext = addslashes(base64_decode($wwquestion->render(0,$answers,0))); $question->questiontextformat = 1; unset($question->code); unset($question->codecheck);