当前位置: 首页>>代码示例>>PHP>>正文


PHP lesson::load_all_pages方法代码示例

本文整理汇总了PHP中lesson::load_all_pages方法的典型用法代码示例。如果您正苦于以下问题:PHP lesson::load_all_pages方法的具体用法?PHP lesson::load_all_pages怎么用?PHP lesson::load_all_pages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lesson的用法示例。


在下文中一共展示了lesson::load_all_pages方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_jumptooptions

 /**
  * 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;
 }
开发者ID:nikitskynikita,项目名称:moodle,代码行数:41,代码来源:locallib.php

示例2: 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 = 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');
 }
开发者ID:mongo0se,项目名称:moodle,代码行数:67,代码来源:renderer.php

示例3: 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');
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:71,代码来源:renderer.php

示例4: 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;
}
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:54,代码来源:locallib.php


注:本文中的lesson::load_all_pages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。