Removing require_once for "fckeditor.php" and tracking.lib.php already loaded in the autoloader

skala
Julio Montoya 12 years ago
parent 482c45f088
commit dca6d44591
  1. 22
      main/admin/calendar.lib.php
  2. 3
      main/announcements/announcements.php
  3. 7
      main/blog/blog.php
  4. 1
      main/calendar/agenda.inc.php
  5. 6
      main/calendar/myagenda.inc.php
  6. 7
      main/exercice/exercise.lib.php
  7. 184
      main/exercice/hotspot_admin.inc.php
  8. 3
      main/inc/lib/auth.lib.php
  9. 256
      main/inc/lib/document.lib.php
  10. 3
      main/inc/lib/formvalidator/Element/html_editor.php
  11. 186
      main/inc/lib/grade_model.lib.php
  12. 2
      main/inc/lib/main_api.lib.php
  13. 2
      main/inc/lib/tracking.lib.php

@ -1475,15 +1475,11 @@ function show_add_form($id = '') {
<input type="text" size="60" name="title" value="<?php if (isset($title)) echo $title; ?>" />
</td>
</tr>
<tr>
<td colspan="4">
<?php
require_once api_get_path(LIBRARY_PATH) . "/fckeditor/fckeditor.php";
$oFCKeditor = new FCKeditor('content') ;
$oFCKeditor->ToolbarSet = 'GlobalAgenda';
$oFCKeditor->Width = '100%';
$oFCKeditor->Height = '175';
@ -1496,25 +1492,11 @@ function show_add_form($id = '') {
?>
</td>
</tr>
<!--<?php /* ADDED BY UGENT, Patrick Cool, march 2004 */ ?>
<tr>
<td colspan="4">
<?php
//onclick="selectAll(this.form.elements[6],true)"
// show_addresource_button('onclick="selectAll(this.form.elements[6],true)"');
?>
</td>
</tr>-->
<?php
//if ($_SESSION['addedresource'])
echo "<tr>\n";
echo "<td colspan=\"4\">\n";
//echo display_resources(0);//--------------------------------------------------------
echo "<td colspan=\"4\">";
$test=$_SESSION['addedresource'];
echo "</td>\n</tr>\n";
/* END ADDED BY UGENT, Patrick Cool, march 2004 */
echo "</td>\n</tr>";
if(empty($id)) //only show repeat fields when adding the first time
{
?>

@ -55,7 +55,6 @@ $tbl_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY);
/* Libraries */
$lib = api_get_path(LIBRARY_PATH); //avoid useless function calls
require_once $lib.'fckeditor/fckeditor.php';
require_once $lib.'fileUpload.lib.php';
$course_id = api_get_course_int_id();
@ -328,7 +327,7 @@ if (AnnouncementManager::user_can_edit_announcement()){
$newContent = (!empty($_POST['newContent']) ? $safe_newContent : '');
$submitAnnouncement = isset($_POST['submitAnnouncement']) ? $_POST['submitAnnouncement'] : 0;
$id = 0;
if (!empty($_POST['id'])) {
$id = intval($_POST['id']);

@ -26,12 +26,7 @@ if(isset($_GET['id_session'])) {
$_SESSION['id_session'] = intval($_GET['id_session']);
}
$lib_path = api_get_path(LIBRARY_PATH);
require_once $lib_path.'blog.lib.php';
require_once $lib_path.'fckeditor/fckeditor.php';
$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
$nameTools = get_lang('Blogs');
$DaysShort = api_get_week_days_short();
$DaysLong = api_get_week_days_long();
@ -302,7 +297,7 @@ Blog :: display_minimonthcalendar($month, $year, $blog_id);
<?php Blog::get_personal_task_list(); ?>
</td>
</tr>
</table>
</table>
</td>
<td valign="top" class="blog_right">
<?php

@ -2673,7 +2673,6 @@ function show_add_form($id = '')
<span class="form_required">*</span>'.get_lang('Description').'
</label>
<div class="controls">';
require_once api_get_path(LIBRARY_PATH)."/fckeditor/fckeditor.php";
$oFCKeditor = new FCKeditor('content');
$oFCKeditor->Width = '100%';
$oFCKeditor->Height = '200';

@ -477,14 +477,12 @@ function show_new_personal_item_form($id = "") {
echo "<option value=\"55\">55</option>";
echo '</select>';
echo '</div><br/>';
// ********** The title field ********** \\
echo '<div>';
echo ''.get_lang('Title').' : <input type="text" name="frm_title" size="50" value="'.$title.'" />';
echo '</div>';
// ********** The text field ********** \\
echo '<br /><div class="formw">';
require_once api_get_path(LIBRARY_PATH) . "/fckeditor/fckeditor.php";
echo '<br /><div class="formw">';
$oFCKeditor = new FCKeditor('frm_content') ;

@ -13,8 +13,6 @@
/**
* Code
*/
// The initialization class for the online editor is needed here.
require_once dirname(__FILE__).'/../inc/lib/fckeditor/fckeditor.php';
/**
* Shows a question
@ -829,7 +827,6 @@ function get_count_exam_hotpotatoes_results($in_hotpot_path)
//function get_exam_results_hotpotatoes_data($from, $number_of_items, $column, $direction, $exercise_id, $extra_where_conditions = null, $get_count = false) {
function get_exam_results_hotpotatoes_data($in_from, $in_number_of_items, $in_column, $in_direction, $in_hotpot_path, $in_get_count = false, $where_condition = null)
{
$tab_res = array();
$course_code = api_get_course_id();
// by default in_column = 1 If parameters given, it is the name of the column witch is the bdd field name
@ -874,8 +871,6 @@ function get_exam_results_hotpotatoes_data($in_from, $in_number_of_items, $in_co
*/
function get_exam_results_data($from, $number_of_items, $column, $direction, $exercise_id, $extra_where_conditions = null, $get_count = false)
{
//@todo replace all this globals
global $documentPath, $filter;
@ -2149,7 +2144,7 @@ function display_question_list_by_attempt($objExercise, $exe_id, $save_user_resu
// We're inside *one* question. Go through each possible answer for this question
$result = $objExercise->manage_answer($exercise_stat_info['exe_id'], $questionId, null, 'exercise_result', array(), $save_user_result, true, $show_results, $objExercise->selectPropagateNeg(), $hotspot_delineation_result);
if (empty($result)) {
continue;
}

@ -1,7 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This script allows to manage answers. It is included from the
* This script allows to manage answers. It is included from the
* script admin.php
* @package chamilo.exercise
* @author Toon Keppens
@ -227,8 +227,8 @@ if ($submitAnswers || $buttonBack) {
break;
}
} // end for()
//now the noerror section
//now the noerror section
$select_question_noerror = $_POST['select_question_noerror'];
$lp_noerror = $_POST['lp_noerror'];
$try_noerror = $_POST['try_noerror'];
@ -274,7 +274,7 @@ if ($submitAnswers || $buttonBack) {
if ($weighting[$i]) {
$questionWeighting+=$weighting[$i];
}
// creates answer
// creates answer
$objAnswer->createAnswer($reponse[$i], '', $comment[$i], $weighting[$i], $i, $hotspot_coordinates[$i], $hotspot_type[$i], $destination[$i]);
} // end for()
// saves the answers into the data base
@ -370,7 +370,7 @@ if ($modifyAnswers) {
}
if ($answerType == HOT_SPOT_DELINEATION) {
//added the noerror answer
//added the noerror answer
$reponse_noerror = 'noerror';
$comment_noerror = $objAnswer->selectComment($nbrAnswers + 1);
$destination_noerror_list = $objAnswer->selectDestination($nbrAnswers + 1);
@ -451,7 +451,7 @@ if ($modifyAnswers) {
if ($moreOARAnswers) {
if ($nbrAnswers < 12) {
// Add a new answer
// Add a new answer
$nbrAnswers++;
$_SESSION['tmp_answers']['answer'][] = '';
@ -507,24 +507,24 @@ if ($modifyAnswers) {
//ie6 fix
if ($navigator_info['name'] == 'Internet Explorer' && $navigator_info['version'] == '6') {
?>
<?php if ($answerType == HOT_SPOT_DELINEATION) { ?>
<?php if ($answerType == HOT_SPOT_DELINEATION) { ?>
<input type="submit" class="btn minus" name="lessAnswers" value="<?php echo get_lang('LessOAR'); ?>" >
<input type="submit" class="btn plus" name="moreOARAnswers" value="<?php echo get_lang('MoreOAR'); ?>" />
<?php } else { ?>
<input type="submit" class="btn minus" name="lessAnswers" value="<?php echo get_lang('LessHotspots'); ?>" >
<input type="submit" class="btn plus" name="moreAnswers" value="<?php echo get_lang('MoreHotspots'); ?>" />
<?php } ?>
<input type="submit" class="btn save" name="submitAnswers" value="<?php echo get_lang('Ok'); ?>" />
<input type="submit" class="btn plus" name="moreAnswers" value="<?php echo get_lang('MoreHotspots'); ?>" />
<?php } ?>
<input type="submit" class="btn save" name="submitAnswers" value="<?php echo get_lang('Ok'); ?>" />
<?php
} else {
if ($answerType == HOT_SPOT_DELINEATION) {
?>
?>
<button type="submit" class="btn minus" name="lessAnswers" value="<?php echo get_lang('LessOAR'); ?>" ><?php echo get_lang('LessOAR'); ?></button>
<button type="submit" class="btn plus" name="moreOARAnswers" value="<?php echo get_lang('MoreOAR'); ?>" /><?php echo get_lang('MoreOAR'); ?></button>
<?php } else { ?>
<button type="submit" class="btn minus" name="lessAnswers" value="<?php echo get_lang('LessHotspots'); ?>" ><?php echo get_lang('LessHotspots'); ?></button>
<button type="submit" class="btn plus" name="moreAnswers" value="<?php echo get_lang('MoreHotspots'); ?>" /><?php echo get_lang('MoreHotspots'); ?></button>
<button type="submit" class="btn plus" name="moreAnswers" value="<?php echo get_lang('MoreHotspots'); ?>" /><?php echo get_lang('MoreHotspots'); ?></button>
<?php } ?>
<button type="submit" class="btn save" name="submitAnswers" value="<?php echo get_lang('Ok'); ?>" /><?php echo get_lang('AddQuestionToExercise'); ?></button>
<?php
@ -533,7 +533,7 @@ if ($modifyAnswers) {
</td>
</tr>
<tr>
<td valign="top">
<td valign="top">
<input type="hidden" name="formSent" value="1" />
<input type="hidden" name="nbrAnswers" value="<?php echo $nbrAnswers; ?>" />
<table class="data_table">
@ -544,18 +544,18 @@ if ($modifyAnswers) {
-->
<tr>
<th width="5">&nbsp;<?php /* echo get_lang('Hotspot'); */ ?></th>
<th><?php echo get_lang('HotspotDescription'); ?> *</th>
<th><?php echo get_lang('HotspotDescription'); ?> *</th>
<?php if ($answerType == HOT_SPOT_DELINEATION) echo '<th >' . get_lang('Thresholds') . '</th>'; ?>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?>
<th><?php echo get_lang('Comment'); ?></th>
<?php if ($answerType == HOT_SPOT_DELINEATION) echo '<th >' . get_lang('Scenario') . '</th>'; ?>
<th><?php echo get_lang('Comment'); ?></th>
<?php if ($answerType == HOT_SPOT_DELINEATION) echo '<th >' . get_lang('Scenario') . '</th>'; ?>
<?php } else { ?>
<th colspan="2"><?php echo get_lang('Comment'); ?></th>
<?php } ?>
<th colspan="2"><?php echo get_lang('Comment'); ?></th>
<?php } ?>
<th><?php echo get_lang('QuestionWeighting'); ?> *</th>
<th><?php echo get_lang('QuestionWeighting'); ?> *</th>
</tr>
</tr>
<?php
require_once '../newscorm/learnpathList.class.php';
$list = new LearnpathList(api_get_user_id());
@ -568,7 +568,7 @@ if ($modifyAnswers) {
$select_lp_id = array();
$option_lp = '';
// setting the LP
// setting the LP
$is_selected = false;
foreach ($flat_list as $id => $details) {
$select_lp_id[$id] = $details['lp_name'];
@ -585,7 +585,7 @@ if ($modifyAnswers) {
$option_lp = '<option value="0" selected="selected" >' . get_lang('SelectTargetLP') . '</option>' . $option_lp;
}
//Feedback SELECT
//Feedback SELECT
$question_list = $objExercise->selectQuestionList();
$option_feed = '';
$option_feed.='<option value="0">' . get_lang('SelectTargetQuestion') . '</option>';
@ -605,7 +605,7 @@ if ($modifyAnswers) {
else
$option_feed.='<option value="-1">' . get_lang('ExitTest') . '</option>';
//-------- IF it is a delineation
//-------- IF it is a delineation
if ($_SESSION['tmp_answers']['hotspot_type'][$i] == 'delineation') {
for ($k = 1; $k <= 100; $k++) {
@ -621,7 +621,7 @@ if ($modifyAnswers) {
$option3.='<option ' . $selected3 . '>' . $k . '</option>';
}
?>
<tr>
<tr>
<td valign="top">
<div style="height: 15px; width: 15px; background-color: <?php echo $hotspot_colors[$i]; ?>"> </div>
<input type="hidden" name="reponse[<?php echo $i; ?>]" value="delineation" />
@ -631,7 +631,7 @@ if ($modifyAnswers) {
<?php echo get_lang('MinOverlap'); ?><br/><br/>
<?php echo get_lang('MaxExcess'); ?><br/><br/>
<?php echo get_lang('MaxMissing'); ?><br/><br/>
</td>
</td>
<td>
<br/><br/>
<select name="threadhold1[<?php echo $i; ?>]" >
@ -641,12 +641,12 @@ if ($modifyAnswers) {
<select name="threadhold2[<?php echo $i; ?>]" >
<?php echo $option2; ?>
</select>%
<br/><br/>
<select name="threadhold3[<?php echo $i; ?>]" >
<br/><br/>
<select name="threadhold3[<?php echo $i; ?>]" >
<?php echo $option3; ?>
</select>%
<br/>
</td>
</td>
<td align="left">
<br />
@ -657,13 +657,13 @@ if ($modifyAnswers) {
<input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="<?php echo (empty($hotspot_coordinates[$i]) ? '0;0|0|0' : $hotspot_coordinates[$i]); ?>" />
<br/>
<?php echo get_lang('LearnerIsInformed'); ?>
</td>
</td>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?>
<td>
<table>
<tr>
<td>
<td>
<input type="checkbox" class="checkbox" name="<?php echo 'try[' . $i; ?>]" <?php if ($try[$i] == 1) echo'checked'; ?> />
<?php echo get_lang('TryAgain'); ?>
<br /><br />
@ -674,43 +674,43 @@ if ($modifyAnswers) {
<?php echo $option_lp; ?>
</select>
<br /><br />
<?php echo get_lang('Other'); ?> <br />
<br /><br />
<?php echo get_lang('Other'); ?> <br />
<input name="url[<?php echo $i; ?>]" value="<?php echo $url[$i]; ?>">
<br /> <br />
<?php echo get_lang('SelectQuestion'); ?> <br />
<?php echo get_lang('SelectQuestion'); ?> <br />
<select name="select_question[<?php echo $i; ?>]" >
<?php echo $option_feed; ?>
</select>
</select>
</td>
</tr>
</tr>
</table>
</td>
<?php } else { ?>
<td> &nbsp;</td>
<td> &nbsp;</td>
<?php
}
}
//elseif ($_SESSION['tmp_answers']['hotspot_type'][$i]=='noerror' || $_SESSION['tmp_answers']['answer'][$i]=='noerror')
elseif (false) {
?>
<tr>
<th colspan="2" ><?php echo get_lang('IfNoError'); ?></th>
?>
<tr>
<th colspan="2" ><?php echo get_lang('IfNoError'); ?></th>
<th colspan="3" ><?php echo get_lang('Feedback'); ?></th>
<!-- th colspan="1" ><?php echo get_lang('Scenario'); ?></th -->
<th></th>
</tr>
<tr>
<tr>
<td colspan="2" valign="top" align="left">
<?php echo get_lang('LearnerHasNoMistake'); ?>
<input type="hidden" name="reponse[<?php echo $i; ?>]" value="noerror" />
<input type="hidden" name="weighting[<?php echo $i; ?>]" value="0" />
<input type="hidden" name="hotspot_type[<?php echo $i; ?>]" value="noerror" />
<input type="hidden" name="hotspot_coordinates[<?php echo $i; ?>]" value="0;0|0|0" />
</td>
</td>
<td colspan="2" align="left">
<textarea wrap="virtual" rows="3" cols="25" name="comment[<?php echo $i; ?>]" style="width: 100%"><?php echo Security::remove_XSS($comment[$i]); ?></textarea>
</td>
@ -724,42 +724,42 @@ if ($modifyAnswers) {
<?php echo get_lang('TryAgain'); ?>
<br /><br />
<?php echo get_lang('SeeTheory'); ?> <br />
<?php echo get_lang('SeeTheory'); ?> <br />
<select name="lp[<?php echo $i; ?>]" >
<?php echo $option_lp; ?>
</select>
<br /><br />
<?php echo get_lang('Other'); ?> <br />
<?php echo get_lang('Other'); ?> <br />
<input name="url[<?php echo $i; ?>]" value="<?php echo $url[$i]; ?>">
<br /> <br />
<?php echo get_lang('SelectQuestion'); ?> <br />
<br /> <br />
<?php echo get_lang('SelectQuestion'); ?> <br />
<select name="select_question[<?php echo $i; ?>]">
<?php echo $option_feed; ?>
</select>
</td>
</tr>
</select>
</td>
</tr>
</table>
</td>
</td>
<?php } else { ?>
<td>&nbsp;</td>
<?php } ?>
<td>&nbsp;</td>
<?php } ?>
</tr>
<?php
}
// if it's an OAR
// if it's an OAR
elseif ($_SESSION['tmp_answers']['hotspot_type'][$i] == 'oar') {
if ($i == 2) {
?>
?>
<tr>
<th width="5">&nbsp;<?php /* echo get_lang('Hotspot'); */ ?></th>
<th ><?php echo get_lang('OAR'); ?>*</th>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?>
<th ><?php echo get_lang('OAR'); ?>*</th>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?>
<th colspan="2" ><?php echo get_lang('Comment'); ?></th>
<th ><?php if ($answerType == HOT_SPOT_DELINEATION) echo get_lang('Scenario'); ?></th>
<?php } else { ?>
<th colspan="3" ><?php echo get_lang('Comment'); ?></th>
<th colspan="3" ><?php echo get_lang('Comment'); ?></th>
<?php } ?>
<th>&nbsp;</th>
@ -773,7 +773,7 @@ if ($modifyAnswers) {
</td>
<td valign="top" align="left">
<input type="text" name="reponse[<?php echo $i; ?>]" value="<?php echo Security::remove_XSS($reponse[$i]); ?>" size="20" />
<input type="text" name="reponse[<?php echo $i; ?>]" value="<?php echo Security::remove_XSS($reponse[$i]); ?>" size="20" />
</td>
<td colspan="2" align="left">
@ -791,40 +791,40 @@ if ($modifyAnswers) {
<?php echo get_lang('TryAgain'); ?>
<br /><br />
<?php echo get_lang('SeeTheory'); ?> <br />
<?php echo get_lang('SeeTheory'); ?> <br />
<select name="lp[<?php echo $i; ?>]" >
<?php echo $option_lp; ?>
</select>
<br /><br />
<?php echo get_lang('Other'); ?> <br />
<br /><br />
<?php echo get_lang('Other'); ?> <br />
<input name="url[<?php echo $i; ?>]" value="<?php echo $url[$i]; ?>">
<br /><br />
<?php echo get_lang('SelectQuestion'); ?> <br />
<br /><br />
<?php echo get_lang('SelectQuestion'); ?> <br />
<select name="select_question[<?php echo $i; ?>]">
<?php echo $option_feed; ?>
</select>
</select>
</td>
</tr>
</tr>
</table>
</td>
</td>
<?php } else { ?>
<td>&nbsp;</td>
<?php } ?>
<td>&nbsp;</td>
<?php } ?>
<?php
}
} else { //end if is delineation
?>
?>
<td valign="top">
<div style="height: 15px; width: 15px; background-color: <?php echo $hotspot_colors[$i]; ?>"> </div>
</td>
</td>
<td valign="top" align="left">
<input type="text" name="reponse[<?php echo $i; ?>]" value="<?php echo Security::remove_XSS($reponse[$i]); ?>" size="45" />
</td>
<?php
require_once(api_get_path(LIBRARY_PATH) . "/fckeditor/fckeditor.php");
$oFCKeditor = new FCKeditor("comment[$i]");
$content = $comment[$i];
$oFCKeditor->ToolbarSet = 'TestProposedAnswer';
@ -836,10 +836,10 @@ if ($modifyAnswers) {
/* <td align="left"><textarea wrap="virtual" rows="1" cols="25" name="comment[<?php echo $i; ?>]" style="width: 100%"><?php echo api_htmlentities($comment[$i], ENT_QUOTES, api_get_system_encoding()); ?></textarea></td> */
?>
<td>&nbsp;</td>
<td align="left" ><?php echo $return; ?></td>
<td align="left" ><?php echo $return; ?></td>
<?php
}
?>
?>
<td valign="top">
<?php
//if ($answerType==HOT_SPOT_DELINEATION && $i!=2)
@ -860,8 +860,8 @@ if ($modifyAnswers) {
<?php
}
?>
</td>
</tr>
</td>
</tr>
<?php
}
require_once '../newscorm/learnpathList.class.php';
@ -869,7 +869,7 @@ if ($modifyAnswers) {
$flat_list = $list->get_flat_list();
$select_lp_id = array();
$option_lp = '';
//$option_lp.='<option value="0">'.get_lang('SelectTargetLP').'</option>';
//$option_lp.='<option value="0">'.get_lang('SelectTargetLP').'</option>';
foreach ($flat_list as $id => $details) {
$selected = '';
$select_lp_id[$id] = $details['lp_name'];
@ -908,20 +908,20 @@ if ($modifyAnswers) {
if ($answerType == HOT_SPOT_DELINEATION) {
?>
<tr>
<tr>
<th colspan="2" ><?php echo get_lang('IfNoError'); ?></th>
<?php if ($objExercise->selectFeedbackType() == EXERCISE_FEEDBACK_TYPE_DIRECT) { ?>
<th colspan="2" ><?php echo get_lang('Feedback'); ?></th>
<th><?php echo get_lang('Scenario'); ?></th>
<?php } else { ?>
<th colspan="3" ><?php echo get_lang('Feedback'); ?></th>
<?php } ?>
<th colspan="3" ><?php echo get_lang('Feedback'); ?></th>
<?php } ?>
<th>&nbsp;</th>
</tr>
<tr>
<tr>
<td colspan="2" valign="top" align="left">
<?php echo get_lang('LearnerHasNoMistake'); ?>
</td>
<?php echo get_lang('LearnerHasNoMistake'); ?>
</td>
<td colspan="2" align="left">
<textarea wrap="virtual" rows="3" cols="25" name="comment_noerror" style="width: 100%"><?php echo Security::remove_XSS($comment_noerror); ?></textarea>
</td>
@ -933,34 +933,34 @@ if ($modifyAnswers) {
<td>
<input type="checkbox" class="checkbox" name="try_noerror" <?php if ($try_noerror == 1) echo'checked'; ?> />
<?php echo get_lang('TryAgain'); ?>
<br /><br />
<?php echo get_lang('SeeTheory'); ?> <br />
<br /><br />
<?php echo get_lang('SeeTheory'); ?> <br />
<select name="lp_noerror" >
<?php echo $option_lp; ?>
</select>
<br /><br />
<?php echo get_lang('Other'); ?> <br />
<?php echo get_lang('Other'); ?> <br />
<input name="url_noerror" value="<?php echo $url_noerror; ?>">
<br /><br />
<?php echo get_lang('SelectQuestion'); ?> <br />
<?php echo get_lang('SelectQuestion'); ?> <br />
<select name="select_question_noerror">
<?php echo $option_feed; ?>
</select>
</td>
</tr>
</select>
</td>
</tr>
</table>
</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
<?php } else { ?>
<td colspan="2">&nbsp;</td>
<?php } ?>
</tr>
</tr>
<?php
}
?>
?>
</table>
</td>
</td>
</tr>
<tr>
<td colspan="2" valign="top" style="border-top:none">

@ -1,5 +1,4 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains a class used like library provides functions for auth tool. It's also used like model to courses_controller (MVC pattern)
@ -9,8 +8,6 @@
/**
* Code
*/
require_once api_get_path(LIBRARY_PATH) . 'tracking.lib.php';
/**
* Auth can be used to instanciate objects or as a library to manage courses
* @package chamilo.auth

@ -18,7 +18,7 @@ class DocumentManager {
}
/**
* @return the document folder quota for the current course, in bytes, or the default quota
* @return the document folder quota for the current course, in bytes, or the default quota
*/
public static function get_course_quota($course_code = null) {
if (empty($course_code)) {
@ -26,7 +26,7 @@ class DocumentManager {
} else {
$course_info = api_get_course_info($course_code);
}
$course_quota = null;
if (empty($course_info)) {
return DEFAULT_DOCUMENT_QUOTA;
@ -456,7 +456,7 @@ class DocumentManager {
public static function get_all_document_data($_course, $path = '/', $to_group_id = 0, $to_user_id = NULL, $can_see_invisible = false, $search = false) {
$TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$TABLE_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
if (!is_null($to_user_id)) {
$to_field = 'last.to_user_id';
$to_value = $to_user_id;
@ -482,24 +482,24 @@ class DocumentManager {
//condition for search (get ALL folders and documents)
$sql = "SELECT docs.id,
docs.filetype,
docs.path,
docs.title,
docs.comment,
docs.size,
docs.readonly,
docs.session_id,
last.id_session item_property_session_id,
last.lastedit_date,
last.visibility,
$sql = "SELECT docs.id,
docs.filetype,
docs.path,
docs.title,
docs.comment,
docs.size,
docs.readonly,
docs.session_id,
last.id_session item_property_session_id,
last.lastedit_date,
last.visibility,
last.insert_user_id
FROM ".$TABLE_ITEMPROPERTY." AS last INNER JOIN ".$TABLE_DOCUMENT." AS docs
FROM ".$TABLE_ITEMPROPERTY." AS last INNER JOIN ".$TABLE_DOCUMENT." AS docs
ON (docs.id = last.ref AND last.tool = '" . TOOL_DOCUMENT . "' AND docs.c_id = {$_course['real_id']} AND last.c_id = {$_course['real_id']})
WHERE
docs.path LIKE '".$path.$added_slash."%' AND
docs.path NOT LIKE '".$path.$added_slash."%/%' AND
".$to_field." = ".$to_value." AND
".$to_field." = ".$to_value." AND
last.visibility".$visibility_bit.$condition_session;
$result = Database::query($sql);
@ -628,10 +628,10 @@ class DocumentManager {
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
if ($to_group_id <> 0) {
$sql = "SELECT DISTINCT docs.id, path
$sql = "SELECT DISTINCT docs.id, path
FROM $TABLE_ITEMPROPERTY AS last INNER JOIN $TABLE_DOCUMENT AS docs
ON (docs.id = last.ref AND last.tool = '" . TOOL_DOCUMENT . "' AND last.c_id = {$_course['real_id']} AND docs.c_id = {$_course['real_id']} )
WHERE
WHERE
docs.filetype = 'folder' AND
last.to_group_id = ".$to_group_id." AND
docs.path NOT LIKE '%shared_folder%' AND
@ -816,50 +816,50 @@ class DocumentManager {
$result = Database::fetch_array(Database::query("SELECT filetype FROM $TABLE_DOCUMENT WHERE c_id = $course_id AND id= $document_id"), 'ASSOC');
return $result['filetype'] == 'folder';
}
public static function delete_document_from_db($document_id, $course_info = array(), $session_id = 0, $remove_content_from_db = false) {
$TABLE_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
$TABLE_ITEMPROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY);
//Deleting from the DB
$user_id = api_get_user_id();
if (empty($course_info)) {
$course_info = api_get_course_info();
}
if (empty($session_id)) {
$session_id = api_get_session_id();
}
//Soft DB delete
api_item_property_update($course_info, TOOL_DOCUMENT, $document_id, 'delete', $user_id, null, null, null, null, $session_id);
self::delete_document_from_search_engine($course_info['code'], $document_id);
self::unset_document_as_template($document_id, $course_info['code'], $user_id);
//Hard DB delete
if ($remove_content_from_db) {
if ($remove_content_from_db) {
$sql = "DELETE FROM $TABLE_ITEMPROPERTY WHERE c_id = {$course_info['real_id']} AND ref = ".$document_id." AND tool='".TOOL_DOCUMENT."'";
Database::query($sql);
$sql = "DELETE FROM ".$TABLE_DOCUMENT." WHERE c_id = {$course_info['real_id']} AND id = ".$document_id;
Database::query($sql);
$sql = "DELETE FROM ".$TABLE_DOCUMENT." WHERE c_id = {$course_info['real_id']} AND id = ".$document_id;
Database::query($sql);
self::delete_document_metadata($document_id);
}
}
public static function delete_document_metadata($document_id) {
//needed to deleted medadata
require_once api_get_path(SYS_CODE_PATH).'metadata/md_funcs.php';
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
$mdStore = new mdstore(true);
//delete metadata
$eid = 'Document'.'.'.$document_id;
$mdStore->mds_delete($eid);
$mdStore->mds_delete_offspring($eid);
$mdStore->mds_delete_offspring($eid);
}
/**
* This deletes a document by changing visibility to 2, renaming it to filename_DELETED_#id
@ -873,34 +873,34 @@ class DocumentManager {
*/
public static function delete_document($_course, $path, $base_work_dir) {
$TABLE_DOCUMENT = Database :: get_course_table(TABLE_DOCUMENT);
if (empty($path) || empty($base_work_dir)) {
return false;
}
$course_id = $_course['real_id'];
//first, delete the actual document...
$document_id = self :: get_document_id($_course, $path);
$document_exists_in_disk = file_exists($base_work_dir.$path);
$new_path = $path.'_DELETED_'.$document_id;
$current_session_id = api_get_session_id();
$file_deleted_from_db = false;
$file_deleted_from_disk = false;
$file_renamed_from_disk = false;
if ($document_id) {
self::delete_document_from_db($document_id);
self::delete_document_from_db($document_id);
//checking
//$file_exists_in_db = self::get_document_data_by_id($document_id, $_course['code']);
//$file_exists_in_db = self::get_document_data_by_id($document_id, $_course['code']);
$file_deleted_from_db = true;
}
if ($document_exists_in_disk) {
if (api_get_setting('permanently_remove_deleted_files') == 'true') {
if (api_get_setting('permanently_remove_deleted_files') == 'true') {
//Deleted files are *really* deleted
$what_to_delete_sql = "SELECT id FROM ".$TABLE_DOCUMENT." WHERE c_id = $course_id AND path='".$path."' OR path LIKE BINARY '".$path."/%'";
//get all id's of documents that are deleted
@ -915,24 +915,24 @@ class DocumentManager {
//delete documents, do it like this so metadata get's deleted too
//update_db_info('delete', $path);
//throw it away
my_delete($base_work_dir.$path);
my_delete($base_work_dir.$path);
$file_deleted_from_disk = true;
}
} else {
//Set visibility to 2 and rename file/folder to xxx_DELETED_#id (soft delete)
if (is_file($base_work_dir.$path) || is_dir($base_work_dir.$path)) {
if (rename($base_work_dir.$path, $base_work_dir.$new_path)) {
$sql = "UPDATE $TABLE_DOCUMENT set path='".$new_path."' WHERE c_id = $course_id AND id='".$document_id."'";
Database::query($sql);
$sql = "SELECT id, path FROM $TABLE_DOCUMENT WHERE c_id = $course_id AND path LIKE BINARY '".$path."/%'";
$result = Database::query($sql);
if ($result && Database::num_rows($result) > 0) {
while ($deleted_items = Database::fetch_array($result, 'ASSOC')) {
self::delete_document_from_db($deleted_items['id']);
while ($deleted_items = Database::fetch_array($result, 'ASSOC')) {
self::delete_document_from_db($deleted_items['id']);
//Change path of subfolders and documents in database
$old_item_path = $deleted_items['path'];
$new_item_path = $new_path.substr($old_item_path, strlen($path));
@ -946,22 +946,22 @@ class DocumentManager {
//Couldn't rename - file permissions problem?
error_log(__FILE__.' '.__LINE__.': Error renaming '.$base_work_dir.$path.' to '.$base_work_dir.$new_path.'. This is probably due to file permissions',0);
}
}
}
}
}
}
//Checking inconsistency
if ($file_deleted_from_db && $file_deleted_from_disk ||
//Checking inconsistency
if ($file_deleted_from_db && $file_deleted_from_disk ||
$file_deleted_from_db && $file_renamed_from_disk) {
return true;
} else {
//Something went wrong
//The file or directory isn't there anymore (on the filesystem)
// This means it has been removed externally. To prevent a
// blocking error from happening, we drop the related items from the
// item_property and the document table.
error_log(__FILE__.' '.__LINE__.': System inconsistency detected. The file or directory '.$base_work_dir.$path.' seems to have been removed from the filesystem independently from the web platform. To restore consistency, the elements using the same path will be removed from the database',0);
error_log(__FILE__.' '.__LINE__.': System inconsistency detected. The file or directory '.$base_work_dir.$path.' seems to have been removed from the filesystem independently from the web platform. To restore consistency, the elements using the same path will be removed from the database',0);
return false;
}
}
@ -1048,9 +1048,9 @@ class DocumentManager {
$row['url'] = api_get_path(WEB_CODE_PATH).'document/showinframes.php?cidReq='.$course_code.'&id='.$id;
$row['document_url'] = api_get_path(WEB_CODE_PATH).'document/document.php?cidReq='.$course_code.'&id='.$id;
$row['absolute_path'] = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/document'.$row['path'];
$row['absolute_path_from_document'] = '/document'.$row['path'];
$pathinfo = pathinfo($row['path']);
$row['absolute_parent_path'] = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/document'.$pathinfo['dirname'].'/';
@ -1174,7 +1174,7 @@ class DocumentManager {
$condition = "AND id_session IN ('$session_id', '0') ";
// The " d.filetype='file' " let the user see a file even if the folder is hidden see #2198
/*
/*
When using hotpotatoes files, a new html files are generated in the hotpotatoes folder
to display the test.
The genuine html file is copied to math4.htm(user_id).t.html
@ -1182,7 +1182,7 @@ class DocumentManager {
To check the html file visibility, we don't have to check file math4.htm(user_id).t.html but file math4.htm
In this case, we have to remove (user_id).t.html to check the visibility of the file
For images, we just check the path of the image file.
Exemple of hotpotatoes folder :
A.jpg
maths4-consigne.jpg
@ -1520,10 +1520,10 @@ class DocumentManager {
$dir_name='/certificates';
$post_dir_name=get_lang('CertificatesFiles');
$visibility_command = 'invisible';
if (!is_dir($base_work_dir_test)) {
$created_dir = create_unexisting_directory($course_info, api_get_user_id(), api_get_session_id(), $to_group_id,$to_user_id,$base_work_dir,$dir_name,$post_dir_name);
$update_id = self::get_document_id_of_directory_certificate();
$created_dir = create_unexisting_directory($course_info, api_get_user_id(), api_get_session_id(), $to_group_id,$to_user_id,$base_work_dir,$dir_name,$post_dir_name);
$update_id = self::get_document_id_of_directory_certificate();
api_item_property_update($course_info, TOOL_DOCUMENT, $update_id, $visibility_command, api_get_user_id());
}
}
@ -1962,11 +1962,11 @@ class DocumentManager {
$destination_course_code = CourseManager::get_course_id_from_path ($destination_course_directory);
$destination_course_info = api_get_course_info($destination_course_code);
$dest_course_path = api_get_path(SYS_COURSE_PATH).$destination_course_directory.'/';
$user_id = api_get_user_id();
if (!empty($orig_source_html)) {
foreach ($orig_source_html as $source) {
foreach ($orig_source_html as $source) {
// get information about source url
$real_orig_url = $source[0]; // url
@ -1981,7 +1981,7 @@ class DocumentManager {
// Replace origin course code by destination course code from origin url query
$dest_url_query = '';
if (!empty($real_orig_query)) {
$dest_url_query = '?'.$real_orig_query;
if (strpos($dest_url_query,$origin_course_code) !== false) {
@ -1990,9 +1990,9 @@ class DocumentManager {
}
if ($scope_url == 'local') {
if ($type_url == 'abs' || $type_url == 'rel') {
if ($type_url == 'abs' || $type_url == 'rel') {
$document_file = strstr($real_orig_path, 'document');
if (strpos($real_orig_path,$document_file) !== false) {
$origin_filepath = $orig_course_path.$document_file;
$destination_filepath = $dest_course_path.$document_file;
@ -2000,31 +2000,31 @@ class DocumentManager {
// copy origin file inside destination course
if (file_exists($origin_filepath)) {
$filepath_dir = dirname($destination_filepath);
if (!is_dir($filepath_dir)) {
$perm = api_get_permissions_for_new_directories();
$result = @mkdir($filepath_dir, $perm, true);
$result = @mkdir($filepath_dir, $perm, true);
if ($result) {
$filepath_to_add = str_replace(array($dest_course_path, 'document'), '', $filepath_dir);
$filepath_to_add = str_replace(array($dest_course_path, 'document'), '', $filepath_dir);
//Add to item properties to the new folder
$doc_id = add_document($destination_course_info, $filepath_to_add, 'folder', 0, basename($filepath_to_add));
api_item_property_update($destination_course_info, TOOL_DOCUMENT, $doc_id, 'FolderCreated', $user_id, null, null, null, null);
}
}
if (!file_exists($destination_filepath)) {
$result = @copy($origin_filepath, $destination_filepath);
if ($result) {
if ($result) {
$filepath_to_add = str_replace(array($dest_course_path, 'document'), '', $destination_filepath);
$size = filesize($destination_filepath);
//Add to item properties to the file
$doc_id = add_document($destination_course_info, $filepath_to_add, 'file', $size, basename($filepath_to_add));
api_item_property_update($destination_course_info, TOOL_DOCUMENT, $doc_id, 'FolderCreated', $user_id, null, null, null, null);
}
}
}
@ -2047,7 +2047,7 @@ class DocumentManager {
if (strpos($real_orig_url, '?') === 0) {
$dest_url = str_replace($origin_course_code, $destination_course_code, $real_orig_url);
$content_html = str_replace($real_orig_url, $dest_url, $content_html);
}
}
} else {
if ($type_url == 'url') {
@ -2246,29 +2246,29 @@ class DocumentManager {
if (isset($files['file'])) {
$upload_ok = process_uploaded_file($files['file'], $show_output);
if ($upload_ok) {
// File got on the server without problems, now process it
$new_path = handle_uploaded_document($course_info, $files['file'], $base_work_dir, $path, api_get_user_id(), api_get_group_id(), null, $unzip, $if_exists, $show_output);
if ($new_path) {
$docid = DocumentManager::get_document_id($course_info, $new_path);
if (!empty($docid)) {
$table_document = Database::get_course_table(TABLE_DOCUMENT);
$params = array();
if (!empty($title)) {
$params['title'] = get_document_title($title);
} else {
if (isset($if_exists) && $if_exists == 'rename') {
$new_path = basename($new_path);
$params['title'] = get_document_title($new_path);
$new_path = basename($new_path);
$params['title'] = get_document_title($new_path);
} else {
$params['title'] = get_document_title($files['file']['name']);
}
}
if (!empty($comment)) {
$params['comment'] = trim($comment);
}
@ -2388,36 +2388,36 @@ class DocumentManager {
static function documents_total_space($course_id = null, $group_id = null, $session_id = null) {
$TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY);
$TABLE_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT);
if (isset($course_id)) {
if (isset($course_id)) {
$course_id = intval($course_id);
} else {
$course_id = api_get_course_int_id();
}
$group_condition = null;
if (isset($group_id)) {
if (isset($group_id)) {
$group_id = intval($group_id);
$group_condition = " AND props.to_group_id='".$group_id."' ";
$group_condition = " AND props.to_group_id='".$group_id."' ";
}
$session_condition = null;
if (isset($session_id)) {
if (isset($session_id)) {
$session_id = intval($session_id);
$session_condition = " AND props.id_session='".$session_id."' ";
}
$session_condition = " AND props.id_session='".$session_id."' ";
}
$sql = "SELECT SUM(size) FROM ".$TABLE_ITEMPROPERTY." AS props, ".$TABLE_DOCUMENT." AS docs
WHERE props.c_id = $course_id AND
docs.c_id = $course_id AND
docs.id = props.ref AND
props.tool = '".TOOL_DOCUMENT."' AND
props.visibility <> 2
$group_condition
$group_condition
$session_condition
";
";
$result = Database::query($sql);
if ($result && Database::num_rows($result) != 0) {
@ -2485,7 +2485,7 @@ class DocumentManager {
$course_quota_m = round($course_quota / 1000000);
$already_consumed_space_m = round($already_consumed_space / 1000000, 2);
$percentage = $already_consumed_space / $course_quota * 100;
$percentage = round($percentage, 1);
$percentage = round($percentage, 1);
$message = get_lang('YouAreCurrentlyUsingXOfYourX');
$message = sprintf($message, $already_consumed_space_m, $percentage.'%',$course_quota_m.' ');
echo Display::div($message, array('id'=>'document_quota'));
@ -2513,33 +2513,33 @@ class DocumentManager {
}
return true;
}
/**
*
*
* @param array paremeters: count, url, extension
* @return string
*/
static function generate_jplayer_jquery($params = array()) {
$js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/';
$jplayer_definition = ' $("#jquery_jplayer_' . $params['count'] . '").jPlayer({
ready: function() {
$(this).jPlayer("setMedia", {
' . $params['extension'] . ' : "' . $params['url'] . '"
$js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/';
$jplayer_definition = ' $("#jquery_jplayer_' . $params['count'] . '").jPlayer({
ready: function() {
$(this).jPlayer("setMedia", {
' . $params['extension'] . ' : "' . $params['url'] . '"
});
},
play: function() { // To avoid both jPlayers playing together.
$(this).jPlayer("pauseOthers");
},
},
//errorAlerts: true,
//warningAlerts: true,
swfPath: "' . $js_path . 'jquery-jplayer",
//supplied: "m4a, oga, mp3, ogg, wav",
supplied: "' . $params['extension'] . '",
wmode: "window",
solution: "flash, html", // Do not change this setting
cssSelectorAncestor: "#jp_container_' . $params['count'] . '",
solution: "flash, html", // Do not change this setting
cssSelectorAncestor: "#jp_container_' . $params['count'] . '",
}); ' . "\n\n";
return $jplayer_definition;
}
@ -2552,7 +2552,7 @@ class DocumentManager {
*/
static function generate_media_preview($i, $type = 'simple') {
$i = intval($i);
$extra_controls = $progress = '';
if ($type == 'advanced') {
$extra_controls = ' <li><a href="javascript:;" class="jp-stop" tabindex="1">stop</a></li>
@ -2564,7 +2564,7 @@ class DocumentManager {
</div>
</div>';
}
//Shows only the play button
$html = '<div id="jquery_jplayer_'.$i.'" class="jp-jplayer"></div>
<div id="jp_container_'.$i.'" class="jp-audio">
@ -2574,8 +2574,8 @@ class DocumentManager {
<li><a href="javascript:;" class="jp-play" tabindex="1">play</a></li>
<li><a href="javascript:;" class="jp-pause" tabindex="1">pause</a></li>
'.$extra_controls.'
</ul>
'.$progress.'
</ul>
'.$progress.'
</div>
</div>
</div>';
@ -2682,30 +2682,30 @@ class DocumentManager {
//$condition_session = " AND (id_session = '$session_id' OR (id_session = '0' AND insert_date <= (SELECT creation_date FROM $tbl_course WHERE code = '".$course_info['code']."' )))";
$condition_session = " AND (id_session = '$session_id' OR id_session = '0' )";
$add_folder_filter = null;
if (!empty($filter_by_folder)) {
$add_folder_filter = " AND docs.path LIKE '".Database::escape_string($filter_by_folder)."%'";
}
$sql_doc = "SELECT last.visibility, docs.*
FROM $tbl_item_prop AS last, $tbl_doc AS docs
WHERE docs.id = last.ref AND
docs.path LIKE '".$path.$added_slash."%' AND
docs.path NOT LIKE '%_DELETED_%' AND
WHERE docs.id = last.ref AND
docs.path LIKE '".$path.$added_slash."%' AND
docs.path NOT LIKE '%_DELETED_%' AND
last.tool = '".TOOL_DOCUMENT."' $condition_session AND
last.visibility = '1' AND
docs.c_id = {$course_info['real_id']} AND
last.c_id = {$course_info['real_id']}
last.visibility = '1' AND
docs.c_id = {$course_info['real_id']} AND
last.c_id = {$course_info['real_id']}
$add_folder_filter
ORDER BY docs.title ASC";
$res_doc = Database::query($sql_doc);
$resources = Database::store_result($res_doc, 'ASSOC');
$resources_sorted = array();
$return = '';
if ($lp_id) {
$return .= '<div class="lp_resource_element">';
$return .= Display::return_icon('new_doc.gif', '', array(), ICON_SIZE_SMALL);
@ -2913,7 +2913,7 @@ class DocumentManager {
$url = $web_code_path.'document/document.php?cidReq='.$course_info['code'].'&id_session='.$session_id.'&id='.$key;
if (!empty($overwrite_url)) {
$url = $overwrite_url.'&document_id='.$key;
}
}
}
$img = $img_path.$icon;
if (!file_exists($img_sys_path.$icon)) {
@ -3229,5 +3229,7 @@ class DocumentManager {
);
return $system_folders;
}
}
//end class DocumentManager

@ -3,7 +3,6 @@
/* For licensing terms, see /license.txt */
require_once 'HTML/QuickForm/textarea.php';
require_once api_get_path(LIBRARY_PATH) . 'fckeditor/fckeditor.php';
/**
* A html editor field to use with QuickForm
@ -106,7 +105,7 @@ class HTML_QuickForm_html_editor extends HTML_QuickForm_textarea {
if (!FCKeditor :: IsCompatible()) {
return parent::toHTML();
}
$this->fck_editor->Value = $this->getValue();
$this->fck_editor->Value = $this->getValue();
$result = $this->fck_editor->CreateHtml();
//Add a link to open the allowed html tags window
//$result .= '<small><a href="#" onclick="MyWindow=window.open('."'".api_get_path(WEB_CODE_PATH)."help/allowed_html_tags.php?fullpage=". ($this->fullPage ? '1' : '0')."','MyWindow','toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=500,height=600,left=200,top=20'".'); return false;">'.get_lang('AllowedHTMLTags').'</a></small>';

@ -12,121 +12,119 @@
* @package chamilo.library
*/
require_once 'fckeditor/fckeditor.php';
class GradeModel extends Model {
var $table;
var $columns = array('id', 'name', 'description');
public function __construct() {
$this->table = Database::get_main_table(TABLE_GRADE_MODEL);
}
}
public function get_all($where_conditions = array()) {
return Database::select('*',$this->table, array('where'=>$where_conditions,'order' =>'name ASC'));
}
public function get_count() {
public function get_count() {
$row = Database::select('count(*) as count', $this->table, array(),'first');
return $row['count'];
}
}
/**
* Displays the title + grid
*/
public function display() {
// action links
echo '<div class="actions" style="margin-bottom:20px">';
echo '<a href="grade_models.php">'.Display::return_icon('back.png',get_lang('Back'),'','32').'</a>';
echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png',get_lang('Add'),'','32').'</a>';
echo '</div>';
echo Display::grid_html('grade_model');
echo '<a href="grade_models.php">'.Display::return_icon('back.png',get_lang('Back'),'','32').'</a>';
echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('add.png',get_lang('Add'),'','32').'</a>';
echo '</div>';
echo Display::grid_html('grade_model');
}
/**
* Returns a Form validator Obj
* @todo the form should be auto generated
* @param string url
* @param string action add, edit
* @return obj form validator obj
* @return obj form validator obj
*/
public function return_form($url, $action) {
$oFCKeditor = new FCKeditor('description') ;
$oFCKeditor->ToolbarSet = 'grade_model';
$oFCKeditor->Width = '100%';
$oFCKeditor->Height = '200';
$oFCKeditor->Value = '';
$oFCKeditor->CreateHtml();
$form = new FormValidator('grades', 'post', $url);
// Settting the form elements
$header = get_lang('Add');
if ($action == 'edit') {
$header = get_lang('Modify');
}
$form->addElement('header', $header);
$id = isset($_GET['id']) ? intval($_GET['id']) : '';
$form->addElement('hidden', 'id', $id);
$form->addElement('text', 'name', get_lang('Name'), array('size' => '70'));
$form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'careers','Width' => '100%', 'Height' => '250'));
$form->add_html_editor('description', get_lang('Description'), false, false, array('ToolbarSet' => 'careers','Width' => '100%', 'Height' => '250'));
$form->addElement('label', get_lang('Components'));
//Get components
$nr_items = 2;
$max = 10;
// Setting the defaults
$defaults = $this->get($id);
$defaults = $this->get($id);
$components = $this->get_components($defaults['id']);
if ($action == 'edit') {
if (!empty($components)) {
if (!empty($components)) {
$nr_items = count($components) -1;
}
}
}
$form->addElement('hidden', 'maxvalue', '100');
$form->addElement('hidden', 'minvalue', '0');
$renderer = & $form->defaultRenderer();
$component_array = array();
for ($i = 0; $i <= $max; $i++) {
$counter = $i;
$form->addElement('text', 'components['.$i.'][percentage]', null, array('class' => 'span1'));
$form->addElement('text', 'components['.$i.'][percentage]', null, array('class' => 'span1'));
$form->addElement('text', 'components['.$i.'][acronym]', null, array('class' => 'span1', 'placeholder' => get_lang('Acronym')));
$form->addElement('text', 'components['.$i.'][title]', null, array('class' => 'span2', 'placeholder' => get_lang('Title')));
$form->addElement('text', 'components['.$i.'][title]', null, array('class' => 'span2', 'placeholder' => get_lang('Title')));
$form->addElement('text', 'components['.$i.'][prefix]', null, array('class'=> 'span1', 'placeholder' => get_lang('Prefix')));
$options = array(0=>0, 1 => 1, 2 => 2, 3=>3, 4=> 4, 5=> 5);
$form->addElement('select', 'components['.$i.'][count_elements]', null, $options);
$options = array(0=>0, 1 => 1, 2 => 2, 3=>3, 4=> 4, 5=> 5);
$options = array(0=>0, 1 => 1, 2 => 2, 3=>3, 4=> 4, 5=> 5);
$form->addElement('select', 'components['.$i.'][exclusions]', null, $options);
$form->addElement('hidden', 'components['.$i.'][id]');
$template_percentage =
'<div id=' . $i . ' style="display: '.(($i<=$nr_items)?'inline':'none').';" class="control-group">
'<div id=' . $i . ' style="display: '.(($i<=$nr_items)?'inline':'none').';" class="control-group">
<p>
<label class="control-label">{label}</label>
<div class="controls">
<div class="controls">
{element} <!-- BEGIN error --><span class="form_error">{error}</span><!-- END error --> % = ';
$template_acronym = '
<!-- BEGIN required -->
<!-- BEGIN required -->
{element} {label} <!-- BEGIN error --><span class="form_error">{error}</span> <!-- END error -->';
$template_title =
@ -136,35 +134,35 @@ class GradeModel extends Model {
</a>
<a href="javascript:minItem(' . ($counter) . ')">
<img style="display: '.(($counter>=$nr_items)?'inline':'none').';" id="min-' . $counter . '" src="../img/delete.png" alt="'.get_lang('Delete').'" title="'.get_lang('Delete').'"></img>
</a>
</a>
</div></p></div>';
$renderer->setElementTemplate($template_acronym, 'components['.$i.'][title]');
$renderer->setElementTemplate($template_percentage , 'components['.$i.'][percentage]');
$renderer->setElementTemplate($template_acronym , 'components['.$i.'][acronym]');
$renderer->setElementTemplate($template_acronym , 'components['.$i.'][prefix]');
$renderer->setElementTemplate($template_title , 'components['.$i.'][exclusions]');
$renderer->setElementTemplate($template_acronym , 'components['.$i.'][count_elements]');
if ($i == 0) {
$form->addRule('components['.$i.'][percentage]', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('components['.$i.'][title]', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('components['.$i.'][acronym]', get_lang('ThisFieldIsRequired'), 'required');
$form->addRule('components['.$i.'][acronym]', get_lang('ThisFieldIsRequired'), 'required');
}
$form->addRule('components['.$i.'][percentage]', get_lang('OnlyNumbers'), 'numeric');
$form->addRule(array('components['.$i.'][percentage]', 'maxvalue'), get_lang('Over100'), 'compare', '<=');
$form->addRule(array('components['.$i.'][percentage]', 'minvalue'), get_lang('UnderMin'), 'compare', '>=');
$form->addRule(array('components['.$i.'][percentage]', 'minvalue'), get_lang('UnderMin'), 'compare', '>=');
$component_array[] = 'components['.$i.'][percentage]';
}
//New rule added in the formvalidator compare_fields that filters a group of fields in order to compare with the wanted value
$form->addRule($component_array, get_lang('AllMustWeight100'), 'compare_fields', '==@100');
$form->addRule($component_array, get_lang('AllMustWeight100'), 'compare_fields', '==@100');
$form->addElement('advanced_settings', get_lang('AllMustWeight100'));
if ($action == 'edit') {
$form->addElement('style_submit_button', 'submit', get_lang('Modify'), 'class="save"');
} else {
@ -179,43 +177,43 @@ class GradeModel extends Model {
}
$counter++;
}
}
}
$form->setDefaults($defaults);
// Setting the rules
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
return $form;
$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
return $form;
}
public function get_components($id) {
public function get_components($id) {
$obj = new GradeModelComponents();
if (!empty($id)) {
return $obj->get_all(array('where'=> array('grade_model_id = ?' => $id)));
}
return $obj->get_all(array('where'=> array('grade_model_id = ?' => $id)));
}
return null;
}
public function save($params, $show_query = false) {
public function save($params, $show_query = false) {
$id = parent::save($params, $show_query);
if (!empty($id)) {
foreach ($params['components'] as $component) {
if (!empty($id)) {
foreach ($params['components'] as $component) {
if (!empty($component['title']) && !empty($component['percentage']) && !empty($component['acronym'])) {
$obj = new GradeModelComponents();
$component['grade_model_id'] = $id;
$obj->save($component);
}
}
}
}
//event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
//event_system(LOG_CAREER_CREATE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
return $id;
}
public function update($params) {
parent::update($params);
if (!empty($params['id'])) {
foreach ($params['components'] as $component) {
foreach ($params['components'] as $component) {
$obj = new GradeModelComponents();
$component['grade_model_id'] = $params['id'];
if (empty($component['title']) && empty($component['percentage']) && empty($component['acronym'])) {
@ -224,41 +222,41 @@ class GradeModel extends Model {
$obj->update($component);
}
}
}
}
//$params['components']
}
public function delete($id) {
parent::delete($id);
//event_system(LOG_CAREER_DELETE, LOG_CAREER_ID, $id, api_get_utc_datetime(), api_get_user_id());
}
public function fill_grade_model_select_in_form(&$form, $name = 'gradebook_model_id', $default_value = null) {
if (api_get_setting('gradebook_enable_grade_model') == 'false') {
return false;
}
}
if (api_get_setting('teachers_can_change_grade_model_settings') == 'true' || api_is_platform_admin()) {
$grade_models = $this->get_all();
$grade_model_options = array('-1' => get_lang('None'));
$grade_models = $this->get_all();
$grade_model_options = array('-1' => get_lang('None'));
if (!empty($grade_models)) {
foreach ($grade_models as $item) {
$grade_model_options[$item['id']] = $item['name'];
}
}
}
$form->addElement('select', $name, get_lang('GradeModel'), $grade_model_options);
$default_platform_setting = api_get_setting('gradebook_default_grade_model_id');
$default = -1;
if ($default_platform_setting == -1) {
if (!empty($default_value)) {
$default = $default_value;
}
}
} else {
$default = $default_platform_setting;
}
if (!empty($default) && $default != '-1') {
$form->setDefaults(array($name => $default));
}
@ -269,12 +267,12 @@ class GradeModel extends Model {
class GradeModelComponents extends Model {
var $table;
var $columns = array('id', 'title', 'percentage', 'acronym', 'grade_model_id', 'prefix', 'exclusions', 'count_elements');
public function __construct() {
$this->table = Database::get_main_table(TABLE_GRADE_MODEL_COMPONENTS);
}
public function save($params, $show_query = false) {
$id = parent::save($params, $show_query);
}
public function save($params, $show_query = false) {
$id = parent::save($params, $show_query);
return $id;
}
}

@ -357,6 +357,8 @@ define('MESSAGE_STATUS_INVITATION_PENDING', '5');
define('MESSAGE_STATUS_INVITATION_ACCEPTED', '6');
define('MESSAGE_STATUS_INVITATION_DENIED', '7');
define('SESSION_LINK_TARGET', '_self');
/**
* Inclusion of internationalization libraries

@ -10,10 +10,8 @@
/**
* Code
*/
define('SESSION_LINK_TARGET', '_self');
require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php';
require_once api_get_path(SYS_CODE_PATH).'newscorm/learnpathList.class.php';
/**
* Class

Loading…
Cancel
Save