Skip to content

Commit

Permalink
Lessons, lesson and classes being updated for testing authorized actions
Browse files Browse the repository at this point in the history
  • Loading branch information
EstebanMendez01 committed Feb 15, 2024
1 parent 77bdf9c commit 7e81f97
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
18 changes: 17 additions & 1 deletion routes/classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,30 @@ router.get('/:id/details', function (req, res, next) {
});
});

// // Get Lessons
// router.get('/:id/lessons', function (req, res, next) {
// Class.getClassById(req.params.id, function (err, className) {
// if (err) throw err;
// res.render('classes/lessons', { class: className });
// });
// });

// Get Lessons
router.get('/:id/lessons', function (req, res, next) {
Class.getClassById(req.params.id, function (err, className) {
if (err) throw err;
res.render('classes/lessons', { class: className });

// Determine if the user is an instructor
const isInstructor = req.user && req.user.type === 'instructor';

res.render('classes/lessons', { class: className, isInstructor });

// Save changes to the session after rendering the template
req.session.save();
});
});


// Get Lesson
router.get('/:id/lessons/:lesson_id', function (req, res, next) {
Class.getClassById(req.params.id, function (err, className) {
Expand Down
12 changes: 6 additions & 6 deletions views/classes/lesson.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@
</div>


<form>
{{!-- <form>
<h3>Quiz Question:</h3>
<p>What is the capital of France?</p>
<p>What is a String?</p>
<!-- Radio buttons for answer choices -->
<input type="radio" name="quiz" value="paris"> Paris<br>
Expand All @@ -95,7 +95,7 @@
<!-- Button to submit the quiz -->
<input type="submit" value="Submit Answer">
</form>
</form> --}}

<!-- Define the afterPyReplExec function for Lesson 1 -->
<script>
Expand All @@ -119,7 +119,7 @@
}
function processConsoleLog1(log) {
var expected_output = "Hello Python!"; // Replace with the expected output for Lesson 1
var expected_output = "{{lesson.lessson_result_script1}}"; // Replace with the expected output for Lesson 1
if (resultIsCorrect1) {
return;
Expand Down Expand Up @@ -160,7 +160,7 @@
}
function processConsoleLog2(log) {
var expected_output = "Hello Python?"; // Replace with the expected output for Lesson 2
var expected_output = "{{lesson.lessson_result_script2}}"; // Replace with the expected output for Lesson 2
if (resultIsCorrect2) {
return;
Expand Down Expand Up @@ -201,7 +201,7 @@
}
function processConsoleLog3(log) {
var expected_output = "Hello Python."; // Replace with the expected output for Lesson 3
var expected_output = "{{lesson.lessson_result_script3}}"; // Replace with the expected output for Lesson 3
if (resultIsCorrect3) {
return;
Expand Down
4 changes: 3 additions & 1 deletion views/classes/lessons.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
<td>{{lesson_number}}</td>
<td>{{lesson_title}}</td>
<td><a class="view_lesson" href="/classes/{{../class._id}}/lessons/{{lesson_number}}"><button>View Lesson</button></a></td>
{{#if isInstructor}}
<!-- "Edit Lesson" button for instructors -->
{{!-- <td><a class="view_lesson" href="/classes/{{../class._id}}/lessons/{{lesson_number}}/edit"><button>Edit Lesson</button></a></td> --}}
<td><a class="view_lesson" href="/classes/{{../class._id}}/lessons/{{lesson_number}}/edit"><button>Edit Lesson</button></a></td>
{{/if}}
</tr>
{{/each}}
</tbody>
Expand Down

0 comments on commit 7e81f97

Please sign in to comment.