Skip to content

Commit

Permalink
feat (theme): note themes configuration
Browse files Browse the repository at this point in the history
via json
  • Loading branch information
santanche committed Sep 7, 2020
1 parent 8bbd374 commit 0424c2b
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 20 deletions.
13 changes: 3 additions & 10 deletions src/adonisjs/public/dccs/components/dcc-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,25 +133,18 @@ class DCCButton extends DCCBlock {

_computeTrigger () {
if (this._active) {
let message = { sourceType: DCCButton.elementTag }
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.message)
MessageBus.ext.publish('var/' + v + '/changed',
{
sourceType: DCCButton.elementTag,
value: (this.variable.endsWith(':label')) ? this.label : this.message
})
message.value = (this.variable.endsWith(':label')) ? this.label : this.message
MessageBus.ext.publish('var/' + v + '/changed', message)
}
if (this.hasAttribute('label') || this.hasAttribute('topic')) {
if (this.hasAttribute('topic') && this.topic.endsWith('/navigate')) { this._active = false }
const topic = (this.hasAttribute('topic'))
? this.topic : 'button/' + this.label + '/clicked'
const message = {}
if (this.hasAttribute('message')) { message.value = this.message }

MessageBus.ext.publish(topic, message)
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/adonisjs/public/player/js/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,14 @@ class PlayerManager {
this._knots[knotName].categories.includes('script')) { MetaPlayer.player.play(this._knots[knotName], this._state) } else {
const knot = await Translator.instance.generateHTML(
this._knots[knotName])
if (this._knots[knotName].categories &&
this._knots[knotName].categories.includes('note')) { this.presentNote(knot) } else { this.presentKnot(knot) }
console.log('=== theme settings')
console.log(Translator.instance.themeSettings.note)
let note = false
if (this._knots[knotName].categories && Translator.instance.themeSettings &&
Translator.instance.themeSettings.note)
note = this._knots[knotName].categories.find(
cat => Translator.instance.themeSettings.note.includes(cat))
if (note) { this.presentNote(knot) } else { this.presentKnot(knot) }
}
}
MessageBus.ext.publish('knot/' + knotName + '/start')
Expand Down
18 changes: 17 additions & 1 deletion src/adonisjs/public/player/js/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,31 @@ class PlayState {
variableGet (topic, message) {
let id = MessageBus.extractLevel(topic, 2)

/*
console.log('=== variable request')
console.log(id)
console.log('=== variables')
console.log(this._state.variables)
*/


if (id.startsWith('Previous.')) {
const previousKnot = this.historyPreviousId()
if (previousKnot != null) { id = previousKnot + '.' + id.substring(9) }
}

// tries to give a scope to the variable
if (id != null && this._state.variables[id] == null) {
const currentKnot = this.historyCurrent()
if (currentKnot != null &&
this._state.variables[currentKnot + '.' + id] != null) { id = currentKnot + '.' + id }
this._state.variables[currentKnot + '.' + id] != null) { id = currentKnot + '.' + id }
}

if (id != null) {
console.log('=== variable get')
console.log(id)
console.log(this._state.variables[id])
MessageBus.ext.publish(MessageBus.buildResponseTopic(topic, message),
this._state.variables[id])
}
Expand Down Expand Up @@ -173,6 +184,11 @@ class PlayState {
return (this._state.history.length > 1)
}

historyPreviousId() {
return (this.historyHasPrevious())
? this._state.history[this._state.history.length - 2] : null;
}

historyCurrent () {
let current = null
if (this._state.history.length > 0) { current = this._state.history[this._state.history.length - 1] }
Expand Down
2 changes: 1 addition & 1 deletion src/adonisjs/public/templates/simple/case/quiz_sequence.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Write here the **feedback**.

# Note (note)

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

Expand Down
10 changes: 5 additions & 5 deletions src/adonisjs/public/templates/simple/case/quiz_short.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@
Write here the **stem** of your quiz.

> Write here the **lead-in** of your quiz.
+ Answer-key <-> "Feedback for Answer-key"
+ Answer-key <-> Presentation References "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

# Presentation Note (note)
# Note (note)

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

# Presentation References (note)

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

References <-> References

# References (note)
# References (note_references)

* [Enter References](References)

Expand Down
12 changes: 12 additions & 0 deletions src/adonisjs/public/themes/simple/note_references.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<div class="styt-main-frame">
<div class="styt-main">
<div id="knot-wrapper" class="styt-main-text">
<dcc-styler xstyle="theme" distribution="generic">
{knot}
</dcc-styler>
</div>
</div>
</div>
<div class="styt-button-frame">
<dcc-button xstyle="theme" topic="knot/</navigate" label="Return"></dcc-button>
</div>
4 changes: 3 additions & 1 deletion src/adonisjs/public/themes/simple/theme.json
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"note": ["note", "note_references"]
}
4 changes: 4 additions & 0 deletions src/adonisjs/public/translator/translator.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class Translator {
return (this.authoringRender) ? ' author' : ''
}

get themeSettings () {
return this._themeSettings;
}

_authorAttrSub (superseq) {
return (this.authoringRender && superseq == -1) ? ' author' : ''
}
Expand Down

0 comments on commit 0424c2b

Please sign in to comment.