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

PHP elispm类代码示例

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

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



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

示例1: test_classmoodlecourse_preventsduplicates

 /**
  * Test validation of duplicates
  * @expectedException data_object_validation_exception
  */
 public function test_classmoodlecourse_preventsduplicates()
 {
     $dataset = $this->createCsvDataSet(array(classmoodlecourse::TABLE => elispm::file('tests/fixtures/class_moodle_course.csv')));
     $this->loadDataSet($dataset);
     $classmoodlecourse = new classmoodlecourse(array('classid' => 100, 'moodlecourseid' => 100));
     $classmoodlecourse->save();
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:11,代码来源:classmoodlecourse_test.php


示例2: test_associate_moodle_course_during_course_update

 /**
  * Validate that course description-moodle template course associations
  * can be created during a course description update action
  */
 public function test_associate_moodle_course_during_course_update()
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/course/lib.php';
     require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
     require_once elispm::lib('data/course.class.php');
     require_once elispm::lib('data/coursetemplate.class.php');
     $coursecategory = new stdClass();
     $coursecategory->name = 'testcoursecategoryname';
     $coursecategory->id = $DB->insert_record('course_categories', $coursecategory);
     $templatecourse = new stdClass();
     $templatecourse->category = $coursecategory->id;
     $templatecourse->shortname = 'testcourseshortname';
     $templatecourse->fullname = 'testcoursefullname';
     $templatecourse = create_course($templatecourse);
     // Create the course description.
     $pmcourse = new course(array('name' => 'testcoursename', 'idnumber' => 'testcourseidnumber', 'syllabus' => ''));
     $pmcourse->save();
     // Run the course description update action.
     $record = new stdClass();
     $record->name = 'testcoursename';
     $record->idnumber = 'testcourseidnumber';
     $record->link = $templatecourse->shortname;
     $importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis');
     $importplugin->fslogger = new silent_fslogger(null);
     $importplugin->course_update($record, 'bogus');
     // Validation.
     $this->assertTrue($DB->record_exists(coursetemplate::TABLE, array('courseid' => $pmcourse->id, 'location' => $templatecourse->id, 'templateclass' => 'moodlecourseurl')));
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:33,代码来源:course_associate_moodle_course_test.php


示例3: xmldb_elisprogram_usetdisppriority_install

/**
 * Install function for this plugin
 *
 * @return  boolean  true  Returns true to satisfy install procedure
 */
function xmldb_elisprogram_usetdisppriority_install()
{
    global $CFG;
    require_once elispm::lib('setup.php');
    // Migrate component.
    $oldcmp = 'pmplugins_userset_display_priority';
    $newcmp = 'elisprogram_usetdisppriority';
    $upgradestepfuncname = 'elisprogram_usetdisppriority_pre26upgradesteps';
    $migrator = new \local_eliscore\install\migration\migrator($oldcmp, $newcmp, $upgradestepfuncname);
    if ($migrator->old_component_installed() === true) {
        $migrator->migrate();
    }
    $field = new field();
    $field->shortname = USERSET_DISPLAY_PRIORITY_FIELD;
    $field->name = get_string('display_priority_field_name', 'elisprogram_usetdisppriority');
    $field->datatype = 'int';
    $category = new field_category();
    $category->name = get_string('display_settings_category_name', 'elisprogram_usetdisppriority');
    $field = field::ensure_field_exists_for_context_level($field, CONTEXT_ELIS_USERSET, $category);
    // make sure 'manual' is an owner
    if (!isset($field->owners['manual'])) {
        $owner = new field_owner();
        $owner->fieldid = $field->id;
        $owner->plugin = 'manual';
        $owner->param_view_capability = '';
        $owner->param_edit_capability = '';
        $owner->param_control = 'text';
        $owner->param_options_source = 'userset_display_priority';
        $owner->param_help_file = 'elisprogram_usetdisppriority/display_priority';
        $owner->save();
    }
    return true;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:38,代码来源:install.php


示例4: test_make_filter_options_custom

 /**
  * Test make_filter_options_custom function
  */
 public function test_make_filter_options_custom()
 {
     global $DB;
     // Fixture.
     $datagenerator = new elis_program_datagenerator($DB);
     $pgm = $datagenerator->create_program();
     $course = $datagenerator->create_course();
     $pmclass = $datagenerator->create_pmclass(array('courseid' => $course->id));
     $dataset = $this->createCsvDataSet(array('local_elisprogram_env' => elispm::file('tests/fixtures/environment.csv')));
     $this->loadDataSet($dataset);
     // Tests.
     $choicestests = array('curriculum' => array('name' => array($pgm->id => $pgm->name)), 'course' => array('name' => array($course->id => $course->name)), 'class' => array('idnumber' => array($pmclass->id => $pmclass->idnumber), 'environmentid' => array(1 => 'Testing')));
     foreach ($choicestests as $group => $names) {
         foreach ($names as $name => $expectedchoices) {
             $curclassopts = array('choices' => array(), 'wrapper' => array($group => ''));
             $filter = new generalized_filter_curriculumclass('filt-curriculumclass', 'Null', $curclassopts);
             $options = $filter->make_filter_options_custom(array(), $group, $name);
             $this->assertInternalType('array', $options);
             $this->assertArrayHasKey('choices', $options);
             $this->assertInternalType('array', $options['choices']);
             $this->assertEquals($expectedchoices, $options['choices']);
             unset($filter);
         }
     }
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:28,代码来源:filtercurriculumclass_test.php


示例5: load_csv_data

 /**
  * Load iniital data from CSVs.
  */
 protected function load_csv_data()
 {
     $dataset = $this->createCsvDataSet(array('user' => elispm::file('tests/fixtures/mdluser.csv'), 'user_info_field' => elispm::file('tests/fixtures/user_info_field.csv'), 'user_info_data' => elispm::file('tests/fixtures/user_info_data.csv'), user::TABLE => elispm::file('tests/fixtures/pmuser.csv'), usermoodle::TABLE => elispm::file('tests/fixtures/usermoodle.csv'), field::TABLE => elispm::file('tests/fixtures/user_field.csv'), field_owner::TABLE => elispm::file('tests/fixtures/user_field_owner.csv'), curriculum::TABLE => elispm::file('tests/fixtures/curriculum.csv'), track::TABLE => elispm::file('tests/fixtures/track.csv'), course::TABLE => elispm::file('tests/fixtures/pmcourse.csv'), pmclass::TABLE => elispm::file('tests/fixtures/pmclass.csv'), userset::TABLE => elispm::file('tests/fixtures/userset.csv')));
     $dataset = new PHPUnit_Extensions_Database_DataSet_ReplacementDataSet($dataset);
     $dataset->addSubStrReplacement('\\n', "\n");
     $this->loadDataSet($dataset);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:10,代码来源:roleassignments_test.php


示例6: fixture_moodleenrol

 /**
  * Set up all data needed for testing.
  * @param array $userids List of moodle user ids to test with.
  * @param array $itemgrades List of grade item grades to test with.
  */
 public function fixture_moodleenrol($userids, $itemgrades)
 {
     global $DB;
     // Import CSV data.
     $dataset = $this->createCsvDataSet(array(course::TABLE => elispm::file('tests/fixtures/pmcourse.csv'), pmclass::TABLE => elispm::file('tests/fixtures/pmclass.csv'), 'user' => elispm::file('tests/fixtures/mdluser.csv'), user::TABLE => elispm::file('tests/fixtures/pmuser.csv'), usermoodle::TABLE => elispm::file('tests/fixtures/user_moodle.csv'), coursecompletion::TABLE => elispm::file('tests/fixtures/course_completion.csv')));
     $this->loadDataSet($dataset);
     // Create course.
     $course = $this->getDataGenerator()->create_course();
     // Link with ELIS class.
     $DB->insert_record(classmoodlecourse::TABLE, (object) array('classid' => 100, 'moodlecourseid' => $course->id));
     // Create grade items.
     $items = array(array('courseid' => $course->id, 'idnumber' => 'required', 'itemtype' => 'manual'), array('courseid' => $course->id, 'idnumber' => 'notrequired', 'itemtype' => 'manual'), array('courseid' => $course->id, 'idnumber' => 'course', 'itemtype' => 'course'));
     foreach ($items as $item) {
         $DB->insert_record('grade_items', (object) $item);
     }
     // Set up our test role.
     $roleid = create_role('gradedrole', 'gradedrole', 'gradedrole');
     set_config('gradebookroles', $roleid);
     // Create all of our test enrolments.
     foreach ($userids as $userid) {
         $this->getDataGenerator()->enrol_user($userid, $course->id, $roleid);
     }
     // Assign item grades.
     foreach ($itemgrades as $itemgrade) {
         $DB->insert_record('grade_grades', (object) $itemgrade);
     }
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:32,代码来源:pmupdatestudentprogress_test.php


示例7: test_get_corequisites

 /**
  * Test get_corequisites function.
  */
 public function test_get_corequisites()
 {
     $dataset = $this->createCsvDataSet(array(curriculumcourse::TABLE => elispm::file('tests/fixtures/curriculum_course.csv'), coursecorequisite::TABLE => elispm::file('tests/fixtures/pmcourse_corequisite.csv')));
     $this->loadDataSet($dataset);
     $curriculumcourse = new curriculumcourse();
     $curriculumcourse->id = 2;
     $coreqs = $curriculumcourse->get_corequisites();
     $this->assertEquals(array(100), $coreqs);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:12,代码来源:curriculumcourse_test.php


示例8: xmldb_elisprogram_preposttest_install

/**
 * Install function for this plugin
 *
 * @return  boolean  true  Returns true to satisfy install procedure
 */
function xmldb_elisprogram_preposttest_install()
{
    global $CFG;
    require_once elispm::lib('setup.php');
    require_once elis::lib('data/customfield.class.php');
    // Migrate component.
    $oldcmp = 'pmplugins_pre_post_test';
    $newcmp = 'elisprogram_preposttest';
    $upgradestepfuncname = 'elisprogram_preposttest_pre26upgradesteps';
    $migrator = new \local_eliscore\install\migration\migrator($oldcmp, $newcmp, $upgradestepfuncname);
    if ($migrator->old_component_installed() === true) {
        $migrator->migrate();
    }
    // Pre-test field
    $field = new field();
    $field->shortname = PRE_TEST_FIELD;
    $field->name = get_string('pre_test_field_name', 'elisprogram_preposttest');
    $field->datatype = 'char';
    $category = new field_category();
    $category->name = get_string('pre_post_test_category_name', 'elisprogram_preposttest');
    $field = field::ensure_field_exists_for_context_level($field, CONTEXT_ELIS_COURSE, $category);
    // make sure 'manual' is an owner
    if (!isset($field->owners['manual'])) {
        $owner = new field_owner();
        $owner->fieldid = $field->id;
        $owner->plugin = 'manual';
        $owner->param_view_capability = '';
        $owner->param_edit_capability = '';
        $owner->param_control = 'menu';
        $owner->param_options_source = 'learning_objectives';
        $owner->param_help_file = 'elisprogram_preposttest/pre_test';
        $owner->save();
    }
    // Post-test field
    $field = new field();
    $field->shortname = POST_TEST_FIELD;
    $field->name = get_string('post_test_field_name', 'elisprogram_preposttest');
    $field->datatype = 'char';
    $category = new field_category();
    $category->name = get_string('pre_post_test_category_name', 'elisprogram_preposttest');
    $field = field::ensure_field_exists_for_context_level($field, CONTEXT_ELIS_COURSE, $category);
    // make sure 'manual' is an owner
    if (!isset($field->owners['manual'])) {
        $owner = new field_owner();
        $owner->fieldid = $field->id;
        $owner->plugin = 'manual';
        $owner->param_view_capability = '';
        $owner->param_edit_capability = '';
        $owner->param_control = 'menu';
        $owner->param_options_source = 'learning_objectives';
        $owner->param_help_file = 'elisprogram_preposttest/post_test';
        $owner->save();
    }
    return true;
}
开发者ID:jamesmcq,项目名称:elis,代码行数:60,代码来源:install.php


示例9: require_elis_dependencies

 /**
  * Require ELIS dependencies if ELIS is installed, otherwise return false.
  * @return bool Whether ELIS dependencies were successfully required.
  */
 public static function require_elis_dependencies()
 {
     global $CFG;
     if (file_exists($CFG->dirroot . '/local/elisprogram/lib/setup.php')) {
         require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
         require_once elispm::lib('data/userset.class.php');
         return true;
     } else {
         return false;
     }
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:15,代码来源:userset_update.class.php


示例10: require_elis_dependencies

 /**
  * Require ELIS dependencies if ELIS is installed, otherwise return false.
  * @return bool Whether ELIS dependencies were successfully required.
  */
 public static function require_elis_dependencies()
 {
     global $CFG;
     if (file_exists($CFG->dirroot . '/local/elisprogram/lib/setup.php')) {
         require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
         require_once elispm::lib('data/user.class.php');
         require_once dirname(__FILE__) . '/../../importplugins/version1elis/version1elis.class.php';
         return true;
     } else {
         return false;
     }
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:16,代码来源:user_delete.class.php


示例11: get_options

 function get_options($dataobject)
 {
     global $DB;
     require_once elispm::file('plugins/usetclassify/usersetclassification.class.php');
     $result = array();
     $recs = $DB->get_recordset(usersetclassification::TABLE, null, 'name ASC', 'shortname, name');
     foreach ($recs as $rec) {
         $result[$rec->shortname] = $rec->name;
     }
     unset($recs);
     return $result;
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:12,代码来源:userset_classifications.php


示例12: init

 /**
  * Perform initialization that should
  * be done at the beginning of the export
  *
  * @param int $targetstarttime The timestamp representing the theoretical
  *                             time when this task was meant to be run
  * @param int $lastruntime     The last time the export was run
  *                             (required for incremental scheduled export)
  */
 public function init($targetstarttime = 0, $lastruntime = 0)
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
     require_once elispm::lib('data/user.class.php');
     require_once elispm::lib('data/student.class.php');
     require_once elispm::lib('data/pmclass.class.php');
     require_once elispm::lib('data/course.class.php');
     require_once elispm::lib('data/classmoodlecourse.class.php');
     // Columns that are always displayed.
     $columns = array(get_string('header_firstname', 'dhexport_version1'), get_string('header_lastname', 'dhexport_version1'), get_string('header_username', 'dhexport_version1'), get_string('header_useridnumber', 'dhexport_version1'), get_string('header_courseidnumber', 'dhexport_version1'), get_string('header_startdate', 'dhexport_version1'), get_string('header_enddate', 'dhexport_version1'), get_string('header_status', 'dhexport_version1elis'), get_string('header_grade', 'dhexport_version1'), get_string('header_letter', 'dhexport_version1'));
     // Query parameters.
     $params = array();
     // Track extra SQL and parameters needed for custom fields.
     $extra_joins = implode(" \n ", rlipexport_version1elis_extrafields::get_extra_joins());
     $extra_select = implode(', ', rlipexport_version1elis_extrafields::get_extra_select());
     if (!empty($extra_select)) {
         $extra_select = ', ' . $extra_select;
     }
     // Get columns.
     $columns = array_merge($columns, rlipexport_version1elis_extrafields::get_extra_columns());
     // Add passed as completion status requirement.
     $params[] = student::STUSTATUS_PASSED;
     // Sql time condition.
     $time_condition = '';
     // Determine if we're in incremental or non-incremental mode.
     $nonincremental = get_config('dhexport_version1elis', 'nonincremental');
     if (empty($nonincremental)) {
         if ($this->manual) {
             // Manual export incremental mode.
             // Get string delta.
             $incrementaldelta = get_config('dhexport_version1elis', 'incrementaldelta');
             // Convert to number of seconds.
             $numsecs = rlip_time_string_to_offset($incrementaldelta);
             // Add to query parameters.
             $params[] = time() - $numsecs;
             // Add query fragment.
             $time_condition = 'AND stu.completetime >= ?';
         } else {
             // Scheduled export incremental mode.
             // Set up the query fragment and parameters.
             $params[] = $lastruntime;
             $time_condition = 'AND stu.completetime >= ?';
         }
     }
     // Initialize our recordset to the core data.
     $sql = "SELECT u.id AS userid,\n                       u.firstname,\n                       u.lastname,\n                       u.username,\n                       u.idnumber,\n                       crs.idnumber AS crsidnumber,\n                       stu.enrolmenttime,\n                       stu.completetime,\n                       stu.grade,\n                       mdlcrs.id AS mdlcrsid\n                       {$extra_select}\n                FROM {" . user::TABLE . "} u\n                JOIN {" . student::TABLE . "} stu\n                  ON u.id = stu.userid\n                JOIN {" . pmclass::TABLE . "} cls\n                  ON stu.classid = cls.id\n                JOIN {" . course::TABLE . "} crs\n                  ON cls.courseid = crs.id\n                LEFT JOIN {" . classmoodlecourse::TABLE . "} clsmdl\n                  ON cls.id = clsmdl.classid\n                LEFT JOIN {course} mdlcrs\n                  ON clsmdl.moodlecourseid = mdlcrs.id\n                {$extra_joins}\n                WHERE stu.completestatusid = ?\n                {$time_condition}\n                ORDER BY u.idnumber ASC,\n                         crs.idnumber ASC,\n                         stu.completetime ASC,\n                         stu.grade DESC,\n                         cls.idnumber ASC,\n                         u.username ASC";
     $this->recordset = $DB->get_recordset_sql($sql, $params);
     // Write out header.
     $this->fileplugin->write($columns);
     // Load string to prevent calling get_string for every record.
     $this->completestatusstring = get_string('completestatusstring', 'dhexport_version1elis');
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:62,代码来源:version1elis.class.php


示例13: test_get_userset_subsets

 /**
  * Tests deepsight_datatable_usersetuser_base::get_userset_subsets
  * @dataProvider dataprovider_get_userset_subsets
  * @param int $parentuserset The ID of a userset to pass to the function as the parent userset ID.
  * @param bool $includeparent Whether to include the parent ID in the return array.
  * @param array $expectedresults The expected return value.
  */
 public function test_get_userset_subsets($parentuserset, $includeparent, $expectedresults)
 {
     $dataset = $this->createCsvDataSet(array(user::TABLE => elispm::file('tests/fixtures/deepsight_user.csv'), userset::TABLE => elispm::file('tests/fixtures/deepsight_usersetwithsubsets.csv')));
     $this->loadDataSet($dataset);
     accesslib_clear_all_caches(true);
     // Set up contexts.
     for ($i = 1; $i <= 6; $i++) {
         $ctx = \local_elisprogram\context\userset::instance($i);
     }
     accesslib_clear_all_caches(true);
     $actualresults = deepsight_datatable_standard::get_userset_subsets($parentuserset, $includeparent);
     $this->assertEquals($expectedresults, array_keys($actualresults));
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:20,代码来源:deepsight_datatable_test.php


示例14: test_format_course_listing

 /**
  * Test format_course_listing function.
  */
 public function test_format_course_listing()
 {
     // Fixture.
     $dataset = $this->createCsvDataSet(array(curriculumcourse::TABLE => elispm::file('tests/fixtures/curriculum_course.csv')));
     $this->loadDataSet($dataset);
     // Test.
     $courses = array(1 => null, 100 => null);
     $pmclass = new pmclass();
     $listing = $pmclass->format_course_listing($courses);
     // Verify.
     $expected = array(1 => array(1 => 1, 100 => 2));
     $this->assertEquals($expected, $listing);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:16,代码来源:pmclass_test.php


示例15: load_csv_data

 /**
  * Load initial data from CSVs.
  */
 protected function load_csv_data()
 {
     $dataset = $this->createCsvDataSet(array('user' => elispm::file('tests/fixtures/mdluser.csv'), 'user_info_field' => elispm::file('tests/fixtures/user_info_field.csv'), 'user_info_data' => elispm::file('tests/fixtures/user_info_data.csv'), user::TABLE => elispm::file('tests/fixtures/pmuser.csv'), usermoodle::TABLE => elispm::file('tests/fixtures/usermoodle.csv'), field::TABLE => elispm::file('tests/fixtures/user_field.csv'), field_owner::TABLE => elispm::file('tests/fixtures/user_field_owner.csv')));
     $dataset = new PHPUnit_Extensions_Database_DataSet_ReplacementDataSet($dataset);
     $dataset->addSubStrReplacement('\\n', "\n");
     $this->loadDataSet($dataset);
     // Load field data next (we need the user context ID and context level).
     $usercontext = \local_elisprogram\context\user::instance(103);
     $dataset = $this->createCsvDataSet(array(field_contextlevel::TABLE => elispm::file('tests/fixtures/user_field_contextlevel.csv'), field_category_contextlevel::TABLE => elispm::file('tests/fixtures/user_field_category_contextlevel.csv'), field_data_int::TABLE => elispm::file('tests/fixtures/user_field_data_int.csv'), field_data_char::TABLE => elispm::file('tests/fixtures/user_field_data_char.csv'), field_data_text::TABLE => elispm::file('tests/fixtures/user_field_data_text.csv')));
     $dataset = new PHPUnit_Extensions_Database_DataSet_ReplacementDataSet($dataset);
     $dataset->addFullReplacement('##USERCTXID##', $usercontext->id);
     $dataset->addFullReplacement('##USERCTXLVL##', CONTEXT_ELIS_USER);
     $this->loadDataSet($dataset);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:17,代码来源:customuserfields_test.php


示例16: setUp

 /**
  * This method is called before the first test of this test class is run.
  */
 public function setUp()
 {
     global $DB, $USER;
     parent::setUp();
     // Create data we need for many test cases.
     set_config('defaultenrol', 1, 'enrol_guest');
     set_config('status', ENROL_INSTANCE_DISABLED, 'enrol_guest');
     set_config('enrol_plugins_enabled', 'manual,guest');
     // Load initial data from CSVs.
     $dataset = $this->createCsvDataSet(array('course' => elispm::file('tests/fixtures/autocreatemoodlecourse_course.csv'), pmclass::TABLE => elispm::file('tests/fixtures/autocreatemoodlecourse_class.csv'), course::TABLE => elispm::file('tests/fixtures/autocreatemoodlecourse_coursedescription.csv'), coursetemplate::TABLE => elispm::file('tests/fixtures/autocreatemoodlecourse_coursetemplate.csv')));
     $this->loadDataSet($dataset);
     // Set current user as admin.
     $this->setAdminUser();
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:17,代码来源:autocreatemoodlecourse_test.php


示例17: assign_track_enrol_permissions

 /**
  * Set up permissions that allow the current user to enrol users in tracks
  */
 protected function assign_track_enrol_permissions()
 {
     global $CFG, $USER, $DB;
     require_once elispm::lib('data/user.class.php');
     // Set up a test role that allows users to enrol users in tracks.
     $roleid = create_role('trackenrol', 'trackenrol', 'trackenrol');
     $syscontext = context_system::instance();
     assign_capability('local/elisprogram:track_enrol', CAP_ALLOW, $roleid, $syscontext->id);
     // Set up our current user.
     $activeuser = new user(array('idnumber' => 'activeuser', 'username' => 'activeuser', 'firstname' => 'Activeuser', 'lastname' => 'Activeuser', 'email' => '[email protected]', 'country' => 'CA'));
     $activeuser->save();
     $USER = $DB->get_record('user', array('username' => 'activeuser'));
     // Assign the role to the current user.
     role_assign($roleid, $USER->id, $syscontext->id);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:18,代码来源:usertrackgetavailableusers_test.php


示例18: load_csv_data

 /**
  * Load CSV data for use in this test class.
  * @param boolean $createnonrequiredlos set to true to create non-required learning objective records
  * @param $createrequiredlos set to true to create required learning objective records
  */
 public function load_csv_data($createnonrequiredlos = false, $createrequiredlos = false)
 {
     // NOTE: for now, can only use one of two parameters.
     $csvs = array(course::TABLE => elispm::file('tests/fixtures/pmcoursewithgrade.csv'), pmclass::TABLE => elispm::file('tests/fixtures/pmclass.csv'), user::TABLE => elispm::file('tests/fixtures/pmuser.csv'), usermoodle::TABLE => elispm::file('tests/fixtures/usermoodle.csv'), 'user' => elispm::file('tests/fixtures/mdluser.csv'));
     if ($createnonrequiredlos) {
         // Want a non-required learning objective.
         $csvs[coursecompletion::TABLE] = elispm::file('tests/fixtures/course_completion_nonrequired.csv');
     } else {
         if ($createrequiredlos) {
             // Want a required learning objective.
             $csvs[coursecompletion::TABLE] = elispm::file('tests/fixtures/course_completion_required.csv');
         }
     }
     $dataset = $this->createCsvDataSet($csvs);
     $this->loadDataSet($dataset);
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:21,代码来源:pmclassupdateenrolmentstatus_test.php


示例19: test_user_sync_on_pm_user_create

 /**
  * Validate that appropriate fields are synched over to Moodle when PM user is enrolled in a class instance during an import.
  */
 public function test_user_sync_on_pm_user_create()
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/course/lib.php';
     require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
     require_once elispm::lib('data/classmoodlecourse.class.php');
     require_once elispm::lib('data/course.class.php');
     require_once elispm::lib('data/pmclass.class.php');
     require_once elispm::lib('data/user.class.php');
     // Configure the elis enrolment plugin.
     $roleid = $DB->get_field('role', 'id', array(), IGNORE_MULTIPLE);
     set_config('roleid', $roleid, 'enrol_elis');
     $user = new user(array('idnumber' => 'testuseridnumber', 'username' => 'testuserusername', 'firstname' => 'testuserfirstname', 'lastname' => 'testuserlastname', 'email' => '[email protected]', 'country' => 'CA'));
     $user->save();
     $course = new course(array('name' => 'testcoursename', 'idnumber' => 'testcourseidnumber', 'syllabus' => ''));
     $course->save();
     $class = new pmclass(array('courseid' => $course->id, 'idnumber' => 'testclassidnumber'));
     $class->save();
     $category = new stdClass();
     $category->name = 'testcategoryname';
     $category->id = $DB->insert_record('course_categories', $category);
     // Create the associated context.
     context_coursecat::instance($category->id);
     $mdlcourse = new stdClass();
     $mdlcourse->category = $category->id;
     $mdlcourse->fullname = 'testcoursefullname';
     $mdlcourse = create_course($mdlcourse);
     // Associate class instance to Moodle course.
     $classmoodlecourse = new classmoodlecourse(array('classid' => $class->id, 'moodlecourseid' => $mdlcourse->id));
     $classmoodlecourse->save();
     // Run the enrolment create action.
     $record = new stdClass();
     $record->context = 'class_testclassidnumber';
     $record->user_username = 'testuserusername';
     $importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis');
     $importplugin->fslogger = new silent_fslogger(null);
     $importplugin->class_enrolment_create($record, 'bogus', 'testclassidnumber');
     // Validate the enrolment.
     $enrolid = $DB->get_field('enrol', 'id', array('enrol' => 'elis', 'courseid' => $mdlcourse->id));
     $this->assertNotEquals(false, $enrolid);
     $mdluserid = $DB->get_field('user', 'id', array('username' => 'testuserusername'));
     $this->assertNotEquals(false, $mdluserid);
     $this->assertTrue($DB->record_exists('user_enrolments', array('enrolid' => $enrolid, 'userid' => $mdluserid)));
     // Validate the role assignment.
     $mdlcoursecontext = context_course::instance($mdlcourse->id);
     $this->assertTrue($DB->record_exists('role_assignments', array('roleid' => $roleid, 'contextid' => $mdlcoursecontext->id, 'userid' => $mdluserid)));
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:50,代码来源:elis_enrolment_sync_test.php


示例20: init_required_data

 /**
  * Set up necessary data
  *
  * @param int $numfields The number of custom fields used in auto-association
  */
 private function init_required_data($numfields = 1)
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
     require_once elis::file('eliscore/fields/moodleprofile/custom_fields.php');
     require_once elis::lib('data/customfield.class.php');
     require_once elispm::file('accesslib.php');
     require_once elispm::lib('data/userset.class.php');
     require_once $CFG->dirroot . '/user/profile/definelib.php';
     require_once $CFG->dirroot . '/user/profile/field/checkbox/define.class.php';
     // Set up the category only once.
     $fieldcategory = new field_category(array('name' => 'testcategoryname'));
     $fieldcategory->save();
     // Ste up the target userset only once.
     $userset = new userset(array('name' => 'testusersetname'));
     $userset->save();
     for ($i = 1; $i <= $numfields; $i++) {
         // Custom field.
         $field = new field(array('categoryid' => $fieldcategory->id, 'shortname' => 'testfieldshortname' . $i, 'name' => 'testfieldname' . $i, 'datatype' => 'bool'));
         $field->save();
         // Ensure manual field owner exists for syncing.
         field_owner::ensure_field_owner_exists($field, 'manual');
         $ownerid = $DB->get_field(field_owner::TABLE, 'id', array('fieldid' => $field->id, 'plugin' => 'manual'));
         $owner = new field_owner($ownerid);
         $owner->param_control = 'checkbox';
         $owner->save();
         // Ensure moodle profile field owner exists.
         field_owner::ensure_field_owner_exists($field, 'moodle_profile');
         $DB->execute("UPDATE {" . field_owner::TABLE . "} SET exclude = ?", array(pm_moodle_profile::sync_to_moodle));
         // Field context level assocation.
         $fieldcontextlevel = new field_contextlevel(array('fieldid' => $field->id, 'contextlevel' => CONTEXT_ELIS_USER));
         $fieldcontextlevel->save();
         // The associated Moodle user profile field.
         $profiledefinecheckbox = new profile_define_checkbox();
         $data = new stdClass();
         $data->datatype = 'checkbox';
         $data->categoryid = 99999;
         $data->shortname = 'testfieldshortname' . $i;
         $data->name = 'testfieldname' . $i;
         $profiledefinecheckbox->define_save($data);
         $mfield = $DB->get_record('user_info_field', array('shortname' => 'testfieldshortname' . $i));
         // The "cluster-profile" association.
         $usersetprofile = new userset_profile(array('clusterid' => $userset->id, 'fieldid' => $mfield->id, 'value' => 1));
         $usersetprofile->save();
     }
 }
开发者ID:jamesmcq,项目名称:elis,代码行数:51,代码来源:elis_cluster_profile_import_test.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP email类代码示例发布时间:2022-05-23
下一篇:
PHP elis类代码示例发布时间: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