summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/study/batch.php7
-rw-r--r--lib/study/batchreview.php6
-rw-r--r--lib/study/brresults.php7
3 files changed, 15 insertions, 5 deletions
diff --git a/lib/study/batch.php b/lib/study/batch.php
index d8df526..60152f1 100644
--- a/lib/study/batch.php
+++ b/lib/study/batch.php
@@ -6,7 +6,8 @@ $batchid = intval($args[2]);
$info = mysql_fetch_assoc(sql(
"SELECT list_study.id AS studyid, batches.name AS bname, ".
"lists.name AS lname, account.login AS uname, ".
- "batch_study.id AS bsid, batches.id AS batchid, batches.json_data AS json_data ".
+ "batch_study.id AS bsid, batch_study.notes_json AS notes, ".
+ "batches.id AS batchid, batches.json_data AS json_data ".
"FROM batches LEFT JOIN list_study ON list_study.list = batches.list AND list_study.user = " . $user['id'] . " " .
"LEFT JOIN batch_study ON batch_study.batch = $batchid AND batch_study.user = " . $user['id'] . " " .
"LEFT JOIN lists ON batches.list = lists.id ".
@@ -16,8 +17,10 @@ assert_error($info, "This batch does not exist.");
assert_error($info['studyid'] != 0, "You are not studying this list.");
if ($info["bsid"] == 0) {
- sql("INSERT INTO batch_study(user, batch, last_review) VALUES(" . $user['id'] . ", $batchid, 0)");
+ sql("INSERT INTO batch_study(user, batch, last_review, notes_json) ".
+ "VALUES(" . $user['id'] . ", $batchid, 0, '{}')");
$info['bsid'] = mysql_insert_id();
+ $info['notes'] = '{}';
}
$reviews = array();
diff --git a/lib/study/batchreview.php b/lib/study/batchreview.php
index 8639193..58fc852 100644
--- a/lib/study/batchreview.php
+++ b/lib/study/batchreview.php
@@ -6,7 +6,8 @@ $batchid = intval($args[2]);
$info = mysql_fetch_assoc(sql(
"SELECT list_study.id AS studyid, batches.name AS bname, ".
"lists.name AS lname, account.login AS uname, ".
- "batch_study.id AS bsid, batches.id AS batchid, batches.json_data AS json_data ".
+ "batch_study.id AS bsid, batch_study.notes_json AS notes, ".
+ "batches.id AS batchid, batches.json_data AS json_data ".
"FROM batches LEFT JOIN list_study ON list_study.list = batches.list AND list_study.user = " . $user['id'] . " " .
"LEFT JOIN batch_study ON batch_study.batch = $batchid AND batch_study.user = " . $user['id'] . " " .
"LEFT JOIN lists ON batches.list = lists.id ".
@@ -16,8 +17,9 @@ assert_error($info, "This batch does not exist.");
assert_error($info['studyid'] != 0, "You are not studying this list.");
if ($info["bsid"] == 0) {
- sql("INSERT INTO batch_study(user, batch, last_review) VALUES(" . $user['id'] . ", $batchid, 0)");
+ sql("INSERT INTO batch_study(user, batch, last_review, notes_json) VALUES(" . $user['id'] . ", $batchid, 0, '{}')");
$info['bsid'] = mysql_insert_id();
+ $info['notes'] = '{}';
}
require("tpl/study/batch_review.php");
diff --git a/lib/study/brresults.php b/lib/study/brresults.php
index b3e1068..9bbafac 100644
--- a/lib/study/brresults.php
+++ b/lib/study/brresults.php
@@ -19,8 +19,10 @@ if (!($info['studyid'] != 0)) {
}
if ($info["bsid"] == 0) {
- sql("INSERT INTO batch_study(user, batch, last_review) VALUES(" . $user['id'] . ", $batchid, 0)");
+ sql("INSERT INTO batch_study(user, batch, last_review, notes_json) ".
+ "VALUES(" . $user['id'] . ", $batchid, 0, '{}')");
$info['bsid'] = mysql_insert_id();
+ $info['notes'] = '{}';
}
if (isset($_POST['results']) && isset($_POST['score'])) {
@@ -28,6 +30,9 @@ if (isset($_POST['results']) && isset($_POST['score'])) {
"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']);
echo 'Saved';
+} else if (isset($_POST['notes'])) {
+ sql("UPDATE batch_study SET notes_json = '" . escs(esca($_POST['notes'])) . "' WHERE id = " . $info['bsid']);
+ echo 'Saved';
} else {
echo 'Error';
}