def post(self):
        """Allows a reviewer to request a new review."""
        student = self.personalize_page_and_get_enrolled()
        if not student:
            return

        if not self.assert_xsrf_token_or_fail(self.request, "review-dashboard-post"):
            return

        course = self.get_course()
        unit, unused_lesson = extract_unit_and_lesson(self)
        if not unit:
            self.error(404)
            return

        rp = course.get_reviews_processor()
        review_steps = rp.get_review_steps_by(unit.unit_id, student.get_key())
        self.template_value["navbar"] = {"course": True}

        if not course.needs_human_grader(unit):
            self.error(404)
            return

        # Check that the student has submitted the corresponding assignment.
        if not rp.does_submission_exist(unit.unit_id, student.get_key()):
            self.template_value["error_code"] = "cannot_review_before_submitting_assignment"
            self.render("error.html")
            return

        # Check that the review due date has not passed.
        time_now = datetime.datetime.now()
        review_due_date = unit.workflow.get_review_due_date()
        if time_now > review_due_date:
            self.template_value["error_code"] = "cannot_request_review_after_deadline"
            self.render("error.html")
            return

        # Check that the student can request a new review.
        review_min_count = unit.workflow.get_review_min_count()
        can_request_new_review = len(review_steps) < review_min_count or ReviewUtils.has_completed_all_assigned_reviews(
            review_steps
        )
        if not can_request_new_review:
            self.template_value["review_min_count"] = review_min_count
            self.template_value["error_code"] = "must_complete_more_reviews"
            self.render("error.html")
            return

        self.template_value["no_submissions_available"] = True

        try:
            review_step_key = rp.get_new_review(unit.unit_id, student.get_key())
            redirect_params = {"key": review_step_key, "unit": unit.unit_id}
            self.redirect("/review?%s" % urllib.urlencode(redirect_params))
        except Exception:  # pylint: disable-msg=broad-except
            review_steps = rp.get_review_steps_by(unit.unit_id, student.get_key())
            self.populate_template(unit, review_steps)
            self.render("review_dashboard.html")
    def get(self):
        """Handles GET requests."""
        student = self.personalize_page_and_get_enrolled()
        if not student:
            return

        course = self.get_course()
        rp = course.get_reviews_processor()
        unit, _ = extract_unit_and_lesson(self)
        if not unit:
            self.error(404)
            return

        self.template_value['navbar'] = {'course': True}

        if not course.needs_human_grader(unit):
            self.error(404)
            return

        #progress bar
        total_progress = (
            self.get_progress_tracker().get_overall_progress_score(student))
        self.template_value['progress_value'] = total_progress.get(
            'progress_score', 0)
        self.template_value['complete_value'] = total_progress.get(
            'completed_score', 0)
        self.template_value['percentage'] = total_progress.get(
            'percentage', '')

        # Check that the student has submitted the corresponding assignment.
        if not rp.does_submission_exist(unit.unit_id, student.get_key()):
            self.template_value['error_code'] = (
                'cannot_review_before_submitting_assignment')
            self.render('error.html')
            return

        review_steps = rp.get_review_steps_by(unit.unit_id, student.get_key())

        self.populate_template(unit, review_steps)
        required_review_count = unit.workflow.get_review_min_count()

        # The student can request a new submission if:
        # - all his/her current reviews are in Draft/Completed state, and
        # - he/she is not in the state where the required number of reviews
        #       has already been requested, but not all of these are completed.
        self.template_value['can_request_new_review'] = (
            len(review_steps) < required_review_count
            or ReviewUtils.has_completed_all_assigned_reviews(review_steps))
        self.render('review_dashboard.html')
Beispiel #3
0
    def get(self):
        """Handles GET requests."""
        student = self.personalize_page_and_get_enrolled()
        if not student:
            return

        course = self.get_course()
        rp = course.get_reviews_processor()
        unit, _ = extract_unit_and_lesson(self)
        if not unit:
            self.error(404)
            return

        self.template_value['navbar'] = {'course': True}

        if not course.needs_human_grader(unit):
            self.error(404)
            return

        # CGL-MOOC-Builder starts:
        # Set template value for students progress bar that shows on the top navigation(header.html)
        total_progress = (self.get_progress_tracker().get_overall_progress_score(student))
        self.template_value['progress_value'] = total_progress.get('progress_score', 0)
        self.template_value['complete_value'] = total_progress.get('completed_score', 0)
        self.template_value['percentage'] = total_progress.get('percentage', '')
        # CGL-MOOC-Builder ends

        # Check that the student has submitted the corresponding assignment.
        if not rp.does_submission_exist(unit.unit_id, student.get_key()):
            self.template_value['error_code'] = (
                'cannot_review_before_submitting_assignment')
            self.render('error.html')
            return

        review_steps = rp.get_review_steps_by(unit.unit_id, student.get_key())

        self.populate_template(unit, review_steps)
        required_review_count = unit.workflow.get_review_min_count()

        # The student can request a new submission if:
        # - all his/her current reviews are in Draft/Completed state, and
        # - he/she is not in the state where the required number of reviews
        #       has already been requested, but not all of these are completed.
        self.template_value['can_request_new_review'] = (
            len(review_steps) < required_review_count or
            ReviewUtils.has_completed_all_assigned_reviews(review_steps)
        )
        self.render('review_dashboard.html')
    def get(self):
        """Handles GET requests."""
        student = self.personalize_page_and_get_enrolled()
        if not student:
            return

        course = self.get_course()
        rp = course.get_reviews_processor()
        unit, _ = extract_unit_and_lesson(self)
        if not unit:
            self.error(404)
            return

        self.template_value["navbar"] = {"course": True}

        if not course.needs_human_grader(unit):
            self.error(404)
            return

        # Check that the student has submitted the corresponding assignment.
        if not rp.does_submission_exist(unit.unit_id, student.get_key()):
            self.template_value["error_code"] = "cannot_review_before_submitting_assignment"
            self.render("error.html")
            return

        review_steps = rp.get_review_steps_by(unit.unit_id, student.get_key())

        self.populate_template(unit, review_steps)
        required_review_count = unit.workflow.get_review_min_count()

        # The student can request a new submission if:
        # - all his/her current reviews are in Draft/Completed state, and
        # - he/she is not in the state where the required number of reviews
        #       has already been requested, but not all of these are completed.
        self.template_value["can_request_new_review"] = len(
            review_steps
        ) < required_review_count or ReviewUtils.has_completed_all_assigned_reviews(review_steps)
        self.render("review_dashboard.html")
Beispiel #5
0
    def post(self):
        """Allows a reviewer to request a new review."""
        student = self.personalize_page_and_get_enrolled()
        if not student:
            return

        if not self.assert_xsrf_token_or_fail(
                self.request, 'review-dashboard-post'):
            return

        course = self.get_course()
        unit, unused_lesson = extract_unit_and_lesson(self)
        if not unit:
            self.error(404)
            return

        rp = course.get_reviews_processor()
        review_steps = rp.get_review_steps_by(unit.unit_id, student.get_key())
        self.template_value['navbar'] = {'course': True}

        if not course.needs_human_grader(unit):
            self.error(404)
            return

        # Check that the student has submitted the corresponding assignment.
        if not rp.does_submission_exist(unit.unit_id, student.get_key()):
            self.template_value['error_code'] = (
                'cannot_review_before_submitting_assignment')
            self.render('error.html')
            return

        # Check that the review due date has not passed.
        time_now = datetime.datetime.now()
        review_due_date = unit.workflow.get_review_due_date()
        if time_now > review_due_date:
            self.template_value['error_code'] = (
                'cannot_request_review_after_deadline')
            self.render('error.html')
            return

        # Check that the student can request a new review.
        review_min_count = unit.workflow.get_review_min_count()
        can_request_new_review = (
            len(review_steps) < review_min_count or
            ReviewUtils.has_completed_all_assigned_reviews(review_steps))
        if not can_request_new_review:
            self.template_value['review_min_count'] = review_min_count
            self.template_value['error_code'] = 'must_complete_more_reviews'
            self.render('error.html')
            return

        self.template_value['no_submissions_available'] = True

        try:
            review_step_key = rp.get_new_review(unit.unit_id, student.get_key())
            redirect_params = {
                'key': review_step_key,
                'unit': unit.unit_id,
            }
            self.redirect('/review?%s' % urllib.urlencode(redirect_params))
        except Exception:  # pylint: disable-msg=broad-except
            review_steps = rp.get_review_steps_by(
                unit.unit_id, student.get_key())
            self.populate_template(unit, review_steps)
            self.render('review_dashboard.html')
Beispiel #6
0
    def post(self):
        """Allows a reviewer to request a new review."""
        student = self.personalize_page_and_get_enrolled()
        if not student:
            return

        if not self.assert_xsrf_token_or_fail(
                self.request, 'review-dashboard-post'):
            return

        # CGL-MOOC-Builder starts:
        # Set template value for students progress bar that shows on the top navigation(header.html)
        total_progress = (self.get_progress_tracker().get_overall_progress_score(student))
        self.template_value['progress_value'] = total_progress.get('progress_score', 0)
        self.template_value['complete_value'] = total_progress.get('completed_score', 0)
        self.template_value['percentage'] = total_progress.get('percentage', '')
        # CGL-MOOC-Builder ends

        course = self.get_course()
        unit, unused_lesson = extract_unit_and_lesson(self)
        if not unit:
            self.error(404)
            return

        rp = course.get_reviews_processor()
        review_steps = rp.get_review_steps_by(unit.unit_id, student.get_key())
        self.template_value['navbar'] = {'course': True}

        if not course.needs_human_grader(unit):
            self.error(404)
            return

        # Check that the student has submitted the corresponding assignment.
        if not rp.does_submission_exist(unit.unit_id, student.get_key()):
            self.template_value['error_code'] = (
                'cannot_review_before_submitting_assignment')
            self.render('error.html')
            return

        # Check that the review due date has not passed.
        time_now = datetime.datetime.now()
        review_due_date = unit.workflow.get_review_due_date()
        if time_now > review_due_date:
            self.template_value['error_code'] = (
                'cannot_request_review_after_deadline')
            self.render('error.html')
            return

        # Check that the student can request a new review.
        review_min_count = unit.workflow.get_review_min_count()
        can_request_new_review = (
            len(review_steps) < review_min_count or
            ReviewUtils.has_completed_all_assigned_reviews(review_steps))
        if not can_request_new_review:
            self.template_value['review_min_count'] = review_min_count
            self.template_value['error_code'] = 'must_complete_more_reviews'
            self.render('error.html')
            return

        self.template_value['no_submissions_available'] = True

        try:
            review_step_key = rp.get_new_review(unit.unit_id, student.get_key())
            redirect_params = {
                'key': review_step_key,
                'unit': unit.unit_id,
            }
            self.redirect('/review?%s' % urllib.urlencode(redirect_params))
        except Exception:  # pylint: disable-msg=broad-except
            review_steps = rp.get_review_steps_by(
                unit.unit_id, student.get_key())
            self.populate_template(unit, review_steps)
            self.render('review_dashboard.html')