Skip to content

Commit

Permalink
Lead section id bug fixes & pods update & event view
Browse files Browse the repository at this point in the history
  • Loading branch information
DDVD233 committed Jan 24, 2018
1 parent ff1e449 commit 3665ed4
Show file tree
Hide file tree
Showing 25 changed files with 272 additions and 193 deletions.
4 changes: 2 additions & 2 deletions Class Schedule/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>1.4.1</string>
<string>1.4.2</string>
<key>CFBundleVersion</key>
<string>986</string>
<string>1045</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionMainStoryboard</key>
Expand Down
8 changes: 4 additions & 4 deletions MFSCalender/Acknowledgements.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -351,23 +351,23 @@ Fabric: Copyright 2017 Google, Inc. All Rights Reserved. Use of this software is

## Firebase

Copyright 2017 Google
Copyright 2018 Google

## FirebaseAnalytics

Copyright 2017 Google
Copyright 2018 Google

## FirebaseCore

Copyright 2017 Google
Copyright 2018 Google

## FirebaseInstanceID

Copyright 2017 Google

## FirebasePerformance

Copyright 2017 Google
Copyright 2018 Google

## FirebaseSwizzlingUtilities

Expand Down
26 changes: 23 additions & 3 deletions MFSCalender/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -1019,18 +1019,33 @@
</cells>
</collectionView>
<containerView opaque="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Upd-iJ-CgO">
<rect key="frame" x="0.0" y="185" width="375" height="232"/>
<rect key="frame" x="0.0" y="186" width="375" height="231"/>
<connections>
<segue destination="Dc0-iM-lFO" kind="embed" id="sbo-FP-LLG"/>
</connections>
</containerView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="xRR-BQ-Vx2">
<rect key="frame" x="20" y="185" width="335" height="1"/>
<color key="backgroundColor" red="0.82352941176470584" green="0.82352941176470584" blue="0.82352941176470584" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstAttribute="height" constant="1" id="mma-5a-tiX"/>
</constraints>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
<real key="value" value="1"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="Upd-iJ-CgO" secondAttribute="trailing" id="3tu-fF-IG9"/>
<constraint firstItem="Upd-iJ-CgO" firstAttribute="top" secondItem="p4P-pw-RjD" secondAttribute="bottom" constant="10" id="Enb-IE-SsR"/>
<constraint firstAttribute="trailing" secondItem="xRR-BQ-Vx2" secondAttribute="trailing" constant="20" id="IaE-BY-DGB"/>
<constraint firstItem="p4P-pw-RjD" firstAttribute="leading" secondItem="U8A-Xp-bII" secondAttribute="leading" constant="20" id="RAM-J1-sEF"/>
<constraint firstItem="Upd-iJ-CgO" firstAttribute="top" secondItem="xRR-BQ-Vx2" secondAttribute="bottom" id="RgC-uS-Fcl"/>
<constraint firstItem="xRR-BQ-Vx2" firstAttribute="top" secondItem="p4P-pw-RjD" secondAttribute="bottom" constant="10" id="RtR-kE-uHI"/>
<constraint firstAttribute="trailing" secondItem="p4P-pw-RjD" secondAttribute="trailing" constant="10" id="U2u-Ae-MFX"/>
<constraint firstItem="xRR-BQ-Vx2" firstAttribute="leading" secondItem="U8A-Xp-bII" secondAttribute="leading" constant="20" id="ZHU-yX-kog"/>
<constraint firstItem="Upd-iJ-CgO" firstAttribute="leading" secondItem="U8A-Xp-bII" secondAttribute="leading" id="cEO-B9-0EQ"/>
<constraint firstItem="p4P-pw-RjD" firstAttribute="top" secondItem="U8A-Xp-bII" secondAttribute="top" constant="20" id="d7z-Hm-ezx"/>
<constraint firstItem="Upd-iJ-CgO" firstAttribute="bottom" secondItem="U8A-Xp-bII" secondAttribute="bottomMargin" id="eyb-Qg-Bx8"/>
Expand Down Expand Up @@ -1395,6 +1410,11 @@
<rect key="frame" x="0.0" y="20" width="375" height="647"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<gestureRecognizers/>
<view key="tableFooterView" contentMode="scaleToFill" id="vht-J6-jmB">
<rect key="frame" x="0.0" y="81" width="375" height="44"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
<prototypes>
<tableViewCell clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="eventTable" id="xE8-0J-TfC" customClass="customEventCell" customModule="MFSMobile" customModuleProvider="target">
<rect key="frame" x="0.0" y="1" width="375" height="80"/>
Expand Down Expand Up @@ -3066,7 +3086,7 @@
<viewControllerLayoutGuide type="bottom" id="duK-sv-58K"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="Aaa-t3-7tw">
<rect key="frame" x="0.0" y="0.0" width="375" height="232"/>
<rect key="frame" x="0.0" y="0.0" width="375" height="231"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
Expand Down
9 changes: 6 additions & 3 deletions MFSCalender/ClassDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,17 @@ class classDetailViewController: UITableViewController, UIDocumentInteractionCon
SVProgressHUD.show()
UIApplication.shared.isNetworkActivityIndicatorVisible = true
}

let sectionIdString = String(describing: sectionId)

let sectionIdString = ClassView().getLeadSectionIDFromSectionInfo(sectionID: String(describing: sectionId))

let semaphore = DispatchSemaphore(value: 0)

provider.request(.getPossibleContent(sectionId: sectionIdString), completion: {
(result) in
switch result {
case let .success(response):
do {
guard let json = try JSONSerialization.jsonObject(with: response.data, options: .allowFragments) as? Array<Dictionary<String, Any?>> else {
guard let json = try JSONSerialization.jsonObject(with: response.data, options: .allowFragments) as? Array<Dictionary<String, Any>> else {
presentErrorMessage(presentMessage: "Internal error: Incorrect data format", layout: .statusLine)
semaphore.signal()
return
Expand Down Expand Up @@ -172,7 +173,9 @@ class classDetailViewController: UITableViewController, UIDocumentInteractionCon
let semaphore = DispatchSemaphore(value: 0)
provider.request(MyService.getClassContentData(contentName: contentNameRemovedWhitespace, sectionId: sectionId), completion: { result in
switch result {

case let .success(response):
print(response.request?.url)
do {
guard let json = try response.mapJSON(failsOnEmptyData: true) as? Array<Dictionary<String, Any?>> else {
semaphore.signal()
Expand Down
25 changes: 11 additions & 14 deletions MFSCalender/CourseFillViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ class courseFillController: UIViewController {
UIApplication.shared.isNetworkActivityIndicatorVisible = true
}

if !self.NCIsRunning() {
self.importCourseTeacher()
return
}

if Preferences().doUpdateQuarter {
setQuarter()
} else {
Expand Down Expand Up @@ -146,28 +151,20 @@ class courseFillController: UIViewController {
self.clearData(day: String(alphabet))
}

if self.NCIsRunning() {
guard let gotSchedule = self.getScheduleNC() else {
DispatchQueue.main.async {
self.viewDismiss()
}
return
guard let gotSchedule = self.getScheduleNC() else {
DispatchQueue.main.async {
self.viewDismiss()
}

schedule = gotSchedule
} else {
self.importCourseTeacher()
return
}

schedule = gotSchedule

//self.fillAdditionalInformarion()
})

group.wait()

if !self.NCIsRunning() {
return
}

self.createScheduleNC(schedule: schedule)

for alphabet in "ABCDEF" {
Expand Down
40 changes: 25 additions & 15 deletions MFSCalender/EventViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class eventViewController: UIViewController, DZNEmptyDataSetSource, DZNEmptyData

@IBOutlet var eventView: UITableView!
let formatter = DateFormatter()
var listEvents: NSMutableArray = []
var listEvents = [[String: Any]]()
var selectedDate: Date? = nil

override func viewDidLoad() {
Expand All @@ -40,22 +40,34 @@ class eventViewController: UIViewController, DZNEmptyDataSetSource, DZNEmptyData
let plistPath = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: "group.org.dwei.MFSCalendar")!.path
let fileName = "/Events.plist"
let path = plistPath.appending(fileName)
let eventData = NSMutableDictionary(contentsOfFile: path)
guard let eventData = NSDictionary(contentsOfFile: path) as? [String: [[String: Any]]] else {
self.listEvents = []
reloadData()
return
}

guard let SelectedDate = selectedDate else {
print("No Date")
return
}
self.formatter.dateFormat = "yyyyMMdd"
let eventDate = formatter.string(from: SelectedDate)
guard let events = eventData?[eventDate] as? NSMutableArray else {
guard let events = eventData[eventDate] else {
self.listEvents = []
self.eventView.reloadData(with: .automatic)
self.eventView.reloadData()
reloadData()
return
}
self.listEvents = events
self.eventView.reloadData(with: .automatic)
self.eventView.reloadData()
reloadData()
}

func reloadData() {
DispatchQueue.main.async {
if self.isViewLoaded && self.view != nil {
self.eventView.reloadData(with: .automatic)
self.eventView.reloadData()
}
}
}

func indicatorInfo(for pagerTabStripController: PagerTabStripViewController) -> IndicatorInfo {
Expand All @@ -74,20 +86,18 @@ extension eventViewController: UITableViewDelegate, UITableViewDataSource {
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "eventTable", for: indexPath as IndexPath) as? customEventCell
let row = indexPath.row
let rowDict = self.listEvents[row] as! Dictionary<String, Any?>
let rowDict = self.listEvents[row]
guard let summary = rowDict["summary"] as? String else {
return UITableViewCell()
}
cell?.ClassName.text = summary
let letter = String(describing: summary[...summary.startIndex])
cell?.PeriodNumber.text = letter
if rowDict["location"] != nil {
let location = rowDict["location"] as! String
if location.hasSuffix("place fields") || location.hasSuffix("Place Fields") {
cell?.RoomNumber.text = nil
} else {
cell?.RoomNumber.text = "At: " + location
}
let location = rowDict["location"] as? String ?? ""
if location.hasSuffix("place fields") || location.hasSuffix("Place Fields") {
cell?.RoomNumber.text = ""
} else {
cell?.RoomNumber.text = location
}

cell?.PeriodTime.text = EventView().getTimeInterval(rowDict: rowDict)
Expand Down
27 changes: 19 additions & 8 deletions MFSCalender/GradeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class gradeViewController: UITableViewController {


var cumGrade: Float = 0 {
willSet {
didSet {
DispatchQueue.main.async {
self.cumGradeProgressRing.setProgress(value: CGFloat(self.cumGrade), animationDuration: 1.0)
}
Expand Down Expand Up @@ -199,7 +199,14 @@ class gradeViewController: UITableViewController {
func getGradeDetail() {
guard loginAuthentication().success else { return }
let userID = loginAuthentication().userId
guard let sectionID = ClassView().getLeadSectionID(classDict: classObject) else { return }
guard let sectionIDInt = ClassView().getLeadSectionID(classDict: classObject) else { return }
var sectionID = String(describing: sectionIDInt)
let group = DispatchGroup()
DispatchQueue.global().async(group: group) {
sectionID = ClassView().getLeadSectionIDFromSectionInfo(sectionID: sectionID)
}

group.wait()

var markingPeriodID: String {
switch quarterSelected {
Expand All @@ -214,7 +221,7 @@ class gradeViewController: UITableViewController {
}
}

let url = "https://mfriends.myschoolapp.com/api/datadirect/GradeBookPerformanceAssignmentStudentList/?sectionId=\(String(describing: sectionID))&markingPeriodId=\(markingPeriodID)&studentUserId=\(userID)"
let url = "https://mfriends.myschoolapp.com/api/datadirect/GradeBookPerformanceAssignmentStudentList/?sectionId=\(sectionID)&markingPeriodId=\(markingPeriodID)&studentUserId=\(userID)"

let semaphore = DispatchSemaphore(value: 0)

Expand Down Expand Up @@ -275,7 +282,8 @@ class gradeViewController: UITableViewController {

let userId = loginAuthentication().userId

let leadSectionId = ClassView().getLeadSectionID(classDict: classObject)
// let leadSectionId = ClassView().getLeadSectionID(classDict: classObject)
let className = classObject["className"] as? String ?? ""

var cumGrade = ""

Expand All @@ -301,9 +309,10 @@ class gradeViewController: UITableViewController {
(data, response, error) -> Void in
if error == nil {
let json = JSON(data!)
print(json)

for (_, subJson): (String, JSON) in json {
if subJson["leadsectionid"].intValue == leadSectionId {
if subJson["sectionidentifier"].stringValue == className {
cumGrade = subJson["cumgrade"].stringValue
print("CumGrade: \(cumGrade)")
}
Expand Down Expand Up @@ -355,12 +364,12 @@ extension gradeViewController {

cell.chartView.delegate = self
cell.chartView.drawBarShadowEnabled = false
cell.chartView.maxVisibleCount = 60
cell.chartView.maxVisibleCount = 10
//cell.chartView.xAxis.labelPosition = .bottom
cell.chartView.chartDescription?.text = ""
cell.chartView.rightAxis.enabled = false
cell.chartView.xAxis.enabled = false
cell.chartView.isUserInteractionEnabled = false
cell.chartView.isUserInteractionEnabled = true

cell.chartView.drawValueAboveBarEnabled = true

Expand All @@ -370,7 +379,7 @@ extension gradeViewController {
yAxisFormatter.positiveSuffix = " %"

let yAxis = cell.chartView.leftAxis
yAxis.labelFont = UIFont.systemFont(ofSize: 10)
yAxis.labelFont = UIFont.systemFont(ofSize: 12)
yAxis.labelCount = 6
yAxis.valueFormatter = DefaultAxisValueFormatter(formatter: yAxisFormatter)
yAxis.labelPosition = .outsideChart
Expand All @@ -381,6 +390,7 @@ extension gradeViewController {
legend.horizontalAlignment = .left
legend.verticalAlignment = .bottom
legend.orientation = .horizontal
legend.font = UIFont.systemFont(ofSize: 12)
legend.xEntrySpace = 4.0

guard !gradeList.isEmpty else { break }
Expand All @@ -399,6 +409,7 @@ extension gradeViewController {

let dataSet = BarChartDataSet(values: yValues, label: assignmentType)
dataSet.setColor(HomeworkView().colorForTheType(type: assignmentType), alpha: 0.7)
dataSet.valueFont = UIFont.systemFont(ofSize: 12)

if let data = cell.chartView.data {
data.addDataSet(dataSet)
Expand Down
4 changes: 2 additions & 2 deletions MFSCalender/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.4.1</string>
<string>1.4.2</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
Expand All @@ -34,7 +34,7 @@
</dict>
</array>
<key>CFBundleVersion</key>
<string>986</string>
<string>1044</string>
<key>Fabric</key>
<dict>
<key>APIKey</key>
Expand Down
Loading

0 comments on commit 3665ed4

Please sign in to comment.