Skip to content

Commit

Permalink
Merge pull request #213 from datasci4health/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
santanche authored Sep 3, 2020
2 parents 4bde7a6 + 8b905cc commit 2c27be8
Show file tree
Hide file tree
Showing 21 changed files with 219 additions and 143 deletions.
48 changes: 46 additions & 2 deletions src/adonisjs/app/Controllers/Http/QuestController.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ class QuestController {
async getCasesByQuest({ request, response }) {
try{
const params = request.all()
console.log('------------------------COR DA QUEST');
console.log(params.color);
var responseData = [];
let endpoint_url = Env.get("HARENA_MANAGER_URL") + "/api/v1/quest/cases"
let endpoint_url = Env.get("HARENA_MANAGER_URL") + "/api/v1/author/quest/cases"

var config = {
method: 'get',
Expand Down Expand Up @@ -48,7 +50,49 @@ class QuestController {
console.log(e)
}

return view.render('player.player-cases', { cases: responseData[0], });
return view.render('player.player-cases', { cases: responseData[0], color: request.input('color') });

}
async getQuests({ request, response }) {
try{
var responseData = [];
let endpoint_url = Env.get("HARENA_MANAGER_URL") + "/api/v1/author/quests"

var config = {
method: 'get',
url: endpoint_url,
headers: {
'Authorization': 'Bearer ' + request.cookie('token')
}
};


await axios(config)
.then(function (endpoint_response) {
console.log('============ Retrieving quests');
console.log(endpoint_response.data);
const busResponse = []
for (const c in endpoint_response.data) {
busResponse.push({
id: endpoint_response.data[c].id,
title: endpoint_response.data[c].title,
color: endpoint_response.data[c].color,
url: endpoint_response.data[c].url,

})

}
responseData[0] = busResponse;
})

.catch(function (error) {
console.log(error);
});
} catch(e){
console.log(e)
}
const pageTitle = 'Welcome Player';
return view.render('player.welcome', { quests: responseData[0], pageTitle});

}
}
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions src/adonisjs/public/author/js/dcc-author-server-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ class DCCAuthorServer {
async uploadArtifact (topic, message) {
const data = new FormData()
if (message.file) { data.append('file', message.file) } else if (message.b64) { data.append('image', this.b64toBlob(message.b64)) }
data.append('case_id', message.caseid)
data.append('caseId', message.caseid)
const header = {
async: true,
crossDomain: true,
Expand All @@ -309,9 +309,10 @@ class DCCAuthorServer {
// console.log(header);
const response =
await fetch(DCCCommonServer.managerAddressAPI + 'artifact', header)
console.log('=== response')
console.log('=== response image upload')
console.log(response)
const jsonResponse = await response.json()
console.log(jsonResponse)
MessageBus.ext.publish(MessageBus.buildResponseTopic(topic, message),
jsonResponse.filename)
}
Expand Down
30 changes: 16 additions & 14 deletions src/adonisjs/public/dccs/components/dcc-input-choice.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ class DCCInputOption extends DCCInput {
if (!this.hasAttribute('value')) { this.value = this._statement.trim() }

// <TODO> align with dcc-state-select
if (this._parent == null && this.hasAttribute('variable')) {
if (this._parent == null && this.hasAttribute('variable')) {
MessageBus.int.publish('var/' + this.variable + '/input/ready',
{
{
sourceType: DCCInputOption.elementTag,
content: this.value
})
content: this.value
})
}
}

Expand Down Expand Up @@ -92,9 +92,9 @@ class DCCInputOption extends DCCInput {
inputChanged () {
this.changed = true
MessageBus.ext.publish('var/' + this.variable + '/changed',
{
{
sourceType: DCCInputOption.elementTag,
value: this.value
value: this.value
})
}

Expand All @@ -118,11 +118,12 @@ class DCCInputOption extends DCCInput {
? '' : this._statement

const html = (this.target)
? "<dcc-trigger id='[id]' xstyle='theme' action='[target]' label='[statement]' divert='round' value='[value]'></dcc-trigger>"
? "<dcc-trigger id='[id]' xstyle='theme' action='[target]' label='[statement]' divert='round' value='[value]' variable='[variable]:label'></dcc-trigger>"
.replace('[id]', varid + nop)
.replace('[target]', this.target)
.replace('[statement]', child._statement)
.replace('[value]', child.value)
.replace('[variable]', this.variable)
: "<input id='presentation-dcc' type='[exclusive]' name='[variable]' value='[value]'[checked]>[statement]</input>"
.replace('[exclusive]', (this.hasAttribute('exclusive') ? 'radio' : 'checkbox'))
.replace('[variable]', this.variable)
Expand Down Expand Up @@ -160,8 +161,8 @@ class DCCInputChoice extends DCCInput {
}

disconnectedCallback () {
if (this._options != null) {
for (const o of this._options) { o.removeEventListener('change', this.inputChanged) }
if (this._options != null) {
for (const o of this._options) { o.removeEventListener('change', this.inputChanged) }
}
}

Expand Down Expand Up @@ -195,9 +196,9 @@ class DCCInputChoice extends DCCInput {
inputChanged (event) {
this.changed = true
MessageBus.ext.publish('var/' + this.variable + '/changed',
{
{
sourceType: DCCInputChoice.elementTag,
value: event.target.value
value: event.target.value
})
}

Expand Down Expand Up @@ -248,11 +249,12 @@ class DCCInputChoice extends DCCInput {
child.tagName.toLowerCase() == DCCInputOption.elementTag) {
nop++
const element = (this.target || child.target)
? "<dcc-trigger id='presentation-dcc-[id]' xstyle='theme' action='[target]' label='[statement]' divert='round' value='[value]'></dcc-trigger>"
? "<dcc-trigger id='presentation-dcc-[id]' xstyle='theme' action='[target]' label='[statement]' divert='round' value='[value]' variable='[variable]:label'></dcc-trigger>"
.replace('[id]', varid + '_' + nop)
.replace('[target]', (child.target) ? child.target : this.target)
.replace('[statement]', child._statement)
.replace('[value]', child.value)
.replace('[variable]', this.variable)
: "<input id='presentation-dcc-[id]' type='[exclusive]' name='[variable]' value='[value]'[checked]>[statement]</input>"
.replace('[id]', varid + '_' + nop)
.replace('[exclusive]',
Expand Down Expand Up @@ -284,9 +286,9 @@ class DCCInputChoice extends DCCInput {
if (this.hasAttribute("xstyle") && this.xstyle.startsWith("out") &&
this._statement != null) {
*/
if (this._statement != null) {
if (this._statement != null) {
await this._applyRender(
'<p>' + this._statement + '</p>', 'innerHTML', 'text')
'<p>' + this._statement + '</p>', 'innerHTML', 'text')
}

// presentation = await this._applyRender(html, "innerHTML", "input");
Expand Down
41 changes: 31 additions & 10 deletions src/adonisjs/public/dccs/components/dcc-trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class DCCTrigger extends DCCBlock {

static get observedAttributes () {
return DCCBlock.observedAttributes.concat(
['type', 'link', 'action', 'value'])
['type', 'link', 'action', 'value', 'variable'])
}

get type () {
Expand Down Expand Up @@ -66,6 +66,14 @@ class DCCTrigger extends DCCBlock {
this.setAttribute('value', newValue)
}

get variable () {
return this.getAttribute('variable')
}

set variable (newValue) {
this.setAttribute('variable', newValue)
}

/* Rendering */

async _renderInterface () {
Expand Down Expand Up @@ -124,15 +132,28 @@ class DCCTrigger extends DCCBlock {
}

_computeTrigger () {
if (this._active &&
(this.hasAttribute('label') || this.hasAttribute('action'))) {
if (this.hasAttribute('action') && this.action.endsWith('/navigate')) { this._active = false }
const topic = (this.hasAttribute('action'))
? this.action : 'trigger/' + this.label + '/clicked'
const message = {}
if (this.hasAttribute('value')) { message.value = this.value }

MessageBus.ext.publish(topic, message)
if (this._active) {
if (this.hasAttribute('variable')) {
const v = (this.variable.includes(':'))
? this.variable.substring(0, this.variable.indexOf(':')) : this.variable
console.log('=== trigger variable')
console.log('var/' + v + '/changed')
console.log((this.variable.endsWith(':label')) ? this.label : this.value)
MessageBus.ext.publish('var/' + v + '/changed',
{
sourceType: DCCTrigger.elementTag,
value: (this.variable.endsWith(':label')) ? this.label : this.value
})
}
if (this.hasAttribute('label') || this.hasAttribute('action')) {
if (this.hasAttribute('action') && this.action.endsWith('/navigate')) { this._active = false }
const topic = (this.hasAttribute('action'))
? this.action : 'trigger/' + this.label + '/clicked'
const message = {}
if (this.hasAttribute('value')) { message.value = this.value }

MessageBus.ext.publish(topic, message)
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/adonisjs/public/start/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ div {
.home-p-text{
font-family: 'Lato',serif;
color: rgb(130,130,130);
font-size: 20pt;
font-size: 27px;
}
.home-header-text{
font-family: 'Lato',serif;
font-weight: 700;
font-size: 40pt;
font-size: 60px;
font-style: bold;
color: rgb(52,110,147);
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/adonisjs/public/start/img/home_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 28 additions & 38 deletions src/adonisjs/public/templates/simple/case/quiz_sequence.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,44 @@
# Quiz1 (quiz)

Write here the **stem** of your quiz.

> Write here the lead-in of your quiz.
>
? hypothesis
* type: choice
* exclusive
* trigger
* scramble
* target: Feedback
* options:
* Answer-key: Feedback for Answer-key
* Distractor 1: Feedback for Distractor 1
* Distractor 2: Feedback for Distractor 2
* Distractor 3: Feedback for Distractor 3

* Next Quiz -> Knot.Next
* Menu -> Presentation
Write here the **stem** of your question.

> Write here the **lead-in** of your question.
+ Answer-key <-> "Feedback for Answer-key"
+ Distractor 1 <-> "Feedback for Distractor 1"
+ Distractor 2 <-> "Feedback for Distractor 2"
+ Distractor 3 <-> "Feedback for Distractor 3"
* Next Question -> Knot.Next

# Quiz2 (quiz)

Write here the **stem** of your quiz.
Write here the **stem** of your question.

> Write here the lead-in of your quiz.
>
? hypothesis
* type: choice
* exclusive
* trigger
* scramble
* target: Feedback
* options:
* Answer-key: Feedback for Answer-key
* Distractor 1: Feedback for Distractor 1
* Distractor 2: Feedback for Distractor 2
* Distractor 3: Feedback for Distractor 3
> Write here the **lead-in** of your question.
+ Answer-key <-> "Feedback for Answer-key"
+ Distractor 1 <-> "Feedback for Distractor 1"
+ Distractor 2 <-> "Feedback for Distractor 2"
+ Distractor 3 <-> "Feedback for Distractor 3"
* Next Case -> Case.Next
* Menu -> Presentation
* Next Question -> Knot.Next

# Feedback (note)
# Note (note)

You answered: ^Block.Presentation.hypothesis^.
**You answered:** ^Presentation.input1^.
<br>
^parameter^

# Presentation References (note)

**You answered:** ^Presentation.input1^.
<br>
^parameter^

* Return -> Presentation
References <-> References

# References (note)

* Próximo caso -> Case.Next
* [Enter References](References)

___ Flow ___

Expand Down
14 changes: 13 additions & 1 deletion src/adonisjs/public/templates/simple/case/quiz_short.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,22 @@ Write here the **stem** of your quiz.

# Presentation Note (note)

You answered: ^Presentation.input^.
**You answered:** ^Presentation.input1^.
<br>
^parameter^

# Presentation References (note)

**You answered:** ^Presentation.input1^.
<br>
^parameter^

References <-> References

# References (note)

* [Enter References](References)

___ Flow ___

* Sequential:
Expand Down
4 changes: 2 additions & 2 deletions src/adonisjs/public/themes/simple/css/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
position: absolute;
bottom: 0px;
width: 100%;
display: flex;
flex-direction: row;
/* display: flex; */
/* flex-direction: row; */
}

.styt-button, .styt-button-option {
Expand Down
2 changes: 1 addition & 1 deletion src/adonisjs/public/themes/simple/note.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="styt-main-frame">
<div class="styt-main">
<div id="knot-wrapper" class="styt-main-text">
<dcc-styler xstyle="out" distribution="generic" targeted="action">
<dcc-styler xstyle="theme" distribution="generic">
{knot}
</dcc-styler>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/adonisjs/public/translator/item-templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
option:
'<dcc-trigger id=\'dcc[seq]\'[author] type=\'[subtype]\' action=\'[target]\' label=\'[display]\'[divert][message][image]></dcc-trigger>',
divert:
'<dcc-trigger id=\'dcc[seq]\'[author] type=\'+\' action=\'[target]\' label=\'[display]\'></dcc-trigger>',
'<dcc-trigger id=\'dcc[seq]\'[author] type=\'+\' action=\'[target]\' label=\'[display]\' divert=\'[divert]\'></dcc-trigger>',
'divert-script':
'-&gt; [target][parameter]<br>',
entity:
Expand Down
Loading

0 comments on commit 2c27be8

Please sign in to comment.