<commit_before><template>

  <div id="exercise-container">
    <assessment-wrapper
      id = "assessment-container"
      v-ref:wrapper
      v-if="exercise"
      :item-id="itemId"
      :mastery-model="exercise.mastery_model"
      :mastery-spacing-time="exercise.masterySpacingTime"
      :mastery-criterion="exercise.masteryCriterion"
    >
      <perseus
        v-if="item"
        :item="item"
        :pass-ratio-m="passRatioM"
        :pass-ratio-n="passRatioN"
        @nextquestion="nextQuestion"
      ></perseus>
    </assessment-wrapper>
  </div>

</template>


<script>

  const ss = require('seededshuffle');

  module.exports = {

    data: () => ({
      item: undefined,
      items: undefined,
      exercise: undefined,
      itemId: undefined,
      // how many most recent questions taken into account?
      passRatioM: 5,
      // how many questions need to get right?
      passRatioN: 4,
    }),
    methods: {
      nextQuestion() {
        this.setItemData();
      },
      loadItemData(attempts) {
        const itemIndex = attempts % this.items.length;
        this.itemId = this.items[itemIndex];
        this.Kolibri.client(
          `${this.defaultFile.storage_url}${this.itemId}.json`
          ).then((itemResponse) => {
            this.item = itemResponse.entity;
          }).catch(function(reason) {
            console.log('Oops, you got rejected: ', reason);
          });
      },
      setItemData() {
        this.passRatioM = this.exercise.m;
        this.passRatioN = this.exercise.n;
        if(!this.totalattempts) {
          let watchRevoke;
          watchRevoke = this.$watch('totalattempts', () => {
            this.loadItemData(this.totalattempts);
            watchRevoke();
          }, {deep:true});
        } else {
          this.loadItemData(this.totalattempts);
        }
      }
    },
    components: {
      perseus: require('./perseus'),
    },
    created() {
      this.Kolibri.client(`${this.defaultFile.storage_url}exercise.json`).then(
        (exerciseResponse) => {
          this.exercise = exerciseResponse.entity;
          this.exercise.masteryCriterion = "to be deleted";
          if (this.userid) {
            this.items = ss.shuffle(exerciseResponse.entity.all_assessment_items, this.userid, true);
          } else {
            this.items = exerciseResponse.entity.all_assessment_items;
          }
          this.setItemData();
        }).catch(function(reason) {
          console.log('Oops, requesting exercise.json got rejected: ', reason);
        });
    },
    props: [
      'defaultFile',
    ],
    vuex: {
      getters: {
        totalattempts: (state) => state.core.logging.mastery.totalattempts,
        userid: (state) => state.core.session.user_id,
      },
    },
  };

</script>

<style lang="stylus" scoped>

  @require '~kolibri.styles.coreTheme'

</style>
<commit_msg>mastery_model from content-curation actually is mastery_criterion in masterylog<commit_after><template>

  <div id="exercise-container">
    <assessment-wrapper
      id = "assessment-container"
      v-ref:wrapper
      v-if="exercise"
      :item-id="itemId"
      :mastery-spacing-time="exercise.masterySpacingTime"
      :mastery-criterion="exercise.mastery_model"
    >
      <perseus
        v-if="item"
        :item="item"
        :pass-ratio-m="passRatioM"
        :pass-ratio-n="passRatioN"
        @nextquestion="nextQuestion"
      ></perseus>
    </assessment-wrapper>
  </div>

</template>


<script>

  const ss = require('seededshuffle');

  module.exports = {

    data: () => ({
      item: undefined,
      items: undefined,
      exercise: undefined,
      itemId: undefined,
      // how many most recent questions taken into account?
      passRatioM: 5,
      // how many questions need to get right?
      passRatioN: 4,
    }),
    methods: {
      nextQuestion() {
        this.setItemData();
      },
      loadItemData(attempts) {
        const itemIndex = attempts % this.items.length;
        this.itemId = this.items[itemIndex];
        this.Kolibri.client(
          `${this.defaultFile.storage_url}${this.itemId}.json`
          ).then((itemResponse) => {
            this.item = itemResponse.entity;
          }).catch(function(reason) {
            console.log('Oops, you got rejected: ', reason);
          });
      },
      setItemData() {
        this.passRatioM = this.exercise.m;
        this.passRatioN = this.exercise.n;
        if(!this.totalattempts) {
          let watchRevoke;
          watchRevoke = this.$watch('totalattempts', () => {
            this.loadItemData(this.totalattempts);
            watchRevoke();
          }, {deep:true});
        } else {
          this.loadItemData(this.totalattempts);
        }
      }
    },
    components: {
      perseus: require('./perseus'),
    },
    created() {
      this.Kolibri.client(`${this.defaultFile.storage_url}exercise.json`).then(
        (exerciseResponse) => {
          this.exercise = exerciseResponse.entity;
          if (this.userid) {
            this.items = ss.shuffle(exerciseResponse.entity.all_assessment_items, this.userid, true);
          } else {
            this.items = exerciseResponse.entity.all_assessment_items;
          }
          this.setItemData();
        }).catch(function(reason) {
          console.log('Oops, requesting exercise.json got rejected: ', reason);
        });
    },
    props: [
      'defaultFile',
    ],
    vuex: {
      getters: {
        totalattempts: (state) => state.core.logging.mastery.totalattempts,
        userid: (state) => state.core.session.user_id,
      },
    },
  };

</script>

<style lang="stylus" scoped>

  @require '~kolibri.styles.coreTheme'

</style>

{'fraction_non_alphanumeric': 0.13885484153388197, 'fraction_numerical': 0.0007004027315706532, 'mean_word_length': 2.1367380560131797, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '364056', 'n_tokens_mistral': 1799, 'n_tokens_neox': 1737, 'n_words': 276}