def list_assignments():
    """
    List assignments

    GET: returns 404 or Student view or Mentor view
    POST: returns HTTP 200 on success and redirect to list-assignments page
    """

    user = user_session(session['user'], session['type'])
    if isinstance(user, Mentor):
        choose = "Mentor"
        assignListOfObjects = Assignment.get_list()
        return render_template('viewassignments.html',
                               user=user_session(session['user'],
                                                 session['type']),
                               choose=choose,
                               assignListOfObjects=assignListOfObjects)

    elif (isinstance(user, Student)):

        choose = "Student"
        student_id = user_session(session['user'], session['type']).id
        student_assignments = Assignment.get_all_assigmnets(student_id)

        return render_template('viewassignments.html',
                               user=user_session(session['user'],
                                                 session['type']),
                               choose=choose,
                               student_assignments=student_assignments)
    else:
        return render_template('404.html',
                               user=user_session(session['user'],
                                                 session['type']))
def grade_assignment():
    """
    List user of assignments and add possibility to grade it
    :return:
    """
    if request.method == 'POST':
        if request.form['assignmentID']:
            assigID = Assignment.get_by_id(request.form['assignmentID'])
            studentsDetails = Assignment.get_students_of_assigmnent(assigID.id)

            return render_template('grade_assignment.html',
                                   user=user_session(session['user'],
                                                     session['type']),
                                   students=studentsDetails,
                                   assignment=assigID)
    elif request.method == "GET":
        assigID = Assignment.get_by_id(request.args['assignmentID'])
        studentsDetails = Assignment.get_students_of_assigmnent(assigID.id)
        return render_template('grade_assignment.html',
                               user=user_session(session['user'],
                                                 session['type']),
                               students=studentsDetails,
                               assignment=assigID)
    else:
        return render_template('404.html',
                               user=user_session(session['user'],
                                                 session['type']))
Esempio n. 3
0
 def __uiAddAssignment(self):
     print("Adding an assignment...\nID:")
     id = int(input())
     print("Description:")
     description = input()
     print("Deadline:")
     deadline = input()
     self.__controllerAssignments.addAssignment(id, description, deadline)
     self.__undoAction.addToUndoList("5",
                                     Assignment(id, description, deadline))
     self.__undoAction.addToRedoList("5",
                                     Assignment(id, description, deadline))
Esempio n. 4
0
 def _populate_list(self):
     """
     Pulls existing information from the Mongo Database and creates all of the instances that should exist for the
     List's corresponding object type. Should only be called by the constructor.
     :return: void.
     """
     for entry in self._collection.find():
         artifact = Artifact(0, 0, None, 0, "")
         account = AuthorAccount(0, "", "", [])
         assignment = Assignment(0, None, artifact, account)
         assignment.set_entry_attributes(entry)
         self._entries[entry["assignmentID"]] = assignment
class TestModels(unittest.TestCase):

    def setUp(self):
        self.__test_student = Student(1,"Alin",123)
        self.__test_assignment = Assignment(2,"lab12","11/11/2034")
        
    def test_model_get_set(self):
        self.assertEqual(self.__test_student.getGroup(),123)
        self.__test_student.setGroup(134)
        self.assertEqual(self.__test_student.getGroup() ,134)
        
        self.assertEqual(self.__test_assignment.getDescription(),"lab12")
        self.__test_assignment.setDescription("asd")
        self.assertEqual(self.__test_assignment.getDescription(),"asd")
def assignment_submit(assignments_id):
    """
    Student submit assignment
    :param assignments_id:
    :return:
    """
    assignment = Assignment.get_by_id(assignments_id)
    submit = Submition.get_submit(
        user_session(session['user'], session['type']).id, assignments_id)
    if request.method == "POST":
        content = request.form['content']
        if assignment.type == 'group':
            team_id = user_session(session['user'], session['type']).team_id
            team = Team.get_by_id(team_id)
            team_members = team.get_members()
            for student in team_members:
                submit = Submition.get_submit(student.id, assignments_id)
                submit.change_content(content)
        else:
            submit.change_content(content)
        return redirect(
            url_for('assignment_controller.view_assignments',
                    assignments_id=assignments_id))

    return render_template('stud-submit.html',
                           user=user_session(session['user'], session['type']),
                           assignment=assignment,
                           submit=submit)
Esempio n. 7
0
 def create_assignment(self, paper_id, author_id):
     paper = self.artifact_list.get_entry(paper_id)
     author = self.account_list.get_entry(author_id)
     assignment_id = paper_id
     assignment = Assignment(assignment_id,
                             Assignment.Status.WAITING_FOR_REVIEWS, paper,
                             author)
     self.assignment_list.add_entry(assignment_id, assignment)
Esempio n. 8
0
 def getRandomAssignment(self):
     #ID = random.randint(10000,99999)
     ID = random.randint(47030, 47040)
     date = self.getRandomDate()
     description = str(
         random.choice(self.__preDescription) + " " +
         random.choice(self.__Description))
     return Assignment(ID, date, description)
def delete_assignment(assignment_id):
    """
    Delete assignment
    :param assignment_id:
    :return:
    """
    assignment = Assignment.get_by_id(assignment_id)
    assignment.delete_assignment()
    return redirect(url_for('assignment_controller.list_assignments'))
def add_assignment():
    """
    Add assignment
    :return:
    """
    if request.method == 'POST':
        if request.form['add_assignment']:
            title = request.form['title']
            description = request.form['description']
            due_to = request.form['due_to']
            type = request.form['type']
            Assignment.create(
                title, description, type,
                user_session(session['user'], session['type']).username,
                due_to,
                user_session(session['user'], session['type']).id)
            flash('Assignment was added')
            return redirect(url_for('assignment_controller.list_assignments'))

    return render_template('addassignment.html',
                           user=user_session(session['user'], session['type']))
def grade_user_assignments(username):
    """
    Grade assignment of user if you are mentor
    :param username:
    :return:
    """
    if request.method == "POST":

        if request.form['grade_user'] == 'grade':
            assignment_id = request.form['assignment']
            student_id = request.form['id']
            assignment = Assignment.get_by_id(assignment_id)
            student = Student.get_by_id(student_id)
            student_submit = Submition.get_submit(student_id, assignment_id)
            return render_template('grade_user_assignments.html',
                                   user=user_session(session['user'],
                                                     session['type']),
                                   student=student,
                                   assignment=assignment,
                                   student_submit=student_submit)
        elif request.form['grade_user'] == 'Save':
            submit_id = request.form['submit_id']
            new_grade = request.form['new_grade']
            assignment_id = request.form['assignment_id']
            assignment = Assignment.get_by_id(assignment_id)
            submit = Submition.get_by_id(submit_id)
            if assignment.type == 'group':
                team_id = Student.get_by_id(submit.student_id).team_id
                team = Team.get_by_id(team_id)
                team_members = team.get_members()
                for student in team_members:
                    submit = Submition.get_submit(student.id, assignment_id)
                    submit.update_grade(new_grade)
            else:
                submit.update_grade(new_grade)
            return redirect(
                url_for('assignment_controller.grade_assignment',
                        assignmentID=assignment_id))
    return render_template('404.html',
                           user=user_session(session['user'], session['type']))
Esempio n. 12
0
 def __uiUpdateAssignment(self):
     print("Updating an assignment...\nID:")
     id = int(input())
     print("New description:")
     description = input()
     print("New deadline:")
     deadline = input()
     oldAssignment = self.__controllerAssignments.getAssignmentByID(id)
     self.__controllerAssignments.updateAssignment(id, description,
                                                   deadline)
     self.__undoAction.addToUndoList("7", oldAssignment)
     self.__undoAction.addToRedoList("7",
                                     Assignment(id, description, deadline))
Esempio n. 13
0
    def update_assignment(self):

        for directory_name in listdir(self.dir):
            directory_path = join(self.dir, directory_name)

            if directory_name.startswith('.') or not isdir(directory_path) or not directory_name.startswith('week'):
                continue

            try:
                assignment = Assignment.create(directory_name, directory_path)
                self.assignments[directory_name] = assignment
            except KeyError:
                print(self.id, self.name, ' 파일이름 에러:', self.dir, directory_name)
def view_assignments(assignments_id):
    """
    List all assignments of user
    :param assignments_id:
    :return:
    """
    assignment = Assignment.get_by_id(assignments_id)
    submit = Submition.get_submit(
        user_session(session['user'], session['type']).id, assignments_id)
    return render_template('stud_view_assiment.html',
                           user=user_session(session['user'], session['type']),
                           assignment=assignment,
                           submit=submit)
Esempio n. 15
0
class MainApp(App):

    session = Session()

    admin_user = User("admin", "12345")
    admin_role = Administrator()
    admin_assign = Assignment(admin_user, admin_role)
    rootpath = "/home/gagos/unb/git/das/das_ep0/objects/organization"
    rootdir = Directory(rootpath, None, admin_role)
    admin_privilege = Privilege(admin_role, rootdir)
    admin_privilege.add_command('OpenObject')
    rootdir.update_directory()

    def build(self):
        return ScreenManagement()
Esempio n. 16
0
 def initializeEntity(self):
     self.__storeAssignments([
         Assignment(1, "lab1", "11/11/2018"),
         Assignment(2, "lab2", "18/11/2018")
     ])