Minor - Format code

1.10.x
Julio Montoya 10 years ago
parent 30356c9a2a
commit a73d8dc26c
  1. 158
      main/gradebook/gradebook_edit_all.php
  2. 10
      main/newscorm/learnpath.class.php

@ -34,23 +34,58 @@ $tbl_forum_thread = Database:: get_course_table(TABLE_FORUM_THREAD);
$tbl_work = Database:: get_course_table(TABLE_STUDENT_PUBLICATION); $tbl_work = Database:: get_course_table(TABLE_STUDENT_PUBLICATION);
$tbl_attendance = Database:: get_course_table(TABLE_ATTENDANCE); $tbl_attendance = Database:: get_course_table(TABLE_ATTENDANCE);
$table_evaluated[LINK_EXERCISE] = array(TABLE_QUIZ_TEST, 'title', 'id', get_lang('Exercise')); $table_evaluated[LINK_EXERCISE] = array(
$table_evaluated[LINK_DROPBOX] = array(TABLE_DROPBOX_FILE, 'name','id', get_lang('Dropbox')); TABLE_QUIZ_TEST,
$table_evaluated[LINK_STUDENTPUBLICATION] = array(TABLE_STUDENT_PUBLICATION, 'url','id', get_lang('Student_publication')); 'title',
$table_evaluated[LINK_LEARNPATH] = array(TABLE_LP_MAIN, 'name','id', get_lang('Learnpath')); 'id',
$table_evaluated[LINK_FORUM_THREAD] = array(TABLE_FORUM_THREAD, 'thread_title_qualify', 'thread_id', get_lang('Forum')); get_lang('Exercise'),
$table_evaluated[LINK_ATTENDANCE] = array(TABLE_ATTENDANCE, 'attendance_title_qualify', 'id', get_lang('Attendance')); );
$table_evaluated[LINK_SURVEY] = array(TABLE_SURVEY, 'code', 'survey_id', get_lang('Survey')); $table_evaluated[LINK_DROPBOX] = array(
TABLE_DROPBOX_FILE,
'name',
'id',
get_lang('Dropbox'),
);
$table_evaluated[LINK_STUDENTPUBLICATION] = array(
TABLE_STUDENT_PUBLICATION,
'url',
'id',
get_lang('Student_publication'),
);
$table_evaluated[LINK_LEARNPATH] = array(
TABLE_LP_MAIN,
'name',
'id',
get_lang('Learnpath'),
);
$table_evaluated[LINK_FORUM_THREAD] = array(
TABLE_FORUM_THREAD,
'thread_title_qualify',
'thread_id',
get_lang('Forum'),
);
$table_evaluated[LINK_ATTENDANCE] = array(
TABLE_ATTENDANCE,
'attendance_title_qualify',
'id',
get_lang('Attendance'),
);
$table_evaluated[LINK_SURVEY] = array(
TABLE_SURVEY,
'code',
'survey_id',
get_lang('Survey'),
);
$submitted = isset($_POST['submitted']) ? $_POST['submitted'] : ''; $submitted = isset($_POST['submitted']) ? $_POST['submitted'] : '';
if ($submitted==1) { if ($submitted == 1) {
Display :: display_confirmation_message(get_lang('GradebookWeightUpdated')) . '<br /><br />'; Display :: display_confirmation_message(get_lang('GradebookWeightUpdated')) . '<br /><br />';
if (isset($_POST['evaluation'])) { if (isset($_POST['evaluation'])) {
$eval_log = new Evaluation(); $eval_log = new Evaluation();
} }
} }
$output=''; $output = '';
$my_cat = Category::load($my_selectcat); $my_cat = Category::load($my_selectcat);
$my_cat = $my_cat[0]; $my_cat = $my_cat[0];
@ -70,12 +105,10 @@ $links = Database::store_result($result, 'ASSOC');
foreach ($links as &$row) { foreach ($links as &$row) {
$item_weight = $row['weight']; $item_weight = $row['weight'];
//$item_weight = $masked_total*$item_weight/$original_total;
//
$sql = 'SELECT * FROM '.GradebookUtils::get_table_type_course($row['type']).' $sql = 'SELECT * FROM '.GradebookUtils::get_table_type_course($row['type']).'
WHERE c_id = '.$course_id.' AND '.$table_evaluated[$row['type']][2].' = '.$row['ref_id']; WHERE c_id = '.$course_id.' AND '.$table_evaluated[$row['type']][2].' = '.$row['ref_id'];
$result = Database::query($sql); $result = Database::query($sql);
$resource_name = Database ::fetch_array($result); $resource_name = Database::fetch_array($result);
if (isset($resource_name['lp_type'])) { if (isset($resource_name['lp_type'])) {
$resource_name = $resource_name[4]; $resource_name = $resource_name[4];
@ -86,15 +119,21 @@ foreach ($links as &$row) {
// Update only if value changed // Update only if value changed
if (isset($_POST['link'][$row['id']])) { if (isset($_POST['link'][$row['id']])) {
//$new_weight = trim($_POST['link'][$row['id']]*$original_total/$masked_total);
$new_weight = trim($_POST['link'][$row['id']]); $new_weight = trim($_POST['link'][$row['id']]);
GradebookUtils::updateLinkWeight($row['id'], $resource_name, $new_weight); GradebookUtils::updateLinkWeight(
$row['id'],
$resource_name,
$new_weight
);
$item_weight = $new_weight; $item_weight = $new_weight;
} }
$output.= '<tr><td>'.GradebookUtils::build_type_icon_tag($row['type']).'</td> $output .= '<tr><td>'.GradebookUtils::build_type_icon_tag($row['type']).'</td>
<td> '.$resource_name.' '.Display::label($table_evaluated[$row['type']][3],'info').' </td>'; <td> '.$resource_name.' '.Display::label(
$output.= '<td> $table_evaluated[$row['type']][3],
'info'
).' </td>';
$output .= '<td>
<input type="hidden" name="link_'.$row['id'].'" value="'.$resource_name.'" /> <input type="hidden" name="link_'.$row['id'].'" value="'.$resource_name.'" />
<input size="10" type="text" name="link['.$row['id'].']" value="'.$item_weight.'"/> <input size="10" type="text" name="link['.$row['id'].']" value="'.$item_weight.'"/>
</td></tr>'; </td></tr>';
@ -105,29 +144,31 @@ $result = Database::query($sql);
$evaluations = Database::store_result($result); $evaluations = Database::store_result($result);
foreach ($evaluations as $evaluationRow) { foreach ($evaluations as $evaluationRow) {
$item_weight = $evaluationRow['weight']; $item_weight = $evaluationRow['weight'];
//$item_weight = $masked_total*$item_weight/$original_total; // update only if value changed
//update only if value changed
if (isset($_POST['evaluation'][$evaluationRow['id']])) { if (isset($_POST['evaluation'][$evaluationRow['id']])) {
//$new_weight = trim($_POST['evaluation'][$evaluationRow['id']]*$original_total/$masked_total);
$new_weight = trim($_POST['evaluation'][$evaluationRow['id']]); $new_weight = trim($_POST['evaluation'][$evaluationRow['id']]);
GradebookUtils::updateEvaluationWeight($evaluationRow['id'], $new_weight); GradebookUtils::updateEvaluationWeight(
$evaluationRow['id'],
$new_weight
);
$item_weight = $new_weight; $item_weight = $new_weight;
} }
$output.= '<tr> $output .= '<tr>
<td>'.GradebookUtils::build_type_icon_tag('evalnotempty').'</td> <td>'.GradebookUtils::build_type_icon_tag('evalnotempty').'</td>
<td>'.$evaluationRow['name'].' '.Display::label(get_lang('Evaluation')).'</td>'; <td>'.$evaluationRow['name'].' '.Display::label(
$output.= '<td> get_lang('Evaluation')
).'</td>';
$output .= '<td>
<input type="hidden" name="eval_'.$evaluationRow['id'].'" value="'.$evaluationRow['name'].'" /> <input type="hidden" name="eval_'.$evaluationRow['id'].'" value="'.$evaluationRow['name'].'" />
<input type="text" size="10" name="evaluation['.$evaluationRow['id'].']" value="'.$item_weight.'"/> <input type="text" size="10" name="evaluation['.$evaluationRow['id'].']" value="'.$item_weight.'"/>
</td></tr>'; </td></tr>';
} }
$my_api_cidreq = api_get_cidreq(); $my_api_cidreq = api_get_cidreq();
if ($my_api_cidreq=='') { if ($my_api_cidreq == '') {
$my_api_cidreq='cidReq='.$my_category['course_code']; $my_api_cidreq = 'cidReq='.$my_category['course_code'];
} }
$currentUrl = api_get_self().'?'.api_get_cidreq().'&selectcat='.$my_selectcat; $currentUrl = api_get_self().'?'.api_get_cidreq().'&selectcat='.$my_selectcat;
@ -175,7 +216,10 @@ if ($form->validate()) {
$diffApplied = true; $diffApplied = true;
} }
} }
GradebookUtils::updateEvaluationWeight($evaluation['id'], $weightToApply); GradebookUtils::updateEvaluationWeight(
$evaluation['id'],
$weightToApply
);
} }
header('Location:'.$currentUrl); header('Location:'.$currentUrl);
@ -186,22 +230,47 @@ if ($form->validate()) {
// DISPLAY HEADERS AND MESSAGES // DISPLAY HEADERS AND MESSAGES
if (!isset($_GET['exportpdf']) and !isset($_GET['export_certificate'])) { if (!isset($_GET['exportpdf']) and !isset($_GET['export_certificate'])) {
if (isset ($_GET['studentoverview'])) { if (isset ($_GET['studentoverview'])) {
$interbreadcrumb[]= array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=' . $my_selectcat,'name' => get_lang('Gradebook')); $interbreadcrumb[] = array(
Display :: display_header(get_lang('FlatView')); 'url' => Security::remove_XSS(
$_SESSION['gradebook_dest']
).'?selectcat='.$my_selectcat,
'name' => get_lang('Gradebook'),
);
Display:: display_header(get_lang('FlatView'));
} elseif (isset ($_GET['search'])) { } elseif (isset ($_GET['search'])) {
$interbreadcrumb[]= array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=' . $my_selectcat,'name' => get_lang('Gradebook')); $interbreadcrumb[] = array(
Display :: display_header(get_lang('SearchResults')); 'url' => Security::remove_XSS(
$_SESSION['gradebook_dest']
).'?selectcat='.$my_selectcat,
'name' => get_lang('Gradebook'),
);
Display:: display_header(get_lang('SearchResults'));
} else { } else {
$interbreadcrumb[] = array ('url' => Security::remove_XSS($_SESSION['gradebook_dest']).'?selectcat=1', 'name' => get_lang('Gradebook')); $interbreadcrumb[] = array(
$interbreadcrumb[] = array ('url' => '#','name' => get_lang('EditAllWeights')); 'url' => Security::remove_XSS(
Display :: display_header(''); $_SESSION['gradebook_dest']
).'?selectcat=1',
'name' => get_lang('Gradebook'),
);
$interbreadcrumb[] = array(
'url' => '#',
'name' => get_lang('EditAllWeights'),
);
Display:: display_header('');
} }
} }
?> ?>
<div class="actions"> <div class="actions">
<a href="<?php echo Security::remove_XSS($_SESSION['gradebook_dest']).'?'.$my_api_cidreq ?>&selectcat=<?php echo $my_selectcat ?>"> <a href="<?php echo Security::remove_XSS(
<?php echo Display::return_icon('back.png',get_lang('FolderView'),'',ICON_SIZE_MEDIUM); ?> $_SESSION['gradebook_dest']
).'?'.$my_api_cidreq ?>&selectcat=<?php echo $my_selectcat ?>">
<?php echo Display::return_icon(
'back.png',
get_lang('FolderView'),
'',
ICON_SIZE_MEDIUM
); ?>
</a> </a>
</div> </div>
<?php <?php
@ -212,12 +281,12 @@ $formNormal = new FormValidator('normal_weight', 'post', $currentUrl);
$formNormal->addHeader(get_lang('EditWeight')); $formNormal->addHeader(get_lang('EditWeight'));
$formNormal->display(); $formNormal->display();
//$warning_message = sprintf(get_lang('TotalWeightMustBeX'), $masked_total);
$warning_message = sprintf(get_lang('TotalWeightMustBeX'), $original_total); $warning_message = sprintf(get_lang('TotalWeightMustBeX'), $original_total);
Display::display_warning_message($warning_message, false); Display::display_warning_message($warning_message, false);
?> ?>
<form method="post" action="gradebook_edit_all.php?<?php echo $my_api_cidreq ?>&selectcat=<?php echo $my_selectcat?>"> <form method="post"
action="gradebook_edit_all.php?<?php echo $my_api_cidreq ?>&selectcat=<?php echo $my_selectcat ?>">
<table class="data_table"> <table class="data_table">
<tr class="row_odd"> <tr class="row_odd">
<th style="width: 35px;"><?php echo get_lang('Type'); ?></th> <th style="width: 35px;"><?php echo get_lang('Type'); ?></th>
@ -226,11 +295,12 @@ Display::display_warning_message($warning_message, false);
</tr> </tr>
<?php echo $output; ?> <?php echo $output; ?>
</table> </table>
<input type="hidden" name="submitted" value="1" /> <input type="hidden" name="submitted" value="1"/>
<br /> <br/>
<button class="btn btn-primary" type="submit" name="name" value="<?php echo get_lang('Save') ?>"> <button class="btn btn-primary" type="submit" name="name"
value="<?php echo get_lang('Save') ?>">
<?php echo get_lang('SaveScoringRules') ?> <?php echo get_lang('SaveScoringRules') ?>
</button> </button>
</form> </form>
<?php <?php
Display :: display_footer(); Display:: display_footer();

@ -381,7 +381,7 @@ class learnpath
if ($this->debug > 2) { if ($this->debug > 2) {
error_log( error_log(
'New LP - learnpath::__construct() '.__LINE__.' - Inserting blank item_view : '.$sql_ins, 'New LP - learnpath::__construct() '.__LINE__.' - Inserting blank item_view : '.$sql,
0 0
); );
} }
@ -732,8 +732,9 @@ class learnpath
// Session id. // Session id.
$session_id = api_get_session_id(); $session_id = api_get_session_id();
$check_name = "SELECT * FROM $tbl_lp WHERE c_id = $course_id AND name = '$name'"; $check_name = "SELECT * FROM $tbl_lp
//if ($this->debug > 2) { error_log('New LP - Checking the name for new LP: '.$check_name, 0); } WHERE c_id = $course_id AND name = '$name'";
$res_name = Database::query($check_name); $res_name = Database::query($check_name);
if ($publicated_on == '0000-00-00 00:00:00' || empty($publicated_on)) { if ($publicated_on == '0000-00-00 00:00:00' || empty($publicated_on)) {
@ -1007,7 +1008,8 @@ class learnpath
// Delete lp item id. // Delete lp item id.
foreach ($this->items as $id => $dummy) { foreach ($this->items as $id => $dummy) {
$sql = "DELETE FROM $lp_item_view WHERE c_id = $course_id AND lp_item_id = '" . $id . "'"; $sql = "DELETE FROM $lp_item_view
WHERE c_id = $course_id AND lp_item_id = '" . $id . "'";
Database::query($sql); Database::query($sql);
} }

Loading…
Cancel
Save