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

Commit 22eda5d

Browse files
committed
Instructor button to share code
1 parent d169442 commit 22eda5d

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

runestone/activecode/js/activecode.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,32 @@ ActiveCode.prototype.createControls = function () {
293293
$(butt).click((function() {new AudioTour(this.divid, this.code, 1, $(this.origElem).data("audio"))}).bind(this));
294294
}
295295

296+
if (eBookConfig.isInstructor) {
297+
let butt = document.createElement("button");
298+
$(butt).addClass("btn btn-info");
299+
$(butt).text("Share Code");
300+
$(butt).css("margin-left", "10px");
301+
this.shareButt = butt;
302+
ctrlDiv.appendChild(butt);
303+
$(butt).click((function() {
304+
let data = {
305+
divid: this.divid,
306+
code: this.editor.getValue(),
307+
lang: this.language,
308+
};
309+
$.getJSON('/runestone/ajax/broadcast_code.json',
310+
data,
311+
function (status) {
312+
if (status.mess === 'success') {
313+
alert(`Shared Code with ${status.share_count} students`);
314+
} else {
315+
alert("Sharing Failed");
316+
}
317+
318+
});
319+
}).bind(this));
320+
}
321+
296322
if (this.enablePartner) {
297323
var checkPartner = document.createElement("input");
298324
checkPartner.type = 'checkbox'

0 commit comments

Comments
 (0)