Skip to content

Commit 86101db

Browse files
committed
New tracing interface for instructors
1 parent cedc264 commit 86101db

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/engine.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,7 @@ BlockPyEngine.prototype.runStudentCode = function(after) {
497497
report['student'] = {
498498
'success': true,
499499
'trace': engine.executionBuffer.trace,
500+
'lines': engine.executionBuffer.trace.map(x => x.line),
500501
'module': module,
501502
'output': engine.main.model.execution.output
502503
}
@@ -562,6 +563,7 @@ BlockPyEngine.prototype.runInstructorCode = function(filename, quick, after) {
562563
'compatibility.get_plots = get_plots\n'+
563564
'compatibility.get_output = get_output\n'+
564565
'compatibility.reset_output = reset_output\n'+
566+
'compatibility.trace_lines = trace_lines\n'+
565567
'def capture_output(func, *args):\n'+
566568
' reset_output()\n'+
567569
' func(*args)\n'+
@@ -617,7 +619,9 @@ BlockPyEngine.prototype.parseGlobals = function(variables) {
617619
if (!this.main.model.settings.trace_off()) {
618620
for (var property in variables) {
619621
var value = variables[property];
620-
if (property !== "__name__" && property !== "__doc__") {
622+
if (property !== "__name__" &&
623+
property !== "__doc__" &&
624+
property !== "__package__") {
621625
property = property.replace('_$rw$', '')
622626
.replace('_$rn$', '');
623627
var parsed = this.parseValue(property, value);

src/sk_mod_instructor.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ var $sk_mod_instructor = function(name) {
8383
return Sk.ffi.remapToPy(Sk.executionReports['verifier'].code);
8484
});
8585

86+
mod.trace_lines = new Sk.builtin.func(function() {
87+
if (Sk.executionReports['student'].success) {
88+
var lines = Sk.executionReports['student'].lines;
89+
return new Sk.builtin.list(lines);
90+
} else {
91+
return new Sk.builtin.list([]);
92+
}
93+
});
94+
8695
/**
8796
*
8897
*/

0 commit comments

Comments
 (0)