summaryrefslogtreecommitdiff
path: root/js/codeq
diff options
context:
space:
mode:
Diffstat (limited to 'js/codeq')
-rw-r--r--js/codeq/prolog.js79
-rw-r--r--js/codeq/python.js87
-rw-r--r--js/codeq/robot.js82
3 files changed, 15 insertions, 233 deletions
diff --git a/js/codeq/prolog.js b/js/codeq/prolog.js
index ea4c9b2..9a674e8 100644
--- a/js/codeq/prolog.js
+++ b/js/codeq/prolog.js
@@ -1,5 +1,5 @@
/* CodeQ: an online programming tutor.
- Copyright (C) 2015 UL FRI
+ Copyright (C) 2015,2016 UL FRI
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU Affero General Public License as published by the Free
@@ -14,18 +14,10 @@ details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-/**
- * Created by robert on 9/17/15.
- *
- * The prolog state of the state machine. When it is entered it'll prepare the console and code editor and load a sub-state machine which represents the 4 different parts fo the screen.
- */
-
(function() {
"use strict";
- var subScreens, //this will be the actual (sub)state machine
- stateNameTag = 'stateName', //a tag for data which is added to some html elements
- jqScreen = $('#screen_prolog'), // the screen container element
- //quadrants
+ var jqScreen = $('#screen_prolog'), // the screen container element
+ // quadrants
jqDescription = jqScreen.find('.block1'),
jqCode = jqScreen.find('.block2'),
jqConsole = jqScreen.find('.block3'),
@@ -35,53 +27,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
jqBtnPlan = jqScreen.find('.btn-plan'),
jqBtnTest = jqScreen.find('.btn-test').ladda(),
jqAllButtons = jqBtnPlan.add(jqBtnTest), // all the buttons
- // misc
- currentSubState = null,
- transitionEventName = 'mousedown',//event name of the event which will trigger the transition between these substates - the most common transition at least (there are some corner cases on the hint and test buttons -> see the code below)
- substates = {
- 'description': {
- 'enter': function () {
- currentSubState = 'block1';
- jqScreen.addClass(currentSubState);
- },
- 'exit': function () {
- jqScreen.removeClass(currentSubState);
- currentSubState = null;
- }
- },
- 'code': {
- 'enter': function () {
- currentSubState = 'block2';
- jqScreen.addClass(currentSubState);
- },
- 'exit': function () {
- jqScreen.removeClass(currentSubState);
- currentSubState = null;
- }
- },
- 'info': {
- 'enter': function () {
- currentSubState = 'block4';
- jqScreen.addClass(currentSubState);
- },
- 'exit': function () {
- jqScreen.removeClass(currentSubState);
- currentSubState = null;
- }
- },
- 'console': {
- 'enter': function () {
- currentSubState = 'block3';
- jqScreen.addClass(currentSubState);
- },
- 'exit': function () {
- jqScreen.removeClass(currentSubState);
- currentSubState = null;
- }
- }
- };
+ prologHandler;
- var enterFun = function(problemDef, commonDef, currentSolution){
+ var enterFun = function(problemDef, commonDef, currentSolution) {
$('#navigation-problem_list').css('display', '');
var navigationProlog = $("#navigation-prolog");
navigationProlog.addClass("active");
@@ -89,16 +37,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
jqScreen.css('display', '');//we have to show the screen now so the code editor shows its initial values correctly
prologHandler = createPrologHandler(problemDef, commonDef, currentSolution);
- subScreens = codeq.makeStateMachine(substates);
- subScreens.transition(jqDescription.data(stateNameTag));
-
- jqAllButtons.on(transitionEventName, function (event) {
- subScreens.transition('info'); // set focus on the hints quadrant
- event.stopPropagation(); // don't allow the event to go on and trigger further transition
- });
- jqAllQuadrants.on(transitionEventName, function () {
- subScreens.transition($(this).data(stateNameTag));
- });
};
var prologHandler; //created when we enter the prolog state and destroyed once we leave it
@@ -123,8 +61,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
jqScreen.css('display', 'none');
prologHandler.destroy();
prologHandler = null;
- subScreens.destroy();
- subScreens = null;
jqScreen.addClass('block1');
$('#navigation-problem_list').css('display', 'none');
@@ -134,11 +70,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
}
});
- jqDescription.data(stateNameTag, 'description');
- jqCode.data(stateNameTag, 'code');
- jqConsole.data(stateNameTag, 'console');
- jqInfo.data(stateNameTag, 'info');
-
// a constant
var firstCharacterPos = {'line': 0, 'ch': 0};
diff --git a/js/codeq/python.js b/js/codeq/python.js
index 2ea960a..4109b62 100644
--- a/js/codeq/python.js
+++ b/js/codeq/python.js
@@ -1,5 +1,5 @@
/* CodeQ: an online programming tutor.
- Copyright (C) 2015 UL FRI
+ Copyright (C) 2015,2016 UL FRI
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU Affero General Public License as published by the Free
@@ -14,20 +14,10 @@ details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-/**
- * Created by robert on 9/17/15.
- *
- * The python state of the state machine. When it is entered it'll prepare the console and code editor and load a sub-state machine which represents the 4 different parts fo the screen.
- *
- * Currentyl it is mostly a copy of the prolog state (the exception is of course the makePythonTerminalHandler instead of makePrologTerminalHandler)
- */
-
(function() {
"use strict";
- var subScreens, //this will be the actual (sub)state machine
- stateNameTag = 'stateName', //a tag for data which is added to some html elements
- jqScreen = $('#screen_python'), // the screen container element
- //quadrants
+ var jqScreen = $('#screen_python'), // the screen container element
+ // quadrants
jqDescription = jqScreen.find('.block1'),
jqCode = jqScreen.find('.block2'),
jqConsole = jqScreen.find('.block3'),
@@ -40,54 +30,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
jqBtnStop = jqScreen.find('.btn-stop'),
jqInfoButtons = jqBtnPlan.add(jqBtnTest), // all info-focusing buttons
jqAllButtons = jqInfoButtons.add(jqBtnRun).add(jqBtnStop), // all buttons
- // misc
- currentSubState = null,
- transitionEventName = 'mousedown',//event name of the event which will trigger the transition between these substates - the most common transition at least (there are some corner cases on the hint and test buttons -> see the code below)
- substates = {
- 'description': {
- 'enter': function () {
- currentSubState = 'block1';
- jqScreen.addClass(currentSubState);
- },
- 'exit': function () {
- jqScreen.removeClass(currentSubState);
- currentSubState = null;
- }
- },
- 'code': {
- 'enter': function () {
- currentSubState = 'block2';
- jqScreen.addClass(currentSubState);
- },
- 'exit': function () {
- jqScreen.removeClass(currentSubState);
- currentSubState = null;
- }
- },
- 'info': {
- 'enter': function () {
- currentSubState = 'block4';
- jqScreen.addClass(currentSubState);
- },
- 'exit': function () {
- jqScreen.removeClass(currentSubState);
- currentSubState = null;
- }
- },
- 'console': {
- 'enter': function () {
- currentSubState = 'block3';
- jqScreen.addClass(currentSubState);
- },
- 'exit': function () {
- jqScreen.removeClass(currentSubState);
- currentSubState = null;
- }
- }
- };
- var pythonHandler; //created when we enter the python state and destroyed once we leave it
+ pythonHandler; // created when we enter the python state and destroyed once we leave it
- var enterFun = function(problemDef, commonDef, currentSolution){
+ var enterFun = function(problemDef, commonDef, currentSolution) {
$('#navigation-problem_list').css('display', '');
var navigationPhython = $("#navigation-python");
navigationPhython.addClass("active");
@@ -95,21 +40,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
jqScreen.css('display', '');//we have to show the screen now so the code editor shows its initial values correctly
pythonHandler = createPythonHandler(problemDef, commonDef, currentSolution);
- subScreens = codeq.makeStateMachine(substates);
- subScreens.transition(jqDescription.data(stateNameTag));
-
- jqInfoButtons.on(transitionEventName, function (event) {
- subScreens.transition('info'); // set focus on the hints quadrant
- event.stopPropagation(); // don't allow the event to go on and trigger further transition
- });
- jqBtnRun.on(transitionEventName, function (event) {
- subScreens.transition('console'); // set focus on the hints quadrant
- event.stopPropagation(); // don't allow the event to go on and trigger further transition
- });
-
- jqAllQuadrants.on(transitionEventName, function () {
- subScreens.transition($(this).data(stateNameTag));
- });
};
codeq.globalStateMachine.register('python', {
@@ -134,8 +64,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
jqScreen.css('display', 'none');
pythonHandler.destroy();
pythonHandler = null;
- subScreens.destroy();
- subScreens = null;
jqScreen.addClass('block1');
$('#navigation-problem_list').css('display', 'none');
@@ -145,11 +73,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
}
});
- jqDescription.data(stateNameTag, 'description');
- jqCode.data(stateNameTag, 'code');
- jqConsole.data(stateNameTag, 'console');
- jqInfo.data(stateNameTag, 'info');
-
// a constant
var firstCharacterPos = {'line': 0, 'ch': 0};
diff --git a/js/codeq/robot.js b/js/codeq/robot.js
index 42f336c..8754c82 100644
--- a/js/codeq/robot.js
+++ b/js/codeq/robot.js
@@ -1,5 +1,5 @@
/* CodeQ: an online programming tutor.
- Copyright (C) 2015 UL FRI
+ Copyright (C) 2015,2016 UL FRI
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU Affero General Public License as published by the Free
@@ -14,16 +14,10 @@ details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-/**
- * The robot state of the state machine. When it is entered it'll prepare the code editor and load a sub-state machine which represents the 3 different parts of the screen.
- */
-
(function() {
"use strict";
- var subScreens, //this will be the actual (sub)state machine
- stateNameTag = 'stateName', //a tag for data which is added to some html elements
- jqScreen = $('#screen_robot'), // the screen container element
- //quadrants
+ var jqScreen = $('#screen_robot'), // the screen container element
+ // quadrants
jqDescription = jqScreen.find('.block1'),
jqCode = jqScreen.find('.block2'),
jqConsole = jqScreen.find('.block3'),
@@ -36,53 +30,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
jqBtnStop = jqScreen.find('.btn-stop'),
jqInfoButtons = jqBtnPlan.add(jqBtnHint), // all info-focusing buttons
jqAllButtons = jqInfoButtons.add(jqBtnRun).add(jqBtnStop), // all buttons
- // misc
- currentSubState = null,
- transitionEventName = 'mousedown',//event name of the event which will trigger the transition between these substates - the most common transition at least (there are some corner cases on the hint and test buttons -> see the code below)
- substates = {
- 'description': {
- 'enter': function () {
- currentSubState = 'block1';
- jqScreen.addClass(currentSubState);
- },
- 'exit': function () {
- jqScreen.removeClass(currentSubState);
- currentSubState = null;
- }
- },
- 'code': {
- 'enter': function () {
- currentSubState = 'block2';
- jqScreen.addClass(currentSubState);
- },
- 'exit': function () {
- jqScreen.removeClass(currentSubState);
- currentSubState = null;
- }
- },
- 'info': {
- 'enter': function () {
- currentSubState = 'block4';
- jqScreen.addClass(currentSubState);
- },
- 'exit': function () {
- jqScreen.removeClass(currentSubState);
- currentSubState = null;
- }
- },
- 'console': {
- 'enter': function () {
- currentSubState = 'block3';
- jqScreen.addClass(currentSubState);
- },
- 'exit': function () {
- jqScreen.removeClass(currentSubState);
- currentSubState = null;
- }
- }
- };
+ robotHandler;
- var enterFun = function(problemDef, commonDef, currentSolution){
+ var enterFun = function(problemDef, commonDef, currentSolution) {
$('#navigation-problem_list').css('display', '');
var navigationRobot = $("#navigation-robot");
navigationRobot.addClass("active");
@@ -90,21 +40,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
jqScreen.css('display', '');//we have to show the screen now so the code editor shows its initial values correctly
robotHandler = createRobotHandler(problemDef, commonDef, currentSolution);
- subScreens = codeq.makeStateMachine(substates);
- subScreens.transition(jqDescription.data(stateNameTag));
-
- jqInfoButtons.on(transitionEventName, function (event) {
- subScreens.transition('info'); // set focus on the hints quadrant
- event.stopPropagation(); // don't allow the event to go on and trigger further transition
- });
- jqBtnRun.on(transitionEventName, function (event) {
- subScreens.transition('console'); // set focus on the hints quadrant
- event.stopPropagation(); // don't allow the event to go on and trigger further transition
- });
-
- jqAllQuadrants.on(transitionEventName, function () {
- subScreens.transition($(this).data(stateNameTag));
- });
};
var robotHandler; //created when we enter the robot state and destroyed once we leave it
@@ -130,8 +65,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
jqScreen.css('display', 'none');
robotHandler.destroy();
robotHandler = null;
- subScreens.destroy();
- subScreens = null;
jqScreen.addClass('block1');
$('#navigation-problem_list').css('display', 'none');
@@ -141,11 +74,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
}
});
- jqDescription.data(stateNameTag, 'description');
- jqCode.data(stateNameTag, 'code');
- jqConsole.data(stateNameTag, 'console');
- jqInfo.data(stateNameTag, 'info');
-
// a constant
var firstCharacterPos = {'line': 0, 'ch': 0};