Skip to content

Commit 56de43e

Browse files
working on directly updated challenge points
1 parent b6bb72a commit 56de43e

9 files changed

Lines changed: 22 additions & 25 deletions

File tree

CTFd/plugins/hintpointdelay/__init__.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,12 @@
44
from flask import Blueprint, render_template, request
55

66
from CTFd.cache import clear_standings
7-
from CTFd.constants.languages import SELECT_LANGUAGE_LIST
8-
from CTFd.models import Awards, Challenges, Hints, Unlocks, db, get_class_by_tablename
7+
from CTFd.models import Challenges, Hints, db, get_class_by_tablename
98
from CTFd.plugins.LuaUtils import ConfigPanel, _LuaAsset, run_after_route
109
from CTFd.schemas.awards import AwardSchema
11-
from CTFd.schemas.unlocks import UnlockSchema
1210
from CTFd.utils import get_config
1311
from CTFd.utils.decorators import (
1412
admins_only,
15-
authed_only,
16-
during_ctf_time_only,
17-
require_verified_emails,
1813
)
1914
from CTFd.utils.logging import log
2015
from CTFd.utils.plugins import override_template
@@ -149,7 +144,7 @@ def hintpoint_config():
149144
return render_template("hintconfig.html", configs=configs)
150145

151146
@app.route("/api/hintpoint/challengevalue/<challenge_id>",methods=['GET'])
152-
def getValues(challenge_id):
147+
def get_hint_Values(challenge_id):
153148
try:
154149
challenge = Challenges.query.filter(
155150
Challenges.id == challenge_id
@@ -206,6 +201,7 @@ def modify_award(res):
206201
db.session.commit()
207202
clear_standings()
208203

204+
209205
run_after_route(app,'api.unlocks_unlock_list',modify_award)
210206

211207
def modify_challenge_correct(res):

CTFd/plugins/hintpointdelay/assets/js/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import $ from "jquery";
22
import CTFd from "./index";
33

4-
$(".toggle-button").click(function() {
4+
$(".toggle-button").on('click',function() {
55
function foo (res) {
66
$("#"+res.id).html(res.data)
77
if(res.data === "enabled"){

CTFd/plugins/hintpointdelay/assets/js/hintpoint.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import $ from "jquery";
22

33
window.Alpine.data("Hintpoints",()=>({
44

5-
challengevalue: '---',
5+
idx: 0,
6+
challengevalue: '',
67
async hintpointvalue(id){
78
const url = `/api/hintpoint/challengevalue/${id}`;
8-
const res = await $.get(url)
9-
this.challengevalue = res.data
10-
}
11-
9+
const res = await $.get(url);
10+
this.challengevalue = res.data;
11+
idx = id;
12+
}
1213
}))
1314

1415
window.Alpine.start()

CTFd/plugins/hintpointdelay/staticAssets/assets/js/config-DY9reIum.js renamed to CTFd/plugins/hintpointdelay/staticAssets/assets/js/config-iNCtBTcr.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CTFd/plugins/hintpointdelay/staticAssets/assets/js/hintpoint-Bq66IX_i.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CTFd/plugins/hintpointdelay/staticAssets/assets/js/hintpoint-BqN4BGW8.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

CTFd/plugins/hintpointdelay/staticAssets/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"name": "jquery"
99
},
1010
"assets/js/config.js": {
11-
"file": "assets/js/config-DY9reIum.js",
11+
"file": "assets/js/config-iNCtBTcr.js",
1212
"name": "js/config",
1313
"src": "assets/js/config.js",
1414
"isEntry": true,
@@ -17,7 +17,7 @@
1717
]
1818
},
1919
"assets/js/hintpoint.js": {
20-
"file": "assets/js/hintpoint-BqN4BGW8.js",
20+
"file": "assets/js/hintpoint-Bq66IX_i.js",
2121
"name": "js/hintpoint",
2222
"src": "assets/js/hintpoint.js",
2323
"isEntry": true,

CTFd/plugins/hintpointdelay/templates/hintchallenge.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,17 @@
4747
</div>
4848

4949
<div>
50-
<div class="tab-content">
50+
<div class="tab-content" x-data="Hintpoints" x-init="hintpointvalue(id)">
5151
<div role="tabpanel" class="tab-pane fade show active" id="challenge">
5252
<h2 class="challenge-name text-center pt-3">
5353
{{ challenge.name }}
5454
</h2>
55-
<h3 class="challenge-value text-center">
56-
{{ hintpointvalue(challenge.id,challenge.value) }}
55+
<h3 class="challenge-value text-center" x-text="challengevalue">
5756
</h3>
5857

5958

6059
{% if tags %}
61-
<div class="challenge-tags text-center pt-2 pb-3">
60+
<div class="challenge-tags text-center pts-2 pb-3">
6261
{% block tags %}
6362
{% for tag in tags %}
6463
<span class="challenge-tag badge bg-info">{{ tag }}</span>
@@ -116,7 +115,7 @@ <h3 class="challenge-value text-center">
116115
<div>{{ hint.html | safe }}</div>
117116
</details>
118117
{% else %}
119-
<details @toggle="showHint(event)">
118+
<details @toggle="await showHint(event); hintpointvalue({{challenge.id}});>
120119
{% if hint.title %}
121120
<summary>{{ hint.title }} (Cost: {{ hint.cost }} point{{ hint.cost|pluralize }})</summary>
122121
{% else %}

CTFd/plugins/hintpointdelay/templates/hintchallenges.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ <h3 x-text="category"></h3>
4444
<div class="category-challenges d-flex flex-column">
4545
<div class="challenges-row row">
4646
<template x-for="(c, idx) in getChallenges(category)" :key="c.id">
47-
<div class="col-sm-6 col-md-4 col-lg-3 my-3">
47+
<div class="col-sm-6 col-md-4 col-lg-3 my-3"
48+
x-ref="challenges"
49+
x-data="Hintpoints"
50+
x-init="hintpointvalue(c.id)">
4851
<button
4952
class="challenge-button btn btn-dark w-100 h-100"
5053
:class="[
@@ -55,8 +58,6 @@ <h3 x-text="category"></h3>
5558
>
5659

5760
<div class="challenge-inner my-3"
58-
x-data="Hintpoints"
59-
x-init="hintpointvalue(c.id)"
6061
>
6162
<p x-text="c.name"></p>
6263
<span x-text="challengevalue"></span>

0 commit comments

Comments
 (0)