on 01-24-2018 9:44 AM
Dear GuruDevelopers,
I'm currently making a questionary app in webide and I want that every page to have 5 questions. How do we build this in with a randomiser who randomly selects the quesitons and make sure that when we press for the next page or previeus that the questions don't change or questions occur several times over different pages?
This is what I have so far.
<Table id="__table0" inset="false" items="{path: '/Questions'}" visibleRowCount="5">
<items>
<ColumnListItem id="__item0">
<cells>
<Text select="_GroupQuestions" key="{/QID}" text="{Qn}" id="__text3"/>
</cells>
<cells style="text-align:end">
<RatingIndicator iconSize="32px" maxValue="5"/>
</cells>
</ColumnListItem></items>
<columns>
<Column id="__column2" width="80%">
<header>
</header>
</Column>
<Column id="__column3" class="tblstarend">
<header>
</header>
</Column>
</columns></Table>
Hi! So if we basically have Array of questions, we can randomly split into additional model property.
Something like this:
var items = [{Qn: 'q1'}, {Qn: 'q2'} ...];<br>var aPages = [];
//randomly split pages<br>while (items.length > 0) {
var lastPage = aPages[aPages.length - 1];
if(!lastPage || lastPage.length === 5) {
lastPage = aPages[aPages.push([]) - 1];
}
lastPage.push(items.splice(Math.floor(Math.random()*items.length), 1)[0])
}
//set new prop for model
this.myModel.setProperty('/QPages', aPages);
this.currentPageId = 0
//setup initial page<br>this.byId('__table0').bindObject('/QPages/' + this.currentPage);
//////////////////////////////////////////////////////////////////////
//change view binding of table: items="{}"
//And change pages with switching binding context of table:
onNextPagePress: function() {
this.byId('__table0').bindObject('/QPages/' + ++this.currentPage);
}
onPrevPagePress: function() {
this.byId('__table0').bindObject('/QPages/' + --this.currentPage);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Let me explain the situation:
We have a HANAXS database with approximately 200 questions. What we want is 5 pages with 5 questions each. These questions should be selected at random but a question may not occur twice in the 5 pages. Our current situation is that it retrieves all of the questions (limited to the standard 100) by binding it to the table.
I hope this clarifies the situation.
Hi xefimix,
thank you for your Answer.
nitinantoon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi xefimix,
thank you for your Answer.
nitinantoon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi xefimix,
thank you for your Answer.
nitinantoon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.