mirror of
https://github.com/moodle/moodle.git
synced 2025-06-02 06:05:31 +02:00
MDL-6477: Added roles support.
Also added lesson_set_message() and lesson_print_message() to locallib.php Also fixed problem in continue.html with not printing nextpageid
This commit is contained in:
parent
ccfc5ecca1
commit
6e1ff5c8fb
@ -32,7 +32,7 @@ if ($lesson->displayleft) {
|
||||
} // 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);
|
||||
?>
|
||||
@ -69,7 +69,7 @@ if ($lesson->ongoing) {
|
||||
<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 />
|
||||
|
@ -8,12 +8,12 @@
|
||||
|
||||
// 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);
|
||||
@ -22,7 +22,7 @@
|
||||
// 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 {
|
||||
@ -49,7 +49,7 @@
|
||||
}
|
||||
|
||||
// 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");
|
||||
}
|
||||
|
||||
@ -536,7 +536,7 @@
|
||||
|
||||
// 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
|
||||
@ -570,7 +570,7 @@
|
||||
$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;
|
||||
@ -744,7 +744,7 @@
|
||||
}
|
||||
}
|
||||
} elseif ($newpageid == LESSON_UNSEENBRANCHPAGE) {
|
||||
if (isteacher($course->id)) {
|
||||
if (has_capability('mod/lesson:manage', $context)) {
|
||||
if ($page->nextpageid == 0) {
|
||||
$newpageid = LESSON_EOL;
|
||||
} else {
|
||||
@ -758,7 +758,7 @@
|
||||
} 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 {
|
||||
@ -779,6 +779,6 @@
|
||||
}
|
||||
|
||||
lesson_print_header($cm, $course, $lesson, 'navigation', false);
|
||||
|
||||
|
||||
include($CFG->wwwroot.'/mod/lesson/action/continue.html');
|
||||
?>
|
||||
|
50
mod/lesson/db/access.php
Normal file
50
mod/lesson/db/access.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?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
|
||||
)
|
||||
)
|
||||
);
|
@ -23,10 +23,8 @@
|
||||
|
||||
|
||||
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");
|
||||
|
@ -32,10 +32,8 @@
|
||||
}
|
||||
|
||||
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");
|
||||
|
@ -68,6 +68,8 @@
|
||||
//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);
|
||||
@ -76,7 +78,7 @@
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -28,6 +28,7 @@
|
||||
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();
|
||||
@ -47,9 +48,7 @@
|
||||
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;
|
||||
|
@ -219,6 +219,7 @@ if (!defined("LESSON_RESPONSE_EDITOR")) {
|
||||
**/
|
||||
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) {
|
||||
@ -241,7 +242,7 @@ function lesson_print_header($cm, $course, $lesson, $currenttab = '', $printhead
|
||||
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');
|
||||
}
|
||||
}
|
||||
@ -282,6 +283,56 @@ function lesson_get_basics($cmid = 0, $lessonid = 0) {
|
||||
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
|
||||
@ -1217,6 +1268,7 @@ function lesson_print_tree_link_menu($page, $id, $showpages=false) {
|
||||
*/
|
||||
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");
|
||||
@ -1260,7 +1312,7 @@ function lesson_print_tree($pageid, $lesson, $cmid) {
|
||||
}
|
||||
|
||||
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";
|
||||
@ -1409,8 +1461,10 @@ function lesson_grade($lesson, $ntries, $userid = 0) {
|
||||
**/
|
||||
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);
|
||||
@ -1489,14 +1543,16 @@ function lesson_check_nickname($name) {
|
||||
**/
|
||||
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;
|
||||
}
|
||||
|
@ -34,6 +34,8 @@
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -35,13 +35,11 @@
|
||||
|
||||
// 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
|
||||
@ -222,8 +220,13 @@
|
||||
$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"];
|
||||
@ -270,23 +273,26 @@
|
||||
}
|
||||
}
|
||||
// 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");
|
||||
|
@ -6,6 +6,22 @@
|
||||
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
|
||||
***/
|
||||
|
@ -19,6 +19,7 @@
|
||||
}
|
||||
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);
|
||||
@ -34,11 +35,12 @@
|
||||
$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'));
|
||||
|
@ -5,7 +5,7 @@
|
||||
/// 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)
|
||||
|
||||
|
@ -27,6 +27,19 @@
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@ -41,7 +54,7 @@
|
||||
|
||||
// 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,
|
||||
@ -76,7 +89,7 @@
|
||||
}
|
||||
|
||||
// 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 .'" />'.
|
||||
@ -108,7 +121,7 @@
|
||||
$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
|
||||
@ -126,7 +139,7 @@
|
||||
/************** 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))) {
|
||||
@ -170,7 +183,7 @@
|
||||
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)) {
|
||||
@ -184,7 +197,7 @@
|
||||
}
|
||||
|
||||
// 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);
|
||||
@ -376,7 +389,7 @@
|
||||
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;
|
||||
@ -430,7 +443,7 @@
|
||||
}
|
||||
|
||||
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
|
||||
@ -456,7 +469,7 @@
|
||||
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
@ -516,7 +529,7 @@
|
||||
}
|
||||
// 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 {
|
||||
@ -536,7 +549,7 @@
|
||||
|
||||
// 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) {
|
||||
@ -570,7 +583,7 @@
|
||||
}
|
||||
|
||||
// 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');
|
||||
@ -591,7 +604,7 @@
|
||||
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) {
|
||||
@ -622,7 +635,7 @@
|
||||
}
|
||||
|
||||
/// 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');
|
||||
@ -636,7 +649,7 @@
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
@ -973,14 +986,14 @@
|
||||
|
||||
// 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');
|
||||
@ -1001,7 +1014,7 @@
|
||||
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);
|
||||
|
||||
@ -1089,7 +1102,7 @@
|
||||
}
|
||||
|
||||
// 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>";
|
||||
@ -1120,7 +1133,7 @@
|
||||
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
|
||||
@ -1135,7 +1148,7 @@
|
||||
$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>";
|
||||
}
|
||||
|
||||
@ -1177,7 +1190,7 @@
|
||||
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>".
|
||||
@ -1226,7 +1239,7 @@
|
||||
}
|
||||
}
|
||||
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\">".
|
||||
@ -1241,7 +1254,7 @@
|
||||
}
|
||||
} 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\">".
|
||||
@ -1257,7 +1270,7 @@
|
||||
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";
|
||||
@ -1472,7 +1485,7 @@
|
||||
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\">".
|
||||
@ -1882,7 +1895,7 @@
|
||||
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>";
|
||||
|
Loading…
x
Reference in New Issue
Block a user