}
        }
    } 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">';
$url = api_get_self() . '?action=generate_all_certificates' . '&' . api_get_cidReq() . '&cat_id=' . $cat_id . '&filter=' . $filterOfficialCode;
echo Display::url(get_lang('GenerateCertificates'), $url, array('class' => 'btn btn-default'));
$url = api_get_self() . '?action=delete_all_certificates' . '&' . api_get_cidReq() . '&cat_id=' . $cat_id . '&filter=' . $filterOfficialCode;
echo Display::url(get_lang('DeleteAllCertificates'), $url, array('class' => 'btn btn-default'));
$hideCertificateExport = api_get_setting('hide_certificate_export_link');
if (count($certificate_list) > 0 && $hideCertificateExport !== 'true') {
    $url = api_get_self() . '?action=export_all_certificates' . '&' . api_get_cidReq() . '&cat_id=' . $cat_id . '&filter=' . $filterOfficialCode;
    echo Display::url(get_lang('ExportAllCertificatesToPDF'), $url, array('class' => 'btn btn-default'));
}
echo '</div>';
echo $filterForm;
if (count($certificate_list) == 0) {
    echo Display::display_warning_message(get_lang('NoResultsAvailable'));
} else {
    echo '<br /><br /><table class="data_table">';
    foreach ($certificate_list as $index => $value) {
        echo '<tr>
                <td width="100%" class="actions">' . get_lang('Student') . ' : ' . api_get_person_name($value['firstname'], $value['lastname']) . ' (' . $value['username'] . ')</td>';
        echo '</tr>';
        echo '<tr><td>
            <table class="data_table">';
        $list_certificate = GradebookUtils::get_list_gradebook_certificates_by_user_id($value['user_id'], $cat_id);
Пример #2
0
}
$confirmYourChoice = addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset));
$htmlHeadXtra[] = "\n<script>\n\tfunction submit_form(obj) {\n\t\tdocument.question_pool.submit();\n\t}\n\n\tfunction mark_course_id_changed() {\n\t\t\$('#course_id_changed').val('1');\n\t}\n\n\tfunction mark_exercice_id_changed() {\n\t\t\$('#exercice_id_changed').val('1');\n\t}\n\n\tfunction confirm_your_choice() {\n\t\treturn confirm('{$confirmYourChoice}');\n\t}\n</script>";
Display::display_header($nameTools, 'Exercise');
// Menu
echo '<div class="actions">';
if (isset($type)) {
    $url = api_get_self() . '?type=1';
} else {
    $url = api_get_self();
}
if (isset($fromExercise) && $fromExercise > 0) {
    echo '<a href="admin.php?' . api_get_cidreq() . '&exerciseId=' . $fromExercise . '">' . Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM) . '</a>';
    $titleAdd = get_lang('AddQuestionToTest');
} else {
    echo '<a href="exercice.php?' . api_get_cidReq() . '">' . Display::return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM) . '</a>';
    echo "<a href='admin.php?exerciseId=0'>" . Display::return_icon('add_question.gif', get_lang('NewQu'), '', ICON_SIZE_MEDIUM) . "</a>";
    $titleAdd = get_lang('ManageAllQuestions');
}
echo '</div>';
if ($displayMessage != "") {
    Display::display_confirmation_message($displayMessage);
    $displayMessage = "";
}
// Form
echo '<form class="form-horizontal" name="question_pool" method="GET" action="' . $url . '">';
// Title
echo '<legend>' . $nameTools . ' - ' . $titleAdd . '</legend>';
if (isset($type)) {
    echo '<input type="hidden" name="type" value="1">';
}
Пример #3
0
 /**
  * Function that displays a list with al the resources that could be added to the learning path
  *
  * @return string
  */
 function display_resources()
 {
     global $_course, $charset;
     //TODO: don't use globals
     $add_page_lang_var = api_convert_encoding(get_lang('LpAddPage'), $charset, api_get_system_encoding());
     $send_file_lang_var = api_convert_encoding(get_lang('SendFile'), $charset, api_get_system_encoding());
     $add_quiz_lang_var = api_convert_encoding(get_lang('LpAddQuiz'), $charset, api_get_system_encoding());
     $upload_quiz_lang_var = api_convert_encoding(get_lang('LpUploadQuiz'), $charset, api_get_system_encoding());
     $mindmap_lang_var = api_convert_encoding(get_lang('Mindmap'), $charset, api_get_system_encoding());
     $video_lang_var = api_convert_encoding(get_lang('Video'), $charset, api_get_system_encoding());
     $commonCssClasses = "big_button four_buttons rounded grey_border";
     // add page
     $href = 'lp_gallery.php?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;action=add_item&type=template&amp;lp_id=' . $_SESSION['oLP']->lp_id;
     $return .= '<a href="' . $href . '" class="' . $commonCssClasses . ' create_page_button">' . $add_page_lang_var . '</a>';
     // upload docs
     $href = 'lp_upload_document.php?' . api_get_cidreq() . '&lp_id=' . $this->lp_id . '&path=%2F&selectcat=';
     $return .= '<a href="' . $href . '" class="' . $commonCssClasses . ' upload_doc_button">' . $send_file_lang_var . '</a>';
     // select document
     $return .= $this->get_documents();
     // links
     $return .= $this->get_links();
     // add quiz
     $href = api_get_path(REL_CODE_PATH) . 'exercice/exercise_admin.php?' . api_get_cidreq() . '&fromlp=1&lp_id=' . $this->lp_id;
     $return .= '<a href="' . $href . '" class="' . $commonCssClasses . ' create_quiz_button">' . $add_quiz_lang_var . '</a>';
     /**
      ==============================================================================
     * 	TODO set upload quiz link
      ==============================================================================
     */
     //upload quiz
     $href = 'lp_upload_quiz.php?' . api_get_cidreq() . '&lp_id=' . $this->lp_id;
     $return .= '<a href="' . $href . '" class="' . $commonCssClasses . ' upload_quiz_button">' . $upload_quiz_lang_var . '</a>';
     // select quiz
     $return .= $this->get_exercises();
     // survey
     $return .= $this->get_survey();
     // forum
     $return .= $this->get_forums();
     // assignement
     $return .= $this->get_student_publication();
     // mindmap
     if (api_get_setting('enable_certificate') === 'true') {
         $href = 'certificate.php?' . api_get_cidReq() . '&lp_id=' . $this->lp_id;
         $return .= '<a href="' . $href . '" class="' . $commonCssClasses . ' create_certificate_button">' . get_lang("Certificate") . '</a>';
     } else {
         //	Mindmaps page
         $href = 'lp_mindmap.php?' . api_get_cidreq() . '&view=&action=add&curdirpath=&type=' . TOOL_MINDMAP . '&amp;lp_id=' . $this->lp_id;
         $return .= '<a href="' . $href . '" class="' . $commonCssClasses . ' mindmap_button">' . $mindmap_lang_var . '</a>';
     }
     /**
      ==============================================================================
     * 	TODO set video link
      ==============================================================================
     */
     // video
     $href = 'lp_video.php?' . api_get_cidreq() . '&view=&action=add&type=video&amp;lp_id=' . $this->lp_id;
     $return .= '<a href="' . $href . '" class="' . $commonCssClasses . ' video_button">' . $video_lang_var . '</a>';
     return $return;
 }
                $total_resource_weight = $total_resource_weight + $item['2'];
            }
        }
    }
    if ($total_resource_weight != $total_weight) {
        Display::display_warning_message(get_lang('SumOfActivitiesWeightMustBeEqualToTotalWeight'));
    }
}
$certificate_list = get_list_users_certificates($cat_id);
echo '<div class="btn-group">';
$url = api_get_self() . '?action=generate_all_certificates' . '&' . api_get_cidReq() . '&cat_id=' . $cat_id;
echo Display::url(get_lang('GenerateCertificates'), $url, array('class' => 'btn'));
$url = api_get_self() . '?action=delete_all_certificates' . '&' . api_get_cidReq() . '&cat_id=' . $cat_id;
echo Display::url(get_lang('DeleteAllCertificates'), $url, array('class' => 'btn'));
if (count($certificate_list) > 0) {
    $url = api_get_self() . '?action=export_all_certificates' . '&' . api_get_cidReq() . '&cat_id=' . $cat_id;
    echo Display::url(get_lang('ExportAllCertificatesToPDF'), $url, array('class' => 'btn'));
}
echo '</div>';
if (count($certificate_list) == 0) {
    echo Display::display_warning_message(get_lang('NoResultsAvailable'));
} else {
    echo '<br /><br /><table class="data_table">';
    foreach ($certificate_list as $index => $value) {
        echo '<tr>
                    <td width="100%" class="actions">' . get_lang('Student') . ' : ' . api_get_person_name($value['firstname'], $value['lastname']) . ' ( ' . $value['username'] . ')</td>';
        echo '</tr>';
        echo '<tr><td>
            <table class="data_table">';
        $list_certificate = get_list_gradebook_certificates_by_user_id($value['user_id'], $cat_id);
        foreach ($list_certificate as $value_certificate) {
Пример #5
0
                case 'csv':
                    Export::arrayToCsv($data);
                    exit;
                    break;
                case 'xls':
                    if (!empty($data)) {
                        Export::arrayToXls($data);
                        exit;
                    }
                    break;
            }
            break;
    }
}
/*	Header */
$interbreadcrumb[] = array('url' => 'group.php?' . api_get_cidReq(), 'name' => get_lang('Groups'));
if (!isset($_GET['origin']) || $_GET['origin'] != 'learnpath') {
    // So we are not in learnpath tool
    if (!$is_allowed_in_course) {
        api_not_allowed(true);
    }
    if (!api_is_allowed_to_edit(false, true)) {
        api_not_allowed(true);
    } else {
        Display::display_header($nameTools, 'Group');
        // Tool introduction
        Display::display_introduction_section(TOOL_GROUP);
    }
} else {
    Display::display_reduced_header();
}
Пример #6
0
    }
    echo '</div>';
} elseif (isset($_GET['action']) && $_GET['action'] == 'showterm') {
    $id = $_GET['q'];
    $t_glossary = Database::get_course_table(TABLE_GLOSSARY);
    $t_item_propery = Database::get_course_table(TABLE_ITEM_PROPERTY);
    $query = "SELECT \tg.glossary_id \t\tAS glossary_id,\n\t\t\t\t\tg.name \t\t\t\tAS glossary_title,\n\t\t\t\t\tg.description \t\tAS glossary_comment,\n\t\t\t\t\tg.display_order\t\tAS glossary_display_order\n\t\t\t   FROM {$t_glossary} g, {$t_item_propery} ip\n\t\t\t   WHERE g.glossary_id = ip.ref\n\t\t\t   AND tool = '" . TOOL_GLOSSARY . "'\n\t\t\t   AND g.glossary_id = '" . Database::escape_string($id) . "' ";
    $res = api_sql_query($query, __FILE__, __LINE__);
    while ($data = Database::fetch_object($res)) {
        $glossary_name = convert_encoding($data->glossary_title);
        $glossary_description = convert_encoding($data->glossary_comment);
    }
    // Wrapper for add edit form + image map
    echo '<div id="wrapper_glossary_form">';
    //To show Add and Edit Definition form
    echo '<div id="glossary_form">';
    echo '<div align="center" class="quiz_content_actions">' . $glossary_name . '</div>';
    echo '<div align="center" class="quiz_content_actions glossary_description_height" style="overflow:auto;text-align:left;">' . $glossary_description . '</div>';
    if (api_is_allowed_to_edit(null, true)) {
        echo '<div align="right" class="quiz_content_actions" style="border:none;"><a href="index.php?' . api_get_cidReq() . '&action=editterm&glossary_id=' . $id . '">' . Display::return_icon('pixel.gif', get_lang('Edit'), array('class' => 'actionplaceholdericon actionedit')) . '&nbsp;&nbsp;<a onclick="return confirmation(\'' . $glossary_name . '\');" href="index.php?action=delete_glossary&glossary_id=' . $id . '">' . Display::return_icon('pixel.gif', get_lang('Delete'), array('class' => 'actionplaceholdericon actiondelete')) . '</a></div>';
    }
    // Close add/edit form
    echo '</div>';
    // Add image map
    echo '<div id="glossary_image_map">';
    echo '<a href="index.php?' . api_get_cidReq() . '"><img class="abs" src="../img/imagemap90.png" style="margin:30px 30px 0 0; right:0; top:0;"></a>';
    // Close "image map"
    echo '</div>';
    // Close glossary wrapper form
    echo '</div>';
}
Пример #7
0
<?php
/* For licensing terms, see /license.txt */
/**
 * Redirection script
 * @package chamilo.learnpath
 * @author Yannick Warnier <*****@*****.**>
 */

// Flag to allow for anonymous user - needs to be set before global.inc.php.
$use_anonymous = true;

require 'back_compat.inc.php';
header('location: lp_controller.php?'.api_get_cidReq().'&action=list');
Пример #8
0
    } else {
        Display::display_warning_message(get_lang('EditingExerciseCauseProblemsInLP'));
    }
}
// If we are in a test
$inATest = isset($exerciseId) && $exerciseId > 0;
if ($inATest) {
    echo '<div class="actions">';
    if (isset($_GET['hotspotadmin']) || isset($_GET['newQuestion']) || isset($_GET['myid'])) {
        echo '<a href="' . $urlMainExercise . 'admin.php?exerciseId=' . $exerciseId . '">' . Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM) . '</a>';
    }
    if (!isset($_GET['hotspotadmin']) && !isset($_GET['newQuestion']) && !isset($_GET['myid']) && !isset($_GET['editQuestion'])) {
        echo '<a href="' . $urlMainExercise . 'exercice.php?' . api_get_cidReq() . '">' . Display::return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM) . '</a>';
    }
    echo '<a href="' . $urlMainExercise . 'overview.php?' . api_get_cidreq() . '&exerciseId=' . $objExercise->id . '&preview=1">' . Display::return_icon('preview_view.png', get_lang('Preview'), '', ICON_SIZE_MEDIUM) . '</a>';
    echo Display::url(Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_MEDIUM), $urlMainExercise . 'exercise_report.php?' . api_get_cidReq() . '&exerciseId=' . $objExercise->id);
    if ($objExercise->edit_exercise_in_lp == false) {
        echo '<a href="">' . Display::return_icon('settings_na.png', get_lang('ModifyExercise'), '', ICON_SIZE_MEDIUM) . '</a>';
    } else {
        echo '<a href="' . $urlMainExercise . 'exercise_admin.php?' . api_get_cidreq() . '&modifyExercise=yes&exerciseId=' . $objExercise->id . '">' . Display::return_icon('settings.png', get_lang('ModifyExercise'), '', ICON_SIZE_MEDIUM) . '</a>';
    }
    // @todo if you have 5000 questions this will slow down everything
    /*
        $maxScoreAllQuestions = 0;
        if (!empty($objExercise->questionList)) {
            foreach ($objExercise->questionList as $q) {
                $question = Question::read($q);
                if ($question) {
                    $maxScoreAllQuestions += $question->selectWeighting();
                }
            }
Пример #9
0
    } else {
        Display::display_warning_message(get_lang('EditingExerciseCauseProblemsInLP'));
    }
}*/
// If we are in a test
$inATest = isset($exerciseId) && $exerciseId > 0;
if ($inATest) {
    echo '<div class="actions">';
    if (isset($_GET['hotspotadmin']) || isset($_GET['newQuestion']) || isset($_GET['myid'])) {
        echo '<a href="' . api_get_path(WEB_CODE_PATH) . 'exercice/admin.php?exerciseId=' . $exerciseId . '&' . api_get_cidReq() . '">' . Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM) . '</a>';
    }
    if (!isset($_GET['hotspotadmin']) && !isset($_GET['newQuestion']) && !isset($_GET['myid']) && !isset($_GET['editQuestion'])) {
        echo '<a href="' . api_get_path(WEB_CODE_PATH) . 'exercice/exercise.php?' . api_get_cidReq() . '">' . Display::return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM) . '</a>';
    }
    echo '<a href="' . api_get_path(WEB_CODE_PATH) . 'exercice/overview.php?' . api_get_cidreq() . '&exerciseId=' . $objExercise->id . '&preview=1">' . Display::return_icon('preview_view.png', get_lang('Preview'), '', ICON_SIZE_MEDIUM) . '</a>';
    echo Display::url(Display::return_icon('test_results.png', get_lang('Results'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH) . 'exercice/exercise_report.php?' . api_get_cidReq() . '&exerciseId=' . $objExercise->id);
    echo '<a href="' . api_get_path(WEB_CODE_PATH) . 'exercice/exercise_admin.php?' . api_get_cidreq() . '&modifyExercise=yes&exerciseId=' . $objExercise->id . '">' . Display::return_icon('settings.png', get_lang('ModifyExercise'), '', ICON_SIZE_MEDIUM) . '</a>';
    $maxScoreAllQuestions = 0;
    if (!empty($objExercise->questionList)) {
        foreach ($objExercise->questionList as $q) {
            $question = Question::read($q);
            if ($question) {
                $maxScoreAllQuestions += $question->selectWeighting();
            }
        }
    }
    echo '</div>';
    echo '<div class="alert alert-info">' . sprintf(get_lang('XQuestionsWithTotalScoreY'), $objExercise->selectNbrQuestions(), $maxScoreAllQuestions) . '</div>';
} else {
    if (isset($_GET['newQuestion'])) {
        // we are in create a new question from question pool not in a test
Пример #10
0
    $exercise_id = $objExercise->id;
    Session::erase('objExercise');
    header('Location:admin.php?&exerciseId=' . $exercise_id . '&' . api_get_cidreq());
    exit;
} else {
    // DISPLAY FORM
    if (api_is_in_gradebook()) {
        $interbreadcrumb[] = array('url' => api_get_path(WEB_CODE_PATH) . 'gradebook/index.php?' . api_get_cidreq(), 'name' => get_lang('ToolGradebook'));
    }
    $nameTools = get_lang('ExerciseManagement');
    $interbreadcrumb[] = array("url" => 'exercise.php?' . api_get_cidreq(), 'name' => get_lang('Exercises'));
    $interbreadcrumb[] = array("url" => 'admin.php?exerciseId=' . $objExercise->id . '&' . api_get_cidreq(), "name" => $objExercise->name);
    Display::display_header($nameTools, get_lang('Exercise'));
    echo '<div class="actions">';
    if ($objExercise->id != 0) {
        echo '<a href="admin.php?' . api_get_cidReq() . '&exerciseId=' . $objExercise->id . '">' . Display::return_icon('back.png', get_lang('GoBackToQuestionList'), '', ICON_SIZE_MEDIUM) . '</a>';
    } else {
        if (!empty($_GET['lp_id']) || !empty($_POST['lp_id'])) {
            if (!empty($_POST['lp_id'])) {
                $lp_id = intval($_POST['lp_id']);
                //TODO:this remains to be implemented after press the first post
            } else {
                $lp_id = intval($_GET['lp_id']);
            }
            echo "<a href=\"../newscorm/lp_controller.php?" . api_get_cidreq() . "&gradebook=&action=add_item&type=step&lp_id=" . $lp_id . "#resource_tab-2\">" . Display::return_icon('back.png', get_lang("BackTo") . ' ' . get_lang("LearningPaths"), '', ICON_SIZE_MEDIUM) . "</a>";
        } else {
            echo '<a href="exercise.php?' . api_get_cidreq() . '">' . Display::return_icon('back.png', get_lang('BackToExercisesList'), '', ICON_SIZE_MEDIUM) . '</a>';
        }
    }
    echo '</div>';
    if ($objExercise->feedback_type == 1) {
Пример #11
0
// If this is the case there will be a language choice
$sql = "SELECT * FROM {$table_survey} WHERE c_id = {$course_id} AND code='" . Database::escape_string($survey_data['code']) . "'";
$result = Database::query($sql);
if (Database::num_rows($result) > 1) {
    Display::display_warning_message(get_lang('IdenticalSurveycodeWarning'));
}
// Invited / answered message
if ($survey_data['invited'] > 0 && !isset($_POST['submit'])) {
    $message = '<a href="' . api_get_path(WEB_CODE_PATH) . 'survey/survey_invitation.php?view=answered&amp;survey_id=' . $survey_data['survey_id'] . '">' . $survey_data['answered'] . '</a> ';
    $message .= get_lang('HaveAnswered') . ' ';
    $message .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'survey/survey_invitation.php?view=invited&amp;survey_id=' . $survey_data['survey_id'] . '">' . $survey_data['invited'] . '</a> ';
    $message .= get_lang('WereInvited');
    Display::display_normal_message($message, false);
}
// Building the form for publishing the survey
$form = new FormValidator('publish_form', 'post', api_get_self() . '?survey_id=' . $survey_id . '&' . api_get_cidReq());
$form->addElement('header', '', $tool_name);
// Course users
$complete_user_list = CourseManager::get_user_list_from_course_code(api_get_course_id(), api_get_session_id(), '', api_sort_by_first_name() ? 'ORDER BY firstname' : 'ORDER BY lastname');
$possible_users = array();
foreach ($complete_user_list as &$user) {
    $possible_users[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
}
$users = $form->addElement('advmultiselect', 'course_users', get_lang('CourseUsers'), $possible_users, 'style="width: 250px; height: 200px;"');
$users->setElementTemplate('
{javascript}
<table{class}>
<!-- BEGIN label_2 --><tr><th>{label_2}</th><!-- END label_2 -->
<!-- BEGIN label_3 --><th>&nbsp;</th><th>{label_3}</th></tr><!-- END label_3 -->
<tr>
  <td valign="top">{unselected}</td>
Пример #12
0
            $dispid = substr($disp[$i], 8, strlen($disp[$i]));
            $query = "UPDATE {$tbl_lp_item} SET display_order = " . $listingCounter . " WHERE id = " . $dispid;
            $result = api_sql_query($query, __FILE__, __LINE__);
            $listingCounter = $listingCounter + 1;
        }
    } elseif ($dispaction == "sortlp") {
        $listingCounter = 1;
        $disp = explode(",", $updateRecordsArray);
        $cntdispid = sizeof($disp);
        for ($i = 0; $i < $cntdispid; $i++) {
            $dispid = substr($disp[$i], 8, strlen($disp[$i]));
            $query = "UPDATE {$lp_table} SET display_order = " . $listingCounter . " WHERE id = " . $dispid;
            $result = api_sql_query($query, __FILE__, __LINE__);
            $listingCounter = $listingCounter + 1;
        }
        echo '<script type="text/javascript">window.location.href="lp_controller.php?' . api_get_cidReq() . '&action=course"</script>';
    }
}
$lp_controller_touched = 1;
$lp_found = false;
if (isset($_SESSION['lpobject'])) {
    if ($debug > 0) {
        error_log('New LP - SESSION[lpobject] is defined', 0);
    }
    $oLP = unserialize($_SESSION['lpobject']);
    if (is_object($oLP)) {
        if ($debug > 0) {
            error_log('New LP - oLP is object', 0);
        }
        $_SESSION['oLP'] = $oLP;
        $lp_found = true;
Пример #13
0
    $nameTools = get_lang('PropModify');
}
$htmlHeadXtra[] = '<script>
$(document).ready( function() {
    $("#max_member").on("focus", function() {
        $("#max_member_selected").attr("checked", true);
    });
});
 </script>';
$interbreadcrumb[] = array('url' => 'group.php?' . api_get_cidReq(), 'name' => get_lang('Groups'));
$course_id = api_get_course_int_id();
// Build the form
if (isset($_GET['id'])) {
    // Update settings of existing category
    $action = 'update_settings';
    $form = new FormValidator('group_category', 'post', api_get_self() . '?id=' . $category['id'] . '&' . api_get_cidReq());
    $form->addElement('hidden', 'id');
} else {
    // Checks if the field was created in the table Category. It creates it if is neccesary
    $table_category = Database::get_course_table(TABLE_GROUP_CATEGORY);
    if (!Database::query("SELECT wiki_state FROM {$table_category} WHERE c_id = {$course_id}")) {
        Database::query("ALTER TABLE {$table_category} ADD wiki_state tinyint(3) UNSIGNED NOT NULL default '1' WHERE c_id = {$course_id}");
    }
    // Create a new category
    $action = 'add_category';
    $form = new FormValidator('group_category');
}
// If categories allowed, show title & description field
if (api_get_setting('allow_group_categories') == 'true') {
    $form->addElement('header', $nameTools);
    $form->addElement('html', '<div class="row"><div class="col-md-6">');
Пример #14
0
/**
 * Handles a given Excel spreadsheets as in the template provided
 */
function lp_upload_quiz_action_handling()
{
    global $debug;
    $_course = api_get_course_info();
    if (!isset($_POST['submit_upload_quiz'])) {
        return;
    }
    // Get the extension of the document.
    $path_info = pathinfo($_FILES['user_upload_quiz']['name']);
    // Check if the document is an Excel document
    if ($path_info['extension'] != 'xls') {
        return;
    }
    // Read the Excel document
    $data = new Spreadsheet_Excel_Reader();
    // Set output Encoding.
    $data->setOutputEncoding(api_get_system_encoding());
    // Reading the xls document.
    $data->read($_FILES['user_upload_quiz']['tmp_name']);
    // Variables
    $quiz_index = 0;
    $question_title_index = array();
    $question_name_index_init = array();
    $question_name_index_end = array();
    $score_index = array();
    $feedback_true_index = array();
    $feedback_false_index = array();
    $number_questions = 0;
    // Reading all the first column items sequencially to create breakpoints
    for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
        if ($data->sheets[0]['cells'][$i][1] == 'Quiz' && $i == 1) {
            $quiz_index = $i;
            // Quiz title position, only occurs once
        } elseif ($data->sheets[0]['cells'][$i][1] == 'Question') {
            $question_title_index[] = $i;
            // Question title position line
            $question_name_index_init[] = $i + 1;
            // Questions name 1st position line
            $number_questions++;
        } elseif ($data->sheets[0]['cells'][$i][1] == 'Score') {
            $question_name_index_end[] = $i - 1;
            // Question name position
            $score_index[] = $i;
            // Question score position
        } elseif ($data->sheets[0]['cells'][$i][1] == 'FeedbackTrue') {
            $feedback_true_index[] = $i;
            // FeedbackTrue position (line)
        } elseif ($data->sheets[0]['cells'][$i][1] == 'FeedbackFalse') {
            $feedback_false_index[] = $i;
            // FeedbackFalse position (line)
        }
    }
    // Variables
    $quiz = array();
    $question = array();
    $answer = array();
    $new_answer = array();
    $score_list = array();
    $feedback_true_list = array();
    $feedback_false_list = array();
    // Get questions
    $k = $z = $q = $l = 0;
    for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
        if (is_array($data->sheets[0]['cells'][$i])) {
            $column_data = $data->sheets[0]['cells'][$i];
            // Fill all column with data to have a full array
            for ($x = 1; $x <= $data->sheets[0]['numCols']; $x++) {
                if (empty($column_data[$x])) {
                    $data->sheets[0]['cells'][$i][$x] = '';
                }
            }
            // Array filled with data
            $column_data = $data->sheets[0]['cells'][$i];
        } else {
            $column_data = '';
        }
        // Fill quiz data
        if ($quiz_index == $i) {
            // The title always in the first position
            $quiz = $column_data;
        } elseif (in_array($i, $question_title_index)) {
            $question[$k] = $column_data;
            //a complete line where 1st column is 'Question'
            $k++;
        } elseif (in_array($i, $score_index)) {
            $score_list[$z] = $column_data;
            //a complete line where 1st column is 'Score'
            $z++;
        } elseif (in_array($i, $feedback_true_index)) {
            $feedback_true_list[$q] = $column_data;
            //a complete line where 1st column is 'FeedbackTrue'
            $q++;
        } elseif (in_array($i, $feedback_false_index)) {
            $feedback_false_list[$l] = $column_data;
            //a complete line where 1st column is 'FeedbackFalse' for wrong answers
            $l++;
        }
    }
    // Get answers
    for ($i = 0; $i < count($question_name_index_init); $i++) {
        for ($j = $question_name_index_init[$i]; $j <= $question_name_index_end[$i]; $j++) {
            if (is_array($data->sheets[0]['cells'][$j])) {
                $column_data = $data->sheets[0]['cells'][$j];
                // Fill all column with data
                for ($x = 1; $x <= $data->sheets[0]['numCols']; $x++) {
                    if (empty($column_data[$x])) {
                        $data->sheets[0]['cells'][$j][$x] = '';
                    }
                }
                $column_data = $data->sheets[0]['cells'][$j];
                // Array filled of data
                if (is_array($data->sheets[0]['cells'][$j]) && count($data->sheets[0]['cells'][$j]) > 0) {
                    $new_answer[$i][$j] = $data->sheets[0]['cells'][$j];
                }
            }
        }
    }
    $quiz_title = $quiz[2];
    // Quiz title
    if ($quiz_title != '') {
        // Variables
        $type = 2;
        $random = $active = $results = $max_attempt = $expired_time = 0;
        //make sure feedback is enabled (3 to disable), otherwise the fields
        // added to the XLS are not shown, which is confusing
        $feedback = 0;
        // Quiz object
        $quiz_object = new Exercise();
        $quiz_id = $quiz_object->create_quiz($quiz_title, $expired_time, $type, $random, $active, $results, $max_attempt, $feedback);
        if ($quiz_id) {
            // insert into the item_property table
            api_item_property_update($_course, TOOL_QUIZ, $quiz_id, 'QuizAdded', api_get_user_id());
            // Import questions
            for ($i = 0; $i < $number_questions; $i++) {
                // Create questions
                $question_title = $question[$i][2];
                // Question name
                // Unique answers are the only question types available for now
                // through xls-format import
                $unique_answer = new UniqueAnswer();
                if ($question_title != '') {
                    $question_id = $unique_answer->create_question($quiz_id, $question_title);
                }
                if (is_array($new_answer[$i])) {
                    $id = 1;
                    $answers_data = $new_answer[$i];
                    foreach ($answers_data as $answer_data) {
                        $answer = $answer_data[2];
                        $correct = 0;
                        $score = 0;
                        $comment = '';
                        if (strtolower($answer_data[3]) == 'x') {
                            $correct = 1;
                            $score = $score_list[$i][3];
                            $comment = $feedback_true_list[$i][2];
                        } else {
                            $comment = $feedback_false_list[$i][2];
                        }
                        // Create answer
                        $unique_answer->create_answer($id, $question_id, $answer, $comment, $score, $correct);
                        $id++;
                    }
                }
            }
        }
        if (isset($_SESSION['lpobject'])) {
            if ($debug > 0) {
                error_log('New LP - SESSION[lpobject] is defined', 0);
            }
            $oLP = unserialize($_SESSION['lpobject']);
            if (is_object($oLP)) {
                if ($debug > 0) {
                    error_log('New LP - oLP is object', 0);
                }
                if (empty($oLP->cc) or $oLP->cc != api_get_course_id()) {
                    if ($debug > 0) {
                        error_log('New LP - Course has changed, discard lp object', 0);
                    }
                    $oLP = null;
                    Session::erase('oLP');
                    Session::erase('lpobject');
                } else {
                    $_SESSION['oLP'] = $oLP;
                    $lp_found = true;
                }
            }
        }
        if (isset($_SESSION['oLP']) && isset($_GET['lp_id'])) {
            $previous = $_SESSION['oLP']->select_previous_item_id();
            $parent = 0;
            // Add a Quiz as Lp Item
            $_SESSION['oLP']->add_item($parent, $previous, TOOL_QUIZ, $quiz_id, $quiz_title, '');
            // Redirect to home page for add more content
            header('Location: ' . api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?' . api_get_cidreq() . '&action=add_item&type=step&lp_id=' . Security::remove_XSS($_GET['lp_id']) . '&session_id=' . api_get_session_id());
            exit;
        } else {
            echo '<script>window.location.href = "' . api_get_path(WEB_CODE_PATH) . 'exercice/admin.php?' . api_get_cidReq() . '&exerciseId=' . $quiz_id . '&session_id=' . api_get_session_id() . '"</script>';
        }
    }
}
Пример #15
0
/**
 * Handles a given Excel spreadsheets as in the template provided
 */
function lp_upload_quiz_action_handling()
{
    global $debug;
    $_course = api_get_course_info();
    $courseId = $_course['real_id'];
    if (!isset($_POST['submit_upload_quiz'])) {
        return;
    }
    // Get the extension of the document.
    $path_info = pathinfo($_FILES['user_upload_quiz']['name']);
    // Check if the document is an Excel document
    if ($path_info['extension'] != 'xls') {
        return;
    }
    // Read the Excel document
    $data = new Spreadsheet_Excel_Reader();
    // Set output Encoding.
    $data->setOutputEncoding(api_get_system_encoding());
    // Reading the xls document.
    $data->read($_FILES['user_upload_quiz']['tmp_name']);
    $correctScore = isset($_POST['correct_score']) ? $_POST['correct_score'] : null;
    $incorrectScore = isset($_POST['incorrect_score']) ? $_POST['incorrect_score'] : null;
    $useCustomScore = isset($_POST['user_custom_score']) ? true : false;
    $propagateNegative = 0;
    if ($useCustomScore && !empty($incorrectScore)) {
        if ($incorrectScore < 0) {
            $propagateNegative = 1;
        }
    }
    // Variables
    $quiz_index = 0;
    $question_title_index = array();
    $question_name_index_init = array();
    $question_name_index_end = array();
    $score_index = array();
    $feedback_true_index = array();
    $feedback_false_index = array();
    $number_questions = 0;
    $question_description_index = array();
    // Reading all the first column items sequentially to create breakpoints
    for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
        if ($data->sheets[0]['cells'][$i][1] == 'Quiz' && $i == 1) {
            $quiz_index = $i;
            // Quiz title position, only occurs once
        } elseif ($data->sheets[0]['cells'][$i][1] == 'Question') {
            $question_title_index[] = $i;
            // Question title position line
            $question_name_index_init[] = $i + 1;
            // Questions name 1st position line
            $number_questions++;
        } elseif ($data->sheets[0]['cells'][$i][1] == 'Score') {
            $question_name_index_end[] = $i - 1;
            // Question name position
            $score_index[] = $i;
            // Question score position
        } elseif ($data->sheets[0]['cells'][$i][1] == 'FeedbackTrue') {
            $feedback_true_index[] = $i;
            // FeedbackTrue position (line)
        } elseif ($data->sheets[0]['cells'][$i][1] == 'FeedbackFalse') {
            $feedback_false_index[] = $i;
            // FeedbackFalse position (line)
        } elseif ($data->sheets[0]['cells'][$i][1] == 'EnrichQuestion') {
            $question_description_index[] = $i;
        }
    }
    // Variables
    $quiz = array();
    $question = array();
    $new_answer = array();
    $score_list = array();
    $feedback_true_list = array();
    $feedback_false_list = array();
    $question_description = array();
    // Getting questions.
    $k = $z = $q = $l = $m = 0;
    for ($i = 1; $i <= $data->sheets[0]['numRows']; $i++) {
        if (is_array($data->sheets[0]['cells'][$i])) {
            $column_data = $data->sheets[0]['cells'][$i];
            // Fill all column with data to have a full array
            for ($x = 1; $x <= $data->sheets[0]['numCols']; $x++) {
                if (empty($column_data[$x])) {
                    $data->sheets[0]['cells'][$i][$x] = '';
                }
            }
            // Array filled with data
            $column_data = $data->sheets[0]['cells'][$i];
        } else {
            $column_data = '';
        }
        // Fill quiz data
        if ($quiz_index == $i) {
            // The title always in the first position
            $quiz = $column_data;
        } elseif (in_array($i, $question_title_index)) {
            //a complete line where 1st column is 'Question'
            $question[$k] = $column_data;
            $k++;
        } elseif (in_array($i, $score_index)) {
            //a complete line where 1st column is 'Score'
            $score_list[$z] = $column_data;
            $z++;
        } elseif (in_array($i, $feedback_true_index)) {
            //a complete line where 1st column is 'FeedbackTrue'
            $feedback_true_list[$q] = $column_data;
            $q++;
        } elseif (in_array($i, $feedback_false_index)) {
            //a complete line where 1st column is 'FeedbackFalse' for wrong answers
            $feedback_false_list[$l] = $column_data;
            $l++;
        } elseif (in_array($i, $question_description_index)) {
            //a complete line where 1st column is 'EnrichQuestion'
            $question_description[$m] = $column_data;
            $m++;
        }
    }
    // Get answers
    for ($i = 0; $i < count($question_name_index_init); $i++) {
        for ($j = $question_name_index_init[$i]; $j <= $question_name_index_end[$i]; $j++) {
            if (is_array($data->sheets[0]['cells'][$j])) {
                $column_data = $data->sheets[0]['cells'][$j];
                // Fill all column with data
                for ($x = 1; $x <= $data->sheets[0]['numCols']; $x++) {
                    if (empty($column_data[$x])) {
                        $data->sheets[0]['cells'][$j][$x] = '';
                    }
                }
                $column_data = $data->sheets[0]['cells'][$j];
                // Array filled of data
                if (is_array($data->sheets[0]['cells'][$j]) && count($data->sheets[0]['cells'][$j]) > 0) {
                    $new_answer[$i][$j] = $data->sheets[0]['cells'][$j];
                }
            }
        }
    }
    // Quiz title.
    $quiz_title = $quiz[2];
    if ($quiz_title != '') {
        // Variables
        $type = 2;
        $random = $active = $results = $max_attempt = $expired_time = 0;
        // Make sure feedback is enabled (3 to disable), otherwise the fields
        // added to the XLS are not shown, which is confusing
        $feedback = 0;
        // Quiz object
        $exercise = new Exercise();
        //
        $quiz_id = $exercise->createExercise($quiz_title, $expired_time, $type, $random, $active, $results, $max_attempt, $feedback, $propagateNegative);
        if ($quiz_id) {
            // insert into the item_property table
            api_item_property_update($_course, TOOL_QUIZ, $quiz_id, 'QuizAdded', api_get_user_id());
            // Import questions.
            for ($i = 0; $i < $number_questions; $i++) {
                // Question name
                $question_title = $question[$i][2];
                $question_description_text = "<p></p>";
                if (isset($question_description[$i][2])) {
                    // Question description.
                    $question_description_text = "<p>" . $question_description[$i][2] . "</p>";
                }
                // Unique answers are the only question types available for now
                // through xls-format import
                $question_id = null;
                $detectQuestionType = detectQuestionType($new_answer[$i], $score_list);
                /** @var Question $answer */
                switch ($detectQuestionType) {
                    case FREE_ANSWER:
                        $answer = new FreeAnswer();
                        break;
                    case GLOBAL_MULTIPLE_ANSWER:
                        $answer = new GlobalMultipleAnswer();
                        break;
                    case MULTIPLE_ANSWER:
                        $answer = new MultipleAnswer();
                        break;
                    case UNIQUE_ANSWER:
                    default:
                        $answer = new UniqueAnswer();
                        break;
                }
                if ($question_title != '') {
                    $question_id = $answer->create_question($quiz_id, $question_title, $question_description_text, 0, $answer->type);
                }
                $total = 0;
                if (is_array($new_answer[$i]) && !empty($question_id)) {
                    $id = 1;
                    $answers_data = $new_answer[$i];
                    $globalScore = null;
                    $objAnswer = new Answer($question_id, $courseId);
                    $globalScore = $score_list[$i][3];
                    // Calculate the number of correct answers to divide the
                    // score between them when importing from CSV
                    $numberRightAnswers = 0;
                    foreach ($answers_data as $answer_data) {
                        if (strtolower($answer_data[3]) == 'x') {
                            $numberRightAnswers++;
                        }
                    }
                    foreach ($answers_data as $answer_data) {
                        $answerValue = $answer_data[2];
                        $correct = 0;
                        $score = 0;
                        if (strtolower($answer_data[3]) == 'x') {
                            $correct = 1;
                            $score = $score_list[$i][3];
                            $comment = $feedback_true_list[$i][2];
                        } else {
                            $comment = $feedback_false_list[$i][2];
                            $floatVal = (double) $answer_data[3];
                            if (is_numeric($floatVal)) {
                                $score = $answer_data[3];
                            }
                        }
                        if ($useCustomScore) {
                            if ($correct) {
                                $score = $correctScore;
                            } else {
                                $score = $incorrectScore;
                            }
                        }
                        // Fixing scores:
                        switch ($detectQuestionType) {
                            case GLOBAL_MULTIPLE_ANSWER:
                                $score /= $numberRightAnswers;
                                break;
                            case UNIQUE_ANSWER:
                                break;
                            case MULTIPLE_ANSWER:
                                if (!$correct) {
                                    //$total = $total - $score;
                                }
                                break;
                        }
                        $objAnswer->createAnswer($answerValue, $correct, $comment, $score, $id);
                        $total += $score;
                        $id++;
                    }
                    $objAnswer->save();
                    $questionObj = Question::read($question_id, $courseId);
                    switch ($detectQuestionType) {
                        case GLOBAL_MULTIPLE_ANSWER:
                            $questionObj->updateWeighting($globalScore);
                            break;
                        case UNIQUE_ANSWER:
                        case MULTIPLE_ANSWER:
                        default:
                            $questionObj->updateWeighting($total);
                            break;
                    }
                    $questionObj->save();
                } else {
                    if ($detectQuestionType === FREE_ANSWER) {
                        $questionObj = Question::read($question_id, $courseId);
                        $globalScore = $score_list[$i][3];
                        $questionObj->updateWeighting($globalScore);
                        $questionObj->save();
                    }
                }
            }
        }
        if (isset($_SESSION['lpobject'])) {
            if ($debug > 0) {
                error_log('New LP - SESSION[lpobject] is defined', 0);
            }
            $oLP = unserialize($_SESSION['lpobject']);
            if (is_object($oLP)) {
                if ($debug > 0) {
                    error_log('New LP - oLP is object', 0);
                }
                if (empty($oLP->cc) or $oLP->cc != api_get_course_id()) {
                    if ($debug > 0) {
                        error_log('New LP - Course has changed, discard lp object', 0);
                    }
                    $oLP = null;
                    Session::erase('oLP');
                    Session::erase('lpobject');
                } else {
                    $_SESSION['oLP'] = $oLP;
                }
            }
        }
        if (isset($_SESSION['oLP']) && isset($_GET['lp_id'])) {
            $previous = $_SESSION['oLP']->select_previous_item_id();
            $parent = 0;
            // Add a Quiz as Lp Item
            $_SESSION['oLP']->add_item($parent, $previous, TOOL_QUIZ, $quiz_id, $quiz_title, '');
            // Redirect to home page for add more content
            header('location: ../newscorm/lp_controller.php?' . api_get_cidreq() . '&action=add_item&type=step&lp_id=' . Security::remove_XSS($_GET['lp_id']));
            exit;
        } else {
            //  header('location: exercise.php?' . api_get_cidreq());
            echo '<script>window.location.href = "' . api_get_path(WEB_CODE_PATH) . 'exercice/admin.php?' . api_get_cidReq() . '&exerciseId=' . $quiz_id . '&session_id=' . api_get_session_id() . '"</script>';
        }
    }
}
Пример #16
0
<?php

//require_once '../inc/global.inc.php';
header('location: ' . api_get_path(WEB_CODE_PATH) . 'survey/survey_list.php?' . api_get_cidReq());
exit;
Пример #17
0
 *
 *	@author various contributors
 *	@author Roan Embrechts (VUB), partial code cleanup, initial virtual course support
 *	@package chamilo.group
 *	@todo course admin functionality to create groups based on who is in which course (or class).
 */
//require_once '../inc/global.inc.php';
$this_section = SECTION_COURSES;
$current_course_tool = TOOL_GROUP;
// Notice for unauthorized people.
api_protect_course_script(true);
$group_id = api_get_group_id();
$current_group = GroupManager::get_group_properties($group_id);
$nameTools = get_lang('EditGroup');
$interbreadcrumb[] = array('url' => 'group.php', 'name' => get_lang('Groups'));
$interbreadcrumb[] = array('url' => 'group_space.php?' . api_get_cidReq(), 'name' => $current_group['name']);
$is_group_member = GroupManager::is_tutor_of_group(api_get_user_id(), $group_id);
if (!api_is_allowed_to_edit(false, true) && !$is_group_member) {
    api_not_allowed(true);
}
/**
 *  List all users registered to the course
 */
function search_members_keyword($firstname, $lastname, $username, $official_code, $keyword)
{
    if (api_strripos($firstname, $keyword) !== false || api_strripos($lastname, $keyword) !== false || api_strripos($username, $keyword) !== false || api_strripos($official_code, $keyword) !== false) {
        return true;
    } else {
        return false;
    }
}
    case 'download':
        $userId = isset($_GET['user_id']) && $_GET['user_id'] ? $_GET['user_id'] : null;
        $cats = Category::load($cat_id, null, null, null, null, null, false);
        GradebookUtils::generateTable($userId, $cats);
        break;
}
$course_code = api_get_course_id();
$interbreadcrumb[] = array('url' => Security::remove_XSS($_SESSION['gradebook_dest']) . '?', 'name' => get_lang('Gradebook'));
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('GradebookListOfStudentsReports'));
$this_section = SECTION_COURSES;
Display::display_header('');
$token = Security::get_token();
echo Display::page_header(get_lang('GradebookListOfStudentsReports'));
echo '<div class="btn-group">';
if (count($userList) > 0) {
    $url = api_get_self() . '?action=export_all&' . api_get_cidReq() . '&selectcat=' . $cat_id;
    echo Display::url(get_lang('ExportAllToPDF'), $url, array('class' => 'btn btn-default'));
}
echo '</div>';
if (count($userList) == 0) {
    echo Display::display_warning_message(get_lang('NoResultsAvailable'));
} else {
    echo '<br /><br /><table class="data_table">';
    foreach ($userList as $index => $value) {
        echo '<tr>
                <td width="100%" >' . get_lang('Student') . ' : ' . api_get_person_name($value['firstname'], $value['lastname']) . ' (' . $value['username'] . ') </td>';
        echo '<td>';
        $url = api_get_self() . '?' . api_get_cidreq() . '&action=download&user_id=' . $value['user_id'] . '&selectcat=' . $cat_id;
        $link = Display::url(get_lang('ExportToPDF'), $url, array('target' => '_blank', 'class' => 'btn btn-default'));
        echo $link;
        echo '</td></tr>';