summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--css/codeq.css12
-rw-r--r--js/codeq/comms.js7
-rw-r--r--js/codeq/problem_list.js44
3 files changed, 48 insertions, 15 deletions
diff --git a/css/codeq.css b/css/codeq.css
index 77d1d9c..ba10bcd 100644
--- a/css/codeq.css
+++ b/css/codeq.css
@@ -520,10 +520,20 @@ ul.dropdown-menu a {
padding-left: 1em;
}
-#screen_problem_list .group-problems li {
+#screen_problem_list ul.group-problems li {
list-style-type: none;
}
#screen_problem_list a {
cursor: pointer;
}
+
+#screen_problem_list .group-problems a.attempted::after {
+ color: orange;
+ content: ' ●';
+}
+
+#screen_problem_list .group-problems a.solved::after {
+ color: green;
+ content: ' ✔';
+}
diff --git a/js/codeq/comms.js b/js/codeq/comms.js
index 5908e0d..fe609c9 100644
--- a/js/codeq/comms.js
+++ b/js/codeq/comms.js
@@ -436,6 +436,13 @@
});
},
+ getAttempts: function commsGetAttempts (language) {
+ return this.send({
+ 'action': 'get_attempts',
+ 'language': language
+ });
+ },
+
loadProblem: function commsLoadProblem (problem_id) {
return this.send({
'action': 'load_problem',
diff --git a/js/codeq/problem_list.js b/js/codeq/problem_list.js
index 4a3d24d..853c8cb 100644
--- a/js/codeq/problem_list.js
+++ b/js/codeq/problem_list.js
@@ -275,6 +275,21 @@
});
},
+ /**
+ * Show attempted/solved status in the link for every problem.
+ */
+ showAttempts = function (languageData, attempts) {
+ var i;
+ for (i = 0; i < languageData.refs.length; i++) {
+ ref = languageData.refs[i];
+ if (ref.id in attempts) {
+ jqScreen.find('a.problem-'+i)
+ .removeClass('solved attempted')
+ .addClass(attempts[ref.id] ? 'solved' : 'attempted');
+ }
+ }
+ },
+
// ================================================================================
// Problem definition processing
// ================================================================================
@@ -349,27 +364,28 @@
codeq.globalStateMachine.register('problem_list', {
'enter': function(language){
- var data = null; // language data
+ var data = languageCache[language]; // language data
$("#navigation-problem_list").addClass("active").css('display', '');
if (!language) language = currentLanguage; // This happens when we hit this with the back button
-
- if (currentLanguage !== language) {
+ if (language !== currentLanguage) {
jqScreen.empty();
- currentLanguage = language;
- data = languageCache[language];
- if (data) {
- createDom(data);
+ }
+ codeq.wait(Q.all([
+ data || codeq.comms.getLanguageDef(language),
+ codeq.comms.getAttempts(language)
+ ]).spread(function (langData, attemptData) {
+ if (!data) {
+ data = createLanguageData(langData, language);
+ languageCache[language] = data;
}
- else {
- codeq.wait(codeq.comms.getLanguageDef(language).then(function (rawData) {
- var data = createLanguageData(rawData, language);
- languageCache[language] = data;
- createDom(data);
- })).done();
+ if (language !== currentLanguage) {
+ createDom(data);
}
- }
+ currentLanguage = language;
+ showAttempts(data, attemptData.data);
+ })).done();
jqScreen.css('display', '');
},