|
@@ -11,7 +11,9 @@ else {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$projects = Project::query(["id" => $ids]);
|
|
$projects = Project::query(["id" => $ids]);
|
|
|
-if(!$projects) throw new Exception("No projects to export.");
|
|
|
|
|
|
|
+if(!$projects) {
|
|
|
|
|
+ throw new RuntimeException("No projects to export.");
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
$template_processing = false;
|
|
$template_processing = false;
|
|
|
|
|
|
|
@@ -25,10 +27,14 @@ switch($type) {
|
|
|
if($template_processing) {
|
|
if($template_processing) {
|
|
|
$template_ids = array_column($projects, "template_id");
|
|
$template_ids = array_column($projects, "template_id");
|
|
|
$template_ids = array_unique($template_ids);
|
|
$template_ids = array_unique($template_ids);
|
|
|
- if(count($template_ids) != 1) throw new Exception("Cannot create export with different templates.");
|
|
|
|
|
|
|
+ if(count($template_ids) !== 1) {
|
|
|
|
|
+ throw new RuntimeException("Cannot create export with different templates.");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
$template = Template::get($template_ids[0]);
|
|
$template = Template::get($template_ids[0]);
|
|
|
- if(!$template) throw new Exception("Template cannot be found.");
|
|
|
|
|
|
|
+ if(!$template) {
|
|
|
|
|
+ throw new RuntimeException("Template cannot be found.");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
$tests = Test::query([
|
|
$tests = Test::query([
|
|
@@ -39,7 +45,10 @@ $tests = Test::query([
|
|
|
switch($type) {
|
|
switch($type) {
|
|
|
|
|
|
|
|
case "admin":
|
|
case "admin":
|
|
|
- if(!$user->canExportProjectCsv()) throw new Exception("You do not have permission to perform this action.");
|
|
|
|
|
|
|
+ if(!$user->canExportProjectCsv()) {
|
|
|
|
|
+ throw new RuntimeException("You do not have permission to perform this action.");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
$template->exportTestsCSV("project_csv.php", $tests);
|
|
$template->exportTestsCSV("project_csv.php", $tests);
|
|
|
break;
|
|
break;
|
|
|
|
|
|