Conditional logic in a way that does not create a conflict. Jotform - jotform

In Jotform I want to display different thank you message based on the Answers/Options selected.
Example
A > B => Display Oily + Dry
A > C => Display Oily + Wet
B > A => Display Dry + Oily
B > C => Display Dry + Wet
C > A => Display Wet + Oily
C > B => Display Wet + Dry
But in the above condition
For
A > B &
B > A
It displays the same result Oily + Dry
Can this conditions be achieved in a different way

Related

Making a discord bot and the way I'm adding roles is causing crashes

trying to make a level system that adds roles at certain levels but the bot is crashing everytime saying that at msg.member.roles.add() giving me a can't read properties of null (reading roles)
if (Date.now() - userStats.last_message > 60000) {
userStats.xp += between(15, 25);
userStats.last_message = Date.now();
//setup what xp needs for levels and reseting/setting levels and xp and adding roles for
certain levels
const xpToNextLevel = 5 * Math.pow(userStats.level, 2) + 50 * userStats.level + 100;
if (userStats.xp >= xpToNextLevel) {
userStats.level++;
userStats.xp = userStats.xp - xpToNextLevel;
msg.channel.send(msg.author.username + ' has increased their chubee faith level to ' +
userStats.level + ' <a:pepesimp:881812231208181790> \n');
if (userStats.level >= 1 && userStats.reached_level_1 === 0) {
userStats.reached_level_1 = 1;
msg.member.roles.add(chubee_follower);
msg.channel.send(msg.author.username + ' is now a chubee follower. Welcome
<a:chubee_pat:881808870681481216>');
You may need to check if member is defined in the message before trying to give the role. This is because there are some cases (like DMing the bot) where member is not defined in the message.
You can do this by changing
msg.member.roles.add(chubee_follower);
for
if(msg.member) msg.member.roles.add(chubee_follower);

How to Replace all occurrence of a character except last in a string in SSIS?

I have a string number like this:
1.000.000.00
So I have to delete all dots except last one, it will look like this:
1000000.00
Also if there is only one dot it should keep it.
Example:
INPUT | OUTPUT
-----------------------------------
1.00 | 1.00
1.000.00 | 1000.00
What I tried:
I create a derived column with this expression
LEFT([Column],FINDSTRING([Column],".",LEN([Column]) - LEN(REPLACE([Column],".",""))) - 1)
+ SUBSTRING([Column],FINDSTRING([Column],".",LEN([Column]) - LEN(REPLACE([Column],".",""))) + 1,LEN([Column]))
It keep the first dot not the last one.
You can try to use SSIS TOKEN() and TOKENCOUNT() functions.
TOKENCOUNT(column,".") == 4 ? TOKEN(1) + TOKEN(2) + TOKEN(3) + "." + TOKEN(4) :
( TOKENCOUNT(column,".") == 3 ? TOKEN(1) + TOKEN(2) + "." + TOKEN(3) :
( TOKENCOUNT(column,".") == 2 ? column :
( TOKENCOUNT(column,".") == 0 ? column: “" ) ) )

Solving stochastic PDEs in Fipy

I would like to simulate coupled PDEs with a Gaussian white noise field, and was unable to find any examples or documentation that suggests how it should be done. In particular, I am interested in Cahn-Hilliard-like systems with noise:
d/dt(phi) = div(grad(psi)) + div(noise)
psi = f(phi) + div(grad(phi))
Is there a way to implement this in Fipy?
You can add a GaussianNoiseVariable as a source to your equations.
For a non-conserved field, you would do, e.g.,
noise = fp.GaussianNoiseVariable(mesh=..., mean=..., variance=...)
:
:
eq = fp.TransientTerm(...) == fp.DiffusionTerm(...) + ... + noise
for step in steps:
noise.scramble()
:
:
eq.solve(...)
For a conserved field, you would use:
eq = fp.TransientTerm(...) == fp.DiffusionTerm(...) + ... + noise.faceGrad.divergence

How to get Categories, items and subitems in Codeigniter 3 Model?

I have just started building a webapp in Codeigniter and i can't solve a problem with nested queries in my model.
I have three Tables:
Categories, Links and Topics. Every Link and every Topic can have just one Category, whereas every Category can have multiple Links or Topics.
Every Link can have one Topic (or no Topic at all) and every Topic can have one or more Links.
The Table-Structure looks like this (shortened):
Categories:
- ID
- DESCR
Links:
- ID
- DESCR
- ID_CATEGORY
- ID_TOPIC (either an ID from the Topics-Table or NULL)
Topics:
- ID
- DESCR
- ID_CATEGORY
In my View, i want to display them in the following manner:
- Category 1
- Link 1
- Link 2
- Topic 1
- Topiclink 1
- Topiclink 2
- Link 3
- Category 2
- Topic 2
- Topiclink 3
- Topiclink 4
- Topic 3
- Topiclink 5
- Topiclink 6
- Link 4
So there will be 3 nested queries.
My Model looks like this:
public function get_categories(){
//1. Get the categories
$this->db->select("
ec.ID_CATEGORY,
c.DESCR,
c.VISIBLE,
i.KEYVALUE");
$this->db->from("episode_categories ec");
$this->db->join("categories c", "c.ID = ec.ID_CATEGORY");
$this->db->join("ini i", "i.SETTING = c.VISIBLE");
$this->db->where("i.KEYWORD", "CATEGORY_VISIBLE");
$this->db->where("ec.ID_EPISODE", $_SESSION['cur_episode']);
$categories = $this->db->get()->result_array();
//2. Get the Entries (Topics and Links with NULL as TOPIC_ID)
foreach($categories as $key => $value)
{
$sql_links="SELECT
pf_users.USERNAME,
pf_users.NAME_SHOW,
pf_links.ID AS ID,
pf_links.URL AS URL,
pf_links.ID_USER AS ID_USER,
pf_links.ID_EPISODE,
pf_links.ID_CATEGORY,
pf_links.DESCR,
NULL AS IS_TOPIC,
pf_links.REIHENF,
pf_links.DONE,
pf_links.DONE_TS,
pf_links.INFO AS INFO,
pf_episoden.DONE AS EPISODE_DONE
from pf_links
JOIN pf_users on pf_users.ID = pf_links.ID_USER
JOIN pf_episoden on pf_episoden.ID = pf_links.ID_EPISODE
WHERE ID_EPISODE = ".$_SESSION['cur_episode']." AND ID_CATEGORY = ".$value['ID_CATEGORY']." AND ID_TOPIC IS NULL
UNION ALL SELECT pf_users.USERNAME,
pf_users.NAME_SHOW,
pf_topics.ID AS ID,
NULL AS URL,
pf_topics.ID_USER AS ID_USER,
pf_topics.ID_EPISODE,
pf_topics.ID_CATEGORY,
pf_topics.DESCR,
1 AS IS_TOPIC,
pf_topics.REIHENF,
pf_topics.DONE,
pf_topics.DONE_TS,
pf_topics.INFO AS INFO,
pf_episoden.DONE AS EPISODE_DONE
from pf_topics
JOIN pf_users on pf_users.ID = pf_topics.ID_USER
JOIN pf_episoden on pf_episoden.ID = pf_topics.ID_EPISODE
WHERE ID_EPISODE = ".$_SESSION['cur_episode']." AND ID_CATEGORY = ".$value['ID_CATEGORY']." ORDER BY REIHENF,
ID ASC";
$query_links = $this->db->query($sql_links);
$categories[$key]['link_list'] = $query_links->result_array();
//3. Get the Topiclinks (Links with an ID_TOPIC set)
foreach( $categories[$key]['link_list'] as $key2 => $value2)
{
if($value2['IS_TOPIC'] == 1)
{
$sql_topic_links = "SELECT * FROM pf_links WHERE ID_TOPIC = ".$value2['ID'];
$query_topic_links = $this->db->query($sql_topic_links);
$categories[$key2]['topic_links'] = $query_topic_links->result();
}
}
}
return $categories;
}
Everything works fine until the links of the topics (So Step 3 in the Code). The array i get is the same for every topiclink with the last one of the possible ID_TOPIC. So the links within the topics are all the same.
What do i have to change to get just the links for the specific topics in the third step of the function?
Thank you in advance!
I was able to solve the issue:
In Step 3 the following line
$categories[$key2]['topic_links'] = $query_topic_links->result();
must be changed to:
$categories[$key]['link_list'][$key2]['topic_links'] = $query_topic_links->result_array();
So in my view i can iterate trhough the result-sets.

Using 2D Array for Tic Tac Toe in Visual Basic

I have to make a tic tac toe game for my Visual Basic class that uses an array to keep track of the state of the game, but I have no idea how to set up this array. The program is supposed to have 2 views (a GUI which I have already done, and a text view using the console which I have no idea how to do), has two controllers (the user can click the button where they want to play, or they can use the keys 1-9 on the keyboard to choose their position), and is to be played between a human and the computer.
It's not much, but here's what I have so far:
Module Module1
Const intMAX_ROWS As Integer = 2
Const intMAX_COL As Integer = 2
Public gameArray(intMAX_ROWS, intMAX_COL) As String
Button1.Text = gameArray(0,0)
Button2.Text = gameArray(0,1)
Button3.Text = gameArray(0,2)
Button4.Text = gameArray(1,0)
Button5.Text = gameArray(1,1)
Button6.Text = gameArray(1,2)
Button7.Text = gameArray(2,0)
Button8.Text = gameArray(2,1)
Button9.Text = gameArray(2,2)
End Module
I am getting an error on all of the Button.Text lines saying
Declaration expected
Any ideas on how to fix that?
Any help or suggestions would be greatly appreciated.
For the program to compile the statements where you assign values to buttons need to be inside a function:
Sub SetButtons()
Button1.Text = gameArray(0, 0)
Button2.Text = gameArray(0, 1)
Button3.Text = gameArray(0, 2)
Button4.Text = gameArray(1, 0)
Button5.Text = gameArray(1, 1)
Button6.Text = gameArray(1, 2)
Button7.Text = gameArray(2, 0)
Button8.Text = gameArray(2, 1)
Button9.Text = gameArray(2, 2)
End Sub
As you need 2 views, a GUI and a text view, I'd recommend ending up with 3 projects:
a TicTacToe library for the game logic (to be shared)
a WinForms or WPF application for the GUI view (that references the library)
a Console application for the text view (that references the library)
Here's an example of drawing a board in a console application:
Dim board(3, 3) As Char
' Set a O in the middle
board(1, 1) = "O"
' Set an X at the bottom right
board(2, 2) = "X"
' Show board
Console.WriteLine(board(0, 0) + "|" + board(1, 0) + "|" + board(2, 0))
Console.WriteLine("-----")
Console.WriteLine(board(0, 1) + "|" + board(1, 1) + "|" + board(2, 1))
Console.WriteLine("-----")
Console.WriteLine(board(0, 2) + "|" + board(1, 2) + "|" + board(2, 2))
which gives:
| |
-----
|O|
-----
| |X
For a little inspiration on the GUI side, here's a short Silverlight sample (written in F#): Tic-Tac-Toe

Resources