minigame_function.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. function rankingClick() {
  2. $("#minigame-ranking-data-box").removeClass("hide");
  3. $("#minigame-rule-data-box").addClass("hide");
  4. }
  5. function ruleClick() {
  6. $("#minigame-rule-data-box").removeClass("hide");
  7. $("#minigame-ranking-data-box").addClass("hide");
  8. }
  9. function redirectToRank() {
  10. $.ajax({
  11. url: '/MiniGame/GetWinner',
  12. type: 'GET',
  13. success: function (result) {
  14. $('#ranking_data').html(result); // Sửa từ .ranking_data thành #ranking_data
  15. $("#minigame-rule-data-box").addClass("hide");
  16. $("#minigame-ranking-data-box").removeClass("hide");
  17. },
  18. error: function () {
  19. $('#ranking_data').html('<p>Error loading ranking.</p>'); // Sửa từ .ranking_data thành #ranking_data
  20. }
  21. });
  22. }
  23. function loadPlay() {
  24. console.log("loadPlay");
  25. $.ajax({
  26. url: '/MiniGame/PlayQuestion',
  27. type: 'POST',
  28. success: function (result) {
  29. console.log(result);
  30. $('#open_play').html(result);
  31. },
  32. error: function () {
  33. console.log("error");
  34. $('#open_play').html('<p>Error loading Play.</p>');
  35. }
  36. });
  37. }
  38. //let selectedAnswer = null;
  39. //let answerList = [];
  40. //let currentQuestionIndex = 0;
  41. //let selectedAnswer = null;
  42. //let answerList = []; // Danh sách lưu các đáp án đã chọn
  43. //function updateQuestion() {
  44. // // Cập nhật nội dung câu hỏi và các đáp án trên giao diện
  45. // const newQuestion = @Html.Raw(JsonConvert.SerializeObject(Model.questions))[questionIndex - 1];
  46. // document.querySelector('.question-container').setAttribute('data-question-id', newQuestion.id);
  47. // document.querySelector('.text-c-2').innerText = newQuestion.content;
  48. // // Cập nhật các đáp án
  49. // const buttons = document.querySelectorAll('.answer-box button');
  50. // buttons.forEach((btn, index) => {
  51. // btn.innerText = newQuestion[`answer${index + 1}`];
  52. // btn.onclick = () => selectAnswer(btn, newQuestion[`answer${index + 1}`]);
  53. // });
  54. //}
  55. //function sendAnswersToServer() {
  56. // const data = {
  57. // serviceId: "3",
  58. // LESSON_ID: "-1",
  59. // ANSWER_LIST: answerList
  60. // };
  61. // $.ajax({
  62. // url: '/MiniGame/ConfirmPlayQuestion',
  63. // type: 'POST',
  64. // contentType: 'application/json',
  65. // data: JSON.stringify(data),
  66. // success: function (result) {
  67. // console.log(result);
  68. // $('#open_play').html(result);
  69. // },
  70. // error: function () {
  71. // console.log("error");
  72. // $('#open_play').html('<p>Error loading Play.</p>');
  73. // }
  74. // });
  75. //}