Skip to content

Instantly share code, notes, and snippets.

@nelisjunior
Last active December 14, 2024 00:10
Show Gist options
  • Save nelisjunior/4563ca6d22c870ac58943c2eb6650b50 to your computer and use it in GitHub Desktop.
Save nelisjunior/4563ca6d22c870ac58943c2eb6650b50 to your computer and use it in GitHub Desktop.
tratamento_gabaritos.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"toc_visible": true,
"authorship_tag": "ABX9TyPNuSWtF/CEgFzWm/JLvrrQ",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/nelisjunior/4563ca6d22c870ac58943c2eb6650b50/tratamento_gabaritos.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "TrnzMTTJF3kS"
},
"outputs": [],
"source": [
"# @title Dados de entrada\n",
"# Cole seu gabarito dentro das pastas\n",
"data = \"\"\"\n",
"1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20\n",
"C C E D E C D A A A D D B B E C * D C E\n",
"21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40\n",
"B E D A B A C C B D E D A B C E C D A B\n",
"41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60\n",
"A B B B D C D C A A E E B A B B B C D C\n",
"61 62 63 64 65 66 67 68 69 70\n",
"D C B A C C D B B B\n",
"\"\"\""
]
},
{
"cell_type": "code",
"source": [
"# @title Limpeza e tratamento do gabarito\n",
"import re\n",
"\n",
"# Remover números, espaços e caracteres que não sejam letras, e obter apenas as letras\n",
"letters = re.findall(r'[A-Z]', data)\n",
"\n",
"# Formatar a lista no estilo solicitado\n",
"formatted_list = \"[\\n '\" + \"', '\".join(letters) + \"',\\n];\"\n",
"\n"
],
"metadata": {
"id": "kdUiO9BKF80Z"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [
"# @title Resultados\n",
"# Resultado\n",
"print(\"const formatted_list = \")\n",
"print(formatted_list)"
],
"metadata": {
"id": "6aLp6FngGSGW"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "markdown",
"source": [
"## Código\n",
"\n",
"Foi utilizado o site [OlhonaVaga](https://olhonavaga.com.br/) para verificação do gabarito.\n",
"Deste modo, o código a baixo funcionará apenas em sites semelhantes\n",
" a ele.\n",
"\n",
"```javascript\n",
"// Função para preencher os campos com base na lista de letras\n",
"\n",
"// COPIE O RESULTADO IMPRIMIDO E COLE AQUI\n",
"\n",
"function preencherCamposComLetras(formatted_list) {\n",
" for (let i = 0; i < letras.length; i++) {\n",
" // Monta o ID do campo com base no índice\n",
" const campoId = `form:j_idt525:${i}:letterIMId`;\n",
" \n",
" // Encontra o campo no DOM\n",
" const campo = document.getElementById(campoId);\n",
" \n",
" // Verifica se o campo existe antes de tentar preencher\n",
" if (campo) {\n",
" campo.value = formatted_list[i]; // Define o valor com a letra da lista\n",
" } else {\n",
" console.warn(`Campo com ID ${campoId} não encontrado.`);\n",
" }\n",
" }\n",
"}\n",
"\n",
"// Chama a função para preencher os campos\n",
"preencherCamposComLetras(formatted_list);\n",
"```"
],
"metadata": {
"id": "HyLTaMpXGj0J"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment