Multiple hints
This commit is contained in:
parent
22e8937879
commit
25bf34e82c
9 changed files with 217 additions and 35 deletions
|
|
@ -16,12 +16,11 @@ new_exercice() {
|
|||
THEME="$1"
|
||||
TITLE=`echo "$2" | sed 's/"/\\\\"/g'`
|
||||
STATEMENT=`echo "$3" | sed 's/"/\\\\"/g' | sed ':a;N;$!ba;s/\n/<br>/g'`
|
||||
HINT=`echo "$4" | sed 's/"/\\\\"/g' | sed ':a;N;$!ba;s/\n/<br>/g'`
|
||||
DEPEND="$5"
|
||||
GAIN="$6"
|
||||
VIDEO="$7"
|
||||
DEPEND="$4"
|
||||
GAIN="$5"
|
||||
VIDEO="$6"
|
||||
|
||||
curl -f -s -d "{\"title\": \"$TITLE\", \"statement\": \"$STATEMENT\", \"hint\": \"$HINT\", \"depend\": $DEPEND, \"gain\": $GAIN, \"videoURI\": \"$VIDEO\"}" "${BASEURL}/api/themes/$THEME" |
|
||||
curl -f -s -d "{\"title\": \"$TITLE\", \"statement\": \"$STATEMENT\", \"depend\": $DEPEND, \"gain\": $GAIN, \"videoURI\": \"$VIDEO\"}" "${BASEURL}/api/themes/$THEME" |
|
||||
grep -Eo '"id":[0-9]+,' | grep -Eo "[0-9]+"
|
||||
}
|
||||
|
||||
|
|
@ -35,6 +34,17 @@ new_file() {
|
|||
grep -Eo '"id":[0-9]+,' | grep -Eo "[0-9]+"
|
||||
}
|
||||
|
||||
new_hint() {
|
||||
THEME="$1"
|
||||
EXERCICE="$2"
|
||||
TITLE=`echo "$3" | sed 's/"/\\\\"/g'`
|
||||
CONTENT=`echo "$4" | sed 's/"/\\\\"/g' | sed ':a;N;$!ba;s/\n/<br>/g'`
|
||||
COST="$5"
|
||||
|
||||
curl -f -s -d "{\"title\": \"$TITLE\", \"content\": \"$CONTENT\", \"cost\": \"$COST\"}" "${BASEURL}/api/themes/$THEME/$EXERCICE/hints" |
|
||||
grep -Eo '"id":[0-9]+,' | grep -Eo "[0-9]+"
|
||||
}
|
||||
|
||||
new_key() {
|
||||
THEME="$1"
|
||||
EXERCICE="$2"
|
||||
|
|
@ -110,9 +120,8 @@ do
|
|||
echo ">>> Using default gain: ${EXO_GAIN} points"
|
||||
|
||||
EXO_SCENARIO=$(get_file "${THM_BASEURI}${EXO_BASEURI}/scenario.txt")
|
||||
EXO_HINT=$(get_file "${THM_BASEURI}${EXO_BASEURI}/hint.txt")
|
||||
|
||||
EXO_ID=`new_exercice "${THEME_ID}" "${EXO_NAME}" "${EXO_SCENARIO}" "${EXO_HINT}" "${LAST}" "${EXO_GAIN}" "/resolution${THM_BASEURI}${EXO_BASEURI}resolution/${EXO_VIDEO}"`
|
||||
EXO_ID=`new_exercice "${THEME_ID}" "${EXO_NAME}" "${EXO_SCENARIO}" "${LAST}" "${EXO_GAIN}" "/resolution${THM_BASEURI}${EXO_BASEURI}resolution/${EXO_VIDEO}"`
|
||||
if [ -z "$EXO_ID" ]; then
|
||||
echo -e "\e[31;01m!!! An error occured during exercice add.\e[00m"
|
||||
continue
|
||||
|
|
@ -140,6 +149,16 @@ do
|
|||
done
|
||||
|
||||
|
||||
# Hints
|
||||
EXO_HINT=$(get_file "${THM_BASEURI}${EXO_BASEURI}/hint.txt")
|
||||
HINT_ID=`new_hint "${THEME_ID}" "${EXO_ID}" "Astuce #1" "${EXO_HINT}" "1"`
|
||||
if [ -z "$HINT_ID" ]; then
|
||||
echo -e "\e[31;01m!!! An error occured during hint import!\e[00m (title=Astuce #1;content=${EXO_HINT};cost=1)"
|
||||
else
|
||||
echo -e "\e[32m>>> New hint added:\e[00m $HINT_ID - Astuce #1"
|
||||
fi
|
||||
|
||||
|
||||
# Files
|
||||
get_dir "${THM_BASEURI}${EXO_BASEURI}files/" | grep -v DIGESTS.txt | while read f; do basename "$f"; done | while read FILE_URI
|
||||
do
|
||||
|
|
|
|||
Reference in a new issue