From bd65314aacb8da6a58f329e50f602aaba682fd5c Mon Sep 17 00:00:00 2001 From: Jochen Rick Date: Mon, 18 Jul 2016 10:54:27 -0400 Subject: [PATCH 1/2] Parsons indent background / backwards compatibility --- runestone/parsons/css/parsons.css | 13 +++++-------- runestone/parsons/images/parsons-indent.svg | 8 ++++++++ runestone/parsons/js/parsons.js | 7 +++++-- 3 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 runestone/parsons/images/parsons-indent.svg diff --git a/runestone/parsons/css/parsons.css b/runestone/parsons/css/parsons.css index f6e78242b..0c19ca74d 100644 --- a/runestone/parsons/css/parsons.css +++ b/runestone/parsons/css/parsons.css @@ -99,20 +99,17 @@ .parsons .incorrectIndent { border: 1px solid red; border-left: 10px solid red; + border-right: 10px solid red; padding-left: 1px; -} -.parsons .correctIndent { - border: 1px solid green; - border-left: 10px solid green; + padding-right: 1px; + background-image: url('parsons-indent.svg'); + background-repeat: no-repeat; + background-position: center; } .parsons .incorrectPosition { background-color: #FFBABA; border:1px solid red; } -.parsons .correctPosition { - background-color: #DFF2BF; - border:1px solid green; -} .parsons { border-left:0; border-right:0; diff --git a/runestone/parsons/images/parsons-indent.svg b/runestone/parsons/images/parsons-indent.svg new file mode 100644 index 000000000..7643a0a40 --- /dev/null +++ b/runestone/parsons/images/parsons-indent.svg @@ -0,0 +1,8 @@ + + + + + + + diff --git a/runestone/parsons/js/parsons.js b/runestone/parsons/js/parsons.js index ea3c22b1c..53b5187af 100644 --- a/runestone/parsons/js/parsons.js +++ b/runestone/parsons/js/parsons.js @@ -127,7 +127,6 @@ LineBasedGrader.prototype.grade = function() { $(block.view).addClass("incorrectIndent"); } } - answerArea.addClass("incorrect"); feedbackArea.fadeIn(500); feedbackArea.attr("class", "alert alert-danger"); if (incorrectBlocks.length == 1) { @@ -753,7 +752,11 @@ Parsons.prototype.loadData = function(data) { Parsons.prototype.localData = function() { var data = localStorage.getItem(this.storageId); if (data !== null) { - data = JSON.parse(data); + if (data.charAt(0) == "{") { + data = JSON.parse(data); + } else { + data = {}; + } } else { data = {}; } From febf78516627fba0f6778c5a4122956d2afb9834 Mon Sep 17 00:00:00 2001 From: Jochen Rick Date: Mon, 18 Jul 2016 13:27:55 -0400 Subject: [PATCH 2/2] Parsons: Do not send ajax calls if not using Runestone Services --- runestone/parsons/js/parsons.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/runestone/parsons/js/parsons.js b/runestone/parsons/js/parsons.js index 53b5187af..41f4e86d2 100644 --- a/runestone/parsons/js/parsons.js +++ b/runestone/parsons/js/parsons.js @@ -358,7 +358,11 @@ Parsons.prototype.init = function (opts) { this.initializeLines(content); this.initializeView(); // Check the server for an answer to complete things - this.checkServer("parsons"); + if (this.useRunestoneServices) { + this.checkServer("parsons"); + } else { + this.checkLocalStorage(); + } }; // Based on the data-fields in the original HTML, initialize options @@ -797,6 +801,9 @@ Parsons.prototype.setLocalStorage = function(data) { // move: the user moved a block to a new position // reset: the reset button was pressed Parsons.prototype.logMove = function(activity) { + if (!this.useRunestoneServices) { + return this; + } var act = activity + "|" + this.sourceHash() + "|" + this.answerHash(); var divid = this.divid; this.logBookEvent({ @@ -810,6 +817,9 @@ Parsons.prototype.logMove = function(activity) { // correct: The answer given matches the solution // incorrect*: The answer is wrong for various reasons Parsons.prototype.logAnswer = function(answer) { + if (!this.useRunestoneServices) { + return this; + } var answerHash = this.answerHash(); var sourceHash = this.sourceHash(); var act = sourceHash + "|" + answerHash;