quizApp.views package

Submodules

quizApp.views.activities module

Views for CRUD of activities.

In order to be as general as possible, each of the activity-specific views tests the kind of activity it is loading and then defers to a more specific function (for example, questions are read by read_question rather than read_activity itself).

class quizApp.views.activities.ActivityCollectionView[source]

Bases: quizApp.views.common.ObjectCollectionView

View for the activity collection.

create_form()[source]
create_member(create_form)[source]
decorators = [<function wrapper>]
get_members()[source]
methods = ['GET', 'POST']
resolve_kwargs

alias of dict

template = 'activities/read_activities.html'
class quizApp.views.activities.ActivityView[source]

Bases: quizApp.views.common.ObjectView

Views for a particular Activity.

collection_url(**_)[source]
get(activity)[source]
methods = ['GET', 'PUT', 'DELETE']
object_key = 'activity'
resolve_kwargs(activity_id)[source]
update_form(activity)[source]
class quizApp.views.activities.ChoiceCollectionView[source]

Bases: quizApp.views.common.ObjectCollectionView

Handle a collection of choices.

create_form()[source]
create_member(create_form, question)[source]
decorators = [<function wrapper>]
get_members = None
methods = ['POST']
resolve_kwargs(question_id)[source]
template = None
class quizApp.views.activities.ChoiceView[source]

Bases: quizApp.views.common.ObjectView

View for handling a singular Choice object.

collection_url(**_)[source]
methods = ['PUT', 'DELETE']
object_key = 'choice'
resolve_kwargs(question_id, choice_id)[source]
update_form(**_)[source]
quizApp.views.activities.create_question_dataset(*args, **kwargs)[source]

Associate this question with a dataset.

The request should contain the ID of the dataset to be associated.

quizApp.views.activities.delete_question_dataset(*args, **kwargs)[source]

Disassociate this question from a dataset.

quizApp.views.activities.render_activity(activity, *args, **kwargs)[source]

Given an activity, render the template that displays this activity and return it.

This function is the central place where activities are rendered.

Extra args/kwargs will be passed on to the specific rendering function for the type of activity.

quizApp.views.activities.render_question(question, disabled=False, assignment=None, render_explanation=True)[source]

Display a given question as it would appear to a participant.

Parameters:
  • question (Question) – The question to render
  • disabled (bool) – if True, disable the form controls
  • assignment (Assignment) – if given, use the assignment’s result and comment to populate fields prior to rendering
  • render_explanation (bool) – If True, render the explanation for this question
quizApp.views.activities.render_scorecard(scorecard, disabled=False, assignment_set=None, assignment=None, this_index=0)[source]

Render a scorecard. This is the central point of rendering for scorecards.

quizApp.views.activities.settings_activity(*args, **kwargs)[source]

Display settings for a particular activity.

quizApp.views.activities.settings_mc_question(question, template_kwargs)[source]

Display settings for the given question.

quizApp.views.activities.settings_question(question)[source]

Return a settings page for a question.

quizApp.views.activities.settings_scorecard(scorecard)[source]

Show settings for a scorecard.

quizApp.views.core module

This blueprint takes care of rendering static pages outside of the other blueprints.

quizApp.views.core.auto_register()[source]

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)[source]

Show some instructions for getting started with quizApp.

quizApp.views.core.home()[source]

Display the homepage.

quizApp.views.core.post_login(*args, **kwargs)[source]

Once a user has logged in, redirect them based on their role.

quizApp.views.core.query_exists(query)[source]

Given a query, return True if it would return any rows, and False otherwise.

quizApp.views.datasets module

Views for CRUD datasets.

class quizApp.views.datasets.DatasetCollectionView[source]

Bases: quizApp.views.common.ObjectCollectionView

View for managing a collection of Datasets.

create_form()[source]
create_member(create_form)[source]
decorators = [<function wrapper>]
get_members()[source]
methods = ['GET', 'POST']
resolve_kwargs

alias of dict

template = 'datasets/read_datasets.html'
class quizApp.views.datasets.DatasetView[source]

Bases: quizApp.views.common.ObjectView

View for handling a particular dataset.

collection_url(**kwargs)[source]
methods = ['PUT', 'DELETE']
object_key = 'dataset'
resolve_kwargs(dataset_id)[source]
update_form(**_)[source]
class quizApp.views.datasets.MediaItemCollectionView[source]

Bases: quizApp.views.common.ObjectCollectionView

Manage a collection of MediaItems.

create_form()[source]
create_member(create_form, dataset)[source]
decorators = [<function wrapper>]
get_members = None
methods = ['POST']
resolve_kwargs(dataset_id)[source]
template = None
class quizApp.views.datasets.MediaItemView[source]

Bases: quizApp.views.common.ObjectView

View for handling a particular media item

collection_url(dataset, **_)[source]
methods = ['DELETE', 'PUT', 'GET']
object_key = 'media_item'
resolve_kwargs(dataset_id, media_item_id)[source]
template = 'datasets/read_media_item.html'
update_form(media_item, **_)[source]
quizApp.views.datasets.settings_dataset(*args, **kwargs)[source]

View the configuration of a particular dataset.

quizApp.views.datasets.settings_media_item(*args, **kwargs)[source]

View the configuration of some media item.

Ultimately this view dispatches to another view for the specific type of media item.

quizApp.views.experiments module

Views that handle CRUD for experiments and rendering questions for participants.

class quizApp.views.experiments.ExperimentCollectionView[source]

Bases: quizApp.views.common.ObjectCollectionView

View for a collection of Experiments.

create_form()[source]
create_member(create_form)[source]
decorators = [<function wrapper>]
get_members()[source]
methods = ['GET', 'POST']
resolve_kwargs(**kwargs)[source]
template = 'experiments/read_experiments.html'
class quizApp.views.experiments.ExperimentView[source]

Bases: quizApp.views.common.ObjectView

View for a particular experiment.

collection_url(**_)[source]
decorators = [<function login_required>]
delete(**kwargs)[source]
get(experiment)[source]

View the landing page of an experiment, along with the ability to start.

methods = ['GET', 'PUT', 'DELETE']
object_key = 'experiment'
put(**kwargs)[source]
resolve_kwargs(experiment_id)[source]
template = 'experiments/read_experiment.html'
update_form(**_)[source]
quizApp.views.experiments.confirm_done_assignment_set(*args, **kwargs)[source]

Show the user a page before finalizing their quiz answers.

quizApp.views.experiments.done_assignment_set(*args, **kwargs)[source]

Show the user a screen indicating that they are finished.

quizApp.views.experiments.export_results_experiment(*args, **kwargs)[source]

Get a spreadsheet breaking down how participants did in this experiment.

quizApp.views.experiments.finalize_assignment_set(*args, **kwargs)[source]

Finalize the user’s answers for this experiment. They will no longer be able to edit them, but may view them.

quizApp.views.experiments.get_activity_column_index(activity, activity_column_mapping, activity_counter, headers)[source]

Find the column index for this occurrence of the given activity. This will update headers, counter, and mapping if necessary.

quizApp.views.experiments.get_next_assignment_url(assignment_set, current_index)[source]

Given an experiment, a assignment_set, and the current index, find the url of the next assignment in the sequence.

quizApp.views.experiments.get_question_stats(assignment, question_stats)[source]

Given an assignment of a question and a stats array, return statistics about this question in the array.

quizApp.views.experiments.get_results_workbook(experiment)[source]

Analyze the assignment sets in the experiment and return an excel workbook.

quizApp.views.experiments.populate_row_segment(sheet, row_index, initial_col, row)[source]

Populate the segment of row # row_index in sheet that starts at initial_col and contains the items in row.

quizApp.views.experiments.read_assignment(*args, **kwargs)[source]

Given an assignment ID, retrieve it from the database and display it to the user.

quizApp.views.experiments.read_mc_question(_, assignment)[source]

Read a multiple choice question, making sure to save the choice order.

quizApp.views.experiments.read_question(experiment, assignment)[source]

Common code for reading questions.

quizApp.views.experiments.read_scorecard(experiment, assignment)[source]

Read an assignment that is a scorecard.

quizApp.views.experiments.results_experiment(*args, **kwargs)[source]

Render some results.

quizApp.views.experiments.settings_experiment(*args, **kwargs)[source]

Give information on an experiment and its activities.

quizApp.views.experiments.update_assignment(experiment_id, assignment_set_id, assignment_id)[source]

Record a user’s answer to this assignment

quizApp.views.experiments.validate_assignment(experiment_id, assignment_set_id, assignment_id)[source]

Do everything validate_assignment_set does, but also check that the assignment exists and that it’s part of the given assignment set.

quizApp.views.experiments.validate_assignment_set(experiment_id, assignment_set_id)[source]

Check if this experiment and assignment set exist, if this assignment set is part of this experiment, and if the current user owns the assignment set.

quizApp.views.helpers module

Various functions that are useful in multiple views.

quizApp.views.helpers.get_first_assignment(experiment)[source]

Get the first assignment for this user in this experiment.

Note that this is not necessarily the same as the first assignment in an assignment set. This function will first call get_or_create_assignment_set in order to retrieve an assignment set. If there is no assignment set or it is empty, this function returns none.

If the set is complete, this function returns the first assignment in the set.

quizApp.views.helpers.get_or_create_assignment_set(experiment)[source]

Attempt to retrieve the AssignmentSet record for the current user in the given Experiment.

If no such record exists, grab a random AssignmentSet record in the experiment AssignmentSet pool, copy it to be the current user’s AssignmentSet record, and return that.

quizApp.views.helpers.validate_form_or_error(form)[source]

Validate this form or return errors in JSON format.

If the form is valid, None is returned.

quizApp.views.helpers.validate_model_id(model, model_id, code=404)[source]

Given a model and id, retrieve and return that model from the database or abort with the given code.

Module contents