Commit 50a06756 authored by ZeMKI's avatar ZeMKI
Browse files

Bug smashing

* pre-post-sort questions bugfix.
* shrinked image in show sorting to 2/3.
* show the image spot on top right only on q-sort.
* bugfix edit study with 0 tokens.
* Inserted sorting name below sorting scheme in new study.
* Inserted token description and adapted export all tokens to qsort.
parent 7e56ab6d
......@@ -16,20 +16,20 @@ class AllInterviewTokenExport implements FromCollection, WithMapping, WithHeadin
use Exportable;
private $id;
/**
* @var array
*/
private $head;
private $sorting;
/**
* AllInterviewTokenExport constructor.
* @param $id
* @param array $headings
*/
public function __construct($id, $headings = [])
public function __construct($id, $headings = [], $sorting)
{
$this->id = $id;
$this->head = $headings;
$this->sorting = $sorting;
}
/**
......@@ -42,12 +42,23 @@ class AllInterviewTokenExport implements FromCollection, WithMapping, WithHeadin
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");
if($this->sorting == 1 || $this->sorting == 2)
{
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, "Interviewee Name");
array_push($columnNames, "classifiers");
}else{
array_push($columnNames, "position column/row");
array_push($columnNames, "token description");
array_push($columnNames, "Interviewee Name");
}
foreach ($this->head as $column)
{
array_push($columnNames, $column);
......@@ -65,7 +76,7 @@ class AllInterviewTokenExport implements FromCollection, WithMapping, WithHeadin
$printArray = [];
foreach ($study->interviews as $emptyInterview)
{
$allinterviews = InterviewTokens::where('interview_id', $emptyInterview->id)->get();
$allinterviews = InterviewTokens::where('interview_id', $emptyInterview->id)->join('tokens','token_id','tokens.id')->get();
foreach ($allinterviews as $token)
{
......@@ -104,13 +115,7 @@ class AllInterviewTokenExport implements FromCollection, WithMapping, WithHeadin
{
$percentagePosition = '';
}
if (is_object($token->valutation->position))
{
$position = "x: " . $token->valutation->position->x . " y:" . $token->valutation->position->y;
} else
{
$position = $token->valutation->position;
}
$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 = "";
......@@ -120,17 +125,29 @@ class AllInterviewTokenExport implements FromCollection, WithMapping, WithHeadin
}
}
$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;
ray($token);
if($token->interview->study->sortings[0]->id == 3)
{
ray("sorting 3");
$toPrint["position column/row"] = $position;
$toPrint["token description"] = json_decode($token->properties) ? json_decode($token->properties)->description : '' ;
}else{
ray("not sorting 3");
$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)
{
......
......@@ -45,10 +45,13 @@ class InterviewTokenExport implements FromCollection, WithMapping, WithHeadings
array_push($columnNames, "position (pixels)");
array_push($columnNames, "% percentage position");
array_push($columnNames, "Interviewee Name");
array_push($columnNames, "classifiers");
array_push($columnNames, "classifiers");;
array_push($columnNames, "section number");;
array_push($columnNames, "section name");;
}else{
array_push($columnNames, "position column/row");
array_push($columnNames, "Interviewee Name");
array_push($columnNames, "token description");
}
foreach ($this->head as $column)
......@@ -64,6 +67,7 @@ class InterviewTokenExport implements FromCollection, WithMapping, WithHeadings
*/
public function map($token): array
{
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;
......@@ -82,6 +86,7 @@ class InterviewTokenExport implements FromCollection, WithMapping, WithHeadings
if($token->interview->study->sortings[0]->id == 3)
{
$tempValuesArray["position column/row"] = $position;
$tempValuesArray["token description"] = json_decode($token->properties) ? json_decode($token->properties)->description : '' ;
}else{
$tempValuesArray["circle"] = $token->valutation->circle;
$tempValuesArray["distance from center (pixels)"] = $token->valutation->distance;
......@@ -117,7 +122,7 @@ class InterviewTokenExport implements FromCollection, WithMapping, WithHeadings
*/
public function collection()
{
return InterviewTokens::where('interview_id', $this->id)->get();
return InterviewTokens::where('interview_id', $this->id)->join('tokens','token_id','tokens.id')->get();
}
}
......
......@@ -22,6 +22,7 @@ use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\View\View;
use Str;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
class InterviewController extends Controller
......@@ -101,7 +102,7 @@ class InterviewController extends Controller
{
array_push($returnQuestions['presort'], $question);
}
if (strpos($question->type, 'postsort') != -1)
if (Str::contains($question->type, 'postsort'))
{
array_push($returnQuestions['postsort'], $question);
}
......
......@@ -16,7 +16,7 @@ class StudyInterviewController extends Controller
if (auth()->user()->notOwnerNorInvited($study)) abort(403, "You are not authorized to download these data.");
$headings = $this->getHeadings($study);
return (new AllInterviewTokenExport($study->id, $headings))->download('Interviews from study' . $study->name . '.xlsx');
return (new AllInterviewTokenExport($study->id, $headings, $study->sortings[0]->id))->download('Interviews from study' . $study->name . '.xlsx');
}
public function getHeadings($study)
......
......@@ -155,14 +155,14 @@
v-show="interview.postsortindex == index" class="mx-auto flex flex-wrap justify-center items-center text-center transition">
<h1 class="text-6xl flex-none w-full">{{ x.q }}</h1>
<a v-if="x.type.includes('showsorting')"
:class="showSorting ? 'select-none mb-2 text-2xl uppercase px-8 py-2 border border-gray-800 bg-gray-800 text-white max-w-max hover:text-gray-100 z-50 mt-2' : 'select-none mb-2 text-2xl uppercase px-8 py-2 border border-gray-800 text-gray-800 max-w-max mt-2'"
:class="showSorting ? 'select-none mb-2 text-2xl uppercase px-8 py-2 border border-gray-800 bg-gray-800 text-white max-w-max hover:text-gray-100 z-50 mt-2 mx-auto' : 'select-none mb-2 text-2xl uppercase px-8 py-2 border border-gray-800 text-gray-800 max-w-max mt-2 mx-auto'"
@click="showSorting = !showSorting"
v-text="showSorting ? trans('Hide Sorting') : trans('Show Sorting')"
>
</a>
<div class="w-full" style="margin-top:-75px" v-for="(sorting,key) in interview.structure.sorting">
<img class="w-auto h-auto" v-if="showSorting && key !== 0 && key === interview.postSortSortingindex" :src="sorting.sortingscreenshot">
<div v-for="(sorting,key) in interview.structure.sorting" class="w-full h-full" style="margin-top:-75px">
<img v-if="showSorting && key !== 0 && key === interview.postSortSortingindex" :src="sorting.sortingscreenshot" class="w-2/3 h-2/3 mx-auto ">
</div>
<div class="field flex flex-wrap w-full text-center">
<div v-for="(a,answerindex) in x.answer" class="flex-none w-full">
......@@ -335,7 +335,8 @@ export default {
circles: function () {
let detailsArray = this.study.sortings[0].pivot.details.split('||');
return detailsArray[0].substr(detailsArray[0].indexOf('|') + 1);
}, sortingdetails: function () {
},
sortingdetails: function () {
let detailsArray = this.study.sortings[0].pivot.details.split('||');
if (detailsArray[1]) {
return detailsArray[1].substr(detailsArray[1].indexOf('|') + 1);
......@@ -343,7 +344,8 @@ export default {
else {
return '';
}
}, classifier: function () {
},
classifier: function () {
let detailsArray = this.study.sortings[0].pivot.details.split('||');
if (detailsArray[2]) {
return detailsArray[2].substr(detailsArray[2].indexOf('|') + 1);
......@@ -375,7 +377,7 @@ export default {
},
qsortColumns: function () {
let qsort = this.study.sortings[0].pivot.details.substr(this.study.sortings[0].pivot.details.indexOf('qsort|') + 6).split('|separator|');
if(qsort[qsort.length-1].includes("yes")) this.qsortshownumbers = true;
if (qsort[qsort.length - 1].includes("yes")) this.qsortshownumbers = true;
else this.qsortshownumbers = false;
qsort.pop();
let qsortArray = [];
......
......@@ -51,7 +51,6 @@
{{ array[array.length - 2] !== '--empty--' ? array[array.length - 2] : '' }}
</div>
<div class="bg-white text-black qsortlg:w-24 qsortmd:w-16 qsortsm:w-12 qsortlg:h-24 qsortmd:h-16 qsortsm:h-12 select-none inline-block align-top justify-center"
>
{{ array[array.length - 1] !== '--empty--' ? array[array.length - 1] : '' }}
</div>
......
......@@ -199,7 +199,8 @@
inputLength.sorting_description - sorting.description.length
}}/{{
inputLength.sorting_description
}}</span>
}}
</span>
</div>
</div>
......@@ -243,6 +244,9 @@
class="text-white items-center"/>
</span>
</div>
<p class="text-white" v-if="selectedSorting === 1">{{ trans('Circle Sorting') }}</p>
<p class="text-white" v-else-if="selectedSorting === 2">{{ trans('Network Sorting') }}</p>
<p class="text-white" v-else-if="selectedSorting === 3">{{ trans('Q Sort') }}</p>
</div>
<div
......@@ -697,8 +701,9 @@
class="token-img w-full mx-auto">
<img
:id="'token'+index"
alt=""
:alt="trans('Upload a token image')"
class="h-full w-full flex self-center mb-6"
style="display: block; position: absolute; content: attr(alt);"
src=""
>
</div>
......@@ -1870,9 +1875,13 @@ export default {
setTimeout(function () {
if(self.studydata.sorting[0].id === 1 && self.studydata.tokens.length === 0){
self.sorting.tokens = []
}
for (let i = 0;
i < self.studydata.tokens.length;
i++) {
document.querySelector('#token' + i).src = self.studydata.tokens[i].image_path;
}
......
......@@ -81,7 +81,7 @@
</div>
<div class="flex flex-shrink-1 ml-2 items-center">
<div class="flex flex-shrink-1 ml-2 items-center" v-if="sortingType == 3">
<img v-if="selectedToken" :src="selectedToken.image_path" style="width: 50px;height: 50px;z-index:100;">
</div>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment