923 lines
42 KiB
Text
923 lines
42 KiB
Text
@model Web.ViewModel.QuestionnaireVM.QuestionnaireViewModel
|
|
|
|
@{
|
|
ViewData["Title"] = "Create Questionnaire";
|
|
}
|
|
|
|
<style>
|
|
@@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');
|
|
|
|
:root {
|
|
--bg: #0f1923;
|
|
--bg-card: #1a2332;
|
|
--bg-elevated: #1f2b3d;
|
|
--bg-input: #16202e;
|
|
--bg-hover: #243044;
|
|
--text-primary: #e8edf2;
|
|
--text-secondary: #9ba8b9;
|
|
--text-muted: #5e6e82;
|
|
--text-faint: #3d4e63;
|
|
--teal: #33b3ae;
|
|
--teal-soft: rgba(51, 179, 174, 0.1);
|
|
--teal-medium: rgba(51, 179, 174, 0.2);
|
|
--teal-glow: rgba(51, 179, 174, 0.12);
|
|
--teal-dark: #2a9490;
|
|
--amber: #f59e0b;
|
|
--amber-soft: rgba(245, 158, 11, 0.1);
|
|
--amber-border: rgba(245, 158, 11, 0.35);
|
|
--purple: #7c3aed;
|
|
--purple-soft: rgba(124, 58, 237, 0.1);
|
|
--purple-border: rgba(124, 58, 237, 0.35);
|
|
--red: #ef4444;
|
|
--red-soft: rgba(239, 68, 68, 0.1);
|
|
--green: #10b981;
|
|
--green-soft: rgba(16, 185, 129, 0.1);
|
|
--green-border: rgba(16, 185, 129, 0.35);
|
|
--border: rgba(255, 255, 255, 0.06);
|
|
--border-light: rgba(255, 255, 255, 0.04);
|
|
--border-focus: rgba(51, 179, 174, 0.4);
|
|
--shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.2);
|
|
--shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
|
|
--shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
|
|
--shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.35);
|
|
--shadow-teal: 0 4px 20px rgba(51, 179, 174, 0.2);
|
|
--radius-sm: 8px;
|
|
--radius-md: 12px;
|
|
--radius-lg: 16px;
|
|
--transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
--transition-spring: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
}
|
|
|
|
@@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
|
|
@@keyframes scaleIn { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
|
|
@@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
|
|
@@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
|
|
|
|
* { box-sizing: border-box; }
|
|
|
|
.create-page {
|
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
|
|
background: var(--bg);
|
|
min-height: 100vh;
|
|
padding: 32px 40px 80px;
|
|
-webkit-font-smoothing: antialiased;
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
/* ===== PAGE HEADER ===== */
|
|
.page-top {
|
|
max-width: 1280px;
|
|
margin: 0 auto 28px;
|
|
animation: slideUp 0.5s ease both;
|
|
}
|
|
|
|
.page-breadcrumb {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
font-size: 13px;
|
|
color: var(--text-muted);
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.page-breadcrumb a { color: var(--text-muted); text-decoration: none; transition: var(--transition); }
|
|
.page-breadcrumb a:hover { color: var(--teal); }
|
|
.page-breadcrumb .sep { color: var(--text-faint); }
|
|
|
|
.page-title-row {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 20px;
|
|
}
|
|
|
|
.page-title {
|
|
font-size: 28px;
|
|
font-weight: 700;
|
|
color: var(--text-primary);
|
|
letter-spacing: -0.5px;
|
|
margin: 0;
|
|
}
|
|
|
|
.page-title-accent {
|
|
display: inline-block;
|
|
width: 8px;
|
|
height: 8px;
|
|
background: var(--teal);
|
|
border-radius: 50%;
|
|
margin-left: 4px;
|
|
vertical-align: super;
|
|
animation: pulse 2s ease infinite;
|
|
}
|
|
|
|
.question-counter-pill {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
background: var(--bg-card);
|
|
border: 1px solid var(--border);
|
|
border-radius: 100px;
|
|
padding: 8px 20px;
|
|
font-size: 13px;
|
|
font-weight: 500;
|
|
color: var(--text-secondary);
|
|
box-shadow: var(--shadow-xs);
|
|
}
|
|
|
|
.counter-number {
|
|
font-weight: 700;
|
|
font-size: 18px;
|
|
color: var(--teal);
|
|
line-height: 1;
|
|
}
|
|
|
|
/* ===== META SECTION ===== */
|
|
.meta-card {
|
|
max-width: 1280px;
|
|
margin: 0 auto 24px;
|
|
background: var(--bg-card);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius-lg);
|
|
padding: 28px 32px;
|
|
box-shadow: var(--shadow-xs);
|
|
animation: slideUp 0.5s ease 0.1s both;
|
|
transition: var(--transition);
|
|
}
|
|
|
|
.meta-card:hover { box-shadow: var(--shadow-sm); border-color: rgba(255,255,255,0.08); }
|
|
|
|
.meta-row {
|
|
display: grid;
|
|
grid-template-columns: 1fr 1fr;
|
|
gap: 24px;
|
|
}
|
|
|
|
.field-group label {
|
|
display: block;
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
color: var(--text-secondary);
|
|
margin-bottom: 8px;
|
|
letter-spacing: -0.01em;
|
|
}
|
|
|
|
.field-input {
|
|
width: 100%;
|
|
background: var(--bg-input);
|
|
border: 1.5px solid var(--border);
|
|
border-radius: var(--radius-sm);
|
|
padding: 12px 16px;
|
|
font-size: 14px;
|
|
font-family: inherit;
|
|
color: var(--text-primary);
|
|
transition: var(--transition);
|
|
outline: none;
|
|
}
|
|
|
|
.field-input::placeholder { color: var(--text-muted); }
|
|
.field-input:focus { background: var(--bg-elevated); border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--teal-glow); }
|
|
|
|
/* ===== BUILDER LAYOUT ===== */
|
|
.builder-layout {
|
|
max-width: 1280px;
|
|
margin: 0 auto;
|
|
display: flex;
|
|
gap: 24px;
|
|
align-items: flex-start;
|
|
animation: slideUp 0.5s ease 0.15s both;
|
|
}
|
|
|
|
/* ===== PALETTE ===== */
|
|
.palette {
|
|
width: 240px;
|
|
min-width: 240px;
|
|
position: sticky;
|
|
top: 24px;
|
|
background: var(--bg-card);
|
|
border: 1px solid var(--border);
|
|
border-radius: var(--radius-lg);
|
|
padding: 20px;
|
|
box-shadow: var(--shadow-xs);
|
|
transition: var(--transition);
|
|
max-height: calc(100vh - 48px);
|
|
overflow-y: auto;
|
|
}
|
|
|
|
.palette:hover { box-shadow: var(--shadow-sm); }
|
|
|
|
.palette-title {
|
|
font-size: 11px;
|
|
font-weight: 700;
|
|
color: var(--text-muted);
|
|
text-transform: uppercase;
|
|
letter-spacing: 1px;
|
|
margin-bottom: 14px;
|
|
}
|
|
|
|
.palette-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
padding: 10px 12px;
|
|
margin-bottom: 4px;
|
|
border-radius: var(--radius-sm);
|
|
color: var(--text-secondary);
|
|
font-size: 13px;
|
|
font-weight: 500;
|
|
cursor: grab;
|
|
transition: var(--transition);
|
|
user-select: none;
|
|
border: 1.5px solid transparent;
|
|
}
|
|
|
|
.palette-item:hover {
|
|
background: var(--teal-soft);
|
|
color: var(--teal);
|
|
border-color: var(--teal-medium);
|
|
transform: translateX(4px);
|
|
}
|
|
|
|
.palette-item:active { cursor: grabbing; transform: scale(0.97); }
|
|
|
|
.palette-item .p-icon {
|
|
width: 28px;
|
|
height: 28px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
border-radius: 6px;
|
|
background: var(--bg-elevated);
|
|
color: var(--teal);
|
|
font-size: 14px;
|
|
flex-shrink: 0;
|
|
transition: var(--transition);
|
|
}
|
|
|
|
.palette-item:hover .p-icon { background: var(--teal); color: #fff; }
|
|
|
|
/* Scrollbar */
|
|
.palette::-webkit-scrollbar { width: 4px; }
|
|
.palette::-webkit-scrollbar-track { background: transparent; }
|
|
.palette::-webkit-scrollbar-thumb { background: var(--text-faint); border-radius: 4px; }
|
|
|
|
/* ===== CANVAS ===== */
|
|
.canvas-area { flex: 1; min-width: 0; }
|
|
|
|
.canvas-drop {
|
|
min-height: 280px;
|
|
border: 2px dashed var(--border);
|
|
border-radius: var(--radius-lg);
|
|
padding: 16px;
|
|
transition: var(--transition);
|
|
background: transparent;
|
|
}
|
|
|
|
.canvas-drop.drag-over { border-color: var(--teal); background: var(--teal-soft); }
|
|
|
|
.canvas-empty {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 64px 24px;
|
|
color: var(--text-muted);
|
|
}
|
|
|
|
.canvas-empty-icon {
|
|
width: 56px;
|
|
height: 56px;
|
|
border-radius: 16px;
|
|
background: var(--bg-elevated);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 24px;
|
|
color: var(--text-faint);
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.canvas-empty p { font-size: 14px; text-align: center; margin: 0; line-height: 1.6; }
|
|
|
|
/* ===== QUESTION CARD ===== */
|
|
.q-card {
|
|
background: var(--bg-card);
|
|
border: 1.5px solid var(--border);
|
|
border-radius: var(--radius-md);
|
|
margin-bottom: 12px;
|
|
overflow: hidden;
|
|
transition: var(--transition);
|
|
box-shadow: var(--shadow-xs);
|
|
animation: scaleIn 0.3s ease both;
|
|
}
|
|
|
|
.q-card:hover { box-shadow: var(--shadow-sm); border-color: rgba(255,255,255,0.1); }
|
|
.q-card.saved { border-color: var(--green-border); }
|
|
.q-card.saved .q-header { background: var(--green-soft); }
|
|
.q-card.sortable-chosen { box-shadow: var(--shadow-lg); transform: rotate(0.5deg); }
|
|
.q-card.sortable-ghost { opacity: 0.3; }
|
|
|
|
.q-header {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
padding: 14px 18px;
|
|
cursor: pointer;
|
|
transition: var(--transition);
|
|
}
|
|
|
|
.q-header:hover { background: var(--bg-elevated); }
|
|
|
|
.q-drag { color: var(--text-faint); cursor: grab; font-size: 16px; transition: var(--transition); }
|
|
.q-drag:hover { color: var(--text-muted); }
|
|
.q-drag:active { cursor: grabbing; }
|
|
|
|
.q-num {
|
|
width: 28px;
|
|
height: 28px;
|
|
border-radius: 8px;
|
|
background: var(--teal);
|
|
color: #fff;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 12px;
|
|
font-weight: 700;
|
|
flex-shrink: 0;
|
|
transition: var(--transition-spring);
|
|
}
|
|
|
|
.q-card:hover .q-num { transform: scale(1.08); }
|
|
|
|
.q-title {
|
|
flex: 1;
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
color: var(--text-primary);
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
|
|
.q-type-tag {
|
|
font-size: 11px;
|
|
font-weight: 600;
|
|
color: var(--teal);
|
|
background: var(--teal-soft);
|
|
padding: 3px 10px;
|
|
border-radius: 100px;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.q-saved-tag {
|
|
font-size: 11px;
|
|
font-weight: 600;
|
|
color: var(--green);
|
|
background: var(--green-soft);
|
|
padding: 3px 10px;
|
|
border-radius: 100px;
|
|
display: none;
|
|
}
|
|
|
|
.q-card.saved .q-saved-tag { display: inline-block; }
|
|
|
|
.q-chevron { color: var(--text-faint); font-size: 14px; transition: transform 0.25s ease; padding: 4px; background: none; border: none; cursor: pointer; }
|
|
.q-chevron.open { transform: rotate(180deg); }
|
|
|
|
.q-remove { background: none; border: none; color: var(--text-faint); font-size: 14px; padding: 4px 6px; cursor: pointer; transition: var(--transition); border-radius: 6px; }
|
|
.q-remove:hover { color: var(--red); background: var(--red-soft); }
|
|
|
|
/* ===== QUESTION BODY ===== */
|
|
.q-body { display: none; padding: 20px 20px 18px; border-top: 1px solid var(--border-light); animation: fadeIn 0.2s ease; }
|
|
.q-body.show { display: block; }
|
|
.q-body .field-group { margin-bottom: 16px; }
|
|
.q-body label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.4px; }
|
|
.q-body .field-input { background: var(--bg-input); border: 1.5px solid var(--border); font-size: 14px; padding: 10px 14px; }
|
|
.q-body .field-input:focus { background: var(--bg-elevated); border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--teal-glow); }
|
|
.q-body .field-input:disabled { background: var(--bg); color: var(--text-muted); cursor: not-allowed; }
|
|
|
|
/* ===== ANSWER LIST ===== */
|
|
.ans-section { margin-top: 14px; }
|
|
.ans-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
|
|
.ans-header label { margin: 0; }
|
|
.ans-hint { font-size: 11px; font-style: italic; color: var(--text-muted); font-weight: 400; text-transform: none; letter-spacing: 0; }
|
|
|
|
.ans-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
margin-bottom: 6px;
|
|
padding: 8px 10px;
|
|
background: var(--bg-elevated);
|
|
border: 1.5px solid var(--border);
|
|
border-radius: var(--radius-sm);
|
|
transition: var(--transition);
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.ans-item:hover { border-color: rgba(255,255,255,0.1); }
|
|
.ans-item.is-other { border-color: var(--amber-border); background: var(--amber-soft); }
|
|
.ans-item.has-logic { border-left: 3px solid var(--purple); background: var(--purple-soft); }
|
|
.ans-item.is-other.has-logic { border-color: var(--amber-border); border-left: 3px solid var(--purple); }
|
|
|
|
.ans-drag { color: var(--text-faint); cursor: grab; font-size: 14px; }
|
|
.ans-drag:active { cursor: grabbing; }
|
|
|
|
.ans-input {
|
|
flex: 1;
|
|
background: var(--bg-input);
|
|
border: 1.5px solid var(--border);
|
|
border-radius: 6px;
|
|
padding: 8px 12px;
|
|
font-size: 13px;
|
|
font-family: inherit;
|
|
color: var(--text-primary);
|
|
outline: none;
|
|
transition: var(--transition);
|
|
min-width: 100px;
|
|
}
|
|
|
|
.ans-input::placeholder { color: var(--text-faint); }
|
|
.ans-input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 2px var(--teal-glow); }
|
|
.ans-input:disabled { background: var(--bg); color: var(--text-muted); }
|
|
|
|
/* Pills */
|
|
.ans-pill {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 4px;
|
|
padding: 3px 8px;
|
|
border-radius: 100px;
|
|
font-size: 10px;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.4px;
|
|
cursor: pointer;
|
|
transition: var(--transition);
|
|
border: 1.5px solid var(--border);
|
|
background: var(--bg-input);
|
|
color: var(--text-muted);
|
|
white-space: nowrap;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.ans-pill:hover { border-color: var(--text-muted); }
|
|
.ans-pill input { display: none; }
|
|
.ans-pill.other-pill.active { background: var(--amber-soft); border-color: var(--amber-border); color: var(--amber); }
|
|
.ans-pill.logic-pill.active { background: var(--purple-soft); border-color: var(--purple-border); color: var(--purple); }
|
|
|
|
.ans-rm { background: none; border: none; color: var(--text-faint); cursor: pointer; padding: 4px; border-radius: 4px; font-size: 13px; transition: var(--transition); }
|
|
.ans-rm:hover { color: var(--red); background: var(--red-soft); }
|
|
|
|
/* Logic panel */
|
|
.logic-panel {
|
|
display: none;
|
|
width: 100%;
|
|
margin-top: 8px;
|
|
padding: 12px 14px;
|
|
background: var(--bg-card);
|
|
border: 1.5px solid var(--purple-border);
|
|
border-radius: var(--radius-sm);
|
|
animation: slideUp 0.2s ease both;
|
|
}
|
|
|
|
.logic-panel.show { display: block; }
|
|
.logic-panel label { font-size: 11px; font-weight: 600; color: var(--purple); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 5px; display: block; }
|
|
|
|
.logic-select, .logic-input {
|
|
width: 100%;
|
|
background: var(--bg-input);
|
|
border: 1.5px solid var(--border);
|
|
border-radius: 6px;
|
|
padding: 7px 10px;
|
|
font-size: 12px;
|
|
font-family: inherit;
|
|
color: var(--text-primary);
|
|
outline: none;
|
|
transition: var(--transition);
|
|
}
|
|
|
|
.logic-select:focus, .logic-input:focus { border-color: var(--purple-border); box-shadow: 0 0 0 2px rgba(124,58,237,0.1); }
|
|
.logic-select option { background: var(--bg-card); color: var(--text-primary); }
|
|
|
|
.logic-sub { margin-top: 8px; display: none; }
|
|
.logic-sub.show { display: block; }
|
|
.logic-summary { margin-top: 8px; font-size: 11px; color: var(--text-muted); font-style: italic; }
|
|
.logic-summary i { color: var(--purple); }
|
|
|
|
/* Add answer */
|
|
.add-ans-btn {
|
|
width: 100%;
|
|
padding: 10px;
|
|
border: 1.5px dashed var(--border);
|
|
background: transparent;
|
|
border-radius: var(--radius-sm);
|
|
font-size: 13px;
|
|
font-weight: 500;
|
|
font-family: inherit;
|
|
color: var(--text-muted);
|
|
cursor: pointer;
|
|
transition: var(--transition);
|
|
margin-top: 4px;
|
|
}
|
|
|
|
.add-ans-btn:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-soft); }
|
|
|
|
/* Image upload */
|
|
.img-ans-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
margin-bottom: 8px;
|
|
padding: 10px 12px;
|
|
background: var(--bg-elevated);
|
|
border: 1.5px solid var(--border);
|
|
border-radius: var(--radius-sm);
|
|
}
|
|
|
|
.img-ans-item .ans-drag { color: var(--text-faint); cursor: grab; font-size: 14px; }
|
|
.img-upload-wrap { flex: 1; display: flex; align-items: center; gap: 10px; }
|
|
.img-upload-inner { flex: 1; }
|
|
.img-upload-label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
|
|
|
|
.img-file-input { background: var(--bg-input); border: 1.5px solid var(--border); color: var(--text-secondary); border-radius: 6px; padding: 6px 10px; font-size: 12px; width: 100%; }
|
|
.img-file-input::-webkit-file-upload-button { background: var(--teal-soft); color: var(--teal); border: 1px solid var(--teal-medium); border-radius: 4px; padding: 4px 12px; margin-right: 10px; cursor: pointer; font-size: 11px; }
|
|
.img-preview { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; border: 1px solid var(--border); display: none; }
|
|
.img-preview.has-image { display: block; }
|
|
|
|
/* ===== ACTIONS ===== */
|
|
.q-actions { display: flex; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-light); }
|
|
|
|
.btn-q-save {
|
|
display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px;
|
|
border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; font-family: inherit;
|
|
cursor: pointer; transition: var(--transition-spring);
|
|
border: 1.5px solid var(--green-border); background: var(--green-soft); color: var(--green);
|
|
}
|
|
|
|
.btn-q-save:hover { background: var(--green); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(16,185,129,0.25); }
|
|
|
|
.btn-q-edit {
|
|
display: none; align-items: center; gap: 6px; padding: 8px 18px;
|
|
border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; font-family: inherit;
|
|
cursor: pointer; transition: var(--transition-spring);
|
|
border: 1.5px solid rgba(51,179,174,0.3); background: var(--teal-soft); color: var(--teal);
|
|
}
|
|
|
|
.btn-q-edit:hover { background: var(--teal); color: #fff; transform: translateY(-1px); box-shadow: var(--shadow-teal); }
|
|
|
|
/* ===== SUBMIT ===== */
|
|
.submit-row {
|
|
max-width: 1280px;
|
|
margin: 24px auto 0;
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
align-items: center;
|
|
animation: slideUp 0.5s ease 0.25s both;
|
|
}
|
|
|
|
.btn-submit {
|
|
display: inline-flex; align-items: center; gap: 8px; padding: 14px 32px;
|
|
background: var(--teal); color: #fff; border: none; border-radius: var(--radius-sm);
|
|
font-size: 15px; font-weight: 600; font-family: inherit; cursor: pointer;
|
|
transition: var(--transition-spring); box-shadow: var(--shadow-teal); letter-spacing: -0.01em;
|
|
}
|
|
|
|
.btn-submit:hover { background: var(--teal-dark); transform: translateY(-2px); box-shadow: 0 8px 28px rgba(51,179,174,0.25); }
|
|
.btn-submit:active { transform: translateY(-1px); }
|
|
|
|
/* ===== RESPONSIVE ===== */
|
|
@@media (max-width: 768px) {
|
|
.create-page { padding: 16px; }
|
|
.builder-layout { flex-direction: column; }
|
|
.palette { width: 100%; min-width: unset; position: static; display: flex; flex-wrap: wrap; gap: 4px; padding: 12px; max-height: none; }
|
|
.palette-title { width: 100%; }
|
|
.palette-item { flex: 0 0 auto; margin-bottom: 0; padding: 8px 10px; font-size: 12px; }
|
|
.meta-row { grid-template-columns: 1fr; }
|
|
}
|
|
|
|
.text-danger { color: var(--red) !important; font-size: 12px; }
|
|
</style>
|
|
|
|
<div class="create-page">
|
|
<form asp-action="Create" asp-controller="Questionnaire" method="post" id="questionnaireForm" enctype="multipart/form-data">
|
|
<div asp-validation-summary="All" class="text-danger mb-3"></div>
|
|
|
|
<div class="page-top">
|
|
<div class="page-breadcrumb">
|
|
<a href="@Url.Action("Index", "Questionnaire")">Questionnaires</a>
|
|
<span class="sep">/</span>
|
|
<span>Create New</span>
|
|
</div>
|
|
<div class="page-title-row">
|
|
<h1 class="page-title">New Questionnaire<span class="page-title-accent"></span></h1>
|
|
<div class="question-counter-pill">
|
|
<span class="counter-number" id="questionCounter">0</span>
|
|
<span>questions</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="meta-card">
|
|
<div class="meta-row">
|
|
<div class="field-group">
|
|
<label asp-for="Title">Title</label>
|
|
<input asp-for="Title" class="field-input" placeholder="Enter questionnaire title" />
|
|
<span asp-validation-for="Title" class="text-danger"></span>
|
|
</div>
|
|
<div class="field-group">
|
|
<label asp-for="Description">Description</label>
|
|
<textarea asp-for="Description" class="field-input" rows="1" placeholder="Brief description"></textarea>
|
|
<span asp-validation-for="Description" class="text-danger"></span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="builder-layout">
|
|
<div class="palette">
|
|
<div class="palette-title">Question Types</div>
|
|
<div id="questionTypePalette">
|
|
<div class="palette-item" data-type="Text" draggable="true"><span class="p-icon"><i class="bi bi-fonts"></i></span>Text</div>
|
|
<div class="palette-item" data-type="CheckBox" draggable="true"><span class="p-icon"><i class="bi bi-check2-square"></i></span>Checkbox</div>
|
|
<div class="palette-item" data-type="TrueFalse" draggable="true"><span class="p-icon"><i class="bi bi-toggle-on"></i></span>True / False</div>
|
|
<div class="palette-item" data-type="Multiple_choice" draggable="true"><span class="p-icon"><i class="bi bi-ui-radios"></i></span>Multiple Choice</div>
|
|
<div class="palette-item" data-type="Rating" draggable="true"><span class="p-icon"><i class="bi bi-star"></i></span>Rating</div>
|
|
<div class="palette-item" data-type="Likert" draggable="true"><span class="p-icon"><i class="bi bi-distribute-horizontal"></i></span>Likert Scale</div>
|
|
<div class="palette-item" data-type="Matrix" draggable="true"><span class="p-icon"><i class="bi bi-grid-3x3"></i></span>Matrix</div>
|
|
<div class="palette-item" data-type="Open_ended" draggable="true"><span class="p-icon"><i class="bi bi-chat-left-text"></i></span>Open Ended</div>
|
|
<div class="palette-item" data-type="Demographic" draggable="true"><span class="p-icon"><i class="bi bi-people"></i></span>Demographic</div>
|
|
<div class="palette-item" data-type="Ranking" draggable="true"><span class="p-icon"><i class="bi bi-sort-numeric-down"></i></span>Ranking</div>
|
|
<div class="palette-item" data-type="Image" draggable="true"><span class="p-icon"><i class="bi bi-image"></i></span>Image</div>
|
|
<div class="palette-item" data-type="Slider" draggable="true"><span class="p-icon"><i class="bi bi-sliders"></i></span>Slider</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="canvas-area">
|
|
<div class="canvas-drop" id="questionsCanvas">
|
|
<div class="canvas-empty" id="canvasPlaceholder">
|
|
<div class="canvas-empty-icon"><i class="bi bi-plus-lg"></i></div>
|
|
<p>Drag a question type from the left<br>or click one to add it here</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="submit-row">
|
|
<button type="submit" class="btn-submit"><i class="bi bi-check-lg"></i> Save Questionnaire</button>
|
|
</div>
|
|
|
|
<div id="hiddenFormData"></div>
|
|
</form>
|
|
</div>
|
|
|
|
@section Scripts {
|
|
<script>
|
|
$(document).ready(function () {
|
|
|
|
const typesRequiredAnswers = ['CheckBox','TrueFalse','Multiple_choice','Rating','Likert','Ranking','Demographic'];
|
|
const typesOptionalAnswers = ['Text','Open_ended','Matrix','Slider'];
|
|
const typeIsImage = 'Image';
|
|
const typesWithOther = ['Multiple_choice','CheckBox','TrueFalse','Demographic','Likert','Matrix'];
|
|
const typesWithConditions = ['Multiple_choice','CheckBox','TrueFalse','Demographic','Likert','Matrix','Rating','Ranking','Image'];
|
|
const defaultAnswers = { 'TrueFalse':['True','False'], 'Likert':['Strongly Disagree','Disagree','Neutral','Agree','Strongly Agree'], 'Rating':['1','2','3','4','5'] };
|
|
let questionIndex = 0;
|
|
|
|
const canvas = document.getElementById('questionsCanvas');
|
|
Sortable.create(canvas, { animation: 200, handle: '.q-drag', ghostClass: 'sortable-ghost', chosenClass: 'sortable-chosen', filter: '.canvas-empty', onSort: () => { updateNums(); rebuild(); refreshAllJumps(); } });
|
|
|
|
document.querySelectorAll('.palette-item').forEach(b => {
|
|
b.addEventListener('dragstart', e => { e.dataTransfer.setData('qType', b.dataset.type); e.dataTransfer.effectAllowed = 'copy'; });
|
|
b.addEventListener('click', () => addQ(b.dataset.type));
|
|
});
|
|
canvas.addEventListener('dragover', e => { e.preventDefault(); e.dataTransfer.dropEffect = 'copy'; canvas.classList.add('drag-over'); });
|
|
canvas.addEventListener('dragleave', () => canvas.classList.remove('drag-over'));
|
|
canvas.addEventListener('drop', e => { e.preventDefault(); canvas.classList.remove('drag-over'); const t = e.dataTransfer.getData('qType'); if (t) addQ(t); });
|
|
|
|
function addQ(type) {
|
|
$('#canvasPlaceholder').hide();
|
|
const qi = questionIndex;
|
|
const isImg = type === typeIsImage;
|
|
const isOpt = typesOptionalAnswers.includes(type);
|
|
const hasOther = typesWithOther.includes(type);
|
|
const hasCond = typesWithConditions.includes(type);
|
|
const defs = defaultAnswers[type] || [];
|
|
|
|
let ansHtml = '';
|
|
if (isImg) {
|
|
ansHtml = `<div class="ans-section"><div class="ans-header"><label>Image Answers</label></div><div class="img-ans-list" data-qi="${qi}">${imgAns(qi,0)}</div><button type="button" class="add-ans-btn add-img-btn" data-qi="${qi}"><i class="bi bi-plus"></i> Add Image</button></div>`;
|
|
} else {
|
|
let items = '';
|
|
if (defs.length) defs.forEach((v,i) => items += ansItem(qi,i,v,false,hasOther,hasCond));
|
|
else { items += ansItem(qi,0,'',false,hasOther,hasCond); items += ansItem(qi,1,'',false,hasOther,hasCond); }
|
|
const hint = isOpt ? `<span class="ans-hint">(optional)</span>` : '';
|
|
ansHtml = `<div class="ans-section"><div class="ans-header"><label>Answers ${hint}</label></div><div class="ans-list" data-qi="${qi}" data-other="${hasOther}" data-cond="${hasCond}">${items}</div><button type="button" class="add-ans-btn add-txt-btn" data-qi="${qi}" data-other="${hasOther}" data-cond="${hasCond}"><i class="bi bi-plus"></i> Add Answer</button></div>`;
|
|
}
|
|
|
|
const label = type.replace('_',' ');
|
|
$(canvas).append(`
|
|
<div class="q-card" data-qi="${qi}" data-type="${type}">
|
|
<div class="q-header">
|
|
<span class="q-drag"><i class="bi bi-grip-vertical"></i></span>
|
|
<span class="q-num">${qi+1}</span>
|
|
<span class="q-title" id="qTitle_${qi}">Untitled Question</span>
|
|
<span class="q-type-tag">${label}</span>
|
|
<span class="q-saved-tag"><i class="bi bi-check"></i> Saved</span>
|
|
<button type="button" class="q-chevron open" data-ti="${qi}"><i class="bi bi-chevron-down"></i></button>
|
|
<button type="button" class="q-remove" data-ri="${qi}"><i class="bi bi-x-lg"></i></button>
|
|
</div>
|
|
<div class="q-body show" id="qBody_${qi}">
|
|
<div class="field-group"><label>Question Text</label><textarea class="field-input q-text" data-qi="${qi}" placeholder="Type your question here..." rows="2"></textarea></div>
|
|
${ansHtml}
|
|
<div class="q-actions">
|
|
<button type="button" class="btn-q-save" data-qi="${qi}"><i class="bi bi-check-lg"></i> Save</button>
|
|
<button type="button" class="btn-q-edit" data-qi="${qi}"><i class="bi bi-pencil"></i> Edit</button>
|
|
</div>
|
|
</div>
|
|
</div>`);
|
|
|
|
const al = document.querySelector(`.ans-list[data-qi="${qi}"]`);
|
|
if (al) Sortable.create(al, { animation: 150, handle: '.ans-drag', ghostClass: 'sortable-ghost', onSort: () => rebuild() });
|
|
const il = document.querySelector(`.img-ans-list[data-qi="${qi}"]`);
|
|
if (il) Sortable.create(il, { animation: 150, handle: '.ans-drag', ghostClass: 'sortable-ghost', onSort: () => rebuild() });
|
|
|
|
questionIndex++;
|
|
updateNums(); rebuild(); refreshAllJumps();
|
|
$(`.q-text[data-qi="${qi}"]`).focus();
|
|
}
|
|
|
|
function ansItem(qi, ai, val, isOth, supOther, supCond) {
|
|
const othCls = isOth ? 'is-other' : '';
|
|
const othPill = supOther ? `<label class="ans-pill other-pill ${isOth?'active':''}" title="Other option"><input type="checkbox" class="oth-chk" ${isOth?'checked':''}><i class="bi bi-chat-dots"></i> Other</label>` : '';
|
|
const condPill = supCond ? `<label class="ans-pill logic-pill" title="Condition logic"><i class="bi bi-lightning"></i> Logic</label>` : '';
|
|
const condPanel = supCond ? `
|
|
<div class="logic-panel">
|
|
<label><i class="bi bi-lightning-fill"></i> When selected:</label>
|
|
<select class="logic-select cond-action"><option value="0">➡️ Continue normally</option><option value="1">🎯 Jump to question</option><option value="2">⏭️ Skip questions</option><option value="3">🏁 End survey</option></select>
|
|
<div class="logic-sub sub-jump"><label>Jump to:</label><select class="logic-select cond-jump"><option value="">-- select --</option></select></div>
|
|
<div class="logic-sub sub-skip"><label>Skip how many:</label><input type="number" class="logic-input cond-skip" min="1" value="1" /></div>
|
|
<div class="logic-sub sub-end"><label>End message:</label><input type="text" class="logic-input cond-end" placeholder="Thank you!" /></div>
|
|
<div class="logic-summary"><i class="bi bi-info-circle"></i> <span class="cond-sum">Continue normally</span></div>
|
|
</div>` : '';
|
|
return `<div class="ans-item ${othCls}" data-ai="${ai}"><span class="ans-drag"><i class="bi bi-grip-vertical"></i></span><input type="text" class="ans-input" placeholder="Answer option..." value="${val}" />${othPill}${condPill}<button type="button" class="ans-rm txt-rm" title="Remove"><i class="bi bi-trash3"></i></button>${condPanel}</div>`;
|
|
}
|
|
|
|
function imgAns(qi, ai) {
|
|
return `<div class="img-ans-item" data-ai="${ai}"><span class="ans-drag"><i class="bi bi-grip-vertical"></i></span><div class="img-upload-wrap"><div class="img-upload-inner"><div class="img-upload-label">Image ${ai+1}</div><input type="file" class="img-file-input" accept="image/*" data-qi="${qi}" data-ai="${ai}" /></div><img class="img-preview" id="imgP_${qi}_${ai}" src="" alt="" /></div><button type="button" class="ans-rm img-rm" title="Remove"><i class="bi bi-trash3"></i></button></div>`;
|
|
}
|
|
|
|
// ===== CONDITION LOGIC =====
|
|
$(document).on('click', '.logic-pill', function () {
|
|
const panel = $(this).closest('.ans-item').find('.logic-panel');
|
|
panel.toggleClass('show'); $(this).toggleClass('active');
|
|
if (panel.hasClass('show')) refreshJump($(this).closest('.ans-item'));
|
|
});
|
|
|
|
$(document).on('change', '.cond-action', function () {
|
|
const p = $(this).closest('.logic-panel');
|
|
p.find('.logic-sub').removeClass('show');
|
|
const v = $(this).val();
|
|
if (v==='1') p.find('.sub-jump').addClass('show');
|
|
else if (v==='2') p.find('.sub-skip').addClass('show');
|
|
else if (v==='3') p.find('.sub-end').addClass('show');
|
|
updateSum(p); updateAnsState($(this).closest('.ans-item')); rebuild();
|
|
});
|
|
|
|
$(document).on('change', '.cond-jump', function () { updateSum($(this).closest('.logic-panel')); rebuild(); });
|
|
$(document).on('input', '.cond-skip', function () { updateSum($(this).closest('.logic-panel')); rebuild(); });
|
|
$(document).on('input', '.cond-end', function () { rebuild(); });
|
|
|
|
function updateSum(p) {
|
|
const a = p.find('.cond-action').val(), s = p.find('.cond-sum');
|
|
if (a==='0') s.text('Continue normally');
|
|
else if (a==='1') { const t = p.find('.cond-jump option:selected').text(); s.text(t && t!=='-- select --' ? 'Jump to '+t : 'Jump to question'); }
|
|
else if (a==='2') s.text('Skip '+(p.find('.cond-skip').val()||1)+' question(s)');
|
|
else if (a==='3') s.text('End the survey');
|
|
}
|
|
|
|
function updateAnsState(item) {
|
|
const a = item.find('.cond-action').val();
|
|
if (a && a !== '0') { item.addClass('has-logic'); item.find('.logic-pill').addClass('active'); }
|
|
else { item.removeClass('has-logic'); if (!item.find('.logic-panel').hasClass('show')) item.find('.logic-pill').removeClass('active'); }
|
|
}
|
|
|
|
function refreshJump(item) {
|
|
const sel = item.find('.cond-jump'); if (!sel.length) return;
|
|
const cv = sel.val(); sel.empty().append('<option value="">-- select --</option>');
|
|
const ci = item.closest('.q-card').index();
|
|
$('.q-card').each(function (i) {
|
|
if (i<=ci) return;
|
|
const n=i+1, t=$(this).find('.q-title').text()||'Untitled';
|
|
sel.append(`<option value="${n}">Q${n}: ${t.length>35?t.substring(0,35)+'...':t}</option>`);
|
|
});
|
|
if (cv) sel.val(cv);
|
|
}
|
|
function refreshAllJumps() { $('.ans-item').each(function () { refreshJump($(this)); }); }
|
|
|
|
// ===== OTHER =====
|
|
$(document).on('change', '.oth-chk', function () {
|
|
const item = $(this).closest('.ans-item'), pill = $(this).closest('.ans-pill');
|
|
if ($(this).is(':checked')) { item.addClass('is-other'); pill.addClass('active'); const inp = item.find('.ans-input'); if (!inp.val().trim()) inp.val('Other (please specify)'); }
|
|
else { item.removeClass('is-other'); pill.removeClass('active'); }
|
|
rebuild();
|
|
});
|
|
|
|
// ===== IMAGE =====
|
|
$(document).on('change', '.img-file-input', function () {
|
|
const qi=$(this).data('qi'), ai=$(this).data('ai'), p=$(`#imgP_${qi}_${ai}`);
|
|
if (this.files&&this.files[0]) { const r=new FileReader(); r.onload=e=>p.attr('src',e.target.result).addClass('has-image'); r.readAsDataURL(this.files[0]); }
|
|
else p.attr('src','').removeClass('has-image');
|
|
rebuild();
|
|
});
|
|
|
|
// ===== ADD/REMOVE =====
|
|
$(document).on('click', '.add-txt-btn', function () {
|
|
const qi=$(this).data('qi'), o=String($(this).data('other'))==='true', c=String($(this).data('cond'))==='true';
|
|
const list=$(this).siblings('.ans-list');
|
|
list.append(ansItem(qi,list.children().length,'',false,o,c));
|
|
list.find('.ans-item:last .ans-input').focus(); rebuild(); refreshAllJumps();
|
|
});
|
|
$(document).on('click', '.txt-rm', function () { const l=$(this).closest('.ans-list'); if(l.children().length>1) $(this).closest('.ans-item').fadeOut(150,function(){$(this).remove();rebuild();refreshAllJumps();}); });
|
|
$(document).on('click', '.add-img-btn', function () { const qi=$(this).data('qi'),l=$(this).siblings('.img-ans-list'); l.append(imgAns(qi,l.children().length)); rebuild(); });
|
|
$(document).on('click', '.img-rm', function () { const l=$(this).closest('.img-ans-list'); if(l.children().length>1) $(this).closest('.img-ans-item').fadeOut(150,function(){$(this).remove();rebuild();}); });
|
|
|
|
// ===== TOGGLE / REMOVE =====
|
|
$(document).on('click', '.q-header', function (e) { if($(e.target).closest('.q-remove').length)return; const i=$(this).find('.q-chevron').data('ti'); $(`#qBody_${i}`).toggleClass('show'); $(this).find('.q-chevron').toggleClass('open'); });
|
|
$(document).on('click', '.q-remove', function (e) { e.stopPropagation(); $(this).closest('.q-card').fadeOut(200,function(){$(this).remove();updateNums();rebuild();refreshAllJumps();if(!$('.q-card').length)$('#canvasPlaceholder').show();}); });
|
|
|
|
// ===== SAVE / EDIT =====
|
|
$(document).on('click', '.btn-q-save', function () {
|
|
const qi=$(this).data('qi'), card=$(this).closest('.q-card'), type=card.data('type');
|
|
if(!card.find('.q-text').val().trim()){card.find('.q-text').css('border-color','var(--red)').focus();return;}
|
|
if(typesRequiredAnswers.includes(type)){let bad=false;card.find('.ans-input').each(function(){if(!$(this).val().trim()){$(this).css('border-color','var(--red)');bad=true;}});if(bad)return;}
|
|
if(type===typeIsImage){let m=false;card.find('.img-file-input').each(function(){if(!this.files||!this.files[0]){const p=$(this).closest('.img-ans-item').find('.img-preview');if(!p.hasClass('has-image')){$(this).css('border-color','var(--red)');m=true;}}});if(m)return;}
|
|
card.find('.q-text,.ans-input,.img-file-input,.oth-chk,.cond-action,.cond-jump,.cond-skip,.cond-end').prop('disabled',true);
|
|
card.find('.txt-rm,.img-rm,.logic-pill,.other-pill').css('pointer-events','none').css('opacity','0.4');
|
|
card.find('.add-txt-btn,.add-img-btn').hide();
|
|
card.find('.ans-drag').css('visibility','hidden');
|
|
card.find('.btn-q-save').hide(); card.find('.btn-q-edit').css('display','inline-flex');
|
|
card.addClass('saved'); $(`#qBody_${qi}`).removeClass('show'); card.find('.q-chevron').removeClass('open');
|
|
rebuild();
|
|
});
|
|
|
|
$(document).on('click', '.btn-q-edit', function () {
|
|
const qi=$(this).data('qi'), card=$(this).closest('.q-card');
|
|
card.find('.q-text,.ans-input,.img-file-input,.oth-chk,.cond-action,.cond-jump,.cond-skip,.cond-end').prop('disabled',false);
|
|
card.find('.txt-rm,.img-rm,.logic-pill,.other-pill').css('pointer-events','').css('opacity','');
|
|
card.find('.add-txt-btn,.add-img-btn').show();
|
|
card.find('.ans-drag').css('visibility','visible');
|
|
card.find('.btn-q-edit').hide(); card.find('.btn-q-save').show();
|
|
card.removeClass('saved'); $(`#qBody_${qi}`).addClass('show'); card.find('.q-chevron').addClass('open');
|
|
card.find('.q-text').focus();
|
|
});
|
|
|
|
$(document).on('input', '.q-text', function () { const qi=$(this).data('qi'); $(`#qTitle_${qi}`).text($(this).val().trim()||'Untitled Question'); $(this).css('border-color',''); rebuild(); refreshAllJumps(); });
|
|
$(document).on('input', '.ans-input', function () { $(this).css('border-color',''); rebuild(); });
|
|
|
|
function updateNums() {
|
|
let c = 0;
|
|
$('.q-card').each(function (i) { $(this).find('.q-num').text(i+1); c++; });
|
|
$('#questionCounter').text(c);
|
|
}
|
|
|
|
function buildCond(item) {
|
|
const sel = item.find('.cond-action'); if (!sel.length) return null;
|
|
const a = sel.val(); if (!a || a==='0') return null;
|
|
let c = {ActionType:parseInt(a)};
|
|
if (a==='1'){const t=item.find('.cond-jump').val();if(t)c.TargetQuestionNumber=parseInt(t);}
|
|
else if(a==='2'){const s=item.find('.cond-skip').val();if(s)c.SkipCount=parseInt(s);}
|
|
else if(a==='3'){const m=item.find('.cond-end').val();if(m)c.EndMessage=m;}
|
|
return JSON.stringify(c);
|
|
}
|
|
|
|
function rebuild() {
|
|
const ct = $('#hiddenFormData'); ct.empty();
|
|
$('.q-card').each(function (qi) {
|
|
const card=$(this), type=card.data('type'), text=card.find('.q-text').val()||'';
|
|
ct.append(`<input type="hidden" name="Questions[${qi}].Text" value="${esc(text)}" />`);
|
|
ct.append(`<input type="hidden" name="Questions[${qi}].Type" value="${type}" />`);
|
|
let ai=0;
|
|
card.find('.ans-list .ans-item').each(function(){
|
|
const v=$(this).find('.ans-input').val()||'', isO=$(this).find('.oth-chk').is(':checked'), cj=buildCond($(this));
|
|
if(v.trim()||typesRequiredAnswers.includes(type)){
|
|
ct.append(`<input type="hidden" name="Questions[${qi}].Answers[${ai}].Text" value="${esc(v)}" />`);
|
|
ct.append(`<input type="hidden" name="Questions[${qi}].Answers[${ai}].IsOtherOption" value="${isO}" />`);
|
|
if(cj) ct.append(`<input type="hidden" name="Questions[${qi}].Answers[${ai}].ConditionJson" value="${esc(cj)}" />`);
|
|
ai++;
|
|
}
|
|
});
|
|
if(type===typeIsImage) card.find('.img-file-input').each(function(ii){$(this).attr('name',`ImageFiles_${qi}_${ii}`);});
|
|
});
|
|
}
|
|
|
|
function esc(t){const d=document.createElement('div');d.appendChild(document.createTextNode(t));return d.innerHTML;}
|
|
|
|
$('#questionnaireForm').on('submit', function (e) {
|
|
$('.q-card.saved').find('.img-file-input,.q-text,.ans-input,.oth-chk,.cond-action,.cond-jump,.cond-skip,.cond-end').prop('disabled',false);
|
|
rebuild();
|
|
if(!$('.q-card').length){e.preventDefault();alert('Please add at least one question.');return false;}
|
|
let ok=true;
|
|
$('.q-card').each(function(){if(!$(this).find('.q-text').val()?.trim()){$(this).find('.q-text').css('border-color','var(--red)');ok=false;}});
|
|
if(!ok){e.preventDefault();alert('Please fill in all question texts.');return false;}
|
|
});
|
|
});
|
|
</script>
|
|
}
|