-
Notifications
You must be signed in to change notification settings - Fork 313
/
cs120_autograder_register.py
103 lines (83 loc) · 4.4 KB
/
cs120_autograder_register.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# Databricks notebook source exported at Mon, 11 Jul 2016 16:37:17 UTC
# MAGIC %md
# MAGIC <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"> <img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-nd/4.0/88x31.png"/> </a> <br/> This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/4.0/"> Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License. </a>
# COMMAND ----------
# MAGIC %md
# MAGIC #![Spark Logo](http://spark-mooc.github.io/web-assets/images/ta_Spark-logo-small.png) + ![Python Logo](http://spark-mooc.github.io/web-assets/images/python-logo-master-v3-TM-flattened_small.png)
# MAGIC
# MAGIC # Registering for the Course Autograder
# MAGIC
# MAGIC This notebook registers you for the course autograder. You need to use the autograder to get a grade for each lab.
# MAGIC
# MAGIC **You will only need to use this notebook once.**
# MAGIC
# MAGIC This notebook will help you create an _autograder token_. You will use that token when you submit each lab for grading, but you'll submit each lab using the
# MAGIC [autograder notebook](https://raw.githubusercontent.com/spark-mooc/mooc-setup/master/cs120_autograder_simple.dbc).
# MAGIC
# MAGIC If you're interested in more details on the autograder, see the [Complete Autograder notebook](https://raw.githubusercontent.com/spark-mooc/mooc-setup/master/cs120_autograder_complete.dbc).
# MAGIC
# MAGIC ## NOTE TO CS105x STUDENTS
# MAGIC
# MAGIC If you took CS105, and you already have an autograder private token, **DO NOT REGISTER FOR ANOTHER ONE.** Re-use your private token from CS105x.
# COMMAND ----------
# MAGIC %md
# MAGIC ## Step 1: Register for the course autograder
# MAGIC
# MAGIC Enter your email address in the next cell. Your email address must be a valid email address.
# COMMAND ----------
# Replace <FILL_IN> with your email address in quotes (e.g., "tester@test.com")
username = <FILL_IN>
# COMMAND ----------
# MAGIC %md
# MAGIC Run the following cell. If you see an **ImportError**, you should verify that you added the `spark_mooc_meta` library to your cluster.
# MAGIC
# MAGIC <img src="http://spark-mooc.github.io/web-assets/images/autograder_LibraryError.png" alt="Drawing" style="width: 600px;"/>
# COMMAND ----------
# Verify that the username is set
from autograder import autograder
signup = autograder()
try:
print "Your username is " + username
except NameError:
assert False, "Your username is not set. Please check that you set your username in the previous cell and you exectuted the cell using SHIFT-ENTER."
try:
print "Your private token is: " + signup.signup(username)
except:
print "autograder signup failed. please detach the cluster and re-run the notebook"
# COMMAND ----------
# MAGIC %md
# MAGIC ## Step 2: Import the Autograder Notebook
# MAGIC
# MAGIC Import a copy of the autograder notebook:
# MAGIC
# MAGIC 1. Download [this file](https://raw.githubusercontent.com/spark-mooc/mooc-setup/master/cs120_autograder_simple.dbc). You'll get a file called `cs120_autograder_simple.dbc`.
# MAGIC 2. In your Databricks Community Edition account, go to your home folder, and right click on it. Select "Import", and import `cs120_autograder_simple.dbc`.
# COMMAND ----------
# MAGIC %md
# MAGIC ## Step 3: Save your private token
# MAGIC
# MAGIC You will receive an email from the course autograder with a private token. Here is a sample email.
# MAGIC
# MAGIC <img src="http://spark-mooc.github.io/web-assets/images/autograder_signup_samplemail.png" alt="Drawing" style="width: 600px;"/>
# MAGIC
# MAGIC Copy the private token to the clipboard. Then, go to the `cs120_autograder_simple` notebook you uploaded in Step 2, and look for a Python cell containing:
# MAGIC
# MAGIC ```
# MAGIC # private_token = <FILL_IN>
# MAGIC ```
# MAGIC
# MAGIC Uncomment the cell, so you get:
# MAGIC
# MAGIC ```
# MAGIC private_token = <FILL_IN>
# MAGIC ```
# MAGIC
# MAGIC and replace `<FILL IN>` with the private token you just copied to the clipboard. (Be sure to surround it with quotes.)
# MAGIC
# MAGIC <img src="http://spark-mooc.github.io/web-assets/images/autograder_private_token.png" alt="Drawing" />
# COMMAND ----------
# MAGIC %md
# MAGIC ## You're ready to go.
# MAGIC
# MAGIC You'll use the `cs120_autograder_simple` notebook throughout the course, to submit each of your lab notebooks for grading.
# COMMAND ----------