<commit_before>${module_content}
%if edit_link:
<div><a href="${edit_link}">Edit</a> / <a href="#${element_id}_xqa-modal" onclick="getlog_${element_id}()" id="${element_id}_xqa_log">QA</a></div>
% endif
<div><a href="#${element_id}_debug" id="${element_id}_trig">Staff Debug Info</a></div>

<section id="${element_id}_xqa-modal" class="modal xqa-modal" style="width:80%; left:20%; height:80%; overflow:auto" >
  <div class="inner-wrapper">
    <header>
      <h2>edX Content Quality Assessment</h2>
    </header>

    <form id="${element_id}_xqa_form" class="xqa_form">
      <label>Comment</label>
      <input id="${element_id}_xqa_entry" type="text" placeholder="comment">
      <label>Tag</label>
      <span style="color:black;vertical-align: -10pt">Optional tag (eg "done" or "broken"):&nbsp;       </span>
      <input id="${element_id}_xqa_tag" type="text" placeholder="tag" style="width:80px;display:inline">
      <div class="submit">
        <button name="submit" type="submit">Add comment</button>
      </div>
      <hr>
      <div id="${element_id}_xqa_log_data"></div>
    </form>

  </div>
</section>

<section class="modal staff-modal" id="${element_id}_debug" style="width:80%; left:20%; height:80%; overflow:auto;" >
  <div class="inner-wrapper" style="color:black">
    <header>
      <h2>Staff Debug</h2>
    </header>
    <div class="staff_info" style="display:block">
is_released = ${is_released}
location = ${location | h}
github = <a href="${edit_link}">${edit_link | h}</a>
%if source_file:
source_url = <a href="${source_url}">${source_file | h}</a>
%endif
definition = <pre>${definition | h}</pre>
metadata = ${metadata | h}
category = ${category | h}
    </div>
    %if render_histogram:
    <div id="histogram_${element_id}" class="histogram" data-histogram="${histogram}"></div>
    %endif
  </div>
</section>

<div id="${element_id}_setup"></div>

## leanModal needs to be included here otherwise this breaks when in a <vertical>
<script type="text/javascript" src="/static/js/vendor/jquery.leanModal.min.js"></script>

<script type="text/javascript">

function setup_debug_${element_id}(){
    $('#${element_id}_trig').leanModal(); 
    $('#${element_id}_xqa_log').leanModal();		
    $('#${element_id}_xqa_form').submit(sendlog_${element_id});
}
 
setup_debug_${element_id}();

function sendlog_${element_id}(){

    var xqaLog = {authkey: '${xqa_key}',
           location: '${location}',
           %if edit_link:
           giturl: '${edit_link}',
           %endif
           category : '${category}',
           username : '${user.username}',
           return : 'query',
           format : 'html',
           email : '${user.email}',
           tag:$('#${element_id}_xqa_tag').val(),
           entry: $('#${element_id}_xqa_entry').val()};
 
    $.ajax({
        url: '${xqa_server}/log',
        type: 'GET',
        contentType: 'application/json',
        data: JSON.stringify(xqaLog),
        crossDomain: true,
        dataType: 'jsonp',
        beforeSend: function (xhr) { xhr.setRequestHeader ("Authorization", "Basic eHFhOmFnYXJ3YWw="); },
        timeout : 1000,
        success: function(result) {
            $('#${element_id}_xqa_log_data').html(result);
        },
        error: function() {
            alert('Error: cannot connect to XQA server');
            console.log('error!');
        }
    });
    return false;
};
 
function getlog_${element_id}(){

var xqaQuery = {authkey: '${xqa_key}',
           location: '${location}',
           format: 'html'};
 
$.ajax({
        url: '${xqa_server}/query',<commit_msg>Don't call fn before defined. [ie8 is only browser which seems to care.]<commit_after>${module_content}
%if edit_link:
<div><a href="${edit_link}">Edit</a> / <a href="#${element_id}_xqa-modal" onclick="getlog_${element_id}()" id="${element_id}_xqa_log">QA</a></div>
% endif
<div><a href="#${element_id}_debug" id="${element_id}_trig">Staff Debug Info</a></div>

<section id="${element_id}_xqa-modal" class="modal xqa-modal" style="width:80%; left:20%; height:80%; overflow:auto" >
  <div class="inner-wrapper">
    <header>
      <h2>edX Content Quality Assessment</h2>
    </header>

    <form id="${element_id}_xqa_form" class="xqa_form">
      <label>Comment</label>
      <input id="${element_id}_xqa_entry" type="text" placeholder="comment">
      <label>Tag</label>
      <span style="color:black;vertical-align: -10pt">Optional tag (eg "done" or "broken"):&nbsp;       </span>
      <input id="${element_id}_xqa_tag" type="text" placeholder="tag" style="width:80px;display:inline">
      <div class="submit">
        <button name="submit" type="submit">Add comment</button>
      </div>
      <hr>
      <div id="${element_id}_xqa_log_data"></div>
    </form>

  </div>
</section>

<section class="modal staff-modal" id="${element_id}_debug" style="width:80%; left:20%; height:80%; overflow:auto;" >
  <div class="inner-wrapper" style="color:black">
    <header>
      <h2>Staff Debug</h2>
    </header>
    <div class="staff_info" style="display:block">
is_released = ${is_released}
location = ${location | h}
github = <a href="${edit_link}">${edit_link | h}</a>
%if source_file:
source_url = <a href="${source_url}">${source_file | h}</a>
%endif
definition = <pre>${definition | h}</pre>
metadata = ${metadata | h}
category = ${category | h}
    </div>
    %if render_histogram:
    <div id="histogram_${element_id}" class="histogram" data-histogram="${histogram}"></div>
    %endif
  </div>
</section>

<div id="${element_id}_setup"></div>

## leanModal needs to be included here otherwise this breaks when in a <vertical>
<script type="text/javascript" src="/static/js/vendor/jquery.leanModal.min.js"></script>

<script type="text/javascript">

function setup_debug_${element_id}(){
    $('#${element_id}_trig').leanModal(); 
    $('#${element_id}_xqa_log').leanModal();		
    $('#${element_id}_xqa_form').submit(sendlog_${element_id});
}
 
function sendlog_${element_id}(){

    var xqaLog = {authkey: '${xqa_key}',
           location: '${location}',
           %if edit_link:
           giturl: '${edit_link}',
           %endif
           category : '${category}',
           username : '${user.username}',
           return : 'query',
           format : 'html',
           email : '${user.email}',
           tag:$('#${element_id}_xqa_tag').val(),
           entry: $('#${element_id}_xqa_entry').val()};
 
    $.ajax({
        url: '${xqa_server}/log',
        type: 'GET',
        contentType: 'application/json',
        data: JSON.stringify(xqaLog),
        crossDomain: true,
        dataType: 'jsonp',
        beforeSend: function (xhr) { xhr.setRequestHeader ("Authorization", "Basic eHFhOmFnYXJ3YWw="); },
        timeout : 1000,
        success: function(result) {
            $('#${element_id}_xqa_log_data').html(result);
        },
        error: function() {
            alert('Error: cannot connect to XQA server');
            console.log('error!');
        }
    });
    return false;
};

setup_debug_${element_id}();
 
function getlog_${element_id}(){

var xqaQuery = {authkey: '${xqa_key}',
           location: '${location}',
           format: 'html'};
 
$.ajax({
        url: '${xqa_server}/query',
{'fraction_non_alphanumeric': 0.19678269310775204, 'fraction_numerical': 0.007072528082096796, 'mean_word_length': 3.5674477517416086, 'pattern_counts': {'":': 0, '<': 121, '<?xml version=': 0, '>': 121, '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': '6524158', 'n_tokens_mistral': 2433, 'n_tokens_neox': 2395, 'n_words': 455}