LISE repating items problem

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
andrewvideouk
Forum Members
Forum Members
Posts: 155
Joined: Thu Aug 20, 2020 10:49 pm

LISE repating items problem

Post 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
andrewvideouk
Forum Members
Forum Members
Posts: 155
Joined: Thu Aug 20, 2020 10:49 pm

Re: LISE repating items problem

Post 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 />
];
User avatar
DIGI3
Dev Team Member
Dev Team Member
Posts: 1609
Joined: Wed Feb 25, 2009 4:25 am
Location: Victoria, BC

Re: LISE repating items problem

Post 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.
Not getting the answer you need? CMSMS support options
andrewvideouk
Forum Members
Forum Members
Posts: 155
Joined: Thu Aug 20, 2020 10:49 pm

Re: LISE repating items problem

Post by andrewvideouk »

Thank you.
Post Reply

Return to “Modules/Add-Ons”