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

Commit 047e46d

Browse files
author
Brad Miller
committed
Add: SQL Logging and History
1 parent 65d41c6 commit 047e46d

2 files changed

Lines changed: 33 additions & 6 deletions

File tree

runestone/activecode/js/activecode.js

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2410,8 +2410,10 @@ SQLActiveCode.prototype.init = function(opts) {
24102410

24112411

24122412
SQLActiveCode.prototype.runProg = function() {
2413-
2413+
var result_mess = "success"
2414+
var scrubber_dfd, history_dfd, saveCode
24142415
// Clear any old results
2416+
saveCode = "True"
24152417
let divid = this.divid+'_sql_out';
24162418
let respDiv = document.getElementById(divid);
24172419
if (respDiv) {
@@ -2423,12 +2425,37 @@ SQLActiveCode.prototype.runProg = function() {
24232425
try {
24242426
var res = this.db.exec(query);
24252427
} catch(error) {
2426-
$(this.output).text(error)
2427-
$(this.outDiv).show()
2428-
return
2428+
result_mess = error.toString();
2429+
$(this.output).text(error);
2430+
$(this.outDiv).show();
2431+
24292432
}
2433+
this.logRunEvent({
2434+
'div_id': this.divid,
2435+
'code': this.editor.getValue(),
2436+
'lang': this.language,
2437+
'errinfo': result_mess,
2438+
'to_save': saveCode,
2439+
'prefix': this.pretext,
2440+
'suffix': this.suffix,
2441+
'partner': this.partner
2442+
}); // Log the run event
24302443

2431-
//
2444+
var __ret = this.manage_scrubber(scrubber_dfd, history_dfd, saveCode);
2445+
history_dfd = __ret.history_dfd;
2446+
saveCode = __ret.saveCode;
2447+
2448+
history_dfd.then(function() {
2449+
if (this.slideit) {
2450+
$(this.historyScrubber).on("slidechange", this.slideit.bind(this));
2451+
}
2452+
$(this.historyScrubber).slider("enable");
2453+
});
2454+
2455+
if (result_mess != "success") {
2456+
return;
2457+
}
2458+
// Create a nice table to show the result of the query
24322459
if (res[0].values.length > 100) {
24332460
$(this.output).text("Result set is longer than 100 rows limiting output to first 100")
24342461
}

runestone/activecode/test/pavement.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
'appname':master_app,
3030
'loglevel': 0,
3131
'course_url':master_url,
32-
'use_services': 'false',
32+
'use_services': False,
3333
'python3': 'true',
3434
'dburl': '', 'downloads_enabled': 'true', 'enable_chatcodes': 'false', 'allow_pairs': 'false',
3535
'basecourse': 'activecodetest',

0 commit comments

Comments
 (0)