Commit 2cf009ef authored by GI's avatar GI

Added grade layout

parent ff6e78a4
......@@ -207,7 +207,8 @@ class Site( staticjinja.Site ):
return True if self.partial_re.search( f ) else False
static_re = re.compile(
'(?:^|/)static/|\.(:?pdf|jpg|png|svg|eps|ps|txt|sty|mp4|webm|bst)$',
'(?:^|/)static/|\.(:?pdf|jpg|png|svg|eps|ps|txt|sty|'
+ 'mp4|webm|bst|csv)$',
flags=re.I )
def is_static( self, f ):
if not self.is_ignored(f) and self.static_re.search( f ):
......
......@@ -203,6 +203,9 @@ def render(site, template, **context):
except:
if( template.name.startswith( "blog" ) ):
layout = 'md-blogpost.j2'
elif re.match( r'teaching\/[0-9-]+\/[0-9a-z-]+\/auth/grades\.md',
template.name ):
layout = 'md-grades.j2'
elif re.match( r'teaching\/[0-9-]+\/[0-9a-z-]+\/.*\.md',
template.name ):
layout = 'md-class.j2'
......
......@@ -10,20 +10,19 @@ def tofloat(x):
print( "Content-type: application/json;\n" )
docroot = os.environ.get( 'CONTEXT_DOCUMENT_ROOT',
os.environ.get('PWD') )
fname = os.path.join( docroot, '{{path_prefix}}',
os.environ.get('QUERY_STRING') )
user = os.environ.get( 'eppn', '' )[:-len('@andrew.cmu.edu')]
{% if dev_env == 'local' %}
# No authentication; just impersonate someone for testing
user = 'afogelso'
{% endif %}
data = {}
try:
arguments = cgi.FieldStorage();
#print( 'getgrades.py:', arguments, file=sys.stderr )
docroot = os.environ.get( 'CONTEXT_DOCUMENT_ROOT',
os.environ.get('PWD') )
fname = os.path.join( docroot, '{{path_prefix}}',
arguments.getvalue('filename') )
user = os.environ.get( 'eppn', '' )[:-len('@andrew.cmu.edu')]
with open(fname) as f:
reader = csv.reader( f )
header = next( reader )
......@@ -45,7 +44,7 @@ try:
for row in reader:
# Check for users score
if user == row[andrewid]:
if user == row[andrewid] and len(user):
data['cols'].append( ['Your Score']
+ row[scores_start:] + ['']*(scores_end - len(row)) )
data['name'] = row[fname] + ' ' + row[lname]
......@@ -57,7 +56,8 @@ try:
if sf > 0: scores[i].append(sf)
# Check for total points
if row[lname] == '' and row[fname] == '':
if arguments.getvalue('show_total', 'true') == 'true' \
and row[lname] == '' and row[fname] == '':
# print( 'getgrades.py:', row, file=sys.stderr )
rf = map( tofloat, row[scores_start:scores_end] )
if all( s != 0 for s in rf ):
......@@ -67,20 +67,17 @@ try:
# This is the last row we care about
break
data['cols'].append( ['# Submissions']
+ [len(s) for s in scores] )
data['cols'].append( ['Max']
+ [max(s) for s in scores] )
#data['cols'].append( ['Min']
# + [min(s) for s in scores] )
data['cols'].append( ['Median']
+ [round(statistics.median(s), 1) for s in scores] )
data['cols'].append( ['Mean']
+ [round(statistics.mean(s), 1) for s in scores] )
if arguments.getvalue( 'show_stats', 'true' ) == 'true':
data['cols'].append( ['# Submissions']
+ [len(s) for s in scores] )
data['cols'].append( ['Max']
+ [max(s) for s in scores] )
#data['cols'].append( ['Min']
# + [min(s) for s in scores] )
data['cols'].append( ['Median']
+ [round(statistics.median(s), 1) for s in scores] )
data['cols'].append( ['Mean']
+ [round(statistics.mean(s), 1) for s in scores] )
#data['cols'].append( ['Std. Dev']
# + [round(statistics.stdev(s), 2) for s in scores] )
......
{%- if path_exists( '../course_info.j2' ) -%}
{%- from get_file('../course_info.j2') import course -%}
{% set page_email = course.email -%}
{% if not breadcrumb -%}
{% set breadcrumb = '../|' ~ course.title -%}
{% endif -%}
{% endif -%}
{% extends "layouts/md-class.j2" -%}
{% block content_block -%}
<div id='status' class='alert alert-info' role='alert'>
Loading...
</div>
{{ content }}
{% if (grade_table | default('show')) == 'show' -%}
<table class='table' id='scores'></table>
{%- endif -%}
{%- endblock -%}
{% block scripts -%}
{{ super() }}
<script>
{#-
window.addEventListener('DOMContentLoaded', function() {
get_grades('{{dirname}}/grades.csv', false, false);
});
#}
$(function() {
get_grades('{{dirname}}/grades.csv',
{{show_stats | default('true')}},
{{show_total | default('true')}});
});
</script>
{%- endblock -%}
......@@ -80,7 +80,7 @@ function submit_comment() {
.fail( failfn );
}
function get_grades(fname) {
function get_grades(fname, show_stats=true, show_total=true) {
function failfn( msg ) {
$('#status')
.attr( 'class', 'alert alert-danger' )
......@@ -95,10 +95,12 @@ function get_grades(fname) {
}
$.getJSON( "{{get_link('/cgi-bin/auth/getgrades.py')}}",
fname, function(data) {
{ filename: fname, show_stats: show_stats, show_total: show_total },
function(data) {
var table = $('#scores');
var thead = table.children('thead').children();
var tbody = table.children('tbody');
var thead = $('<thead><tr><th></th></tr></thead>').appendTo(table)
.children();
var tbody = $('<tbody></tbody>').appendTo(table);
{% if dev_env == 'local' -%}
/* Save for debugging */
......
{%- from get_file('../course_info.j2') import course -%}
title: Your Grades
breadcrumb: ../|{{course.title}}
<script>
window.addEventListener('DOMContentLoaded', function() {
get_grades('{{dirname}}/grades.csv');
});
</script>
<div id='status' class='alert alert-info' role='alert'>
Loading...
</div>
Hi <span id='student-name'>there</span>.
Here are all the grades / scores I have on record for you, along with the averages.
<table class='table' id='scores'>
<thead><tr><th></th></tr></thead>
<tbody></tbody>
</table>
{#-
## CGI Output
<pre id='form-output'></pre>
......
......@@ -17,8 +17,8 @@
* An [[auth/old-final.pdf|old final]] with [[auth/old-final-sol.pdf|solutions]].
* 2016-17 [[../../2016-17/944-scalc-finance1/pdfs/final.pdf|final]] and [[auth/2016-final-sol.pdf|solutions]].
* 2017-18 [[../../2017-18/944-scalc-finance1/pdfs/final.pdf|final]] and [[auth/2017-final-sol.pdf|solutions]].
{#
* Your [[pdfs/final.pdf|final]] and [[auth/final-sol.pdf|solutions]].
{#
* [Stochastic Calculus Self Study](https://tepper.instructure.com/courses/43672)
-#}
* [[../../2017-18/944-scalc-finance1|Last years website]]
......@@ -11,3 +11,6 @@ Homework and solutions will be posted here.
{%- if glob('auth/sol*') %}
* [[sol.md]]
{%- endif %}
{%- if glob('auth/grades.csv') %}
* [[auth/grades.md|Your Grades]]
{%- endif %}
<Files "*.csv">
Order deny,allow
Deny from all
</Files>
Options -Indexes
# Shibboleth header
AuthType Shibboleth
ShibRequireSession On
......
title: Your Grades
show_stats: false
Hi <span id='student-name'>there</span>.
Here is your score on the final, and overall course grade.
(New York students: as the FCE response rate was significantly below 80%, your grades will be delayed until March 13th.)
{#-
<table class='table' id='scores'></table>
## CGI Output
<pre id='form-output'></pre>
-#}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment