update
This commit is contained in:
parent
85170c8dfa
commit
3ae6d66dbd
@ -2591,6 +2591,62 @@ class Document(Base):
|
||||
return ""
|
||||
|
||||
|
||||
class InterviewQuestion(models.Model):
|
||||
"""Model to store AI-generated interview questions"""
|
||||
|
||||
class QuestionType(models.TextChoices):
|
||||
TECHNICAL = "technical", _("Technical")
|
||||
BEHAVIORAL = "behavioral", _("Behavioral")
|
||||
SITUATIONAL = "situational", _("Situational")
|
||||
|
||||
schedule = models.ForeignKey(
|
||||
'ScheduledInterview',
|
||||
on_delete=models.CASCADE,
|
||||
related_name="ai_questions",
|
||||
verbose_name=_("Interview Schedule")
|
||||
)
|
||||
question_text = models.TextField(
|
||||
verbose_name=_("Question Text")
|
||||
)
|
||||
question_type = models.CharField(
|
||||
max_length=20,
|
||||
choices=QuestionType.choices,
|
||||
default=QuestionType.TECHNICAL,
|
||||
verbose_name=_("Question Type")
|
||||
)
|
||||
difficulty_level = models.CharField(
|
||||
max_length=20,
|
||||
choices=[
|
||||
("easy", _("Easy")),
|
||||
("medium", _("Medium")),
|
||||
("hard", _("Hard")),
|
||||
],
|
||||
default="medium",
|
||||
verbose_name=_("Difficulty Level")
|
||||
)
|
||||
category = models.CharField(
|
||||
max_length=100,
|
||||
blank=True,
|
||||
verbose_name=_("Category")
|
||||
)
|
||||
created_at = models.DateTimeField(
|
||||
auto_now_add=True,
|
||||
verbose_name=_("Created At")
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = _("Interview Question")
|
||||
verbose_name_plural = _("Interview Questions")
|
||||
ordering = ["created_at"]
|
||||
indexes = [
|
||||
models.Index(fields=["schedule", "question_type"]),
|
||||
models.Index(fields=["created_at"]),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.get_question_type_display()} Question for {self.schedule}"
|
||||
|
||||
|
||||
class Settings(Base):
|
||||
"""Model to store key-value pair settings"""
|
||||
name = models.CharField(
|
||||
|
||||
@ -142,22 +142,14 @@ def create_default_stages(sender, instance, created, **kwargs):
|
||||
if created:
|
||||
with transaction.atomic():
|
||||
# Stage 1: Contact Information
|
||||
contact_stage = FormStage.objects.create(
|
||||
resume_upload = FormStage.objects.create(
|
||||
template=instance,
|
||||
name="Contact Information",
|
||||
name="Resume Upload",
|
||||
order=0,
|
||||
is_predefined=True,
|
||||
)
|
||||
FormField.objects.create(
|
||||
stage=contact_stage,
|
||||
label="GPA",
|
||||
field_type="text",
|
||||
required=False,
|
||||
order=1,
|
||||
is_predefined=True,
|
||||
)
|
||||
FormField.objects.create(
|
||||
stage=contact_stage,
|
||||
stage=resume_upload,
|
||||
label="Resume Upload",
|
||||
field_type="file",
|
||||
required=True,
|
||||
|
||||
@ -1565,16 +1565,152 @@ def send_email_task(
|
||||
"message": f"Attempted to send email to {len(recipient_emails)} recipients. Service reported processing {processed_count}."
|
||||
})
|
||||
|
||||
# def send_single_email_task(
|
||||
# recipient_emails,
|
||||
# subject: str,
|
||||
# template_name: str,
|
||||
# context: dict,
|
||||
# ) -> str:
|
||||
# """
|
||||
# Django-Q task to send a bulk email asynchronously.
|
||||
# """
|
||||
# from .services.email_service import EmailService
|
||||
def generate_interview_questions(schedule_id: int) -> dict:
|
||||
"""
|
||||
Generate AI-powered interview questions based on job requirements and candidate profile.
|
||||
|
||||
Args:
|
||||
schedule_id (int): The ID of the scheduled interview
|
||||
|
||||
Returns:
|
||||
dict: Result containing status and generated questions or error message
|
||||
"""
|
||||
from .models import ScheduledInterview, InterviewQuestion
|
||||
|
||||
try:
|
||||
# Get the scheduled interview with related data
|
||||
schedule = ScheduledInterview.objects.get(pk=schedule_id)
|
||||
application = schedule.application
|
||||
job = schedule.job
|
||||
|
||||
logger.info(f"Generating interview questions for schedule {schedule_id}")
|
||||
|
||||
# Prepare context for AI
|
||||
job_description = job.description or ""
|
||||
job_qualifications = job.qualifications or ""
|
||||
candidate_resume_text = ""
|
||||
|
||||
# Extract candidate resume text if available and parsed
|
||||
if application.ai_analysis_data:
|
||||
resume_data_en = application.ai_analysis_data.get('resume_data_en', {})
|
||||
candidate_resume_text = f"""
|
||||
Candidate Name: {resume_data_en.get('full_name', 'N/A')}
|
||||
Current Title: {resume_data_en.get('current_title', 'N/A')}
|
||||
Summary: {resume_data_en.get('summary', 'N/A')}
|
||||
Skills: {resume_data_en.get('skills', {})}
|
||||
Experience: {resume_data_en.get('experience', [])}
|
||||
Education: {resume_data_en.get('education', [])}
|
||||
"""
|
||||
|
||||
# Create the AI prompt
|
||||
prompt = f"""
|
||||
You are an expert technical interviewer and hiring manager. Generate relevant interview questions based on the following information:
|
||||
|
||||
JOB INFORMATION:
|
||||
Job Title: {job.title}
|
||||
Department: {job.department}
|
||||
Job Description: {job_description}
|
||||
Qualifications: {job_qualifications}
|
||||
|
||||
CANDIDATE PROFILE:
|
||||
{candidate_resume_text}
|
||||
|
||||
TASK:
|
||||
Generate 8-10 interview questions that are:
|
||||
1. Technical questions related to the job requirements
|
||||
2. Behavioral questions to assess soft skills and cultural fit
|
||||
3. Situational questions to evaluate problem-solving abilities
|
||||
4. Questions should be appropriate for the candidate's experience level
|
||||
|
||||
For each question, specify:
|
||||
- Type: "technical", "behavioral", or "situational"
|
||||
- Difficulty: "easy", "medium", or "hard"
|
||||
- Category: A brief category name (e.g., "Python Programming", "Team Collaboration", "Problem Solving")
|
||||
- Question: The actual interview question
|
||||
|
||||
OUTPUT FORMAT:
|
||||
Return a JSON object with the following structure:
|
||||
{{
|
||||
"questions": [
|
||||
{{
|
||||
"question_text": "The actual question text",
|
||||
"question_type": "technical|behavioral|situational",
|
||||
"difficulty_level": "easy|medium|hard",
|
||||
"category": "Category name"
|
||||
}}
|
||||
]
|
||||
}}
|
||||
|
||||
Make questions specific to the job requirements and candidate background. Avoid generic questions.
|
||||
"""
|
||||
|
||||
# Call AI handler
|
||||
result = ai_handler(prompt)
|
||||
|
||||
if result["status"] == "error":
|
||||
logger.error(f"AI handler returned error for interview questions: {result['data']}")
|
||||
return {"status": "error", "message": "Failed to generate questions"}
|
||||
|
||||
# Parse AI response
|
||||
data = result["data"]
|
||||
if isinstance(data, str):
|
||||
data = json.loads(data)
|
||||
|
||||
questions = data.get("questions", [])
|
||||
|
||||
if not questions:
|
||||
return {"status": "error", "message": "No questions generated"}
|
||||
|
||||
# Clear existing questions for this schedule
|
||||
InterviewQuestion.objects.filter(schedule=schedule).delete()
|
||||
|
||||
# Save generated questions to database
|
||||
created_questions = []
|
||||
for q_data in questions:
|
||||
question = InterviewQuestion.objects.create(
|
||||
schedule=schedule,
|
||||
question_text=q_data.get("question_text", ""),
|
||||
question_type=q_data.get("question_type", "technical"),
|
||||
difficulty_level=q_data.get("difficulty_level", "medium"),
|
||||
category=q_data.get("category", "General")
|
||||
)
|
||||
created_questions.append({
|
||||
"id": question.id,
|
||||
"text": question.question_text,
|
||||
"type": question.question_type,
|
||||
"difficulty": question.difficulty_level,
|
||||
"category": question.category
|
||||
})
|
||||
|
||||
logger.info(f"Successfully generated {len(created_questions)} questions for schedule {schedule_id}")
|
||||
|
||||
return {
|
||||
"status": "success",
|
||||
"questions": created_questions,
|
||||
"message": f"Generated {len(created_questions)} interview questions"
|
||||
}
|
||||
|
||||
except ScheduledInterview.DoesNotExist:
|
||||
error_msg = f"Scheduled interview with ID {schedule_id} not found"
|
||||
logger.error(error_msg)
|
||||
return {"status": "error", "message": error_msg}
|
||||
|
||||
except Exception as e:
|
||||
error_msg = f"Error generating interview questions: {str(e)}"
|
||||
logger.error(error_msg, exc_info=True)
|
||||
return {"status": "error", "message": error_msg}
|
||||
|
||||
|
||||
def send_single_email_task(
|
||||
recipient_emails,
|
||||
subject: str,
|
||||
template_name: str,
|
||||
context: dict,
|
||||
) -> str:
|
||||
"""
|
||||
Django-Q task to send a bulk email asynchronously.
|
||||
"""
|
||||
from .services.email_service import EmailService
|
||||
|
||||
# if not recipient_emails:
|
||||
# return json.dumps({"status": "error", "message": "No recipients provided."})
|
||||
@ -1589,9 +1725,9 @@ def send_email_task(
|
||||
# context=context,
|
||||
# )
|
||||
|
||||
# # The return value is stored in the result object for monitoring
|
||||
# return json.dumps({
|
||||
# "status": "success",
|
||||
# "count": processed_count,
|
||||
# "message": f"Attempted to send email to {len(recipient_emails)} recipients. Service reported processing {processed_count}."
|
||||
# })
|
||||
# The return value is stored in the result object for monitoring
|
||||
return json.dumps({
|
||||
"status": "success",
|
||||
"count": processed_count,
|
||||
"message": f"Attempted to send email to {len(recipient_emails)} recipients. Service reported processing {processed_count}."
|
||||
})
|
||||
|
||||
@ -82,6 +82,7 @@ urlpatterns = [
|
||||
# Interview CRUD Operations
|
||||
path("interviews/", views.interview_list, name="interview_list"),
|
||||
path("interviews/<slug:slug>/", views.interview_detail, name="interview_detail"),
|
||||
path("interviews/<slug:slug>/generate-ai-questions/", views.generate_ai_questions, name="generate_ai_questions"),
|
||||
path("interviews/<slug:slug>/update_interview_status", views.update_interview_status, name="update_interview_status"),
|
||||
path("interviews/<slug:slug>/update_interview_result", views.update_interview_result, name="update_interview_result"),
|
||||
|
||||
|
||||
@ -4801,6 +4801,57 @@ def interview_list(request):
|
||||
return render(request, "interviews/interview_list.html", context)
|
||||
|
||||
|
||||
@login_required
|
||||
@staff_user_required
|
||||
def generate_ai_questions(request, slug):
|
||||
"""Generate AI-powered interview questions for a scheduled interview"""
|
||||
from django_q.tasks import async_task
|
||||
from .models import InterviewQuestion
|
||||
|
||||
schedule = get_object_or_404(ScheduledInterview, slug=slug)
|
||||
|
||||
if request.method == "POST":
|
||||
# Queue the AI question generation task
|
||||
task_id = async_task(
|
||||
"recruitment.tasks.generate_interview_questions",
|
||||
schedule.id
|
||||
)
|
||||
|
||||
if request.headers.get("X-Requested-With") == "XMLHttpRequest":
|
||||
return JsonResponse({
|
||||
"status": "success",
|
||||
"message": "AI question generation started in background",
|
||||
"task_id": task_id
|
||||
})
|
||||
else:
|
||||
messages.success(
|
||||
request,
|
||||
"AI question generation started. Questions will appear shortly."
|
||||
)
|
||||
return redirect("interview_detail", slug=slug)
|
||||
|
||||
# For GET requests, return existing questions if any
|
||||
questions = schedule.ai_questions.all().order_by("created_at")
|
||||
|
||||
if request.headers.get("X-Requested-With") == "XMLHttpRequest":
|
||||
return JsonResponse({
|
||||
"status": "success",
|
||||
"questions": [
|
||||
{
|
||||
"id": q.id,
|
||||
"text": q.question_text,
|
||||
"type": q.question_type,
|
||||
"difficulty": q.difficulty_level,
|
||||
"category": q.category,
|
||||
"created_at": q.created_at.isoformat()
|
||||
}
|
||||
for q in questions
|
||||
]
|
||||
})
|
||||
|
||||
return redirect("interview_detail", slug=slug)
|
||||
|
||||
|
||||
@login_required
|
||||
@staff_user_required
|
||||
def interview_detail(request, slug):
|
||||
@ -4824,9 +4875,9 @@ def interview_detail(request, slug):
|
||||
reschedule_form = OnsiteScheduleInterviewUpdateForm()
|
||||
reschedule_form.initial["physical_address"] = interview.physical_address
|
||||
reschedule_form.initial["room_number"] = interview.room_number
|
||||
reschedule_form.initial["topic"] = interview.topic
|
||||
reschedule_form.initial["start_time"] = interview.start_time
|
||||
reschedule_form.initial["duration"] = interview.duration
|
||||
reschedule_form.initial["topic"] = interview.topic
|
||||
reschedule_form.initial["start_time"] = interview.start_time
|
||||
reschedule_form.initial["duration"] = interview.duration
|
||||
|
||||
meeting = interview
|
||||
interview_email_form = InterviewEmailForm(job, application, schedule)
|
||||
|
||||
@ -192,6 +192,126 @@
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
/* AI Questions Styling */
|
||||
.ai-question-item {
|
||||
background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
|
||||
border: 1px solid var(--kaauh-border);
|
||||
border-radius: 0.75rem;
|
||||
padding: 1.25rem;
|
||||
margin-bottom: 1rem;
|
||||
position: relative;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
.ai-question-item:hover {
|
||||
box-shadow: 0 6px 16px rgba(0,0,0,0.08);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
.ai-question-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 0.75rem;
|
||||
}
|
||||
.ai-question-badges {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.ai-question-badge {
|
||||
font-size: 0.75rem;
|
||||
padding: 0.25rem 0.5rem;
|
||||
border-radius: 0.25rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
}
|
||||
.badge-technical {
|
||||
background-color: #e3f2fd;
|
||||
color: #1976d2;
|
||||
}
|
||||
.badge-behavioral {
|
||||
background-color: #f3e5f5;
|
||||
color: #7b1fa2;
|
||||
}
|
||||
.badge-situational {
|
||||
background-color: #e8f5e8;
|
||||
color: #388e3c;
|
||||
}
|
||||
.badge-easy {
|
||||
background-color: #e8f5e8;
|
||||
color: #2e7d32;
|
||||
}
|
||||
.badge-medium {
|
||||
background-color: #fff3e0;
|
||||
color: #f57c00;
|
||||
}
|
||||
.badge-hard {
|
||||
background-color: #ffebee;
|
||||
color: #c62828;
|
||||
}
|
||||
.ai-question-text {
|
||||
font-size: 1rem;
|
||||
line-height: 1.6;
|
||||
color: var(--kaauh-primary-text);
|
||||
margin-bottom: 0.75rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
.ai-question-meta {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
font-size: 0.85rem;
|
||||
color: #6c757d;
|
||||
border-top: 1px solid #e9ecef;
|
||||
padding-top: 0.5rem;
|
||||
}
|
||||
.ai-question-category {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
.ai-question-category i {
|
||||
color: var(--kaauh-teal);
|
||||
}
|
||||
.ai-question-actions {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.ai-question-actions button {
|
||||
padding: 0.25rem 0.5rem;
|
||||
font-size: 0.8rem;
|
||||
border-radius: 0.25rem;
|
||||
border: 1px solid var(--kaauh-border);
|
||||
background-color: white;
|
||||
color: var(--kaauh-primary-text);
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
.ai-question-actions button:hover {
|
||||
background-color: var(--kaauh-teal);
|
||||
color: white;
|
||||
border-color: var(--kaauh-teal);
|
||||
}
|
||||
.ai-questions-empty {
|
||||
text-align: center;
|
||||
padding: 3rem 1rem;
|
||||
color: #6c757d;
|
||||
}
|
||||
.ai-questions-empty i {
|
||||
color: var(--kaauh-teal);
|
||||
opacity: 0.6;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.ai-questions-loading {
|
||||
text-align: center;
|
||||
padding: 2rem;
|
||||
}
|
||||
.htmx-indicator {
|
||||
display: none;
|
||||
}
|
||||
.htmx-indicator.htmx-request {
|
||||
display: block;
|
||||
}
|
||||
|
||||
/* Responsive adjustments */
|
||||
@media (max-width: 768px) {
|
||||
.action-buttons {
|
||||
@ -200,6 +320,19 @@
|
||||
.action-buttons .btn {
|
||||
width: 100%;
|
||||
}
|
||||
.ai-question-header {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.ai-question-badges {
|
||||
width: 100%;
|
||||
}
|
||||
.ai-question-meta {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
@ -292,7 +425,7 @@
|
||||
<i class="fas fa-calendar-check me-2"></i> {% trans "Interview Details" %}
|
||||
</h5>
|
||||
<div class="d-flex gap-2">
|
||||
|
||||
|
||||
<span class="bg-primary-theme badge status-badge text-white">
|
||||
{{interview.location_type}}
|
||||
</span>
|
||||
@ -378,6 +511,56 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- AI Generated Questions Section -->
|
||||
<div class="kaauh-card shadow-sm p-4 mb-4">
|
||||
<div class="d-flex align-items-center justify-content-between mb-3">
|
||||
<h5 class="mb-0" style="color: var(--kaauh-teal-dark); font-weight: 600;">
|
||||
<i class="fas fa-brain me-2"></i> {% trans "AI Generated Questions" %}
|
||||
</h5>
|
||||
<div class="d-flex gap-2">
|
||||
<button type="button"
|
||||
class="btn btn-main-action btn-sm"
|
||||
id="generateQuestionsBtn"
|
||||
hx-post="{% url 'generate_ai_questions' schedule.slug %}"
|
||||
hx-target="#aiQuestionsContainer"
|
||||
hx-indicator="#generateQuestionsSpinner">
|
||||
<i class="fas fa-magic me-1"></i> {% trans "Generate Questions" %}
|
||||
</button>
|
||||
<button type="button"
|
||||
class="btn btn-outline-secondary btn-sm"
|
||||
id="refreshQuestionsBtn"
|
||||
hx-get="{% url 'generate_ai_questions' schedule.slug %}"
|
||||
hx-target="#aiQuestionsContainer"
|
||||
hx-indicator="#refreshQuestionsSpinner">
|
||||
<i class="fas fa-sync-alt me-1"></i> {% trans "Refresh" %}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Loading Spinners -->
|
||||
<div class="text-center py-3" id="generateQuestionsSpinner" class="htmx-indicator d-none">
|
||||
<div class="spinner-border text-primary" role="status">
|
||||
<span class="visually-hidden">{% trans "Generating questions..." %}</span>
|
||||
</div>
|
||||
<p class="mt-2 text-muted">{% trans "AI is generating personalized interview questions..." %}</p>
|
||||
</div>
|
||||
|
||||
<div class="text-center py-3" id="refreshQuestionsSpinner" class="htmx-indicator d-none">
|
||||
<div class="spinner-border text-secondary" role="status">
|
||||
<span class="visually-hidden">{% trans "Refreshing..." %}</span>
|
||||
</div>
|
||||
<p class="mt-2 text-muted">{% trans "Loading questions..." %}</p>
|
||||
</div>
|
||||
|
||||
<!-- Questions Container -->
|
||||
<div id="aiQuestionsContainer">
|
||||
<div class="text-center py-4 text-muted">
|
||||
<i class="fas fa-brain fa-2x mb-3"></i>
|
||||
<p class="mb-0">{% trans "No AI questions generated yet. Click 'Generate Questions' to create personalized interview questions based on the candidate's profile and job requirements." %}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="kaauh-card shadow-sm p-4">
|
||||
<h5 class="mb-3" style="color: var(--kaauh-teal-dark); font-weight: 600;">
|
||||
<i class="fas fa-history me-2"></i> {% trans "Interview Timeline" %}
|
||||
@ -394,7 +577,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{% if schedule.status == 'confirmed' %}
|
||||
<div class="timeline-item">
|
||||
<div class="timeline-content">
|
||||
@ -403,7 +586,7 @@
|
||||
<h6 class="mb-1">{% trans "Interview Confirmed" %}</h6>
|
||||
<p class="mb-0 text-muted">{% trans "Candidate has confirmed attendance" %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -416,7 +599,7 @@
|
||||
<h6 class="mb-1">{% trans "Interview Completed" %}</h6>
|
||||
<p class="mb-0 text-muted">{% trans "Interview has been completed" %}</p>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -429,7 +612,7 @@
|
||||
<h6 class="mb-1">{% trans "Interview Cancelled" %}</h6>
|
||||
<p class="mb-0 text-muted">{% trans "Interview was cancelled on: " %}{{ schedule.cancelled_at|date:"d-m-Y" }} {{ schedule.cancelled_at|date:"h:i A" }}</p>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -490,7 +673,7 @@
|
||||
<i class="fas fa-user-plus me-1"></i> {% trans "Add Participants" %}
|
||||
</button>
|
||||
</div> {% endcomment %}
|
||||
|
||||
|
||||
|
||||
<div class="kaauh-card shadow-sm p-4">
|
||||
<h5 class="mb-3" style="color: var(--kaauh-teal-dark); font-weight: 600;">
|
||||
@ -759,4 +942,4 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
170
templates/interviews/partials/ai_questions_list.html
Normal file
170
templates/interviews/partials/ai_questions_list.html
Normal file
@ -0,0 +1,170 @@
|
||||
{% load i18n %}
|
||||
|
||||
{% if questions %}
|
||||
{% for question in questions %}
|
||||
<div class="ai-question-item">
|
||||
<div class="ai-question-header">
|
||||
<div class="ai-question-badges">
|
||||
<span class="ai-question-badge badge-{{ question.type|lower }}">
|
||||
{% if question.type == 'Technical' %}
|
||||
<i class="fas fa-code me-1"></i>
|
||||
{% elif question.type == 'Behavioral' %}
|
||||
<i class="fas fa-users me-1"></i>
|
||||
{% elif question.type == 'Situational' %}
|
||||
<i class="fas fa-lightbulb me-1"></i>
|
||||
{% endif %}
|
||||
{{ question.type }}
|
||||
</span>
|
||||
<span class="ai-question-badge badge-{{ question.difficulty|lower }}">
|
||||
{% if question.difficulty == 'Easy' %}
|
||||
<i class="fas fa-smile me-1"></i>
|
||||
{% elif question.difficulty == 'Medium' %}
|
||||
<i class="fas fa-meh me-1"></i>
|
||||
{% elif question.difficulty == 'Hard' %}
|
||||
<i class="fas fa-frown me-1"></i>
|
||||
{% endif %}
|
||||
{{ question.difficulty }}
|
||||
</span>
|
||||
{% if question.category %}
|
||||
<span class="ai-question-badge badge-technical">
|
||||
<i class="fas fa-tag me-1"></i>
|
||||
{{ question.category }}
|
||||
</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ai-question-text">
|
||||
{{ question.text|linebreaksbr }}
|
||||
</div>
|
||||
|
||||
<div class="ai-question-meta">
|
||||
<div class="ai-question-category">
|
||||
<i class="fas fa-clock"></i>
|
||||
<small>{% trans "Generated" %}: {{ question.created_at|date:"d M Y, H:i" }}</small>
|
||||
</div>
|
||||
<div class="ai-question-actions">
|
||||
<button type="button"
|
||||
class="btn btn-sm"
|
||||
onclick="copyQuestionText('{{ question.id }}')"
|
||||
title="{% trans 'Copy question' %}">
|
||||
<i class="fas fa-copy"></i>
|
||||
</button>
|
||||
<button type="button"
|
||||
class="btn btn-sm"
|
||||
onclick="toggleQuestionNotes('{{ question.id }}')"
|
||||
title="{% trans 'Add notes' %}">
|
||||
<i class="fas fa-sticky-note"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Hidden notes section -->
|
||||
<div id="questionNotes_{{ question.id }}" class="mt-3" style="display: none;">
|
||||
<textarea class="form-control"
|
||||
rows="3"
|
||||
placeholder="{% trans 'Add your notes for this question...' %}"></textarea>
|
||||
<div class="mt-2">
|
||||
<button type="button"
|
||||
class="btn btn-main-action btn-sm"
|
||||
onclick="saveQuestionNotes('{{ question.id }}')">
|
||||
<i class="fas fa-save me-1"></i> {% trans "Save Notes" %}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="ai-questions-empty">
|
||||
<i class="fas fa-brain fa-3x mb-3"></i>
|
||||
<h5 class="mb-3">{% trans "No AI Questions Available" %}</h5>
|
||||
<p class="mb-0">{% trans "Click 'Generate Questions' to create personalized interview questions based on the candidate's profile and job requirements." %}</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<script>
|
||||
// Copy question text to clipboard
|
||||
function copyQuestionText(questionId) {
|
||||
const questionText = document.querySelector(`#questionText_${questionId}`);
|
||||
if (questionText) {
|
||||
navigator.clipboard.writeText(questionText.textContent).then(() => {
|
||||
// Show success feedback
|
||||
showNotification('{% trans "Question copied to clipboard!" %}', 'success');
|
||||
}).catch(err => {
|
||||
console.error('Failed to copy text: ', err);
|
||||
showNotification('{% trans "Failed to copy question" %}', 'error');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Toggle question notes visibility
|
||||
function toggleQuestionNotes(questionId) {
|
||||
const notesSection = document.getElementById(`questionNotes_${questionId}`);
|
||||
if (notesSection) {
|
||||
if (notesSection.style.display === 'none') {
|
||||
notesSection.style.display = 'block';
|
||||
} else {
|
||||
notesSection.style.display = 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Save question notes (placeholder function)
|
||||
function saveQuestionNotes(questionId) {
|
||||
const notesTextarea = document.querySelector(`#questionNotes_${questionId} textarea`);
|
||||
if (notesTextarea) {
|
||||
// Here you would typically save to backend
|
||||
const notes = notesTextarea.value;
|
||||
console.log(`Saving notes for question ${questionId}:`, notes);
|
||||
showNotification('{% trans "Notes saved successfully!" %}', 'success');
|
||||
|
||||
// Hide notes section after saving
|
||||
setTimeout(() => {
|
||||
toggleQuestionNotes(questionId);
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
// Show notification (helper function)
|
||||
function showNotification(message, type = 'info') {
|
||||
// Create notification element
|
||||
const notification = document.createElement('div');
|
||||
notification.className = `alert alert-${type === 'success' ? 'success' : type === 'error' ? 'danger' : 'info'} alert-dismissible fade show position-fixed`;
|
||||
notification.style.cssText = `
|
||||
position: fixed;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
z-index: 9999;
|
||||
min-width: 300px;
|
||||
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
||||
`;
|
||||
notification.innerHTML = `
|
||||
${message}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
`;
|
||||
|
||||
document.body.appendChild(notification);
|
||||
|
||||
// Auto-remove after 3 seconds
|
||||
setTimeout(() => {
|
||||
if (notification.parentNode) {
|
||||
notification.parentNode.removeChild(notification);
|
||||
}
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
// Initialize question text elements with IDs for copying
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const questionTexts = document.querySelectorAll('.ai-question-text');
|
||||
questionTexts.forEach((element, index) => {
|
||||
// Add ID to question text elements for copying functionality
|
||||
const questionItem = element.closest('.ai-question-item');
|
||||
if (questionItem) {
|
||||
const questionId = questionItem.querySelector('[onclick*="copyQuestionText"]')?.getAttribute('onclick').match(/'(\d+)'/)?.[1];
|
||||
if (questionId) {
|
||||
element.id = `questionText_${questionId}`;
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@ -199,7 +199,7 @@
|
||||
<div class="col-md-4 d-flex">
|
||||
<div class="filter-buttons">
|
||||
<button type="submit" class="btn btn-main-action btn-sm">
|
||||
<i class="fas fa-filter me-1"></i> {% trans "Apply Filter" %}
|
||||
<i class="fas fa-filter me-1"></i> {% trans "Apply Filters" %}
|
||||
</button>
|
||||
{% if request.GET.q or request.GET.nationality or request.GET.gender %}
|
||||
<a href="{% url 'person_list' %}" class="btn btn-outline-secondary btn-sm">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user