gradebook_edit_all.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php // $Id: $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2006-2008 Dokeos SPRL
  6. Copyright (c) 2006 Ghent University (UGent)
  7. Copyright (c) various contributors
  8. For a full list of contributors, see "credits.txt".
  9. The full license can be read in "license.txt".
  10. This program is free software; you can redistribute it and/or
  11. modify it under the terms of the GNU General Public License
  12. as published by the Free Software Foundation; either version 2
  13. of the License, or (at your option) any later version.
  14. See the GNU General Public License for more details.
  15. Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  16. Mail: info@dokeos.com
  17. ==============================================================================
  18. */
  19. $language_file= 'gradebook';
  20. $cidReset= true;
  21. require_once ('../inc/global.inc.php');
  22. $this_section = SECTION_MYGRADEBOOK;
  23. require_once ('lib/be.inc.php');
  24. require_once ('lib/scoredisplay.class.php');
  25. require_once ('lib/gradebook_functions.inc.php');
  26. require_once ('lib/fe/catform.class.php');
  27. require_once ('lib/fe/evalform.class.php');
  28. require_once ('lib/fe/linkform.class.php');
  29. require_once ('lib/gradebook_data_generator.class.php');
  30. require_once ('lib/fe/gradebooktable.class.php');
  31. require_once ('lib/fe/displaygradebook.php');
  32. api_block_anonymous_users();
  33. if (!api_is_allowed_to_edit()) {
  34. header('Location: /index.php');
  35. }
  36. // --------------------------------------------------------------------------------
  37. // - DISPLAY HEADERS AND MESSAGES -
  38. // --------------------------------------------------------------------------------
  39. if (!isset($_GET['exportpdf']) and !isset($_GET['export_certificate'])) {
  40. if (isset ($_GET['studentoverview'])) {
  41. $interbreadcrumb[]= array (
  42. 'url' => 'gradebook.php?selectcat=' . Security::remove_XSS($_GET['selectcat']),
  43. 'name' => get_lang('Gradebook')
  44. );
  45. Display :: display_header(get_lang('FlatView'));
  46. } elseif (isset ($_GET['search'])) {
  47. $interbreadcrumb[]= array (
  48. 'url' => 'gradebook.php?selectcat=' . Security::remove_XSS($_GET['selectcat']),
  49. 'name' => get_lang('Gradebook')
  50. );
  51. Display :: display_header(get_lang('SearchResults'));
  52. } else {
  53. $interbreadcrumb[]= array (
  54. 'url' => 'index.php?',
  55. 'name' => get_lang('Gradebook'));
  56. Display :: display_header('');
  57. //api_get_cidreq()
  58. }
  59. }
  60. $table_link = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
  61. $table_evaluation = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
  62. $table_forum_thread=Database::get_course_table(TABLE_FORUM_THREAD);
  63. /*
  64. if($_SERVER['REQUEST_METHOD']=='POST'):
  65. foreach($_POST['link'] as $key => $value){
  66. api_sql_query('UPDATE '.$table_link.' SET weight = '."'".$value."'".' WHERE id = '.$key);
  67. }
  68. foreach($_POST['evaluation'] as $key => $value){
  69. api_sql_query('UPDATE '.$table_evaluation.' SET weight = '."'".$value."'".' WHERE id = '.$key);
  70. }
  71. Display :: display_normal_message(get_lang('GradebookWeightUpdated')) . '<br /><br />';
  72. endif;*/
  73. /*
  74. define('LINK_EXERCISE',1);
  75. define('LINK_DROPBOX',2);
  76. define('LINK_STUDENTPUBLICATION',3);
  77. define('LINK_LEARNPATH',4);
  78. define('LINK_FORUM_THREAD',5);
  79. */
  80. $table_evaluated[1] = array(TABLE_QUIZ_TEST, 'title', 'id', get_lang('Exercise'));
  81. $table_evaluated[2] = array(TABLE_DROPBOX_FILE, 'name','id', get_lang('Dropbox'));
  82. $table_evaluated[3] = array(TABLE_STUDENT_PUBLICATION, 'url','id', get_lang('Student_publication'));
  83. $table_evaluated[4] = array(TABLE_LP_MAIN, 'name','id', get_lang('Learnpath'));
  84. $table_evaluated[5] = array(TABLE_FORUM_THREAD, 'thread_title_qualify', 'thread_id', get_lang('Forum'));
  85. function get_table_type_course($type,$course) {
  86. global $_configuration;
  87. global $table_evaluated;
  88. return Database::get_course_table($table_evaluated[$type][0],$_configuration['db_prefix'].$course);
  89. }
  90. if($_POST['submitted']==1) {
  91. Display :: display_normal_message(get_lang('GradebookWeightUpdated')) . '<br /><br />';
  92. if (isset($_POST['evaluation'])) {
  93. require_once 'lib/be/evaluation.class.php';
  94. $eval_log = new Evaluation();
  95. }
  96. if(isset($_POST['link'])){
  97. require_once 'lib/be/abstractlink.class.php';
  98. //$eval_link_log = new AbstractLink();
  99. }
  100. }
  101. $category_id = (int)$_GET['selectcat'];
  102. $sql='SELECT * FROM '.$table_link.' WHERE category_id = '.$category_id;
  103. $result = api_sql_query($sql,__FILE__,__LINE__);
  104. while($row = Database ::fetch_array($result)){
  105. //update only if value changed
  106. if(isset($_POST['link'][$row['id']]) && $_POST['link'][$row['id']] != $row['weight']) {
  107. api_sql_query('UPDATE '.$table_link.' SET weight = '."'".trim($_POST['link'][$row['id']])."'".' WHERE id = '.$row['id'],__FILE__,__LINE__);
  108. api_sql_query('UPDATE '.$table_forum_thread.' SET thread_weight='.$_POST['link'][$row['id']].' WHERE thread_id='.$row['ref_id']);
  109. AbstractLink::add_link_log($row['id']);
  110. $row['weight'] = trim($_POST['link'][$row['id']]);
  111. }
  112. $tempsql = api_sql_query('SELECT * FROM '.get_table_type_course($row['type'],$row['course_code']).' WHERE '.$table_evaluated[$row['type']][2].' = '.$row['ref_id']);
  113. $resource_name = Database ::fetch_array($tempsql);
  114. $output.= '<tr><td> [ '.$table_evaluated[$row['type']][3].' ] '.$resource_name[$table_evaluated[$row['type']][1]].'</td><td><input size="10" type="text" name="link['.$row['id'].']" value="'.$row['weight'].'"/></td></tr>';
  115. }
  116. $sql = api_sql_query('SELECT * FROM '.$table_evaluation.' WHERE category_id = '.$category_id,__FILE__,__LINE__);
  117. while($row = Database ::fetch_array($sql)) {
  118. //update only if value changed
  119. if(isset($_POST['evaluation'][$row['id']]) && $_POST['evaluation'][$row['id']] != $row['weight']) {
  120. api_sql_query('UPDATE '.$table_evaluation.' SET weight = '."'".trim($_POST['evaluation'][$row['id']])."'".' WHERE id = '.$row['id'],__FILE__,__LINE__);
  121. AbstractLink::add_link_log($row['id']);
  122. $row['weight'] = trim($_POST['evaluation'][$row['id']]);
  123. }
  124. $output.= '<tr><td> [ '.get_lang('Evaluation').$table_evaluated[$row['type']][3].' ] '.$row['name'].'</td><td><input type="text" size="10" name="evaluation['.$row['id'].']" value="'.$row['weight'].'"/></td></tr>';
  125. }
  126. ?>
  127. <a href="/main/gradebook/index.php?<?php echo api_get_cidreq() ?>&selectcat=<?php echo $category_id ?>"><< <?php echo get_lang('Back') ?>
  128. <!--<a href="/main/gradebook/index.php?<?php echo api_get_cidreq() ?>&selectcat=<?php echo $category_id ?>"><< <?php echo get_lang('Back') ?></a>-->
  129. <form method="post" action="gradebook_edit_all.php?<?php echo api_get_cidreq() ?>&selectcat=<?php echo $category_id?>">
  130. <table class="data_table">
  131. <tr class="row_odd">
  132. <th><?php echo get_lang('Resource'); ?></th>
  133. <th><?php echo get_lang('Weight'); ?></th>
  134. </tr>
  135. <?php echo $output ?>
  136. </table>
  137. <input type="hidden" name="submitted" value="1" />
  138. <input type="submit" name="name" value="<?php echo get_lang('Save') ?>"/>
  139. </form>
  140. <?php
  141. Display :: display_footer();
  142. ?>