<commit_before><problem>
<!-- If you don't have hx-js anywhere else on your page, uncomment these lines. -->

<!-- <script src="/static/hx.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="/static/hx.css" /> -->

<!-- This problem only logs student responses. It grades nearly anything as correct. -->
<script type="loncapa/python">
<![CDATA[
# The CDATA declaration lets us use less-than signs
# without edX thinking that we're starting an XML tag.
import json

def journalingResponseGrader(ans, new_options={"min_length": 10}):

  options = {"min_length": 10}
  options.update(new_options)

  # Parse the state and obtain the "answer" string from it.
  parsed = json.loads(ans)
  answer = json.loads(parsed["answer"])["answer"]
  length = json.loads(parsed["answer"])["length"]

  # Checking for sufficient length.
  if length >= options["min_length"]:
    return {
      "input_list": [
        {
          "ok": True,
          "msg": "Thank you for your response.",
          "grade_decimal": 1
        }
      ]
    }
  else:
    return {
      "input_list": [
        {
          "ok": False,
          "msg": "Your response is too short. Please try again.",
          "grade_decimal": 0
        }
      ]
    }

def answercheck(e, ans):

  options = {
    'min_length': 10   # This is the minimum length in characters of the response.
  }

  return journalingResponseGrader(ans, options)

]]>
</script>

<!-- The default save slot is "journaling". If you want more than one
  of this kind of problem, the others should have different save slots
  if learners are to see different things in them. -->

<script type="text/javascript">
$(document).ready(function(){
  console.log('outer ready');
});

function logThatThing(ThatThing){
  console.log(JSON.stringify(ThatThing));
  // Call the edX logging code.
  Logger.log("harvardx.StudioAdv.journaling", ThatThing);
}
</script>

  <p>Put your prompt here</p>

  <!-- This will get turned into a rich text editor by hx-js. -->
  <!-- Change the ID here and above if you have multiple on the same screen. -->
  <div
    class="hx-editor"
    data-saveslot="journaling">
    [Editor not loaded yet]
  </div>

  <customresponse cfn="answercheck">
    <jsinput
      title="Journaling Exercise"
      gradefn="journaling.getGrade"
      get_statefn="journaling.getState"
      set_statefn="journaling.setState"
      width="30"
      height="30"
      html_file="/static/journaling.html?saveslot=journaling"
      sop="false"/>
  </customresponse>
  <solution>
    <div class="detailed-solution">
      <p>Explanation</p>
      <p>You can put commentary here if you want, or you can remove this.</p>
    </div>
  </solution>

</problem>
<commit_msg>Shifting to python_lib as standard<commit_after><problem>
<!-- If you don't have hx-js anywhere else on your page, uncomment these lines. -->

<!-- <script src="/static/hx.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="/static/hx.css" /> -->

<!-- This problem only logs student responses. It grades nearly anything as correct. -->
<script type="loncapa/python">
<![CDATA[
# The CDATA declaration lets us use less-than signs
# without edX thinking that we're starting an XML tag.
import json
from python_lib import HXGraders

def answercheck(e, ans):

  options = {
    'min_length': 10   # This is the minimum length in characters of the response.
  }

  return HXGraders.journalingResponseGrader(ans, options)

]]>
</script>

<!-- The default save slot is "journaling". If you want more than one
  of this kind of problem, the others should have different save slots
  if learners are to see different things in them. -->

<script type="text/javascript">
$(document).ready(function(){
  console.log('outer ready');
});

function logThatThing(ThatThing){
  console.log(JSON.stringify(ThatThing));
  // Call the edX logging code.
  Logger.log("harvardx.StudioAdv.journaling", ThatThing);
}
</script>

  <p>Put your prompt here</p>

  <!-- This will get turned into a rich text editor by hx-js. -->
  <!-- Change the ID here and above if you have multiple on the same screen. -->
  <div
    class="hx-editor"
    data-saveslot="journaling">
    [Editor not loaded yet]
  </div>

  <customresponse cfn="answercheck">
    <jsinput
      title="Journaling Exercise"
      gradefn="journaling.getGrade"
      get_statefn="journaling.getState"
      set_statefn="journaling.setState"
      width="30"
      height="30"
      html_file="/static/journaling.html?saveslot=journaling"
      sop="false"/>
  </customresponse>
  <solution>
    <div class="detailed-solution">
      <p>Explanation</p>
      <p>You can put commentary here if you want, or you can remove this.</p>
    </div>
  </solution>

</problem>

{'fraction_non_alphanumeric': 0.13561098302242716, 'fraction_numerical': 0.0037727939635296584, 'mean_word_length': 3.256913470115968, 'pattern_counts': {'":': 10, '<': 65, '<?xml version=': 0, '>': 66, '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': '1327815', 'n_tokens_mistral': 1501, 'n_tokens_neox': 1453, 'n_words': 455}