} // End if ($lesson->displayleft)
?>
-<?php if($lesson->timed and !isteacher($course->id)) {
+<?php if($lesson->timed and !has_capability('mod/lesson:manage', $context)) {
// code for the clock
print_simple_box_start("right", "150px", "#ffffff", 0);
?>
<form name="pageform" method ="post" action="view.php">
<input type="hidden" name="id" value="<?php echo $cm->id ?>" />
<input type="hidden" name="action" value="navigation" />
-<input type="hidden" name="pageid" value="<?php $newpageid ?>" />
+<input type="hidden" name="pageid" value="<?php echo $newpageid ?>" />
<?php if (isset($USER->modattempts[$lesson->id])) { ?>
<p align="center"><?php print_string("savechangesandeol", "lesson") ?> <br /><br />
// left menu code
// check to see if the user can see the left menu
- if (!isteacher($course->id)) {
+ if (!has_capability('mod/lesson:manage', $context)) {
$lesson->displayleft = lesson_displayleftif($lesson);
}
// This is the warning msg for teachers to inform them that cluster and unseen does not work while logged in as a teacher
- if(isteacher($course->id) and lesson_display_teacher_warning($lesson->id)) {
+ if(has_capability('mod/lesson:manage', $context) and lesson_display_teacher_warning($lesson->id)) {
$warningvars->cluster = get_string("clusterjump", "lesson");
$warningvars->unseen = get_string("unseenpageinbranch", "lesson");
$messages[] = get_string("teacherjumpwarning", "lesson", $warningvars);
// This is the code updates the lesson time for a timed test
// get time information for this user
$outoftime = false;
- if (!isteacher($course->id)) {
+ if (!has_capability('mod/lesson:manage', $context)) {
if (!$timer = get_records_select('lesson_timer', "lessonid = $lesson->id AND userid = $USER->id", 'starttime')) {
error('Error: could not find records');
} else {
}
// Inform teacher that s/he will not see the timer
- if ($lesson->timed and isteacher($course->id)) {
+ if ($lesson->timed and has_capability('mod/lesson:manage', $context)) {
$messages[] = get_string("teachertimerwarning", "lesson");
}
// this is called when jumping to random from a branch table
if($newpageid == LESSON_UNSEENBRANCHPAGE) {
- if (isteacher($course->id)) {
+ if (has_capability('mod/lesson:manage', $context)) {
$newpageid = LESSON_NEXTPAGE;
} else {
$newpageid = lesson_unseen_question_jump($lesson->id, $USER->id, $pageid); // this may return 0
$newpageid = $pageid; // display same page again
} else {
$nretakes = count_records("lesson_grades", "lessonid", $lesson->id, "userid", $USER->id);
- if (isstudent($course->id)) {
+ if (!has_capability('mod/lesson:manage', $context)) {
// record student's attempt
$attempt = new stdClass;
$attempt->lessonid = $lesson->id;
}
}
} elseif ($newpageid == LESSON_UNSEENBRANCHPAGE) {
- if (isteacher($course->id)) {
+ if (has_capability('mod/lesson:manage', $context)) {
if ($page->nextpageid == 0) {
$newpageid = LESSON_EOL;
} else {
} elseif ($newpageid == LESSON_RANDOMPAGE) {
$newpageid = lesson_random_question_jump($lesson->id, $pageid);
} elseif ($newpageid == LESSON_CLUSTERJUMP) {
- if (isteacher($course->id)) {
+ if (has_capability('mod/lesson:manage', $context)) {
if ($page->nextpageid == 0) { // if teacher, go to next page
$newpageid = LESSON_EOL;
} else {
}
lesson_print_header($cm, $course, $lesson, 'navigation', false);
-
+
include($CFG->wwwroot.'/mod/lesson/action/continue.html');
?>
--- /dev/null
+<?php // $Id$
+/**
+ * Capability definitions for the lesson module.
+ *
+ * For naming conventions, see lib/db/access.php.
+ */
+$mod_lesson_capabilities = array(
+
+ 'mod/lesson:view' => array(
+
+ 'captype' => 'read',
+ 'contextlevel' => CONTEXT_MODULE,
+ 'legacy' => array(
+ 'guest' => CAP_PREVENT,
+ 'student' => CAP_ALLOW,
+ 'teacher' => CAP_ALLOW,
+ 'editingteacher' => CAP_ALLOW,
+ 'coursecreator' => CAP_ALLOW,
+ 'admin' => CAP_ALLOW
+ )
+ ),
+
+ 'mod/lesson:edit' => array(
+
+ 'captype' => 'write',
+ 'contextlevel' => CONTEXT_MODULE,
+ 'legacy' => array(
+ 'guest' => CAP_PREVENT,
+ 'student' => CAP_PREVENT,
+ 'teacher' => CAP_PREVENT,
+ 'editingteacher' => CAP_ALLOW,
+ 'coursecreator' => CAP_ALLOW,
+ 'admin' => CAP_ALLOW
+ )
+ ),
+
+ 'mod/lesson:manage' => array(
+
+ 'captype' => 'write',
+ 'contextlevel' => CONTEXT_MODULE,
+ 'legacy' => array(
+ 'guest' => CAP_PREVENT,
+ 'student' => CAP_PREVENT,
+ 'teacher' => CAP_ALLOW,
+ 'editingteacher' => CAP_ALLOW,
+ 'coursecreator' => CAP_ALLOW,
+ 'admin' => CAP_ALLOW
+ )
+ )
+);
require_login($course->id, false);
-
- if (!isteacher($course->id)) {
- error("Only the teacher can import questions!");
- }
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ require_capability('mod/lesson:edit', $context);
$strimportquestions = get_string("importquestions", "lesson");
$strlessons = get_string("modulenameplural", "lesson");
}
require_login($course->id, false);
-
- if (!isteacher($course->id)) {
- error("Only the teacher can import questions!");
- }
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ require_capability('mod/lesson:edit', $context);
$strimportppt = get_string("importppt", "lesson");
$strlessons = get_string("modulenameplural", "lesson");
//Show normal if the mod is visible
$link = "<a href=\"view.php?id=$lesson->coursemodule\">".format_string($lesson->name,true)."</a>";
}
+ $cm = get_coursemodule_from_instance('lesson', $lesson->id);
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
if ($lesson->deadline > $timenow) {
$due = userdate($lesson->deadline);
}
if ($course->format == "weeks" or $course->format == "topics") {
- if (isteacher($course->id)) {
+ if (has_capability('mod/lesson:manage', $context)) {
$grade_value = $lesson->grade;
} else {
// it's a student, show their mean or maximum grade
list($cm, $course, $lesson) = lesson_get_basics($id);
require_login($course->id);
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
/// Set up some general variables
$usehtmleditor = can_use_html_editor();
case 'insertpage':
case 'updatepage':
case 'moveit':
- if (!isteacheredit($course->id)) {
- error('You must be a teacher with editing privileges to access this page.');
- }
+ require_capability('mod/lesson:edit', $context);
case 'continue':
include($CFG->dirroot.'/mod/lesson/action/'.$action.'.php');
break;
**/
function lesson_print_header($cm, $course, $lesson, $currenttab = '', $printheading = true) {
global $CFG, $USER;
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
/// Header setup
if ($course->category) {
print_heading_with_help(format_string($lesson->name, true), "overview", "lesson");
}
- if (!empty($currenttab) and isteacher($course->id)) {
+ if (!empty($currenttab) and has_capability('mod/lesson:manage', $context)) {
include($CFG->dirroot.'/mod/lesson/tabs.php');
}
}
return array($cm, $course, $lesson);
}
+/**
+ * Sets a message to be printed. Messages are printed
+ * by calling {@link lesson_print_messages()}.
+ *
+ * @uses $SESSION
+ * @param string $message The message to be printed
+ * @param string $class Class to be passed to {@link notify()}. Usually notifyproblem or notifysuccess.
+ * @param string $align Alignment of the message
+ * @return boolean
+ **/
+function lesson_set_message($message, $class="notifyproblem", $align='center') {
+ global $SESSION;
+
+ if (empty($SESSION->lesson_messages) or !is_array($SESSION->lesson_messages)) {
+ $SESSION->lesson_messages = array();
+ }
+
+ $SESSION->lesson_messages[] = array($message, $class, $align);
+
+ return true;
+}
+
+/**
+ * Print all set messages.
+ *
+ * See {@link lesson_set_message()} for setting messages.
+ *
+ * Uses {@link notify()} to print the messages.
+ *
+ * @uses $SESSION
+ * @return boolean
+ **/
+function lesson_print_messages() {
+ global $SESSION;
+
+ if (empty($SESSION->lesson_messages)) {
+ // No messages to print
+ return true;
+ }
+
+ foreach($SESSION->lesson_messages as $message) {
+ notify($message[0], $message[1], $message[2]);
+ }
+
+ // Reset
+ unset($SESSION->lesson_messages);
+
+ return true;
+}
+
/**
* Given some question info and some data about the the answers
* this function parses, organises and saves the question
*/
function lesson_print_tree($pageid, $lesson, $cmid) {
global $USER, $CFG;
+ $context = get_context_instance(CONTEXT_MODULE, $cmid);
if(!$pages = get_records_select("lesson_pages", "lessonid = $lesson->id")) {
error("Error: could not find lesson pages");
}
echo $output;
- if (isteacheredit($lesson->course)) {
+ if (has_capability('mod/lesson:edit', $context)) {
if (count($pages) > 1) {
echo "<a title=\"move\" href=\"lesson.php?id=$cmid&action=move&pageid=".$pages[$pageid]->id."\">\n".
"<img src=\"$CFG->pixpath/t/move.gif\" hspace=\"2\" height=11 width=11 alt=\"move\" border=0></a>\n";
**/
function lesson_print_ongoing_score($lesson) {
global $USER;
-
- if (isteacher($lesson->course)) {
+ $cm = get_coursemodule_from_instance('lesson', $lesson->id);
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+
+ if (has_capability('mod/lesson:manage', $context)) {
echo "<p align=\"center\">".get_string('teacherongoingwarning', 'lesson').'</p>';
} else {
$ntries = count_records("lesson_grades", "lessonid", $lesson->id, "userid", $USER->id);
**/
function lesson_print_progress_bar($lesson, $course) {
global $CFG, $USER;
-
+ $cm = get_coursemodule_from_instance('lesson', $lesson->id);
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+
// lesson setting to turn progress bar on or off
if (!$lesson->progressbar) {
return false;
}
// catch teachers
- if (isteacher($course->id)) {
+ if (has_capability('mod/lesson:manage', $context)) {
notify(get_string('progressbarteacherwarning', 'lesson', $course->teachers));
return false;
}
}
require_login($course->id, false, $cm);
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ require_capability('mod/lesson:view', $context);
// get the mimetype
//$path_parts = pathinfo('http://www.apple.com'); //$lesson->mediafile
// make sure people are where they should be
require_login($course->id, false);
-
- if (!isteacher($course->id)) {
- error("Must be teacher to view Reports");
- }
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ require_capability('mod/lesson:manage', $context);
/// Process any form data before fetching attempts, grades and times
- if ($form = data_submitted()) {
+ if (has_capability('mod/lesson:edit', $context) and $form = data_submitted()) {
confirm_sesskey();
/// Cycle through array of userids with nested arrays of tries
$studentname = "{$student->lastname}, $student->firstname";
foreach ($tries as $try) {
// start to build up the checkbox and link
- $temp = '<input type="checkbox" id="attempts" name="attempts['.$try['userid'].']['.$try['try'].']" /> '.
- "<a href=\"report.php?id=$cm->id&action=detail&userid=".$try['userid'].'&try='.$try['try'].'">';
+ if (has_capability('mod/lesson:edit', $context)) {
+ $temp = '<input type="checkbox" id="attempts" name="attempts['.$try['userid'].']['.$try['try'].']" /> ';
+ } else {
+ $temp = '';
+ }
+
+ $temp .= "<a href=\"report.php?id=$cm->id&action=detail&userid=".$try['userid'].'&try='.$try['try'].'">';
if ($try["grade"] !== NULL) { // if NULL then not done yet
// this is what the link does when the user has completed the try
$timetotake = $try["timeend"] - $try["timestart"];
}
}
// print it all out !
- echo "<form id=\"theform\" name=\"theform\" method=\"post\" action=\"report.php\">\n
- <input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />\n
- <input type=\"hidden\" name=\"id\" value=\"$cm->id\" />\n
- <input type=\"hidden\" name=\"id\" value=\"$cm->id\" />\n";
-
+ if (has_capability('mod/lesson:edit', $context)) {
+ echo "<form id=\"theform\" name=\"theform\" method=\"post\" action=\"report.php\">\n
+ <input type=\"hidden\" name=\"sesskey\" value=\"".sesskey()."\" />\n
+ <input type=\"hidden\" name=\"id\" value=\"$cm->id\" />\n
+ <input type=\"hidden\" name=\"id\" value=\"$cm->id\" />\n";
+ }
print_table($table);
- echo '<br /><table width="90%" align="center"><tr><td>'.
- '<a href="javascript: checkall();">'.get_string('selectall').'</a> / '.
- '<a href="javascript: checknone();">'.get_string('deselectall').'</a> ';
+ if (has_capability('mod/lesson:edit', $context)) {
+ echo '<br /><table width="90%" align="center"><tr><td>'.
+ '<a href="javascript: checkall();">'.get_string('selectall').'</a> / '.
+ '<a href="javascript: checknone();">'.get_string('deselectall').'</a> ';
- $options = array();
- $options['delete'] = get_string('deleteselected');
- choose_from_menu($options, 'attemptaction', 0, 'choose', 'submitFormById(\'theform\')');
+ $options = array();
+ $options['delete'] = get_string('deleteselected');
+ choose_from_menu($options, 'attemptaction', 0, 'choose', 'submitFormById(\'theform\')');
+
+ echo '</td></tr></table></form>';
+ }
- echo '</td></tr></table></form>';
-
// some stat calculations
if ($numofattempts == 0) {
$avescore = get_string("notcompleted", "lesson");
text-align: left;
}
+/***
+ *** Style for essay.php
+ ***/
+
+#mod-lesson-essay .graded {
+ color:#DF041E;
+}
+
+#mod-lesson-essay .sent {
+ color:#006600;
+}
+
+#mod-lesson-essay .ungraded {
+ color:#999999;
+}
+
/***
*** Style for responses
***/
}
if (!isset($cm)) {
$cm = get_coursemodule_from_instance('lesson', $lesson->id);
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
}
if (!isset($course)) {
$course = get_record('course', 'id', $lesson->course);
$counts->attempts = count_records('lesson_grades', 'lessonid', $lesson->id);
$counts->student = $course->student;
+
$row[] = new tabobject('teacherview', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id", get_string('edit'), get_string('editlesson', 'lesson', format_string($lesson->name)));
$row[] = new tabobject('navigation', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&action=navigation", get_string('preview', 'lesson'), get_string('previewlesson', 'lesson', format_string($lesson->name)));
$row[] = new tabobject('reports', "$CFG->wwwroot/mod/lesson/report.php?id=$cm->id", get_string('reports', 'lesson'), get_string('viewreports', 'lesson', $counts));
- if (isteacheredit($course->id)) {
- $row[] = new tabobject('essayview', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&action=essayview", get_string('manualgrading', 'lesson'));
+ if (has_capability('mod/lesson:edit', $context)) {
+ $row[] = new tabobject('essayview', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&action=essayview", get_string('manualgrading', 'lesson'));
}
if ($lesson->highscores) {
$row[] = new tabobject('highscores', "$CFG->wwwroot/mod/lesson/view.php?id=$cm->id&action=highscores", get_string('highscores', 'lesson'));
/// This fragment is called by moodle_needs_upgrading() and /admin/index.php
/////////////////////////////////////////////////////////////////////////////////
-$module->version = 2006080900; // The current module version (Date: YYYYMMDDXX)
+$module->version = 2006090700; // The current module version (Date: YYYYMMDDXX)
$module->requires = 2006080900; // Requires this Moodle version
$module->cron = 0; // Period for cron to check this module (secs)
}
require_login($course->id, false, $cm);
+ $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+
+ switch ($action) {
+ case 'essayview':
+ case 'essaygrade':
+ case 'updategrade':
+ case 'emailessay':
+ require_capability('mod/lesson:edit', $context);
+ break;
+ default:
+ require_capability('mod/lesson:view', $context);
+ break;
+ }
/// Print the page header
// moved the action up because I needed to know what the action will be before the header is printed
if (empty($action)) {
- if (isteacher($course->id)) {
+ if (has_capability('mod/lesson:manage', $context)) {
$action = 'teacherview';
} elseif (time() < $lesson->available) {
print_header($course->shortname .': '. format_string($lesson->name), $course->fullname,
}
// changed the update_module_button and added another button when a teacher is checking the navigation of the lesson
- if (isteacheredit($course->id)) {
+ if (has_capability('mod/lesson:edit', $context)) {
$button = '<table><tr><td>';
$button .= '<form target="'. $CFG->framename .'" method="get" action="'. $CFG->wwwroot .'/course/mod.php">'.
'<input type="hidden" name="sesskey" value="'. $USER->sesskey .'" />'.
$button, // took out update_module_button($cm->id, $course->id, $strlesson) and replaced it with $button
navmenu($course, $cm));
- if (isteacher($course->id)) {
+ if (has_capability('mod/lesson:manage', $context)) {
if ($action == 'teacherview' and $display) {
// teacherview tab not selected when displaying a single page/question
/************** navigation **************************************/
if ($action == 'navigation') {
// password protected lesson code
- if ($lesson->usepassword && !isteacher($course->id)) {
+ if ($lesson->usepassword && !has_capability('mod/lesson:manage', $context)) {
$correctpass = false;
if ($password = optional_param('userpassword', '', PARAM_CLEAN)) {
if ($lesson->password == md5(trim($password))) {
if (empty($pageid)) {
// make sure there are pages to view
if (!get_field('lesson_pages', 'id', 'lessonid', $lesson->id, 'prevpageid', 0)) {
- if (isstudent($course->id)) {
+ if (!has_capability('mod/lesson:manage', $context)) {
notify(get_string('lessonnotready', 'lesson', $course->teacher)); // a nice message to the student
} else {
if (!count_records('lesson_pages', 'lessonid', $lesson->id)) {
}
// check for dependencies
- if ($lesson->dependency and !isteacher($course->id)) {
+ if ($lesson->dependency and !has_capability('mod/lesson:manage', $context)) {
if ($dependentlesson = get_record('lesson', 'id', $lesson->dependency)) {
// lesson exists, so we can proceed
$conditions = unserialize($lesson->conditions);
error('Navigation: first page not found');
}
/// This is the code for starting a timed test
- if(!isset($USER->startlesson[$lesson->id]) && !isteacher($course->id)) {
+ if(!isset($USER->startlesson[$lesson->id]) && !has_capability('mod/lesson:manage', $context)) {
$USER->startlesson[$lesson->id] = true;
$startlesson = new stdClass;
$startlesson->lessonid = $lesson->id;
}
if ($page->qtype == LESSON_CLUSTER) { //this only gets called when a user starts up a new lesson and the first page is a cluster page
- if (!isteacher($course->id)) {
+ if (!has_capability('mod/lesson:manage', $context)) {
// get new id
$pageid = lesson_cluster_jump($lesson->id, $USER->id, $pageid);
// get new page info
// check to see if the user can see the left menu
- if (!isteacher($course->id)) {
+ if (!has_capability('mod/lesson:manage', $context)) {
$lesson->displayleft = lesson_displayleftif($lesson);
}
}
// clock code
// get time information for this user
- if(!isteacher($course->id)) {
+ if(!has_capability('mod/lesson:manage', $context)) {
if (!$timer = get_records_select('lesson_timer', "lessonid = $lesson->id AND userid = $USER->id", 'starttime')) {
error('Error: could not find records');
} else {
// for timed lessons, display clock
if ($lesson->timed) {
- if(isteacher($course->id)) {
+ if(has_capability('mod/lesson:manage', $context)) {
echo '<p align="center">'. get_string('teachertimerwarning', 'lesson') .'<p>';
} else {
if ((($timer->starttime + $lesson->maxtime * 60) - time()) > 0) {
}
// update the clock
- if (!isteacher($course->id)) {
+ if (!has_capability('mod/lesson:manage', $context)) {
$timer->lessontime = time();
if (!update_record('lesson_timer', $timer)) {
error('Error: could not update lesson_timer table');
if ($answer->jumpto == LESSON_RANDOMBRANCH) {
$answer->jumpto = lesson_unseen_branch_jump($lesson->id, $USER->id);
} elseif ($answer->jumpto == LESSON_CLUSTERJUMP) {
- if (!isteacher($course->id)) {
+ if (!has_capability('mod/lesson:manage', $context)) {
$answer->jumpto = lesson_cluster_jump($lesson->id, $USER->id, $pageid);
} else {
if ($page->nextpageid == 0) {
}
/// This is the warning msg for teachers to inform them that cluster and unseen does not work while logged in as a teacher
- if(isteacher($course->id)) {
+ if(has_capability('mod/lesson:manage', $context)) {
if (lesson_display_teacher_warning($lesson->id)) {
$warningvars->cluster = get_string('clusterjump', 'lesson');
$warningvars->unseen = get_string('unseenpageinbranch', 'lesson');
}
if ($page->qtype == LESSON_BRANCHTABLE) {
- if ($lesson->minquestions and isstudent($course->id)) {
+ if ($lesson->minquestions and !has_capability('mod/lesson:manage', $context)) {
// tell student how many questions they have seen, how many are required and their grade
$ntries = count_records("lesson_grades", "lessonid", $lesson->id, "userid", $USER->id);
// check to see if the student ran out of time
$outoftime = optional_param('outoftime', '', PARAM_ALPHA);
- if ($lesson->timed && !isteacher($course->id)) {
+ if ($lesson->timed && !has_capability('mod/lesson:manage', $context)) {
if ($outoftime == 'normal') {
print_simple_box(get_string("eolstudentoutoftime", "lesson"), "center");
}
}
// Update the clock / get time information for this user
- if (!isteacher($course->id)) {
+ if (!has_capability('mod/lesson:manage', $context)) {
unset($USER->startlesson[$lesson->id]);
if (!$timer = get_records_select('lesson_timer', "lessonid = $lesson->id AND userid = $USER->id", 'starttime')) {
error('Error: could not find records');
if (isset($USER->modattempts[$lesson->id])) {
$ntries--; // need to look at the old attempts :)
}
- if (isstudent($course->id)) {
+ if (!has_capability('mod/lesson:manage', $context)) {
$gradeinfo = lesson_grade($lesson, $ntries);
}
// high scores code
- if ($lesson->highscores && !isteacher($course->id) && !$lesson->practice) {
+ if ($lesson->highscores && !has_capability('mod/lesson:manage', $context) && !$lesson->practice) {
echo "<div align=\"center\"><br>";
if (!$grades = get_records_select("lesson_grades", "lessonid = $lesson->id", "completed")) {
echo get_string("youmadehighscore", "lesson", $lesson->maxhighscores)."<br>";
echo "</div>";
}
- if ($lesson->modattempts && !isteacher($course->id)) {
+ if ($lesson->modattempts && !has_capability('mod/lesson:manage', $context)) {
// make sure if the student is reviewing, that he/she sees the same pages/page path that he/she saw the first time
// look at the attempt records to find the first QUESTION page that the user answered, then use that page id
// to pass to view again. This is slick cause it wont call the empty($pageid) code
$lastattempt = end($attempts);
$USER->modattempts[$lesson->id] = $lastattempt->pageid;
echo "<div align=\"center\" style=\"padding: 5px;\" class=\"lessonbutton standardbutton\"><a href=\"view.php?id=$cm->id&pageid=$pageid\">".get_string("reviewlesson", "lesson")."</a></div>\n";
- } elseif ($lesson->modattempts && isteacher($course->id)) {
+ } elseif ($lesson->modattempts && has_capability('mod/lesson:manage', $context)) {
echo "<p align=\"center\">".get_string("modattemptsnoteacher", "lesson")."</p>";
}
if (!$page = get_record_select("lesson_pages", "lessonid = $lesson->id AND prevpageid = 0")) {
// if there are no pages give teacher the option to create a new page or a new branch table
echo "<div align=\"center\">";
- if (isteacheredit($course->id)) {
+ if (has_capability('mod/lesson:edit', $context)) {
print_simple_box( "<table cellpadding=\"5\" border=\"0\">\n<tr><th>".get_string("whatdofirst", "lesson")."</th></tr><tr><td>".
"<a href=\"import.php?id=$cm->id&pageid=0\">".
get_string("importquestions", "lesson")."</a></td></tr><tr><td>".
}
}
echo "<table align=\"center\" cellpadding=\"5\" border=\"0\" width=\"80%\">\n";
- if (isteacheredit($course->id)) {
+ if (has_capability('mod/lesson:edit', $context)) {
echo "<tr><td align=\"left\"><small><a href=\"import.php?id=$cm->id&pageid=$page->prevpageid\">".
get_string("importquestions", "lesson")."</a> | ".
"<a href=\"lesson.php?id=$cm->id&sesskey=".$USER->sesskey."&action=addcluster&pageid=$page->prevpageid\">".
}
} else {
echo "<table align=\"center\" cellpadding=\"5\" border=\"0\" width=\"80%\">\n";
- if (isteacheredit($course->id)) {
+ if (has_capability('mod/lesson:edit', $context)) {
echo "<tr><td align=\"left\"><small><a href=\"import.php?id=$cm->id&pageid=0\">".
get_string("importquestions", "lesson")."</a> | ".
"<a href=\"lesson.php?id=$cm->id&sesskey=".$USER->sesskey."&action=addcluster&pageid=0\">".
while (true) {
echo "<tr><td>\n";
echo "<table width=\"100%\" border=\"1\" class=\"generalbox\"><tr><th colspan=\"2\">".format_string($page->title)." \n";
- if (isteacheredit($course->id)) {
+ if (has_capability('mod/lesson:edit', $context)) {
if ($npages > 1) {
echo "<a title=\"".get_string("move")."\" href=\"lesson.php?id=$cm->id&action=move&pageid=$page->id\">\n".
"<img src=\"$CFG->pixpath/t/move.gif\" hspace=\"2\" height=\"11\" width=\"11\" border=\"0\" alt=\"move\" /></a>\n";
echo " </td></tr>\n";
}
echo "</table></td></tr>\n";
- if (isteacheredit($course->id)) {
+ if (has_capability('mod/lesson:edit', $context)) {
echo "<tr><td align=\"left\"><small><a href=\"import.php?id=$cm->id&pageid=$page->id\">".
get_string("importquestions", "lesson")."</a> | ".
"<a href=\"lesson.php?id=$cm->id&sesskey=".$USER->sesskey."&action=addcluster&pageid=$page->id\">".
print_table($table);
}
- if (!isteacher($course->id)) { // teachers don't need the links
+ if (!has_capability('mod/lesson:manage', $context)) { // teachers don't need the links
echo '<div align="center">';
if (optional_param('link', 0, PARAM_INT)) {
echo "<br /><div class=\"lessonbutton standardbutton\"><a href=\"../../course/view.php?id=$course->id\">".get_string("returntocourse", "lesson")."</a></div>";