Пример #1
0
 def init_participants(self):
     r, t1, t2, rs11, rs12, rs21, rs22 = self.init_response_sets()
     p111 = Participant.create(response_set=rs11)
     p112 = Participant.create(response_set=rs11)
     p121 = Participant.create(response_set=rs12)
     p122 = Participant.create(response_set=rs12)
     return r, t1, rs11, rs12, p111, p112, p121, p122
Пример #2
0
    def get(self):
        """Create a bunch of entities so we can practice quering."""
        self.write('hi')
        return
        # create a researcher out of the current user
        Researcher.create(users.get_current_user().user_id())

        # create some tasks for that researcher
        t1 = Task.create(name='t1', url_list=[
            'http://www.gentoo.org', 'http://www.xkcd.com'])
        t2 = Task.create(name='t2', url_list=[
            'http://www.abc.com', 'http://www.hampsterdance.com'])

        # create response sets in each task
        rs11 = ResponseSet.create(name='rs11', task=t1)
        rs12 = ResponseSet.create(name='rs12', task=t1)
        ResponseSet.create(name='rs21', task=t2)
        ResponseSet.create(name='rs22', task=t2)

        # create participants in one of the response sets
        Participant.create(response_set=rs11)
        Participant.create(response_set=rs12)
Пример #3
0
 def get(self, response_set_id):
     try:
         rs = ResponseSet.get_by_id(response_set_id)
     except (db.BadKeyError, db.KindError, InvalidIdError, EntityDNEError):
         self.write("Invalid response set id: {}.".format(response_set_id))
         return
     # create a participant to take this task
     p = Participant.create(response_set=rs)
     # construct the url that will send the participant to the task
     request_data = {'pid': str(p.id())}
     for key in self.request.arguments():
         request_data[key] = self.request.get(key)
     request_pairs = [k + '=' + v for k, v in request_data.items()]
     url = rs.task.url + '?' + '&'.join(request_pairs)
     # redirect the user to that url
     # (was getting some complaints from python about url being unicode...)
     self.redirect(str(url))
Пример #4
0
 def init(self):
     # create a dummy user
     self.testbed.setup_env(
         USER_EMAIL = '*****@*****.**',
         USER_ID = '123',
         USER_IS_ADMIN = '1',
         overwrite = True)
     user = users.get_current_user()
     # create a researcher from that user
     r = Researcher.create(user)
     # create a task for the participant
     t = Task.create(name='t1', url='http://www.a.com')
     # create a response set for the participant
     rs = ResponseSet.create(name='rs', task=t)
     # create a participant
     p = Participant.create(response_set=rs)
     # and get the datastore's copy
     p = db.get(p.key())
     return r, t, rs, p