Example #1
0
 public static function getSimpleTextarea($label_name, $id, $name, $value = '', $css_line = false, $css_label = false, $css_text = false, $rows = 5, $cols = 22, $afterlabel = '')
 {
     if ($css_line === false) {
         $css_line = 'form_line_l';
     }
     if ($css_label === false) {
         $css_label = 'floating';
     }
     if ($css_text === false) {
         $css_text = 'textarea';
     }
     return '<div class="' . $css_line . '">' . '<p><label class="' . $css_label . '" for="' . $id . '">' . $label_name . '</label></p>' . Form::getInputTextarea($id, $name, $value, $css_text, $rows, $cols) . '' . $afterlabel . '</div>';
 }
Example #2
0
 public function getPresenceTable()
 {
     $user = $this->classroom_man->getUserForPresence($this->id_date);
     $day = $this->getDateDay($this->id_date);
     $test_type = $this->getTestType();
     $user_presence = $this->classroom_man->getUserPresenceForDate($this->id_date);
     $tb = new Table(0, Lang::t('_ATTENDANCE', 'course'), Lang::t('_ATTENDANCE', 'course'));
     $cont_h = array(Lang::t('_USERNAME', 'course'), Lang::t('_FULLNAME', 'course'));
     $type_h = array('', '');
     foreach ($day as $id_day => $day_info) {
         $cont_h[] = Format::date($day_info['date_begin'], 'date') . '<br />' . '<a href="javascript:;" onClick="checkAllDay(' . $id_day . ')">' . Get::img('standard/checkall.png', Lang::t('_CHECK_ALL_DAY', 'presence') . '</a>') . ' ' . '<a href="javascript:;" onClick="unCheckAllDay(' . $id_day . ')">' . Get::img('standard/uncheckall.png', Lang::t('_UNCHECK_ALL_DAY', 'presence') . '</a>');
         $type_h[] = 'img-cell';
     }
     $cont_h[] = '';
     $type_h[] = 'img-cell';
     if ($test_type == _DATE_TEST_TYPE_PAPER) {
         $cont_h[] = Lang::t('_SCORE', 'course');
         $type_h[] = 'img-cell';
     }
     $cont_h[] = Lang::t('_NOTES', 'course');
     $type_h[] = 'img-cell';
     $tb->setColsStyle($type_h);
     $tb->addHead($cont_h);
     $array_user_id = array();
     foreach ($user as $id_user => $user_info) {
         reset($day);
         $array_user_id[] = $id_user;
         $cont = array();
         $cont[] = $user_info['userid'];
         $cont[] = $user_info['lastname'] . ' ' . $user_info['firstname'];
         foreach ($day as $id_day => $day_info) {
             if (isset($user_presence[$id_user][substr($day_info['date_begin'], 0, 10)]) && $user_presence[$id_user][substr($day_info['date_begin'], 0, 10)]['presence'] == 1) {
                 $presence = true;
             } elseif (isset($user_presence[$id_user][substr($day_info['date_begin'], 0, 10)]) && $user_presence[$id_user][substr($day_info['date_begin'], 0, 10)]['presence'] == 0) {
                 $presence = false;
             } else {
                 $presence = false;
             }
             $cont[] = Form::getInputCheckbox('date_' . $id_day . '_' . $id_user, 'date_' . $id_day . '_' . $id_user, 1, $presence, false);
         }
         $cont[] = '<a href="javascript:;" onClick="checkAllUser(' . $id_user . ')">' . Get::img('standard/checkall.png', Lang::t('_CHECK_ALL_USER', 'presence') . '</a>') . '<br />' . '<a href="javascript:;" onClick="unCheckAllUser(' . $id_user . ')">' . Get::img('standard/uncheckall.png', Lang::t('_UNCHECK_ALL_USER', 'presence') . '</a>');
         if ($test_type == _DATE_TEST_TYPE_PAPER) {
             if (isset($user_presence[$id_user]['0000-00-00']) && $user_presence[$id_user]['0000-00-00']['presence'] == 1) {
                 $passed = true;
             } else {
                 $passed = false;
             }
             //$cont[] = Form::getTextfield('', 'score_'.$id_user, 'score_'.$id_user, 255, (isset($user_presence[$id_user]['0000-00-00']['score']) ? $user_presence[$id_user]['0000-00-00']['score'] : '0'));
             $cont[] = Form::getInputTextfield('', 'score_' . $id_user, 'score_' . $id_user, isset($user_presence[$id_user]['0000-00-00']['score']) ? $user_presence[$id_user]['0000-00-00']['score'] : '0', Lang::t('_SCORE', 'course'), 255, '');
         }
         //$cont[] = Form::getSimpleTextarea('', 'note_'.$id_user, 'note_'.$id_user, (isset($user_presence[$id_user]['0000-00-00']['note']) ? $user_presence[$id_user]['0000-00-00']['note'] : ''), false, false, false, 2);
         $cont[] = Form::getInputTextarea('note_' . $id_user, 'note_' . $id_user, isset($user_presence[$id_user]['0000-00-00']['note']) ? $user_presence[$id_user]['0000-00-00']['note'] : '', '', 5, 22);
         $tb->addBody($cont);
     }
     return $tb->getTable();
 }
Example #3
0
function modactivityscore()
{
    checkPerm('mod');
    require_once $GLOBALS['where_lms'] . '/lib/lib.coursereport.php';
    require_once _base_ . '/lib/lib.form.php';
    require_once _base_ . '/lib/lib.table.php';
    // XXX: Initializaing
    $id_report = importVar('id_report', true, 0);
    $lang =& DoceboLanguage::createInstance('coursereport', 'lms');
    $out =& $GLOBALS['page'];
    $out->setWorkingZone('content');
    // XXX: Instance management
    $acl_man = Docebo::user()->getAclManager();
    $report_man = new CourseReportManager();
    // XXX: Find users
    $type_filter = false;
    if (isset($_GET['type_filter']) && $_GET['type_filter'] != null) {
        $type_filter = $_GET['type_filter'];
    }
    $lev = $type_filter;
    $students = getSubscribed((int) $_SESSION['idCourse'], FALSE, $lev, TRUE, false, false, true);
    $id_students = array_keys($students);
    $students_info =& $acl_man->getUsers($id_students);
    if (isset($_POST['save'])) {
        // retirive activity info
        $info_report = array('id_report' => importVar('id_report', true, 0), 'title' => importVar('title'), 'max_score' => importVar('max_score', true), 'required_score' => importVar('required_score', true), 'source_of' => importVar('source_of'), 'weight' => importVar('weight', true), 'show_to_user' => importVar('show_to_user', false, 'true'), 'use_for_final' => importVar('use_for_final', false, 'true'));
        // XXX: retrive scores
    } else {
        // retirive activity info
        $query_report = "\r\n\t\tSELECT id_report, title, max_score, required_score, weight, show_to_user, use_for_final, id_source, source_of\r\n\t\tFROM " . $GLOBALS['prefix_lms'] . "_coursereport\r\n\t\tWHERE id_course = '" . $_SESSION['idCourse'] . "' AND id_report = '" . $id_report . "'\r\n\t\t\t\tAND (source_of = 'scoitem' OR source_of = 'activity')";
        // TBD AND id_source = '0'";
        $info_report = sql_fetch_assoc(sql_query($query_report));
        // XXX: retrive scores
        $report_score =& $report_man->getReportsScores(array($id_report));
    }
    // XXX: Write in output
    $page_title = array('index.php?modname=coursereport&amp;op=coursereport' => $lang->def('_COURSEREPORT', 'menu_course'), strip_tags($info_report['title']));
    $out->add(getTitleArea($page_title, 'coursereport') . '<div class="std_block">' . Form::openForm('activity', 'index.php?modname=coursereport&amp;op=modactivityscore'));
    // XXX: Save input if needed
    if (isset($_POST['save'])) {
        if ($_POST['title'] == '') {
            $_POST['title'] = $lang->def('_NOTITLE');
        }
        $re_check = $report_man->checkActivityData($_POST);
        if (!$re_check['error']) {
            if (!$report_man->updateActivity($id_report, $_SESSION['idCourse'], $info_report)) {
                $out->add(getErrorUi($lang->def('_OPERATION_FAILURE')));
            } else {
                // save user score modification
                $query_upd_report = "\r\n\t\t\t\tUPDATE " . $GLOBALS['prefix_lms'] . "_coursereport\r\n\t\t\t\tSET weight = '" . $info_report['weight'] . "',\r\n\t\t\t\t\tuse_for_final = '" . $info_report['use_for_final'] . "',\r\n\t\t\t\t\tshow_to_user = '******'show_to_user'] . "'\r\n\t\t\t\tWHERE id_course = '" . $_SESSION['idCourse'] . "' AND id_report = '" . $id_report . "'";
                $re = sql_query($query_upd_report);
                $re = $report_man->saveReportScore($id_report, $_POST['user_score'], $_POST['date_attempt'], $_POST['comment']);
                Util::jump_to('index.php?modname=coursereport&amp;op=coursereport&result=' . ($re ? 'ok' : 'err'));
            }
        } else {
            $out->add(getErrorUi($re_check['message']));
        }
    }
    // main form
    $out->add(Form::openElementSpace() . Form::getOpenFieldSet($lang->def('_ACTIVITY_INFO')) . Form::getHidden('id_report', 'id_report', $id_report) . Form::getHidden('id_source', 'id_source', $info_report['id_source']) . Form::getHidden('source_of', 'source_of', $info_report['source_of']));
    // for scorm object changing title, maxScore and requiredScore is not allowed
    switch ($info_report['source_of']) {
        case 'scoitem':
            $out->add(Form::getLinebox($lang->def('_TITLE_ACT'), strip_tags($info_report['title'])) . Form::getLinebox($lang->def('_MAX_SCORE'), strip_tags($info_report['max_score'])) . Form::getLinebox($lang->def('_REQUIRED_SCORE'), strip_tags($info_report['required_score'])));
            break;
        case 'activity':
            $out->add(Form::getTextfield($lang->def('_TITLE_ACT'), 'title', 'title', '255', $info_report['title']) . Form::getTextfield($lang->def('_MAX_SCORE'), 'max_score', 'max_score', '11', $info_report['max_score']) . Form::getTextfield($lang->def('_REQUIRED_SCORE'), 'required_score', 'required_score', '11', $info_report['required_score']));
            break;
    }
    $out->add(Form::getTextfield($lang->def('_WEIGHT'), 'weight', 'weight', '11', $info_report['weight']) . Form::getDropdown($lang->def('_SHOW_TO_USER'), 'show_to_user', 'show_to_user', array('true' => $lang->def('_YES'), 'false' => $lang->def('_NO')), $info_report['show_to_user']) . Form::getDropdown($lang->def('_USE_FOR_FINAL'), 'use_for_final', 'use_for_final', array('true' => $lang->def('_YES'), 'false' => $lang->def('_NO')), $info_report['use_for_final']) . Form::getCloseFieldSet() . Form::closeElementSpace());
    if ($info_report['source_of'] != 'scoitem') {
        /* XXX: scores */
        $tb = new Table(0, $lang->def('_STUDENTS_VOTE'), $lang->def('_STUDENTS_VOTE'));
        $type_h = array('', 'align-center', 'align-center', '');
        $tb->setColsStyle($type_h);
        $cont_h = array($lang->def('_STUDENTS'), $lang->def('_SCORE'), $lang->def('_DATE'), $lang->def('_COMMENTS'));
        $tb->addHead($cont_h);
        // XXX: Display user scores
        $i = 0;
        while (list($idst_user, $user_info) = each($students_info)) {
            $user_name = $user_info[ACL_INFO_LASTNAME] . $user_info[ACL_INFO_FIRSTNAME] ? $user_info[ACL_INFO_LASTNAME] . ' ' . $user_info[ACL_INFO_FIRSTNAME] : $acl_man->relativeId($user_info[ACL_INFO_USERID]);
            $cont = array(Form::getLabel('user_score_' . $idst_user, $user_name));
            $cont[] = Form::getInputTextfield('textfield_nowh', 'user_score_' . $idst_user, 'user_score[' . $idst_user . ']', isset($report_score[$id_report][$idst_user]['score']) ? $report_score[$id_report][$idst_user]['score'] : (isset($_POST['user_score'][$idst_user]) ? $_POST['user_score'][$idst_user] : ''), strip_tags($lang->def('_SCORE')), '8', ' tabindex="' . $i++ . '" ');
            $cont[] = Form::getInputDatefield('textfield_nowh', 'date_attempt_' . $idst_user, 'date_attempt[' . $idst_user . ']', Format::date(isset($report_score[$id_report][$idst_user]['date_attempt']) ? $report_score[$id_report][$idst_user]['date_attempt'] : (isset($_POST['date_attempt'][$idst_user]) ? $_POST['date_attempt'][$idst_user] : ''), 'date'));
            $cont[] = Form::getInputTextarea('comment_' . $idst_user, 'comment[' . $idst_user . ']', isset($report_score[$id_report][$idst_user]['comment']) ? $report_score[$id_report][$idst_user]['comment'] : (isset($_POST['comment'][$idst_user]) ? stripslashes($_POST['comment'][$idst_user]) : ''), 'textarea_wh_full', 2);
            $tb->addBody($cont);
        }
    }
    $out->add(Form::openButtonSpace() . Form::getButton('save', 'save', $lang->def('_SAVE')) . Form::getButton('undo', 'undo', $lang->def('_UNDO')) . Form::closeButtonSpace());
    if ($info_report['source_of'] != 'scoitem') {
        $out->add($tb->getTable() . Form::openButtonSpace() . Form::getButton('save', 'save', $lang->def('_SAVE')) . Form::getButton('undo', 'undo', $lang->def('_UNDO')) . Form::closeButtonSpace());
    }
    $out->add(Form::closeForm() . '</div>');
}
 function getAddCommentMask($ext_key)
 {
     require_once _base_ . '/lib/lib.form.php';
     $html = '' . Form::openForm('ajax_comment_add', '', false, false, '', ' onSubmit="addajaxcomment(); return false;"') . Form::getHidden('ajaxcomment_ext_key', 'ajaxcomment_ext_key', $ext_key) . Form::getHidden('ajaxcomment_reply_to', 'ajaxcomment_reply_to', '0') . '<p>' . Form::getLabel('ajaxcomment_textof', Lang::t('_COMMENTS', $this->_module, $this->_platform), 'label_bold') . '</p>' . '<p>' . Form::getInputTextarea('ajaxcomment_textof', 'ajaxcomment_textof', '') . '</p>' . '<p>' . Form::getButton('ajaxcomment_send', 'ajaxcomment_send', Lang::t('_SEND', $this->_module, $this->_platform), '') . '</p>' . Form::closeForm();
     return $html;
 }