-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_crits.php
80 lines (66 loc) · 2.51 KB
/
edit_crits.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<div class="row">
<div class="span 6">
<h2>Criteria for <?php echo $row->name; ?></h2>
</div>
<div class="button-right">
<form action="edit_crits2.php?courseId=<?php echo $courseId; ?>" method="POST">
<input type="hidden" name="id" value="<?php echo $row->id; ?>"/>
<input type="hidden" name="name" value="<?php echo $row->name; ?>"/>
<button class="btn btn-info" type="submit" name="editUnit" value="Edit unit criteria"/>
<i class="icon-edit icon-white"></i> Edit unit criteria</button>
</form>
</div>
</div>
<?php
// get all the criteria
$query = "SELECT {$CFG->prefix}unit_tracker_units_criteria.id, name, unitid, description, markid, {$CFG->prefix}unit_tracker_marks_criteria.id as markid2, type
FROM {$CFG->prefix}unit_tracker_units_criteria
JOIN {$CFG->prefix}unit_tracker_marks_criteria ON {$CFG->prefix}unit_tracker_units_criteria.markid={$CFG->prefix}unit_tracker_marks_criteria.id
WHERE unitid='" . $row->id . "'";
$crits = $DB->get_records_sql($query);
if (empty($crits)) {
echo '<h3>There are no criteria set yet for this course</h3>';
} else {
?>
<table class="table">
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th>Marking</th>
</tr>
</thead>
<tbody>
<?php
foreach ($crits as $crit) {
?>
<tr>
<td><input type="text" name="criteriaName" value="<?php echo $crit->name; ?>"/></td>
<td><textarea name="criteriaDescription"><?php echo $crit->description; ?></textarea></td>
<td>
<?php
// echo ' markid ' . $row['markid'];
// $queryMark = "SELECT id, type FROM unit_tracker_marks_criteria";
$resultMark = $DB->get_records('unit_tracker_marks_criteria');
echo '<select name="marking"/>';
foreach ($resultMark as $rowMark) {
if ($rowMark->id == $crit->markid) {
$selected = 'selected="selected" ';
} else {
$selected = ' ';
}
echo '<option ' . $selected . 'value="' . $rowMark->id . '" >' . $rowMark->type . '</option>';
}
echo '</select>';
?>
</td>
</tr>
<?php
}
?>
</tbody>
</table>
<?php
}
?>
</div>