Fixing Grade model creation

skala
Julio Montoya 14 years ago
parent 09b5a6d00f
commit 048af1fdc9
  1. 13
      main/admin/grade_models.php
  2. 3
      main/admin/index.php
  3. 9
      main/gradebook/index.php
  4. 29
      main/inc/lib/grade_model.lib.php

@ -37,9 +37,9 @@ if ($action == 'add') {
$interbreadcrumb[]=array('url' => '#','name' => get_lang('GradeModel'));
}
$htmlHeadXtra[]= '
<script>
function plusItem(item) {
$htmlHeadXtra[]= '<script>
function plusItem(item) {
if (item != 1) {
document.getElementById(item).style.display = "inline";
document.getElementById("plus-"+item).style.display = "none";
@ -50,7 +50,8 @@ $htmlHeadXtra[]= '
//document.getElementById("txta-"+(item-1)).value = "";
}
}
function minItem(item) {
function minItem(item) {
if (item != 1) {
document.getElementById(item).style.display = "none";
//document.getElementById("txta-"+item).value = "";
@ -62,8 +63,8 @@ $htmlHeadXtra[]= '
if (item = 1) {
document.getElementById("min-"+(item)).style.display = "none";
}
}
</script>';
}
</script>';
// The header.
Display::display_header($tool_name);

@ -120,9 +120,8 @@ if (api_is_platform_admin()) {
$items[] = array('url'=>'subscribe_user2course.php', 'label' => get_lang('AddUsersToACourse'));
$items[] = array('url'=>'course_user_import.php', 'label' => get_lang('ImportUsersToACourse'));
$items[] = array('url'=>'grade_models.php', 'label' => get_lang('GradeModel'));
if (isset($extAuthSource) && isset($extAuthSource['ldap']) && count($extAuthSource['ldap']) > 0) {
$items[] = array('url'=>'ldap_import_students.php', 'label' => get_lang('ImportLDAPUsersIntoCourse'));
}

@ -852,7 +852,7 @@ if (isset($first_time) && $first_time==1 && api_is_allowed_to_edit(null,true)) {
$cats = Category :: load(null, null, $course_code, null, null, $session_id, false); //already init
if (!empty($cats)) {
$items = $grading_contents['items'];
//$items = $grading_contents['items'];
$i = 0;
foreach ($cats as $cat) {
@ -872,15 +872,14 @@ if (isset($first_time) && $first_time==1 && api_is_allowed_to_edit(null,true)) {
if (!empty($grading_string)) {
Display::display_normal_message(get_lang('GradeModel').': '.$grading_string);
}
}
}
$obj = new GradeModel();
$grade_models = $obj->get_all();
$options = array(0 => get_lang('none'));
foreach ($grade_models as $item) {
$options[$item['id']] = $item['name'];
}
//$grade_model_id = $cat->get_grade_model_id();
//
//No children
if (empty($allcat)) {
$form = new FormValidator('grade_model_settings');
@ -911,8 +910,6 @@ if (isset($first_time) && $first_time==1 && api_is_allowed_to_edit(null,true)) {
$params['grade_model_id'] = api_get_session_id();
$gradebook->save($params);
}
}
}

@ -70,22 +70,33 @@ class GradeModel extends Model {
$form->addElement('label', get_lang('Components'));
//Get components
$nr_items = 10;
$nr_items = 2;
$max = 10;
// Setting the defaults
$defaults = $this->get($id);
$components = $this->get_components($defaults['grade_model_id']);
if ($action == 'edit') {
if (!empty($components)) {
$nr_items = count($components) -1;
}
}
$renderer = & $form->defaultRenderer();
for ($i = 0; $i <= $nr_items; $i++) {
for ($i = 0; $i <= $max; $i++) {
$counter = $i;
$form->addElement('text', 'components['.$i.'][percentage]', null, array('class' => 'span1'));
$form->addElement('text', 'components['.$i.'][acronym]', null , array('class' => 'span1'));
$form->addElement('text', 'components['.$i.'][title]', null, array('class' => 'span3'));
$form->addElement('hidden', 'components['.$i.'][id]', null , array('class' => 'span3'));
$form->addElement('text', 'components['.$i.'][acronym]', null, array('class' => 'span1'));
$form->addElement('text', 'components['.$i.'][title]', null, array('class' => 'span3'));
$form->addElement('hidden', 'components['.$i.'][id]', null, array('class' => 'span3'));
$template_percentage =
'<div id=' . $i . ' style="display: '.(($i<=$nr_items)?'inline':'none').';" class="control-group">
<p><!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->
<label class="control-label">{label}</label>
<div class="controls"><!-- BEGIN error --><span class="form_error">{error}</span><br /><!-- END error -->{element} % =';
<div class="controls"><!-- BEGIN error --><span class="form_error">{error}</span><br /><!-- END error -->{element} % = ';
$template_acronym = '
<!-- BEGIN required --><span class="form_required">*</span> <!-- END required -->
@ -113,11 +124,7 @@ class GradeModel extends Model {
} else {
$form->addElement('style_submit_button', 'submit', get_lang('Add'), 'class="save"');
}
// Setting the defaults
$defaults = $this->get($id);
$components = $this->get_components($defaults['grade_model_id']);
if (!empty($components)) {
$counter = 0;
foreach ($components as $component) {

Loading…
Cancel
Save