Select Git revision
RangeInput.php
Forked from
Stud.IP / Stud.IP
Source project has a limited visibility.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
Exercise.php 21.09 KiB
<?php
/*
* Exercise.php - base class for all exercise types
* Copyright (c) 2003-2005 Erik Schmitt, Philipp Hügelmeyer
* Copyright (c) 2005-2006 Christa Deiwiks
* Copyright (c) 2006-2009 Elmar Ludwig, Martin Schröder
*
* 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.
*/
abstract class Exercise extends SimpleORMap
{
public $task = [];
private static $exercise_types = [];
/**
* Configure the database mapping.
*/
protected static function configure($config = [])
{
$config['db_table'] = 'vips_exercise';
$config['serialized_fields']['options'] = 'JSONArrayObject';
$config['has_and_belongs_to_many']['tests'] = [
'class_name' => 'VipsTest',
'thru_table' => 'vips_exercise_ref',
'thru_key' => 'exercise_id',
'thru_assoc_key' => 'test_id'
];
$config['has_and_belongs_to_many']['files'] = [
'class_name' => 'VipsFile',
'thru_table' => 'vips_file_ref',
'thru_key' => 'object_id',
'thru_assoc_key' => 'file_id',
'order_by' => "AND type = 'exercise' ORDER BY name"
];
$config['has_many']['exercise_refs'] = [
'class_name' => 'VipsExerciseRef',
'assoc_foreign_key' => 'exercise_id',
'on_delete' => 'delete'
];
$config['has_many']['file_refs'] = [
'class_name' => 'VipsFileRef',
'assoc_foreign_key' => 'object_id',
'on_delete' => 'delete',
'order_by' => "AND type = 'exercise'"
];
$config['has_many']['solutions'] = [
'class_name' => 'VipsSolution',
'assoc_foreign_key' => 'exercise_id',
'on_delete' => 'delete'
];
$config['has_many']['old_solutions'] = [
'class_name' => 'VipsSolutionArchive',
'assoc_foreign_key' => 'exercise_id',
'on_delete' => 'delete'
];
$config['belongs_to']['user'] = [
'class_name' => 'User',
'foreign_key' => 'user_id'
];
parent::configure($config);