def runGrader(settingsFile="settings.json", submissionFile="submission.s", outputFile="output.txt", concatFile="concat.s", autograderOutput="graderResults.txt", ShowAll=False, printResults=True, IO=None): try: _ShowAll = sys.argv[1] except: _ShowAll = False # overrides json "show" and shows the StudentOutputs of every test _ShowAll = _ShowAll or ShowAll if IO is None: io = settings(settingsFile) else: io = IO runMips = concat(IO=io, sfile=submissionFile, concatFile=concatFile) autograder(IO=io, _ShowAll=_ShowAll, runMips=runMips, outputDest=outputFile, concatFile=concatFile, autograderOutput=autograderOutput, printResults=printResults)
def test3(self): self.assertEqual( autograder.autograder({ "Homework": 0, "Prelim 1": 0, "Prelim 2": 0, "Final": 0, "Projects": 0, "Iclicker": 14 }), 14)
def test2(self): self.assertEqual( autograder.autograder({ "Homework": 0, "Prelim 1": 80, "Prelim 2": 90, "Final": 100, "Projects": 400, "Iclicker": 50 }), 720)
def test1(self): self.assertEqual( autograder.autograder({ "Homework": 50, "Prelim 1": 100, "Prelim 2": 100, "Final": 200, "Projects": 500, "Iclicker": 50 }), 1000)
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." # 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 and, if necessary, repeat step (1a) in **cs105_lab0.** # MAGIC # MAGIC <img src="http://spark-mooc.github.io/web-assets/images/autograder_LibraryError.png" alt="Drawing" style="width: 600px;"/> # COMMAND ---------- from autograder import autograder signup = autograder() try: print "Your private token is " + private_token except NameError: print signup.signup(username) # COMMAND ---------- # MAGIC %md # MAGIC #### ** Part 2: 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 and paste it into the cell at the beginning of the notebook. Make sure you remove the comment character (#) before *private_token* and you execute the cell using SHIFT-ENTER.
dirs = [name for name in os.listdir(subdirName) if os.path.isdir(os.path.join(subdirName, name))] dirs.sort() os.chdir(subdirName) if len(sys.argv) > 1: dirs = sys.argv[1:] # For each subdirectory (i.e., student) for thisDir in dirs: # Skip submissions that do not need regrading. All AUTOGRADE.txt files should be deleted whenever the autograder tests are changed to ensure that the new tests are applied to any already-autograded. if os.path.exists(os.path.join(thisDir, "AUTOGRADE.txt")): print("SKIPPING %s because it has already been autograded." % thisDir); continue # Set up the autograder ag = autograder.autograder("AUTOGRADE.txt", thisDir) # Verify that the files are there that we are expecting and look for unexpected files. ag.expect_only_files(["*.cpp", "*.h", "AUTOGRADE*.txt", "AUTOGRADE.json"], 1) ag.find_unexpected_subdirectories([], 1) ag.expect_file_one_of(["*.cpp"], 1) exe=[ 'compound_interest' ] # a list of executables we are expecting # Delete any executables the student might have submitted---we will compile them ourselves. for f in exe: ag.delete(f) # run 'make' in the students directory ag.run_expectExitCode(['VsDevCmd.bat'], expectExitCode=0, deductWrongExit=5, timeout=30) ag.expect_file_all_of(exe, 5) # check that exe got created # Figure out if all executables are there.
# Replace <FILL_IN> with your email address in quotes (e.g., "*****@*****.**") 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
if not os.path.exists(subdir): print("Directory doesn't exist. Exiting.") exit(1) # Get a list of subdirectories (each student submission will be in its own subdirectory) dirs = [ name for name in os.listdir(subdir) if os.path.isdir(os.path.join(subdir, name)) ] dirs.sort() os.chdir(subdir) # For each subdirectory (i.e., student) for thisDir in dirs: # Set up the autograder ag = autograder.autograder("AUTOGRADE.txt", thisDir) # Verify that the files are there that we are expecting and look for unexpected files. ag.expect_only_files([ "makefile", "Makefile", "*.c", "*.h", "README", "README.txt", "AUTOGRADE*.txt" ]) ag.find_unexpected_subdirectories([]) ag.expect_file_one_of(["*.c", "*.C"], 1) ag.expect_file_one_of(["makefile", "Makefile"], 5) exe = ['mtusort'] # a list of executables we are expecting # Delete any executables the student might have submitted---we will compile them ourselves. for f in exe: ag.delete(f) # run 'make' in the students directory