Commit 8adb5050 authored by ZeMKI's avatar ZeMKI

solved bug on edit study

* now you can edit the study and change the sorting.
* sorting image updated.
parent 768a8dc3
......@@ -2,30 +2,8 @@
<project version="4">
<component name="ChangeListManager">
<list default="true" id="b51d2beb-a115-4b2a-80a2-b27cfb404d6c" name="Default Changelist" comment="">
<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$/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$/app/Helpers/Helper.php" beforeDir="false" afterPath="$PROJECT_DIR$/app/Helpers/Helper.php" afterDir="false" />
<change beforePath="$PROJECT_DIR$/resources/js/components/newstudy.vue" beforeDir="false" afterPath="$PROJECT_DIR$/resources/js/components/newstudy.vue" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
......@@ -226,7 +204,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="preferences.pluginManager" />
<property name="settings.editor.selected.configurable" value="preferences.customizations" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
......@@ -286,6 +264,7 @@
<workItem from="1590480658730" duration="551000" />
<workItem from="1590484643170" duration="25829000" />
<workItem from="1590656055131" duration="4234000" />
<workItem from="1590665422138" duration="796000" />
</task>
<servers />
</component>
......@@ -305,50 +284,54 @@
<screen x="0" y="0" width="2048" height="1280" />
</state>
<state x="770" y="559" key="ComposerInitDialogKey/0.0.2048.1280@0.0.2048.1280" timestamp="1589809796036" />
<state width="2006" height="398" key="GridCell.Tab.0.bottom" timestamp="1590569820144">
<state width="2006" height="405" key="GridCell.Tab.0.bottom" timestamp="1590665409302">
<screen x="0" y="0" width="2048" height="1280" />
</state>
<state width="2006" height="491" key="GridCell.Tab.0.bottom/0.0.2048.1280@0.0.2048.1280" timestamp="1590419278940" />
<state width="2006" height="406" key="GridCell.Tab.0.bottom/128.-1057.1920.1057/0.23.2048.1257@0.23.2048.1257" timestamp="1590060860387" />
<state width="2006" height="406" key="GridCell.Tab.0.bottom/128.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590058941151" />
<state width="2006" height="398" key="GridCell.Tab.0.bottom/65.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590569820144" />
<state width="2006" height="405" key="GridCell.Tab.0.bottom/65.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590665409302" />
<state width="1878" height="406" key="GridCell.Tab.0.bottom/65.-1080.1920.1080/0.0.2048.1280@65.-1080.1920.1080" timestamp="1590168747932" />
<state width="2006" height="398" key="GridCell.Tab.0.center" timestamp="1590569820142">
<state width="2006" height="405" key="GridCell.Tab.0.center" timestamp="1590665409301">
<screen x="0" y="0" width="2048" height="1280" />
</state>
<state width="2006" height="491" key="GridCell.Tab.0.center/0.0.2048.1280@0.0.2048.1280" timestamp="1590419278939" />
<state width="2006" height="406" key="GridCell.Tab.0.center/128.-1057.1920.1057/0.23.2048.1257@0.23.2048.1257" timestamp="1590060860386" />
<state width="2006" height="406" key="GridCell.Tab.0.center/128.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590058941150" />
<state width="2006" height="398" key="GridCell.Tab.0.center/65.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590569820142" />
<state width="2006" height="405" key="GridCell.Tab.0.center/65.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590665409301" />
<state width="1878" height="406" key="GridCell.Tab.0.center/65.-1080.1920.1080/0.0.2048.1280@65.-1080.1920.1080" timestamp="1590168747929" />
<state width="2006" height="398" key="GridCell.Tab.0.left" timestamp="1590569820141">
<state width="2006" height="405" key="GridCell.Tab.0.left" timestamp="1590665409301">
<screen x="0" y="0" width="2048" height="1280" />
</state>
<state width="2006" height="491" key="GridCell.Tab.0.left/0.0.2048.1280@0.0.2048.1280" timestamp="1590419278938" />
<state width="2006" height="406" key="GridCell.Tab.0.left/128.-1057.1920.1057/0.23.2048.1257@0.23.2048.1257" timestamp="1590060860385" />
<state width="2006" height="406" key="GridCell.Tab.0.left/128.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590058941149" />
<state width="2006" height="398" key="GridCell.Tab.0.left/65.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590569820141" />
<state width="2006" height="405" key="GridCell.Tab.0.left/65.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590665409301" />
<state width="1878" height="406" key="GridCell.Tab.0.left/65.-1080.1920.1080/0.0.2048.1280@65.-1080.1920.1080" timestamp="1590168747922" />
<state width="2006" height="398" key="GridCell.Tab.0.right" timestamp="1590569820143">
<state width="2006" height="405" key="GridCell.Tab.0.right" timestamp="1590665409302">
<screen x="0" y="0" width="2048" height="1280" />
</state>
<state width="2006" height="491" key="GridCell.Tab.0.right/0.0.2048.1280@0.0.2048.1280" timestamp="1590419278939" />
<state width="2006" height="406" key="GridCell.Tab.0.right/128.-1057.1920.1057/0.23.2048.1257@0.23.2048.1257" timestamp="1590060860386" />
<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="2006" height="405" key="GridCell.Tab.0.right/65.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590665409302" />
<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="1590656020691">
<state x="0" y="23" width="2048" height="1257" key="SettingsEditor" timestamp="1590665405159">
<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="1590656020691" />
<state x="754" y="390" width="598" height="526" key="StructurePopup" timestamp="1590659300816">
<state x="0" y="23" key="SettingsEditor/65.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590665405159" />
<state x="754" y="390" width="598" height="526" key="StructurePopup" timestamp="1590664935009">
<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="1590659300816" />
<state x="754" y="390" width="598" height="526" key="StructurePopup/65.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590664935009" />
<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="349" y="331" key="com.intellij.ide.ui.customization.CustomizableActionsPanel$EditIconDialog" timestamp="1590665402287">
<screen x="0" y="0" width="2048" height="1280" />
</state>
<state x="349" y="331" key="com.intellij.ide.ui.customization.CustomizableActionsPanel$EditIconDialog/65.-1080.1920.1080/0.0.2048.1280@0.0.2048.1280" timestamp="1590665402287" />
<state x="799" y="561" key="com.intellij.openapi.vcs.update.UpdateOrStatusOptionsDialogupdate-v2" timestamp="1590581191374">
<screen x="0" y="0" width="2048" height="1280" />
</state>
......@@ -376,12 +359,24 @@
</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="1590663077267">
<state x="689" y="292" width="715" height="677" key="search.everywhere.popup" timestamp="1590665227104">
<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="1590663077267" />
<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="1590665227104" />
<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>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="javascript">
<url>file://$PROJECT_DIR$/resources/js/components/newstudy.vue</url>
<line>929</line>
<properties lambdaOrdinal="-1" />
<option name="timeStamp" value="2" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>
\ No newline at end of file
<?php
// Code within app\Helpers\Helper.php
namespace App\Helpers;
use Exception;
......@@ -11,7 +9,7 @@ class Helper
{
/**
* Generate random string with a given set of chars.
* @param $length
* @param $length
* @param string $keyspace
* @return string
* @throws Exception
......@@ -20,10 +18,10 @@ class Helper
{
$pieces = [];
$max = mb_strlen($keyspace, '8bit') - 1;
for ($i = 0; $i < $length; $i++) {
for ($i = 0; $i < $length; $i++)
{
$pieces[] = $keyspace[random_int(0, $max)];
}
return implode('', $pieces);
}
......@@ -37,7 +35,6 @@ class Helper
$img = explode(',', $uri);
$ini = substr($img[0], 11);
$type = explode(';', $ini);
return $type[0];
}
......@@ -50,13 +47,12 @@ class Helper
$filesInFolder = File::files(storage_path('app/presets_tokens'));
$arrayOfFiles = [];
$i = 0;
foreach ($filesInFolder as $path) {
foreach ($filesInFolder as $path)
{
$arrayOfFiles[$i]['basename'] = pathinfo($path)['basename'];
$arrayOfFiles[$i]['dirname'] = url('/images/presets_tokens') . '/' . pathinfo($path)['basename'];
$i++;
}
return $arrayOfFiles;
}
......@@ -70,10 +66,12 @@ class Helper
$arrayOfFiles = $arrayOfClassifiersName = [];
$classifierIndex = 1;
$arrayOfClassifiersName[0]['name'] = 'none';
foreach ($classifiers as $classifier) {
foreach ($classifiers as $classifier)
{
$i = 0;
$filesInFolder = File::files($dir . "/" . $classifier);
foreach ($filesInFolder as $path) {
foreach ($filesInFolder as $path)
{
$arrayOfFiles[$i]['name'] = $classifier;
$arrayOfFiles[$i]['basename'] = pathinfo($path)['basename'];
......@@ -94,13 +92,34 @@ class Helper
public static function super_unique($array, $key)
{
$temp_array = [];
foreach ($array as &$value) {
if (!isset($temp_array[$value[$key]])) {
foreach ($array as &$value)
{
if (!isset($temp_array[$value[$key]]))
{
$temp_array[$value[$key]] = &$value;
}
}
$array = array_values($temp_array);
return $array;
}
/**
* @param $string
* @param $start
* @param $end
* @return bool|string
*/
public static function get_string_between($string, $start, $end)
{
$string = ' ' . $string;
$ini = strpos($string, $start);
if ($ini === 0 || $ini === false) return '';
$ini += strlen($start);
$len = strpos($string, $end, $ini) - $ini;
if (strpos($string, $end, $ini) === false) {
$len = strlen($string) - 1;
}
return substr($string, $ini, $len);
}
}
......@@ -130,7 +130,7 @@
<span class="icon hover:bg-blue-500 text-2xl pb-2" @click="selectedSorting > 1 ? selectedSorting-- : false">
<arrow-left class="text-white items-center"/>
</span>
<img class="w-40 h-40 rounded-full" :src="baseUrl+productionUrl+'/images/sorting1.png'" alt="circle sorting">
<img class="w-40 h-40 rounded-full" :src="baseUrl+productionUrl+'/images/sorting'+selectedSorting+'.png'" alt="circle sorting">
<span class="icon hover:bg-blue-500 text-2xl pb-2" @click="selectedSorting < 2 ? selectedSorting++ : false">
<arrow-right class="text-white items-center"/>
</span>
......@@ -565,7 +565,7 @@
id: 1,
minvalue: 0,
maxvalue: 1,
centerLabel: "",
centerLabel: '',
numberofcircles: 3,
tokennumber: 1,
description: '',
......@@ -621,14 +621,14 @@
},
response: '',
errormessages: {
studyname: this.trans('Name of the Study required.')+'<br>',
author: this.trans('Author\'s name required.')+'<br>',
short_description: this.trans('Study description required required.')+ '<br>',
studyname: this.trans('Name of the Study required.') + '<br>',
author: this.trans('Author\'s name required.') + '<br>',
short_description: this.trans('Study description required required.') + '<br>',
tokens: this.trans('Please fill all the Tokens\'s names.') + '<br>',
answertype: this.trans('Please check that all the answer have a type.') +'<br>',
answertype: this.trans('Please check that all the answer have a type.') + '<br>',
question: this.trans('Please check all the questions.') + '<br>',
multipleanswer: this.trans('One of your Multiple Choice is empty.') + '<br>',
centerLabel: this.trans('Select a label for the center of the sorting.')+ '<br>'
centerLabel: this.trans('Select a label for the center of the sorting.') + '<br>',
},
};
},
......@@ -681,36 +681,39 @@
},
'sorting.sectionNumber': function(newVal, oldVal)
{
console.log('looking for section number');
if (newVal < 0 || oldVal < 0)
if (!this.fetching)
{
newVal = 0;
oldVal = 0;
}
let direction = (newVal - oldVal);
console.log('looking for section number');
if (newVal < 0 || oldVal < 0)
{
newVal = 0;
oldVal = 0;
}
let direction = (newVal - oldVal);
if (direction > 0)
{
for (
var i = 0;
i < direction;
i++
)
if (direction > 0)
{
this.sorting.sections.push('');
for (
var i = 0;
i < direction;
i++
)
{
this.sorting.sections.push('');
}
}
}
else
{
// decrease
for (
var i = 0;
i < Math.abs(direction);
i++
)
else
{
this.sorting.sections.pop();
// decrease
for (
var i = 0;
i < Math.abs(direction);
i++
)
{
this.sorting.sections.pop();
}
}
}
},
......@@ -881,7 +884,7 @@
methods: {
showModal: function()
{
this.$refs['sorting-preview'].toggleSortingPreviewModal()
this.$refs['sorting-preview'].toggleSortingPreviewModal();
},
toggleTabs: function(tabNumber)
{
......@@ -889,6 +892,16 @@
},
fetchAndFormatDataForedit: function()
{
function substrInBetween(whole_str, str1, str2)
{
return whole_str.substring(
whole_str.indexOf(str1) + str1.length,
whole_str.lastIndexOf(str2),
);
}
this.fetching = true;
// study info
this.name = this.studydata.name;
......@@ -912,9 +925,15 @@
this.sorting.description = '';
}
if (detailsArray[2])
this.sorting.classifier = this.studydata.sortings[0].pivot.details.includes('classifier|') ? {name: detailsArray[2].substr(detailsArray[2].indexOf('|') + 1)} : '';
this.sorting.id = _.parseInt(this.studydata.sorting[0].id);
this.selectedSorting = _.parseInt(this.studydata.sorting[0].id);
if (this.studydata.sorting[0].id === 2)
{
this.sorting.classifier = {name: detailsArray[2].substr(detailsArray[2].indexOf('|') + 1)};
this.sorting.sectionNumber = _.parseInt(this.studydata.sortings[0].pivot.details.substr(this.studydata.sortings[0].pivot.details.indexOf('divisions|') + 10, 1));
this.sorting.sections = _.pickBy(this.studydata.sortings[0].pivot.details.substr(this.studydata.sortings[0].pivot.details.indexOf('names|') + 6).split('||')[0].split('|'));
this.sorting.centerLabel = substrInBetween(this.studydata.sortings[0].pivot.details, 'center|', '||');
}
let self = this;
......@@ -1169,14 +1188,16 @@
let study = {};
this.loading = true;
_.merge(study,
{id: this.studydata.id},
{name: this.name},
{author: this.author},
{description: this.short_description},
{sorting: this.sorting},
{presort: this.presort},
{postsort: this.postsort});
_.merge(
study,
{id: this.studydata.id},
{name: this.name},
{author: this.author},
{description: this.short_description},
{sorting: this.sorting},
{presort: this.presort},
{postsort: this.postsort},
);
window.axios.patch('../' + study['id'], study).then(response =>
{
......@@ -1231,7 +1252,7 @@
this.response += this.errormessages.tokens;
}
if(this.sorting.id == 2 && this.sorting.centerLabel == "")
if (this.sorting.id == 2 && this.sorting.centerLabel == '')
{
this.response += this.errormessages.centerLabel;
}
......
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