*/ if (!defined('DOKU_INC')) { define('DOKU_INC', dirname(__FILE__) . '/../../../../'); include_once DOKU_INC . 'inc/init.php'; include_once DOKU_INC . 'inc/plugin.php'; } class helper_plugin_judge_crud extends DokuWiki_Plugin { function __construct() { define('DBFILE', dirname(dirname(__FILE__)) . '/submissions.sqlite'); date_default_timezone_set('Asia/Tehran'); $this->db = new SQLite3(DBFILE); } public function tableRender($data, $mode, $count = 1, $sort = "timestamp") { /** * Find submissions */ $results = $this->getSubmissions($data, $sort); if (!$results) { return Array('submissions_table' => null, 'count' => 0); } /** * Building result table */ $table = ''; $i = $count; $table_data = Array(); if ($data["type"] == "output-only") { while ($row = $results->fetchArray()) { if ($mode == "html" && is_null($data["problem_name"])) { $table_data[] = Array($i, '' . $row["problem_name"] . '', $this->convert_time($row["timestamp"]), ($row["status_code"] == '1' ? "درست" : "نادرست")); } elseif ($mode == "html" && !is_null($data["problem_name"])) { $table_data[] = Array($i, $this->convert_time($row["timestamp"]), ($row["status_code"] == '1' ? "درست" : "نادرست")); } elseif ($mode == "csv") { $table .= $i . "\toutput-only\t" . $row["problem_name"] . "\t" . $this->convert_time($row["timestamp"]) . "\t \t" . ($row["status_code"] == '1' ? "درست" : "نادرست") . "\n"; } $i += 1; } } elseif ($data["type"] == "test-case") { while ($row = $results->fetchArray()) { $language = $this-> db->query('SELECT language FROM submission_test_case WHERE submit_id = ' . $row["submit_id"] . ';')->fetchArray(); if ($row["status_code"] == '0') { $valid_text = '
'; } else { $valid_text = $this->valid_text($row["submit_id"]); } /** * table rendering */ if ($mode == "html" && is_null($data["user"])) { $table_data[] = Array($i, '' . $row["problem_name"] . '', $row['username'], $this->convert_time($row["timestamp"]), $language[0], $valid_text); } elseif ($mode == "html" && is_null($data["problem_name"])) { $table_data[] = Array($i, '' . $row["problem_name"] . '', $this->convert_time($row["timestamp"]), $language[0], $valid_text); } elseif ($mode == "html" && !is_null($data["problem_name"])) { $table_data[] = Array($i, $this->convert_time($row["timestamp"]), $language[0], $valid_text); } elseif ($mode == "csv") { $table .= $i . "\ttest-case\t" . $row["problem_name"] . "\t" . $this->convert_time($row["timestamp"]) . "\t" . $language[0] . "\t" . $this->valid_text($row["submit_id"]) . "\n"; } $i += 1; } } else { while ($row = $results->fetchArray()) { if ($row["type"] == "output-only") { $table_data[] = Array($i, '' . $row["problem_name"] . '', $this->getLang('outputonly_question'), $this->convert_time($row["timestamp"]), ($row["status_code"] == '1' ? "درست" : "نادرست")); } else { if (!$row["status_code"]) { $table_data[] = Array($i, '' . $row["problem_name"] . '', $this->getLang('programming_question'), $this->convert_time($row["timestamp"]), ''); } else { $table_data[] = Array($i, '' . $row["problem_name"] . '', $this->getLang('programming_question'), $this->convert_time($row["timestamp"]), $this->valid_text($row["submit_id"])); } } $i += 1; } } if ($mode == "html") { $table_row = Array(); foreach ($table_data as &$data) { $table_row[] = join($data, '