summaryrefslogtreecommitdiff
path: root/lib/study
diff options
context:
space:
mode:
authorAlex AUVOLAT <alexis211@gmail.com>2013-08-12 21:17:29 +0200
committerAlex AUVOLAT <alexis211@gmail.com>2013-08-12 21:17:29 +0200
commit8c24f8d84c338de8320596c5a9b8da72c2541080 (patch)
tree304af41ab28375dde5cd21aadaa7ed7d76a4f14e /lib/study
parentfac8f09c3bf40aaea5513c696af562cd9f728ea6 (diff)
downloadBits-8c24f8d84c338de8320596c5a9b8da72c2541080.tar.gz
Bits-8c24f8d84c338de8320596c5a9b8da72c2541080.zip
Small presentation changes.
Diffstat (limited to 'lib/study')
-rw-r--r--lib/study/brresults.php1
-rw-r--r--lib/study/list.php9
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/study/brresults.php b/lib/study/brresults.php
index 9bbafac..93ebfdf 100644
--- a/lib/study/brresults.php
+++ b/lib/study/brresults.php
@@ -26,6 +26,7 @@ if ($info["bsid"] == 0) {
}
if (isset($_POST['results']) && isset($_POST['score'])) {
+ sql("UPDATE batch_study SET before_last_review = last_review WHERE id = " . $info['bsid']);
sql("INSERT INTO batch_review(user, batch, results, score, date) ".
"VALUES(" . $user['id'] . ", $batchid, '" . escs(esca($_POST['results'])) . "', " . intval($_POST['score']) . ", NOW())");
sql("UPDATE batch_study SET last_review = " . mysql_insert_id() . " WHERE id = " . $info['bsid']);
diff --git a/lib/study/list.php b/lib/study/list.php
index 928e253..bebffa6 100644
--- a/lib/study/list.php
+++ b/lib/study/list.php
@@ -26,11 +26,16 @@ $fdefaults = array(
$batches = array();
$n = sql(
"SELECT batches.id AS id, batches.name AS name, ".
- "batch_study.id AS bs_id, batch_review.date AS lr_date, batch_review.score AS lr_score ".
+ "batch_study.id AS bs_id, ba.date AS lr_date, TO_DAYS(NOW()) - TO_DAYS(ba.date) AS lr_days, ".
+ "ba.score AS lr_score, bc.date AS blr_date, bc.score AS blr_score, ".
+ "COUNT(bb.id) AS num_reviews ".
"FROM batches ".
"LEFT JOIN batch_study ON batch_study.batch = batches.id AND batch_study.user = " . $user['id'] . " " .
- "LEFT JOIN batch_review ON batch_review.id = batch_study.last_review ".
+ "LEFT JOIN batch_review ba ON ba.id = batch_study.last_review ".
+ "LEFT JOIN batch_review bb ON bb.batch = batches.id AND bb.user = " . $user['id'] . " ".
+ "LEFT JOIN batch_review bc ON bc.id = batch_study.before_last_review ".
"WHERE batches.list = " . $study['listid'] . " " .
+ "GROUP BY batches.id ".
"ORDER BY " . get_filter("order") . " " . get_filter("way")
);
while ($b = mysql_fetch_assoc($n)) $batches[] = $b;