-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
336 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
### JetBrains template | ||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
# User-specific stuff | ||
.idea/**/workspace.xml | ||
.idea/**/tasks.xml | ||
.idea/**/dictionaries | ||
.idea/**/shelf | ||
|
||
# Sensitive or high-churn files | ||
.idea/**/dataSources/ | ||
.idea/**/dataSources.ids | ||
.idea/**/dataSources.local.xml | ||
.idea/**/sqlDataSources.xml | ||
.idea/**/dynamic.xml | ||
.idea/**/uiDesigner.xml | ||
.idea/**/dbnavigator.xml | ||
|
||
# Gradle | ||
.idea/**/gradle.xml | ||
.idea/**/libraries | ||
|
||
# CMake | ||
cmake-build-debug/ | ||
cmake-build-release/ | ||
|
||
# Mongo Explorer plugin | ||
.idea/**/mongoSettings.xml | ||
|
||
# File-based project format | ||
*.iws | ||
|
||
# IntelliJ | ||
out/ | ||
|
||
# mpeltonen/sbt-idea plugin | ||
.idea_modules/ | ||
|
||
# JIRA plugin | ||
atlassian-ide-plugin.xml | ||
|
||
# Cursive Clojure plugin | ||
.idea/replstate.xml | ||
|
||
# Crashlytics plugin (for Android Studio and IntelliJ) | ||
com_crashlytics_export_strings.xml | ||
crashlytics.properties | ||
crashlytics-build.properties | ||
fabric.properties | ||
|
||
# Editor-based Rest Client | ||
.idea/httpRequests | ||
### Python template | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
*_ans.py | ||
|
||
data/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# GitHubClassroomAIGrader | ||
# GitHub Classroom AI Grader | ||
After students completed their test or exercise, sometimes teachers must review it one by one and give them the mark. The unit test approach does not work if students cannot submit the runnable code, so it is better to use AI to access their answers and give the objective mark to them. | ||
Using Azure Open AI to score programming practical test. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Extract Answer\n", | ||
"\n", | ||
"Read each student repo and save their source code and number of commit to excel." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%pip install langchain GitPython pandas openpyxl" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from datetime import datetime\n", | ||
"base_folder = \"data/ITE3101_practical_tests/ite-3101-practical-test-ab-submissions/\"\n", | ||
"code_files =[\"lab/lab01/ch01_t01_q1.py\",\"lab/lab01/ch01_t02_q2.py\",\"lab/lab01/ch01_t03_q3.py\",\"lab/lab01/ch01_t04_q4.py\"]\n", | ||
"deadline = datetime.strptime(\"2023-11-27 16:00:00\", \"%Y-%m-%d %H:%M:%S\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"from git import Repo\n", | ||
"\n", | ||
"commit_times = {}\n", | ||
"\n", | ||
"for directory in os.listdir(base_folder):\n", | ||
" directory_path = os.path.join(base_folder, directory)\n", | ||
" if os.path.isdir(directory_path):\n", | ||
" repo = Repo(directory_path)\n", | ||
" last_commit = repo.head.commit\n", | ||
" commit_times[directory] = last_commit.committed_datetime\n", | ||
"\n", | ||
"commit_times\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import pandas as pd\n", | ||
"from pytz import utc\n", | ||
"\n", | ||
"df_commit_times = pd.DataFrame(commit_times.items(), columns=['Directory', 'Commit Time'])\n", | ||
"df_commit_times['Commit Time'] = pd.to_datetime(df_commit_times['Commit Time'], utc=True)\n", | ||
"# Convert deadline to datetime64[ns, UTC]\n", | ||
"deadline = pd.to_datetime(deadline, utc=True)\n", | ||
"df_commit_times['After Deadline'] = df_commit_times['Commit Time'] > deadline\n", | ||
"\n", | ||
"df_commit_times" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"Check any student commit code after the deadline." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"filtered_df = df_commit_times[df_commit_times['After Deadline']]\n", | ||
"filtered_df\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"from git import Repo\n", | ||
"\n", | ||
"def get_number_of_commits(repo_path, file_path):\n", | ||
" repo = Repo(repo_path)\n", | ||
" commits = list(repo.iter_commits(paths=file_path))\n", | ||
" return len(commits)\n", | ||
"\n", | ||
"for code_file in code_files:\n", | ||
" column_name = os.path.basename(code_file)\n", | ||
" file_content = []\n", | ||
" number_of_code_commit = []\n", | ||
" \n", | ||
" for directory in df_commit_times['Directory']:\n", | ||
" file_path = os.path.join(base_folder, directory, code_file) \n", | ||
" if os.path.isfile(file_path):\n", | ||
" with open(file_path, 'r') as file:\n", | ||
" content = file.read()\n", | ||
" file_content.append(content)\n", | ||
" # get the number of GitHub commit for file_path\n", | ||
" number_of_code_commit.append(get_number_of_commits(os.path.join(base_folder, directory), code_file))\n", | ||
" else:\n", | ||
" file_content.append(None)\n", | ||
" number_of_code_commit.append(0)\n", | ||
" df_commit_times[column_name + ' Content'] = file_content\n", | ||
" df_commit_times[column_name + ' Commit'] = number_of_code_commit\n", | ||
"\n", | ||
"\n", | ||
"df_commit_times\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os\n", | ||
"\n", | ||
"# Convert timezone-aware datetime to timezone-naive\n", | ||
"df_commit_times['Commit Time'] = df_commit_times['Commit Time'].dt.tz_convert(None)\n", | ||
"\n", | ||
"excel_file_path = os.path.join(base_folder, 'answer.xlsx')\n", | ||
"df_commit_times.to_excel(excel_file_path, index=False)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.8.10" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |