Skip to content

Commit

Permalink
Merge branch 'gradebook-dev' of github.com:presnick/runestone into pr…
Browse files Browse the repository at this point in the history
…esnick-gradebook-dev
  • Loading branch information
bnmnetp committed Jun 23, 2014
2 parents 41f85b4 + 5bed84a commit 91eec82
Show file tree
Hide file tree
Showing 22 changed files with 1,758 additions and 57 deletions.
61 changes: 52 additions & 9 deletions controllers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# select acid, sid from code as T where timestamp = (select max(timestamp) from code where sid=T.sid and acid=T.acid);


@auth.requires_login()
@auth.requires(lambda: verifyInstructorStatus(auth.user.course_name, auth.user), requires_login=True)
def index():
row = db(db.courses.id == auth.user.course_id).select(db.courses.course_name).first()
# get current build info
Expand Down Expand Up @@ -56,9 +56,14 @@ def listassignments():
else:
q = db((db.code.course_id == auth.user.course_id)
& (db.code.timestamp >= course.term_start_date))

rset = q.select(db.code.acid,orderby=db.code.acid,distinct=True)
return dict(exercises=rset,course_id=course.course_name)
prefixes = {}
for row in q.select(db.code.acid,orderby=db.code.acid,distinct=True):
acid = row.acid
acid_prefix = acid.split('_')[0]
if acid_prefix not in prefixes.keys():
prefixes[acid_prefix] = []
prefixes[acid_prefix].append(acid)
return dict(sections=prefixes,course_id=course.course_name)

@auth.requires(lambda: verifyInstructorStatus(auth.user.course_name, auth.user), requires_login=True)
def listassessments():
Expand Down Expand Up @@ -126,11 +131,49 @@ def gradeassignment():
acid = request.vars.id
course = db(db.courses.id == auth.user.course_id).select(db.courses.course_name).first()

rset = db.executesql('''select acid, sid, grade, T.id, first_name, last_name, comment from code as T, auth_user
where sid = username and T.course_id = '%s' and acid = '%s' and timestamp =
(select max(timestamp) from code where sid=T.sid and acid=T.acid) order by last_name;''' %
(auth.user.course_id,acid))
return dict(solutions=rset,course_id=course.course_name)
section_form=FORM(
INPUT(_type="hidden", _name="id", _value=acid),
_class="form-inline",
_method="GET",
)
section_form.append(LABEL(
INPUT(_name="section_id", _type="radio", _value=""),
"All Students",
_class="radio-inline",
))
for section in db(db.sections.course_id == auth.user.course_id).select():
section_form.append(LABEL(
INPUT(_name="section_id", _type="radio", _value=section.id),
section.name,
_class="radio-inline",
))

section_form.append(INPUT(_type="submit", _value="Filter Students", _class="btn btn-default"))

joined = db((db.code.sid == db.auth_user.username) & (db.section_users.auth_user == db.auth_user.id))
q = joined((db.code.course_id == auth.user.course_id) & (db.code.acid == acid))

if section_form.accepts(request.vars, session, keepvalues=True) and section_form.vars.section_id != "":
q = q(db.section_users.section == section_form.vars.section_id)

rset = q.select(
db.code.acid,
db.code.sid,
db.code.grade,
db.code.id,
db.auth_user.first_name,
db.auth_user.last_name,
db.code.comment,
distinct = db.code.sid,
orderby = db.code.sid|db.code.timestamp,
)
return dict(
acid = acid,
sid = sid,
section_form = section_form,
solutions=rset,
course_id=course.course_name
)


@auth.requires(lambda: verifyInstructorStatus(auth.user.course_name, auth.user), requires_login=True)
Expand Down
51 changes: 26 additions & 25 deletions controllers/ajax.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,44 +503,45 @@ def getSphinxBuildStatus():
elif st == 'RUNNING' or st == 'QUEUED' or st == 'ASSIGNED':
status = 'false'
return dict(status=status, course_url=course_url)
else: # task failed
else: # task failed
status = 'failed'
tb = db(db.scheduler_run.task_id == row.id).select().first()['traceback']
return dict(status=status, traceback=tb)

def getassignmentgrade():
print 'in getassignmentgrade'
if auth.user:
sid = auth.user.username
else:
return json.dumps([dict(message="not logged in")])

response.headers['content-type'] = 'application/json'
if not auth.user:
return json.dumps([dict(message="not logged in")])

divid = request.vars.div_id
course_id = auth.user.course_id
"select grade, comment from code where sid='%s' and acid='%s' and grade is not null order by timestamp desc"
result = db( (db.code.sid == sid) &
(db.code.acid == divid) &
(db.code.course_id == course_id) &
(db.code.grade != None) ).select(db.code.grade,db.code.comment,orderby=~db.code.timestamp).first()

ret = {}

result = db(
(db.code.sid == auth.user.username) &
(db.code.acid == db.problems.acid) &
(db.problems.assignment == db.assignments.id) &
(db.assignments.released == True) &
(db.code.acid == divid)
).select(
db.code.grade,
db.code.comment,
).first()

ret = {
'grade':"Not graded yet",
'comment': "No Comments",
'avg': 'None',
'count': 'None',
}
if result:
ret['grade'] = result.grade
if result.comment:
ret['comment'] = result.comment
else:
ret['comment'] = "No Comments"
else:
ret['grade'] = "not graded yet"
ret['comment'] = "No Comments"

query = '''select avg(grade), count(grade)
from code where sid='%s' and course_id='%d' and grade is not null;''' % (sid,course_id)
query = '''select avg(grade), count(grade)
from code where acid='%s';''' % (divid)

rows = db.executesql(query)
ret['avg'] = rows[0][0]
ret['count'] = rows[0][1]
rows = db.executesql(query)
ret['avg'] = rows[0][0]
ret['count'] = rows[0][1]

return json.dumps([ret])
Loading

0 comments on commit 91eec82

Please sign in to comment.