Get Picture out questiontext

Get Picture out questiontext

Mathias Kohs發表於
Number of replies: 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?

評比平均分數: -
In reply to Mathias Kohs

Re: Get Picture out questiontext

Tim Hunt發表於
Core developers的相片 Documentation writers的相片 Particularly helpful Moodlers的相片 Peer reviewers的相片 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?

評比平均分數:Useful (1)
In reply to Tim Hunt

Re: Get Picture out questiontext

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.

In reply to Mathias Kohs

Re: Get Picture out questiontext

Tim Hunt發表於
Core developers的相片 Documentation writers的相片 Particularly helpful Moodlers的相片 Peer reviewers的相片 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?

In reply to Tim Hunt

Re: Get Picture out questiontext

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. 眨眼

In reply to Mathias Kohs

Re: Get Picture out questiontext

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

 

In reply to Mathias Kohs

Re: Get Picture out questiontext

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