Beispiel #1
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;
}
 /**
  * Validate that the check_for_moodle_courses method deletes the correct set of orphaned associations for a specific user.
  * @param array $associations The list of associations and information regarding whether they should be cleaned up or not.
  * @dataProvider dataprovider_checkformoodlecourses
  */
 public function test_checkformoodlecoursesrespectsuseridparameter($associations)
 {
     global $DB;
     // Set up our classes.
     $this->load_csv_data();
     $student = new student(array('userid' => 103, 'classid' => 103));
     $sink = $this->redirectMessages();
     $student->save();
     // Track which associations should remain.
     $remainingassociations = array();
     foreach ($associations as $association) {
         // Persist the record.
         $record = new classmoodlecourse($association);
         $record->save();
         // Test user is enrolled in class 103, so this one should be deleted.
         if ($association['classid'] != 103) {
             // It should persist after the method is called.
             $remainingassociations[] = $association;
         }
     }
     // Delete orphaned records.
     pmclass::check_for_moodle_courses(103);
     // Validate count.
     $this->assertEquals(count($remainingassociations), $DB->count_records(classmoodlecourse::TABLE));
     // Validate records specifically.
     foreach ($remainingassociations as $remainingassociation) {
         $params = array('classid' => $remainingassociation['classid'], 'moodlecourseid' => $remainingassociation['moodlecourseid']);
         $exists = $DB->record_exists(classmoodlecourse::TABLE, $params);
         $this->assertTrue($exists);
     }
 }