Hello everyone,
I started my code from a slightly easier topic (the weighted selection) before starting with the random selection.
I am writing a template to create a contract with a score and an automatic text note depending on the score. I have read the published topics regarding “if…else” conditions" and the documentation, but I still cannot understand where I am wrong.
Could someone please help? Sorry if I keep pestering all of you with my questions! Your help is so precious to me!
template GiveScore
with
mainEntity : Party
score : Int
scoreNotes : Text
entity: Party
where
signatory mainEntity
observer entity
ensure (score>=0)
choice AssignScore
: GiveScoreId
with
weightedScore :Int
scoreComment: Text
controller mainEntity
do
assertMsg "The score must be an integer between 1 & 10" $
(weightedScore>=0 && weightedScore<=10)
if (weightedScore>=0 && weightedScore<=4 scoreComment == "You can improve") then do
create this with
score = weightedScore
scoreNotes = scoreComment
if (weightedScore>4 && weightedScore<=6 scoreComment == "You are average") then do
create this with
score = weightedScore
scoreNotes = scoreComment
else if (weightedScore>6 && weightedScore<=10 scoreComment == "You are great ") then do
create this with
score = weightedScore
scoreNotes = scoreComment