Code coverage report for src/components/student-dashboard/progress-guide.cjsx

Statements: 94.23% (49 / 52)      Branches: 100% (4 / 4)      Functions: 90.91% (10 / 11)      Lines: 94.23% (49 / 52)      Ignored: none     

All files » src/components/student-dashboard/ » progress-guide.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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168                                                               44× 44× 44× 44× 44×                     44× 44× 44× 150× 150×               44×                                                           49× 49× 49× 49×   44× 44× 13×   44×                                                         26×           26× 49×              
var BS, ChapterSection, ChapterSectionMixin, LoadableItem, NUM_SECTIONS, PerformanceForecast, PerformanceForecastColorKey, PerformanceForecastSection, PracticeButton, ProgressGuide, ProgressGuidePanels, React, S, Section, SpyMode, _;
 
React = require('react');
 
BS = require('react-bootstrap');
 
SpyMode = require('openstax-react-components').SpyMode;
 
LoadableItem = require('../loadable-item');
 
_ = require('underscore');
 
S = require('../../helpers/string');
 
PerformanceForecast = require('../../flux/performance-forecast');
 
ChapterSection = require('../task-plan/chapter-section');
 
ChapterSectionMixin = require('openstax-react-components').ChapterSectionMixin;
 
PerformanceForecastSection = require('../performance-forecast/section');
 
PerformanceForecastColorKey = require('../performance-forecast/color-key');
 
PracticeButton = require('../performance-forecast/practice-button');
 
Section = require('../performance-forecast/section');
 
NUM_SECTIONS = 4;
 
ProgressGuide = React.createClass({
  displayName: 'ProgressGuide',
  contextTypes: {
    router: React.PropTypes.func
  },
  propTypes: {
    courseId: React.PropTypes.string.isRequired,
    sampleSizeThreshold: React.PropTypes.number.isRequired
  },
  onPractice: function(section) {
    return this.context.router.transitionTo('viewPractice', {
      courseId: this.props.courseId
    }, {
      page_ids: section.page_ids
    });
  },
  render: function() {
    var courseId, guide, i, section, sections;
    courseId = this.props.courseId;
    guide = PerformanceForecast.Student.store.get(courseId);
    sections = PerformanceForecast.Helpers.recentSections(PerformanceForecast.Student.store.getAllSections(courseId));
    return React.createElement("div", {
      "className": 'progress-guide'
    }, React.createElement("h1", {
      "className": 'panel-title'
    }, "Performance Forecast"), React.createElement("h2", {
      "className": 'recent'
    }, "Recent topics"), React.createElement("div", {
      "className": 'guide-group'
    }, React.createElement("div", {
      "className": 'chapter-panel'
    }, (function() {
      var j, len, results;
      results = [];
      for (i = j = 0, len = sections.length; j < len; i = ++j) {
        section = sections[i];
        results.push(React.createElement(Section, React.__spread({
          "key": i,
          "section": section,
          "onPractice": this.onPractice
        }, this.props, {
          "sampleSizeThreshold": 3.
        })));
      }
      return results;
    }).call(this))), React.createElement(PerformanceForecastColorKey, null));
  }
});
 
ProgressGuidePanels = React.createClass({displayName: "ProgressGuidePanels",
  contextTypes: {
    router: React.PropTypes.func
  },
  propTypes: {
    courseId: React.PropTypes.string.isRequired,
    sampleSizeThreshold: React.PropTypes.number.isRequired
  },
  mixins: [ChapterSectionMixin],
  viewPerformanceForecast: function() {
    return this.context.router.transitionTo('viewPerformanceForecast', {
      courseId: this.props.courseId
    });
  },
  renderEmpty: function(sections) {
    var section;
    return React.createElement("div", {
      "className": 'progress-guide empty'
    }, React.createElement("div", {
      "className": 'actions-box'
    }, React.createElement("h1", {
      "className": 'panel-title'
    }, "Performance Forecast"), React.createElement("p", null, "The performance forecast is an estimate of your current understanding of a topic.\nIt is a personalized display based on your answers to reading questions,\nhomework problems, and previous practices."), React.createElement("p", null, "This area will fill in with topics as you complete your assignments"), React.createElement(SpyMode.Content, null, React.createElement("ul", null, React.createElement("li", null, sections.length, " sections were returned by the performance forecast"), (function() {
      var j, len, results;
      results = [];
      for (j = 0, len = sections.length; j < len; j++) {
        section = sections[j];
        results.push(React.createElement("li", null, this.sectionFormat(section.chapter_section), " section.title"));
      }
      return results;
    }).call(this)))));
  },
  render: function() {
    var practiceSections, recent, sections;
    sections = PerformanceForecast.Student.store.getAllSections(this.props.courseId);
    recent = PerformanceForecast.Helpers.recentSections(sections);
    if (_.isEmpty(recent)) {
      return this.renderEmpty(sections);
    }
    practiceSections = PerformanceForecast.Helpers.weakestSections(sections);
    if (_.isEmpty(practiceSections)) {
      practiceSections = recent;
    }
    return React.createElement("div", {
      "className": 'progress-guide'
    }, React.createElement("div", {
      "className": 'actions-box'
    }, React.createElement(ProgressGuide, {
      "sections": recent,
      "courseId": this.props.courseId
    }), React.createElement(PracticeButton, {
      "ref": 'practiceBtn',
      "title": 'Practice my weakest topics',
      "courseId": this.props.courseId,
      "sections": practiceSections
    }), React.createElement(BS.Button, {
      "onClick": this.viewPerformanceForecast,
      "className": 'view-performance-forecast'
    }, "View All Topics")));
  }
});
 
module.exports = React.createClass({
  displayName: 'ProgressGuideShell',
  propTypes: {
    courseId: React.PropTypes.string.isRequired,
    sampleSizeThreshold: React.PropTypes.number.isRequired
  },
  renderLoading: function(refreshButton) {
    return React.createElement("div", {
      "className": 'actions-box loadable is-loading'
    }, "Loading progress information... ", refreshButton);
  },
  render: function() {
    return React.createElement(LoadableItem, {
      "id": this.props.courseId,
      "store": PerformanceForecast.Student.store,
      "renderLoading": this.renderLoading,
      "actions": PerformanceForecast.Student.actions,
      "renderItem": ((function(_this) {
        return function() {
          return React.createElement(ProgressGuidePanels, React.__spread({}, _this.props));
        };
      })(this))
    });
  }
});