예제 #1
0
def view_final_grades():
    """This function shows the final grade of each user.
    """
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    props = db(db.user_properties.user == auth.user.email).select().first()
    if not access.can_view_ratings(c, props):
	session.flash = T('You do not have access to the final grades for this venue.')
	redirect(URL('venues', 'view_venue', args=[c.id]))
    # Checking that final grades are recent and don't need recomputation.
    venue_row = db(db.venue.id == c.id).select().first()
    final_grades_date = venue_row.latest_final_grades_evaluation_date
    reviewers_eval_date = venue_row.latest_reviewers_evaluation_date
    rank_update_date = venue_row.latest_rank_update_date
    if (rank_update_date is None or
        reviewers_eval_date is None or
        final_grades_date is None or
        reviewers_eval_date < rank_update_date or
        final_grades_date < rank_update_date or
        final_grades_date < reviewers_eval_date):
        session.flash = T('Grades are not updated/computed. Please compute final grades')
        redirect(URL('venues', 'view_venue', args=[c.id]))
    # Okay, final grades are computed and are updated.
    # Prepares the query for the grid.
    q = (db.grades.venue_id == c.id)
    grid = SQLFORM.grid(q,
	args=request.args[:1],
	user_signature=False, details=True,
	create=False, editable=False, deletable=False,
	fields=[db.grades.user, db.grades.grade],
	)
    title = A(c.name, _href=URL('venues', 'view_venue', args=[c.id]))
    histogram_link = A(T("View histogram of final grades"),
                  _href=URL('ranking', 'view_grades_histogram', args=[c.id]))
    return dict(grid=grid, title=title, histogram_link=histogram_link)
예제 #2
0
def view_venue():
    """This function enables the view of the ranking of items submitted to a
    venue.  It is assumed that the people accessing this can have full
    information about the venue, including the identity of the submitters."""
    def represent_n_completed_reviews(v, r):
        if v is None:
            return None
        url = A(str(v), _href=URL('ranking',
            'view_comparisons_given_submission' ,args=[r.id]))
        return url
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    props = db(db.user_properties.user == auth.user.email).select().first()
    if not access.can_view_submissions(c, props):
	session.flash = T('You do not have access to the submissions of this venue.')
	redirect(URL('venues', 'view_venue', args=[c.id]))
    can_view_ratings = access.can_view_ratings(c, props)
    # Prepares the query for the grid.
    q = (db.submission.venue_id == c.id)
    db.submission.quality.readable = can_view_ratings
    db.submission.error.readable = can_view_ratings
    db.submission.content.readable = False
    db.submission.title.writable = False
    db.submission.content.writable = False
    db.submission.comment.writable = False
    db.submission.n_assigned_reviews.readable = True
    db.submission.n_assigned_reviews.label = T('Reviews Assigned')
    db.submission.n_completed_reviews.label = T('Completed')
    db.submission.n_rejected_reviews.label = T('Rejected')
    db.submission.n_completed_reviews.represent = represent_n_completed_reviews
    if c.allow_link_submission:
	db.submission.link.readable = True
    is_editable = False
    if access.can_view_feedback(c, props):
	db.submission.user.label = T('Submission')
	db.submission.user.represent = lambda v, r : A(v, 
			    _href=URL('feedback', 'view_feedback', args=['s', r.id]))
    fields=[db.submission.user, db.submission.percentile,
	    db.submission.n_assigned_reviews, db.submission.n_completed_reviews,
	    db.submission.n_rejected_reviews]
    if access.can_enter_true_quality:
	fields.append(db.submission.true_quality)
	is_editable = True
	db.submission.true_quality.readable = db.submission.true_quality.writable = True
    grid = SQLFORM.grid(q,
	field_id=db.submission.id,
	csv=True,
	args=request.args[:1],
	user_signature=False,
	details=False, create=False,
	editable=is_editable,
	deletable=False,
	fields=fields,
	)
    title = A(c.name, _href=URL('venues', 'view_venue', args=[c.id]))
    return dict(title=title, grid=grid)
예제 #3
0
def view_venue():
    """This function enables the view of the ranking of items submitted to a
    venue.  It is assumed that the people accessing this can have full
    information about the venue, including the identity of the submitters."""
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    props = db(db.user_properties.email == auth.user.email).select().first()
    if not access.can_view_submissions(c, props):
	session.flash = T('You do not have access to the submissions of this venue.')
	redirect(URL('venues', 'view_venue', args=[c.id]))
    can_view_ratings = access.can_view_ratings(c, props)
    # Prepares the query for the grid.
    q = (db.submission.venue_id == c.id)
    db.submission.quality.readable = can_view_ratings
    db.submission.error.readable = can_view_ratings
    db.submission.content.readable = False
    db.submission.title.writable = False
    db.submission.content.writable = False
    db.submission.comment.writable = False
    db.submission.n_assigned_reviews.readable = True
    db.submission.n_assigned_reviews.label = T('Reviews Assigned')
    db.submission.n_completed_reviews.label = T('Done')
    db.submission.n_rejected_reviews.label = T('Rejected')
    if c.allow_link_submission:
	db.submission.link.readable = True
    is_editable = False
    fields=[db.submission.title, db.submission.email, db.submission.quality,
	    db.submission.percentile, db.submission.n_assigned_reviews, db.submission.n_completed_reviews,
	    db.submission.n_rejected_reviews, db.submission.error, db.submission.content]
    if access.can_enter_true_quality:
	fields.append(db.submission.true_quality)
	is_editable = True
	db.submission.true_quality.readable = db.submission.true_quality.writable = True
    links = [
	# dict(header=T('N. reviews'), body = lambda r: get_num_reviews(r.id, c.id)),
	dict(header=T('Download'), body = lambda r:
	     A(T('Download'), _class='btn',
	       _href=URL('submission', 'download_viewer', args=[r.id, r.content])))]
    if access.can_view_feedback(c, props):
	links.append(dict(header=T('Feedback'), body = lambda r:
			  A(T('Read comments'), 
			    _href=URL('feedback', 'view_feedback', args=[r.id]))))
    grid = SQLFORM.grid(q,
	field_id=db.submission.id,
	csv=True,
	args=request.args[:1],
	user_signature=False,
	details=False, create=False,
	editable=is_editable,
	deletable=False,
	fields=fields,
	links=links,
	)
    title = A(c.name, _href=URL('venues', 'view_venue', args=[c.id]))
    return dict(title=title, grid=grid)
예제 #4
0
def view_venue():
    c = db.venue(request.args(0)) or redirect(URL("default", "index"))
    props = db(db.user_properties.user == auth.user.email).select().first()
    # if c.raters_equal_submitters:
    db.venue.rate_constraint.readable = False
    if props == None:
        can_submit = False
        can_rate = False
        has_submitted = False
        has_rated = False
        can_manage = False
        can_observe = False
        can_view_ratings = False
    else:
        can_submit = c.id in util.get_list(props.venues_can_submit)
        can_rate = c.id in util.get_list(props.venues_can_rate)
        has_submitted = c.id in util.get_list(props.venues_has_submitted)
        has_rated = c.id in util.get_list(props.venues_has_rated)
        can_manage = c.id in util.get_list(props.venues_can_manage)
        can_observe = c.id in util.get_list(props.venues_can_observe)
        # MAYDO(luca): Add option to allow only raters, or only submitters, to view
        # all ratings.
        can_view_ratings = access.can_view_ratings(c, props)
    if access.can_observe(c, props):
        db.venue.grading_instructions.readable = True
    venue_form = SQLFORM(db.venue, record=c, readonly=True)
    link_list = []
    if can_manage:
        link_list.append(
            A(T("Edit"), _href=URL("venues", "managed_index", args=["edit", "venue", c.id], user_signature=True))
        )
    if can_submit:
        link_list.append(A(T("Submit to this venue"), _href=URL("submission", "submit", args=[c.id])))
    if can_manage:
        link_list.append(A(T("Add submission"), _href=URL("submission", "manager_submit", args=[c.id])))
    if has_submitted:
        link_list.append(A(T("View my submissions"), _href=URL("feedback", "index", args=[c.id])))
    if can_view_ratings or access.can_view_submissions(c, props):
        link_list.append(A(T("View submissions"), _href=URL("ranking", "view_venue", args=[c.id])))
    if can_rate:
        link_list.append(
            A(T("Review a submission"), _href=URL("rating", "accept_review", args=[c.id], user_signature=True))
        )
    if can_observe or can_manage:
        # link_list.append(A(T('View reviewing tasks'), _href=URL('ranking', 'view_tasks', args=[c.id])))
        link_list.append(A(T("View comparisons"), _href=URL("ranking", "view_comparisons_index", args=[c.id])))
    if can_manage:
        link_list.append(A(T("Run reputation system"), _href=URL("rating", "run_rep_system", args=[c.id])))
    if can_view_ratings:
        link_list.append(A(T("View grades"), _href=URL("ranking", "view_final_grades", args=[c.id])))
    if auth.user.email in ["*****@*****.**", "*****@*****.**"]:
        link_list.append(A(T("Research view"), _href=URL("view_venue_research", args=[c.id])))
    return dict(form=venue_form, link_list=link_list, venue=c, has_rated=has_rated)
예제 #5
0
def view_grades_histogram():
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    props = db(db.user_properties.user == auth.user.email).select().first()
    if not access.can_view_ratings(c, props):
        session.flash = T('You do not have access to the final grades for this venue.')
        redirect(URL('venues', 'view_venue', args=[c.id]))
    # TODO(michael): if we want to optimize db access we can save all grades in
    # one row.
    # Fetching grades.
    grades_records = db(db.grades.venue_id == c.id).select(db.grades.grade)
    grades = [x.grade for x in grades_records]
    # Building histogram.
    hist, bins = np.histogram(grades, bins=50 , range=(0, 100))
    hist = [(bins[i], hist[i]) for i in xrange(len(hist))]
    title = A(c.name, _href=URL('venues', 'view_venue', args=[c.id]))
    return dict(sub_title=title, hist=hist)
예제 #6
0
def view_final_grades():
    """This function shows the final grade of each user.
    """
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    props = db(db.user_properties.user == auth.user.email).select().first()
    if not access.can_view_ratings(c, props):
	session.flash = T('You do not have access to the final grades for this venue.')
	redirect(URL('venues', 'view_venue', args=[c.id]))
    # Checking that final grades are recent and don't need recomputation.
    venue_row = db(db.venue.id == c.id).select().first()
    grades_date = venue_row.latest_grades_date
    if grades_date is None:
        session.flash = T('Grades are not updated/computed. Please compute final grades')
        redirect(URL('venues', 'view_venue', args=[c.id]))
    # Okay, final grades are computed and are updated.
    # Prepares the query for the grid.
    if is_user_admin():
	db.grades.reputation.readable = True
    db.grades.user.represent = represent_user_by_submission_feedback
    db.grades.venue_id.readable = False
    db.grades.submission_percentile.label = T('Submission')
    db.grades.percentile.label = T('Overall')
    link_list = []
    if access.can_manage(c, props):
	db.grades.assigned_grade.writable = True
	db.grades.assigned_grade.comment = T('Assign the desired grade to a few users, '
					     'then automatically fill-in the remaining '
	                                     'grades via interpolation. ')
	is_editable = True
	link_list.append(A(T('Interpolate final grades'), 
			   _href=URL('ranking', 'interpolate_grades', args=[c.id], user_signature=True)))
	link_list.append(A(T('Clear final grades'), 
			   _href=URL('ranking', 'reset_grades', args=[c.id], user_signature=True)))
    else:
	db.grades.assigned_grade.writable = False
	is_editable = False
    q = (db.grades.venue_id == c.id)
    grid = SQLFORM.grid(q,
	args=request.args[:1],
	user_signature=False, details=False,
	create=False, editable=is_editable, deletable=False,
	fields=[db.grades.user, db.grades.submission_percentile, db.grades.venue_id,
		db.grades.n_ratings, db.grades.accuracy,
		db.grades.reputation, db.grades.percentile, db.grades.assigned_grade ],
	)
    title = A(c.name, _href=URL('venues', 'view_venue', args=[c.id]))
    return dict(grid=grid, title=title, link_list=link_list)
예제 #7
0
def view_grades_histogram():
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    props = db(db.user_properties.user == auth.user.email).select().first()
    if not access.can_view_ratings(c, props):
        session.flash = T(
            'You do not have access to the final grades for this venue.')
        redirect(URL('venues', 'view_venue', args=[c.id]))
    # TODO(michael): if we want to optimize db access we can save all grades in
    # one row.
    # Fetching grades.
    grades_records = db(db.grades.venue_id == c.id).select(db.grades.grade)
    grades = [x.grade for x in grades_records]
    # Building histogram.
    hist, bins = np.histogram(grades, bins=50, range=(0, 100))
    hist = [(bins[i], hist[i]) for i in xrange(len(hist))]
    title = A(c.name, _href=URL('venues', 'view_venue', args=[c.id]))
    return dict(sub_title=title, hist=hist)
예제 #8
0
def view_venue_research():
    c = db.venue(request.args(0)) or redirect(URL("default", "index"))
    props = db(db.user_properties.user == auth.user.email).select().first()
    if props == None:
        can_submit = False
        can_rate = False
        has_submitted = False
        has_rated = False
        can_manage = False
        can_observe = False
        can_view_ratings = False
    else:
        can_submit = c.id in util.get_list(props.venues_can_submit) or util.is_none(c.submit_constraint)
        can_rate = c.id in util.get_list(props.venues_can_rate) or util.is_none(c.rate_constraint)
        has_submitted = c.id in util.get_list(props.venues_has_submitted)
        has_rated = c.id in util.get_list(props.venues_has_rated)
        can_manage = c.id in util.get_list(props.venues_can_manage)
        can_observe = c.id in util.get_list(props.venues_can_observe)
        # MAYDO(luca): Add option to allow only raters, or only submitters, to view
        # all ratings.
        can_view_ratings = access.can_view_ratings(c, props)
    db.venue.ranking_algo_description.readable = True
    venue_form = SQLFORM(db.venue, record=c, readonly=True)
    link_list = []
    if can_submit:
        link_list.append(A(T("Submit to this venue"), _href=URL("submission", "submit", args=[c.id])))
    if can_rate:
        link_list.append(A(T("Review a submission"), _href=URL("rating", "accept_review", args=[c.id])))
    if has_submitted:
        link_list.append(A(T("View my submissions"), _href=URL("feedback", "index", args=[c.id])))
    if can_manage:
        link_list.append(A(T("Edit"), _href=URL("managed_index", vars=dict(cid=c.id))))
        link_list.append(A(T("Add submission"), _href=URL("submission", "manager_submit", args=[c.id])))
        link_list.append(A(T("Rep sys - small alpha"), _href=URL("rating", "run_rep_sys_research", args=[c.id, 3])))
        link_list.append(A(T("Rep sys - all compar"), _href=URL("rating", "run_rep_sys_research", args=[c.id, 2])))
        link_list.append(A(T("Ranking without rep sys"), _href=URL("rating", "run_rep_sys_research", args=[c.id, 1])))
    if can_observe or can_manage:
        link_list.append(A(T("View reviewing tasks"), _href=URL("ranking", "view_tasks", args=[c.id])))
        link_list.append(A(T("View comparisons"), _href=URL("ranking", "view_comparisons_index", args=[c.id])))
    if can_view_ratings or access.can_view_submissions(c, props):
        link_list.append(A(T("View submissions"), _href=URL("ranking", "view_venue", args=[c.id])))
    if access.can_view_rating_contributions(c, props):
        link_list.append(A(T("View reviewer contribution"), _href=URL("ranking", "view_raters", args=[c.id])))
    if can_view_ratings:
        link_list.append(A(T("View final grades"), _href=URL("ranking", "view_final_grades", args=[c.id])))
    return dict(form=venue_form, link_list=link_list, venue=c, has_rated=has_rated)
예제 #9
0
def view_venue():
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    props = db(db.user_properties.user == get_user_email()).select().first()
    # if c.raters_equal_submitters:
    db.venue.rate_constraint.readable = False
    if props == None and not is_user_admin(): 
        session.flash = T('Not Authorized.')
        redirect(URL('default', 'index'))
    # Checks view permission
    can_submit = access.can_submit(c, props)
    can_rate = access.can_rate(c, props)
    has_submitted = access.has_submitted(c, props)
    has_rated = access.has_rated(c, props)
    can_manage = access.can_manage(c, props)
    can_observe = access.can_observe(c, props)
    can_view_ratings = access.can_view_ratings(c, props)
    # Builds some links that are useful to give out to people.
    submission_link = URL('submission', 'submit', args=[c.id])
    review_link = URL('venues', 'reviewing_duties')
    if not (can_submit or can_rate or has_submitted or has_rated or can_manage or can_observe or can_view_ratings):
        session.flash = T('Not authorized.')
        redirect(URL('default', 'index'))
    if can_observe:
        db.venue.grading_instructions.readable = True
    venue_form = SQLFORM(db.venue, record=c, readonly=True)
    link_list = []
    if can_manage:
        link_list.append(A(T('Edit'), _href=URL('venues', 'edit', args=[c.id], user_signature=True)))
    if can_submit:
        link_list.append(A(T('Submit to this venue'), _href=URL('submission', 'submit', args=[c.id])))
    if can_manage:
        link_list.append(A(T('Add submission'), _href=URL('submission', 'manager_submit', args=[c.id])))
    if has_submitted:
        link_list.append(A(T('My submissions'), _href=URL('feedback', 'index', args=[c.id])))
    if can_view_ratings or access.can_view_submissions(c, props):
        link_list.append(A(T('Submissions'), _href=URL('ranking', 'view_submissions', args=[c.id])))
    if can_rate and not can_manage:
        link_list.append(A(T('Review'), _href=URL('rating', 'accept_review', args=[c.id], user_signature=True)))
    if can_observe or can_manage:
        link_list.append(A(T('Comparisons'), _href=URL('ranking', 'view_comparisons_index', args=[c.id])))
    if can_view_ratings:
        link_list.append(A(T('Crowd-grades'), _href=URL('ranking', 'view_grades', args=[c.id])))
    if is_user_admin():
        link_list.append(A(T('Experimental grades'), _href=URL('ranking', 'view_exp_grades', args=[c.id])))
    return dict(form=venue_form, link_list=link_list, venue=c, has_rated=has_rated,
                submission_link=submission_link, review_link=review_link)
예제 #10
0
def view_venue_research():
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    props = db(db.user_properties.user == auth.user.email).select().first()
    if props == None: 
        can_submit = False
        can_rate = False
        has_submitted = False
        has_rated = False
        can_manage = False
	can_observe = False
        can_view_ratings = False
    else:
        can_submit = c.id in util.get_list(props.venues_can_submit) or util.is_none(c.submit_constraint)
        can_rate = c.id in util.get_list(props.venues_can_rate) or util.is_none(c.rate_constraint)
        has_submitted = c.id in util.get_list(props.venues_has_submitted)
        has_rated = c.id in util.get_list(props.venues_has_rated)
        can_manage = c.id in util.get_list(props.venues_can_manage)
        can_observe = c.id in util.get_list(props.venues_can_observe)
	# MAYDO(luca): Add option to allow only raters, or only submitters, to view
	# all ratings.
	can_view_ratings = access.can_view_ratings(c, props)
    db.venue.ranking_algo_description.readable = True
    venue_form = SQLFORM(db.venue, record=c, readonly=True)
    link_list = []
    if can_submit:
        link_list.append(A(T('Submit to this venue'), _href=URL('submission', 'submit', args=[c.id])))
    if can_rate:
        link_list.append(A(T('Review a submission'), _href=URL('rating', 'accept_review', args=[c.id])))
    if has_submitted:
        link_list.append(A(T('View my submissions'), _href=URL('feedback', 'index', args=[c.id])))
    if can_manage:
        link_list.append(A(T('Edit'), _href=URL('managed_index', vars=dict(cid=c.id))))
	link_list.append(A(T('Add submission'), _href=URL('submission', 'manager_submit', args=[c.id])))
        link_list.append(A(T('Rep sys - small alpha'), _href=URL('rating', 'run_rep_sys_research', args=[c.id, 3])))
        link_list.append(A(T('Rep sys - all compar'), _href=URL('rating', 'run_rep_sys_research', args=[c.id, 2])))
        link_list.append(A(T('Ranking without rep sys'), _href=URL('rating', 'run_rep_sys_research', args=[c.id, 1])))
    if can_observe or can_manage:
	link_list.append(A(T('View reviewing tasks'), _href=URL('ranking', 'view_tasks', args=[c.id])))
	link_list.append(A(T('View comparisons'), _href=URL('ranking', 'view_comparisons_index', args=[c.id])))
    if can_view_ratings or access.can_view_submissions(c, props):
        link_list.append(A(T('View submissions'), _href=URL('ranking', 'view_venue', args=[c.id])))
    if access.can_view_rating_contributions(c, props):
        link_list.append(A(T('View reviewer contribution'), _href=URL('ranking', 'view_raters', args=[c.id])))
    if can_view_ratings:
        link_list.append(A(T('View final grades'), _href=URL('ranking', 'view_final_grades', args=[c.id])))
    return dict(form=venue_form, link_list=link_list, venue=c, has_rated=has_rated)
예제 #11
0
def view_venue():
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    props = db(db.user_properties.email == auth.user.email).select().first()
    if props == None: 
        can_submit = False
        can_rate = False
        has_submitted = False
        has_rated = False
        can_manage = False
	can_observe = False
        can_view_ratings = False
    else:
        can_submit = c.id in util.get_list(props.venues_can_submit) or util.is_none(c.submit_constraint)
        can_rate = c.id in util.get_list(props.venues_can_rate) or util.is_none(c.rate_constraint)
        has_submitted = c.id in util.get_list(props.venues_has_submitted)
        has_rated = c.id in util.get_list(props.venues_has_rated)
        can_manage = c.id in util.get_list(props.venues_can_manage)
        can_observe = c.id in util.get_list(props.venues_can_observe)
	# MAYDO(luca): Add option to allow only raters, or only submitters, to view
	# all ratings.
	can_view_ratings = access.can_view_ratings(c, props)
    venue_form = SQLFORM(db.venue, record=c, readonly=True)
    link_list = []
    if can_submit:
        link_list.append(A(T('Submit to this venue'), _href=URL('submission', 'submit', args=[c.id])))
    if can_rate:
        link_list.append(A(T('Review a submission'), _href=URL('rating', 'accept_review', args=[c.id])))
    if has_submitted:
        link_list.append(A(T('View my submissions'), _href=URL('submission', 'my_submissions_index', args=[c.id])))
    if can_manage:
        link_list.append(A(T('Edit'), _href=URL('managed_index', vars=dict(cid=c.id))))
	link_list.append(A(T('Add submission'), _href=URL('submission', 'manager_submit', args=[c.id])))
        link_list.append(A(T('Recompute submission ranking'), _href=URL('rating', 'recompute_ranks', args=[c.id])))
        link_list.append(A(T('Run reputation system'), _href=URL('rating', 'run_rep_system', args=[c.id])))
        link_list.append(A(T('Evaluate reviewers'), _href=URL('rating', 'evaluate_reviewers', args=[c.id])))
        link_list.append(A(T('Compute final grades'), _href=URL('rating', 'compute_final_grades', args=[c.id])))
    if can_observe or can_manage:
	link_list.append(A(T('View reviewing tasks'), _href=URL('ranking', 'view_tasks', args=[c.id])))
	link_list.append(A(T('View comparisons'), _href=URL('ranking', 'view_comparisons_index', args=[c.id])))
    if can_view_ratings or access.can_view_submissions(c, props):
        link_list.append(A(T('View submissions'), _href=URL('ranking', 'view_venue', args=[c.id])))
    if access.can_view_rating_contributions(c, props):
        link_list.append(A(T('View reviewer contribution'), _href=URL('ranking', 'view_raters', args=[c.id])))
    if can_view_ratings:
        link_list.append(A(T('View final grades'), _href=URL('ranking', 'view_final_grades', args=[c.id])))
    return dict(form=venue_form, link_list=link_list, venue=c, has_rated=has_rated)
예제 #12
0
def view_final_grades():
    """This function shows the final grade of each user.
    """
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    props = db(db.user_properties.user == auth.user.email).select().first()
    if not access.can_view_ratings(c, props):
        session.flash = T(
            'You do not have access to the final grades for this venue.')
        redirect(URL('venues', 'view_venue', args=[c.id]))
    # Checking that final grades are recent and don't need recomputation.
    venue_row = db(db.venue.id == c.id).select().first()
    final_grades_date = venue_row.latest_final_grades_evaluation_date
    reviewers_eval_date = venue_row.latest_reviewers_evaluation_date
    rank_update_date = venue_row.latest_rank_update_date
    if (rank_update_date is None or reviewers_eval_date is None
            or final_grades_date is None
            or reviewers_eval_date < rank_update_date
            or final_grades_date < rank_update_date
            or final_grades_date < reviewers_eval_date):
        session.flash = T(
            'Grades are not updated/computed. Please compute final grades')
        redirect(URL('venues', 'view_venue', args=[c.id]))
    # Okay, final grades are computed and are updated.
    # Prepares the query for the grid.
    q = (db.grades.venue_id == c.id)
    grid = SQLFORM.grid(
        q,
        args=request.args[:1],
        user_signature=False,
        details=True,
        create=False,
        editable=False,
        deletable=False,
        fields=[db.grades.user, db.grades.grade],
    )
    title = A(c.name, _href=URL('venues', 'view_venue', args=[c.id]))
    histogram_link = A(T("View histogram of final grades"),
                       _href=URL('ranking',
                                 'view_grades_histogram',
                                 args=[c.id]))
    return dict(grid=grid, title=title, histogram_link=histogram_link)
예제 #13
0
def view_venue():
    """This function enables the view of the ranking of items submitted to a
    venue.  It is assumed that the people accessing this can have full
    information about the venue, including the identity of the submitters."""
    def represent_n_completed_reviews(v, r):
        if v is None:
            return None
        url = A(str(v),
                _href=URL('ranking',
                          'view_comparisons_given_submission',
                          args=[r.id]))
        return url

    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    props = db(db.user_properties.user == auth.user.email).select().first()
    if not access.can_view_submissions(c, props):
        session.flash = T(
            'You do not have access to the submissions of this venue.')
        redirect(URL('venues', 'view_venue', args=[c.id]))
    can_view_ratings = access.can_view_ratings(c, props)
    # Prepares the query for the grid.
    q = (db.submission.venue_id == c.id)
    db.submission.quality.readable = can_view_ratings
    db.submission.error.readable = can_view_ratings
    db.submission.content.readable = False
    db.submission.title.writable = False
    db.submission.content.writable = False
    db.submission.comment.writable = False
    db.submission.n_assigned_reviews.readable = True
    db.submission.n_assigned_reviews.label = T('Reviews Assigned')
    db.submission.n_completed_reviews.label = T('Comparisons')
    db.submission.n_rejected_reviews.label = T('Rejected')
    db.submission.n_completed_reviews.represent = represent_n_completed_reviews
    if c.allow_link_submission:
        db.submission.link.readable = True
    is_editable = False
    fields = [
        db.submission.title, db.submission.user, db.submission.quality,
        db.submission.percentile, db.submission.n_assigned_reviews,
        db.submission.n_completed_reviews, db.submission.n_rejected_reviews,
        db.submission.error, db.submission.content
    ]
    if access.can_enter_true_quality:
        fields.append(db.submission.true_quality)
        is_editable = True
        db.submission.true_quality.readable = db.submission.true_quality.writable = True
    links = [
        # dict(header=T('N. reviews'), body = lambda r: get_num_reviews(r.id, c.id)),
        dict(header=T('Download'),
             body=lambda r: A(T('Download'),
                              _class='btn',
                              _href=URL('submission',
                                        'download_viewer',
                                        args=[r.id, r.content])))
    ]
    if access.can_view_feedback(c, props):
        links.append(
            dict(header=T('Feedback'),
                 body=lambda r: A(
                     T('Read comments'),
                     _href=URL('feedback', 'view_feedback', args=[r.id]))))
    grid = SQLFORM.grid(
        q,
        field_id=db.submission.id,
        csv=True,
        args=request.args[:1],
        user_signature=False,
        details=False,
        create=False,
        editable=is_editable,
        deletable=False,
        fields=fields,
        links=links,
    )
    title = A(c.name, _href=URL('venues', 'view_venue', args=[c.id]))
    return dict(title=title, grid=grid)
예제 #14
0
def view_grades():
    """This function shows the final grade of each user.
    It takes as single argument the venue id.
    """

    # This function is used to get experimental grades from the db.
    def get_grade_fn(venue_id, run_id):
        def f(row):
            row = db((db.grades_exp.venue_id == venue_id)
                     & (db.grades_exp.user == row.user)
                     & (db.grades_exp.run_id == run_id)).select().first()
            if row is None:
                return 'None'
            # Generates a string summary.
            s = "subm_grade: %r subm_confidence: %r rev: %r rep: %r tot: %r" % (
                short_float_or_None(
                    row.subm_grade), short_float_or_None(row.subm_confidence),
                short_float_or_None(
                    row.review_grade), short_float_or_None(
                        row.reputation), short_float_or_None(row.grade))
            return s

        return f

    # Main function.
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    props = db(db.user_properties.user == get_user_email()).select().first()
    if not access.can_view_ratings(c, props):
        session.flash = T(
            'You do not have access to the final grades for this venue.')
        redirect(URL('venues', 'view_venue', args=[c.id]))
    # Checking that final grades are recent and don't need recomputation.
    venue_row = db(db.venue.id == c.id).select().first()
    grades_date = venue_row.latest_grades_date
    if grades_date is None:
        session.flash = T('The crowd-grades have not been computed yet.')
        redirect(URL('rating', 'crowd_grade', args=[c.id]))
    # The crowd-grades have been computed already.
    if is_user_admin():
        db.grades.reputation.readable = True
    db.grades.user.represent = represent_user_by_submission_feedback
    db.grades.venue_id.readable = False
    # Prepares the buttons at the top.
    link_list = []
    if access.can_manage(c, props):
        db.grades.assigned_grade.writable = True
        db.grades.assigned_grade.comment = T(
            'Assign the desired grade to a few users, '
            'then automatically fill-in the remaining '
            'grades via interpolation. ')
        is_editable = True
        link_list.append(
            A(T('Recompute crowd-grades'),
              _href=URL('rating', 'crowd_grade', args=[c.id])))
        link_list.append(
            A(T('Interpolate final grades'),
              _href=URL('ranking',
                        'interpolate_grades',
                        args=[c.id],
                        user_signature=True)))
        link_list.append(
            A(T('Clear final grades'),
              _href=URL('ranking',
                        'reset_grades',
                        args=[c.id],
                        user_signature=True)))

        # Creates button to release / withdraw grades.
        if c.grades_released:
            link_list.append(
                A(T('Hide grades from students'),
                  _href=URL('ranking',
                            'release_grades',
                            args=[c.id, 'False'],
                            user_signature=True)))
        else:
            link_list.append(
                A(T('Show grades to students'),
                  _href=URL('ranking',
                            'release_grades',
                            args=[c.id, 'True'],
                            user_signature=True)))
    else:
        db.grades.assigned_grade.writable = False
        is_editable = False
    # If one is the manager, and we are viewing experimental grades, offers the option
    # to download a spreadsheet including the experimental grades.
    if is_user_admin():
        link_list.append(
            A(T('View experimental runs'),
              _href=URL('ranking', 'view_exp_grades', args=[c.id])))
    if is_user_admin() and request.vars.run_ids is not None:
        link_list.append(
            A(T('Download research data'),
              _href=URL('research',
                        'download_research_data.csv',
                        args=[c.id],
                        vars=dict(run_ids=request.vars.run_ids),
                        user_signature=True)))
    if is_user_admin():
        link_list.append(
            A(T('Evaluate grades'),
              _href=URL('research',
                        'evaluate_grades',
                        args=[c.id],
                        user_signature=True)))
        link_list.append(
            A(T('Rerun evaluations'),
              _href=URL('research',
                        'rerun_evaluations',
                        args=[c.id],
                        user_signature=True)))
    # Chooses the display fields.
    display_fields = [
        db.grades.user, db.grades.venue_id, db.grades.submission_grade,
        db.grades.submission_percentile, db.grades.accuracy,
        db.grades.n_ratings, db.grades.grade, db.grades.percentile,
        db.grades.assigned_grade
    ]
    if is_user_admin():
        display_fields.append(db.grades.reputation)
        display_fields.append(db.grades.submission_control_grade)
        db.grades.submission_control_grade.readable = True
    # Adds columns for any extra grade we wish to see.
    grid_links = []
    if is_user_admin() and request.vars.run_ids is not None:
        run_ids = request.vars.run_ids.split(',')
        for r in run_ids:
            grid_links.append(dict(header=r, body=get_grade_fn(c.id, r)))
    if is_user_admin():
        # Adds a column for the true grade.
        grid_links.append(
            dict(header='',
                 body=lambda row: A(T('Enter control grade'),
                                    _class='btn',
                                    _href=URL('ranking',
                                              'edit_control_grade',
                                              args=[c.id, row.user],
                                              user_signature=True))))
    # Prepares the grid.
    q = (db.grades.venue_id == c.id)
    grid = SQLFORM.grid(
        q,
        fields=display_fields,
        args=request.args[:1],
        user_signature=False,
        details=False,
        create=False,
        editable=is_editable,
        deletable=False,
        links=grid_links,
        maxtextlength=24,
    )
    title = A(c.name, _href=URL('venues', 'view_venue', args=[c.id]))
    grades_date_info = represent_date(c.latest_grades_date, c)
    if c.grades_released:
        grades_visibility = T('Grades are visible to students')
    else:
        grades_visibility = T('Grades are not visible to students')
    return dict(grid=grid,
                title=title,
                link_list=link_list,
                grades_date_info=grades_date_info,
                grades_visibility=grades_visibility)
예제 #15
0
def view_venue():
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    props = db(db.user_properties.user == get_user_email()).select().first()
    # if c.raters_equal_submitters:
    db.venue.rate_constraint.readable = False
    if props == None and not is_user_admin():
        session.flash = T('Not Authorized.')
        redirect(URL('default', 'index'))
    # Checks view permission
    can_submit = access.can_submit(c, props)
    can_rate = access.can_rate(c, props)
    has_submitted = access.has_submitted(c, props)
    has_rated = access.has_rated(c, props)
    can_manage = access.can_manage(c, props)
    can_observe = access.can_observe(c, props)
    can_view_ratings = access.can_view_ratings(c, props)
    # Builds some links that are useful to give out to people.
    submission_link = URL('submission', 'submit', args=[c.id])
    review_link = URL('venues', 'reviewing_duties')
    if not (can_submit or can_rate or has_submitted or has_rated or can_manage
            or can_observe or can_view_ratings):
        session.flash = T('Not authorized.')
        redirect(URL('default', 'index'))
    if can_observe:
        db.venue.grading_instructions.readable = True
    venue_form = SQLFORM(db.venue, record=c, readonly=True)
    link_list = []
    if can_manage:
        link_list.append(
            A(T('Edit'),
              _href=URL('venues', 'edit', args=[c.id], user_signature=True)))
    if can_submit:
        link_list.append(
            A(T('Submit to this venue'),
              _href=URL('submission', 'submit', args=[c.id])))
    if can_manage:
        link_list.append(
            A(T('Add submission'),
              _href=URL('submission', 'manager_submit', args=[c.id])))
    if has_submitted:
        link_list.append(
            A(T('My submissions'), _href=URL('feedback', 'index',
                                             args=[c.id])))
    if can_view_ratings or access.can_view_submissions(c, props):
        link_list.append(
            A(T('Submissions'),
              _href=URL('ranking', 'view_submissions', args=[c.id])))
    if can_rate and not can_manage:
        link_list.append(
            A(T('Review'),
              _href=URL('rating',
                        'accept_review',
                        args=[c.id],
                        user_signature=True)))
    if can_observe or can_manage:
        link_list.append(
            A(T('Comparisons'),
              _href=URL('ranking', 'view_comparisons_index', args=[c.id])))
    if can_view_ratings:
        link_list.append(
            A(T('Crowd-grades'),
              _href=URL('ranking', 'view_grades', args=[c.id])))
    if is_user_admin():
        link_list.append(
            A(T('Experimental grades'),
              _href=URL('ranking', 'view_exp_grades', args=[c.id])))
    return dict(form=venue_form,
                link_list=link_list,
                venue=c,
                has_rated=has_rated,
                submission_link=submission_link,
                review_link=review_link)
예제 #16
0
def view_grades():
    """This function shows the final grade of each user.
    It takes as single argument the venue id.
    """
    # This function is used to get experimental grades from the db.
    def get_grade_fn(venue_id, run_id):
        def f(row):
            row = db((db.grades_exp.venue_id == venue_id) &
                     (db.grades_exp.user == row.user) &
                     (db.grades_exp.run_id == run_id)).select().first()
            if row is None:
                return 'None'
            # Generates a string summary.
            s = "subm_grade: %r subm_confidence: %r rev: %r rep: %r tot: %r" % (
                short_float_or_None(row.subm_grade),
                short_float_or_None(row.subm_confidence),
                short_float_or_None(row.review_grade),
                short_float_or_None(row.reputation),
                short_float_or_None(row.grade))
            return s
        return f
    
    # Main function.
    c = db.venue(request.args(0)) or redirect(URL('default', 'index'))
    props = db(db.user_properties.user == get_user_email()).select().first()
    if not access.can_view_ratings(c, props):
        session.flash = T('You do not have access to the final grades for this venue.')
        redirect(URL('venues', 'view_venue', args=[c.id]))
    # Checking that final grades are recent and don't need recomputation.
    venue_row = db(db.venue.id == c.id).select().first()
    grades_date = venue_row.latest_grades_date
    if grades_date is None:
        session.flash = T('The crowd-grades have not been computed yet.')
        redirect(URL('rating', 'crowd_grade', args=[c.id]))
    # The crowd-grades have been computed already.
    if is_user_admin():
        db.grades.reputation.readable = True
    db.grades.user.represent = represent_user_by_submission_feedback
    db.grades.venue_id.readable = False
    # Prepares the buttons at the top.
    link_list = []
    if access.can_manage(c, props):
        db.grades.assigned_grade.writable = True
        db.grades.assigned_grade.comment = T('Assign the desired grade to a few users, '
                                             'then automatically fill-in the remaining '
                                             'grades via interpolation. ')
        is_editable = True
        link_list.append(A(T('Recompute crowd-grades'), _href=URL('rating', 'crowd_grade', args=[c.id])))
        link_list.append(A(T('Interpolate final grades'), 
                           _href=URL('ranking', 'interpolate_grades', args=[c.id], user_signature=True)))
        link_list.append(A(T('Clear final grades'), 
                           _href=URL('ranking', 'reset_grades', args=[c.id], user_signature=True)))

        # Creates button to release / withdraw grades. 
        if c.grades_released:
            link_list.append(A(T('Hide grades from students'),
                               _href=URL('ranking', 'release_grades', args=[c.id, 'False'], user_signature=True)))
        else:
            link_list.append(A(T('Show grades to students'),
                               _href=URL('ranking', 'release_grades', args=[c.id, 'True'], user_signature=True)))
    else:
        db.grades.assigned_grade.writable = False
        is_editable = False
    # If one is the manager, and we are viewing experimental grades, offers the option
    # to download a spreadsheet including the experimental grades.
    if is_user_admin():
        link_list.append(A(T('View experimental runs'),
                           _href=URL('ranking', 'view_exp_grades', args=[c.id])))
    if is_user_admin() and request.vars.run_ids is not None:
        link_list.append(A(T('Download research data'), 
                           _href=URL('research', 'download_research_data.csv', args=[c.id], 
                                     vars=dict(run_ids=request.vars.run_ids),
                                     user_signature=True)))
    if is_user_admin():
        link_list.append(A(T('Evaluate grades'),
                           _href=URL('research', 'evaluate_grades', args=[c.id],
                                     user_signature=True)))
        link_list.append(A(T('Rerun evaluations'),
                           _href=URL('research', 'rerun_evaluations', args=[c.id],
                                     user_signature=True)))
    # Chooses the display fields.
    display_fields = [
        db.grades.user, db.grades.venue_id,
        db.grades.submission_grade, db.grades.submission_percentile,
        db.grades.accuracy, db.grades.n_ratings, 
        db.grades.grade, db.grades.percentile,
        db.grades.assigned_grade]
    if is_user_admin():
        display_fields.append(db.grades.reputation)
        display_fields.append(db.grades.submission_control_grade)
        db.grades.submission_control_grade.readable = True
    # Adds columns for any extra grade we wish to see.
    grid_links = []
    if is_user_admin() and request.vars.run_ids is not None:
        run_ids = request.vars.run_ids.split(',')
        for r in run_ids:
            grid_links.append(dict(
                header = r, 
                body = get_grade_fn(c.id, r)))
    if is_user_admin():
        # Adds a column for the true grade.
        grid_links.append(dict(
            header = '',
            body = lambda row: A(T('Enter control grade'), _class='btn',
                _href=URL('ranking', 'edit_control_grade', args=[c.id, row.user], user_signature=True))))
    # Prepares the grid.
    q = (db.grades.venue_id == c.id)
    grid = SQLFORM.grid(q,
        fields=display_fields,
        args=request.args[:1],
        user_signature=False, details=False,
        create=False, editable=is_editable, deletable=False,
        links=grid_links,
        maxtextlength=24,
        )
    title = A(c.name, _href=URL('venues', 'view_venue', args=[c.id]))
    grades_date_info = represent_date(c.latest_grades_date, c)
    if c.grades_released:
        grades_visibility = T('Grades are visible to students')
    else:
        grades_visibility = T('Grades are not visible to students')
    return dict(grid=grid, title=title, link_list=link_list, 
                grades_date_info=grades_date_info, grades_visibility=grades_visibility)