quizApp package¶
Subpackages¶
Submodules¶
quizApp.config module¶
Configurations for the project. These are loaded in app.py.
-
class
quizApp.config.Config[source]¶ Bases:
future.types.newobject.newobjectGlobal default config.
-
DEBUG= False¶
-
EXPERIMENTS_PLACEHOLDER_GRAPH= u'missing.png'¶
-
GRAPH_DIRECTORY= u'graphs'¶
-
SECURITY_CHANGEABLE= True¶
-
SECURITY_POST_LOGIN_VIEW= u'core.post_login'¶
-
SECURITY_REGISTERABLE= True¶
-
SQLALCHEMY_TRACK_MODIFICATIONS= False¶
-
TESTING= False¶
-
WTF_CSRF_ENABLED= True¶
-
WTF_CSRF_METHODS= [u'POST', u'PUT', u'PATCH', u'DELETE']¶
-
-
class
quizApp.config.Development[source]¶ Bases:
quizApp.config.ConfigConfiguration for development environments.
-
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¶
-
quizApp.models module¶
Models for the quizApp.
-
class
quizApp.models.Activity(*args, **kwargs)[source]¶ Bases:
quizApp.models.BaseAn Activity is essentially a screen that a User sees while doing an Experiment. It may be an instructional screen or show a Question, or do something else.
This class allows us to use Inheritance to easily have a variety of Activities in an Experiment, since we have a M2M between Experiment and Activity, while a specific Activity may actually be a Question thanks to SQLAlchemy’s support for polymorphism.
-
type¶ string – Discriminator column that determines what kind of Activity this is.
-
needs_comment¶ bool – True if the participant should be asked why they picked what they did after they answer the question.
-
category¶ string – A description of this assignment’s category, for the users’ convenience.
-
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[source]¶ Bases:
future.types.newobject.newobjectDefine what kind of Result we are looking for.
-
-
class
quizApp.models.Assignment(**kwargs)[source]¶ Bases:
quizApp.models.BaseFor 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.
-
-
class
quizApp.models.AssignmentSet(**kwargs)[source]¶ Bases:
quizApp.models.BaseAn AssignmentSet represents a sequence of Assignments within an Experiment. All Assignments in an AssignmentSet 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
-
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)[source]¶ Bases:
flask_sqlalchemy.ModelBase class for all models.
All models have an identical id field.
-
id¶ int – A unique identifier.
-
import_dict(**kwargs)[source]¶ 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.
-
-
class
quizApp.models.Choice(**kwargs)[source]¶ Bases:
quizApp.models.BaseA Choice is a string that is a possible answer for a Question.
-
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)[source]¶ Bases:
quizApp.models.BaseA 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)[source]¶ Bases:
quizApp.models.BaseAn 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.
If the
display_scorecardfield isFalse, then no scorecards will be displayed.If the
display_scorecardfield isTrue, then scorecards will be displayed after Activities whose ownScorecardSettingsobjects specify that scorecards should be shown. They will be rendered according to theScorecardSettingsof that Activity.In addition, a scorecard will be rendered after the experiment according to the Experiment’s
ScorecardSettings.
-
flash¶ bool – If True, flash the MediaItem for flash_duration milliseconds
-
flash_duration¶ int – How long to display the MediaItem in milliseconds
-
running¶ Returns True if this experiment is currently running, otherwise False.
-
-
class
quizApp.models.FreeAnswerQuestion(*args, **kwargs)[source]¶ Bases:
quizApp.models.QuestionA FreeAnswerQuestion allows a Participant to enter an arbitrary answer.
-
class
Meta[source]¶ Bases:
future.types.newobject.newobjectDefine what kind of Result we are looking for.
-
result_class¶ alias of
FreeAnswerQuestionResult
-
-
class
-
class
quizApp.models.FreeAnswerQuestionResult(**kwargs)[source]¶ Bases:
quizApp.models.ResultWhat a Participant entered into a text box.
-
class
quizApp.models.Graph(**kwargs)[source]¶ Bases:
quizApp.models.MediaItemA Graph is an image file located on the server that may be shown in conjunction with an Assignment.
-
path¶ str – Absolute path to this Graph on disk
-
directory¶ Return the directory this graph is located in.
If
pathis not empty, return the lowest directory specified bypath. Otherwise, return the designated graph directory.
-
-
class
quizApp.models.IntegerQuestion(*args, **kwargs)[source]¶ Bases:
quizApp.models.QuestionAsk participants to enter an integer, optionally bounded above/below.
All bounds are inclusive.
-
answer¶ int – The correct answer to this question
-
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[source]¶ Bases:
future.types.newobject.newobjectSpecify the result class.
-
result_class¶ alias of
IntegerQuestionResult
-
-
-
class
quizApp.models.IntegerQuestionResult(**kwargs)[source]¶ Bases:
quizApp.models.ResultThe integer entered as an answer to an Integer Question.
-
integer¶ int – The answer entered to this question.
-
-
class
quizApp.models.MediaItem(**kwargs)[source]¶ Bases:
quizApp.models.BaseA 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)[source]¶ Bases:
quizApp.models.MultipleChoiceQuestionA MultiSelectQuestion allows any number of Choices to be selected.
-
class
Meta[source]¶ Bases:
future.types.newobject.newobjectDefine what kind of Result we are looking for.
-
result_class¶ alias of
MultiSelectQuestionResult
-
-
class
-
class
quizApp.models.MultiSelectQuestionResult(**kwargs)[source]¶ Bases:
quizApp.models.ResultThe Choices that a Participant picked in a MultiSelectQuestion.
-
class
quizApp.models.MultipleChoiceQuestion(*args, **kwargs)[source]¶ Bases:
quizApp.models.QuestionA MultipleChoiceQuestion has one or more choices that are correct.
-
class
Meta[source]¶ Bases:
future.types.newobject.newobjectDefine what kind of Result we are looking for.
-
result_class¶ alias of
MultipleChoiceQuestionResult
-
-
class
-
class
quizApp.models.MultipleChoiceQuestionResult(**kwargs)[source]¶ Bases:
quizApp.models.ResultThe Choice that a Participant picked in a MultipleChoiceQuestion.
-
class
quizApp.models.Participant(**kwargs)[source]¶ Bases:
quizApp.models.UserA User that takes Experiments.
-
opt_in¶ bool – Has this user opted in to data collection?
-
foreign_id¶ str – If the user is coming from an external source (e.g. canvas, mechanical turk) it may be necessary to record their user ID on the other service (e.g. preventing multiple submission). This field holds the foreign ID of this user.
-
assignment_sets¶ list of AssignmentSets – List of AssignmentSets that this participant has
-
-
class
quizApp.models.Question(*args, **kwargs)[source]¶ Bases:
quizApp.models.ActivityA Question is related to one or more MediaItems and has one or more Choices, and is a part of one or more Experiments.
-
question¶ string – This question as a string
-
explantion¶ string – The explanation for why the correct answer is correct.
-
num_media_items¶ int – How many MediaItems should be shown when displaying this question
-
choices¶ list of Choice – What Choices this Question has
-
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)[source]¶ Bases:
quizApp.models.BaseA 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 information 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)[source]¶ Bases:
quizApp.models.Base,flask_security.core.RoleMixinA Role describes what a User can and can’t do.
-
class
quizApp.models.ScaleQuestion(*args, **kwargs)[source]¶ Bases:
quizApp.models.SingleSelectQuestionA 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)[source]¶ Bases:
quizApp.models.ActivityA 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[source]¶ Bases:
future.types.newobject.newobjectDefine what kind of Result we are looking for.
-
result_class¶ alias of
ScorecardResult
-
-
-
class
quizApp.models.ScorecardResult(**kwargs)[source]¶ Bases:
quizApp.models.ResultResult 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)[source]¶ Bases:
quizApp.models.BaseA 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.
-
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)[source]¶ Bases:
quizApp.models.MultipleChoiceQuestionA SingleSelectQuestion allows only one Choice to be selected.
-
class
quizApp.models.Text(**kwargs)[source]¶ Bases:
quizApp.models.MediaItemText 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)[source]¶ Bases:
quizApp.models.Base,flask_security.core.UserMixinA 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
-