Skip to content

Commit 42fccca

Browse files
author
christophe_guide
committed
Suppression de PlayQuestions.js pour l'inclure dans Play.js
1 parent 642f2b2 commit 42fccca

File tree

3 files changed

+31
-23
lines changed

3 files changed

+31
-23
lines changed

front/src/components/Play.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useParams } from 'react-router-dom';
33
import axios from 'axios';
44
import config from '../config';
55
import {Redirect} from 'react-router-dom';
6-
import PlayQuestion from './PlayQuestion';
6+
import ReactPlayer from 'react-player'
77
import './css/play.css';
88

99
export default function Play(){
@@ -30,6 +30,7 @@ export default function Play(){
3030
}
3131
});
3232
}
33+
3334
async function fetchQuestions(){
3435
await axios.get(`http://${config.server}/quizzes/${id_quizz}/questions`)
3536
.then(res => {
@@ -45,6 +46,23 @@ export default function Play(){
4546
});
4647
}
4748

49+
function playQuestion(question){
50+
return (
51+
<div id='question'>
52+
{question.path_file !== '' ?
53+
<ReactPlayer
54+
id='player'
55+
controls={true}
56+
volume={0.5}
57+
wrapper='question'
58+
url={`http://${config.server}/video/${question.path_file}`}
59+
/>
60+
: ''}
61+
<h2>{question.question}</h2>
62+
</div>
63+
);
64+
}
65+
4866
useEffect(() => {
4967
fetchQuizz();
5068
fetchQuestions();
@@ -81,13 +99,13 @@ export default function Play(){
8199
}
82100
}
83101

84-
function handleNext(){
102+
function handleNext(){
85103
for(const i of document.querySelectorAll('.material-icons')){
86104
i.style.visibility = 'hidden';
87105
}
88106
document.querySelector('#next-button').style.visibility='hidden';
89107
setCurrentidx(parseInt(currentidx)+1);
90-
setAnswered(false);
108+
setAnswered(false);
91109
}
92110

93111
return(
@@ -99,17 +117,19 @@ export default function Play(){
99117
<h2>{quizz ? quizz.title : "Quizz not found"}</h2>
100118
</div>
101119

102-
{currentQuestion ? <PlayQuestion question={currentQuestion.question} src={currentQuestion.path_file}/> : ''}
120+
{currentQuestion ? playQuestion(currentQuestion) : ''}
103121

104122
<div id='score'>
105123
<h2>Score : {score ? score : 0}</h2>
106124
</div>
125+
126+
<div id='chrono'>
127+
</div>
107128

108129
<div id='answers'>
109130
{ currentAnswers ?
110131
currentAnswers.map((a, idx) => {
111132
if(a.path_file.split('.')[1] !== 'jpg'){
112-
console.log('pas image')
113133
return(
114134
<div className='answer'
115135
id={'answer'+idx}

front/src/components/PlayQuestion.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

front/src/components/css/play.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
right: 5%;
1515
}
1616

17+
#chrono{
18+
position: absolute;
19+
top: 40px;
20+
left: 5%;
21+
font-size: 2em;
22+
}
1723

1824
#score>h2{
1925
font-size: 2em;

0 commit comments

Comments
 (0)