textbox.html 1.55 KB
Newer Older
1
<section id="textbox_${id}" class="textbox">
2 3 4 5 6
  <textarea rows="${rows}" cols="${cols}" name="input_${id}" id="input_${id}"
       % if hidden:
      	    style="display:none;"
       % endif
  >${value|h}</textarea>
7 8 9 10 11

  <span id="answer_${id}"></span>

  % if state == 'unsubmitted':
  <span class="unanswered" style="display:inline-block;" id="status_${id}"></span>
12
  % elif state == 'correct':
13 14 15 16 17 18
  <span class="correct" id="status_${id}"></span>
  % elif state == 'incorrect':
  <span class="incorrect" id="status_${id}"></span>
  % elif state == 'incomplete':
  <span class="incorrect" id="status_${id}"></span>
  % endif
19 20 21
  % if hidden:
      <div style="display:none;" name="${hidden}" inputid="input_${id}" />
  % endif
22 23 24
  <br/>
  <span class="debug">(${state})</span>
  <br/>
25
  <span class="message">${msg|n}</span>
26 27
  <br/>

28 29 30 31 32 33 34 35 36
  <br/>

  <script type="text/javascript" src="${ settings.LIB_URL }CodeMirror/codemirror.js"></script>
  <script type="text/javascript" src="${ settings.LIB_URL }CodeMirror/python.js"></script>
  <link rel="stylesheet" href="${ settings.LIB_URL }CodeMirror/codemirror.css" />
  <script>
    // Note: We need to make the area follow the CodeMirror for this to work.
    $(function(){
      var cm = CodeMirror.fromTextArea(document.getElementById("input_${id}"), {
37 38 39 40
        % if linenumbers == 'true':
        lineNumbers: true,
        % endif
        mode: "${mode}"
41 42 43 44
      });
    });
  </script>
  <style type="text/css">
45 46 47
    .CodeMirror-scroll {
	height: ${height}px;
    }
48 49 50
    .CodeMirror {border-style: solid;
      border-width: 1px;}
  </style>
51
</section>