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

Commit 779e466

Browse files
committed
Add ActiveCode.addActiveCodeToDiv to support grading interface
1 parent dcf3b8b commit 779e466

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

runestone/activecode/js/activecode.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ ActiveCode.prototype.init = function(opts) {
2323
this.python3 = opts.python3;
2424
this.origElem = orig;
2525
this.divid = orig.id;
26-
this.code = $(orig).text();
26+
this.code = $(orig).text() || "\n\n\n\n\n";
2727
this.language = $(orig).data('lang');
2828
this.timelimit = $(orig).data('timelimit');
2929
this.includes = $(orig).data('include');
@@ -316,6 +316,9 @@ ActiveCode.prototype.loadEditor = function () {
316316

317317
if (res.source) {
318318
this.editor.setValue(res.source);
319+
setTimeout(function() {
320+
this.editor.refresh();
321+
}.bind(this),500);
319322
$(this.loadButton).tooltip({'placement': 'bottom',
320323
'title': "Loaded your saved code.",
321324
'trigger': 'manual'
@@ -657,19 +660,21 @@ ActiveCode.prototype.runProg = function() {
657660
};
658661

659662
ActiveCode.addActiveCodeToDiv = function(outerdiv, acdiv, sid, initialcode, language) {
660-
var acdiv, thepre, newac;
663+
var thepre, newac;
664+
$("#"+acdiv).empty();
661665
thepre = document.createElement("pre");
662666
thepre['data-component'] = "activecode";
663667
thepre.id = acdiv;
664668
thepre['data-lang'] = language;
665669
$("#"+acdiv).append(thepre);
666670
var opts = {'orig' : thepre, 'useRunestoneServices': true };
667-
newac = new ActiveCode(opts)
671+
// todo: look at lang to decide what kind of ActiveCode to make
672+
newac = new ActiveCode(opts);
668673
savediv = newac.divid;
669674
newac.divid = outerdiv;
670675
newac.loadEditor();
671676
newac.divid = savediv;
672-
677+
newac.editor.setSize(500,300);
673678
};
674679

675680
ActiveCode.createScratchActivecode = function() {
@@ -1548,4 +1553,4 @@ $(document).bind("runestone:logout",function() {
15481553
edList[k].disableSaveLoad();
15491554
}
15501555
}
1551-
});
1556+
});

0 commit comments

Comments
 (0)