* This page handles deleting lesson overrides * * @package mod_lesson * @copyright 2015 Jean-Michel vedrine * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require_once dirname(__FILE__) . '/../../config.php'; require_once $CFG->dirroot . '/mod/lesson/lib.php'; require_once $CFG->dirroot . '/mod/lesson/locallib.php'; require_once $CFG->dirroot . '/mod/lesson/override_form.php'; $overrideid = required_param('id', PARAM_INT); $confirm = optional_param('confirm', false, PARAM_BOOL); if (!($override = $DB->get_record('lesson_overrides', array('id' => $overrideid)))) { print_error('invalidoverrideid', 'lesson'); } $lesson = new lesson($DB->get_record('lesson', array('id' => $override->lessonid), '*', MUST_EXIST)); if (!($cm = get_coursemodule_from_instance("lesson", $lesson->id, $lesson->course))) { print_error('invalidcoursemodule'); } $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $context = context_module::instance($cm->id); require_login($course, false, $cm); // Check the user has the required capabilities to modify an override. require_capability('mod/lesson:manageoverrides', $context); $url = new moodle_url('/mod/lesson/overridedelete.php', array('id' => $override->id)); $confirmurl = new moodle_url($url, array('id' => $override->id, 'confirm' => 1)); $cancelurl = new moodle_url('/mod/lesson/overrides.php', array('cmid' => $cm->id)); if (!empty($override->userid)) { $cancelurl->param('mode', 'user'); } // If confirm is set (PARAM_BOOL) then we have confirmation of intention to delete.
**/ require_once(dirname(__FILE__) . '/../../config.php'); require_once($CFG->dirroot.'/mod/lesson/locallib.php'); require_once($CFG->dirroot.'/mod/lesson/view_form.php'); require_once($CFG->libdir . '/completionlib.php'); $id = required_param('id', PARAM_INT); // Course Module ID $pageid = optional_param('pageid', NULL, PARAM_INT); // Lesson Page ID $edit = optional_param('edit', -1, PARAM_BOOL); $userpassword = optional_param('userpassword','',PARAM_RAW); $backtocourse = optional_param('backtocourse', false, PARAM_RAW); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST);; $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); if ($backtocourse) { redirect(new moodle_url('/course/view.php', array('id'=>$course->id))); } $url = new moodle_url('/mod/lesson/view.php', array('id'=>$id)); if ($pageid !== null) { $url->param('pageid', $pageid); } $PAGE->set_url($url); $context = get_context_instance(CONTEXT_MODULE, $cm->id); $canmanage = has_capability('mod/lesson:manage', $context);
* * If there is a way to use the resource class instead of this code, please change to do so * * * @package mod_lesson * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **/ require_once '../../config.php'; require_once $CFG->dirroot . '/mod/lesson/locallib.php'; $id = required_param('id', PARAM_INT); // Course Module ID $printclose = optional_param('printclose', 0, PARAM_INT); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); // Apply overrides. $lesson->update_effective_access($USER->id); $context = context_module::instance($cm->id); $canmanage = has_capability('mod/lesson:manage', $context); $url = new moodle_url('/mod/lesson/mediafile.php', array('id' => $id)); if ($printclose !== '') { $url->param('printclose', $printclose); } $PAGE->set_url($url); $PAGE->set_pagelayout('popup'); $PAGE->set_title($course->shortname); $lessonoutput = $PAGE->get_renderer('mod_lesson'); // Get the mimetype $mimetype = mimeinfo("type", $lesson->mediafile);
/** * Returns HTML to display a progress bar of progression through a lesson * * @param lesson $lesson * @return string */ public function progress_bar(lesson $lesson) { global $CFG, $USER, $DB; $context = get_context_instance(CONTEXT_MODULE, $this->page->cm->id); // lesson setting to turn progress bar on or off if (!$lesson->progressbar) { return ''; } // catch teachers if (has_capability('mod/lesson:manage', $context)) { return $this->output->notification(get_string('progressbarteacherwarning2', 'lesson')); } if (!isset($USER->modattempts[$lesson->id])) { // all of the lesson pages $pages = $lesson->load_all_pages(); foreach ($pages as $page) { if ($page->prevpageid == 0) { $pageid = $page->id; // find the first page id break; } } // current attempt number if (!($ntries = $DB->count_records("lesson_grades", array("lessonid" => $lesson->id, "userid" => $USER->id)))) { $ntries = 0; // may not be necessary } $viewedpageids = array(); if ($attempts = $lesson->get_attempts($ntries, true)) { $viewedpageids = array_merge($viewedpageids, array_keys($attempts)); } // collect all of the branch tables viewed if ($viewedbranches = $DB->get_records("lesson_branch", array("lessonid" => $lesson->id, "userid" => $USER->id, "retry" => $ntries), 'timeseen DESC', 'id, pageid')) { $viewedpageids = array_merge($viewedpageids, array_keys($viewedbranches)); } // Filter out the following pages: // End of Cluster // End of Branch // Pages found inside of Clusters // Do not filter out Cluster Page(s) because we count a cluster as one. // By keeping the cluster page, we get our 1 $validpages = array(); while ($pageid != 0) { $pageid = $pages[$pageid]->valid_page_and_view($validpages, $viewedpageids); } // progress calculation as a percent $progress = round(count($viewedpageids) / count($validpages), 2) * 100; } else { $progress = 100; } // print out the Progress Bar. Attempted to put as much as possible in the style sheets. $cells = array(); if ($progress != 0) { // some browsers do not repsect the 0 width. $cells[0] = new html_table_cell(); $cells[0]->style = 'width:' . $progress . '%'; $cells[0]->attributes['class'] = 'progress_bar_completed'; $cells[0]->text = ' '; } $cells[] = '<div class="progress_bar_token"></div>'; $table = new html_table(); $table->attributes['class'] = 'progress_bar_table'; $table->data = array(new html_table_row($cells)); return $this->output->box(html_writer::table($table), 'progress_bar'); }
public function construction_override($pageid, lesson $lesson) { global $DB, $CFG, $PAGE; require_sesskey(); // first get the preceeding page $timenow = time(); // the new page is not the first page (end of branch always comes after an existing page) if (!($page = $DB->get_record("lesson_pages", array("id" => $pageid)))) { print_error('cannotfindpagerecord', 'lesson'); } // chain back up to find the (nearest branch table) $btpage = clone $page; $btpageid = $btpage->id; while ($btpage->qtype != LESSON_PAGE_BRANCHTABLE && $btpage->prevpageid > 0) { $btpageid = $btpage->prevpageid; if (!($btpage = $DB->get_record("lesson_pages", array("id" => $btpageid)))) { print_error('cannotfindpagerecord', 'lesson'); } } if ($btpage->qtype == LESSON_PAGE_BRANCHTABLE) { $newpage = new stdClass(); $newpage->lessonid = $lesson->id; $newpage->prevpageid = $pageid; $newpage->nextpageid = $page->nextpageid; $newpage->qtype = $this->qtype; $newpage->timecreated = $timenow; $newpage->title = get_string("endofbranch", "lesson"); $newpage->contents = get_string("endofbranch", "lesson"); $newpageid = $DB->insert_record("lesson_pages", $newpage); // update the linked list... $DB->set_field("lesson_pages", "nextpageid", $newpageid, array("id" => $pageid)); if ($page->nextpageid) { // the new page is not the last page $DB->set_field("lesson_pages", "prevpageid", $newpageid, array("id" => $page->nextpageid)); } // ..and the single "answer" $newanswer = new stdClass(); $newanswer->lessonid = $lesson->id; $newanswer->pageid = $newpageid; $newanswer->timecreated = $timenow; $newanswer->jumpto = $btpageid; $newanswerid = $DB->insert_record("lesson_answers", $newanswer); $lesson->add_message(get_string('addedanendofbranch', 'lesson'), 'notifysuccess'); } else { $lesson->add_message(get_string('nobranchtablefound', 'lesson')); } redirect($CFG->wwwroot . "/mod/lesson/edit.php?id=" . $PAGE->cm->id); }
public function construction_override($pageid, lesson $lesson) { global $CFG, $PAGE, $DB; require_sesskey(); $timenow = time(); // the new page is not the first page (end of cluster always comes after an existing page) if (!($page = $DB->get_record("lesson_pages", array("id" => $pageid)))) { print_error('cannotfindpages', 'lesson'); } // could put code in here to check if the user really can insert an end of cluster $newpage = new stdClass(); $newpage->lessonid = $lesson->id; $newpage->prevpageid = $pageid; $newpage->nextpageid = $page->nextpageid; $newpage->qtype = $this->qtype; $newpage->timecreated = $timenow; $newpage->title = get_string("endofclustertitle", "lesson"); $newpage->contents = get_string("endofclustertitle", "lesson"); $newpageid = $DB->insert_record("lesson_pages", $newpage); // update the linked list... $DB->set_field("lesson_pages", "nextpageid", $newpageid, array("id" => $pageid)); if ($page->nextpageid) { // the new page is not the last page $DB->set_field("lesson_pages", "prevpageid", $newpageid, array("id" => $page->nextpageid)); } // ..and the single "answer" $newanswer = new stdClass(); $newanswer->lessonid = $lesson->id; $newanswer->pageid = $newpageid; $newanswer->timecreated = $timenow; $newanswer->jumpto = LESSON_NEXTPAGE; $newanswerid = $DB->insert_record("lesson_answers", $newanswer); $lesson->add_message(get_string('addedendofcluster', 'lesson'), 'notifysuccess'); redirect($CFG->wwwroot . '/mod/lesson/edit.php?id=' . $PAGE->cm->id); }
* * @package mod * @subpackage lesson * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **/ /** include required files */ require_once '../../config.php'; require_once $CFG->dirroot . '/mod/lesson/locallib.php'; $id = required_param('id', PARAM_INT); // Course Module ID $mode = optional_param('mode', '', PARAM_ALPHA); $link = optional_param('link', 0, PARAM_INT); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); $url = new moodle_url('/mod/lesson/highscores.php', array('id' => $id)); if ($mode !== '') { $url->param('mode', $mode); } if ($link !== 0) { $url->param('link', $link); } $PAGE->set_url($url); $context = get_context_instance(CONTEXT_MODULE, $cm->id); switch ($mode) { case 'add': // Ensure that we came from view.php if (!confirm_sesskey() or !data_submitted()) { print_error('invalidformdata');
* @package mod * @subpackage lesson * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **/ require_once("../../config.php"); require_once($CFG->dirroot.'/mod/lesson/locallib.php'); $id = required_param('id', PARAM_INT); // Course Module ID $action = required_param('action', PARAM_ALPHA); // Action $pageid = required_param('pageid', PARAM_INT); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST);; $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); $url = new moodle_url('/mod/lesson/lesson.php', array('id'=>$id,'action'=>$action)); $PAGE->set_url($url); $context = context_module::instance($cm->id); require_capability('mod/lesson:edit', $context); require_sesskey(); $lessonoutput = $PAGE->get_renderer('mod_lesson'); /// Process the action switch ($action) { case 'confirmdelete':
public function construction_override($pageid, lesson $lesson) { global $PAGE, $CFG, $DB; require_sesskey(); $timenow = time(); if ($pageid == 0) { if ($lesson->has_pages()) { if (!($page = $DB->get_record("lesson_pages", array("prevpageid" => 0, "lessonid" => $lesson->id)))) { print_error('cannotfindpagerecord', 'lesson'); } } else { // This is the ONLY page $page = new stdClass(); $page->id = 0; } } else { if (!($page = $DB->get_record("lesson_pages", array("id" => $pageid)))) { print_error('cannotfindpagerecord', 'lesson'); } } $newpage = new stdClass(); $newpage->lessonid = $lesson->id; $newpage->prevpageid = $pageid; if ($pageid != 0) { $newpage->nextpageid = $page->nextpageid; } else { $newpage->nextpageid = $page->id; } $newpage->qtype = $this->qtype; $newpage->timecreated = $timenow; $newpage->title = get_string("clustertitle", "lesson"); $newpage->contents = get_string("clustertitle", "lesson"); $newpageid = $DB->insert_record("lesson_pages", $newpage); // update the linked list... if ($pageid != 0) { $DB->set_field("lesson_pages", "nextpageid", $newpageid, array("id" => $pageid)); } if ($pageid == 0) { $page->nextpageid = $page->id; } if ($page->nextpageid) { // the new page is not the last page $DB->set_field("lesson_pages", "prevpageid", $newpageid, array("id" => $page->nextpageid)); } // ..and the single "answer" $newanswer = new stdClass(); $newanswer->lessonid = $lesson->id; $newanswer->pageid = $newpageid; $newanswer->timecreated = $timenow; $newanswer->jumpto = LESSON_CLUSTERJUMP; $newanswerid = $DB->insert_record("lesson_answers", $newanswer); $lesson->add_message(get_string('addedcluster', 'lesson'), 'notifysuccess'); redirect($CFG->wwwroot . '/mod/lesson/edit.php?id=' . $PAGE->cm->id); }
/** * Returns progress percentage of courses which will be displayed in course_overview block * Autor : GalaxyWebLinks * * @param bool $course and $USER of current user. * @return int progress percentage of courses */ function get_course_progress_percentage($course, $USER) { global $DB, $CFG; require_once $CFG->dirroot . '/mod/lesson/locallib.php'; $progress = 0; $lessions = $DB->get_record("lesson", array("course" => $course->id)); $lessonid = $lessions->id; $courseshown = $course->id; if ($lessonid) { if (!isset($USER->modattempts[$lessonid])) { $lesson = new lesson($DB->get_record('lesson', array('id' => $lessonid), '*', MUST_EXIST)); $pages = $lesson->load_all_pages($lesson); foreach ($pages as $page) { if ($page->prevpageid == 0) { $pageid = $page->id; // find the first page id break; } } // current attempt number if (!($ntries = $DB->count_records("lesson_grades", array("lessonid" => $lessonid, "userid" => $USER->id)))) { $ntries = 0; // may not be necessary } $viewedpageids = array(); if ($attempts = $lesson->get_attempts($ntries, false)) { foreach ($attempts as $attempt) { $viewedpageids[$attempt->pageid] = $attempt; } } $branches = $DB->get_records("lesson_branch", array("lessonid" => $lessonid, "userid" => $USER->id, "retry" => $ntries), 'timeseen ASC', 'id, pageid'); $viewedbranches = array(); foreach ($branches as $branch) { $viewedbranches[$branch->pageid] = $branch; } $viewedpageids = array_merge($viewedpageids, $viewedbranches); $validpages = array(); while ($pageid != 0) { $pageid = $pages[$pageid]->valid_page_and_view($validpages, $viewedpageids); } $progress = round(count($viewedpageids) / count($validpages), 2) * 100; } else { $progress = 100; } } return $progress; }
<?php require_once "../config.php"; verify_access($list_modules); $emailSent = false; $lessApr = false; $lessRej = false; $dash = new dashboard(); $lesson = new lesson(); $list_last_pend_lessons = $lesson->list_last_pend_lessons($user->id); if ($_POST['action'] == 'Submit') { $dash->sendEmail($user->name, $user->email, $_POST['reseiver'], $_POST['subject'], $_POST['message']); $emailSent = true; } else { if ($_POST['action'] == 'Eval') { if (isset($_POST['hdIdAR'])) { $lesson->change_status($_POST['hdIdAR'], $_POST['hdEval'], $_POST['obs']); if ($_POST['hdEval'] == '2') { $lessApr = true; } else { if ($_POST['hdEval'] == '3') { $lessRej = true; } } $list_last_pend_lessons = $lesson->list_last_pend_lessons($user->id); } } } ?> <!DOCTYPE html>
function getApprLessByIdMonth($idUser, $month) { $lesson = new lesson(); $data['lesson'] = $lesson->getApprLessByIdMonth($idUser, $month); echo json_encode($data); }
* Provides the interface for viewing and adding high scores * * @package mod_lesson * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **/ /** include required files */ require_once '../../config.php'; require_once $CFG->dirroot . '/mod/lesson/locallib.php'; $id = required_param('id', PARAM_INT); // Course Module ID $mode = optional_param('mode', '', PARAM_ALPHA); $link = optional_param('link', 0, PARAM_INT); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); $url = new moodle_url('/mod/lesson/highscores.php', array('id' => $id)); if ($mode !== '') { $url->param('mode', $mode); } if ($link !== 0) { $url->param('link', $link); } $PAGE->set_url($url); $context = context_module::instance($cm->id); switch ($mode) { case 'add': // Ensure that we came from view.php if (!confirm_sesskey() or !data_submitted()) { print_error('invalidformdata');
require_once $CFG->dirroot . '/mod/lesson/override_form.php'; $cmid = optional_param('cmid', 0, PARAM_INT); $overrideid = optional_param('id', 0, PARAM_INT); $action = optional_param('action', null, PARAM_ALPHA); $reset = optional_param('reset', false, PARAM_BOOL); $override = null; if ($overrideid) { if (!($override = $DB->get_record('lesson_overrides', array('id' => $overrideid)))) { print_error('invalidoverrideid', 'lesson'); } $lesson = new lesson($DB->get_record('lesson', array('id' => $override->lessonid), '*', MUST_EXIST)); list($course, $cm) = get_course_and_cm_from_instance($lesson, 'lesson'); } else { if ($cmid) { list($course, $cm) = get_course_and_cm_from_cmid($cmid, 'lesson'); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); } else { print_error('invalidcoursemodule'); } } $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $url = new moodle_url('/mod/lesson/overrideedit.php'); if ($action) { $url->param('action', $action); } if ($overrideid) { $url->param('id', $overrideid); } else { $url->param('cmid', $cmid); } $PAGE->set_url($url);
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or late **/ require_once dirname(__FILE__) . '/../../config.php'; require_once $CFG->dirroot . '/mod/lesson/locallib.php'; require_once $CFG->dirroot . '/mod/lesson/view_form.php'; require_once $CFG->libdir . '/completionlib.php'; $id = required_param('id', PARAM_INT); // Course Module ID $pageid = optional_param('pageid', NULL, PARAM_INT); // Lesson Page ID $edit = optional_param('edit', -1, PARAM_BOOL); $userpassword = optional_param('userpassword', '', PARAM_RAW); $backtocourse = optional_param('backtocourse', false, PARAM_RAW); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); if ($backtocourse) { redirect(new moodle_url('/course/view.php', array('id' => $course->id))); } // Mark as viewed $completion = new completion_info($course); $completion->set_module_viewed($cm); $url = new moodle_url('/mod/lesson/view.php', array('id' => $id)); if ($pageid !== null) { $url->param('pageid', $pageid); } $PAGE->set_url($url); $context = get_context_instance(CONTEXT_MODULE, $cm->id); $canmanage = has_capability('mod/lesson:manage', $context); $lessonoutput = $PAGE->get_renderer('mod_lesson');
**/ require_once(dirname(__FILE__) . '/../../config.php'); require_once($CFG->dirroot.'/mod/lesson/locallib.php'); require_once($CFG->dirroot.'/mod/lesson/view_form.php'); require_once($CFG->libdir . '/completionlib.php'); $id = required_param('id', PARAM_INT); // Course Module ID $pageid = optional_param('pageid', null, PARAM_INT); // Lesson Page ID $edit = optional_param('edit', -1, PARAM_BOOL); $userpassword = optional_param('userpassword','',PARAM_RAW); $backtocourse = optional_param('backtocourse', false, PARAM_RAW); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); if ($backtocourse) { redirect(new moodle_url('/course/view.php', array('id'=>$course->id))); } // Mark as viewed $completion = new completion_info($course); $completion->set_module_viewed($cm); $url = new moodle_url('/mod/lesson/view.php', array('id'=>$id)); if ($pageid !== null) { $url->param('pageid', $pageid); }
* @subpackage lesson * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **/ require_once('../../config.php'); require_once($CFG->dirroot.'/mod/lesson/locallib.php'); require_once($CFG->dirroot.'/mod/lesson/essay_form.php'); require_once($CFG->libdir.'/eventslib.php'); $id = required_param('id', PARAM_INT); // Course Module ID $mode = optional_param('mode', 'display', PARAM_ALPHA); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST);; $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); $context = get_context_instance(CONTEXT_MODULE, $cm->id); require_capability('mod/lesson:edit', $context); $url = new moodle_url('/mod/lesson/essay.php', array('id'=>$id)); if ($mode !== 'display') { $url->param('mode', $mode); } $PAGE->set_url($url); /// Handle any preprocessing before header is printed - based on $mode switch ($mode) { case 'grade': // Grading form - get the necessary data
/** * Given an ID of an instance of this module, * this function will permanently delete the instance * and any data that depends on it. * * @global object * @param int $id * @return bool */ function lesson_delete_instance($id) { global $DB, $CFG; require_once $CFG->dirroot . '/mod/lesson/locallib.php'; $lesson = $DB->get_record("lesson", array("id" => $id), '*', MUST_EXIST); $lesson = new lesson($lesson); return $lesson->delete(); }
// You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. /** * Action for processing page answers by users * * @package mod_lesson * @copyright 2009 Sam Hemelryk * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **/ /** Require the specific libraries */ require_once "../../config.php"; require_once $CFG->dirroot . '/mod/lesson/locallib.php'; $id = required_param('id', PARAM_INT); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); require_sesskey(); // Apply overrides. $lesson->update_effective_access($USER->id); $context = context_module::instance($cm->id); $canmanage = has_capability('mod/lesson:manage', $context); $lessonoutput = $PAGE->get_renderer('mod_lesson'); $url = new moodle_url('/mod/lesson/continue.php', array('id' => $cm->id)); $PAGE->set_url($url); $PAGE->set_pagetype('mod-lesson-view'); $PAGE->navbar->add(get_string('continue', 'lesson')); // This is the code updates the lesson time for a timed test // get time information for this user if (!$canmanage) { $lesson->displayleft = lesson_displayleftif($lesson);
* @subpackage lesson * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **/ /** include required files */ require_once('../../config.php'); require_once($CFG->dirroot.'/mod/lesson/locallib.php'); $id = required_param('id', PARAM_INT); // Course Module ID $mode = optional_param('mode', '', PARAM_ALPHA); $link = optional_param('link', 0, PARAM_INT); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); $url = new moodle_url('/mod/lesson/highscores.php', array('id'=>$id)); if ($mode !== '') { $url->param('mode', $mode); } if ($link !== 0) { $url->param('link', $link); } $PAGE->set_url($url); $context = context_module::instance($cm->id); switch ($mode) {
* @package mod_lesson * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **/ require_once '../../config.php'; require_once $CFG->dirroot . '/mod/lesson/locallib.php'; require_once $CFG->dirroot . '/mod/lesson/pagetypes/essay.php'; require_once $CFG->dirroot . '/mod/lesson/essay_form.php'; require_once $CFG->libdir . '/eventslib.php'; $id = required_param('id', PARAM_INT); // Course Module ID $mode = optional_param('mode', 'display', PARAM_ALPHA); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $dblesson = $DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST); $lesson = new lesson($dblesson); require_login($course, false, $cm); $context = context_module::instance($cm->id); require_capability('mod/lesson:grade', $context); $url = new moodle_url('/mod/lesson/essay.php', array('id' => $id)); if ($mode !== 'display') { $url->param('mode', $mode); } $PAGE->set_url($url); $currentgroup = groups_get_activity_group($cm, true); $attempt = new stdClass(); $user = new stdClass(); $attemptid = optional_param('attemptid', 0, PARAM_INT); $formattextdefoptions = new stdClass(); $formattextdefoptions->noclean = true; $formattextdefoptions->para = false;
/** * Returns HTML to show the start of a slideshow * @param lesson $lesson */ public function slideshow_start(lesson $lesson) { $attributes = array(); $attributes['class'] = 'slideshow'; $attributes['style'] = 'background-color:' . $lesson->properties()->bgcolor . ';height:' . $lesson->properties()->height . 'px;width:' . $lesson->properties()->width . 'px;'; $output = html_writer::start_tag('div', $attributes); return $output; }
* moveit * @package mod * @subpackage lesson * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **/ require_once "../../config.php"; require_once $CFG->dirroot . '/mod/lesson/locallib.php'; $id = required_param('id', PARAM_INT); // Course Module ID $action = required_param('action', PARAM_ALPHA); // Action $pageid = required_param('pageid', PARAM_INT); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); $url = new moodle_url('/mod/lesson/lesson.php', array('id' => $id, 'action' => $action)); $PAGE->set_url($url); $context = get_context_instance(CONTEXT_MODULE, $cm->id); require_capability('mod/lesson:edit', $context); require_sesskey(); $lessonoutput = $PAGE->get_renderer('mod_lesson'); /// Process the action switch ($action) { case 'confirmdelete': $PAGE->navbar->add(get_string($action, 'lesson')); $thispage = $lesson->load_page($pageid); echo $lessonoutput->header($lesson, $cm); echo $OUTPUT->heading(get_string("deletingpage", "lesson", format_string($thispage->title))); // print the jumps to this page
**/ require_once dirname(__FILE__) . '/../../config.php'; require_once $CFG->dirroot . '/mod/lesson/locallib.php'; require_once $CFG->dirroot . '/mod/lesson/view_form.php'; require_once $CFG->libdir . '/completionlib.php'; require_once $CFG->libdir . '/grade/constants.php'; $id = required_param('id', PARAM_INT); // Course Module ID $pageid = optional_param('pageid', null, PARAM_INT); // Lesson Page ID $edit = optional_param('edit', -1, PARAM_BOOL); $userpassword = optional_param('userpassword', '', PARAM_RAW); $backtocourse = optional_param('backtocourse', false, PARAM_RAW); $cm = get_coursemodule_from_id('lesson', $id, 0, false, MUST_EXIST); $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST); $lesson = new lesson($DB->get_record('lesson', array('id' => $cm->instance), '*', MUST_EXIST)); require_login($course, false, $cm); if ($backtocourse) { redirect(new moodle_url('/course/view.php', array('id' => $course->id))); } // Apply overrides. $lesson->update_effective_access($USER->id); // Mark as viewed $completion = new completion_info($course); $completion->set_module_viewed($cm); $url = new moodle_url('/mod/lesson/view.php', array('id' => $id)); if ($pageid !== null) { $url->param('pageid', $pageid); } $PAGE->set_url($url); $context = context_module::instance($cm->id);
/** * Returns HTML to display a progress bar of progression through a lesson * * @param lesson $lesson * @return string */ public function progress_bar(lesson $lesson) { global $CFG, $USER, $DB; $context = context_module::instance($this->page->cm->id); // lesson setting to turn progress bar on or off if (!$lesson->progressbar) { return ''; } // catch teachers if (has_capability('mod/lesson:manage', $context)) { return $this->output->notification(get_string('progressbarteacherwarning2', 'lesson')); } if (!isset($USER->modattempts[$lesson->id])) { // all of the lesson pages $pages = $lesson->load_all_pages(); foreach ($pages as $page) { if ($page->prevpageid == 0) { $pageid = $page->id; // find the first page id break; } } // current attempt number if (!($ntries = $DB->count_records("lesson_grades", array("lessonid" => $lesson->id, "userid" => $USER->id)))) { $ntries = 0; // may not be necessary } $viewedpageids = array(); if ($attempts = $lesson->get_attempts($ntries, false)) { foreach ($attempts as $attempt) { $viewedpageids[$attempt->pageid] = $attempt; } } $viewedbranches = array(); // collect all of the branch tables viewed if ($branches = $DB->get_records("lesson_branch", array("lessonid" => $lesson->id, "userid" => $USER->id, "retry" => $ntries), 'timeseen ASC', 'id, pageid')) { foreach ($branches as $branch) { $viewedbranches[$branch->pageid] = $branch; } $viewedpageids = array_merge($viewedpageids, $viewedbranches); } // Filter out the following pages: // End of Cluster // End of Branch // Pages found inside of Clusters // Do not filter out Cluster Page(s) because we count a cluster as one. // By keeping the cluster page, we get our 1 $validpages = array(); while ($pageid != 0) { $pageid = $pages[$pageid]->valid_page_and_view($validpages, $viewedpageids); } // progress calculation as a percent $progress = round(count($viewedpageids) / count($validpages), 2) * 100; } else { $progress = 100; } // print out the Progress Bar. Attempted to put as much as possible in the style sheets. $content = '<br />' . html_writer::tag('div', $progress . '%', array('class' => 'progress_bar_completed', 'style' => 'width: ' . $progress . '%;')); $printprogress = html_writer::tag('div', get_string('progresscompleted', 'lesson', $progress) . $content, array('class' => 'progress_bar')); return $this->output->box($printprogress, 'progress_bar'); }
/** * Returns an array of options to display when choosing the jumpto for a page/answer * @static * @param int $pageid * @param lesson $lesson * @return array */ public static function get_jumptooptions($pageid, lesson $lesson) { global $DB; $jump = array(); $jump[0] = get_string("thispage", "lesson"); $jump[LESSON_NEXTPAGE] = get_string("nextpage", "lesson"); $jump[LESSON_PREVIOUSPAGE] = get_string("previouspage", "lesson"); $jump[LESSON_EOL] = get_string("endoflesson", "lesson"); if ($pageid == 0) { return $jump; } $pages = $lesson->load_all_pages(); if ($pages[$pageid]->qtype == LESSON_PAGE_BRANCHTABLE || $lesson->is_sub_page_of_type($pageid, array(LESSON_PAGE_BRANCHTABLE), array(LESSON_PAGE_ENDOFBRANCH, LESSON_PAGE_CLUSTER))) { $jump[LESSON_UNSEENBRANCHPAGE] = get_string("unseenpageinbranch", "lesson"); $jump[LESSON_RANDOMPAGE] = get_string("randompageinbranch", "lesson"); } if ($pages[$pageid]->qtype == LESSON_PAGE_CLUSTER || $lesson->is_sub_page_of_type($pageid, array(LESSON_PAGE_CLUSTER), array(LESSON_PAGE_ENDOFCLUSTER))) { $jump[LESSON_CLUSTERJUMP] = get_string("clusterjump", "lesson"); } if (!optional_param('firstpage', 0, PARAM_INT)) { $apageid = $DB->get_field("lesson_pages", "id", array("lessonid" => $lesson->id, "prevpageid" => 0)); while (true) { if ($apageid) { $title = $DB->get_field("lesson_pages", "title", array("id" => $apageid)); $jump[$apageid] = strip_tags(format_string($title, true)); $apageid = $DB->get_field("lesson_pages", "nextpageid", array("id" => $apageid)); } else { // last page reached break; } } } return $jump; }
function getApprLessByIdMonth($idUser, $month) { $query = $this->con->genericQuery("select l._id,fk_mobile, l.fk_client, DATE_FORMAT( l.date, '%d/%m/%Y' ) as date, c.name as client, d.description as discipline, l.hours, l.currency, l.value_wo_discount, l.value_discount, l.value_total_user from " . $this->table . " l inner join disciplines d on l.fk_discipline = d._id inner join clients c on l.fk_client = c._id where fk_user = "******" and MONTH(date)='" . $month . "' and fk_less_stat = 2"); $objReturn = array(); foreach ($query as $value) { $less = new lesson(); $less->open($value); $objReturn[] = $less; } return $objReturn; }