Skip to content

Commit

Permalink
Merge pull request #443 from harena-lab/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
santanche authored Sep 12, 2023
2 parents 143bfd1 + f0194cd commit a969287
Show file tree
Hide file tree
Showing 12 changed files with 252 additions and 55 deletions.
170 changes: 118 additions & 52 deletions src/adonisjs/public/author/env/inf331_2023/js/lab-progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,32 @@
let prognosisList = {}
await axios(config)
.then(function (endpointResponse) {
// for (let c of endpointResponse.data.cases){}
labList = endpointResponse.data.cases
})
.catch(function (error) {
console.log(error)
})
for (let lab of labList) {
let property = await this.getCaseProperties(lab.id)
if ('complete' in property){
property = property['complete']
if (lab.username == sessionStorage.getItem('harena-user-username')){
let propsLab = await this.getCaseProperties(lab.id)
let extendPeriod = null
let property = null
if ('complete' in propsLab){
property = propsLab['complete']
}else{
property = null
}
if ('extendPeriod' in propsLab){
extendPeriod = new Date((propsLab['extendPeriod']))
}else{
extendPeriod = null
}
if (lab.title == lab.description && lab.title == lab.keywords){
labProgressManager.i.lab[lab.title.substring(lab.title.length-1)] = {'id':lab.id,'desc':lab.description,'keywords':lab.keywords,'property':property}
labProgressManager.i.lab[lab.title.substring(lab.title.length-1)] = {'id':lab.id,'desc':lab.description,'keywords':lab.keywords,'property':property, 'extendPeriod':extendPeriod}
}else if (lab.description == lab.keywords){
labProgressManager.i.lab[lab.description.substring(lab.description.length-1)] = {'id':lab.id,'desc':lab.description,'keywords':lab.keywords,'property':property}
}
labProgressManager.i.lab[lab.description.substring(lab.description.length-1)] = {'id':lab.id,'desc':lab.description,'keywords':lab.keywords,'property':property, 'extendPeriod':extendPeriod}
}}
}
MessageBus.i.publish('data/lab.info/ready')
}
Expand Down Expand Up @@ -210,24 +219,44 @@
let labCompleted = false
let labDelivered = false
let labLastEdit = null
let labExtended = false
let labExpired = false
let pastRelease = false
const highestLab = Object.keys(labList).length
let nLabReleased = 0
// let nLabReleased = 0
const currentDate = new Date()
// console.log('============',this.convertToLocalTz(new Date(),'date'))
// let tzOffset = this.prependZero(-1*(currentDate.getTimezoneOffset()/60))
// if (-1*(currentDate.getTimezoneOffset()/60) > 0){
// tzOffset = `GMT+${tzOffset}00`
// }
// console.log('============',this.getDateString(currentDate))
// console.log('============',this.getTimeString(this.labRelease[1]))
// console.log('============',this.convertToLocalTz(currentDate,true))
// console.log(labProgressManager.i.lab);

let createdBtn = false
let released = true
const lateReleaseTxt = 'Não publicado...(atraso)'
progressWrapper.innerHTML = ''
for (var i = 1; i <= Object.keys(this.labRelease).length; i++) {
labCompleted = false
labDelivered = false
labExtended = false
labExpired = false
pastRelease = false


if (this.setDateToISO(currentDate) > this.setDateToISO(this.labExpiration[i])){
labExpired = true
}
// console.log(`lab ${i}`,this.setDateToISO(currentDate), this.setDateToISO(this.labRelease[i]));
if (this.setDateToISO(currentDate) > this.setDateToISO(this.labRelease[i])){
pastRelease = true
}

if (labExpired){
if (Object.keys(labList).length >= i){
if (labList[i]['extendPeriod'] != null){
if((this.setDateToISO((labList[i]['extendPeriod'])) > this.setDateToISO(currentDate))){
labExtended = true
}
}
}
}

let labTemplate = await MessageBus.i.request(
'data/template/' + `labs/lab_${i}`.replace(/\//g, '.') +
'/get', {static: false}, null, true)
Expand All @@ -237,10 +266,10 @@
createdBtn = false

let template = document.createElement('template')
// console.log('============ current greater then release',this.setDateToISO(currentDate) > this.setDateToISO(this.labRelease[i]))
// console.log('============ current date greater then expiration',this.setDateToISO(currentDate) > this.setDateToISO(this.labExpiration[i]))
// console.log('============ current greater then release',pastRelease)
// console.log('============ current date greater then expiration',labExpired)

if (this.setDateToISO(currentDate) > this.setDateToISO(this.labRelease[i]) && highestLab >= i){
if (pastRelease && highestLab >= i){
if (labProgressManager.i.lab[i]['property'] != null && labProgressManager.i.lab[i]['property'] == '0'){
labDelivered = true
}
Expand All @@ -252,7 +281,7 @@
.replace(/\[labRelease\]/ig, `${this.convertToLocalTz(this.labRelease[i],'string')}`)
.replace(/\[labText\]/ig, lateReleaseTxt)

}else if (this.setDateToISO(currentDate) > this.setDateToISO(this.labRelease[i]) && this.setDateToISO(currentDate) > this.setDateToISO(this.labExpiration[i])){
}else if (pastRelease && labExpired && !labExtended){
// console.log('============ release and expiration greater')
template.innerHTML = labProgressManager.lvlContainerExpired
.replace(/\[containerColor\]/ig, 'bg-lab-primary')
Expand All @@ -267,26 +296,44 @@
.replace(/\[labDeliveredColor\]/ig, labDelivered?successColor:failColor)
.replace(/\[labLastEdit\]/ig, labLastEdit)
.replace(/\[labLastEditColor\]/ig, (failColor))
}else{
template.innerHTML = labProgressManager.lvlContainer
.replace(/\[containerColor\]/ig, 'bg-lab-primary')
.replace(/\[btnColor\]/ig, 'btn-lab-primary')
.replace(/\[labNumber\]/ig, Object.keys(labList)[i-1])
.replace(/\[progress\]/ig, 'Em aberto')
.replace(/\[progressColor\]/ig, labCompleted?successColor:'bg-lab-dark text-lab-light')
.replace(/\[this.labExpirationColor\]/ig, 'bg-lab-dark text-lab-light-pink')
.replace(/\[this.labExpiration\]/ig,
`${this.convertToLocalTz(this.labExpiration[i],'string')}`)
.replace(/\[labDelivered\]/ig, labDelivered?'Sim!':'Não')
.replace(/\[labDeliveredColor\]/ig, labDelivered?successColor:failColor)
.replace(/\[labLastEdit\]/ig, labLastEdit)
.replace(/\[labLastEditColor\]/ig, (failColor))
.replace(/\[labId\]/ig, labList[i]['id'])
.replace(/\[buttonIcon\]/ig, 'play')
}else if (pastRelease && !labExpired || (pastRelease && labExpired && labExtended)){
if (labExtended){
template.innerHTML = labProgressManager.lvlContainer
.replace(/\[containerColor\]/ig, 'bg-lab-primary')
.replace(/\[btnColor\]/ig, 'btn-lab-primary')
.replace(/\[labNumber\]/ig, Object.keys(labList)[i-1])
.replace(/\[progress\]/ig, 'Submissão extendida')
.replace(/\[progressColor\]/ig, labCompleted?successColor:'bg-lab-dark text-lab-light')
.replace(/\[this.labExpirationColor\]/ig, 'bg-lab-dark text-lab-light-pink')
.replace(/\[this.labExpiration\]/ig,
`${this.convertToLocalTz(labList[i]['extendPeriod'],'string')}`)
.replace(/\[labDelivered\]/ig, labDelivered?'Sim!':'Não')
.replace(/\[labDeliveredColor\]/ig, labDelivered?successColor:failColor)
.replace(/\[labLastEdit\]/ig, labLastEdit)
.replace(/\[labLastEditColor\]/ig, (failColor))
.replace(/\[labId\]/ig, labList[i]['id'])
.replace(/\[buttonIcon\]/ig, 'play')
}else{
template.innerHTML = labProgressManager.lvlContainer
.replace(/\[containerColor\]/ig, 'bg-lab-primary')
.replace(/\[btnColor\]/ig, 'btn-lab-primary')
.replace(/\[labNumber\]/ig, Object.keys(this.labRelease)[i-1])
.replace(/\[progress\]/ig, 'Em aberto')
.replace(/\[progressColor\]/ig, labCompleted?successColor:'bg-lab-dark text-lab-light')
.replace(/\[this.labExpirationColor\]/ig, 'bg-lab-dark text-lab-light-pink')
.replace(/\[this.labExpiration\]/ig,
`${this.convertToLocalTz(this.labExpiration[i],'string')}`)
.replace(/\[labDelivered\]/ig, labDelivered?'Sim!':'Não')
.replace(/\[labDeliveredColor\]/ig, labDelivered?successColor:failColor)
.replace(/\[labLastEdit\]/ig, labLastEdit)
.replace(/\[labLastEditColor\]/ig, (failColor))
.replace(/\[labId\]/ig, labList[i]['id'])
.replace(/\[buttonIcon\]/ig, 'play')
}
}


}else if(this.setDateToISO(currentDate) > this.setDateToISO(this.labRelease[i]) && this.setDateToISO(currentDate) > this.setDateToISO(this.labExpiration[i])){
}else if(pastRelease && labExpired && !labExtended){
template.innerHTML = labProgressManager.lvlContainerExpired
.replace(/\[containerColor\]/ig, 'bg-lab-primary')
.replace(/\[btnColor\]/ig, 'btn-lab-secondary')
Expand All @@ -300,7 +347,7 @@
.replace(/\[labDeliveredColor\]/ig, labDelivered?successColor:failColor)
.replace(/\[labLastEdit\]/ig, labLastEdit)
.replace(/\[labLastEditColor\]/ig, (failColor))
}else if (currentDate > this.labRelease[i]){
}else if (pastRelease){
if (released == false){
template.innerHTML = labProgressManager.lvlContainerLocked
.replace(/\[difficulty\]/ig, i)
Expand All @@ -309,22 +356,41 @@

}else{
createdBtn = true
template.innerHTML = labProgressManager.lvlContainer
.replace(/\[containerColor\]/ig, 'bg-lab-primary')
.replace(/\[btnColor\]/ig, 'btn-lab-secondary')
.replace(/\[labNumber\]/ig, Object.keys(this.labRelease)[i-1])
.replace(/\[progress\]/ig, 'Em aberto')
.replace(/\[progressColor\]/ig, labCompleted?successColor:'bg-lab-dark text-lab-light')
.replace(/\[this.labExpirationColor\]/ig, 'bg-lab-dark text-lab-light-pink')
.replace(/\[this.labExpiration\]/ig,
`${this.convertToLocalTz(this.labExpiration[i],'string')}`)
.replace(/\[labDelivered\]/ig, labDelivered?'Sim!':'Não')
.replace(/\[labDeliveredColor\]/ig, labDelivered?successColor:failColor)
.replace(/\[labLastEdit\]/ig, labLastEdit)
.replace(/\[labLastEditColor\]/ig, (failColor))
.replace(/\[buttonIcon\]/ig, 'plus')
if (!labExpired || (pastRelease && labExpired && labExtended)){
if (labExtended){
template.innerHTML = labProgressManager.lvlContainer
.replace(/\[containerColor\]/ig, 'bg-lab-primary')
.replace(/\[btnColor\]/ig, 'btn-lab-primary')
.replace(/\[labNumber\]/ig, Object.keys(labList)[i-1])
.replace(/\[progress\]/ig, 'Submissão extendida')
.replace(/\[progressColor\]/ig, labCompleted?successColor:'bg-lab-dark text-lab-light')
.replace(/\[this.labExpirationColor\]/ig, 'bg-lab-dark text-lab-light-pink')
.replace(/\[this.labExpiration\]/ig,
`${this.convertToLocalTz(labList[i]['extendPeriod'],'string')}`)
.replace(/\[labDelivered\]/ig, labDelivered?'Sim!':'Não')
.replace(/\[labDeliveredColor\]/ig, labDelivered?successColor:failColor)
.replace(/\[labLastEdit\]/ig, labLastEdit)
.replace(/\[labLastEditColor\]/ig, (failColor))
.replace(/\[buttonIcon\]/ig, 'plus')
}else{
template.innerHTML = labProgressManager.lvlContainer
.replace(/\[containerColor\]/ig, 'bg-lab-primary')
.replace(/\[btnColor\]/ig, 'btn-lab-secondary')
.replace(/\[labNumber\]/ig, Object.keys(this.labRelease)[i-1])
.replace(/\[progress\]/ig, 'Em aberto')
.replace(/\[progressColor\]/ig, labCompleted?successColor:'bg-lab-dark text-lab-light')
.replace(/\[this.labExpirationColor\]/ig, 'bg-lab-dark text-lab-light-pink')
.replace(/\[this.labExpiration\]/ig,
`${this.convertToLocalTz(this.labExpiration[i],'string')}`)
.replace(/\[labDelivered\]/ig, labDelivered?'Sim!':'Não')
.replace(/\[labDeliveredColor\]/ig, labDelivered?successColor:failColor)
.replace(/\[labLastEdit\]/ig, labLastEdit)
.replace(/\[labLastEditColor\]/ig, (failColor))
.replace(/\[buttonIcon\]/ig, 'plus')
}
}
}else if (currentDate < this.labRelease[i]){
}
}else if (!pastRelease){
template.innerHTML = labProgressManager.lvlContainerLocked
.replace(/\[difficulty\]/ig, i)
.replace(/\[labRelease\]/ig, `${this.convertToLocalTz(this.labRelease[i],'string')}`)
Expand Down
12 changes: 11 additions & 1 deletion src/adonisjs/public/infra/conditional-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,23 @@ class LayoutController {
document.querySelector('#harena-case-property').remove()
document.querySelector('#harena-inf331-complete-lab').remove()
})
if (expirationDate < new Date()){
let currentDate = labProgressManager.i.setDateToISO(new Date())
if (expirationDate < currentDate && LayoutController.case.message.property.extendPeriod == null){
const saveBtn = document.querySelector('#btn-save-draft')
saveBtn.innerHTML = 'Data da entrega expirada'
btnLabDelivered.firstElementChild.innerHTML = btnLabDelivered.firstElementChild.innerHTML == 'Entregar'?'Não entregue':'Entregue'
saveBtn.classList.add('disabled')
saveBtn.classList.add('no-pointer')
saveBtn.nextElementSibling.topic = ""
}else if (LayoutController.case.message.property.extendPeriod != null){
if (labProgressManager.i.setDateToISO(new Date(LayoutController.case.message.property.extendPeriod)) < currentDate){
const saveBtn = document.querySelector('#btn-save-draft')
saveBtn.innerHTML = 'Data da entrega expirada'
btnLabDelivered.firstElementChild.innerHTML = btnLabDelivered.firstElementChild.innerHTML == 'Entregar'?'Não entregue':'Entregue'
saveBtn.classList.add('disabled')
saveBtn.classList.add('no-pointer')
saveBtn.nextElementSibling.topic = ""
}
}
}
/*else if(userGrade === 'professor' || userGrade === 'coordinator'){
Expand Down
3 changes: 3 additions & 0 deletions src/adonisjs/public/infra/token-validator-mc.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class TokenController {
sessionStorage.setItem('harena-user-institution', endpointResponse.data.institution)
sessionStorage.setItem('harena-user-institution-id', endpointResponse.data.institutionId)
sessionStorage.setItem('harena-user-id', endpointResponse.data.userId)
sessionStorage.setItem('harena-user-username', endpointResponse.data.username)
// localStorage.setItem('harena-user-grade', endpointResponse.data.grade)
// localStorage.setItem('harena-user-institution', endpointResponse.data.institution)
// localStorage.setItem('harena-user-institution-id', endpointResponse.data.institutionId)
Expand Down Expand Up @@ -119,6 +120,8 @@ class TokenController {
sessionStorage.setItem('harena-user-grade', endpointResponse.data.grade)
sessionStorage.setItem('harena-user-institution', endpointResponse.data.institution)
sessionStorage.setItem('harena-user-institution-id', endpointResponse.data.institutionId)
sessionStorage.setItem('harena-user-id', endpointResponse.data.userId)
sessionStorage.setItem('harena-user-username', endpointResponse.data.username)
// localStorage.setItem('harena-user-grade', endpointResponse.data.grade)
// localStorage.setItem('harena-user-institution', endpointResponse.data.institution)
// localStorage.setItem('harena-user-institution-id', endpointResponse.data.institutionId)
Expand Down
3 changes: 3 additions & 0 deletions src/adonisjs/public/infra/token-validator-swe.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class TokenController {
sessionStorage.setItem('harena-user-institution', endpointResponse.data.institution)
sessionStorage.setItem('harena-user-institution-id', endpointResponse.data.institutionId)
sessionStorage.setItem('harena-user-id', endpointResponse.data.userId)
sessionStorage.setItem('harena-user-username', endpointResponse.data.username)
// localStorage.setItem('harena-user-grade', endpointResponse.data.grade)
// localStorage.setItem('harena-user-institution', endpointResponse.data.institution)
// localStorage.setItem('harena-user-institution-id', endpointResponse.data.institutionId)
Expand Down Expand Up @@ -119,6 +120,8 @@ class TokenController {
sessionStorage.setItem('harena-user-grade', endpointResponse.data.grade)
sessionStorage.setItem('harena-user-institution', endpointResponse.data.institution)
sessionStorage.setItem('harena-user-institution-id', endpointResponse.data.institutionId)
sessionStorage.setItem('harena-user-id', endpointResponse.data.userId)
sessionStorage.setItem('harena-user-username', endpointResponse.data.username)
// localStorage.setItem('harena-user-grade', endpointResponse.data.grade)
// localStorage.setItem('harena-user-institution', endpointResponse.data.institution)
// localStorage.setItem('harena-user-institution-id', endpointResponse.data.institutionId)
Expand Down
3 changes: 3 additions & 0 deletions src/adonisjs/public/infra/token-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class TokenController {
sessionStorage.setItem('harena-user-institution', endpointResponse.data.institution)
sessionStorage.setItem('harena-user-institution-id', endpointResponse.data.institutionId)
sessionStorage.setItem('harena-user-id', endpointResponse.data.userId)
sessionStorage.setItem('harena-user-username', endpointResponse.data.username)
// localStorage.setItem('harena-user-grade', endpointResponse.data.grade)
// localStorage.setItem('harena-user-institution', endpointResponse.data.institution)
// localStorage.setItem('harena-user-institution-id', endpointResponse.data.institutionId)
Expand Down Expand Up @@ -119,6 +120,8 @@ class TokenController {
sessionStorage.setItem('harena-user-grade', endpointResponse.data.grade)
sessionStorage.setItem('harena-user-institution', endpointResponse.data.institution)
sessionStorage.setItem('harena-user-institution-id', endpointResponse.data.institutionId)
sessionStorage.setItem('harena-user-id', endpointResponse.data.userId)
sessionStorage.setItem('harena-user-username', endpointResponse.data.username)
// localStorage.setItem('harena-user-grade', endpointResponse.data.grade)
// localStorage.setItem('harena-user-institution', endpointResponse.data.institution)
// localStorage.setItem('harena-user-institution-id', endpointResponse.data.institutionId)
Expand Down
21 changes: 21 additions & 0 deletions src/adonisjs/public/templates/simple/case/sequence-dynamic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Scene 1 (detailed) #

**Scene 1**

Write here.

* Next -> Flow.Next

# Final (detailed,end)

Write here.

* Next Case -> Case.Next

# Answer (note, division) #

**You answered:** ^Previous.input1^

___ Template ___

* template: simple/case/sequence
33 changes: 33 additions & 0 deletions src/adonisjs/public/templates/simple/case/sequence-static.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
___ Flow ___

* Sequential:
* _sequential_

___ Data ___

* theme: simple(blue)
* namespaces:
* evidence: http://purl.org/versum/evidence/
* templates:
* categories:
* detailed:
* Description: simple/knot/seq_description
* Question: simple/knot/seq_question
* Question Certainty: simple/knot/seq_question_certainty
* Quiz: simple/knot/quiz
* Quiz Short: simple/knot/quiz_short
* Visit Day: simple/knot/visit_day
* input:
* Description: simple/knot/seq_description
* Question: simple/knot/seq_question
* Question Certainty: simple/knot/seq_question_certainty
* Quiz: simple/knot/quiz
* Quiz Short: simple/knot/quiz_short
* Visit Day: simple/knot/visit_day
* quiz:
* Description: simple/knot/seq_description
* Question: simple/knot/seq_question
* Question Certainty: simple/knot/seq_question_certainty
* Quiz: simple/knot/quiz
* Quiz Short: simple/knot/quiz_short
* Visit Day: simple/knot/visit_day
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a969287

Please sign in to comment.