Code coverage report for src/components/cc-dashboard/dashboard.cjsx

Statements: 97.14% (34 / 35)      Branches: 66.67% (4 / 6)      Functions: 80% (4 / 5)      Lines: 97.14% (34 / 35)      Ignored: none     

All files » src/components/cc-dashboard/ » dashboard.cjsx
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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130                                                                                                                                       37× 37×                                                          
var BS, BlankCourse, CCDashboard, CCDashboardStore, CourseDataMixin, CoursePeriodsNav, CourseStore, DashboardChapter, Icon, React, Router, TOOLTIPS;
 
React = require('react');
 
BS = require('react-bootstrap');
 
Router = require('react-router');
 
CCDashboardStore = require('../../flux/cc-dashboard').CCDashboardStore;
 
CoursePeriodsNav = require('../course-periods-nav').CoursePeriodsNav;
 
CourseStore = require('../../flux/course').CourseStore;
 
Icon = require('../icon');
 
CourseDataMixin = require('../course-data-mixin');
 
DashboardChapter = require('./chapter');
 
BlankCourse = require('./blank-course');
 
TOOLTIPS = {
  complete: 'Complete shows the percentage of students who\nhave completed the Concept Coach for this section.\nStudents who have not answered all of the Concept Coach\nquestions for this section will not be counted, although\nthe questions they have answered will be included in the\nOriginal and Spaced Practice Performance percentages.',
  original: 'The original performance shows the percentage of Concept Coach\nquestions that students answered correctly on this section of the\nbook the first time they were presented. The performance bars\nshow up for a section of the book once at least 10% of students\nin the class (or section) have submitted answers.',
  spaced: 'Spaced practice performance shows the percentage of Concept Coach\nquestions on this section that were correctly answered after the\nsection was originally practiced. Compare this measure to\nOriginal Performance to gauge how well students are retaining\nthe information.'
};
 
CCDashboard = React.createClass({displayName: "CCDashboard",
  mixins: [CourseDataMixin],
  contextTypes: {
    router: React.PropTypes.func
  },
  propTypes: {
    courseId: React.PropTypes.string
  },
  getDefaultProps: function() {
    return {
      initialActivePeriod: 0
    };
  },
  getInitialState: function() {
    var activePeriod, ref;
    activePeriod = (ref = CCDashboardStore.getPeriods(this.props.courseId)) != null ? ref[this.props.initialActivePeriod] : void 0;
    return {
      activePeriodId: activePeriod != null ? activePeriod.id : void 0
    };
  },
  handlePeriodSelect: function(period) {
    return this.setState({
      activePeriodId: period.id
    });
  },
  render: function() {
    var chapter, chapters, course, courseDataProps, courseId, dashboardResults, emptyGraphic, emptyPeriod, index, periods;
    courseId = this.props.courseId;
    periods = CCDashboardStore.getPeriods(courseId);
    chapters = CCDashboardStore.chaptersForDisplay(courseId, this.state.activePeriodId);
    courseDataProps = this.getCourseDataProps(courseId);
    course = CourseStore.get(courseId);
    emptyPeriod = chapters.length === 0;
    emptyGraphic = React.createElement(BlankCourse, {
      "courseId": courseId,
      "inPeriod": emptyPeriod
    });
    dashboardResults = React.createElement("div", null, React.createElement(BS.Row, {
      "className": "column-legend"
    }, React.createElement(BS.Col, {
      "xs": 2.,
      "xsOffset": 6.
    }, "Complete", React.createElement(Icon, {
      "type": 'info-circle',
      "tooltipProps": {
        placement: 'top'
      },
      "tooltip": TOOLTIPS.complete
    })), React.createElement(BS.Col, {
      "xs": 2.
    }, "Original Performance", React.createElement(Icon, {
      "type": 'info-circle',
      "tooltipProps": {
        placement: 'top'
      },
      "tooltip": TOOLTIPS.original
    })), React.createElement(BS.Col, {
      "xs": 2.
    }, "Spaced Practice Performance", React.createElement(Icon, {
      "type": 'info-circle',
      "tooltipProps": {
        placement: 'top'
      },
      "tooltip": TOOLTIPS.spaced
    }))), (function() {
      var i, len, results;
      results = [];
      for (index = i = 0, len = chapters.length; i < len; index = ++i) {
        chapter = chapters[index];
        results.push(React.createElement(DashboardChapter, {
          "chapter": chapter,
          "key": index
        }));
      }
      return results;
    })(), React.createElement(BS.Row, null, React.createElement(BS.Col, {
      "className": "hide-section-legend",
      "xs": 12.
    }, "Chapters and sections that are less than 10% complete are hidden")));
    return React.createElement("div", {
      "className": "dashboard",
      "data-period": this.state.activePeriodId
    }, React.createElement("div", React.__spread({}, courseDataProps, {
      "className": 'tutor-booksplash-background'
    })), React.createElement(BS.Panel, null, React.createElement("h2", null, "Class Dashboard"), React.createElement(Router.Link, {
      "className": 'detailed-scores btn btn-default',
      "to": 'viewScores',
      "params": {
        courseId: courseId
      }
    }, "View Detailed Scores"), React.createElement(CoursePeriodsNav, {
      "handleSelect": this.handlePeriodSelect,
      "initialActive": this.props.initialActivePeriod,
      "periods": periods,
      "courseId": courseId
    }), (emptyPeriod ? emptyGraphic : dashboardResults)));
  }
});
 
module.exports = CCDashboard;