{"action":"created","comment":{"url":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/comments/88742396","pull_request_review_id":9309962,"id":88742396,"diff_hunk":"@@ -38,45 +39,57 @@ const usersThatHaveErrors = {};\n \n router.post('/typeformAssignment/:assignment', function (req, res) {\n   const formResponse = req.body.form_response;\n-  const emailWithSubmission = helpers.extractEmailAndFormatSubmission(formResponse);\n   const assignment = req.params.assignment;\n+  const emailAndAnswers = helpers.extractEmailAndFormatSubmission(formResponse);\n   const logErrEmailHeather = createLogErrEmailHeatherFunc(`typeform submission for email:` +\n-        `${emailWithSubmission.email} was not able to be given credit for ${assignment}`);\n-\n-  retrieveUserCourseAssignmentIds(emailWithSubmission.email, assignment, logErrEmailHeather)\n-  .then(responses => {\n-    // responses is [userID, courseID, assignmentID] so we spread it\n-    const pSubmitAssign = canvas.submitAssignment(...responses, emailWithSubmission.submissionHTML, delay);\n-\n-    // If updateUserGrade after submitAssignment then Canvas marks the assignment as graded\n-    // we need updateUserGrade to run first so that Canvas alerts trainers to grade the submission\n-    if (formResponse.calculated && formResponse.calculated.score) {\n-      return canvas.updateUserGrade(...responses, (formResponse.calculated.score + emailWithSubmission.gradeModifier), delay)\n-        .then(() => pSubmitAssign);\n-    } else {\n-      return pSubmitAssign;\n-    }\n-  }).then(() => {\n-    if (helpers.triggersBasedOnAssignment[assignment]) {\n-      return helpers.triggersBasedOnAssignment[assignment](emailWithSubmission.email);\n-    }\n-  })\n-  .then(() => res.send({message: `Successfully submitted ${assignment} with ${JSON.stringify(emailWithSubmission)}`}))\n-  .catch((err) => {\n-    const message = `Submitting ${assignment} for ${emailWithSubmission.email} in Canvas failed: ${err}`;\n-    if (!usersThatHaveErrors[emailWithSubmission.email]) {\n-      usersThatHaveErrors[emailWithSubmission.email] = 1;\n-      res.status(500).send({message});\n-    } else if (usersThatHaveErrors[emailWithSubmission.email] === CONFIG.sherlock.retrySubmission) {\n-      res.status(202).send({message});\n-    } else {\n-      usersThatHaveErrors[emailWithSubmission.email]++;\n-      res.status(500).send({message});\n-    }\n-  });\n+        `${emailAndAnswers.email} was not able to be given credit for ${assignment}`);\n+  const sortedQuestions = helpers.sortQuestions(formResponse);\n+  // queryEachQuestion returns a score adjustment number but also modifies the pairedQtoA object \n+  // to include commentary about grade adjustments from Prediction\n+\n+  helpers.queryEachQuestion(sortedQuestions,emailAndAnswers.answers,assignment)\n+    .then(function(scoreAndComments){\n+      const answers = emailAndAnswers.answers;\n+      return {sortedQuestions, answers, scoreAndComments};\n+    })\n+    .then(helpers.formatHTMLresponse)\n+    .then(function(submissionHTMLandGradeModifier){\n+      const gradeMod = submissionHTMLandGradeModifier.gradeModifier;","path":"www/canvas/index.js","position":70,"original_position":70,"commit_id":"00139bb083ed761520421fa763309cd4ae14db31","original_commit_id":"00139bb083ed761520421fa763309cd4ae14db31","user":{"login":"apackin","id":10517945,"avatar_url":"https://avatars.githubusercontent.com/u/10517945?v=3","gravatar_id":"","url":"https://api.github.com/users/apackin","html_url":"https://github.com/apackin","followers_url":"https://api.github.com/users/apackin/followers","following_url":"https://api.github.com/users/apackin/following{/other_user}","gists_url":"https://api.github.com/users/apackin/gists{/gist_id}","starred_url":"https://api.github.com/users/apackin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apackin/subscriptions","organizations_url":"https://api.github.com/users/apackin/orgs","repos_url":"https://api.github.com/users/apackin/repos","events_url":"https://api.github.com/users/apackin/events{/privacy}","received_events_url":"https://api.github.com/users/apackin/received_events","type":"User","site_admin":false},"body":"What if this isn't an assignment that has a gradeModifier?","created_at":"2016-11-18T21:25:20Z","updated_at":"2016-11-18T21:25:20Z","html_url":"https://github.com/CrisisTextLine/Elmer/pull/251#discussion_r88742396","pull_request_url":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/251","_links":{"self":{"href":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/comments/88742396"},"html":{"href":"https://github.com/CrisisTextLine/Elmer/pull/251#discussion_r88742396"},"pull_request":{"href":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/251"}}},"pull_request":{"url":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/251","id":94269835,"html_url":"https://github.com/CrisisTextLine/Elmer/pull/251","diff_url":"https://github.com/CrisisTextLine/Elmer/pull/251.diff","patch_url":"https://github.com/CrisisTextLine/Elmer/pull/251.patch","issue_url":"https://api.github.com/repos/CrisisTextLine/Elmer/issues/251","number":251,"state":"open","locked":false,"title":"Google Prediction API Learning","user":{"login":"mikehow1984","id":8138556,"avatar_url":"https://avatars.githubusercontent.com/u/8138556?v=3","gravatar_id":"","url":"https://api.github.com/users/mikehow1984","html_url":"https://github.com/mikehow1984","followers_url":"https://api.github.com/users/mikehow1984/followers","following_url":"https://api.github.com/users/mikehow1984/following{/other_user}","gists_url":"https://api.github.com/users/mikehow1984/gists{/gist_id}","starred_url":"https://api.github.com/users/mikehow1984/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikehow1984/subscriptions","organizations_url":"https://api.github.com/users/mikehow1984/orgs","repos_url":"https://api.github.com/users/mikehow1984/repos","events_url":"https://api.github.com/users/mikehow1984/events{/privacy}","received_events_url":"https://api.github.com/users/mikehow1984/received_events","type":"User","site_admin":false},"body":"#### What's this PR do?\r\nTakes Typeform assignment submissions and integrates the Google Prediction API to grade short text answers.\r\n#### Where should the reviewer start?\r\n#### How should this be manually tested?\r\nIn the '/typeformAssignment/:assignment' route, comment out everything below ````const emailBody = submissionHTMLandGradeModifier.submissionHTML;```` in line 58 of ````index.js```` and add ````res.send(emailBody)````.\r\n\r\nhit the route in Postman. \r\n#### Any background context you want to provide?\r\n#### What are the relevant tickets?\r\nhttps://admin.crisistextline.org/jira/browse/INT-435\r\n#### Questions:\r\n","created_at":"2016-11-17T23:00:43Z","updated_at":"2016-11-18T21:25:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"435aec9f6d27eafda542a7135f7468af8badc87b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/251/commits","review_comments_url":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/251/comments","review_comment_url":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CrisisTextLine/Elmer/issues/251/comments","statuses_url":"https://api.github.com/repos/CrisisTextLine/Elmer/statuses/00139bb083ed761520421fa763309cd4ae14db31","head":{"label":"CrisisTextLine:sherlockLayers","ref":"sherlockLayers","sha":"00139bb083ed761520421fa763309cd4ae14db31","user":{"login":"CrisisTextLine","id":3536558,"avatar_url":"https://avatars.githubusercontent.com/u/3536558?v=3","gravatar_id":"","url":"https://api.github.com/users/CrisisTextLine","html_url":"https://github.com/CrisisTextLine","followers_url":"https://api.github.com/users/CrisisTextLine/followers","following_url":"https://api.github.com/users/CrisisTextLine/following{/other_user}","gists_url":"https://api.github.com/users/CrisisTextLine/gists{/gist_id}","starred_url":"https://api.github.com/users/CrisisTextLine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CrisisTextLine/subscriptions","organizations_url":"https://api.github.com/users/CrisisTextLine/orgs","repos_url":"https://api.github.com/users/CrisisTextLine/repos","events_url":"https://api.github.com/users/CrisisTextLine/events{/privacy}","received_events_url":"https://api.github.com/users/CrisisTextLine/received_events","type":"Organization","site_admin":false},"repo":{"id":47287892,"name":"Elmer","full_name":"CrisisTextLine/Elmer","owner":{"login":"CrisisTextLine","id":3536558,"avatar_url":"https://avatars.githubusercontent.com/u/3536558?v=3","gravatar_id":"","url":"https://api.github.com/users/CrisisTextLine","html_url":"https://github.com/CrisisTextLine","followers_url":"https://api.github.com/users/CrisisTextLine/followers","following_url":"https://api.github.com/users/CrisisTextLine/following{/other_user}","gists_url":"https://api.github.com/users/CrisisTextLine/gists{/gist_id}","starred_url":"https://api.github.com/users/CrisisTextLine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CrisisTextLine/subscriptions","organizations_url":"https://api.github.com/users/CrisisTextLine/orgs","repos_url":"https://api.github.com/users/CrisisTextLine/repos","events_url":"https://api.github.com/users/CrisisTextLine/events{/privacy}","received_events_url":"https://api.github.com/users/CrisisTextLine/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CrisisTextLine/Elmer","description":"Extends the functionality of WhenIWork for custom use cases","fork":false,"url":"https://api.github.com/repos/CrisisTextLine/Elmer","forks_url":"https://api.github.com/repos/CrisisTextLine/Elmer/forks","keys_url":"https://api.github.com/repos/CrisisTextLine/Elmer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CrisisTextLine/Elmer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CrisisTextLine/Elmer/teams","hooks_url":"https://api.github.com/repos/CrisisTextLine/Elmer/hooks","issue_events_url":"https://api.github.com/repos/CrisisTextLine/Elmer/issues/events{/number}","events_url":"https://api.github.com/repos/CrisisTextLine/Elmer/events","assignees_url":"https://api.github.com/repos/CrisisTextLine/Elmer/assignees{/user}","branches_url":"https://api.github.com/repos/CrisisTextLine/Elmer/branches{/branch}","tags_url":"https://api.github.com/repos/CrisisTextLine/Elmer/tags","blobs_url":"https://api.github.com/repos/CrisisTextLine/Elmer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CrisisTextLine/Elmer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CrisisTextLine/Elmer/git/refs{/sha}","trees_url":"https://api.github.com/repos/CrisisTextLine/Elmer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CrisisTextLine/Elmer/statuses/{sha}","languages_url":"https://api.github.com/repos/CrisisTextLine/Elmer/languages","stargazers_url":"https://api.github.com/repos/CrisisTextLine/Elmer/stargazers","contributors_url":"https://api.github.com/repos/CrisisTextLine/Elmer/contributors","subscribers_url":"https://api.github.com/repos/CrisisTextLine/Elmer/subscribers","subscription_url":"https://api.github.com/repos/CrisisTextLine/Elmer/subscription","commits_url":"https://api.github.com/repos/CrisisTextLine/Elmer/commits{/sha}","git_commits_url":"https://api.github.com/repos/CrisisTextLine/Elmer/git/commits{/sha}","comments_url":"https://api.github.com/repos/CrisisTextLine/Elmer/comments{/number}","issue_comment_url":"https://api.github.com/repos/CrisisTextLine/Elmer/issues/comments{/number}","contents_url":"https://api.github.com/repos/CrisisTextLine/Elmer/contents/{+path}","compare_url":"https://api.github.com/repos/CrisisTextLine/Elmer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CrisisTextLine/Elmer/merges","archive_url":"https://api.github.com/repos/CrisisTextLine/Elmer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CrisisTextLine/Elmer/downloads","issues_url":"https://api.github.com/repos/CrisisTextLine/Elmer/issues{/number}","pulls_url":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls{/number}","milestones_url":"https://api.github.com/repos/CrisisTextLine/Elmer/milestones{/number}","notifications_url":"https://api.github.com/repos/CrisisTextLine/Elmer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CrisisTextLine/Elmer/labels{/name}","releases_url":"https://api.github.com/repos/CrisisTextLine/Elmer/releases{/id}","deployments_url":"https://api.github.com/repos/CrisisTextLine/Elmer/deployments","created_at":"2015-12-02T20:51:51Z","updated_at":"2016-10-24T17:48:01Z","pushed_at":"2016-11-18T16:40:17Z","git_url":"git://github.com/CrisisTextLine/Elmer.git","ssh_url":"git@github.com:CrisisTextLine/Elmer.git","clone_url":"https://github.com/CrisisTextLine/Elmer.git","svn_url":"https://github.com/CrisisTextLine/Elmer","homepage":"","size":899,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":5,"default_branch":"master"}},"base":{"label":"CrisisTextLine:master","ref":"master","sha":"86d6a77f77bdd9d2afbaeae5c1b346b2f8a59f8e","user":{"login":"CrisisTextLine","id":3536558,"avatar_url":"https://avatars.githubusercontent.com/u/3536558?v=3","gravatar_id":"","url":"https://api.github.com/users/CrisisTextLine","html_url":"https://github.com/CrisisTextLine","followers_url":"https://api.github.com/users/CrisisTextLine/followers","following_url":"https://api.github.com/users/CrisisTextLine/following{/other_user}","gists_url":"https://api.github.com/users/CrisisTextLine/gists{/gist_id}","starred_url":"https://api.github.com/users/CrisisTextLine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CrisisTextLine/subscriptions","organizations_url":"https://api.github.com/users/CrisisTextLine/orgs","repos_url":"https://api.github.com/users/CrisisTextLine/repos","events_url":"https://api.github.com/users/CrisisTextLine/events{/privacy}","received_events_url":"https://api.github.com/users/CrisisTextLine/received_events","type":"Organization","site_admin":false},"repo":{"id":47287892,"name":"Elmer","full_name":"CrisisTextLine/Elmer","owner":{"login":"CrisisTextLine","id":3536558,"avatar_url":"https://avatars.githubusercontent.com/u/3536558?v=3","gravatar_id":"","url":"https://api.github.com/users/CrisisTextLine","html_url":"https://github.com/CrisisTextLine","followers_url":"https://api.github.com/users/CrisisTextLine/followers","following_url":"https://api.github.com/users/CrisisTextLine/following{/other_user}","gists_url":"https://api.github.com/users/CrisisTextLine/gists{/gist_id}","starred_url":"https://api.github.com/users/CrisisTextLine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CrisisTextLine/subscriptions","organizations_url":"https://api.github.com/users/CrisisTextLine/orgs","repos_url":"https://api.github.com/users/CrisisTextLine/repos","events_url":"https://api.github.com/users/CrisisTextLine/events{/privacy}","received_events_url":"https://api.github.com/users/CrisisTextLine/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CrisisTextLine/Elmer","description":"Extends the functionality of WhenIWork for custom use cases","fork":false,"url":"https://api.github.com/repos/CrisisTextLine/Elmer","forks_url":"https://api.github.com/repos/CrisisTextLine/Elmer/forks","keys_url":"https://api.github.com/repos/CrisisTextLine/Elmer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CrisisTextLine/Elmer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CrisisTextLine/Elmer/teams","hooks_url":"https://api.github.com/repos/CrisisTextLine/Elmer/hooks","issue_events_url":"https://api.github.com/repos/CrisisTextLine/Elmer/issues/events{/number}","events_url":"https://api.github.com/repos/CrisisTextLine/Elmer/events","assignees_url":"https://api.github.com/repos/CrisisTextLine/Elmer/assignees{/user}","branches_url":"https://api.github.com/repos/CrisisTextLine/Elmer/branches{/branch}","tags_url":"https://api.github.com/repos/CrisisTextLine/Elmer/tags","blobs_url":"https://api.github.com/repos/CrisisTextLine/Elmer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CrisisTextLine/Elmer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CrisisTextLine/Elmer/git/refs{/sha}","trees_url":"https://api.github.com/repos/CrisisTextLine/Elmer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CrisisTextLine/Elmer/statuses/{sha}","languages_url":"https://api.github.com/repos/CrisisTextLine/Elmer/languages","stargazers_url":"https://api.github.com/repos/CrisisTextLine/Elmer/stargazers","contributors_url":"https://api.github.com/repos/CrisisTextLine/Elmer/contributors","subscribers_url":"https://api.github.com/repos/CrisisTextLine/Elmer/subscribers","subscription_url":"https://api.github.com/repos/CrisisTextLine/Elmer/subscription","commits_url":"https://api.github.com/repos/CrisisTextLine/Elmer/commits{/sha}","git_commits_url":"https://api.github.com/repos/CrisisTextLine/Elmer/git/commits{/sha}","comments_url":"https://api.github.com/repos/CrisisTextLine/Elmer/comments{/number}","issue_comment_url":"https://api.github.com/repos/CrisisTextLine/Elmer/issues/comments{/number}","contents_url":"https://api.github.com/repos/CrisisTextLine/Elmer/contents/{+path}","compare_url":"https://api.github.com/repos/CrisisTextLine/Elmer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CrisisTextLine/Elmer/merges","archive_url":"https://api.github.com/repos/CrisisTextLine/Elmer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CrisisTextLine/Elmer/downloads","issues_url":"https://api.github.com/repos/CrisisTextLine/Elmer/issues{/number}","pulls_url":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls{/number}","milestones_url":"https://api.github.com/repos/CrisisTextLine/Elmer/milestones{/number}","notifications_url":"https://api.github.com/repos/CrisisTextLine/Elmer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CrisisTextLine/Elmer/labels{/name}","releases_url":"https://api.github.com/repos/CrisisTextLine/Elmer/releases{/id}","deployments_url":"https://api.github.com/repos/CrisisTextLine/Elmer/deployments","created_at":"2015-12-02T20:51:51Z","updated_at":"2016-10-24T17:48:01Z","pushed_at":"2016-11-18T16:40:17Z","git_url":"git://github.com/CrisisTextLine/Elmer.git","ssh_url":"git@github.com:CrisisTextLine/Elmer.git","clone_url":"https://github.com/CrisisTextLine/Elmer.git","svn_url":"https://github.com/CrisisTextLine/Elmer","homepage":"","size":899,"stargazers_count":5,"watchers_count":5,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":4,"forks":1,"open_issues":4,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/251"},"html":{"href":"https://github.com/CrisisTextLine/Elmer/pull/251"},"issue":{"href":"https://api.github.com/repos/CrisisTextLine/Elmer/issues/251"},"comments":{"href":"https://api.github.com/repos/CrisisTextLine/Elmer/issues/251/comments"},"review_comments":{"href":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/251/comments"},"review_comment":{"href":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CrisisTextLine/Elmer/pulls/251/commits"},"statuses":{"href":"https://api.github.com/repos/CrisisTextLine/Elmer/statuses/00139bb083ed761520421fa763309cd4ae14db31"}}}}
{"actor":{"display_login":"apackin"}}