def get_csv(current_user, assignment): the_assignment = _get_assignment(assignment, current_user) if current_user.account_type != "admin" and \ the_assignment.for_class not in current_user.classes: raise PermissionError( "You can only modify assignments for classes you teach." ) # Create the task ID here rather than inside sisyphus so that we can tell # the user how to find the archive once its done. task_id = ObjectId() # We will not perform the work of archiving right now but will instead pass # if off to the heavy lifter to do it for us. send_task( config["SISYPHUS_ADDRESS"], "create_assignment_csv", str(task_id), current_user.email, str(the_assignment.id) ) return ( "The CSV file for this assignment is being created.", { "X-Download": "reports/csv/" + str(task_id), "X-Download-DefaultName": "assignment.csv" } )
def get_gradebook(current_user, the_class, fill=0): if current_user.account_type == "admin": the_class = _get_class(the_class) else: the_class = _get_class(the_class, current_user) if current_user.account_type != "admin" and \ the_class.id not in current_user.classes: raise PermissionError( "You can only get information about classes you teach." ) task_id = ObjectId() send_task( config["SISYPHUS_ADDRESS"], "create_gradebook_csv", str(task_id), current_user.email, str(the_class.id), int(fill) ) return ( "The CSV gradebook for this class is being created.", { "X-Download": "reports/csv/" + str(task_id), "X-Download-DefaultName": "gradebook.csv" } )
def get_archive(current_user, assignment, email = ""): # zip_tasks imports galahweb because it wants access to the logger, to # prevent a circular dependency we won't load the module until we need it. the_assignment = _get_assignment(assignment, current_user) if current_user.account_type != "admin" and \ the_assignment.for_class not in current_user.classes: raise PermissionError( "You can only modify assignments for classes you teach." ) # Create the task ID here rather than inside sisyphus so that we can tell # the user how to find the archive once its done. task_id = ObjectId() # We will not perform the work of archiving right now but will instead pass # if off to the heavy lifter to do it for us. send_task( config["SISYPHUS_ADDRESS"], "zip_bulk_submissions", str(task_id), current_user.email, str(the_assignment.id), email ) return ( "Your archive is being created.", { "X-Download": "archives/" + str(task_id), "X-Download-DefaultName": "submissions.zip" } )
def rerun_harness(current_user, assignment): the_assignment = _get_assignment(assignment, current_user) send_task(config["SISYPHUS_ADDRESS"], "rerun_test_harness", str(the_assignment.id)) return "Rerunning test harnesses on submissions for %s" % \ the_assignment.name
def rerun_harness(current_user, assignment): the_assignment = _get_assignment(assignment, current_user) send_task( config["SISYPHUS_ADDRESS"], "rerun_test_harness", str(the_assignment.id) ) return "Rerunning test harnesses on submissions for %s" % \ the_assignment.name
def delete_class(to_delete): the_class = _get_class(to_delete) # Get all of the assignments for the class assignments = [str(i.id) for i in Assignment.objects(for_class=the_class.id)] send_task(config["SISYPHUS_ADDRESS"], "delete_assignments", assignments, str(the_class.id)) return "%s has been queued for deletion. Please allow a few minutes for the " "task to complete." % _class_to_str( the_class )
def delete_assignment(current_user, id): to_delete = _get_assignment(id, current_user) if current_user.account_type != "admin" and to_delete.for_class not in current_user.classes: raise PermissionError("You cannot delete an assignment for a class you're not teaching.") send_task(config["SISYPHUS_ADDRESS"], "delete_assignments", [str(to_delete.id)], "") return ( "%s has been queued for deletion. Please allow a few minutes for the " "task to complete." % _assignment_to_str(to_delete) )
def delete_class(to_delete): the_class = _get_class(to_delete) # Get all of the assignments for the class assignments = \ [str(i.id) for i in Assignment.objects(for_class = the_class.id)] send_task(config["SISYPHUS_ADDRESS"], "delete_assignments", assignments, str(the_class.id)) return ( "%s has been queued for deletion. Please allow a few minutes for the " "task to complete." % _class_to_str(the_class))
def delete_assignment(current_user, id): to_delete = _get_assignment(id, current_user) if current_user.account_type != "admin" and \ to_delete.for_class not in current_user.classes: raise PermissionError( "You cannot delete an assignment for a class you're not teaching.") send_task(config["SISYPHUS_ADDRESS"], "delete_assignments", [str(to_delete.id)], "") return ( "%s has been queued for deletion. Please allow a few minutes for the " "task to complete." % _assignment_to_str(to_delete))
def get_gradebook(current_user, the_class, fill=0): if current_user.account_type == "admin": the_class = _get_class(the_class) else: the_class = _get_class(the_class, current_user) if current_user.account_type != "admin" and \ the_class.id not in current_user.classes: raise PermissionError( "You can only get information about classes you teach.") task_id = ObjectId() send_task(config["SISYPHUS_ADDRESS"], "create_gradebook_csv", str(task_id), current_user.email, str(the_class.id), int(fill)) return ("The CSV gradebook for this class is being created.", { "X-Download": "reports/csv/" + str(task_id), "X-Download-DefaultName": "gradebook.csv" })
def get_csv(current_user, assignment): the_assignment = _get_assignment(assignment, current_user) if current_user.account_type != "admin" and \ the_assignment.for_class not in current_user.classes: raise PermissionError( "You can only modify assignments for classes you teach.") # Create the task ID here rather than inside sisyphus so that we can tell # the user how to find the archive once its done. task_id = ObjectId() # We will not perform the work of archiving right now but will instead pass # if off to the heavy lifter to do it for us. send_task(config["SISYPHUS_ADDRESS"], "create_assignment_csv", str(task_id), current_user.email, str(the_assignment.id)) return ("The CSV file for this assignment is being created.", { "X-Download": "reports/csv/" + str(task_id), "X-Download-DefaultName": "assignment.csv" })
def get_archive(current_user, assignment, email=""): # tar_tasks imports galahweb because it wants access to the logger, to # prevent a circular dependency we won't load the module until we need it. the_assignment = _get_assignment(assignment, current_user).id if current_user.account_type != "admin" and \ the_assignment.for_class not in current_user.classes: raise PermissionError( "You can only modify assignments for classes you teach.") # Create the task ID here rather than inside sisyphus so that we can tell # the user how to find the archive once its done. task_id = ObjectId() # We will not perform the work of archiving right now but will instead pass # if off to the heavy lifter to do it for us. send_task(config["SISYPHUS_ADDRESS"], "tar_bulk_submissions", str(task_id), current_user.email, str(the_assignment), email) return ("Your archive is being created.", { "X-Download": "archives/" + str(task_id), "X-Download-DefaultName": "submissions.tar.gz" })