function awardOrRevokeChallenge($shortname, $userid, $currentState, $newState)
 {
     // award challenge if adding
     if (!$currentState && $newState) {
         require_once PATH_CORE . '/classes/challenges.class.php';
         $ct = new ChallengeCompletedTable($db);
         if (!$ct->submitAutomaticChallenge($userid, $shortname, &$statuscode, true)) {
             $this->log($statuscode);
             // TODO: take this out when done testing
             return false;
         }
         $this->db->log("Awarded points for {$shortname} to {$userid}");
     }
     // revoke points if removing
     if ($currentState && !$newState) {
         require_once PATH_CORE . '/classes/challenges.class.php';
         $ct = new ChallengeCompletedTable($db);
         if (!$ct->revokeAutomaticChallengeAward($userid, $shortname)) {
             $this->db->log("Error, couldnt revoke points for {$shortname} for userid {$userid}");
             return false;
         }
         $this->db->log("Revoked points for {$shortname} from {$userid}");
     }
     return true;
 }