if ($id and $item = $DB->get_record('evaluation_item', array('id'=>$id))) { $typ = $item->typ; } else { $item = new stdClass(); $item->id = null; $item->position = -1; if (!$typ) { print_error('typemissing', 'local_evaluations', $editurl->out(false)); } $item->typ = $typ; $item->options = ''; } require_once($CFG->dirroot.'/local/evaluations/item/'.$typ.'/lib.php'); $itemobj = evaluation_get_item_class($typ); $itemobj->build_editform($item, $evaluation, $classid); if ($itemobj->is_cancelled()) { redirect($editurl->out(false)); exit; } if ($test = $itemobj->get_data()) { if ($item = $itemobj->save_item()) { evaluation_move_item($item, $item->position); redirect($editurl->out(false)); } }
/** * this function toggled the item-attribute required (yes/no) * * @global object * @param object $item * @return boolean */ function evaluation_switch_item_required($item) { global $DB, $CFG; $itemobj = evaluation_get_item_class($item->typ); if ($itemobj->can_switch_require()) { $new_require_val = (int) !(bool) $item->required; $params = array('id' => $item->id); $DB->set_field('evaluation_item', 'required', $new_require_val, $params); } return true; }
function evaluation_excelprint_detailed_items(&$worksheet, $xls_formats, $completed, $items, $row_offset) { global $DB, $fstring; if (!$items) { return; } $col_offset = 0; $classid = 0; $evaluation = $DB->get_record('local_evaluation', array('id' => $completed->evaluation)); //get the username //anonymous users are separated automatically because the userid in the completed is "0" if ($user = $DB->get_record('user', array('id' => $completed->userid))) { if ($completed->anonymous_response == EVALUATION_ANONYMOUS_NO) { $worksheet->write_string($row_offset, $col_offset, $user->idnumber, $xls_formats->head2); $col_offset++; $userfullname = fullname($user); $worksheet->write_string($row_offset, $col_offset, $user->username, $xls_formats->head2); $col_offset++; } else { $userfullname = $fstring->anonymous_user; $worksheet->write_string($row_offset, $col_offset, '-', $xls_formats->head2); $col_offset++; $worksheet->write_string($row_offset, $col_offset, '-', $xls_formats->head2); $col_offset++; } } else { $userfullname = $fstring->anonymous_user; $worksheet->write_string($row_offset, $col_offset, '-', $xls_formats->head2); $col_offset++; $worksheet->write_string($row_offset, $col_offset, '-', $xls_formats->head2); $col_offset++; } $worksheet->write_string($row_offset, $col_offset, $userfullname, $xls_formats->head2); $col_offset++; foreach ($items as $item) { $params = array('item' => $item->id, 'completed' => $completed->id); $value = $DB->get_record('evaluation_value', $params); $itemobj = evaluation_get_item_class($item->typ); $printval = $itemobj->get_printval($item, $value); $printval = trim($printval); if (is_numeric($printval)) { $worksheet->write_number($row_offset, $col_offset, $printval, $xls_formats->default); } else if ($printval != '') { $worksheet->write_string($row_offset, $col_offset, $printval, $xls_formats->default); } $printval = ''; $col_offset++; $classid = isset($value->class_id) ? $value->class_id : 0; if ($classid == 0) { $classid = $evaluation->class; } } $worksheet->write_number($row_offset, $col_offset, $classid, $xls_formats->default); $col_offset++; //if (isset($classid) AND $class = $DB->get_record('class', array('id' => $classid))) { // $classcontext = context_class::instance($classid); // $shortname = format_string($class->shortname, true, array('context' => $classcontext)); // $worksheet->write_string($row_offset, $col_offset, $shortname, $xls_formats->default); //} return $row_offset + 1; }