Hi everyone, here I am again.
Thank you to this community help (And Wallace thank you again for your incredible patience
) I managed to create the first part of my code and I have now started the second part.
I am trying to create a scoring system, on some assets that I created. I saw that there is a good example in Daml examples (Voting example) and I was following that. However, my problem is slightly different as I have to create a score not to express a vote. I wrote the code below, where I am trying to do the following:
1- I want to send some parties a contract to express a score
2- I want use use THAT score to create a template with the score calculation
3- I would like it to work even with 1 party giving the score (the requirement is minimum of 1, up to 5). The score must between 1 and 5.
My code below complies. However, the template where the parties express the score is not linked to the score calculation template. Could please someone help me with the above? I would be extremely grateful for your help and patience.
module AABCVotingSystem where
import DA.Set as S
import DA.List as L
import Daml.Script
import DA.Math
type ScoreComputationId = ContractId ScoreComputation
type Voting1Id = ContractId Voting1
type Voting2Id = ContractId Voting2
{-data AssetProposal = AssetProposal
with
proposer : Party
text : Text
deriving (Eq, Show)-}
template ScoreComputation
with
assetidCode :Text
scoreCalculator: Party
calculatedScore :Int
scoreVoter1: Int
scoreVoter2: Int
scoreVoter3: Int
scoreVoter4: Int
scoreVoter5: Int
where
ensure (scoreVoter1 >= 1) && (scoreVoter1<= 5)
&& (scoreVoter2 >= 1) && (scoreVoter2<= 5)
&& (scoreVoter3 >= 1) && (scoreVoter3<= 5)
&& (scoreVoter4 >= 1) && (scoreVoter4<= 5)
&& (scoreVoter5 >= 1) && (scoreVoter5<= 5)
signatory scoreCalculator
choice MakeScoreCalutation
: ScoreComputationId
with
score1 : Int
score2 : Int
score3 : Int
score4 : Int
score5 : Int
controller scoreCalculator
do
create this with
calculatedScore = (score1 + score2 + score3 + score4 + score5)/5
scoreVoter1= score1
scoreVoter2= score2
scoreVoter3= score3
scoreVoter4= score4
scoreVoter5= score5
template Voting1
with
assetIdcode :Text
solicitor1 :Party
score1 :Int
notes : Text
where
signatory solicitor1
template Voting2
with
assetIdcode :Text
solicitor2 :Party
score2 :Int
notes : Text
where
signatory solicitor2