{"action":"created","comment":{"url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/pulls/comments/25851575","id":25851575,"diff_hunk":"@@ -0,0 +1,261 @@\n+/*\n+ * This program is free software; you can redistribute it and/or\n+ * modify it under the terms of the GNU General Public License\n+ * as published by the Free Software Foundation; under version 2\n+ * of the License (non-upgradable).\n+ *\n+ * This program is distributed in the hope that it will be useful,\n+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\n+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+ * GNU General Public License for more details.\n+ *\n+ * You should have received a copy of the GNU General Public License\n+ * along with this program; if not, write to the Free Software\n+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\n+ *\n+ * Copyright (c) 2015 (original work) Open Assessment Technlogies SA (under the project TAO-PRODUCT);\n+ *\n+ */\n+\n+/**\n+ * The mathOperator processor.\n+ * @see http://www.imsglobal.org/question/qtiv2p1/imsqti_infov2p1.html#element106451\n+ *\n+ * @author Bertrand Chevrier <bertrand@taotesting.com>\n+ */\n+define([\n+    'lodash'\n+], function(_){\n+    'use strict';\n+\n+    /**\n+     * Process operands and returns the mathOperator result.\n+     * @type {OperandProcessor}\n+     * @exports taoQtiItem/scoring/processor/expressions/operators/mathOperator\n+     */\n+    var mathOperatorProcessor = {\n+\n+        accuracy : 0.000000000000001,\n+\n+        constraints : {\n+            minOperand : 1,\n+            maxOperand : -1,\n+            cardinality : ['single'],\n+            baseType : ['float','integer']\n+        },\n+\n+        operands   : [],\n+\n+        /**\n+         * Process the mathOperator of the operands.\n+         * @returns {?ProcessingValue} the and or null\n+         */\n+        process : function(){\n+\n+            var result = {\n+                cardinality : 'single',\n+                baseType : 'float'\n+            };\n+\n+            //if at least one operand is null, then break and return null\n+            if(_.some(this.operands, _.isNull) === true){\n+                return null;\n+            }\n+\n+            var name = this.expression.attributes.name;\n+\n+            if (!_.contains(Object.keys(functions), name)) {\n+                return null;\n+            }\n+\n+            var operands = this.preProcessor.parseOperands(this.operands).value();\n+\n+            if (_.some(operands, _.isNaN)) {\n+                return null;\n+            }\n+\n+            if (_.isFunction(functions[name])) {\n+                result.value = functions[name](operands[0]);\n+            } else {\n+                result.value = functions[name].func(operands);\n+            }\n+\n+            if (_.isNull(result.value) || _.isNaN(result.value)) {\n+                return null;\n+            }\n+            return result;\n+        }\n+    };\n+\n+    var functions = {\n+        sin: Math.sin,\n+        cos: Math.cos,\n+        tan: Math.tan,\n+        sec: reciprocalFactory(Math.cos),\n+        csc: reciprocalFactory(Math.sin),\n+        cot: reciprocalFactory(Math.tan),\n+        asin: Math.asin,\n+        acos: Math.acos,\n+        atan: Math.atan,\n+        atan2: {","path":"views/js/scoring/processor/expressions/operators/mathOperator.js","position":100,"original_position":100,"commit_id":"10be88aa694ee85c24eea89c61b34b49fc95975d","original_commit_id":"10be88aa694ee85c24eea89c61b34b49fc95975d","user":{"login":"krampstudio","id":468620,"avatar_url":"https://avatars.githubusercontent.com/u/468620?v=3","gravatar_id":"","url":"https://api.github.com/users/krampstudio","html_url":"https://github.com/krampstudio","followers_url":"https://api.github.com/users/krampstudio/followers","following_url":"https://api.github.com/users/krampstudio/following{/other_user}","gists_url":"https://api.github.com/users/krampstudio/gists{/gist_id}","starred_url":"https://api.github.com/users/krampstudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krampstudio/subscriptions","organizations_url":"https://api.github.com/users/krampstudio/orgs","repos_url":"https://api.github.com/users/krampstudio/repos","events_url":"https://api.github.com/users/krampstudio/events{/privacy}","received_events_url":"https://api.github.com/users/krampstudio/received_events","type":"User","site_admin":false},"body":"Why do you use the property `func` inside ?","created_at":"2015-03-05T09:53:43Z","updated_at":"2015-03-05T09:53:43Z","html_url":"https://github.com/oat-sa/extension-tao-itemqti/pull/129#discussion_r25851575","pull_request_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/pulls/129","_links":{"self":{"href":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/pulls/comments/25851575"},"html":{"href":"https://github.com/oat-sa/extension-tao-itemqti/pull/129#discussion_r25851575"},"pull_request":{"href":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/pulls/129"}}},"pull_request":{"url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/pulls/129","id":30081990,"html_url":"https://github.com/oat-sa/extension-tao-itemqti/pull/129","diff_url":"https://github.com/oat-sa/extension-tao-itemqti/pull/129.diff","patch_url":"https://github.com/oat-sa/extension-tao-itemqti/pull/129.patch","issue_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/issues/129","number":129,"state":"open","locked":false,"title":"operator-mathOperator","user":{"login":"boajer","id":4569734,"avatar_url":"https://avatars.githubusercontent.com/u/4569734?v=3","gravatar_id":"","url":"https://api.github.com/users/boajer","html_url":"https://github.com/boajer","followers_url":"https://api.github.com/users/boajer/followers","following_url":"https://api.github.com/users/boajer/following{/other_user}","gists_url":"https://api.github.com/users/boajer/gists{/gist_id}","starred_url":"https://api.github.com/users/boajer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boajer/subscriptions","organizations_url":"https://api.github.com/users/boajer/orgs","repos_url":"https://api.github.com/users/boajer/repos","events_url":"https://api.github.com/users/boajer/events{/privacy}","received_events_url":"https://api.github.com/users/boajer/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-26T14:32:25Z","updated_at":"2015-03-05T09:53:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d7f80797c39e79b9cae4dab31b8b36294e514222","assignee":{"login":"krampstudio","id":468620,"avatar_url":"https://avatars.githubusercontent.com/u/468620?v=3","gravatar_id":"","url":"https://api.github.com/users/krampstudio","html_url":"https://github.com/krampstudio","followers_url":"https://api.github.com/users/krampstudio/followers","following_url":"https://api.github.com/users/krampstudio/following{/other_user}","gists_url":"https://api.github.com/users/krampstudio/gists{/gist_id}","starred_url":"https://api.github.com/users/krampstudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krampstudio/subscriptions","organizations_url":"https://api.github.com/users/krampstudio/orgs","repos_url":"https://api.github.com/users/krampstudio/repos","events_url":"https://api.github.com/users/krampstudio/events{/privacy}","received_events_url":"https://api.github.com/users/krampstudio/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/pulls/129/commits","review_comments_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/pulls/129/comments","review_comment_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/pulls/comments{/number}","comments_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/issues/129/comments","statuses_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/statuses/10be88aa694ee85c24eea89c61b34b49fc95975d","head":{"label":"oat-sa:operator-mathOperator","ref":"operator-mathOperator","sha":"10be88aa694ee85c24eea89c61b34b49fc95975d","user":{"login":"oat-sa","id":7581081,"avatar_url":"https://avatars.githubusercontent.com/u/7581081?v=3","gravatar_id":"","url":"https://api.github.com/users/oat-sa","html_url":"https://github.com/oat-sa","followers_url":"https://api.github.com/users/oat-sa/followers","following_url":"https://api.github.com/users/oat-sa/following{/other_user}","gists_url":"https://api.github.com/users/oat-sa/gists{/gist_id}","starred_url":"https://api.github.com/users/oat-sa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oat-sa/subscriptions","organizations_url":"https://api.github.com/users/oat-sa/orgs","repos_url":"https://api.github.com/users/oat-sa/repos","events_url":"https://api.github.com/users/oat-sa/events{/privacy}","received_events_url":"https://api.github.com/users/oat-sa/received_events","type":"Organization","site_admin":false},"repo":{"id":22111399,"name":"extension-tao-itemqti","full_name":"oat-sa/extension-tao-itemqti","owner":{"login":"oat-sa","id":7581081,"avatar_url":"https://avatars.githubusercontent.com/u/7581081?v=3","gravatar_id":"","url":"https://api.github.com/users/oat-sa","html_url":"https://github.com/oat-sa","followers_url":"https://api.github.com/users/oat-sa/followers","following_url":"https://api.github.com/users/oat-sa/following{/other_user}","gists_url":"https://api.github.com/users/oat-sa/gists{/gist_id}","starred_url":"https://api.github.com/users/oat-sa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oat-sa/subscriptions","organizations_url":"https://api.github.com/users/oat-sa/orgs","repos_url":"https://api.github.com/users/oat-sa/repos","events_url":"https://api.github.com/users/oat-sa/events{/privacy}","received_events_url":"https://api.github.com/users/oat-sa/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/oat-sa/extension-tao-itemqti","description":"extension to create QTI items for TAO","fork":false,"url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti","forks_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/forks","keys_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/teams","hooks_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/hooks","issue_events_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/issues/events{/number}","events_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/events","assignees_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/assignees{/user}","branches_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/branches{/branch}","tags_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/tags","blobs_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/git/refs{/sha}","trees_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/statuses/{sha}","languages_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/languages","stargazers_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/stargazers","contributors_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/contributors","subscribers_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/subscribers","subscription_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/subscription","commits_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/commits{/sha}","git_commits_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/git/commits{/sha}","comments_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/comments{/number}","issue_comment_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/issues/comments{/number}","contents_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/contents/{+path}","compare_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/merges","archive_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/downloads","issues_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/issues{/number}","pulls_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/pulls{/number}","milestones_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/milestones{/number}","notifications_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/labels{/name}","releases_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/releases{/id}","created_at":"2014-07-22T16:28:02Z","updated_at":"2015-02-27T15:23:28Z","pushed_at":"2015-03-05T09:49:12Z","git_url":"git://github.com/oat-sa/extension-tao-itemqti.git","ssh_url":"git@github.com:oat-sa/extension-tao-itemqti.git","clone_url":"https://github.com/oat-sa/extension-tao-itemqti.git","svn_url":"https://github.com/oat-sa/extension-tao-itemqti","homepage":"","size":17746,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":7,"forks":0,"open_issues":7,"watchers":3,"default_branch":"master"}},"base":{"label":"oat-sa:newrunner","ref":"newrunner","sha":"73b0a6180855fc8c7e5386a686565cc99c6e5bb2","user":{"login":"oat-sa","id":7581081,"avatar_url":"https://avatars.githubusercontent.com/u/7581081?v=3","gravatar_id":"","url":"https://api.github.com/users/oat-sa","html_url":"https://github.com/oat-sa","followers_url":"https://api.github.com/users/oat-sa/followers","following_url":"https://api.github.com/users/oat-sa/following{/other_user}","gists_url":"https://api.github.com/users/oat-sa/gists{/gist_id}","starred_url":"https://api.github.com/users/oat-sa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oat-sa/subscriptions","organizations_url":"https://api.github.com/users/oat-sa/orgs","repos_url":"https://api.github.com/users/oat-sa/repos","events_url":"https://api.github.com/users/oat-sa/events{/privacy}","received_events_url":"https://api.github.com/users/oat-sa/received_events","type":"Organization","site_admin":false},"repo":{"id":22111399,"name":"extension-tao-itemqti","full_name":"oat-sa/extension-tao-itemqti","owner":{"login":"oat-sa","id":7581081,"avatar_url":"https://avatars.githubusercontent.com/u/7581081?v=3","gravatar_id":"","url":"https://api.github.com/users/oat-sa","html_url":"https://github.com/oat-sa","followers_url":"https://api.github.com/users/oat-sa/followers","following_url":"https://api.github.com/users/oat-sa/following{/other_user}","gists_url":"https://api.github.com/users/oat-sa/gists{/gist_id}","starred_url":"https://api.github.com/users/oat-sa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oat-sa/subscriptions","organizations_url":"https://api.github.com/users/oat-sa/orgs","repos_url":"https://api.github.com/users/oat-sa/repos","events_url":"https://api.github.com/users/oat-sa/events{/privacy}","received_events_url":"https://api.github.com/users/oat-sa/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/oat-sa/extension-tao-itemqti","description":"extension to create QTI items for TAO","fork":false,"url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti","forks_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/forks","keys_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/teams","hooks_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/hooks","issue_events_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/issues/events{/number}","events_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/events","assignees_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/assignees{/user}","branches_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/branches{/branch}","tags_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/tags","blobs_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/git/refs{/sha}","trees_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/statuses/{sha}","languages_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/languages","stargazers_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/stargazers","contributors_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/contributors","subscribers_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/subscribers","subscription_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/subscription","commits_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/commits{/sha}","git_commits_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/git/commits{/sha}","comments_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/comments{/number}","issue_comment_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/issues/comments{/number}","contents_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/contents/{+path}","compare_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/merges","archive_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/downloads","issues_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/issues{/number}","pulls_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/pulls{/number}","milestones_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/milestones{/number}","notifications_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/labels{/name}","releases_url":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/releases{/id}","created_at":"2014-07-22T16:28:02Z","updated_at":"2015-02-27T15:23:28Z","pushed_at":"2015-03-05T09:49:12Z","git_url":"git://github.com/oat-sa/extension-tao-itemqti.git","ssh_url":"git@github.com:oat-sa/extension-tao-itemqti.git","clone_url":"https://github.com/oat-sa/extension-tao-itemqti.git","svn_url":"https://github.com/oat-sa/extension-tao-itemqti","homepage":"","size":17746,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":7,"forks":0,"open_issues":7,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/pulls/129"},"html":{"href":"https://github.com/oat-sa/extension-tao-itemqti/pull/129"},"issue":{"href":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/issues/129"},"comments":{"href":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/issues/129/comments"},"review_comments":{"href":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/pulls/129/comments"},"review_comment":{"href":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/pulls/129/commits"},"statuses":{"href":"https://api.github.com/repos/oat-sa/extension-tao-itemqti/statuses/10be88aa694ee85c24eea89c61b34b49fc95975d"}}}}