<commit_before>import UIKit
import MapKit

class ExamViewController: UITableViewController, MKMapViewDelegate {
    var exam : Exam? = nil
    @IBOutlet weak var mapView: MKMapView!
    @IBOutlet weak var examName: UILabel!
    @IBOutlet weak var examPaper: UILabel!
    @IBOutlet weak var venue: UILabel!
    @IBOutlet weak var date: UILabel!
    @IBOutlet weak var length: UILabel!
    var dateTimeFormatter = NSDateFormatter()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        mapView.delegate = self
        
        dateTimeFormatter.dateStyle = NSDateFormatterStyle.LongStyle
        dateTimeFormatter.timeStyle = NSDateFormatterStyle.ShortStyle
        dateTimeFormatter.locale = NSLocale(localeIdentifier: "en-IE")
        
        if let exam = exam {
            navigationItem.title = exam.code
            examName.text = exam.name
            examPaper.text = exam.paper
            venue.text = exam.venue
            date.text = dateTimeFormatter.stringFromDate(exam.date)
            length.text = exam.durationString
            
            let location = exam.location
            let span = MKCoordinateSpanMake(0.008, 0.008)
            let region = MKCoordinateRegion(center: location, span: span)
            mapView.setRegion(region, animated: false)
            
            // Shown a pin at the exam location
            let annotation = MKPointAnnotation()
            annotation.setCoordinate(location)
            mapView.addAnnotation(annotation)
        }
    
        navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Action, target: self, action: "onAction")
    }
    
    func onAction() {
        let actions = UIActionSheet(title: nil, delegate: nil, cancelButtonTitle: "Cancel", destructiveButtonTitle: nil, otherButtonTitles: "Get directions", "Add to calendar")
        actions.showFromBarButtonItem(navigationItem.rightBarButtonItem, animated: true)
    }
    <commit_msg>Implement exam's view action sheet<commit_after>import UIKit
import MapKit
import EventKit

class ExamViewController: UITableViewController, MKMapViewDelegate, UIActionSheetDelegate {
    var exam : Exam? = nil
    @IBOutlet weak var mapView: MKMapView!
    @IBOutlet weak var examName: UILabel!
    @IBOutlet weak var examPaper: UILabel!
    @IBOutlet weak var venue: UILabel!
    @IBOutlet weak var date: UILabel!
    @IBOutlet weak var length: UILabel!
    var dateTimeFormatter = NSDateFormatter()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        mapView.delegate = self
        
        dateTimeFormatter.dateStyle = NSDateFormatterStyle.LongStyle
        dateTimeFormatter.timeStyle = NSDateFormatterStyle.ShortStyle
        dateTimeFormatter.locale = NSLocale(localeIdentifier: "en-IE")
        
        if let exam = exam {
            navigationItem.title = exam.code
            examName.text = exam.name
            examPaper.text = exam.paper
            venue.text = exam.venue
            date.text = dateTimeFormatter.stringFromDate(exam.date)
            length.text = exam.durationString
            
            let location = exam.location
            let span = MKCoordinateSpanMake(0.008, 0.008)
            let region = MKCoordinateRegion(center: location, span: span)
            mapView.setRegion(region, animated: false)
            
            // Shown a pin at the exam location
            let annotation = MKPointAnnotation()
            annotation.setCoordinate(location)
            mapView.addAnnotation(annotation)
        }
    
        navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Action, target: self, action: "onAction")
    }
    
    // MARK: - Action Sheet

    func onAction() {
        let actions = UIActionSheet(title: nil, delegate: self, cancelButtonTitle: "Cancel", destructiveButtonTitle: nil, otherButtonTitles: "Get Directions", "Add To Calendar")
        actions.showFromBarButtonItem(navigationItem.rightBarButtonItem, animated: true)
    }
    
    func actionSheet(myActionSheet: UIActionSheet!, clickedButtonAtIndex buttonIndex: Int) {
        switch(buttonIndex) {
        case 1:
            // Get directions
            let location = exam!.location
            let destination = MKMapItem(placemark: MKPlacemark(coordinate: location, addressDictionary: nil))
            destination.name = exam?.venue
            destination.openInMapsWithLaunchOptions([MKLaunchOptionsDirectionsModeKey: MKLaunchOptionsDirectionsModeDriving])
        case 2:
            // Add to calendar
            let store = EKEventStore()
            let event = EKEvent(eventStore: store)
            event.title = "\(exam!.name) Exam"
            event.startDate = exam!.date
            event.endDate = exam!.date.dateByAddingTimeInterval(exam!.duration.doubleValue * 60)
            store.requestAccessToEntityType(EKEntityTypeEvent) { (granted: Bool, error: NSError!) in
                if granted {
                    event.calendar = store.defaultCalendarForNewEvents
                    var err: NSError? = nil
                    store.saveEvent(event, span: EKSpanThisEvent, error: &err)
                }
            }
            break
        default:
            break
        }
    }

{'fraction_non_alphanumeric': 0.07571752265861027, 'fraction_numerical': 0.0037764350453172208, 'mean_word_length': 2.4086229086229087, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3607496', 'n_tokens_mistral': 1451, 'n_tokens_neox': 1404, 'n_words': 337}