Please try to work through Tasks 0 and 1 ahead of your lab time on Monday. Your team and TA can help you during the lab if you had any trouble, so don't worry if you don't get through Task 1 before lab. There will also be some time to do this as your TA helps everyone get into teams.
- As with the previous lab activities, start by making a fork of this repo and cloning it.
In order to use the Grade API, you will need to use an API Token. To obtain your token, we are going to make a simple request to the Grade API.
- Go to https://hoppscotch.io. This is a tool like Postman, which can be used to quickly interact with APIs.
- Beside the word GET, replace https://echo.hoppscotch.io/ with https://grade-logging-api.chenpan.ca/signUp.
Next, we need to specify the username which we want to sign up with. To do this, we add a parameter.
- In the Parameters tab, choose
+ Add new
and set the parameter name toutorid
. - For its value, choose whatever username you want to use. Make note of the name you choose, as you'll use it during the lab. (Don't worry, you can repeat this process with a new username if you need to later!)
- Press the
Send
button to make the request. You may receive an error that the request didn't go through. Scroll down and selectproxy
as the middleware and pressSend
again. You should now see the result of the request. - If the username had been used before, you will see a response indicating that. Choose a new username and send the request again.
You can also refer to apiDocuments/signUp.md
in this repo for the documentation of this API request.
Alternative to the above: Enter https://grade-logging-api.chenpan.ca/signUp?utorid=USERNAME
in any web browser
with USERNAME
replaced with the username you want to use.
- Create a new file called
username.txt
in the root directory of your project and record your username and API token in that file. This file is indicated in the.gitignore
for your project, so its name will appear yellow in IntelliJ to indicate that git will ignore the file (it won't be version controlled). This can be useful to ensure that you don't accidentally share private information (like personal API tokens) or configurations specific to your local environment when working on a team project.
Now that you have your API token, the last step is to get your program to use it. To do so, we are going to set an environment variable in the run configuration.
-
Try running the main application (
src/main/java/app/gui/GUI
). When you start the program, you will see that it says your API Token is null (since we didn't set it yet). Stop the program and go toRun -> Edit Configurations...
. -
Open the Run Configuration for
GUI
and find theEnvironment Variables:
field. -
In that field, type
API_TOKEN=YOUR_TOKEN
, with YOUR_TOKEN replaced with your actual API Token which you saved inusername.txt
. -
Click
Apply
and thenOK
. -
Now, rerun the program and you should see your API token displayed.
-
Enter a valid grade for
207
in theLog a Grade
menu. You should see a popup telling you that your grade was successfully entered. You can then check your grade by using theGet a Grade
menu and specifying your username and207
for the course.
You are now ready to use the program! The following task will be completed with your team during the lab. First, make sure everyone has successfully completed the steps above.
As a team-building exercise, you will now work together to form a team using this application. Team members in this program are able to view the grades of other team members.
-
Choose a team name. Make it something unique to your team, as other teams will also be picking team names and duplicate names aren't allowed.
-
Have one member of your team form a team with the name your team chose.
-
Each other member of the team should then join the team. Make sure you see the popup confirming that you successfully joined the team.
-
Try looking up the grade another team member entered for
207
using theGet a Grade
menu.
Now that you are all on the team, there is one coding task for your team to work on today!
Note: If your team finds it convenient to work on parts of this lab on a common machine,
you can create different run configurations (copy an existing one) which each use a different
API_TOKEN
environment variable. Then you can run multiple instances of the program and
enter requests as different users.
While this program has some useful core functionality which is provided by the Grade API, there are certain things which the Grade API can't currently do.
-
As a team, brainstorm some potential additional features which this program could have. Aim to come up with one feature per team member.
-
For each feature, think about whether it is possible to implement, given the current functionality provided by the Grade API. If it isn't possible, identify what new capabilities would need to be added. And if it is possible, think about what the steps would need to be taken to implement the feature in the program.
-
You may have noticed that the functionality for
My Team -> Get Average Grade
isn't actually implemented yet (see the TODOs in the code). As a team, work to implement this feature and confirm that it works.
Note: Your team can choose how you want to work on this part, but below is our suggestions.
Suggested logistics: One of you should invite the others to collaborate on their fork of the
original repo on GitHub. You can do this in your repo on GitHub under Settings -> Collaborators
.
This will allow you to push branches to a common repo and then use pull requests to contribute
your code and review.
If your team finishes the above task and has extra time, we encourage you to go through the code base in more detail and think critically about the structure of the code. What strikes you as being good design? What feels like it could be improved or restructured to make the code better? How easy would it be to implement new functionality into the program?
In lecture this week, we will finish our initial tour of Clean Architecture with a full example designed with Clean Architecture in mind. You might find it useful to revisit this code base after to see what parts align with Clean Architecture and which parts do not.