View difference between Paste ID: wnC7SYif and ARJGRXPq
SHOW: | | - or go back to the newest paste.
1-
 var tests:[Test]
1+
for item in subjects {
2-
2+
      item.lessonAvailable = 0.0
3-
3+
      item.lessonCompleted = 0.0
4-
4+
      item.otherLesson = 0.0
5-
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
5+
      Database.shared.database.collection(item.databasePath + "/lessons").getDocuments(completion: {(query, error) in
6-
    if indexPath.row == 0 {
6+
        if let docs = query?.documents {
7-
      return 15
7+
          for it in docs {
8
            do {
9-
    else if (indexPath.row == 1 && (tests[testIndex].imagesURL.isEmpty && !checkMode)) || (indexPath.row == 2 && (!tests[testIndex].imagesURL.isEmpty || checkMode)) {
9+
              let lesson = try Lesson(fromDictionary: it.data())
10-
      return 0.1
10+
              if Database.shared.user.teacherIsContains(lesson.professorPath) {
11
                item.lessonAvailable += 1
12-
    else if (indexPath.row == 7 && (tests[testIndex].imagesURL.isEmpty && !checkMode)) || (indexPath.row == 8 && (!tests[testIndex].imagesURL.isEmpty || checkMode)) {
12+
                self.allAvailable += 1
13-
      return 20
13+
                for i in Database.shared.user.completedLessonsKey {
14
                  if i["key"] == lesson.databaseID {
15-
    else if indexPath.row == 1 && !tests[testIndex].imagesURL.isEmpty && !checkMode {
15+
                    item.lessonCompleted += 1
16-
      return 215
16+
                    self.allCompleted += 1
17
                    break
18-
    else if indexPath.row == 1 && checkMode {
18+
                  }
19-
      return 150
19+
                }
20
              }
21-
    else if (indexPath.row == 2 && (tests[testIndex].imagesURL.isEmpty && !checkMode)) || (indexPath.row == 3 && (!tests[testIndex].imagesURL.isEmpty || checkMode)) {
21+
              else {
22-
      return UITableViewAutomaticDimension
22+
                for i in Database.shared.user.completedLessonsKey {
23
                  if i["key"] == lesson.databaseID {
24-
    else if (indexPath.row == 8 && (tests[testIndex].imagesURL.isEmpty && !checkMode)) || (indexPath.row == 9 && (!tests[testIndex].imagesURL.isEmpty || checkMode)) {
24+
                    item.otherLesson += 1
25-
      return 75
25+
                    self.allOther += 1
26
                    break
27-
    else {
27+
                  }
28-
      return UITableViewAutomaticDimension
28+
                }
29
              }
30
            } catch {}
31
          }
32
        }
33
        for item in self.progressBars {
34
          item.removeFromSuperview()
35
        }
36
        self.tableView.reloadDataAnimated()
37
      })
38
    }
39
  }