Skip to content
This repository has been archived by the owner on Sep 21, 2024. It is now read-only.

Question Schemas

Noah Piraino edited this page Dec 13, 2018 · 6 revisions

JScout Questions

Question Types

The scouting form in the JScout frontend is built dynamically, to allow for easy modification. Each question is based on a template class, which is used to fill in a templated block of HTML for the final page. These classes can be found at jscout/src/app/question-types/ from the root of the repository, and contain the available properties for each available type of question.

Base Question

class QuestionBase from question-base.ts

The base question class contains properties required for all types of questions, and is not itself an actual question. Each of these proeprties are inherited by all other question types.

Required Properties:

  • key: (string) Specifies the property name to be used in the final JSON formatted submission
  • label: (string) Specifies the name of the field that will appear on the form to the end user/scouter
  • order: (number) Specifies the order in which this question will appear in it's section of questions
    • NOTE: You MUST NOT skip a number for the order proeprties, or the form will not render properly!

Optional Properties:

  • value: Specifies the default value of the question
  • required: (boolean) Specifies whether or not a question is required

Checkbox Question

class CheckboxQuestion from question-checkbox.ts

This class is used for a checkbox. There are no additional properties needed.

Dropdown Question

class DropdownQuestion from question-dropdown.ts

This class is used for dropdown questions (selects).

Required Properties:

  • options: (array) Specifies an array of objects that make up each of the options for the dropdown.

    Required Options Object Properties:

    • value: (string) Specifies the selected value of the option
    • name: (string) Specifies the name of the option in the dropdown

    Optional Options Object Properties:

    • disable: (boolean) Specifies whether or not the option should be disabled

Number Question

class NumberQuestion from question-number.ts

This class is used for number questions.

Optional Properties:

  • min: (number) Specifies the minimum possible value of the question
  • max: (number) Specifies the maximum possible value of the question
  • tickers: (boolean) Specifies whether the question should have the red/green plus and minus buttons on the sides of the input box

Text Question

class TextQuestion from question-text.ts

This class is used for small text questions. There are no additional properties needed.

Textarea Question

class TextareaQuestion from question-textarea.ts

This class is used for large textbox questions (textareas).

Optional Properties:

  • rows: (number) Specifies the number of rows the textarea will have.
    • NOTE: Specifying columns is not supported due to the fixed width nature of the form.

Creating Questions

Questions are defined in the jscout/src/app/question.service.ts file. In this file there are 4 methods for the 4 main sections of the scouting form:

  • getSetupQuestions(): Defines questions for the base information needed to scout a match
    • NOTE: You should NOT need to edit these unless you know exactly what you're doing!
  • getAutoQuestions(): Defines questions for the autonomous period of a match
  • getTeleopQuestions(): Defines questions for the teleoperated period of a match
  • getEndgameQuestions(): Defines closing questions for after a match has concluded
    • NOTE: This section contains questions for Yellow Cards, Red Cards, and Additional Notes. You should not need to edit these fields.

Each of these functions contain an array of objects, each object being one of the question classes defined above. For example:

new NumberQuestion({
	key: 'AutoSwitchCubes',
	label: 'Autonomous Power Cubes on Switch',
	tickers: true,
	min: 0,
	value: 0,
	order: 2
})

would make a Number Question

  • with the plus/minus increment buttons enabled
  • a display name of Autonomous Power Cubes on Switch
  • a payload key of AutoSwitchCubes
  • a minimum value of 0
  • an initial value of 0

and would be the second question in the section if you start the order at 1.

GoScout Struct

The GoScout backend uses a struct contained in the goscout/src/struct.go file for the data model. Each line of the struct will corespond to a column in the database. For example:

AutoSwitchCubes uint8 `gorm:"type:tinyint"`

would be the line for the example question above. The line/property name must match the key of whatever question it coresponds with, in this case AutoSwitchCubes. The second part is what type we want the property to be in Go, in this case a uint8 value. The third part is information used by GORM to interact with the database. It can be used to specify what type we want the column to be, among other things. In this example we are setting the column to type tinyint.