示例#1
0
 function get_options($data)
 {
     if (is_array($data) && isset($data['obj']) && !empty($data['obj']->id)) {
         $dataobject = $data['obj'];
         if (property_exists($dataobject, 'name')) {
             $course = new course($dataobject);
         } else {
             if (property_exists($dataobject, 'courseid')) {
                 $course = new course($dataobject->courseid);
             } else {
                 return array();
             }
         }
         $compelems = $course->get_completion_elements();
     } else {
         // just get ALL completion elements (LOs)
         global $DB;
         $compelems = $DB->get_recordset('local_elisprogram_crs_cmp', null, '', 'id, name, idnumber');
     }
     $result = array('' => get_string('anyvalue', 'filters'));
     foreach ($compelems as $compelem) {
         $result[$compelem->idnumber] = "{$compelem->name} ({$compelem->idnumber})";
     }
     unset($compelems);
     return $result;
 }
 /**
  * Test student save works when $USER object not set
  */
 public function test_student_save_nouserobject()
 {
     global $DB, $USER;
     // Create Moodle course category.
     $crscat = create_course_category((object) array('name' => 'Test Course category', 'idnumber' => 'MCC-1'));
     // Create Moodle course.
     $crsdata = array('category' => $crscat->id, 'fullname' => 'MC-TEST-ELIS-8484', 'shortname' => 'MC-TEST-ELIS-8484', 'idnumber' => 'MC-TEST-ELIS-8484');
     $mdlcrs = new stdClass();
     $mdlcrs->id = $DB->insert_record('course', (object) $crsdata);
     $cddata = array('name' => 'CD-ELIS-8484', 'code' => 'CD-ELIS-8484', 'idnumber' => 'CD-ELIS-8484', 'syllabus' => 'syllabus');
     $cd = new course($cddata);
     $cd->save();
     $ci = new pmclass(array('idnumber' => 'CI-ELIS-8484', 'courseid' => $cd->id, 'moodlecourseid' => $mdlcrs->id, 'autocreate' => 0));
     $ci->save();
     $testuser = new user(array('idnumber' => 'testuserelis8484', 'username' => 'testuserelis8484', 'firstname' => 'Test', 'lastname' => 'User-ELIS8484', 'email' => '*****@*****.**', 'city' => 'Waterloo', 'country' => 'CA'));
     $testuser->save();
     $USER = null;
     $sturec = new stdClass();
     $sturec->userid = $testuser->id;
     $sturec->classid = $ci->id;
     $sturec->grade = 0;
     $sturec->enrolmenttime = time();
     $student = new student($sturec);
     $student->save();
     $this->assertFalse(empty($student));
     if (!empty($student)) {
         $this->assertFalse(empty($student->id));
     }
 }
示例#3
0
 public static function getDetails()
 {
     $result = DB::getInstance()->directSelect("SELECT * FROM course ORDER BY course_id;");
     $allCourse = array();
     foreach ($result as $key => $row) {
         $courseObj = new course();
         $courseObj->create($row);
         $allCourse[] = $courseObj;
     }
     return $allCourse;
 }
示例#4
0
 function test_find()
 {
     $name = "Math";
     $course_number = "112";
     $test_course = new course($name, $course_number);
     $test_course->save();
     $name2 = "The Same Exact Name";
     $course_number2 = "112";
     $test_course2 = new course($name2, $course_number2);
     $test_course2->save();
     $result = course::find($test_course->getId());
     $this->assertEquals($test_course, $result);
 }
/**
 * description: A function that takes parameters from a given url to add a new
 * course to the database. It echos a json with result being 1 when successful 
 * or 0 if query failed
 */
function add()
{
    $cid = $_REQUEST["cid"];
    $cname = $_REQUEST["cname"];
    $desc = $_REQUEST["cdesc"];
    include "course.php";
    $obj = new course();
    if ($obj->addCourse($cid, $cname, $desc)) {
        echo '{"result":1}';
    } else {
        echo '{"result":0}';
    }
}
示例#6
0
 /**
  * Test block_elisadmin_load_menu_children_course function.
  */
 public function test_block_elisadmin_load_menu_children_course()
 {
     global $DB, $USER;
     accesslib_clear_all_caches(true);
     // Create test user - ensure the returned user is NOT a site admin. if they are, our capability restrictions won't work.
     $testuser = new user();
     $testuser->username = '******';
     $testuser->idnumber = 'testELIS4093';
     $testuser->firstname = 'testELIS4093';
     $testuser->lastname = 'testELIS4093';
     $testuser->email = '*****@*****.**';
     $testuser->country = 'CA';
     $testuser->save();
     $testmuser = $testuser->get_moodleuser();
     // Create role with cap: 'local/elisprogram:class_view'.
     $testrole = new stdClass();
     $testrole->name = 'ELIS Class View';
     $testrole->shortname = '_test_ELIS_4093';
     $testrole->description = 'ELIS Class View';
     $testrole->archetype = '';
     $testrole->id = create_role($testrole->name, $testrole->shortname, $testrole->description, $testrole->archetype);
     // Ensure our new role is assignable to ELIS class contexts.
     set_role_contextlevels($testrole->id, array(CONTEXT_ELIS_CLASS));
     // Ensure the role has our required capability assigned.
     $sitecontext = context_system::instance();
     assign_capability('local/elisprogram:class_view', CAP_ALLOW, $testrole->id, $sitecontext->id, true);
     $sitecontext->mark_dirty();
     // Create ELIS Course Description.
     $testcrs = new course(array('name' => 'CD-ELIS-4093', 'idnumber' => 'CDELIS4093', 'syllabus' => ''));
     $testcrs->save();
     $testcrs->load();
     // Create three(3) Class Instances for Course Descrption.
     $testcls1 = new pmclass(array('courseid' => $testcrs->id, 'idnumber' => 'CI_ELIS_4093.1'));
     $testcls1->save();
     $testcls1->load();
     $testcls2 = new pmclass(array('courseid' => $testcrs->id, 'idnumber' => 'CI_ELIS_4093.2'));
     $testcls2->save();
     $testcls2->load();
     $testcls3 = new pmclass(array('courseid' => $testcrs->id, 'idnumber' => 'CI_ELIS_4093.3'));
     $testcls3->save();
     $testcls3->load();
     // Assign testuser new role in one Class Instance.
     $context = \local_elisprogram\context\pmclass::instance($testcls2->id);
     role_assign($testrole->id, $testmuser->id, $context->id);
     // Switch to testuser.
     $USER = $testmuser;
     $this->setUser($testmuser);
     $items = block_elisadmin_load_menu_children_course($testcrs->id, 0, 0, 5, '');
     $this->assertEquals(1, count($items));
     $this->assertTrue($items[0]->name == 'pmclass_2');
 }
 /**
  * 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' => '*****@*****.**', '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 = '******';
     $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)));
 }
示例#8
0
function viewAllCourses()
{
    include "models/course.php";
    $obj = new course();
    if (!$obj->viewAllCourses()) {
        echo '{"result": 0, "message": "You have no course in the database"}';
        return;
    }
    $row = $obj->fetch();
    echo '{"result": 1, "message": [';
    while ($row) {
        echo json_encode($row);
        $row = $obj->fetch();
        if ($row) {
            echo ',';
        }
    }
    echo "]}";
    return;
}
示例#9
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $this->validate($request, ['id' => 'required|unique:courses,id,' . $id . '', 'id_1' => 'required', 'id_2' => 'required', 'id_3' => 'required', 'id_4' => 'required', 'name' => 'required', 'author' => 'required', 'introduction' => 'required', 'body' => 'required', 'pay_type' => 'required', 'score' => 'required', 'ava_dir' => 'required', 'vid_dir' => 'required']);
     $course = course::find($id);
     $course->id = Input::get('id');
     $course->id_1 = Input::get('id_1');
     $course->id_2 = Input::get('id_2');
     $course->id_3 = Input::get('id_3');
     $course->id_4 = Input::get('id_3');
     $course->name = Input::get('name');
     $course->author = Input::get('author');
     $course->introduction = Input::get('introduction');
     $course->body = Input::get('body');
     $course->pay_type = Input::get('pay_type');
     $course->score = Input::get('score');
     $course->ava_dir = Input::get('ava_dir');
     $course->vid_dir = Input::get('vid_dir');
     if ($course->save()) {
         return Redirect::to('admin');
     } else {
         return Redirect::back()->withInput()->withErrors('保存失败!');
     }
 }
示例#10
0
 /**
  * Initialize a new course description object
  */
 protected function initcourse()
 {
     $data = array('idnumber' => '__fcH__TESTID001__', 'name' => 'Test Course 1', 'syllabus' => '');
     $newcourse = new course($data);
     $newcourse->save();
     $this->tcourseid = $newcourse->id;
 }
示例#11
0
 /**
  * Clone a curriculum.
  * @param array $options options for cloning.  Valid options are:
  * - 'tracks': whether or not to clone tracks (default: false)
  * - 'courses': whether or not to clone courses (default: false)
  * - 'classes': whether or not to clone classes (default: false)
  * - 'moodlecourses': whether or not to clone Moodle courses (if they were
  *   autocreated).  Values can be (default: "copyalways"):
  *   - "copyalways": always copy course
  *   - "copyautocreated": only copy autocreated courses
  *   - "autocreatenew": autocreate new courses from course template
  *   - "link": link to existing course
  * - 'targetcluster': the cluster id or cluster object (if any) to
  *   associate the clones with (default: none)
  * @return array array of array of object IDs created.  Key in outer array
  * is type of object (plural).  Key in inner array is original object ID,
  * value is new object ID.  Outer array also has an entry called 'errors',
  * which is an array of any errors encountered when duplicating the
  * object.
  */
 function duplicate($options = array())
 {
     require_once CURMAN_DIRLOCATION . '/lib/track.class.php';
     $objs = array('errors' => array());
     if (isset($options['targetcluster'])) {
         $cluster = $options['targetcluster'];
         if (!is_object($cluster) || !is_a($cluster, 'cluster')) {
             $options['targetcluster'] = $cluster = new cluster($cluster);
         }
     }
     // clone main curriculum object
     $clone = new curriculum($this);
     unset($clone->id);
     if (isset($cluster)) {
         // if cluster specified, append cluster's name to curriculum
         $clone->name = $clone->name . ' - ' . $cluster->name;
         $clone->idnumber = $clone->idnumber . ' - ' . $cluster->name;
     }
     $clone = new curriculum(addslashes_recursive($clone));
     if (!$clone->add()) {
         $objs['errors'][] = get_string('failclustcpycurr', 'block_curr_admin', $this);
         return $objs;
     }
     $objs['curricula'] = array($this->id => $clone->id);
     $options['targetcurriculum'] = $clone->id;
     // associate with target cluster (if any)
     if (isset($cluster)) {
         clustercurriculum::associate($cluster->id, $clone->id);
     }
     if (!empty($options['courses'])) {
         // copy courses
         $currcrs = curriculumcourse_get_list_by_curr($this->id);
         if (!empty($currcrs)) {
             $objs['courses'] = array();
             $objs['classes'] = array();
             foreach ($currcrs as $currcrsdata) {
                 $course = new course($currcrsdata->courseid);
                 $rv = $course->duplicate($options);
                 if (isset($rv['errors']) && !empty($rv['errors'])) {
                     $objs['errors'] = array_merge($objs['errors'], $rv['errors']);
                 }
                 if (isset($rv['courses'])) {
                     $objs['courses'] = $objs['courses'] + $rv['courses'];
                 }
                 if (isset($rv['classes'])) {
                     $objs['classes'] = $objs['classes'] + $rv['classes'];
                 }
                 // associate with curriculum
                 if (isset($rv['courses'][$course->id])) {
                     $curcrs = new curriculumcourse($currcrsdata);
                     unset($curcrs->id);
                     $curcrs->courseid = $rv['courses'][$course->id];
                     $curcrs->curriculumid = $clone->id;
                     $curcrs->add();
                 }
             }
         }
     }
     if (!empty($objs['errors'])) {
         return $objs;
     }
     if (!empty($options['tracks'])) {
         // copy tracks
         $tracks = track_get_listing('name', 'ASC', 0, 0, '', '', $this->id);
         if (isset($objs['courses'])) {
             $options['coursemap'] = $objs['courses'];
         }
         if (!empty($tracks)) {
             $objs['tracks'] = array();
             if (isset($objs['courses'])) {
                 $options['coursemap'] = $objs['courses'];
             }
             if (!isset($objs['classes'])) {
                 $objs['classes'] = array();
             }
             foreach ($tracks as $track) {
                 $track = new track($track);
                 $options['classmap'] = $objs['classes'];
                 $rv = $track->duplicate($options);
                 if (isset($rv['errors']) && !empty($rv['errors'])) {
                     $objs['errors'] = array_merge($objs['errors'], $rv['errors']);
                 }
                 if (isset($rv['tracks'])) {
                     $objs['tracks'] = $objs['tracks'] + $rv['tracks'];
                 }
                 if (isset($rv['classes'])) {
                     $objs['classes'] = $objs['classes'] + $rv['classes'];
                 }
             }
         }
     }
     return $objs;
 }
示例#12
0
 /**
  * Test sync_completionelements method.
  *
  * @dataProvider dataprovider_sync_completionelements
  * @param array $gradeitem Array of parameters to create grade_item.
  * @param array $gradegrade Array of parameters to create grade_grade.
  * @param array $coursecompletion Array of parameters to create coursecompletion.
  * @param array $studentgrade Array of parameters to create student_grade.
  * @param int $timenow Current timestamp to enable testing with time.
  * @param array $expectedstudentgrade Array of parameters we expect to be set in the student_grade.
  */
 public function test_sync_completionelements($gradeitem, $gradegrade, $coursecompletion, $studentgrade, $timenow, $expectedstudentgrade)
 {
     global $DB;
     $sync = new \local_elisprogram\moodle\synchronize();
     // Test data setup.
     $crs = new \course(array('idnumber' => 'CRS1', 'name' => 'Course 1', 'syllabus' => ''));
     $crs->save();
     $cls = new \pmclass(array('courseid' => $crs->id, 'idnumber' => 'CLS1'));
     $cls->save();
     $usr = new \user(array('username' => 'test1', 'idnumber' => 'test2', 'firstname' => 'test', 'lastname' => 'user', 'email' => '*****@*****.**', 'country' => 'CA'));
     $usr->save();
     $musr = $this->getDataGenerator()->create_user();
     $gradeitem = new \grade_item($gradeitem, false);
     $gradeitem->insert();
     $gradegrade['itemid'] = $gradeitem->id;
     $gradegrade['userid'] = $musr->id;
     $gradegrade = new \grade_grade($gradegrade, false);
     $gradegrade->insert();
     $coursecompletion['courseid'] = $crs->id;
     $coursecompletion = new \coursecompletion($coursecompletion);
     $coursecompletion->save();
     if ($studentgrade !== false) {
         $studentgrade['classid'] = $cls->id;
         $studentgrade['userid'] = $usr->id;
         $studentgrade['completionid'] = $coursecompletion->id;
         $studentgrade = new \student_grade($studentgrade);
         $studentgrade->save();
         $studentgrade = new \student_grade($studentgrade->id);
         $studentgrade->load();
     }
     // Method parameter setup.
     $causer = (object) array('cmid' => $usr->id, 'pmclassid' => $cls->id);
     $gis = array($gradeitem->id => (object) array('id' => $gradeitem->id, 'grademax' => $gradeitem->grademax));
     $compelements = array($gradeitem->id => (object) array('id' => $coursecompletion->id, 'completion_grade' => $coursecompletion->completion_grade));
     $moodlegrades = array($gradeitem->id => $gradegrade);
     if ($studentgrade !== false) {
         $cmgrades = array($coursecompletion->id => $studentgrade->to_object());
     } else {
         $cmgrades = array();
     }
     $sync->sync_completionelements($causer, $gis, $compelements, $moodlegrades, $cmgrades, $timenow);
     $actualstudentgrade = false;
     if ($studentgrade !== false) {
         $actualstudentgrade = $DB->get_record(\student_grade::TABLE, array('id' => $studentgrade->id));
     } else {
         $actualstudentgrades = $DB->get_records(\student_grade::TABLE, array(), 'id DESC');
         if (!empty($actualstudentgrades)) {
             $actualstudentgrade = array_shift($actualstudentgrades);
         }
     }
     if ($actualstudentgrade !== false) {
         if ($expectedstudentgrade !== false) {
             $expectedstudentgrade['id'] = $actualstudentgrade->id;
             $expectedstudentgrade['classid'] = $cls->id;
             $expectedstudentgrade['userid'] = $usr->id;
             $expectedstudentgrade['completionid'] = $coursecompletion->id;
             // This is here for tests where we can't reliably predetermine timemodified (i.e. no-sync cases).
             if (!isset($expectedstudentgrade['timemodified'])) {
                 $expectedstudentgrade['timemodified'] = $actualstudentgrade->timemodified;
             }
             $expectedstudentgrade = (object) $expectedstudentgrade;
             $this->assertEquals($expectedstudentgrade, $actualstudentgrade);
         } else {
             $this->assertTrue(false, 'A student_grade was created when one was not expected.');
         }
     } else {
         // If $expectedstudentgrade is false we were expected no grade to be created. If not, we have a problem.
         if ($expectedstudentgrade !== false) {
             $this->assertTrue(false, 'No student_grade created when one was expected');
         } else {
             $this->assertTrue(true);
         }
     }
 }
示例#13
0
 function display_savenew()
 {
     $courseid = $this->optional_param('cfccourseid', 0, PARAM_INT);
     $target = $this->get_new_page(array('action' => 'savenew', 'cfccourseid' => $courseid));
     $form = new $this->form_class($target->url);
     if ($form->is_cancelled()) {
         //go back to course and list programs
         $target = new coursecurriculumpage(array('id' => $courseid, 'action' => 'default', 's' => 'crscurr'));
         redirect($target->url);
         return;
     }
     $data = $form->get_data();
     if ($data) {
         $obj = new $this->data_class();
         $obj->set_from_data($data);
         $obj->save();
         $course = new course($data->courseid);
         $course->add_course_to_curricula(array($obj->id));
         $page = new coursecurriculumpage();
         $params = array('action' => 'default', 'id' => $data->courseid);
         $target = $page->get_new_page($params);
         redirect($target->url, ucwords($obj->get_verbose_name()) . ' ' . $obj->__toString() . ' saved.');
     } else {
         // Validation must have failed, redisplay form
         $form->display();
     }
 }
示例#14
0
 /**
  * Returns the edit course completion form.
  *
  * @return string HTML for the form.
  */
 function get_completion_edit_form($crsid, $elemid = 0)
 {
     $output = '';
     $crs = new course($crsid);
     $crs->seturl(null, array('s' => 'crs', 'section' => 'curr', 'action' => 'selem'));
     $output .= $crs->edit_completion_form_html($elemid);
     return $output;
 }
 /**
  * Validate that mappings are applied during the instructor enrolment delete action
  */
 public function test_mapping_applied_during_instructor_enrolment_delete()
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/local/elisprogram/lib/data/course.class.php';
     require_once $CFG->dirroot . '/local/elisprogram/lib/data/instructor.class.php';
     require_once $CFG->dirroot . '/local/elisprogram/lib/data/pmclass.class.php';
     $this->init_mapping();
     $userid = $this->create_test_user();
     $course = new course(array('name' => 'testcoursename', 'idnumber' => 'testcourseidnumber', 'syllabus' => ''));
     $course->save();
     $pmclass = new pmclass(array('courseid' => $course->id, 'idnumber' => 'testclassidnumber'));
     $pmclass->save();
     $instructor = new instructor(array('classid' => $pmclass->id, 'userid' => $userid));
     $instructor->save();
     // Run the instructor enrolment delete action.
     $record = new stdClass();
     $record->customaction = 'delete';
     $record->customcontext = 'class_testclassidnumber';
     $record->customuser_username = '******';
     $record->customuser_email = '*****@*****.**';
     $record->customuser_idnumber = 'testuseridnumber';
     $record->customrole = 'instructor';
     $this->run_enrolment_import((array) $record);
     // Validation.
     $this->assertEquals(0, $DB->count_records(instructor::TABLE));
 }
 /**
  * Validate that credits are correctly transferred from course to enrolment
  * for a specific user
  *
  * @param array $enrolments Enrolment records to create
  * @param array $expectedenrolments Records to validate
  * @param array $classids The ids of the classes we should run the method for
  * @dataProvider dataprovider_credits
  */
 public function test_enrolmentupdatesetscreditsforspecificuserid($enrolments, $expectedenrolments, $classids)
 {
     global $DB;
     $this->load_csv_data(true);
     // Set up a second course and class.
     $course = new course(array('name' => 'secondcourse', 'idnumber' => 'secondcourse', 'syllabus' => '', 'credits' => 1));
     $course->save();
     $pmclass = new pmclass(array('courseid' => $course->id, 'idnumber' => 'secondclass'));
     $pmclass->save();
     $this->save_enrolments($enrolments);
     $pmuserid = 103;
     foreach ($classids as $classid) {
         $pmclass = new pmclass($classid);
         $sink = $this->redirectMessages();
         $pmclass->update_enrolment_status($pmuserid);
     }
     $expectedenrolments = $this->filter_by_userid($expectedenrolments, $pmuserid);
     $this->validate_expected_enrolments($expectedenrolments, $pmuserid);
 }
示例#17
0
 /**
  * Test main newenrolmentemail() function.
  */
 public function test_version1importnewenrolmentemail()
 {
     global $CFG, $DB;
     // This is needed by the required files.
     require_once dirname(__FILE__) . '/other/rlip_importplugin_version1elis_fakeemail.php';
     $importplugin = new rlip_importplugin_version1elis_fakeemail();
     // Create Moodle course.
     $course = $this->getDataGenerator()->create_course();
     // Enrol some students into Moodle course.
     $user2 = $this->getDataGenerator()->create_user();
     $this->getDataGenerator()->enrol_user($user2->id, $course->id);
     $user3 = $this->getDataGenerator()->create_user();
     $this->getDataGenerator()->enrol_user($user3->id, $course->id);
     // Enrol teachers into Moodle course.
     $teacherrole = $DB->get_record('role', array('shortname' => 'editingteacher'));
     $teacher = $this->getDataGenerator()->create_user();
     $this->getDataGenerator()->enrol_user($teacher->id, $course->id, $teacherrole->id);
     $teacher2 = $this->getDataGenerator()->create_user();
     $this->getDataGenerator()->enrol_user($teacher2->id, $course->id, $teacherrole->id);
     // Create ELIS class and ELIS user.
     $ecourse = new course(array('name' => 'Test Course', 'idnumber' => 'CRS100', 'syllabus' => ''));
     $ecourse->save();
     $eclass = new pmclass(array('idnumber' => 'CLS100', 'courseid' => $ecourse->id));
     $eclass->save();
     $euser = new user(array('username' => 'testuser', 'idnumber' => 'testuser', 'firstname' => 'Test', 'lastname' => 'User', 'email' => '*****@*****.**', 'city' => 'Waterloo', 'country' => 'CA'));
     $euser->save();
     $muser = $euser->get_moodleuser();
     // Create student object for elis user/elis class.
     $student = new student(array('userid' => $euser->id, 'classid' => $eclass->id));
     // Test false return when student "no_moodle_enrol" is set.
     $student->no_moodle_enrol = true;
     $result = $importplugin->newenrolmentemail($student);
     $this->assertFalse($result);
     $student->no_moodle_enrol = false;
     // Test false return when ELIS class is not linked to Moodle course.
     $DB->delete_records(classmoodlecourse::TABLE, array('classid' => $eclass->id, 'moodlecourseid' => $course->id));
     $result = $importplugin->newenrolmentemail($student);
     $this->assertFalse($result);
     // Test false return when ELIS class is linked to a Moodle course, but Moodle course does not exist.
     $cmcid = $DB->insert_record(classmoodlecourse::TABLE, array('classid' => $eclass->id, 'moodlecourseid' => 999999999));
     $result = $importplugin->newenrolmentemail($student);
     $this->assertFalse($result);
     $DB->update_record(classmoodlecourse::TABLE, array('id' => $cmcid, 'moodlecourseid' => $course->id));
     // Test false return when ELIS user is not linked to Moodle user.
     $DB->delete_records(usermoodle::TABLE, array('cuserid' => $euser->id, 'muserid' => $muser->id));
     $result = $importplugin->newenrolmentemail($student);
     $this->assertFalse($result);
     // Test false return when ELIS user is linked to Moodle user, but Moodle user does not exist.
     $usermoodleid = $DB->insert_record(usermoodle::TABLE, array('cuserid' => $euser->id, 'muserid' => 99999999));
     $result = $importplugin->newenrolmentemail($student);
     $this->assertFalse($result);
     $DB->update_record(usermoodle::TABLE, array('id' => $usermoodleid, 'muserid' => $muser->id));
     // Test false return when not enabled.
     set_config('newenrolmentemailenabled', '0', 'dhimport_version1elis');
     set_config('newenrolmentemailsubject', 'Test Subject', 'dhimport_version1elis');
     set_config('newenrolmentemailtemplate', 'Test Body', 'dhimport_version1elis');
     set_config('newenrolmentemailfrom', 'teacher', 'dhimport_version1elis');
     $result = $importplugin->newenrolmentemail($student);
     $this->assertFalse($result);
     // Test false return when enabled but empty template.
     set_config('newenrolmentemailenabled', '1', 'dhimport_version1elis');
     set_config('newenrolmentemailsubject', 'Test Subject', 'dhimport_version1elis');
     set_config('newenrolmentemailtemplate', '', 'dhimport_version1elis');
     set_config('newenrolmentemailfrom', 'teacher', 'dhimport_version1elis');
     $result = $importplugin->newenrolmentemail($student);
     $this->assertFalse($result);
     // Test success when enabled, has template text, and user has email.
     $testsubject = 'Test Subject';
     $testbody = 'Test Body';
     set_config('newenrolmentemailenabled', '1', 'dhimport_version1elis');
     set_config('newenrolmentemailsubject', $testsubject, 'dhimport_version1elis');
     set_config('newenrolmentemailtemplate', $testbody, 'dhimport_version1elis');
     set_config('newenrolmentemailfrom', 'admin', 'dhimport_version1elis');
     $result = $importplugin->newenrolmentemail($student);
     $this->assertNotEmpty($result);
     $this->assertInternalType('array', $result);
     $this->assertArrayHasKey('user', $result);
     $this->assertEquals($muser, $result['user']);
     $this->assertArrayHasKey('from', $result);
     $this->assertEquals(get_admin(), $result['from']);
     $this->assertArrayHasKey('subject', $result);
     $this->assertEquals($testsubject, $result['subject']);
     $this->assertArrayHasKey('body', $result);
     $this->assertEquals($testbody, $result['body']);
     // Test success and from is set to teacher when selected.
     $testsubject = 'Test Subject';
     $testbody = 'Test Body';
     set_config('newenrolmentemailenabled', '1', 'dhimport_version1elis');
     set_config('newenrolmentemailsubject', $testsubject, 'dhimport_version1elis');
     set_config('newenrolmentemailtemplate', $testbody, 'dhimport_version1elis');
     set_config('newenrolmentemailfrom', 'teacher', 'dhimport_version1elis');
     $result = $importplugin->newenrolmentemail($student);
     $this->assertNotEmpty($result);
     $this->assertInternalType('array', $result);
     $this->assertArrayHasKey('user', $result);
     $this->assertEquals($muser, $result['user']);
     $this->assertArrayHasKey('from', $result);
     $this->assertEquals($teacher, $result['from']);
     $this->assertArrayHasKey('subject', $result);
     $this->assertEquals($testsubject, $result['subject']);
     $this->assertArrayHasKey('body', $result);
     $this->assertEquals($testbody, $result['body']);
     // Test that subject is replaced by empty string when not present.
     $testsubject = null;
     $testbody = 'Test Body';
     set_config('newenrolmentemailenabled', '1', 'dhimport_version1elis');
     set_config('newenrolmentemailsubject', $testsubject, 'dhimport_version1elis');
     set_config('newenrolmentemailtemplate', $testbody, 'dhimport_version1elis');
     set_config('newenrolmentemailfrom', 'admin', 'dhimport_version1elis');
     $result = $importplugin->newenrolmentemail($student);
     $this->assertNotEmpty($result);
     $this->assertInternalType('array', $result);
     $this->assertArrayHasKey('user', $result);
     $this->assertEquals($muser, $result['user']);
     $this->assertArrayHasKey('from', $result);
     $this->assertEquals(get_admin(), $result['from']);
     $this->assertArrayHasKey('subject', $result);
     $this->assertEquals('', $result['subject']);
     $this->assertArrayHasKey('body', $result);
     $this->assertEquals($testbody, $result['body']);
     // Full testing of replacement is done below, but just test that it's being done at all from the main function.
     $testsubject = 'Test Subject';
     $testbody = 'Test Body %%user_username%%';
     $expectedtestbody = 'Test Body ' . $muser->username;
     set_config('newenrolmentemailenabled', '1', 'dhimport_version1elis');
     set_config('newenrolmentemailsubject', $testsubject, 'dhimport_version1elis');
     set_config('newenrolmentemailtemplate', $testbody, 'dhimport_version1elis');
     set_config('newenrolmentemailfrom', 'admin', 'dhimport_version1elis');
     $result = $importplugin->newenrolmentemail($student);
     $this->assertNotEmpty($result);
     $this->assertInternalType('array', $result);
     $this->assertArrayHasKey('user', $result);
     $this->assertEquals($muser, $result['user']);
     $this->assertArrayHasKey('from', $result);
     $this->assertEquals(get_admin(), $result['from']);
     $this->assertArrayHasKey('subject', $result);
     $this->assertEquals($testsubject, $result['subject']);
     $this->assertArrayHasKey('body', $result);
     $this->assertEquals($expectedtestbody, $result['body']);
 }
 /**
  * Validate that the provided custom field type and value produce the
  * specified error message on course description 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_course_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/course.class.php';
     $this->create_custom_field(CONTEXT_ELIS_COURSE, $uitype, $otherparams);
     // Create mapping record.
     $this->create_mapping_record('course', 'testfieldshortname', 'customtestfieldshortname');
     $course = new course(array('name' => 'testcoursename', 'idnumber' => 'testcourseidnumber', 'syllabus' => ''));
     $course->save();
     $data = array('action' => 'update', 'context' => 'course', 'idnumber' => 'testcourseidnumber', 'customtestfieldshortname' => $value);
     $message = '[course.csv line 2] Course description with idnumber "testcourseidnumber" could not be updated. ' . $message . "\n";
     $this->assert_data_produces_error($data, $message, 'course');
 }
 /**
  * Validate that an appropriate error is logged when max field lengths are
  * exceeded during a class instance create 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 classcreatefieldprovider
  */
 public function test_classinstancecreatelogserrorwhenfieldstoolong($field, $length, $customvalue)
 {
     global $CFG, $DB;
     require_once $CFG->dirroot . '/local/elisprogram/lib/data/course.class.php';
     require_once $CFG->dirroot . '/local/elisprogram/lib/data/pmclass.class.php';
     $course = new course(array('idnumber' => 'testcourseidnumber', 'name' => 'testcoursename', 'syllabus' => ''));
     $course->save();
     $data = array('action' => 'create', 'context' => 'class', 'assignment' => 'testcourseidnumber', 'idnumber' => 'testclassidnumber');
     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');
 }
示例#20
0
 /**
  * Test failure conditions.
  * @dataProvider dataprovider_failure
  * @expectedException moodle_exception
  * @param array $user The incoming user data.
  */
 public function test_failure(array $user, $giveperms = true)
 {
     global $DB;
     if ($giveperms === true) {
         $this->give_permissions(array('local/elisprogram:class_create'));
     }
     $course = new course();
     $course->idnumber = 'testcourse1';
     $course->name = 'Test Course 1';
     $course->syllabus = 'Test';
     $course->save();
     // Create a class (used for duplicate test).
     $class = new pmclass();
     $class->idnumber = 'testclass1';
     $class->courseid = $course->id;
     $class->save();
     $response = local_datahub_elis_class_create::class_create($user);
 }
<?php

$courseAPI = new course($course_id);
$course = $courseAPI->info();
?>

<!-- START PAGE CONTENT WRAPPER -->
<div class="page-content-wrapper">
    <!-- START PAGE CONTENT -->
    <div class="content">
        <!-- START JUMBOTRON -->
        <div class="jumbotron" data-pages="parallax">
            <div class="container-fluid container-fixed-lg sm-p-l-20 sm-p-r-20">
                <div class="inner">
                    <!-- START BREADCRUMB -->
                    <ul class="breadcrumb">
                        <li>
                            <a href="<?php 
echo $router->generate('course');
?>
" class="">Course</a>
                        </li>
                        <li><a href="#" class="active"><?php 
echo $course['name'];
?>
</a>
                        </li>
                    </ul>
                    <!-- END BREADCRUMB -->
                </div>
            </div>
示例#22
0
}
if ($_FILES["cfile"]["name"]) {
    if ($_FILES["cfile"]["type"] == "application/pdf") {
        if ($_FILES["cfile"]["size"] < 2048000) {
            $tempr = explode(".", $_FILES["cfile"]["name"]);
            $extension = end($tempr);
            //  echo "Upload: " . $_FILES["cfile"]["name"] . "<br />";
            // echo "Type: " . $_FILES["cfile"]["type"] . "<br />";
            // echo "Size: " . ($_FILES["cfile"]["size"] / 1024) . " Kb<br />";
            //  echo "Temp file: " . $_FILES["cfile"]["tmp_name"] . "<br />";
            //  echo "Stored in: " . "../resumes/" . $_FILES["cfile"]["name"];
            $url = "CoursePDF/" . $_POST['programme'] . "/" . $id . "." . $extension;
        } else {
            die("Invalid file extension or file size grater then 2MB. ");
        }
    } else {
        die("Invalid file");
    }
} else {
    $url = NULL;
}
$course = new course($id, $name, $credit, $pro, $semester, $url);
$status = $course->insertCourse();
if ($_FILES["cfile"]["name"]) {
    if ($status === 1) {
        move_uploaded_file($_FILES["cfile"]["tmp_name"], "../../CoursePDF/" . $_POST['programme'] . "/" . $id . "." . $extension);
    }
}
echo $status;
$l = new site_log(NULL, NULL, $_SESSION['user']->username, $_SERVER['REMOTE_ADDR'], $id . " Course added");
$l->insertlog();
<?php

$assignmentAPI = new Assignment($assignment_id);
$assignment = $assignmentAPI->info();
$course_id = $assignment['course_id'];
$courseAPI = new course($course_id);
$course = $courseAPI->info();
$group_id = $param2;
?>
<style>
#code_hierarchy
{
	position:relative;
	width:600px;
	margin:0 auto;
}

#code_hierarchy_legend
{
	height:100px;
	font-size:1.4em;
	text-align:center;
}

.bg-success:hover {
	background-color: #626c75;
	border-color: #626c75;
	cursor: pointer;
}
</style>
<script type="text/javascript" src="/js/data/visualization.js"></script>
示例#24
0
<?php

require '../inc/config.php';
?>

<?php 
$userAPI->authService();
$userAPI->authRight('teacher');
?>

<?php 
require '../inc/template_start.php';
require '../inc/page_head.php';
require '../api/course.php';
$courseAPI = new course($_GET['course_id']);
?>


<!-- Page content -->
<div id="page-content">
    <!-- Courses Header -->
    <div class="content-header">
        <div class="header-section">
            <h1>
                <i class="gi gi-book_open"></i><?php 
echo $courseAPI->info['course_code'];
?>
 - <?php 
echo $courseAPI->info['name'];
?>
<br><small>Assignments</small>
 /**
  * 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)));
 }
 function action_savenew()
 {
     $courseid = $this->required_param('courseid', PARAM_INT);
     $target = $this->get_new_page(array('action' => 'add'));
     $form = new $this->form_class($target->get_moodle_url());
     if ($form->is_cancelled()) {
         $coursepage = new coursecurriculumpage();
         $target = $coursepage->get_new_page(array('id' => $courseid));
         redirect($target->get_url(), '', 0.1);
     }
     $data = $form->get_data();
     if ($data) {
         $obj = new $this->data_class();
         $obj->set_from_data($data);
         $obj->add();
         $course = new course($data->courseid);
         $course->add_course_to_curricula(array($obj->id));
         $coursepage = new coursepage();
         $target = $coursepage->get_new_page(array('action' => 'view', 'id' => $course->id));
         redirect($target->get_url(), ucwords($obj->get_verbose_name()) . ' ' . $obj->to_string() . ' saved.');
     } else {
         // Validation must have failed, redisplay form
         $form->display();
     }
 }
示例#27
0
文件: lib.php 项目: jamesmcq/elis
/**
 * 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;
}
示例#28
0
 /**
  * Performs course update
  * @throws moodle_exception If there was an error in passed parameters.
  * @throws data_object_exception If there was an error updating the entity.
  * @param array $data The incoming data parameter.
  * @return array An array of parameters, if successful.
  */
 public static function course_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::course_update_parameters(), array('data' => $data));
     // Context validation.
     $context = context_user::instance($USER->id);
     self::validate_context($context);
     $data = (object) $data;
     // Validate course exists
     if (!($crsid = $DB->get_field(course::TABLE, 'id', array('idnumber' => $data->idnumber)))) {
         throw new data_object_exception('ws_course_update_fail_invalid_idnumber', 'local_datahub', '', $data);
     }
     // Capability checking.
     require_capability('local/elisprogram:course_edit', \local_elisprogram\context\course::instance($crsid));
     // Initialize version1elis importplugin for utility functions.
     $importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis');
     // Validate credits.
     if (isset($data->credits) && !(is_numeric($data->credits) && $data->credits >= 0)) {
         throw new data_object_exception('ws_course_update_fail_invalid_credits', 'local_datahub', '', $data);
     }
     // Validate completion grade.
     if (isset($data->completion_grade) && !(is_numeric($data->completion_grade) && $data->completion_grade >= 0 && $data->completion_grade <= 100)) {
         throw new data_object_exception('ws_course_update_fail_invalid_completion_grade', 'local_datahub', '', $data);
     }
     // Handle assignment to program.
     if (isset($data->assignment) && !empty($data->assignment)) {
         $programid = $DB->get_field(curriculum::TABLE, 'id', array('idnumber' => $data->assignment));
         if ($programid) {
             $curriculumcourseid = $DB->get_field(curriculumcourse::TABLE, 'id', array('curriculumid' => $programid, 'courseid' => $crsid));
             // Only assign if it is not already assigned
             if (!$curriculumcourseid) {
                 $data->curriculum = array($programid);
             }
         } else {
             throw new data_object_exception('ws_course_update_fail_invalid_assignment', 'local_datahub', '', $data);
         }
     }
     $course = new course($crsid);
     $course->load();
     $course->set_from_data($data);
     $course->save();
     // Handle linking to Moodle course.
     if (isset($data->link) && !empty($data->link)) {
         $moodlecourseid = $DB->get_field('course', 'id', array('shortname' => $data->link));
         if ($moodlecourseid) {
             $importplugin->associate_course_to_moodle_course($data, $course->id);
         } else {
             throw new data_object_exception('ws_course_update_fail_invalid_link', 'local_datahub', '', $data);
         }
     }
     // Respond.
     if (!empty($course->id)) {
         $courserec = (array) $DB->get_record(course::TABLE, array('id' => $course->id));
         $courseobj = $course->to_array();
         // convert multi-valued custom field arrays to comma-separated listing
         $fields = self::get_course_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($courseobj[$fullfieldname]) && is_array($courseobj[$fullfieldname])) {
                 $courseobj[$fullfieldname] = implode(',', $courseobj[$fullfieldname]);
             }
         }
         return array('messagecode' => get_string('ws_course_update_success_code', 'local_datahub'), 'message' => get_string('ws_course_update_success_msg', 'local_datahub'), 'record' => array_merge($courserec, $courseobj));
     } else {
         throw new data_object_exception('ws_course_update_fail', 'local_datahub');
     }
 }
 /**
  * Validate that class instance-moodle course associations can be created during a class instance update action.
  *
  * @param string $link The link attribute to use in the import, or 'auto' to auto-create from template.
  * @dataProvider link_course_provider
  */
 public function test_associate_moodle_course_during_class_update($link)
 {
     global $CFG, $DB, $USER;
     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/coursetemplate.class.php');
     require_once elispm::lib('data/course.class.php');
     require_once elispm::lib('data/pmclass.class.php');
     // Make sure $USER is set up for backup/restore.
     $USER->id = $DB->get_field_select('user', 'id', "username != 'guest' AND deleted = 0", array(), IGNORE_MULTIPLE);
     // Need the moodle/backup:backupcourse capability.
     $guestroleid = create_role('guestrole', 'guestrole', 'guestrole');
     set_config('guestroleid', $guestroleid);
     set_config('siteguest', '');
     $systemcontext = context_system::instance();
     $roleid = create_role('testrole', 'testrole', 'testrole');
     assign_capability('moodle/backup:backupcourse', CAP_ALLOW, $roleid, $systemcontext->id);
     role_assign($roleid, $USER->id, $systemcontext->id);
     $coursecategory = new stdClass();
     $coursecategory->name = 'testcoursecategoryname';
     $coursecategory->id = $DB->insert_record('course_categories', $coursecategory);
     $moodlecourse = new stdClass();
     $moodlecourse->category = $coursecategory->id;
     $moodlecourse->shortname = 'testcourseshortname';
     $moodlecourse->fullname = 'testcoursefullname';
     $moodlecourse = create_course($moodlecourse);
     $course = new course(array('name' => 'testcoursename', 'idnumber' => 'testcourseidnumber', 'syllabus' => ''));
     $course->save();
     $class = new pmclass(array('courseid' => $course->id, 'idnumber' => 'testclassidnumber'));
     $class->save();
     // Need this for the 'auto' case, at the very least.
     $coursetemplate = new coursetemplate(array('courseid' => $course->id, 'location' => $moodlecourse->id, 'templateclass' => 'moodlecourseurl'));
     $coursetemplate->save();
     // Run the class instance create action.
     $record = new stdClass();
     $record->idnumber = 'testclassidnumber';
     $record->assignment = 'testcourseidnumber';
     $record->link = $link;
     $importplugin = rlip_dataplugin_factory::factory('dhimport_version1elis');
     $importplugin->fslogger = new silent_fslogger(null);
     $importplugin->class_update($record, 'bogus');
     // Validation.
     if ($record->link == 'auto') {
         $moodlecourseid = $moodlecourse->id + 1;
     } else {
         $moodlecourseid = $moodlecourse->id;
     }
     $dbautocreated = $record->link == 'auto' ? 1 : 0;
     $this->assertTrue($DB->record_exists(classmoodlecourse::TABLE, array('classid' => $class->id, 'moodlecourseid' => $moodlecourseid, 'enroltype' => 0, 'enrolplugin' => 'crlm', 'autocreated' => $dbautocreated)));
     ini_set('max_execution_time', '0');
 }
示例#30
0
 /**
  * Test failure conditions.
  * @dataProvider dataprovider_failure
  * @expectedException moodle_exception
  * @param array $params The incoming parameters.
  */
 public function test_failure(array $params, $giveperms = true)
 {
     global $DB;
     if ($giveperms === true) {
         $this->give_permissions(array('local/elisprogram:class_delete'));
     }
     $course = new course(array('idnumber' => 'testcourse', 'name' => 'Test Course', 'syllabus' => ''));
     $course->save();
     $pmclass = new pmclass(array('idnumber' => 'testclass', 'courseid' => $course->id));
     $pmclass->save();
     $response = local_datahub_elis_class_delete::class_delete($params);
 }