Skip to content
papajohn edited this page Sep 29, 2014 · 3 revisions

An example of how to grab data from the server if your @berkeley.edu account has staff access to a class.

Assume, e.g., that you want all submissions for a list of email accounts from your section.

First, download a copy of ok and place it along with your analysis script. You can authenticate with

import sys
import zipimport

sys.path.insert(0, 'ok')
from ok import authenticate
TOKEN = authenticate()

Next, you need to decide which fields to keep from the data you request. You can specify a dictionary to do so. For example, the FIELDS dictionary below specifies fields from a submission and its subfields.

FIELDS = {'created':'true',
          'id':'true',
          'submitter': {'id':'true'},
          'messages': 'true',
          'assignment': {'name':'proj1'}}

You can see the fields of a model in model.py

https://github.com/Cal-CS-61A-Staff/ok/blob/master/server/app/models.py