Skip to content
This repository was archived by the owner on Jun 30, 2024. It is now read-only.

Commit b60b0c1

Browse files
committed
merge master
2 parents 4a25ac4 + 1959c66 commit b60b0c1

File tree

7 files changed

+126
-19
lines changed

7 files changed

+126
-19
lines changed

controllers/admin.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
4040
datafile=[],
4141
)
4242

43+
AUTOGRADEABLE = set(
44+
["clickablearea", "fillintheblank", "dragndrop", "mchoice", "parsonsprob"]
45+
)
46+
4347
ALL_WHICH_OPTIONS = ["first_answer", "last_answer", "best_answer"]
4448
WHICH_TO_GRADE_POSSIBLE_VALUES = dict(
4549
clickablearea=ALL_WHICH_OPTIONS,
@@ -643,13 +647,22 @@ def grading():
643647
db.assignment_questions.question_id,
644648
db.assignment_questions.points,
645649
db.questions.name,
650+
db.questions.question_type,
651+
db.questions.autograde,
646652
orderby=db.assignment_questions.sorting_priority,
647653
)
648654
questions = []
649655
if row.name not in question_points:
650656
question_points[row.name] = {}
651657
for q in assignment_questions:
652-
questions.append(q.questions.name)
658+
if (
659+
q.questions.question_type in AUTOGRADEABLE
660+
or q.questions.autograde == "unittest"
661+
):
662+
name_suff = "+"
663+
else:
664+
name_suff = ""
665+
questions.append(q.questions.name + name_suff)
653666
question_points[row.name][q.questions.name] = q.assignment_questions.points
654667

655668
assignments[row.name] = questions

controllers/dashboard.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ def questiongrades():
566566
)
567567
sid = request.vars.sid
568568
student = db(db.auth_user.username == sid).select(
569-
db.auth_user.first_name, db.auth_user.last_name
569+
db.auth_user.first_name, db.auth_user.last_name, db.auth_user.username
570570
)
571571

572572
query = """select questions.name, score, points
@@ -736,7 +736,6 @@ def subchapoverview():
736736

737737
if request.vars.tablekind == "sccount":
738738
x = pt.to_dict()
739-
print(x)
740739
for k in x:
741740
for j in x[k]:
742741
x[k][j] = format_cell(k, j[0], j[1], x[k][j])

static/js/admin.js

Lines changed: 68 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ function createGradingPanel(element, acid, studentId, multiGrader) {
334334
function show(data) {
335335
// get rid of any other modals -- incase they are just hanging out.
336336
//jQuery('.modal.modal-grader:not(#modal-template .modal)').remove();
337-
337+
// the submit button is connected to the save function by a jquery submit event.
338338
var rightDiv = jQuery(element);
339339

340340
jQuery("#gradingform", rightDiv).remove();
@@ -536,13 +536,18 @@ function makeOption(text, value, disabledQ) {
536536
function populateQuestions(select, question_names) {
537537
$(select).empty();
538538
var chapter = "";
539+
var questiontext;
539540
for (i = 0; i < question_names.length; i++) {
540541
var q = question_names[i];
541-
var questiontext = "";
542-
questiontext = q;
543-
/*
544-
};*/
545-
select.add(makeOption(questiontext, question_names[i]));
542+
if (q.endsWith("+")) {
543+
q = q.substring(0, q.length - 1);
544+
questiontext = q + " ✓";
545+
} else {
546+
questiontext = q;
547+
}
548+
549+
// makeOption(text,value)
550+
select.add(makeOption(questiontext, q));
546551
}
547552

548553
$(select).select2({
@@ -1615,7 +1620,7 @@ function create_question(formdata) {
16151620
}
16161621

16171622
// Given a question ID, preview it.
1618-
function preview_question_id(question_id, preview_div) {
1623+
function preview_question_id(question_id, preview_div, sid, gradeit) {
16191624
if (arguments.length == 1) {
16201625
preview_div = "component-preview";
16211626
}
@@ -1624,10 +1629,65 @@ function preview_question_id(question_id, preview_div) {
16241629
acid: question_id,
16251630
}).done(function (html_src) {
16261631
// Render it.
1627-
renderRunestoneComponent(html_src, preview_div, { acid: question_id });
1632+
data = { acid: question_id };
1633+
if (sid) {
1634+
data.sid = sid;
1635+
data.graderactive = true;
1636+
data.useRunestoneServices = true;
1637+
}
1638+
renderRunestoneComponent(html_src, preview_div, data);
1639+
if (gradeit) {
1640+
let pd = document.getElementById(preview_div);
1641+
pd.appendChild(renderGradingComponents(sid, question_id));
1642+
}
16281643
});
16291644
}
16301645

1646+
function renderGradingComponents(sid, divid) {
1647+
let div = document.createElement("div");
1648+
let grade = document.createElement("input");
1649+
let gradelabel = document.createElement("label");
1650+
gradelabel.for = "grade-input";
1651+
$(gradelabel).text("Grade");
1652+
grade.type = "text";
1653+
grade.id = "grade-input";
1654+
let comment = document.createElement("input");
1655+
let commentlabel = document.createElement("label");
1656+
$(commentlabel).text("Comment");
1657+
comment.type = "text";
1658+
comment.id = "comment-input";
1659+
commentlabel.for = "comment-input";
1660+
1661+
let butt = document.createElement("button");
1662+
$(butt).text("Save Grade");
1663+
$(butt).addClass("btn btn-normal");
1664+
1665+
$(butt).click(function () {
1666+
jQuery.ajax({
1667+
url: eBookConfig.gradeRecordingUrl,
1668+
type: "POST",
1669+
dataType: "JSON",
1670+
data: {
1671+
acid: divid,
1672+
sid: sid,
1673+
grade: $(grade).val(),
1674+
comment: $(comment).val(),
1675+
},
1676+
success: function (data) {
1677+
$(grade).css("background", "lightgreen");
1678+
$(comment).css("background", "lightgreen");
1679+
},
1680+
});
1681+
});
1682+
div.appendChild(gradelabel);
1683+
div.appendChild(grade);
1684+
div.appendChild(commentlabel);
1685+
div.appendChild(comment);
1686+
div.appendChild(butt);
1687+
1688+
return div;
1689+
}
1690+
16311691
// Called by the "Preview" button of the "Write" panel.
16321692
function preview_question(form, preview_div) {
16331693
if (arguments.length == 1) {

views/_sphinx_static_files.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,16 @@
2222
<script type="text/javascript" src="{{=base_static_url}}/jquery.tablesorter.js"></script>
2323
<script type="text/javascript" src="{{=base_static_url}}/jquery-ui-1.10.3.custom.min.js"></script>
2424

25+
<<<<<<< HEAD
26+
=======
27+
<link href="{{=base_static_url}}/codemirror.css" rel="stylesheet" type="text/css"/>
28+
<script src="{{=base_static_url}}/underscore.js"></script>
29+
>>>>>>> master
2530
<link rel="stylesheet" type="text/css" href="{{=URL('static', 'jquery.datetimepicker.min.css')}}" />
2631
<link href="{{=base_static_url}}/jquery-ui-1.10.3.custom.min.css" rel="stylesheet" type="text/css"/>
32+
<link rel="stylesheet" href="{{=base_static_url}}/pygments.css" type="text/css"/>
33+
<link rel="stylesheet" href="{{=base_static_url}}/runestone-custom-sphinx-bootstrap.css?v={{=settings.components_version}}" type="text/css"/>
34+
<link rel="stylesheet" type="text/css" href="{{=base_static_url}}/accessibility.css?v=DB047029"/>
2735

2836
<script type="text/javascript" src="{{=base_static_url}}/sharedb.js?v={{=settings.components_version}}"></script>
2937

@@ -158,6 +166,9 @@
158166
list-style-type: circle;
159167
list-style-image: url('{{=base_static_url}}/active.png');
160168
}
169+
.gradeablerow:hover {
170+
background-color: #cccccc;
171+
}
161172
</style>
162173

163174

@@ -186,4 +197,5 @@
186197
eBookConfig.isLoggedIn = true ? "{{='auth' in globals()}}" == "True" : false;
187198
eBookConfig.useRunestoneServices = true;
188199
eBookConfig.basecourse = "{{=course['base_course']}}";
200+
eBookConfig.gradeRecordingUrl = `${eBookConfig.app}/assignments/record_grade`;
189201
</script>

views/dashboard/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ <h2 style="width: 800px; display: inline;">{{=selected_chapter['chapter_name']}}
5050
{{ for section in sections: }}
5151
{{ sectionnumber=section["number"] }}
5252
<div style="height: 30px;">
53-
<div style="font-size:1.0em; font-weight: bold; margin-top: 0.5em;"><a style="color:black;" href="{{=get_course_url(selected_chapter['chapter_label'], section['text'])}}">{{=selected_chapter['chapter_num']}}.{{=sectionnumber}}. {{=section["name"]}}</a></div>
53+
<div style="font-size:1.0em; font-weight: bold; margin-top: 0.5em;"><a style="color:black;" href="{{=get_course_url(selected_chapter['chapter_label'], section['text'])}}.html">{{=selected_chapter['chapter_num']}}.{{=sectionnumber}}. {{=section["name"]}}</a></div>
5454
<div style="" class="dash-bar-container">
5555
<div class="dash-bar dash-bar-correct" style="width: {{=section['readPercent']}};"> {{=section["readPercent"]}}&nbsp;</div>
5656
<div class="dash-bar dash-bar-attempts" style=" width: {{=section['startedPercent']}};"> {{=section["startedPercent"]}}&nbsp;</div>

views/dashboard/questiongrades.html

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{{extend 'admin/instructors.html'}}
2+
23
{{ block tabcontent }}
34

45
<script type="text/javascript" src="https://kozea.github.io/pygal.js/javascripts/svg.jquery.js"></script>
@@ -10,8 +11,8 @@
1011

1112
<div id="dashboard">
1213
<h2 style="text-align:center;">{{=assignment['name']}}</h2>
13-
<h2>Report for {{=student[0]['first_name']}} {{=student[0]['last_name']}}</h2>
14-
14+
<h2>Report for {{=student[0]['first_name']}} {{=student[0]['last_name']}}</h2>
15+
<p>Click on the question name to display or update the grade for any question.</p>
1516
<div id="questions" class="col-md-12">
1617
<table class="sortable">
1718
<thead style="cursor: pointer;">
@@ -24,14 +25,21 @@ <h2>Report for {{=student[0]['first_name']}} {{=student[0]['last_name']}}</h2>
2425
<tbody>
2526
{{for row in rows:}}
2627
<tr>
27-
{{for item in range(len(row)):}}
28-
<td>{{=row[item]}}</td>
28+
{{for item in range(len(row)):}}
29+
{{ if item == 0:}}
30+
<td onclick="preview_question_id('{{=row[item]}}', 'question_viewer', '{{=student[0]['username']}}', true)"
31+
class="gradeablerow">
32+
{{ else: }}
33+
<td>
34+
{{ pass }}
35+
{{=row[item]}}
36+
</td>
2937
{{if item == 1:}}
3038
{{total += row[item] or 0}}
3139
{{pass}}
3240
{{pass}}
3341
</tr>
34-
{{pass}}
42+
{{pass}}
3543
</tbody>
3644
<tfoot>
3745
<tr>
@@ -44,4 +52,8 @@ <h2>Report for {{=student[0]['first_name']}} {{=student[0]['last_name']}}</h2>
4452
</div>
4553

4654
</div>
55+
<p></p>
56+
<div id="question_viewer">
57+
</div>
58+
4759
{{end}}

views/dashboard/subchapdetail.html

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1-
{{extend 'admin/instructors.html'}} {{ block moreincludes }} {{super}}
1+
{{extend 'admin/instructors.html'}}
2+
3+
{{ block moreincludes }}
4+
{{super}}
5+
{{include '_sphinx_static_files.html'}}
6+
27
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/handsontable.full.js"></script>
38
<link
49
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/handsontable.full.min.css"
510
rel="stylesheet"
611
media="screen"
712
/>
8-
{{ end }} {{ block tabcontent }}
13+
{{ end }}
14+
15+
{{ block tabcontent }}
916
<h2>{{=chapter}} / {{=subchapter}}</h2>
1017
<h2>{{=sid}}</h2>
1118
<hr />
@@ -31,7 +38,11 @@ <h2>{{=sid}}</h2>
3138
<td>{{=row["first"]}}</td>
3239
<td>{{=row["last"]}}</td>
3340
<td>{{=row["clicks"]}}</td>
41+
<td><button onclick="preview_question_id('{{=row['name']}}', 'question_viewer', '{{=sid}}', true)">View</button></td>
3442
</tr>
3543
{{ pass }}
3644
</table>
45+
46+
<div id="question_viewer"></div>
47+
3748
{{ end }}

0 commit comments

Comments
 (0)