From 2288b50152c090131f51f6de2de55baf32b3c9bf Mon Sep 17 00:00:00 2001 From: vitvara Date: Thu, 22 Jul 2021 14:51:14 +0700 Subject: [PATCH 1/9] add ta comment to lib --- lib/ta_comment/check_comment.py | 88 +++++++++++++++++++++++++++++++++ lib/ta_comment/main.py | 26 ++++++++++ 2 files changed, 114 insertions(+) create mode 100644 lib/ta_comment/check_comment.py create mode 100644 lib/ta_comment/main.py diff --git a/lib/ta_comment/check_comment.py b/lib/ta_comment/check_comment.py new file mode 100644 index 0000000..f9189e1 --- /dev/null +++ b/lib/ta_comment/check_comment.py @@ -0,0 +1,88 @@ +import json + +class TAComment: + def __init__(self, filedata) -> None: + + self.filedata = filedata + self.__requried = ["comment","lines"] + self.__start = 0 + self.__end = 0 + self.__startstate = False + self.__string_container = "" + self.__lines_container = [] + self.__lines_num = 0 + self.__status = True + self.__out = "" + + @property + def out(self): + return self.__out + + def run(self): + for line in self.filedata: + self.__lines_num += 1 + self.__condition_state(line) + return self.__lines_container + + def __condition_state(self,line): + if "#>>> :end:" in line and self.__startstate: + self.__have_end(line) + elif self.__startstate: + self.__add_line(line) + elif "#>>> :end:" in line and not self.__startstate: + self.__can_not_find_start(line) + if "#>>> :start:" in line and self.__startstate: + self.__did_not_have_end_point() + if "#>>> :start:" in line: + self.__have_start() + + def __check_comment_syntax(self,data): + return self.__requried != list(data.keys()) + + + def __did_not_have_end_point(self): + self.__out += f"syntax error line:{self.__lines_num-1}\n \n" + self.__status = False + self.__have_start() + + def __have_end(self,line): + self.__end = self.__lines_num + self.__startstate = False + data = self.__org_info(self.__split_line_data(line)) + if self.__check_comment_syntax(data): + self.__not_follow_req(line) + return + data["lines"] = {f"{self.__start}-{self.__end}":self.__string_container} + self.__lines_container.append(data) + + def __not_follow_req(self,line): + self.__out += f"syntax error line:{self.__lines_num}\n" + self.__out += f" \n" + self.__out += f" {line}\n" + self.__status = False + + def __have_start(self): + self.__start = self.__lines_num + self.__string_container = "" + self.__startstate = True + + def __add_line(self,line): + self.__string_container += line + + def __can_not_find_start(self,line): + self.__out += f"syntax error line:{self.__lines_num}\n \n {line}" + self.__status = False + + def __org_info(self,element): + data = {} + for i in element: + pre_data = i.split("=") + data[pre_data[0].strip()] = pre_data[1].strip() + data[f"lines"] = {f"{self.__start}-{self.__end}":self.__lines_container} + return data + + def __split_line_data(self,line): + elementline = line[11:] + element = elementline.split(",") + return element + diff --git a/lib/ta_comment/main.py b/lib/ta_comment/main.py new file mode 100644 index 0000000..7171510 --- /dev/null +++ b/lib/ta_comment/main.py @@ -0,0 +1,26 @@ +from check_comment import TAComment +import os +import json +def ta_comment(path): + std_list = os.listdir(path) + comments = {"comments":[]} + container = {} + traceback = "" + for studir in std_list: + container[studir] = [] + for directory, subdirectories, files in os.walk(os.path.join(path,studir)): + for file in files: + with open(os.path.join(directory, file),"r") as readfile: + filedata = readfile.readlines() + TA = TAComment(filedata) + container[studir].append({file:TA.run()}) + traceback += "=========================\n" + traceback += f"{studir} {file}\n" + traceback += "=========================\n" + traceback += TA.out + print(traceback) + return json.dumps(container,indent=3) + + +with open('readme.txt', 'w') as f: + f.write(ta_comment("test1")) From 2ac15f218692a634d0629190367a94f737df76ac Mon Sep 17 00:00:00 2001 From: vitvara Date: Thu, 22 Jul 2021 14:51:50 +0700 Subject: [PATCH 2/9] remove unuse code on ta comment main --- lib/ta_comment/main.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/ta_comment/main.py b/lib/ta_comment/main.py index 7171510..15f41a5 100644 --- a/lib/ta_comment/main.py +++ b/lib/ta_comment/main.py @@ -21,6 +21,3 @@ def ta_comment(path): print(traceback) return json.dumps(container,indent=3) - -with open('readme.txt', 'w') as f: - f.write(ta_comment("test1")) From d3a7c28129c1dafd69c40f5ede9f6619712dc39a Mon Sep 17 00:00:00 2001 From: vitvara <69972884+vitvara@users.noreply.github.com> Date: Thu, 22 Jul 2021 15:36:48 +0700 Subject: [PATCH 3/9] Create readme.md add readme comment --- lib/ta_comment/readme.md | 52 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 lib/ta_comment/readme.md diff --git a/lib/ta_comment/readme.md b/lib/ta_comment/readme.md new file mode 100644 index 0000000..c463e6a --- /dev/null +++ b/lib/ta_comment/readme.md @@ -0,0 +1,52 @@ +# TA COMMENT + +Because we have a problem that when the students were deducted and wondered where they were deducted, then the +students asked ta one by one, causing difficulty in answer question. So we came up with this idea. + +This feature started out when we saw on github that when we reviewing the code we could tell which line of +code were bugs to the person that respomsible for that project. So we think this the way to solved that problem. But we can't +do exactly like github. Then we have to change somthing to make it compatible with our projects. + +## Examples of use +### how to write comment +``` +#>>> :start: + +### YOUR CODE ### + +#>>> :end: comment=good job +``` + +### how to read comment +``` +from ta_comment.main import ta_comment +print(ta_comment(workpath) +``` + +### what you will get +you will get comments in form of json follow this order studentId -> filename -> comment, lines +``` +{ + "123456789": [ + { + "1.py": [ + { + "comment": "good job", + "lines": { + "15-23": "def create_ta_dir(path):\n ta_path = os.path.join(path, \"ta\")\n if os.path.exists(ta_path):\n return False\n else:\n DirManagement().create_dir(ta_path,out=False)\n return True\n" + } + }, + { + "comment": "good job", + "lines": { + "55-60": "def init_work_directory(path, workid) -> bool:\n config_path = os.path.join(path, \"ta\", \"config.json\")\n ta_path = os.path.join(path, \"ta\")\n draft_path = os.path.join(path, \"ta\", \"draft.json\")\n" + } + } + ] + } + } +``` +- we need to write down comment to student file +- we have our own syntax (you can't change it) +- all comment in student file will be read and send to server when we use `ta submit` (in case that you didn't use this feature on our project ignore this line) + From 60a3aa7694c3c7d3a89bceabe7145ff26401cc03 Mon Sep 17 00:00:00 2001 From: vitvara <69972884+vitvara@users.noreply.github.com> Date: Thu, 22 Jul 2021 21:13:34 +0700 Subject: [PATCH 4/9] Update README.md --- README.md | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 147 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9973d37..8e6e4dd 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,147 @@ -# Admin-CLI -Client +Client 1.0.0 +

Admin-CLI

+ + +

This program is about checking students work in ta's computer and send students score to server by CLI

+ +## Installation + +Use the package manager [pip](https://pip.pypa.io/en/stable/) to install + +### library we use that are not in python standard library +$ pip install requests + +$ pip install -U click + +Let's start the installation process first you need to install library that we mention +then we will clone this github into your local computer + +ssh +> $ git clone git@github.com:ta-assistant/TA-CLI.git + +https +> $ git clone https://github.com/ta-assistant/TA-CLI.git + +and you need to goto TA-CLI directory to install CLI. + + +Goto TA-CLI directory +```bash +$ cd TA-CLI +``` +install CLI ( for more infomation -> [CLI](https://github.com/ta-assistant/TA-CLI/tree/master/ta_cli#readme) ) + +```bash +$ pip install --editable . +``` + +Now you have completed the installation process. + +## How to use +Nowaday we have 4 command that can use. + 1. init [Init TA's work directory Args: workID (str): Work's ID] + 2. login [Login] + 3. start [Start working on TA directory] + 4. submit [Submit] + +first let login we login with apikey that you need to ask server manager to get it then assume that your apikey is `1234567890` +then type command ta login --apikey 1234567890 +```bash +$ ta login --apikey `yourapikey` +``` +then you should get this massage +```bash +~\User\key has been created +~\User\key\taconfig.json has been created. +``` +now your apikey will kept in your User directory +```bash +~/user/key/taconfig +``` +So now you have apikey that in your computer next if you want to check students work you must create new directory that have students work in it when you use our command you must use it in that directory path. In this example I will call it work_directory. + +let's start. I will assume that you already have lot of students work files in your work directory. then type command (this command you need to have work id if you don't know what is work id -> [work_id]) +```bash +$ ta init --workid `work id` +``` +if everything successful, you will receive this message. +``` +[*] ~\Users\dir\work_directory makeing work directory + |-[/] Creating workDirectory ~\Users\dir\work_directory + |-[/] Creating `config.json` + |-[/] Checking API-KEY + |-[/] fetching draft.json ... + | |-[/] API Request + + * statusCode : 200 + * message : Success + * requestId : ***************** + * workDraft : {'outputDraft': ['studentId', 'param1', 'param2', 'comment', 'score', 'scoreTimestamp'], 'fileDraft': '{studentId}_test.zip'} + + | +[/] ~\Users\dir\work_directory is ready +``` +if you don't know what workDraft for -> [work draft] + +now you will have +```bash +$ ./work_directory + ├── stuwork1 + ├── stuwork2 + ├── stuwork3 + . + . + . + └── ta + ├── draft.json + └── config.json + +``` + +if everything is ready now you can use `ta start` ( if something is't ready ta start will send you what is missing ) +``` +ta start +``` +then you will receive this message +``` +Do you want to open vscode?(y/n): n +``` +in this example I choose no but you can choose yes if you want to open student work by vscode. +``` +[*] starting... + |-[/] checking config.json + |-[/] checking draft.json +Do you want to use draft from draft.json or fetch from the server +(R)ead from file or (F)etch from server: r + |-[*] Your workId is 'workId' + |-[*] draft has been written to work.json + |-[/] ~\Users\dir\work_directory\ta\work.json created + | + |-[/] 5 file has processed +[/] finish +``` +> (R)ead from file or (F)etch from server: r +> +> in this line you can choose read or fetch upto you +fetch is for fetching updated draft form server +read is for reading draft.json from ta directory + +(In this example I have 5 file in my working directory) + +Now let's check it! +( it will run every work that follow the draft ) +``` +=========================== +studentId: stuwork1 +=========================== +Enter param1: test +Enter param2: test +Enter comment: test +Enter score: 10 +{'scoreTimestamp': 1626962297679, 'studentId': 'stu1', 'param1': 'test', 'param2': 'test', 'comment': 'test', 'score': 10.0} +has been written down in ~\Users\dir\work_directory\ta\work.json +``` +when check is done and you want to sent it to the server use command ta submit +``` +ta submit +``` From 77dedbecce293d2845049adcbe60b7b7459202ef Mon Sep 17 00:00:00 2001 From: vitvara <69972884+vitvara@users.noreply.github.com> Date: Thu, 22 Jul 2021 21:15:05 +0700 Subject: [PATCH 5/9] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 8e6e4dd..6be9839 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ Client 1.0.0

Admin-CLI

-

This program is about checking students work in ta's computer and send students score to server by CLI

## Installation @@ -38,7 +37,7 @@ $ pip install --editable . Now you have completed the installation process. ## How to use -Nowaday we have 4 command that can use. +#### Available Commands 1. init [Init TA's work directory Args: workID (str): Work's ID] 2. login [Login] 3. start [Start working on TA directory] From c9c582c3537c0a7f4719d9843794c56fd100a815 Mon Sep 17 00:00:00 2001 From: vitvara <69972884+vitvara@users.noreply.github.com> Date: Thu, 22 Jul 2021 21:24:42 +0700 Subject: [PATCH 6/9] Update README.md adding document link --- README.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6be9839..2025c05 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,13 @@ Client 1.0.0

This program is about checking students work in ta's computer and send students score to server by CLI

+## Documentation +* [Installation](#installation) +* [Getting start](#getting-start) + - [Available Commands](#available-commands) + - [Login](#login) + - [Init work directory](#init-work-directory) + - [Start checking work](#start-checking-work) ## Installation Use the package manager [pip](https://pip.pypa.io/en/stable/) to install @@ -36,13 +43,14 @@ $ pip install --editable . Now you have completed the installation process. -## How to use +## Getting start #### Available Commands 1. init [Init TA's work directory Args: workID (str): Work's ID] 2. login [Login] 3. start [Start working on TA directory] 4. submit [Submit] +#### Login first let login we login with apikey that you need to ask server manager to get it then assume that your apikey is `1234567890` then type command ta login --apikey 1234567890 ```bash @@ -58,7 +66,7 @@ now your apikey will kept in your User directory ~/user/key/taconfig ``` So now you have apikey that in your computer next if you want to check students work you must create new directory that have students work in it when you use our command you must use it in that directory path. In this example I will call it work_directory. - +#### Init work directory let's start. I will assume that you already have lot of students work files in your work directory. then type command (this command you need to have work id if you don't know what is work id -> [work_id]) ```bash $ ta init --workid `work id` @@ -96,7 +104,7 @@ $ ./work_directory └── config.json ``` - +#### Start checking work if everything is ready now you can use `ta start` ( if something is't ready ta start will send you what is missing ) ``` ta start From 5e7ce9e87ab6e7385c5e6071080cab1a7584b1a8 Mon Sep 17 00:00:00 2001 From: vitvara <69972884+vitvara@users.noreply.github.com> Date: Thu, 22 Jul 2021 21:27:43 +0700 Subject: [PATCH 7/9] Update README.md --- README.md | 156 +----------------------------------------------------- 1 file changed, 2 insertions(+), 154 deletions(-) diff --git a/README.md b/README.md index 2025c05..9973d37 100644 --- a/README.md +++ b/README.md @@ -1,154 +1,2 @@ -Client 1.0.0 -

Admin-CLI

- -

This program is about checking students work in ta's computer and send students score to server by CLI

- -## Documentation -* [Installation](#installation) -* [Getting start](#getting-start) - - [Available Commands](#available-commands) - - [Login](#login) - - [Init work directory](#init-work-directory) - - [Start checking work](#start-checking-work) -## Installation - -Use the package manager [pip](https://pip.pypa.io/en/stable/) to install - -### library we use that are not in python standard library -$ pip install requests - -$ pip install -U click - -Let's start the installation process first you need to install library that we mention -then we will clone this github into your local computer - -ssh -> $ git clone git@github.com:ta-assistant/TA-CLI.git - -https -> $ git clone https://github.com/ta-assistant/TA-CLI.git - -and you need to goto TA-CLI directory to install CLI. - - -Goto TA-CLI directory -```bash -$ cd TA-CLI -``` -install CLI ( for more infomation -> [CLI](https://github.com/ta-assistant/TA-CLI/tree/master/ta_cli#readme) ) - -```bash -$ pip install --editable . -``` - -Now you have completed the installation process. - -## Getting start -#### Available Commands - 1. init [Init TA's work directory Args: workID (str): Work's ID] - 2. login [Login] - 3. start [Start working on TA directory] - 4. submit [Submit] - -#### Login -first let login we login with apikey that you need to ask server manager to get it then assume that your apikey is `1234567890` -then type command ta login --apikey 1234567890 -```bash -$ ta login --apikey `yourapikey` -``` -then you should get this massage -```bash -~\User\key has been created -~\User\key\taconfig.json has been created. -``` -now your apikey will kept in your User directory -```bash -~/user/key/taconfig -``` -So now you have apikey that in your computer next if you want to check students work you must create new directory that have students work in it when you use our command you must use it in that directory path. In this example I will call it work_directory. -#### Init work directory -let's start. I will assume that you already have lot of students work files in your work directory. then type command (this command you need to have work id if you don't know what is work id -> [work_id]) -```bash -$ ta init --workid `work id` -``` -if everything successful, you will receive this message. -``` -[*] ~\Users\dir\work_directory makeing work directory - |-[/] Creating workDirectory ~\Users\dir\work_directory - |-[/] Creating `config.json` - |-[/] Checking API-KEY - |-[/] fetching draft.json ... - | |-[/] API Request - - * statusCode : 200 - * message : Success - * requestId : ***************** - * workDraft : {'outputDraft': ['studentId', 'param1', 'param2', 'comment', 'score', 'scoreTimestamp'], 'fileDraft': '{studentId}_test.zip'} - - | -[/] ~\Users\dir\work_directory is ready -``` -if you don't know what workDraft for -> [work draft] - -now you will have -```bash -$ ./work_directory - ├── stuwork1 - ├── stuwork2 - ├── stuwork3 - . - . - . - └── ta - ├── draft.json - └── config.json - -``` -#### Start checking work -if everything is ready now you can use `ta start` ( if something is't ready ta start will send you what is missing ) -``` -ta start -``` -then you will receive this message -``` -Do you want to open vscode?(y/n): n -``` -in this example I choose no but you can choose yes if you want to open student work by vscode. -``` -[*] starting... - |-[/] checking config.json - |-[/] checking draft.json -Do you want to use draft from draft.json or fetch from the server -(R)ead from file or (F)etch from server: r - |-[*] Your workId is 'workId' - |-[*] draft has been written to work.json - |-[/] ~\Users\dir\work_directory\ta\work.json created - | - |-[/] 5 file has processed -[/] finish -``` -> (R)ead from file or (F)etch from server: r -> -> in this line you can choose read or fetch upto you -fetch is for fetching updated draft form server -read is for reading draft.json from ta directory - -(In this example I have 5 file in my working directory) - -Now let's check it! -( it will run every work that follow the draft ) -``` -=========================== -studentId: stuwork1 -=========================== -Enter param1: test -Enter param2: test -Enter comment: test -Enter score: 10 -{'scoreTimestamp': 1626962297679, 'studentId': 'stu1', 'param1': 'test', 'param2': 'test', 'comment': 'test', 'score': 10.0} -has been written down in ~\Users\dir\work_directory\ta\work.json -``` -when check is done and you want to sent it to the server use command ta submit -``` -ta submit -``` +# Admin-CLI +Client From 8d773db8ed8d28edc3aa2fc49dd0f987a8f9e54d Mon Sep 17 00:00:00 2001 From: Tanin_dean <70503441+Tanidean@users.noreply.github.com> Date: Thu, 22 Jul 2021 22:33:17 +0700 Subject: [PATCH 8/9] Delete .DS_Store --- src/.DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/.DS_Store diff --git a/src/.DS_Store b/src/.DS_Store deleted file mode 100644 index fbc621c38c918d4f849fcd5d485682ae971e865f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKy-LJD5T4Ztfora?u-wl2zz4`3v9-D4un~;`JxI(UoOK#s!RPQ11Yf}Cu(c5@ zzu6gM_6*pG=nU+ByYsWN`5?PHMC4}cazZpFq7;qM@nAq$J!sleXEwU9Mp<1<=I2el z8d&Ccs(9}^RM481RME!%cb{Wx-Q;;uH3hWk!^z_2_2_ZB=}~^;vAXOtGkH(lOwu0g4Ko?2?U;=dzjJcNJ7_XQqwt}!goP+`;)M<&~BpiCLewkt` zDB#j_d`a*gcQomnpV_yb9|>IM5yffe`DAfgfPt E9nj%O;s5{u From a3be8f2e570e6151896b43ed2ca21a254e3a8ed8 Mon Sep 17 00:00:00 2001 From: vitvara <69972884+vitvara@users.noreply.github.com> Date: Thu, 22 Jul 2021 22:53:55 +0700 Subject: [PATCH 9/9] Update readme.md --- lib/ta_comment/readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ta_comment/readme.md b/lib/ta_comment/readme.md index c463e6a..5570e70 100644 --- a/lib/ta_comment/readme.md +++ b/lib/ta_comment/readme.md @@ -9,7 +9,7 @@ do exactly like github. Then we have to change somthing to make it compatible wi ## Examples of use ### how to write comment -``` +```python #>>> :start: ### YOUR CODE ### @@ -18,7 +18,7 @@ do exactly like github. Then we have to change somthing to make it compatible wi ``` ### how to read comment -``` +```python from ta_comment.main import ta_comment print(ta_comment(workpath) ```