Commit 2cb63229 authored by ZeMKI's avatar ZeMKI

Merge branch 'master' into Production

parents b60fc37d 8adb5050
This diff is collapsed.
<?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