if (!isloggedin() or isguest()) {
redirect('view.php?d='.$data->id);
}
+
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
/// If it's hidden then it's don't show anything. :)
- if (empty($cm->visible) and !isteacher($course->id)) {
+ if (empty($cm->visible) and !has_capability('moodle/course:viewhiddenactivities', $context)) {
$strdatabases = get_string("modulenameplural", "data");
$navigation = "<a href=\"index.php?id=$course->id\">$strdatabases</a> ->";
print_header_simple(format_string($data->name), "",
}
/// Can't use this if there are no fields
- if (isteacher($course->id)) {
+ if (has_capability('mod/data:managetemplates', $context)) {
if (!record_exists('data_fields','dataid',$data->id)) { // Brand new database!
redirect($CFG->wwwroot.'/mod/data/field.php?d='.$data->id); // Redirect to field entry
}
}
-/// Check access for participants
- if ((!isteacher($course->id)) && $data->participants == DATA_TEACHERS_ONLY) {
- error (get_string('noaccess','data'));
- }
-
if ($rid) { // So do you have access?
- if (!(isteacher($course->id) or data_isowner($rid)) or !confirm_sesskey() ) {
+ if (!(has_capability('mod/data:manageentries', $context) or data_isowner($rid)) or !confirm_sesskey() ) {
error(get_string('noaccess','data'));
}
}
/// All student edits are marked unapproved by default
$record = get_record('data_records','id',$rid);
- if ($data->approval == 1 || isteacher($course->id)) {
+ if ($data->approval == 1 || has_capability('mod/data:approve', $context)) {
$record->approved = 1;
} else {
$record->approved = 0;
/// Check if maximum number of entry as specified by this database is reached
/// Of course, you can't be stopped if you are an editting teacher! =)
- if (data_atmaxentries($data) and !isteacheredit($course->id)){
+ if (data_atmaxentries($data) and !has_capability('mod/data:manageentries',$context)){
notify (get_string('atmaxentry','data'));
print_footer($course);
exit;
/// Upload records section. Only for teachers and the admin.
- if (isteacher($course->id)) {
+ if (has_capability('mod/data:manageentries',$context)) {
if ($import) {
print_simple_box_start('center','80%');
print_heading(get_string('uploadrecords', 'data'), '', 3);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/data:managetemplates', $context);
-
-
- if (!isteacheredit($course->id)){
- error(get_string('noaccess','data'));
- }
-
-
/************************************
* Data Processing *
-<?php
+<?php
///////////////////////////////////////////////////////////////////////////
// //
// NOTICE OF COPYRIGHT //
require_course_login($course, true, $cm);
/// If it's hidden then it's don't show anything. :)
-if (empty($cm->visible) and !isteacher($course->id)) {
+if (empty($cm->visible) and !has_capability('moodle/course:viewhiddenactivities',get_context_instance(CONTEXT_MODULE, $cm->id))) {
$strdatabases = get_string("modulenameplural", "data");
$navigation = "<a href=\"index.php?id=$course->id\">$strdatabases</a> ->";
print_header_simple(format_string($data->name), "",
}
/// If we have an empty Database then redirect because this page is useless without data
-if (isteacher($course->id)) {
+if (has_capability('mod/data:managetemplates', $context)) {
if (!record_exists('data_fields','dataid',$data->id)) { // Brand new database!
redirect($CFG->wwwroot.'/mod/data/field.php?d='.$data->id); // Redirect to field entry
}
}
}
- ///checking for participants
- // needs fixing?
- /*
- if ((!isteacher($course->id)) && $data->participants == DATA_TEACHERS_ONLY) {
- error ('students are not allowed to participate in this activity');
- }
-
if ($rid){ //editting a record, do you have access to edit this?
- if (!isteacher($course->id) or !data_isowner($rid) or !confirm_sesskey()){
+ if (!has_capability('mod/data:manageentries', $context) or !data_isowner($rid) or !confirm_sesskey()){
error (get_string('noaccess','data'));
}
- }*/
+ }
/// Print the page header
}
$currentgroup = get_current_group($course->id);
- if ($currentgroup and isteacheredit($course->id)) {
+ if ($currentgroup and has_capability('mod/data:manageentries', $context)) {
$group = get_record("groups", "id", $currentgroup);
$groupname = " ($group->name)";
} else {
$record->groupid = $groupid;
$record->timecreated = $record->timemodified = time();
if (has_capability('mod/data:approve', $context)) {
- //if (isteacher($data->course)) {
$record->approved = 1;
} else {
$record->approved = 0;
foreach ($fieldrecords as $fieldrecord) {
$fields[]= data_get_field($fieldrecord, $data);
}
- $isteacher = isteacher($data->course);
+ $isteacher = has_capability('mod/data:managetemplates', $context);
}
if (empty($records)) {
require_login($course->id);
-if (!isteacher($course->id)) {
- error('Must be a teacher to Import Database');
-}
-
+require_capability('mod/data:managetemplates', get_context_instance(CONTEXT_MODULE, $cm->id))
/* get the list of standard presets found in /mod/data/preset */
$presets = array();
echo "<th><a href=\"report.php?id=$id&sort=firstname\">$strname</a>";
echo "<th width=\"100%\"><a href=\"report.php?id=$id&sort=rating\">$strrating</a>";
foreach ($ratings as $rating) {
- if (isteacher($data->course)) {
+ if (has_capability('mod/data:manageentries', $context)) {
echo '<tr class="forumpostheadertopic">';
} else {
echo '<tr class="forumpostheader">';
//Check if the user is a teacher
$bypassteacher = 1; //This means NO (by default)
- if (isteacher($courseid)) {
+ if (has_capability('mod/glossary:manageentries', get_context_instance(CONTEXT_COURSE, $courseid))) {
$bypassteacher = 0; //This means YES
}
$glos = $glossary->id;
}
- if (!isteacher($glossary->course)) {
+ if (!has_capability('mod/glossary:manageentries', get_context_instance(CONTEXT_COURSE, $glossary->course))) {
$glossarymodule = get_record("modules", "name", "glossary");
$onlyvisible = " AND g.id = cm.instance AND cm.visible = 1 AND cm.module = $glossarymodule->id";
$onlyvisibletable = ", {$CFG->prefix}course_modules cm";
if (!$cm = get_coursemodule_from_instance("glossary", $glossary->id)) {
error("Could not determine which course module this belonged to!");
}
- if (!$cm->visible and !isteacher($cm->course)) {
+ if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $cm->id))) {
redirect($CFG->wwwroot.'/course/view.php?id='.$cm->course, get_string('activityiscurrentlyhidden'));
}
$entry->cmid = $cm->id;
$navigation = "<a href=\"../../course/view.php?id=$course->id\">$course->shortname</a> ->";
require_login($course->id);
}
- if (!$cm->visible and !isteacher($course->id)) {
+ if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', $context)) {
print_header();
notice(get_string("activityiscurrentlyhidden"));
}
/// the "Print" icon
$printicon = '';
if ( $isuserframe and $mode != 'search') {
- if (isteacher($course->id) or $glossary->allowprintview) {
+ if (has_capability('mod/glossary:manageentries', $context) or $glossary->allowprintview) {
$printicon = " <a title =\"". get_string("printerfriendly","glossary") . "\" target=\"printview\" href=\"print.php?id=$cm->id&mode=$mode&hook=$hook&sortkey=$sortkey&sortorder=$sortorder&offset=$offset\"><img border=\"0\" src=\"print.gif\" alt=\"\" /></a>";
}
}
require_once("lib.php");
$id = required_param("id"); // course
-
+ $coursecontext = get_context_instance(CONTEXT_COURSE, $id);
+
if (! $course = get_record("course", "id", $id)) {
error("Course ID is incorrect");
}
MAX(a.score) AS maxscore
";
$select = "a.hotpot IN ($hotpotids)";
- if (isteacher($course->id)) {
+ if (has_capability('mod/hotpot:viewreport', $coursecontext)) {
// do nothing (=get all users)
} else {
// restrict results to this user only
array_push($table->head, $title);
array_push($table->align, "center");
}
- if (isteacheredit($course->id)) {
+ if (has_capability('moodle/course:manageactivities', $coursecontext)) {
array_push($table->head, $strupdate);
array_push($table->align, "center");
}
array_push($table->align,
"left", "left", "center", "left"
);
- if (isadmin()) {
+ if (has_capability('mod/hotpot:grade', $coursecontext)) {
array_push($table->head, $strregrade);
array_push($table->align, "center");
}
$bestscore = " ";
} else {
+
+ $cm = get_coursemodule_from_instance('hotpot', $hotpot->id);
// report number of attempts and users
$report = get_string("viewallreports","quiz", $totals[$hotpot->id]->attemptcount);
- if (isteacher($course->id)) {
+ if (has_capability('mod/hotpot:viewreport', get_context_instance(CONTEXT_MODULE, $cm->id))) {
$report .= " (".$totals[$hotpot->id]->usercount." $strusers)";
}
$report = '<a href="report.php?hp='.$hotpot->id.'">'.$report.'</a>';
array_push($data, $printsection);
}
- if (isteacheredit($course->id)) {
+ if (has_capability('moodle/course:manageactivities', $coursecontext)) {
$updatebutton = ''
. '<form target="'.$CFG->framename.'" method="get" action="'.$CFG->wwwroot.'/course/mod.php">'
. '<input type="hidden" name="update" value="'.$hotpot->coursemodule.'" />'
if ($rawmods = get_records_sql($query)) {
// cache $isteacher setting
- $isteacher = isteacher($course->id);
+
+ $isteacher = has_capability('mod/hotpot:viewreport', get_context_instance(CONTEXT_MODULE, $course->id));
$explodesection = array();
$order = array();
$href = "$CFG->wwwroot/mod/hotpot/view.php?hp=$activity->instance";
print '<a href="'.$href.'">'.$activity->name.'</a> - ';
}
- if (isteacher($course)) {
+ if (has_capability('mod/hotpot:viewreport',get_context_instance(CONTEXT_COURSE, $course))) {
// score (with link to attempt details)
$href = "$CFG->wwwroot/mod/hotpot/review.php?hp=$activity->instance&attempt=".$activity->content->attemptid;
print '<a href="'.$href.'">('.hotpot_format_score($activity->content).')</a> ';
}
}
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
// set homeurl of couse (for error messages)
$course_homeurl = "$CFG->wwwroot/course/view.php?id=$course->id";
require_login($course->id);
// get report mode
- if (isteacher($course->id)) {
+ if (has_capability('mod/hotpot:viewreport',$context)) {
$mode = optional_param("mode", "overview");
} else {
// students have no choice
$formdata = array(
'mode' => $mode,
'reportcourse' => isadmin() ? optional_param('reportcourse', get_user_preferences('hotpot_reportcourse', 'this')) : 'this',
- 'reportusers' => isteacher($course->id) ? optional_param('reportusers', get_user_preferences('hotpot_reportusers', 'all')) : 'this',
+ 'reportusers' => has_capability('mod/hotpot:viewreport',$context) ? optional_param('reportusers', get_user_preferences('hotpot_reportusers', 'all')) : 'this',
'reportattempts' => optional_param('reportattempts', get_user_preferences('hotpot_reportattempts', 'all')),
'reportformat' => optional_param('reportformat', 'htm'),
'reportshowlegend' => optional_param('reportshowlegend', get_user_preferences('hotpot_reportshowlegend', '0')),
// print page header. if required
if ($formdata['reportformat']=='htm') {
hotpot_print_report_heading($course, $cm, $hotpot, $mode);
- if (isteacher($course->id)) {
+ if (has_capability('mod/hotpot:viewreport',$context)) {
hotpot_print_report_selector($course, $hotpot, $formdata);
}
}
// delete selected attempts, if any
- if (isteacher($course->id)) {
+ if (has_capability('mod/hotpot:deleteattempt',$context)) {
$del = optional_param("del", "");
hotpot_delete_selected_attempts($hotpot, $del);
}
$navigation = "<a href=index.php?id=$course->id>$strmodulenameplural</a> -> ";
$navigation .= "<a href=\"view.php?id=$cm->id\">$hotpot->name</a> -> ";
- if (isteacher($course->id)) {
+ if (has_capability('mod/hotpot:viewreport',$context)) {
if ($mode=='overview' || $mode=='simplestat' || $mode=='fullstat') {
$module = "quiz";
} else {
// set align and wrap\r
$this->set_align_and_wrap($table);\r
// is link to review allowed?\r
- $allow_review = ($is_html && (isteacher($course->id) || $hotpot->review));\r
+ $allow_review = ($is_html && (has_capability('mod/hotpot:viewreport',get_context_instance(CONTEXT_COURSE, $course->id)) || $hotpot->review));\r
// initialize array of data values\r
$this->data = array();\r
// set exercise data values\r
$nobr_start = $is_html ? '<nobr>' : '';
$nobr_end = $is_html ? '</nobr>' : '';
// is review allowed? (do this once here, to save time later)
- $allow_review = ($is_html && (isteacher($course->id) || $hotpot->review));
+ $allow_review = ($is_html && (has_capability('mod/hotpot:viewreport',get_context_instance(CONTEXT_COURSE, $course->id)) || $hotpot->review));
// assume penalties column is NOT required
$show_penalties = false;
// initialize $table
}\r
$attemptnumber = $attempt->attempt;\r
$starttime = trim(userdate($attempt->timestart, $strtimeformat));\r
- if ($is_html && isset($attempt->score) && (isteacher($course->id) || $hotpot->review)) {\r
+ if ($is_html && isset($attempt->score) && (has_capability('mod/hotpot:viewreport',get_context_instance(CONTEXT_COURSE, $course->id)) || $hotpot->review)) {\r
$attemptnumber = '<a href="review.php?hp='.$hotpot->id.'&attempt='.$attempt->id.'">'.$attemptnumber.'</a>';\r
$starttime = '<a href="review.php?hp='.$hotpot->id.'&attempt='.$attempt->id.'">'.$starttime.'</a>';\r
}\r
- if ($is_html && isteacher($course->id)) {\r
+ if ($is_html && has_capability('mod/hotpot:viewreport',get_context_instance(CONTEXT_COURSE, $course))) {\r
$checkbox = '<input type=checkbox name="box'.$attempt->clickreportid.'" value="'.$attempt->clickreportid.'">'.$spacer;\r
} else {\r
$checkbox = '';\r
// remove final 'hr' from data rows\r
array_pop($table->data);\r
// add the "delete" form to the table\r
- if ($options['reportformat']=='htm' && isteacher($course->id)) {\r
+ if ($options['reportformat']=='htm' && has_capability('mod/hotpot:viewreport',get_context_instance(CONTEXT_COURSE, $course->id))) {\r
$strdeletecheck = get_string('deleteattemptcheck','quiz');\r
$table->start = $this->deleteform_javascript();\r
$table->start .= '<form method="post" action="report.php" name="deleteform" onsubmit="'."return deletecheck('".$strdeletecheck."', 'selection')".'">'."\n";\r
$is_html = ($options['reportformat']=='htm');
$blank = ($download ? '' : ' ');
$no_value = ($download ? '' : '-');
- $allow_review = true; // ($options['reportformat']=='htm' && (isteacher($course->id) || $hotpot->review));
+ $allow_review = true;
// start the table
unset($table);
$table->border = 1;
if (! $attempt = get_record("hotpot_attempts", "id", $attempt)) {
error("Attempt ID was incorrect");
}
+
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_login($course->id);
- if (!isteacher($course->id)) {
+ if (!has_capability('mod/hotpot:viewreport',$context)) {
if (!$hotpot->review) {
error(get_string("noreview", "quiz"));
}
print_heading($hotpot->name);
hotpot_print_attempt_summary($hotpot, $attempt);
hotpot_print_review_buttons($course, $hotpot, $attempt);
- $action = isteacher($course->id) ? optional_param('action') : '';
+ $action = has_capability('mod/hotpot:viewreport',$context) ? optional_param('action') : '';
if ($action) {
$xml = get_field('hotpot_details', 'details', 'attempt', $attempt->id);
print '<hr>';
print "\n".'<table border="0" align="center" cellpadding="2" cellspacing="2" class="generaltable">';
print "\n<tr>\n".'<td align="center">';
print_single_button("report.php?hp=$hotpot->id", NULL, get_string('continue'), 'post');
- if (isteacher($course->id) && record_exists('hotpot_details', 'attempt', $attempt->id)) {
+ if (has_capability('mod/hotpot:viewreport',$context) && record_exists('hotpot_details', 'attempt', $attempt->id)) {
print "</td>\n".'<td align="center">';
print_single_button("review.php?hp=$hotpot->id&attempt=$attempt->id&action=showxmlsource", NULL, get_string('showxmlsource', 'hotpot'), 'post');
print "</td>\n".'<td align="center">';
$params->course = required_param('course');
$params->reference = required_param('reference');
require_login($params->course);
- if (!isteacher($params->course)) {
+ if (!has_capability('mod/hotpot:viewreport',get_context_instance(CONTEXT_COURSE, $params->course))) {
error("You are not allowed to view this page!");
}
if (isadmin()) {
if (! $cm = get_coursemodule_from_instance("hotpot", $hotpot->id, $course->id)) {
error("Course Module ID was incorrect");
}
+
}
require_login($course->id);
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
}
// set nextpage (for error messages)
$nextpage = "$CFG->wwwroot/course/view.php?id=$course->id";
$loggedinas = '<span class="logininfo">'.user_login_string($course, $USER).'</span>';
$time = time();
$hppassword = optional_param('hppassword');
- if (HOTPOT_FIRST_ATTEMPT && !isteacher($course->id)) {
+ if (HOTPOT_FIRST_ATTEMPT && !has_capability('mod/hotpot:grade', $context)) {
// check this quiz is available to this student
// error message, if quiz is unavailable
$error = '';
require_login($course->id, false);
- if (!isteacher($course->id)) {
- error("You can't modify this course!");
- }
+ require_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $course->id));
$streditingasurvey = get_string("editingasurvey", "survey");
$strsurveys = get_string("modulenameplural", "survey");
}
require_login($course->id, false);
-
- if (!isteacher($course->id)) {
- error("Sorry, only teachers can see this.");
- }
+ require_capability('mod/survey:download', get_context_instance(CONTEXT_MODULE, $cm->id)) ;
if (! $survey = get_record("survey", "id", $cm->instance)) {
error("Survey ID was incorrect");
require_login($course->id, false, $cm);
$groupmode = groupmode($course, $cm); // Groups are being used
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
- if (!isteacher($course->id)) {
+ if (!has_capability('mod/survey:readresponses', $context)) {
if ($type != "student.png" or $sid != $USER->id ) {
error("Sorry, you aren't allowed to see this.");
} else if ($groupmode and !ismember($group)) {