stundentReport.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. // FOR MOODLE
  2. /**
  3. * To be show on moodle
  4. */
  5. const studentReport = {
  6. create: function () {
  7. const offsetW = defaultWidth / 4;
  8. let x = offsetW / 2;
  9. let y = defaultHeight / 2 - 50;
  10. game.add.geom.rect(0, 0, defaultWidth, defaultHeight, undefined, 0, colors.blueBckg, 1);
  11. game.add.image(300, 100, 'cloud');
  12. game.add.image(660, 80, 'cloud');
  13. game.add.image(110, 85, 'cloud', 0.8);
  14. for (let i = 0; i < 9; i++) { game.add.image(i * 100, defaultHeight - 100, 'floor'); }
  15. game.add.text(defaultWidth / 2, 80, game.lang.results, textStyles.h1_green);
  16. game.add.image(x - 40, y - 70, info[gameTypeString].gameTypeUrl, 0.8);
  17. text = game.lang[gameShape].charAt(0).toUpperCase() + game.lang[gameShape].slice(1);
  18. text = game.lang.game + ': ' + text + ((gameTypeString.slice(-3) == 'One') ? ' I' : ' II');
  19. game.add.text(190, y - 50, text, textStyles.h4_brown).align = 'left';
  20. game.add.text(190, y - 25, game.lang.game_mode + ': ' + gameMode, textStyles.h4_brown).align = 'left';
  21. game.add.text(190, y, game.lang.operation + ': ' + gameOperation, textStyles.h4_brown).align = 'left';
  22. game.add.text(190, y + 25, game.lang.difficulty + ': ' + gameDifficulty, textStyles.h4_brown).align = 'left';
  23. y = defaultHeight - 200;
  24. for (let i = 0; i < 4; i++, x += offsetW) {
  25. if (moodleVar.hits[i] == 0) {
  26. const sign = game.add.image(x, defaultHeight - 100, 'broken_sign', 0.7);
  27. sign.anchor(0.5, 0.5);
  28. continue;
  29. }
  30. const sign = game.add.image(x, defaultHeight - 100, 'sign', 0.7);
  31. sign.anchor(0.5, 0.5);
  32. game.add.text(x, defaultHeight - 100, '' + (i + 1), textStyles.h2_white);
  33. game.add.geom.rect(x - 55, y - 40, 5, 135, undefined, 0, colors.blueMenuLine);
  34. game.add.text(x - 40, y - 25, game.lang.time + ': ' + convertTime(moodleVar.time[i]), textStyles.h4_brown).align = 'left';
  35. game.add.text(x - 40, y, game.lang.hits + ': ' + moodleVar.hits[i], textStyles.h4_brown).align = 'left';
  36. game.add.text(x - 40, y + 25, game.lang.errors + ': ' + moodleVar.errors[i], textStyles.h4_brown).align = 'left';
  37. }
  38. },
  39. convertTime: function (s) {
  40. let h = 0, m = 0;
  41. if (s > 1200) {
  42. h = s / 1200;
  43. s = s % 1200;
  44. }
  45. if (s > 60) {
  46. m = s / 60;
  47. s = s % 60;
  48. }
  49. h = '' + h;
  50. m = '' + m;
  51. s = '' + s;
  52. if (h.length < 2) h = '0' + h;
  53. if (m.length < 2) m = '0' + m;
  54. if (s.length < 2) s = '0' + s;
  55. return h + ':' + m + ':' + s;
  56. }
  57. }