Page 1 of 1

LISE repating items problem

Posted: Thu Sep 02, 2021 2:25 pm
by andrewvideouk
Hi guys.

I am trying to show entries and I only have 2 items added. The problem is that its repating same entries about 7 times, I not a programmer but this I tried to make. Can anyone help please.

Code: Select all


<!-- Summary Template -->

var config = [<br />
{if $items|@count > 0}
	<!-- items -->
	{foreach from=$items item=item}
	<!-- item -->
		{if !empty($item->fielddefs)}		<!-- field definitions -->

			{foreach from=$item->fielddefs item=fielddef}
	
			{if $fielddef.type == 'Categories' && ($fielddef.value != '')}
			{LISELoader item='category' force_array=1 value=$fielddef.value assign='cats'}
{assign var="qtheme" value={implode(',', $cats)}}			<!-- categories //-->
			{/if}
					
{ level:"{$item->level}",  theme: "{$qtheme}", question: "{$item->title}", answers: [ "{$item->answer1}","{$item->answer2}","{$item->answer3}","{$item->answer4}" correct: {$item->correct} ]}, 	 <br />
	
			{/foreach}
	
		<!-- field definitions //-->
		{/if}
	<!-- item //-->
	{/foreach}	<!-- items //-->

{/if}
<br />
];

Code: Select all


<!-- outout -->
var config = [
{ level:"1", theme: "Learning Disability", question: "Approximately how many people in the uk have a learning disability?", answers: [ "1.5 million","500 thousand","3.5 million","850 thousand" correct: 4 ]},
{ level:"1", theme: "Learning Disability", question: "Approximately how many people in the uk have a learning disability?", answers: [ "1.5 million","500 thousand","3.5 million","850 thousand" correct: 4 ]},
{ level:"1", theme: "Learning Disability", question: "Approximately how many people in the uk have a learning disability?", answers: [ "1.5 million","500 thousand","3.5 million","850 thousand" correct: 4 ]},
{ level:"1", theme: "Learning Disability", question: "Approximately how many people in the uk have a learning disability?", answers: [ "1.5 million","500 thousand","3.5 million","850 thousand" correct: 4 ]},
{ level:"1", theme: "Learning Disability", question: "Approximately how many people in the uk have a learning disability?", answers: [ "1.5 million","500 thousand","3.5 million","850 thousand" correct: 4 ]},
{ level:"1", theme: "Learning Disability", question: "Approximately how many people in the uk have a learning disability?", answers: [ "1.5 million","500 thousand","3.5 million","850 thousand" correct: 4 ]},
{ level:"1", theme: "Learning Disability", question: "Approximately how many people in the uk have a learning disability?", answers: [ "1.5 million","500 thousand","3.5 million","850 thousand" correct: 4 ]},
{ level:"1", theme: "Learning Disability", question: "A learning disability is a lifelong condition that develops around the time of birth?", answers: [ "True","False","","" correct: 1 ]},
{ level:"1", theme: "Learning Disability", question: "A learning disability is a lifelong condition that develops around the time of birth?", answers: [ "True","False","","" correct: 1 ]},
{ level:"1", theme: "Learning Disability", question: "A learning disability is a lifelong condition that develops around the time of birth?", answers: [ "True","False","","" correct: 1 ]},
{ level:"1", theme: "Learning Disability", question: "A learning disability is a lifelong condition that develops around the time of birth?", answers: [ "True","False","","" correct: 1 ]},
{ level:"1", theme: "Learning Disability", question: "A learning disability is a lifelong condition that develops around the time of birth?", answers: [ "True","False","","" correct: 1 ]},
{ level:"1", theme: "Learning Disability", question: "A learning disability is a lifelong condition that develops around the time of birth?", answers: [ "True","False","","" correct: 1 ]},
{ level:"1", theme: "Learning Disability", question: "A learning disability is a lifelong condition that develops around the time of birth?", answers: [ "True","False","","" correct: 1 ]},

];

Code: Select all

<!-- outout should be -->
{ level:"1", theme: "Learning Disability", question: "Approximately how many people in the uk have a learning disability?", answers: [ "1.5 million","500 thousand","3.5 million","850 thousand" correct: 4 ]},
{ level:"1", theme: "Learning Disability", question: "A learning disability is a lifelong condition that develops around the time of birth?", answers: [ "True","False","","" correct: 1 ]},
Also how would I sort by level and category

so I want sometining like

Level 1 Learning Disability ...
Level 1 Learning Disability ...
Level 1 Autism ...
Level 1 Autism ...

Level 2 Learning Disability ...
Level 2 Learning Disability ...
Level 2Autism ...
Level 2 Autism ...


Thank you very much

Re: LISE repating items problem

Posted: Thu Sep 02, 2021 2:38 pm
by andrewvideouk
I think i fixed the repating problem by moving {/foreach} up.


Code: Select all

var config = [<br />
{if $items|@count > 0}
	<!-- items -->
	{foreach from=$items item=item}
	<!-- item -->
		{if !empty($item->fielddefs)}		<!-- field definitions -->

			{foreach from=$item->fielddefs item=fielddef}
	
			{if $fielddef.type == 'Categories' && ($fielddef.value != '')}
			{LISELoader item='category' force_array=1 value=$fielddef.value assign='cats'}
{assign var="qtheme" value={implode(',', $cats)}}			<!-- categories //-->
			{/if}
			
				{/foreach}
					
{ level:"{$item->level}",  theme: "{$qtheme}", question: "{$item->title}", answers: [ "{$item->answer1}","{$item->answer2}","{$item->answer3}","{$item->answer4}" correct: {$item->correct} ]}, 	 <br />
	
		<!-- field definitions //-->
		{/if}
	<!-- item //-->
	{/foreach}	<!-- items //-->

{/if}
<br />
];

Re: LISE repating items problem

Posted: Thu Sep 02, 2021 2:58 pm
by DIGI3
Sorting options are in the LISE documentation, there's quite a bit of control. Mixing category and field sorting can be a bit iffy though, so it's possible you'll need to call the module once for each category or do some tertiary sorting within the template or a UDT. You'll need to experiment though.

Re: LISE repating items problem

Posted: Fri Sep 03, 2021 11:10 am
by andrewvideouk
Thank you.