Skip to content

Instantly share code, notes, and snippets.

@omairvaiyani
Last active November 16, 2018 09:58
Show Gist options
  • Select an option

  • Save omairvaiyani/6b3285954f8b359432d12a1b8dc200a8 to your computer and use it in GitHub Desktop.

Select an option

Save omairvaiyani/6b3285954f8b359432d12a1b8dc200a8 to your computer and use it in GitHub Desktop.

In Synap, the term, quiz, is referenced as the Test class. Tests store information on the questions they contain, and point to a number of other related objects. When querying for a specific test, we will return a 'data transfer object', shortened to DTO. This object only contains fields that are relevant to the task at hand.

interface TestDTO {
  objectId: string;
  createdAt: Date;
  updatedAt: Date;
  title: string;
  slug: string;
  description: string;
  isSpacedRepetition: boolean;
  isGenerated: boolean;
  tags: string[];
  totalQuestions: number;
  questions: TestDTO.Question[];
  author: TestDTO.User;
  
}
namespace TestDTO {
  export interface Question {
    objectId: string;
    createdAt: Date;
    updatedAt: Date;
    stem: string;
    options: Option[];
    optionType: OptionType;
    feedback: string;
    tags?: string[];
    image?: File;
    feedbackImage?: File;
    bank?: QuestionBank;
    emqGroup?: EmqGroup;
    emqGroupOrder?: number;
  }

  interface Option {
    phrase: string;
    isCorrect: boolean;
    rank?: number;
  }

  type OptionType = 'phrase' | 'phrase:multipleCorrect' | 'phrase:ranked'

  interface EmqGroup {
    objectId: string;
    createdAt: Date;
    updatedAt: Date;
    instructions: string;
    title?: string;
    feedback?: string;
    image?: File;
  }

  export interface User {
    objectId: string;
    createdAt: Date;
    updatedAt: Date;
    name: string;
    slug: string;
    email: string;
    bio?: string;
    attr?: { [key: string]: any };
    emailVerified?: boolean;
    profilePicture?: File;
  }

  export interface File {
    __type: 'Pointer';
    _name: string;
    _url: string;
  }

  export interface QuestionBank {
    objectId: string;
    createdAt: Date;
    updatedAt: Date;
    name: string;
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment