Get Picture out questiontext

Get Picture out questiontext

per Mathias Kohs -
Nombre de respostes: 7

Hello together,

I'm used to work with Moodle1.9 but in Moodle2.x it's different.

I try to get the picture from questions questiontext.
I want to develop a block which uses this pictures.

In the Version 1.9 I extrakted the path and thats it.

In Version 2.3 there is a path like:

I don't now how can i get the file oder filepath out of this path.
The path is used by Quiz like that: www.mymoodle123.com/pluginfile.php?file=/453/question/questiontext/98/1/815/LFILFI.png

I understand:
- 453: is contextid
- question: links to table question
- questiontext links to column

but I can agree with the other params.

Can someone tell me where I finde the other params?
Or it there a better way, to get the picture?

Mitjana de qualificacions: -
En resposta a Mathias Kohs

Re: Get Picture out questiontext

per Tim Hunt -
Imatge Core developers Imatge Documentation writers Imatge Particularly helpful Moodlers Imatge Peer reviewers Imatge Plugin developers

Generally, in Moodle 2.x, you should not use an image belonging to one bit of content in an unrelated place. What are you acutally trying to do?

En resposta a Tim Hunt

Re: Get Picture out questiontext

per Mathias Kohs -

I trying to build a Block which deals the quizz-content to a mobile-app.
The block generades ZIP-files. If the app ist asking for, it will get the content.

The app should be used local so it's important that the block get the pictures.

En resposta a Mathias Kohs

Re: Get Picture out questiontext

per Tim Hunt -
Imatge Core developers Imatge Documentation writers Imatge Particularly helpful Moodlers Imatge Peer reviewers Imatge Plugin developers

Ah, I see. You are not really creating a block at all. Would it not be better to do this using web services, like the official Moodle mobile app does?

En resposta a Tim Hunt

Re: Get Picture out questiontext

per Mathias Kohs -

The Block for Moodle 1.9 which deals the Data is allrady finished.

And for this Block are some Apps build and in use. 

If I want to change the plugin-interface from block to service, it would be more clear but my colleagues would kill me. Complicitat

En resposta a Mathias Kohs

Re: Get Picture out questiontext

per Mathias Kohs -

Thanks for showing me the link to File-API.

Where can I find the params for usering the File-API?

I tried to get the File via File-API:

$fs = get_file_storage();
$file = $fs->get_file(453, "question", "questiontext", 814, "/", 'iOS%20Simulator%20Bildschirmfoto%2004.12.2012%2009.42.23.png');

if ($file) {

  $contents = $file->get_content();
  syslog(LOG_INFO, "!TOP!: ");
  $datei = fopen($CFG->dirroot."/blocks/quizztwogo/TEST.png", "w");
  fwrite($datei, $contents);
  fclose($datei);

} else {

  syslog(LOG_INFO, "TEST dont fitt");
}

The problem is, this code don't fit and the $file doesn't exist, after $fs->get_file...

 

En resposta a Mathias Kohs

Re: Get Picture out questiontext

per Mathias Kohs -

I have fixxed the Problem.

$file = $fs->get_file(453, "question", "questiontext", 814, "/", 'iOS%20Simulator%20Bildschirmfoto%2004.12.2012%2009.42.23.png');

=>is wrong

I need use $file = $fs->get_file(453, "question", "questiontext", 814, "/", 'iOS 20Simulator 20Bildschirmfoto 2004.12.2012 2009.42.23.png');