Пример #1
0
 public function toIMS($path)
 {
     $lesson_entries = eF_getTableData("content", "id, name, data", "lessons_ID=" . $this->lesson['id'] . " and ctg_type = 'theory' and active=1");
     $cur_dir = getcwd();
     chdir(G_LESSONSPATH . $this->lesson['id'] . '/');
     $filelist = eF_getDirContents();
     chdir($cur_dir);
     create_manifest($this->lesson['id'], $lesson_entries, $filelist, $path);
     //create the EfrontLesson.xml
     $str = '<?xml version="1.0" encoding="UTF-8"?><efrontlesson>';
     //write out the glossary
     $glossary = ef_getTableData("glossary", "*", "lessons_ID=" . $this->lesson['id']);
     if (sizeof($glossary) > 0) {
         $str .= '<glossary>';
         for ($i = 0; $i < sizeof($glossary); $i++) {
             $str .= '<word>';
             $str .= '<name>' . $glossary[$i]['name'] . '</name>';
             $str .= '<info>' . $glossary[$i]['info'] . '</info>';
             $str .= '<type>' . $glossary[$i]['type'] . '</type>';
             $str .= '<active>' . $glossary[$i]['active'] . '</active>';
             $str .= '</word>';
         }
         $str .= '</glossary>';
     }
     //write out the lesson conditions
     $conditions = ef_getTableData("lesson_conditions", "*", "lessons_ID=" . $this->lesson['id']);
     if (sizeof($conditions) > 0) {
         $str .= '<conditions>';
         for ($i = 0; $i < sizeof($conditions); $i++) {
             $str .= '<condition>';
             $str .= '<type>' . $conditions[$i]['type'] . '</type>';
             $str .= '<options>' . $conditions[$i]['options'] . '</options>';
             $str .= '<relation>' . $conditions[$i]['relation'] . '</relation>';
             $str .= '</condition>';
         }
         $str .= '</conditions>';
     }
     //write out the rules
     $rules = ef_getTableData("rules r, content c", "r.*", "c.id = r.content_ID and c.lessons_ID=" . $this->lesson['id']);
     if (sizeof($rules) > 0) {
         $str .= '<rules>';
         for ($i = 0; $i < sizeof($rules); $i++) {
             $str .= "<rule>";
             $str .= "<content_id>" . $rules[$i]['content_ID'] . "</content_id>";
             $str .= "<rule_content_id>" . $rules[$i]['rule_content_ID'] . "</rule_content_id>";
             $str .= "<rule_type>" . $rules[$i]['rule_type'] . "</rule_type>";
             $str .= "<rule_option>" . $rules[$i]['rule_option'] . "</rule_option>";
             $str .= '</rule>';
         }
         $str .= '</rules>';
     }
     //write out the questions
     $questions = ef_getTableData("questions q, content c", "q.*", "q.content_id = c.id and c.lessons_id=" . $this->lesson['id'] . "");
     if (sizeof($questions) > 0) {
         $str .= "<questions>";
         for ($i = 0; $i < sizeof($questions); $i++) {
             $str .= "<question>";
             $str .= "<refid>q" . $questions[$i]['id'] . "</refid>";
             $str .= "<type>" . $questions[$i]['type'] . "</type>";
             $str .= "<difficulty>" . $questions[$i]['difficulty'] . "</difficulty>";
             $str .= "<options>" . $questions[$i]['options'] . "</options>";
             $str .= "<answer>" . $questions[$i]['answer'] . "</answer>";
             $str .= "<explanation>" . $questions[$i]['explanation'] . "</explanation>";
             $str .= "</question>";
         }
         $str .= "</questions>";
     }
     //write out the tests
     $tests = ef_getTableData("tests t, content c", "t.*", "t.content_id = c.id and c.lessons_id=" . $this->lesson['id'] . "");
     if (sizeof($tests) > 0) {
         $str .= "<tests>";
         for ($i = 0; $i < sizeof($tests); $i++) {
             $str .= "<test>";
             $str .= "<refid>t" . $tests[$i]['id'] . "</refid>";
             $str .= "<duration>" . $tests[$i]['duration'] . "</duration>";
             $str .= "<redoable>" . $tests[$i]['redoable'] . "</redoable>";
             $str .= "<onebyone>" . $tests[$i]['onebyone'] . "</onebyone>";
             $str .= "<answers>" . $tests[$i]['answers'] . "</answers>";
             $str .= "<shuffle_questions>" . $tests[$i]['shuffle_questions'] . "</shuffle_questions>";
             $str .= "<shuffle_answers>" . $tests[$i]['shuffle_answers'] . "</shuffle_answers>";
             $str .= "<given_answers>" . $tests[$i]['given_answers'] . "</given_answers>";
             $questions = ef_getTableData("tests_to_questions", "*", "tests_ID = " . $tests[$i]['id']);
             $str .= "<questions>";
             for ($j = 0; $j < sizeof($questions); $j++) {
                 $str .= "<question>";
                 $str .= "<refid>q" . $questions[$j]['questions_ID'] . "</refid>";
                 $str .= "<weight>" . $questions[$j]['weight'] . "</weight>";
                 $str .= "<previous>q" . $questions[$j]['previous_question_ID'] . "</previous>";
                 $str .= "</question>";
             }
             $str .= "</questions>";
             $str .= "</test>";
         }
         $str .= "</tests>";
     }
     $str .= '</efrontlesson>';
     if ($fp = fopen($path . "/lesson" . $this->lesson['id'] . "/eFrontLesson.xml", "wb")) {
         fwrite($fp, $str);
     }
     fclose($fp);
     chdir($path . "/lesson" . $this->lesson['id']);
     $d = dir(".");
     $entries = array();
     while (false !== ($entry = $d->read())) {
         if ($entry != "." & $entry != "..") {
             array_push($entries, $entry);
         }
     }
     $d->close();
     $zip = new Archive_zip($path . "/lesson" . $this->lesson['id'] . ".tar.gz");
     $zip->create($entries);
     chdir($cur_dir);
     deldir($path . "/lesson" . $this->lesson['id']);
 }
Пример #2
0
function checkToken($token)
{
    if (eF_checkParameter($token, 'alnum')) {
        $tmp = ef_getTableData("tokens", "status", "token='{$token}'");
        $token = $tmp[0]['status'];
        if ($token == 'logged') {
            return true;
        }
    }
    return false;
}
Пример #3
0
 function addProject($project_id)
 {
     $pdata = ef_getTableData("projects", "*", "id={$project_id}");
     $this->projects[$project_id] = $pdata[0];
 }