Skip to content

Commit

Permalink
Add success message on complete proof
Browse files Browse the repository at this point in the history
  • Loading branch information
norm2782 committed May 24, 2011
1 parent 0d9f509 commit 8608d01
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
17 changes: 16 additions & 1 deletion resources/static/brunch/build/web/js/app.js
Expand Up @@ -11159,6 +11159,7 @@ d.data(g[0],"droppable");e.greedyChild=c=="isover"?1:0}}if(e&&c=="isover"){e.iso
__extends(ProofTree, Backbone.Model);
function ProofTree() {
this.setProofResult = __bind(this.setProofResult, this);
this.isProved = __bind(this.isProved, this);
this.isValid = __bind(this.isValid, this);
this.treeRoot = __bind(this.treeRoot, this);
this.reset = __bind(this.reset, this);
Expand All @@ -11183,6 +11184,9 @@ d.data(g[0],"droppable");e.greedyChild=c=="isover"?1:0}}if(e&&c=="isover"){e.iso
ProofTree.prototype.isValid = function() {
return this.treeRoot().isValid();
};
ProofTree.prototype.isProved = function() {
return this.treeRoot().isProved();
};
ProofTree.prototype.setProofResult = function(data) {
return this.treeRoot().setProofResult(data);
};
Expand All @@ -11209,6 +11213,7 @@ d.data(g[0],"droppable");e.greedyChild=c=="isover"?1:0}}if(e&&c=="isover"){e.iso
this.setChildren = __bind(this.setChildren, this);
this.childTerms = __bind(this.childTerms, this);
this.setTerm = __bind(this.setTerm, this);
this.isProved = __bind(this.isProved, this);
this.proofResult = __bind(this.proofResult, this);
this.term = __bind(this.term, this);
this.initialize = __bind(this.initialize, this);
Expand All @@ -11226,6 +11231,13 @@ d.data(g[0],"droppable");e.greedyChild=c=="isover"?1:0}}if(e&&c=="isover"){e.iso
ProofTreeNode.prototype.proofResult = function() {
return this.get('proofResult');
};
ProofTreeNode.prototype.isProved = function() {
var f;
f = function(acc, nd) {
return nd.isProved() && acc;
};
return (this.proofResult() === "Correct") && this.childTerms().reduce(f, true);
};
ProofTreeNode.prototype.setTerm = function(tm) {
return this.set({
term: tm
Expand Down Expand Up @@ -11526,7 +11538,10 @@ d.data(g[0],"droppable");e.greedyChild=c=="isover"?1:0}}if(e&&c=="isover"){e.iso
HomeView.prototype.checkProof = function() {
var callback;
callback = function(data) {
return app.models.tree.setProofResult(data);
app.models.tree.setProofResult(data);
if (app.models.tree.isProved()) {
return alert("Congratulations! You have successfully completed your proof!");
}
};
if (app.models.tree.isValid()) {
return $.ajax({
Expand Down
Expand Up @@ -17,5 +17,8 @@ class exports.ProofTree extends Backbone.Model
isValid: =>
@treeRoot().isValid()

isProved: =>
@treeRoot().isProved()

setProofResult: (data) =>
@treeRoot().setProofResult data
Expand Up @@ -15,6 +15,10 @@ class exports.ProofTreeNode extends Backbone.Model
proofResult: =>
@get('proofResult')

isProved: =>
f = (acc, nd) -> nd.isProved() && acc
(@proofResult() == "Correct") && @childTerms().reduce f, true

setTerm: (tm) =>
@set({term: tm})

Expand Down
2 changes: 2 additions & 0 deletions resources/static/brunch/src/app/views/home_view.coffee
Expand Up @@ -74,6 +74,8 @@ class exports.HomeView extends Backbone.View
checkProof: =>
callback = (data) ->
app.models.tree.setProofResult(data)
if app.models.tree.isProved()
alert "Congratulations! You have successfully completed your proof!"

if app.models.tree.isValid()
$.ajax
Expand Down

0 comments on commit 8608d01

Please sign in to comment.