[Xerte-dev] Re: Problem with Number of uses count in both trunk and v2.0

Pat @ Pgogy xerte at pgogywebstuff.com
Sun Jun 30 10:29:59 BST 2013


Play is best. The extra hit is just a fact of life sometimes - there is still a check recycle bin statement in index i think....

I think update can have conditions?

Or try using replace maybe?

On 30 Jun 2013, at 09:50, "Smith, John" <J.J.Smith at gcu.ac.uk> wrote:

> Yeah I considered that but where should this be? In upgrade.php to be run once? or just near the start of play.php where is will be run each time? Was trying to avoid the additional database hit every time the LO is played...
> 
> Regards,
> 
> John Smith | Learning Technologist
> Room A251, Govan Mbeki Building | School of Health & Life Sciences | Glasgow Caledonian University
> Cowcaddens Road | Glasgow | G4 0BA
> ________________________________________
> From: xerte-dev-bounces at lists.nottingham.ac.uk [xerte-dev-bounces at lists.nottingham.ac.uk] On Behalf Of Pat @ Pgogy  [xerte at pgogywebstuff.com]
> Sent: 29 June 2013 22:23
> To: For Xerte technical developers
> Subject: [Xerte-dev] Re: Problem with Number of uses count in both trunk and    v2.0
> 
> Why not update but with a where on template id
> 
> I think adding a select in to look for null is ok
> 
> On 29 Jun 2013, at 22:09, "Smith, John" <J.J.Smith at gcu.ac.uk> wrote:
> 
>> Hi,
>> 
>> I've noticed (and fixed) a bug which has been introduced into v2.0 (and probably before) where 'number_of_uses' in templatedetails is setup with default of NULL and was not being set to 0 when a new template was created. In this situation the play code query which runs number_of_uses=number_of_uses+1 doesn't work and the value stays as NULL...
>> 
>> So I've fixed it so that when new ones are created that 0 is inserted in this field but existing ones are stuck in limbo... I thought about fixing it in upgrade.php but have come up with what seems to me to be an elegant solution in play.php. I've changed the UPDATE query to:
>> 
>>   SET number_of_uses=COALESCE(number_of_uses+1,1)
>> 
>> which seems to work. Basically COALESCE returns the first value that isn't NULL... so if number_of_uses is NULL then so it the +1 so in that case it returns the second value of 1.
>> 
>> Never having used this SQL function before though i'm wondering what you all think about this... it seems to work with the problematic entries as well as the ok ones but is there anything I'm missing with the use of this function? I've committed it to trunk but will wait before pushing it into v2.0 branch to see what you all think...
>> 
>> Regards,
>> 
>> John Smith | Learning Technologist
>> Room A251, Govan Mbeki Building | School of Health & Life Sciences | Glasgow Caledonian University
>> Cowcaddens Road | Glasgow | G4 0BA
>> 
>> Glasgow Caledonian University is a registered Scottish charity, number SC021474
>> 
>> Winner: Times Higher Education’s Widening Participation Initiative of the Year 2009 and Herald Society’s Education Initiative of the Year 2009.
>> http://www.gcu.ac.uk/newsevents/news/bycategory/theuniversity/1/name,6219,en.html
>> 
>> Winner: Times Higher Education’s Outstanding Support for Early Career Researchers of the Year 2010, GCU as a lead with Universities Scotland partners.
>> http://www.gcu.ac.uk/newsevents/news/bycategory/theuniversity/1/name,15691,en.html
>> _______________________________________________
>> Xerte-dev mailing list
>> Xerte-dev at lists.nottingham.ac.uk
>> http://lists.nottingham.ac.uk/mailman/listinfo/xerte-dev
> 
> _______________________________________________
> Xerte-dev mailing list
> Xerte-dev at lists.nottingham.ac.uk
> http://lists.nottingham.ac.uk/mailman/listinfo/xerte-dev
> 
> Glasgow Caledonian University is a registered Scottish charity, number SC021474
> 
> Winner: Times Higher Education’s Widening Participation Initiative of the Year 2009 and Herald Society’s Education Initiative of the Year 2009.
> http://www.gcu.ac.uk/newsevents/news/bycategory/theuniversity/1/name,6219,en.html
> 
> Winner: Times Higher Education’s Outstanding Support for Early Career Researchers of the Year 2010, GCU as a lead with Universities Scotland partners.
> http://www.gcu.ac.uk/newsevents/news/bycategory/theuniversity/1/name,15691,en.html
> 
> _______________________________________________
> Xerte-dev mailing list
> Xerte-dev at lists.nottingham.ac.uk
> http://lists.nottingham.ac.uk/mailman/listinfo/xerte-dev
> This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it.   Please do not use, copy or disclose the information contained in this message or in any attachment.  Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham.
> 
> This message has been checked for viruses but the contents of an attachment
> may still contain software viruses which could damage your computer system, you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation.
> 
> 
> 
> 



More information about the Xerte-dev mailing list