summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex AUVOLAT <alexis211@gmail.com>2013-08-04 17:05:20 +0200
committerAlex AUVOLAT <alexis211@gmail.com>2013-08-04 17:05:20 +0200
commitd529672a314e188d9effdc14a30c37a990f80ebe (patch)
tree9ad28a9de239bbe542b99846156f37002dfe7ab4
parent187883fd80675211a022a6e98f6d5d84a796373f (diff)
downloadBits-d529672a314e188d9effdc14a30c37a990f80ebe.tar.gz
Bits-d529672a314e188d9effdc14a30c37a990f80ebe.zip
Some changes to the way reviews work - custom styles!
-rw-r--r--design/style.css23
-rw-r--r--js/liststudy.js4
-rw-r--r--js/reviewdesu.js44
-rw-r--r--lib/list/inc_process.php28
-rw-r--r--lib/list/list_models.php17
-rw-r--r--tpl/study/list.php2
6 files changed, 95 insertions, 23 deletions
diff --git a/design/style.css b/design/style.css
index 3aaff45..af90223 100644
--- a/design/style.css
+++ b/design/style.css
@@ -6,6 +6,7 @@ body {
padding: 0px;
margin: 0px;
width: 400px;
+ font-size: 0.9em;
}
.menu {
@@ -276,6 +277,28 @@ hr {
border-bottom: 1px solid #0000FF;
}
+/* Study lists */
+
+.review_item{
+ text-align: center;
+}
+.review_item div {
+ width: 400px;
+ margin: auto;
+ height: 300px;
+ border: 1px solid #eeeeee;
+ background: #ffffff;
+}
+
+.review_item_prop span {
+ display: inline-block;
+ padding-right: 8px;
+ font-size: 0.8em;
+}
+
+.rtk_kr_q_1, .rtk_kr_a_1, .rtk_kr_q_2, .rtk_kr_a_2 { margin: 0px; padding: 0px; padding-top: 50px; }
+.rtk_kr_q_1, .rtk_kr_a_2 span { font-size: 4em; font-family: "IPAMincho", serif; }
+.rtk_kr_q_2, .rtk_kr_a_1 span { font-size: 1.2em; }
/* blog */
diff --git a/js/liststudy.js b/js/liststudy.js
index 4d715b8..d4a74c8 100644
--- a/js/liststudy.js
+++ b/js/liststudy.js
@@ -49,7 +49,7 @@ function show_contents_table() {
var html = '<table><tr>';
for (var i = 0; i < batch_data.columns.length; i++) {
var c = batch_data.columns[i];
- html += '<th>' + c.name + ' - <a class="tool_link" href="#" onclick="ch(' + i + ')" id="chsl' + i + '">hide</a></th>';
+ html += '<th>' + c + ' - <a class="tool_link" href="#" onclick="ch(' + i + ')" id="chsl' + i + '">hide</a></th>';
}
html += '<th>win</th><th>fail</th><th>score</th></tr>';
for (var i = 0; i < items.length; i++) {
@@ -91,7 +91,7 @@ function show_reviews_table() {
var color = '';
if (reviews_data[i].score == 100)
color = '#00aa00';
- else if (reviews_data[i].score >= 90)
+ else if (reviews_data[i].score >= 80)
color = '#55FF55';
else if (reviews_data[i].score >= 50)
color = '#FFFF00';
diff --git a/js/reviewdesu.js b/js/reviewdesu.js
index 45726dd..79bae82 100644
--- a/js/reviewdesu.js
+++ b/js/reviewdesu.js
@@ -26,24 +26,41 @@ function start_review() {
}
function prepare_questions() {
- for (var i = 0; i < batch_data.items.length; i++) {
- for (var j = 0; j < batch_data.columns.length; j++) {
- if (batch_data.columns[j].question == true) {
+ for (var j = 0; j < batch_data.questions.length; j++) {
+ var tq = [];
+
+ var q = batch_data.questions[j];
+ for (var i = 0; i < batch_data.items.length; i++) {
+ if (q.col) {
var answer = '';
for (var k = 0; k < batch_data.items[i].length; k++) {
- if (k != j)
- answer += '<p style="text-align: center">' + batch_data.items[i][k] + "</p>";
+ answer += '<p class="review_item_prop"><strong>' + batch_data.columns[k] + '</strong>' + batch_data.items[i][k] + "</p>";
}
- questions.push({
- "question": batch_data.items[i][j],
+ tq.push({
+ "question": '<p class="review_item_q">' + batch_data.items[i][q.col] + '</p>',
"answer": answer,
"key": batch_data.items[i][0],
});
+ } else {
+ var qu = q.q;
+ var an = q.a;
+ for (var k = 0; k < batch_data.items[i].length; k++) {
+ qu = qu.replace('%' + k, batch_data.items[i][k]);
+ an = an.replace('%' + k, batch_data.items[i][k]);
+ }
+ tq.push({
+ "question": qu,
+ "answer": an,
+ "key": batch_data.items[i][0],
+ });
}
}
+
+ tq.shuffle();
+ // first question asked is the last in array questions, so just put them in reverse order.
+ questions = tq.concat(questions);
}
total = questions.length;
- questions.shuffle();
}
function next_question() {
@@ -66,8 +83,10 @@ function next_question() {
question_nb++;
html = '<h3>Question ' + question_nb + ' of ' + total + '</h3>';
- html += '<p style="text-align: center; font-size: 1.2em">' + question.question + '</p>';
+ html += '<div class="review_item">';
+ html += '<div>' + question.question + '</div>';
html += '<p><button id="flipbtn" onclick="show_answer();">answer</button></p>';
+ html += '</div>';
$("core").innerHTML = html;
$("flipbtn").focus();
}
@@ -75,11 +94,12 @@ function next_question() {
function show_answer() {
html = '<h3>Question ' + question_nb + ' of ' + total + '</h3>';
- html += '<p style="text-align: center; font-size: 1.2em">' + question.question + '</p>';
- html += question.answer;
+ html += '<div class="review_item">';
+ html += '<div>' + question.answer + '</div>';
html += '<p><button taborder="1" onclick="answer_question(-1);">fail</button>';
html += '<button taborder="2" id="dunnobtn" onclick="answer_question(0);">dunno</button>';
- html += '<button taborder="3" onclick="answer_question(1);">win</button></p>';
+ html += '<button taborder="3" id="winbtn" onclick="answer_question(1);">win</button></p>';
+ html += '</div>';
$("core").innerHTML = html;
$("dunnobtn").focus();
}
diff --git a/lib/list/inc_process.php b/lib/list/inc_process.php
index d4656b5..0c7dd82 100644
--- a/lib/list/inc_process.php
+++ b/lib/list/inc_process.php
@@ -1,16 +1,28 @@
<?php
require("lib/JSON/inc_json.php");
+require("lib/list/list_models.php");
function mk_batch_json($models, $contents) {
- $data = array("columns" => array(), "items" => array());
-
- $columns = explode('|', $models);
- foreach ($columns as $c) {
- if ($c[0] == '!') {
- $data['columns'][] = array("question" => false, "name" => substr($c, 1));
- } else {
- $data['columns'][] = array("question" => true, "name" => $c);
+ global $list_models;
+
+ $data = array("columns" => array(), "items" => array(), "questions" => array());
+
+ if ($models[0] == '*') {
+ $model = $list_models[substr($models, 1)];
+
+ $columns = $data['columns'] = $model['columns'];
+ $data['questions'] = $model['questions'];
+ } else {
+ $columns = explode('|', $models);
+
+ foreach ($columns as $k => $c) {
+ if ($c[0] == '!') {
+ $data['columns'][] = substr($c, 1);
+ } else {
+ $data['columns'][] = $c;
+ $data['questions'][] = array('col' => $k);
+ }
}
}
diff --git a/lib/list/list_models.php b/lib/list/list_models.php
new file mode 100644
index 0000000..0d34856
--- /dev/null
+++ b/lib/list/list_models.php
@@ -0,0 +1,17 @@
+<?php
+
+$list_models = array(
+ "RTK-Kanji" => array(
+ "columns" => array("N#", "Kanji", "Keyword", "Strokes"),
+ "questions" => array(
+ array(
+ 'q' => '<p class="rtk_kr_q_2">%2</p>',
+ 'a' => '<p class="rtk_kr_a_2">#%0: %2 [%3]<br /><span>%1</span></p>'
+ ),
+ array(
+ 'q' => '<p class="rtk_kr_q_1">%1</p>',
+ 'a' => '<p class="rtk_kr_a_1">#%0: %1 [%3]<br /><span>%2</span></p>'
+ ),
+ ),
+ ),
+);
diff --git a/tpl/study/list.php b/tpl/study/list.php
index 0d04ccb..c44e45e 100644
--- a/tpl/study/list.php
+++ b/tpl/study/list.php
@@ -13,7 +13,7 @@ foreach ($batches as $batch) {
if ($batch['lr_date']) {
if ($batch['lr_score'] == 100)
$color = "#00AA00";
- else if ($batch['lr_score'] >= 90)
+ else if ($batch['lr_score'] >= 80)
$color = "#55FF55";
else if ($batch['lr_score'] >= 50)
$color = "#FFFF00";