summaryrefslogtreecommitdiff
path: root/js/codeq/problem_list.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/codeq/problem_list.js')
-rw-r--r--js/codeq/problem_list.js38
1 files changed, 35 insertions, 3 deletions
diff --git a/js/codeq/problem_list.js b/js/codeq/problem_list.js
index 8c3808e..4e81927 100644
--- a/js/codeq/problem_list.js
+++ b/js/codeq/problem_list.js
@@ -274,8 +274,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
if (!ref) {
codeq.log.error('Clicked on a problem link having erroneous index: ' + index);
return;
- }
- codeq.wait(
+ }//TODO
+ /*codeq.wait(
Q.all([
codeq.comms.getCurrentSolution(ref.id), // the current user's solution to the selected problem
getProblemData(language, ref.g, ref.p) // the (cached) result of processProblemData()
@@ -290,7 +290,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
codeq.log.error('Failed to obtain the problem definition: ' + reason, reason);
alert('Failed to obtain the problem definition: ' + reason);
})
- .done();
+ .done();*/
+ /*loadProblemData(ref,data).then(function(tmp){
+ codeq.log.debug("then:"+JSON.stringify(tmp));
+ return tmp;
+ })
+ .fail(function (reason) {
+ codeq.log.error('Failed to obtain the problem definition: ' + reason, reason);
+ alert('Failed to obtain the problem definition: ' + reason);
+ })
+ .done(codeq.log.debug("done"));*/
+ codeq.globalStateMachine.transition(language,ref,data);
});
},
@@ -365,8 +375,30 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
});
},
+ loadProblemData = function(ref, data){
+ var language = data.language;
+ return codeq.wait(
+ Q.all([
+ codeq.comms.getCurrentSolution(ref.id), // the current user's solution to the selected problem
+ getProblemData(language, ref.g, ref.p) // the (cached) result of processProblemData()
+ ])
+ .spread(function (userProblemData, generalProblemData) {
+ //codeq.log.debug("spread");
+ if (userProblemData.code !== 0) throw new Error('Failed to obtain user problem data, code: ' + userProblemData.code + ', message: ' + userProblemData.message);
+ if (!generalProblemData) throw new Error('General problem data is not defined');
+ //codeq.globalStateMachine.transition(language, generalProblemData, data.commonDef, userProblemData.data.solution);
+ return {"generalProblemData":generalProblemData,"solution":userProblemData.data.solution};
+ })
+ );
+ //while(!generalProblemData1){}
+ //return [generalProblemData1, userProblemDataSolution];
+ //codeq.log.debug("after wait:"+a);
+ },
+
currentLanguage; // the currently active language
+ codeq.loadProblemData = loadProblemData;
+
// ================================================================================
// Initialization, invoked from the boot sequence
// ================================================================================