require_login($course->id, false, $cm);
- if (($USER->id != $user->id) && !isteacher($course->id)) {
+ if (($USER->id != $user->id) && !has_capability('mod/assignment:grade', get_context_instance(CONTEXT_MODULE, $cm->id))) {
error("You can not view this assignment");
}
$mod_hotpot_capabilities = array(
- 'mod/hotpot:view' => array(
+ 'mod/hotpot:attempt' => array(
'captype' => 'read',
'contextlevel' => CONTEXT_MODULE,
'coursecreator' => CAP_ALLOW,
'admin' => CAP_ALLOW
)
+ ),
+
+ 'mod/hotpot:viewreport' => array(
+
+ 'captype' => 'read',
+ 'contextlevel' => CONTEXT_MODULE,
+ 'legacy' => array(
+ 'guest' => CAP_PREVENT,
+ 'student' => CAP_PREVENT,
+ 'teacher' => CAP_ALLOW,
+ 'editingteacher' => CAP_ALLOW,
+ 'coursecreator' => CAP_ALLOW,
+ 'admin' => CAP_ALLOW
+ )
+ ),
+
+ 'mod/hotpot:grade' => array(
+
+ 'captype' => 'read',
+ 'contextlevel' => CONTEXT_MODULE,
+ 'legacy' => array(
+ 'guest' => CAP_PREVENT,
+ 'student' => CAP_PREVENT,
+ 'teacher' => CAP_ALLOW,
+ 'editingteacher' => CAP_ALLOW,
+ 'coursecreator' => CAP_ALLOW,
+ 'admin' => CAP_ALLOW
+ )
+ ),
+
+ 'mod/hotpot:deleteattempt' => array(
+
+ 'captype' => 'read',
+ 'contextlevel' => CONTEXT_MODULE,
+ 'legacy' => array(
+ 'guest' => CAP_PREVENT,
+ 'student' => CAP_PREVENT,
+ 'teacher' => CAP_PREVENT,
+ 'editingteacher' => CAP_ALLOW,
+ 'coursecreator' => CAP_ALLOW,
+ 'admin' => CAP_ALLOW
+ )
)
);
/// Code fragment to define the version of hotpot
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
-$module->version = 2006080900; // release date of this version (see note below)
+$module->version = 2006083100; // release date of this version (see note below)
$module->release = 'v2.2.0'; // human-friendly version name (used in mod/hotpot/lib.php)
$module->requires = 2006080900; // Requires this Moodle version
$module->cron = 0; // period for cron to check this module (secs)
}
require_login($course->id, false, $cm);
- $isteacher = isteacher($course->id);
+ $isteacher = has_capability('mod/quiz:grade', get_context_instance(CONTEXT_MODULE, $cm->id));
$coursecontext = get_context_instance(CONTEXT_COURSE, $id); // course context
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
}
- if (isteacher($course)) {
+ if has_capability('mod/quiz:grade', get_context_instance(CONTEXT_MODULE, $course)) {
$grades = "(" . $activity->content->sumgrades . " / " . $activity->content->maxgrade . ") ";
echo "<a href=\"$CFG->wwwroot/mod/quiz/review.php?q="
. $activity->instance . "&attempt="
}
} else {
require_login($questioncategory->course);
- if (!isteacher($questioncategory->course)) {
- error('Access not allowed');
- }
+ $cm = get_coursemodule_from_instance('quiz', $quizid);
+ require_capability('mod/quiz:preview', get_context_instance(CONTEXT_MODULE, $cm->id));
}
} else {
if (!($quiz = get_record('quiz', 'id', $quizid))) {
$attempt->layout = $quizquestions;
//Set the preview field (code from upgrade)
- if (isteacher($restore->course_id,$attempt->userid)) {
+ $cm = get_coursemodule_from_instance('quiz', $quiz_id);
+ if (has_capability('mod/quiz:preview', get_context_instance(CONTEXT_MODULE, $cm->id))) {
$attempt->preview = 1;
}
require_login($course->id, false, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$coursecontext = get_context_instance(CONTEXT_COURSE, $cm->course);
- $isteacher = isteacher($course->id);
+ $isteacher = has_capability('mod/quiz:preview', get_context_instance(CONTEXT_MODULE, $cm->id));
$options = quiz_get_reviewoptions($quiz, $attempt, $context);
$popup = $isteacher ? 0 : $quiz->popup; // Controls whether this is shown in a javascript-protected window.