Exemplo n.º 1
0
 /**
  * Test get_completion_counts function.
  */
 public function test_get_completion_counts()
 {
     global $DB;
     // Fixture.
     $elisgen = new elis_program_datagenerator($DB);
     $pmcourse = $elisgen->create_course();
     $class = $elisgen->create_pmclass(array('courseid' => $pmcourse->id));
     $class2 = $elisgen->create_pmclass(array('courseid' => $pmcourse->id));
     $user = $elisgen->create_user();
     $user2 = $elisgen->create_user();
     $elisgen->assign_user_to_class($user->id, $class->id);
     $elisgen->assign_user_to_class($user2->id, $class2->id);
     $course = new course();
     $course->id = $pmcourse->id;
     $completioncounts = $course->get_completion_counts();
     // Verify results.
     $this->assertInternalType('array', $completioncounts);
     $this->assertEquals(3, count($completioncounts));
     $this->assertArrayHasKey(STUSTATUS_NOTCOMPLETE, $completioncounts);
     $this->assertArrayHasKey(STUSTATUS_FAILED, $completioncounts);
     $this->assertArrayHasKey(STUSTATUS_PASSED, $completioncounts);
     $this->assertEquals(2, $completioncounts[STUSTATUS_NOTCOMPLETE]);
     $this->assertEquals(0, $completioncounts[STUSTATUS_FAILED]);
     $this->assertEquals(0, $completioncounts[STUSTATUS_PASSED]);
 }
Exemplo n.º 2
0
 function freeze()
 {
     $this->_form->removeElement('templateButtons');
     // Add completion status information
     $obj = new course($this->_customdata['obj']);
     $counts = $obj->get_completion_counts();
     $counttext = "Passed: {$counts[2]}, Failed: {$counts[1]}, In Progress: {$counts[0]}";
     $this->_form->addElement('static', 'test', get_string('completion_status', 'local_elisprogram'), $counttext);
     parent::freeze();
 }