Guest User

Untitled

a guest
May 25th, 2018
101
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. @section scripts {
  3. <script>
  4. $(document).ready(function () {
  5.  
  6. let userAnswers = [];
  7. let answers = [];
  8.  
  9. $('#checkResultBtn').click(function () {
  10. $('input:checked', '.card-body').each(function () {
  11. userAnswers.push({
  12. questionId: $(this).attr('name'),
  13. answerId: $(this).val()
  14. });
  15. });
  16. console.log(userAnswers);
  17. console.log(answers);
  18. diff(userAnswers, answers);
  19.  
  20.  
  21. });
  22. function diff(userAnswers, answers) {
  23. userAnswers.forEach(function (userAns) {
  24. answers.forEach(function (ans) {
  25. if (userAns['questionId'] == ans['questionId']) {
  26. if (userAns['answerId'] == ans['answerId'])
  27. console.log(true)
  28. else
  29. console.log(false)
  30. }
  31.  
  32. });
  33.  
  34.  
  35. });
  36.  
  37. }
  38.  
  39. @foreach(var answers in Model){
  40.  
  41. var answersList = answers.Answers.Where(x => x.Answer == 1);
  42.  
  43. foreach(var answer in @answersList)
  44. {
  45. <text>
  46. answers.push({
  47. questionId: '@answer.QuestionId',
  48. answerId: '@answer.Id'
  49. });
  50.  
  51. </text>
  52. }
  53.  
  54. }
  55.  
  56.  
  57.  
  58.  
  59. });
  60.  
  61.  
  62.  
  63. </script>
  64. }
RAW Paste Data