• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP completion_info类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: is_available

 public function is_available($not, \core_availability\info $info, $grabthelot, $userid)
 {
     $modinfo = $info->get_modinfo();
     $completion = new \completion_info($modinfo->get_course());
     if (!array_key_exists($this->cmid, $modinfo->cms)) {
         // If the cmid cannot be found, always return false regardless
         // of the condition or $not state. (Will be displayed in the
         // information message.)
         $allow = false;
     } else {
         // The completion system caches its own data so no caching needed here.
         $completiondata = $completion->get_data((object) array('id' => $this->cmid), $grabthelot, $userid, $modinfo);
         $allow = true;
         if ($this->expectedcompletion == COMPLETION_COMPLETE) {
             // Complete also allows the pass, fail states.
             switch ($completiondata->completionstate) {
                 case COMPLETION_COMPLETE:
                 case COMPLETION_COMPLETE_FAIL:
                 case COMPLETION_COMPLETE_PASS:
                     break;
                 default:
                     $allow = false;
             }
         } else {
             // Other values require exact match.
             if ($completiondata->completionstate != $this->expectedcompletion) {
                 $allow = false;
             }
         }
         if ($not) {
             $allow = !$allow;
         }
     }
     return $allow;
 }
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:35,代码来源:condition.php


示例2: section_activity_summary

 /**
  * Taken from /format/renderer.php
  * Generate a summary of the activites in a section
  *
  * @param stdClass $section The course_section entry from DB
  * @param stdClass $course the course record from DB
  * @param array    $mods (argument not used)
  * @return string HTML to output.
  */
 public static function section_activity_summary($section, $course, $mods)
 {
     global $CFG;
     require_once $CFG->libdir . '/completionlib.php';
     $modinfo = get_fast_modinfo($course);
     if (empty($modinfo->sections[$section->section])) {
         return '';
     }
     // Generate array with count of activities in this section.
     $sectionmods = array();
     $total = 0;
     $complete = 0;
     $cancomplete = isloggedin() && !isguestuser();
     $completioninfo = new completion_info($course);
     foreach ($modinfo->sections[$section->section] as $cmid) {
         $thismod = $modinfo->cms[$cmid];
         if ($thismod->uservisible) {
             if (isset($sectionmods[$thismod->modname])) {
                 $sectionmods[$thismod->modname]['name'] = $thismod->modplural;
                 $sectionmods[$thismod->modname]['count']++;
             } else {
                 $sectionmods[$thismod->modname]['name'] = $thismod->modfullname;
                 $sectionmods[$thismod->modname]['count'] = 1;
             }
             if ($cancomplete && $completioninfo->is_enabled($thismod) != COMPLETION_TRACKING_NONE) {
                 $total++;
                 $completiondata = $completioninfo->get_data($thismod, true);
                 if ($completiondata->completionstate == COMPLETION_COMPLETE || $completiondata->completionstate == COMPLETION_COMPLETE_PASS) {
                     $complete++;
                 }
             }
         }
     }
     if (empty($sectionmods)) {
         // No sections.
         return '';
     }
     // Output section activities summary.
     $o = '';
     $o .= "<div class='section-summary-activities mdl-right'>";
     foreach ($sectionmods as $mod) {
         $o .= "<span class='activity-count'>";
         $o .= $mod['name'] . ': ' . $mod['count'];
         $o .= "</span>";
     }
     $o .= "</div>";
     $a = false;
     // Output section completion data.
     if ($total > 0) {
         $a = new stdClass();
         $a->complete = $complete;
         $a->total = $total;
         $a->percentage = $complete / $total * 100;
         $o .= "<div class='section-summary-activities mdl-right'>";
         $o .= "<span class='activity-count'>" . get_string('progresstotal', 'completion', $a) . "</span>";
         $o .= "</div>";
     }
     $retobj = (object) array('output' => $o, 'progress' => $a, 'complete' => $complete, 'total' => $total);
     return $retobj;
 }
开发者ID:nbartley,项目名称:moodle-theme_snap,代码行数:69,代码来源:snap_shared.php


示例3: toc_progress

 /**
  * toc progress percentage
  * @param stdClass $section
  * @param stdClass $course
  * @param boolean $perc - display as a percentage if true
  * @return string
  *
  * @Author Guy Thomas
  * @Date 2014-05-23
  */
 protected function toc_progress($section, $course, $perc = false)
 {
     global $CFG, $OUTPUT;
     require_once $CFG->libdir . '/completionlib.php';
     $completioninfo = new completion_info($course);
     if (!$completioninfo->is_enabled()) {
         return '';
         // Completion tracking not enabled.
     }
     $sac = snap_shared::section_activity_summary($section, $course, null);
     if (!empty($sac->progress)) {
         if ($perc) {
             $percentage = $sac->progress->percentage != null ? round($sac->progress->percentage, 0) . '%' : '';
             return '<span class="completionstatus percentage">' . $percentage . '</span>';
         } else {
             if ($sac->progress->total > 0) {
                 $progress = get_string('progresstotal', 'completion', $sac->progress);
                 $completed = '';
                 if ($sac->progress->complete === $sac->progress->total) {
                     $winbadge = $OUTPUT->pix_url('i/completion-manual-y');
                     $completedstr = s(get_string('completed', 'completion'));
                     $completed = "<img class=snap-section-complete src='{$winbadge}' alt='{$completedstr}' />";
                 }
                 $printprogress = "<span class='completionstatus outoftotal'>{$completed} {$progress}</span>";
                 return $printprogress;
             } else {
                 return '';
             }
         }
     }
 }
开发者ID:nadavkav,项目名称:moodle-theme_snap,代码行数:41,代码来源:toc_renderer.php


示例4: test_update_activity_completion_status_manually

 /**
  * Test update_activity_completion_status_manually
  */
 public function test_update_activity_completion_status_manually()
 {
     global $DB, $CFG;
     $this->resetAfterTest(true);
     $CFG->enablecompletion = true;
     $user = $this->getDataGenerator()->create_user();
     $course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
     $data = $this->getDataGenerator()->create_module('data', array('course' => $course->id), array('completion' => 1));
     $cm = get_coursemodule_from_id('data', $data->cmid);
     $studentrole = $DB->get_record('role', array('shortname' => 'student'));
     $this->getDataGenerator()->enrol_user($user->id, $course->id, $studentrole->id);
     $this->setUser($user);
     $result = core_completion_external::update_activity_completion_status_manually($data->cmid, true);
     // We need to execute the return values cleaning process to simulate the web service server.
     $result = external_api::clean_returnvalue(core_completion_external::update_activity_completion_status_manually_returns(), $result);
     // Check in DB.
     $this->assertEquals(1, $DB->get_field('course_modules_completion', 'completionstate', array('coursemoduleid' => $data->cmid)));
     // Check using the API.
     $completion = new completion_info($course);
     $completiondata = $completion->get_data($cm);
     $this->assertEquals(1, $completiondata->completionstate);
     $this->assertTrue($result['status']);
     $result = core_completion_external::update_activity_completion_status_manually($data->cmid, false);
     // We need to execute the return values cleaning process to simulate the web service server.
     $result = external_api::clean_returnvalue(core_completion_external::update_activity_completion_status_manually_returns(), $result);
     $this->assertEquals(0, $DB->get_field('course_modules_completion', 'completionstate', array('coursemoduleid' => $data->cmid)));
     $completiondata = $completion->get_data($cm);
     $this->assertEquals(0, $completiondata->completionstate);
     $this->assertTrue($result['status']);
 }
开发者ID:Hirenvaghasiya,项目名称:moodle,代码行数:33,代码来源:externallib_test.php


示例5: navbuttons_activity_showbuttons

/**
 * Check if an activity is configured to only show navbuttons when
 * complete and then check if the activity is complete
 * @param cm_info $cm the course module for the activity
 * @return boolean true if the navbuttons should be shown
 */
function navbuttons_activity_showbuttons($cm)
{
    $modname = $cm->modname;
    $show = get_config('block_navbuttons', 'activity' . $modname);
    if ($show === false || $show == NAVBUTTONS_ACTIVITY_ALWAYS) {
        return true;
        // No config or 'always show'
    }
    if ($show == NAVBUTTONS_ACTIVITY_NEVER) {
        return false;
    }
    if ($show == NAVBUTTONS_ACTIVITY_COMPLETE) {
        $completion = new completion_info($cm->get_course());
        if (!$completion->is_enabled($cm)) {
            return true;
            // No completion tracking - show the buttons
        }
        $cmcompletion = $completion->get_data($cm);
        if ($cmcompletion->completionstate == COMPLETION_INCOMPLETE) {
            return false;
        }
        return true;
    }
    if (!isloggedin() || isguestuser()) {
        return true;
        // Always show the buttons if not logged in
    }
    // NAVBUTTONS_ACTIVITY_CUSTOM
    $funcname = 'navbuttons_mod_' . $modname . '_showbuttons';
    if (!function_exists($funcname)) {
        return true;
        // Shouldn't have got to here, but allow the buttons anyway
    }
    return $funcname($cm);
}
开发者ID:kbwebsolutions,项目名称:moodle-navbuttons,代码行数:41,代码来源:activityready.php


示例6: test_survey_view

 /**
  * Test survey_view
  * @return void
  */
 public function test_survey_view()
 {
     global $CFG;
     $CFG->enablecompletion = 1;
     $this->resetAfterTest();
     $this->setAdminUser();
     // Setup test data.
     $course = $this->getDataGenerator()->create_course(array('enablecompletion' => 1));
     $survey = $this->getDataGenerator()->create_module('survey', array('course' => $course->id), array('completion' => 2, 'completionview' => 1));
     $context = context_module::instance($survey->cmid);
     $cm = get_coursemodule_from_instance('survey', $survey->id);
     // Trigger and capture the event.
     $sink = $this->redirectEvents();
     survey_view($survey, $course, $cm, $context, 'form');
     $events = $sink->get_events();
     // 2 additional events thanks to completion.
     $this->assertCount(3, $events);
     $event = array_shift($events);
     // Checking that the event contains the expected values.
     $this->assertInstanceOf('\\mod_survey\\event\\course_module_viewed', $event);
     $this->assertEquals($context, $event->get_context());
     $moodleurl = new \moodle_url('/mod/survey/view.php', array('id' => $cm->id));
     $this->assertEquals($moodleurl, $event->get_url());
     $this->assertEquals('form', $event->other['viewed']);
     $this->assertEventContextNotUsed($event);
     $this->assertNotEmpty($event->get_name());
     // Check completion status.
     $completion = new completion_info($course);
     $completiondata = $completion->get_data($cm);
     $this->assertEquals(1, $completiondata->completionstate);
 }
开发者ID:evltuma,项目名称:moodle,代码行数:35,代码来源:lib_test.php


示例7: update_activity_completion_status_manually

 /**
  * Update completion status for the current user in an activity, only for activities with manual tracking.
  * @param  int $cmid      Course module id
  * @param  bool $completed Activity completed or not
  * @return array            Result and possible warnings
  * @since Moodle 2.9
  * @throws moodle_exception
  */
 public static function update_activity_completion_status_manually($cmid, $completed)
 {
     // Validate and normalize parameters.
     $params = self::validate_parameters(self::update_activity_completion_status_manually_parameters(), array('cmid' => $cmid, 'completed' => $completed));
     $cmid = $params['cmid'];
     $completed = $params['completed'];
     $warnings = array();
     $context = context_module::instance($cmid);
     self::validate_context($context);
     list($course, $cm) = get_course_and_cm_from_cmid($cmid);
     // Set up completion object and check it is enabled.
     $completion = new completion_info($course);
     if (!$completion->is_enabled()) {
         throw new moodle_exception('completionnotenabled', 'completion');
     }
     // Check completion state is manual.
     if ($cm->completion != COMPLETION_TRACKING_MANUAL) {
         throw new moodle_exception('cannotmanualctrack', 'error');
     }
     $targetstate = $completed ? COMPLETION_COMPLETE : COMPLETION_INCOMPLETE;
     $completion->update_state($cm, $targetstate);
     $result = array();
     $result['status'] = true;
     $result['warnings'] = $warnings;
     return $result;
 }
开发者ID:Hirenvaghasiya,项目名称:moodle,代码行数:34,代码来源:external.php


示例8: execute

    function execute($data, $row, $user, $courseid, $starttime = 0, $endtime = 0) {
        global $DB, $CFG;

        require_once("{$CFG->libdir}/completionlib.php");

        $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);

        $info = new completion_info($course);

        // Is course complete?
        $coursecomplete = $info->is_course_complete($row->id);

        // Load course completion.
        $params = array(
            'userid' => $row->id,
            'course' => $course->id
        );
        $ccompletion = new completion_completion($params);

        // Has this user completed any criteria?
        $criteriacomplete = $info->count_course_user_data($row->id);

        $content = "";
        if ($coursecomplete) {
            $content .= get_string('complete');
        } else if (!$criteriacomplete && !$ccompletion->timestarted) {
            $content .= html_writer::tag('i', get_string('notyetstarted', 'completion'));
        } else {
            $content .= html_writer::tag('i', get_string('inprogress', 'completion'));
        }
        return $content;
    }
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:32,代码来源:plugin.class.php


示例9: execute

 public function execute()
 {
     global $DB, $CFG;
     $result = $DB->get_records_sql('SELECT ba.id, ba.bookingid, ba.optionid, ba.userid, b.course
         FROM {booking_answers} AS ba
         LEFT JOIN {booking_options} AS bo 
         ON bo.id = ba.optionid
         LEFT JOIN {booking} AS b
         ON b.id = bo.bookingid
         WHERE bo.removeafterminutes > 0
         AND ba.completed = 1
         AND IF(ba.timemodified < (UNIX_TIMESTAMP() - (bo.removeafterminutes*60)), 1, 0) = 1;');
     require_once $CFG->libdir . '/completionlib.php';
     foreach ($result as $value) {
         $course = $DB->get_record('course', array('id' => $value->course));
         $completion = new \completion_info($course);
         $cm = get_coursemodule_from_instance('booking', $value->bookingid);
         $userData = $DB->get_record('booking_answers', array('id' => $value->id));
         $booking = $DB->get_record('booking', array('id' => $value->bookingid));
         $userData->completed = '0';
         $userData->timemodified = time();
         $DB->update_record('booking_answers', $userData);
         if ($completion->is_enabled($cm) && $booking->enablecompletion) {
             $completion->update_state($cm, COMPLETION_INCOMPLETE, $userData->userid);
         }
     }
 }
开发者ID:375michael40veit,项目名称:moodle-mod_booking,代码行数:27,代码来源:remove_activity_completion.php


示例10: get_content

 public function get_content()
 {
     global $CFG, $USER;
     // If content is cached
     if ($this->content !== NULL) {
         return $this->content;
     }
     // Create empty content
     $this->content = new stdClass();
     // Can edit settings?
     $can_edit = has_capability('moodle/course:update', get_context_instance(CONTEXT_COURSE, $this->page->course->id));
     // Get course completion data
     $info = new completion_info($this->page->course);
     // Don't display if completion isn't enabled!
     if (!completion_info::is_enabled_for_site()) {
         if ($can_edit) {
             $this->content->text = get_string('completionnotenabledforsite', 'completion');
         }
         return $this->content;
     } else {
         if (!$info->is_enabled()) {
             if ($can_edit) {
                 $this->content->text = get_string('completionnotenabledforcourse', 'completion');
             }
             return $this->content;
         }
     }
     // Get this user's data
     $completion = $info->get_completion($USER->id, COMPLETION_CRITERIA_TYPE_SELF);
     // Check if self completion is one of this course's criteria
     if (empty($completion)) {
         if ($can_edit) {
             $this->content->text = get_string('selfcompletionnotenabled', 'block_selfcompletion');
         }
         return $this->content;
     }
     // Check this user is enroled
     if (!$info->is_tracked_user($USER->id)) {
         $this->content->text = get_string('notenroled', 'completion');
         return $this->content;
     }
     // Is course complete?
     if ($info->is_course_complete($USER->id)) {
         $this->content->text = get_string('coursealreadycompleted', 'completion');
         return $this->content;
         // Check if the user has already marked themselves as complete
     } else {
         if ($completion->is_complete()) {
             $this->content->text = get_string('alreadyselfcompleted', 'block_selfcompletion');
             return $this->content;
             // If user is not complete, or has not yet self completed
         } else {
             $this->content->text = '';
             $this->content->footer = '<br /><a href="' . $CFG->wwwroot . '/course/togglecompletion.php?course=' . $this->page->course->id . '">';
             $this->content->footer .= get_string('completecourse', 'block_selfcompletion') . '</a>...';
         }
     }
     return $this->content;
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:59,代码来源:block_selfcompletion.php


示例11: completion_report_extend_navigation

/**
 * This function extends the navigation with the report items
 *
 * @param navigation_node $navigation The navigation node to extend
 * @param stdClass $course The course to object for the report
 * @param stdClass $context The context of the course
 */
function completion_report_extend_navigation($navigation, $course, $context)
{
    global $CFG, $OUTPUT;
    if (has_capability('coursereport/completion:view', $context)) {
        $completion = new completion_info($course);
        if ($completion->is_enabled() && $completion->has_criteria()) {
            $url = new moodle_url('/course/report/completion/index.php', array('course' => $course->id));
            $navigation->add(get_string('pluginname', 'coursereport_completion'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
        }
    }
}
开发者ID:vuchannguyen,项目名称:web,代码行数:18,代码来源:lib.php


示例12: allow_add

 protected function allow_add($course, \cm_info $cm = null, \section_info $section = null)
 {
     global $CFG;
     // Check if completion is enabled for the course.
     require_once $CFG->libdir . '/completionlib.php';
     $info = new \completion_info($course);
     if (!$info->is_enabled()) {
         return false;
     }
     // Check if there's at least one other module with completion info.
     $params = $this->get_javascript_init_params($course, $cm, $section);
     return (array) $params[0] != false;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:13,代码来源:frontend.php


示例13: course_completion_gauge

 public function course_completion_gauge(&$course, $div, $width = 160, $height = 160, $type = 'progressbar')
 {
     global $USER, $PAGE;
     $str = '';
     $completion = new completion_info($course);
     if ($completion->is_enabled(null)) {
         $alltracked = count($completion->get_activities());
         $progressinfo = $completion->get_progress_all('u.id = :userid', array('userid' => $USER->id));
         $completed = 0;
         if (!empty($progressinfo)) {
             if (!empty($progressinfo[$USER->id]->progress)) {
                 foreach ($progressinfo[$USER->id]->progress as $progressrecord) {
                     if ($progressrecord->completionstate) {
                         $completed++;
                     }
                 }
             }
         }
         $ratio = $alltracked == 0 ? 0 : round($completed / $alltracked * 100);
         $jqwrenderer = $PAGE->get_renderer('local_vflibs');
         if ($div == 'div') {
             $str .= '<div class="course-completion" title="' . get_string('completion', 'local_my', 0 + $ratio) . '">';
         } else {
             $str .= '<td class="course-completion" title="' . get_string('completion', 'local_my', 0 + $ratio) . '">';
         }
         if ($type == 'gauge') {
             $properties = array('width' => $width, 'height' => $height, 'max' => 100, 'crop' => 120);
             $str .= $jqwrenderer->jqw_bargauge_simple('completion-jqw-' . $course->id, array($ratio), $properties);
         } else {
             $properties = array('width' => $width, 'height' => $height, 'animation' => 300, 'template' => 'success');
             $str .= $jqwrenderer->jqw_progress_bar('completion-jqw-' . $course->id, $ratio, $properties);
         }
         if ($div == 'div') {
             $str .= '</div>';
         } else {
             $str .= '</td>';
         }
     } else {
         if ($div == 'div') {
             $str .= '<div class="course-completion">';
         } else {
             $str .= '<td class="course-completion">';
         }
         if ($div == 'div') {
             $str .= '</div>';
         } else {
             $str .= '</td>';
         }
     }
     return $str;
 }
开发者ID:vfremaux,项目名称:moodle-local_my,代码行数:51,代码来源:renderer.php


示例14: display_action

 /**
  * Routes to a valid action.
  *
  * @param string $action
  * @access public
  * @return string Rendered output for display.
  */
 public function display_action($action)
 {
     $this->renderer->setup_page($this);
     $method = "action_{$action}";
     if (!method_exists(__CLASS__, $method)) {
         throw new \invalid_parameter_exception("Unknown action: {$action}");
     }
     $output = $this->{$method}();
     $completion = new \completion_info($this->course);
     $completion->set_module_viewed($this->cm);
     $header = $this->header();
     $footer = $this->renderer->footer();
     return $header . $output . $footer;
 }
开发者ID:eSrem,项目名称:moodle-mod_mediagallery,代码行数:21,代码来源:viewcontroller.php


示例15: progress_report_extend_navigation

/**
 * This function extends the navigation with the report items
 *
 * @param navigation_node $navigation The navigation node to extend
 * @param stdClass $course The course to object for the report
 * @param stdClass $context The context of the course
 */
function progress_report_extend_navigation($navigation, $course, $context)
{
    global $CFG, $OUTPUT;
    $showonnavigation = has_capability('coursereport/progress:view', $context);
    $group = groups_get_course_group($course, true);
    // Supposed to verify group
    if ($group === 0 && $course->groupmode == SEPARATEGROUPS) {
        $showonnavigation = $showonnavigation && has_capability('moodle/site:accessallgroups', $context);
    }
    $completion = new completion_info($course);
    $showonnavigation = $showonnavigation && $completion->is_enabled() && count($completion->get_activities()) > 0;
    if ($showonnavigation) {
        $url = new moodle_url('/course/report/progress/index.php', array('course' => $course->id));
        $navigation->add(get_string('pluginname', 'coursereport_progress'), $url, navigation_node::TYPE_SETTING, null, null, new pix_icon('i/report', ''));
    }
}
开发者ID:vuchannguyen,项目名称:web,代码行数:23,代码来源:lib.php


示例16: test_has_activities

 function test_has_activities()
 {
     global $DB;
     $this->resetAfterTest(true);
     // Create a course with mixed auto completion data.
     $course = $this->getDataGenerator()->create_course();
     $course2 = $this->getDataGenerator()->create_course();
     $completionauto = array('completion' => COMPLETION_TRACKING_AUTOMATIC);
     $completionnone = array('completion' => COMPLETION_TRACKING_NONE);
     $c1forum = $this->getDataGenerator()->create_module('forum', array('course' => $course->id), $completionauto);
     $c2forum = $this->getDataGenerator()->create_module('forum', array('course' => $course2->id), $completionnone);
     $c1 = new completion_info($course);
     $c2 = new completion_info($course2);
     $this->assertTrue($c1->has_activities());
     $this->assertFalse($c2->has_activities());
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:16,代码来源:completionlib_advanced_test.php


示例17: mod_stopwatch_update_timer

/**
 *
 * @param cm_info $cm
 * @param stdClass $stopwatch
 * @param int $duration
 */
function mod_stopwatch_update_timer(cm_info $cm, $stopwatch, $duration)
{
    global $USER, $DB, $CFG;
    require_once $CFG->libdir . '/completionlib.php';
    $record = $DB->get_record('stopwatch_user', array('stopwatchid' => $cm->instance, 'courseid' => $cm->course, 'userid' => $USER->id));
    if ($record) {
        $data = array('id' => $record->id, 'timemodified' => time(), 'duration' => $duration);
        $DB->update_record('stopwatch_user', $data);
    } else {
        $data = array('courseid' => $cm->course, 'stopwatchid' => $cm->instance, 'userid' => $USER->id, 'timecreated' => time(), 'timemodified' => time(), 'duration' => $duration);
        $DB->insert_record('stopwatch_user', $data);
    }
    // Update completion state
    $completion = new completion_info($cm->get_course());
    if ($completion->is_enabled($cm) && $stopwatch->completiontimed) {
        $completion->update_state($cm, COMPLETION_COMPLETE);
    }
}
开发者ID:marinaglancy,项目名称:moodle-mod_stopwatch,代码行数:24,代码来源:locallib.php


示例18: update_require_specific_grade

 /**
  * Updates activity completion status.
  *
  * @return void
  */
 public static function update_require_specific_grade(\core\event\base $event)
 {
     global $DB;
     $entryuserid = $event->relateduserid;
     $giid = $event->other['itemid'];
     if (!($gitem = \grade_item::fetch(array('id' => $giid, 'itemmodule' => 'dataform')))) {
         return;
     }
     $dataformid = $gitem->iteminstance;
     $df = \mod_dataform_dataform::instance($dataformid);
     // Currently only completion by require entries.
     if ($df->completionspecificgrade) {
         $completion = new \completion_info($df->course);
         if ($completion->is_enabled($df->cm) != COMPLETION_TRACKING_AUTOMATIC) {
             return;
         }
         $completion->update_state($df->cm, COMPLETION_UNKNOWN, $entryuserid);
     }
 }
开发者ID:parksandwildlife,项目名称:learning,代码行数:24,代码来源:completion.php


示例19: read_page

 /**
  * Read page
  *
  * @throws \coding_exception
  * @return stdClass
  */
 private function read_page()
 {
     global $PAGE, $COURSE;
     $cm = $PAGE->cm;
     $page = \theme_snap\local::get_page_mod($cm);
     $context = $PAGE->context;
     // Trigger module instance viewed event.
     $event = \mod_page\event\course_module_viewed::create(array('objectid' => $page->id, 'context' => $context));
     $event->add_record_snapshot('course_modules', $cm);
     $event->add_record_snapshot('course', $COURSE);
     $event->add_record_snapshot('page', $page);
     $event->trigger();
     // Update 'viewed' state if required by completion system.
     $completion = new \completion_info($COURSE);
     $completion->set_module_viewed($cm);
     $renderer = $PAGE->get_renderer('core', 'course');
     $page->completionhtml = $renderer->course_section_cm_completion($COURSE, $completion, $cm);
     return $page;
 }
开发者ID:pramithkm,项目名称:moodle-theme_snap,代码行数:25,代码来源:pagemod_controller.php


示例20: get_content

 public function get_content()
 {
     global $USER;
     // If content is cached
     if ($this->content !== NULL) {
         return $this->content;
     }
     global $CFG;
     // Create empty content
     $this->content = new stdClass();
     // Don't display if completion isn't enabled!
     if (!$this->page->course->enablecompletion) {
         $this->content->text = get_string('completionnotenabled', 'block_selfcompletion');
         return $this->content;
     }
     // Get course completion data
     $info = new completion_info($this->page->course);
     $completion = $info->get_completion($USER->id, COMPLETION_CRITERIA_TYPE_SELF);
     // Is course complete?
     if ($info->is_course_complete($USER->id)) {
         return $this->content;
     }
     // Check if self completion is one of this course's criteria
     if (empty($completion)) {
         $this->content->text = get_string('selfcompletionnotenabled', 'block_selfcompletion');
         return $this->content;
     }
     // Check this user is enroled
     if (!$info->is_tracked_user($USER->id)) {
         $this->content->text = get_string('notenroled', 'completion');
         return $this->content;
     }
     // Check if the user has already marked themselves as complete
     if ($completion->is_complete()) {
         return $this->content;
     } else {
         $this->content->text = '';
         $this->content->footer = '<br /><a href="' . $CFG->wwwroot . '/course/togglecompletion.php?course=' . $this->page->course->id . '">' . get_string('completecourse', 'block_selfcompletion') . '</a>...';
     }
     return $this->content;
 }
开发者ID:nfreear,项目名称:moodle,代码行数:41,代码来源:block_selfcompletion.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP complex_array类代码示例发布时间:2022-05-23
下一篇:
PHP completion_completion类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap