Commit d0ad9642 authored by AravindR-K's avatar AravindR-K

Remove unwanted files and changed the overall candidate level

parent c2e9bafa
require('dotenv').config();
const mongoose = require('mongoose');
const User = require('./models/User');
const checkAdmin = async () => {
try {
// Connect to MongoDB using the URI from .env
const conn = await mongoose.connect(process.env.MONGODB_URI);
console.log(`\n✅ Connected to MongoDB: ${conn.connection.host}`);
// Find users with the role 'admin'
const admins = await User.find({ role: 'admin' }).select('-password'); // Exclude password from logs
if (admins.length > 0) {
console.log(`\n🎉 Found ${admins.length} Admin User(s) in the database:\n`);
console.log(admins);
} else {
console.log('\n❌ No admin users found in the database. When the server starts up, it should automatically create admin@test.com if it doesn\'t exist.');
}
process.exit(0);
} catch (error) {
console.error('\n❌ Error connecting to database or checking admins:');
console.error(error.message);
process.exit(1);
}
};
checkAdmin();
const xlsx = require('xlsx');
const path = require('path');
// Sample quiz data
const questions = [
{ Question: 'What is JavaScript?', Option1: 'A Programming Language', Option2: 'An Operating System', Option3: 'A Database', Option4: 'A Hardware', Correct: 'A Programming Language' },
{ Question: 'Which keyword declares a variable in JS?', Option1: 'var', Option2: 'int', Option3: 'string', Option4: 'dim', Correct: 'var' },
{ Question: 'What does DOM stand for?', Option1: 'Document Object Model', Option2: 'Data Object Model', Option3: 'Document Order Method', Option4: 'Digital Object Memory', Correct: 'Document Object Model' },
{ Question: 'Which is NOT a JS data type?', Option1: 'String', Option2: 'Boolean', Option3: 'Float', Option4: 'Undefined', Correct: 'Float' },
{ Question: 'Which symbols are used for comments in JS?', Option1: '//', Option2: '/* */', Option3: '<!-- -->', Option4: '#', Correct: '//,/* */' },
{ Question: 'What is NaN?', Option1: 'Not a Number', Option2: 'Null and None', Option3: 'New Array Notation', Option4: 'No Active Node', Correct: 'Not a Number' },
{ Question: 'Which method converts JSON to a JS object?', Option1: 'JSON.parse()', Option2: 'JSON.stringify()', Option3: 'JSON.convert()', Option4: 'JSON.toObject()', Correct: 'JSON.parse()' },
{ Question: 'What is the output of typeof null?', Option1: 'object', Option2: 'null', Option3: 'undefined', Option4: 'string', Correct: 'object' },
{ Question: 'Which company developed JavaScript?', Option1: 'Netscape', Option2: 'Microsoft', Option3: 'Google', Option4: 'Apple', Correct: 'Netscape' },
{ Question: 'Which are valid loop types in JS?', Option1: 'for', Option2: 'while', Option3: 'repeat', Option4: 'do-while', Correct: 'for,while,do-while' }
];
const ws = xlsx.utils.json_to_sheet(questions);
const wb = xlsx.utils.book_new();
xlsx.utils.book_append_sheet(wb, ws, 'Questions');
const filePath = path.join(__dirname, 'sample_quiz.xlsx');
xlsx.writeFile(wb, filePath);
console.log(`Sample quiz file created at: ${filePath}`);
console.log(`Total questions: ${questions.length}`);
console.log('Note: Questions 5 and 10 are multi-correct (MCQ) type');
...@@ -303,4 +303,5 @@ router.put('/profile', async (req, res) => { ...@@ -303,4 +303,5 @@ router.put('/profile', async (req, res) => {
} }
}); });
module.exports = router; module.exports = router;
const jwt = require('jsonwebtoken');
const http = require('http');
const JWT_SECRET = 'quiz_app_super_secret_key_2026';
// The admin user id from the previous query was 69d49c922c5d4255f1586365
const token = jwt.sign({ id: '69d49c922c5d4255f1586365', role: 'admin' }, JWT_SECRET, { expiresIn: '1h' });
const data = JSON.stringify({
assigneeIds: ['69dbd7dc839ed359fa93408a', '69e60a415b06f9656a2dc37d']
});
const options = {
hostname: 'localhost',
port: 5000,
path: '/api/admin/quiz/69e88245efc8e25294852356/assign',
method: 'PUT',
headers: {
'Content-Type': 'application/json',
'Content-Length': data.length,
'Authorization': `Bearer ${token}`
}
};
const req = http.request(options, (res) => {
console.log(`STATUS: ${res.statusCode}`);
res.on('data', (chunk) => {
console.log(`BODY: ${chunk}`);
});
});
req.on('error', (e) => {
console.error(`problem with request: ${e.message}`);
});
req.write(data);
req.end();
const mongoose = require('mongoose');
const Quiz = require('./models/Quiz');
require('dotenv').config();
const MONGO_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017/quizapp';
async function check() {
await mongoose.connect(MONGO_URI);
console.log('Connected to DB');
const quiz = await Quiz.findOne({});
if (!quiz) {
console.log('No quiz found');
process.exit(0);
}
console.log('Quiz found:', quiz.title, 'ID:', quiz._id.toString());
console.log('Initial assignees:', quiz.assignees);
// simulate PUT request assignToAll = false, assignees = [some mock id]
const mockId = new mongoose.Types.ObjectId();
quiz.assignToAll = false;
quiz.assignees = [mockId];
await quiz.save();
console.log('Saved assignees:', quiz.assignees);
const reloaded = await Quiz.findById(quiz._id);
console.log('Reloaded assignees:', reloaded.assignees);
await mongoose.disconnect();
}
check().catch(console.error);
const mongoose = require('mongoose');
const Quiz = require('./models/Quiz');
require('dotenv').config();
const MONGO_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017/quizapp';
async function check() {
await mongoose.connect(MONGO_URI);
console.log('Connected to DB');
const quizzes = await Quiz.find({ title: 'React Basics' });
console.log(`Found ${quizzes.length} React Basics quizzes`);
quizzes.forEach(q => {
console.log(`ID: ${q._id}, assignees: ${q.assignees.length}, createdBy: ${q.createdBy}`);
});
await mongoose.disconnect();
}
check().catch(console.error);
const mongoose = require('mongoose');
const Quiz = require('./models/Quiz');
const User = require('./models/User');
require('dotenv').config();
const MONGO_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017/quizapp';
async function check() {
await mongoose.connect(MONGO_URI);
console.log('Connected to DB');
const quiz = await Quiz.findOne({ title: 'React Basics' });
if (!quiz) {
console.log('No React Basics quiz found');
process.exit(0);
}
console.log('Quiz assignees:', quiz.assignees);
const users = await User.find({ role: 'candidate' });
console.log('Candidates IDs:', users.map(u => ({ name: u.name, id: u._id.toString() })));
await mongoose.disconnect();
}
check().catch(console.error);
...@@ -8,7 +8,7 @@ import { QuizService } from '../../../services/quiz.service'; ...@@ -8,7 +8,7 @@ import { QuizService } from '../../../services/quiz.service';
@Component({ @Component({
selector: 'app-hr-users', selector: 'app-hr-users',
standalone: true, standalone: true,
imports: [CommonModule, FormsModule, RouterLink], imports: [CommonModule, FormsModule],
templateUrl: './hr-users.html', templateUrl: './hr-users.html',
styleUrl: './hr-users.css' styleUrl: './hr-users.css'
}) })
......
...@@ -8,7 +8,7 @@ import { DragDropModule, CdkDragDrop } from '@angular/cdk/drag-drop'; ...@@ -8,7 +8,7 @@ import { DragDropModule, CdkDragDrop } from '@angular/cdk/drag-drop';
@Component({ @Component({
selector: 'app-manage-groups', selector: 'app-manage-groups',
standalone: true, standalone: true,
imports: [CommonModule, FormsModule, RouterLink, DragDropModule], imports: [CommonModule, FormsModule, DragDropModule],
templateUrl: './manage-groups.html', templateUrl: './manage-groups.html',
styleUrl: './manage-groups.css' styleUrl: './manage-groups.css'
}) })
......
...@@ -87,11 +87,7 @@ ...@@ -87,11 +87,7 @@
</div> </div>
} }
} }
<div class="evaulation-summary">
<button>
Evaluate Summary
</button>
</div>
</div> </div>
</div> </div>
......
...@@ -20,9 +20,9 @@ export class UserHistoryComponent implements OnInit { ...@@ -20,9 +20,9 @@ export class UserHistoryComponent implements OnInit {
toast = signal<{ message: string; type: 'success' | 'error' } | null>(null); toast = signal<{ message: string; type: 'success' | 'error' } | null>(null);
levels = [ levels = [
{ value: 'beginner', label: 'Beginner' }, { value: 'beginner', label: 'Fresher' },
{ value: 'intermediate', label: 'Intermediate' }, { value: 'intermediate', label: 'Intern' },
{ value: 'advanced', label: 'Advanced' }, { value: 'advanced', label: 'Intermediate' },
{ value: 'expert', label: 'Expert' } { value: 'expert', label: 'Expert' }
]; ];
......
...@@ -20,6 +20,7 @@ color: var(--text-secondary); ...@@ -20,6 +20,7 @@ color: var(--text-secondary);
margin: 0; margin: 0;
} }
.filter-tabs { .filter-tabs {
display: flex; display: flex;
gap: 8px; gap: 8px;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<div class="page-header"> <div class="page-header">
<h1>Student Users</h1> <h1>Student Users</h1>
<p>View and manage registered students</p> <p>View and manage registered students</p>
</div> </div>
<div class="filter-tabs"> <div class="filter-tabs">
......
...@@ -7,7 +7,7 @@ import { DragDropModule, CdkDragDrop } from '@angular/cdk/drag-drop'; ...@@ -7,7 +7,7 @@ import { DragDropModule, CdkDragDrop } from '@angular/cdk/drag-drop';
@Component({ @Component({
selector: 'app-manage-groups', selector: 'app-manage-groups',
imports: [CommonModule, FormsModule, RouterLink, DragDropModule], imports: [CommonModule, FormsModule, DragDropModule],
templateUrl: './manage-groups.html', templateUrl: './manage-groups.html',
styleUrl: './manage-groups.css', styleUrl: './manage-groups.css',
}) })
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
id="name" id="name"
[(ngModel)]="name" [(ngModel)]="name"
name="name" name="name"
placeholder="John Doe" placeholder="Enter your Name"
/> />
</div> </div>
</div> </div>
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
id="email" id="email"
[(ngModel)]="email" [(ngModel)]="email"
name="email" name="email"
placeholder="you&#64;company.com" placeholder="Enter your Email"
autocomplete="email" autocomplete="email"
/> />
</div> </div>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment