Unclear instructions

This has got to be the worst set of instructions I have encountered in any course. It is not clear what I’m supposed to do, what code I’m supposed to edit … as a student, I should not have to fumble around just to determine whether I can answer a question or not.

Can you be more specific about which parts you do not understand? As stated, it is unclear what is unclear for you and nobody can help you.

For example, Chapter 2 - Ticket: User management

The instructions are:

For this Ticket, you’ll be required to implement all the methods in usersDAO.js that are called by the API endpoints in users.controller.js. Specifically, you’ll implement:

*** getUser**
*** addUser**
*** loginUser**
*** logoutUser**
*** getUserSession**
Look within the user-management.test.js file to view the unit tests for this ticket

In user-management.test.js, I see user credentials:

const testUser = {
name: “Magical Mr. Mistoffelees”,
email: "magicz@cats.com",
password: “somehashedpw”,
}

Am I supposed to use these credentials in the following manner:

await users.insertOne({
name: “Magical Mr. Mistoffelees”,
email: "magicz@cats.com",
password: “somehashedpw”, })
return { success: true }

If so, how will the application work with hard coded values in?

Would it not be easier to leave out the add function and ask the students to write one? In M121, that is what the instructors ask us to do. As hard as that course is, at least the instructions are clear i.e. ‘… construct a pipeline that should result in some result’.

The code in the DAO files looks complete. So is my task just to copy and paste?

==== just to add, below is the code from your answer to the ticket
static async addUser(userInfo) {
try {
await users.insertOne({ …userInfo })
return { success: true }
} catch (e) {
if (String(e).startsWith(“MongoError: E11000 duplicate key error”)) {
return { error: “A user with the given email already exists.” }
}
console.error(Error occurred while adding new user, ${e}.)
return { error: e }
}
}

where does the variable ‘userInfo’ come from?

Go back and read the instructions. They ask to go in usersDAO.js and yet you go in user-management.test.js. In the latter, just like in any unit tests, they use hard-coded values if your code in usersDAO.js is working fine. You have to implement the requested methods getUser … in the requested files.

As for userInfo in addUser, it looks like it is a parameter.

3 Likes