Store exercice title XML in DB
This commit is contained in:
parent
3f773dffb0
commit
b81af5aa90
10 changed files with 69 additions and 55 deletions
|
|
@ -26,6 +26,7 @@ try
|
|||
if (!empty($_POST))
|
||||
{
|
||||
$exercice->points = intval($_POST["points"]);
|
||||
$exercice->title = $_POST["title"];
|
||||
$exercice->statement = $_POST["desc"];
|
||||
$exercice->require = $_POST["require"];
|
||||
$exercice->level = intval($_POST["level"]);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ class Exercice
|
|||
var $require;
|
||||
var $level;
|
||||
var $points;
|
||||
var $title;
|
||||
var $statement;
|
||||
var $files = array();
|
||||
var $keys = array();
|
||||
|
|
@ -24,7 +25,7 @@ class Exercice
|
|||
|
||||
$db->escape($id);
|
||||
$res = $db->unique_query("SELECT `id`, `id_theme`, `require`, `level`,
|
||||
`points`, `statement`
|
||||
`points`, `title`, `statement`
|
||||
FROM exercices WHERE id = '$id'");
|
||||
|
||||
if (!empty($res))
|
||||
|
|
@ -64,6 +65,7 @@ class Exercice
|
|||
$this->require = $res['require'];
|
||||
$this->level = $res['level'];
|
||||
$this->points = $res['points'];
|
||||
$this->title = $res['title'];
|
||||
$this->statement = $res['statement'];
|
||||
|
||||
$this->set_number();
|
||||
|
|
@ -86,6 +88,7 @@ class Exercice
|
|||
$tmp->require = $array["require"];
|
||||
$tmp->level = $array["level"];
|
||||
$tmp->points = $array["points"];
|
||||
$tmp->title = $array["title"];
|
||||
$tmp->statement = $array["statement"];
|
||||
$tmp->files = $array["files"];
|
||||
$tmp->keys = $array["keys"];
|
||||
|
|
@ -98,9 +101,12 @@ class Exercice
|
|||
return $this->id;
|
||||
}
|
||||
|
||||
function get_name()
|
||||
function get_title($menu=false)
|
||||
{
|
||||
return "Exercice ".$this->number;
|
||||
if ($menu || empty($this->title))
|
||||
return "Exercice ".$this->number;
|
||||
else
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
function get_statement()
|
||||
|
|
@ -108,8 +114,7 @@ class Exercice
|
|||
return $this->statement;
|
||||
}
|
||||
|
||||
// retourne le nombre d'equipes qui ont résolues l'exercice
|
||||
// trié par date
|
||||
// retourne les équipes qui ont résolues l'exercice triées par date
|
||||
function get_solved()
|
||||
{
|
||||
$id = $this->id;
|
||||
|
|
@ -209,6 +214,7 @@ class Exercice
|
|||
$require = $this->require;
|
||||
$level = intval($this->level);
|
||||
$points = intval($this->points);
|
||||
$title = $this->title;
|
||||
$statement = $this->statement;
|
||||
$files = $this->files;
|
||||
$keys = $this->keys;
|
||||
|
|
@ -217,17 +223,18 @@ class Exercice
|
|||
$db->escape($id);
|
||||
$db->escape($theme);
|
||||
$db->escape($require);
|
||||
$db->escape($title);
|
||||
$db->escape($statement);
|
||||
|
||||
if ($create)
|
||||
{
|
||||
$db->query("INSERT INTO exercices
|
||||
VALUES ('".$id."', '".$theme."', '".$require."', '".$level."', '".$points."','".$statement."');");
|
||||
VALUES ('".$id."', '".$theme."', '".$require."', '".$level."', '".$points."','".$title."','".$statement."');");
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->query("UPDATE exercices
|
||||
SET `id_theme` = '".$theme."', `require` = '".$require."', `level` = '".$level."', `points` = '".$points."', `statement` = '".$statement."'
|
||||
SET `id_theme` = '".$theme."', `require` = '".$require."', `level` = '".$level."', `points` = '".$points."', `title` = '".$title."', `statement` = '".$statement."'
|
||||
WHERE id = '$id'");
|
||||
|
||||
$aff = $db->affected();
|
||||
|
|
|
|||
|
|
@ -3,6 +3,10 @@
|
|||
{if isset($ex)}
|
||||
<h2>{$theme->name} <small>{$ex->id}</small></h2>
|
||||
<form role="form" method="post" action="/{$SALT_ADMIN}/ex/{$theme->id}-{$theme->name}/{$ex->id}">
|
||||
<div class="form-group">
|
||||
<label for="title">Titre</label>
|
||||
<input type="text" class="form-control" value="{$ex->title|escape}" name="title" id="title">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="desc">Description</label>
|
||||
<textarea class="form-control" name="desc" id="desc">{$ex->statement|escape}</textarea>
|
||||
|
|
@ -85,7 +89,7 @@
|
|||
<p>
|
||||
<ul>
|
||||
{foreach from=$theme->get_exercices_ordered() item=ex}
|
||||
<li><a href="/{$SALT_ADMIN}/ex/{$theme->id}-{$theme->name}/{$ex->id}">{$ex->get_name()}</a></li>
|
||||
<li><a href="/{$SALT_ADMIN}/ex/{$theme->id}-{$theme->name}/{$ex->id}">{$ex->get_title()}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</p>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
{if $theme->get_exercices_ordered()}
|
||||
{foreach from=$theme->get_exercices_ordered() item=e}
|
||||
<exercice id="{$e->id}" level="{$e->level}"{if $e->require} depends="{$e->require}"{/if}>
|
||||
<title>{$e->get_name()}</title>
|
||||
<title>{$e->get_title()}</title>
|
||||
<points>{$e->points}</points>
|
||||
<statement>{$e->statement}</statement>
|
||||
{if $e->keys}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
{link href_prefix="/{$SALT_ADMIN}/" href="ex/{$t->get_id()}-{$t->get_name()}" class="dropdown-toggle" data-toggle="dropdown" label="{$t->get_name()} <b class=\"caret\"></b>"}
|
||||
<ul class="dropdown-menu">
|
||||
{foreach from=$t->get_exercices_ordered() item=e}
|
||||
<li>{link href_prefix="/{$SALT_ADMIN}/" href="ex/{$t->get_id()}-{$t->get_name()}/{$e->get_id()}" label="{$e->get_name()}"}</li>
|
||||
<li>{link href_prefix="/{$SALT_ADMIN}/" href="ex/{$t->get_id()}-{$t->get_name()}/{$e->get_id()}" label="{$e->get_title(true)}"}</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</li>
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
<td><a href="/{$SALT_ADMIN}/ex/{$t->id}-{$t->name}">{$t->name}</a></td>
|
||||
<td><ul>
|
||||
{foreach from=$t->get_exercices_ordered() item=e}
|
||||
<li><a href="/{$SALT_ADMIN}/ex/{$t->id}-{$t->name}/{$e->id}">{$e->get_name()}</a></li>
|
||||
<li><a href="/{$SALT_ADMIN}/ex/{$t->id}-{$t->name}/{$e->id}">{$e->get_title()}</a></li>
|
||||
{/foreach}
|
||||
</ul></td>
|
||||
<td>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
{block name=exercices}
|
||||
<div class="panel panel-info">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">Exercice {$cur_exercice->number} <small>{$solved} équipe{if $solved > 1}s ont{else} a{/if} résolu cet exercice</small></h3>
|
||||
<h3 class="panel-title">{$cur_exercice->get_title()} <small>{$solved} équipe{if $solved > 1}s ont{else} a{/if} résolu cet exercice</small></h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<ul>
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@
|
|||
<p>
|
||||
{foreach from=$cur_theme->get_exercices_ordered() item=exercice}
|
||||
{if $exercice->has_solved($my_team)}
|
||||
{link class="btn btn-success" role="button" href_prefix="/{$SALT_USER}/{$my_team->get_id()}/" href="{$cur_theme->get_id()}-{$cur_theme->get_name_url()}/{$exercice->get_id()}/" label="{$exercice->get_name()}"}
|
||||
{link class="btn btn-success" role="button" href_prefix="/{$SALT_USER}/{$my_team->get_id()}/" href="{$cur_theme->get_id()}-{$cur_theme->get_name_url()}/{$exercice->get_id()}/" label="{$exercice->get_title(true)}"}
|
||||
{elseif $exercice->is_unlocked($my_team)}
|
||||
{link class="btn btn-primary" role="button" href_prefix="/{$SALT_USER}/{$my_team->get_id()}/" href="{$cur_theme->get_id()}-{$cur_theme->get_name_url()}/{$exercice->get_id()}/" label="{$exercice->get_name()}"}
|
||||
{link class="btn btn-primary" role="button" href_prefix="/{$SALT_USER}/{$my_team->get_id()}/" href="{$cur_theme->get_id()}-{$cur_theme->get_name_url()}/{$exercice->get_id()}/" label="{$exercice->get_title(true)}"}
|
||||
{else}
|
||||
<a class="btn btn-danger" disabled="disabled">{$exercice->get_name()}</a>
|
||||
<a class="btn btn-danger" disabled="disabled">{$exercice->get_title(true)}</a>
|
||||
{/if}
|
||||
{/foreach}
|
||||
</p>
|
||||
|
|
|
|||
Reference in a new issue