Exemple #1
0
def staff_group_add(cid, email, aid):
    assign = Assignment.query.filter_by(id=aid, course_id=cid).one_or_none()
    if not assign or not Assignment.can(assign, current_user, 'grade'):
        flash('Cannot access assignment', 'error')
        return abort(404)

    form = forms.StaffAddGroupFrom()
    result_page = url_for('.student_assignment_detail', cid=cid,
                          email=email, aid=aid)

    student = User.lookup(email)
    if not student:
        return abort(404)

    if form.validate_on_submit():
        target = User.lookup(form.email.data)
        if not target or not target.is_enrolled(cid):
            flash("This user is not enrolled", 'warning')
            return redirect(result_page)
        try:
            Group.force_add(current_user, student, target, assign)
        except BadRequest as e:
            flash("Error: {}".format(str(e.description)), 'error')
            return redirect(result_page)

    return redirect(result_page)
Exemple #2
0
def staff_group_add(cid, email, aid):
    assign = Assignment.query.filter_by(id=aid, course_id=cid).one_or_none()
    if not assign or not Assignment.can(assign, current_user, 'grade'):
        flash('Cannot access assignment', 'error')
        return abort(404)

    form = forms.StaffAddGroupFrom()
    result_page = url_for('.student_assignment_detail', cid=cid,
                          email=email, aid=aid)

    student = User.lookup(email)
    if not student:
        return abort(404)

    if form.validate_on_submit():
        target = User.lookup(form.email.data)
        if not target or not target.is_enrolled(cid):
            flash("This user is not enrolled", 'warning')
            return redirect(result_page)
        try:
            Group.force_add(current_user, student, target, assign)
        except BadRequest as e:
            flash("Error: {}".format(str(e.description)), 'error')
            return redirect(result_page)

    return redirect(result_page)
    def test_group_submit_with_extension(self):
        self.set_offset(-2) # Lock assignment

        # Should fail because it's late.
        self._submit_to_api(self.user2, False)

        Group.force_add(self.staff1, self.user1, self.user2, self.assignment)
        ext = self._make_ext(self.assignment, self.user1)

        # An extension for user1 should also apply to all members of the group
        self._submit_to_api(self.user2, True)
        self._submit_to_api(self.user1, True)
        self._submit_to_api(self.user3, False)

        Group.force_add(self.staff1, self.user1, self.user3, self.assignment)
        self._submit_to_api(self.user3, True)
Exemple #4
0
    def test_group_submit_with_extension(self):
        self.set_offset(-1) # Lock assignment

        # Should fail because it's late.
        self._submit_to_api(self.user2, False)

        Group.force_add(self.staff1, self.user1, self.user2, self.assignment)
        ext = self._make_ext(self.assignment, self.user1)

        # An extension for user1 should also apply to all members of the group
        self._submit_to_api(self.user2, True)
        self._submit_to_api(self.user1, True)
        self._submit_to_api(self.user3, False)

        Group.force_add(self.staff1, self.user1, self.user3, self.assignment)
        self._submit_to_api(self.user3, True)
    def test_submit_between_due_and_lock(self):
        """ Extensions should also change the custom submission time
        when submitted after the due date but before the lock date.
        """
        self.assignment.due_date = dt.datetime.utcnow() + dt.timedelta(hours=-1)
        self.assignment.lock_date = dt.datetime.utcnow() + dt.timedelta(hours=1)

        Group.force_add(self.staff1, self.user1, self.user2, self.assignment)

        # User 1 is allowed to submit since it's between due and lock date
        self._submit_to_api(self.user1, True)
        first_back = Backup.query.filter(Backup.submitter_id == self.user1.id,
                                         Backup.submit == True).first()
        self.assertIsNone(first_back.custom_submission_time)
        ext = self._make_ext(self.assignment, self.user1)
        self._submit_to_api(self.user2, True)

        second_back = Backup.query.filter(Backup.submitter_id == self.user2.id,
                                          Backup.submit == True).first()
        # The submission from User 2 should have a custom submission time
        self.assertEqual(second_back.custom_submission_time, ext.custom_submission_time)
Exemple #6
0
    def test_submit_between_due_and_lock(self):
        """ Extensions should also change the custom submission time
        when submitted after the due date but before the lock date.
        """
        self.assignment.due_date = dt.datetime.utcnow() + dt.timedelta(hours=-1)
        self.assignment.lock_date = dt.datetime.utcnow() + dt.timedelta(hours=1)

        Group.force_add(self.staff1, self.user1, self.user2, self.assignment)

        # User 1 is allowed to submit since it's between due and lock date
        self._submit_to_api(self.user1, True)
        first_back = Backup.query.filter(Backup.submitter_id == self.user1.id,
                                         Backup.submit == True).first()
        self.assertIsNone(first_back.custom_submission_time)
        ext = self._make_ext(self.assignment, self.user1)
        self._submit_to_api(self.user2, True)

        second_back = Backup.query.filter(Backup.submitter_id == self.user2.id,
                                          Backup.submit == True).first()
        # The submission from User 2 should have a custom submission time
        self.assertEquals(second_back.custom_submission_time, ext.custom_submission_time)