Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
yotta
/
pictogram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
60
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b7aef735
authored
Jan 16, 2016
by
Fernando Martínez Santiago
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Instructions bug fixed (issue
#309
)
parent
2ad4ba48
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
121 additions
and
116 deletions
sails/conf/pictodb_init_keepsymbolstix.sql
sails/conf/pictodb_sessions_integrity_constraints.sql
sails/src/api/controllers/StudentController.js
sails/src/api/controllers/WorkingSessionController.js
sails/src/assets/app/modules/student/controllers/session.js
sails/src/assets/app/modules/student/controllers/student.js
sails/src/assets/app/modules/student/views/session.html
sails/conf/pictodb_init_keepsymbolstix.sql
100755 → 100644
View file @
b7aef735
File mode changed
sails/conf/pictodb_sessions_integrity_constraints.sql
View file @
b7aef735
...
@@ -30,11 +30,11 @@ END;;
...
@@ -30,11 +30,11 @@ END;;
-- Memory table in order to recover data about current working sessions
-- Memory table in order to recover data about current working sessions
--
--
CREATE
TABLE
stu_opentry
(
CREATE
TABLE
stu_opentry
(
id
int
NOT
NULL
AUTO_INCREMENT
,
id
int
(
11
)
NOT
NULL
AUTO_INCREMENT
,
id_stu
int
NOT
NULL
,
id_stu
int
(
11
)
NOT
NULL
,
id_sup
int
NOT
NULL
,
id_sup
int
(
11
)
NOT
NULL
,
id_ws
int
NOT
NULL
,
id_ws
int
(
11
)
NOT
NULL
,
id_opentry
int
,
id_opentry
int
(
11
)
,
total_tries
int
DEFAULT
0
,
total_tries
int
DEFAULT
0
,
begin
timestamp
NULL
,
begin
timestamp
NULL
,
end
timestamp
NULL
,
end
timestamp
NULL
,
...
@@ -42,11 +42,10 @@ PRIMARY KEY(id),
...
@@ -42,11 +42,10 @@ PRIMARY KEY(id),
UNIQUE
(
id_stu
),
UNIQUE
(
id_stu
),
UNIQUE
(
id_sup
),
UNIQUE
(
id_sup
),
UNIQUE
(
id_ws
),
UNIQUE
(
id_ws
),
FOREIGN
KEY
(
id_stu
)
REFERENCES
student
,
FOREIGN
KEY
(
id_stu
)
REFERENCES
student
(
id
),
FOREIGN
KEY
(
id_opentry
)
REFERENCES
try
,
FOREIGN
KEY
(
id_opentry
)
REFERENCES
try
(
id
)
ON
DELETE
SET
NULL
,
INDEX
USING
HASH
(
id_stu
),
FOREIGN
KEY
(
id_ws
)
REFERENCES
working_session
(
id
)
ON
DELETE
CASCADE
INDEX
USING
HASH
(
id_ws
)
)
ENGINE
=
InnoDB
;;
)
ENGINE
=
MEMORY
;;
--
--
-- It creates a new try and notes down the try into the STU_OPENTRY memory table
-- It creates a new try and notes down the try into the STU_OPENTRY memory table
...
@@ -87,9 +86,6 @@ BEGIN
...
@@ -87,9 +86,6 @@ BEGIN
IF
(
idopentry
IS
NOT
NULL
)
THEN
IF
(
idopentry
IS
NOT
NULL
)
THEN
DELETE
FROM
try
DELETE
FROM
try
WHERE
id
=
idopentry
;
WHERE
id
=
idopentry
;
UPDATE
stu_opentry
SET
id_opentry
=
NULL
WHERE
id_opentry
=
idopentry
;
END
IF
;
END
IF
;
END
;;
END
;;
...
@@ -131,6 +127,7 @@ BEGIN
...
@@ -131,6 +127,7 @@ BEGIN
END
IF
;
END
IF
;
END
;;
END
;;
-- Integrity rule 3: every event is required to have the id try whenver a try happens
-- Integrity rule 3: every event is required to have the id try whenver a try happens
-- when: state COM, event a4
-- when: state COM, event a4
--
--
...
@@ -201,6 +198,8 @@ END;;
...
@@ -201,6 +198,8 @@ END;;
ALTER
TABLE
`working_session`
ALTER
TABLE
`working_session`
ADD
CONSTRAINT
`idx_ws_supcur`
UNIQUE
(
id_sup
,
current
);;
ADD
CONSTRAINT
`idx_ws_supcur`
UNIQUE
(
id_sup
,
current
);;
-- Integrity rule 2: when a session is closed, last try must be discharged
-- Integrity rule 2: when a session is closed, last try must be discharged
-- when: state COM, event a4
-- when: state COM, event a4
-- current is to NULL (integrity rule 6)
-- current is to NULL (integrity rule 6)
...
...
sails/src/api/controllers/StudentController.js
View file @
b7aef735
...
@@ -722,7 +722,7 @@ module.exports = {
...
@@ -722,7 +722,7 @@ module.exports = {
var
attributes
=
req
.
param
(
'attributes'
);
var
attributes
=
req
.
param
(
'attributes'
);
var
roomName
=
'studentRoom'
+
attributes
.
id_stu
;
var
roomName
=
'studentRoom'
+
attributes
.
id_stu
;
sails
.
log
.
debug
(
"Inside action
"
);
sails
.
log
.
debug
(
"Inside action
. Student:"
+
attributes
.
id_stu
);
if
(
req
.
isSocket
)
{
if
(
req
.
isSocket
)
{
sails
.
log
.
debug
(
"websockets - room "
+
roomName
);
sails
.
log
.
debug
(
"websockets - room "
+
roomName
);
...
...
sails/src/api/controllers/WorkingSessionController.js
View file @
b7aef735
...
@@ -150,13 +150,13 @@ module.exports = {
...
@@ -150,13 +150,13 @@ module.exports = {
WorkingSession
.
update
({
id
:
params
.
id
},
params
).
exec
(
function
(
err
,
ws
){
WorkingSession
.
update
({
id
:
params
.
id
},
params
).
exec
(
function
(
err
,
ws
){
if
(
err
||
!
ws
){
if
(
err
||
!
ws
){
sails
.
log
.
debug
(
"Updating Working Sesion
: "
+
err
);
sails
.
log
.
error
(
"Updating Working Sesion error
: "
+
err
);
return
res
.
json
(
500
,
{
error
:
'Working Session not updated'
});
return
res
.
json
(
500
,
{
error
:
'Working Session not updated'
});
}
}
sails
.
log
.
debug
(
"Working session updated: "
+
JSON
.
stringify
(
ws
[
0
]));
sails
.
log
.
debug
(
"Working session updated: "
+
JSON
.
stringify
(
ws
[
0
]));
if
(
params
.
end
!=
null
){
if
(
params
.
end
!=
null
){
//Closing WS
// Create the EndSession Action
// Create the EndSession Action
Action
.
create
({
Action
.
create
({
"type"
:
"endsession"
,
"type"
:
"endsession"
,
...
@@ -169,21 +169,27 @@ module.exports = {
...
@@ -169,21 +169,27 @@ module.exports = {
return
res
.
json
(
500
,
{
error
:
'Working Session not updated'
});
return
res
.
json
(
500
,
{
error
:
'Working Session not updated'
});
}
}
});
});
Try
.
findOne
(
{
id_ws
:
params
.
id
}
).
exec
(
function
(
err
,
t
)
{
//Deleting empty WS (no tries)
if
(
err
)
{
sails
.
log
.
error
(
"Error Recovering from ws "
+
err
);
return
res
.
json
(
500
,
{
error
:
'recovering from ws:'
+
err
});
}
if
(
typeof
(
t
)
==
'undefined'
)
/*Empty WS must be deleted*/
{
sails
.
log
.
debug
(
"Empty WS to be deleted, id: "
+
params
.
id
);
WorkingSession
.
destroy
({
id
:
params
.
id
}).
exec
(
function
(
err
,
u
)
{
if
(
err
)
{
sails
.
log
.
error
(
"Error deleting empty WS (no tries) "
+
t
.
id_ws
);
return
res
.
json
(
500
,
{
error
:
'Error deleting empty WS (no tries)'
});
}});
}
}
/* NOT REQUIRED: Integrity session rule #2. Remove open try
Try.getOpenTry(ws[0].student, function(err, id_try) {
if (id_try)
Try.destroy({id: id_try}).exec(function deleteCB(err) {
if (err)
sails.log.debug("Error deleting open try " + id_try);
});
});
});
*/
}
// Return the working session updated
// Return the working session updated
return
res
.
json
(
ws
);
return
res
.
json
(
ws
);
}
});
);
},
},
...
...
sails/src/assets/app/modules/student/controllers/session.js
View file @
b7aef735
...
@@ -3,19 +3,58 @@
...
@@ -3,19 +3,58 @@
//-----------------------
//-----------------------
// Student Session Controller
// Student Session Controller
//-----------------------
//-----------------------
dashboardControllers
.
controller
(
'StudentSessionCtrl'
,
function
StudentSessionCtrl
(
$
rootScope
,
$
scope
,
$stateParams
,
$http
,
config
,
$window
)
{
dashboardControllers
.
controller
(
'StudentSessionCtrl'
,
function
StudentSessionCtrl
(
$scope
,
$stateParams
,
$http
,
config
,
$window
)
{
console
.
log
(
"dashboardControllers reload:"
+
$scope
.
$id
);
console
.
log
(
"dashboardControllers reload:"
+
$scope
.
$id
);
// For tab navigation (here too, if the user refresh the page...)
// For tab navigation (here too, if the user refresh the page...)
$scope
.
nav
.
tab
=
'session'
;
$scope
.
nav
.
tab
=
'session'
;
// ----------------------------------------------------------------------
// SESSION
// Prepare session recording information
//
//
// Actual WS
$scope
.
ws
=
$scope
.
ws
||
{};
$scope
.
actual_try
=
$scope
.
actual_try
||
{};
// pause flag
$scope
.
paused
=
false
;
// Read the last working session to show the last tries when session tab is opened
$scope
.
wsessions
=
[];
// Query to obtain an array of only one working session (the last) with its tries/actions
$http
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
studentData
.
id
+
'/lasttries'
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// Add to list
$scope
.
wsessions
=
data
;
console
.
log
(
JSON
.
stringify
(
$scope
.
wsessions
));
console
.
log
(
"Tries of last working session recovered"
);
$scope
.
currentPage
=
1
;
$scope
.
numPerPage
=
5
;
$scope
.
totalPages
=
Math
.
ceil
(
$scope
.
wsessions
.
length
/
$scope
.
numPerPage
);
$scope
.
ws_recover
=
$scope
.
wsessions
[
0
]
!=
null
&&
$scope
.
wsessions
[
0
].
end
==
null
;
console
.
log
(
"tries: "
+
$scope
.
wsessions
.
length
);
console
.
log
(
"numPerPage: "
+
$scope
.
numPerPage
);
console
.
log
(
"pages: "
+
$scope
.
totalPages
);
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"Error from API: "
+
data
.
error
);
});
// Initially, show the last try
$scope
.
showLastTry
=
true
;
// VER SI BORRAR --> SÓLO NECESARIO PARA DEJAR EN BLANCO LOS ENSAYOS CARGADOS
// VER SI BORRAR --> SÓLO NECESARIO PARA DEJAR EN BLANCO LOS ENSAYOS CARGADOS
// Cargar instrucciones en select del método seleccionado arriba
// Cargar instrucciones en select del método seleccionado arriba
$scope
.
load_instructions
=
function
(
method
){
$scope
.
load_instructions
=
function
(
method
){
console
.
log
(
JSON
.
stringify
(
method
));
console
.
log
(
JSON
.
stringify
(
method
));
// Empty ws/tries/actions
// Empty ws/tries/actions
$
rootS
cope
.
wsessions
=
[];
$
s
cope
.
wsessions
=
[];
// Update the number of pages
// Update the number of pages
$scope
.
totalPages
=
0
;
$scope
.
totalPages
=
0
;
...
@@ -40,15 +79,15 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
...
@@ -40,15 +79,15 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
.
get
(
config
.
backend
+
'/instruction/'
+
instruction
.
id
+
'/ws'
)
.
get
(
config
.
backend
+
'/instruction/'
+
instruction
.
id
+
'/ws'
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// Add to list
// Add to list
$
rootS
cope
.
wsessions
=
data
;
$
s
cope
.
wsessions
=
data
;
console
.
log
(
JSON
.
stringify
(
$
rootS
cope
.
wsessions
));
console
.
log
(
JSON
.
stringify
(
$
s
cope
.
wsessions
));
console
.
log
(
"
WS/Tries/Actions for instruction "
+
instruction
.
id
+
" recovered"
);
console
.
log
(
"
#WS for instruction "
+
instruction
.
id
+
" recovered: "
+
$scope
.
wsessions
.
length
);
// Refresh navigation vars
// Refresh navigation vars
$scope
.
currentPage
=
1
;
$scope
.
currentPage
=
1
;
$scope
.
numPerPage
=
5
;
$scope
.
numPerPage
=
5
;
$scope
.
totalPages
=
Math
.
ceil
(
$
rootS
cope
.
wsessions
.
length
/
$scope
.
numPerPage
);
$scope
.
totalPages
=
Math
.
ceil
(
$
s
cope
.
wsessions
.
length
/
$scope
.
numPerPage
);
})
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"Error from API: "
+
data
);
console
.
log
(
"Error from API: "
+
data
);
...
@@ -64,7 +103,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
...
@@ -64,7 +103,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
// Tries pagination - next tries
// Tries pagination - next tries
$scope
.
after
=
function
(){
$scope
.
after
=
function
(){
var
total_pages
=
Math
.
ceil
(
$
rootS
cope
.
wsessions
.
length
/
$scope
.
numPerPage
);
var
total_pages
=
Math
.
ceil
(
$
s
cope
.
wsessions
.
length
/
$scope
.
numPerPage
);
if
(
$scope
.
currentPage
<
total_pages
)
$scope
.
currentPage
++
;
if
(
$scope
.
currentPage
<
total_pages
)
$scope
.
currentPage
++
;
};
};
...
@@ -88,33 +127,33 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
...
@@ -88,33 +127,33 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
$scope
.
update_current_try
=
function
(){
$scope
.
update_current_try
=
function
(){
$http
$http
.
put
(
config
.
backend
+
'/try/'
+
$
rootScope
.
actual_try
.
id
,
{
result
:
$rootS
cope
.
actual_try
.
result
,
end
:
new
Date
()
})
.
put
(
config
.
backend
+
'/try/'
+
$
scope
.
actual_try
.
id
,
{
result
:
$s
cope
.
actual_try
.
result
,
end
:
new
Date
()
})
.
then
(
.
then
(
function
(
data
,
status
,
headers
,
config
)
{
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"Current try - updated. Student: "
+
$scope
.
studentData
.
id
+
" try:"
+
$
rootS
cope
.
actual_try
.
id
);
console
.
log
(
"Current try - updated. Student: "
+
$scope
.
studentData
.
id
+
" try:"
+
$
s
cope
.
actual_try
.
id
);
}
}
,
function
(
data
,
status
,
headers
,
config
)
{
,
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"Error from API: "
+
data
.
error
+
"when updating try "
+
$
rootS
cope
.
actual_try
);
console
.
log
(
"Error from API: "
+
data
.
error
+
"when updating try "
+
$
s
cope
.
actual_try
);
}
}
);
);
};
};
$scope
.
send_show_action
=
function
(){
$scope
.
send_show_action
=
function
(){
console
.
log
(
"ACTION!"
+
$scope
.
studentData
.
id
+
" try:"
+
$
rootS
cope
.
actual_try
.
id
);
console
.
log
(
"ACTION!"
+
$scope
.
studentData
.
id
+
" try:"
+
$
s
cope
.
actual_try
.
id
);
$http
$http
.
post
(
config
.
backend
+
'/action'
,
{
.
post
(
config
.
backend
+
'/action'
,
{
student
:
$scope
.
studentData
.
id
,
student
:
$scope
.
studentData
.
id
,
type
:
'Show'
,
type
:
'Show'
,
timestamp
:
new
Date
(),
timestamp
:
new
Date
(),
_try
:
$
rootS
cope
.
actual_try
.
id
_try
:
$
s
cope
.
actual_try
.
id
})
})
.
then
(
.
then
(
function
(
data
,
status
,
headers
,
config
)
{
function
(
data
,
status
,
headers
,
config
)
{
$scope
.
load_tries
(
$scope
.
selectedIns
);
$scope
.
load_tries
(
$scope
.
selectedIns
);
// Empty actual try and push the first action of next try
// Empty actual try and push the first action of next try
$
rootS
cope
.
actual_try
.
actions
=
[];
$
s
cope
.
actual_try
.
actions
=
[];
$
rootS
cope
.
actual_try
.
actions
.
push
({
action
:
'tryinit'
});
$
s
cope
.
actual_try
.
actions
.
push
({
action
:
'tryinit'
});
$
rootS
cope
.
actual_try
.
id
=
data
.
data
.
open_try
;
$
s
cope
.
actual_try
.
id
=
data
.
data
.
open_try
;
console
.
log
(
"New try: "
+
$
rootS
cope
.
actual_try
.
id
+
"="
+
data
.
data
.
open_try
+
": "
+
JSON
.
stringify
(
data
));
console
.
log
(
"New try: "
+
$
s
cope
.
actual_try
.
id
+
"="
+
data
.
data
.
open_try
+
": "
+
JSON
.
stringify
(
data
));
}
}
,
function
(
data
,
status
,
headers
,
config
)
{
,
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"Error from API: "
+
data
.
error
);
console
.
log
(
"Error from API: "
+
data
.
error
);
...
@@ -133,13 +172,13 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
...
@@ -133,13 +172,13 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
$scope
.
close_ws
=
function
(){
$scope
.
close_ws
=
function
(){
$http
$http
.
post
(
config
.
backend
+
'/workingsession/'
+
$
rootS
cope
.
wsessions
[
0
].
id
+
'/close'
)
.
post
(
config
.
backend
+
'/workingsession/'
+
$
s
cope
.
wsessions
[
0
].
id
+
'/close'
)
.
then
(
.
then
(
function
(
data
,
status
,
headers
,
config
)
{
function
(
data
,
status
,
headers
,
config
)
{
$
rootS
cope
.
wsessions
[
0
].
end
=
data
.
data
.
end
;
$
s
cope
.
wsessions
[
0
].
end
=
data
.
data
.
end
;
$scope
.
ws_recover
=
false
;
$scope
.
ws_recover
=
false
;
console
.
log
(
"WS "
+
$
rootS
cope
.
wsessions
[
0
].
id
+
"closed at "
+
JSON
.
stringify
(
data
.
data
.
end
));
console
.
log
(
"WS "
+
$
s
cope
.
wsessions
[
0
].
id
+
"closed at "
+
JSON
.
stringify
(
data
.
data
.
end
));
}
}
,
function
(
data
,
status
,
headers
,
config
)
{
,
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"Error from API: "
+
data
.
error
);
console
.
log
(
"Error from API: "
+
data
.
error
);
...
@@ -165,7 +204,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
...
@@ -165,7 +204,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// Actual WS
// Actual WS
$
rootS
cope
.
ws
=
{
$
s
cope
.
ws
=
{
id
:
data
.
id
id
:
data
.
id
};
};
...
@@ -173,14 +212,14 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
...
@@ -173,14 +212,14 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
// List of tries --> empty
// List of tries --> empty
// BORRAR después lo que no sirva
// BORRAR después lo que no sirva
$
rootS
cope
.
actual_try
=
{
$
s
cope
.
actual_try
=
{
actions
:
[],
actions
:
[],
id
:
data
.
first_try_id
,
id
:
data
.
first_try_id
,
result
:
null
result
:
null
};
};
// Adding initial action to the list of actions
// Adding initial action to the list of actions
$
rootS
cope
.
actual_try
.
actions
.
push
({
action
:
'tryinit'
});
$
s
cope
.
actual_try
.
actions
.
push
({
action
:
'tryinit'
});
console
.
log
(
"WS created for method "
+
$scope
.
selectedMethod
.
name
+
" Ins:"
+
$scope
.
selectedIns
.
name
+
": "
+
JSON
.
stringify
(
data
));
console
.
log
(
"WS created for method "
+
$scope
.
selectedMethod
.
name
+
" Ins:"
+
$scope
.
selectedIns
.
name
+
": "
+
JSON
.
stringify
(
data
));
$scope
.
studentData
.
current_method
=
$scope
.
selectedMethod
.
name
;
$scope
.
studentData
.
current_method
=
$scope
.
selectedMethod
.
name
;
$scope
.
studentData
.
current_instruction
=
$scope
.
selectedIns
.
name
;
$scope
.
studentData
.
current_instruction
=
$scope
.
selectedIns
.
name
;
...
@@ -213,18 +252,18 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
...
@@ -213,18 +252,18 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
// For view
// For view
$scope
.
sessionRunning
=
false
;
$scope
.
sessionRunning
=
false
;
$
rootS
cope
.
ws
.
end
=
new
Date
();
$
s
cope
.
ws
.
end
=
new
Date
();
$http
$http
.
put
(
config
.
backend
+
'/workingsession/'
+
$
rootScope
.
ws
.
id
,
{
"end"
:
$rootS
cope
.
ws
.
end
,
.
put
(
config
.
backend
+
'/workingsession/'
+
$
scope
.
ws
.
id
,
{
"end"
:
$s
cope
.
ws
.
end
,
"id_stu"
:
$scope
.
studentData
.
id
"id_stu"
:
$scope
.
studentData
.
id
})
})
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"WS stopped - updated: "
+
JSON
.
stringify
(
data
));
console
.
log
(
"WS stopped - updated: "
+
JSON
.
stringify
(
data
));
// Empty actual WS and actual try
// Empty actual WS and actual try
$
rootS
cope
.
ws
=
{};
$
s
cope
.
ws
=
{};
$
rootS
cope
.
actual_try
=
{};
$
s
cope
.
actual_try
=
{};
})
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"Error from API: "
+
data
.
error
);
console
.
log
(
"Error from API: "
+
data
.
error
);
...
@@ -245,7 +284,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
...
@@ -245,7 +284,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
action: 'pausesession',
action: 'pausesession',
attributes: {
attributes: {
id_stu: $scope.studentData.id,
id_stu: $scope.studentData.id,
id_ws: $
rootS
cope.ws.id
id_ws: $
s
cope.ws.id
}
}
};
};
...
@@ -265,7 +304,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
...
@@ -265,7 +304,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
console
.
log
(
"Action created: "
+
JSON
.
stringify
(
data
));
console
.
log
(
"Action created: "
+
JSON
.
stringify
(
data
));
// Adding pause action to the list of actions
// Adding pause action to the list of actions
$
rootS
cope
.
actual_try
.
actions
.
push
({
action
:
'pausesession'
}
);
$
s
cope
.
actual_try
.
actions
.
push
({
action
:
'pausesession'
}
);
})
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
...
@@ -284,7 +323,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
...
@@ -284,7 +323,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
action: 'resumesession',
action: 'resumesession',
attributes: {
attributes: {
id_stu: $scope.studentData.id,
id_stu: $scope.studentData.id,
id_ws: $
rootS
cope.ws.id
id_ws: $
s
cope.ws.id
}
}
};
};
...
@@ -304,7 +343,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
...
@@ -304,7 +343,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
console
.
log
(
"Action created: "
+
JSON
.
stringify
(
data
));
console
.
log
(
"Action created: "
+
JSON
.
stringify
(
data
));
// Adding pause action to the list of actions
// Adding pause action to the list of actions
$
rootS
cope
.
actual_try
.
actions
.
push
({
action
:
'resumesession'
}
);
$
s
cope
.
actual_try
.
actions
.
push
({
action
:
'resumesession'
}
);
})
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
...
@@ -349,8 +388,8 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
...
@@ -349,8 +388,8 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
*/
*/
$scope
.
is_currentOpenTry
=
function
(
t
)
{
$scope
.
is_currentOpenTry
=
function
(
t
)
{
if
(
t
.
end
==
null
&&
$
rootS
cope
.
ws
.
id
==
t
.
workingSession
)
{
if
(
t
.
end
==
null
&&
$
s
cope
.
ws
.
id
==
t
.
workingSession
)
{
$
rootS
cope
.
actual_try
.
id
=
t
.
id
;
$
s
cope
.
actual_try
.
id
=
t
.
id
;
return
true
;
return
true
;
}
}
return
false
;
return
false
;
...
@@ -389,7 +428,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
...
@@ -389,7 +428,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
};
};
// For simulating the managing of the try in the pcb
// For simulating the managing of the try in the pcb
// if($
rootS
cope.ws) $scope.pcb_try = {};
// if($
s
cope.ws) $scope.pcb_try = {};
$scope.pcb_actions = [];
$scope.pcb_actions = [];
...
@@ -517,14 +556,14 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
...
@@ -517,14 +556,14 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
// It depends on the working session created
// It depends on the working session created
// Here is controlled by a scope var, but in PCB it will be created
// Here is controlled by a scope var, but in PCB it will be created
// a flag var to this purpouse when it gets an "WSInit" action
// a flag var to this purpouse when it gets an "WSInit" action
if($
rootS
cope.ws){
if($
s
cope.ws){
// End the try with actual time
// End the try with actual time
$scope.pcb_try.end = endDate;
$scope.pcb_try.end = endDate;
// Save actions with a try (working session is running)
// Save actions with a try (working session is running)
$http
$http
.post(config.backend+'/try', {
.post(config.backend+'/try', {
"ws": $
rootS
cope.ws.id,
"ws": $
s
cope.ws.id,
"begin": $scope.pcb_try.begin,
"begin": $scope.pcb_try.begin,
"end": $scope.pcb_try.end,
"end": $scope.pcb_try.end,
"actions": $scope.pcb_actions,
"actions": $scope.pcb_actions,
...
@@ -571,7 +610,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
...
@@ -571,7 +610,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
$scope.unshow_sentence = function(){
$scope.unshow_sentence = function(){
// Begin a new try if there is a session initiated
// Begin a new try if there is a session initiated
if($
rootS
cope.ws){
if($
s
cope.ws){
$scope.pcb_try = {};
$scope.pcb_try = {};
$scope.pcb_try.begin = new Date();
$scope.pcb_try.begin = new Date();
}
}
...
@@ -650,7 +689,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
...
@@ -650,7 +689,7 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
case 'endsession':
case 'endsession':
console.log("PCB: EndSession action!!!!!!!!!!!!!");
console.log("PCB: EndSession action!!!!!!!!!!!!!");
// In PCB use other var to control the session (it is important to save the actions with or without the id_try field)
// In PCB use other var to control the session (it is important to save the actions with or without the id_try field)
$
rootS
cope.ws = null;
$
s
cope.ws = null;
break;
break;
case 'pausesession':
case 'pausesession':
console.log("PCB: blocked");
console.log("PCB: blocked");
...
@@ -695,19 +734,19 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
...
@@ -695,19 +734,19 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
console
.
log
(
'Action '
+
data
.
action
+
' event received with the following data:'
);
console
.
log
(
'Action '
+
data
.
action
+
' event received with the following data:'
);
console
.
log
(
JSON
.
stringify
(
data
.
attributes
));
console
.
log
(
JSON
.
stringify
(
data
.
attributes
));
if
(
$
rootS
cope
.
ws
){
if
(
$
s
cope
.
ws
){
switch
(
data
.
action
){
switch
(
data
.
action
){
case
'Add'
:
case
'Add'
:
console
.
log
(
"ADD action to ws "
+
$
rootScope
.
ws
.
id
+
":"
+
$rootS
cope
.
actual_try
.
id
+
" Scope:"
+
$scope
.
$id
);
console
.
log
(
"ADD action to ws "
+
$
scope
.
ws
.
id
+
":"
+
$s
cope
.
actual_try
.
id
+
" Scope:"
+
$scope
.
$id
);
$
rootS
cope
.
actual_try
.
actions
.
push
(
data
);
$
s
cope
.
actual_try
.
actions
.
push
(
data
);
break
;
break
;
case
'Delete'
:
case
'Delete'
:
console
.
log
(
"delete action!!!!!!!!!!!!!"
);
console
.
log
(
"delete action!!!!!!!!!!!!!"
);
$
rootS
cope
.
actual_try
.
actions
.
push
(
data
);
$
s
cope
.
actual_try
.
actions
.
push
(
data
);
break
;
break
;
case
'Select'
:
case
'Select'
:
console
.
log
(
"select action!!!!!!!!!!!!"
);
console
.
log
(
"select action!!!!!!!!!!!!"
);
$
rootS
cope
.
actual_try
.
actions
.
push
(
data
);
$
s
cope
.
actual_try
.
actions
.
push
(
data
);
break
;
break
;
case
'Show'
:
case
'Show'
:
console
.
log
(
"show action!!!!!!!!!!!!"
);
console
.
log
(
"show action!!!!!!!!!!!!"
);
...
@@ -721,27 +760,27 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
...
@@ -721,27 +760,27 @@ dashboardControllers.controller('StudentSessionCtrl', function StudentSessionCtr
$scope
.
load_tries
(
$scope
.
selectedIns
);
$scope
.
load_tries
(
$scope
.
selectedIns
);
/*
/*
// Add the last show action to the list of try actions
// Add the last show action to the list of try actions
$
rootS
cope.actual_try.actions.push(data);
$
s
cope.actual_try.actions.push(data);
// Put it in the list
// Put it in the list
$
rootScope.wsessions.push($rootS
cope.actual_try);
$
scope.wsessions.push($s
cope.actual_try);
// Update total pages for navigation
// Update total pages for navigation
$scope.totalPages = Math.ceil($
rootS
cope.wsessions.length / $scope.numPerPage);
$scope.totalPages = Math.ceil($
s
cope.wsessions.length / $scope.numPerPage);
*/
*/
// Empty actual try and push the first action of next try
// Empty actual try and push the first action of next try
$
rootS
cope
.
actual_try
.
actions
=
[];
$
s
cope
.
actual_try
.
actions
=
[];
$
rootS
cope
.
actual_try
.
actions
.
push
({
action
:
'tryinit'
});
$
s
cope
.
actual_try
.
actions
.
push
({
action
:
'tryinit'
});
break
;
break
;
/*
/*
case 'unshow':
case 'unshow':
console.log("unshow action!!!!!!!!!!!!");
console.log("unshow action!!!!!!!!!!!!");
$
rootS
cope.actual_try.actions = [];
$
s
cope.actual_try.actions = [];
$
rootS
cope.actual_try.actions.push(data);
$
s
cope.actual_try.actions.push(data);
// If a session is initiated
// If a session is initiated
if($
rootS
cope.ws){
if($
s
cope.ws){
// Start the timer for the new try
// Start the timer for the new try
$scope.startTimer();
$scope.startTimer();
}
}
...
...
sails/src/assets/app/modules/student/controllers/student.js
View file @
b7aef735
...
@@ -204,46 +204,7 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf
...
@@ -204,46 +204,7 @@ dashboardControllers.controller('StudentCtrl', function StudentCtrl($scope, conf
console
.
log
(
"Error from API: "
+
data
.
error
);
console
.
log
(
"Error from API: "
+
data
.
error
);
});
});
// ----------------------------------------------------------------------
// SESSION
// Prepare session recording information
//
//
// Actual WS
$rootScope
.
ws
=
$rootScope
.
ws
||
{};
$rootScope
.
actual_try
=
$rootScope
.
actual_try
||
{};
// pause flag
$scope
.
paused
=
false
;
// Read the last working session to show the last tries when session tab is opened
$rootScope
.
wsessions
=
[];
// Query to obtain an array of only one working session (the last) with its tries/actions
$http
.
get
(
config
.
backend
+
'/stu/'
+
$scope
.
studentData
.
id
+
'/lasttries'
)
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// Add to list
$rootScope
.
wsessions
=
data
;
console
.
log
(
JSON
.
stringify
(
$rootScope
.
wsessions
));
console
.
log
(
"Tries of last working session recovered"
);
$scope
.
currentPage
=
1
;
$scope
.
numPerPage
=
5
;
$scope
.
totalPages
=
Math
.
ceil
(
$rootScope
.
wsessions
.
length
/
$scope
.
numPerPage
);
$scope
.
ws_recover
=
$rootScope
.
wsessions
[
0
]
!=
null
&&
$rootScope
.
wsessions
[
0
].
end
==
null
;
console
.
log
(
"tries: "
+
$rootScope
.
wsessions
.
length
);
console
.
log
(
"numPerPage: "
+
$scope
.
numPerPage
);
console
.
log
(
"pages: "
+
$scope
.
totalPages
);
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
console
.
log
(
"Error from API: "
+
data
.
error
);
});
// Initially, show the last try
$scope
.
showLastTry
=
true
;
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
...
...
sails/src/assets/app/modules/student/views/session.html
View file @
b7aef735
...
@@ -199,7 +199,7 @@
...
@@ -199,7 +199,7 @@
</table>
</table>
</p>
</p>
</div>
</div>
</div>
</div>
<!--showLasTry -->
<button
class=
"btn btn-primary pull-right"
type=
"button"
ng-click=
"showTries = !showTries"
>
<button
class=
"btn btn-primary pull-right"
type=
"button"
ng-click=
"showTries = !showTries"
>
Ensayos
<span
class=
"badge"
>
{{ s.tries.length }}
</span>
Ensayos
<span
class=
"badge"
>
{{ s.tries.length }}
</span>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment