PageRenderTime 94ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/app/_attachments/js/modules/result/Result.js

https://github.com/bilalawan101/Tangerine
JavaScript | 56 lines | 46 code | 10 blank | 0 comment | 7 complexity | d3d047c955d47c40e10978ef0633c317 MD5 | raw file
Possible License(s): GPL-3.0, Apache-2.0
  1. var Result,
  2. __hasProp = Object.prototype.hasOwnProperty,
  3. __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
  4. Result = (function(_super) {
  5. __extends(Result, _super);
  6. function Result() {
  7. Result.__super__.constructor.apply(this, arguments);
  8. }
  9. Result.prototype.url = "result";
  10. Result.prototype.initialize = function(options) {
  11. if (options.blank === true) {
  12. this.set({
  13. 'subtestData': [],
  14. 'start_time': (new Date()).getTime(),
  15. 'enumerator': Tangerine.user.name
  16. });
  17. return this.unset("blank");
  18. }
  19. };
  20. Result.prototype.add = function(subtestDataElement) {
  21. var subtestData;
  22. subtestData = this.get('subtestData');
  23. subtestData['timestamp'] = (new Date()).getTime();
  24. subtestData.push(subtestDataElement);
  25. return this.save({
  26. 'subtestData': subtestData
  27. });
  28. };
  29. Result.prototype.getGridScore = function(id) {
  30. var datum, _i, _len, _ref;
  31. _ref = this.get('subtestData');
  32. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  33. datum = _ref[_i];
  34. if (datum.subtestId === id) return parseInt(datum.data.attempted);
  35. }
  36. };
  37. Result.prototype.gridWasAutostopped = function(id) {
  38. var datum, _i, _len, _ref;
  39. _ref = this.get('subtestData');
  40. for (_i = 0, _len = _ref.length; _i < _len; _i++) {
  41. datum = _ref[_i];
  42. if (datum.subtestId === id) return datum.data.auto_stop;
  43. }
  44. };
  45. return Result;
  46. })(Backbone.Model);