public static function fetch_assignment_profile(Token $token)
 {
     $query = Database::generate_query("assignment_lookup_id", [$token->toString()]);
     $result = $query->execute();
     $row = $result->fetch_data();
     return ["assignment-id" => $token->toString(), "assessment-id" => Token::decode($row['assessment_id']), "deadline" => $row['assignment_deadline']];
 }
 public static function create_token(Token $clientid, Token $userid, $tokenType, $expires)
 {
     $token = Token::generateToken($tokenType, $userid->getUserSecret());
     $query = Database::generate_query("token_create", [$token->toString(), $userid->toString(), $clientid->toString(), $expires]);
     $query->execute();
     return $token;
 }
 public function __construct(Token $profile)
 {
     parent::__construct("Could not find assessment with id provided.", ["id" => $profile->toString()]);
 }
 public static function delete_question(AssessmentProfile $profile, Token $id)
 {
     $query = Database::generate_query("assessment_question_delete", [$profile->getAssessmentId()->toString(), $id->toString()]);
     $query->execute();
 }
 /**
  * Convert this group profile into a json encodedable form to return from the API
  *
  * @return array this profile as an array
  */
 public function toExternalForm()
 {
     return ["group-id" => $this->groupid->toString(), "group-name" => $this->groupname, "display-name" => $this->displayName];
 }
 /**
  * Convert this assessment profile into a json encodedable form to return from the API
  *
  * @return array this profile as an array
  */
 public function toExternalForm()
 {
     return ["assessment-id" => $this->assessmentId->toString(), "assessment-name" => $this->assessmentName, "display-name" => $this->displayName];
 }
 public function __construct($error = "Could not find assignment with id provided.", Token $id = null)
 {
     parent::__construct($error, $id != null ? ["id" => $id->toString()] : []);
 }
 public static function add_assignment_scores(UserProfile $user, Token $assignmentId, Token $assessmentId, array $scores)
 {
     $query = Database::generate_query("user_score_add", [$user->getUserId()->toString(), $assignmentId->toString(), $assessmentId->toString()]);
     $query->execute();
     $scoreId = Database::insert_id();
     foreach ($scores as $score) {
         $query = Database::generate_query("user_score_question_add", [$scoreId, $user->getUserId()->toString(), $assignmentId->toString(), $score['question-id'], $assessmentId->toString(), $score['score']]);
         $query->execute();
     }
 }
 /**
  * Convert this user profile into a json encodedable form to return from the API
  *
  * @return array this profile as an array
  */
 public function toExternalForm()
 {
     return ["user-id" => $this->userid->toString(), "user-name" => $this->username, "display-name" => $this->displayName];
 }