How to create a new content from external data

Hi everyone, I want to create a new content from external data (for example with drag text content type and data from an excel file). Who can help me or show me suggestion? Pleaseee

I have read source code of H5p plugin but I don't understand all. I find insertContent() function in public/class-h5p-wordpress.php and I tried with data created but it only insert data to wp_h5p_contents table, don't insert data to wp_h5p_contents_libraries => content type in a post doesn't work

And I find some function in admin/class-h5p-content-admin.php file but i don't know how to do

Someone can help me. Thank you very much=))

timothylim23's picture

Hi, there has been some interest in creating H5P content types programmatically:

https://www.drupal.org/node/2756639

I believe as long as you format the csv files to the structure of the semantic files you should be able to do it. It will require a bit of reverse engineering. A starting point could be looking at the textual editor in question set:

https://github.com/h5p/h5p-editor-question-set-textual-editor

Thanks for your helping, timothylim23=)) I have solved it myself. But it seems stupid=(( I read data from excel, replace content json in .h5p and use phantomjs to upload file by programming.

I want to ask one more thing. Do you know: How does h5p check the result of content type(for example drag word content type) when you do. I ask this because I want to use content type to create an examination. There are many content type in per examination but h5p only check result of one content type. 

timothylim23's picture

Each content type has an internal way of checking the validity of the answers, they then call the x-api to push the data:
https://github.com/h5p/h5p-drag-question/blob/master/js/dragquestion.js#L109

Would you mind elaborating what you want to do with step by step explanations?

I want to use h5p to make a examination online. Firstly, i have imported data to database. Next, I want to use content type to make questions in an examination. But h5p only check for one content type( one question ) and save result in database. So I want to figure out the way to check all question when click a button check. 

timothylim23's picture

Hi, have you tried looking at the xAPI documentation? 

https://h5p.org/documentation/x-api