{"action":"created","comment":{"url":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/comments/63591933","id":63591933,"diff_hunk":"@@ -20,70 +18,62 @@ def predictor_badges(student)\n       if current_user.is_student?(current_course)\n         badge.prediction = {\n           id: prediction.id,\n-          times_earned: prediction.times_earned_including_actual\n+          predicted_times_earned: prediction.times_earned_including_actual\n         }\n         badge\n       else\n         badge.prediction = {\n           id: prediction.id,\n-          times_earned: prediction.actual_times_earned\n+          predicted_times_earned: prediction.actual_times_earned\n         }\n         badge\n       end\n     end\n   end\n \n   def predictor_challenges(student)\n-    challenges = []\n-    if current_course.challenges.present? &&\n-        student.team_for_course(current_course).present? &&\n-        current_course.add_team_score_to_student\n-      challenges = current_course.challenges.select(\n-        :id,\n-        :name,\n-        :visible,\n-        :description,\n-        :point_total)\n-\n-      team = student.team_for_course(current_course)\n-      grades = team.challenge_grades\n+    return [] unless challenge_conditions_met? student\n+    team = student.team_for_course(current_course)\n+    grades = team.challenge_grades\n \n-      challenges.each do |challenge|\n-        prediction =\n-          challenge.find_or_create_predicted_earned_challenge(@student.id)\n-        if current_user.is_student?(current_course)\n-          challenge.prediction = {\n-            id: prediction.id, points_earned: prediction.points_earned\n-          }\n-        else\n-          challenge.prediction = {\n-            id: prediction.id, points_earned: 0\n-          }\n-        end\n-\n-        grade = grades.where(challenge_id: challenge.id).first\n+    current_course.challenges.select(\n+      :id,\n+      :name,\n+      :visible,\n+      :description,\n+      :point_total\n+    ).map do |challenge|\n+      prediction =\n+        challenge.find_or_create_predicted_earned_challenge(@student.id)\n+      if current_user.is_student?(current_course)","path":"app/controllers/concerns/predictor_data.rb","position":69,"original_position":69,"commit_id":"7aa1731852a26adc3bf6c8489529786440ebd5f2","original_commit_id":"7aa1731852a26adc3bf6c8489529786440ebd5f2","user":{"login":"acousticrobot","id":1138350,"avatar_url":"https://avatars.githubusercontent.com/u/1138350?v=3","gravatar_id":"","url":"https://api.github.com/users/acousticrobot","html_url":"https://github.com/acousticrobot","followers_url":"https://api.github.com/users/acousticrobot/followers","following_url":"https://api.github.com/users/acousticrobot/following{/other_user}","gists_url":"https://api.github.com/users/acousticrobot/gists{/gist_id}","starred_url":"https://api.github.com/users/acousticrobot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acousticrobot/subscriptions","organizations_url":"https://api.github.com/users/acousticrobot/orgs","repos_url":"https://api.github.com/users/acousticrobot/repos","events_url":"https://api.github.com/users/acousticrobot/events{/privacy}","received_events_url":"https://api.github.com/users/acousticrobot/received_events","type":"User","site_admin":false},"body":"👍 ","created_at":"2016-05-17T19:55:03Z","updated_at":"2016-05-17T19:55:03Z","html_url":"https://github.com/UM-USElab/gradecraft-development/pull/1988#discussion_r63591933","pull_request_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/1988","_links":{"self":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/comments/63591933"},"html":{"href":"https://github.com/UM-USElab/gradecraft-development/pull/1988#discussion_r63591933"},"pull_request":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/1988"}}},"pull_request":{"url":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/1988","id":70374005,"html_url":"https://github.com/UM-USElab/gradecraft-development/pull/1988","diff_url":"https://github.com/UM-USElab/gradecraft-development/pull/1988.diff","patch_url":"https://github.com/UM-USElab/gradecraft-development/pull/1988.patch","issue_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/issues/1988","number":1988,"state":"open","locked":false,"title":"Pr/predicted earned grade","user":{"login":"acousticrobot","id":1138350,"avatar_url":"https://avatars.githubusercontent.com/u/1138350?v=3","gravatar_id":"","url":"https://api.github.com/users/acousticrobot","html_url":"https://github.com/acousticrobot","followers_url":"https://api.github.com/users/acousticrobot/followers","following_url":"https://api.github.com/users/acousticrobot/following{/other_user}","gists_url":"https://api.github.com/users/acousticrobot/gists{/gist_id}","starred_url":"https://api.github.com/users/acousticrobot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acousticrobot/subscriptions","organizations_url":"https://api.github.com/users/acousticrobot/orgs","repos_url":"https://api.github.com/users/acousticrobot/repos","events_url":"https://api.github.com/users/acousticrobot/events{/privacy}","received_events_url":"https://api.github.com/users/acousticrobot/received_events","type":"User","site_admin":false},"body":"This PR adds a `PredictedEarnedGrade` model, which pulls all Prediction Logic off of the `Grade` model. Routing follows the pattern of the other Prediction models, through the API namespace.\r\n\r\nThis PR also:\r\n\r\n  * Standardizes prediction models to use `predicted_points` (`predicted_times_earned` for badges)\r\n  * Updates the sample data to create `PredictedEarnedGrades`\r\n  * Includes a rake task `rake grades:transfer_predictions` to move existing predictions from Grades to PredictedEarnedGrades. Once this is run, we can drop the field off of `Grades`.\r\n\r\nNote: In `app/models/grade.rb`, `Grade#predicted_points` is now a method that finds the PredictedEarnedGrade with the same student and assignment, to handle view calls that present the predicted grade for a grade. I would like to examine the pages that use both `Grade` and `PredictedEarnedGrade` info (the syllabus page, for one), and come up with a better way retrieve this information in one call.","created_at":"2016-05-17T15:07:42Z","updated_at":"2016-05-17T19:55:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4def8e15a4d78ebf2a6cb4d8b0fb464103ce6333","assignee":{"login":"acousticrobot","id":1138350,"avatar_url":"https://avatars.githubusercontent.com/u/1138350?v=3","gravatar_id":"","url":"https://api.github.com/users/acousticrobot","html_url":"https://github.com/acousticrobot","followers_url":"https://api.github.com/users/acousticrobot/followers","following_url":"https://api.github.com/users/acousticrobot/following{/other_user}","gists_url":"https://api.github.com/users/acousticrobot/gists{/gist_id}","starred_url":"https://api.github.com/users/acousticrobot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acousticrobot/subscriptions","organizations_url":"https://api.github.com/users/acousticrobot/orgs","repos_url":"https://api.github.com/users/acousticrobot/repos","events_url":"https://api.github.com/users/acousticrobot/events{/privacy}","received_events_url":"https://api.github.com/users/acousticrobot/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/1988/commits","review_comments_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/1988/comments","review_comment_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/comments{/number}","comments_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/issues/1988/comments","statuses_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/statuses/7aa1731852a26adc3bf6c8489529786440ebd5f2","head":{"label":"UM-USElab:PR/predicted-earned-grade","ref":"PR/predicted-earned-grade","sha":"7aa1731852a26adc3bf6c8489529786440ebd5f2","user":{"login":"UM-USElab","id":4459066,"avatar_url":"https://avatars.githubusercontent.com/u/4459066?v=3","gravatar_id":"","url":"https://api.github.com/users/UM-USElab","html_url":"https://github.com/UM-USElab","followers_url":"https://api.github.com/users/UM-USElab/followers","following_url":"https://api.github.com/users/UM-USElab/following{/other_user}","gists_url":"https://api.github.com/users/UM-USElab/gists{/gist_id}","starred_url":"https://api.github.com/users/UM-USElab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UM-USElab/subscriptions","organizations_url":"https://api.github.com/users/UM-USElab/orgs","repos_url":"https://api.github.com/users/UM-USElab/repos","events_url":"https://api.github.com/users/UM-USElab/events{/privacy}","received_events_url":"https://api.github.com/users/UM-USElab/received_events","type":"Organization","site_admin":false},"repo":{"id":8105769,"name":"gradecraft-development","full_name":"UM-USElab/gradecraft-development","owner":{"login":"UM-USElab","id":4459066,"avatar_url":"https://avatars.githubusercontent.com/u/4459066?v=3","gravatar_id":"","url":"https://api.github.com/users/UM-USElab","html_url":"https://github.com/UM-USElab","followers_url":"https://api.github.com/users/UM-USElab/followers","following_url":"https://api.github.com/users/UM-USElab/following{/other_user}","gists_url":"https://api.github.com/users/UM-USElab/gists{/gist_id}","starred_url":"https://api.github.com/users/UM-USElab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UM-USElab/subscriptions","organizations_url":"https://api.github.com/users/UM-USElab/orgs","repos_url":"https://api.github.com/users/UM-USElab/repos","events_url":"https://api.github.com/users/UM-USElab/events{/privacy}","received_events_url":"https://api.github.com/users/UM-USElab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/UM-USElab/gradecraft-development","description":"GradeCraft is a gameful learning management system, intended to help motivate students to be more engaged in their own learning.","fork":false,"url":"https://api.github.com/repos/UM-USElab/gradecraft-development","forks_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/forks","keys_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/keys{/key_id}","collaborators_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/teams","hooks_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/hooks","issue_events_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/issues/events{/number}","events_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/events","assignees_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/assignees{/user}","branches_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/branches{/branch}","tags_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/tags","blobs_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/git/refs{/sha}","trees_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/git/trees{/sha}","statuses_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/statuses/{sha}","languages_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/languages","stargazers_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/stargazers","contributors_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/contributors","subscribers_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/subscribers","subscription_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/subscription","commits_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/commits{/sha}","git_commits_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/git/commits{/sha}","comments_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/comments{/number}","issue_comment_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/issues/comments{/number}","contents_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/contents/{+path}","compare_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/compare/{base}...{head}","merges_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/merges","archive_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/downloads","issues_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/issues{/number}","pulls_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls{/number}","milestones_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/milestones{/number}","notifications_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/labels{/name}","releases_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/releases{/id}","deployments_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/deployments","created_at":"2013-02-09T03:44:54Z","updated_at":"2016-05-17T17:49:03Z","pushed_at":"2016-05-17T19:39:19Z","git_url":"git://github.com/UM-USElab/gradecraft-development.git","ssh_url":"git@github.com:UM-USElab/gradecraft-development.git","clone_url":"https://github.com/UM-USElab/gradecraft-development.git","svn_url":"https://github.com/UM-USElab/gradecraft-development","homepage":"","size":67368,"stargazers_count":28,"watchers_count":28,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":160,"forks":18,"open_issues":160,"watchers":28,"default_branch":"master"}},"base":{"label":"UM-USElab:master","ref":"master","sha":"242e59a97205aa749439fa63bf6c50b352479f51","user":{"login":"UM-USElab","id":4459066,"avatar_url":"https://avatars.githubusercontent.com/u/4459066?v=3","gravatar_id":"","url":"https://api.github.com/users/UM-USElab","html_url":"https://github.com/UM-USElab","followers_url":"https://api.github.com/users/UM-USElab/followers","following_url":"https://api.github.com/users/UM-USElab/following{/other_user}","gists_url":"https://api.github.com/users/UM-USElab/gists{/gist_id}","starred_url":"https://api.github.com/users/UM-USElab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UM-USElab/subscriptions","organizations_url":"https://api.github.com/users/UM-USElab/orgs","repos_url":"https://api.github.com/users/UM-USElab/repos","events_url":"https://api.github.com/users/UM-USElab/events{/privacy}","received_events_url":"https://api.github.com/users/UM-USElab/received_events","type":"Organization","site_admin":false},"repo":{"id":8105769,"name":"gradecraft-development","full_name":"UM-USElab/gradecraft-development","owner":{"login":"UM-USElab","id":4459066,"avatar_url":"https://avatars.githubusercontent.com/u/4459066?v=3","gravatar_id":"","url":"https://api.github.com/users/UM-USElab","html_url":"https://github.com/UM-USElab","followers_url":"https://api.github.com/users/UM-USElab/followers","following_url":"https://api.github.com/users/UM-USElab/following{/other_user}","gists_url":"https://api.github.com/users/UM-USElab/gists{/gist_id}","starred_url":"https://api.github.com/users/UM-USElab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UM-USElab/subscriptions","organizations_url":"https://api.github.com/users/UM-USElab/orgs","repos_url":"https://api.github.com/users/UM-USElab/repos","events_url":"https://api.github.com/users/UM-USElab/events{/privacy}","received_events_url":"https://api.github.com/users/UM-USElab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/UM-USElab/gradecraft-development","description":"GradeCraft is a gameful learning management system, intended to help motivate students to be more engaged in their own learning.","fork":false,"url":"https://api.github.com/repos/UM-USElab/gradecraft-development","forks_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/forks","keys_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/keys{/key_id}","collaborators_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/teams","hooks_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/hooks","issue_events_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/issues/events{/number}","events_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/events","assignees_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/assignees{/user}","branches_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/branches{/branch}","tags_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/tags","blobs_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/git/refs{/sha}","trees_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/git/trees{/sha}","statuses_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/statuses/{sha}","languages_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/languages","stargazers_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/stargazers","contributors_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/contributors","subscribers_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/subscribers","subscription_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/subscription","commits_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/commits{/sha}","git_commits_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/git/commits{/sha}","comments_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/comments{/number}","issue_comment_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/issues/comments{/number}","contents_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/contents/{+path}","compare_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/compare/{base}...{head}","merges_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/merges","archive_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/downloads","issues_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/issues{/number}","pulls_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls{/number}","milestones_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/milestones{/number}","notifications_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/labels{/name}","releases_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/releases{/id}","deployments_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/deployments","created_at":"2013-02-09T03:44:54Z","updated_at":"2016-05-17T17:49:03Z","pushed_at":"2016-05-17T19:39:19Z","git_url":"git://github.com/UM-USElab/gradecraft-development.git","ssh_url":"git@github.com:UM-USElab/gradecraft-development.git","clone_url":"https://github.com/UM-USElab/gradecraft-development.git","svn_url":"https://github.com/UM-USElab/gradecraft-development","homepage":"","size":67368,"stargazers_count":28,"watchers_count":28,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":18,"mirror_url":null,"open_issues_count":160,"forks":18,"open_issues":160,"watchers":28,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/1988"},"html":{"href":"https://github.com/UM-USElab/gradecraft-development/pull/1988"},"issue":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/issues/1988"},"comments":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/issues/1988/comments"},"review_comments":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/1988/comments"},"review_comment":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/1988/commits"},"statuses":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/statuses/7aa1731852a26adc3bf6c8489529786440ebd5f2"}}}}