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


PHP completion_info类代码示例

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


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


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