app/soc/models/question.py
author Sverre Rabbelier <srabbelier@gmail.com>
Thu, 23 Oct 2008 05:21:41 +0000
changeset 410 2af7f84f4fc7
parent 351 b37fc4c1e189
child 512 aae25d2b4464
permissions -rw-r--r--
Moved all key_name related things to the logic modules Patch by: Sverre Rabbelier Reviewed by: to-be-reviewed
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
339
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     2
#
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     4
#
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     8
# 
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    10
# 
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    15
# limitations under the License.
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    16
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    17
"""This module contains the Question Model."""
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    18
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    19
__authors__ = [
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    20
  '"Todd Larsen" <tlarsen@google.com>',
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    21
]
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    22
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    23
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    24
from google.appengine.ext import db
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    25
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    26
import soc.models.work
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    27
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    28
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    29
class Question(soc.models.work.Work):
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    30
  """Model of a Question, which is a specialized form of Work.
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    31
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    32
  Specific types of Questions are actually implemented in subclasses.
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    33
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    34
  The specific way that the properties and relations inherited from
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    35
  Work are used with a Question are described below.
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    36
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    37
    work.title:  the title of the Question, used for finding the
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    38
      Question in a list of Questions
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    39
342
72482d8e5b34 Remove the proposed WorksAuthors many:many relation and promote the "founder"
Todd Larsen <tlarsen@google.com>
parents: 339
diff changeset
    40
    work.author:  the author of the Work referred to by this relation
72482d8e5b34 Remove the proposed WorksAuthors many:many relation and promote the "founder"
Todd Larsen <tlarsen@google.com>
parents: 339
diff changeset
    41
      is the original author of the actual Question, regardless of
72482d8e5b34 Remove the proposed WorksAuthors many:many relation and promote the "founder"
Todd Larsen <tlarsen@google.com>
parents: 339
diff changeset
    42
      which Quizzes might incorporate the Question
339
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    43
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    44
    work.reviews:  even Questions can be "reviewed" (possibly commented
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    45
      on during creation or annotated once put into use).
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    46
342
72482d8e5b34 Remove the proposed WorksAuthors many:many relation and promote the "founder"
Todd Larsen <tlarsen@google.com>
parents: 339
diff changeset
    47
    work.partial_path:  used to scope (and, when combined with
339
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    48
      work.link_name, uniquely identify) a Question in the same way the
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    49
      property are used with Documents, etc.
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    50
342
72482d8e5b34 Remove the proposed WorksAuthors many:many relation and promote the "founder"
Todd Larsen <tlarsen@google.com>
parents: 339
diff changeset
    51
    work.link_name:  used to identify (and, when combined with
339
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    52
      work.partial_path, *uniquely* identify) a Question in the same way
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    53
      these properties are used with Documents, etc.
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    54
      
351
b37fc4c1e189 Eliminate the Work.abstract property and move the Document.content property
Todd Larsen <tlarsen@google.com>
parents: 342
diff changeset
    55
    work.content:  the Question text, asked to the respondent
b37fc4c1e189 Eliminate the Work.abstract property and move the Document.content property
Todd Larsen <tlarsen@google.com>
parents: 342
diff changeset
    56
339
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    57
  In addition to any explicit ReferenceProperties in the Question Model
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    58
  and those inherited as described above, a Question entity participates
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    59
  in these relationships:
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    60
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    61
    answers)  a 1:many relationship, where each Question has many different
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    62
      Answers associated with it as parts of Responses to Quizzes.  This is
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    63
      implemented as the 'answers' back-reference Query of the Answer model
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    64
      'question' reference.  It is currently unclear how useful this
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    65
      back-reference will be, since the same Question could be used in
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    66
      multiple different Quizzes. Given this, 'answers' currently only
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    67
      exists for completeness.
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    68
      
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    69
    quizzes)  a many:many relationship between Questions and the Quizzes
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    70
      that collect them into a set.  This relation is not explicitly
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    71
      implemented, but can be obtained via a query something like:
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    72
      
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    73
        quizzes_with_a_question = db.GqlQuery(
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    74
            "SELECT * FROM Quiz where questions = :1",
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    75
            a_question.key())
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    76
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    77
      Such queries are probably only needed when a Question might be
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    78
      altered, in order to find which Quizzes will be affected.
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    79
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    80
  The properties in this Model do not have verbose_name or help_text,
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    81
  because the dynamic nature of the forms required to create, edit, and
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    82
  use entities of this Model make them pretty useless.
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    83
  
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    84
  ######################################################################
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    85
  # TODO(tlarsen): the following verbose comments can be removed later,
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    86
    when these ideas are implemented in the views and controllers; they
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    87
    are here now so that the concepts will not be lost before that time.
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    88
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    89
  The recommended use for the combination of work.partial_path and
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    90
  work.link_name is to keep the *same* link_name when copying and
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    91
  modifying an existing Question for a new Program (or instance of a
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    92
  Group that is per-Program), while changing the work.partial_path to
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    93
  represent the Program and Group "ownership" of the Question.  For
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    94
  example, if a Question asking about prior GSoC participation needed
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    95
  to have an additional choice (see the choice_ids and choices properties
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    96
  below), it is desirable to keep the same work.link_name (and also
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    97
  simply append new choice_ids and choices to keep the old answer values
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    98
  compatible).  An existing Question in the above example might be identified
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
    99
  as something like:
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   100
    Question:google/gsoc2009/gsoc_past_participation
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   101
    <type>:<Sponsor>/<Program>/<link_name> 
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   102
  To make it possible to query for gsoc_past_participation answers regardless
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   103
  of the Program, the next year, new values are added to choice_ids and
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   104
  choices in a new Question copied from the one above, which would then
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   105
  be named something (still unique) like:
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   106
    Question:google/gsoc2010/gsoc_past_participation
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   107
  Care just needs to be taken to keep the existing choice_ids and choices
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   108
  compatible.
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   109
  
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   110
  Other interesting possibilities also exist, such as asking about GSoC
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   111
  participation of the GHOP participants (some GHOP high school students
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   112
  have actually previously been GSoC mentors, for example).  To produce
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   113
  unique statistics for GHOP that could also be aggregated overall in
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   114
  combination with GSoC, the gsoc_past_participation Question would be
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   115
  duplicated (unaltered) to something like:
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   116
    Question:google/ghop2009/gsoc_past_participation
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   117
  To get the combined results, query on a link_name of
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   118
  gsoc_past_participation.  For more targeted results, include the
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   119
  partial_path to make the query more specific.
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   120
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   121
  Question creation to permit use cases like the one above is going to
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   122
  be a bit of an "advanced" skill, possibly.  "Doing it wrong" the first
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   123
  time a Question is created will make it difficult to implement stuff
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   124
  like multiple-choice Questions that "grow" new choices year-over-year.
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   125
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   126
  A dynamic form is most definitely going to be needed to implement the
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   127
  Question creation and editing for multiple-choice questions.
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   128
  """
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   129
  #: db.ListProperty of short, plain-text, "link_name-like" strings
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   130
  #: representing the "encoded" answer choices (must be strings compatible
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   131
  #: with being query arguments and being used in HTML controls and POST
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   132
  #: responses).
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   133
  #:
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   134
  #: If empty (None or an empty list), it is assumed that this Question
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   135
  #: is *not* a multiple choice question.  In that case, the UI should
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   136
  #: display the Question as a textarea in forms and accept any plain-text.
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   137
  #:
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   138
  #: If non-empty, max_answers helps determine how the UI should display
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   139
  #: the Question.  Also, controller logic needs to validate if the
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   140
  #: strings in the 'answers' property of the Answer entity come only
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   141
  #: from this list.
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   142
  #:
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   143
  #: Once Answers to this Question have been stored in the Datastore,
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   144
  #: choice_ids and choices should *not* be modified.  An existing
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   145
  #: Question can be duplicated and then modified (but, it will be a
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   146
  #: different question as a result).
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   147
  choice_ids = db.ListProperty(item_type=str)
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   148
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   149
  #: db.ListProperty of human-readable choice strings, in the same order
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   150
  #: as, and corresponding to, the "encoded" choices in the choice_ids
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   151
  #: db.ListProperty. 
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   152
  choices = db.ListProperty(item_type=str)
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   153
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   154
  #: db.IntegerProperty indicating the maximum number of answer values
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   155
  #: permitted for this question.  If 'choices' does not contain a list of
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   156
  #: choice strings, this value is ignored (but should still only be 1).
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   157
  #:
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   158
  #: If there are 'choices' and this value is 1, the UI should render the
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   159
  #: Question in forms as a single-choice control ("radio buttons").
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   160
  #:
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   161
  #: If there are 'choices' and this value is greater than 1, the UI should
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   162
  #: render the question as a list of check-boxes.
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   163
  #:
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   164
  #: max_answers greater than 1 combined with choices enables Questions
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   165
  #: like, for example, "...select the three most important...".
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   166
  max_answers = db.IntegerProperty(default=1)
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   167
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   168
  #: field storing whether the Answer to a Question is optional
b9be44e09530 Define the Models for implementing Quizzes (collections of Questions) and their
Todd Larsen <tlarsen@google.com>
parents:
diff changeset
   169
  is_optional = db.BooleanProperty(default=False)