Code coverage report for src/flux/scores.coffee

Statements: 40% (8 / 20)      Branches: 100% (0 / 0)      Functions: 0% (0 / 5)      Lines: 40% (8 / 20)      Ignored: none     

All files » src/flux/ » scores.coffee
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45                                                                          
var CrudConfig, ScoresConfig, _, actions, allStudents, extendConfig, makeSimpleStore, ref, ref1, store;
 
ref = require('./helpers'), CrudConfig = ref.CrudConfig, makeSimpleStore = ref.makeSimpleStore, extendConfig = ref.extendConfig;
 
_ = require('underscore');
 
allStudents = function(scores) {
  return _.chain(scores).pluck('students').flatten(true).value();
};
 
ScoresConfig = {
  exports: {
    getStudent: function(courseId, roleId) {
      var students;
      students = allStudents(this._get(courseId));
      return _.findWhere(allStudents(this._get(courseId)), {
        role: parseInt(roleId)
      });
    },
    getAllStudents: function(courseId) {
      return allStudents(this._get(courseId));
    },
    getStudentOfTask: function(courseId, taskId) {
      var students;
      students = allStudents(this._get(courseId));
      taskId = parseInt(taskId);
      return _.find(students, function(student) {
        var taskIds;
        taskIds = _.pluck(student.data, 'id');
        return _.indexOf(taskIds, taskId) > -1;
      });
    }
  }
};
 
extendConfig(ScoresConfig, new CrudConfig());
 
ref1 = makeSimpleStore(ScoresConfig), actions = ref1.actions, store = ref1.store;
 
module.exports = {
  ScoresActions: actions,
  ScoresStore: store
};