# Evaluate, Learner Licence Tasks

  • Edit DlFlow.kflow and change insert the below content to change the DrivingLicence flow.
role-ref RTO("rto"), Applicant("applicant")

flow DrivingLicence {
document(applicantId:String, firstName:String,lastName:String,  age:Int, reviewOkay:Boolean = `false`,
    first:Int?, ^second:Int?, result:Int?,
    writtenTestPassed:Boolean = `false`) 

task ReviewApplication {
  input(firstName, lastName, age) display-id("${document.firstName} ${document.lastName}")
  output(reviewOkay)
  realizer manual(RTO) distribution(system)
}
task SelectQuestion {
  output(first!,^second!)
  realizer auto
}

task WriteTest {
  input(applicantId, first!,^second!) display-id("${document.firstName} ${document.lastName}")
  output(result!)
    realizer manual(Applicant) distribution(custom)
} 

task IssueRegretLetter {
    input(firstName)
    realizer auto
}
task Evaluate {
  input(first!,^second!,result!)
  output(writtenTestPassed)
    realizer auto
}
task IssueLL {
  input(firstName)
    realizer auto 
}
    
net DL {
  init-document(applicantId, firstName,lastName, age) having coorelation-id (applicantId)
  START out (ReviewApplication)
  connector C1 in(ReviewApplication) out select {
    case  applicationFine => `reviewOkay` => SelectQuestion
    case default => IssueRegretLetter
  }
  connector C2 in(SelectQuestion) out(WriteTest)
  connector C3 in(WriteTest) out(Evaluate)
  connector C4 in(Evaluate) out select {  
    case writtenTestPassed => `writtenTestPassed` => IssueLL  
    case default => IssueRegretLetter
  }
    END in any (IssueRegretLetter,IssueLL)
}    
}
  • Two task got added here one is Evaluate which checks if answer entered in WriteTest is correct, other is IssueLL which issues a learner licence. Connector C4 checks if evaluation is fine then Learner Licence gets issued else Regret Letter task gets fired.
  • Two new tasks are auto tasks, so we need to provide the code.
  • EvaluateTaskCode evaluate the written test questionand returns writtenTestPassed as output.
  • Edit EvaluateTaskCode and replace execute method with the following,
def execute(taskId:Id, input:Input): Output = Output(input.first + input.second == input.result)
  • Edit IssueLLTaskCode and replace execute method with the following,
def execute(taskId:Id, input:Input): Output = {
    println(s"Issue LL to ${input.firstName}")
    Output()
}
  • $compile.
  • $run.

# Execute Flow

  • Go to the browser, and localhost:9000/monitorview.
  • Enter username and password rto/rtorto (rto user can create the flow).
  • Go to Team tab and click on + button next to the team name.
  • In Create Flow page select the net DL, application Id as johndoe,and First name as Steve ,Last name as Martin and age as 24.
  • Submit will create the flow, and a review Application task (notice the task is allocated to rto).
  • Go to localhost:9000/benchview to see the task allocated to rto.
  • Click on the task display as Steve Martin.
  • Start the task by clicking on START button, check output Review Okay as true, and COMPLETE.
  • If you check output Review Okay as false,then as a result of the Connector C1, IssueRegretLetter Task will get executed and End the flow, since the flow ends in any of the task IssueregretLetter or WriteTest.
  • Now browse localhost:9000/monitorview, notice SelectQuestion auto task got completed automatically, and WriteTest task is assigned to johndoe.
  • Go to localhost:9000/benchview but we need to login as johndoe to complete the task,so logout, and login again in benchview as johndoe/johndoe(may use a different browser).
  • WriteTest task is listed, start the task. Add the numbers First and Second and enter the Result. Click on Save and Complete.
  • Logout and login as rto/rto (If a different browser is used then come back to the previous one).
  • Connector C4 tells if right answer is entered then IssueLL task get executed, if wrong answer then IssueRegretLetter, and flow ends if one of them get triggered.
  • Go to http://localhost:9000/reportview#/flow/search and select Flow Name as DrivingLicence from the dropdown.
  • Click on search result, and see the details of the flow just got completed along with all the completed tasks.

That concludes the phase three.