studentReport.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /************************************************************************************
  2. * This code is used EXCLUSIVELY when iFractions is runnign inside Moodle via iAssign
  3. * as an iLM (interactive learning module) and the global variable moodle=true.
  4. *
  5. * This file holds game states.
  6. ************************************************************************************/
  7. /**
  8. * [STUDENT REPORT STATE] Screen that shows the stats of a previously played game (exclusive to moodle).
  9. *
  10. * FOR MOODLE
  11. *
  12. * @namespace
  13. */
  14. const studentReport = {
  15. /** FOR MOODLE
  16. * Main code
  17. */
  18. create: function () {
  19. const offsetW = context.canvas.width / 4;
  20. let x = offsetW / 2;
  21. let y = context.canvas.height / 2 - 50;
  22. // Background
  23. game.add.geom.rect(
  24. 0,
  25. 0,
  26. context.canvas.width,
  27. context.canvas.height,
  28. undefined,
  29. 0,
  30. colors.blueBg,
  31. 1
  32. );
  33. game.add.image(640, 100, 'cloud');
  34. game.add.image(1280, 80, 'cloud');
  35. game.add.image(300, 85, 'cloud', 0.8);
  36. for (let i = 0; i < context.canvas.width / 100; i++) {
  37. game.add.image(i * 100, context.canvas.height - 100, 'floor');
  38. }
  39. // Title
  40. game.add.text(
  41. context.canvas.width / 2,
  42. 80,
  43. game.lang.results,
  44. textStyles.h1_green
  45. );
  46. game.add.image(x - 40, y - 70, info.all[gameType].gameTypeUrl, 0.8);
  47. // Game info
  48. text =
  49. game.lang[gameShape].charAt(0).toUpperCase() +
  50. game.lang[gameShape].slice(1);
  51. text =
  52. game.lang.game +
  53. ': ' +
  54. text +
  55. (gameType.slice(-3) == 'One' ? ' I' : ' II');
  56. game.add.text(190, y - 50, text, textStyles.h4_brown).align = 'left';
  57. game.add.text(
  58. 190,
  59. y - 25,
  60. game.lang.game_mode + ': ' + gameMode,
  61. textStyles.h4_brown
  62. ).align = 'left';
  63. game.add.text(
  64. 190,
  65. y,
  66. game.lang.operation + ': ' + gameOperation,
  67. textStyles.h4_brown
  68. ).align = 'left';
  69. game.add.text(
  70. 190,
  71. y + 25,
  72. game.lang.difficulty + ': ' + gameDifficulty,
  73. textStyles.h4_brown
  74. ).align = 'left';
  75. // Student info
  76. y = context.canvas.height - 200;
  77. for (let i = 0; i < 4; i++, x += offsetW) {
  78. // If level wasnt completed, show broken sign
  79. if (moodleVar.hits[i] == 0 && moodleVar.errors[i] == 0) {
  80. const sign = game.add.image(
  81. x,
  82. context.canvas.height - 100,
  83. 'broken_sign',
  84. 0.7
  85. );
  86. sign.anchor(0.5, 0.5);
  87. } else {
  88. // If level was completed shows sign with level number and student report
  89. const sign = game.add.image(
  90. x,
  91. context.canvas.height - 100,
  92. 'sign',
  93. 0.7
  94. );
  95. sign.anchor(0.5, 0.5);
  96. game.add.text(
  97. x,
  98. context.canvas.height - 100,
  99. '' + (i + 1),
  100. textStyles.h2_white
  101. );
  102. game.add.geom.rect(
  103. x - 55,
  104. y - 40,
  105. 5,
  106. 135,
  107. undefined,
  108. 0,
  109. colors.blueMenuLine
  110. );
  111. game.add.text(
  112. x - 40,
  113. y - 25,
  114. game.lang.time + ': ' + game.math.convertTime(moodleVar.time[i]),
  115. textStyles.h4_brown
  116. ).align = 'left';
  117. game.add.text(
  118. x - 40,
  119. y,
  120. game.lang.hits + ': ' + moodleVar.hits[i],
  121. textStyles.h4_brown
  122. ).align = 'left';
  123. game.add.text(
  124. x - 40,
  125. y + 25,
  126. game.lang.errors + ': ' + moodleVar.errors[i],
  127. textStyles.h4_brown
  128. ).align = 'left';
  129. }
  130. }
  131. },
  132. };