1106 lines
No EOL
41 KiB
Text
1106 lines
No EOL
41 KiB
Text
@model EditQuestionnaireViewModel
|
|
|
|
@{
|
|
ViewData["Title"] = "Edit";
|
|
}
|
|
|
|
<style>
|
|
/* Modern Design Enhancements */
|
|
@@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
|
|
|
|
:root {
|
|
--primary-color: #6366f1;
|
|
--primary-light: #8b5cf6;
|
|
--primary-dark: #4338ca;
|
|
--success-color: #10b981;
|
|
--danger-color: #ef4444;
|
|
--warning-color: #f59e0b;
|
|
--info-color: #06b6d4;
|
|
--gray-50: #f8fafc;
|
|
--gray-100: #f1f5f9;
|
|
--gray-200: #e2e8f0;
|
|
--gray-300: #cbd5e1;
|
|
--gray-400: #94a3b8;
|
|
--gray-500: #64748b;
|
|
--gray-600: #475569;
|
|
--gray-700: #334155;
|
|
--gray-800: #1e293b;
|
|
--gray-900: #0f172a;
|
|
--shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
|
|
--shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
|
|
--shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
|
|
--shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
|
|
--shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
|
|
--border-radius-sm: 8px;
|
|
--border-radius-md: 12px;
|
|
--border-radius-lg: 16px;
|
|
--border-radius-xl: 20px;
|
|
}
|
|
|
|
* {
|
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
}
|
|
|
|
body {
|
|
background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
|
|
min-height: 100vh;
|
|
}
|
|
|
|
.container {
|
|
max-width: 1200px;
|
|
}
|
|
|
|
/* Enhanced Card Design */
|
|
.main-card {
|
|
background: white;
|
|
border-radius: var(--border-radius-xl);
|
|
box-shadow: var(--shadow-2xl);
|
|
border: 1px solid var(--gray-200);
|
|
overflow: hidden;
|
|
backdrop-filter: blur(10px);
|
|
}
|
|
|
|
.card-header-custom {
|
|
background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
|
|
color: white;
|
|
padding: 2.5rem;
|
|
text-align: center;
|
|
border: none;
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.card-header-custom::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 20"><defs><radialGradient id="a" cx="50%" cy="0%" r="100%"><stop offset="0%" stop-color="white" stop-opacity="0.1"/><stop offset="100%" stop-color="white" stop-opacity="0"/></radialGradient></defs><rect width="100" height="20" fill="url(%23a)"/></svg>');
|
|
opacity: 0.3;
|
|
}
|
|
|
|
.card-header-custom h5 {
|
|
font-size: 2rem;
|
|
font-weight: 700;
|
|
margin: 0;
|
|
text-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
|
position: relative;
|
|
z-index: 1;
|
|
}
|
|
|
|
.card-body-custom {
|
|
padding: 3rem;
|
|
background: var(--gray-50);
|
|
}
|
|
|
|
/* Form Enhancements */
|
|
.form-group {
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.form-control {
|
|
border: 2px solid var(--gray-200);
|
|
border-radius: var(--border-radius-md);
|
|
padding: 1rem 1.25rem;
|
|
font-size: 0.95rem;
|
|
font-weight: 500;
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
background: white;
|
|
box-shadow: var(--shadow-sm);
|
|
width: 100%;
|
|
min-height: 50px;
|
|
}
|
|
|
|
.form-control:focus {
|
|
border-color: var(--primary-color);
|
|
background: white;
|
|
box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1), var(--shadow-md);
|
|
outline: none;
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
/* Enhanced Select Styling */
|
|
select.form-control {
|
|
appearance: none;
|
|
-webkit-appearance: none;
|
|
-moz-appearance: none;
|
|
background-color: white;
|
|
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
|
|
background-position: right 0.75rem center;
|
|
background-repeat: no-repeat;
|
|
background-size: 1.25em 1.25em;
|
|
padding-right: 2.5rem;
|
|
cursor: pointer;
|
|
}
|
|
|
|
select.form-control:focus {
|
|
background-color: white;
|
|
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236366f1' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
|
|
background-position: right 0.75rem center;
|
|
background-repeat: no-repeat;
|
|
background-size: 1.25em 1.25em;
|
|
}
|
|
|
|
select.form-control option {
|
|
padding: 0.75rem;
|
|
font-weight: 500;
|
|
color: var(--gray-900);
|
|
background: white;
|
|
}
|
|
|
|
.control-label {
|
|
font-weight: 600;
|
|
color: var(--gray-700);
|
|
margin-bottom: 0.75rem;
|
|
font-size: 0.95rem;
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
/* Button Enhancements */
|
|
.btn {
|
|
border-radius: var(--border-radius-md);
|
|
font-weight: 600;
|
|
padding: 0.75rem 1.5rem;
|
|
font-size: 0.875rem;
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
border: none;
|
|
text-decoration: none;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
box-shadow: var(--shadow-sm);
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.btn::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: -100%;
|
|
width: 100%;
|
|
height: 100%;
|
|
background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
|
|
transition: left 0.5s;
|
|
}
|
|
|
|
.btn:hover::before {
|
|
left: 100%;
|
|
}
|
|
|
|
.btn-primary {
|
|
background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
|
|
color: white;
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%);
|
|
transform: translateY(-2px);
|
|
box-shadow: var(--shadow-lg);
|
|
color: white;
|
|
}
|
|
|
|
.btn-success {
|
|
background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%);
|
|
color: white;
|
|
}
|
|
|
|
.btn-success:hover {
|
|
background: linear-gradient(135deg, #059669 0%, #047857 100%);
|
|
transform: translateY(-2px);
|
|
box-shadow: var(--shadow-lg);
|
|
color: white;
|
|
}
|
|
|
|
.btn-danger {
|
|
background: linear-gradient(135deg, var(--danger-color) 0%, #dc2626 100%);
|
|
color: white;
|
|
}
|
|
|
|
.btn-danger:hover {
|
|
background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
|
|
transform: translateY(-2px);
|
|
box-shadow: var(--shadow-lg);
|
|
color: white;
|
|
}
|
|
|
|
.btn-info {
|
|
background: linear-gradient(135deg, var(--info-color) 0%, #0891b2 100%);
|
|
color: white;
|
|
}
|
|
|
|
.btn-info:hover {
|
|
background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
|
|
transform: translateY(-2px);
|
|
box-shadow: var(--shadow-lg);
|
|
color: white;
|
|
}
|
|
|
|
.btn-warning {
|
|
background: linear-gradient(135deg, var(--warning-color) 0%, #d97706 100%);
|
|
color: white;
|
|
}
|
|
|
|
.btn-warning:hover {
|
|
background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
|
|
transform: translateY(-2px);
|
|
box-shadow: var(--shadow-lg);
|
|
color: white;
|
|
}
|
|
|
|
.btn-secondary {
|
|
background: linear-gradient(135deg, var(--gray-500) 0%, var(--gray-600) 100%);
|
|
color: white;
|
|
}
|
|
|
|
.btn-secondary:hover {
|
|
background: linear-gradient(135deg, var(--gray-600) 0%, var(--gray-700) 100%);
|
|
transform: translateY(-2px);
|
|
box-shadow: var(--shadow-lg);
|
|
color: white;
|
|
}
|
|
|
|
/* Question Container Enhancements */
|
|
#customCard {
|
|
background: white;
|
|
border: none;
|
|
border-radius: var(--border-radius-lg);
|
|
padding: 3rem;
|
|
margin: 3rem 0;
|
|
box-shadow: var(--shadow-xl);
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
#customCard::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
height: 4px;
|
|
background: linear-gradient(90deg, var(--primary-color), var(--primary-light), var(--info-color));
|
|
}
|
|
|
|
#customCard h4 {
|
|
font-size: 1.75rem;
|
|
font-weight: 700;
|
|
color: var(--gray-800);
|
|
margin-bottom: 3rem;
|
|
text-align: center;
|
|
}
|
|
|
|
.question {
|
|
background: white;
|
|
border-radius: var(--border-radius-lg);
|
|
padding: 2.5rem;
|
|
margin-bottom: 2.5rem;
|
|
box-shadow: var(--shadow-lg);
|
|
border: 1px solid var(--gray-200);
|
|
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.question::before {
|
|
content: '';
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 4px;
|
|
height: 100%;
|
|
background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
|
|
transform: scaleY(0);
|
|
transition: transform 0.3s ease;
|
|
transform-origin: bottom;
|
|
}
|
|
|
|
.question:hover {
|
|
box-shadow: var(--shadow-2xl);
|
|
transform: translateY(-4px);
|
|
border-color: var(--primary-color);
|
|
}
|
|
|
|
.question:hover::before {
|
|
transform: scaleY(1);
|
|
}
|
|
|
|
/* Question Separator */
|
|
.question-separator {
|
|
display: flex;
|
|
align-items: center;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.line-container {
|
|
flex: 1;
|
|
}
|
|
|
|
.line-start, .line-end {
|
|
border: none;
|
|
height: 3px;
|
|
background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
|
|
margin: 0;
|
|
border-radius: 2px;
|
|
}
|
|
|
|
.next-question-container {
|
|
padding: 0 1.5rem;
|
|
}
|
|
|
|
.badge {
|
|
background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
|
|
color: white;
|
|
padding: 0.75rem 1.25rem;
|
|
border-radius: var(--border-radius-md);
|
|
font-weight: 600;
|
|
font-size: 0.8rem;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
box-shadow: var(--shadow-md);
|
|
}
|
|
|
|
/* Question Title Styling */
|
|
.question-title {
|
|
background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%);
|
|
padding: 2rem;
|
|
border-radius: var(--border-radius-md);
|
|
border: 1px solid var(--gray-200);
|
|
margin-bottom: 1.5rem;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.question-title:hover {
|
|
background: linear-gradient(135deg, var(--gray-100) 0%, var(--gray-200) 100%);
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
.item-question {
|
|
font-size: 1.15rem;
|
|
font-weight: 600;
|
|
color: var(--gray-900);
|
|
line-height: 1.6;
|
|
display: block;
|
|
word-wrap: break-word;
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
/* Answer Section Enhancements */
|
|
.answers {
|
|
background: linear-gradient(135deg, var(--gray-50) 0%, var(--gray-100) 100%);
|
|
border-radius: var(--border-radius-md);
|
|
padding: 2rem;
|
|
margin: 1.5rem 0;
|
|
border: 1px solid var(--gray-200);
|
|
}
|
|
|
|
.answers h6 {
|
|
font-size: 1.1rem;
|
|
font-weight: 600;
|
|
color: var(--gray-800);
|
|
margin-bottom: 1.5rem;
|
|
}
|
|
|
|
.answer, .answer-group {
|
|
background: white;
|
|
border-radius: var(--border-radius-md);
|
|
padding: 1.5rem;
|
|
margin-bottom: 1.25rem;
|
|
border: 2px solid var(--gray-200);
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
box-shadow: var(--shadow-sm);
|
|
}
|
|
|
|
.answer:hover, .answer-group:hover {
|
|
border-color: var(--primary-color);
|
|
box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1), var(--shadow-md);
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
/* Other Option Styling */
|
|
.other-option-group {
|
|
background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
|
|
border: 2px solid var(--warning-color);
|
|
position: relative;
|
|
}
|
|
|
|
.other-option-group::before {
|
|
content: "OTHER OPTION";
|
|
position: absolute;
|
|
top: -12px;
|
|
left: 20px;
|
|
background: var(--warning-color);
|
|
color: white;
|
|
padding: 0.375rem 1rem;
|
|
border-radius: var(--border-radius-sm);
|
|
font-size: 0.7rem;
|
|
font-weight: 700;
|
|
letter-spacing: 0.5px;
|
|
box-shadow: var(--shadow-sm);
|
|
}
|
|
|
|
.other-option-badge {
|
|
background: var(--warning-color);
|
|
color: white;
|
|
padding: 0.375rem 1rem;
|
|
border-radius: var(--border-radius-sm);
|
|
font-size: 0.75rem;
|
|
font-weight: 600;
|
|
margin-left: 0.75rem;
|
|
box-shadow: var(--shadow-sm);
|
|
}
|
|
|
|
.other-option-info {
|
|
background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
|
|
border: 1px solid var(--info-color);
|
|
border-radius: var(--border-radius-sm);
|
|
padding: 1rem 1.25rem;
|
|
margin-top: 1rem;
|
|
font-size: 0.875rem;
|
|
color: var(--gray-700);
|
|
font-weight: 500;
|
|
}
|
|
|
|
.other-option-info i {
|
|
color: var(--info-color);
|
|
margin-right: 0.75rem;
|
|
}
|
|
|
|
/* Action Buttons */
|
|
.action-buttons {
|
|
display: flex;
|
|
gap: 1rem;
|
|
margin-top: 2rem;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.action-buttons .btn {
|
|
flex: 0 0 auto;
|
|
}
|
|
|
|
/* Add Question Button */
|
|
#addNewQuestion {
|
|
background: linear-gradient(135deg, var(--success-color) 0%, #059669 100%);
|
|
color: white;
|
|
padding: 1.25rem 2.5rem;
|
|
font-size: 1.1rem;
|
|
font-weight: 700;
|
|
border-radius: var(--border-radius-lg);
|
|
margin: 3rem 0;
|
|
box-shadow: var(--shadow-lg);
|
|
border: none;
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
position: relative;
|
|
overflow: hidden;
|
|
}
|
|
|
|
#addNewQuestion:hover {
|
|
transform: translateY(-3px);
|
|
box-shadow: var(--shadow-2xl);
|
|
background: linear-gradient(135deg, #059669 0%, #047857 100%);
|
|
}
|
|
|
|
/* Alert Enhancements */
|
|
.alert {
|
|
border-radius: var(--border-radius-md);
|
|
padding: 1.25rem 1.5rem;
|
|
margin: 1.5rem 0;
|
|
border: none;
|
|
font-weight: 500;
|
|
box-shadow: var(--shadow-sm);
|
|
}
|
|
|
|
.alert-success {
|
|
background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
|
|
color: #065f46;
|
|
border-left: 4px solid var(--success-color);
|
|
}
|
|
|
|
.alert-info {
|
|
background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
|
|
color: #0c4a6e;
|
|
border-left: 4px solid var(--info-color);
|
|
}
|
|
|
|
.alert-warning {
|
|
background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
|
|
color: #92400e;
|
|
border-left: 4px solid var(--warning-color);
|
|
}
|
|
|
|
/* Form Actions */
|
|
.form-actions {
|
|
background: white;
|
|
padding: 2.5rem;
|
|
border-radius: var(--border-radius-lg);
|
|
margin-top: 3rem;
|
|
display: flex;
|
|
gap: 1.5rem;
|
|
flex-wrap: wrap;
|
|
align-items: center;
|
|
box-shadow: var(--shadow-lg);
|
|
border: 1px solid var(--gray-200);
|
|
}
|
|
|
|
/* Responsive Design */
|
|
@@media (max-width: 768px) {
|
|
.card-body-custom
|
|
|
|
{
|
|
padding: 2rem;
|
|
}
|
|
|
|
.question {
|
|
padding: 2rem;
|
|
}
|
|
|
|
#customCard {
|
|
padding: 2rem;
|
|
}
|
|
|
|
.action-buttons {
|
|
flex-direction: column;
|
|
}
|
|
|
|
.form-actions {
|
|
flex-direction: column;
|
|
align-items: stretch;
|
|
}
|
|
|
|
.card-header-custom h5 {
|
|
font-size: 1.5rem;
|
|
}
|
|
|
|
}
|
|
|
|
/* Modal Enhancements */
|
|
.modal-content {
|
|
border-radius: var(--border-radius-lg);
|
|
border: none;
|
|
box-shadow: var(--shadow-2xl);
|
|
overflow: hidden;
|
|
}
|
|
|
|
.modal-header {
|
|
background: linear-gradient(135deg, var(--danger-color) 0%, #dc2626 100%);
|
|
color: white;
|
|
border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
|
|
border: none;
|
|
padding: 2rem 2.5rem;
|
|
}
|
|
|
|
.modal-body {
|
|
padding: 2.5rem;
|
|
font-size: 1.1rem;
|
|
color: var(--gray-700);
|
|
}
|
|
|
|
.modal-footer {
|
|
padding: 2rem 2.5rem;
|
|
border: none;
|
|
background: var(--gray-50);
|
|
}
|
|
|
|
/* Loading States */
|
|
.btn.loading {
|
|
opacity: 0.7;
|
|
pointer-events: none;
|
|
}
|
|
|
|
.btn.loading::after {
|
|
content: "";
|
|
width: 18px;
|
|
height: 18px;
|
|
margin-left: 0.75rem;
|
|
border: 2px solid transparent;
|
|
border-top-color: currentColor;
|
|
border-radius: 50%;
|
|
animation: spin 1s linear infinite;
|
|
}
|
|
|
|
@@keyframes spin {
|
|
0%
|
|
|
|
{
|
|
transform: rotate(0deg);
|
|
}
|
|
|
|
100% {
|
|
transform: rotate(360deg);
|
|
}
|
|
|
|
}
|
|
|
|
/* Animations */
|
|
.fade-in {
|
|
animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
|
|
}
|
|
|
|
@@keyframes fadeIn {
|
|
from
|
|
|
|
{
|
|
opacity: 0;
|
|
transform: translateY(20px);
|
|
}
|
|
|
|
to {
|
|
opacity: 1;
|
|
transform: translateY(0);
|
|
}
|
|
|
|
}
|
|
|
|
/* Enhanced Focus States */
|
|
.btn:focus,
|
|
.form-control:focus {
|
|
outline: 2px solid var(--primary-color);
|
|
outline-offset: 2px;
|
|
}
|
|
|
|
/* Smooth scrolling */
|
|
html {
|
|
scroll-behavior: smooth;
|
|
}
|
|
|
|
/* Enhanced Typography */
|
|
h1, h2, h3, h4, h5, h6 {
|
|
font-weight: 700;
|
|
letter-spacing: -0.025em;
|
|
}
|
|
|
|
/* Icon styling */
|
|
.bi {
|
|
font-size: 1.1em;
|
|
}
|
|
</style>
|
|
|
|
<div class="container mt-4">
|
|
<div class="card main-card">
|
|
<div class="card-header-custom">
|
|
<h5><i class="bi bi-pencil-square me-2"></i>Edit Survey</h5>
|
|
</div>
|
|
<div class="card-body-custom">
|
|
<form asp-action="Edit">
|
|
<input type="hidden" asp-for="Id" />
|
|
|
|
<!-- Basic Information -->
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label asp-for="Title" class="control-label">
|
|
<i class="bi bi-card-heading me-2"></i>Survey Title
|
|
</label>
|
|
<input asp-for="Title" class="form-control" placeholder="Enter survey title" />
|
|
<span asp-validation-for="Title" class="text-danger"></span>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="form-group">
|
|
<label asp-for="Description" class="control-label">
|
|
<i class="bi bi-card-text me-2"></i>Description
|
|
</label>
|
|
<textarea asp-for="Description" class="form-control" rows="4" placeholder="Enter survey description"></textarea>
|
|
<span asp-validation-for="Description" class="text-danger"></span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Questions Section -->
|
|
<div class="card" id="customCard">
|
|
<div class="text-center">
|
|
<h4><i class="bi bi-question-circle me-2"></i>Edit Questions or Add New Questions</h4>
|
|
</div>
|
|
|
|
<div id="questionsContainer">
|
|
@for (int i = 0; i < Model.Questions.Count; i++)
|
|
{
|
|
<div class="question fade-in">
|
|
<div class="question-separator">
|
|
<div class="line-container">
|
|
<hr class="line-start">
|
|
</div>
|
|
<div class="next-question-container">
|
|
<span class="badge">Question @(i + 1)</span>
|
|
</div>
|
|
<div class="line-container">
|
|
<hr class="line-end">
|
|
</div>
|
|
</div>
|
|
|
|
<input type="hidden" asp-for="Questions[i].Id" />
|
|
|
|
<div class="question-title">
|
|
<div class="d-flex justify-content-between align-items-start">
|
|
<div class="flex-grow-1">
|
|
<span class="item-question">@Html.Raw(Model.Questions[i].Text)</span>
|
|
</div>
|
|
<div class="action-buttons">
|
|
<button type="button" class="btn btn-primary btn-sm editQuestion">
|
|
<i class="bi bi-pencil-square"></i> Edit
|
|
</button>
|
|
<button type="button" class="btn btn-danger btn-sm removeQuestion">
|
|
<i class="bi bi-trash"></i> Remove
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="question-details" style="display: none;">
|
|
<div class="form-group">
|
|
<label asp-for="Questions[i].Text" class="control-label">Question Text</label>
|
|
<input asp-for="Questions[i].Text" class="form-control" placeholder="Enter question text" />
|
|
<span asp-validation-for="Questions[i].Text" class="text-danger"></span>
|
|
</div>
|
|
<div class="form-group">
|
|
<label asp-for="Questions[i].Type" class="control-label">Question Type</label>
|
|
<select asp-for="Questions[i].Type" asp-items="@ViewBag.QuestionTypes" class="form-control"></select>
|
|
<span asp-validation-for="Questions[i].Type" class="text-danger"></span>
|
|
</div>
|
|
|
|
<div class="answers">
|
|
<h6 class="mb-3"><i class="bi bi-list-ul me-2"></i>Answer Options</h6>
|
|
@for (int j = 0; j < Model.Questions[i].Answers.Count; j++)
|
|
{
|
|
<div class="answer-group @(Model.Questions[i].Answers[j].IsOtherOption ? "other-option-group" : "")">
|
|
<input type="hidden" asp-for="Questions[i].Answers[j].Id" />
|
|
<input type="hidden" asp-for="Questions[i].Answers[j].IsOtherOption" />
|
|
<div class="form-group mb-0">
|
|
<label asp-for="Questions[i].Answers[j].Text" class="control-label">
|
|
Answer @(j + 1)
|
|
@if (Model.Questions[i].Answers[j].IsOtherOption)
|
|
{
|
|
<span class="other-option-badge">Other Option</span>
|
|
}
|
|
</label>
|
|
<div class="d-flex gap-2">
|
|
<input asp-for="Questions[i].Answers[j].Text" class="form-control" placeholder="Enter answer text" />
|
|
<button type="button" class="btn btn-danger btn-sm removeAnswer">
|
|
<i class="bi bi-trash3"></i>
|
|
</button>
|
|
</div>
|
|
<span asp-validation-for="Questions[i].Answers[j].Text" class="text-danger"></span>
|
|
@if (Model.Questions[i].Answers[j].IsOtherOption)
|
|
{
|
|
<div class="other-option-info">
|
|
<i class="bi bi-info-circle"></i>
|
|
This option allows users to write their own custom response
|
|
</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
<div class="d-flex gap-2 mt-3">
|
|
<button type="button" class="btn btn-success btn-sm addAnswer">
|
|
<i class="bi bi-plus-square"></i> Add Answer
|
|
</button>
|
|
<button type="button" class="btn btn-warning btn-sm addOtherOption">
|
|
<i class="bi bi-pencil-square"></i> Add "Other" Option
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="action-buttons">
|
|
<button type="button" class="btn btn-primary saveQuestion">
|
|
<i class="bi bi-check-circle"></i> Save Changes
|
|
</button>
|
|
<button type="button" class="btn btn-secondary cancelEdit">
|
|
<i class="bi bi-x-circle"></i> Cancel
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="text-center">
|
|
<button type="button" id="addNewQuestion">
|
|
<i class="bi bi-plus-circle-fill"></i> Add New Question
|
|
</button>
|
|
</div>
|
|
|
|
<div class="form-actions">
|
|
<button type="submit" class="btn btn-primary btn-lg">
|
|
<i class="bi bi-save"></i> Update Survey
|
|
</button>
|
|
<a asp-action="Index" class="btn btn-info btn-lg">
|
|
<i class="bi bi-arrow-left"></i> Back to List
|
|
</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Enhanced Confirmation Modal -->
|
|
<div class="modal fade" id="confirmDeleteModal" tabindex="-1" aria-labelledby="confirmDeleteModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-dialog-centered">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="confirmDeleteModalLabel">
|
|
<i class="bi bi-exclamation-triangle me-2"></i>Confirm Deletion
|
|
</h5>
|
|
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<p class="mb-3">Are you sure you want to delete this question?</p>
|
|
<div class="alert alert-warning">
|
|
<i class="bi bi-warning me-2"></i>
|
|
<strong>Warning:</strong> This action cannot be undone. All associated answers and responses will be permanently removed.
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
|
|
<i class="bi bi-x"></i> Cancel
|
|
</button>
|
|
<button type="button" class="btn btn-danger confirm-delete">
|
|
<i class="bi bi-trash"></i> Delete Question
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@section Scripts {
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/ckeditor/4.11.4/ckeditor.js"></script>
|
|
<script>
|
|
CKEDITOR.replace("Description");
|
|
</script>
|
|
@{
|
|
<partial name="_ValidationScriptsPartial" />
|
|
}
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
|
<script>
|
|
$(document).ready(function () {
|
|
let questionToDelete = null;
|
|
|
|
// Function to add a new regular answer
|
|
$(document).on('click', '.addAnswer', function () {
|
|
var questionContainer = $(this).closest('.question');
|
|
var newQuestionIndex = questionContainer.index();
|
|
var newAnswerIndex = questionContainer.find('.answers .answer-group').length;
|
|
|
|
var answerHtml = `
|
|
<div class="answer-group fade-in">
|
|
<div class="form-group mb-0">
|
|
<label class="control-label">Answer ${newAnswerIndex + 1}</label>
|
|
<div class="d-flex gap-2">
|
|
<input type="text" name="Questions[${newQuestionIndex}].Answers[${newAnswerIndex}].Text" class="form-control" placeholder="Enter answer text" />
|
|
<input type="hidden" name="Questions[${newQuestionIndex}].Answers[${newAnswerIndex}].IsOtherOption" value="false" />
|
|
<button type="button" class="btn btn-danger btn-sm removeAnswer">
|
|
<i class="bi bi-trash3"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>`;
|
|
|
|
$(this).closest('.d-flex').before(answerHtml);
|
|
});
|
|
|
|
// Function to add "Other" option
|
|
$(document).on('click', '.addOtherOption', function () {
|
|
var questionContainer = $(this).closest('.question');
|
|
var newQuestionIndex = questionContainer.index();
|
|
var newAnswerIndex = questionContainer.find('.answers .answer-group').length;
|
|
|
|
// Check if "Other" option already exists
|
|
var existingOther = questionContainer.find('.other-option-group');
|
|
if (existingOther.length > 0) {
|
|
alert('An "Other" option already exists for this question.');
|
|
return;
|
|
}
|
|
|
|
var otherOptionHtml = `
|
|
<div class="answer-group other-option-group fade-in">
|
|
<div class="form-group mb-0">
|
|
<label class="control-label">
|
|
Answer ${newAnswerIndex + 1}
|
|
<span class="other-option-badge">Other Option</span>
|
|
</label>
|
|
<div class="d-flex gap-2">
|
|
<input type="text" name="Questions[${newQuestionIndex}].Answers[${newAnswerIndex}].Text" class="form-control" placeholder="Other (please specify)" value="Other (please specify)" />
|
|
<input type="hidden" name="Questions[${newQuestionIndex}].Answers[${newAnswerIndex}].IsOtherOption" value="true" />
|
|
<button type="button" class="btn btn-warning btn-sm removeAnswer">
|
|
<i class="bi bi-trash3"></i> Remove Other
|
|
</button>
|
|
</div>
|
|
<div class="other-option-info">
|
|
<i class="bi bi-info-circle"></i>
|
|
This option allows users to write their own custom response
|
|
</div>
|
|
</div>
|
|
</div>`;
|
|
|
|
$(this).closest('.d-flex').before(otherOptionHtml);
|
|
});
|
|
|
|
// Function to remove an answer
|
|
$(document).on('click', '.removeAnswer', function () {
|
|
$(this).closest('.answer-group').fadeOut(300, function() {
|
|
$(this).remove();
|
|
});
|
|
});
|
|
|
|
// Function to toggle question edit mode
|
|
$(document).on('click', '.editQuestion', function () {
|
|
var questionContainer = $(this).closest('.question');
|
|
questionContainer.find('.question-title').hide();
|
|
questionContainer.find('.question-details').slideDown(300);
|
|
});
|
|
|
|
// Function to cancel edit
|
|
$(document).on('click', '.cancelEdit', function () {
|
|
var questionContainer = $(this).closest('.question');
|
|
questionContainer.find('.question-details').slideUp(300);
|
|
questionContainer.find('.question-title').show();
|
|
});
|
|
|
|
// Function to save question details
|
|
$(document).on('click', '.saveQuestion', function () {
|
|
var $btn = $(this);
|
|
var questionContainer = $btn.closest('.question');
|
|
|
|
// Add loading state
|
|
$btn.addClass('loading').prop('disabled', true);
|
|
|
|
setTimeout(function() {
|
|
var questionText = questionContainer.find('.question-details input[name$=".Text"]:first').val();
|
|
|
|
// Update the question title display with full text
|
|
questionContainer.find('.item-question').text(questionText);
|
|
|
|
questionContainer.find('.question-details').slideUp(300);
|
|
questionContainer.find('.question-title').show();
|
|
|
|
// Show success message
|
|
var successMessage = $('<div class="alert alert-success fade-in" role="alert"><i class="bi bi-check-circle me-2"></i>Question updated successfully!</div>');
|
|
questionContainer.prepend(successMessage);
|
|
|
|
setTimeout(function() {
|
|
successMessage.fadeOut(300, function() {
|
|
$(this).remove();
|
|
});
|
|
}, 3000);
|
|
|
|
// Remove loading state
|
|
$btn.removeClass('loading').prop('disabled', false);
|
|
}, 500);
|
|
});
|
|
|
|
// Function to handle question deletion
|
|
$(document).on('click', '.removeQuestion', function () {
|
|
questionToDelete = $(this).closest('.question');
|
|
$('#confirmDeleteModal').modal('show');
|
|
});
|
|
|
|
// Confirm deletion
|
|
$('.confirm-delete').click(function () {
|
|
if (questionToDelete) {
|
|
questionToDelete.fadeOut(300, function() {
|
|
$(this).remove();
|
|
});
|
|
$('#confirmDeleteModal').modal('hide');
|
|
questionToDelete = null;
|
|
}
|
|
});
|
|
|
|
// Function to add a new question
|
|
$('#addNewQuestion').click(function () {
|
|
var $btn = $(this);
|
|
$btn.addClass('loading').prop('disabled', true);
|
|
|
|
setTimeout(function() {
|
|
var newQuestionIndex = $('.question').length;
|
|
|
|
var questionHtml = `
|
|
<div class="question fade-in">
|
|
<div class="question-separator">
|
|
<div class="line-container">
|
|
<hr class="line-start">
|
|
</div>
|
|
<div class="next-question-container">
|
|
<span class="badge">Question ${newQuestionIndex + 1}</span>
|
|
</div>
|
|
<div class="line-container">
|
|
<hr class="line-end">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="question-details">
|
|
<div class="form-group">
|
|
<label class="control-label">Question Text</label>
|
|
<input type="text" class="form-control" name="Questions[${newQuestionIndex}].Text" placeholder="Enter question text"/>
|
|
</div>
|
|
<div class="form-group">
|
|
<label class="control-label">Question Type</label>
|
|
<select class="form-control" name="Questions[${newQuestionIndex}].Type">
|
|
<option value="0">Text</option>
|
|
<option value="1">CheckBox</option>
|
|
<option value="2">TrueFalse</option>
|
|
<option value="3">Multiple_choice</option>
|
|
<option value="4">Rating</option>
|
|
<option value="5">Likert</option>
|
|
<option value="6">Matrix</option>
|
|
<option value="7">Open_ended</option>
|
|
<option value="8">Demographic</option>
|
|
<option value="9">Ranking</option>
|
|
<option value="10">Image</option>
|
|
<option value="11">Slider</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="answers">
|
|
<h6 class="mb-3"><i class="bi bi-list-ul me-2"></i>Answer Options</h6>
|
|
<div class="answer-group">
|
|
<div class="form-group mb-0">
|
|
<label class="control-label">Answer 1</label>
|
|
<div class="d-flex gap-2">
|
|
<input type="text" class="form-control" name="Questions[${newQuestionIndex}].Answers[0].Text" placeholder="Enter answer text"/>
|
|
<input type="hidden" name="Questions[${newQuestionIndex}].Answers[0].IsOtherOption" value="false"/>
|
|
<button type="button" class="btn btn-danger btn-sm removeAnswer">
|
|
<i class="bi bi-trash3"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="d-flex gap-2 mt-3">
|
|
<button type="button" class="btn btn-success btn-sm addAnswer">
|
|
<i class="bi bi-plus-square"></i> Add Answer
|
|
</button>
|
|
<button type="button" class="btn btn-warning btn-sm addOtherOption">
|
|
<i class="bi bi-pencil-square"></i> Add "Other" Option
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="action-buttons">
|
|
<button type="button" class="btn btn-primary saveQuestion">
|
|
<i class="bi bi-check-circle"></i> Save Question
|
|
</button>
|
|
<button type="button" class="btn btn-danger removeQuestion">
|
|
<i class="bi bi-trash"></i> Remove Question
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>`;
|
|
|
|
$('#questionsContainer').append(questionHtml);
|
|
|
|
// Scroll to new question
|
|
$('html, body').animate({
|
|
scrollTop: $('.question:last').offset().top - 100
|
|
}, 500);
|
|
|
|
$btn.removeClass('loading').prop('disabled', false);
|
|
}, 300);
|
|
});
|
|
});
|
|
</script>
|
|
} |