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


PHP completion_info::internal_set_data方法代码示例

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


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

示例1: test_course_module_completion_updated_event

 /**
  * Test course module completion update event.
  */
 public function test_course_module_completion_updated_event()
 {
     global $USER, $CFG;
     $this->setup_data();
     $this->setAdminUser();
     $completionauto = array('completion' => COMPLETION_TRACKING_AUTOMATIC);
     $forum = $this->getDataGenerator()->create_module('forum', array('course' => $this->course->id), $completionauto);
     $c = new completion_info($this->course);
     $activities = $c->get_activities();
     $this->assertEquals(1, count($activities));
     $this->assertTrue(isset($activities[$forum->cmid]));
     $this->assertEquals($activities[$forum->cmid]->name, $forum->name);
     $current = $c->get_data($activities[$forum->cmid], false, $this->user->id);
     $current->completionstate = COMPLETION_COMPLETE;
     $current->timemodified = time();
     $sink = $this->redirectEvents();
     $c->internal_set_data($activities[$forum->cmid], $current);
     $events = $sink->get_events();
     $event = reset($events);
     $this->assertInstanceOf('\\core\\event\\course_module_completion_updated', $event);
     $this->assertEquals($forum->cmid, $event->get_record_snapshot('course_modules_completion', $event->objectid)->coursemoduleid);
     $this->assertEquals($current, $event->get_record_snapshot('course_modules_completion', $event->objectid));
     $this->assertEquals(context_module::instance($forum->cmid), $event->get_context());
     $this->assertEquals($USER->id, $event->userid);
     $this->assertEquals($this->user->id, $event->relateduserid);
     $this->assertInstanceOf('moodle_url', $event->get_url());
     $this->assertEventLegacyData($current, $event);
 }
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:31,代码来源:completionlib_test.php

示例2: array

    function test_internal_set_data() {
        global $DB, $SESSION;

        $cm = (object)array('course' => 42,'id' => 13);
        $c = new completion_info((object)array('id' => 42));

        // 1) Test with new data
        $data = (object)array('id'=>0, 'userid' => 314159, 'coursemoduleid' => 99);
        $DB->expects($this->at(0))
            ->method('start_delegated_transaction')
            ->will($this->returnValue($this->getMock('moodle_transaction', array(), array($DB))));

        $DB->expects($this->at(1))
            ->method('get_field')
            ->with('course_modules_completion', 'id', array('coursemoduleid'=>99, 'userid'=>314159))
            ->will($this->returnValue(false));

        $DB->expects($this->at(2))
            ->method('insert_record')
            ->will($this->returnValue(4));

        $c->internal_set_data($cm, $data);
        $this->assertEquals(4, $data->id);
        $this->assertEquals(array(42 => array(13 => $data)), $SESSION->completioncache);

        // 2) Test with existing data and for different user (not cached)
        unset($SESSION->completioncache);
        $d2 = (object)array('id' => 7, 'userid' => 17, 'coursemoduleid' => 66);
        $DB->expects($this->at(0))
            ->method('start_delegated_transaction')
            ->will($this->returnValue($this->getMock('moodle_transaction', array(), array($DB))));
        $DB->expects($this->at(1))
            ->method('update_record')
            ->with('course_modules_completion', $d2);
        $c->internal_set_data($cm, $d2);
        $this->assertFalse(isset($SESSION->completioncache));

        // 3) Test where it THINKS the data is new (from cache) but actually
        // in the database it has been set since
        // 1) Test with new data
        $data = (object)array('id'=>0, 'userid' => 314159, 'coursemoduleid' => 99);
        $d3 = (object)array('id' => 13, 'userid' => 314159, 'coursemoduleid' => 99);
        $DB->expects($this->at(0))
            ->method('start_delegated_transaction')
            ->will($this->returnValue($this->getMock('moodle_transaction', array(), array($DB))));
        $DB->expects($this->at(1))
            ->method('get_field')
            ->with('course_modules_completion', 'id', array('coursemoduleid' => 99, 'userid' => 314159))
            ->will($this->returnValue(13));
        $DB->expects($this->at(2))
            ->method('update_record')
            ->with('course_modules_completion', $d3);
        $c->internal_set_data($cm, $data);
    }
开发者ID:nigeli,项目名称:moodle,代码行数:54,代码来源:completionlib_test.php

示例3: test_badges_observer_course_module_criteria_review

 /**
  * Test badges observer when course module completion event id fired.
  */
 public function test_badges_observer_course_module_criteria_review()
 {
     $this->preventResetByRollback();
     // Messaging is not compatible with transactions.
     $badge = new badge($this->coursebadge);
     $this->assertFalse($badge->is_issued($this->user->id));
     $criteria_overall = award_criteria::build(array('criteriatype' => BADGE_CRITERIA_TYPE_OVERALL, 'badgeid' => $badge->id));
     $criteria_overall->save(array('agg' => BADGE_CRITERIA_AGGREGATION_ANY));
     $criteria_overall = award_criteria::build(array('criteriatype' => BADGE_CRITERIA_TYPE_ACTIVITY, 'badgeid' => $badge->id));
     $criteria_overall->save(array('agg' => BADGE_CRITERIA_AGGREGATION_ANY, 'module_' . $this->module->cmid => $this->module->cmid));
     // Set completion for forum activity.
     $c = new completion_info($this->course);
     $activities = $c->get_activities();
     $this->assertEquals(1, count($activities));
     $this->assertTrue(isset($activities[$this->module->cmid]));
     $this->assertEquals($activities[$this->module->cmid]->name, $this->module->name);
     $current = $c->get_data($activities[$this->module->cmid], false, $this->user->id);
     $current->completionstate = COMPLETION_COMPLETE;
     $current->timemodified = time();
     $sink = $this->redirectEmails();
     $c->internal_set_data($activities[$this->module->cmid], $current);
     $this->assertCount(1, $sink->get_messages());
     $sink->close();
     // Check if badge is awarded.
     $this->assertDebuggingCalled('Error baking badge image!');
     $this->assertTrue($badge->is_issued($this->user->id));
 }
开发者ID:nikitskynikita,项目名称:moodle,代码行数:30,代码来源:badgeslib_test.php

示例4: array

 function test_internal_set_data()
 {
     global $DB, $SESSION;
     $cm = (object) array('course' => 42, 'id' => 13);
     $c = new completion_info((object) array('id' => 42));
     // 1) Test with new data
     $data = (object) array('id' => 0, 'userid' => 314159);
     $DB->setReturnValueAt(0, 'insert_record', 4);
     $DB->expectAt(0, 'insert_record', array('course_modules_completion', $data));
     $c->internal_set_data($cm, $data);
     $this->assertEqual(4, $data->id);
     $this->assertEqual(array(42 => array(13 => $data)), $SESSION->completioncache);
     // 2) Test with existing data and for different user (not cached)
     unset($SESSION->completioncache);
     $d2 = (object) array('id' => 7, 'userid' => 17);
     $DB->expectAt(0, 'update_record', array('course_modules_completion', $d2));
     $c->internal_set_data($cm, $d2);
     $this->assertFalse(isset($SESSION->completioncache));
     $DB->tally();
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:20,代码来源:testcompletionlib.php

示例5: array

 function test_internal_set_data()
 {
     global $DB, $SESSION;
     $cm = (object) array('course' => 42, 'id' => 13);
     $c = new completion_info((object) array('id' => 42));
     // 1) Test with new data
     $data = (object) array('id' => 0, 'userid' => 314159, 'coursemoduleid' => 99);
     $DB->setReturnValueAt(0, 'start_delegated_transaction', new mock_transaction());
     $DB->setReturnValueAt(0, 'insert_record', 4);
     $DB->expectAt(0, 'get_field', array('course_modules_completion', 'id', array('coursemoduleid' => 99, 'userid' => 314159)));
     $DB->expectAt(0, 'insert_record', array('course_modules_completion', $data));
     $c->internal_set_data($cm, $data);
     $this->assertEqual(4, $data->id);
     $this->assertEqual(array(42 => array(13 => $data)), $SESSION->completioncache);
     // 2) Test with existing data and for different user (not cached)
     unset($SESSION->completioncache);
     $d2 = (object) array('id' => 7, 'userid' => 17, 'coursemoduleid' => 66);
     $DB->setReturnValueAt(1, 'start_delegated_transaction', new mock_transaction());
     $DB->expectAt(0, 'update_record', array('course_modules_completion', $d2));
     $c->internal_set_data($cm, $d2);
     $this->assertFalse(isset($SESSION->completioncache));
     // 3) Test where it THINKS the data is new (from cache) but actually
     // in the database it has been set since
     // 1) Test with new data
     $data = (object) array('id' => 0, 'userid' => 314159, 'coursemoduleid' => 99);
     $DB->setReturnValueAt(2, 'start_delegated_transaction', new mock_transaction());
     $DB->setReturnValueAt(1, 'get_field', 13);
     $DB->expectAt(1, 'get_field', array('course_modules_completion', 'id', array('coursemoduleid' => 99, 'userid' => 314159)));
     $d3 = (object) array('id' => 13, 'userid' => 314159, 'coursemoduleid' => 99);
     $DB->expectAt(1, 'update_record', array('course_modules_completion', $d3));
     $c->internal_set_data($cm, $data);
     //$DB->tally();
 }
开发者ID:robadobdob,项目名称:moodle,代码行数:33,代码来源:testcompletionlib.php

示例6: xmldb_hotpot_upgrade


//.........这里部分代码省略.........
        }
        upgrade_mod_savepoint(true, "{$newversion}", 'hotpot');
    }
    $newversion = 2014011694;
    if ($oldversion < $newversion) {
        require_once $CFG->dirroot . '/mod/hotpot/lib.php';
        hotpot_update_grades();
        upgrade_mod_savepoint(true, "{$newversion}", 'hotpot');
    }
    $newversion = 2014111133;
    if ($oldversion < $newversion) {
        // fix all hotpots with view completion
        if (defined('COMPLETION_VIEW_REQUIRED')) {
            $moduleid = $DB->get_field('modules', 'id', array('name' => 'hotpot'));
            $params = array('module' => $moduleid, 'completionview' => COMPLETION_VIEW_REQUIRED);
            if ($cms = $DB->get_records('course_modules', $params, 'course,section')) {
                $time = time();
                $course = null;
                foreach ($cms as $cm) {
                    $params = array('coursemoduleid' => $cm->id, 'viewed' => COMPLETION_VIEWED, 'completionstate' => COMPLETION_INCOMPLETE);
                    if ($userids = $DB->get_records_menu('course_modules_completion', $params, '', 'id,userid')) {
                        if ($course === null || $course->id != $cm->course) {
                            $params = array('id' => $cm->course);
                            $course = $DB->get_record('course', $params);
                            $completion = new completion_info($course);
                        }
                        $userids = array_values($userids);
                        $userids = array_unique($userids);
                        foreach ($userids as $userid) {
                            // mimic "set_module_viewed($cm, $userid)"
                            // but without the warnings about headers
                            $data = $completion->get_data($cm, false, $userid);
                            $data->viewed = COMPLETION_VIEWED;
                            $completion->internal_set_data($cm, $data);
                            $completion->update_state($cm, COMPLETION_COMPLETE, $userid);
                        }
                    }
                }
            }
        }
        upgrade_mod_savepoint(true, "{$newversion}", 'hotpot');
    }
    $newversion = 2014112837;
    if ($oldversion < $newversion) {
        require_once $CFG->dirroot . '/mod/hotpot/lib.php';
        if (function_exists('get_log_manager')) {
            if ($loglegacy = get_config('loglegacy', 'logstore_legacy')) {
                set_config('loglegacy', 0, 'logstore_legacy');
            }
            $legacy_log_tablename = 'log';
            $legacy_log_table = new xmldb_table($legacy_log_tablename);
            $standard_log_tablename = 'logstore_standard_log';
            $standard_log_table = new xmldb_table($standard_log_tablename);
            if ($dbman->table_exists($legacy_log_table) && $dbman->table_exists($standard_log_table)) {
                $select = 'module = ?';
                $params = array('hotpot');
                if ($time = $DB->get_field($standard_log_tablename, 'MAX(timecreated)', array('component' => 'hotpot'))) {
                    $select .= ' AND time > ?';
                    $params[] = $time;
                } else {
                    if ($time = $DB->get_field($standard_log_tablename, 'MIN(timecreated)', array())) {
                        $select .= ' AND time > ?';
                        $params[] = $time;
                    }
                }
                if ($count = $DB->count_records_select($legacy_log_tablename, $select, $params)) {
开发者ID:OctaveBabel,项目名称:moodle-itop,代码行数:67,代码来源:upgrade.php


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