Example #1
0
 /**
  * @param FormValidator $form
  * @param null $objExercise
  * @return bool
  */
 public function processCreation($form, $objExercise = null)
 {
     $file_info = $form->getSubmitValue('imageUpload');
     $_course = api_get_course_info();
     parent::processCreation($form, $objExercise);
     if (!empty($file_info['tmp_name'])) {
         $this->uploadPicture($file_info['tmp_name'], $file_info['name']);
         $documentPath = api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document';
         $picturePath = $documentPath . '/images';
         // fixed width ang height
         if (file_exists($picturePath . '/' . $this->picture)) {
             $this->resizePicture('width', 800);
             $this->save();
         } else {
             return false;
         }
     }
 }
 /**
  * abstract function which creates the form to create/edit the answers of the question
  * @param FormValidator $form
  */
 function processAnswersCreation($form)
 {
     $this->weighting = $form->getSubmitValue('weighting');
     $this->save();
 }
 /**
  * abstract function which creates the form to create / edit the answers of the question
  * @param FormValidator $form
  */
 function processAnswersCreation($form)
 {
     if (!self::isAnswered()) {
         $table = Database::get_course_table(TABLE_QUIZ_ANSWER);
         Database::delete($table, array('c_id = ? AND question_id = ?' => array($this->course['real_id'], $this->id)));
         $answer = $form->getSubmitValue('answer');
         $formula = $form->getSubmitValue('formula');
         $lowestValues = $form->getSubmitValue('lowestValue');
         $highestValues = $form->getSubmitValue('highestValue');
         $answerVariations = $form->getSubmitValue('answerVariations');
         $this->weighting = $form->getSubmitValue('weighting');
         // Create as many answers as $answerVariations
         for ($j = 0; $j < $answerVariations; $j++) {
             $auxAnswer = $answer;
             $auxFormula = $formula;
             $nb = preg_match_all('/\\[[^\\]]*\\]/', $auxAnswer, $blanks);
             if ($nb > 0) {
                 for ($i = 0; $i < $nb; ++$i) {
                     $blankItem = $blanks[0][$i];
                     $replace = array("[", "]");
                     $newBlankItem = str_replace($replace, "", $blankItem);
                     $newBlankItem = "[" . trim($newBlankItem) . "]";
                     // take random float values when one or both edge values have a decimal point
                     $randomValue = strpos($lowestValues[$i], '.') !== false || strpos($highestValues[$i], '.') !== false ? mt_rand($lowestValues[$i] * 100, $highestValues[$i] * 100) / 100 : mt_rand($lowestValues[$i], $highestValues[$i]);
                     $auxAnswer = str_replace($blankItem, $randomValue, $auxAnswer);
                     $auxFormula = str_replace($blankItem, $randomValue, $auxFormula);
                 }
                 $math = new EvalMath();
                 $result = $math->evaluate($auxFormula);
                 $result = number_format($result, 2, ".", "");
                 // Remove decimal trailing zeros
                 $result = rtrim($result, "0");
                 // If it is an integer (ends in .00) remove the decimal point
                 if (mb_substr($result, -1) === ".") {
                     $result = str_replace(".", "", $result);
                 }
                 // Attach formula
                 $auxAnswer .= " [" . $result . "]@@" . $formula;
             }
             $this->save();
             $objAnswer = new Answer($this->id);
             $objAnswer->createAnswer($auxAnswer, 1, '', $this->weighting, '');
             $objAnswer->position = array();
             $objAnswer->save();
         }
     }
 }
 /**
  * abstract function which creates the form to create/edit the answers of the question
  * @param FormValidator $form
  */
 public function processAnswersCreation($form)
 {
     $questionWeighting = $nbrGoodAnswers = 0;
     $objAnswer = new Answer($this->id);
     $nb_answers = $form->getSubmitValue('nb_answers');
     for ($i = 1; $i <= $nb_answers; $i++) {
         $answer = trim($form->getSubmitValue('answer[' . $i . ']'));
         $comment = trim($form->getSubmitValue('comment[' . $i . ']'));
         if ($i == 1) {
             $weighting = trim($form->getSubmitValue('weighting[' . $i . ']'));
         } else {
             $weighting = 0;
         }
         $goodAnswer = trim($form->getSubmitValue('correct[' . $i . ']'));
         if ($goodAnswer) {
             $weighting = abs($weighting);
         } else {
             $weighting = abs($weighting);
             //	$weighting = -$weighting;
         }
         if ($weighting > 0) {
             $questionWeighting += $weighting;
         }
         $objAnswer->createAnswer($answer, $goodAnswer, $comment, $weighting, $i);
     }
     // saves the answers into the data base
     $objAnswer->save();
     // sets the total weighting of the question
     $this->updateWeighting($questionWeighting);
     $this->save();
 }
 /**
  * function which process the creation of exercises
  * @param FormValidator $form the formvalidator instance
  */
 function processCreation($form, $type = '')
 {
     $values = $form->exportValues();
     $this->updateTitle($form->getSubmitValue('exerciseTitle'));
     $this->updateDescription($form->getSubmitValue('exerciseDescription'));
     $this->updateAttempts($form->getSubmitValue('exerciseAttempts'));
     $this->updateFeedbackType($form->getSubmitValue('exerciseFeedbackType'));
     $this->updateType($form->getSubmitValue('exerciseType'));
     $this->setRandom($form->getSubmitValue('randomQuestions'));
     $this->updateRandomAnswers($form->getSubmitValue('randomAnswers'));
     $this->updateResultsDisabled($form->getSubmitValue('results_disabled'));
     $this->updateExpiredTime($form->getSubmitValue('enabletimercontroltotalminutes'));
     $this->updatePropagateNegative($form->getSubmitValue('propagate_neg'));
     $this->updateRandomByCat($form->getSubmitValue('randomByCat'));
     $this->updateTextWhenFinished($form->getSubmitValue('text_when_finished'));
     $this->updateDisplayCategoryName($form->getSubmitValue('display_category_name'));
     $this->updateReviewAnswers($form->getSubmitValue('review_answers'));
     $this->updatePassPercentage($form->getSubmitValue('pass_percentage'));
     $this->updateCategories($form->getSubmitValue('category'));
     $this->updateEndButton($form->getSubmitValue('end_button'));
     $this->updateEmailNotificationTemplate($form->getSubmitValue('email_notification_template'));
     $this->setModelType($form->getSubmitValue('model_type'));
     $this->setQuestionSelectionType($form->getSubmitValue('question_selection_type'));
     $this->setHideQuestionTitle($form->getSubmitValue('hide_question_title'));
     var_dump($values);
     $this->setScoreTypeModel($form->getSubmitValue('score_type_model'));
     $this->setGlobalCategoryId($form->getSubmitValue('global_category_id'));
     if ($form->getSubmitValue('activate_start_date_check') == 1) {
         $start_time = $form->getSubmitValue('start_time');
         $start_time['F'] = sprintf('%02d', $start_time['F']);
         $start_time['i'] = sprintf('%02d', $start_time['i']);
         $start_time['d'] = sprintf('%02d', $start_time['d']);
         $this->start_time = $start_time['Y'] . '-' . $start_time['F'] . '-' . $start_time['d'] . ' ' . $start_time['H'] . ':' . $start_time['i'] . ':00';
     } else {
         $this->start_time = '0000-00-00 00:00:00';
     }
     if ($form->getSubmitValue('activate_end_date_check') == 1) {
         $end_time = $form->getSubmitValue('end_time');
         $end_time['F'] = sprintf('%02d', $end_time['F']);
         $end_time['i'] = sprintf('%02d', $end_time['i']);
         $end_time['d'] = sprintf('%02d', $end_time['d']);
         $this->end_time = $end_time['Y'] . '-' . $end_time['F'] . '-' . $end_time['d'] . ' ' . $end_time['H'] . ':' . $end_time['i'] . ':00';
     } else {
         $this->end_time = '0000-00-00 00:00:00';
     }
     if ($form->getSubmitValue('enabletimercontrol') == 1) {
         $expired_total_time = $form->getSubmitValue('enabletimercontroltotalminutes');
         if ($this->expired_time == 0) {
             $this->expired_time = $expired_total_time;
         }
     } else {
         $this->expired_time = 0;
     }
     if ($form->getSubmitValue('randomAnswers') == 1) {
         $this->random_answers = 1;
     } else {
         $this->random_answers = 0;
     }
     $this->save($type);
 }
Example #6
0
    if (count($a_sessions) > 0) {
        $actionsRight = Display::url(Display::return_icon('printer.png', get_lang('Print'), array(), 32), 'javascript: void(0);', array('onclick' => 'javascript: window.print();'));
        $actionsRight .= Display::url(Display::return_icon('export_csv.png', get_lang('ExportAsCSV'), array(), 32), api_get_self() . '?export=csv');
    }
    $toolbar = Display::toolbarAction('toolbar-session', $content = array(0 => $actionsLeft, 1 => $actionsRight));
    echo $toolbar;
    echo Display::page_header(get_lang('YourSessionsList'));
} else {
    $a_sessions = Tracking::get_sessions_coached_by_user($id_coach);
}
$form = new FormValidator('search_course', 'get', api_get_path(WEB_CODE_PATH) . 'mySpace/session.php');
$form->addElement('text', 'keyword', get_lang('Keyword'));
$form->addButtonSearch(get_lang('Search'));
$keyword = '';
if ($form->validate()) {
    $keyword = $form->getSubmitValue('keyword');
}
$form->setDefaults(array('keyword' => $keyword));
$url = api_get_path(WEB_AJAX_PATH) . 'model.ajax.php?a=get_sessions_tracking&keyword=' . Security::remove_XSS($keyword);
$columns = array(get_lang('Title'), get_lang('Date'), get_lang('NbCoursesPerSession'), get_lang('NbStudentPerSession'), get_lang('Details'));
// Column config
$columnModel = array(array('name' => 'name', 'index' => 'name', 'width' => '255', 'align' => 'left'), array('name' => 'date', 'index' => 'date', 'width' => '150', 'align' => 'left', 'sortable' => 'false'), array('name' => 'course_per_session', 'index' => 'course_per_session', 'width' => '150', 'sortable' => 'false'), array('name' => 'student_per_session', 'index' => 'student_per_session', 'width' => '100', 'sortable' => 'false'), array('name' => 'details', 'index' => 'details', 'width' => '100', 'sortable' => 'false'));
$extraParams = array('autowidth' => 'true', 'height' => 'auto');
$js = '<script>
    $(function() {
        ' . Display::grid_js('session_tracking', $url, $columns, $columnModel, $extraParams, array(), null, true) . '
    });
</script>';
echo $js;
$form->display();
echo Display::grid_html('session_tracking');
 /**
  * Function which creates the form to create/edit the answers of the question
  * @param FormValidator $form
  */
 public function processAnswersCreation($form)
 {
     $answer = $form->getSubmitValue('answer');
     // Due the ckeditor transform the elements to their HTML value
     //$answer = api_html_entity_decode($answer, ENT_QUOTES, $charset);
     //$answer = htmlentities(api_utf8_encode($answer));
     // remove the :: eventually written by the user
     $answer = str_replace('::', '', $answer);
     // remove starting and ending space and &nbsp;
     $answer = api_preg_replace("/ /", " ", $answer);
     // start and end separator
     $blankStartSeparator = self::getStartSeparator($form->getSubmitValue('select_separator'));
     $blankEndSeparator = self::getEndSeparator($form->getSubmitValue('select_separator'));
     $blankStartSeparatorRegexp = self::escapeForRegexp($blankStartSeparator);
     $blankEndSeparatorRegexp = self::escapeForRegexp($blankEndSeparator);
     // remove spaces at the beginning and the end of text in square brackets
     $answer = preg_replace_callback("/" . $blankStartSeparatorRegexp . "[^]]+" . $blankEndSeparatorRegexp . "/", function ($matches) use($blankStartSeparator, $blankEndSeparator) {
         $matchingResult = $matches[0];
         $matchingResult = trim($matchingResult, $blankStartSeparator);
         $matchingResult = trim($matchingResult, $blankEndSeparator);
         $matchingResult = trim($matchingResult);
         // remove forbidden chars
         $matchingResult = str_replace("/\\/", "", $matchingResult);
         $matchingResult = str_replace('/"/', "", $matchingResult);
         return $blankStartSeparator . $matchingResult . $blankEndSeparator;
     }, $answer);
     // get the blanks weightings
     $nb = preg_match_all('/' . $blankStartSeparatorRegexp . '[^' . $blankStartSeparatorRegexp . ']*' . $blankEndSeparatorRegexp . '/', $answer, $blanks);
     if (isset($_GET['editQuestion'])) {
         $this->weighting = 0;
     }
     /* if we have some [tobefound] in the text
        build the string to save the following in the answers table
        <p>I use a [computer] and a [pen].</p>
        becomes
        <p>I use a [computer] and a [pen].</p>::100,50:100,50@1
            ++++++++-------**
            --- -- --- -- -
            A B  (C) (D)(E)
        +++++++ : required, weighting of each words
        ------- : optional, input width to display, 200 if not present
        ** : equal @1 if "Allow answers order switches" has been checked, @ otherwise
        A : weighting for the word [computer]
        B : weighting for the word [pen]
        C : input width for the word [computer]
        D : input width for the word [pen]
        E : equal @1 if "Allow answers order switches" has been checked, @ otherwise
        */
     if ($nb > 0) {
         $answer .= '::';
         // weighting
         for ($i = 0; $i < $nb; ++$i) {
             // enter the weighting of word $i
             $answer .= $form->getSubmitValue('weighting[' . $i . ']');
             // not the last word, add ","
             if ($i != $nb - 1) {
                 $answer .= ",";
             }
             // calculate the global weighting for the question
             $this->weighting += $form->getSubmitValue('weighting[' . $i . ']');
         }
         // input width
         $answer .= ":";
         for ($i = 0; $i < $nb; ++$i) {
             // enter the width of input for word $i
             $answer .= $form->getSubmitValue('sizeofinput[' . $i . ']');
             // not the last word, add ","
             if ($i != $nb - 1) {
                 $answer .= ",";
             }
         }
     }
     // write the blank separator code number
     // see function getAllowedSeparator
     /*
        0 [...]
        1 {...}
        2 (...)
        3 *...*
        4 #...#
        5 %...%
        6 $...$
     */
     $answer .= ":" . $form->getSubmitValue('select_separator');
     // Allow answers order switches
     $is_multiple = $form->getSubmitValue('multiple_answer');
     $answer .= '@' . $is_multiple;
     $this->save();
     $objAnswer = new Answer($this->id);
     $objAnswer->createAnswer($answer, 0, '', 0, 1);
     $objAnswer->save();
 }
 /**
  * Receives the unique answer question type creation form data and creates
  * or updates the answers from that question
  * @param FormValidator $form
  */
 public function processAnswersCreation($form)
 {
     $questionWeighting = $nbrGoodAnswers = 0;
     $correct = $form->getSubmitValue('correct');
     $objAnswer = new Answer($this->id);
     $nb_answers = $form->getSubmitValue('nb_answers');
     for ($i = 1; $i <= $nb_answers; $i++) {
         $answer = trim($form->getSubmitValue('answer[' . $i . ']'));
         $comment = trim($form->getSubmitValue('comment[' . $i . ']'));
         $weighting = trim($form->getSubmitValue('weighting[' . $i . ']'));
         $scenario = $form->getSubmitValue('scenario');
         //$list_destination = $form -> getSubmitValue('destination'.$i);
         //$destination_str = $form -> getSubmitValue('destination'.$i);
         $try = $scenario['try' . $i];
         $lp = $scenario['lp' . $i];
         $destination = $scenario['destination' . $i];
         $url = trim($scenario['url' . $i]);
         /*
                     How we are going to parse the destination value
         
                    here we parse the destination value which is a string
                     1@@3@@2;4;4;@@http://www.chamilo.org
         
                     where: try_again@@lp_id@@selected_questions@@url
         
                    try_again = is 1 || 0
                    lp_id = id of a learning path (0 if dont select)
                    selected_questions= ids of questions
                    url= an url
         
                     $destination_str='';
                     foreach ($list_destination as $destination_id)
                     {
                         $destination_str.=$destination_id.';';
                     }*/
         $goodAnswer = $correct == $i ? true : false;
         if ($goodAnswer) {
             $nbrGoodAnswers++;
             $weighting = abs($weighting);
             if ($weighting > 0) {
                 $questionWeighting += $weighting;
             }
         }
         if (empty($try)) {
             $try = 0;
         }
         if (empty($lp)) {
             $lp = 0;
         }
         if (empty($destination)) {
             $destination = 0;
         }
         if ($url == '') {
             $url = 0;
         }
         //1@@1;2;@@2;4;4;@@http://www.chamilo.org
         $dest = $try . '@@' . $lp . '@@' . $destination . '@@' . $url;
         $objAnswer->createAnswer($answer, $goodAnswer, $comment, $weighting, $i, null, null, $dest);
     }
     // saves the answers into the data base
     $objAnswer->save();
     // sets the total weighting of the question
     $this->updateWeighting($questionWeighting);
     $this->save();
 }
Example #9
0
 * @package chamilo.gradebook
 */
use ChamiloSession as Session;
$cidReset = true;
require_once '../inc/global.inc.php';
if (api_get_setting('allow_public_certificates') != 'true') {
    api_not_allowed(true, Display::return_message(get_lang('CertificatesNotPublic'), 'warning'));
}
$userId = isset($_GET['id']) ? intval($_GET['id']) : 0;
$userList = $userInfo = $courseList = $sessionList = [];
$searchForm = new FormValidator('search_form', 'post', null, null);
$searchForm->addText('firstname', get_lang('FirstName'));
$searchForm->addText('lastname', get_lang('LastName'));
$searchForm->addButtonSearch();
if ($searchForm->validate()) {
    $firstname = $searchForm->getSubmitValue('firstname');
    $lastname = $searchForm->getSubmitValue('lastname');
    $userList = UserManager::getUserByName($firstname, $lastname);
    if (empty($userList)) {
        Display::addFlash(Display::return_message(get_lang('NoResults'), 'warning'));
        header('Location: ' . api_get_self());
        exit;
    }
} elseif ($userId > 0) {
    $userInfo = api_get_user_info($userId);
    if (empty($userInfo)) {
        Display::addFlash(Display::return_message(get_lang('NoUser'), 'warning'));
        header('Location: ' . api_get_self());
        exit;
    }
    $courseList = GradebookUtils::getUserCertificatesInCourses($userId, false);
Example #10
0
            $urlToRedirect .= http_build_query(['status' => BuyCoursesPlugin::SALE_STATUS_CANCELED, 'sale' => $sale['id']]);
            break;
    }
    header("Location: {$urlToRedirect}");
    exit;
}
$productTypes = $plugin->getProductTypes();
$saleStatuses = $plugin->getSaleStatuses();
$paymentTypes = $plugin->getPaymentTypes();
$selectedFilterType = '0';
$selectedStatus = isset($_GET['status']) ? $_GET['status'] : BuyCoursesPlugin::SALE_STATUS_PENDING;
$selectedSale = isset($_GET['sale']) ? intval($_GET['sale']) : 0;
$searchTerm = '';
$form = new FormValidator('search', 'get');
if ($form->validate()) {
    $selectedFilterType = $form->getSubmitValue('filter_type');
    $selectedStatus = $form->getSubmitValue('status');
    $searchTerm = $form->getSubmitValue('user');
    if ($selectedStatus === false) {
        $selectedStatus = BuyCoursesPlugin::SALE_STATUS_PENDING;
    }
    if ($selectedFilterType === false) {
        $selectedFilterType = '0';
    }
}
$form->addRadio('filter_type', get_lang('Filter'), [$plugin->get_lang('ByStatus'), $plugin->get_lang('ByUser')]);
$form->addHtml('<div id="report-by-status" ' . ($selectedFilterType !== '0' ? 'style="display:none"' : '') . '>');
$form->addSelect('status', $plugin->get_lang('OrderStatus'), $saleStatuses);
$form->addHtml('</div>');
$form->addHtml('<div id="report-by-user" ' . ($selectedFilterType !== '1' ? 'style="display:none"' : '') . '>');
$form->addText('user', get_lang('UserName'), false);
Example #11
0
$help_name = isset($_GET['open']) ? Security::remove_XSS($_GET['open']) : null;
Display::display_header(get_lang('Faq'));
if (api_is_platform_admin()) {
    echo '&nbsp;<a href="faq.php?edit=true"><img src="' . api_get_path(WEB_IMG_PATH) . 'edit.png" /></a>';
}
echo Display::page_header(get_lang('Faq'));
$faq_file = 'faq.html';
if (!empty($_GET['edit']) && $_GET['edit'] == 'true' && api_is_platform_admin()) {
    $form = new FormValidator('set_faq', 'post', 'faq.php?edit=true');
    $form->addHtmlEditor('faq_content', null, false, false, array('ToolbarSet' => 'FAQ', 'Width' => '100%', 'Height' => '300'));
    $form->addButtonSave(get_lang('Ok'), 'faq_submit');
    $faq_content = @(string) file_get_contents(api_get_path(SYS_APP_PATH) . 'home/faq.html');
    $faq_content = api_to_system_encoding($faq_content, api_detect_encoding(strip_tags($faq_content)));
    $form->setDefaults(array('faq_content' => $faq_content));
    if ($form->validate()) {
        $content = $form->getSubmitValue('faq_content');
        $fpath = api_get_path(SYS_APP_PATH) . 'home/' . $faq_file;
        if (is_file($fpath) && is_writeable($fpath)) {
            $fp = fopen(api_get_path(SYS_APP_PATH) . 'home/' . $faq_file, 'w');
            fwrite($fp, $content);
            fclose($fp);
        } else {
            Display::display_warning_message(get_lang('WarningFaqFileNonWriteable'));
        }
        echo $content;
    } else {
        $form->display();
    }
} else {
    $faq_content = @(string) file_get_contents(api_get_path(SYS_APP_PATH) . 'home/' . $faq_file);
    $faq_content = api_to_system_encoding($faq_content, api_detect_encoding(strip_tags($faq_content)));
 /**
  * abstract function which creates the form to create / edit the answers of the question
  * @param FormValidator $form
  */
 public function processAnswersCreation($form)
 {
     $questionWeighting = $nbrGoodAnswers = 0;
     $objAnswer = new Answer($this->id);
     $nb_answers = $form->getSubmitValue('nb_answers');
     $options_count = $form->getSubmitValue('options_count');
     $course_id = api_get_course_int_id();
     $correct = array();
     $options = Question::readQuestionOption($this->id, $course_id);
     if (!empty($options)) {
         foreach ($options as $option_data) {
             $id = $option_data['id'];
             unset($option_data['id']);
             Question::updateQuestionOption($id, $option_data, $course_id);
         }
     } else {
         for ($i = 1; $i <= 3; $i++) {
             $last_id = Question::saveQuestionOption($this->id, $this->options[$i], $course_id, $i);
             $correct[$i] = $last_id;
         }
     }
     /* Getting quiz_question_options (true, false, doubt) because
        it's possible that there are more options in the future */
     $new_options = Question::readQuestionOption($this->id, $course_id);
     $sorted_by_position = array();
     foreach ($new_options as $item) {
         $sorted_by_position[$item['position']] = $item;
     }
     /* Saving quiz_question.extra values that has the correct scores of
        the true, false, doubt options registered in this format
        XX:YY:ZZZ where XX is a float score value.*/
     $extra_values = array();
     for ($i = 1; $i <= 3; $i++) {
         $score = trim($form->getSubmitValue('option[' . $i . ']'));
         $extra_values[] = $score;
     }
     $this->setExtra(implode(':', $extra_values));
     for ($i = 1; $i <= $nb_answers; $i++) {
         $answer = trim($form->getSubmitValue('answer[' . $i . ']'));
         $comment = trim($form->getSubmitValue('comment[' . $i . ']'));
         $goodAnswer = trim($form->getSubmitValue('correct[' . $i . ']'));
         if (empty($options)) {
             //If this is the first time that the question is created when
             // change the default values from the form 1 and 2 by the correct "option id" registered
             $goodAnswer = $sorted_by_position[$goodAnswer]['id'];
         }
         $questionWeighting += $extra_values[0];
         //By default 0 has the correct answers
         $objAnswer->createAnswer($answer, $goodAnswer, $comment, '', $i);
     }
     // saves the answers into the data base
     $objAnswer->save();
     // sets the total weighting of the question
     $this->updateWeighting($questionWeighting);
     $this->save();
 }
Example #13
0
    } else {
        $endDateInSeconds = $firstAccess + $duration * 24 * 60 * 60;
        $last = api_convert_and_format_date($endDateInSeconds, DATE_FORMAT_SHORT);
        $msg = sprintf(get_lang('FirstAccessWasXSessionDurationYEndDateWasZ'), $firstAccessString, $duration, $last);
    }
}
$form->addElement('html', sprintf(get_lang('UserXSessionY'), $userInfo['complete_name'], $sessionInfo['name']));
$form->addElement('html', '<br>');
$form->addElement('html', $msg);
$form->addElement('text', 'duration', array(get_lang('ExtraDurationForUser'), null, get_lang('Days')));
$form->addElement('button', 'submit', get_lang('Send'));
if (empty($data['duration'])) {
    $data['duration'] = 0;
}
$form->setDefaults($data);
$message = null;
if ($form->validate()) {
    $duration = $form->getSubmitValue('duration');
    // Only update if the duration is different from the default duration
    if ($duration != 0) {
        SessionManager::editUserSessionDuration($duration, $userId, $sessionId);
        $message = Display::return_message(get_lang('ItemUpdated'), 'confirmation');
    } else {
        $message = Display::return_message(get_lang('DurationIsSameAsDefault'), 'warning');
    }
}
// display the header
Display::display_header(get_lang('Edit'));
echo $message;
$form->display();
Display::display_footer();
 /**
  * function which process the creation of questions
  * @param FormValidator $form
  * @param Exercise $objExercise
  */
 public function processCreation($form, $objExercise = null)
 {
     $this->updateTitle($form->getSubmitValue('questionName'));
     $this->updateDescription($form->getSubmitValue('questionDescription'));
     $this->updateLevel($form->getSubmitValue('questionLevel'));
     $this->updateCategory($form->getSubmitValue('questionCategory'));
     //Save normal question if NOT media
     if ($this->type != MEDIA_QUESTION) {
         $this->save($objExercise->id);
         // modify the exercise
         $objExercise->addToList($this->id);
         $objExercise->update_question_positions();
     }
 }
 /**
  * abstract function which creates the form to create / edit the answers of the question
  * @param FormValidator $form
  */
 function processAnswersCreation($form)
 {
     global $charset;
     $answer = $form->getSubmitValue('answer');
     //remove the :: eventually written by the user
     $answer = str_replace('::', '', $answer);
     // get the blanks weightings
     $nb = preg_match_all('/\\[[^\\]]*\\]/', $answer, $blanks);
     if (isset($_GET['editQuestion'])) {
         $this->weighting = 0;
     }
     if ($nb > 0) {
         $answer .= '::';
         for ($i = 0; $i < $nb; ++$i) {
             $blankItem = $blanks[0][$i];
             $replace = array("[", "]");
             $newBlankItem = str_replace($replace, "", $blankItem);
             $newBlankItem = "[" . trim($newBlankItem) . "]";
             $answer = str_replace($blankItem, $newBlankItem, $answer);
             $answer .= $form->getSubmitValue('weighting[' . $i . ']') . ',';
             $this->weighting += $form->getSubmitValue('weighting[' . $i . ']');
         }
         $answer = api_substr($answer, 0, -1);
     }
     $is_multiple = $form->getSubmitValue('multiple_answer');
     $answer .= '@' . $is_multiple;
     $this->save();
     $objAnswer = new answer($this->id);
     $objAnswer->createAnswer($answer, 0, '', 0, '1');
     $objAnswer->save();
 }
 /**
  * function which process the creation of exercises
  * @param FormValidator $form
  * @param string
  */
 function processCreation($form, $type = '')
 {
     $this->updateTitle(Exercise::format_title_variable($form->getSubmitValue('exerciseTitle')));
     $this->updateDescription($form->getSubmitValue('exerciseDescription'));
     $this->updateAttempts($form->getSubmitValue('exerciseAttempts'));
     $this->updateFeedbackType($form->getSubmitValue('exerciseFeedbackType'));
     $this->updateType($form->getSubmitValue('exerciseType'));
     $this->setRandom($form->getSubmitValue('randomQuestions'));
     $this->updateRandomAnswers($form->getSubmitValue('randomAnswers'));
     $this->updateResultsDisabled($form->getSubmitValue('results_disabled'));
     $this->updateExpiredTime($form->getSubmitValue('enabletimercontroltotalminutes'));
     $this->updatePropagateNegative($form->getSubmitValue('propagate_neg'));
     $this->updateRandomByCat($form->getSubmitValue('randomByCat'));
     $this->updateTextWhenFinished($form->getSubmitValue('text_when_finished'));
     $this->updateDisplayCategoryName($form->getSubmitValue('display_category_name'));
     $this->updateReviewAnswers($form->getSubmitValue('review_answers'));
     $this->updatePassPercentage($form->getSubmitValue('pass_percentage'));
     if ($form->getSubmitValue('activate_start_date_check') == 1) {
         $start_time = $form->getSubmitValue('start_time');
         $this->start_time = api_get_utc_datetime($start_time);
     } else {
         $this->start_time = '0000-00-00 00:00:00';
     }
     if ($form->getSubmitValue('activate_end_date_check') == 1) {
         $end_time = $form->getSubmitValue('end_time');
         $this->end_time = api_get_utc_datetime($end_time);
     } else {
         $this->end_time = '0000-00-00 00:00:00';
     }
     if ($form->getSubmitValue('enabletimercontrol') == 1) {
         $expired_total_time = $form->getSubmitValue('enabletimercontroltotalminutes');
         if ($this->expired_time == 0) {
             $this->expired_time = $expired_total_time;
         }
     } else {
         $this->expired_time = 0;
     }
     if ($form->getSubmitValue('randomAnswers') == 1) {
         $this->random_answers = 1;
     } else {
         $this->random_answers = 0;
     }
     $this->save($type);
 }
 /**
  * abstract function which creates the form to create / edit the answers of the question
  * @param FormValidator $form
  */
 public function processAnswersCreation($form)
 {
     $nb_matches = $form->getSubmitValue('nb_matches');
     $nb_options = $form->getSubmitValue('nb_options');
     $this->weighting = 0;
     $position = 0;
     $objAnswer = new Answer($this->id);
     // Insert the options
     for ($i = 1; $i <= $nb_options; ++$i) {
         $position++;
         $option = $form->getSubmitValue('option[' . $i . ']');
         $objAnswer->createAnswer($option, 0, '', 0, $position);
     }
     // Insert the answers
     for ($i = 1; $i <= $nb_matches; ++$i) {
         $position++;
         $answer = $form->getSubmitValue('answer[' . $i . ']');
         $matches = $form->getSubmitValue('matches[' . $i . ']');
         $weighting = $form->getSubmitValue('weighting[' . $i . ']');
         $this->weighting += $weighting;
         $objAnswer->createAnswer($answer, $matches, '', $weighting, $position);
     }
     $objAnswer->save();
     $this->save();
 }
 /**
  * abstract function which creates the form to create / edit the answers of the question
  * @param FormValidator $form
  */
 function processAnswersCreation($form)
 {
     $questionWeighting = $nbrGoodAnswers = 0;
     $objAnswer = new Answer($this->id);
     $nb_answers = $form->getSubmitValue('nb_answers');
     // Score total
     $answer_score = trim($form->getSubmitValue('weighting[1]'));
     // Reponses correctes
     $nbr_corrects = 0;
     for ($i = 1; $i <= $nb_answers; $i++) {
         $goodAnswer = trim($form->getSubmitValue('correct[' . $i . ']'));
         if ($goodAnswer) {
             $nbr_corrects++;
         }
     }
     // Set question weighting (score total)
     $questionWeighting = $answer_score;
     // Set score per answer
     $nbr_corrects = $nbr_corrects == 0 ? 1 : $nbr_corrects;
     $answer_score = $nbr_corrects == 0 ? 0 : $answer_score;
     $answer_score = $answer_score / $nbr_corrects;
     //$answer_score �quivaut � la valeur d'une bonne r�ponse
     // cr�ation variable pour r�cuperer la valeur de la coche pour la prise en compte des n�gatifs
     $test = $form->getSubmitValue('pts');
     for ($i = 1; $i <= $nb_answers; $i++) {
         $answer = trim($form->getSubmitValue('answer[' . $i . ']'));
         $comment = trim($form->getSubmitValue('comment[' . $i . ']'));
         $goodAnswer = trim($form->getSubmitValue('correct[' . $i . ']'));
         if ($goodAnswer) {
             $weighting = abs($answer_score);
         } else {
             if ($test == 1) {
                 $weighting = 0;
             } else {
                 $weighting = -abs($answer_score);
             }
         }
         $objAnswer->createAnswer($answer, $goodAnswer, $comment, $weighting, $i);
     }
     // saves the answers into the data base
     $objAnswer->save();
     // sets the total weighting of the question --> sert � donner le score total pendant l'examen
     $this->updateWeighting($questionWeighting);
     $this->save();
 }
Example #19
0
$nameTools = get_lang('Import');
/*	Libraries */
include_once api_get_path(LIBRARY_PATH) . 'groupmanager.lib.php';
include_once api_get_path(LIBRARY_PATH) . 'export.lib.inc.php';
$interbreadcrumb[] = array('url' => 'group.php', 'name' => get_lang('Groups'));
Display::display_header($nameTools, 'Group');
$form = new FormValidator('import', 'post', api_get_self() . '?' . api_get_cidreq());
$form->addElement('header', get_lang('ImportGroups'));
$form->addElement('file', 'file', get_lang('File'));
$form->addRule('file', get_lang('ThisFieldIsRequired'), 'required');
$form->addElement('checkbox', 'delete_not_in_file', null, get_lang('DeleteItemsNotInFile'));
$form->addElement('button', 'submit', get_lang('Import'));
if ($form->validate()) {
    if (isset($_FILES['file']['tmp_name']) && !empty($_FILES['file']['tmp_name'])) {
        $groupData = Import::csv_reader($_FILES['file']['tmp_name']);
        $deleteNotInArray = $form->getSubmitValue('delete_not_in_file') == 1 ? true : false;
        $result = GroupManager::importCategoriesAndGroupsFromArray($groupData, $deleteNotInArray);
        if (!empty($result)) {
            $html = null;
            foreach ($result as $status => $data) {
                if (empty($data['category']) && empty($data['group'])) {
                    continue;
                }
                $html .= " <h3>" . get_lang(ucfirst($status)) . ' </h3>';
                if (!empty($data['category'])) {
                    $html .= "<h4> " . get_lang('Categories') . ':</h4>';
                    foreach ($data['category'] as $category) {
                        $html .= "<div>" . $category['category'] . "</div>";
                    }
                }
                if (!empty($data['group'])) {
    }
}
$filter = api_get_setting('certificate_filter_by_official_code');
$userList = array();
$filterForm = null;
$certificate_list = array();
if ($filter === 'true') {
    echo '<br />';
    $options = UserManager::getOfficialCodeGrouped();
    $options = array_merge(array('all' => get_lang('All')), $options);
    $form = new FormValidator('official_code_filter', 'POST', api_get_self() . '?' . api_get_cidreq() . '&cat_id=' . $cat_id);
    $form->addElement('select', 'filter', get_lang('OfficialCode'), $options);
    $form->addButton('submit', get_lang('Submit'));
    $filterForm = '<br />' . $form->return_form();
    if ($form->validate()) {
        $officialCode = $form->getSubmitValue('filter');
        if ($officialCode == 'all') {
            $certificate_list = GradebookUtils::get_list_users_certificates($cat_id);
        } else {
            $userList = UserManager::getUsersByOfficialCode($officialCode);
            if (!empty($userList)) {
                $certificate_list = GradebookUtils::get_list_users_certificates($cat_id, $userList);
            }
        }
    } else {
        $certificate_list = GradebookUtils::get_list_users_certificates($cat_id);
    }
} else {
    $certificate_list = GradebookUtils::get_list_users_certificates($cat_id);
}
echo '<div class="btn-group">';
Example #21
0
 /**
  * function which process the creation of exercises
  * @param FormValidator $form
  * @param string
  */
 public function processCreation($form, $type = '')
 {
     $this->updateTitle(Exercise::format_title_variable($form->getSubmitValue('exerciseTitle')));
     $this->updateDescription($form->getSubmitValue('exerciseDescription'));
     $this->updateAttempts($form->getSubmitValue('exerciseAttempts'));
     $this->updateFeedbackType($form->getSubmitValue('exerciseFeedbackType'));
     $this->updateType($form->getSubmitValue('exerciseType'));
     $this->setRandom($form->getSubmitValue('randomQuestions'));
     $this->updateRandomAnswers($form->getSubmitValue('randomAnswers'));
     $this->updateResultsDisabled($form->getSubmitValue('results_disabled'));
     $this->updateExpiredTime($form->getSubmitValue('enabletimercontroltotalminutes'));
     $this->updatePropagateNegative($form->getSubmitValue('propagate_neg'));
     $this->updateSaveCorrectAnswers($form->getSubmitValue('save_correct_answers'));
     $this->updateRandomByCat($form->getSubmitValue('randomByCat'));
     $this->updateTextWhenFinished($form->getSubmitValue('text_when_finished'));
     $this->updateDisplayCategoryName($form->getSubmitValue('display_category_name'));
     $this->updateReviewAnswers($form->getSubmitValue('review_answers'));
     $this->updatePassPercentage($form->getSubmitValue('pass_percentage'));
     $this->updateCategories($form->getSubmitValue('category'));
     $this->updateEndButton($form->getSubmitValue('end_button'));
     $this->setOnSuccessMessage($form->getSubmitValue('on_success_message'));
     $this->setOnFailedMessage($form->getSubmitValue('on_failed_message'));
     $this->updateEmailNotificationTemplate($form->getSubmitValue('email_notification_template'));
     $this->updateEmailNotificationTemplateToUser($form->getSubmitValue('email_notification_template_to_user'));
     $this->setNotifyUserByEmail($form->getSubmitValue('notify_user_by_email'));
     $this->setModelType($form->getSubmitValue('model_type'));
     $this->setQuestionSelectionType($form->getSubmitValue('question_selection_type'));
     $this->setHideQuestionTitle($form->getSubmitValue('hide_question_title'));
     $this->setQuestionSelectionType($form->getSubmitValue('question_selection_type'));
     $this->setScoreTypeModel($form->getSubmitValue('score_type_model'));
     $this->setGlobalCategoryId($form->getSubmitValue('global_category_id'));
     if ($form->getSubmitValue('activate_start_date_check') == 1) {
         $start_time = $form->getSubmitValue('start_time');
         $this->start_time = api_get_utc_datetime($start_time);
     } else {
         $this->start_time = '0000-00-00 00:00:00';
     }
     if ($form->getSubmitValue('activate_end_date_check') == 1) {
         $end_time = $form->getSubmitValue('end_time');
         $this->end_time = api_get_utc_datetime($end_time);
     } else {
         $this->end_time = '0000-00-00 00:00:00';
     }
     if ($form->getSubmitValue('enabletimercontrol') == 1) {
         $expired_total_time = $form->getSubmitValue('enabletimercontroltotalminutes');
         if ($this->expired_time == 0) {
             $this->expired_time = $expired_total_time;
         }
     } else {
         $this->expired_time = 0;
     }
     if ($form->getSubmitValue('randomAnswers') == 1) {
         $this->random_answers = 1;
     } else {
         $this->random_answers = 0;
     }
     $this->save($type);
 }
Example #22
0
 /**
  * function which process the creation of questions
  * @param FormValidator $form the formvalidator instance
  * @param Exercise $objExercise the Exercise instance
  */
 public function processCreation($form, $objExercise = null)
 {
     $this->updateParentId($form->getSubmitValue('parent_id'));
     $this->updateTitle($form->getSubmitValue('questionName'));
     $this->updateDescription($form->getSubmitValue('questionDescription'));
     $this->updateLevel($form->getSubmitValue('questionLevel'));
     $this->updateCategory($form->getSubmitValue('questionCategory'));
     // Save normal question if NOT media
     if ($this->type != MEDIA_QUESTION) {
         $this->save($objExercise->id);
         $field_value = new ExtraFieldValue('question');
         $params = $form->getSubmitValues();
         $params['question_id'] = $this->id;
         $field_value->save_field_values($params);
         if ($objExercise) {
             // modify the exercise
             $objExercise->addToList($this->id);
             $objExercise->update_question_positions();
         }
     }
 }
Example #23
0
//Initialization
$cidReset = true;
require_once '../../../main/inc/global.inc.php';
$htmlHeadXtra[] = '<link rel="stylesheet" href="../resources/css/style.css" type="text/css">';
$htmlHeadXtra[] = '<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js"></script>';
api_protect_admin_script(true);
$plugin = BuyCoursesPlugin::create();
$commissionsEnable = $plugin->get('commissions_enable');
$payoutStatuses = $plugin->getPayoutStatuses();
$selectedStatus = isset($_GET['status']) ? $_GET['status'] : BuyCoursesPlugin::SALE_STATUS_COMPLETED;
if ($commissionsEnable !== "true") {
    api_not_allowed(true);
}
$form = new FormValidator('search', 'get');
if ($form->validate()) {
    $selectedStatus = $form->getSubmitValue('status');
    if ($selectedStatus === false) {
        $selectedStatus = BuyCoursesPlugin::PAYOUT_STATUS_PENDING;
    }
}
$form->addSelect('status', $plugin->get_lang('PayoutStatus'), $payoutStatuses);
$form->addButtonFilter(get_lang('Search'));
$form->setDefaults(['status' => $selectedStatus]);
switch ($selectedStatus) {
    case '2':
        $payouts = $plugin->getPayouts($selectedStatus);
        break;
    case '1':
        $payouts = $plugin->getPayouts($selectedStatus);
        break;
    case '0':