Пример #1
0
 if (isset($currentUser->coreAccess['content']) && $currentUser->coreAccess['content'] != 'change') {
     eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=control_panel&message=" . urlencode(_UNAUTHORIZEDACCESS) . "&message_type=failure");
 }
 try {
     $smarty->assign("T_MAX_FILE_SIZE", FileSystemTree::getUploadMaxSize());
     $maxUploads = 5;
     $form = new HTML_QuickForm("upload_scorm_form", "post", basename($_SERVER['PHP_SELF']) . '?ctg=scorm&scorm_import=1', "", null, true);
     $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
     //Register this rule for checking user input with our function, eF_checkParameter
     $form->addElement('file', 'scorm_file[0]', _UPLOADTHESCORMFILEINZIPFORMAT);
     //$form -> addRule('scorm_file[0]', _THEFIELD.' "'._UPLOADTHESCORMFILEINZIPFORMAT.'" '._ISMANDATORY, 'required', null, 'client');
     for ($i = 1; $i < $maxUploads; $i++) {
         $form->addElement('file', "scorm_file[{$i}]", null);
     }
     //$form -> addElement('file', 'scorm_file', _SCORMFILEINZIPFORMAT);
     $form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
     $form->addElement('text', 'url_upload', _UPLOADFILEFROMURL, 'class = "inputText"');
     $form->addElement('select', 'embed_type', _EMBEDTYPE, array('iframe' => _INLINEIFRAME, 'popup' => _NEWWINDOWPOPUP), 'class = "inputSelect"');
     $form->addElement('text', 'popup_parameters', _POPUPPARAMETERS, 'class = "inputText" style = "width:600px"');
     $form->addElement('text', 'iframe_parameters', _IFRAMEPARAMETERS, 'class = "inputText" style = "width:600px"');
     $form->addElement('submit', 'submit_upload_scorm', _SUBMIT, 'class = "flatButton"');
     $form->setDefaults(array('popup_parameters' => 'width=800,height=600,scrollbars=no,resizable=yes,status=yes,toolbar=no,location=no,menubar=no,top="+(parseInt(parseInt(screen.height)/2) - 300)+",left="+(parseInt(parseInt(screen.width)/2) - 400)+"', 'iframe_parameters' => 'height = "100%"  width = "100%" frameborder = "no"'));
     //@todo: url upload, if not exists, report a human-readable error!
     $timestamp = time();
     if ($form->isSubmitted() && $form->validate()) {
         $values = $form->exportValues();
         try {
             $urlUpload = $form->exportValue('url_upload');
             $scormFiles = array();
             if ($urlUpload != "") {
                 FileSystemTree::checkFile($urlUpload);
Пример #2
0
                } elseif ($pathParts['extension'] == 'js') {
                    //do not create unit for js files
                } else {
                    if (file_exists(G_THEMESPATH . 'default/images/file_types/' . $pathParts['extension'] . '.png')) {
                        $fields['data'] = '<a href = "view_file.php?file=' . $file['id'] . '&action=download"><img src="images/file_types/' . $pathParts['extension'] . '.png" style="vertical-align:middle" />' . eFront_basename($file['name']) . '</a>';
                    } else {
                        $fields['data'] = '<a href = "view_file.php?file=' . $file['id'] . '&action=download">' . eFront_basename($file['name']) . '</a>';
                    }
                    $unit = $currentContent->insertNode($fields);
                }
            }
        }
        $message = _FILESIMPORTEDSUCCESSFULLY;
        $message_type = 'success';
    } catch (Exception $e) {
        handleNormalFlowExceptions($e);
    }
}
$form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
$form->setRequiredNote(_REQUIREDNOTE);
$renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
$renderer->setRequiredTemplate('{$html}{if $required}
            &nbsp;<span class = "formRequired">*</span>
        {/if}');
$renderer->setErrorTemplate('{$html}{if $error}
            <span class = "formError">{$error}</span>
        {/if}');
$form->accept($renderer);
$smarty->assign("T_MAX_FILE_SIZE", FileSystemTree::getUploadMaxSize());
$smarty->assign('T_ENTITY_FORM', $renderer->toArray());
#cpp#endif
 /**
  * The main functionality
  *
  * (non-PHPdoc)
  * @see libraries/EfrontModule#getModule()
  */
 public function getModule()
 {
     $smarty = $this->getSmartyVar();
     $smarty->assign("T_MODULE_BASEDIR", $this->moduleBaseDir);
     $smarty->assign("T_MODULE_BASELINK", $this->moduleBaseLink);
     $smarty->assign("T_MODULE_BASEURL", $this->moduleBaseUrl);
     $dir = $this->moduleBaseDir . 'assets/';
     if (!is_dir($dir)) {
         mkdir($dir, 0755);
     }
     if ($_SESSION['s_type'] == 'administrator') {
         try {
             $form = new HTML_QuickForm("upload_files_form", "post", $this->moduleBaseUrl . '&tab=upload', "", null, true);
             $form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
             //Register this rule for checking user input with our function, eF_checkParameter
             $form->addElement('file', 'file', _UPLOADFILE);
             if (G_VERSIONTYPE == 'enterprise') {
                 $tree = new EfrontBranchesTree();
                 $pathString = $tree->toPathString();
                 //$result = eF_getTableData("module_hcd_branch", "*", "url is not null and url !=''");
                 $handle = '<img id = "busy" src = "images/16x16/clock.png" style = "display:none;" alt = "{$smarty.const._LOADING}" title = "{$smarty.const._LOADING}"/><div id = "autocomplete_leaflet_branches" class = "autocomplete"></div>&nbsp;&nbsp;&nbsp;';
                 $form->addElement('static', 'sidenote', $handle);
                 $form->addElement('text', 'leaflet_branch_autoselect', _BRANCH, 'class = "autoCompleteTextBox" id = "autocomplete"');
                 $form->addElement('hidden', 'leaflet_branch', '', 'id = "leaflet_branch_value"');
             }
             $form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
             $form->addElement('submit', 'submit_upload', _UPLOAD, 'class = "flatButton"');
             if ($form->isSubmitted() && $form->validate()) {
                 $values = $form->exportValues();
                 try {
                     if ($values['leaflet_branch'] && eF_checkParameter($values['leaflet_branch'], 'id')) {
                         $branch = new EfrontBranch($values['leaflet_branch']);
                         if (!$branch->branch['url']) {
                             throw new Exception("You must assign a url to the selected branch to upload files for it");
                         }
                         $dir = $this->moduleBaseDir . 'assets/' . $branch->branch['url'];
                         mkdir($dir, 0755);
                     }
                     $filesystem = new FileSystemTree($dir);
                     $file = $filesystem->uploadFile("file", $dir);
                 } catch (Exception $e) {
                     $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
                     $message = $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
                     $message_type = failure;
                     $this->setMessageVar($message, $message_type);
                 }
             }
             $smarty->assign('T_UPLOAD_FORM', $form->toArray());
             $url = $this->moduleBaseUrl;
             $basedir = $dir;
             $options = array('zip' => false, 'upload' => false, 'create_folder' => false, 'folders' => true);
             /**The file manager*/
             include "file_manager.php";
         } catch (Exception $e) {
             $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
             $message = $e->getMessage() . ' (' . $e->getCode() . ') &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
             $message_type = 'failure';
             $this->setMessageVar($message, $message_type);
         }
     } else {
         if (defined('G_BRANCH_URL') && G_BRANCH_URL) {
             try {
                 $assets_path = $root_path = $this->moduleBaseDir . 'assets/' . G_BRANCH_URL;
             } catch (Exception $e) {
                 //do nothing here if the directory doesn't exist
             }
         } else {
             $assets_path = $root_path = $this->moduleBaseDir . 'assets/';
         }
         $files = array();
         if (!empty($_GET['folder'])) {
             $folder = urldecode($_GET['folder']);
             if (is_dir($assets_path . $folder)) {
                 $folder = new EfrontDirectory($assets_path . $folder);
                 if (strpos(realpath($folder['path']), $root_path) === false) {
                     throw new Exception("Invalid folder");
                 }
                 $parent_folder = dirname($folder['path']);
                 $url = urlencode(str_replace($root_path, '', $folder['path']));
                 $assets_path = $folder['path'];
                 $parent_url = $this->moduleBaseUrl . "&folder=" . urlencode(str_replace($root_path, '', dirname($folder['path']) . '/'));
                 $parent_url or $parent_url = $this->moduleBaseUrl . 'assets/';
                 $files[] = array('text' => '.. (Up one level)', 'image' => $this->moduleBaseLink . 'ico/folders.png', 'href' => $parent_url);
             }
         }
         //pr($url);pr($parent_url);
         //
         $filesystem = new FileSystemTree($assets_path, true);
         foreach ($filesystem->tree as $key => $value) {
             if ($value instanceof EfrontDirectory) {
                 $files[] = array('text' => basename($key), 'image' => $this->moduleBaseLink . 'ico/folders.png', 'href' => $this->moduleBaseUrl . "&folder=" . urlencode(str_replace($root_path, '', $value['path'] . '/')));
             }
         }
         foreach ($filesystem->tree as $key => $value) {
             if ($value instanceof EfrontFile) {
                 if (is_file($this->moduleBaseDir . 'ico/' . pathinfo($key, PATHINFO_EXTENSION) . '.png')) {
                     $icon = $this->moduleBaseLink . 'ico/' . pathinfo($key, PATHINFO_EXTENSION) . '.png';
                 } else {
                     $icon = $this->moduleBaseLink . 'ico/unknown.png';
                 }
                 $files[] = array('text' => basename($key), 'image' => $icon, 'href' => $this->moduleBaseLink . str_replace($this->moduleBaseDir, '', $key));
             }
         }
         $smarty->assign("T_FILES", $files);
     }
     return true;
 }
Пример #4
0
 /**
  * (non-PHPdoc)
  * @see libraries/EfrontEntity#getForm($form)
  */
 public function getForm($form)
 {
     //$system_form = new HTML_QuickForm("customization_form", "post", basename($_SERVER['PHP_SELF'])."?ctg=themes&tab=customization", "", null, true);
     $form->addElement('file', 'theme_file', _UPLOADTHEMEFILEZIPFORMAT);
     $form->addElement('text', 'remote_theme', _ORSPECIFYREMOTETHEME, 'class = "inputText"');
     $form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
     $form->addElement("submit", "submit_theme", _INSTALL, 'class = "flatButton"');
     return $form;
 }
Пример #5
0
     $result = array_combine(array_values($result['login']), array_values($result['login']));
 }
 // Using the array_values function to form 0=>login1,1=>login2... instead of login1=>login1, login2=>login2
 if (isset($recipients) && !empty($result)) {
     $recipients = array_values(array_merge($recipients, $result));
 } else {
     if (!empty($result)) {
         $recipients = array_values($result);
     }
 }
 // else the $recipients = $recipients
 // If only a massive sent selection was used and no employee was found
 if (isset($recipients)) {
     $pm = new eF_PersonalMessage($currentUser->user['login'], $recipients, $values['subject'], $values['body'], $values['bcc']);
     if ($_FILES['attachment']['name'][0] != "") {
         $maxFileSize = FileSystemTree::getUploadMaxSize();
         if ($_FILES['attachment']['size'][0] == 0 || $_FILES['attachment']['size'][0] > $maxFileSize * 1024) {
             //	G_MAXFILESIZE is deprecated                                                          //If the directory could not be created, display an erro message
             $message = _EACHFILESIZEMUSTBESMALLERTHAN . " " . $maxFileSize . _KB;
             $message_type = 'failure';
         }
         //Upload user avatar file
         $pm->sender_attachment_timestamp = time();
         $user_dir = G_UPLOADPATH . $currentUser->user['login'] . '/message_attachments/Sent/' . $pm->sender_attachment_timestamp . '/';
         mkdir($user_dir, 0755);
         $filesystem = new FileSystemTree($user_dir);
         try {
             $uploadedFile = $filesystem->uploadFile('attachment', $user_dir, 0);
             $pm->sender_attachment_fileId = $uploadedFile['id'];
             $pm->setAttachment($uploadedFile['path']);
         } catch (EfrontFileException $e) {
 public function getModule()
 {
     $smarty = $this->getSmartyVar();
     global $load_editor;
     $load_editor = true;
     $current_user = $this->getCurrentUser();
     $smarty->assign("T_MODULE_CURRENT_USER", $current_user->getType());
     $form = new HTML_QuickForm("module_mail_form", "post", $this->moduleBaseUrl, "", "id = 'module_mail_form'");
     $form->addElement('hidden', 'recipients', $_GET['rec']);
     $form->addElement('text', 'subject', _SUBJECT, 'class = "inputText" style = "width:400px"');
     $form->addElement('textarea', 'body', _BODY, 'class = "simpleEditor" style = "width:100%;height:200px"');
     $form->addElement('checkbox', 'email', _SENDASEMAILALSO, null, 'id = "send_as_email" class = "inputCheckBox"');
     $form->addRule('subject', _THEFIELD . ' "' . _SUBJECT . '" ' . _ISMANDATORY, 'required', null, 'client');
     $form->addRule('recipients', _THEFIELD . ' "' . _RECIPIENTS . '" ' . _ISMANDATORY, 'required', null, 'client');
     $form->addElement('file', 'attachment[0]', _ATTACHMENT, null, 'class = "inputText"');
     $form->addElement('submit', 'submit_mail', _SEND, 'class = "flatButton"');
     if ($form->isSubmitted() && $form->validate()) {
         $values = $form->exportValues();
         switch ($values['recipients']) {
             case "lesson_students":
                 $lesson = new EfrontLesson($_SESSION['s_lessons_ID']);
                 $lessonUsers = $lesson->getUsers("student");
                 foreach ($lessonUsers as $value) {
                     $mail_recipients[] = $value['login'];
                 }
                 //pr($mail_recipients);return;
                 break;
             case "lesson_professors":
                 $lesson = new EfrontLesson($_SESSION['s_lessons_ID']);
                 $lessonUsers = $lesson->getUsers("professor");
                 if (isset($_SESSION['s_courses_ID'])) {
                     $course = new EfrontCourse($_SESSION['s_courses_ID']);
                     $course_users = $course->getCourseUsers();
                     foreach ($lessonUsers as $key => $value) {
                         if (!isset($course_users[$key])) {
                             unset($lessonUsers[$key]);
                         }
                     }
                 }
                 foreach ($lessonUsers as $value) {
                     $mail_recipients[] = $value['login'];
                 }
                 break;
             case "admin":
                 $result = eF_getTableData("users", "*", "user_type='administrator' and user_types_ID=0 and archive = 0");
                 //not
                 foreach ($result as $value) {
                     $mail_recipients[] = $value['login'];
                 }
                 break;
         }
         //$list = implode(",",$mail_recipients);
         $pm = new eF_PersonalMessage($_SESSION['s_login'], $mail_recipients, $values['subject'], $values['body']);
         if ($_FILES['attachment']['name'][0] != "") {
             $maxFileSize = FileSystemTree::getUploadMaxSize();
             if ($_FILES['attachment']['size'][0] == 0 || $_FILES['attachment']['size'][0] > $maxFileSize * 1024) {
                 //	G_MAXFILESIZE is deprecated
                 $message = _EACHFILESIZEMUSTBESMALLERTHAN . " " . G_MAXFILESIZE . " Bytes";
                 $message_type = 'failure';
             }
             //Upload user avatar file
             $pm->sender_attachment_timestamp = time();
             $user_dir = G_UPLOADPATH . $_SESSION['s_login'] . '/message_attachments/Sent/' . $pm->sender_attachment_timestamp . '/';
             mkdir($user_dir, 0755);
             $filesystem = new FileSystemTree($user_dir);
             $uploadedFile = $filesystem->uploadFile('attachment', $user_dir, 0);
             $pm->sender_attachment_fileId = $uploadedFile['id'];
             $pm->setAttachment($uploadedFile['path']);
         }
         if ($pm->send($values['email'], $values)) {
             $message = _MESSAGEWASSENT;
             $message_type = 'success';
         } else {
             $message = $pm->errorMessage;
             $message_type = 'failure';
         }
     }
     $renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
     //Create a smarty renderer
     $renderer->setRequiredTemplate('{$html}{if $required}
     	&nbsp;<span class = "formRequired">*</span>
 		{/if}');
     $form->setJsWarnings(_BEFOREJAVASCRIPTERROR, _AFTERJAVASCRIPTERROR);
     //Set javascript error messages
     $form->setRequiredNote(_REQUIREDNOTE);
     $form->accept($renderer);
     //Assign this form to the renderer, so that corresponding template code is created
     $smarty->assign('T_MODULE_MAIL_FORM', $renderer->toArray());
     $smarty->assign("T_MESSAGE_MAIL", $message);
     $smarty->assign("T_MESSAGE_MAIL_TYPE", $message_type);
     //pr($renderer -> toArray());
     return true;
 }
Пример #7
0
    /**
     * Populate the test form
     *
     * This function is used to populate the test form and create the
     * test html code.
     * <br/>Example:
     * <code>
     * $test = new EfrontTest(1);                               //Instantiate test form
     * $form = new HTML_QuickForm("questionForm", "post", "", "", null, true);      //Create the test form
     * echo $test -> toHTMLQuickForm($form);                    //Populates the form and returns the equivalent HTML code
     * echo $test -> toHTMLQuickForm($form, 2);                 //Populates the form and returns the equivalent HTML code, but displays only question with id 2
     * $test -> setDone('jdoe');                                //Get the done test information for user 'jdoe';
     * echo $test -> toHTMLQuickForm($form, false, true);       //Populates the form and returns the equivalent HTML code, but the mode is set to display the done test
     * </code>
     *
     * @param HTML_QuickForm $form The form to populate
     * @param int $questionId If set, it displays only the designated question
     * @param boolean $done If set to true and the test has done information (previously acquired with setDone()), then it displays the done test
     * @param boolean $editHandles Whether to display correction handles, to update questions scores and feedback
     * @param boolean $nocache Whether to skip caching this time
     * @since 3.5.0
     * @access public
     */
    public function toHTMLQuickForm(&$form = false, $questionId = false, $done = false, $editHandles = false, $nocache = false, $isFeedback = false)
    {
        $storeCache = false;
        if (!$questionId && !$done && !$this->options['random_pool'] && !$this->options['shuffle_questions'] && !$this->options['shuffle_answers'] && !$nocache) {
            if ($testString = EfrontCache::getInstance()->getCache('test:' . $this->test['id'])) {
                return $testString;
            } else {
                $storeCache = true;
            }
        }
        $originalTestQuestions = $this->getQuestions();
        //Initialize questions information, it case it isn't
        if (!$form) {
            $form = new HTML_QuickForm("questionForm", "post", "", "", null, true);
            //Create a sample form
        }
        $form->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
        $allTestQuestions = $this->getQuestions(true);
        //$allTestQuestionsFilter = $allTestQuestions;
        // lines added for redo only wrong questions
        $allTestQuestionsFilter = array();
        $resultCompleted = EfrontCompletedTest::retrieveCompletedTest("completed_tests ct join completed_tests_blob ctb on ct.id=ctb.completed_tests_ID", "ctb.test", "archive=1 AND users_LOGIN='******'s_login'] . "' AND tests_ID=" . $this->test['id'], "timestamp desc");
        if (!empty($resultCompleted)) {
            $recentlyCompleted = unserialize($resultCompleted[0]['test']);
            if ($recentlyCompleted->redoOnlyWrong == true && !$done) {
                foreach ($recentlyCompleted->questions as $key => $value) {
                    if ($value->score != 100 && isset($originalTestQuestions[$key])) {
                        // && added for the case professor deleted question from test after student clicked to redo only wrong
                        $value->userAnswer = false;
                        $allTestQuestionsFilter[$key] = $value;
                    }
                }
                $allTestQuestions = $allTestQuestionsFilter;
            }
        }
        // If we have a random pool of question then get a random sub-array of the questions
        if ($this->options['random_pool'] > 0 && $this->options['random_pool'] < sizeof($allTestQuestions)) {
            $rand_questions = array_rand($allTestQuestions, $this->options['random_pool']);
            $testQuestions = array();
            foreach ($rand_questions as $question) {
                $testQuestions[$question] = $allTestQuestions[$question];
            }
        } else {
            $testQuestions = $allTestQuestions;
        }
        $questionId && in_array($questionId, array_keys($testQuestions)) ? $testQuestions = $testQuestions[$questionId] : null;
        //If $questionId is specified, keep only this question
        $this->options['display_list'] ? $testString = '<style type = "text/css">span.orderedList{float:left;}</style>' : ($testString = '<style type = "text/css">span.orderedList{display:none;}</style>');
        $count = 1;
        if ($this->test['content_ID']) {
            //Get unit names and ids
            $content = new EfrontContentTree(key($this->getLesson()));
            foreach (new EfrontNodeFilterIterator(new RecursiveIteratorIterator(new RecursiveArrayIterator($content->tree), RecursiveIteratorIterator::SELF_FIRST)) as $key => $value) {
                $units[$key] = $value['name'];
            }
        }
        $currentLesson = $this->getLesson(true);
        foreach ($testQuestions as $id => $question) {
            if ($done) {
                switch ($question->score) {
                    case '':
                    case 0:
                        $image = 'error_delete.png';
                        $alt = _INCORRECTQUESTION;
                        $title = _INCORRECTQUESTION;
                        break;
                    case '100':
                        $image = 'success.png';
                        $alt = _QUESTIONISCORRECT;
                        $title = _QUESTIONISCORRECT;
                        break;
                    default:
                        $image = 'semi_success.png';
                        $alt = _PARTIALLYCORRECTQUESTION;
                        $title = _PARTIALLYCORRECTQUESTION;
                        break;
                }
                if ($question->pending) {
                    $image = 'exclamation.png';
                    $alt = _CORRECTIONPENDING;
                    $title = _CORRECTIONPENDING;
                }
            }
            $weight = round(10000 * $this->getQuestionWeight($question->question['id'])) / 100;
            $timeSpentString = '';
            if (!empty($question->time)) {
                $timeSpent = eF_convertIntervalToTime($question->question['estimate'] - $question->time);
                $timeSpent['hours'] ? $timeSpentString .= $timeSpent['hours'] . _HOURSSHORTHAND . '&nbsp;' : null;
                $timeSpent['minutes'] ? $timeSpentString .= $timeSpent['minutes'] . _MINUTESSHORTHAND . '&nbsp;' : null;
                $timeSpent['seconds'] ? $timeSpentString .= $timeSpent['seconds'] . _SECONDSSHORTHAND . '&nbsp;' : null;
                $timeSpentString ? $timeSpentString = _TIMESPENT . ': ' . $timeSpentString : null;
            }
            //The hidden span below the div is used in a js down() so as to know which question we are looking at
            $testString .= '
            		<div id = "question_' . $count . '" ' . (!$done && $this->options['onebyone'] ? 'style = "display:none"' : '') . '>
                    <span id = "question_content_' . $question->question['id'] . '" style = "display:none">' . $question->question['id'] . '</span>
                    <table width = "100%">
                        <tr><td class = "questionWeight" style = "vertical-align:middle;">
								<span style = "float:right">' . $timeSpentString . '</span>';
            if (!$isFeedback) {
                $testString .= '<img src = "images/32x32/' . ($done && ($this->options['show_score'] || $_SESSION['s_type'] != 'student') ? $image : 'unit.png') . '" style = "vertical-align:middle" alt = "' . ($done ? $alt : _QUESTION) . '" title = "' . ($done ? $title : _QUESTION) . '"/>&nbsp;';
            }
            $testString .= '<span style = "vertical-align:middle;font-weight:bold">' . _QUESTION . '&nbsp;' . $count++ . '</span>
                                ' . ($this->options['display_weights'] || $done && !$isFeedback ? '<span style = "vertical-align:middle;margin-left:10px">(' . _WEIGHT . '&nbsp;' . $weight . '%)</span>' : '') . '
                                ' . ($units[$question->question['content_ID']] && $done ? '<span style = "vertical-align:middle;margin-left:10px">' . _UNIT . ' "' . $units[$question->question['content_ID']] . '"</span>' : '') . '
								' . ($_SESSION['s_lesson_user_type'] == "student" && $currentLesson->options['content_report'] == 1 ? '<a href = "content_report.php?ctg=tests&edit_question=' . $question->question['id'] . '&question_type=' . $question->question['type'] . '&lessons_Id=' . $_SESSION['s_lessons_ID'] . '" onclick = "eF_js_showDivPopup(event, \'' . _CONTENTREPORT . '\', 1)" target = "POPUP_FRAME"><img src = "images/16x16/warning.png" border=0 style = "vertical-align:middle" alt = "' . _CONTENTREPORT . '" title = "' . _CONTENTREPORT . '"/></a>' : '') . '
								' . ($_SESSION['s_lesson_user_type'] == "professor" ? '<a href = "' . basename($_SERVER['PHP_SELF']) . '?ctg=tests&edit_question=' . $question->question['id'] . '&question_type=' . $question->question['type'] . '&lessonId=' . $currentLesson->lesson['id'] . '&return=' . urlencode($_SERVER['QUERY_STRING']) . '" style = "float:right;line-height:32px;"><img src = "images/16x16/edit.png" alt = "' . _EDIT . '" title = "' . _EDIT . '" style = "loat:right;vertical-align:middle"/></a>' : '') . '
							</td></tr>
                    </table>';
            if ($done) {
                if ($isFeedback) {
                    $showCorrectAnswers = false;
                } else {
                    if ($this->options['answers']) {
                        $showCorrectAnswers = true;
                    } else {
                        if ($this->options['show_answers_if_pass'] && ($this->completedTest['status'] == 'passed' || $this->completedTest['status'] == 'completed')) {
                            $showCorrectAnswers = true;
                        } else {
                            $showCorrectAnswers = false;
                        }
                    }
                }
                $questionString = $question->toHTMLSolved(new HTML_QuickForm(), $showCorrectAnswers, $this->options['given_answers']);
                $testString .= $questionString;
            } else {
                if (!empty($this->preview_correct)) {
                    $question->preview_correct = true;
                }
                $questionString = $question->toHTML($form);
                $testString .= $questionString;
            }
            $testString .= '<br/></div>';
            if ($done && !$isFeedback) {
                $testString .= '
                        <table style = "width:100%" >
                            <tr><td>
                                <span style = "font-weight:bold;" id = "question_' . $id . '_score_span">
                                    ' . ($this->options['show_score'] || $_SESSION['s_type'] != 'student' ? _SCORE . ': <span style = "vertical-align:middle" id = "question_' . $id . '_score">' . formatScore($question->score) . '%</span>' : '') . '
                                    ' . ($editHandles ? '<a href = "javascript:void(0)" onclick = "$(\'question_' . $id . '_score_span\').hide();$(\'edit_question_' . $id . '_score_span\').show();"><img src = "images/16x16/edit.png" title = "' . _CHANGESCORE . '" alt = "' . _CHANGESCORE . '"  style = "vertical-align:middle" border = "0"/></a>' : '') . '
                                    <span id = "question_' . $id . '_pending">' . ($question->pending ? '&nbsp;(' . _THISQUESTIONCORRECTEDPROFESSOR . ')' : '') . '</span>
                                </span>
                                <span id = "edit_question_' . $id . '_score_span" style = "display:none;">
                                    <input type = "text" name = "edit_question_' . $id . '_score" id = "edit_question_' . $id . '_score" value = "' . formatScore($question->score) . '" style = "vertical-align:middle"/>
                                    <a href = "javascript:void(0)" onclick = "editQuestionScore(this, ' . $id . ')">
                                        <img src = "images/16x16/success.png" alt = "' . _SUBMIT . '" title = "' . _SUBMIT . '" border = "0"  style = "vertical-align:middle"/>
                                    </a>
                                    <a href = "javascript:void(0)" onclick = "$(\'question_' . $id . '_score_span\').show();$(\'edit_question_' . $id . '_score_span\').hide();">
                                        <img src = "images/16x16/error_delete.png" alt = "' . _CANCEL . '" title = "' . _CANCEL . '" border = "0"  style = "vertical-align:middle"/>
                                    </a>
                                </span>';
                if ($this->options['show_score'] || $_SESSION['s_type'] != 'student') {
                    $testString .= '<span style = "border-left:1px solid black;margin-left:5px;padding-left:5px">' . _SCOREINTEST . ': <span id = "question_' . $id . '_score_coefficient">' . formatScore($question->score) . '</span>% &#215; ' . $weight . ' = <span id = "question_' . $id . '_scoreInTest">' . formatScore($question->scoreInTest) . '</span>%</span>';
                }
                if ($editHandles) {
                    $testString .= '
                            <span style = "border-left:1px solid black;margin-left:5px;padding-left:5px">';
                    if ($question->feedback) {
                        $testString .= '
                                            <img src = "images/16x16/edit.png" alt = "' . _EDITFEEDBACK . '" title = "' . _EDITFEEDBACK . '" border = "0" style = "vertical-align:middle">
                                            <a href = "javascript:void(0)" onclick = "$(\'question_' . $id . '_feedback_div\').toggle();$(\'edit_question_' . $id . '_feedback_div\').toggle()">' . _EDITFEEDBACK . '</a>';
                    } else {
                        $testString .= '
                                            <img src = "images/16x16/add.png" alt = "' . _ADDFEEDBACK . '" title = "' . _ADDFEEDBACK . '" border = "0" style = "vertical-align:middle">
                                            <a href = "javascript:void(0)" onclick = "$(\'question_' . $id . '_feedback_div\').toggle();$(\'edit_question_' . $id . '_feedback_div\').toggle()">' . _ADDFEEDBACK . '</a>';
                    }
                    $testString .= '
                        			</span>
                    			</td></tr>
                    			<tr><td>
                                    <div id = "question_' . $id . '_feedback_div" ' . ($question->feedback ? 'class = "feedback_test"' : '') . ' >
                                        <span id = "question_' . $id . '_feedback">' . $question->feedback . '</span>
                                    </div>
                                    <div id = "edit_question_' . $id . '_feedback_div" style = "display:none;">
                                        <textarea id = "edit_question_' . $id . '_feedback" style = "vertical-align:middle;width:90%;height:50px">' . $question->feedback . '</textarea>
                                        <a href = "javascript:void(0)" onclick = "editQuestionFeedback(this, ' . $id . ')" style = "vertical-align:middle">
                                            <img src = "images/16x16/success.png" alt = "' . _SUBMIT . '" title = "' . _SUBMIT . '" border = "0" style = "vertical-align:middle" />
                                        </a>
                                        <a href = "javascript:void(0)" onclick = "$(\'question_' . $id . '_feedback_div\').toggle();$(\'edit_question_' . $id . '_feedback_div\').toggle()">
                                            <img src = "images/16x16/error_delete.png" alt = "' . _CANCEL . '" title = "' . _CANCEL . '" border = "0" style = "vertical-align:middle" />
                                        </a>
                                    </div>
                            </td></tr>';
                } else {
                    $testString .= '
                                    <div id = "question_' . $id . '_feedback_div" ' . ($question->feedback ? 'class = "feedback_test"' : '') . ' >
                                        <span id = "question_' . $id . '_feedback">' . $question->feedback . '</span>
                                    </div>';
                }
                $testString .= '
                            </table><br/>';
            }
        }
        if (!$done && $this->options['onebyone']) {
            if (!empty($GLOBALS['rtl'])) {
                $next_question_handle = 'arrow_left.png';
                $previous_question_handle = 'arrow_right.png';
            } else {
                $next_question_handle = 'arrow_right.png';
                $previous_question_handle = 'arrow_left.png';
            }
            $testString .= '
	                        <table width = "100%">
	                            <tr><td style = "text-align:center;vertical-align:middle;padding-top:50px">
	                                <img src = "images/32x32/' . $previous_question_handle . '"  alt = "' . _PREVIOUSQUESTION . '" title = "' . _PREVIOUSQUESTION . '" border = "0" id = "previous_question_button" onclick = "showTestQuestion(\'previous\')" style = "vertical-align:middle;margin-right:10px;' . ($this->options['only_forward'] ? 'visibility:hidden' : '') . '" />
	                                <select id = "goto_question" name = "goto_question" style = "vertical-align:middle;' . ($this->options['only_forward'] ? 'display:none' : '') . '" onchange = "showTestQuestion(this.options[this.selectedIndex].value)">';
            for ($i = 1; $i <= sizeof($testQuestions); $i++) {
                $testString .= '
	                                    <option value = "' . $i . '">' . $i . '</option>';
            }
            $testString .= '
	                                </select>&nbsp;
	                                <img src = "images/32x32/' . $next_question_handle . '" alt = "' . _NEXTQUESTION . '" title = "' . _NEXTQUESTION . '" border = "0" id = "next_question_button" onclick = "showTestQuestion(\'next\')" style = "vertical-align:middle"/>
	                            </td></tr>
	                        </table>';
            $testString .= "\r\n                        <script>\r\n                            var total_questions  = " . sizeof($testQuestions) . ";\r\n                            var current_question = " . ($this->currentQuestion ? $this->currentQuestion : 1) . ";\r\n                            //showTestQuestion(current_question);\r\n                        </script>";
        }
        if (sizeof($this->questions) > 0) {
            if ($this->options['answer_all']) {
                $testString .= "\r\n\t\t\t\t<script>\r\n\t\t\t\tvar force_answer_all  = 1;\r\n            \ttranslations['youhavenotcompletedquestions'] = '" . _YOUHAVENOTCOMPLETEDTHEFOLLOWINGQUESTIONS . "';\r\n            \ttranslations['youhavetoanswerallquestions'] = '" . _YOUHAVETOANSWERALLQUESTIONS . "';</script>";
            } else {
                $testString .= "\r\n\t\t\t\t<script>\r\n\t\t\t\tvar force_answer_all  = 0;\r\n            \ttranslations['youhavenotcompletedquestions'] = '" . _YOUHAVENOTCOMPLETEDTHEFOLLOWINGQUESTIONS . "';\r\n            \ttranslations['areyousureyouwanttosubmittest'] = '" . _AREYOUSUREYOUWANTTOSUBMITTEST . "';</script>";
            }
        }
        /*
                if ($this -> options['shuffle_questions'] && !$form -> isSubmitted()) {
                    $form -> addElement("hidden", "answers_order", serialize($shuffleOrder));       //The questions' answers order is hold at a hidden element, so that it can be stored when the test is complete
                }
        */
        if ($storeCache) {
            EfrontCache::getInstance()->setCache('test:' . $this->test['id'], $testString);
        }
        return $testString;
    }
Пример #8
0
            EfrontConfiguration::setValue('logo_timestamp', time());
            // to avoid browser caching when changing logo dimensions
            EfrontCache::getInstance()->deleteCache('logo');
            eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=appearance&tab=logo&message=" . urlencode(_SUCCESFULLYUPDATECONFIGURATION) . "&message_type=success");
        } catch (Exception $e) {
            handleNormalFlowExceptions($e);
        }
    }
}
$smarty->assign("T_APPEARANCE_LOGO_FORM", $appearanceLogoForm->toArray());
$appearanceFaviconForm = new Html_QuickForm("appearance_favicon_form", "post", basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=appearance&tab=favicon", "", null, true);
$appearanceFaviconForm->registerRule('checkParameter', 'callback', 'eF_checkParameter');
$appearanceFaviconForm->addElement('file', 'favicon', _FILENAME);
$appearanceFaviconForm->addElement("static", "", _EACHFILESIZEMUSTBESMALLERTHAN . ' <b>' . FileSystemTree::getUploadMaxSize() . '</b> ' . _KB);
$appearanceFaviconForm->addElement("advcheckbox", "default_favicon", _USEDEFAULTFAVICON, null, 'class = "inputCheckBox"  id = "set_default_favicon" onclick = "$(\'favicon_settings\').select(\'input\').each(function(s) {if (s.type != \'submit\' && s.id != \'set_default_favicon\') s.disabled ? s.disabled = \'\' : s.disabled = \'disabled\' })"', array(0, 1));
$appearanceFaviconForm->setMaxFileSize(FileSystemTree::getUploadMaxSize() * 1024);
if (isset($currentUser->coreAccess['configuration']) && $currentUser->coreAccess['configuration'] != 'change') {
    $appearanceFaviconForm->freeze();
} else {
    $appearanceFaviconForm->addElement("submit", "submit", _SAVE, 'class = "flatButton"');
    if ($appearanceFaviconForm->isSubmitted() && $appearanceFaviconForm->validate()) {
        try {
            //If the form is submitted and validated
            if ($appearanceFaviconForm->exportValue('default_favicon')) {
                EfrontConfiguration::setValue('favicon', '');
            } else {
                $faviconDirectory = new EfrontDirectory(G_LOGOPATH);
                $filesystem = new FileSystemTree(G_LOGOPATH);
                try {
                    $faviconFile = $filesystem->uploadFile('favicon', $logoDirectory);
                    if (strpos($faviconFile['mime_type'], 'image') === false) {
Пример #9
0
 $generalPHPForm->addElement("submit", "submit", _SAVE, 'class = "flatButton"');
 if ($generalPHPForm->isSubmitted() && $generalPHPForm->validate()) {
     //If the form is submitted and validated
     $values = $generalPHPForm->exportValues();
     unset($values['submit']);
     if ($GLOBALS['configuration']['version_hosted']) {
         unset($values['memory_limit']);
         unset($values['max_execution_time']);
     }
     foreach ($values as $key => $value) {
         if ($value == '') {
             if ($key == 'memory_limit' || $key == 'max_execution_time') {
                 ini_restore($key);
                 EfrontConfiguration::setValue($key, str_ireplace("M", "", ini_get($key)));
             } elseif ($key == 'max_file_size') {
                 EfrontConfiguration::setValue($key, FileSystemTree::getUploadMaxSize());
             } else {
                 EfrontConfiguration::deleteValue($key);
             }
         } else {
             if ($key == 'memory_limit' || $key == 'max_execution_time') {
                 //You can't set these values below the php.ini setting
                 ini_restore($key);
                 EfrontConfiguration::setValue($key, $value);
             } else {
                 EfrontConfiguration::setValue($key, $value);
             }
         }
     }
     eF_redirect(basename($_SERVER['PHP_SELF']) . "?ctg=system_config&op=general&tab=php&message=" . urlencode(_SUCCESFULLYUPDATECONFIGURATION) . "&message_type=success");
 }