{"id":1786,"date":"2013-05-08T09:55:14","date_gmt":"2013-05-08T00:55:14","guid":{"rendered":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/?p=1786"},"modified":"2016-10-17T09:13:19","modified_gmt":"2016-10-17T09:13:19","slug":"scorm%e3%82%b3%e3%83%b3%e3%83%86%e3%83%b3%e3%83%84%e3%81%ae%e4%bf%ae%e6%ad%a3php%e3%82%b9%e3%82%af%e3%83%aa%e3%83%97%e3%83%88","status":"publish","type":"post","link":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/?p=1786","title":{"rendered":"SCORM\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u4fee\u6b63php\u30b9\u30af\u30ea\u30d7\u30c8"},"content":{"rendered":"<p>\u5185\u8f2a\u306e\u8a71\u3067\u3059\u3002SCORM\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u4ed5\u69d8\u3092\u3001\u3068\u304d\u3069\u304d\u5909\u66f4\u3059\u308b\u5fc5\u8981\u304c\u751f\u3058\u307e\u3059\u3002\u305d\u3053\u3067\u3001\u53e4\u3044\u30b3\u30f3\u30c6\u30f3\u30c4\u3092\u8aad\u307f\u8fbc\u3093\u3067\u65b0\u3057\u3044\u3082\u306e\u306b\u66f8\u304d\u63db\u3048\u308bphp\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u66f8\u304d\u307e\u3057\u305f\u3002ubuntu\u4e0a\u3067\u3001zip\u304c\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u5165\u308c\u3070\u52d5\u304f\u3068\u601d\u3044\u307e\u3059\u3002\u307e\u305akanaike\u306b\u3042\u308b\u30d5\u30a1\u30a4\u30eb<a href=\"http:\/\/kanaike.susi.oita-u.ac.jp\/zip\/trans.zip\">\uff08\u4f8b\u3048\u3070\u3053\u308c\uff09<\/a>\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u3001\u89e3\u51cd\u3059\u308b\u3068\u3001trans\u3068\u3044\u3046\u30d5\u30a9\u30eb\u30c0\u30fc\u304c\u4f5c\u3089\u308c\u307e\u3059\u3002\u305d\u306e\u4e2d\u8eab\u306f\u4e0b\u8a18\u3002<\/p>\n<ul>\n<li>trans.php<\/li>\n<li>readme.txt<\/li>\n<li>simple_question<\/li>\n<li>source<\/li>\n<li>temporary<\/li>\n<li>zip<\/li>\n<\/ul>\n<p>\u30e1\u30a4\u30f3\u3068\u306a\u308b\u30b9\u30af\u30ea\u30d7\u30c8\u306ftrans.php \u3067\u3059\u3002simple_question, source, temporary, zip \u306f\u4f5c\u696d\u7528\u306e\u30d5\u30a9\u30eb\u30c0\u30fc\u3067\u3001\u305d\u308c\u305e\u308c\u4e0b\u8a18\u306e\u3088\u3046\u306a\u5f79\u5272\u3067\u3059\u3002<\/p>\n<ul>\n<li>simple_question \uff1a \u65b0\u3057\u3044SCORM\u306e\u96db\u5f62\u30d5\u30a1\u30a4\u30eb\u304c\u3042\u308b\u30d5\u30a9\u30eb\u30c0\u30fc<\/li>\n<li>source \uff1a \u53e4\u3044\u4ed5\u69d8\u306eSCORM\u30d5\u30a1\u30a4\u30eb\uff08zip\u30d5\u30a1\u30a4\u30eb\uff09\u3092\u7f6e\u304f\u30d5\u30a9\u30eb\u30c0\u30fc\u3002<\/li>\n<li>temporary \uff1a \u4f5c\u696d\u7528\u306e\u4e00\u6642\u30d5\u30a1\u30a4\u30eb\u304c\u66f8\u304d\u8fbc\u307e\u308c\u308b\u30d5\u30a9\u30eb\u30c0\u30fc<\/li>\n<li>zip \uff1a \u4fee\u6b63\u3055\u308c\u305fzip\u30d5\u30a1\u30a4\u30eb\u304c\u66f8\u304d\u8fbc\u307e\u308c\u308b\u30d5\u30a9\u30eb\u30c0\u30fc<\/li>\n<\/ul>\n<p>\u4f7f\u7528\u65b9\u6cd5\u306f\u3001\u307e\u305a source\u30d5\u30a9\u30eb\u30c0\u30fc\u306b\u53e4\u3044SCORM\u30d5\u30a1\u30a4\u30eb\u3092\u30b3\u30d4\u30fc\u3057\u307e\u3059\uff08\u8907\u6570\u53ef\uff09\u3002\u5f8c\u306f\u3001\u7aef\u672b\u3067trans\u30d5\u30a9\u30eb\u30c0\u30fc\u306b\u79fb\u52d5\u3057\u3066\u3001\u4e0b\u8a18\u306e\u30b3\u30de\u30f3\u30c9\u3092\u6253\u3064\u3060\u3051\u3067\u3059\u3002<\/p>\n<ul>\nphp trans.php\n<\/ul>\n<p>\u4fee\u6b63\u3055\u308c\u305fSCORM\u30b3\u30f3\u30c6\u30f3\u30c4\u304c\uff0czip\u30d5\u30a9\u30eb\u30c0\u30fc\u306b\u51fa\u6765\u4e0a\u304c\u308a\u307e\u3059\u3002<\/p>\n<p>\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u52d5\u4f5c\u306f\u3001\u6700\u521d\u306b\u53e4\u3044SCORM\u30d5\u30a1\u30a4\u30eb\u304c\u89e3\u51cd\u3055\u308c\u3066\u3001temporary\u30d5\u30a9\u30eb\u30c0\u30fc\u306b\u30b3\u30d4\u30fc\u3055\u308c\u307e\u3059\u3002\u6b21\u306b\u3001simple_question\u30d5\u30a9\u30eb\u30c0\u30fc\u306b\u3042\u308b\u65b0\u3057\u3044\u96db\u5f62\u30d5\u30a1\u30a4\u30eb\u3092\u89e3\u51cd\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u306b\u4e0a\u66f8\u304d\u3057\u307e\u3059\u3002\u305d\u306e\u5f8c\uff0c\u65b0\u3057\u3044\u554f\u984c\u306e\u5f62\u5f0f\u306b\u3042\u308f\u305b\u3066\u30b3\u30f3\u30d5\u30a3\u30b0\u30ec\u30fc\u30b7\u30e7\u30f3\u7528\u306e\u30d5\u30a1\u30a4\u30eb\uff08config.xml\uff09\u3092\u4fee\u6b63\u3057\u307e\u3059\u3002\u3053\u306e\u305f\u3081\u306e\u30b3\u30fc\u30c9\u304c\u9577\u3005\u3068\u3042\u3063\u3066\uff0c\u6700\u5f8c\u306f\u3001\u305d\u308c\u3092\u5727\u7e2e\u3057\u3066zip\u30d5\u30a9\u30eb\u30c0\u30fc\u306b\u30b3\u30d4\u30fc\u3057\u3066\u7d42\u4e86\u3067\u3059\u3002<\/p>\n<p>trans.php\u306e\u30b3\u30fc\u30c9\u3067\u3059\u3002<\/p>\n<pre><code style=\"color:midnightblue;\">&lt;?php\r\n\r\n\/\/ \u66f8\u304d\u8fbc\u3080\u8a2d\u5b9a\r\n\r\n\/\/ \u73fe\u5728\u3001\u63a1\u70b9\u30b5\u30fc\u30d0\u30fc\u306f\u5909\u66f4\u3057\u306a\u3044\u3002\u305d\u308c\u3086\u3048\u4e0b\u8a18\u306e\u5024\u306f\u5229\u7528\u3057\u3066\u3044\u306a\u3044\u3002\r\n$servername = \"kanaike.susi.oita-u.ac.jp\";\r\n\r\n$cgi_url = \"\/php_simple_question_recursion\/answertest_for_stack3_ver2.php\";\r\n$tex_url = \"\/php_simple_question_recursion\/fortex_xml_dimension.php\";\r\n\r\n$folder = \".\/source\/\";\r\n\r\n$xmlText = &lt;&lt;&lt; end_of_quote\r\n&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n&lt;root&gt;\\n\r\n&lt;folder&gt;$folder&lt;\/folder&gt;\\n\r\nend_of_quote;\r\n\r\n\r\nif ($handle = opendir($folder)) {\r\n\r\n\/\/    echo \"Directory handle: $handle\\n\";\r\n\/\/    echo \"Entries:\\n\";\r\n\r\n    \/* \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u30eb\u30fc\u30d7\u3059\u308b\u969b\u306e\u6b63\u3057\u3044\u65b9\u6cd5\u3067\u3059 *\/\r\n    while (false !== ($entry = readdir($handle))) {\r\n\r\n\tif (eregi('zip',$entry) ) {\r\n\r\n\/\/        echo \"$entry\\n\";\r\n\r\n\t$xmlText = $xmlText.'&lt;filename&gt;'.$entry.\"&lt;\/filename&gt;\\n\";\r\n\r\n\t}\r\n    }\r\n    closedir($handle);\r\n}\r\n\r\n$xmlText = $xmlText.\"&lt;\/root&gt;\\n\";\r\n\r\necho $xmlText;\r\n\r\n\r\n$xml = simplexml_load_string($xmlText);\r\n\r\n\r\n\/\/ \u4ee5\u524d\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u6d88\u3059\r\n\r\nexec(\"rm -rf .\/temporary\/*\");\r\nexec(\"rm -rf .\/zip\/*\");\r\n\r\n\r\nforeach ($xml-&gt;filename as $filename) {\r\n\r\n\/\/ \u30d5\u30a1\u30a4\u30eb\u6bce\u306b\u6642\u9593\u3092\u304b\u3048\u306a\u3044\u3068\u306d\r\n\r\n$stamp =  microtime();\r\nlist($msec, $sec) = explode(\" \", $stamp);\r\n$mustamp = $stamp*1000000;\r\n$timestamp = $sec.$mustamp;\r\n\r\n$zip_file = '.\/source\/' . $filename;\r\n\r\n$foldername = mb_eregi_replace('\\.zip','',$filename);\r\n\r\nexec(\"mkdir .\/temporary\/$foldername\");\r\nexec(\"cd .\/temporary\/$foldername\/ ; unzip ..\/..\/$zip_file\");\r\n\r\n\/\/ \u65b0\u3057\u3044\u30d5\u30a1\u30a4\u30eb\u3067\u4e0a\u66f8\u304d\r\nexec(\"cp -f -r .\/simple_question\/glossary .\/temporary\/$foldername\/\");\r\nexec(\"cp -f -r .\/simple_question\/history .\/temporary\/$foldername\/\");\r\nexec(\"cp -f -r .\/simple_question\/jquery .\/temporary\/$foldername\/\");\r\nexec(\"cp -f -r .\/simple_question\/jquery.treeview .\/temporary\/$foldername\/\");\r\nexec(\"cp -f .\/simple_question\/AC_OETags.js .\/temporary\/$foldername\/\");\r\nexec(\"cp -f .\/simple_question\/batu.gif .\/temporary\/$foldername\/\");\r\nexec(\"cp -f .\/simple_question\/imsmanifest.xml .\/temporary\/$foldername\/\");\r\nexec(\"cp -f .\/simple_question\/index.html .\/temporary\/$foldername\/\");\r\nexec(\"cp -f .\/simple_question\/index_sentence.html .\/temporary\/$foldername\/\");\r\nexec(\"cp -f .\/simple_question\/insert_panel.txt .\/temporary\/$foldername\/\");\r\nexec(\"cp -f .\/simple_question\/maru.gif .\/temporary\/$foldername\/\");\r\nexec(\"cp -f .\/simple_question\/message.jpg .\/temporary\/$foldername\/\");\r\nexec(\"cp -f .\/simple_question\/playerProductInstall.swf .\/temporary\/$foldername\/\");\r\nexec(\"cp -f .\/simple_question\/poweredbyflash.swf .\/temporary\/$foldername\/\");\r\nexec(\"cp -f .\/simple_question\/q_style.css .\/temporary\/$foldername\/\");\r\nexec(\"cp -f .\/simple_question\/scorm_functions_test.js .\/temporary\/$foldername\/\");\r\n\r\n\r\n\/\/ config \u306e\u51e6\u7406\r\n\r\n$config_text = file_get_contents(\".\/temporary\/$foldername\/\".'configfile.xml');\r\n\r\n$config_xml = simplexml_load_string($config_text);\r\n\r\n\/\/ \u53e4\u3044info\u3078\u306e\u5bfe\u5fdc\r\nif (!($config_xml-&gt;info-&gt;where)) {\r\n\t$config_xml-&gt;info-&gt;where = \"kanaike.susi.oita-u.ac.jp\";\r\n\t$config_xml-&gt;info-&gt;when = \"100\";\r\n}\r\n\r\n\/\/ edit\u304c\u3042\u3063\u3066\u3082\u306a\u304f\u3066\u3082\r\n\r\n$config_xml-&gt;edit-&gt;where = $servername;\r\n$config_xml-&gt;edit-&gt;when = $timestamp;\r\n\r\n$xml_server_url = $config_xml-&gt;server-&gt;url;\r\n$xml_cgi_url = $cgi_url;\r\n$xml_tex_url = $tex_url;\r\n$xml_title = $config_xml-&gt;title;\r\n$xml_info_where = $config_xml-&gt;info-&gt;where;\r\n$xml_info_when = $config_xml-&gt;info-&gt;when;\r\n$xml_edit_where = $config_xml-&gt;edit-&gt;where;\r\n$xml_edit_when = $config_xml-&gt;edit-&gt;when;\r\n$xml_passmark = $config_xml-&gt;passmark;\r\n$xml_TextHeight = $config_xml-&gt;TextHeight;\r\n\r\n\/\/ key \u304c\u306a\u3044\u5834\u5408\u3082\u3042\u308b\r\n\r\nif ($config_xml-&gt;key) {\r\n\r\n\t$public_key = (string) $config_xml-&gt;key;\r\n\r\n} else {\r\n\r\n$public_key = 'YTozOntpOjA7czoxMjg6Ilf2eJ3ruWeu53QPEdsmUy+aXVek\/gRRr52Cs7cETrJSapu\/zIo6pb6CkTxnC\/StbXdCha5hqFzhEsPmVaMDm6J\/46N4LRnGJ0Ioz\/4JB5HOZ4qToQTYCIM08bzHa0wh+23bYc8eMwbI1n74n2oosutTLfqP+GceE0EJ6wC6WtyJIjtpOjE7czo2NDoiZaQiod9dnBpZ11XUUpEPjsxKyQeGBIPBf748uzl49nSzMbDubOspqCZl42GgHp3bWdgWldNR0A6Ny0mIBv\/7ciI7aToyO3M6NjoicHVibGljIjt9';\r\n\r\n}\r\n\r\n$xmlstr = &lt;&lt;&lt; end_of_quote\r\n&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;\r\n\r\n&lt;root&gt;\r\n\r\n&lt;server&gt;\r\n&lt;url&gt;$xml_server_url&lt;\/url&gt;\r\n&lt;\/server&gt;\r\n\r\n&lt;cgi&gt;\r\n&lt;url&gt;$xml_cgi_url&lt;\/url&gt;\r\n&lt;\/cgi&gt;\r\n\r\n&lt;tex&gt;\r\n&lt;url&gt;$xml_tex_url&lt;\/url&gt;\r\n&lt;\/tex&gt;\r\n\r\n&lt;title&gt;$xml_title&lt;\/title&gt;\r\n\r\n&lt;info&gt;\r\n&lt;where&gt;$xml_info_where&lt;\/where&gt;\r\n&lt;when&gt;$xml_info_when&lt;\/when&gt;\r\n&lt;\/info&gt;\r\n\r\n&lt;edit&gt;\r\n&lt;where&gt;$xml_edit_where&lt;\/where&gt;\r\n&lt;when&gt;$xml_edit_when&lt;\/when&gt;\r\n&lt;\/edit&gt;\r\n\r\n&lt;key&gt;$public_key&lt;\/key&gt;\r\n\r\n&lt;passmark&gt;$xml_passmark&lt;\/passmark&gt;\r\n\r\n&lt;textHeight&gt;$xml_TextHeight&lt;\/textHeight&gt;\r\n\r\nend_of_quote;\r\n\r\n\r\n\/\/ \u5165\u308c\u5b50\u306equestion\u306b\u5bfe\u5fdc\r\n\r\n$i = 0;\r\n$str = '';\r\n\r\nforeach ($config_xml-&gt;question as $q) {\r\n\r\n\t$i = $i + 1;\r\n\r\n\t$someobj = new make_xml();\r\n\r\n\t$str = $str.$someobj-&gt;action($q,$i);\r\n\r\n}\r\n\r\n$xmlstr = $xmlstr.$str;\r\n\r\n\r\n$xmlstr = $xmlstr.\"&lt;\/root&gt;\";\r\n\r\n\/\/echo $xmlstr.\"\\n\";\r\n\r\n$configfile = fopen(\".\/temporary\/$foldername\/configfile.xml\",\"w\");\r\n\r\nfputs($configfile,$xmlstr);\r\n\r\nfclose($configfile);\r\n\r\n\r\n\/\/ zip \u3092\u4f5c\u308b\r\n\r\npassthru(\"cd .\/temporary\/$foldername ; zip -r -q ..\/..\/zip\/$foldername.zip .\");\r\n\r\n\r\n} \/\/ each filename\r\n\r\n\r\n\r\n\/\/ \u5165\u308c\u5b50\u306eXML\u3092\u4f5c\u6210\r\n\r\nclass make_xml {\r\n\r\nfunction __constructor() {\r\n}\r\n\r\npublic function action($q,$i) {\r\n\r\n$str = '';\r\n$str = $str.\"&lt;question&gt;\\n\\n&lt;num&gt;\".$i.\"&lt;\/num&gt;\\n\";\r\n$str = $str.\"&lt;answerTest&gt;\".$q-&gt;AnswerTest.\"&lt;\/answerTest&gt;\\n\";\r\n\r\nif ($q-&gt;size) {\r\n\t$str = $str.'&lt;size&gt;'.$q-&gt;size.\"&lt;\/size&gt;\\n\";\r\n}\r\n\r\nif ($q-&gt;x) {\r\n\t$str = $str.'&lt;x&gt;'.$q-&gt;x.\"&lt;\/x&gt;\\n\";\r\n}\r\n\r\nif ($q-&gt;y) {\r\n\t$str = $str.'&lt;y&gt;'.$q-&gt;y.\"&lt;\/y&gt;\\n\";\r\n}\r\n\r\n\/\/ \u6700\u521d\u306equestion\u306b\u306e\u307fSAns\u3092\u4ed8\u3051\u308b\r\n\r\nif ($q-&gt;size) {\r\n\t$str = $str.\"&lt;sans&gt;&lt;\/sans&gt;\\n\";\r\n}\r\n\r\n$str = $str.'&lt;tans&gt;'.$q-&gt;TAns.\"&lt;\/tans&gt;\\n\";\r\n$str = $str.'&lt;ansTestOpt&gt;'.$q-&gt;AnsTestOpt.\"&lt;\/ansTestOpt&gt;\\n\";\r\n\r\nif ($q-&gt;operation-&gt;text) {\r\n\t$str = $str.\"&lt;operation&gt;&lt;text&gt;&lt;![CDATA[\".$q-&gt;operation-&gt;text.\"]]&gt;&lt;\/text&gt;&lt;\/operation&gt;\\n\";\r\n}\r\n\r\nif ($q-&gt;true) {\r\n\t$str = $str.\"&lt;true&gt;\\n&lt;message&gt;\".$q-&gt;true-&gt;message.\"&lt;\/message&gt;\\n&lt;\/true&gt;\\n\";\r\n}\r\n\r\nif ($q-&gt;false) {\r\n\t$str = $str.\"&lt;false&gt;\\n&lt;message&gt;\".$q-&gt;false-&gt;message.\"&lt;\/message&gt;\\n&lt;\/false&gt;\\n\\n\";\r\n}\r\n\r\n\r\nif ($q-&gt;question) {\r\n\r\n\t$newq = $q-&gt;question;\r\n\r\n\t$someobj = new make_xml();\r\n\r\n\t$str = $str.$someobj-&gt;action($newq,$i);\r\n\r\n}\r\n\r\n$str = $str.\"&lt;\/question&gt;\\n\\n\";\r\n\r\nreturn $str;\r\n}\r\n\r\n} \/\/ end of class\r\n\r\n?&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u5185\u8f2a\u306e\u8a71\u3067\u3059\u3002SCORM\u30b3\u30f3\u30c6\u30f3\u30c4\u306e\u4ed5\u69d8\u3092\u3001\u3068\u304d\u3069\u304d\u5909\u66f4\u3059\u308b\u5fc5\u8981\u304c\u751f\u3058\u307e\u3059\u3002\u305d\u3053 &#8230; <a class=\"more-link\" href=\"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/?p=1786\">Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1786","post","type-post","status-publish","format-standard","hentry","category-column"],"_links":{"self":[{"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1786","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1786"}],"version-history":[{"count":2,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1786\/revisions"}],"predecessor-version":[{"id":5453,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1786\/revisions\/5453"}],"wp:attachment":[{"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1786"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1786"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/zairyo.susi.oita-u.ac.jp\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1786"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}