Skip to content

Commit

Permalink
Merge pull request #32 from ngecu/resolutions
Browse files Browse the repository at this point in the history
Remaining client Intergration
  • Loading branch information
ngecu authored Mar 27, 2024
2 parents 7a6a6e2 + 2b1af76 commit 5da6dad
Show file tree
Hide file tree
Showing 51 changed files with 892 additions and 2,202 deletions.
18 changes: 9 additions & 9 deletions .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MONGO_URI=mongodb+srv://devngecu:[email protected]/
MONGO_URI=
JWT_SECRET = "abc123"
BASE_URL=http://localhost:5173/

Expand All @@ -8,21 +8,21 @@ HOST='smtp.gmail.com'
SERVICE='gmail'
EMAIL_PORT=587
SECURE=true
USER=[email protected]
PASS=falvxbsapmgowzel
USER=
PASS=



# SAFARICOM VARIABLES
BUSINESS_SHORT_CODE = 174379
PASS_KEY = bfb279f9aa9bdbcf158e97dd71a467cd2e0c893059b10f78e6b72ada1ed2c919
CONSUMER_KEY = X2Z6G1kKFjOQ8ttSGVhhrBH4viOdoQF4
CONSUMER_SECRET = lvYbjEgi1Qco6E2h
BUSINESS_SHORT_CODE =
PASS_KEY =
CONSUMER_KEY =
CONSUMER_SECRET =
SAFARICOM_PORT = 6000
PORT = 5000



cliendID=451025251359-813olgkbnta7djitumcbd7m744ejjnf9.apps.googleusercontent.com
clientSecret=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
cliendID=
clientSecret=
NODE_ENV=production
3 changes: 3 additions & 0 deletions backend/controllers/accountantController.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncHandler from 'express-async-handler';
import Accountant from '../models/accountantModel.js';
import User from '../models/userModel.js';
import { sendWelcomeEmail } from '../utils/sendEmail.js';

export const addAccountant = asyncHandler(async (req, res) => {
const password = "accountantPassword123";
Expand Down Expand Up @@ -60,6 +61,8 @@ export const addAccountant = asyncHandler(async (req, res) => {
})

if (user) {
sendWelcomeEmail(user,password,req.headers['user-agent'])

res.status(200).json({
message: "Accountant registered successfully",
})
Expand Down
3 changes: 3 additions & 0 deletions backend/controllers/adminControllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import asyncHandler from 'express-async-handler';
import Admin from '../models/adminModel.js';
import User from '../models/userModel.js';
import { sendWelcomeEmail } from '../utils/sendEmail.js';

// @desc Create a new admin
// @route POST /api/admins
Expand Down Expand Up @@ -64,6 +65,8 @@ export const addAdmin = asyncHandler(async (req, res) => {
});

if (user) {
sendWelcomeEmail(user,password,req.headers['user-agent'])

res.status(200).json({
message: "Admin registered successfully",
});
Expand Down
66 changes: 0 additions & 66 deletions backend/controllers/attendanceController.js

This file was deleted.

24 changes: 24 additions & 0 deletions backend/controllers/examResultController.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,30 @@ export const getExamResultById = asyncHandler(async (req, res) => {
}
});

// @desc Get a single exam result by ID
// @route GET /api/exam-results/:id
// @access Public
export const getExamResultByStudents = asyncHandler(async (req, res) => {
console.log(req.body);
const {students} = req.body;

try {
const examResults = [];
for (const studentId of students) {
console.log("Student ID: ", studentId);
const examResult = await ExamResult.find({ student: studentId }).populate('student exam');
examResults.push(...examResult);
}

res.json(examResults);
} catch (error) {

res.status(500).json({ message: `Server Error : ${error}` });
}
});



// @desc Update an existing exam result
// @route PUT /api/exam-results/:id
// @access Private
Expand Down
3 changes: 2 additions & 1 deletion backend/controllers/lecturerController.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncHandler from 'express-async-handler';
import Lecturer from '../models/lecturerModel.js';
import User from '../models/userModel.js';
import { sendWelcomeEmail } from '../utils/sendEmail.js';

export const addLecturer = asyncHandler(async (req, res) => {
const {
Expand Down Expand Up @@ -57,10 +58,10 @@ export const addLecturer = asyncHandler(async (req, res) => {
email,
password,
userType: "Lecturer",
// Add other relevant fields based on your User schema
});

if (user) {
sendWelcomeEmail(user,password,req.headers['user-agent'])
res.status(200).json({
message: "Lecturer registered successfully",
});
Expand Down
6 changes: 6 additions & 0 deletions backend/controllers/studentController.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Course from '../models/courseModel.js';

import { v4 as uuidv4 } from 'uuid';
import ExamResult from '../models/examResultModel.js';
import { sendWelcomeEmail } from '../utils/sendEmail.js';

export const admitStudent = asyncHandler(async (req, res) => {
try {
Expand Down Expand Up @@ -71,6 +72,10 @@ export const admitStudent = asyncHandler(async (req, res) => {
isActive:true

});

sendWelcomeEmail(user_parent,password,req.headers['user-agent'])


}
}

Expand Down Expand Up @@ -133,6 +138,7 @@ export const admitStudent = asyncHandler(async (req, res) => {
});

if (user) {
sendWelcomeEmail(user,password,req.headers['user-agent'])

const studentId = student._id;

Expand Down
12 changes: 12 additions & 0 deletions backend/requests/examResults.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
GET http://localhost:5000/api/exam-results
Content-Type: application/json
Authorization:Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY2MDE2Zjg2MWYxMzBmYzBhY2QxNDRiYSIsImlhdCI6MTcxMTUyNzYwMiwiZXhwIjoxNzE0MTE5NjAyfQ.v4BwGwcund1mLtOp3NOwceH0GN4OOEnEeQy3ZbkD1h8

###
POST http://localhost:5000/api/exam-results/student/
Content-Type: application/json
Authorization:Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjY2MDE2Zjg2MWYxMzBmYzBhY2QxNDRiYSIsImlhdCI6MTcxMTUyNzYwMiwiZXhwIjoxNzE0MTE5NjAyfQ.v4BwGwcund1mLtOp3NOwceH0GN4OOEnEeQy3ZbkD1h8

{
"students":["66016f851f130fc0acd144b6"]
}
14 changes: 0 additions & 14 deletions backend/routes/attendanceRoutes.js

This file was deleted.

6 changes: 3 additions & 3 deletions backend/routes/examResultRoutes.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import express from 'express'
import { createExam, deleteExam, getAllExams, getExamByCourse, getExamById, updateExam } from '../controllers/examController.js'
import { createExamResult, deleteExamResult, getAllExamResults, getExamResultById, updateExamResult } from '../controllers/examResultController.js'
import { createExamResult, deleteExamResult, getAllExamResults, getExamResultById, getExamResultByStudents, updateExamResult } from '../controllers/examResultController.js'
const router = express.Router()

import { protect, admin } from '../middleware/authMiddleware.js'

router.route('/').post(protect, createExamResult)
router.route('/').get(protect, getAllExamResults)
router.route('/:id').get(protect, getExamResultById)
router.route('/student').post(protect, getExamResultByStudents)
router.route('/:id').put(protect, updateExamResult)
router.route('/:id').delete(protect, deleteExamResult)
router.route('/').post(protect, createExamResult)

export default router
Loading

0 comments on commit 5da6dad

Please sign in to comment.