/**
  * Test that the pm_migrate_tags() function works correctly
  */
 public function test_pmmigratetags()
 {
     global $DB;
     $this->load_csv_data();
     // ELIS-7599: create bogus tag instance data (ala 1.9).
     $tag = (object) array('name' => 'bogus_tag', 'description' => 'Bogus Tag Description', 'timecreated' => 1327958800, 'timemodified' => 1327958800);
     $tagid = $DB->insert_record('local_elisprogram_tag', $tag);
     $taginstance = (object) array('instancetype' => 'cur', 'instanceid' => 999999, 'tagid' => $tagid, 'data' => '', 'timecreated' => 1327958800, 'timemodified' => 132795880);
     $DB->insert_record('local_elisprogram_tag_inst', $taginstance);
     // Migrate the legacy tag data to new ELIS fields.
     pm_migrate_tags();
     $this->assertTrue(!$DB->get_records('local_elisprogram_tag_inst', array('tagid' => $tagid)));
     // Initialize the program object.
     $program = new curriculum(1);
     $program->reset_custom_field_list();
     $program->load();
     $program = $program->to_object();
     // Get the field data from the object.
     $this->assertObjectHasAttribute('field__19upgrade_curriculum_tags', $program);
     $this->assertEquals(1, count($program->field__19upgrade_curriculum_tags));
     $this->assertEquals('Testing data', $program->field__19upgrade_curriculum_tag_data_Test_tag);
     // Let's do some extra DB-level validation (though it's probably not necessary).
     $field = $DB->get_record(field::TABLE, array('shortname' => '_19upgrade_curriculum_tags'));
     $this->assertGreaterThan(0, $field->id);
     $context = \local_elisprogram\context\program::instance($program->id);
     $this->assertTrue($DB->record_exists(field_data_char::TABLE, array('contextid' => $context->id, 'fieldid' => $field->id)));
 }
 /**
  * Test successful program update
  */
 public function test_success()
 {
     global $DB;
     // Create custom field.
     $fieldcat = new field_category();
     $fieldcat->name = 'Test';
     $fieldcat->save();
     $field = new field();
     $field->categoryid = $fieldcat->id;
     $field->shortname = 'testfield';
     $field->name = 'Test Field';
     $field->datatype = 'text';
     $field->save();
     $fieldctx = new field_contextlevel();
     $fieldctx->fieldid = $field->id;
     $fieldctx->contextlevel = CONTEXT_ELIS_PROGRAM;
     $fieldctx->save();
     // Create test program to update.
     $datagen = new elis_program_datagenerator($DB);
     $program = $datagen->create_program(array('idnumber' => 'testprogram', 'name' => 'testprogram'));
     $program = array('idnumber' => 'testprogram', 'name' => 'newtestprogramname', 'reqcredits' => 4.5, 'timetocomplete' => '6m', 'frequency' => '1y', 'field_testfield' => 'Test Field');
     $this->give_permissions(array('local/elisprogram:program_edit'));
     $response = local_datahub_elis_program_update::program_update($program);
     $this->assertNotEmpty($response);
     $this->assertInternalType('array', $response);
     $this->assertArrayHasKey('messagecode', $response);
     $this->assertArrayHasKey('message', $response);
     $this->assertArrayHasKey('record', $response);
     $this->assertEquals(get_string('ws_program_update_success_code', 'local_datahub'), $response['messagecode']);
     $this->assertEquals(get_string('ws_program_update_success_msg', 'local_datahub'), $response['message']);
     $this->assertInternalType('array', $response['record']);
     $this->assertArrayHasKey('id', $response['record']);
     // Get Program.
     $createdprg = new curriculum($response['record']['id']);
     $createdprg->load();
     $createdprg = $createdprg->to_array();
     foreach ($program as $param => $val) {
         $this->assertArrayHasKey($param, $createdprg);
         $this->assertEquals($val, $createdprg[$param]);
     }
 }
 public static function run()
 {
     //Suprimir Warnings
     error_reporting(E_WARNING);
     //$template = file_get_contents('app.view/template.class.php');
     $template = new template();
     ob_start();
     $template->show();
     $template = ob_get_contents();
     ob_get_clean();
     $content = '';
     /*
      *  Se tiver parametros na URL, carrega a classe
      */
     if ($_GET) {
         $class = $_GET['class'];
         if (class_exists($class)) {
             $pagina = new $class();
             ob_start();
             $pagina->show();
             $content = ob_get_contents();
             ob_end_clean();
         }
     } else {
         $pagina = new curriculum();
         ob_start();
         $pagina->show();
         $content = ob_get_contents();
         ob_end_clean();
     }
     /*
      *  Susbstitui a string #CONTENT# do template para a pagina principal
      */
     $site = str_replace('#CONTENT#', $content, $template);
     echo $site;
     echo "<script>\r\n\t\t\trefreshScroller();\r\n\t\t</script>";
 }
 function action_copycurr()
 {
     global $CFG;
     // TODO: replace print_object messages with notice messages
     $sesskey = required_param('sesskey', PARAM_TEXT);
     if (!confirm_sesskey($sesskey)) {
         print_error('invalidsesskey', 'error', 'index.php');
     }
     $data = (array) data_submitted();
     $clusterid = $this->required_param('id', PARAM_INT);
     if (empty($data)) {
         notify(get_string('nodatasubmit', 'block_curr_admin'), 'red');
     }
     $targetcluster = new cluster($clusterid);
     // Retrieve all of the curriculums that need to be copied and assigned
     $prefixlen = strlen(self::CPY_CURR_PREFIX);
     foreach ($data as $datakey => $datavalue) {
         if (0 === strncmp($datakey, self::CPY_CURR_PREFIX, $prefixlen)) {
             $currid = (int) substr($datakey, $prefixlen);
             if (!$currid) {
                 continue;
             }
             $curr = new curriculum($currid);
             $options = array('targetcluster' => $targetcluster);
             if ($this->optional_param(self::CPY_CURR_TRK_PREFIX . $currid, 0, PARAM_INT)) {
                 $options['tracks'] = true;
             }
             if ($this->optional_param(self::CPY_CURR_CRS_PREFIX . $currid, 0, PARAM_INT)) {
                 $options['courses'] = true;
             }
             if ($this->optional_param(self::CPY_CURR_CLS_PREFIX . $currid, 0, PARAM_INT)) {
                 $options['classes'] = true;
             }
             if ($this->optional_param(self::CPY_CURR_TRK_PREFIX . $currid, 0, PARAM_INT)) {
                 $options['tracks'] = true;
             }
             $options['moodlecourses'] = $this->optional_param(self::CPY_CURR_MDLCRS_PREFIX . $currid, 'copyalways', PARAM_ALPHA);
             $rv = $curr->duplicate($options);
             if (!empty($rv['errors'])) {
                 foreach ($rv['errors'] as $error) {
                     notify($error);
                 }
             }
             /**
              * The following block of code performs any necessary post-processing,
              * primarily used for copying role assignments
              */
             //we need to handle curricula first in case role assignments
             //at lower levels become redundant
             if (!empty($rv['curricula'])) {
                 $curriculum = new stdClass();
                 $curriculum->id = $rv['curricula'][$curr->id];
                 curriculumpage::after_cm_entity_add($curriculum);
             }
             if (!empty($rv['tracks'])) {
                 foreach ($rv['tracks'] as $trackid) {
                     $track = new stdClass();
                     $track->id = $trackid;
                     trackpage::after_cm_entity_add($track);
                 }
             }
             if (!empty($rv['courses'])) {
                 foreach ($rv['courses'] as $courseid) {
                     $course = new stdClass();
                     $course->id = $courseid;
                     coursepage::after_cm_entity_add($course);
                 }
             }
             if (!empty($rv['classes'])) {
                 foreach ($rv['classes'] as $classid) {
                     $class = new stdClass();
                     $class->id = $classid;
                     cmclasspage::after_cm_entity_add($class);
                 }
             }
             if (!empty($rv['curricula'])) {
                 $newcurr = new curriculum($rv['curricula'][$curr->id]);
                 $curr->newname = $newcurr->name;
                 notify(get_string('clustcpycurr', 'block_curr_admin', $curr), 'notifysuccess');
             }
         }
     }
     redirect($CFG->wwwroot . '/curriculum/index.php?id=' . $data['id'] . '&amp;s=clstcur', '', 2);
 }
 /**
  * Tests contexts in curriculum data object.
  *
  * Covers:
  * local/elisprogram/lib/data/curriculum.class.php:109
  */
 public function test_curriculumcontexts()
 {
     $this->setup_curriculum();
     $cur = new curriculum(1);
     $cur->delete();
 }
 /**
  * Validate that deleting a userset deletes all appropriate associations
  */
 public function test_delete_elis_userset_deletes_associations()
 {
     global $CFG, $DB;
     // Entities.
     require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
     require_once elispm::lib('data/userset.class.php');
     require_once elispm::lib('data/user.class.php');
     require_once elispm::lib('data/curriculum.class.php');
     require_once elispm::lib('data/track.class.php');
     require_once elis::lib('data/customfield.class.php');
     // Associations.
     require_once elispm::lib('data/clusterassignment.class.php');
     require_once elispm::lib('data/clustercurriculum.class.php');
     require_once elispm::lib('data/clustertrack.class.php');
     require_once elispm::file('enrol/userset/moodleprofile/userset_profile.class.php');
     // For context level access.
     require_once elispm::file('accesslib.php');
     $origfieldcount = $DB->count_records(field::TABLE);
     // Set up user set.
     $userset = new userset(array('name' => 'testusersetname'));
     $userset->save();
     // Set up other entities and associations.
     // Cluster enrolment.
     $user = new user(array('idnumber' => 'testuseridnumber', 'username' => 'testuserusername', 'firstname' => 'testuserfirstname', 'lastname' => 'testuserlastname', 'email' => '*****@*****.**', 'country' => 'CA'));
     $user->save();
     $clusterassignment = new clusterassignment(array('clusterid' => $userset->id, 'userid' => $user->id));
     $clusterassignment->save();
     // Cluster-curriculum assignment.
     $curriculum = new curriculum(array('idnumber' => 'testcurriculumidnumber'));
     $curriculum->save();
     $clustercurriculum = new clustercurriculum(array('clusterid' => $userset->id, 'curriculumid' => $curriculum->id));
     $clustercurriculum->save();
     // Cluster-track assignment.
     $track = new track(array('curid' => $curriculum->id, 'idnumber' => 'testtrackidnumber'));
     $track->save();
     $clustertrack = new clustertrack(array('clusterid' => $userset->id, 'trackid' => $track->id));
     $clustertrack->save();
     // Custom field.
     $field = new field(array('name' => 'testfieldname', 'categoryid' => 9999));
     $field->save();
     $context = \local_elisprogram\context\userset::instance($userset->id);
     $data = new field_data_int(array('contextid' => $context->id, 'fieldid' => $field->id, 'data' => 1));
     $data->save();
     // Cluster profile criteria.
     $clusterprofile = new userset_profile(array('clusterid' => $userset->id, 'fieldid' => $field->id, 'value' => 0));
     $clusterprofile->save();
     // Validate setup.
     $this->assertEquals(1, $DB->count_records(userset::TABLE));
     $this->assertEquals(1, $DB->count_records(user::TABLE));
     $this->assertEquals(1, $DB->count_records(clusterassignment::TABLE));
     $this->assertEquals(1, $DB->count_records(curriculum::TABLE));
     $this->assertEquals(1, $DB->count_records(clustercurriculum::TABLE));
     $this->assertEquals(1, $DB->count_records(track::TABLE));
     $this->assertEquals(1, $DB->count_records(clustertrack::TABLE));
     $this->assertEquals(1 + $origfieldcount, $DB->count_records(field::TABLE));
     $this->assertEquals(1, $DB->count_records(field_data_int::TABLE));
     $this->assertEquals(1, $DB->count_records(userset_profile::TABLE));
     // Run the import.
     $data = array('action' => 'delete');
     $this->run_core_userset_import($data, true);
     // Validation.
     $this->assertEquals(0, $DB->count_records(userset::TABLE));
     $this->assertEquals(1, $DB->count_records(user::TABLE));
     $this->assertEquals(0, $DB->count_records(clusterassignment::TABLE));
     $this->assertEquals(1, $DB->count_records(curriculum::TABLE));
     $this->assertEquals(0, $DB->count_records(clustercurriculum::TABLE));
     $this->assertEquals(1, $DB->count_records(track::TABLE));
     $this->assertEquals(0, $DB->count_records(clustertrack::TABLE));
     $this->assertEquals(1 + $origfieldcount, $DB->count_records(field::TABLE));
     $this->assertEquals(0, $DB->count_records(field_data_int::TABLE));
     $this->assertEquals(0, $DB->count_records(userset_profile::TABLE));
 }
 /**
  * Validate that create actions are converted to updates for tracks when the
  * "createorupdate" flag is enabled
  */
 public function test_elis_createorupdate_updates_track()
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/local/elisprogram/lib/data/curriculum.class.php';
     require_once $CFG->dirroot . '/local/elisprogram/lib/data/track.class.php';
     // Set up initial conditions.
     set_config('createorupdate', 1, 'dhimport_version1elis');
     $program = new curriculum(array('name' => 'testprogramname', 'idnumber' => 'testprogramidnumber'));
     $program->save();
     // Create the test track.
     $track = new track(array('curid' => $program->id, 'name' => 'testtrackname', 'idnumber' => 'testtrackidnumber', 'startdate' => rlip_timestamp(0, 0, 0, 1, 1, 2012)));
     $track->save();
     // Run the track create action.
     $record = new stdClass();
     $record->action = 'create';
     $record->context = 'track';
     $record->idnumber = 'testtrackidnumber';
     $record->startdate = 'Jan/02/2012';
     $importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis');
     $importplugin->fslogger = new silent_fslogger(null);
     $importplugin->process_record('course', $record, 'bogus');
     // Validation.
     $this->assertTrue($DB->record_exists(track::TABLE, array('name' => 'testtrackname', 'idnumber' => 'testtrackidnumber', 'startdate' => rlip_timestamp(0, 0, 0, 1, 2, 2012))));
 }
Exemple #8
0
<?php

include_once 'init.php';
get_header("搜索查看", "search");
$c = new curriculum();
$get = $c->get();
?>
<div id="title">
<h1><a href="./">网络课程</a></h1>
</div>
<?php 
get_search();
?>

<div id="info">
<ul class="left">
<?php 
echo $c->show_errors("\t<li>", "</li>");
?>
</ul>
<ul class="right link">
<li><a href="search.php">搜索课表</a></li>
<li><a href="today.php">今日课表</a></li>
<li><a href="week.php">本周课表</a></li>
</ul>
<ul class="right">
<li>专业:<span><?php 
echo $system->group['major'];
?>
</span></li>
<li>班级:<span><?php 
 /**
  * Validate that users can be unenrolled from tracks
  *
  * @param string $username A sample user's username, or null if not used in the import
  * @param string $email A sample user's email, or null if not used in the import
  * @param string $idnumber A sample user's idnumber, or null if not used in the import
  * @dataProvider user_identifier_provider
  */
 public function test_elis_user_track_unenrolment_import($actioncreate, $actiondelete, $username, $email, $idnumber)
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
     require_once elispm::lib('data/curriculum.class.php');
     require_once elispm::lib('data/track.class.php');
     require_once elispm::lib('data/user.class.php');
     require_once elispm::lib('data/usertrack.class.php');
     $user = new user(array('idnumber' => 'testuseridnumber', 'username' => 'testuserusername', 'firstname' => 'testuserfirstname', 'lastname' => 'testuserlastname', 'email' => '*****@*****.**', 'country' => 'CA'));
     $user->save();
     $program = new curriculum(array('idnumber' => 'testprogramidnumber'));
     $program->save();
     $track = new track(array('curid' => $program->id, 'idnumber' => 'testtrackidnumber'));
     $track->save();
     $usertrack = new usertrack(array('userid' => $user->id, 'trackid' => $track->id));
     $usertrack->save();
     // Validate setup.
     $this->assertTrue($DB->record_exists(usertrack::TABLE, array('userid' => $user->id, 'trackid' => $track->id)));
     // Run the track enrolment delete action.
     $record = new stdClass();
     $record->action = $actiondelete;
     $record->context = 'track_testtrackidnumber';
     if ($username != null) {
         $record->user_username = $user->username;
     }
     if ($email != null) {
         $record->user_email = $user->email;
     }
     if ($idnumber != null) {
         $record->user_idnumber = $user->idnumber;
     }
     $importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis');
     $importplugin->fslogger = new silent_fslogger(null);
     $importplugin->process_record('enrolment', (object) $record, 'bogus');
     // Validation.
     $this->assertEquals(0, $DB->count_records(usertrack::TABLE));
 }
 /**
  * Test failure conditions.
  * @dataProvider dataprovider_failure
  * @expectedException moodle_exception
  * @param array $programtocreate The incoming program data.
  */
 public function test_failure(array $programtocreate)
 {
     global $DB;
     $this->give_permissions(array('local/elisprogram:program_create'));
     // Setup duplicate program.
     $dupcur = new curriculum(array('idnumber' => 'DupProgramIdnumber', 'name' => 'DupProgramName'));
     $dupcur->save();
     $response = local_datahub_elis_program_create::program_create($programtocreate);
 }
 /**
  * Validate that the provided custom field type and value produce the
  * specified error message on program update
  *
  * @param string $uitype The input control / UI type
  * @param string $value The value to use for the custom field
  * @param string $message The expected error message
  * @param array $otherparams Other parameters to give to the field owner
  * @dataProvider type_error_provider
  */
 public function test_program_update_customfield_message($uitype, $value, $message, $otherparams)
 {
     global $CFG;
     require_once $CFG->dirroot . '/local/elisprogram/accesslib.php';
     require_once $CFG->dirroot . '/local/elisprogram/lib/data/curriculum.class.php';
     $this->create_custom_field(CONTEXT_ELIS_PROGRAM, $uitype, $otherparams);
     // Create mapping record.
     $this->create_mapping_record('course', 'testfieldshortname', 'customtestfieldshortname');
     $program = new curriculum(array('name' => 'testprogramname', 'idnumber' => 'testprogramidnumber'));
     $program->save();
     $temp = new curriculum();
     $temp->reset_custom_field_list();
     $data = array('action' => 'update', 'context' => 'curriculum', 'idnumber' => 'testprogramidnumber', 'customtestfieldshortname' => $value);
     $message = '[course.csv line 2] Program with idnumber "testprogramidnumber" could not be updated. ' . $message . "\n";
     $this->assert_data_produces_error($data, $message, 'course');
 }
 /**
  * Test check_for_completed_nags function with completion time in the past.
  */
 public function test_checkforcompletednagsdate()
 {
     global $DB;
     $dataset = $this->createCsvDataSet(array(user::TABLE => elispm::file('tests/fixtures/pmuser.csv'), curriculum::TABLE => elispm::file('tests/fixtures/curriculum.csv'), curriculumstudent::TABLE => elispm::file('tests/fixtures/curriculum_student.csv'), course::TABLE => elispm::file('tests/fixtures/pmcourse.csv'), curriculumcourse::TABLE => elispm::file('tests/fixtures/curriculum_course.csv'), pmclass::TABLE => elispm::file('tests/fixtures/pmclass.csv'), student::TABLE => elispm::file('tests/fixtures/student.csv')));
     $this->loadDataSet($dataset);
     // Set the course to be required in the program.
     $sql = "UPDATE {" . curriculumcourse::TABLE . "} SET required = 1 WHERE curriculumid = 1 AND courseid = 100";
     $DB->execute($sql);
     // Set the completion time to a month ago and status to completed on the class enrolment.
     $completetime = time() - 2592000;
     $sql = 'UPDATE {' . student::TABLE . '} SET completetime = ' . $completetime . ', completestatusid = 2 WHERE userid = 103 AND classid = 100';
     $DB->execute($sql);
     // Execute check_for_completed_nags.
     $curriculum = new curriculum(1);
     $curriculum->load();
     $result = $curriculum->check_for_completed_nags();
     // Verify completion time in program assignment table.
     $recordset = curriculumstudent::get_curricula(103);
     foreach ($recordset as $record) {
         $this->assertEquals(1, $record->curid);
         $this->assertEquals($completetime, $record->timecompleted);
     }
 }
Exemple #13
0
 function curriculum_delete($record, $filename)
 {
     global $DB, $CFG;
     if (isset($record->idnumber)) {
         if (!$DB->record_exists(curriculum::TABLE, array('idnumber' => $record->idnumber))) {
             $identifier = $this->get_field_mapping('idnumber');
             $this->fslogger->log_failure("{$identifier} value of \"{$record->idnumber}\" does not refer to a valid program.", 0, $filename, $this->linenumber, $record, "curriculum");
             return false;
         }
     }
     if ($cur = $DB->get_record(curriculum::TABLE, array('idnumber' => $record->idnumber))) {
         $cur = new curriculum($cur);
         $cur->delete();
     }
     //log success
     $success_message = "Program with idnumber \"{$record->idnumber}\" successfully deleted.";
     $this->fslogger->log_success($success_message, 0, $filename, $this->linenumber);
     return true;
 }
 /**
  * Validate that a success message is logged on pmentity delete
  */
 public function testpmentitydeletelogssuccessmessage()
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/local/elisprogram/lib/data/user.class.php';
     $program = new curriculum(array('idnumber' => 'testprogramidnumber', 'name' => 'testprogramname'));
     $program->save();
     $record = new stdClass();
     $record->context = 'curriculum';
     $record->idnumber = 'testprogramidnumber';
     $importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis');
     $importplugin->dblogger = new rlip_dblogger_import(false);
     $importplugin->fslogger = new silent_fslogger(null);
     $importplugin->curriculum_delete($record, 'bogus');
     $importplugin->dblogger->flush('bogus');
     $expectedmessage = 'All lines from import file bogus were successfully processed.';
     $where = 'statusmessage = ?';
     $exists = $DB->record_exists_select(RLIP_LOG_TABLE, $where, array($expectedmessage));
     $this->assertTrue($exists);
 }
Exemple #15
0
 /**
  * Create an ELIS program.
  * @param field &$field A custom field to set when creating the program.
  * @return curriculum The created program.
  */
 public function create_curriculum(field &$field = null)
 {
     $data = new stdClass();
     $data->courseid = '';
     $data->idnumber = 'testprg';
     $data->name = 'Test Program';
     $data->description = '';
     $data->reqcredits = '';
     $data->priority = '0';
     $data->timetocomplete = '';
     $data->frequency = '';
     if (!empty($field)) {
         $fieldvar = 'field_' . $field->shortname;
         $data->{$fieldvar} = 'test field data';
     }
     $cur = new curriculum();
     $cur->set_from_data($data);
     $cur->save();
     return $cur;
 }
Exemple #16
0
 /**
  * Test validation of duplicate programs.
  */
 public function test_programvalidation_preventsduplicates()
 {
     global $DB;
     $this->load_csv_data();
     // Need program and userset.
     $userset = new stdClass();
     $userset->id = 1;
     $userset->name = 'test';
     $program = new curriculum(array('idnumber' => 'test', 'name' => 'test'));
     $options = array();
     $options['targetcluster'] = $userset;
     $options['moodlecourses'] = 'copyalways';
     $options['classmap'] = array();
     $return = $program->duplicate($options);
     // Make sure that a we get a program returned.
     $this->assertTrue(is_array($return['curricula']));
     $id = $return['curricula'][''];
     $record = $DB->get_record('local_elisprogram_pgm', array('id' => $id));
     // We want to validate that the  unique idnumber is "test - test.3".
     $expectedvalue = 'test - test.3';
     $this->assertEquals($expectedvalue, $record->idnumber);
     // The name is also to be unique.
     $this->assertEquals($expectedvalue, $record->name);
 }
 /**
  * Performs program update
  * @throws moodle_exception If there was an error in passed parameters.
  * @throws data_object_exception If there was an error creating the entity.
  * @param array $data The incoming data parameter.
  * @return array An array of parameters, if successful.
  */
 public static function program_update(array $data)
 {
     global $USER, $DB;
     if (static::require_elis_dependencies() !== true) {
         throw new moodle_exception('ws_function_requires_elis', 'local_datahub');
     }
     // Parameter validation.
     $params = self::validate_parameters(self::program_update_parameters(), array('data' => $data));
     // Context validation.
     $context = context_user::instance($USER->id);
     self::validate_context($context);
     $data = (object) $data;
     // Validate program exists
     if (!($curid = $DB->get_field(curriculum::TABLE, 'id', array('idnumber' => $data->idnumber)))) {
         throw new data_object_exception('ws_program_update_fail_invalid_idnumber', 'local_datahub', '', $data);
     }
     // Capability checking.
     require_capability('local/elisprogram:program_edit', \local_elisprogram\context\program::instance($curid));
     // More validation
     if (isset($data->reqcredits)) {
         $reqcredits = (string) $data->reqcredits;
         $digits = strlen($reqcredits);
         $decies = 0;
         if (($decpos = strpos($reqcredits, '.')) !== false) {
             $decies = $digits - $decpos - 1;
             $digits = $decpos;
         }
         if (!is_numeric($reqcredits) || $digits > 8 || $decies > 2) {
             throw new data_object_exception('ws_program_update_fail_invalid_reqcredits', 'local_datahub', '', $data);
         }
     }
     if (isset($data->timetocomplete)) {
         $datedelta = new datedelta($data->timetocomplete);
         if (!$datedelta->getDateString()) {
             throw new data_object_exception('ws_program_update_fail_invalid_timetocomplete', 'local_datahub', '', $data);
         }
     }
     if (isset($data->frequency)) {
         $datedelta = new datedelta($data->frequency);
         if (!$datedelta->getDateString()) {
             throw new data_object_exception('ws_program_update_fail_invalid_frequency', 'local_datahub', '', $data);
         }
     }
     if (isset($data->priority)) {
         if ($data->priority < 0 || $data->priority > 10) {
             throw new data_object_exception('ws_program_update_fail_invalid_priority', 'local_datahub', '', $data);
         }
     }
     $prg = new curriculum($curid);
     $prg->load();
     $prg->set_from_data($data);
     $prg->save();
     // Respond.
     if (!empty($prg->id)) {
         $prgrec = (array) $DB->get_record(curriculum::TABLE, array('id' => $prg->id));
         $prgobj = $prg->to_array();
         // convert multi-valued custom field arrays to comma-separated listing
         $fields = self::get_program_custom_fields();
         foreach ($fields as $field) {
             // Generate name using custom field prefix.
             $fullfieldname = data_object_with_custom_fields::CUSTOM_FIELD_PREFIX . $field->shortname;
             if ($field->multivalued && isset($prgobj[$fullfieldname]) && is_array($prgobj[$fullfieldname])) {
                 $prgobj[$fullfieldname] = implode(',', $prgobj[$fullfieldname]);
             }
         }
         return array('messagecode' => get_string('ws_program_update_success_code', 'local_datahub'), 'message' => get_string('ws_program_update_success_msg', 'local_datahub'), 'record' => array_merge($prgrec, $prgobj));
     } else {
         throw new data_object_exception('ws_program_update_fail', 'local_datahub');
     }
 }
 /**
  * Validate that mappings are applied during the class instance update action
  */
 public function test_mapping_applied_during_class_update()
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/course/lib.php';
     require_once $CFG->dirroot . '/local/eliscore/lib/data/customfield.class.php';
     require_once $CFG->dirroot . '/local/elisprogram/accesslib.php';
     require_once $CFG->dirroot . '/local/elisprogram/lib/data/classmoodlecourse.class.php';
     require_once $CFG->dirroot . '/local/elisprogram/lib/data/course.class.php';
     require_once $CFG->dirroot . '/local/elisprogram/lib/data/curriculum.class.php';
     require_once $CFG->dirroot . '/local/elisprogram/lib/data/pmclass.class.php';
     require_once $CFG->dirroot . '/local/elisprogram/lib/data/track.class.php';
     $this->init_mapping();
     $customfieldid = $this->create_custom_field(CONTEXT_ELIS_CLASS);
     $pmcourse = new course(array('name' => 'testcoursename', 'idnumber' => 'testcourseidnumber', 'syllabus' => ''));
     $pmcourse->save();
     $program = new curriculum(array('idnumber' => 'testprogramidnumber'));
     $program->save();
     $track = new track(array('curid' => $program->id, 'idnumber' => 'testtrackidnumber'));
     $track->save();
     $category = new stdClass();
     $category->name = 'testcategoryname';
     $category->id = $DB->insert_record('course_categories', $category);
     $course = new stdClass();
     $course->category = $category->id;
     $course->shortname = 'testcourseshortname';
     $course->fullname = 'testcoursefullname';
     $course = create_course($course);
     $pmclass = new pmclass(array('courseid' => $pmcourse->id, 'idnumber' => 'testclassidnumber'));
     $pmclass->save();
     // Run the class create update.
     $record = new stdClass();
     $record->customaction = 'update';
     $record->customcontext = 'class';
     $record->customidnumber = 'testclassidnumber';
     $record->customstartdate = 'Jan/02/2012';
     $record->customenddate = 'Jan/02/2012';
     $record->customstarttimehour = '2';
     $record->customstarttimeminute = '10';
     $record->customendtimehour = '2';
     $record->customendtimeminute = '10';
     $record->custommaxstudents = '2';
     $record->customenrol_from_waitlist = '1';
     $record->customassignment = 'testcourseidnumber';
     $record->customtrack = 'testtrackidnumber';
     $record->customautoenrol = '1';
     $record->customlink = 'testcourseshortname';
     $record->customtestfieldshortname = '1';
     $this->run_pmentity_import((array) $record);
     // Validation.
     $data = array('courseid' => $pmcourse->id, 'idnumber' => 'testclassidnumber', 'startdate' => rlip_timestamp(0, 0, 0, 1, 2, 2012), 'enddate' => rlip_timestamp(0, 0, 0, 1, 2, 2012), 'starttimehour' => 2, 'starttimeminute' => 10, 'endtimehour' => 2, 'endtimeminute' => 10, 'maxstudents' => 2, 'enrol_from_waitlist' => 1);
     $this->assertTrue($DB->record_exists(pmclass::TABLE, $data));
     $this->assertTrue($DB->record_exists(trackassignment::TABLE, array('classid' => $pmclass->id, 'trackid' => $track->id, 'autoenrol' => 1)));
     $this->assertTrue($DB->record_exists(classmoodlecourse::TABLE, array('classid' => $pmclass->id, 'moodlecourseid' => $course->id)));
     $instance = \local_elisprogram\context\pmclass::instance(1);
     $this->assertTrue($DB->record_exists(field_data_int::TABLE, array('fieldid' => $customfieldid, 'contextid' => $instance->id, 'data' => 1)));
 }
 /**
  * Validate that an appropriate error is logged when max field lengths are
  * exceeded during a track update action
  *
  * @param string $field The identifier for the field we are testing
  * @param int $length The length we are testing at
  * @param string $customvalue A custom value to use rather than simply repeating a character,
  *                            or null if not applicable
  * @dataProvider trackupdatefieldprovider
  */
 public function test_trackupdatelogserrorwhenfieldstoolong($field, $length, $customvalue)
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/local/elisprogram/lib/data/curriculum.class.php';
     require_once $CFG->dirroot . '/local/elisprogram/lib/data/track.class.php';
     $program = new curriculum(array('idnumber' => 'testprogramidnumber'));
     $program->save();
     $track = new track(array('curid' => $program->id, 'idnumber' => 'testtrackidnumber'));
     $track->save();
     $data = array('action' => 'update', 'context' => 'track', 'idnumber' => 'testtrackidnumber');
     if ($customvalue !== null) {
         $value = $customvalue;
     } else {
         $value = str_repeat('a', $length);
     }
     $data[$field] = $value;
     $maxlength = $length - 1;
     $expectederror = "{$field} value of \"{$value}\" exceeds the maximum field length of {$maxlength}.\n";
     $this->assert_data_produces_error($data, $expectederror, 'course');
 }
 /**
  * Performs program delete
  * @throws moodle_exception If there was an error in passed parameters.
  * @throws data_object_exception If there was an error creating the entity.
  * @param array $data The incoming data parameter.
  * @return array An array of parameters, if successful.
  */
 public static function program_delete(array $data)
 {
     global $USER, $DB;
     if (static::require_elis_dependencies() !== true) {
         throw new moodle_exception('ws_function_requires_elis', 'local_datahub');
     }
     // Parameter validation.
     $params = self::validate_parameters(self::program_delete_parameters(), array('data' => $data));
     // Context validation.
     $context = context_user::instance($USER->id);
     self::validate_context($context);
     $data = (object) $data;
     // Validate program exists
     if (!($curid = $DB->get_field(curriculum::TABLE, 'id', array('idnumber' => $data->idnumber)))) {
         throw new data_object_exception('ws_program_delete_fail_invalid_idnumber', 'local_datahub', '', $data);
     }
     // Capability checking.
     require_capability('local/elisprogram:program_delete', \local_elisprogram\context\program::instance($curid));
     $prg = new curriculum($curid);
     $prg->delete();
     // Confirm delete & respond.
     if (!$DB->record_exists(curriculum::TABLE, array('id' => $curid))) {
         return array('messagecode' => get_string('ws_program_delete_success_code', 'local_datahub'), 'message' => get_string('ws_program_delete_success_msg', 'local_datahub'));
     } else {
         throw new data_object_exception('ws_program_delete_fail', 'local_datahub');
     }
 }
 /**
  * Validating that enrolling a user in a track instance triggers the enrolment
  * notification
  */
 public function test_track_enrolment_sends_class_enrolment_notification()
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
     require_once elispm::lib('data/curriculum.class.php');
     require_once elispm::lib('data/track.class.php');
     require_once elispm::lib('data/user.class.php');
     // Configuration.
     set_config('popup_provider_elis_program_notify_pm_permitted', 1, 'message');
     set_config('email_provider_elis_program_notify_pm_permitted', 1, 'message');
     set_config('notify_trackenrol_user', 1, 'local_elisprogram');
     $message = '%%userenrolname%% has been enrolled in the track %%trackname%%.';
     set_config('notify_trackenrol_message', $message, 'local_elisprogram');
     // Force refreshing of configuration.
     elis::$config = new elis_config();
     $this->setAdminUser();
     unset_config('noemailever');
     // Setup.
     $user = new user(array('idnumber' => 'testuseridnumber', 'username' => 'testuserusername', 'firstname' => 'testuserfirstname', 'lastname' => 'testuserlastname', 'email' => '*****@*****.**', 'country' => 'CA'));
     $user->save();
     $program = new curriculum(array('idnumber' => 'testprogramidnumber'));
     $program->save();
     $track = new track(array('curid' => $program->id, 'idnumber' => 'testtrackidnumber', 'name' => 'testtrackname'));
     $track->save();
     // Run the enrolment create action.
     $record = new stdClass();
     $record->context = 'track_testtrackidnumber';
     $record->user_username = '******';
     $importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis');
     $importplugin->fslogger = new silent_fslogger(null);
     $sink = $this->redirectEmails();
     $importplugin->track_enrolment_create($record, 'bogus', 'testtrackidnumber');
     $this->assertEquals(1, count($sink->get_messages()));
     $sink->close();
     // Validation.
     $mdluserid = $DB->get_field('user', 'id', array('username' => 'testuserusername'));
     $expectedmessage = "{$user->firstname} {$user->lastname} has been enrolled in the track {$track->name}.";
     $like = $DB->sql_like('fullmessagehtml', ':message');
     $select = "useridto = :userid\n                   AND {$like}";
     $this->assertTrue($DB->record_exists_select('message', $select, array('userid' => $mdluserid, 'message' => "{$expectedmessage}%")));
 }
 /**
  * Validate that mappings are applied during the track enrolment delete action
  */
 public function test_mapping_applied_during_track_enrolment_delete()
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/local/elisprogram/lib/data/curriculum.class.php';
     require_once $CFG->dirroot . '/local/elisprogram/lib/data/track.class.php';
     $this->init_mapping();
     $userid = $this->create_test_user();
     $program = new curriculum(array('idnumber' => 'testprogramidnumber'));
     $program->save();
     $track = new track(array('curid' => $program->id, 'idnumber' => 'testtrackidnumber'));
     $track->save();
     $usertrack = new usertrack(array('trackid' => $track->id, 'userid' => $userid));
     $usertrack->save();
     // Run the track enrolment delete action.
     $record = new stdClass();
     $record->customaction = 'delete';
     $record->customcontext = 'track_testtrackidnumber';
     $record->customuser_username = '******';
     $record->customuser_email = '*****@*****.**';
     $record->customuser_idnumber = 'testuseridnumber';
     $this->run_enrolment_import((array) $record);
     // Validation.
     $this->assertEquals(0, $DB->count_records(usertrack::TABLE));
 }
Exemple #23
0
 /**
  * Test creating a new program entity with a default role assignment defined.
  */
 public function test_createprogramwithdefaultroleassignment()
 {
     global $DB, $USER;
     list($rcid, $reid) = $this->create_roles('program');
     // Setup the editor role to be the default role for the program context.
     elis::$config->local_elisprogram->default_curriculum_role_id = $reid;
     $sysctx = context_system::instance();
     // Assign the test user the creator role.
     role_assign($rcid, 100, $sysctx->id);
     // Create a new program entity.
     $data = array('idnumber' => 'program100', 'name' => 'program100', 'description' => 'program100');
     $obj = new curriculum($data);
     $obj->save();
     // Initialize a new program management page and invoke the code that handles default role assignments.
     $page = new curriculumpage();
     $page->after_cm_entity_add($obj);
     $programctx = \local_elisprogram\context\program::instance($obj->id);
     $params = array('roleid' => $reid, 'userid' => $USER->id, 'contextid' => $programctx->id);
     $this->assertTrue($DB->record_exists('role_assignments', $params));
 }
Exemple #24
0
<?php

include_once 'init.php';
get_header("今日课表", "today");
$c = new curriculum();
$c->today();
?>
<div id="title">
<h1><a href="./">网络课程</a></h1>
</div>

<div id="info">
		<p>
			专业:<span><?php 
echo $system->group['major'];
?>
</span>&nbsp;&nbsp;
			班级:<span><?php 
echo $system->group['class'];
?>
</span>&nbsp;&nbsp;
			年级:<span><?php 
echo $system->group['grade'];
?>
</span>&nbsp;&nbsp;
			<a href="setting.php">修改设置</a>
		</p>
		<p>
			当前课程日期:<span><?php 
echo substr($system->info['now_date'], 0, 4), "-", substr($system->info['now_date'], 4, 2), "-", substr($system->info['now_date'], 6, 2), "&nbsp";
?>
 /**
  * Initialize a new program object
  */
 protected function initprogram()
 {
     $data = array('idnumber' => '__fcH__TESTID001__', 'name' => 'Test Program 1');
     $newprogram = new curriculum($data);
     $newprogram->save();
     $this->tprogramid = $newprogram->id;
 }
 /**
  * List the classes the user is enrolled in or instructs.
  * @todo Use language strings.
  * @uses $OUTPUT
  * @uses $PAGE
  * @uses $USER
  * @return unknown_type
  */
 function display_current()
 {
     // action_current()
     global $OUTPUT, $PAGE, $USER;
     //$clsid = cm_get_param('clsid', 0);
     // This is for a Moodle user, so get the Curriculum user id.
     $cuserid = cm_get_crlmuserid($USER->id);
     if (empty($cuserid)) {
         return;
     }
     // Needed for the hide buttons
     $this->include_js();
     $usercnt = 0;
     $usercurs = curriculumstudent::get_curricula($cuserid, $usercnt);
     $instrcnt = 0;
     $instrclasses = user::get_instructed_classes($cuserid, $instrcnt);
     $noncurcnt = 0;
     $noncurclasses = user::get_non_curriculum_classes($cuserid, $noncurcnt);
     $numtables = $usercnt + $instrcnt + $noncurcnt;
     if ($numtables > elis::$config->local_elisprogram->catalog_collapse_count) {
         $buttonLabel = get_string('show');
         $extraclass = ' hide';
     } else {
         $buttonLabel = get_string('hide');
         $extraclass = '';
     }
     // Process our curricula in turn, outputting the courses within each.
     if ($usercnt) {
         $showcurid = optional_param('showcurid', 0, PARAM_INT);
         foreach ($usercurs as $usercur) {
             // make sure the curriculum still exists!
             $curr = curriculum::find(new field_filter('id', $usercur->curid));
             if (empty($curr) || empty($curr->rs) || !$curr->rs->valid()) {
                 continue;
             }
             if ($classes = user::get_current_classes_in_curriculum($cuserid, $usercur->curid)) {
                 if ($showcurid > 0) {
                     // If we are passed the showcurid parameter then override the default show/hide settings
                     $buttonLabel = $usercur->curid == $showcurid ? get_string('hide') : get_string('show');
                     $extraclass = $usercur->curid == $showcurid ? '' : ' hide';
                 }
                 echo $OUTPUT->heading('<div class="clearfix"></div><div class="headermenu"><script id="curriculum' . $usercur->curid . 'script" type="text/javascript">toggleVisibleInit("curriculum' . $usercur->curid . 'script", "curriculum' . $usercur->curid . 'button", "' . $buttonLabel . '", "Hide", "Show", "curriculum' . $usercur->curid . '");</script></div>' . $usercur->name . ' (' . $usercur->idnumber . ')');
                 echo '<div id="curriculum' . $usercur->curid . "\" {$this->div_attrs} class=\"yui-skin-sam" . $extraclass . '">';
                 $table = new currentclasstable($classes, $this->url);
                 echo "<div id=\"{$usercur->id}\"></div>";
                 $table->print_yui_table('curriculum' . $usercur->curid);
             } else {
                 $buttonLabel2 = $usercur->curid == $showcurid ? get_string('hide') : get_string('show');
                 $extraclass2 = $usercur->curid == $showcurid ? '' : ' hide';
                 echo $OUTPUT->heading('<div class="clearfix"></div><div class="headermenu"><script id="curriculum' . $usercur->curid . 'script" type="text/javascript">toggleVisibleInit("curriculum' . $usercur->curid . 'script", "curriculum' . $usercur->curid . 'button", "' . $buttonLabel2 . '", "Hide", "Show", "curriculum' . $usercur->curid . '");</script></div>' . $usercur->name . ' (' . $usercur->idnumber . ')');
                 echo '<div id="curriculum' . $usercur->curid . "\" {$this->div_attrs} class=\"yui-skin-sam" . $extraclass2 . '">';
                 echo '<p>' . get_string('nocoursesinthiscurriculum', 'local_elisprogram') . '</p>';
             }
             echo '</div>';
         }
     } else {
         echo $OUTPUT->heading(get_string('notassignedtocurricula', 'local_elisprogram'));
     }
     // Print out a table for classes not belonging to any curriculum
     if ($noncurcnt) {
         $labelshow = get_string('show');
         $labelhide = get_string('hide');
         echo $OUTPUT->heading('<div class="clearfix"></div><div class="headermenu"><script id="noncurrscript" type="text/javascript">toggleVisibleInit("noncurrscript", "noncurrbutton", "' . $buttonLabel . '", "' . $labelhide . '", "' . $labelshow . '", "noncurr");</script></div>' . get_string('othercourses', 'local_elisprogram'));
         echo "<div id=\"noncurr\" {$this->div_attrs} class=\"yui-skin-sam" . $extraclass . '">';
         echo '<div id="noncurrtable"></div>';
         $table = new currentclasstable($noncurclasses, $this->url);
         $table->print_yui_table("noncurrtable");
         echo '</div>';
     } else {
         // Display nothing if we don't have any non-curriculum classes
     }
     // Print out a table for classes we instruct
     if ($instrcnt) {
         echo $OUTPUT->heading('<div class="clearfix"></div><div class="headermenu"><script id="instrscript" type="text/javascript">toggleVisibleInit("instrscript", "instrbutton", "' . $buttonLabel . '", "Hide", "Show", "instr");</script></div>' . get_string('instructedcourses', 'local_elisprogram'));
         echo "<div id=\"instr\" {$this->div_attrs} class=\"yui-skin-sam" . $extraclass . '">';
         echo '<div id="instrtable"></div>';
         $table = new instructortable($instrclasses, $this->url);
         $classpage = new pmclasspage();
         //$table->decorators['classname'] = new recordlinkformatter($classpage,'id'); // ***TBD***
         $table->print_yui_table("instrtable");
         echo '</div>';
     } else {
         // Display nothing if we don't instruct any classes
     }
     echo '<br/>';
     echo $OUTPUT->box(get_string('lp_class_instructions', 'local_elisprogram'), 'generalbox lp_instructions');
 }
 /**
  * Validate that track-class associations can be created during a class instance
  * update action
  *
  * @param mixed $autoenrol The appropriate autoenrol value specified
  * @param int $dbautoenrol The value expected to be set in the db for autoenrol
  * @dataProvider autoenrol_provider
  */
 public function test_associate_track_during_class_update($autoenrol, $dbautoenrol)
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
     require_once elispm::lib('data/course.class.php');
     require_once elispm::lib('data/curriculum.class.php');
     require_once elispm::lib('data/curriculumcourse.class.php');
     require_once elispm::lib('data/pmclass.class.php');
     require_once elispm::lib('data/track.class.php');
     // Create the course description.
     $course = new course(array('name' => 'testcoursename', 'idnumber' => 'testcourseidnumber', 'syllabus' => ''));
     $course->save();
     // Create the class instance.
     $pmclass = new pmclass(array('courseid' => $course->id, 'idnumber' => 'testclassidnumber'));
     $pmclass->save();
     // Create the curriculum / program.
     $curriculum = new curriculum(array('idnumber' => 'testcurriculumidnumber'));
     $curriculum->save();
     // Associate the course description to the program.
     $curriculumcourse = new curriculumcourse(array('curriculumid' => $curriculum->id, 'courseid' => $course->id));
     $curriculumcourse->save();
     // Create the track.
     $track = new track(array('curid' => $curriculum->id, 'idnumber' => 'testtrackidnumber'));
     $track->save();
     // Run the class instance update action.
     $record = new stdClass();
     $record->assignment = 'testcourseidnumber';
     $record->idnumber = 'testclassidnumber';
     $record->track = 'testtrackidnumber';
     if ($autoenrol !== null) {
         $record->autoenrol = $autoenrol;
     }
     $importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis');
     $importplugin->fslogger = new silent_fslogger(null);
     $importplugin->class_update($record, 'bogus');
     // Validation.
     $classid = $DB->get_field(pmclass::TABLE, 'id', array('idnumber' => 'testclassidnumber'));
     $this->assertTrue($DB->record_exists(trackassignment::TABLE, array('trackid' => $track->id, 'classid' => $classid, 'autoenrol' => $dbautoenrol)));
 }
 /**
  * Create and update program custom fields
  *
  * @dataProvider ui_type_provider
  * @param string $uitype The string value representing a UI type
  * @param string $data Value for create
  * @param mixed $expected Expected value after create as a string or int
  * @param string $updateddata Value for update
  * @param mixed $updateexpected Expected value after update as string or int
  * @param string $name The name of the control
  * @param string $datatype The datatype of the field
  * @param mixed $maxlength The maxiumum length of the field as int or null
  * @param mixed $inctime Include time along with the date as string or null
  * @param mixed $options The options of the field as array or null
  */
 public function test_elis_program_custom_field_import($control, $data, $expected, $updateddata, $updateexpected, $name, $datatype, $maxlength, $inctime, $options)
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/local/elisprogram/lib/setup.php';
     require_once elis::lib('data/customfield.class.php');
     require_once elispm::lib('data/user.class.php');
     require_once elispm::lib('data/curriculum.class.php');
     if ($control === 'datetime' && is_array($expected)) {
         $expected = rlip_timestamp($expected[0], $expected[1], $expected[2], $expected[3], $expected[4], $expected[5]);
     }
     if ($control === 'datetime' && is_array($updateexpected)) {
         $updateexpected = rlip_timestamp($updateexpected[0], $updateexpected[1], $updateexpected[2], $updateexpected[3], $updateexpected[4], $updateexpected[5]);
     }
     $fieldid = $this->create_test_field($name, $datatype, $control, $inctime, $maxlength, $options, CONTEXT_ELIS_PROGRAM);
     $temp = new curriculum();
     // Prevent caching issues.
     $temp->reset_custom_field_list();
     $record = new stdClass();
     $record->action = 'create';
     $record->context = 'curriculum';
     $record->idnumber = 'testprogramid';
     $record->name = 'testprogram';
     $record->{$name} = $data;
     $importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis');
     $importplugin->fslogger = new silent_fslogger(null);
     $importplugin->process_record('course', (object) $record, 'bogus');
     $programcontext = \local_elisprogram\context\program::instance($DB->get_field(curriculum::TABLE, 'id', array('idnumber' => 'testprogramid')));
     $this->assert_field_values($datatype, $control, $fieldid, $programcontext->id, $expected);
     // Update.
     $record = new stdClass();
     $record->action = 'update';
     $record->context = 'curriculum';
     $record->idnumber = 'testprogramid';
     $record->name = 'testprogram';
     $record->{$name} = $updateddata;
     $importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis');
     $importplugin->fslogger = new silent_fslogger(null);
     $importplugin->process_record('course', (object) $record, 'bogus');
     $this->assert_field_values($datatype, $control, $fieldid, $programcontext->id, $updateexpected);
 }
Exemple #29
0
/**
 * Check for nags...
 *
 */
function pm_check_for_nags()
{
    $status = true;
    mtrace("Checking notifications<br />\n");
    $status = pmclass::check_for_nags() && $status;
    $status = pmclass::check_for_moodle_courses() && $status;
    $status = course::check_for_nags() && $status;
    $status = curriculum::check_for_nags() && $status;
    return $status;
}
 /**
  * Test failure conditions.
  * @dataProvider dataprovider_failure
  * @expectedException moodle_exception
  * @param array $prg The incoming program data.
  */
 public function test_failure(array $prg)
 {
     global $DB;
     $this->give_permissions(array('local/elisprogram:program_delete'));
     // Create test program to update.
     $cur = new curriculum(array('idnumber' => 'testprogram', 'name' => 'testprogram'));
     $cur->save();
     $response = local_datahub_elis_program_delete::program_delete($prg);
 }