selection of method and instruction fixed

parent 81e74156
......@@ -6,15 +6,15 @@
"license": "Private",
"private": true,
"dependencies": {
"angular": "1.2.x",
"angular-mocks": "1.3.x",
"angular": "~1.2.2",
"angular-mocks": "~1.3.1",
"jquery": "^3.1.1",
"bootstrap": "~3.1.1",
"jquery-timeago": "1.4.x",
"jquery-timeago": "~1.4.1",
"angular-translate": "~2.6.0",
"angular-translate-loader-static-files": "~2.6.1",
"angular-bootstrap": "~0.12.1",
"ng-file-upload": "12.2.x",
"ng-file-upload": "~12.2.1",
"ngImgCrop": "~0.3.2",
"angular-ui-router": "~0.2.13",
"angular-filter": "~0.5.4",
......
......@@ -36,11 +36,21 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
// Visibility of the list of stored sessions
$scope.showSessions = false;
// Initially, show the last try
$scope.showLastTry = true;
$scope.selected = { item: -1 };
// Query to obtain an array of student methods
$http
.get(config.backend+'/stu/'+ $scope.studentData.id +'/methods')
.success(function(data, status, headers, config) {
$scope.methods = data;
for (var i = 0; i < $scope.methods.length; i++) {
for (var j = 0; j < $scope.methods[i].instructions; j++) {
$scope.methods[i].instructions[j].m_name = $scope.methods[i].name;
}
}
})
.error(function(data, status, headers, config) {
});
......@@ -59,11 +69,6 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
.error(function(data, status, headers, config) {
});
// Initially, show the last try
$scope.showLastTry = true;
$scope.selectedIns = -1;
////////////////////////////////////////////////////////////////////////////
// Tries ///////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
......@@ -72,14 +77,18 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
// load its working sessions with its associated tries and with its actions
$scope.load_tries = function (){
if ($scope.selectedIns == -1)
if ($scope.selected.item == -1)
return;
$scope.showLastTry = false;
var ids = $scope.selected.item.split("-"); // this is because Angular 1.2 doesn't assign objects in ng-value
$scope.selected.method = $scope.methods[parseInt(ids[0])];
$scope.selected.instruction = $scope.selected.method.instructions[parseInt(ids[1])];
// If to avoid the default select option "-- select one instruction --"
$http
.get(config.backend+'/instruction/'+ $scope.selectedIns +'/ws')
.get(config.backend+'/instruction/'+ $scope.selected.instruction.id +'/ws')
.success(function(data, status, headers, config) {
// Add to list
$scope.wsessions = data;
......@@ -128,7 +137,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
.post(config.backend+'/try/', {ws: $scope.ws, student: $scope.studentData.id, supervisor: $scope.user.id, begin:new Date().toISOString() })
.then(
function(data, status, headers, config) {
$scope.load_tries($scope.selectedIns);
$scope.load_tries();
// Empty actual try and push the first action of next try
$scope.actual_try.actions = [];
$scope.actual_try.actions.push({ action: 'tryinit' });
......@@ -183,7 +192,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
.post(config.backend+'/ws', {
"id_sup": $scope.user.id,
"id_stu": $scope.studentData.id,
"id_ins": $scope.selectedIns.id,
"id_ins": scope.selected.instruction.id,
"begin": new Date().toISOString()
})
.success(function(data, status, headers, config) {
......@@ -202,8 +211,9 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
// Adding initial action to the list of actions
$scope.actual_try.actions.push({ action: 'tryinit' });
$scope.studentData.current_method=$scope.selectedMethod.name;
$scope.studentData.current_instruction=$scope.selectedIns.name;
$scope.studentData.current_method = scope.selected.method.name;
$scope.studentData.current_instruction = scope.selected.instruction.name;
})
.error(function(data, status, headers, config) {
ngToast.danger({ content: $translate.instant('error_creating_session') });
......@@ -360,22 +370,18 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
}
return false;
}
//
// websockets events handling (Dashboard)
//
io.socket.on('update_peers', function (data) {
if($scope.ws && $scope.sessionRunning && $scope.actual_try.actions && $scope.paused == false && data.count<2) {
$scope.pause_ws();
$scope.pauseTimer();
$translate('room_changed').then(function (translation) {
ngToast.create({
className: 'warning',
content: translation,
dismissOnTimeout: false,
dismissButton: true
});
ngToast.warning({
content: $translate.instant('room_changed'),
dismissOnTimeout: false,
dismissButton: true
});
}
});
......@@ -407,7 +413,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
case 'Show':
// Empty actual try and push the first action of next try
if (!data.attributes.id_sup) {
$scope.load_tries($scope.selectedIns);
$scope.load_tries();
$scope.actual_try.actions = [];
$scope.actual_try.actions.push({ action: 'tryinit' });
}
......
......@@ -8,25 +8,28 @@
<div class="row">
<div class="col-md-6">
<form role="form" action="#" ng-hide="ws_recover ">
<select class="form-control" name="met_select" id="met_select" ng-model="selectedIns" ng-change="load_tries()">
<select class="form-control" name="met_select" id="met_select" ng-model="selected.item" ng-change="load_tries()">
<option value="-1" selected disabled hidden>{{ 'select_instruction' | translate }}</option>
<optgroup ng-repeat="m in methods" label="{{ m.name }}">
<option ng-repeat="ins in m.instructions" ng-value="ins.id">{{ins.name}}</option>
<optgroup ng-repeat="m in methods track by $index" label="{{ m.name }}">
<option ng-repeat="ins in m.instructions track by $index" value="{{$parent.$index}}-{{$index}}">{{ins.name}}</option>
</optgroup>
</select>
</form>
</div>
<div class="col-md-6">
<div class="row session-controls form-horizontal" ng-show="selectedIns != -1">
<div class="row session-controls form-horizontal" ng-show="selected.item != -1">
<div class="col-md-4 form-group">
<label class="control-label" translate> sessions </label>
<button ng-click="showSessions = !showSessions" class="btn btn-default" ng-disabled="wsessions.length == 0">
<span class="badge" style="font-size: 10pt"> {{ wsessions.length }}</span>
<span class="glyphicon glyphicon-collapse-down" aria-hidden="true" ng-show="!showSessions"></span>
<span class="glyphicon glyphicon-collapse-up" aria-hidden="true" ng-show="showSessions"></span>
<span class="control-label"> {{ wsessions.length }} {{ 'sessions' | translate }}</span>
<button ng-click="showSessions = !showSessions" class="btn btn-default btn-sm" ng-disabled="wsessions.length == 0">
<div ng-show="!showSessions">
{{ 'show' | translate }} <span class="glyphicon glyphicon-collapse-down" aria-hidden="true"></span>
</div>
<div ng-show="showSessions">
{{ 'hide' | translate }} <span class="glyphicon glyphicon-collapse-up" aria-hidden="true"></span>
</div>
</button>
</div>
<div class="col-md-8 form-group" ng-disabled="selectedIns == -1 || studentData.num_peers<2">
<div class="col-md-8 form-group" ng-disabled="selected.item == -1 || studentData.num_peers<2">
<div class="btn-group pull-right"> <!-- controls for session recording-->
<button type="button"
class="btn btn-default btn-sm"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment