<commit_before>{% import _self as self %}

{% if gradeable_id|length %}
    {% set upload_url = upload_url ~ '?g_id=' ~ gradeable_id %}
    {% set rename_url = rename_url ~ '?g_id=' ~ gradeable_id %}
    {% set delete_url = delete_url ~ '?g_id=' ~ gradeable_id %}
{% endif %}

<div class="content">
    <h1>Upload Autograding Config</h1>
    <br><br>
    <p>
        Following the assignment configuration specifications:<br>
        <a href="http://submitty.org/instructor/assignment_configuration">
            http://submitty.org/instructor/assignment_configuration</a><br>
        and examples:<br>
        <a target=_blank href="https://github.com/Submitty/Tutorial/tree/master/examples">Submitty Tutorial example autograding configurations</a><br>
        <a target=_blank href="https://github.com/Submitty/Submitty/tree/master/more_autograding_examples">Additional example autograding configurations</a><br>
    </p>

    <br><br>
    <p>
        Prepare your autograding configuration as a single <code>config.json</code> file.<br>
        Or as a zip of the <code>config.json</code>, and the directories <code>provided_code</code>,
        <code>test_input</code>, <code>instructor_solution</code>, <code>test_output</code>, and/or <code>custom_validation_code</code>.
    </p>

    <br><br>

    <form action="{{ upload_url }}" method="POST" enctype="multipart/form-data">
        <input type="hidden" name="csrf_token" value="{{ csrf_token }}" />
        Upload Config: <input type="file" name="config_upload" /><br />
        <input type="submit" value="Upload" />
    </form>
    <br>
    {% if gradeable_id|length %}
        <a class="btn btn-primary" style="margin-top: 6px" href={{ back_url }}>Go Back To Autograding Page</a>
    {% endif %}
</div>

{% if all_files|length > 0 %}
<div class="content">
    <h2>Previous Uploads</h2>
    <br>
    <b>located in {{ target_dir }}</b>
    <br>&nbsp;<br>
    <script>
        function openRenamePopup(file_path){
            let url = buildCourseUrl(['autograding_config', 'usage']) + '?config_path=' + encodeURIComponent(file_path);
            $('#alert_in_use').html('');
            $('#gradeables_using_config').empty();
            $.ajax({
                url : url,
                success(data){
                    var gradeable_ids = JSON.parse(data)['data'];
                    if(gradeable_ids.length > 0){
                        $('#alert_in_use').html("Note: Currently these gradeables are using this config, rename at your own risk");
                        for(var i = 0; i < gradeable_ids.length; i++){
                            $('#gradeables_using_config').append("<li>" + gradeable_ids[i] + "</li>");<commit_msg>[Feature:InstructorUI] cancel option for uploading autograding configuration (#5140)<commit_after>{% import _self as self %}

{% if gradeable_id|length %}
    {% set upload_url = upload_url ~ '?g_id=' ~ gradeable_id %}
    {% set rename_url = rename_url ~ '?g_id=' ~ gradeable_id %}
    {% set delete_url = delete_url ~ '?g_id=' ~ gradeable_id %}
{% endif %}

<div class="content">
    <h1>Upload Autograding Config</h1>
    <br><br>
    <p>
        Following the assignment configuration specifications:<br>
        <a href="http://submitty.org/instructor/assignment_configuration">
            http://submitty.org/instructor/assignment_configuration</a><br>
        and examples:<br>
        <a target=_blank href="https://github.com/Submitty/Tutorial/tree/master/examples">Submitty Tutorial example autograding configurations</a><br>
        <a target=_blank href="https://github.com/Submitty/Submitty/tree/master/more_autograding_examples">Additional example autograding configurations</a><br>
    </p>

    <br><br>
    <p>
        Prepare your autograding configuration as a single <code>config.json</code> file.<br>
        Or as a zip of the <code>config.json</code>, and the directories <code>provided_code</code>,
        <code>test_input</code>, <code>instructor_solution</code>, <code>test_output</code>, and/or <code>custom_validation_code</code>.
    </p>

    <br><br>

    <form action="{{ upload_url }}" method="POST" enctype="multipart/form-data">
        <input type="hidden" name="csrf_token" value="{{ csrf_token }}" />
        Upload Config: <input type="file" name="config_upload" /><br />
        <input type="submit" value="Upload" /><br />
        <button type='reset'>Cancel Upload</button>
    </form>
    <br>
    
    <br>
    {% if gradeable_id|length %}
        <a class="btn btn-primary" style="margin-top: 6px" href={{ back_url }}>Go Back To Autograding Page</a>
    {% endif %}
</div>

{% if all_files|length > 0 %}
<div class="content">
    <h2>Previous Uploads</h2>
    <br>
    <b>located in {{ target_dir }}</b>
    <br>&nbsp;<br>
    <script>
        function openRenamePopup(file_path){
            let url = buildCourseUrl(['autograding_config', 'usage']) + '?config_path=' + encodeURIComponent(file_path);
            $('#alert_in_use').html('');
            $('#gradeables_using_config').empty();
            $.ajax({
                url : url,
                success(data){
                    var gradeable_ids = JSON.parse(data)['data'];
                    if(gradeable_ids.length > 0){
                        $('#alert_in_use').html("Note: Currently these gradeables are using this config, rename at your own risk");
                        for(var i = 0; i < gradeable_ids.length; i++){
                            $('#gradeables_using_config').append("<li>" + gradeable_ids[i] + "</li>");
{'fraction_non_alphanumeric': 0.16085936089546848, 'fraction_numerical': 0.003610760064993681, 'mean_word_length': 2.951497860199715, 'pattern_counts': {'":': 0, '<': 129, '<?xml version=': 0, '>': 131, 'https://': 4, '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': '245451', 'n_tokens_mistral': 1810, 'n_tokens_neox': 1714, 'n_words': 361}