Commit 768a8dc3 authored by ZeMKI's avatar ZeMKI

export for new sorting

* now the export can export the new values for the new sorting.
* optimized export.
* optimized models for phpstorm.
parent 1417de50
......@@ -9,7 +9,9 @@
<excludeFolder url="file://$MODULE_DIR$/vendor/arietimmerman/laravel-url-shortener" />
<excludeFolder url="file://$MODULE_DIR$/vendor/barryvdh/laravel-debugbar" />
<excludeFolder url="file://$MODULE_DIR$/vendor/barryvdh/laravel-dompdf" />
<excludeFolder url="file://$MODULE_DIR$/vendor/barryvdh/laravel-ide-helper" />
<excludeFolder url="file://$MODULE_DIR$/vendor/barryvdh/laravel-translation-manager" />
<excludeFolder url="file://$MODULE_DIR$/vendor/barryvdh/reflection-docblock" />
<excludeFolder url="file://$MODULE_DIR$/vendor/binarytorch/larecipe" />
<excludeFolder url="file://$MODULE_DIR$/vendor/composer" />
<excludeFolder url="file://$MODULE_DIR$/vendor/dnoegel/php-xdg-base-dir" />
......
......@@ -170,6 +170,8 @@
<path value="$PROJECT_DIR$/vendor/phenx/php-svg-lib" />
<path value="$PROJECT_DIR$/vendor/phpstan/phpdoc-parser" />
<path value="$PROJECT_DIR$/vendor/fzaninotto/faker" />
<path value="$PROJECT_DIR$/vendor/barryvdh/laravel-ide-helper" />
<path value="$PROJECT_DIR$/vendor/barryvdh/reflection-docblock" />
</include_path>
</component>
<component name="PhpProjectSharedConfiguration" php_language_level="7.2" />
......
......@@ -2,18 +2,31 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="b51d2beb-a115-4b2a-80a2-b27cfb404d6c" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/resources/js/components/Interview/sorting_preview.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/mesort.iml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/mesort.iml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/php.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/php.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/Action.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Action.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/AllInterviewTokenExport.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/AllInterviewTokenExport.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/Answer.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Answer.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/Files.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Files.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/Http/Controllers/InterviewController.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Http/Controllers/InterviewController.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/Http/Controllers/StudyInterviewController.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Http/Controllers/StudyInterviewController.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/Interview.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Interview.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/InterviewTokenExport.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/InterviewTokenExport.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/InterviewTokens.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/InterviewTokens.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/Permission.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Permission.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/PermissionUser.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/PermissionUser.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/Profile.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Profile.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/PublicInterviewUrl.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/PublicInterviewUrl.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/Question.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Question.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/Role.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Role.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/RoleUser.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/RoleUser.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/Sorting.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Sorting.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/public/js/manifest.js" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/js/app.js" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/app.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/js/components/Interview/network-sorting.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/Interview/network-sorting.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/js/components/Interview/newinterview.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/Interview/newinterview.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/Study.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Study.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/app/User.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/User.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/composer.json" beforeDir="false" afterPath="$PROJECT_DIR$/composer.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/composer.lock" beforeDir="false" afterPath="$PROJECT_DIR$/composer.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/js/components/newstudy.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/newstudy.vue" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/lang/en.json" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/lang/en/_json.php" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/resources/sass/_interview.scss" beforeDir="false" afterPath="$PROJECT_DIR$/resources/sass/_interview.scss" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/views/interview/view.blade.php" beforeDir="false" afterPath="$PROJECT_DIR$/resources/views/interview/view.blade.php" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
......@@ -194,6 +207,8 @@
<path value="$PROJECT_DIR$/vendor/phenx/php-svg-lib" />
<path value="$PROJECT_DIR$/vendor/phpstan/phpdoc-parser" />
<path value="$PROJECT_DIR$/vendor/fzaninotto/faker" />
<path value="$PROJECT_DIR$/vendor/barryvdh/laravel-ide-helper" />
<path value="$PROJECT_DIR$/vendor/barryvdh/reflection-docblock" />
</include_path>
</component>
<component name="ProjectId" id="1c4j7kChBrblXbK13ZHSu3a8um6" />
......@@ -211,7 +226,7 @@
<property name="node.js.selected.package.eslint" value="(autodetect)" />
<property name="nodejs_package_manager_path" value="yarn" />
<property name="run.code.analysis.last.selected.profile" value="pProject Default" />
<property name="settings.editor.selected.configurable" value="configurable.group.language" />
<property name="settings.editor.selected.configurable" value="preferences.pluginManager" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
......@@ -269,7 +284,8 @@
<workItem from="1590395860432" duration="74000" />
<workItem from="1590396032148" duration="11625000" />
<workItem from="1590480658730" duration="551000" />
<workItem from="1590484643170" duration="23958000" />
<workItem from="1590484643170" duration="25829000" />
<workItem from="1590656055131" duration="4234000" />
</task>
<servers />
</component>
......@@ -277,6 +293,10 @@
<option name="version" value="2" />
</component>
<component name="WindowStateProjectService">
<state x="762" y="402" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog" timestamp="1590662018992">
<screen x="0" y="0" width="2048" height="1280" />
</state>
<state x="762" y="402" key="#com.jetbrains.php.actions.copyPaste.importReferences.PhpImportReferencesDialog/65.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590662018992" />
<state x="767" y="491" key="ANALYSIS_DLG_com.intellij.analysis.BaseAnalysisAction$1" timestamp="1590053715461">
<screen x="0" y="0" width="2048" height="1280" />
</state>
......@@ -317,17 +337,17 @@
<state width="2006" height="406" key="GridCell.Tab.0.right/128.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590058941150" />
<state width="2006" height="398" key="GridCell.Tab.0.right/65.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590569820143" />
<state width="1878" height="406" key="GridCell.Tab.0.right/65.-1080.1920.1080/0.0.2048.1280@65.-1080.1920.1080" timestamp="1590168747931" />
<state x="0" y="23" width="2048" height="1257" key="SettingsEditor" timestamp="1590572867401">
<state x="0" y="23" width="2048" height="1257" key="SettingsEditor" timestamp="1590656020691">
<screen x="0" y="0" width="2048" height="1280" />
</state>
<state x="0" y="23" width="2048" height="1257" key="SettingsEditor/128.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590056101932" />
<state x="0" y="23" key="SettingsEditor/65.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590572867401" />
<state x="754" y="390" width="597" height="524" key="StructurePopup" timestamp="1590585143194">
<state x="0" y="23" key="SettingsEditor/65.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590656020691" />
<state x="754" y="390" width="598" height="526" key="StructurePopup" timestamp="1590659300816">
<screen x="0" y="0" width="2048" height="1280" />
</state>
<state x="754" y="390" width="597" height="524" key="StructurePopup/0.0.2048.1280@0.0.2048.1280" timestamp="1590585143194" />
<state x="754" y="390" width="597" height="524" key="StructurePopup/128.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590054141097" />
<state x="754" y="390" width="598" height="526" key="StructurePopup/65.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590574274986" />
<state x="754" y="390" width="598" height="526" key="StructurePopup/65.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590659300816" />
<state x="772" y="-751" width="560" height="443" key="StructurePopup/65.-1080.1920.1080/0.0.2048.1280@65.-1080.1920.1080" timestamp="1590168084313" />
<state x="799" y="561" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2" timestamp="1590581191374">
<screen x="0" y="0" width="2048" height="1280" />
......@@ -345,22 +365,23 @@
</state>
<state x="899" y="515" width="250" height="278" key="jetbrains.javascript.buildTools.run-task-popup/0.0.2048.1280@0.0.2048.1280" timestamp="1589969203120" />
<state x="899" y="515" width="250" height="278" key="jetbrains.javascript.buildTools.run-task-popup/65.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590568927491" />
<state x="689" y="287" key="run.anything.popup" timestamp="1590057476445">
<state x="689" y="287" width="670" height="675" key="run.anything.popup" timestamp="1590663068985">
<screen x="0" y="0" width="2048" height="1280" />
</state>
<state x="689" y="305" key="run.anything.popup/128.-1057.1920.1057/0.23.2048.1257@0.23.2048.1257" timestamp="1589882069680" />
<state x="689" y="287" key="run.anything.popup/128.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590057476445" />
<state x="689" y="287" width="670" height="675" key="run.anything.popup/65.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590663068985" />
<state x="824" y="505" width="498" height="379" key="scopes" timestamp="1590055889310">
<screen x="0" y="0" width="2048" height="1280" />
</state>
<state x="824" y="505" key="scopes/128.-1057.1920.1057/0.0.2048.1280@0.0.2048.1280" timestamp="1590055889310" />
<state x="824" y="505" width="498" height="379" key="scopes/128.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590055356254" />
<state x="689" y="292" width="715" height="677" key="search.everywhere.popup" timestamp="1590574030439">
<state x="689" y="292" width="715" height="677" key="search.everywhere.popup" timestamp="1590663077267">
<screen x="0" y="0" width="2048" height="1280" />
</state>
<state x="689" y="291" width="670" height="676" key="search.everywhere.popup/0.0.2048.1280@0.0.2048.1280" timestamp="1590150028065" />
<state x="689" y="291" width="670" height="676" key="search.everywhere.popup/128.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590054146808" />
<state x="689" y="292" width="715" height="677" key="search.everywhere.popup/65.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590574030439" />
<state x="689" y="292" width="715" height="677" key="search.everywhere.popup/65.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590663077267" />
<state x="711" y="-834" width="670" height="571" key="search.everywhere.popup/65.-1080.1920.1080/0.0.2048.1280@65.-1080.1920.1080" timestamp="1590165045513" />
</component>
</project>
\ No newline at end of file
This diff is collapsed.
......@@ -5,6 +5,31 @@ namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
/**
* App\Action
*
* @property int $id
* @property string $name
* @property string|null $description
* @property string $url
* @property int|null $user_id
* @property string $time
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\User|null $user
* @method static \Illuminate\Database\Eloquent\Builder|\App\Action newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Action newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Action query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Action whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Action whereDescription($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Action whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Action whereName($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Action whereTime($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Action whereUpdatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Action whereUrl($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Action whereUserId($value)
* @mixin \Eloquent
*/
class Action extends Model
{
/**
......
......@@ -6,24 +6,30 @@ use App\InterviewTokens;
use App\Study;
use App\Token;
use Illuminate\Support\Collection;
use Image;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Storage;
class AllInterviewTokenExport implements FromCollection, WithMapping, WithHeadings
{
use Exportable;
private $id;
/**
* @var array
*/
private $head;
/**
* AllInterviewTokenExport constructor.
* @param $id
* @param $id
* @param array $headings
*/
public function __construct($id)
public function __construct($id, $headings = [])
{
$this->id = $id;
$this->head = $headings;
}
/**
......@@ -31,16 +37,22 @@ class AllInterviewTokenExport implements FromCollection, WithMapping, WithHeadin
*/
public function headings(): array
{
return [
'#',
'token name',
'circle',
'distance from center (pixels)',
'sorting number',
'position (pixels)',
'% percentage position',
'classifiers'
];
$columnNames = ["token id"];
array_push($columnNames, "token_name");
array_push($columnNames, "interview id");
array_push($columnNames, "interviewee");
array_push($columnNames, "circle");
array_push($columnNames, "distance from center (pixels)");
array_push($columnNames, "sorting number");
array_push($columnNames, "position (pixels)");
array_push($columnNames, "% percentage position");
array_push($columnNames, "classifiers");
foreach ($this->head as $column)
{
array_push($columnNames, $column);
}
return $columnNames;
}
/**
......@@ -51,14 +63,18 @@ class AllInterviewTokenExport implements FromCollection, WithMapping, WithHeadin
{
$printArray = [];
foreach ($study->interviews as $emptyInterview) {
foreach ($study->interviews as $emptyInterview)
{
$allinterviews = InterviewTokens::where('interview_id', $emptyInterview->id)->get();
array_push($printArray, [$emptyInterview->interviewed]);
foreach ($allinterviews as $interview) {
foreach ($allinterviews as $token)
{
if ($this->invalidData($interview)) continue;
$this->formatTokenValuesForExport($interview, $toprint);
array_push($printArray, $toprint);
if ($this->invalidData($token)) continue;
$this->formatTokenValuesForExport($token, $toPrint, $emptyInterview->interviewed);
array_push($printArray, $toPrint);
}
}
return $printArray;
......@@ -75,37 +91,56 @@ class AllInterviewTokenExport implements FromCollection, WithMapping, WithHeadin
}
/**
* @param $interview
* @param $toprint
* @param $token
* @param $toPrint
* @param $interviewee
*/
private function formatTokenValuesForExport($interview, &$toprint): void
private function formatTokenValuesForExport($token, &$toPrint,$interviewee): void
{
if (isset($interview->valutation->percentagePosition)) {
$percentagePosition = "x: " . $interview->valutation->percentagePosition->x . " y:" . $interview->valutation->percentagePosition->y;
} else {
if (isset($token->valutation->percentagePosition))
{
$percentagePosition = "x: " . $token->valutation->percentagePosition->x . " y:" . $token->valutation->percentagePosition->y;
} else
{
$percentagePosition = '';
}
if (is_object($interview->valutation->position)) {
$position = "x: " . $interview->valutation->position->x . " y:" . $interview->valutation->position->y;
} else {
$position = $interview->valutation->position;
if (is_object($token->valutation->position))
{
$position = "x: " . $token->valutation->position->x . " y:" . $token->valutation->position->y;
} else
{
$position = $token->valutation->position;
}
if (is_array($interview->valutation->classifiers)) {
if (is_array($token->valutation->classifiers))
{
$classifiers = "";
foreach ($interview->valutation->classifiers as $classifier) {
foreach ($token->valutation->classifiers as $classifier)
{
$classifiers .= $classifier->basename . " - ";
}
}
$toprint = [
$interview->token_id,
Token::where('id', $interview->token_id)->first()->name,
$interview->valutation->circle,
$interview->valutation->distance,
$interview->valutation->sorting,
$position,
$percentagePosition,
$classifiers
];
$toPrint["token id"] = $token->token_id;
$toPrint["token_name"] = Token::where('id', $token->token_id)->first()->name;
$toPrint['interview id'] = $token->interview_id;
$toPrint['interviewee'] = $interviewee;
$toPrint["circle"] = $token->valutation->circle;
$toPrint["distance from center (pixels)"] = $token->valutation->distance;
$toPrint["sorting number"] = $token->valutation->sorting;
$toPrint["position (pixels)"] = $position;
$toPrint["% percentage position"] = $percentagePosition;
$toPrint["classifiers"] = $classifiers;
if ($token->interview->study->sortings[0]->id === 2)
{
$toPrint['section number'] = $token->valutation->section;
$toPrint['section name'] = $token->valutation->sectionName;
}
}
/**
......
......@@ -5,6 +5,27 @@ namespace App;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
/**
* App\Answer
*
* @property int $id
* @property int|null $question_id
* @property array $answer
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Interview[] $interviews
* @property-read int|null $interviews_count
* @property-read \App\Question|null $question
* @method static \Illuminate\Database\Eloquent\Builder|\App\Answer newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Answer newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Answer query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Answer whereAnswer($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Answer whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Answer whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Answer whereQuestionId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Answer whereUpdatedAt($value)
* @mixin \Eloquent
*/
class Answer extends Model
{
/**
......
......@@ -9,6 +9,29 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Image;
/**
* App\Files
*
* @property int $id
* @property string $type
* @property string $path
* @property string $size
* @property int|null $interview_id
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \App\Interview|null $interview
* @method static \Illuminate\Database\Eloquent\Builder|\App\Files newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Files newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Files query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Files whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Files whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Files whereInterviewId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Files wherePath($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Files whereSize($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Files whereType($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Files whereUpdatedAt($value)
* @mixin \Eloquent
*/
class Files extends Model
{
/**
......
......@@ -16,8 +16,10 @@ use Exception;
use File;
use Helper;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Routing\ResponseFactory;
use Illuminate\Contracts\View\Factory;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\View\View;
......@@ -162,12 +164,12 @@ class InterviewController extends Controller
/**
* @param Interview $interview
* @param Request $request
* @return ResponseFactory|Response
* @return JsonResponse
* @throws Exception
*/
public function destroy(Interview $interview, Request $request)
{
if (!auth()->user()->can('delete-interviews', $interview->study->id)) return response('You are not authorized to delete this study.', 403);
if (!auth()->user()->can('delete-interviews', $interview->study->id)) return response()->json('You are not authorized to delete this study.', 403);
$id = $interview->id;
$interview->files()->delete();
$interview->answers()->detach();
......@@ -188,9 +190,25 @@ class InterviewController extends Controller
public function export(Interview $interview)
{
if (!auth()->user()->can('read-studies', $interview->study_id)) abort(403, "You are not authorized to download these data.");
return (new InterviewTokenExport($interview->id))->download($interview->interviewed . ' tokens.xlsx');
$headings = $this->getHeadings($interview->study);
return (new InterviewTokenExport($interview->id, $headings))->download($interview->interviewed . ' tokens.xlsx');
}
public function getHeadings($study)
{
if($study->sortings[0]->id == 2)
{
return ["section number","section name"];
}else return [];
}
/**
* @return Application|Factory|View
*/
public function done()
{
return view('interview.done');
......
......@@ -40,6 +40,19 @@ class StudyInterviewController extends Controller
public function exportall(Study $study)
{
if (!auth()->user()->can('read-studies', $study->id)) abort(403, "You are not authorized to download these data.");
return (new AllInterviewTokenExport($study->id))->download('Interviews from study' . $study->name . '.xlsx');
$headings = $this->getHeadings($study);
return (new AllInterviewTokenExport($study->id, $headings))->download('Interviews from study' . $study->name . '.xlsx');
}
public function getHeadings($study)
{
if($study->sortings[0]->id == 2)
{
return ["section number","section name"];
}else return [];
}
}
......@@ -4,6 +4,37 @@ namespace App;
use Illuminate\Database\Eloquent\Model;
/**
* App\Interview
*
* @property int $id
* @property \App\User $author
* @property string $interviewed
* @property int|null $study_id
* @property string $start
* @property string $end
* @property \Illuminate\Support\Carbon|null $created_at
* @property \Illuminate\Support\Carbon|null $updated_at
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Answer[] $answers
* @property-read int|null $answers_count
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Files[] $files
* @property-read int|null $files_count
* @property-read \App\Study|null $study
* @property-read \Illuminate\Database\Eloquent\Collection|\App\Token[] $tokens
* @property-read int|null $tokens_count
* @method static \Illuminate\Database\Eloquent\Builder|\App\Interview newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Interview newQuery()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Interview query()
* @method static \Illuminate\Database\Eloquent\Builder|\App\Interview whereAuthor($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Interview whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Interview whereEnd($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Interview whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Interview whereInterviewed($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Interview whereStart($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Interview whereStudyId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\Interview whereUpdatedAt($value)
* @mixin \Eloquent
*/
class Interview extends Model
{
/* protected $casts = [
......
......@@ -2,83 +2,95 @@
namespace App\Exports;
use App\Interview;
use App\InterviewTokens;
use App\Token;
use Illuminate\Support\Collection;
use Image;
use Maatwebsite\Excel\Concerns\Exportable;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Storage;
class InterviewTokenExport implements FromCollection, WithMapping, WithHeadings
{
use Exportable;
/**
* @var array
*/
private $head;
private $id;
/**
* InterviewTokenExport constructor.
* @param $id
* @param $id
* @param array $headings
*/
public function __construct($id)
public function __construct($id,$headings = [])
{
$this->id = $id;
$this->head = $headings;
}
/**
* @return array
*/
public function headings(): array
{
return [
'#',
'token name',
'circle',
'distance from center (pixels)',
'sorting number',
'position (pixels)',
'% percentage position',
'classifiers'
];
$columnNames = ["#"];
array_push($columnNames, "token_name");
array_push($columnNames, "circle");
array_push($columnNames, "distance from center (pixels)");
array_push($columnNames, "sorting number");
array_push($columnNames, "position (pixels)");
array_push($columnNames, "% percentage position");
array_push($columnNames, "classifiers");
foreach ($this->head as $column) {
array_push($columnNames, $column);
}
return $columnNames;
}
/**
* @return array
* @var Interview $interview
* @var Token $token
*/
public function map($interview): array
public function map($token): array
{
if ($this->invalidData($interview)) return [];
if (isset($interview->valutation->percentagePosition)) {
$percentagePosition = "x: " . $interview->valutation->percentagePosition->x . " y:" . $interview->valutation->percentagePosition->y;
} else {
$percentagePosition = '';
}
if (is_object($interview->valutation->position)) {
$position = "x: " . $interview->valutation->position->x . " y:" . $interview->valutation->position->y;
} else {
$position = $interview->valutation->position;
}
if (is_array($interview->valutation->classifiers)) {
if ($this->invalidData($token)) return [];
$percentagePosition = isset($token->valutation->percentagePosition) ? "x: " . $token->valutation->percentagePosition->x . " y:" . $token->valutation->percentagePosition->y : '';
$position = is_object($token->valutation->position) ? "x: " . $token->valutation->position->x . " y:" . $token->valutation->position->y : $token->valutation->position;
if (is_array($token->valutation->classifiers))
{
$classifiers = "";
foreach ($interview->valutation->classifiers as $classifier) {
foreach ($token->valutation->classifiers as $classifier)
{