Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
4577d28
Merge pull request #25 from RunestoneInteractive/master
flysaiah Feb 11, 2016
c0ee7b6
Merge pull request #26 from RunestoneInteractive/master
flysaiah Apr 3, 2016
aaf6587
Modified timed checking for existing components to allow for ignorabl…
flysaiah Apr 8, 2016
4852ace
Removed unnecessary SA code that was causing bugs
flysaiah Apr 8, 2016
7f4372f
Fixed small syntax bug
flysaiah Apr 8, 2016
662c03d
Added support for ignorable components in Timed
flysaiah Apr 8, 2016
f791016
Added support for timed shortanswer questions
flysaiah Apr 10, 2016
d9f11fc
Don't need ignoredTimed property anymore
flysaiah Apr 10, 2016
05a2f4b
Updated comments
flysaiah Apr 10, 2016
63a866a
Fixed grading bug in FITB
flysaiah Apr 10, 2016
c6cb107
Merge pull request #28 from RunestoneInteractive/master
flysaiah Apr 29, 2016
4bb395c
Merge pull request #29 from flysaiah/master
flysaiah Apr 29, 2016
de51664
Added support for timed parsons questions
flysaiah Apr 29, 2016
6e874b1
Fixing merge conflict
flysaiah Apr 29, 2016
df5282e
Removed console.logs
flysaiah Apr 29, 2016
9a89407
First version of timed activecode
flysaiah Apr 29, 2016
cd4c393
Fixed timed activecode bugs
flysaiah Apr 29, 2016
beb89dc
Fixed local storage bug in timed parsons
flysaiah Apr 29, 2016
5a1483a
Removed extraneous console log
flysaiah Apr 29, 2016
c55f94d
Fixed loading/running from storage after timed submit in activecode
flysaiah May 1, 2016
1803748
Ensure timed is rendered after login; also fixed UL bug
flysaiah May 1, 2016
6747522
Reverting parsons
flysaiah May 1, 2016
4708aef
Merge pull request #30 from RunestoneInteractive/master
flysaiah May 2, 2016
15f453c
Merging with moreTimed
flysaiah May 2, 2016
6a211b9
Merge branch 'master' into moreTimed
flysaiah May 2, 2016
f8a39fd
Missed '>>>' in merge conflict
flysaiah May 2, 2016
b898a0f
Timed parsons support minus eval re-added to PR with hook to be imple…
flysaiah May 11, 2016
2018b70
Added missing login-complete triggers
flysaiah May 12, 2016
03c7861
Login-complete trigger should always happen now
flysaiah May 13, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions runestone/activecode/activecode.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def setup(app):
app.add_javascript('skulpt.min.js')
app.add_javascript('skulpt-stdlib.js')
app.add_javascript('clike.js')
app.add_javascript('timed_activecode.js')

app.add_node(ActivcodeNode, html=(visit_ac_node, depart_ac_node))

Expand Down
6 changes: 5 additions & 1 deletion runestone/activecode/css/activecode.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,8 @@

.full_width ol {
max-width: 100% !important;
}
}

.ac-disabled {
pointer-events: none;
}
37 changes: 21 additions & 16 deletions runestone/activecode/js/activecode.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,24 @@ ActiveCode.prototype.init = function(opts) {
};

ActiveCode.prototype.createEditor = function (index) {
var newdiv = document.createElement('div');
this.containerDiv = document.createElement('div');
var linkdiv = document.createElement('div')
linkdiv.id = this.divid.replace(/_/g,'-').toLowerCase(); // :ref: changes _ to - so add this as a target
$(newdiv).addClass("ac_section alert alert-warning");
$(this.containerDiv).addClass("ac_section alert alert-warning");
var codeDiv = document.createElement("div");
$(codeDiv).addClass("ac_code_div col-md-12");
this.codeDiv = codeDiv;
newdiv.id = this.divid;
newdiv.lang = this.language;
this.outerDiv = newdiv;
this.containerDiv.id = this.divid;
this.containerDiv.lang = this.language;
this.outerDiv = this.containerDiv;

$(this.origElem).replaceWith(newdiv);
$(this.origElem).replaceWith(this.containerDiv);
if (linkdiv.id !== this.divid) { // Don't want the 'extra' target if they match.
newdiv.appendChild(linkdiv);
this.containerDiv.appendChild(linkdiv);
}
newdiv.appendChild(codeDiv);
this.containerDiv.appendChild(codeDiv);
var editor = CodeMirror(codeDiv, {value: this.code, lineNumbers: true,
mode: newdiv.lang, indentUnit: 4,
mode: this.containerDiv.lang, indentUnit: 4,
matchBrackets: true, autoMatchParens: true,
extraKeys: {"Tab": "indentMore", "Shift-Tab": "indentLess"}
});
Expand Down Expand Up @@ -203,6 +203,7 @@ ActiveCode.prototype.createControls = function () {
$(butt).click((function() {new AudioTour(this.divid, this.editor.getValue(), 1, $(this.origElem).data("audio"))}).bind(this));
}


$(this.outerDiv).prepend(ctrlDiv);

};
Expand Down Expand Up @@ -326,11 +327,9 @@ ActiveCode.prototype.saveEditor = function () {
};

ActiveCode.prototype.loadEditor = function () {

var loadEditor = (function (data, status, whatever) {
// function called when contents of database are returned successfully
var res = eval(data)[0];

if (res.source) {
this.editor.setValue(res.source);
setTimeout(function() {
Expand All @@ -356,8 +355,12 @@ ActiveCode.prototype.loadEditor = function () {
if (this.sid !== undefined) {
data['sid'] = this.sid;
}
// This function needs to be chainable for when we want to do things like run the activecode
// immediately after loading the previous input (such as in a timed exam)
var dfd = jQuery.Deferred();
this.logBookEvent({'event': 'activecode', 'act': 'load', 'div_id': this.divid}); // Log the run event
jQuery.get(eBookConfig.ajaxURL + 'getprog', data, loadEditor);
jQuery.get(eBookConfig.ajaxURL + 'getprog', data, loadEditor).done(function () {dfd.resolve();});
return dfd;

};

Expand Down Expand Up @@ -731,7 +734,7 @@ JSActiveCode.prototype.runProg = function() {
if (!str) str="";
_this.output.innerHTML += _this.outputfun(str)+"<br />";
};

$(this.eContainer).remove();
$(this.output).text('');
$(this.codeDiv).switchClass("col-md-12","col-md-6",{duration:500,queue:false});
Expand Down Expand Up @@ -1001,8 +1004,8 @@ AudioTour.prototype.tour = function (divid, audio_type, bcount) {
// str+="<audio id="+akey+" preload='auto'><source src='http://ice-web.cc.gatech.edu/ce21/audio/"+
// akey+".mp3' type='audio/mpeg'><source src='http://ice-web.cc.gatech.edu/ce21/audio/"+akey+
// ".ogg' type='audio/ogg'>Your browser does not support the audio tag</audio>";
var dir = "http://media.interactivepython.org/" + eBookConfig.basecourse + "/audio/"

var dir = "http://media.interactivepython.org/" + eBookConfig.basecourse + "/audio/"
//var dir = "../_static/audio/"
str += "<audio id=" + akey + " preload='auto' >";
str += "<source src='" + dir + akey + ".wav' type='audio/wav'>";
Expand Down Expand Up @@ -1595,7 +1598,9 @@ ACFactory.toggleScratchActivecode = function () {
$(document).ready(function() {
ACFactory.createScratchActivecode();
$('[data-component=activecode]').each( function(index ) {
edList[this.id] = ACFactory.createActiveCode(this, $(this).data('lang'));
if ($(this.parentNode).data("component") !== "timedAssessment") { // If this element exists within a timed component, don't render it here
edList[this.id] = ACFactory.createActiveCode(this, $(this).data('lang'));
}
});
if (loggedout) {
for (k in edList) {
Expand Down
57 changes: 57 additions & 0 deletions runestone/activecode/js/timed_activecode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
function TimedActiveCode (opts) {
if (opts) {
this.timedInit(opts);
}
}
TimedActiveCode.prototype = new ActiveCode();

TimedActiveCode.prototype.timedInit = function (opts) {
this.init(opts);
this.renderTimedIcon(this.containerDiv);
this.hideButtons();
};


TimedActiveCode.prototype.hideButtons = function () {
var buttonList = [this.saveButton, this.loadButton, this.gradeButton, this.showHideButt, this.clButton, this.coachButton, this.atButton];
for (var i = 0; i < buttonList.length; i++) {
if (buttonList[i] !== undefined && buttonList[i] !== null)
$(buttonList[i]).hide();
}
};

TimedActiveCode.prototype.renderTimedIcon = function (component) {
// renders the clock icon on timed components. The component parameter
// is the element that the icon should be appended to.
var timeIconDiv = document.createElement("div");
var timeIcon = document.createElement("img");
$(timeIcon).attr({
"src": "../_static/clock.png",
"style": "width:15px;height:15px"
});
timeIconDiv.className = "timeTip";
timeIconDiv.title = "";
timeIconDiv.appendChild(timeIcon);
$(component).prepend(timeIconDiv);
};

TimedActiveCode.prototype.checkCorrectTimed = function () {
return "I"; // we ignore this in the grading
};

TimedActiveCode.prototype.hideFeedback = function () {
// no feedback to hide
};

TimedActiveCode.prototype.processTimedSubmission = function (logFlag) {
// Disable input & evaluate component
if (this.useRunestoneServices) {
if (logFlag) {
this.saveEditor();
} else {
this.loadEditor().done(this.runProg.bind(this));
}
}
this.runButton.disabled = true;
$(this.codeDiv).addClass("ac-disabled");
};
36 changes: 14 additions & 22 deletions runestone/assess/js/fitb.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,6 @@
=== 6/4/15 ===
==========================================*/

/*=======================================
=== Global functions ===
=== (used by more than one component) ===
=======================================*/

var feedBack = function (elem, correct, feedbackText) { // Displays feedback on page--miscellaneous function that can be used by multple objects
// elem is the Element in which to put the feedback
if (correct) {
$(elem).html("You are Correct!");
$(elem).attr("class", "alert alert-success");
} else {
if (feedbackText === null) {
feedbackText = "";
}
$(elem).html("Incorrect. " + feedbackText);
$(elem).attr("class", "alert alert-danger");
}
};


/*==================================================
== Begin code for the Fill In The Blank component ==
==================================================*/
Expand Down Expand Up @@ -247,7 +227,7 @@ FITB.prototype.enableCompareButton = function () {
FITB.prototype.checkFITBStorage = function () {
this.isCorrectArray = [];
this.displayFeed = [];
// Starts chain of functions which ends with feedBack() displaying feedback to user
// Starts chain of functions which ends with displaying feedback to user
this.evaluateAnswers();
this.renderFITBFeedback();
var answerInfo = "answer:" + this.given_arr + ":" + (this.correct ? "correct" : "no");
Expand Down Expand Up @@ -278,12 +258,24 @@ FITB.prototype.evaluateAnswers = function () {
}
if ($.inArray("", this.isCorrectArray) < 0 && $.inArray(false, this.isCorrectArray) < 0) {
this.correct = true;
} else if ($.inArray(false, this.isCorrectArray) >= 0 && $.inArray("", this.isCorrectArray) < 0) {
} else if (this.isCompletelyBlank()) {
this.correct = null;
} else {
this.correct = false;
}
localStorage.setItem(eBookConfig.email + ":" + this.divid + "-given", this.given_arr.join(";"));
};

FITB.prototype.isCompletelyBlank = function () {
// Returns true if the user didn't fill in any of the blanks, else false
for (var i = 0; i < this.isCorrectArray.length; i++) {
if (this.isCorrectArray[i] !== "") {
return false;
}
}
return true;
};

FITB.prototype.populateDisplayFeed = function (index, given) {
var fbl = this.feedbackArray[index];
for (var j = 0; j < fbl.length; j++) {
Expand Down
Loading