Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@web.authenticated
@check_xsrf
@check_notebook_dir
def put(self, grade_id):
try:
comment = self.gradebook.find_comment_by_id(grade_id)
except MissingEntry:
raise web.HTTPError(404)
data = self.get_json_body()
comment.manual_comment = data.get("manual_comment", None)
self.gradebook.db.commit()
self.write(json.dumps(comment.to_dict()))
class FlagSubmissionHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
@check_notebook_dir
def post(self, submission_id):
try:
submission = self.gradebook.find_submission_notebook_by_id(submission_id)
except MissingEntry:
raise web.HTTPError(404)
submission.flagged = not submission.flagged
self.gradebook.db.commit()
self.write(json.dumps(submission.to_dict()))
class AssignmentCollectionHandler(BaseApiHandler):
@web.authenticated
@check_notebook_dir
def get(self, assignment_id):
notebooks = self.api.get_notebooks(assignment_id)
self.write(json.dumps(notebooks))
class SubmissionCollectionHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
@check_notebook_dir
def get(self, assignment_id):
submissions = self.api.get_submissions(assignment_id)
self.write(json.dumps(submissions))
class SubmissionHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
@check_notebook_dir
def get(self, assignment_id, student_id):
submission = self.api.get_submission(assignment_id, student_id)
if submission is None:
raise web.HTTPError(404)
self.write(json.dumps(submission))
class SubmittedNotebookCollectionHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
@check_notebook_dir
def get(self, assignment_id, notebook_id):
submissions = self.api.get_notebook_submissions(assignment_id, notebook_id)
class GradeCollectionHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
@check_notebook_dir
def get(self):
submission_id = self.get_argument("submission_id")
try:
notebook = self.gradebook.find_submission_notebook_by_id(submission_id)
except MissingEntry:
raise web.HTTPError(404)
self.write(json.dumps([g.to_dict() for g in notebook.grades]))
class CommentCollectionHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
@check_notebook_dir
def get(self):
submission_id = self.get_argument("submission_id")
try:
notebook = self.gradebook.find_submission_notebook_by_id(submission_id)
except MissingEntry:
raise web.HTTPError(404)
self.write(json.dumps([c.to_dict() for c in notebook.comments]))
class GradeHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
@check_notebook_dir
@web.authenticated
@check_xsrf
@check_notebook_dir
def post(self, assignment_id):
self.write(json.dumps(self.api.generate_feedback(assignment_id)))
class ReleaseAllFeedbackHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
@check_notebook_dir
def post(self, assignment_id):
self.write(json.dumps(self.api.release_feedback(assignment_id)))
class GenerateFeedbackHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
@check_notebook_dir
def post(self, assignment_id, student_id):
self.write(json.dumps(self.api.generate_feedback(assignment_id, student_id)))
class ReleaseFeedbackHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
@check_notebook_dir
def post(self, assignment_id, student_id):
self.write(json.dumps(self.api.release_feedback(assignment_id, student_id)))
default_handlers = [
def put(self, assignment_id):
data = self.get_json_body()
duedate = data.get("duedate_notimezone", None)
timezone = data.get("duedate_timezone", None)
if duedate and timezone:
duedate = duedate + " " + timezone
assignment = {"duedate": duedate}
assignment_id = assignment_id.strip()
self.gradebook.update_or_create_assignment(assignment_id, **assignment)
sourcedir = os.path.abspath(self.coursedir.format_path(self.coursedir.source_directory, '.', assignment_id))
if not os.path.isdir(sourcedir):
os.makedirs(sourcedir)
self.write(json.dumps(self.api.get_assignment(assignment_id)))
class NotebookCollectionHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
@check_notebook_dir
def get(self, assignment_id):
notebooks = self.api.get_notebooks(assignment_id)
self.write(json.dumps(notebooks))
class SubmissionCollectionHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
@check_notebook_dir
def get(self, assignment_id):
submissions = self.api.get_submissions(assignment_id)
self.write(json.dumps(submissions))
import json
import os
from tornado import web
from .base import BaseApiHandler, check_xsrf, check_notebook_dir
from ...api import MissingEntry
class StatusHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
def get(self):
self.write({"status": True})
class GradeCollectionHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
@check_notebook_dir
def get(self):
submission_id = self.get_argument("submission_id")
try:
notebook = self.gradebook.find_submission_notebook_by_id(submission_id)
except MissingEntry:
raise web.HTTPError(404)
class CommentCollectionHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
@check_notebook_dir
def get(self):
submission_id = self.get_argument("submission_id")
try:
notebook = self.gradebook.find_submission_notebook_by_id(submission_id)
except MissingEntry:
raise web.HTTPError(404)
self.write(json.dumps([c.to_dict() for c in notebook.comments]))
class GradeHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
@check_notebook_dir
def get(self, grade_id):
try:
grade = self.gradebook.find_grade_by_id(grade_id)
except MissingEntry:
raise web.HTTPError(404)
self.write(json.dumps(grade.to_dict()))
@web.authenticated
@check_xsrf
@check_notebook_dir
def put(self, grade_id):
try:
grade = self.gradebook.find_grade_by_id(grade_id)
submissions = self.api.get_submissions(assignment_id)
self.write(json.dumps(submissions))
class SubmissionHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
@check_notebook_dir
def get(self, assignment_id, student_id):
submission = self.api.get_submission(assignment_id, student_id)
if submission is None:
raise web.HTTPError(404)
self.write(json.dumps(submission))
class SubmittedNotebookCollectionHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
@check_notebook_dir
def get(self, assignment_id, notebook_id):
submissions = self.api.get_notebook_submissions(assignment_id, notebook_id)
self.write(json.dumps(submissions))
class StudentCollectionHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
@check_notebook_dir
def get(self):
students = self.api.get_students()
self.write(json.dumps(students))
@web.authenticated
@check_xsrf
@check_notebook_dir
def put(self, student_id):
data = self.get_json_body()
student = {
"last_name": data.get("last_name", None),
"first_name": data.get("first_name", None),
"email": data.get("email", None),
}
student_id = student_id.strip()
self.gradebook.update_or_create_student(student_id, **student)
self.write(json.dumps(self.api.get_student(student_id)))
class StudentSubmissionCollectionHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
@check_notebook_dir
def get(self, student_id):
submissions = self.api.get_student_submissions(student_id)
self.write(json.dumps(submissions))
class StudentNotebookSubmissionCollectionHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
@check_notebook_dir
def get(self, student_id, assignment_id):
submissions = self.api.get_student_notebook_submissions(student_id, assignment_id)
self.write(json.dumps(submissions))
}
student_id = student_id.strip()
self.gradebook.update_or_create_student(student_id, **student)
self.write(json.dumps(self.api.get_student(student_id)))
class StudentSubmissionCollectionHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
@check_notebook_dir
def get(self, student_id):
submissions = self.api.get_student_submissions(student_id)
self.write(json.dumps(submissions))
class StudentNotebookSubmissionCollectionHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
@check_notebook_dir
def get(self, student_id, assignment_id):
submissions = self.api.get_student_notebook_submissions(student_id, assignment_id)
self.write(json.dumps(submissions))
class AssignHandler(BaseApiHandler):
@web.authenticated
@check_xsrf
@check_notebook_dir
def post(self, assignment_id):
self.write(json.dumps(self.api.generate_assignment(assignment_id)))