jssanshi / concerto-platform

Automatically exported from code.google.com/p/concerto-platform
0 stars 0 forks source link

Items and Charts Tutorial images not showing #65

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

# Table query
ibank<- concerto.table.query(
  # SQL query to perform.
  sql=paste("
SELECT
*
FROM `concerto4_102`.`Tutorial_L2_item bank`
",sep=""),
  # Named list with parameters.
  params=list()
)

response1<- concerto.template.show(5)

for (i in 1:dim(ibank)[1]){
  # Table query
  no_responses<- concerto.table.query(
    # SQL query to perform.
    sql=paste("
SELECT
*
FROM `concerto4_102`.`Tutorial_L1_responses`
WHERE
`response` = '",dbEscapeStrings(concerto$db$connection,toString(0)),"'
AND `question_id` = 
'",dbEscapeStrings(concerto$db$connection,toString(ibank[i,"id"])),"'
",sep=""),
    # Named list with parameters.
    params=list())
  # Table query
  yes_responses<- concerto.table.query(
    # SQL query to perform.
    sql=paste("
SELECT
*
FROM `concerto4_102`.`Tutorial_L1_responses`
WHERE
`response` = '",dbEscapeStrings(concerto$db$connection,toString(1)),"'
AND `question_id` = 
'",dbEscapeStrings(concerto$db$connection,toString(ibank[i,"id"])),"'
",sep=""),
    # Named list with parameters.
    params=list()
  )

  file_name <- paste(ibank[i, "id"], ".jpg", sep="")
  chart_path<- paste(concerto$mediaPath, file_name, sep='')
  chart_url<- paste(concerto$MediaURL, file_name, "?", as.numeric(Sys.time()), sep='')

  if(dim(yes_responses)[1]>0 || dim(no_responses)[1]>0){
    jpeg(chart_path)
    pie(x=c(dim(yes_responses)[1], dim(no_responses)[1]), labels=c("yes", "no"))
    dev.off()
  }

  response2<- concerto.template.show(6, params=list(question=ibank[i, "question"], chart_url = chart_url))

  # Table query
  concerto.table.query(
    # SQL query to perform.
    sql=paste("
INSERT
INTO `concerto4_102`.`Tutorial_L1_responses`
SET 
`response`='",dbEscapeStrings(concerto$db$connection,toString(response2$response
)),"'
,
`question_id`='",dbEscapeStrings(concerto$db$connection,toString(ibank[i, 
"id"])),"'
",sep=""),
    # Named list with parameters.
    params=list()
  )
}

response3<- concerto.template.show(7, params=list(username=response1$username))

#-------------------------------------------------------------------------------
----

What is the expected output? What do you see instead?

A pie chart should appear with every question after the first response, but all 
I get is the image icon and no chart. 

What version of the product are you using? On what operating system?

Demo Server, latest version (up-to-date). 

Please provide any additional information below.

I have the exact same code as in the "Items and Charts" tutorial, except I have 
adapted the variables names and template/table numbers to my situation. The 
test works perfectly, apart from the image that does not show. 

Original issue reported on code.google.com by vicsan...@gmail.com on 24 Nov 2014 at 6:12

GoogleCodeExporter commented 9 years ago
Please ignore my post. I just realized I had "concerto$MediaURL" instead of 
"concerto$mediaURL", in small letters. It works great now. Thank you

Original comment by vicsan...@gmail.com on 24 Nov 2014 at 6:25

GoogleCodeExporter commented 9 years ago

Original comment by LisPrzem...@gmail.com on 29 Dec 2014 at 1:06