File "ver_curso.php"

Full Path: C:/wamp64/www/Formaciones/Vistas/Evaluaciones/ver_curso.php
File size: 6.42 KB
MIME-type: text/x-php
Charset: utf-8

<?php // Vistas/evaluaciones/ver_curso.php ?>

<style>
.dashboard-container {
  max-width: 1000px;
  margin: 20px auto;
  padding: 15px;
  background: #f8f9fa;
  min-height: auto;
  border-radius: 10px;
  border: 1px solid #000000;
}

.dashboard-header {
  background: white;
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  margin-bottom: 30px;
  text-align: center;
}

.dashboard-header h1 {
  margin: 0;
  color: #2c3e50;
  font-size: 2.5rem;
}

.dashboard-content {
  background: white;
  padding: 30px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.course-materials, .course-quiz {
  margin-bottom: 30px;
}

.material-item {
  background: #f8f9fa;
  padding: 15px;
  margin-bottom: 10px;
  border-radius: 5px;
  border-left: 4px solid #3498db;
}

.alert {
  padding: 15px;
  border-radius: 5px;
  margin-bottom: 15px;
}

.alert.info {
  background: #d1ecf1;
  border-left: 4px solid #17a2b8;
  color: #0c5460;
}

.button {
  display: inline-block;
  padding: 10px 20px;
  background: #3498db;
  color: white;
  text-decoration: none;
  border-radius: 5px;
  transition: background 0.3s;
}

.button:hover {
  background: #2980b9;
}

.button.primary {
  background: #3498db;
}

.button.secondary {
  background: #2ecc71;
}

.button.secondary:hover {
  background: #27ae60;
}
</style>

<div class="dashboard-container">
    <div class="dashboard-header">
        <h1><?= htmlspecialchars($course['title']) ?></h1>
        <p><?= htmlspecialchars($course['description'] ?? '') ?></p>
        
        <?php if (!empty($limite_at_display)): ?>
            <p style="margin-top: 10px; font-weight: bold; color: #e74c3c;">
                📅 Fecha Límite para Evaluación: <?= $limite_at_display ?>
            </p>
        <?php else: ?>
            <p style="margin-top: 10px; color: #2ecc71;">
                ✅ Evaluación sin fecha límite establecida.
            </p>
        <?php endif; ?>
    </div>
    
    <div class="dashboard-content">
        <!-- Sección de Materiales -->
        <div class="course-materials">
            <h2>Materiales del Curso</h2>
            <?php if ($materials && $materials->num_rows > 0): ?>
                <?php while($material = $materials->fetch_assoc()): ?>
                    <div class="material-item">
                        <h3><?= htmlspecialchars($material['title']) ?></h3>
                        <p>
                            <?php if ($material['type'] === 'url'): ?>
                                <a href="<?= htmlspecialchars($material['url'] ?? $material['file_path']) ?>" target="_blank">🔗 Abrir recurso</a>
                            <?php else: ?>
                                <a href="<?= htmlspecialchars($material['file_path']) ?>" target="_blank">📥 Descargar archivo</a>
                            <?php endif; ?>
                        </p>
                        <small style="color: #2c5aa0; font-weight: bold;">Duración del curso: <?= (int)$course['duracion'] ?> horas</small>
                        <br>
                        <small>Subido: <?= htmlspecialchars($material['created_at']) ?></small>
                    </div>
                <?php endwhile; ?>
            <?php else: ?>
                <p>No hay materiales disponibles para este curso.</p>
            <?php endif; ?>
        </div>

        <!-- Sección de Evaluación -->
        <?php if ($quiz): ?>
          <div class="course-quiz">
            <h2>Evaluación: <?= htmlspecialchars($quiz['title']) ?></h2>
            
            <?php 
            $can_take = $attempt_count < 3;
            $already_taken = $attempt_count > 0;
            ?>
            
            <?php if (!$can_take): ?>
              <div class="alert info">
                  <p>✅ Ya has agotado tus 3 intentos para esta evaluación.</p>
                  <p><strong>Mejor puntaje obtenido:</strong> <?= htmlspecialchars($best_score) ?>%</p>
                  <p><strong>Total de intentos utilizados:</strong> <?= $attempt_count ?></p>
              </div>
            <?php else: ?>
              <?php if ($already_taken): ?>
                <div class="alert info">
                    <p>📝 Has completado <?= $attempt_count ?> intento(s) de 3.</p>
                    <p><strong>Último puntaje:</strong> <?= htmlspecialchars($last_score) ?>%</p>
                    <p><strong>Mejor puntaje:</strong> <?= htmlspecialchars($best_score) ?>%</p>
                    <p><strong>Intentos restantes:</strong> <?= 3 - $attempt_count ?></p>
                </div>
              <?php else: ?>
                <div class="alert info">
                    <p>🎯 Tienes 3 intentos para realizar esta evaluación.</p>
                    <p>Se conservará tu mejor puntaje.</p>
                </div>
              <?php endif; ?>
              
              <!-- SIEMPRE mostrar el botón si hay intentos disponibles -->
              <a class="button primary" href="index.php?r=evaluaciones/quiz/take&id=<?= (int)$quiz['id'] ?>">
                  <?php if ($already_taken): ?>
                      Realizar <?= ($attempt_count === 2) ? 'último ' : 'siguiente ' ?>intento (<?= $attempt_count + 1 ?> de 3)
                  <?php else: ?>
                      Presentar evaluación (Primer intento)
                  <?php endif; ?>
              </a>
              
              <?php if ($already_taken): ?>
                <p style="margin-top: 10px; font-size: 0.9rem; color: #666;">
                    💡 Puedes realizar la evaluación nuevamente para mejorar tu puntaje. Se conservará tu mejor resultado.
                </p>
              <?php endif; ?>
            <?php endif; ?>
          </div>
        <?php else: ?>
          <div class="course-quiz">
            <h2>Evaluación</h2>
            <p>No hay evaluación disponible para este curso en este momento.</p>
          </div>
        <?php endif; ?>

        <!-- Botón para ver evaluaciones realizadas -->
        <?php if ($attempt_count > 0): ?>
        <div style="margin-top: 20px; padding-top: 20px; border-top: 1px solid #eee;">
            <a class="button secondary" href="index.php?r=evaluaciones/ver-evaluaciones&course_id=<?= (int)$course['id'] ?>">
                📊 Ver mis evaluaciones realizadas
            </a>
        </div>
        <?php endif; ?>
    </div>
</div>