studentReport.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 = defaultWidth / 4;
  20. let x = offsetW / 2;
  21. let y = defaultHeight / 2 - 50;
  22. // Background
  23. game.add.geom.rect(0, 0, defaultWidth, defaultHeight, undefined, 0, colors.blueBckg, 1);
  24. game.add.image(300, 100, 'cloud');
  25. game.add.image(660, 80, 'cloud');
  26. game.add.image(110, 85, 'cloud', 0.8);
  27. for (let i = 0; i < 9; i++) { game.add.image(i * 100, defaultHeight - 100, 'floor'); }
  28. // Title
  29. game.add.text(defaultWidth / 2, 80, game.lang.results, textStyles.h1_green);
  30. game.add.image(x - 40, y - 70, info[gameTypeString].gameTypeUrl, 0.8);
  31. // Game info
  32. text = game.lang[gameShape].charAt(0).toUpperCase() + game.lang[gameShape].slice(1);
  33. text = game.lang.game + ': ' + text + ((gameTypeString.slice(-3) == 'One') ? ' I' : ' II');
  34. game.add.text(190, y - 50, text, textStyles.h4_brown).align = 'left';
  35. game.add.text(190, y - 25, game.lang.game_mode + ': ' + gameMode, textStyles.h4_brown).align = 'left';
  36. game.add.text(190, y, game.lang.operation + ': ' + gameOperation, textStyles.h4_brown).align = 'left';
  37. game.add.text(190, y + 25, game.lang.difficulty + ': ' + gameDifficulty, textStyles.h4_brown).align = 'left';
  38. // Student info
  39. y = defaultHeight - 200;
  40. for (let i = 0; i < 4; i++, x += offsetW) {
  41. // If level wasnt completed, show broken sign
  42. if (moodleVar.hits[i] == 0) {
  43. const sign = game.add.image(x, defaultHeight - 100, 'broken_sign', 0.7);
  44. sign.anchor(0.5, 0.5);
  45. } else {
  46. // If level was completed shows sign with level number and student report
  47. const sign = game.add.image(x, defaultHeight - 100, 'sign', 0.7);
  48. sign.anchor(0.5, 0.5);
  49. game.add.text(x, defaultHeight - 100, '' + (i + 1), textStyles.h2_white);
  50. game.add.geom.rect(x - 55, y - 40, 5, 135, undefined, 0, colors.blueMenuLine);
  51. game.add.text(x - 40, y - 25, game.lang.time + ': ' + game.math.convertTime(moodleVar.time[i]), textStyles.h4_brown).align = 'left';
  52. game.add.text(x - 40, y, game.lang.hits + ': ' + moodleVar.hits[i], textStyles.h4_brown).align = 'left';
  53. game.add.text(x - 40, y + 25, game.lang.errors + ': ' + moodleVar.errors[i], textStyles.h4_brown).align = 'left';
  54. }
  55. }
  56. }
  57. };