本文整理汇总了PHP中lesson类的典型用法代码示例。如果您正苦于以下问题:PHP lesson类的具体用法?PHP lesson怎么用?PHP lesson使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了lesson类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dirname
* 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.
示例2: require_once
**/
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);
示例3: required_param
*
* 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);
示例4: progress_bar
/**
* 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');
}
示例5: construction_override
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);
}
示例6: construction_override
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);
}
示例7: required_param
*
* @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');
示例8: require_once
* @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':
示例9: construction_override
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);
}
示例10: get_course_progress_percentage
/**
* 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;
}
示例11: verify_access
<?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>
示例12: getApprLessByIdMonth
function getApprLessByIdMonth($idUser, $month)
{
$lesson = new lesson();
$data['lesson'] = $lesson->getApprLessByIdMonth($idUser, $month);
echo json_encode($data);
}
示例13: required_param
* 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');
示例14: optional_param
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);
示例15: dirname
* @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');