Beispiel #1
0
 /**
  * Test get_completion_counts function
  */
 public function test_get_completion_counts()
 {
     // Fixture.
     $dataset = $this->createCsvDataSet(array(student::TABLE => elispm::file('tests/fixtures/student.csv'), user::TABLE => elispm::file('tests/fixtures/pmuser.csv')));
     $this->loadDataSet($dataset);
     // Test.
     $pmclass = new pmclass();
     $pmclass->id = 100;
     $completioncounts = $pmclass->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(1, $completioncounts[STUSTATUS_NOTCOMPLETE]);
     $this->assertEquals(0, $completioncounts[STUSTATUS_FAILED]);
     $this->assertEquals(0, $completioncounts[STUSTATUS_PASSED]);
 }
Beispiel #2
0
 /**
  * Override print_num_items to display the max number of students allowed in this class
  *
  * @param int $numitems max number of students
  */
 public function print_num_items($classid, $max)
 {
     $pmclass = new pmclass($classid);
     $students = $pmclass->get_completion_counts($classid);
     $langfailed = get_string('num_students_failed', static::LANG_FILE);
     $langpassed = get_string('num_students_passed', static::LANG_FILE);
     $langnotcomplete = get_string('num_students_not_complete', static::LANG_FILE);
     $langmaxstudents = get_string('num_max_students', static::LANG_FILE);
     if (!empty($students[STUSTATUS_FAILED])) {
         // echo '<div style="float:right;">'.$langfailed.': '.$students[STUSTATUS_FAILED].'</div><br />';
     }
     if (!empty($students[STUSTATUS_PASSED])) {
         // echo '<div style="float:right;">'.$langpassed.': '.$students[STUSTATUS_PASSED].'</div><br />';
     }
     if (!empty($students[STUSTATUS_NOTCOMPLETE])) {
         // echo '<div style="float:right;">'.$langnotcomplete.': '.$students[STUSTATUS_NOTCOMPLETE].'</div><br />';
     }
     if (!empty($max)) {
         echo '<div style="float:right;">' . $langmaxstudents . ': ' . $max . '</div><br />';
     }
 }
Beispiel #3
0
 function freeze()
 {
     // Add completion status information
     $obj = new pmclass($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();
 }