<commit_before>TestOJ Websocket APIs
================================

The judge will start a websocket server at port 2501.

Sending a `Challenge Request`_ to ``ws://${SERVER_IP}:2501/judge`` will start a challenge. And the result will be sent back by the same websocket connection.


.. _`Challenge Request`:

Challenge Request JSON Format
---------------------

.. code:: python

    ${CHALREQ}
    {
        "chal_id": ${CHALLENGE_ID},
        "code_path": ${CODE_PATH},
        "res_path": ${RES_PATH},
        "comp_type": "c++"|"clang++"|"makefile"|"python3",
        "check_type": "diff"|"ioredir",
        "metadata": ${CHALMETA},
        "test": [${TEST},...]
    }


For details of ``check_type``, see `Diff Check Type`_, `IORedir Check Type`_.


Challenge Response JSON Format
------------------------------

.. code:: python

    ${CHALRESP}
    {
        "chal_id": ${CHALLENGE_ID},<commit_msg>Fix "comp_type": "c++" => "g++"<commit_after>TestOJ Websocket APIs
================================

The judge will start a websocket server at port 2501.

Sending a `Challenge Request`_ to ``ws://${SERVER_IP}:2501/judge`` will start a challenge. And the result will be sent back by the same websocket connection.


.. _`Challenge Request`:

Challenge Request JSON Format
---------------------

.. code:: python

    ${CHALREQ}
    {
        "chal_id": ${CHALLENGE_ID},
        "code_path": ${CODE_PATH},
        "res_path": ${RES_PATH},
        "comp_type": "g++"|"clang++"|"makefile"|"python3",
        "check_type": "diff"|"ioredir",
        "metadata": ${CHALMETA},
        "test": [${TEST},...]
    }


For details of ``check_type``, see `Diff Check Type`_, `IORedir Check Type`_.


Challenge Response JSON Format
------------------------------

.. code:: python

    ${CHALRESP}
    {
        "chal_id": ${CHALLENGE_ID},
{'fraction_non_alphanumeric': 0.2371864776444929, 'fraction_numerical': 0.009814612868047983, 'mean_word_length': 2.633663366336634, 'pattern_counts': {'":': 17, '<': 3, '<?xml version=': 0, '>': 4, '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': '5184394', 'n_tokens_mistral': 625, 'n_tokens_neox': 572, 'n_words': 158}