public function getSmartyTpl()
 {
     $smarty = $this->getSmartyVar();
     $currentUser = $this->getCurrentUser();
     $currentLesson = $this->getCurrentLesson();
     $currentLessonID = $currentLesson->lesson['id'];
     if ($currentUser->getRole($this->getCurrentLesson()) == 'professor' || $currentUser->getRole($this->getCurrentLesson()) == 'student') {
         // XXX
         $workbookLessonName = _WORKBOOK_NAME . ' [' . $this->getWorkbookLessonName($currentLessonID) . ']';
         $smarty->assign("T_WORKBOOK_LESSON_NAME", $workbookLessonName);
         $lessonQuestions = $this->getLessonQuestions($currentLessonID);
         $workbookLessons = $this->isWorkbookInstalledByUser($currentUser, $currentUser->getRole($this->getCurrentLesson()), $currentLessonID);
         $workbookItems = $this->getWorkbookItems($currentLessonID);
         $nonOptionalQuestionsNr = $this->getNonOptionalQuestionsNr($workbookItems);
         if ($nonOptionalQuestionsNr != 0) {
             $questionPercentage = (double) (100 / $nonOptionalQuestionsNr);
             $questionPercentage = round($questionPercentage, 2);
         }
         $isWorkbookPublished = $this->isWorkbookPublished($currentLessonID);
     }
     if ($currentUser->getRole($this->getCurrentLesson()) == 'student') {
         $workbookSettings = $this->getWorkbookSettings($currentLessonID);
         $smarty->assign("T_WORKBOOK_SETTINGS", $workbookSettings);
     }
     $smarty->assign("T_WORKBOOK_BASEURL", $this->moduleBaseUrl);
     $smarty->assign("T_WORKBOOK_BASELINK", $this->moduleBaseLink);
     global $popup;
     isset($popup) && $popup == 1 ? $popup_ = '&popup=1' : ($popup_ = '');
     if (isset($_REQUEST['question_preview']) && $_REQUEST['question_preview'] == '1' && isset($_REQUEST['question_id']) && eF_checkParameter($_REQUEST['question_id'], 'id')) {
         $id = $_REQUEST['question_id'];
         if (!in_array($id, array_keys($lessonQuestions))) {
             // reused item
             $reusedQuestion = $this->getReusedQuestionDetails($id);
             $type = $reusedQuestion['type'];
         } else {
             $type = $lessonQuestions[$id]['type'];
         }
         echo $this->questionToHtml($id, $type);
         exit;
     }
     if (isset($_REQUEST['get_progress']) && $_REQUEST['get_progress'] == '1') {
         $isWorkbookCompleted = $this->isWorkbookCompleted($currentUser->user['login'], $currentLessonID, array_keys($workbookItems), $nonOptionalQuestionsNr);
         $studentProgress = $this->getStudentProgress($currentUser->user['login'], $currentLessonID);
         if ($isWorkbookCompleted['is_completed'] == 1) {
             $unitToComplete = $workbookSettings['unit_to_complete'];
             $result = eF_updateTableData('module_workbook_progress', array('completion_date' => time()), "lessons_ID='" . $currentLessonID . "' AND users_LOGIN='******'login'] . "'");
             if ($unitToComplete != -1) {
                 $currentUser->setSeenUnit($unitToComplete, $currentLessonID, true);
             }
         }
         echo $studentProgress . '-' . $isWorkbookCompleted['id'];
         exit;
     }
     if (isset($_GET['edit_settings']) && $_GET['edit_settings'] == '1') {
         if ($_SESSION['s_type'] != 'professor') {
             $message = _WORKBOOK_NOACCESS;
             $message_type = 'failure';
             $this->setMessageVar(urlencode($message), $message_type);
         }
         $content = new EfrontContentTree($currentLessonID);
         $iterator = new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($content->tree), RecursiveIteratorIterator::SELF_FIRST), array('ctg_type' => 'theory'));
         $contentOptions = $content->toHTMLSelectOptions($iterator);
         $contentOptions = array(-1 => '-------------') + $contentOptions;
         $workbookSettings = $this->getWorkbookSettings($currentLessonID);
         if ($isWorkbookPublished == 1) {
             $contentOptions[$workbookSettings['unit_to_complete']] = str_replace(' ', '', $contentOptions[$workbookSettings['unit_to_complete']]);
             $contentOptions[$workbookSettings['unit_to_complete']] = str_replace('»', '', $contentOptions[$workbookSettings['unit_to_complete']]);
         }
         $form = new HTML_QuickForm("edit_settings_form", "post", $this->moduleBaseUrl . "&edit_settings=1", "", null, true);
         $form->addElement('text', 'lesson_name', _WORKBOOK_LESSON_NAME, 'class="inputText"');
         $form->addRule('lesson_name', _THEFIELD . ' "' . _WORKBOOK_LESSON_NAME . '" ' . _ISMANDATORY, 'required', null, 'client');
         $form->addElement('advcheckbox', 'allow_print', _WORKBOOK_ALLOW_PRINT, null, 'class="inputCheckBox"', array(0, 1));
         $form->addElement('advcheckbox', 'allow_export', _WORKBOOK_ALLOW_EXPORT, null, 'class="inputCheckBox"', array(0, 1));
         $form->addElement('advcheckbox', 'edit_answers', _WORKBOOK_EDIT_ANSWERS, null, 'class="inputCheckBox"', array(0, 1));
         $form->addElement('select', 'unit_to_complete', _WORKBOOK_UNIT_TO_COMPLETE, $contentOptions);
         $form->addElement('submit', 'submit', _UPDATE, 'class="flatButton"');
         if ($isWorkbookPublished == 1) {
             $form->freeze('unit_to_complete');
         }
         $form->setDefaults($workbookSettings);
         if ($form->isSubmitted() && $form->validate()) {
             $values = $form->exportValues();
             $fields = array("lesson_name" => $values['lesson_name'], "allow_print" => $values['allow_print'], "allow_export" => $values['allow_export'], "edit_answers" => $values['edit_answers'], "unit_to_complete" => $values['unit_to_complete']);
             if (eF_updateTableData("module_workbook_settings", $fields, "id=" . $workbookSettings['id'])) {
                 $smarty->assign("T_WORKBOOK_MESSAGE", _WORKBOOK_SETTINGS_SUCCESSFULLY_EDITED);
                 $smarty->assign("T_WORKBOOK_MESSAGE_TYPE", 'success');
             } else {
                 $smarty->assign("T_WORKBOOK_MESSAGE", _WORKBOOK_SETTINGS_EDIT_PROBLEM);
                 $smarty->assign("T_WORKBOOK_MESSAGE_TYPE", 'failure');
             }
         }
         $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
         $renderer->setRequiredTemplate('{$html}{if $required}&nbsp;<span class="formRequired">*</span>{/if}');
         $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
         $form->setRequiredNote(_REQUIREDNOTE);
         $form->accept($renderer);
         $smarty->assign('T_WORKBOOK_EDIT_SETTINGS_FORM', $renderer->toArray());
     }
     if (isset($_GET['reuse_item']) && $_GET['reuse_item'] == '1') {
         if ($_SESSION['s_type'] != 'professor') {
             $message = _WORKBOOK_NOACCESS;
             $message_type = 'failure';
             $this->setMessageVar(urlencode($message), $message_type);
         }
         $form = new HTML_QuickForm("reuse_item_form", "post", $this->moduleBaseUrl . "&reuse_item=1", "", null, true);
         $form->addElement('text', 'item_id', _WORKBOOK_ITEM_ID, 'class="inputText"');
         $form->addRule('item_id', _THEFIELD . ' "' . _WORKBOOK_ITEM_ID . '" ' . _ISMANDATORY, 'required', null, 'client');
         $form->addElement('submit', 'submit', _WORKBOOK_REUSE_ITEM, 'class="flatButton"');
         if ($form->isSubmitted() && $form->validate()) {
             $values = $form->exportValues();
             $existingIDs = $this->getItemsUniqueIDs();
             if (!in_array($values['item_id'], $existingIDs)) {
                 $message = _WORKBOOK_INVALID_UNIQUE_ID;
                 $message_type = 'failure';
                 $this->setMessageVar(urlencode($message), $message_type);
             } else {
                 $item = $this->getItemByUniqueID($values['item_id']);
                 $fields = array("item_title" => $item['item_title'], "item_text" => $item['item_text'], "item_question" => $item['item_question'], "question_text" => $item['question_text'], "check_answer" => $item['check_answer'], "lessons_ID" => $currentLessonID, "unique_ID" => $this->generateItemID(), "position" => $this->itemPosition($currentLessonID));
                 if (eF_insertTableData("module_workbook_items", $fields)) {
                     $smarty->assign("T_WORKBOOK_MESSAGE", urlencode(_WORKBOOK_ITEM_SUCCESSFULLY_ADDED));
                     $smarty->assign("T_WORKBOOK_MESSAGE_TYPE", 'success');
                 } else {
                     $smarty->assign("T_WORKBOOK_MESSAGE", _WORKBOOK_ITEM_ADD_PROBLEM);
                     $smarty->assign("T_WORKBOOK_MESSAGE_TYPE", 'failure');
                 }
             }
         }
         $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
         $renderer->setRequiredTemplate('{$html}{if $required}&nbsp;<span class="formRequired">*</span>{/if}');
         $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
         $form->setRequiredNote(_REQUIREDNOTE);
         $form->accept($renderer);
         $smarty->assign('T_WORKBOOK_REUSE_ITEM_FORM', $renderer->toArray());
     }
     if (isset($_GET['move_item']) && eF_checkParameter($_GET['move_item'], 'id') && in_array($_GET['move_item'], array_keys($workbookItems))) {
         if ($_SESSION['s_type'] != 'professor') {
             $message = _WORKBOOK_NOACCESS;
             $message_type = 'failure';
             $this->setMessageVar(urlencode($message), $message_type);
         }
         $smarty->assign("T_WORKBOOK_ITEMS_COUNT", count($workbookItems));
         $itemPosition = $workbookItems[$_GET['move_item']]['position'];
         $availablePositions = array();
         foreach ($workbookItems as $key => $value) {
             if ($value['position'] != $itemPosition) {
                 $availablePositions[$value['position']] = $value['position'];
             }
         }
         $form = new HTML_QuickForm("move_item_form", "post", $this->moduleBaseUrl . "&move_item=" . $_GET['move_item'], "", null, true);
         $form->addElement('select', 'item_position', _WORKBOOK_ITEM_NEW_POSITION, $availablePositions, '');
         $form->addElement('submit', 'submit', _WORKBOOK_MOVE_ITEM, 'class="flatButton"');
         if ($form->isSubmitted() && $form->validate()) {
             $values = $form->exportValues();
             $newPosition = $values['item_position'];
             if ($newPosition > $itemPosition) {
                 foreach ($workbookItems as $key => $value) {
                     if ($value['position'] > $itemPosition && $value['position'] <= $newPosition) {
                         eF_updateTableData("module_workbook_items", array('position' => $value['position'] - 1), "id=" . $key);
                     }
                 }
             } else {
                 foreach ($workbookItems as $key => $value) {
                     if ($value['position'] < $itemPosition && $value['position'] >= $newPosition) {
                         eF_updateTableData("module_workbook_items", array('position' => $value['position'] + 1), "id=" . $key);
                     }
                 }
             }
             eF_updateTableData("module_workbook_items", array('position' => $newPosition), "id=" . $_GET['move_item']);
             $smarty->assign("T_WORKBOOK_MESSAGE", _WORKBOOK_ITEM_SUCCESSFULLY_MOVED);
             $smarty->assign("T_WORKBOOK_MESSAGE_TYPE", 'success');
         }
         $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
         $renderer->setRequiredTemplate('{$html}{if $required}&nbsp;<span class="formRequired">*</span>{/if}');
         $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
         $form->setRequiredNote(_REQUIREDNOTE);
         $form->accept($renderer);
         $smarty->assign('T_WORKBOOK_MOVE_ITEM_FORM', $renderer->toArray());
     }
     if (isset($_GET['delete_item']) && eF_checkParameter($_GET['delete_item'], 'id') && in_array($_GET['delete_item'], array_keys($workbookItems))) {
         $item_id = $_GET['delete_item'];
         $itemPosition = $workbookItems[$item_id]['position'];
         foreach ($workbookItems as $key => $value) {
             if ($value['position'] > $itemPosition) {
                 eF_updateTableData("module_workbook_items", array('position' => $value['position'] - 1), "id=" . $key);
             }
         }
         eF_deleteTableData("module_workbook_items", "id=" . $item_id);
     }
     if (isset($_GET['switch_lesson']) && eF_checkParameter($_GET['switch_lesson'], 'id') && in_array($_GET['switch_lesson'], array_keys($workbookLessons))) {
         $lessonID = $_GET['switch_lesson'];
         eF_redirect("location:" . $this->moduleBaseUrl . "&lessons_ID=" . $lessonID . $popup_);
     }
     if (isset($_GET['add_item']) && $_GET['add_item'] == '1' || isset($_GET['edit_item']) && eF_checkParameter($_GET['edit_item'], 'id') && in_array($_GET['edit_item'], array_keys($workbookItems))) {
         if ($_SESSION['s_type'] != "professor") {
             eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_WORKBOOK_NOACCESS) . $popup_);
         }
         global $load_editor;
         $load_editor = true;
         $questionsText = array();
         $questionsText[-1] = "-----------------------";
         foreach ($lessonQuestions as $key => $value) {
             $questionsText[$key] = $this->truncateText(strip_tags($value['text']), 70);
         }
         if (isset($_GET['edit_item'])) {
             $editItemID = $_GET['edit_item'];
             $editItemQuestion = $workbookItems[$editItemID]['item_question'];
             if ($editItemQuestion != '-1' && !in_array($editItemQuestion, array_keys($questionsText))) {
                 // reused item
                 $reusedQuestion = $this->getReusedQuestionDetails($editItemQuestion);
                 $questionsText[$editItemQuestion] = $this->truncateText(strip_tags($reusedQuestion['text']), 70);
             }
         }
         isset($_GET['add_item']) ? $postTarget = "&add_item=1" : ($postTarget = "&edit_item=" . $_GET['edit_item']);
         $form = new HTML_QuickForm("add_edit_item_form", "post", $this->moduleBaseUrl . $postTarget, "", null, true);
         $form->addElement('text', 'item_title', _WORKBOOK_ITEM_TITLE, 'class="inputText" style="width:500px;"');
         $form->addElement('textarea', 'item_text', _WORKBOOK_ITEM_TEXT, 'class="mceEditor" style="width:99%;height:300px;" id="editor_content_data"');
         $form->addElement('select', 'item_question', _WORKBOOK_ITEM_QUESTION, $questionsText, 'onchange="questionPreview(this)"');
         $form->addElement('advcheckbox', 'check_answer', _WORKBOOK_ITEM_GRADE_ANSWER, null, 'class="inputCheckBox"', array(0, 1));
         if (isset($_GET['add_item'])) {
             $form->addElement('submit', 'submit', _WORKBOOK_ADD_ITEM, 'class="flatButton"');
         } else {
             $form->addElement('submit', 'submit', _WORKBOOK_UPDATE_ITEM, 'class="flatButton"');
         }
         if (isset($_GET['edit_item'])) {
             $editItem = $workbookItems[$_GET['edit_item']];
             $form->setDefaults($editItem);
             if ($isWorkbookPublished == '1') {
                 $editItem['question_title'] = $questionsText[$editItem['item_question']];
                 if ($editItem['check_answer'] == '1') {
                     $editItem['check_answer_text'] = _YES;
                 } else {
                     $editItem['check_answer_text'] = _NO;
                 }
             }
             $smarty->assign('T_WORKBOOK_EDIT_ITEM_DETAILS', $editItem);
         }
         if ($form->isSubmitted() && $form->validate()) {
             $values = $form->exportValues();
             isset($_GET['add_item']) ? $lessonID = $currentLessonID : ($lessonID = $editItem['lessons_ID']);
             isset($_GET['add_item']) ? $uniqueID = $this->generateItemID() : ($uniqueID = $editItem['unique_ID']);
             isset($_GET['add_item']) ? $position = $this->itemPosition($currentLessonID) : ($position = $editItem['position']);
             if ($values['item_question'] != '-1') {
                 $id = $values['item_question'];
                 if (!in_array($id, array_keys($lessonQuestions))) {
                     // edit reused item
                     $reusedQuestion = $this->getReusedQuestionDetails($id);
                     $type = $reusedQuestion['type'];
                 } else {
                     $type = $lessonQuestions[$id]['type'];
                 }
                 $questionText = $this->questionToHtml($id, $type);
             } else {
                 $questionText = '';
             }
             $fields = array("item_title" => $values['item_title'], "item_text" => $values['item_text'], "item_question" => $values['item_question'], "question_text" => $questionText, "check_answer" => $values['check_answer'], "lessons_ID" => $lessonID, "unique_ID" => $uniqueID, "position" => $position);
             if ($values['item_title'] == '' && $values['item_text'] == '' && $values['item_question'] == '-1') {
                 $message = _WORKBOOK_ITEM_EMPTY_FIELDS;
                 if (isset($_GET['add_item'])) {
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure&add_item=1" . $popup_);
                 } else {
                     $itemID = $_GET['edit_item'];
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure&edit_item=" . $itemID . $popup_);
                 }
             }
             if (isset($_GET['add_item'])) {
                 if (eF_insertTableData("module_workbook_items", $fields)) {
                     $message = _WORKBOOK_ITEM_SUCCESSFULLY_ADDED;
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=success" . $popup_);
                 } else {
                     $message = _WORKBOOK_ITEM_ADD_PROBLEM;
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure" . $popup_);
                 }
             } else {
                 if (eF_updateTableData("module_workbook_items", $fields, "id=" . $_GET['edit_item'])) {
                     $message = _WORKBOOK_ITEM_SUCCESSFULLY_EDITED;
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=success" . $popup_);
                 } else {
                     $message = _WORKBOOK_ITEM_EDIT_PROBLEM;
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure" . $popup_);
                 }
             }
         }
         $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
         $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
         $form->setRequiredNote(_REQUIREDNOTE);
         $form->accept($renderer);
         $smarty->assign('T_WORKBOOK_ADD_EDIT_ITEM_FORM', $renderer->toArray());
         $basedir = $currentLesson->getDirectory();
         $options = array('lessons_ID' => $currentLessonID, 'metadata' => 0);
         $url = $_SERVER['REQUEST_URI'];
         $extraFileTools = array(array('image' => 'images/16x16/arrow_right.png', 'title' => _INSERTEDITOR, 'action' => 'insert_editor'));
         include "file_manager.php";
     }
     if (isset($_GET['publish_workbook']) && $_GET['publish_workbook'] == '1') {
         $result = eF_getTableData("module_workbook_publish", "publish", "lessons_ID=" . $currentLessonID);
         if (count($result) == 0) {
             if (eF_insertTableData("module_workbook_publish", array('lessons_ID' => $currentLessonID, 'publish' => 1))) {
                 $message = _WORKBOOK_SUCCESSFULLY_PUBLISHED;
                 eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=success" . $popup_);
             } else {
                 $message = _WORKBOOK_PUBLISH_PROBLEM;
                 eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure" . $popup_);
             }
         } else {
             if (eF_updateTableData("module_workbook_publish", array('publish' => 1), "lessons_ID=" . $currentLessonID)) {
                 $message = _WORKBOOK_SUCCESSFULLY_PUBLISHED;
                 eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=success" . $popup_);
             } else {
                 $message = _WORKBOOK_PUBLISH_PROBLEM;
                 eF_redirect($this->moduleBaseUrl . "&message=" . urlencode($message) . "&message_type=failure" . $popup_);
             }
         }
     }
     if (isset($_GET['reset_workbook_professor']) && $_GET['reset_workbook_professor'] == '1') {
         eF_updateTableData("module_workbook_publish", array('publish' => 0), "lessons_ID=" . $currentLessonID);
         foreach ($workbookItems as $key => $value) {
             eF_deleteTableData("module_workbook_answers", "item_id=" . $key);
             eF_deleteTableData("module_workbook_autosave", "item_id=" . $key);
             eF_deleteTableData("module_workbook_progress", "lessons_ID=" . $currentLessonID);
         }
     }
     if (isset($_GET['reset_workbook_student']) && eF_checkParameter($_GET['reset_workbook_student'], 'id')) {
         $id = $_GET['reset_workbook_student'];
         $result = eF_getTableData("module_workbook_progress", "users_LOGIN", "id=" . $id);
         if ($result[0]['users_LOGIN'] != $currentUser->user['login']) {
             eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_WORKBOOK_NOACCESS) . $popup_);
         }
         eF_deleteTableData("module_workbook_progress", "id=" . $id);
         foreach ($workbookItems as $key => $value) {
             eF_deleteTableData("module_workbook_answers", "item_id=" . $key . " AND users_LOGIN='******'login'] . "'");
         }
         $unitToComplete = $workbookSettings['unit_to_complete'];
         if ($unitToComplete != -1) {
             $currentUser->setSeenUnit($unitToComplete, $currentLessonID, false);
         }
     }
     if (isset($_GET['download_as']) && $_GET['download_as'] == 'doc') {
         include dirname(__FILE__) . "/classes/html_to_doc.inc.php";
         $workbookAnswers = $this->getWorkbookAnswers($currentUser->user['login'], array_keys($workbookItems));
         $workbookHTML = '';
         foreach ($workbookItems as $key => $value) {
             $workbookHTML .= '<div style="width:98%;float:left;border:1px dotted #808080;padding: 5px 10px;">';
             $workbookHTML .= '<div style="background-color: #EAEAEA;border: 1px solid #AAAAAA;padding: 2px;font-weight: bold;">';
             $workbookHTML .= _WORKBOOK_ITEMS_COUNT . $value['position'];
             if ($value['item_title'] != '') {
                 $workbookHTML .= '&nbsp;-&nbsp;' . $value['item_title'];
             }
             $workbookHTML .= '</div><br/>';
             if ($value['item_text'] != '') {
                 $workbookHTML .= '<div>' . $value['item_text'] . '</div><br/>';
             }
             if ($value['item_question'] != '-1') {
                 $questionType = $lessonQuestions[$value['item_question']]['type'];
                 if ($workbookAnswers[$value['id']] == '') {
                     if ($questionType == 'drag_drop') {
                         $dragDrop = eF_getTableData("questions", "options, answer, text", "id=" . $value['item_question']);
                         $options = unserialize($dragDrop[0]['options']);
                         $answer = unserialize($dragDrop[0]['answer']);
                         shuffle($options);
                         shuffle($answer);
                         $workbookHTML .= $dragDrop[0]['text'];
                         for ($i = 0; $i < count($options); $i++) {
                             $workbookHTML .= '<div>' . $options[$i] . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                             $workbookHTML .= $answer[$i] . '</div>';
                         }
                     } else {
                         $workbookHTML .= '<div>' . $value['question_text'] . '</div>';
                     }
                 } else {
                     $workbookHTML .= '<div>' . $workbookAnswers[$value['id']] . '</div>';
                 }
             }
             $workbookHTML .= '</div><br/>';
         }
         $workbookHTML = preg_replace('/<script\\b[^>]*>(.*?)<\\/script>/is', "", $workbookHTML);
         $fileName = _WORKBOOK_NAME . '_' . $this->getWorkbookLessonName($currentLessonID);
         $fileName = preg_replace('/[\\s]+/', '_', $fileName);
         $htmltodoc = new HTML_TO_DOC();
         $htmltodoc->createDoc($workbookHTML, $fileName, true);
         exit(0);
     }
     if (isset($_GET['download_as']) && $_GET['download_as'] == 'pdf') {
         $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
         $pdf->SetCreator(PDF_CREATOR);
         $pdf->SetAuthor(PDF_AUTHOR);
         $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
         $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
         $pdf->setFontSubsetting(false);
         $pdf->AddPage();
         $completion_date = '';
         $resutlt = eF_getTableData('module_workbook_progress', 'completion_date', "users_LOGIN='******'login'] . "' and lessons_ID='" . $currentLessonID . "'");
         if ($resutlt) {
             $completion_date = $resutlt[0]['completion_date'];
         }
         $workbookHTML = '';
         $workbookHTML .= '<table>';
         $workbookHTML .= '<tr>';
         $workbookHTML .= '<td colspan="2">';
         $workbookHTML .= formatLogin($currentUser->user['login']);
         $workbookHTML .= '</td>';
         $workbookHTML .= '</tr>';
         $workbookHTML .= '<tr>';
         $workbookHTML .= '<td>';
         $workbookHTML .= $workbookLessonName;
         $workbookHTML .= '</td>';
         $workbookHTML .= '<td>';
         $workbookHTML .= formatTimestamp($completion_date);
         $workbookHTML .= '</td>';
         $workbookHTML .= '</tr>';
         $workbookHTML .= '</table>';
         $pdf->writeHTML($workbookHTML, true, false, true, false, '');
         $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
         $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
         $pdf->setHeaderFont(array('Freeserif', 'I', 11));
         $pdf->setFooterFont(array('Freeserif', '', 8));
         $pdf->setHeaderData('', '', '', $workbookLessonName);
         $pdf->AliasNbPages();
         $pdf->SetFont('Freeserif', '', 10);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFont('Freeserif', '', 10);
         $pdf->SetTextColor(0, 0, 0);
         $workbookAnswers = $this->getWorkbookAnswers($currentUser->user['login'], array_keys($workbookItems));
         $pdf->AddPage();
         $workbookHTML .= '';
         $itemLogo = new EfrontFile(G_DEFAULTIMAGESPATH . "32x32/unit.png");
         $itemLogoUrl = $itemLogo['path'];
         foreach ($workbookItems as $key => $value) {
             $workbookHTML .= '<div id="pdf-block" style="width:98%;float:left;border:1px dotted #808080;page-break-after:always;">';
             $workbookHTML .= '<div style="background-color: #EAEAEA;font-weight: bold;">';
             $workbookHTML .= '<img src="' . $itemLogoUrl . '"/>&nbsp;' . _WORKBOOK_ITEMS_COUNT . $value['position'];
             if ($value['item_title'] != '') {
                 $workbookHTML .= '&nbsp;-&nbsp;' . $value['item_title'];
             }
             $workbookHTML .= '</div>';
             if ($value['item_text'] != '') {
                 $workbookHTML .= '<div>' . $value['item_text'] . '</div>';
             }
             if ($value['item_question'] != '-1') {
                 $questionType = $lessonQuestions[$value['item_question']]['type'];
                 if ($workbookAnswers[$value['id']] == '') {
                     if ($questionType == 'drag_drop') {
                         $dragDrop = eF_getTableData("questions", "options, answer, text", "id=" . $value['item_question']);
                         $options = unserialize($dragDrop[0]['options']);
                         $answer = unserialize($dragDrop[0]['answer']);
                         shuffle($options);
                         shuffle($answer);
                         $workbookHTML .= $dragDrop[0]['text'];
                         for ($i = 0; $i < count($options); $i++) {
                             $workbookHTML .= '<div>' . $options[$i] . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
                             $workbookHTML .= $answer[$i] . '</div>';
                         }
                     } else {
                         $workbookHTML .= '<div>' . $value['question_text'] . '</div>';
                     }
                 } else {
                     $workbookHTML .= '<div>' . $workbookAnswers[$value['id']] . '</div>';
                 }
             }
             $workbookHTML .= '</div><br/>';
         }
         $workbookHTML = preg_replace('/<script\\b[^>]*>(.*?)<\\/script>/is', "", $workbookHTML);
         $pdf->writeHTML($workbookHTML, true, false, true, false, '');
         $fileName = _WORKBOOK_NAME . '_' . str_replace(' ', '_', $this->getWorkbookLessonName($currentLessonID)) . '.pdf';
         header("Content-type: application/pdf");
         header("Content-disposition: attachment; filename=" . $fileName);
         echo $pdf->Output('', 'S');
         exit(0);
     }
     if (isset($_GET['check_workbook_progress']) && $_GET['check_workbook_progress'] == '1') {
         $lessonStudents = $currentLesson->getUsers('student');
         $workbookStudents = array();
         foreach ($lessonStudents as $userLogin => $value) {
             if ($nonOptionalQuestionsNr != 0) {
                 $studentProgress = $this->getStudentProgress($userLogin, $currentLessonID);
                 $studentProgress .= '%';
             } else {
                 $studentProgress = '-';
             }
             $workbookStudents[$userLogin] = array('login' => $userLogin, 'progress' => $studentProgress);
         }
         $smarty->assign("T_WORKBOOK_STUDENTS", $workbookStudents);
     }
     if (isset($_GET['preview_workbook']) && $_GET['preview_workbook'] == '1' && isset($_GET['student']) && eF_checkParameter($_GET['student'], 'login')) {
         $userLogin = $_GET['student'];
         $studentProgress = $this->getStudentProgress($userLogin, $currentLessonID);
         $smarty->assign("T_WORKBOOK_PREVIEW_STUDENT_PROGRESS", $studentProgress);
         $workbookAnswers = $this->getWorkbookAnswers($userLogin, array_keys($workbookItems));
         $smarty->assign("T_WORKBOOK_PREVIEW_ANSWERS", $workbookAnswers);
     }
     if (isset($_GET['get_reset_message']) && $_GET['get_reset_message'] == '1') {
         echo $this->getResetMessage(array_keys($workbookItems));
         exit;
     }
     if (isset($_POST['item_submitted'])) {
         $itemID = $_POST['item_submitted'];
         $questionID = $workbookItems[$itemID]['item_question'];
         $checkAnswer = $workbookItems[$itemID]['check_answer'];
         if (!in_array($questionID, array_keys($lessonQuestions))) {
             // reused item
             $reusedQuestion = $this->getReusedQuestionDetails($questionID);
             $questionType = $reusedQuestion['type'];
         } else {
             $questionType = $lessonQuestions[$questionID]['type'];
         }
         $question = QuestionFactory::factory($questionID);
         $question->setDone($_POST['question'][$questionID]);
         $results = $question->correct();
         if ($questionType != 'raw_text' && !ef_compare_float($results['score'], 1)) {
             print '-1';
         } else {
             $form = new HTML_QuickForm("questionForm", "post", "", "", null, true);
             $fields = array('item_id' => $itemID, 'html_solved' => $question->toHTMLSolved($form), 'users_LOGIN' => $currentUser->user['login']);
             eF_insertTableData("module_workbook_answers", $fields);
             if ($checkAnswer == '1') {
                 $this->updateStudentProgress($currentUser->user['login'], $currentLessonID, $questionPercentage, $nonOptionalQuestionsNr);
             }
             echo $question->toHTMLSolved($form);
         }
         eF_deleteTableData("module_workbook_autosave", "item_id=" . $itemID . " AND users_LOGIN='******'login'] . "'");
         exit(0);
     }
     if (isset($_POST['item_submitted_autosave'])) {
         $itemID = $_POST['item_submitted_autosave'];
         $questionID = $workbookItems[$itemID]['item_question'];
         $question = QuestionFactory::factory($questionID);
         $form = new HTML_QuickForm("questionForm", "post", "", "", null, true);
         $form->setDefaults($_POST);
         $fields = array('item_id' => $itemID, 'autosave_text' => $question->toHTML($form), 'users_LOGIN' => $currentUser->user['login']);
         eF_deleteTableData("module_workbook_autosave", "item_id=" . $itemID . " AND users_LOGIN='******'login'] . "'");
         eF_insertTableData("module_workbook_autosave", $fields);
         exit(0);
     }
     if (isset($_POST['item_to_update'])) {
         $itemID = $_POST['item_to_update'];
         $questionID = $workbookItems[$itemID]['item_question'];
         $question = QuestionFactory::factory($questionID);
         $question->userAnswer = urldecode($_POST['ans']);
         $form = new HTML_QuickForm("questionForm", "post", "", "", null, true);
         $form->setDefaults($_POST);
         print $question->toHTML($form);
         exit(0);
     }
     if (isset($_POST['item_updated'])) {
         $itemID = $_POST['item_updated'];
         $questionID = $workbookItems[$itemID]['item_question'];
         $question = QuestionFactory::factory($questionID);
         $question->setDone($_POST['question'][$questionID]);
         $form = new HTML_QuickForm("questionForm", "post", "", "", null, true);
         $answerToUpdate = eF_getTableData("module_workbook_answers", "id", "item_id=" . $itemID . " AND users_LOGIN='******'login'] . "'");
         eF_updateTableData("module_workbook_answers", array('html_solved' => $question->toHTMLSolved($form)), "id=" . $answerToUpdate[0]['id']);
         echo $question->toHTMLSolved($form);
         eF_deleteTableData("module_workbook_autosave", "item_id=" . $itemID . " AND users_LOGIN='******'login'] . "'");
         exit(0);
     } else {
         if ($currentUser->getRole($this->getCurrentLesson()) == 'professor' || $currentUser->getRole($this->getCurrentLesson()) == 'student') {
             $workbookItems = $this->getWorkbookItems($currentLessonID);
             $smarty->assign("T_WORKBOOK_ITEMS", $workbookItems);
             $smarty->assign("T_WORKBOOK_LESSONS", $workbookLessons);
             $isWorkbookPublished = $this->isWorkbookPublished($currentLessonID);
             $smarty->assign("T_WORKBOOK_IS_PUBLISHED", $isWorkbookPublished);
             $smarty->assign("T_WORKBOOK_NON_OPTIONAL_QUESTIONS_NR", $nonOptionalQuestionsNr);
         }
         if ($currentUser->getRole($this->getCurrentLesson()) == 'professor') {
             $workbookOptions[] = array('text' => _SETTINGS, 'image' => $this->moduleBaseLink . 'images/settings.png', 'href' => $this->moduleBaseUrl . '&edit_settings=1&popup=1', 'onClick' => "eF_js_showDivPopup(event, '" . _SETTINGS . "', 0)", 'target' => 'POPUP_FRAME', 'id' => 'edit_settings');
             $workbookOptions[] = array('text' => _WORKBOOK_POPUP_INFO, 'image' => $this->moduleBaseLink . 'images/info.png', 'href' => $this->moduleBaseUrl . '&popup_info=1&popup=1', 'onClick' => "eF_js_showDivPopup(event, '" . _WORKBOOK_POPUP_INFO . "', 2)", 'target' => 'POPUP_FRAME', 'id' => 'popup_info');
             $smarty->assign("T_WORKBOOK_OPTIONS", $workbookOptions);
         } else {
             if ($currentUser->getRole($this->getCurrentLesson()) == 'student') {
                 $workbookAnswers = $this->getWorkbookAnswers($currentUser->user['login'], array_keys($workbookItems));
                 $smarty->assign("T_WORKBOOK_ANSWERS", $workbookAnswers);
                 $autoSaveAnswers = $this->getAutoSaveAnswers($currentUser->user['login'], array_keys($workbookItems));
                 $smarty->assign("T_WORKBOOK_AUTOSAVE_ANSWERS", $autoSaveAnswers);
                 $studentProgress = $this->getStudentProgress($currentUser->user['login'], $currentLessonID);
                 $smarty->assign("T_WORKBOOK_STUDENT_PROGRESS", $studentProgress);
                 $isWorkbookCompleted = $this->isWorkbookCompleted($currentUser->user['login'], $currentLessonID, array_keys($workbookItems), $nonOptionalQuestionsNr);
                 $smarty->assign("T_WORKBOOK_IS_COMPLETED", $isWorkbookCompleted);
             }
         }
     }
     if ($currentUser->getRole($this->getCurrentLesson()) == 'professor') {
         return $this->moduleBaseDir . "module_workbook_professor.tpl";
     } else {
         if ($currentUser->getRole($this->getCurrentLesson()) == 'student') {
             return $this->moduleBaseDir . "module_workbook_student.tpl";
         }
     }
 }
Ejemplo n.º 2
0
/*                                                                      */
/* Collab WS-Pad 1.44 by Developpeur and Jpb                            */
/*                                                                      */
/* NPDS Copyright (c) 2002-2015 by Philippe Brunier                     */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
// For More security
if (!stristr($_SERVER['PHP_SELF'], "modules.php")) {
    die;
}
if (strstr($ModPath, "..") || strstr($ModStart, "..") || stristr($ModPath, "script") || stristr($ModPath, "cookie") || stristr($ModPath, "iframe") || stristr($ModPath, "applet") || stristr($ModPath, "object") || stristr($ModPath, "meta") || stristr($ModStart, "script") || stristr($ModStart, "cookie") || stristr($ModStart, "iframe") || stristr($ModStart, "applet") || stristr($ModStart, "object") || stristr($ModStart, "meta")) {
    die;
}
global $NPDS_Prefix;
$wspad = rawurldecode(decrypt($pad));
$wspad = explode("#wspad#", $wspad);
switch ($type) {
    case "doc":
        include "lib/html2doc.php";
        $htmltodoc = new HTML_TO_DOC();
        $row = sql_fetch_assoc(sql_query("SELECT content FROM " . $NPDS_Prefix . "wspad WHERE page='" . $wspad[0] . "' AND member='" . $wspad[1] . "' AND ranq='" . $wspad[2] . "'"));
        // nettoyage des SPAN
        $tmp = preg_replace('#style="[^\\"]*\\"#', "", aff_langue($row['content']));
        $htmltodoc->createDoc($tmp, $wspad[0] . "-" . $wspad[2], true);
        break;
    default:
        break;
}
require_once "includes/session.php";
include "includes/DataAccess.php";
include "html_to_doc.inc.php";
?>
<? ob_start(); ?>
<?php 
if (!logged_in()) {
    redirect_to("index.php");
}
if ($_POST["action"] == "Submit Form") {
    if (isset($_GET["flag"]) == "1") {
        $old_date = date('l, F d y h:i:s');
        // returns Saturday, January 30 10 02:06:34
        $old_date_timestamp = strtotime($old_date);
        $new_date = date('m_d_Y_h_i_s', $old_date_timestamp);
        $htmltodoc = new HTML_TO_DOC();
        $htmltodoc->createDoc($_POST["tafinal"], $_SESSION["username"] . "/DoorSchedule_" . $new_date . ".doc");
        redirect_to("coursesyllabus.php");
    }
}
?>
<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Export Schedule</title>
        <link href="css/menu.css" rel="stylesheet" type="text/css">
        <script src="js/jquery-latest.min.js"></script>
        <script src="ckeditor/ckeditor.js"></script>
        <link href="css/style.css" rel="stylesheet" type="text/css">
    </head>
Ejemplo n.º 4
0
                        if (!empty($arrTemp[3]) && is_numeric($arrTemp[3])) {
                            $intID = $arrTemp[3];
                            $strDir = $arrGCache['cache_root'] . '/' . $arrTemp[2] . '-' . $arrModule[1] . '/' . $intID . $arrGWeb['file_suffix'];
                            $boolCache = true;
                        }
                        if (!empty($arrTemp[4]) && is_numeric($arrTemp[4])) {
                            $intID = $arrTemp[4];
                            $strDir = $arrGCache['cache_root'] . '/' . $arrTemp[2] . '-' . $arrTemp[3] . '/' . $intID . $arrGWeb['file_suffix'];
                            $boolCache = true;
                        }
                    }
                }
            }
        }
        header("HTTP/1.1 200 OK");
        $objDoc = new HTML_TO_DOC();
        $strUrl = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $arrTemp[2] . '/detail.php?type=doc&id=' . $intID;
        $objDoc->createDocFromURL($strUrl, $strDir, true);
        //header("location:$strDir");
    }
} elseif (strpos($strMyUrl, '.pdf')) {
    //静态PDF文件处理
}
//非静态文件直接跳转到网站首页
if (v === 'v') {
    exit;
}
if (!$boolCache) {
    if ($strMyUrl != '/') {
        $arrUrl = parse_url($strMyUrl);
        header("HTTP/1.1 301 Moved Permanently");
Ejemplo n.º 5
0
<?php

require_once dirname(__FILE__) . '/../../includes/global.inc.php';
// pdf was breaking
define(RELATIVE_PATH, '');
switch ($_GET['action']) {
    case 'word':
        require_once dirname(__FILE__) . '/HTML2Doc.php';
        $doc = new HTML_TO_DOC();
        $doc->setTitle(iBeginShare::quoteSmart($_GET['title']));
        $doc->createDoc($raw_content, (strlen(iBeginShare::quoteSmart($_GET['title'])) > 0 ? str_replace(' ', '-', strip_tags($_GET['title'])) : 'Document-' . date('Y-m-d')) . '.doc');
        break;
    case 'pdf':
        require_once dirname(__FILE__) . '/html2fpdf/html2fpdf.php';
        $pdf = new HTML2FPDF();
        $pdf->DisplayPreferences($_GET['title']);
        $pdf->AddPage();
        $pdf->WriteHTML(html_entity_decode($raw_content));
        $pdf->Output((strlen(iBeginShare::quoteSmart($_GET['title'])) > 0 ? str_replace(' ', '-', strip_tags($_GET['title'])) : 'Document-' . date('Y-m-d')) . '.pdf', 'D');
        break;
}
Ejemplo n.º 6
0
 static function getDocFromHTML($source)
 {
     $doc = new HTML_TO_DOC();
     return $doc->getDocData($source);
 }
Ejemplo n.º 7
0
<?php

include 'html2doc.php';
$htmltodoc = new HTML_TO_DOC();
$htmltodoc->createDoc('<html><head><title>Documento</title></head><body><b>Espero funciones...</b></body></html>', 'test');
Ejemplo n.º 8
0
 public function getSmartyTpl()
 {
     $currentUser = $this->getCurrentUser();
     $rules = $this->getRules();
     $smarty = $this->getSmartyVar();
     if ($currentUser->getRole($this->getCurrentLesson()) == 'professor' || $currentUser->getRole($this->getCurrentLesson()) == 'student') {
         $currentLesson = $this->getCurrentLesson();
         $currentLessonID = $currentLesson->lesson['id'];
         if (!isset($_SESSION['module_journal_dimension']) || count($_GET) == 2 && $_GET['ctg'] == 'module' && $_GET['op'] == 'module_journal' || count($_GET) == 3 && $_GET['ctg'] == 'module' && $_GET['op'] == 'module_journal' && $_GET['new_lesson_id'] == $currentLessonID) {
             $_SESSION['module_journal_dimension'] = 'small';
         }
         if (!isset($_SESSION['module_journal_entries_from']) || count($_GET) == 2 && $_GET['ctg'] == 'module' && $_GET['op'] == 'module_journal' || count($_GET) == 3 && $_GET['ctg'] == 'module' && $_GET['op'] == 'module_journal' && $_GET['new_lesson_id'] == $currentLessonID) {
             $_SESSION['module_journal_entries_from'] = '-1';
         }
         if (isset($_SESSION['module_journal_scroll_position'])) {
             $smarty->assign("T_JOURNAL_SCROLL_POSITION", $_SESSION['module_journal_scroll_position']);
         }
         $smarty->assign("T_JOURNAL_DIMENSIONS", $_SESSION['module_journal_dimension']);
         $smarty->assign("T_JOURNAL_ENTRIES_FROM", $_SESSION['module_journal_entries_from']);
         $entries = $this->getEntries($currentUser->user['login'], $_SESSION['module_journal_entries_from']);
         global $popup;
         isset($popup) && $popup == 1 ? $popup_ = '&popup=1' : ($popup_ = '');
     }
     $smarty->assign("T_JOURNAL_BASEURL", $this->moduleBaseUrl);
     $smarty->assign("T_JOURNAL_BASELINK", $this->moduleBaseLink);
     if (isset($_GET['edit_allow_export']) && $_GET['edit_allow_export'] == '1' && isset($_GET['allow'])) {
         try {
             $object = eF_getTableData("module_journal_settings", "id", "name='export'");
             eF_updateTableData("module_journal_settings", array("value" => $_GET['allow']), "id=" . $object[0]['id']);
         } catch (Exception $e) {
             handleAjaxExceptions($e);
         }
         exit;
     }
     if (isset($_GET['edit_professor_preview']) && $_GET['edit_professor_preview'] == '1' && isset($_GET['preview'])) {
         try {
             $object = eF_getTableData("module_journal_settings", "id", "name='preview'");
             eF_updateTableData("module_journal_settings", array("value" => $_GET['preview']), "id=" . $object[0]['id']);
         } catch (Exception $e) {
             handleAjaxExceptions($e);
         }
         exit;
     }
     if (isset($_GET['dimension']) && eF_checkParameter($_GET['dimension'], 'string')) {
         $smarty->assign("T_JOURNAL_DIMENSIONS", $_GET['dimension']);
         $_SESSION['module_journal_dimension'] = $_GET['dimension'];
     }
     if (isset($_GET['entries_from'])) {
         $smarty->assign("T_JOURNAL_ENTRIES_FROM", $_GET['entries_from']);
         $_SESSION['module_journal_entries_from'] = $_GET['entries_from'];
     }
     if (isset($_GET['delete_rule']) && eF_checkParameter($_GET['delete_rule'], 'id') && in_array($_GET['delete_rule'], array_keys($rules))) {
         try {
             eF_deleteTableData("module_journal_rules", "id=" . $_GET['delete_rule']);
         } catch (Exception $e) {
             handleAjaxExceptions($e);
         }
         exit;
     }
     if (isset($_GET['deactivate_rule']) && eF_checkParameter($_GET['deactivate_rule'], 'id') && in_array($_GET['deactivate_rule'], array_keys($rules))) {
         eF_updateTableData("module_journal_rules", array('active' => 0), "id=" . $_GET['deactivate_rule']);
     }
     if (isset($_GET['activate_rule']) && eF_checkParameter($_GET['activate_rule'], 'id') && in_array($_GET['activate_rule'], array_keys($rules))) {
         eF_updateTableData("module_journal_rules", array('active' => 1), "id=" . $_GET['activate_rule']);
     }
     if (isset($_GET['delete_entry']) && eF_checkParameter($_GET['delete_entry'], 'id') && in_array($_GET['delete_entry'], array_keys($entries))) {
         $object = eF_getTableData("module_journal_entries", "users_LOGIN", "id=" . $_GET['delete_entry']);
         if ($object[0]['users_LOGIN'] != $_SESSION['s_login']) {
             eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_JOURNAL_NOACCESS) . $popup_);
             exit;
         }
         eF_deleteTableData("module_journal_entries", "id=" . $_GET['delete_entry']);
     }
     if (isset($_GET['saveas']) && $_GET['saveas'] == 'pdf') {
         $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true);
         $pdf->SetCreator(PDF_CREATOR);
         $pdf->SetAuthor(PDF_AUTHOR);
         $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
         $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
         $pdf->setFontSubsetting(false);
         $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
         $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
         $pdf->setHeaderFont(array('Freeserif', 'I', 11));
         $pdf->setFooterFont(array('Freeserif', '', 8));
         $pdf->setHeaderData('', '', '', _JOURNAL_NAME);
         $pdf->AliasNbPages();
         $pdf->AddPage();
         $pdf->SetFont('Freeserif', '', 10);
         $pdf->SetTextColor(0, 0, 0);
         foreach ($entries as $entry) {
             $pdf->Cell(0, 0, $entry['entry_date_formatted'], 0, 1, L, 0);
             $pdf->writeHTML('<br/>', true, false, true, false, '');
             $pdf->writeHTML($entry['entry_body'], true, false, true, false, '');
             $pdf->writeHTML('<div style="height: 5px;"></div>', true, false, true, false, '');
             $pdf->writeHTML('<hr>', true, false, true, false, '');
         }
         $fileNamePdf = "journal.pdf";
         header("Content-type: application/pdf");
         header("Content-disposition: attachment; filename=" . $fileNamePdf);
         echo $pdf->Output('', 'S');
         exit(0);
     }
     if (isset($_GET['saveas']) && $_GET['saveas'] == 'doc') {
         include dirname(__FILE__) . "/classes/html_to_doc.inc.php";
         $entriesHTML = '';
         foreach ($entries as $entry) {
             $entriesHTML .= $entry['entry_date_formatted'];
             $entriesHTML .= $entry['entry_body'];
             $entriesHTML .= '<hr><br/>';
         }
         $htmltodoc = new HTML_TO_DOC();
         $htmltodoc->createDoc($entriesHTML, "journal", true);
         exit(0);
     }
     if (isset($_GET['saveas']) && $_GET['saveas'] == 'txt') {
         include dirname(__FILE__) . "/classes/html2text.inc";
         header('Content-Type: text/plain');
         header('Content-Disposition: attachment; filename="journal.txt"');
         $entriesHTML = '';
         foreach ($entries as $entry) {
             $entriesHTML .= $entry['entry_date_formatted'];
             $entriesHTML .= $entry['entry_body'];
             $entriesHTML .= '<p></p>';
             $entriesHTML .= '_______________________________________________________';
             $entriesHTML .= '<p></p>';
         }
         $htmlToText = new Html2Text($entriesHTML, 100);
         $entriesHTMLtext = $htmlToText->convert();
         echo $entriesHTMLtext;
         exit(0);
     }
     if (isset($_GET['check_students_journals']) && $_GET['check_students_journals'] == '1') {
         $professorJournalLessons = $this->getProfessorJournalLessons($currentUser);
         $journalLessonsStudents = $this->getJournalLessonsStudents($professorJournalLessons);
         $smarty->assign("T_JOURNAL_STUDENTS", $journalLessonsStudents);
     }
     if (isset($_GET['preview_journal']) && $_GET['preview_journal'] == '1' && isset($_GET['student']) && eF_checkParameter($_GET['student'], 'login')) {
         $userLogin = $_GET['student'];
         $professorJournalLessons = $this->getProfessorJournalLessons($currentUser);
         $studentEntries = $this->getStudentEntries($userLogin, $professorJournalLessons);
         $smarty->assign("T_JOURNAL_STUDENT_ENTRIES", $studentEntries);
     }
     if (isset($_REQUEST['autosave']) && $_REQUEST['autosave'] == "1" && isset($_REQUEST['entry_body']) && isset($_REQUEST['edit_entry'])) {
         if ($_REQUEST['edit_entry'] != "-1") {
             if (eF_checkParameter($_GET['edit_entry'], 'id')) {
                 $object = eF_getTableData("module_journal_entries", "lessons_ID", "id=" . $_GET['edit_entry']);
                 $fields = array("entry_body" => $_REQUEST['entry_body'], "entry_date" => date('Y') . '-' . date('m') . '-' . date('d') . ' ' . date('H') . ':' . date('i') . ':' . date('s'), "lessons_ID" => $object[0]['lessons_ID'], "users_LOGIN" => $currentUser->user['login']);
                 eF_updateTableData("module_journal_entries", $fields, "id=" . $_REQUEST['edit_entry']);
             }
         } else {
             $fields = array("entry_body" => $_REQUEST['entry_body'], "entry_date" => date('Y') . '-' . date('m') . '-' . date('d') . ' ' . date('H') . ':' . date('i') . ':' . date('s'), "lessons_ID" => $currentLessonID, "users_LOGIN" => $currentUser->user['login']);
             $id = eF_insertTableData("module_journal_entries", $fields);
             if ($id) {
                 if (isset($_SESSION['module_journal_autosave_entry'])) {
                     $this->deleteAutoSaveEntry();
                     $_SESSION['module_journal_autosave_entry'] = $id;
                 } else {
                     $_SESSION['module_journal_autosave_entry'] = $id;
                 }
             }
         }
         exit(0);
     }
     if (isset($_REQUEST['show_right']) && $_REQUEST['show_right'] == "1" && isset($_REQUEST['entry_body']) && $_REQUEST['entry_body'] != "" && isset($_REQUEST['edit']) && isset($_REQUEST['edit_entry'])) {
         if (isset($_SESSION['module_journal_show_right_entry'])) {
             unset($_SESSION['module_journal_show_right_entry']);
         }
         $_SESSION['module_journal_show_right_entry'] = $_REQUEST['entry_body'];
     }
     if (isset($_REQUEST['hide_right']) && $_REQUEST['hide_right'] == "1" && isset($_REQUEST['entry_body']) && $_REQUEST['entry_body'] != "" && isset($_REQUEST['edit']) && isset($_REQUEST['edit_entry'])) {
         if (isset($_SESSION['module_journal_hide_right_entry'])) {
             unset($_SESSION['module_journal_hide_right_entry']);
         }
         $_SESSION['module_journal_hide_right_entry'] = $_REQUEST['entry_body'];
     }
     if (isset($_REQUEST['hide_left']) && $_REQUEST['hide_left'] == "1" && isset($_REQUEST['entry_body']) && $_REQUEST['entry_body'] != "" && isset($_REQUEST['edit']) && isset($_REQUEST['edit_entry'])) {
         if (isset($_SESSION['module_journal_hide_left_entry'])) {
             unset($_SESSION['module_journal_hide_left_entry']);
         }
         $_SESSION['module_journal_hide_left_entry'] = $_REQUEST['entry_body'];
     }
     if (isset($_REQUEST['scroll_position']) && eF_checkParameter($_REQUEST['scroll_position'], 'id')) {
         $_SESSION['module_journal_scroll_position'] = $_REQUEST['scroll_position'];
     }
     if (isset($_GET['add_rule']) || isset($_GET['edit_rule']) && eF_checkParameter($_GET['edit_rule'], 'id') && in_array($_GET['edit_rule'], array_keys($rules))) {
         if ($_SESSION['s_type'] != "administrator") {
             eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_JOURNAL_NOACCESS));
         }
         isset($_GET['add_rule']) ? $postTarget = "&add_rule=1" : ($postTarget = "&edit_rule=" . $_GET['edit_rule']);
         global $load_editor;
         $load_editor = true;
         $form = new HTML_QuickForm("add_edit_rule_form", "post", $this->moduleBaseUrl . $postTarget, "", null, true);
         $form->addElement('text', 'title', _TITLE, 'class="inputText" style="width:498px;"');
         $form->addRule('title', _THEFIELD . ' "' . _TITLE . '" ' . _ISMANDATORY, 'required', null, 'client');
         $form->addElement('textarea', 'description', _DESCRIPTION, 'class="inputContentTextarea simpleEditor" style="width:500px;height:20em;"');
         $form->addElement('submit', 'submit', _SUBMIT, 'class="flatButton"');
         if (isset($_GET['edit_rule'])) {
             $editRule = $rules[$_GET['edit_rule']];
             $form->setDefaults($editRule);
         }
         if ($form->isSubmitted() && $form->validate()) {
             $values = $form->exportValues();
             $fields = array("title" => $values['title'], "description" => $values['description']);
             if ($values['description'] == '') {
                 $message = _JOURNAL_EMPTY_RULE_DESCRIPTION;
                 if (isset($_GET['add_rule'])) {
                     eF_redirect($this->moduleBaseUrl . "&message=" . $message . "&message_type=failure&add_rule=1");
                 } else {
                     eF_redirect($this->moduleBaseUrl . "&message=" . $message . "&message_type=failure&edit_rule=" . $_GET['edit_rule']);
                 }
             }
             if (isset($_GET['add_rule'])) {
                 if (eF_insertTableData("module_journal_rules", $fields)) {
                     $message = _JOURNAL_RULE_SUCCESSFULLY_ADDED;
                     eF_redirect($this->moduleBaseUrl . "&message=" . $message . "&message_type=success");
                 } else {
                     $message = _JOURNAL_RULE_ADD_PROBLEM;
                     eF_redirect($this->moduleBaseUrl . "&message=" . $message . "&message_type=failure");
                 }
             } else {
                 if (eF_updateTableData("module_journal_rules", $fields, "id=" . $_GET['edit_rule'])) {
                     $message = _JOURNAL_RULE_SUCCESSFULLY_EDITED;
                     eF_redirect($this->moduleBaseUrl . "&message=" . $message . "&message_type=success");
                 } else {
                     $message = _JOURNAL_RULE_EDIT_PROBLEM;
                     eF_redirect($this->moduleBaseUrl . "&message=" . $message . "&message_type=failure");
                 }
             }
         }
         $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
         $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
         $form->setRequiredNote(_REQUIREDNOTE);
         $form->accept($renderer);
         $smarty->assign('T_JOURNAL_ADD_EDIT_RULE_FORM', $renderer->toArray());
     } else {
         $rules = $this->getRules();
         $smarty->assign("T_JOURNAL_RULES", $rules);
         $object = eF_getTableData("module_journal_settings", "value", "name='export'");
         $smarty->assign("T_JOURNAL_ALLOW_EXPORT", $object[0]['value']);
         $object = eF_getTableData("module_journal_settings", "value", "name='preview'");
         $smarty->assign("T_JOURNAL_ALLOW_PROFESSOR_PREVIEW", $object[0]['value']);
         if ($currentUser->getRole($this->getCurrentLesson()) == 'professor' || $currentUser->getRole($this->getCurrentLesson()) == 'student') {
             $activeRules = $this->getRules(true);
             $smarty->assign("T_JOURNAL_ACTIVE_RULES", $activeRules);
             $entries = $this->getEntries($currentUser->user['login'], $_SESSION['module_journal_entries_from']);
             $smarty->assign("T_JOURNAL_ENTRIES", $entries);
             $journalLessons = $this->getJournalLessons($currentUser->user['login']);
             $smarty->assign("T_JOURNAL_LESSONS", $journalLessons);
             /*					*/
             global $load_editor;
             $load_editor = true;
             if (isset($_GET['edit_entry']) && $_GET['edit_entry'] != '-1') {
                 $postTarget = "&edit_entry=" . $_GET['edit_entry'];
             } else {
                 $postTarget = "&add_entry=1";
             }
             if (isset($_GET['hide_right']) && $_GET['hide_right'] == '1') {
                 $editorStyle = array('small' => 'width:588px; height:320px;', 'medium' => 'width:673px; height:375px;', 'large' => 'width:759px; height:430px;');
             } else {
                 $editorStyle = array('small' => 'width:300px; height:320px;', 'medium' => 'width:344px; height:375px;', 'large' => 'width:388px; height:430px;');
             }
             $form = new HTML_QuickForm("add_edit_entry_form", "post", $this->moduleBaseUrl . $postTarget, "", null, true);
             $form->addElement('textarea', 'entry_body', _DESCRIPTION, 'class="inputContentTextarea simpleEditor" style="' . $editorStyle[$_SESSION['module_journal_dimension']] . '"');
             if (isset($_GET['edit_entry']) && $_GET['edit_entry'] != '-1') {
                 $form->addElement('submit', 'submit', _UPDATE . ' ' . _JOURNAL_ENTRY, 'class="flatButton"');
             } else {
                 $form->addElement('submit', 'submit', _SAVE . ' ' . _JOURNAL_ENTRY, 'class="flatButton"');
             }
             if (isset($_GET['edit_entry']) && $_GET['edit_entry'] != '-1') {
                 $editEntry = $entries[$_GET['edit_entry']];
                 $form->setDefaults($editEntry);
                 if (!in_array($_GET['edit_entry'], array_keys($entries))) {
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_JOURNAL_NOACCESS) . $popup_);
                 }
                 $object = eF_getTableData("module_journal_entries", "lessons_ID, users_LOGIN, entry_date", "id=" . $_GET['edit_entry']);
                 if ($object[0]['users_LOGIN'] != $_SESSION['s_login']) {
                     eF_redirect($this->moduleBaseUrl . "&message=" . urlencode(_JOURNAL_NOACCESS) . $popup_);
                 }
             }
             if (isset($_GET['show_left']) && $_GET['show_left'] == '1' && isset($_GET['edit']) && isset($_GET['edit_entry'])) {
                 if (isset($_SESSION['module_journal_hide_left_entry'])) {
                     $form->setDefaults(array("entry_body" => $_SESSION['module_journal_hide_left_entry']));
                     unset($_SESSION['module_journal_hide_left_entry']);
                 }
             }
             if (isset($_GET['show_right']) && $_GET['show_right'] == '1' && isset($_GET['edit']) && isset($_GET['edit_entry'])) {
                 if (isset($_SESSION['module_journal_show_right_entry'])) {
                     $form->setDefaults(array("entry_body" => $_SESSION['module_journal_show_right_entry']));
                     unset($_SESSION['module_journal_show_right_entry']);
                 }
             }
             if (isset($_GET['hide_right']) && $_GET['hide_right'] == '1' && isset($_GET['edit']) && isset($_GET['edit_entry'])) {
                 if (isset($_SESSION['module_journal_hide_right_entry'])) {
                     $form->setDefaults(array("entry_body" => $_SESSION['module_journal_hide_right_entry']));
                     unset($_SESSION['module_journal_hide_right_entry']);
                 }
             }
             if ($form->isSubmitted() && $form->validate()) {
                 $values = $form->exportValues();
                 isset($_GET['add_entry']) ? $lessonID = $currentLessonID : ($lessonID = $object[0]['lessons_ID']);
                 if (isset($_GET['add_entry'])) {
                     $date = date('Y') . '-' . date('m') . '-' . date('d') . ' ' . date('H') . ':' . date('i') . ':' . date('s');
                 } else {
                     $date = $object[0]['entry_date'];
                 }
                 $fields = array("entry_body" => $values['entry_body'], "entry_date" => $date, "lessons_ID" => $lessonID, "users_LOGIN" => $currentUser->user['login']);
                 if ($values['entry_body'] == '') {
                     $message = _JOURNAL_EMPTY_ENTRY_BODY;
                     eF_redirect($this->moduleBaseUrl . "&message=" . $message . "&message_type=failure" . $popup_);
                 }
                 if (isset($_GET['add_entry'])) {
                     if (eF_insertTableData("module_journal_entries", $fields)) {
                         if (isset($_SESSION['module_journal_autosave_entry'])) {
                             $this->deleteAutoSaveEntry();
                         }
                         $message = _JOURNAL_ENTRY_SUCCESSFULLY_ADDED;
                         eF_redirect($this->moduleBaseUrl . "&message=" . $message . "&message_type=success" . $popup_);
                     } else {
                         $message = _JOURNAL_ENTRY_ADD_PROBLEM;
                         eF_redirect($this->moduleBaseUrl . "&message=" . $message . "&message_type=failure" . $popup_);
                     }
                 } else {
                     if (eF_updateTableData("module_journal_entries", $fields, "id=" . $_GET['edit_entry'])) {
                         $message = _JOURNAL_ENTRY_SUCCESSFULLY_EDITED;
                         eF_redirect($this->moduleBaseUrl . "&message=" . $message . "&message_type=success" . $popup_);
                     } else {
                         $message = _JOURNAL_ENTRY_EDIT_PROBLEM;
                         eF_redirect($this->moduleBaseUrl . "&message=" . $message . "&message_type=failure" . $popup_);
                     }
                 }
             }
             $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
             $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
             $form->setRequiredNote(_REQUIREDNOTE);
             $form->accept($renderer);
             $smarty->assign('T_JOURNAL_ADD_ENTRY_FORM', $renderer->toArray());
             if ($currentUser->getRole($this->getCurrentLesson()) == 'professor') {
                 $popupInfo[] = array('text' => _JOURNAL_POPUP_INFO, 'image' => $this->moduleBaseLink . 'images/info.png', 'href' => $this->moduleBaseUrl . '&popup_info=1&popup=1', 'onClick' => "eF_js_showDivPopup(event, '" . _JOURNAL_POPUP_INFO . "', 2)", 'target' => 'POPUP_FRAME', 'id' => 'popup_info');
                 $smarty->assign("T_JOURNAL_POPUP_INFO", $popupInfo);
             }
         }
     }
     if ($currentUser->getType() == 'administrator') {
         return $this->moduleBaseDir . "module_journal_admin.tpl";
     } else {
         if ($currentUser->getRole($this->getCurrentLesson()) == 'professor' || $currentUser->getRole($this->getCurrentLesson()) == 'student') {
             if (isset($_GET['hide_left']) && $_GET['hide_left'] == '1') {
                 return $this->moduleBaseDir . "module_journal_user_right.tpl";
             }
             if (isset($_GET['hide_right']) && $_GET['hide_right'] == '1') {
                 return $this->moduleBaseDir . "module_journal_user_left.tpl";
             }
             return $this->moduleBaseDir . "module_journal_user.tpl";
         }
     }
 }
function filldata($syllabustmp)
{
    recursiveRemoveDirectory("tmpfilesloc");
    if ($syllabustmp == "All") {
        $str = "";
        $syllabusdata = ExecuteNonQuery("select * from section where semid=" . $_SESSION['ddlsbssem'] . " and active=1");
        $sylarr = array();
        $sbscnt = 0;
        while ($syllabusinfo = mysqli_fetch_assoc($syllabusdata)) {
            $cno = GetSingleField("select courseno from courses where cid=(select cid from course_section where csid=" . $syllabusinfo["csid"] . ")", "courseno");
            $cnot = substr($cno, 0, 1);
            if ($cnot == "C") {
                $version = GetSingleField("select version from fileinfo where active=1 and ftype='matrix'", "version");
            } else {
                $version = GetSingleField("select version from fileinfo where active=1 and ftype='gmatrix'", "version");
            }
            $cnm = GetSingleField("select coursename from courses where courseno like '" . $cno . "'", "coursename");
            $desc = GetSingleField("select description from courses where courseno like '" . $cno . "'", "description");
            $credits = GetSingleField("select credits from courses where courseno like '" . $cno . "'", "credits");
            $sem = GetSingleField("select semname from semester where active=1", "semname");
            $pid = GetSingleField("select prereqid from courses  where courseno like '" . $cno . "'", "prereqid");
            $cid = GetSingleField("select coreqid from courses  where courseno like '" . $cno . "'", "coreqid");
            $prereq = GetSingleField("select pcname from pre_req  where prereqid={$pid}", "pcname");
            $coreq = GetSingleField("select ccname from co_req  where coreqid={$cid}", "ccname");
            $sql = "select starttime,endtime,cday,roomno from facultyhours where uid=" . $syllabusinfo["uid"] . " and semid=" . $_SESSION["ddlsbssem"] . " and csid=" . $syllabusinfo["csid"];
            $web = GetSingleField('select website from section where sectionid=' . $syllabusinfo["sectionid"], 'website');
            $reqmaterials = GetSingleField('select reqmaterials from section where sectionid=' . $syllabusinfo["sectionid"], 'reqmaterials');
            $uid = $syllabusinfo["uid"];
            $dt2 = ExecuteNonQuery($sql);
            while ($inf2 = mysqli_fetch_assoc($dt2)) {
                $classloc = $inf2["roomno"];
                $cday = explode(" ", $inf2["cday"]);
                $tmp = explode(":", $inf2["starttime"]);
                $sttimehr = $tmp[0];
                $sttimemin = substr($tmp[1], 0, 2);
                $sttimeampm = substr($tmp[1], -2);
                $tmp1 = explode(":", $inf2["endtime"]);
                $entimehr = $tmp1[0];
                $entimemin = substr($tmp1[1], 0, 2);
                $entimeampm = substr($tmp1[1], -2);
            }
            $str = "<table width='100%'><tr>\r\n\t\t\t\t\t\t <td><h3><b>Gannon University</b></h3></td>\r\n\t\t\t\t\t\t<td style='text-align:right'><h3><b>Department of Computer and Information Science</b></h3></td>\r\n\t\t\t\t\t   </tr> \r\n\t\t\t\t\t   </table>\r\n\t\t\t\t\t<table style='width:100%' border='1'>\r\n\t\t\t\t<tr>\r\n\t\t\t\t<td>\r\n\t\t\t\t\r\n\t\t\t\t\t   <table>";
            $data = ExecuteNonQuery('select * from users where uid=' . $uid);
            $inst = '';
            $offrno = '';
            $ph = '';
            $email = '';
            while ($info = mysqli_fetch_assoc($data)) {
                $inst = $info['salutation'] . ' ' . $info['firstname'] . $info['lastname'];
                $offrno = $info['office'];
                $ph = $info['officeno'];
                $email = $info['email'];
            }
            $str .= "<tr><td><b>Instructor:</b></td>\r\n\t\t\t\t\t\t<td>" . $inst . "</td>" . "</tr><tr>\r\n\t\t\t\t\t\t<td><b>Office:</b></td>\r\n\t\t\t\t\t\t<td>" . $offrno . "</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td><b>Phone:</b></td>\r\n\t\t\t\t\t\t<td>" . $ph . "</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td><b>Email:</b></td>\r\n\t\t\t\t\t\t<td>" . $email . "</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t   </table>\r\n\t\t\t\t\t   </td>\r\n\t\t\t\t\t   <td>\r\n\t\t\t\t\t   <table>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t<td colspan='2'><b>Office Hours</b></td>\r\n\t\t\t\t\t\t</tr>";
            $data1 = ExecuteNonQuery('select starttime,endtime,cday from facultyhours where uid=' . $uid . ' and semid=' . $_SESSION['ddlsbssem'] . ' and type=\'office\'');
            while ($info1 = mysqli_fetch_assoc($data1)) {
                $str .= "<tr>\r\n\t\t\t\t\t\t\t\t\t<td>" . $info1['cday'] . ':' . "</td>" . "<td>" . $info1['starttime'] . ':' . $info1['endtime'] . "</td>\r\n\t\t\t\t\t\t\t\t</tr>";
            }
            $str .= "</table></td>\r\n        \t\t\t\t\t </tr>\r\n        \t\t\t\t\t </table>\r\n        \t<table border='1'>\r\n\t        <tr>\r\n            \t<td>Course Title:</td>\r\n                <td>";
            if (isset($cnm) && $cnm != '') {
                $str .= $cnm;
            }
            $str .= "</td>" . "</tr>\r\n        \t<tr>\r\n            \t<td>Credit Hours:</td>\r\n                <td>";
            if (isset($credits) && $credits != '') {
                $str .= $credits;
            }
            $str .= ' credit(s)' . "</td>" . "\r\n             </tr>";
            $str .= "<tr>\r\n            \t<td>Semester:</td>\r\n                <td>";
            if (isset($sem) && $sem != '') {
                $str .= $sem;
            }
            $str .= "</td>\r\n            </tr>\r\n         \t<tr>\r\n            \t<td>Class Location:</td>\r\n                <td>";
            if (isset($classloc) && $classloc != '') {
                $str .= $classloc;
            }
            $str .= "</td></tr>";
            $sday = "";
            if (in_array('M', $cday)) {
                $sday .= 'M ';
            }
            if (in_array('T', $cday)) {
                $sday .= 'T ';
            }
            if (in_array('W', $cday)) {
                $sday .= 'W ';
            }
            if (in_array('Th', $cday)) {
                $sday .= 'Th ';
            }
            if (in_array('F', $cday)) {
                $sday .= 'F ';
            }
            $str .= "\r\n             <tr>\r\n            \t<td>Class Time:</td>\r\n                <td>";
            $str .= $sday . " " . $sttimehr . ':' . $sttimemin . ' ' . $sttimeampm . "\r\n               <b> to</b>" . $entimehr . ':' . $entimemin . ' ' . $entimeampm . "</option>\r\n                   \r\n                   </td>\r\n            </tr> <tr>\r\n            \t\t<td>Course Description:</td>\r\n                    \r\n            \t\t<td>";
            if (isset($desc) && $desc != '') {
                $str .= $desc;
            }
            $str .= "</td></tr>";
            $str .= "<tr>\r\n            \t\t<td>Course Learning Objectives:</td>\r\n                    \r\n                    <td>\r\n                    The student will be able to<br>";
            $cnot = substr($cno, 0, 1);
            if ($cnot == "C") {
                $cntrec = CountRecords("select cno from course_mappings where cno='" . str_replace(' ', '_', $cno) . "' and version='" . strtoupper($version) . "'");
            } else {
                $cntrec = CountRecords("select cno from gcourse_mappings where cno='" . str_replace(' ', '_', $cno) . "' and version='" . strtoupper($version) . "'");
            }
            $cnt2 = CountRecords('select * from fclo where semid=' . $_SESSION['ddlsbssem'] . ' and csid=' . $syllabusinfo["csid"] . " and uid=" . $uid);
            if ($cntrec > 0) {
                if ($cnot == "C") {
                    $data2 = ExecuteNonQuery("select mappingname from course_mappings where cno='" . str_replace(' ', '_', $cno) . "' and version='" . strtoupper($version) . "'");
                } else {
                    $data2 = ExecuteNonQuery("select mappingname from gcourse_mappings where cno='" . str_replace(' ', '_', $cno) . "' and version='" . strtoupper($version) . "'");
                }
                $cnt = 1;
                while ($info2 = mysqli_fetch_assoc($data2)) {
                    $str .= $info2['mappingname'] . '<br>';
                }
            }
            if ($cnt2 > 0) {
                $data5 = ExecuteNonQuery('select * from fclo where semid=' . $_SESSION['ddlsbssem'] . ' and uid=' . $uid . ' and csid=' . $syllabusinfo["csid"]);
                while ($info5 = mysqli_fetch_assoc($data5)) {
                    $str .= $info5['name'] . '<br>';
                }
            }
            $str .= "\t\r\n                    </td>\r\n            </tr>";
            $str .= "<tr>\r\n            \t\t<td>Co-requisites:</td>\r\n            \t\t\r\n            \t\t<td>";
            if (isset($coreq) && $coreq != '') {
                $str .= $coreq;
            }
            $str .= "</td>\r\n            </tr>\r\n           \t<tr>\r\n            \t\t<td>Prerequisites:</td>\r\n            \t\t\r\n            \t\t<td>";
            if (isset($prereq) && $prereq != '') {
                $str .= $prereq;
            }
            $str .= "</td></tr>";
            //echo $str;
            $str .= "<tr>\r\n         \t\t\t<td>Resources:</td>\r\n            \t\t<td>{$web}       </td>\r\n            </tr>\r\n\t\t\t<tr>\t<td>Required Textbooks:</td>\r\n            \t\t\r\n            \t\t<td>{$reqmaterials}\r\n          \t\t    </td>\r\n            </tr>";
            $str .= " <tr>\r\n            \t\t<td>Course Assessment Method:</td>\r\n            \t\t<td>";
            $cnt = 0;
            $sql = 'select camid,camname,camdetails from cams where csid=' . $syllabusinfo["csid"] . ' and semid=' . $_SESSION["ddlsbssem"] . " and uid=" . $uid;
            $data3 = ExecuteNonQuery($sql);
            //echo $sql;
            $cntrec1 = mysqli_num_rows($data3);
            $cnt = mysqli_num_rows($data3);
            //	echo $cnt;
            $str .= "<div>\r\n \t             \t\t<table align='left' id='camtable' style='text-align:left;' border='1' >";
            if ($cnt > 0) {
                $cnt = 1;
                while ($info3 = mysqli_fetch_assoc($data3)) {
                    $str .= "  <tr>\r\n                                        <td>" . $info3['camname'] . "</td>\r\n                                        <td width='100%'>" . $info3['camdetails'] . "\r\n                                     </td>\r\n                                  </tr>";
                }
            }
            $str .= " </table>\r\n \t\t\t\t\t\t\r\n                        </div>\r\n                    </td>\r\n            </tr>";
            $str .= " <tr>\r\n            \t\t<td>Assessment Method Mappings:</td>\r\n            \t\t\r\n            \t\t<td>";
            //		$sql="select * from course_mappings where cno='".str_replace(" ","_",$cno)."'";
            //	echo $sql;
            $cnot = substr($cno, 0, 1);
            if ($cnot == "C") {
                $cnt = CountRecords("select * from course_mappings where cno='" . str_replace(" ", "_", $cno) . "'");
            } else {
                $cnt = CountRecords("select * from gcourse_mappings where cno='" . str_replace(" ", "_", $cno) . "'");
            }
            $cnt2 = CountRecords('select * from fclo where semid=' . $_SESSION["ddlsbssem"] . ' and csid=' . $syllabusinfo["csid"] . " and uid=" . $uid);
            $myval = $cnt + $cnt2;
            //      echo $myval;
            $str .= "<table align='left' border='1' style='text-align:center'>\r\n                           \t<tr>\r\n                            \t<td rowspan='2'>ASSESSMENT METHODS</td>\r\n                                        \t<td colspan=" . $myval . " align='center'>\r\n                                            \tOBJECTIVES\r\n                          \t\t          </td>\r\n                            </tr>\r\n                            <tr>";
            for ($i = 1; $i <= $cnt + $cnt2; $i++) {
                $str .= "<td>" . $i . "</td>";
            }
            $str .= "</tr>";
            $sql = 'select camid,camname from cams where csid=' . $syllabusinfo["csid"] . ' and semid=' . $_SESSION["ddlsbssem"] . " and uid=" . $uid;
            $data = ExecuteNonQuery($sql);
            while ($info = mysqli_fetch_assoc($data)) {
                $str .= "\t\r\n                            <tr>\r\n                            \t<td>" . $info['camname'] . "</td>";
                for ($i = 1; $i <= $myval; $i++) {
                    $objnm = 'obj' . $i;
                    $t1 = GetSingleField('select ' . $objnm . ' from fcamm where camid=' . $info['camid'] . ' and csid=' . $syllabusinfo["csid"] . ' and semid=' . $_SESSION['ddlsbssem'] . " and uid=" . $uid, $objnm);
                    $str .= "<td>";
                    if ($t1 == '1') {
                        $str .= 'X';
                    } else {
                        $str .= '';
                    }
                    $str .= "</td>";
                }
                $str .= "</tr>";
            }
            $str .= "<tr>\r\n                                <td>Department-Wide Outcomes</td>";
            $cnot = substr($cno, 0, 1);
            if ($cnot == "C") {
                $data = ExecuteNonQuery('select * from matrix_' . strtolower($version) . " where cno like '" . str_replace(" ", "_", $cno) . "'");
            } else {
                $data = ExecuteNonQuery('select * from matrix_' . strtolower($version) . " where cno like '" . str_replace(" ", "_", $cno) . "'");
            }
            //						  echo mysqli_num_rows($data);
            //					  echo $sql;
            while ($info = mysqli_fetch_assoc($data)) {
                $temp = '';
                if ($info['col0'] == '1') {
                    $temp = 'CIS-1';
                }
                if ($info['col1'] == '1') {
                    if ($temp == '') {
                        $temp = 'CIS-2';
                    } else {
                        $temp .= ',' . 'CIS-2';
                    }
                }
                if ($info['col2'] == '1') {
                    if ($temp == '') {
                        $temp = 'CIS-3';
                    } else {
                        $temp .= ',' . 'CIS-3';
                    }
                }
                if ($info['col3'] == '1' || $info['col4'] == '1' || $info['col5'] == '1' || $info['col6'] == '1' || $info['col7'] == '1') {
                    if ($temp == '') {
                        $temp = 'CIS-4';
                    } else {
                        $temp .= ',' . 'CIS-4';
                    }
                }
                if ($info['col8'] == '1') {
                    if ($temp == '') {
                        $temp = 'CIS-5';
                    } else {
                        $temp .= ',' . 'CIS-5';
                    }
                }
                if ($info['col9'] == '1' || $info['col9'] == '1') {
                    if ($temp == '') {
                        $temp = 'CIS-6';
                    } else {
                        $temp .= ',' . 'CIS-6';
                    }
                }
                $str .= "<td>{$temp}</td>";
            }
            $data = ExecuteNonQuery('select * from fclo where csid=' . $syllabusinfo["csid"] . ' and semid=' . $_SESSION['ddlsbssem'] . " and uid=" . $uid);
            $i = mysqli_num_rows($data);
            while ($info = mysqli_fetch_assoc($data)) {
                $str .= "<td>" . $info['docm'] . "</td>";
            }
            $str .= "\r\n\t\t\t\t\t\t\t</tr> \r\n                           <tr>\r\n                                <td>Program-Specific Outcomes</td>";
            $cnot = substr($cno, 0, 1);
            if ($cnot == "C") {
                $data = ExecuteNonQuery('select * from matrix_' . strtolower($version) . " where cno='" . str_replace(" ", "_", $cno) . "'");
            } else {
                $data = ExecuteNonQuery('select * from gmatrix_' . strtolower($version) . " where cno='" . str_replace(" ", "_", $cno) . "'");
            }
            while ($info = mysqli_fetch_assoc($data)) {
                $temp = '';
                if ($info['col11'] == '1' || $info['col12'] == '1') {
                    if ($temp == '') {
                        $temp = 'CS-1';
                    } else {
                        $temp .= ',' . 'CS-1';
                    }
                }
                if ($info['col13'] == '1' || $info['col14'] == '1') {
                    if ($temp == '') {
                        $temp = 'CS-2';
                    } else {
                        $temp .= ',' . 'CS-2';
                    }
                }
                if ($info['col15'] == '1') {
                    if ($temp == '') {
                        $temp = 'CS-3';
                    } else {
                        $temp .= ',' . 'CS-3';
                    }
                }
                if ($info['col16'] == '1') {
                    if ($temp == '') {
                        $temp = 'CS-4';
                    } else {
                        $temp .= ',' . 'CS-4';
                    }
                }
                if ($info['col17'] == '1') {
                    if ($temp == '') {
                        $temp = 'CS-5';
                    } else {
                        $temp .= ',' . 'CS-5';
                    }
                }
                if ($info['col18'] == '1' || $info['col19'] == '1' || $info['col20'] == '1' || $info['col21'] == '1') {
                    if ($temp == '') {
                        $temp = 'IS-1';
                    } else {
                        $temp .= ',' . 'IS-1';
                    }
                }
                if ($info['col22'] == '1') {
                    if ($temp == '') {
                        $temp = 'IS-2';
                    } else {
                        $temp .= ',' . 'IS-2';
                    }
                }
                if ($info['col23'] == '1' || $info['col24'] == '1') {
                    if ($temp == '') {
                        $temp = 'IS-3';
                    } else {
                        $temp .= ',' . 'IS-3';
                    }
                }
                if ($info['col25'] == '1') {
                    if ($temp == '') {
                        $temp = 'IS-4';
                    } else {
                        $temp .= ',' . 'IS-4';
                    }
                }
                if ($info['col26'] == '1' || $info['col27'] == '1' || $info['col28'] == '1' || $info['col29'] == '1' || $info['col30'] == '1' || $info['col31'] == '1') {
                    if ($temp == '') {
                        $temp = 'SE-1';
                    } else {
                        $temp .= ',' . 'SE-1';
                    }
                }
                if ($info['col32'] == '1') {
                    if ($temp == '') {
                        $temp = 'SE-2';
                    } else {
                        $temp .= ',' . 'SE-2';
                    }
                }
                if ($info['col33'] == '1') {
                    if ($temp == '') {
                        $temp = 'SE-3';
                    } else {
                        $temp .= ',' . 'SE-3';
                    }
                }
                $str .= "<td>{$temp}</td>";
            }
            $data = ExecuteNonQuery('select * from fclo where csid=' . $syllabusinfo["csid"] . ' and semid=' . $_SESSION['ddlsbssem'] . " and uid=" . $uid);
            $i = mysqli_num_rows($data);
            while ($info = mysqli_fetch_assoc($data)) {
                $str .= "<td>" . $info['pocm'] . "</td>";
            }
            $str .= "</tr> \r\n                           </table>\r\n\t                </td>\r\n            </tr>\r\n\t\t\t  <tr>";
            $gp = GetSingleField("select gradingpolicy from section where csid=" . $syllabusinfo["csid"] . " and semid=" . $_SESSION['ddlsbssem'] . " and uid=" . $uid, "gradingpolicy");
            $str .= "      \r\n    \t   \t<td>Grading Policy:</td>\r\n           \t<td style='text-align:center'>";
            if (isset($gp) && $gp != "") {
                $str .= str_replace("<table>", "<table border='1'>", $gp);
            }
            $str .= "\r\n \t                </td>\r\n            </tr>\r\n\t\t\t <tr>\r\n           \r\n            \t<td>Course Policies:</td>\r\n            \t\r\n           \t\t<td>";
            $sql = "select coursepolicy from section where csid=" . $syllabusinfo["csid"] . " and semid=" . $_SESSION['ddlsbssem'] . " and uid=" . $uid;
            $cp = GetSingleField($sql, "coursepolicy");
            $str .= $cp;
            $str .= "</td></tr>\r\n\t\t\t\t\t<tr>\r\n        \t\t    \t<td>Attendance Policies:</td>\r\n\t\t\t\t\t\t<td>";
            $attp = GetSingleField("select attpolicy from section where csid=" . $syllabusinfo["csid"] . " and semid=" . $_SESSION['ddlsbssem'] . " and uid=" . $uid, "attpolicy");
            $str .= $attp;
            $str .= "</td></tr>\r\n\t\t\t\t\t <tr>\r\n            \r\n            \t<td>Academic Integrity:</td>\r\n            \t\r\n           \t\t<td>";
            $ai = GetSingleField("select academicintegrity from section where csid=" . $syllabusinfo["csid"] . " and  semid=" . $_SESSION['ddlsbssem'] . " and uid=" . $uid, "academicintegrity");
            $str .= $ai;
            $str .= "</td></tr>\r\n\t\t\t\t\t<tr>\r\n            \t<td>Course Calendar with Topics:</td>\r\n            \t\r\n           \t\t<td>";
            $cctopics = GetSingleField("select coursetopics from section where csid=" . $syllabusinfo["csid"] . " and  semid=" . $_SESSION['ddlsbssem'] . " and uid=" . $uid, "coursetopics");
            $csnm = GetSingleField("select sections from course_section where csid=" . $syllabusinfo["csid"], "sections");
            $fnm = GetSingleField("select firstname from users where uid=" . $uid, "firstname");
            $lnm = GetSingleField("select lastname from users where uid=" . $uid, "lastname");
            $str .= $cctopics;
            $str .= "</td>\r\n            </tr></table>";
            if (!mkdir("tmpfilesloc", 0777, true)) {
                $sylarr[$sbscnt] = "tmpfilesloc/" . $csnm . "_" . substr($fnm, 0, 1) . substr($lnm, 0, 1) . ".doc";
                $htmltodoc = new HTML_TO_DOC();
                $htmltodoc->createDoc($str, $sylarr[$sbscnt]);
                $sbscnt++;
            }
        }
        if (!mkdir("tmpzips", 0777, true)) {
            //----------------Creating zip
            $file = 'tmpzips/allcourses.zip';
            if (file_exists($file)) {
                unlink($file);
            }
            $result = create_zip($sylarr, 'tmpzips/allcourses.zip');
        }
        // We'll be outputting a PDF
        header('Content-type: application/zip');
        // It will be called downloaded.pdf
        header('Content-Disposition: attachment; filename=allcourses.zip');
        // The PDF source is in original.pdf
        readfile('tmpzips/allcourses.zip');
        //	return $str;
        //	rmdir("tmpfilesloc");
        //-----------------------------
    } else {
    }
}
            $sql = "select semname,year from semester where semid=" . $_SESSION["ddlsem4"];
            $data2 = ExecuteNonQuery($sql);
            while ($info = mysqli_fetch_assoc($data2)) {
                $sem = $info["semname"] . " " . $info["year"];
            }
        }
    }
}
if (isset($_POST["export"]) && $_POST["ddlcnm"] != "") {
    $old_date = date('l, F d y h:i:s');
    // returns Saturday, January 30 10 02:06:34
    $old_date_timestamp = strtotime($old_date);
    $new_date = date('mdYhis', $old_date_timestamp);
    $cno = GetSingleField("select courseno from courses where cid=(select cid from course_section where csid=" . $_POST["ddlcnm"] . ")", "courseno");
    $cno = str_replace(" ", "_", $cno);
    $htmltodoc = new HTML_TO_DOC();
    $htmltodoc->createDoc($_POST["tafinal"], $_SESSION["username"] . "/" . $cno . "_" . $new_date);
    redirect_to("coursesyllabus.php");
}
?>
<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>View Course Details</title>
        <link href="css/menu.css" rel="stylesheet" type="text/css">
        <script src="js/jquery-latest.min.js"></script>
        <script src="ckeditor/ckeditor.js"></script>

        <link href="css/style.css" rel="stylesheet" type="text/css">
    </head>
    }
    $str .= "\r\n \t                </td>\r\n            </tr>\r\n\t\t\t <tr>\r\n           \r\n            \t<td>Course Policies:</td>\r\n            \t\r\n           \t\t<td>";
    $sql = "select coursepolicy from section where csid=" . $syllabusinfo["csid"] . " and semid=" . $_SESSION['ddlsbssem'];
    $cp = GetSingleField($sql, "coursepolicy");
    $str .= $cp;
    $str .= "</td></tr>\r\n\t\t\t\t\t<tr>\r\n        \t\t    \t<td>Attendance Policies:</td>\r\n\t\t\t\t\t\t<td>";
    $attp = GetSingleField("select attpolicy from section where csid=" . $syllabusinfo["csid"] . " and semid=" . $_SESSION['ddlsbssem'], "attpolicy");
    $str .= $attp;
    $str .= "</td></tr>\r\n\t\t\t\t\t <tr>\r\n            \r\n            \t<td>Academic Integrity:</td>\r\n            \t\r\n           \t\t<td>";
    $ai = GetSingleField("select academicintegrity from section where csid=" . $syllabusinfo["csid"] . " and  semid=" . $_SESSION['ddlsbssem'], "academicintegrity");
    $str .= $ai;
    $str .= "</td></tr>\r\n\t\t\t\t\t<tr>\r\n            \t<td>Course Calendar with Topics:</td>\r\n            \t\r\n           \t\t<td>";
    $cctopics = GetSingleField("select coursetopics from section where csid=" . $syllabusinfo["csid"] . " and  semid=" . $_SESSION['ddlsbssem'], "coursetopics");
    $str .= $cctopics;
    $str .= "</td>\r\n            </tr></table>";
    $sylarr[$cnt] = "tmpfileloc/" . $syllabusinfo["sectionid"] . ".doc";
    $htmltodoc = new HTML_TO_DOC();
    $htmltodoc->createDoc($str, $sylarr[$cnt]);
    $cnt++;
    echo $str;
}
//----------------Creating zip
/*			$result = create_zip($sylarr,'tmpfileloc/test.zip');
					// We'll be outputting a PDF
					header('Content-type: application/zip');
					// It will be called downloaded.pdf
					header('Content-Disposition: attachment; filename=test.zip');
					// The PDF source is in original.pdf
					readfile('test.zip');*/
//	return $str;
//-----------------------------