123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- import UIKit
- class InstructionViewController: UIViewController {
-
- @IBOutlet var instructionTableView: UITableView!
-
- var assessmentType = String()
- var assessmentId = Int()
- var assessmentName = String()
-
- var quizInstruction = [String]()
- var quizTime = Int()
- var quesCount = Int()
-
- var viewModel = InstructionViewModel()
-
- override func viewDidLoad() {
- super.viewDidLoad()
-
-
- instructionTableView.delegate = self
- instructionTableView.dataSource = self
- setupData()
- }
-
- override func viewWillAppear(_ animated: Bool) {
- getQuizTime()
- }
-
- func setupData() {
- quizInstruction = ["There will be \(quesCount) questions for digital literacy assessment.", "For each question only one possible answer can be given.", "You have to choose the correct one by clicking the mouse.", "Exam can be accessed only twice before final submission.", "The time limit will be \(quizTime) minutes."]
- instructionTableView.reloadData()
- }
-
- func getQuizTime() {
- if Reachability.isConnectedToNetwork() {
- viewModel.getQuizTime(assessmentId: assessmentId) {
-
- if let time = self.viewModel.quizTime {
-
- self.quizTime = time
- self.setupData()
- }
- }
- } else {
- Alert.showInternetFailureAlert(on: self)
- }
- }
-
-
-
-
-
- @IBAction func backAction(_ sender: Any) {
- self.navigationController?.popViewController(animated: true)
- }
-
- @IBAction func continueAction(_ sender: Any) {
- if assessmentType == "Assessment" {
- let vc = self.storyboard?.instantiateViewController(withIdentifier: "NewQuizViewController") as! NewQuizViewController
- vc.assessmentId = self.assessmentId
- vc.assessmentName = self.assessmentName
- vc.quesCount = quesCount
- vc.quizTime = quizTime
- self.navigationController?.pushViewController(vc, animated: true)
- } else {
- let vc = self.storyboard?.instantiateViewController(withIdentifier: "QuizViewController") as! QuizViewController
- vc.assessmentId = self.assessmentId
- vc.assessmentName = self.assessmentName
- vc.quesNo = quesCount
- self.navigationController?.pushViewController(vc, animated: true)
- }
- }
-
- }
- extension InstructionViewController: UITableViewDelegate, UITableViewDataSource {
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return AppConstant.quizInstruction.count
- }
-
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- guard let cell = tableView.dequeueReusableCell(withIdentifier: "InstructionTableViewCell", for: indexPath) as? InstructionTableViewCell else {
- return UITableViewCell()
- }
-
- cell.instructionLabel.text = "\(indexPath.row + 1). \(quizInstruction[indexPath.row])"
-
- return cell
- }
- }
|