Exemplo n.º 1
0
 /**
  * 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);
     }
 }