示例#1
0
文件: Data.php 项目: thezawad/vakuum
 /**
  * edit
  * @param array $data_config
  * @return void
  */
 public static function edit($data_config)
 {
     $prob_id = $data_config['id'];
     $data_config = self::format($data_config);
     $data_config['version'] = time();
     $data_config = BFL_XML::Array2XML($data_config);
     $prob_meta = new MDL_Problem_Meta($prob_id);
     $prob_meta->setVar('data_config', $data_config);
     $prob_meta->setVar('verified', 0);
 }
示例#2
0
 public static function verify($data_config)
 {
     $verify_result['testdata_path'] = MDL_Config::getInstance()->getVar('judger_testdata') . $data_config['name'] . '/';
     $verify_result['overall'] = '';
     if (!file_exists($verify_result['testdata_path'])) {
         //testdata_path not exist
         $verify_result['overall'] = 'testdata_path';
         return $verify_result;
     }
     $hash_code = '';
     $verify_result['checker'] = true;
     if ($data_config['checker']['type'] == 'custom') {
         $checker_file = $verify_result['testdata_path'] . $data_config['checker']['custom']['source'];
         if (file_exists($checker_file)) {
             $hash_code .= sha1_file($checker_file, true);
         } else {
             $verify_result['checker'] = false;
             $verify_result['overall'] = 'checker';
         }
     }
     $success = true;
     $case_id = 0;
     foreach ($data_config['case'] as $item) {
         $input_file = $verify_result['testdata_path'] . $item['input'];
         $output_file = $verify_result['testdata_path'] . $item['output'];
         if (file_exists($input_file)) {
             $verify_result['case'][$case_id]['input'] = true;
             $hash_code .= sha1_file($input_file, true);
         } else {
             $verify_result['case'][$case_id]['input'] = false;
             $success = false;
         }
         if (file_exists($output_file)) {
             $verify_result['case'][$case_id]['output'] = true;
             $hash_code .= sha1_file($output_file, true);
         } else {
             $verify_result['case'][$case_id]['output'] = false;
             $success = false;
         }
         ++$case_id;
     }
     $hash_code = sha1($hash_code);
     if (!$success) {
         $verify_result['overall'] = 'case';
     } else {
         $verify_result['hash_code'] = $hash_code;
         $problem_meta = new MDL_Problem_Meta($data_config['id']);
         $problem_meta->setVar('verified', 1);
     }
     return $verify_result;
 }
示例#3
0
文件: Edit.php 项目: thezawad/vakuum
 /**
  * edit
  * @param array $problem
  * @return void
  */
 public static function edit($problem)
 {
     self::verify($problem);
     $db = BFL_Database::getInstance();
     $meta = array('`prob_name` = :prob_name', '`prob_title` = :prob_title', '`prob_content` = :prob_content');
     $stmt = $db->update(DB_TABLE_PROB, $meta, 'where `prob_id`=:prob_id ');
     $stmt->bindParam(':prob_id', $problem['prob_id']);
     $stmt->bindParam(':prob_name', $problem['prob_name']);
     $stmt->bindParam(':prob_title', $problem['prob_title']);
     $stmt->bindParam(':prob_content', $problem['prob_content']);
     $stmt->execute();
     $prob_meta = new MDL_Problem_Meta($problem['prob_id']);
     $prob_meta->setVar('display', $problem['display']);
 }
示例#4
0
文件: Show.php 项目: thezawad/vakuum
 /**
  * Ger Problem
  * @param string $sql_where
  * @param string $param
  * @return array Problem
  */
 private static function getProblemAbstract($sql_where, $param)
 {
     $db = BFL_Database::getInstance();
     $stmt = $db->factory('select * from ' . DB_TABLE_PROB . ' ' . $sql_where);
     $stmt->bindParam(':param', $param);
     $stmt->execute();
     $rs = $stmt->fetch();
     if (empty($rs)) {
         throw new MDL_Exception_Problem(MDL_Exception_Problem::NOTFOUND);
     }
     $problem = $rs;
     $prob_id = $problem['prob_id'];
     $prob_meta = new MDL_Problem_Meta($prob_id);
     $rs = $prob_meta->getAll();
     $problem = array_merge($problem, $rs);
     $problem['data_config'] = BFL_XML::XML2Array($problem['data_config']);
     if (!isset($problem['data_config']['case'][0])) {
         $problem['data_config']['case'] = array($problem['data_config']['case']);
     }
     return $problem;
 }