{"action":"created","issue":{"url":"https://api.github.com/repos/PHILIPPFROMME/bpmn-questionnaire/issues/3","labels_url":"https://api.github.com/repos/PHILIPPFROMME/bpmn-questionnaire/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/PHILIPPFROMME/bpmn-questionnaire/issues/3/comments","events_url":"https://api.github.com/repos/PHILIPPFROMME/bpmn-questionnaire/issues/3/events","html_url":"https://github.com/PHILIPPFROMME/bpmn-questionnaire/issues/3","id":126449542,"number":3,"title":"Implementierung einer Unterstützung von verschiedenen Typen von Fragen","user":{"login":"PHILIPPFROMME","id":7633572,"avatar_url":"https://avatars.githubusercontent.com/u/7633572?v=3","gravatar_id":"","url":"https://api.github.com/users/PHILIPPFROMME","html_url":"https://github.com/PHILIPPFROMME","followers_url":"https://api.github.com/users/PHILIPPFROMME/followers","following_url":"https://api.github.com/users/PHILIPPFROMME/following{/other_user}","gists_url":"https://api.github.com/users/PHILIPPFROMME/gists{/gist_id}","starred_url":"https://api.github.com/users/PHILIPPFROMME/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PHILIPPFROMME/subscriptions","organizations_url":"https://api.github.com/users/PHILIPPFROMME/orgs","repos_url":"https://api.github.com/users/PHILIPPFROMME/repos","events_url":"https://api.github.com/users/PHILIPPFROMME/events{/privacy}","received_events_url":"https://api.github.com/users/PHILIPPFROMME/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/PHILIPPFROMME/bpmn-questionnaire/labels/in%20progress","name":"in progress","color":"ededed"}],"state":"open","locked":false,"assignee":{"login":"PHILIPPFROMME","id":7633572,"avatar_url":"https://avatars.githubusercontent.com/u/7633572?v=3","gravatar_id":"","url":"https://api.github.com/users/PHILIPPFROMME","html_url":"https://github.com/PHILIPPFROMME","followers_url":"https://api.github.com/users/PHILIPPFROMME/followers","following_url":"https://api.github.com/users/PHILIPPFROMME/following{/other_user}","gists_url":"https://api.github.com/users/PHILIPPFROMME/gists{/gist_id}","starred_url":"https://api.github.com/users/PHILIPPFROMME/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PHILIPPFROMME/subscriptions","organizations_url":"https://api.github.com/users/PHILIPPFROMME/orgs","repos_url":"https://api.github.com/users/PHILIPPFROMME/repos","events_url":"https://api.github.com/users/PHILIPPFROMME/events{/privacy}","received_events_url":"https://api.github.com/users/PHILIPPFROMME/received_events","type":"User","site_admin":false},"milestone":null,"comments":2,"created_at":"2016-01-13T15:53:39Z","updated_at":"2016-01-19T14:08:28Z","closed_at":null,"body":"* [ ] Es ist möglich, Fragetypen zu definieren.\r\n* [ ] Es ist möglich eine Frage eines Typs mit Inhalt anzuzeigen.\r\n "},"comment":{"url":"https://api.github.com/repos/PHILIPPFROMME/bpmn-questionnaire/issues/comments/172863946","html_url":"https://github.com/PHILIPPFROMME/bpmn-questionnaire/issues/3#issuecomment-172863946","issue_url":"https://api.github.com/repos/PHILIPPFROMME/bpmn-questionnaire/issues/3","id":172863946,"user":{"login":"PHILIPPFROMME","id":7633572,"avatar_url":"https://avatars.githubusercontent.com/u/7633572?v=3","gravatar_id":"","url":"https://api.github.com/users/PHILIPPFROMME","html_url":"https://github.com/PHILIPPFROMME","followers_url":"https://api.github.com/users/PHILIPPFROMME/followers","following_url":"https://api.github.com/users/PHILIPPFROMME/following{/other_user}","gists_url":"https://api.github.com/users/PHILIPPFROMME/gists{/gist_id}","starred_url":"https://api.github.com/users/PHILIPPFROMME/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/PHILIPPFROMME/subscriptions","organizations_url":"https://api.github.com/users/PHILIPPFROMME/orgs","repos_url":"https://api.github.com/users/PHILIPPFROMME/repos","events_url":"https://api.github.com/users/PHILIPPFROMME/events{/privacy}","received_events_url":"https://api.github.com/users/PHILIPPFROMME/received_events","type":"User","site_admin":false},"created_at":"2016-01-19T14:08:28Z","updated_at":"2016-01-19T14:08:28Z","body":"```\n/*\n * BpmnQuestionnaire has built in standard types of questions.\n * You can overwrite existing types or add new ones.\n */\n\nvar questionnaire = {\n  name:      'Sample Questionnaire',\n  intro:     'Lorem ipsum',\n  questions: [\n    {\n      type: 'single',\n      text: 'What is 1 + 2?',\n      answers: [\n        {\n          answer: '1',\n          isTrue: false\n        }, {\n          answer: '3',\n          isTrue: true\n        }, {\n          answer: '3,5',\n          isTrue: false\n        }, {\n          answer: '5',\n          isTrue: false\n        }\n      ]\n    },\n    {\n      type: 'multiple',\n      text: 'What is true about 1 + 2?',\n      answers: [\n        {\n          answer: 'It is 3',\n          isTrue: true\n        }, {\n          answer: 'It is below 0',\n          isTrue: false\n        }, {\n          answer: 'It is a number',\n          isTrue: true\n        }, {\n          answer: 'It is awesome',\n          isTrue: true\n        }\n      ]\n    }\n  ]\n};\n\nvar types = {\n  'multiple': function Multiple(options, question) {\n    function render() {\n        var html = $('<div><h1>Single: ' + options.text + '</h1><div class=\"buttons\"></div></div>');\n        \n        options.answers.forEach(function(answer) {\n          var button = $('<button class=\"btn btn-primary\">' + answer.answer + '</button>');\n          button.on('click', function() {\n            if($(this).hasClass('btn-success')) {\n              $(this).removeClass('btn-success');\n            } else {\n              $(this).addClass('btn-success');\n            }\n            question.answer();\n          });\n          html.find('.buttons').append(button);\n        });\n        \n        return html;\n      }\n    \n    console.log('Multiple created');\n    \n    return render;\n  }\n};\n\n\nfunction Question(index, options, questionnaire) {\n  this.index = index;\n  this.questionnaire = questionnaire;\n  this.questionnaire.state.results[this.index] = {\n    answered: false\n  };\n  this.state = {\n    answered: false\n  };\n  this.concreteQuestion = new questionnaire.types[options.type](options, this);\n}\n\nQuestion.prototype.render = function() {\n  console.log('Rendering question');\n  $('#container')\n    .empty()\n    .append(this.concreteQuestion());\n};\n\nQuestion.prototype.answer = function() {\n  _.assign(this.state, {answered: true});\n  this.questionnaire.state.results[this.index].answered = true;\n  console.log(this.questionnaire.state.results);\n};\n\nfunction BpmnQuestionnaire(options) {\n  this.state = {\n    currentQuestion: 0,\n    results: {}\n  };\n  \n  this.questions = [];\n  \n  // Standard types\n  this.types     = {\n    'single': function Single(options, question) {\n      function render() {\n        var html = $('<div><h1>Single: ' + options.text + '</h1><div class=\"buttons\"></div></div>');\n        \n        options.answers.forEach(function(answer) {\n          var button = $('<button class=\"btn btn-primary\">' + answer.answer + '</button>');\n          button.on('click', function() {\n            $(this).parent().find('button').removeClass('btn-success');\n            $(this).addClass('btn-success');\n            question.answer();\n          });\n          html.find('.buttons').append(button);\n        });\n        \n        return html;\n      }\n    \n      console.log('Single created');\n    \n      return render;\n    },\n  };\n  \n  // Additional types\n  if (options.types) {\n    \n    // Existing types can be overwritten\n    _.assign(this.types, options.types);\n  }\n  \n  var that = this;\n  \n  options.questionnaire.questions.forEach(function(options, index) {\n    that.questions.push(new Question(index, options, that));\n  });\n}\n\nBpmnQuestionnaire.prototype.renderQuestion = function(index) {\n  this.questions[index].render();\n};\n\nvar q = new BpmnQuestionnaire({\n  types:         types,\n  questionnaire: questionnaire\n});\n\nq.renderQuestion(0);\nconsole.log(q.state.results);\n```"}}