frontend: display MCQ in interface
This commit is contained in:
parent
6903c91df2
commit
d6012dfffb
@ -219,18 +219,49 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||||||
o.found = $scope.my.exercices[$rootScope.current_exercice].solved_matrix[kid];
|
o.found = $scope.my.exercices[$rootScope.current_exercice].solved_matrix[kid];
|
||||||
this.push(o);
|
this.push(o);
|
||||||
}, $scope.flags);
|
}, $scope.flags);
|
||||||
|
|
||||||
|
$scope.mcqs = [];
|
||||||
|
angular.forEach($scope.my.exercices[$rootScope.current_exercice].mcqs, function(mcq,qid) {
|
||||||
|
var o = {
|
||||||
|
title: mcq.title,
|
||||||
|
kind: mcq.kind,
|
||||||
|
solved: mcq.solved,
|
||||||
|
choices: {}
|
||||||
|
};
|
||||||
|
angular.forEach(mcq["choices"], function(choice,cid) {
|
||||||
|
this[cid] = {
|
||||||
|
label: choice,
|
||||||
|
value: false
|
||||||
|
};
|
||||||
|
}, o["choices"]);
|
||||||
|
this.push(o);
|
||||||
|
}, $scope.mcqs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
waitMy();
|
waitMy();
|
||||||
|
|
||||||
$scope.ssubmit = function() {
|
$scope.ssubmit = function() {
|
||||||
var flgs = {}
|
var resp = {}
|
||||||
|
|
||||||
|
if ($scope.flags && $scope.flags.length)
|
||||||
|
{
|
||||||
|
resp["flags"] = {};
|
||||||
angular.forEach($scope.flags, function(flag,kid) {
|
angular.forEach($scope.flags, function(flag,kid) {
|
||||||
flgs[flag.name] = flag.value;
|
resp["flags"][flag.name] = flag.value;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$http({ url: "/submit/" + $rootScope.current_exercice, method: "POST", data: flgs }).then(function(response, status, header, config) {
|
if ($scope.mcqs && $scope.mcqs.length)
|
||||||
|
{
|
||||||
|
resp["mcqs"] = {};
|
||||||
|
angular.forEach($scope.mcqs, function(mcq) {
|
||||||
|
angular.forEach(mcq.choices, function(choice, cid) {
|
||||||
|
if (choice.value) resp["mcqs"][cid] = choice.value;
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$http({ url: "/submit/" + $rootScope.current_exercice, method: "POST", data: resp }).then(function(response, status, header, config) {
|
||||||
$rootScope.messageClass = {"text-success": true};
|
$rootScope.messageClass = {"text-success": true};
|
||||||
$rootScope.message = response.data.errmsg;
|
$rootScope.message = response.data.errmsg;
|
||||||
$rootScope.sberr = "";
|
$rootScope.sberr = "";
|
||||||
@ -242,7 +273,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
|||||||
var checkDiff = function() {
|
var checkDiff = function() {
|
||||||
$http.get("/my.json").then(function(response) {
|
$http.get("/my.json").then(function(response) {
|
||||||
var my = response.data;
|
var my = response.data;
|
||||||
if ($scope.my.exercices[$rootScope.current_exercice].solved_time != my.exercices[$rootScope.current_exercice].solved_time) {
|
if ($scope.my.exercices[$rootScope.current_exercice].tries != my.exercices[$rootScope.current_exercice].tries || $scope.my.exercices[$rootScope.current_exercice].solved_time != my.exercices[$rootScope.current_exercice].solved_time) {
|
||||||
$rootScope.refresh();
|
$rootScope.refresh();
|
||||||
$scope.my = my;
|
$scope.my = my;
|
||||||
waitMy();
|
waitMy();
|
||||||
|
@ -67,6 +67,17 @@
|
|||||||
<input type="text" class="form-control" id="sol_{{ key.id }}" name="sol_{{ key.id }}" ng-model="key.value" ng-disabled="key.found">
|
<input type="text" class="form-control" id="sol_{{ key.id }}" name="sol_{{ key.id }}" ng-model="key.value" ng-disabled="key.found">
|
||||||
<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true" ng-if="key.found"></span>
|
<span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true" ng-if="key.found"></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-check" ng-repeat="(k,mcq) in mcqs">
|
||||||
|
<p ng-if="mcq.title" ng-bind="mcq.title"></p>
|
||||||
|
<label class="custom-control custom-checkbox" ng-repeat="(cid,choice) in mcq.choices" style="display: block">
|
||||||
|
<input class="custom-control-input" type="checkbox" name="mcq_{{k}}_{{cid}}" ng-model="choice.value">
|
||||||
|
<span class="custom-control-indicator"></span>
|
||||||
|
<span class="custom-control-description" ng-bind="mcq.label"></span>
|
||||||
|
</label>
|
||||||
|
<hr>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group text-right">
|
<div class="form-group text-right">
|
||||||
<button type="submit" class="btn btn-danger" id="sbmt">Soumettre</button>
|
<button type="submit" class="btn btn-danger" id="sbmt">Soumettre</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -17,22 +17,29 @@ type myTeamFile struct {
|
|||||||
type myTeamHint struct {
|
type myTeamHint struct {
|
||||||
HintId int64 `json:"id"`
|
HintId int64 `json:"id"`
|
||||||
Title string `json:"title"`
|
Title string `json:"title"`
|
||||||
Content *string `json:"content"`
|
Content *string `json:"content,omitempty"`
|
||||||
File *string `json:"file"`
|
File *string `json:"file,omitempty"`
|
||||||
Cost int64 `json:"cost"`
|
Cost int64 `json:"cost"`
|
||||||
}
|
}
|
||||||
|
type myTeamMCQ struct {
|
||||||
|
Title string `json:"title"`
|
||||||
|
Kind string `json:"kind"`
|
||||||
|
Choices map[int64]string `json:"choices,omitempty"`
|
||||||
|
Solved *time.Time `json:"solved,omitempty"`
|
||||||
|
}
|
||||||
type myTeamExercice struct {
|
type myTeamExercice struct {
|
||||||
ThemeId int `json:"theme_id"`
|
ThemeId int `json:"theme_id"`
|
||||||
Statement string `json:"statement"`
|
Statement string `json:"statement"`
|
||||||
Hints []myTeamHint `json:"hints"`
|
Hints []myTeamHint `json:"hints,omitempty"`
|
||||||
Gain float64 `json:"gain"`
|
Gain float64 `json:"gain"`
|
||||||
Files []myTeamFile `json:"files"`
|
Files []myTeamFile `json:"files,omitempty"`
|
||||||
Keys []string `json:"keys"`
|
Keys []string `json:"keys,omitempty"`
|
||||||
SolvedMat []bool `json:"solved_matrix"`
|
SolvedMat []bool `json:"solved_matrix,omitempty"`
|
||||||
SolvedTime time.Time `json:"solved_time"`
|
MCQs []myTeamMCQ `json:"mcqs,omitempty"`
|
||||||
SolvedRank int64 `json:"solved_rank"`
|
SolvedTime time.Time `json:"solved_time,omitempty"`
|
||||||
Tries int64 `json:"tries"`
|
SolvedRank int64 `json:"solved_rank,omitempty"`
|
||||||
VideoURI string `json:"video_uri"`
|
Tries int64 `json:"tries,omitempty"`
|
||||||
|
VideoURI string `json:"video_uri,omitempty"`
|
||||||
}
|
}
|
||||||
type myTeam struct {
|
type myTeam struct {
|
||||||
Id int64 `json:"team_id"`
|
Id int64 `json:"team_id"`
|
||||||
@ -121,6 +128,22 @@ func MyJSONTeam(t *Team, started bool) (interface{}, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Expose exercice MCQs
|
||||||
|
|
||||||
|
exercice.MCQs = []myTeamMCQ{}
|
||||||
|
|
||||||
|
if mcqs, err := e.GetMCQ(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
} else {
|
||||||
|
for _, mcq := range mcqs {
|
||||||
|
choices := map[int64]string{}
|
||||||
|
for _, e := range mcq.Entries {
|
||||||
|
choices[e.Id] = e.Label
|
||||||
|
}
|
||||||
|
exercice.MCQs = append(exercice.MCQs, myTeamMCQ{mcq.Title, mcq.Kind, choices, t.HasPartiallyRespond(mcq)})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Expose exercice keys
|
// Expose exercice keys
|
||||||
|
|
||||||
exercice.Keys = []string{}
|
exercice.Keys = []string{}
|
||||||
|
Loading…
Reference in New Issue
Block a user