Get Picture out questiontext

Get Picture out questiontext

deur Mathias Kohs -
Getal antwoorde: 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?

Gemiddeld van beoordelings: -
In antwoord op Mathias Kohs

Re: Get Picture out questiontext

deur Joseph Rézeau -
Prentjie van Core developers Prentjie van Particularly helpful Moodlers Prentjie van Plugin developers Prentjie van Testers Prentjie van Translators

Hi Mathias,

Yes, the way that files (and picture files) are handled has completely changed in Moodle 2.

It is now much more complicated, but you can do it, with the help of the documentation here:

http://docs.moodle.org/dev/File_API

Joseph

Gemiddeld van beoordelings: -
In antwoord op Mathias Kohs

Re: Get Picture out questiontext

deur Tim Hunt -
Prentjie van Core developers Prentjie van Documentation writers Prentjie van Particularly helpful Moodlers Prentjie van Peer reviewers Prentjie van 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?

Gemiddeld van beoordelings:Useful (1)
In antwoord op Tim Hunt

Re: Get Picture out questiontext

deur 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.

Gemiddeld van beoordelings: -
In antwoord op Mathias Kohs

Re: Get Picture out questiontext

deur Tim Hunt -
Prentjie van Core developers Prentjie van Documentation writers Prentjie van Particularly helpful Moodlers Prentjie van Peer reviewers Prentjie van 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?

Gemiddeld van beoordelings: -
In antwoord op Tim Hunt

Re: Get Picture out questiontext

deur 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. knipoog

Gemiddeld van beoordelings: -
In antwoord op Mathias Kohs

Re: Get Picture out questiontext

deur 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...

 

Gemiddeld van beoordelings: -
In antwoord op Mathias Kohs

Re: Get Picture out questiontext

deur 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');

 

 

 

Gemiddeld van beoordelings: -