====== LU04c - Working with GitHub Classroom ====== [[https://youtu.be/f85qDdNDtCw|Video for working with GitHub, Classroom and PyCharm]] ===== Overview ===== For the programming tasks in module 319, we use GitHub Classroom and PyCharm (or a similar development environment). This allows you to learn the most important steps with git and you do not need to upload your solutions separately to Moodle. {{modul:m319:learningunits:lu04:lu04_ablauf_classroom.png?600|}} ===== Prerequisite ===== Before you can work with GitHub Classroom, you must ... * ... have created an account with GitHub. ===== Procedure ===== === 1. accept the assignment === In the Moodle course you will find the link to the assignment in the classroom. {{modul:m319:learningunits:lu04:screenshot_2024-09-10_at_15.56.55.png?800|}} === For the first task in a new module:=== Select your name from the list: {{modul:m319:learningunits:lu04:screenshot_2024-09-10_at_16.04.04.png?400|}} Open this link and accept the //assignment//. {{modul:m319:learningunits:lu04:screenshot_2024-09-10_at_16.09.19.png?600|}} Wait a few seconds and reload the website. You will see the address (URL) of your personal repository. Copy this address. {{modul:m319:learningunits:lu04:screenshot_2024-09-10_at_16.11.09.png?600|}} === 2. clone repository === Now open PyCharm and clone the repository as a new project using the copied link. {{modul:m319:learningunits:lu04:lu04_classroom03.png?800|}} **or** {{modul:m319:learningunits:lu04:lu04_classroom04.png?200|}} Enter the copied URL. If necessary, adjust the folder path in which the project is created. {{modul:m319:learningunits:lu04:lu04_classroom05.png?600|}} You may then need to confirm that you trust this project. {{modul:m319:learningunits:lu04:lu04_classroom06.png?400|}} === 3. set up the virtual environment === The Python virtual environment contains all the external packages that our project requires. Pycharm can set this up automatically for us {{modul:m319:learningunits:lu04:lu04_classroom11.png?600|}} Confirm the setup of the virtual environment with [OK] === 4. solve the task === You now have a local copy of the project on your computer. The project contains several files and folders, only two of which are currently relevant to you: * main.py: The Python script with the task. * main_test.py: A Python script with which you can test your solution. Search in the file ''main.py'' file, find the line with the comment ''# TODO ...''. Change the line according to the instructions in the comment. Then delete the comment. === 5. test the solution === Automated testing of your solution initially has nothing to do with git or GitHub Classroom. It allows you to receive direct feedback on your solution. Open the file ''main_test.py'' and execute the function ''test()'' function. If your solution is correct, you will see the following in the "run" window: ============================= test session starts ============================= collecting ... collected 1 item main_test.py::test PASSED [100%] ============================== 1 passed in 0.01s ============================== If there is still an error in your solution, the output will look something like this: ============================= test session starts ============================= collecting ... collected 1 item main_test.py::test FAILED [100%] main_test.py:2 (test) 'Total: 47.25\n' != 'Total: 78.75\n' Expected :'Total: 78.75\n' Actual :'Total: 47.25\n' === 6. commit === Once you have completed the task, perform a commit. This commits the current status of your files. 1. in the menu, select **git** menu, select the **commit** from the menu. A new view opens: {{modul:m319:learningunits:lu04:lu04_classroom07.png?400|}} 2. in the **commit message** to indicate what you have changed. 3. click on [Commit]. You should now receive a confirmation that the commit was successful. If you end the comment with ''# TODO ...'' you will receive a warning. You can remove the comment and perform the commit again. Alternatively, you can also click on [Commit anyways]. === 7. push === To submit the completed task, perform a **push** of your repository. This uploads the changes from your local repository to GitHub Classroom. 1. in the menu, select **git** menu, select the **push ...** from the menu. A new window opens: {{modul:m319:learningunits:lu04:lu04_classroom08.png?400|}} This window shows you which branch (e.g. master) is sent to which remote repository (e.g. origin). You will learn how to work with different branches later. For now, you can simply accept these settings. 2. click on [Push] and you will receive a confirmation that the push was successful. Sometimes you will receive a message instead of the confirmation that you must first authorise yourself with GitHub. In this case, select [Login via GitHub ...]. This will open a new page in your web browser. === 8. check submission === You can check your submission by viewing your repository in a web browser. To do this, open the link you used for **Clone project** you have created your local project. {{modul:m319:learningunits:lu04:lu04_classroom10.png?400|}} A small symbol shows you whether your solution is correct: * Yellow circle: The check is still running. Wait 1-2 minutes and reload the page. * Red cross: One or more tests have not been successful. Click on the red cross for more detailed information. * Green tick: All tests were successful. ---- {{tag>m319-E1F}} [[https://creativecommons.org/licenses/by-nc-sa/4.0/|{{https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png}}]] Marcel Suter, Kevin Maurizi