diff options
author | Nicolas BERNSTEIN <alexis211@gmail.com> | 2011-11-20 13:39:47 +0100 |
---|---|---|
committer | Nicolas BERNSTEIN <alexis211@gmail.com> | 2011-11-20 13:39:47 +0100 |
commit | d45c7f14891d951f8a6987cc6492073b97e05b5b (patch) | |
tree | d6467b1202c27f67fd8e894d25fd4aea0085b559 /lib/list/inc_process.php | |
parent | 4d7e065c2d2ec407b6a7ebfc7569628bac9149d1 (diff) | |
download | Bits-d45c7f14891d951f8a6987cc6492073b97e05b5b.tar.gz Bits-d45c7f14891d951f8a6987cc6492073b97e05b5b.zip |
Added the bit list study system
Diffstat (limited to 'lib/list/inc_process.php')
-rw-r--r-- | lib/list/inc_process.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/list/inc_process.php b/lib/list/inc_process.php new file mode 100644 index 0000000..d4656b5 --- /dev/null +++ b/lib/list/inc_process.php @@ -0,0 +1,28 @@ +<?php + +require("lib/JSON/inc_json.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); + } + } + + $items = explode("\n", $contents); + foreach($items as $i) { + $ii = explode('|', str_replace("\r", '', $i)); + if (count($ii) == count($columns)) { + $data['items'][] = $ii; + } + } + + return json_encode($data); +} + + |