Merge branch 'dev' into 'staging'
Dev See merge request frontend/squzanswerer!101
This commit is contained in:
commit
ce6eb998d3
@ -43,10 +43,10 @@ export const publicationMakeRequest = ({ url, body }: any) => {
|
|||||||
headers: {
|
headers: {
|
||||||
"X-Sessionkey": SESSIONS,
|
"X-Sessionkey": SESSIONS,
|
||||||
"Content-Type": "multipart/form-data",
|
"Content-Type": "multipart/form-data",
|
||||||
// "DeviceType" : DeviceType,
|
"DeviceType" : DeviceType,
|
||||||
// "Device" : Device,
|
"Device" : Device,
|
||||||
// "OS": OSDevice,
|
"OS": OSDevice,
|
||||||
// "Browser" : browserUser
|
"Browser" : browserUser
|
||||||
},
|
},
|
||||||
method: "POST",
|
method: "POST",
|
||||||
});
|
});
|
||||||
@ -65,10 +65,10 @@ export async function getData(quizId: string): Promise<{
|
|||||||
headers: {
|
headers: {
|
||||||
"X-Sessionkey": SESSIONS,
|
"X-Sessionkey": SESSIONS,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
// "DeviceType" : DeviceType,
|
"DeviceType" : DeviceType,
|
||||||
// "Device" : Device,
|
"Device" : Device,
|
||||||
// "OS": OSDevice,
|
"OS": OSDevice,
|
||||||
// "Browser" : userAgent
|
"Browser" : userAgent
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
quiz_id: quizId,
|
quiz_id: quizId,
|
||||||
|
|||||||
@ -26,9 +26,10 @@ type Props = {
|
|||||||
quizSettings?: QuizSettings;
|
quizSettings?: QuizSettings;
|
||||||
quizId: string;
|
quizId: string;
|
||||||
preview?: boolean;
|
preview?: boolean;
|
||||||
|
changeFaviconAndTitle?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function QuizAnswerer({ quizSettings, quizId, preview = false }: Props) {
|
export default function QuizAnswerer({ quizSettings, quizId, preview = false, changeFaviconAndTitle = true }: Props) {
|
||||||
const [quizViewStore] = useState(createQuizViewStore);
|
const [quizViewStore] = useState(createQuizViewStore);
|
||||||
const [rootContainerWidth, setRootContainerWidth] = useState<number>(() => window.innerWidth);
|
const [rootContainerWidth, setRootContainerWidth] = useState<number>(() => window.innerWidth);
|
||||||
const rootContainerRef = useRef<HTMLDivElement>(null);
|
const rootContainerRef = useRef<HTMLDivElement>(null);
|
||||||
@ -65,7 +66,7 @@ export default function QuizAnswerer({ quizSettings, quizId, preview = false }:
|
|||||||
return (
|
return (
|
||||||
<QuizViewContext.Provider value={quizViewStore}>
|
<QuizViewContext.Provider value={quizViewStore}>
|
||||||
<RootContainerWidthContext.Provider value={rootContainerWidth}>
|
<RootContainerWidthContext.Provider value={rootContainerWidth}>
|
||||||
<QuizDataContext.Provider value={{ ...quizSettings, quizId, preview }}>
|
<QuizDataContext.Provider value={{ ...quizSettings, quizId, preview, changeFaviconAndTitle }}>
|
||||||
<LocalizationProvider dateAdapter={AdapterMoment} adapterLocale="ru" localeText={localeText}>
|
<LocalizationProvider dateAdapter={AdapterMoment} adapterLocale="ru" localeText={localeText}>
|
||||||
<ThemeProvider theme={lightTheme}>
|
<ThemeProvider theme={lightTheme}>
|
||||||
<SnackbarProvider
|
<SnackbarProvider
|
||||||
|
|||||||
@ -54,6 +54,8 @@ export const Question = ({
|
|||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
height: "100%",
|
height: "100%",
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
background: settings.cfg.design
|
background: settings.cfg.design
|
||||||
? quizThemes[settings.cfg.theme].isLight
|
? quizThemes[settings.cfg.theme].isLight
|
||||||
? "transparent"
|
? "transparent"
|
||||||
@ -64,19 +66,19 @@ export const Question = ({
|
|||||||
>
|
>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
height: "calc(100% - 75px)",
|
|
||||||
overflow: "auto",
|
overflow: "auto",
|
||||||
width: "100%"
|
width: "100%",
|
||||||
|
flexGrow: 1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
height: "calc(100% - 75px)",
|
position: "relative",
|
||||||
|
height: "100%",
|
||||||
width: "100%",
|
width: "100%",
|
||||||
maxWidth: "1440px",
|
maxWidth: "1440px",
|
||||||
padding: "40px 25px 20px",
|
padding: "40px 25px 20px",
|
||||||
margin: "0 auto",
|
margin: "0 auto",
|
||||||
//overflow: "auto",
|
|
||||||
display: "flex",
|
display: "flex",
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
justifyContent: "space-between",
|
justifyContent: "space-between",
|
||||||
@ -88,14 +90,30 @@ export const Question = ({
|
|||||||
stepNumber={currentQuestionStepNumber}
|
stepNumber={currentQuestionStepNumber}
|
||||||
/>
|
/>
|
||||||
{show_badge && (
|
{show_badge && (
|
||||||
<Link target="_blank" href="https://quiz.pena.digital" sx={{ mt: "20px", textAlign: "end" }}>
|
<Link
|
||||||
|
target="_blank"
|
||||||
|
href="https://quiz.pena.digital"
|
||||||
|
sx={{
|
||||||
|
position: "absolute",
|
||||||
|
bottom: "20px",
|
||||||
|
right: "25px",
|
||||||
|
}}
|
||||||
|
>
|
||||||
{quizThemes[settings.cfg.theme].isLight ? (
|
{quizThemes[settings.cfg.theme].isLight ? (
|
||||||
<NameplateLogoFQ
|
<NameplateLogoFQ
|
||||||
style={{ fontSize: "34px", width: "200px", height: "auto" }}
|
style={{
|
||||||
|
fontSize: "34px",
|
||||||
|
width: "200px",
|
||||||
|
height: "auto",
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<NameplateLogoFQDark
|
<NameplateLogoFQDark
|
||||||
style={{ fontSize: "34px", width: "200px", height: "auto" }}
|
style={{
|
||||||
|
fontSize: "34px",
|
||||||
|
width: "200px",
|
||||||
|
height: "auto",
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@ -16,7 +16,7 @@ import PrevButton from "./tools/PrevButton";
|
|||||||
import "https://markknol.github.io/console-log-viewer/console-log-viewer.js"
|
import "https://markknol.github.io/console-log-viewer/console-log-viewer.js"
|
||||||
|
|
||||||
export default function ViewPublicationPage() {
|
export default function ViewPublicationPage() {
|
||||||
const { settings, recentlyCompleted, quizId, preview } = useQuizData();
|
const { settings, recentlyCompleted, quizId, preview, changeFaviconAndTitle } = useQuizData();
|
||||||
const answers = useQuizViewStore(state => state.answers);
|
const answers = useQuizViewStore(state => state.answers);
|
||||||
let currentQuizStep = useQuizViewStore((state) => state.currentQuizStep);
|
let currentQuizStep = useQuizViewStore((state) => state.currentQuizStep);
|
||||||
const {
|
const {
|
||||||
@ -31,17 +31,16 @@ export default function ViewPublicationPage() {
|
|||||||
|
|
||||||
const isAnswer = answers.some(ans => ans.questionId === currentQuestion.id);
|
const isAnswer = answers.some(ans => ans.questionId === currentQuestion.id);
|
||||||
|
|
||||||
useEffect(
|
useEffect(function setFaviconAndTitle() {
|
||||||
function setFaviconAndTitle() {
|
if (!changeFaviconAndTitle) return;
|
||||||
const link = document.querySelector('link[rel="icon"]');
|
|
||||||
if (link && settings.cfg.startpage.favIcon) {
|
|
||||||
link.setAttribute("href", settings.cfg.startpage.favIcon);
|
|
||||||
}
|
|
||||||
|
|
||||||
document.title = settings.name;
|
const link = document.querySelector('link[rel="icon"]');
|
||||||
},
|
if (link && settings.cfg.startpage.favIcon) {
|
||||||
[settings]
|
link.setAttribute("href", settings.cfg.startpage.favIcon);
|
||||||
);
|
}
|
||||||
|
|
||||||
|
document.title = settings.name;
|
||||||
|
}, [changeFaviconAndTitle, settings.cfg.startpage.favIcon, settings.name]);
|
||||||
|
|
||||||
if (recentlyCompleted) throw new Error("Quiz already completed");
|
if (recentlyCompleted) throw new Error("Quiz already completed");
|
||||||
if (currentQuizStep === "startpage" && settings.cfg.noStartPage)
|
if (currentQuizStep === "startpage" && settings.cfg.noStartPage)
|
||||||
|
|||||||
@ -1,7 +1,11 @@
|
|||||||
import { QuizSettings } from "@model/settingsData";
|
import { QuizSettings } from "@model/settingsData";
|
||||||
import { createContext, useContext } from "react";
|
import { createContext, useContext } from "react";
|
||||||
|
|
||||||
type QuizData = QuizSettings & { quizId: string; preview: boolean; };
|
type QuizData = QuizSettings & {
|
||||||
|
quizId: string;
|
||||||
|
preview: boolean;
|
||||||
|
changeFaviconAndTitle: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
export const QuizDataContext = createContext<QuizData | null>(null);
|
export const QuizDataContext = createContext<QuizData | null>(null);
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@frontend/squzanswerer",
|
"name": "@frontend/squzanswerer",
|
||||||
"version": "1.0.18",
|
"version": "1.0.19",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "./dist-package/index.js",
|
"main": "./dist-package/index.js",
|
||||||
"module": "./dist-package/index.js",
|
"module": "./dist-package/index.js",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user