Quizapp Documentation: Release 0.0.1
Quizapp Documentation: Release 0.0.1
Release 0.0.1
1 Contents 3
i
ii
QuizApp Documentation, Release 0.0.1
QuizApp is a platform for conducting experiments in the form of online surveys. It is highly generalized, which makes
it useful for a wide variety of experiments.
At the fundamental level, QuizApp allows you to show a participant a sequence of assignments. These assignments can
be anything from instructional screens to questions to reviews of the participant’s past performance. The participant’s
responses to these assignments are stored in the database and associated with the assignment set that they completed.
An experiment contains several assignment sets.
This structure allows researchers to have fine grain control over what each participant sees as well as detailed infor-
mation about how each participant responded to each assignment.
For more information, please read through the documentation listed below.
Contents 1
QuizApp Documentation, Release 0.0.1
2 Contents
CHAPTER 1
Contents
1.1.1 Quickstart
This will check out the most recent stable version of QuizApp. If you like to live dangerously and want the bleeding
edge version, replace master with develop .
It is best practice to install python dependencies using a virtual environment. This means that the packages that
QuizApp installs are independent from any packages you already have installed, which reduces any possible compati-
bility nightmares.
Before continuing, you should follow the installation instructions for virtualenvwrapper.
Now that you’ve done that, create a virtual environment for QuizApp.
mkvirtualenv quizApp
Lastly, you need to set up the database. QuizApp uses MariaDB. If you use MySQL instead of MariaDB, QuizApp
should still work normally. If you have neither, you should install MariaDB.
Once you have MariaDB installed and running, you need to set up the database:
3
QuizApp Documentation, Release 0.0.1
./manage.py create-db
You will be prompted for your MySQL root password. This will create a database called quizapp and a user named
quizapp .
If you would like to have a different username/password combo, edit quizApp/config.py , find the configuration
you wish to modify (e.g. development, production) and modify the variables to your new values. You will then have
to re-run create-db . Note that your information is not secure if you do not modify the database username
and password.
Note: manage.py can handle creation and population of multiple database configurations. If you are running a
development sever, the above command is sufficient. This is because manage.py defaults to the development
configuration.
If you want to set up a production server, you must specify the --config option:
Keep this in mind when you see other commands using manage.py .
Creating a user
You will need to create a user to work with QuizApp. Full details are available on Managing users, but your command
should look something like this:
Running QuizApp
This is essentally all you have to do to install QuizApp. To run QuizApp using the default Flask webserver, simply
run:
./manage.py run
However, it is not recommended to use this server for production environments. See Production servers for instructions
on running QuizApp in a production environment.
If you are running quizApp in a production environment, you are definitely going to want to modify the password of
the QuizApp database user for extra security. You are maybe going to want to modify the database name or username
that QuizApp uses.
In any case, the easiest method to change the database setup is by modifying quizApp/config.py . There are
3 main environments that QuizApp recognizes - testing, development, and production. You are probably most inter-
ested in modifying production settings - however note that the Production class does not contain any database
particulars. This is because database information for production is stored using instance configuration.
In QuizApp, the instance folder is called instance . There is a file there called instance_config.py.ex
. If you wish to override any of the default production database settings, you should copy this file to
instance/instance_config.py .
4 Chapter 1. Contents
QuizApp Documentation, Release 0.0.1
In that file, there are four options. The first option is the database URI. The full reference for the URI syntax is located
here.
The second is the secret key. This is used for various cryptographic purposes and needs to be randomly generated.
Refer to the flask documentation for instructions on generating secret keys.
Repeat the process above for the third option, SECURITY_PASSWORD_SALT .
The fourth option represents what email address QuizApp will use to send emails such as registration confirmation,
password recovery, etc.
In addition, if you plan to use QuizApp with Amazon Mechanical Turk, you will need to move
instance/mturk.yaml.ex to instance/mturk.yaml and update the AWS access key ID and secret key
for your mechanical turk user. Remember to follow best practices and use IAM for this.
There are many ways to run QuizApp in a server. However, QuizApp is merely a platform and does not include a web
server.
One popular way to run a server is via gunicorn and nginx. Here is a good tutorial for setting up that configuration.
QuizApp already includes a wsgi file for use with gunicorn, located at wsgi.py .
There are 3 principle parts of the quizApp system: the experiments, activities, and datasets. The experiment com-
ponents handle tasks related to rendering, running, and updating experiments - this includes showing assignments to
participants, saving their answers, generating experiment reports, and more. Activities is concerned primarily with
rendering and managing activities. Datasets is primarily concerned with managing datasets as well as rendering and
managing activities. Most components of quizApp are divided along these broad lines.
As far as application logic goes, quizApp follows a fairly typical MVC design pattern. The quizApp/ directory is
organized like so:
• forms : Contains logic used for rendering and validating forms
• static : Contains static files, like graphs, css, and js
• templates : Contains template files, which specify what is displayed to the users and in what format
• views : Contains view logic that interfaces with the models and sends data to templates for rendering
• models.py : Database models that specify how information is stored in the database and take care of valida-
tion. More information about models is available in Understanding the QuizApp models.
• filters.py : Various jinja filters that are used for formatting and rendering purposes
• __init__.py : File that handles setup and initialization of the application
In general, each view file registers a number of URLs that are handled by some function in the view file. When a
user makes a request to a certain endpoint, the view function first checks authentication, then validates the URL (if
applicable, e.g. checking to make sure the requested experiment exists), accesses the database (if necessary), performs
any necessary processing, then sends some context variables to a template, which is rendered and shown to the user.
When it comes to running experiments, participants must first be given a link to the experiment itself. Once they arrive
at the landing page, they will see the experiment’s blurb and be assigned an assignment set. Once they click “start”
they will begin the first assignment in their set. Each assignment will be rendered as its media items followed by its
activity. The participant’s response will be stored as a Result object on the Assignment. Once the participant finalizes
their responses, their assignment set will be marked as completed and they will be unable to run the experiment again.
The structure of a QuizApp database may be confusing at first, but it is actually fairly understandable. This document
focuses on the relationships between the models. For information about the other fields, view the documentation for
quizApp.models .
1.3.1 Experiment
At the root, there is the quizApp.models.Experiment . An Experiment contains information such as when to
start running, when to stop running, and any introductory text necessary.
1.3.2 AssignmentSet
1.3.3 Assignment
An Assignment is the object that associates a Participant with an quizApp.models.Activity . The rea-
son that AssignmentSet does not directly contain Activities is that Activity is also associated with a collection of
quizApp.models.MediaItem s. This means that, for the same Activity, two Participants may see two different
Mediaitems. While performing an Experiment, Participants are shown Assignments in the order they appear in their
AssignmentSet class.
1.3.4 Activity
An Activity is some screen that the Participant sees in the course of an Experiment. Currently, the only Activity is
quizApp.models.Question , which displays a Question and some choices. However, it is possible to extend
QuizApp to have other types of Activities. This would require creating a subclass of Activity in models.py and
implementing the correct logic to handle creation, reading, and updating of your new Activity type.
Question
There are several subclasses of Question. They all operate around the principle of displaying a string of text, followed
by a series of quizApp.models.Choice s. Each Choice is related to only one Question, so Choices are not
recycled from Question to Question. Since each Choice has its own correct field, you can have a Question with
all correct choices, no correct choices, or anywhere in between. Questions are also associated with Datasets. This
represents which Datasets a Question’s MediaItems are drawn from. A Question not associated with any Datasets can
draw MediaItems from any dataset.
6 Chapter 1. Contents
QuizApp Documentation, Release 0.0.1
1.3.5 MediaItem
A MediaItem is some stimulus that should be displayed when a Participant is doing an Activity. Each MediaItem is
associated with a quizApp.models.Dataset . By default, QuizApp contains the quizApp.models.Graph
MediaItem. A Graph is simply an image file located on disk. Again, it is possible to expand QuizApp to have
MediaItems that are videos, sounds, or anything else. You would need to subclass MediaItem, then implement the
correct logic for rendering the new MediaItem type.
1.3.6 Dataset
After creating your experiment, activities, media items, and datasets, you must set up your assignment sets and as-
signments to begin an experiment. Setting up your assignment sets and assignments is referred to as “importing data”.
Due to the diversity of methods for assigning assignments, quizApp does not provide a GUI but does allow a lot of
flexibility. Once an experiment has been run, you will want to export your data to analyze responses. The primary
way of importing and exporting data is through the /data/manage page. There are two operations you can do on
this page: importing and exporting.
1.4.1 Exporting
All data
To export a dump of all data in the database, click on the Export link. Alternatively, you can visit the /data/export
page. This will take some time due to the amount of database queries and processing, but it will give you all the data
in the database in spreadsheet form. The tab names correspond to the types of objects in the database, and the column
headers are in the format <table_name>:<database_column_name> . Each row in every tab represents one
database record.
To export just the data from one experiment, you can use the /experiments/<id>/results page. There is a
link there titled Export to XLSX. Clicking on this link will download a summary of answers to this experiment. Each
assignment set will have its own row, and each assignment in that assignment set will have three columns:
1. A string representation of that activity, e.g. the question text. The contents of this row is a string representation
of the result for this activity prepended with the assignment ID - so for example, the header might be the question
text and each cell under the header would be a participant’s answer (prepended with the ID of the assignment
itself).
2. Correct/incorrect, with each cell below that being TRUE or FALSE
3. Number of points awarded for the result
If a participant did not answer a question present in their assignment set, the token _BLANK_ will be present to
indicate this.
1.4.2 Importing
To import data into the database, you must modify a script provided with quizApp, namely
scripts/generate_import_sheet.py . There are two variables you are going to be interested in,
both defined in the beginning of the file:
1. DEST_FILE : The name of the output file
2. DATA : A list containing the actual data that should be written to the spreadsheet
DEST_FILE is self explanatory, and DATA has comments above it documenting its format. Note that you must know
the IDs of the experiments, activities, and media items you are interested in using. You can find them in the export
spreadsheet or in the web interface.
Once you have specified your DATA variable, you can simply run ./generate_import_sheet.py (make
sure you are in your quizApp virtual environment). There will be a file in the current directory named based on
DEST_FILE , and by uploading this spreadsheet in /data/manage your experiment will be populated with as-
signments and ready for use.
Note that there is no discovery mechanism for participants to find experiments - the experiment URL must be provided
to the participants, e.g. /experiments/5 where 5 is the ID of the experiment you are linking.
For a general overview of how the models work, refer to Understanding the QuizApp models. For a detailed documen-
tation of the models and their fields (which correspond to the columns in the spreadsheet), refer to quizApp.models
.
QuizApp includes a small script which allows you to post an Experiment as a HIT on Amazon Mechanical Turk.
Using the script is fairly straightforward:
1. Modify instance/mturk.yaml to correspond to your AWS credentials
2. Run ./manage.py post-hits --experiment-id <experiment_id> with the ID of the experi-
ment you wish to post.
Note: Make sure you are still in the virtual environment you made previously: workon quizApp
3. If you are successful, you will see the message “HIT Created” followed by the ID of the HIT. You should now
be able to see them in the requester interface on mechanical turk.
Note: This only creates the HIT in the amazon turk sandbox. If you wish to post it in the production environ-
ment, you must specify --live on the command line.
Further information on using the post-hits subcommand can be found by doing ./manage.py post-hits
--help .
Managing users is fairly straightforward with manage.py . The relevant commands are manage.py
create-user and mange.py delete-user . Remember that --help will give information about possi-
ble command line options.
8 Chapter 1. Contents
QuizApp Documentation, Release 0.0.1
2. Create a new experimenter with the username username and password password :
1.7 API
Subpackages
quizApp.forms package
Submodules
quizApp.forms.activities module
1.7. API 9
QuizApp Documentation, Release 0.0.1
ChoiceForm. correct = <UnboundField(BooleanField, (), {‘widget’: None, ‘description’: ‘’, ‘default’: None, ‘label’: u
ChoiceForm. label = <UnboundField(StringField, (), {‘widget’: None, ‘description’: ‘’, ‘default’: None, ‘label’: u’La
ChoiceForm. points = <UnboundField(IntegerField, (), {‘widget’: None, ‘description’: ‘’, ‘default’: 0, ‘label’: u’Poin
ChoiceForm. submit = <UnboundField(SubmitField, (‘Save’,), {})>
class quizApp.forms.activities. DatasetListForm ( formdata=<class flask_wtf.form._Auto>,
obj=None, prefix=’‘, csrf_context=None,
secret_key=None, csrf_enabled=None,
*args, **kwargs)
Bases: quizApp.forms.common.ListObjectForm
List a bunch of datasets.
get_choice_tuple ( dataset)
class quizApp.forms.activities. IntegerQuestionForm ( *args, **kwargs)
Bases: quizApp.forms.activities.ActivityForm
Create or update an IntegerQuestion.
class Meta
Bases: quizApp.forms.activities.Meta , wtforms_alchemy.Meta ,
wtforms_alchemy.Meta , wtforms.meta.DefaultMeta , object
IntegerQuestionForm. answer = <UnboundField(IntegerField, (), {‘widget’: None, ‘description’: ‘’, ‘default’: Non
IntegerQuestionForm. explanation = <UnboundField(TextAreaField, (), {‘widget’: None, ‘description’: ‘’, ‘defa
IntegerQuestionForm. lower_bound = <UnboundField(IntegerField, (), {‘widget’: None, ‘description’: ‘’, ‘defaul
IntegerQuestionForm. num_media_items = <UnboundField(IntegerField, (), {‘widget’: None, ‘description’: ‘’, ‘d
IntegerQuestionForm. question = <UnboundField(TextAreaField, (), {‘widget’: None, ‘description’: ‘’, ‘default’:
IntegerQuestionForm. upper_bound = <UnboundField(IntegerField, (), {‘widget’: None, ‘description’: ‘’, ‘defaul
class quizApp.forms.activities. QuestionForm ( *args, **kwargs)
Bases: quizApp.forms.activities.ActivityForm
Form that can be used for creating or updating questions.
class Meta
Bases: quizApp.forms.activities.Meta , wtforms_alchemy.Meta ,
wtforms_alchemy.Meta , wtforms.meta.DefaultMeta , object
QuestionForm. explanation = <UnboundField(TextAreaField, (), {‘widget’: None, ‘description’: ‘’, ‘default’: None
QuestionForm. num_media_items = <UnboundField(IntegerField, (), {‘widget’: None, ‘description’: ‘’, ‘default’: N
QuestionForm. question = <UnboundField(TextAreaField, (), {‘widget’: None, ‘description’: ‘’, ‘default’: None, ‘la
class quizApp.forms.activities. ScorecardForm ( *args, **kwargs)
Bases: quizApp.forms.activities.ActivityForm
Form that can be used for creating or updating scorecards.
class Meta
Bases: quizApp.forms.activities.Meta , wtforms_alchemy.Meta ,
wtforms_alchemy.Meta , wtforms.meta.DefaultMeta , object
ScorecardForm. prompt = <UnboundField(StringField, (), {‘widget’: None, ‘description’: ‘’, ‘default’: u’‘, ‘label’: u’
ScorecardForm. title = <UnboundField(StringField, (), {‘widget’: None, ‘description’: ‘’, ‘default’: u’‘, ‘label’: u’T
10 Chapter 1. Contents
QuizApp Documentation, Release 0.0.1
quizApp.forms.common module
1.7. API 11
QuizApp Documentation, Release 0.0.1
quizApp.forms.datasets module
12 Chapter 1. Contents
QuizApp Documentation, Release 0.0.1
quizApp.forms.experiments module
1.7. API 13
QuizApp Documentation, Release 0.0.1
14 Chapter 1. Contents
QuizApp Documentation, Release 0.0.1
1.7. API 15
QuizApp Documentation, Release 0.0.1
populate_from_result ( result)
result
class quizApp.forms.experiments. ScaleAnswerForm ( formdata=<class
flask_wtf.form._Auto>, obj=None,
prefix=’‘, csrf_context=None, se-
cret_key=None, csrf_enabled=None,
*args, **kwargs)
Bases: quizApp.forms.experiments.MultipleChoiceAnswerForm
Form for rendering a likert scale question.
choices = <UnboundField(LikertField, (), {‘validators’: [<wtforms.validators.DataRequired object>]})>
populate_from_activity ( activity)
class quizApp.forms.experiments. ScorecardAnswerForm ( formdata=<class
flask_wtf.form._Auto>, obj=None,
prefix=’‘, csrf_context=None,
secret_key=None,
csrf_enabled=None, *args,
**kwargs)
Bases: quizApp.forms.experiments.ActivityAnswerForm
Form to render when rendering a scorecard.
populate_from_activity ( activity)
populate_from_result ( result)
result
quizApp.forms.experiments. get_answer_form ( activity, data=None)
Given an activity, return the proper form that should be displayed to the participant.
Module contents
quizApp.views package
Submodules
quizApp.views.activities module
16 Chapter 1. Contents
QuizApp Documentation, Release 0.0.1
1.7. API 17
QuizApp Documentation, Release 0.0.1
quizApp.views.core module
This blueprint takes care of rendering static pages outside of the other blueprints.
quizApp.views.core. auto_register ( )
Convenience endpoint for using QuizApp embedded in another site.
When a logged in user accesses this endpoint, they will be redirected to the specified experiment.
When a user that is not logged in access this endpoint, an account will be created, they will be logged in, then
redirected to the specified experiment.
quizApp.views.core. getting_started ( *args, **kwargs)
Show some instructions for getting started with quizApp.
quizApp.views.core. home ( )
Display the homepage.
quizApp.views.core. post_login ( *args, **kwargs)
Once a user has logged in, redirect them based on their role.
quizApp.views.core. query_exists ( query)
Given a query, return True if it would return any rows, and False otherwise.
18 Chapter 1. Contents
QuizApp Documentation, Release 0.0.1
quizApp.views.datasets module
1.7. API 19
QuizApp Documentation, Release 0.0.1
quizApp.views.experiments module
Views that handle CRUD for experiments and rendering questions for participants.
class quizApp.views.experiments. ExperimentCollectionView
Bases: quizApp.views.common.ObjectCollectionView
View for a collection of Experiments.
create_form ( )
create_member ( create_form)
decorators = [<function wrapper>]
get_members ( )
methods = [’GET’, ‘POST’]
resolve_kwargs ( **kwargs)
template = ‘experiments/read_experiments.html’
class quizApp.views.experiments. ExperimentView
Bases: quizApp.views.common.ObjectView
View for a particular experiment.
collection_url ( **_)
decorators = [<function login_required>]
delete ( **kwargs)
get ( experiment)
View the landing page of an experiment, along with the ability to start.
methods = [’GET’, ‘PUT’, ‘DELETE’]
object_key = ‘experiment’
put ( **kwargs)
resolve_kwargs ( experiment_id)
template = ‘experiments/read_experiment.html’
update_form ( **_)
quizApp.views.experiments. confirm_done_assignment_set ( *args, **kwargs)
Show the user a page before finalizing their quiz answers.
20 Chapter 1. Contents
QuizApp Documentation, Release 0.0.1
1.7. API 21
QuizApp Documentation, Release 0.0.1
quizApp.views.helpers module
Module contents
Submodules
quizApp.config module
22 Chapter 1. Contents
QuizApp Documentation, Release 0.0.1
DEBUG = True
SECRET_KEY = u’—‘
SECURITY_PASSWORD_HASH = u’bcrypt’
SECURITY_PASSWORD_SALT = u’—‘
SECURITY_SEND_REGISTER_EMAIL = False
SQLALCHEMY_DATABASE_URI = u’mysql://quizapp:foobar@localhost/quizapp’
SQLALCHEMY_ECHO = True
class quizApp.config. Production
Bases: quizApp.config.Config
Configuration for production environments.
DEBUG = False
SECURITY_PASSWORD_HASH = u’bcrypt’
TESTING = False
class quizApp.config. Testing
Bases: quizApp.config.Config
Config used for testing.
DEBUG = True
SECRET_KEY = u’—‘
SECURITY_PASSWORD_SALT = u’—‘
SQLALCHEMY_DATABASE_URI = u’mysql://quizapp:foobar@localhost/quizapp_test’
TESTING = True
WTF_CSRF_ENABLED = False
quizApp.models module
1.7. API 23
QuizApp Documentation, Release 0.0.1
assignments
list of Assignment – What Assignments include this Activity
scorecard_settings
ScorecardSettings – Settings for scorecards after this Activity is done
include_in_scorecards
bool – Whether or not to show this Activity in scorecards
class Meta
Bases: future.types.newobject.newobject
Define what kind of Result we are looking for.
result_class
alias of Result
Activity. get_score ( result)
Get the participant’s score for this Activity.
Given a Result object, an Activity subclass should be able to “score” the result in some way, and return an
integer quantifying the Participant’s performance.
Activity. is_correct ( result)
Given a result, return True if the answer was correct or False otherwise.
If this activity does not have a concept of correct/incorrect, return None.
class quizApp.models. Assignment ( **kwargs)
Bases: quizApp.models.Base
For a given Activity, determine which MediaItems, if any, a particular Participant sees, as well as recording the
Participant’s answer, or if they skipped this assignment.
comment
string – An optional comment entered by the student.
choice_order
string – A JSON object in string form that represents the order of choices that this participant was presented
with when answering this question, e.g. {[1, 50, 9, 3]} where the numbers are the IDs of those choices.
time_to_submit
timedelta – Time from the question being rendered to the question being submitted.
media_items
list of MediaItem – What MediaItems should be shown
activity
Activity – Which Activity this Participant should see
assignment_set
AssignmentSet – Which AssignmentSet this Assignment belongs to
correct
Check if this assignment was answered correctly.
score
Get the score for this assignment.
This method simply passes result to the activity‘s get_score method and returns the result.
Note that if there is no activity this will raise an AttributeError.
24 Chapter 1. Contents
QuizApp Documentation, Release 0.0.1
validate_activity ( _, activity)
Make sure that the number of media items on the activity is the same as the number of media items this
assignment has.
validate_result ( _, result)
Make sure that this assignment has the correct type of result.
class quizApp.models. AssignmentSet ( **kwargs)
Bases: quizApp.models.Base
An AssignmentSet represents a sequence of Assignments within an Experiment. All Assignments in an Assign-
mentSet are done in order by the same Participant.
progress
int – Which Assignment the user is currently working on.
complete
bool – True if the user has finalized their responses, False otherwise
participant
Participant – Which Participant this refers to
experiment
Experiment – Which Experiment this refers to
assignments
list of Assignment – The assignments that this Participant should do in this Experiment
class Meta
Bases: future.types.newobject.newobject
Specify field order.
AssignmentSet. score
Return the cumulative score of all assignments in this AssignmentSet,
Currently this iterates through all assignments. Profiling will be required to see if this is too slow.
class quizApp.models. Base ( **kwargs)
Bases: flask_sqlalchemy.Model
Base class for all models.
All models have an identical id field.
id
int – A unique identifier.
import_dict ( **kwargs)
Populate this object using data imported from a spreadsheet or similar. This means that not all fields
will be passed into this function, however there are enough fields to populate all necessary fields. Due to
validators, some fields need to be populated before others. Subclasses of Base to which this applies are
expected to override this method and implement their import correctly.
save ( commit=True)
Save this model to the database.
If commit is True, then the session will be comitted as well.
class quizApp.models. Choice ( **kwargs)
Bases: quizApp.models.Base
A Choice is a string that is a possible answer for a Question.
1.7. API 25
QuizApp Documentation, Release 0.0.1
choice
string – The choice as a string.
label
string – The label for this choice (1,2,3,a,b,c etc)
correct
bool – “True” if this choice is correct, “False” otherwise
question
Question – Which Question owns this Choice
points
int – How many points the Participant gets for picking this choice
class quizApp.models. Dataset ( **kwargs)
Bases: quizApp.models.Base
A Dataset represents some data that MediaItems are based on.
name
string – The name of this dataset.
info
string – Some information about this dataset
media_items
list of MediaItem – Which MediaItems this Dataset owns
questions
list of Questions – Which Questions reference this Dataset
class quizApp.models. Experiment ( *args, **kwargs)
Bases: quizApp.models.Base
An Experiment contains a list of Activities.
name
str – The name of this experiment
created
datetime – When this experiment was created
start
datetime – When this experiment becomes accessible for answers
stop
datetime – When this experiment stops accepting answers
assignment_sets
list of ParticiapntExperiment – List of AssignmentSets that are associated with this Experiment
disable_previous
bool – If True, don’t allow Participants to view and modify previous activities.
show_timers
bool – If True, display a timer on each activity expressing how long the user has been viewing this activity.
show_scores
bool – If True, show the participant a cumulative score on every activity.
scorecard_settings
ScorecardSettings – A ScorecardSettings instance that determines how scorecards will be rendered in this
Experiment.
26 Chapter 1. Contents
QuizApp Documentation, Release 0.0.1
1.7. API 27
QuizApp Documentation, Release 0.0.1
bounded_below
bool – If True, enforce a lower bound
lower_bound
int – The minimum possible answer.
bounded_above
bool – If True, enforce an upper bound
upper_bound
int – The maximum possible answer.
class Meta
Bases: future.types.newobject.newobject
Specify the result class.
result_class
alias of IntegerQuestionResult
IntegerQuestion. get_score ( result)
If the choice is the answer, one point.
IntegerQuestion. validate_answer ( _, answer)
Ensure answer is within the bounds.
class quizApp.models. IntegerQuestionResult ( **kwargs)
Bases: quizApp.models.Result
The integer entered as an answer to an Integer Question.
integer
int – The answer entered to this question.
class quizApp.models. MediaItem ( **kwargs)
Bases: quizApp.models.Base
A MediaItem is any aid to be shown when displaying an assignment. It can be text, image, videos, sound,
whatever. Specific types should subclass this class and define their own fields needed for rendering.
name
str – Name for this Media Item
assignments
list of Assignment – Which Assignments display this MediaItem
dataset
Dataset – Which Dataset owns this MediaItem
class quizApp.models. MultiSelectQuestion ( *args, **kwargs)
Bases: quizApp.models.MultipleChoiceQuestion
A MultiSelectQuestion allows any number of Choices to be selected.
class Meta
Bases: future.types.newobject.newobject
Define what kind of Result we are looking for.
result_class
alias of MultiSelectQuestionResult
class quizApp.models. MultiSelectQuestionResult ( **kwargs)
Bases: quizApp.models.Result
28 Chapter 1. Contents
QuizApp Documentation, Release 0.0.1
1.7. API 29
QuizApp Documentation, Release 0.0.1
datasets
list of Dataset – Which Datasets this Question can pull MediaItems from. If this is empty, this Question
can use MediaItems from any Dataset.
class quizApp.models. Result ( **kwargs)
Bases: quizApp.models.Base
A Result is the outcome of a Participant completing an Activity.
Different Activities have different data that they generate, so this model does not actually contain any infor-
mation on the outcome of an Activity. That is something that child classes of this class must define in their
schemas.
On the Assignment level, the type of Activity will determine the type of Result.
assignment
Assignment – The Assignment that owns this Result.
class quizApp.models. Role ( **kwargs)
Bases: quizApp.models.Base , flask_security.core.RoleMixin
A Role describes what a User can and can’t do.
class quizApp.models. ScaleQuestion ( *args, **kwargs)
Bases: quizApp.models.SingleSelectQuestion
A ScaleQuestion is like a SingleSelectQuestion, but it displays its options horizontally. This is useful for
“strongly agree/disagree” sort of questions.
class quizApp.models. Scorecard ( *args, **kwargs)
Bases: quizApp.models.Activity
A Scorecard shows some kind of information about all previous activities.
title
str – The title of this scorecard
prompt
str – The prompt to show when asking for a comment
class Meta
Bases: future.types.newobject.newobject
Define what kind of Result we are looking for.
result_class
alias of ScorecardResult
class quizApp.models. ScorecardResult ( **kwargs)
Bases: quizApp.models.Result
Result to a Scorecard activity. This class just exists to implement __str__ since there is no action to be taken in
a scorecard.
class quizApp.models. ScorecardSettings ( **kwargs)
Bases: quizApp.models.Base
A ScorecardSettings object represents the configuration of some kind of scorecard.
Scorecards may be shown after each Activity or after each Experiment (or both). Since the configuration of the
two scorecards is identical, it has been refactored to this class.
display_scorecard
bool – Whether or not to display this scorecard at all.
30 Chapter 1. Contents
QuizApp Documentation, Release 0.0.1
display_score
bool – Whether or not to display a tally of points.
display_time
bool – Whether or not to display a count of how much time elapsed.
display_correctness
bool – Whether or not to display correctness grades.
display_feedback
bool – Whether or not to display feedback on responses.
class quizApp.models. SingleSelectQuestion ( *args, **kwargs)
Bases: quizApp.models.MultipleChoiceQuestion
A SingleSelectQuestion allows only one Choice to be selected.
class quizApp.models. Text ( **kwargs)
Bases: quizApp.models.MediaItem
Text is simply a piece of text that can be used as a MediaItem.
text
str – The text of this media item.
class quizApp.models. User ( **kwargs)
Bases: quizApp.models.Base , flask_security.core.UserMixin
A User is used for authentication.
name
string – The username of this user.
password
string – This user’s password.
authenticated
bool – True if this user is authenticated.
type
string – The type of this user, e.g. experimenter, participant
has_any_role ( roles)
Given a list of Roles, return True if the user has at least one of them.
Module contents
1.7. API 31
QuizApp Documentation, Release 0.0.1
32 Chapter 1. Contents
CHAPTER 2
• genindex
• modindex
• search
33
QuizApp Documentation, Release 0.0.1
q
quizApp, 31
quizApp.config, 22
quizApp.forms, 16
quizApp.forms.activities, 9
quizApp.forms.common, 11
quizApp.forms.datasets, 12
quizApp.forms.experiments, 13
quizApp.models, 23
quizApp.views, 22
quizApp.views.activities, 16
quizApp.views.core, 18
quizApp.views.datasets, 19
quizApp.views.experiments, 20
quizApp.views.helpers, 22
35
QuizApp Documentation, Release 0.0.1
A C
Activity (class in quizApp.models), 23 category (quizApp.forms.activities.ActivityForm at-
activity (quizApp.models.Assignment attribute), 24 tribute), 9
Activity.Meta (class in quizApp.models), 24 category (quizApp.models.Activity attribute), 23
ActivityAnswerForm (class inChoice (class in quizApp.models), 25
quizApp.forms.experiments), 13 choice (quizApp.forms.activities.ChoiceForm attribute),
ActivityCollectionView (class in 9
quizApp.views.activities), 16 choice (quizApp.models.Choice attribute), 25
ActivityForm (class in quizApp.forms.activities), 9 choice_order (quizApp.models.Assignment attribute), 24
ActivityForm.Meta (class in quizApp.forms.activities), 9 ChoiceAnswerFormMixin (class in
ActivityView (class in quizApp.views.activities), 17 quizApp.forms.experiments), 14
answer (quizApp.forms.activities.IntegerQuestionForm ChoiceCollectionView (class in
attribute), 10 quizApp.views.activities), 17
answer (quizApp.models.IntegerQuestion attribute), 27 ChoiceForm (class in quizApp.forms.activities), 9
apply_default_user_role() (in module quizApp), 31 ChoiceForm.Meta (class in quizApp.forms.activities), 9
Assignment (class in quizApp.models), 24 choices (quizApp.forms.experiments.MultipleChoiceAnswerForm
assignment (quizApp.models.Result attribute), 30 attribute), 15
assignment_set (quizApp.models.Assignment attribute), choices (quizApp.forms.experiments.MultiSelectAnswerForm
24 attribute), 15
assignment_sets (quizApp.models.Experiment attribute), choices (quizApp.forms.experiments.ScaleAnswerForm
26 attribute), 16
assignment_sets (quizApp.models.Participant attribute), choices (quizApp.models.Question attribute), 29
29 ChoiceView (class in quizApp.views.activities), 17
assignments (quizApp.models.Activity attribute), 23 collection_url() (quizApp.views.activities.ActivityView
assignments (quizApp.models.AssignmentSet attribute), method), 17
25 collection_url() (quizApp.views.activities.ChoiceView
assignments (quizApp.models.MediaItem attribute), 28 method), 17
AssignmentSet (class in quizApp.models), 25 collection_url() (quizApp.views.datasets.DatasetView
AssignmentSet.Meta (class in quizApp.models), 25 method), 19
authenticated (quizApp.models.User attribute), 31 collection_url() (quizApp.views.datasets.MediaItemView
auto_register() (in module quizApp.views.core), 18 method), 19
collection_url() (quizApp.views.experiments.ExperimentView
B method), 20
Base (class in quizApp.models), 25 comment (quizApp.forms.experiments.ActivityAnswerForm
blurb (quizApp.forms.experiments.CreateExperimentForm attribute), 13
attribute), 14 comment (quizApp.models.Assignment attribute), 24
bounded_above (quizApp.models.IntegerQuestion complete (quizApp.models.AssignmentSet attribute), 25
attribute), 28 Config (class in quizApp.config), 22
bounded_below (quizApp.models.IntegerQuestion confirm_done_assignment_set() (in module
attribute), 27 quizApp.views.experiments), 20
37
QuizApp Documentation, Release 0.0.1
38 Index
QuizApp Documentation, Release 0.0.1
Index 39
QuizApp Documentation, Release 0.0.1
40 Index
QuizApp Documentation, Release 0.0.1
Index 41
QuizApp Documentation, Release 0.0.1
resolve_kwargs() (quizApp.views.experiments.ExperimentCollectionView
ScorecardForm.Meta (class in quizApp.forms.activities),
method), 20 10
resolve_kwargs() (quizApp.views.experiments.ExperimentViewScorecardResult (class in quizApp.models), 30
method), 20 ScorecardSettings (class in quizApp.models), 30
Result (class in quizApp.models), 30 ScorecardSettingsForm (class in
result (quizApp.forms.experiments.ActivityAnswerForm quizApp.forms.common), 12
attribute), 14 ScorecardSettingsForm.Meta (class in
result (quizApp.forms.experiments.FreeAnswerForm at- quizApp.forms.common), 12
tribute), 15 SECRET_KEY (quizApp.config.Development attribute),
result (quizApp.forms.experiments.IntegerAnswerForm 23
attribute), 15 SECRET_KEY (quizApp.config.Testing attribute), 23
result (quizApp.forms.experiments.MultipleChoiceAnswerFormSECURITY_CHANGEABLE (quizApp.config.Config
attribute), 16 attribute), 22
result (quizApp.forms.experiments.MultiSelectAnswerFormSECURITY_PASSWORD_HASH
attribute), 15 (quizApp.config.Development attribute),
result (quizApp.forms.experiments.ScorecardAnswerForm 23
attribute), 16 SECURITY_PASSWORD_HASH
result_class (quizApp.models.Activity.Meta attribute), 24 (quizApp.config.Production attribute), 23
result_class (quizApp.models.FreeAnswerQuestion.Meta SECURITY_PASSWORD_SALT
attribute), 27 (quizApp.config.Development attribute),
result_class (quizApp.models.IntegerQuestion.Meta at- 23
tribute), 28 SECURITY_PASSWORD_SALT
result_class (quizApp.models.MultipleChoiceQuestion.Meta (quizApp.config.Testing attribute), 23
attribute), 29 SECURITY_POST_LOGIN_VIEW
result_class (quizApp.models.MultiSelectQuestion.Meta (quizApp.config.Config attribute), 22
attribute), 28 SECURITY_REGISTERABLE (quizApp.config.Config
result_class (quizApp.models.Scorecard.Meta attribute), attribute), 22
30 SECURITY_SEND_REGISTER_EMAIL
results_experiment() (in module (quizApp.config.Development attribute),
quizApp.views.experiments), 21 23
Role (class in quizApp.models), 30 settings_activity() (in module quizApp.views.activities),
running (quizApp.models.Experiment attribute), 27 18
settings_dataset() (in module quizApp.views.datasets), 20
S settings_experiment() (in module
save() (quizApp.models.Base method), 25 quizApp.views.experiments), 21
ScaleAnswerForm (class in quizApp.forms.experiments), settings_mc_question() (in module
16 quizApp.views.activities), 18
ScaleQuestion (class in quizApp.models), 30 settings_media_item() (in module
score (quizApp.models.Assignment attribute), 24 quizApp.views.datasets), 20
score (quizApp.models.AssignmentSet attribute), 25 settings_question() (in module quizApp.views.activities),
Scorecard (class in quizApp.models), 30 18
Scorecard.Meta (class in quizApp.models), 30 settings_scorecard() (in module
scorecard_settings (quizApp.forms.activities.ActivityForm quizApp.views.activities), 18
attribute), 9 show_scores (quizApp.forms.experiments.CreateExperimentForm
scorecard_settings (quizApp.forms.experiments.CreateExperimentForm attribute), 14
attribute), 14 show_scores (quizApp.models.Experiment attribute), 26
scorecard_settings (quizApp.models.Activity attribute), show_timers (quizApp.forms.experiments.CreateExperimentForm
24 attribute), 14
scorecard_settings (quizApp.models.Experiment at- show_timers (quizApp.models.Experiment attribute), 26
tribute), 26 SingleSelectQuestion (class in quizApp.models), 31
ScorecardAnswerForm (class in SQLALCHEMY_DATABASE_URI
quizApp.forms.experiments), 16 (quizApp.config.Development attribute),
ScorecardForm (class in quizApp.forms.activities), 10 23
42 Index
QuizApp Documentation, Release 0.0.1
T V
template (quizApp.views.activities.ActivityCollectionView validate() (quizApp.forms.experiments.CreateExperimentForm
attribute), 17 method), 14
template (quizApp.views.activities.ChoiceCollectionView validate_activity() (quizApp.models.Assignment
attribute), 17 method), 24
template (quizApp.views.datasets.DatasetCollectionView validate_answer() (quizApp.models.IntegerQuestion
attribute), 19 method), 28
template (quizApp.views.datasets.MediaItemCollectionViewvalidate_assignment() (in module
attribute), 19 quizApp.views.experiments), 21
template (quizApp.views.datasets.MediaItemView validate_assignment_set() (in module
attribute), 20 quizApp.views.experiments), 21
template (quizApp.views.experiments.ExperimentCollectionView
validate_choice() (quizApp.models.MultipleChoiceQuestionResult
attribute), 20 method), 29
template (quizApp.views.experiments.ExperimentView validate_choice() (quizApp.models.MultiSelectQuestionResult
attribute), 20 method), 29
Testing (class in quizApp.config), 23 validate_form_or_error() (in module
TESTING (quizApp.config.Config attribute), 22 quizApp.views.helpers), 22
TESTING (quizApp.config.Production attribute), 23 validate_model_id() (in module quizApp.views.helpers),
TESTING (quizApp.config.Testing attribute), 23 22
Text (class in quizApp.models), 31 validate_result() (quizApp.models.Assignment method),
text (quizApp.forms.datasets.TextForm attribute), 13 25
Index 43
QuizApp Documentation, Release 0.0.1
W
widget (quizApp.forms.common.MultiCheckboxField at-
tribute), 11
WTF_CSRF_ENABLED (quizApp.config.Config at-
tribute), 22
WTF_CSRF_ENABLED (quizApp.config.Testing
attribute), 23
WTF_CSRF_METHODS (quizApp.config.Config
attribute), 22
44 Index