2 | | - | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | | - | {-# CONTENT_TYPE DAPP #-} |
---|
4 | | - | let estEnCours = "estEnCours" |
---|
5 | | - | |
---|
6 | | - | let classeEnCours = "" |
---|
7 | | - | |
---|
8 | | - | func getClassName (nom,professeur) = ((nom + "_") + toString(professeur)) |
---|
9 | | - | |
---|
10 | | - | |
---|
11 | | - | func canEtudiantLease (adresse) = { |
---|
12 | | - | let balance = wavesBalance(adresse) |
---|
13 | | - | if ((balance.available > 0)) |
---|
14 | | - | then true |
---|
15 | | - | else false |
---|
16 | | - | } |
---|
17 | | - | |
---|
18 | | - | |
---|
19 | | - | func validerEleve (acc,e) = { |
---|
20 | | - | let studentAddress = Address(fromBase58String(take(e, 35))) |
---|
21 | | - | let studentStatus = takeRight(e, (size(e) - 34)) |
---|
22 | | - | if (if (canEtudiantLease(studentAddress)) |
---|
23 | | - | then if ((studentStatus == "Retard")) |
---|
24 | | - | then true |
---|
25 | | - | else (studentStatus == "Present") |
---|
26 | | - | else false) |
---|
27 | | - | then Lease(studentAddress, wavesBalance(studentAddress).available) |
---|
28 | | - | else unit |
---|
29 | | - | } |
---|
30 | | - | |
---|
31 | | - | |
---|
32 | | - | @Callable(i) |
---|
33 | | - | func createOrModifyClass (nom,eleves) = [StringEntry(getClassName(nom, i.caller), eleves)] |
---|
34 | | - | |
---|
35 | | - | |
---|
36 | | - | |
---|
37 | | - | @Callable(i) |
---|
38 | | - | func deleteClass (nom) = [DeleteEntry(getClassName(nom, i.caller))] |
---|
39 | | - | |
---|
40 | | - | |
---|
41 | | - | |
---|
42 | | - | @Callable(i) |
---|
43 | | - | func faireAppel (classe,eleves) = { |
---|
44 | | - | let leasedEtudiants = { |
---|
45 | | - | let $l = eleves |
---|
46 | | - | let $s = size($l) |
---|
47 | | - | let $acc0 = nil |
---|
48 | | - | func $f0_1 ($a,$i) = if (($i >= $s)) |
---|
49 | | - | then $a |
---|
50 | | - | else validerEleve($a, $l[$i]) |
---|
51 | | - | |
---|
52 | | - | func $f0_2 ($a,$i) = if (($i >= $s)) |
---|
53 | | - | then $a |
---|
54 | | - | else throw("List size exceeds 30") |
---|
55 | | - | |
---|
56 | | - | $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30) |
---|
| 2 | + | {-# CONTENT_TYPE EXPRESSION #-} |
---|
| 3 | + | let sender = toString(tx.sender) |
---|
| 4 | + | let isProfesseur = (getString(("professeur_" + sender)) != unit) |
---|
| 5 | + | if (if (isProfesseur) |
---|
| 6 | + | then true |
---|
| 7 | + | else (this == tx.sender)) |
---|
| 8 | + | then true |
---|
| 9 | + | else { |
---|
| 10 | + | let publicProfesseur = (getString(("professeur_" + toUtf8String(tx.proofs[1]))) != unit) |
---|
| 11 | + | true |
---|