{"action":"created","comment":{"url":"https://api.github.com/repos/blstream/StudyBox_iOS/pulls/comments/56763778","id":56763778,"diff_hunk":"@@ -9,64 +9,73 @@\n import Foundation\n \n enum StudyType {\n-    \n-    case Test(flashcardsAmount: uint), Learn\n+  case Test(uint), Learn\n }\n \n class Test {\n+  private var deck : [Flashcard]\n+  private(set) var currentCard : Flashcard?\n+  private var passedFlashcards = 0\n+  private var index = 0\n+  private var numberOfFlashcardsInFullDeck : Int\n+  private let testType : StudyType\n+  private let cardsInTest : Int\n+  \n+  init(deck : [Flashcard], testType : StudyType) {\n+    self.deck = deck\n+    self.numberOfFlashcardsInFullDeck = deck.count\n+    self.testType = testType\n     \n-    private var deck : [Flashcard]\n-    private(set) var currentCard : Flashcard?\n-    private var passedFlashcards = 0\n-    private var index = 0\n-    private var numberOfFlashcardsInFullDeck : Int\n-    private let testType : StudyType\n-    private let cardsInTest : Int\n-    \n-    init(deck : [Flashcard], testType : StudyType) {\n-        \n-        self.deck = deck\n-        self.numberOfFlashcardsInFullDeck = deck.count\n-        self.testType = testType\n-        \n-        switch testType {\n-        case .Learn:\n-            cardsInTest = deck.count\n-        case .Test(let questionsNumber):\n-            if questionsNumber > uint(deck.count) {\n-                cardsInTest = deck.count\n-            } else {\n-                cardsInTest = Int(questionsNumber)\n-            }\n-        }\n-        currentFlashcard()\n+    switch testType {\n+    case .Learn:\n+      cardsInTest = deck.count\n+    case .Test(let questionsNumber):\n+      if questionsNumber > uint(deck.count) {\n+        cardsInTest = deck.count\n+      } else {\n+        cardsInTest = Int(questionsNumber)\n+      }\n     }\n     \n-    func currentFlashcard() {\n-        \n-        var rand : Int\n-        \n-        if(cardsInTest == index) {\n-            \n-            currentCard = nil\n-        }\n-        else {\n-            \n-            rand = Int(arc4random_uniform(UInt32(deck.count)))\n-            currentCard = deck[rand]\n-            deck.removeAtIndex(rand)\n-            index += 1\n-        }\n-    }\n-    \n-    func correctAnswer() { //funkcja podpieta pod przycisk dobra odpowiedz\n-        \n-        passedFlashcards += 1\n-        currentFlashcard()\n-    }\n+    newFlashcard(answeredCorrect:true)\n+  }\n+  \n+  /// Sets new flashcard and depending on `answeredCorrect` moves the card to end of deck\n+  /// - Parameter answeredCorrect: was the last card marked correct or not\n+  func newFlashcard(answeredCorrect answeredCorrect:Bool) {\n+    var rand : Int\n     \n-    func IncorrectAnswer() {   //funkcja podpieta pod przycisk zla odpowiedz\n-        \n-        currentFlashcard()\n+    if(cardsInTest == index) {\n+      currentCard = nil\n+    } else {\n+      rand = Int(arc4random_uniform(UInt32(deck.count)))\n+      currentCard = deck[rand]\n+      deck.removeAtIndex(rand)\n+      if !answeredCorrect{\n+        switch testType{\n+        case .Learn:\n+          //moves card to end of deck, if currentCard is not nil\n+          if let moveCardToEnd = currentCard {\n+            deck.append(moveCardToEnd)","path":"StudyBox_iOS/TestLogic.swift","position":107,"original_position":103,"commit_id":"ba837a16bc6a5a20dc68e2c44489a3af650fe381","original_commit_id":"fb1efa5c366833699721f05889613132ba0535a4","user":{"login":"Ymcyk","id":12700069,"avatar_url":"https://avatars.githubusercontent.com/u/12700069?v=3","gravatar_id":"","url":"https://api.github.com/users/Ymcyk","html_url":"https://github.com/Ymcyk","followers_url":"https://api.github.com/users/Ymcyk/followers","following_url":"https://api.github.com/users/Ymcyk/following{/other_user}","gists_url":"https://api.github.com/users/Ymcyk/gists{/gist_id}","starred_url":"https://api.github.com/users/Ymcyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ymcyk/subscriptions","organizations_url":"https://api.github.com/users/Ymcyk/orgs","repos_url":"https://api.github.com/users/Ymcyk/repos","events_url":"https://api.github.com/users/Ymcyk/events{/privacy}","received_events_url":"https://api.github.com/users/Ymcyk/received_events","type":"User","site_admin":false},"body":"Tu powinien się zwiększać cardsInTest, bo test zakończy się po osiągnięciu pierwotnego rozmiaru talii (ewentualnie można zmniejszać index).","created_at":"2016-03-20T12:44:11Z","updated_at":"2016-03-20T12:44:11Z","html_url":"https://github.com/blstream/StudyBox_iOS/pull/29#discussion_r56763778","pull_request_url":"https://api.github.com/repos/blstream/StudyBox_iOS/pulls/29","_links":{"self":{"href":"https://api.github.com/repos/blstream/StudyBox_iOS/pulls/comments/56763778"},"html":{"href":"https://github.com/blstream/StudyBox_iOS/pull/29#discussion_r56763778"},"pull_request":{"href":"https://api.github.com/repos/blstream/StudyBox_iOS/pulls/29"}}},"pull_request":{"url":"https://api.github.com/repos/blstream/StudyBox_iOS/pulls/29","id":63492867,"html_url":"https://github.com/blstream/StudyBox_iOS/pull/29","diff_url":"https://github.com/blstream/StudyBox_iOS/pull/29.diff","patch_url":"https://github.com/blstream/StudyBox_iOS/pull/29.patch","issue_url":"https://api.github.com/repos/blstream/StudyBox_iOS/issues/29","number":29,"state":"open","locked":false,"title":"SB-195-Tryb nauki, logika testu","user":{"login":"kacper1703","id":12765428,"avatar_url":"https://avatars.githubusercontent.com/u/12765428?v=3","gravatar_id":"","url":"https://api.github.com/users/kacper1703","html_url":"https://github.com/kacper1703","followers_url":"https://api.github.com/users/kacper1703/followers","following_url":"https://api.github.com/users/kacper1703/following{/other_user}","gists_url":"https://api.github.com/users/kacper1703/gists{/gist_id}","starred_url":"https://api.github.com/users/kacper1703/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kacper1703/subscriptions","organizations_url":"https://api.github.com/users/kacper1703/orgs","repos_url":"https://api.github.com/users/kacper1703/repos","events_url":"https://api.github.com/users/kacper1703/events{/privacy}","received_events_url":"https://api.github.com/users/kacper1703/received_events","type":"User","site_admin":false},"body":"Added learn mode handling in test logic","created_at":"2016-03-20T11:21:25Z","updated_at":"2016-03-20T12:44:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b33febb91e61d509dc9faf83e8718f7ce9d23836","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/blstream/StudyBox_iOS/pulls/29/commits","review_comments_url":"https://api.github.com/repos/blstream/StudyBox_iOS/pulls/29/comments","review_comment_url":"https://api.github.com/repos/blstream/StudyBox_iOS/pulls/comments{/number}","comments_url":"https://api.github.com/repos/blstream/StudyBox_iOS/issues/29/comments","statuses_url":"https://api.github.com/repos/blstream/StudyBox_iOS/statuses/ba837a16bc6a5a20dc68e2c44489a3af650fe381","head":{"label":"blstream:feature/SB-195-Tryb_nauki_logika","ref":"feature/SB-195-Tryb_nauki_logika","sha":"ba837a16bc6a5a20dc68e2c44489a3af650fe381","user":{"login":"blstream","id":316451,"avatar_url":"https://avatars.githubusercontent.com/u/316451?v=3","gravatar_id":"","url":"https://api.github.com/users/blstream","html_url":"https://github.com/blstream","followers_url":"https://api.github.com/users/blstream/followers","following_url":"https://api.github.com/users/blstream/following{/other_user}","gists_url":"https://api.github.com/users/blstream/gists{/gist_id}","starred_url":"https://api.github.com/users/blstream/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blstream/subscriptions","organizations_url":"https://api.github.com/users/blstream/orgs","repos_url":"https://api.github.com/users/blstream/repos","events_url":"https://api.github.com/users/blstream/events{/privacy}","received_events_url":"https://api.github.com/users/blstream/received_events","type":"Organization","site_admin":false},"repo":{"id":52280705,"name":"StudyBox_iOS","full_name":"blstream/StudyBox_iOS","owner":{"login":"blstream","id":316451,"avatar_url":"https://avatars.githubusercontent.com/u/316451?v=3","gravatar_id":"","url":"https://api.github.com/users/blstream","html_url":"https://github.com/blstream","followers_url":"https://api.github.com/users/blstream/followers","following_url":"https://api.github.com/users/blstream/following{/other_user}","gists_url":"https://api.github.com/users/blstream/gists{/gist_id}","starred_url":"https://api.github.com/users/blstream/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blstream/subscriptions","organizations_url":"https://api.github.com/users/blstream/orgs","repos_url":"https://api.github.com/users/blstream/repos","events_url":"https://api.github.com/users/blstream/events{/privacy}","received_events_url":"https://api.github.com/users/blstream/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/blstream/StudyBox_iOS","description":"StudyBox for iOS - BLStream Patronage 2016 application","fork":false,"url":"https://api.github.com/repos/blstream/StudyBox_iOS","forks_url":"https://api.github.com/repos/blstream/StudyBox_iOS/forks","keys_url":"https://api.github.com/repos/blstream/StudyBox_iOS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/blstream/StudyBox_iOS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/blstream/StudyBox_iOS/teams","hooks_url":"https://api.github.com/repos/blstream/StudyBox_iOS/hooks","issue_events_url":"https://api.github.com/repos/blstream/StudyBox_iOS/issues/events{/number}","events_url":"https://api.github.com/repos/blstream/StudyBox_iOS/events","assignees_url":"https://api.github.com/repos/blstream/StudyBox_iOS/assignees{/user}","branches_url":"https://api.github.com/repos/blstream/StudyBox_iOS/branches{/branch}","tags_url":"https://api.github.com/repos/blstream/StudyBox_iOS/tags","blobs_url":"https://api.github.com/repos/blstream/StudyBox_iOS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/blstream/StudyBox_iOS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/blstream/StudyBox_iOS/git/refs{/sha}","trees_url":"https://api.github.com/repos/blstream/StudyBox_iOS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/blstream/StudyBox_iOS/statuses/{sha}","languages_url":"https://api.github.com/repos/blstream/StudyBox_iOS/languages","stargazers_url":"https://api.github.com/repos/blstream/StudyBox_iOS/stargazers","contributors_url":"https://api.github.com/repos/blstream/StudyBox_iOS/contributors","subscribers_url":"https://api.github.com/repos/blstream/StudyBox_iOS/subscribers","subscription_url":"https://api.github.com/repos/blstream/StudyBox_iOS/subscription","commits_url":"https://api.github.com/repos/blstream/StudyBox_iOS/commits{/sha}","git_commits_url":"https://api.github.com/repos/blstream/StudyBox_iOS/git/commits{/sha}","comments_url":"https://api.github.com/repos/blstream/StudyBox_iOS/comments{/number}","issue_comment_url":"https://api.github.com/repos/blstream/StudyBox_iOS/issues/comments{/number}","contents_url":"https://api.github.com/repos/blstream/StudyBox_iOS/contents/{+path}","compare_url":"https://api.github.com/repos/blstream/StudyBox_iOS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/blstream/StudyBox_iOS/merges","archive_url":"https://api.github.com/repos/blstream/StudyBox_iOS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/blstream/StudyBox_iOS/downloads","issues_url":"https://api.github.com/repos/blstream/StudyBox_iOS/issues{/number}","pulls_url":"https://api.github.com/repos/blstream/StudyBox_iOS/pulls{/number}","milestones_url":"https://api.github.com/repos/blstream/StudyBox_iOS/milestones{/number}","notifications_url":"https://api.github.com/repos/blstream/StudyBox_iOS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/blstream/StudyBox_iOS/labels{/name}","releases_url":"https://api.github.com/repos/blstream/StudyBox_iOS/releases{/id}","deployments_url":"https://api.github.com/repos/blstream/StudyBox_iOS/deployments","created_at":"2016-02-22T14:53:27Z","updated_at":"2016-02-28T20:33:11Z","pushed_at":"2016-03-20T12:34:44Z","git_url":"git://github.com/blstream/StudyBox_iOS.git","ssh_url":"git@github.com:blstream/StudyBox_iOS.git","clone_url":"https://github.com/blstream/StudyBox_iOS.git","svn_url":"https://github.com/blstream/StudyBox_iOS","homepage":null,"size":13140,"stargazers_count":3,"watchers_count":3,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":3,"default_branch":"master"}},"base":{"label":"blstream:master","ref":"master","sha":"c8f16ead40a69bad799f388c2039bf0c134c93d2","user":{"login":"blstream","id":316451,"avatar_url":"https://avatars.githubusercontent.com/u/316451?v=3","gravatar_id":"","url":"https://api.github.com/users/blstream","html_url":"https://github.com/blstream","followers_url":"https://api.github.com/users/blstream/followers","following_url":"https://api.github.com/users/blstream/following{/other_user}","gists_url":"https://api.github.com/users/blstream/gists{/gist_id}","starred_url":"https://api.github.com/users/blstream/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blstream/subscriptions","organizations_url":"https://api.github.com/users/blstream/orgs","repos_url":"https://api.github.com/users/blstream/repos","events_url":"https://api.github.com/users/blstream/events{/privacy}","received_events_url":"https://api.github.com/users/blstream/received_events","type":"Organization","site_admin":false},"repo":{"id":52280705,"name":"StudyBox_iOS","full_name":"blstream/StudyBox_iOS","owner":{"login":"blstream","id":316451,"avatar_url":"https://avatars.githubusercontent.com/u/316451?v=3","gravatar_id":"","url":"https://api.github.com/users/blstream","html_url":"https://github.com/blstream","followers_url":"https://api.github.com/users/blstream/followers","following_url":"https://api.github.com/users/blstream/following{/other_user}","gists_url":"https://api.github.com/users/blstream/gists{/gist_id}","starred_url":"https://api.github.com/users/blstream/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/blstream/subscriptions","organizations_url":"https://api.github.com/users/blstream/orgs","repos_url":"https://api.github.com/users/blstream/repos","events_url":"https://api.github.com/users/blstream/events{/privacy}","received_events_url":"https://api.github.com/users/blstream/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/blstream/StudyBox_iOS","description":"StudyBox for iOS - BLStream Patronage 2016 application","fork":false,"url":"https://api.github.com/repos/blstream/StudyBox_iOS","forks_url":"https://api.github.com/repos/blstream/StudyBox_iOS/forks","keys_url":"https://api.github.com/repos/blstream/StudyBox_iOS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/blstream/StudyBox_iOS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/blstream/StudyBox_iOS/teams","hooks_url":"https://api.github.com/repos/blstream/StudyBox_iOS/hooks","issue_events_url":"https://api.github.com/repos/blstream/StudyBox_iOS/issues/events{/number}","events_url":"https://api.github.com/repos/blstream/StudyBox_iOS/events","assignees_url":"https://api.github.com/repos/blstream/StudyBox_iOS/assignees{/user}","branches_url":"https://api.github.com/repos/blstream/StudyBox_iOS/branches{/branch}","tags_url":"https://api.github.com/repos/blstream/StudyBox_iOS/tags","blobs_url":"https://api.github.com/repos/blstream/StudyBox_iOS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/blstream/StudyBox_iOS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/blstream/StudyBox_iOS/git/refs{/sha}","trees_url":"https://api.github.com/repos/blstream/StudyBox_iOS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/blstream/StudyBox_iOS/statuses/{sha}","languages_url":"https://api.github.com/repos/blstream/StudyBox_iOS/languages","stargazers_url":"https://api.github.com/repos/blstream/StudyBox_iOS/stargazers","contributors_url":"https://api.github.com/repos/blstream/StudyBox_iOS/contributors","subscribers_url":"https://api.github.com/repos/blstream/StudyBox_iOS/subscribers","subscription_url":"https://api.github.com/repos/blstream/StudyBox_iOS/subscription","commits_url":"https://api.github.com/repos/blstream/StudyBox_iOS/commits{/sha}","git_commits_url":"https://api.github.com/repos/blstream/StudyBox_iOS/git/commits{/sha}","comments_url":"https://api.github.com/repos/blstream/StudyBox_iOS/comments{/number}","issue_comment_url":"https://api.github.com/repos/blstream/StudyBox_iOS/issues/comments{/number}","contents_url":"https://api.github.com/repos/blstream/StudyBox_iOS/contents/{+path}","compare_url":"https://api.github.com/repos/blstream/StudyBox_iOS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/blstream/StudyBox_iOS/merges","archive_url":"https://api.github.com/repos/blstream/StudyBox_iOS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/blstream/StudyBox_iOS/downloads","issues_url":"https://api.github.com/repos/blstream/StudyBox_iOS/issues{/number}","pulls_url":"https://api.github.com/repos/blstream/StudyBox_iOS/pulls{/number}","milestones_url":"https://api.github.com/repos/blstream/StudyBox_iOS/milestones{/number}","notifications_url":"https://api.github.com/repos/blstream/StudyBox_iOS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/blstream/StudyBox_iOS/labels{/name}","releases_url":"https://api.github.com/repos/blstream/StudyBox_iOS/releases{/id}","deployments_url":"https://api.github.com/repos/blstream/StudyBox_iOS/deployments","created_at":"2016-02-22T14:53:27Z","updated_at":"2016-02-28T20:33:11Z","pushed_at":"2016-03-20T12:34:44Z","git_url":"git://github.com/blstream/StudyBox_iOS.git","ssh_url":"git@github.com:blstream/StudyBox_iOS.git","clone_url":"https://github.com/blstream/StudyBox_iOS.git","svn_url":"https://github.com/blstream/StudyBox_iOS","homepage":null,"size":13140,"stargazers_count":3,"watchers_count":3,"language":"Swift","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":5,"forks":0,"open_issues":5,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/blstream/StudyBox_iOS/pulls/29"},"html":{"href":"https://github.com/blstream/StudyBox_iOS/pull/29"},"issue":{"href":"https://api.github.com/repos/blstream/StudyBox_iOS/issues/29"},"comments":{"href":"https://api.github.com/repos/blstream/StudyBox_iOS/issues/29/comments"},"review_comments":{"href":"https://api.github.com/repos/blstream/StudyBox_iOS/pulls/29/comments"},"review_comment":{"href":"https://api.github.com/repos/blstream/StudyBox_iOS/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/blstream/StudyBox_iOS/pulls/29/commits"},"statuses":{"href":"https://api.github.com/repos/blstream/StudyBox_iOS/statuses/ba837a16bc6a5a20dc68e2c44489a3af650fe381"}}}}