diff --git a/README.md b/README.md index 21af77f..99c4665 100644 --- a/README.md +++ b/README.md @@ -12,4 +12,6 @@ npm install -g http-server 2. Navigate to the root directory and start the server with: ``` http-server -``` \ No newline at end of file +``` + +3. Access peerprep on http://localhost:8080/ \ No newline at end of file diff --git a/src/index.js b/src/index.js index 49faf53..ad6bf9e 100644 --- a/src/index.js +++ b/src/index.js @@ -28,7 +28,7 @@ document.addEventListener('DOMContentLoaded', function() { var questionCategory = document.getElementById('questionCategory').value; // Set question id - const questionId = getNextId(); + const questionId = 0; // This will be updated in populateTable() // Get question difficulty var questionDifficulty = document.getElementById('questionComplexity').value; @@ -77,7 +77,6 @@ document.addEventListener('DOMContentLoaded', function() { // Clear the table (assuming you have a function to do this) populateTable(); - resetIds(); alert('All questions cleared successfully'); }); @@ -86,15 +85,14 @@ document.addEventListener('DOMContentLoaded', function() { // Add a click event listener to the table body for event delegation tableBody.addEventListener('click', function(event) { - console.log("here"); if (event.target.classList.contains('delete')) { - console.log("there"); // Get all questions from local storage var questions = JSON.parse(localStorage.getItem(ALL_QUESTIONS)); // Get the id of the question to be deleted const idToDelete = parseInt(event.target.getAttribute('data-id'), 10); - + console.log(idToDelete) + console.log(questions) // Delete the question from the array const updatedQuestions = questions.filter(question => question.id !== idToDelete); @@ -152,7 +150,10 @@ function populateTable() { // Update the table body with the questions if (questions !== null) { + var id = 1; questions.forEach(question => { + question.id = id; + id++; var row = document.createElement('tr'); row.innerHTML = `