コード例 #1
0
 public function batch_remove()
 {
     $ids = $this->input->post('ids');
     if (empty($ids) or !is_array($ids)) {
         message('请选择要删除的项目!');
         return;
     }
     $back_url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'admin/question_external/index/trash';
     $success = $fail = 0;
     foreach ($ids as $id) {
         $this->examine_permission($id);
         //判断该试题已经被考试过 或 正在被考
         $be_tested = QuestionModel::question_has_test_action($id);
         if ($be_tested) {
             $fail++;
             continue;
         }
         if (QuestionModel::remove($id) === true) {
             $success++;
         } else {
             $fail++;
         }
     }
     message('批量操作完成,成功删除:' . $success . ' 个,失败:' . $fail . ' 个(可能原因:试题已经被考生考过 或者 正在被考 或者 删除失败)。', $back_url);
 }