{"action":"created","comment":{"url":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/comments/52757847","id":52757847,"diff_hunk":"@@ -0,0 +1,36 @@\n+class InstructorOfRecord\n+  attr_reader :course\n+\n+  def initialize(course)\n+    @course = course\n+  end\n+\n+  def update_course_memberships(user_ids)\n+    current_instructors_of_record(user_ids).each do |membership|\n+      membership.update_attributes instructor_of_record: false\n+    end\n+\n+    not_instructors_of_record(user_ids).map do |membership|\n+      membership.update_attributes instructor_of_record: true\n+      membership\n+    end\n+  end\n+\n+  def users\n+    course.course_memberships.instructors_of_record.map(&:user)\n+  end\n+\n+  private\n+\n+  def current_instructors_of_record(user_ids)\n+    course.course_memberships.instructors_of_record.select do |membership|\n+      !user_ids.include?(membership.user_id)\n+    end\n+  end\n+\n+  def not_instructors_of_record(user_ids)\n+    course.course_memberships.select do |membership|","path":"app/models/instructor_of_record.rb","position":32,"original_position":32,"commit_id":"69ffc7c5f098aff6674c7a6a1c1e87beb8c9f83a","original_commit_id":"69ffc7c5f098aff6674c7a6a1c1e87beb8c9f83a","user":{"login":"zazaian","id":95957,"avatar_url":"https://avatars.githubusercontent.com/u/95957?v=3","gravatar_id":"","url":"https://api.github.com/users/zazaian","html_url":"https://github.com/zazaian","followers_url":"https://api.github.com/users/zazaian/followers","following_url":"https://api.github.com/users/zazaian/following{/other_user}","gists_url":"https://api.github.com/users/zazaian/gists{/gist_id}","starred_url":"https://api.github.com/users/zazaian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zazaian/subscriptions","organizations_url":"https://api.github.com/users/zazaian/orgs","repos_url":"https://api.github.com/users/zazaian/repos","events_url":"https://api.github.com/users/zazaian/events{/privacy}","received_events_url":"https://api.github.com/users/zazaian/received_events","type":"User","site_admin":false},"body":"Shouldn't we only be querying for staff here? It seems like there wouldn't be any circumstances in which we have students being reassigned as instructors of record. @chcholman? Thoughts on this workflow? Not a big deal but probably less overhead to iterate over 5-15 staff instead of 50-500 students.","created_at":"2016-02-12T15:53:04Z","updated_at":"2016-02-12T15:53:04Z","html_url":"https://github.com/UM-USElab/gradecraft-development/pull/1650#discussion_r52757847","pull_request_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/1650","_links":{"self":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/comments/52757847"},"html":{"href":"https://github.com/UM-USElab/gradecraft-development/pull/1650#discussion_r52757847"},"pull_request":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/1650"}}},"pull_request":{"url":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/1650","id":59058486,"html_url":"https://github.com/UM-USElab/gradecraft-development/pull/1650","diff_url":"https://github.com/UM-USElab/gradecraft-development/pull/1650.diff","patch_url":"https://github.com/UM-USElab/gradecraft-development/pull/1650.patch","issue_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/issues/1650","number":1650,"state":"open","locked":false,"title":"1384 refactor course","user":{"login":"jwright","id":35017,"avatar_url":"https://avatars.githubusercontent.com/u/35017?v=3","gravatar_id":"","url":"https://api.github.com/users/jwright","html_url":"https://github.com/jwright","followers_url":"https://api.github.com/users/jwright/followers","following_url":"https://api.github.com/users/jwright/following{/other_user}","gists_url":"https://api.github.com/users/jwright/gists{/gist_id}","starred_url":"https://api.github.com/users/jwright/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jwright/subscriptions","organizations_url":"https://api.github.com/users/jwright/orgs","repos_url":"https://api.github.com/users/jwright/repos","events_url":"https://api.github.com/users/jwright/events{/privacy}","received_events_url":"https://api.github.com/users/jwright/received_events","type":"User","site_admin":false},"body":"Refactor the course model and reduce the complexity of it by extracting the updating of course memberships for instructors of record to an `InstructorOfRecord` class.\r\n\r\nCreated a new, non AR backed, model that interacts with instructors of record for `CourseMembership`. This includes the updating of the course memberships based on user ids and the retrieval of users that are marked as instructors of record. Doing so also eliminated a method on `User` that should not of been there.\r\n\r\nRemoved unused `.students_auditing` methods from `Course` and `User`.\r\n\r\nNOTE: This introduces a new, non AR backed, class into the `app/models` directory. Depending on the answer to this open PR question: https://github.com/UM-USElab/gradecraft-development/pull/1638#discussion_r52484671, this may need to be moved.\r\n\r\nReferences #1384 ","created_at":"2016-02-11T16:44:45Z","updated_at":"2016-02-12T15:53:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6f319fa374ffb6a321db3782607d004bd0c72885","assignee":{"login":"zazaian","id":95957,"avatar_url":"https://avatars.githubusercontent.com/u/95957?v=3","gravatar_id":"","url":"https://api.github.com/users/zazaian","html_url":"https://github.com/zazaian","followers_url":"https://api.github.com/users/zazaian/followers","following_url":"https://api.github.com/users/zazaian/following{/other_user}","gists_url":"https://api.github.com/users/zazaian/gists{/gist_id}","starred_url":"https://api.github.com/users/zazaian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zazaian/subscriptions","organizations_url":"https://api.github.com/users/zazaian/orgs","repos_url":"https://api.github.com/users/zazaian/repos","events_url":"https://api.github.com/users/zazaian/events{/privacy}","received_events_url":"https://api.github.com/users/zazaian/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/1650/commits","review_comments_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/1650/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/1650/comments","statuses_url":"https://api.github.com/repos/UM-USElab/gradecraft-development/statuses/69ffc7c5f098aff6674c7a6a1c1e87beb8c9f83a","head":{"label":"UM-USElab:1384-refactor-course","ref":"1384-refactor-course","sha":"69ffc7c5f098aff6674c7a6a1c1e87beb8c9f83a","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-01-27T18:03:56Z","pushed_at":"2016-02-12T15:16:28Z","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":65135,"stargazers_count":27,"watchers_count":27,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":115,"forks":17,"open_issues":115,"watchers":27,"default_branch":"master"}},"base":{"label":"UM-USElab:master","ref":"master","sha":"e5ee4d59592e4a6421d66b37760fd586e3befc91","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-01-27T18:03:56Z","pushed_at":"2016-02-12T15:16:28Z","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":65135,"stargazers_count":27,"watchers_count":27,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":17,"mirror_url":null,"open_issues_count":115,"forks":17,"open_issues":115,"watchers":27,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/1650"},"html":{"href":"https://github.com/UM-USElab/gradecraft-development/pull/1650"},"issue":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/issues/1650"},"comments":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/issues/1650/comments"},"review_comments":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/pulls/1650/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/1650/commits"},"statuses":{"href":"https://api.github.com/repos/UM-USElab/gradecraft-development/statuses/69ffc7c5f098aff6674c7a6a1c1e87beb8c9f83a"}}}}