[svn r14002] Improved gradebook extension to allow for multi-course evaluations, including learning paths.

skala
Yannick Warnier 17 years ago
parent e70cf5d21b
commit a8961a00a4
  1. 44
      main/gradebook/gradebook.php
  2. 24
      main/gradebook/gradebook_add_link.php
  3. 56
      main/gradebook/gradebook_add_link_select_course.php
  4. 9
      main/gradebook/lib/be/abstractlink.class.php
  5. 39
      main/gradebook/lib/be/category.class.php
  6. 24
      main/gradebook/lib/be/exerciselink.class.php
  7. 32
      main/gradebook/lib/be/learnpathlink.class.php
  8. 2
      main/gradebook/lib/be/linkfactory.class.php
  9. 27
      main/gradebook/lib/fe/catform.class.php
  10. 12
      main/gradebook/lib/fe/displaygradebook.php
  11. 7
      main/gradebook/lib/fe/gradebooktable.class.php
  12. 12
      main/gradebook/lib/fe/linkaddeditform.class.php
  13. 18
      main/gradebook/lib/fe/linkform.class.php

@ -89,12 +89,12 @@ if (isset ($_GET['movecat']))
$cats[0],
'move_cat_form',
null,
api_get_self() . '?movecat=' . $_GET['movecat']
. '&selectcat=' . $_GET['selectcat']);
api_get_self() . '?movecat=' . Security::remove_XSS($_GET['movecat'])
. '&selectcat=' . Security::remove_XSS($_GET['selectcat']));
if ($move_form->validate())
{
header('Location: ' . api_get_self() . '?selectcat=' . $_GET['selectcat']
. '&movecat=' . $_GET['movecat']
header('Location: ' . api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat'])
. '&movecat=' . Security::remove_XSS($_GET['movecat'])
. '&targetcat=' . $move_form->exportValue('move_cat'));
exit;
}
@ -108,7 +108,7 @@ if (isset ($_GET['movecat']))
if (!($course_to_crsind && !isset($_GET['confirm'])))
{
$cats[0]->move_to_cat($targetcat[0]);
header('Location: ' . api_get_self() . '?categorymoved=&selectcat=' . $_GET['selectcat']);
header('Location: ' . api_get_self() . '?categorymoved=&selectcat=' . Security::remove_XSS($_GET['selectcat']));
exit;
}
unset ($targetcat);
@ -129,13 +129,13 @@ if (isset ($_GET['moveeval']))
null,
'move_eval_form',
null,
api_get_self() . '?moveeval=' . $_GET['moveeval']
. '&selectcat=' . $_GET['selectcat']);
api_get_self() . '?moveeval=' . Security::remove_XSS($_GET['moveeval'])
. '&selectcat=' . Security::remove_XSS($_GET['selectcat']));
if ($move_form->validate())
{
header('Location: ' .api_get_self() . '?selectcat=' . $_GET['selectcat']
. '&moveeval=' . $_GET['moveeval']
header('Location: ' .api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat'])
. '&moveeval=' . Security::remove_XSS($_GET['moveeval'])
. '&targetcat=' . $move_form->exportValue('move_cat'));
exit;
}
@ -149,7 +149,7 @@ if (isset ($_GET['moveeval']))
if (!($course_to_crsind && !isset($_GET['confirm'])))
{
$evals[0]->move_to_cat($targetcat[0]);
header('Location: ' . api_get_self() . '?evaluationmoved=&selectcat=' . $_GET['selectcat']);
header('Location: ' . api_get_self() . '?evaluationmoved=&selectcat=' . Security::remove_XSS($_GET['selectcat']));
exit;
}
unset ($targetcat);
@ -162,13 +162,13 @@ if (isset ($_GET['movelink']))
{
block_students();
$link= LinkFactory :: load($_GET['movelink']);
$move_form= new LinkForm(LinkForm :: TYPE_MOVE, null, $link[0], 'move_link_form', null, api_get_self() . '?movelink=' . $_GET['movelink'] . '&selectcat=' . $_GET['selectcat']);
$move_form= new LinkForm(LinkForm :: TYPE_MOVE, null, $link[0], 'move_link_form', null, api_get_self() . '?movelink=' . $_GET['movelink'] . '&selectcat=' . Security::remove_XSS($_GET['selectcat']));
if ($move_form->validate())
{
$targetcat= Category :: load($move_form->exportValue('move_cat'));
$link[0]->move_to_cat($targetcat[0]);
unset ($link);
header('Location: ' . api_get_self(). '?linkmoved=&selectcat=' . $_GET['selectcat']);
header('Location: ' . api_get_self(). '?linkmoved=&selectcat=' . Security::remove_XSS($_GET['selectcat']));
exit;
}
}
@ -265,10 +265,10 @@ if ($course_to_crsind && !isset($_GET['confirm']))
$button = '<form name="confirm"
method="post"
action="'.api_get_self() .'?confirm='
.(isset($_GET['movecat']) ? '&movecat=' . $_GET['movecat']
: '&moveeval=' . $_GET['moveeval'] )
.'&selectcat=' . $_GET['selectcat']
.'&targetcat=' . $_GET['targetcat'].'">
.(isset($_GET['movecat']) ? '&movecat=' . Security::remove_XSS($_GET['movecat'])
: '&moveeval=' . Security::remove_XSS($_GET['moveeval']) )
.'&selectcat=' . Security::remove_XSS($_GET['selectcat'])
.'&targetcat=' . Security::remove_XSS($_GET['targetcat']).'">
<input type="submit" value="'.get_lang('Ok').'">
</form>';
@ -373,8 +373,8 @@ if (isset ($_POST['action']))
if (isset ($_POST['submit']) && isset ($_POST['keyword']))
{
header('Location: ' . api_get_self() . '?selectcat=' . $_GET['selectcat']
. '&search='.$_POST['keyword']);
header('Location: ' . api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat'])
. '&search='.Security::remove_XSS($_POST['keyword']));
exit;
}
@ -388,7 +388,7 @@ if (!isset($_GET['exportpdf']))
if (isset ($_GET['studentoverview']))
{
$interbreadcrumb[]= array (
'url' => 'gradebook.php?selectcat=' . $_GET['selectcat'],
'url' => 'gradebook.php?selectcat=' . Security::remove_XSS($_GET['selectcat']),
'name' => get_lang('Gradebook'
));
Display :: display_header(get_lang('FlatView'));
@ -396,7 +396,7 @@ if (!isset($_GET['exportpdf']))
elseif (isset ($_GET['search']))
{
$interbreadcrumb[]= array (
'url' => 'gradebook.php?selectcat=' . $_GET['selectcat'],
'url' => 'gradebook.php?selectcat=' . Security::remove_XSS($_GET['selectcat']),
'name' => get_lang('Gradebook'
));
Display :: display_header(get_lang('SearchResults'));
@ -454,11 +454,11 @@ else
$category= $_GET['selectcat'];
// search form
$simple_search_form= new UserForm(UserForm :: TYPE_SIMPLE_SEARCH, null, 'simple_search_form', null, api_get_self() . '?selectcat=' . $_GET['selectcat']);
$simple_search_form= new UserForm(UserForm :: TYPE_SIMPLE_SEARCH, null, 'simple_search_form', null, api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat']));
$values= $simple_search_form->exportValues();
$keyword = '';
if (isset($_GET['search']) && !empty($_GET['search']))
$keyword = $_GET['search'];
$keyword = Security::remove_XSS($_GET['search']);
if ($simple_search_form->validate() && (empty($keyword)))
$keyword = $values['keyword'];

@ -39,35 +39,50 @@ $typeform = new LinkForm(LinkForm :: TYPE_CREATE,
'create_link',
null,
api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat'])
. '&newtypeselected=',
isset($_GET['typeselected']) ? Security::remove_XSS($_GET['typeselected']) : null);
. '&newtypeselected=' . (isset($_GET['typeselected']) ? Security::remove_XSS($_GET['typeselected']) : '')
. '&course_code=' . (empty($_GET['course_code'])?'':Security::remove_XSS($_GET['course_code'])))
;
// if user selected a link type
if ($typeform->validate() && isset($_GET['newtypeselected']))
{
// reload page, this time with a parameter indicating the selected type
header('Location: '.api_get_self() . '?selectcat=' . Security::remove_XSS($_GET['selectcat'])
. '&typeselected='.$typeform->exportValue('select_link'));
. '&typeselected='.$typeform->exportValue('select_link')
. '&course_code=' . Security::remove_XSS($_GET['course_code']));
exit;
}
// link type selected, show 2nd form to retrieve the link data
if (isset($_GET['typeselected']) && $_GET['typeselected'] != '0')
{
error_log(__LINE__);
$addform = new LinkAddEditForm(LinkAddEditForm :: TYPE_ADD,
$category[0],
intval($_GET['typeselected']),
null,
'add_link',
api_get_self() . '?selectcat=' . $_GET['selectcat']
. '&typeselected=' . $_GET['typeselected']);
. '&typeselected=' . $_GET['typeselected'] . '&course_code=' . $_GET['course_code']);
error_log(__LINE__);
if ($addform->validate())
{
error_log(__LINE__);
$addvalues = $addform->exportValues();
$link= LinkFactory :: create($_GET['typeselected']);
$link->set_user_id(api_get_user_id());
if($category[0]->get_course_code() == '' && !empty($_GET['course_code']))
{
error_log(__LINE__);
$link->set_course_code(Database::escape_string($_GET['course_code']));
}
else
{
error_log(__LINE__);
$link->set_course_code($category[0]->get_course_code());
}
error_log(__LINE__);
$link->set_category_id($category[0]->get_id());
if ($link->needs_name_and_description())
@ -88,6 +103,7 @@ if (isset($_GET['typeselected']) && $_GET['typeselected'] != '0')
$link->set_visible(empty ($addvalues['visible']) ? 0 : 1);
$link->add();
error_log(__LINE__);
if ($addvalues['addresult'] == 1)

@ -0,0 +1,56 @@
<?php
// $Id: $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2007 Dokeos S.A.
Copyright (c) 2006 Ghent University (UGent)
Copyright (c) various contributors
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
$language_file = 'gradebook';
$cidReset = true;
include_once ('../inc/global.inc.php');
include_once ('lib/be.inc.php');
include_once ('lib/gradebook_functions.inc.php');
include_once ('lib/fe/catform.class.php');
api_block_anonymous_users();
block_students();
$catadd = new Category();
$catadd->set_user_id($_user['user_id']);
$catadd->set_parent_id($_GET['selectcat']);
$catcourse = Category :: load ($_GET['selectcat']);
//$catadd->set_course_code($catcourse[0]->get_course_code());
$form = new CatForm(CatForm :: TYPE_SELECT_COURSE, $catadd, 'add_cat_form', null, api_get_self().'?selectcat=' . $_GET['selectcat']);
if ($form->validate()) {
$values = $form->exportValues();
$cat = new Category();
$cat->set_course_code($values['select_course']);
$cat->set_name($values['name']);
header('location: gradebook_add_link.php?selectcat=' .Security::remove_XSS($_GET['selectcat']).'&course_code='.Security::remove_XSS($values['select_course']));
exit;
}
$interbreadcrumb[] = array (
'url' => 'gradebook.php?selectcat='.$_GET['selectcat'],
'name' => get_lang('Gradebook'
));
Display :: display_header(get_lang('NewCategory'));
$form->display();
Display :: display_footer();
?>

@ -6,7 +6,7 @@
* To implement specific links,
* extend this class and define a type in LinkFactory.
* Use the methods in LinkFactory to create link objects.
* @author Bert Steppé
* @author Bert Stepp<EFBFBD>
* @package dokeos.gradebook
*/
abstract class AbstractLink implements GradebookItem
@ -54,6 +54,7 @@ abstract class AbstractLink implements GradebookItem
public function get_course_code()
{
error_log('Returning course_code = '.$this->course_code);
return $this->course_code;
}
@ -102,6 +103,7 @@ abstract class AbstractLink implements GradebookItem
public function set_course_code ($course_code)
{
$this->course_code = $course_code;
error_log('Link '.$this->get_id().' course code is now = '.$this->course_code);
}
public function set_category_id ($category_id)
@ -395,7 +397,10 @@ abstract class AbstractLink implements GradebookItem
{
return null;
}
public function get_all_links()
{
return null;
}
public function add_linked_data()
{

@ -3,7 +3,7 @@
/**
* Defines a gradebook Category object
* @author Bert Steppé, Stijn Konings
* @author Bert Stepp<EFBFBD>, Stijn Konings
* @package dokeos.gradebook
*/
class Category implements GradebookItem
@ -706,7 +706,7 @@ class Category implements GradebookItem
$tbl_main_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_grade_categories = Database :: get_gradebook_table(TABLE_GRADEBOOK_CATEGORY);
$sql = 'SELECT * FROM '.$tbl_main_courses.' cc, '.$tbl_main_course_user.' cu'
$sql = 'SELECT DISTINCT(code), title FROM '.$tbl_main_courses.' cc, '.$tbl_main_course_user.' cu'
.' WHERE cc.code = cu.course_code'
.' AND cu.status = '.COURSEMANAGER;
if (!api_is_platform_admin())
@ -716,11 +716,11 @@ class Category implements GradebookItem
.' WHERE parent_id = 0'
// .' AND user_id = '.$user_id
.' AND course_code IS NOT null)';
error_log($sql);
$result = api_sql_query($sql, __FILE__, __LINE__);
$cats=array();
while ($data=mysql_fetch_array($result))
while ($data=Database::fetch_array($result))
{
$cats[] = array ($data['code'], $data['title']);
}
@ -728,6 +728,31 @@ class Category implements GradebookItem
}
/**
* Generate an array of all courses that a teacher is admin of.
* @return array 2-dimensional array - every element contains 2 subelements (code, title)
*/
public function get_all_courses ($user_id)
{
$tbl_main_courses = Database :: get_main_table(TABLE_MAIN_COURSE);
$tbl_main_course_user = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
$tbl_grade_categories = Database :: get_gradebook_table(TABLE_GRADEBOOK_CATEGORY);
$sql = 'SELECT DISTINCT(code), title FROM '.$tbl_main_courses.' cc, '.$tbl_main_course_user.' cu'
.' WHERE cc.code = cu.course_code'
.' AND cu.status = '.COURSEMANAGER;
if (!api_is_platform_admin())
$sql .= ' AND cu.user_id = '.$user_id;
$result = api_sql_query($sql, __FILE__, __LINE__);
$cats=array();
while ($data=Database::fetch_array($result))
{
$cats[] = array ($data['code'], $data['title']);
}
return $cats;
}
/**
* Apply the same visibility to every subcategory, evaluation and link
@ -920,17 +945,17 @@ class Category implements GradebookItem
$links = array();
// no links in root or course independent categories
if ($this->id == 0 || !isset($this->course_code) || empty($this->course_code))
if ($this->id == 0)
;
// 1 student
elseif (isset($stud_id))
$links = LinkFactory::load(null,null,null,null,$this->course_code,$this->id,
$links = LinkFactory::load(null,null,null,null,empty($this->course_code)?null:$this->course_code,$this->id,
api_is_allowed_to_create_course() ? null : 1);
// all students -> only for course/platform admin
elseif (api_is_allowed_to_create_course())
$links = LinkFactory::load(null,null,null,null,$this->course_code,$this->id, null);
$links = LinkFactory::load(null,null,null,null,empty($this->course_code)?null:$this->course_code,$this->id, null);
if ($recursive)
{

@ -3,7 +3,7 @@
/**
* Defines a gradebook ExerciseLink object.
* @author Bert Steppé
* @author Bert Stepp<EFBFBD>
* @package dokeos.gradebook
*/
class ExerciseLink extends AbstractLink
@ -54,6 +54,28 @@ class ExerciseLink extends AbstractLink
}
return $cats;
}
/**
* Generate an array of all exercises available.
* @return array 2-dimensional array - every element contains 2 subelements (id, name)
*/
public function get_all_links()
{
if (empty($this->course_code))
die('Error in get_not_created_links() : course code not set');
$course_info = api_get_course_info($this->course_code);
$tbl_grade_links = Database :: get_gradebook_table(TABLE_GRADEBOOK_LINK,$course_info['dbName']);
$sql = 'SELECT id,title from '.$this->get_exercise_table();
$result = api_sql_query($sql, __FILE__, __LINE__);
$cats=array();
while ($data=mysql_fetch_array($result))
{
$cats[] = array ($data['id'], $data['title']);
}
return $cats;
}
/**
* Has anyone done this exercise yet ?

@ -51,13 +51,36 @@ class LearnpathLink extends AbstractLink
}
return $cats;
}
/**
* Generate an array of all learnpaths available.
* @return array 2-dimensional array - every element contains 2 subelements (id, name)
*/
public function get_all_links()
{
if (empty($this->course_code))
die('Error in get_not_created_links() : course code not set');
$course_info = api_get_course_info($this->course_code);
$tbl_grade_links = Database :: get_gradebook_table(TABLE_GRADEBOOK_LINK,$course_info['dbName']);
$sql = 'SELECT id,name from '.$this->get_learnpath_table();
$result = api_sql_query($sql, __FILE__, __LINE__);
$cats=array();
while ($data=Database::fetch_array($result))
{
$cats[] = array ($data['id'], $data['name']);
}
return $cats;
}
/**
* Has anyone used this learnpath yet ?
*/
public function has_results()
{
$course_info = api_get_course_info($this->get_course_code);
$course_info = api_get_course_info($this->get_course_code());
$tbl_stats = Database::get_course_table(TABLE_LP_VIEW,$course_info['dbName']);
$sql = 'SELECT count(id) AS number FROM '.$tbl_stats
." WHERE lp_id = '".$this->get_ref_id()."'";
@ -75,7 +98,7 @@ class LearnpathLink extends AbstractLink
*/
public function calc_score($stud_id = null)
{
$course_info = api_get_course_info($this->get_course_code);
$course_info = api_get_course_info($this->get_course_code());
$tbl_stats = Database::get_course_table(TABLE_LP_VIEW,$course_info['dbName']);
$sql = 'SELECT * FROM '.$tbl_stats
." WHERE lp_id = ".$this->get_ref_id();
@ -85,14 +108,17 @@ class LearnpathLink extends AbstractLink
// order by id, that way the student's first attempt is accessed first
$sql .= ' ORDER BY view_count DESC';
error_log($sql);
$scores = api_sql_query($sql, __FILE__, __LINE__);
// for 1 student
if (isset($stud_id))
{
if ($data=Database::fetch_array($scores))
{
error_log(print_r($data,1));
return array ($data['progress'], 100);
}
else
return null;
}

@ -24,7 +24,7 @@ include_once('learnpathlink.class.php');
/**
* Factory for link objects
* @author Bert Stepp<EFBFBD>
* @author Bert Steppé
* @package dokeos.gradebook
*/
class LinkFactory

@ -15,6 +15,7 @@ class CatForm extends FormValidator {
const TYPE_ADD = 1;
const TYPE_EDIT = 2;
const TYPE_MOVE = 3;
const TYPE_SELECT_COURSE = 4;
private $category_object;
/**
@ -44,6 +45,10 @@ class CatForm extends FormValidator {
{
$this->build_move_form();
}
elseif ($this->form_type == self :: TYPE_SELECT_COURSE)
{
$this->build_select_course_form();
}
$this->setDefaults();
}
@ -142,6 +147,28 @@ class CatForm extends FormValidator {
$this->addRule('weight',get_lang('NoDecimals'),'nopunctuation');
$this->addRule(array ('weight', 'zero'), get_lang('NegativeValue'), 'compare', '>=');
}
/**
* This function builds an 'select course' form in the add category process,
* if parent id is 0, it will only show courses
*/
protected function build_select_course_form()
{
$select = $this->addElement('select','select_course',array(get_lang('PickACourse'),'test'), null);
$coursecat = Category :: get_all_courses(api_get_user_id());
//only return courses that are not yet created by the teacher
foreach($coursecat as $row)
{
$select->addoption($row[1],$row[0]);
}
$this->setDefaults(array(
'hid_user_id' => $this->category_object->get_user_id(),
'hid_parent_id' => $this->category_object->get_parent_id()
));
$this->addElement('hidden','hid_user_id');
$this->addElement('hidden','hid_parent_id');
$this->addElement('submit', null, get_lang('Ok'));
}
function display()
{

@ -138,10 +138,10 @@ class DisplayGradebook
$cattotal = Category :: load(0);
$scoretotal= $cattotal[0]->calc_score(api_get_user_id());
$scoretotal_display = (isset($scoretotal) ? $scoredisplay->display_score($scoretotal,SCORE_PERCENT) : get_lang('NoResultsAvailable'));
$scoreinfo = get_lang('StatsStudent') . ' :<b> '.$user['lastname'].' '.$user['firstname'].'</b><br>';
$scoreinfo = get_lang('StatsStudent') . ' :<b> '.$user['lastname'].' '.$user['firstname'].'</b><br />';
if ((!$catobj->get_id() == '0') && (!isset ($_GET['studentoverview'])) && (!isset ($_GET['search'])))
$scoreinfo.= '<br>'.get_lang('TotalForThisCategory') . ' : <b>' . $scorecourse_display . '</b>';
$scoreinfo.= '<br>'.get_lang('Total') . ' : <b>' . $scoretotal_display . '</b>';
$scoreinfo.= '<br />'.get_lang('TotalForThisCategory') . ' : <b>' . $scorecourse_display . '</b>';
$scoreinfo.= '<br />'.get_lang('Total') . ' : <b>' . $scoretotal_display . '</b>';
Display :: display_normal_message($scoreinfo,false);
}
// show navigation tree and buttons?
@ -206,8 +206,14 @@ class DisplayGradebook
$header .= '<td><a href=gradebook_add_eval.php?selectcat=' . $catobj->get_id() . '><img src=../img/filenew.gif alt=' . get_lang('NewEvaluation') . ' align=absmiddle/> ' . get_lang('NewEvaluation') . '</a>';
$cats= Category :: load($selectcat);
if ($cats[0]->get_course_code() != null)
{
$header .= '<td><a href=gradebook_add_link.php?&selectcat=' . $catobj->get_id() . '><img src=../img/link_blank.gif alt=' . get_lang('MakeLink') . ' align=absmiddle/> ' . get_lang('MakeLink') . '</a>';
}
else
{
$header .= '<td><a href=gradebook_add_link_select_course.php?&selectcat=' . $catobj->get_id() . '><img src=../img/link_blank.gif alt=' . get_lang('MakeLink') . ' align=absmiddle/> ' . get_lang('MakeLink') . '</a>';
}
}
}
elseif (isset ($_GET['search']))
{

@ -6,7 +6,7 @@ include_once ('../be.inc.php');
/**
* Table to display categories, evaluations and links
* @author Stijn Konings
* @author Bert Steppé (refactored, optimised)
* @author Bert Stepp<EFBFBD> (refactored, optimised)
*/
class GradebookTable extends SortableTable
{
@ -201,6 +201,11 @@ class GradebookTable extends SortableTable
else
$text = $item->get_name();
$text .= '&nbsp;[' . $item->get_type_name() . ']';
$cc = $this->currentcat->get_course_code();
if(empty($cc))
{
$text .= '&nbsp;[<a href="'.api_get_path(REL_COURSE_PATH).$item->get_course_code().'/">'.$item->get_course_code().'</a>]';
}
return $text;
}
}

@ -8,7 +8,7 @@ require_once (api_get_path(LIBRARY_PATH) . 'formvalidator/FormValidator.class.ph
/**
* Form used to add or edit links
* @author Stijn Konings
* @author Bert Steppé
* @author Bert Stepp<EFBFBD>
*/
class LinkAddEditForm extends FormValidator
{
@ -31,8 +31,16 @@ class LinkAddEditForm extends FormValidator
elseif (isset ($link_type) && isset ($category_object))
{
$link = LinkFactory :: create ($link_type);
$cc = $category_object->get_course_code();
if(empty($cc) && !empty($_GET['course_code']))
{
$link->set_course_code(Database::escape_string($_GET['course_code']));
}
else
{
$link->set_course_code($category_object->get_course_code());
}
}
else
die ('LinkAddEditForm error: define link_type/category_object or link_object');
@ -55,7 +63,7 @@ class LinkAddEditForm extends FormValidator
$select = $this->addElement('select',
'select_link',
get_lang('ChooseExercise'));
foreach ($link->get_not_created_links() as $newlink)
foreach ($link->get_all_links() as $newlink)
$select->addoption($newlink[1],$newlink[0]);
}
}

@ -8,7 +8,7 @@ require_once (api_get_path(LIBRARY_PATH) . 'formvalidator/FormValidator.class.ph
/**
* Forms related to links
* @author Stijn Konings
* @author Bert Steppé (made more generic)
* @author Bert Stepp<EFBFBD> (made more generic)
* @package dokeos.gradebook
*/
class LinkForm extends FormValidator
@ -80,14 +80,26 @@ class LinkForm extends FormValidator
$select->addoption('['.get_lang('ChooseLink').']', 0);
$cc = $this->category_object->get_course_code();
foreach ($linktypes as $linktype)
{
$link = LinkFactory :: create ($linktype);
$link->set_course_code($this->category_object->get_course_code());
error_log(__FUNCTION__.' '.__LINE__);
if(!empty($cc))
{
error_log(__FUNCTION__.' '.__LINE__);
$link->set_course_code($cc);
}
elseif(!empty($_GET['course_code']))
{
error_log(__FUNCTION__.' '.__LINE__.' '.$_GET['course_code']);
$link->set_course_code(Database::escape_string($_GET['course_code']));
}
error_log(__FUNCTION__.' '.__LINE__);
// disable this element if the link works with a dropdownlist
// and if there are no links left
if (!$link->needs_name_and_description()
&& count($link->get_not_created_links()) == '0')
&& count($link->get_all_links()) == '0')
$select->addoption($link->get_type_name(), $linktype, 'disabled');
else
$select->addoption($link->get_type_name(), $linktype);

Loading…
Cancel
Save