{"action":"created","comment":{"url":"https://api.github.com/repos/open-craft/xblock-mentoring/pulls/comments/27218762","id":27218762,"diff_hunk":"@@ -0,0 +1,197 @@\n+# -*- coding: utf-8 -*-\n+#\n+# Copyright (c) 2014-2015 Harvard, edX & OpenCraft\n+#\n+# This software's license gives you freedom; you can copy, convey,\n+# propagate, redistribute and/or modify this program under the terms of\n+# the GNU Affero General Public License (AGPL) as published by the Free\n+# Software Foundation (FSF), either version 3 of the License, or (at your\n+# option) any later version of the AGPL published by the FSF.\n+#\n+# This program is distributed in the hope that it will be useful, but\n+# WITHOUT ANY WARRANTY; without even the implied warranty of\n+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero\n+# General Public License for more details.\n+#\n+# You should have received a copy of the GNU Affero General Public License\n+# along with this program in a file in the toplevel directory called\n+# \"AGPLv3\".  If not, see <http://www.gnu.org/licenses/>.\n+#\n+\n+# Imports ###########################################################\n+\n+import logging\n+\n+from xblock.fields import Scope, String, List\n+from xblock.fragment import Fragment\n+from xblock.validation import ValidationMessage\n+from xblockutils.resources import ResourceLoader\n+\n+from .questionnaire import QuestionnaireAbstractBlock\n+\n+\n+# Globals ###########################################################\n+\n+log = logging.getLogger(__name__)\n+loader = ResourceLoader(__name__)\n+\n+\n+# Make '_' a no-op so we can scrape strings\n+def _(text):\n+    return text\n+\n+# Classes ###########################################################\n+\n+\n+class MCQBlock(QuestionnaireAbstractBlock):\n+    \"\"\"\n+    An XBlock used to ask multiple-choice questions\n+    \"\"\"\n+    student_choice = String(\n+        # {Last input submitted by the student\n+        default=\"\",\n+        scope=Scope.user_state,\n+    )\n+\n+    correct_choices = List(\n+        display_name=_(\"Correct Choice[s]\"),\n+        help=_(\"Specify the value[s] that students may select for this question to be considered correct.\"),\n+        scope=Scope.content,\n+        list_values_provider=QuestionnaireAbstractBlock.choice_values_provider,\n+        list_style='set',  # Underered, unique items. Affects the UI editor.\n+    )\n+    editable_fields = QuestionnaireAbstractBlock.editable_fields + ('correct_choices', )\n+\n+    def describe_choice_correctness(self, choice_value):\n+        if choice_value in self.correct_choices:\n+            if len(self.correct_choices) == 1:\n+                # Translators: This is an adjective, describing a choice as correct\n+                return self._(u\"Correct\")\n+            return self._(u\"Acceptable\")\n+        else:\n+            if len(self.correct_choices) == 1:\n+                return self._(u\"Wrong\")\n+            return self._(u\"Not Acceptable\")\n+\n+    def submit(self, submission):\n+        log.debug(u'Received MCQ submission: \"%s\"', submission)\n+\n+        correct = submission in self.correct_choices\n+        tips_html = []\n+        for tip in self.get_tips():\n+            if submission in tip.values:\n+                tips_html.append(tip.render('mentoring_view').content)\n+\n+        if tips_html:\n+            formatted_tips = ResourceLoader(__name__).render_template('templates/html/tip_choice_group.html', {","path":"mentoring/mcq.py","position":86,"original_position":86,"commit_id":"670486507a484ccfd37e78ad14e76d3b71394eea","original_commit_id":"670486507a484ccfd37e78ad14e76d3b71394eea","user":{"login":"cpennington","id":30236,"avatar_url":"https://avatars.githubusercontent.com/u/30236?v=3","gravatar_id":"","url":"https://api.github.com/users/cpennington","html_url":"https://github.com/cpennington","followers_url":"https://api.github.com/users/cpennington/followers","following_url":"https://api.github.com/users/cpennington/following{/other_user}","gists_url":"https://api.github.com/users/cpennington/gists{/gist_id}","starred_url":"https://api.github.com/users/cpennington/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpennington/subscriptions","organizations_url":"https://api.github.com/users/cpennington/orgs","repos_url":"https://api.github.com/users/cpennington/repos","events_url":"https://api.github.com/users/cpennington/events{/privacy}","received_events_url":"https://api.github.com/users/cpennington/received_events","type":"User","site_admin":false},"body":"Is `ResourceLoader` expensive to instantiate?","created_at":"2015-03-26T14:46:30Z","updated_at":"2015-03-26T14:46:30Z","html_url":"https://github.com/open-craft/xblock-mentoring/pull/4#discussion_r27218762","pull_request_url":"https://api.github.com/repos/open-craft/xblock-mentoring/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/open-craft/xblock-mentoring/pulls/comments/27218762"},"html":{"href":"https://github.com/open-craft/xblock-mentoring/pull/4#discussion_r27218762"},"pull_request":{"href":"https://api.github.com/repos/open-craft/xblock-mentoring/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/open-craft/xblock-mentoring/pulls/4","id":28813760,"html_url":"https://github.com/open-craft/xblock-mentoring/pull/4","diff_url":"https://github.com/open-craft/xblock-mentoring/pull/4.diff","patch_url":"https://github.com/open-craft/xblock-mentoring/pull/4.patch","issue_url":"https://api.github.com/repos/open-craft/xblock-mentoring/issues/4","number":4,"state":"open","locked":false,"title":"Unification of forks & conversion to real children","user":{"login":"antoviaque","id":514483,"avatar_url":"https://avatars.githubusercontent.com/u/514483?v=3","gravatar_id":"","url":"https://api.github.com/users/antoviaque","html_url":"https://github.com/antoviaque","followers_url":"https://api.github.com/users/antoviaque/followers","following_url":"https://api.github.com/users/antoviaque/following{/other_user}","gists_url":"https://api.github.com/users/antoviaque/gists{/gist_id}","starred_url":"https://api.github.com/users/antoviaque/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/antoviaque/subscriptions","organizations_url":"https://api.github.com/users/antoviaque/orgs","repos_url":"https://api.github.com/users/antoviaque/repos","events_url":"https://api.github.com/users/antoviaque/events{/privacy}","received_events_url":"https://api.github.com/users/antoviaque/received_events","type":"User","site_admin":false},"body":"Note that this PR isn't meant to be merged, it just serves to show the difference with what is on edx.org. Note that the two have slightly diverged, due to backports of features. We would likely switch the requirements used on edx.org to use the current repository's master rather than merging.\r\n\r\nSee https://openedx.atlassian.net/browse/OSPR-419\r\n\r\nSandbox: LMS: http://sandbox.opencraft.com/ - CMS: http://sandbox.opencraft.com:18010/","created_at":"2015-02-06T14:53:17Z","updated_at":"2015-03-26T14:46:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/open-craft/xblock-mentoring/pulls/4/commits","review_comments_url":"https://api.github.com/repos/open-craft/xblock-mentoring/pulls/4/comments","review_comment_url":"https://api.github.com/repos/open-craft/xblock-mentoring/pulls/comments{/number}","comments_url":"https://api.github.com/repos/open-craft/xblock-mentoring/issues/4/comments","statuses_url":"https://api.github.com/repos/open-craft/xblock-mentoring/statuses/670486507a484ccfd37e78ad14e76d3b71394eea","head":{"label":"open-craft:master","ref":"master","sha":"670486507a484ccfd37e78ad14e76d3b71394eea","user":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars.githubusercontent.com/u/7414786?v=3","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"repo":{"id":29684458,"name":"xblock-mentoring","full_name":"open-craft/xblock-mentoring","owner":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars.githubusercontent.com/u/7414786?v=3","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/open-craft/xblock-mentoring","description":"Mentoring XBlock for edX","fork":true,"url":"https://api.github.com/repos/open-craft/xblock-mentoring","forks_url":"https://api.github.com/repos/open-craft/xblock-mentoring/forks","keys_url":"https://api.github.com/repos/open-craft/xblock-mentoring/keys{/key_id}","collaborators_url":"https://api.github.com/repos/open-craft/xblock-mentoring/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/open-craft/xblock-mentoring/teams","hooks_url":"https://api.github.com/repos/open-craft/xblock-mentoring/hooks","issue_events_url":"https://api.github.com/repos/open-craft/xblock-mentoring/issues/events{/number}","events_url":"https://api.github.com/repos/open-craft/xblock-mentoring/events","assignees_url":"https://api.github.com/repos/open-craft/xblock-mentoring/assignees{/user}","branches_url":"https://api.github.com/repos/open-craft/xblock-mentoring/branches{/branch}","tags_url":"https://api.github.com/repos/open-craft/xblock-mentoring/tags","blobs_url":"https://api.github.com/repos/open-craft/xblock-mentoring/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/open-craft/xblock-mentoring/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/open-craft/xblock-mentoring/git/refs{/sha}","trees_url":"https://api.github.com/repos/open-craft/xblock-mentoring/git/trees{/sha}","statuses_url":"https://api.github.com/repos/open-craft/xblock-mentoring/statuses/{sha}","languages_url":"https://api.github.com/repos/open-craft/xblock-mentoring/languages","stargazers_url":"https://api.github.com/repos/open-craft/xblock-mentoring/stargazers","contributors_url":"https://api.github.com/repos/open-craft/xblock-mentoring/contributors","subscribers_url":"https://api.github.com/repos/open-craft/xblock-mentoring/subscribers","subscription_url":"https://api.github.com/repos/open-craft/xblock-mentoring/subscription","commits_url":"https://api.github.com/repos/open-craft/xblock-mentoring/commits{/sha}","git_commits_url":"https://api.github.com/repos/open-craft/xblock-mentoring/git/commits{/sha}","comments_url":"https://api.github.com/repos/open-craft/xblock-mentoring/comments{/number}","issue_comment_url":"https://api.github.com/repos/open-craft/xblock-mentoring/issues/comments{/number}","contents_url":"https://api.github.com/repos/open-craft/xblock-mentoring/contents/{+path}","compare_url":"https://api.github.com/repos/open-craft/xblock-mentoring/compare/{base}...{head}","merges_url":"https://api.github.com/repos/open-craft/xblock-mentoring/merges","archive_url":"https://api.github.com/repos/open-craft/xblock-mentoring/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/open-craft/xblock-mentoring/downloads","issues_url":"https://api.github.com/repos/open-craft/xblock-mentoring/issues{/number}","pulls_url":"https://api.github.com/repos/open-craft/xblock-mentoring/pulls{/number}","milestones_url":"https://api.github.com/repos/open-craft/xblock-mentoring/milestones{/number}","notifications_url":"https://api.github.com/repos/open-craft/xblock-mentoring/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/open-craft/xblock-mentoring/labels{/name}","releases_url":"https://api.github.com/repos/open-craft/xblock-mentoring/releases{/id}","created_at":"2015-01-22T15:11:16Z","updated_at":"2015-03-24T20:32:32Z","pushed_at":"2015-03-26T05:33:15Z","git_url":"git://github.com/open-craft/xblock-mentoring.git","ssh_url":"git@github.com:open-craft/xblock-mentoring.git","clone_url":"https://github.com/open-craft/xblock-mentoring.git","svn_url":"https://github.com/open-craft/xblock-mentoring","homepage":null,"size":2702,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"open-craft:gsehub","ref":"gsehub","sha":"fd472edde6ea1455333a955d7b1942378ae68bd8","user":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars.githubusercontent.com/u/7414786?v=3","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"repo":{"id":29684458,"name":"xblock-mentoring","full_name":"open-craft/xblock-mentoring","owner":{"login":"open-craft","id":7414786,"avatar_url":"https://avatars.githubusercontent.com/u/7414786?v=3","gravatar_id":"","url":"https://api.github.com/users/open-craft","html_url":"https://github.com/open-craft","followers_url":"https://api.github.com/users/open-craft/followers","following_url":"https://api.github.com/users/open-craft/following{/other_user}","gists_url":"https://api.github.com/users/open-craft/gists{/gist_id}","starred_url":"https://api.github.com/users/open-craft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/open-craft/subscriptions","organizations_url":"https://api.github.com/users/open-craft/orgs","repos_url":"https://api.github.com/users/open-craft/repos","events_url":"https://api.github.com/users/open-craft/events{/privacy}","received_events_url":"https://api.github.com/users/open-craft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/open-craft/xblock-mentoring","description":"Mentoring XBlock for edX","fork":true,"url":"https://api.github.com/repos/open-craft/xblock-mentoring","forks_url":"https://api.github.com/repos/open-craft/xblock-mentoring/forks","keys_url":"https://api.github.com/repos/open-craft/xblock-mentoring/keys{/key_id}","collaborators_url":"https://api.github.com/repos/open-craft/xblock-mentoring/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/open-craft/xblock-mentoring/teams","hooks_url":"https://api.github.com/repos/open-craft/xblock-mentoring/hooks","issue_events_url":"https://api.github.com/repos/open-craft/xblock-mentoring/issues/events{/number}","events_url":"https://api.github.com/repos/open-craft/xblock-mentoring/events","assignees_url":"https://api.github.com/repos/open-craft/xblock-mentoring/assignees{/user}","branches_url":"https://api.github.com/repos/open-craft/xblock-mentoring/branches{/branch}","tags_url":"https://api.github.com/repos/open-craft/xblock-mentoring/tags","blobs_url":"https://api.github.com/repos/open-craft/xblock-mentoring/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/open-craft/xblock-mentoring/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/open-craft/xblock-mentoring/git/refs{/sha}","trees_url":"https://api.github.com/repos/open-craft/xblock-mentoring/git/trees{/sha}","statuses_url":"https://api.github.com/repos/open-craft/xblock-mentoring/statuses/{sha}","languages_url":"https://api.github.com/repos/open-craft/xblock-mentoring/languages","stargazers_url":"https://api.github.com/repos/open-craft/xblock-mentoring/stargazers","contributors_url":"https://api.github.com/repos/open-craft/xblock-mentoring/contributors","subscribers_url":"https://api.github.com/repos/open-craft/xblock-mentoring/subscribers","subscription_url":"https://api.github.com/repos/open-craft/xblock-mentoring/subscription","commits_url":"https://api.github.com/repos/open-craft/xblock-mentoring/commits{/sha}","git_commits_url":"https://api.github.com/repos/open-craft/xblock-mentoring/git/commits{/sha}","comments_url":"https://api.github.com/repos/open-craft/xblock-mentoring/comments{/number}","issue_comment_url":"https://api.github.com/repos/open-craft/xblock-mentoring/issues/comments{/number}","contents_url":"https://api.github.com/repos/open-craft/xblock-mentoring/contents/{+path}","compare_url":"https://api.github.com/repos/open-craft/xblock-mentoring/compare/{base}...{head}","merges_url":"https://api.github.com/repos/open-craft/xblock-mentoring/merges","archive_url":"https://api.github.com/repos/open-craft/xblock-mentoring/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/open-craft/xblock-mentoring/downloads","issues_url":"https://api.github.com/repos/open-craft/xblock-mentoring/issues{/number}","pulls_url":"https://api.github.com/repos/open-craft/xblock-mentoring/pulls{/number}","milestones_url":"https://api.github.com/repos/open-craft/xblock-mentoring/milestones{/number}","notifications_url":"https://api.github.com/repos/open-craft/xblock-mentoring/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/open-craft/xblock-mentoring/labels{/name}","releases_url":"https://api.github.com/repos/open-craft/xblock-mentoring/releases{/id}","created_at":"2015-01-22T15:11:16Z","updated_at":"2015-03-24T20:32:32Z","pushed_at":"2015-03-26T05:33:15Z","git_url":"git://github.com/open-craft/xblock-mentoring.git","ssh_url":"git@github.com:open-craft/xblock-mentoring.git","clone_url":"https://github.com/open-craft/xblock-mentoring.git","svn_url":"https://github.com/open-craft/xblock-mentoring","homepage":null,"size":2702,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/open-craft/xblock-mentoring/pulls/4"},"html":{"href":"https://github.com/open-craft/xblock-mentoring/pull/4"},"issue":{"href":"https://api.github.com/repos/open-craft/xblock-mentoring/issues/4"},"comments":{"href":"https://api.github.com/repos/open-craft/xblock-mentoring/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/open-craft/xblock-mentoring/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/open-craft/xblock-mentoring/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/open-craft/xblock-mentoring/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/open-craft/xblock-mentoring/statuses/670486507a484ccfd37e78ad14e76d3b71394eea"}}}}