Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 442 | Rev 452 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
306 geraldo 1
import React from "react";
2
import Option from "../option/Option";
3
 
4
const Question = (props) => {
310 geraldo 5
 
306 geraldo 6
    // get props
340 geraldo 7
    const { question, backendVars, handleAnswer } = props;
306 geraldo 8
 
9
    return (
313 geraldo 10
        <div className="col-md-12 col-sm-12 col-xs-12 np-padding">
310 geraldo 11
            <div className="form-group" >
333 geraldo 12
                <h6>{backendVars.LBL_QUESTION} #{question.position + 1}</h6>
310 geraldo 13
                <div
14
                    dangerouslySetInnerHTML={{ __html: question.text }}
15
                    className="title"
16
                />
17
            </div>
306 geraldo 18
            {question.type == 'open' &&
310 geraldo 19
                <div className="form-group">
306 geraldo 20
                    {question.multiline == 1 ? (
21
                        <textarea
22
                            className="form-control"
23
                            rows="5"
442 geraldo 24
                            value={question.answer}
306 geraldo 25
                            maxLength={question.maxlength}
26
                            name={question.slug_question}
342 geraldo 27
                            onChange={e =>
28
                                handleAnswer(question.slug_section, question.slug_question, e.target.value)
29
                            }
30
                        />
306 geraldo 31
                    ) : (
32
                        <input
33
                            type="text"
34
                            className="form-control"
442 geraldo 35
                            value={question.answer}
306 geraldo 36
                            maxLength={question.maxlength}
340 geraldo 37
                            name={question.slug_question}
342 geraldo 38
                            onChange={e =>
39
                                handleAnswer(question.slug_section, question.slug_question, e.target.value)
40
                            }
41
                        />
306 geraldo 42
                    )}
43
                </div>
44
            }
45
            {question.type == 'rating-range' &&
310 geraldo 46
                <div className="form-group">
334 geraldo 47
                    {[...Array(parseInt(question.range))].map((x, i) => {
306 geraldo 48
                        return (
333 geraldo 49
                            <div className="checkbox"
50
                                key={i}>
306 geraldo 51
                                <input
52
                                    type="radio"
443 geraldo 53
                                    checked={question.answer == i + 1}
306 geraldo 54
                                    name={question.slug_question}
342 geraldo 55
                                    value={i + 1}
56
                                    onChange={() =>
57
                                        handleAnswer(question.slug_section, question.slug_question, i + 1)
58
                                    }
59
                                />
333 geraldo 60
                                <div className="option">
336 geraldo 61
                                    {i + 1}
333 geraldo 62
                                </div>
306 geraldo 63
                            </div>
64
                        )
65
                    })}
66
                </div>
67
            }
333 geraldo 68
            {(question.type == 'simple' || question.type == 'rating-open' || question.type == 'multiple') &&
310 geraldo 69
                <div className="form-group">
323 geraldo 70
                    {question.options.length > 0 &&
340 geraldo 71
                        <Option
72
                            question={question}
73
                            handleAnswer={handleAnswer} />
306 geraldo 74
                    }
75
                </div>
76
            }
77
        </div>
78
    )
79
}
80
 
81
export default Question;