Skip to content

Instantly share code, notes, and snippets.

@AladinDridi
Last active April 7, 2023 20:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AladinDridi/6f41e94c70fabf9e15726634fb9a967b to your computer and use it in GitHub Desktop.
Save AladinDridi/6f41e94c70fabf9e15726634fb9a967b to your computer and use it in GitHub Desktop.
<?php
require_once("wp-load.php");
//or//
$incPath = str_replace(ABSPATH,"",getcwd());
include($incPath.'/wp-load.php');
$uploads_dir = wp_upload_dir();
//||(function_exists('pmpro_hasMembershipLevel'))&&(pmpro_hasMembershipLevel())// maybe i need this
//if(!is_user_logged_in()){
//exit;//
//}//
$user_id = get_current_user_id();
if($_POST){
if (($_POST['remember']=="vrai")&&((trim($_POST['reponse'])=="Tunisie"))){
pmpro_changeMembershipLevel(1, $user_id);
$url= bp_learndash_adminbar_nav_link(bp_learndash_profile_courses_slug());
//$order = wc_get_order(get_last_order());
//$order->update_status( 'completed' );
wp_redirect($url);
}
else if (($_POST['question']=="trop")&&((trim($_POST['reponses'])=="Tunis"))){
pmpro_changeMembershipLevel(2, $user_id);
$url= bp_learndash_adminbar_nav_link(bp_learndash_profile_courses_slug());
wp_redirect($url);
}
else{
echo " vérfiez encore une fois votre réponse";
}
}
?>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script>
window.onload=function(){
document.getElementById('part1').style.display="none";
document.getElementById('part2').style.display="none";
}
function choix1(){
if(document.getElementById('titre1').checked){
document.getElementById('part1').style.display="initial";
document.getElementById('part2').style.display="none";
}
}
function choix2(){
if(document.getElementById('titre2').checked){
document.getElementById('part2').style.display="initial";
document.getElementById('part1').style.display="none";
}
}
var textarray = [
"Question 1",
"Question 2",
"Question 3",
"Question 4" // No comma after last entry
];
function RndText() {
var rannum= Math.floor(Math.random()*textarray.length);
document.getElementById('ShowText').innerHTML=textarray[rannum];
if(textarray[rannum]=="Question 1"){
document.getElementById('txt1').style.display="none";
document.getElementById('txt2').style.display="initial";
} else if(textarray[rannum]=="Question 2"){
document.getElementById('txt2').style.display="none";
document.getElementById('txt1').style.display="initial";
}
}
window.onload = function() { RndText();}
</script>
<style>
#ShowText ,.choixmult{
font-weight: 900;
margin-left: 550px;
}
#part1,#part2{
display: none;
}
form{
margin-right: 25px;
}
@media (max-width: 800px) {
#ShowText,.choixmult{
margin-top: 10px;
margin-left: 20px;
}
}
</style>
</head>
<h2></h2>
<form method="post" class="form-horizontal" >
<div class="col-sm-offset-2 col-sm-10">
<div class="checkbox">
<label>
Le titre de livre
<label>titre1</label> <input type="Radio" onclick="javascript:choix1();" id="titre1" name="titre" value="vrai">
<label>titre2</label><input type="Radio" onclick="javascript:choix2();" id="titre2" name="titre" value="faux">
</label>
</div>
</div>
<div id="part1" class="formrep1">
<div class="form-group">
<p></p>
<label class="control-label col-sm-2" for="reponse">C'est quoi le titre de la page num 30</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="réponse" placeholder="votre réponse" name="reponse">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="choix"></label>
<div class="col-sm-10">
<SELECT class="form-control" name="choix">
<option>7ème</option>
<option>8ème</option>
<option>9ème</option>
</SELECT>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="checkbox">
<label>
Avez-vous un parascolaire ?
<label>oui</label> <input type="Radio" name="remember" value="vrai">
<label>non</label><input type="Radio" name="remember" value="faux">
</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Validez</button>
</div>
</div>
</div>
<div id="part2" class="formrep2">
<div id="ShowText"></div>
<div id="txt1" class="form-group">
<label class="control-label col-sm-2" for="reponses"><div id="ShowText"></div>
</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="rep" placeholder="votre réponse txt1" name="reponses">
</div>
</div>
<div id="txt2" class="form-group">
<label class="control-label col-sm-2" for="reponses"><div id="ShowText"></div>
</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="rep" placeholder="votre réponse txt2" name="reponses">
</div>
</div>
<div class="form-group">
<div class="choixmult">Choix multiple</div>
<label class="control-label col-sm-2" for="choices"></label>
<div id="select2" class="col-sm-10">
<SELECT class="form-control" name="choices">
<option>class1</option>
<option>class2</option>
<option>class3</option>
</SELECT>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<div class="checkbox">
<label for="question">Repondez-vous?</label>
<label>Trop</label> <input type="Radio" name="question" value="trop">
<label>un peu</label><input type="Radio" name="question" value="un peu">
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Validez</button>
</div>
</div>
</div>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment