This commit is contained in:
Luca Jäntsch
2019-05-29 17:06:29 +02:00
parent c4c36b2787
commit fa6f0f88e0
8 changed files with 125 additions and 18 deletions

38
bash_scripts/generate.sh Executable file
View File

@@ -0,0 +1,38 @@
#!/bin/bash
# relative or absolute path where the classes are
path=../public/data/class/*
# image filetype needs to be the same
file_type=*.jpg
# REGEX
reg='(.*)class\/([0\-9A\-z_]*)\/([0\-9A\-z_]*)\.jpg'
#reg='class\/([0\-9A\-z_]*)'
for i in $path
do
if [ -d "$i" ]; then
#echo "$i"
json_file=$i/user.json
printf '{\n"user":[\n'>$json_file
for j in $i/*
do
if [[ $j == ${file_type} ]]; then
if [[ $j =~ ${reg} ]]; then
echo "${BASH_REMATCH[3]}"
printf '"'>>$json_file
printf ${BASH_REMATCH[3]}>>$json_file
printf '",\n'>>$json_file
else
echo "TEST2"
echo $j
fi
fi
done
cat $json_file | rev | cut -c 3- | rev
fi
done

View File

View File

View File

@@ -1,8 +1,26 @@
{
"user":[
"max_mustermann",
"bernd_baecker",
"fred_fischer",
"charley_"
"user": [
"stanislav_teun",
"christina_juliana",
"nele_mechthild",
"hans-guenther_Patrick",
"irmingrad_eckhard",
"felix_leonore",
"ruediger_gregor",
"kai_tanja",
"hans_judit",
"susann_laurenz",
"mathis_raphaela",
"stanislav_teun",
"christina_juliana",
"nele_mechthild",
"hans-guenther_Patrick",
"irmingrad_eckhard",
"felix_leonore",
"ruediger_gregor",
"kai_tanja",
"hans_judit",
"susann_laurenz",
"mathis_raphaela"
]
}

View File

@@ -13,12 +13,17 @@ export class Main extends React.Component{
selected:"-",
students:[],
stud_html:[],
choose:1
choose:1,
prank:30,
prank_i:0,
prank_delay:100
}
this.selCh = this.selCh.bind(this);
this.changeChoosen = this.changeChoosen.bind(this);
this.choose = this.choose.bind(this);
this.chooseInit = this.chooseInit.bind(this);
var me = this;
Classes.load_Classes((data)=>{
@@ -51,21 +56,40 @@ export class Main extends React.Component{
changeChoosen(e){
this.setState({choose:e.target.value})
}
chooseInit(){
this.setState({prank_i:0})
this.choose();
}
choose(){
for(var i in User.user_arr){
User.user_arr[i].appear();
}
var me = this;
var c = [];
for(var i = 0;i<this.state.choose;i++){
var y = -1;
var nc = false;
y = Math.floor(Math.random()*User.user_arr.length);
if(c[0]==y){
y = Math.floor(Math.random()*User.user_arr.length);
}
c.push(y);
var users = User.user_arr.length;
var needed = User.user_arr.length-this.state.choose;
User.user_arr[y].disappear();
var already_picked = [];
for(var i = 0;i<needed;i++){
var pushed = false;
do {
var x = Math.floor(Math.random()*users);
if(already_picked.indexOf(x)===-1){
already_picked.push(x);
console.log(x);
User.user_arr[x].disappear();
pushed = true;
}
} while (pushed == false);
}
console.log(c)
setTimeout(function(){
if(me.state.prank > me.state.prank_i){
me.setState({prank_i:me.state.prank_i+1})
me.choose();
}
},me.state.prank_delay)
}
render(){
return (
@@ -83,7 +107,7 @@ export class Main extends React.Component{
<input type="number" min="1" value={this.state.choose} onChange={this.changeChoosen}/>
</div>
<div>
<button onClick={this.choose}>Auswählen</button>
<button onClick={this.chooseInit}>Auswählen</button>
</div>
</div>
<div className="studentList">

View File

@@ -30,6 +30,9 @@ export class Student extends React.Component{
var url = '/data/class/student.svg';
this.setState({img_url:url});
}
appear(){
this.setState({dis:""});
}
disappear(){
this.setState({dis:"disappear"});
}

View File

@@ -26,8 +26,14 @@ html,body{
border: 1px solid #454545;
margin: 5px;
padding: 5px;
transition: cubic-bezier(0.075, 0.82, 0.165, 1) 1000ms;
&.disappear{
opacity: 0;
opacity: 0.09;
transition: cubic-bezier(0.075, 0.82, 0.165, 1) 1000ms;
}
&.appear{
opacity: 1;
transition: cubic-bezier(0.075, 0.82, 0.165, 1) 1000ms;
}
.user_img{
img{

18
test/random.js Normal file
View File

@@ -0,0 +1,18 @@
var users = 10;
var needed = 5;
var already_picked = [];
for(var i = 0;i<needed;i++){
var pushed = false;
do {
var x = Math.floor(Math.random()*users);
if(already_picked.indexOf(x)===-1){
already_picked.push(x);
console.log(x);
pushed = true;
}
} while (pushed == false);
}